Codeforces Round #501 (Div. 3) E2 - Stars Drawing (Hard Edition)(差分)

桌面云架构讲解(VDI、IDV、VOI/TCI、RDS) 什么是云桌面桌面云是虚拟化技术成熟后发展起来的一种应用,桌面云通常也称为云桌面、VDI等桌面云中的云一般指的是企业的数据中心,通过在数据中心的服务器上安装若干个虚拟机,这个虚拟机就是桌面;但是终端无法直接连接到这个虚拟机(云桌面),因此就需要通过技术将就虚拟机变为桌面云发放出来;发放出来之后只需要瘦客户端(PC、手机、瘦客户机等)连接到数据中心的云桌面服务器平台,最终就可以连接到桌面来进行使用云桌面的优势终端与数据信息分离,数据在后台集中处理和存储 ,数据实现统一管理。 阅读详情

题目

n*m(n,m<=1e3)的矩阵,由*和.组成

从中挑出不超过n*m个star(star被定义为全为*的十字架,上下左右伸出的部分需要等长)

*可以被多个star公用,

如果所有*都能被star覆盖,输出挑选方案

否则输出-1

思路来源

涛神

题解

先预处理左条、右条、上条、下条的最大长度,分四个方向dp

这里记录的是不包括中心点的长度,所以需要相邻两个都为*

十字架半径,显然为四者取最小

 

代码1:自己瞎搞的,覆盖的时候,up down left right记录上次覆盖到哪里了,避免重复覆盖

这样分四个方向覆盖就好了,最多遍历8次全图,复杂度O(n*m),注意dp增序降序

 

代码2:涛神讲的,差分,记rr为半径,考虑[i-rr,i+rr][j-rr,j+rr]的区域

就等价成分别在横条和竖条上区间+1,维护差分数组,端点+1-1,

check时分别对横条和竖条求前缀和,判断是否存在行列都等于0的*,这样的*是没被覆盖的

心得

差分常常和线段有关,如区间染色、区间加等

还是要多多练习,培养思维

代码1

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const int N=1e3+5;
int n,m,cnt;
int r[4][N][N],R[N][N];
int up[N],down[N],LEFT[N],RIGHT[N];
char s[N][N];
bool ok[N][N],vis[N][N],flag;//2 star 1 * 0 .
struct node
{
	int x,y,r;
}e[N*N];
int RR(int a,int b,int c,int d)
{
	return min(min(a,b),min(c,d));
}
int main() 
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
	scanf("%s",s[i]+1);
	for(int i=1;i<=n;++i)
	for(int j=1;j<=m;++j)
	{
		if(s[i][j]!='*')continue;
		if(s[i][j-1]=='*')r[0][i][j]=r[0][i][j-1]+1;//左
	}
	for(int i=1;i<=n;++i)
	for(int j=m;j>=1;--j)
	{
		if(s[i][j]!='*')continue;
		if(s[i][j+1]=='*')r[1][i][j]=r[1][i][j+1]+1;//右
	}
	for(int j=1;j<=m;++j)
	for(int i=1;i<=n;++i)
	{
		if(s[i][j]!='*')continue;
		if(s[i-1][j]=='*')r[2][i][j]=r[2][i-1][j]+1;//上 
	}
	for(int j=1;j<=m;++j)
	for(int i=n;i>=1;--i)
	{
		if(s[i][j]!='*')continue;
		if(s[i+1][j]=='*')r[3][i][j]=r[3][i+1][j]+1;//下 
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=m;++j)
		{
			int rr=RR(r[0][i][j],r[1][i][j],r[2][i][j],r[3][i][j]);
			if(rr==0)continue;
			e[++cnt]=node{i,j,rr};	
			ok[i][j]=1;
			R[i][j]=rr;
		}
	}
	memset(LEFT,0x3f,sizeof LEFT);
	for(int i=1;i<=n;++i)
	{
		for(int j=m;j>=1;--j)
		{
			if(!ok[i][j])continue;
			vis[i][j]=1;
			LEFT[i]=min(LEFT[i],j);
			for(int y=LEFT[i]-1;y>=j-R[i][j];y--)
			vis[i][y]=1;
			LEFT[i]=min(LEFT[i],j-R[i][j]);
		}
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=m;++j)
		{
			if(!ok[i][j])continue;
			vis[i][j]=1;
			RIGHT[i]=max(RIGHT[i],j);
			for(int y=RIGHT[i]+1;y<=j+R[i][j];y++)
			vis[i][y]=1;
			RIGHT[i]=max(RIGHT[i],j+R[i][j]);
		}
	}
	memset(up,0x3f,sizeof up);
	for(int j=1;j<=m;++j)
	{
		for(int i=n;i>=1;--i)
		{
			if(!ok[i][j])continue;
			vis[i][j]=1;
			up[j]=min(up[j],i);
			for(int x=up[j]-1;x>=i-R[i][j];x--)
			vis[x][j]=1;
			up[j]=min(up[j],i-R[i][j]);
		}
	}
	for(int j=1;j<=m;++j)
	{
		for(int i=1;i<=n;++i)
		{
			if(!ok[i][j])continue;
			vis[i][j]=1;
			down[j]=max(down[j],i);
			for(int x=down[j]+1;x<=i+R[i][j];x++)
			vis[x][j]=1;
			down[j]=max(down[j],i+R[i][j]);
		}
	}
	for(int i=1;i<=n&&!flag;++i)
	{
		for(int j=1;j<=m&&!flag;++j)
		{
			if(s[i][j]!='*')continue;
			if(!vis[i][j])
			{
				//printf("(%d,%d)",i,j);
				flag=1;
			}
		}
	}
	if(flag)puts("-1");
	else
	{
		printf("%d\n",cnt);
		for(int i=1;i<=cnt;++i)
		printf("%d %d %d\n",e[i].x,e[i].y,e[i].r);
	}
	return 0;
} 

代码2

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const int N=1e3+5;
int n,m,cnt;
int r[4][N][N];
int row[N][N],col[N][N];
char s[N][N];
bool ok;
struct node
{
	int x,y,r;
}e[N*N];
int RR(int a,int b,int c,int d)
{
	return min(min(a,b),min(c,d));
}
int main() 
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
	scanf("%s",s[i]+1);
	for(int i=1;i<=n;++i)
	for(int j=1;j<=m;++j)
	{
		if(s[i][j]!='*')continue;
		if(s[i][j-1]=='*')r[0][i][j]=r[0][i][j-1]+1;//左
	}
	for(int i=1;i<=n;++i)
	for(int j=m;j>=1;--j)
	{
		if(s[i][j]!='*')continue;
		if(s[i][j+1]=='*')r[1][i][j]=r[1][i][j+1]+1;//右
	}
	for(int j=1;j<=m;++j)
	for(int i=1;i<=n;++i)
	{
		if(s[i][j]!='*')continue;
		if(s[i-1][j]=='*')r[2][i][j]=r[2][i-1][j]+1;//上 
	}
	for(int j=1;j<=m;++j)
	for(int i=n;i>=1;--i)
	{
		if(s[i][j]!='*')continue;
		if(s[i+1][j]=='*')r[3][i][j]=r[3][i+1][j]+1;//下 
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=m;++j)
		{
			int rr=RR(r[0][i][j],r[1][i][j],r[2][i][j],r[3][i][j]);
			if(rr==0)continue;
			e[++cnt]=node{i,j,rr};	
			row[i][j-rr]++;row[i][j+rr+1]--;//差分 []区间染色 
			col[i-rr][j]++;col[i+rr+1][j]--;
		}
	}
	for(int i=1;i<=n&&!ok;++i)
	{
		for(int j=1;j<=m&&!ok;++j)
		{
			row[i][j]+=row[i][j-1];
			col[i][j]+=col[i-1][j];
			//printf("(%d,%d)  ",row[i][j],col[i][j]);
			if(s[i][j]!='*')continue;
			if(row[i][j]<=0&&col[i][j]<=0)ok=1;
		}
		//puts(""); 
	}
	if(ok)puts("-1");
	else
	{
		printf("%d\n",cnt);
		for(int i=1;i<=cnt;++i)
		printf("%d %d %d\n",e[i].x,e[i].y,e[i].r); 
	}
	return 0;
}

 

产品包装质检实战:基于YOLOv5的智能包装合格检测系统全流程指南 摘要: 针对产品包装质检效率低、漏检率高的问题,本文提出基于YOLOv5的智能检测系统。系统通过采集包装缺陷数据(破损、缺标、封装不良等),利用YOLOv5实现多类别缺陷识别(准确率≥95%),并开发Flask Web界面实现检测可视化与报告生成。实验表明,该系统在30帧/秒的产线速度下可稳定运行,显著提升质检效率。项目涵盖数据标注、模型训练、系统开发全流程,具有工业落地价值,适用于智能制造场景的自动化质检需求。(149字) 阅读详情

相关推荐

Landsat9 地表温度反演方法

landsat9地表温度反演及缺失值处理方法

xiangliu12345的博客 3926

Coderforces 1015 E2 - Stars Drawing (Hard Edition)(dp,前缀和,差分数组)

题目 题意:用任意大于1长度的十字去覆盖图形 输出一种解 瞄到了下面的dp标签 所以一下就想到了上下左右都做一下前缀和就好 然而把每个十字都找出来之后怎么办呢 想了半天 然后去看英文题解还没看懂 然后搜中文题解才发现原来还有差分数组这种东西。。。 确实不难 然而这都没想到 而且还wa了无数次 还写了1h15min... sigh.... #include &lt;bits/stdc...

博客 235

zedboard(5)spi轮询和中断

一个SPI可以有几个从设备 在程序中使用 s32 XSpiPs_SetSlaveSelect(XSpiPs *InstancePtr, u8 SlaveSel) 选择。其实就是吧对应设备的ss拉低。 备注:只选一个ss,可以不用指定。(感觉,还没测试) 这是xspips.c中定义的函数,发送和接收有 XSpiPs_Transfer 和 XSpiPs_PolledTransfer 两个函数,分别采用中断和轮询模式。    一、轮询模式 米联客参考代码,SpiPs_Init中部分和官方例程流程一样,Spi

Kiss丶小坏 5898

Codeforces Round #501 (Div. 3) E2. Stars Drawing (Hard Edition)

题目链接 A star is a figure of the following type: an asterisk character '*' in the center of the figure and four rays (to the left, right, top, bottom) of the same positive length. The size of a star is...

FFOYeah的博客 616

直流电动机的建模仿真(1)他励,串励和并励电动机建模仿真

本文根据不同励磁方式的直流电动机的接线原理图,建立了相应的数学模型,然后根据与数学模型对应的等效电路以及模拟机械运动方程的等效电路,用Matlab/simulink中的SpecializedPower system库中的电路元件,建立了他励,并励和串励直流电动机的全等效电路仿真模型,经过与Matlab自带的直流电动机仿真模型比较以及仿真实例验证,所建立的仿真模型时完全正确的。

weixin_45670943的博客 7530

Docker:快速部署 Temporal 工作流引擎的技术指南

Temporal是一个开源的分布式工作流引擎,适用于复杂业务流程(如订单处理、支付流程等),提供状态持久化、自动重试、多语言SDK支持等特性。部署简单,支持Docker Compose,包含核心服务、Web UI及数据库。以TypeScript为例,开发者可快速编写工作流(如订单处理)和Worker,通过CLI或SDK启动和管理。Temporal简化了分布式系统的可靠性设计,适合电商、自动化任务等场景。

木头 651

Codeforces Round #501 (Div. 3)E2. Stars Drawing (Hard Edition)

题意: 给出一个n*m的图,四方向的最大长度相同为一个星星,问能否找到不大于n*m颗星星,使得图中的所有都被星星覆盖。 思路: 首先o(n^2)算出所有*能扩展的最大规格,4个方向dp求最小值 然后o(n^2) 用差分前缀和的方法进行填充 值得一提的是,这题的标程tle了,因为使用的cin/cout输入输出 #include &lt;bits/stdc++.h&gt; #define ...

蒟蒻 lxw的博客 242

【Bug已解决】Codex Desktop 更新后无法启动/闪退解决方案

方案适用场景推荐指数清理本地缓存重启最常见、最应优先尝试的方案⭐⭐⭐⭐⭐完全卸载重装缓存清理无效时的进阶方案⭐⭐⭐⭐详细日志定位崩溃环节需要精确诊断问题原因⭐⭐⭐⭐锁定旧稳定版本确认是特定版本缺陷时的过渡方案⭐⭐⭐反馈官方支持团队自助方式无效时的最终途径⭐⭐⭐⭐Codex Desktop 更新后无法启动/闪退的本质通常是新版本程序在启动时读取到了旧版本遗留的、格式不兼容的本地缓存或配置数据,导致启动流程中途崩溃。

一键难忘的博客 6303

Codeforces Round #501 (Div. 3) E2 - Stars Drawing (Hard Edition)(dp,前缀和,覆盖)

        题目链接:http://codeforces.com/contest/1015/problem/E2                题目大意,给你一个n×m大小的字符矩阵,仅由‘.’和‘*’组成,提问这个图可否划分为一些由‘*’组成的十字形状,这些十字之间可以有重叠,如果可以完全覆盖输出每个十字中心坐标与边长度,不可以输出-1。                         ...

u013573243的博客 527

手把手教你学Simulink——基于Simulink的输入输出线性化精确转矩控制

由于IOFL控制律中实时引入了当前状态的反馈(id​,iq​,ωe​),电感的变化被非线性项自动补偿,转矩仅出现微小幅度的波动(< 2%),展现出极强的参数鲁棒性。:电压方程中的耦合项(ωe​Lq​iq​和 −ωe​Ld​id​)仅通过前馈补偿,当转速 ωe​较高时,微小的前馈误差会导致显著的d-q轴电流交叉耦合;其中,ud​,uq​为定子电压,id​,iq​为定子电流,Rs​为定子电阻,Ls​为定子电感,ωe​为电角速度,ψf​为永磁体磁链,p为极对数。(步长 Ts​=10μs,即100ns?

MHD0815的博客 94

从地方政府网站抓取政务公开数据:Python爬虫技术详解

在本文中,我们通过具体实例介绍了如何使用Python编写爬虫,从地方政府门户网站抓取政务公开数据。我们使用了requestsSelenium等最新技术,结合SQLite数据库存储抓取的数据,最后使用matplotlib进行数据可视化分析。通过本项目,您可以掌握如何抓取政府网站的公开数据,并将其进行清洗、存储和分析。这些技术对于进行政府政策分析、公共服务分析等方面具有重要的实际意义。希望通过本文的介绍,您能够更好地理解政务数据抓取的流程和方法,并能在实际工作中运用这些技术进行数据采集和分析。

2201_76125261的博客 1714

Codeforces Round #501 (Div. 3)

最近很是浮躁啊。。div3做出来两题。。rating1234-&gt;1230... 究其原因还是因为自己菜吧 不谈了,补个题 B. Obtaining the String 不多说,少了一个break D. Walking Between Houses 也不想说,爆int E1. Stars Drawing (Easy Edition) E2. Stars Drawing (Ha...

swunHJ的博客 279

如何通过 GitHub Actions 使用 SSH 自动化部署到阿里云 ECS 实例

通过 GitHub Actions 和 SSH 自动化部署,可以显著提高你的开发效率和部署的可靠性。本文介绍了如何生成 SSH 密钥、将公钥添加到阿里云 ECS 实例、将私钥添加到 GitHub Secrets,以及编写 GitHub Actions 工作流来实现自动化部署。希望这篇文章对你有所帮助!

吃面不喝汤的博客 1520

Codeforces Round #501 (Div. 3) E2. Stars Drawing (Hard Edition)

E2. Stars Drawing (Hard Edition) time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output A star is a figure of the following type: an ast...

哇-WA 的博客 359

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

Codeforces Round #501 E2. Stars Drawing (Hard Edition) 暴力枚举+标记

题意: 定义一种“星”,问有多少个,输出坐标和大小,,不合法时输出-1 思路: 他的星可以重叠,所以我们枚举每个星的中心点,尽量往外找,找到这个点为中心的最大大小的星 存起来最后 对整个矩阵标记,检查合法情况     #include &lt;bits/stdc++.h&gt; using namespace std; typedef long long ll; const int...

床前明月光 309

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain&#39;s apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath(&#39;DeepLearnToolbox&#39;));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand(&#39;state&#39;,0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = &#39;sigm&#39;;%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, &#39;Too big error&#39;);```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, &#39;Too big error&#39;);```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

AtCoder Beginner Contest 260 G.Scalene Triangle Area(花式二维差分/二维线段树)

AtCoder Beginner Contest 260 G.Scalene Triangle Area(斜向二维差分+二维前缀和/二维线段树)

小衣同学的博客 686

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

Codeforces Round #770 (Div. 2) F. Fibonacci Additions(构造+差分)

题目 长为n(n<=3e5)的序列a、b,模数mod(1<=mod<=1e9+7) 两个序列有初值,0<=ai,bi<mod q(q<=3e5)次操作,每次给一个a或b的区间加上一个斐波那契数列, 此处,fib[1]=fib[2]=1%mod,fib[i]=(fib[i-1]+fib[i-2])%mod A l r,对a[l]加fib[1]%mod,...,对a[r]加fib[r-l+1]%mod B l r,对b[l]加fib[1]%mod,...,对b[r

小衣同学的博客 570

AtCoder Beginner Contest 150 F. Xor Shift (异或性质+扩展kmp)

将s1扩展成原来的2倍之后(s1=s1+s1),与s2做扩展kmp即可。你可以自行选择一个k(0

小衣同学的博客 538

ContestHunter4302 Interval GCD(差分+线段树+gcd性质)

题目 长度为n(n<=5e5)的数组a[],m(m<=2e5)次操作,操作分两种 ①对[l,r]区间加d ②询问[l,r]区间的gcd 题目保证ai在任何操作之后都为不超过的正整数 思路来源 https://blog.csdn.net/forever_dreams/article/details/85222870 题解 注意到gcd(x,y,z)==gcd(x,y-x...

小衣同学的博客 515

牛客练习赛48 C.小w的糖果(差分)

题目 n(n<=1e5)个人,m(m<=1e5)种操作, 操作分三种, ①[pos,n]从左到右第i个点+1 ②[pos,n]从左到右第i个点+i ③[pos,n]从左到右第i个点+i的平方 询问,所有操作完之后,每个点的值 思路来源 https://ac.nowcoder.com/acm/contest/view-submission?submissionId=407...

小衣同学的博客 491

AtCoder Regular Contest 136 C.Circular Addition(差分/环上区间减1使所有数为0的最小操作数)

AtCoder Regular Contest 136 C.Circular Addition(差分/环上区间减1使所有数为0的最小操作数)

小衣同学的博客 490

牛客小白月赛12 H-华华和月月种树(dfs序+差分树状数组)

题目 思路来源 官方题解 https://ac.nowcoder.com/discuss/160376?type=101&order=0&pos=5&page=1 思路来源 https://ac.nowcoder.com/acm/contest/view-submission?submissionId=40398427 题解 官方题解 先离线...

小衣同学的博客 480

Codeforces Round #590 (Div. 3) E(暴力/差分)+F(状压dp)

思路来源 https://www.cnblogs.com/carcar/p/11618099.html https://blog.csdn.net/BeNoble_/article/details/101985236 https://codeforces.com/blog/entry/70233 E. Special Permutations(暴力/差分) 对于长度为n(n<=2e...

小衣同学的博客 455

牛客练习赛48 B.小w的a=b问题(差分+数论)

题目 一个a[]数组,长度为n,第i个元素ai, 另一个是b[]数组,长度为m,第j个元素bj。 先对每个元素求阶乘,再对数组求乘积,问两个数组最终所得结果是否相等 1<=n,m<=1e5;0<=ai,bj<=1e5;T<=200;n,m总和不超过2e6 思路来源 https://ac.nowcoder.com/acm/contest/923/B 题解 ...

小衣同学的博客 449

牛客练习赛49 D.筱玛爱线段树(差分)

题目 给定一个长度为n(n<=1e5)的数组A,刚开始每一项的值均为0。 支持以下两种操作,操作共m(m<=1e5)次: 1 l r:将Al∼Ar的每一项的值加上1。 2 l r:执行操作编号在[l,r]内的所有操作各一次,保证r小于当前操作的编号。 m次操作结束后,你要告诉马爷A数组变成什么样子了。 由于答案可能会很大,你只需要输出数组A中的每个数在模1e9+7意义下的值...

小衣同学的博客 400

Codeforces Round 893 (Div. 2) E2. Rollbacks (Hard Version) (主席树/树状数组/差分+前缀和)

主席树需要维护lson、rson、num三个变量,num从0变1表示新增,其余非新增,每个空间1e6*20大概2e7,三个6e7,倍增也需要开1e6*20=2e7,3. 回滚时,维护一个数组记录一下操作的点号的序列,退到前一个。2. 查询时,就全局查询数的种类数,实际只需要用到根节点。,询问当前数组内的不同的数的个数(即数的种类数)1. 加数时,按照询问动态开点,在主席树上建一条链。当主席树上建一条新链的时候,在进入叶子结点前,jjleo代码/jiangly代码/官方题解。

小衣同学的博客 382
上一篇: 牛客练习赛49 D.筱玛爱线段树(差分)
下一篇: 牛客练习赛49 B.筱玛爱阅读(状压/子集dp)
小衣同学
博客等级 码龄9年 1444粉丝 995原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小衣同学

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值