hdu 4297 One and One Story

政府科技管理者在推动科技成果转化过程中,如何解决科研成果与市场需求脱节的问题?.docx 政府科技管理者在推动科技成果转化过程中,如何解决科研成果与市场需求脱节的问题? 立即下载

One and One Story

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 327680/327680 K (Java/Others)
Total Submission(s): 657    Accepted Submission(s): 335


Problem Description
  Have you ever played the romantic Flash game, "One and One Story"? 1 In this story of a boy and a girl and their romance you are to direct them to meet together as they face their euphoria and trials of their relationship.
  You, as a member of the FFF Inquisition,  2 are fed up with such game since you believe that to make things fair, you should not keep providing guidance information while risking remaining forever alone  3 . So you decided to write a program working out guidance for these sweet small lovers on behalf of you. ( Another reason is, you have to help K couples, which would make you somewhat overwhelmed. )
  Fortunately, you are to handle not the Flash game above, but a simplified version: In the game, a maze consists of some rooms connected with one-way hallways. For each room, there is exactly one outgoing hallway here, and it would lead directly to some room (not necessarily a different one). The boy and girl are trapped in (not necessarily different) rooms. In each round of the games, both of them could choose to stay in the current room or walk to the room to which the unique outgoing hallway leads. Note that boy and girl could act independently of each other. Your goal is to come to the reunion between them.
  Your program should determine a pair of numbers (A,B) for each couple of boy and girl, where A represents number of hallway the boy walked through, B the girl, that could lead reunion between them. First, your program should minimize max(A,B). If there are several solutions, you should then guarantee that min(A,B) is minimized subject to above. If, satisfying above conditions, there are still multiple solutions, girl should walk less, that is you should then keep A >= B subject to conditions above. 
  In case they could not reunion, just let A = B = -1.
---------------------------------------------------------------------------------
1It’s available here: http://armorgames.com/play/12409/one-and-one-story
2See http://bakatotest.wikia.com/wiki/FFF_Inquisition
3http://foreveralonecomic.com/
 

Input
  There're several test cases.
  In each test case, in the first line there are two positive integers N and K (1 <= N <= 500000; 1 <= K <= 500000) denoting the number of rooms and number of couples. Rooms a numbered from 1 to N.
  The second line contains n positive integers: the i th integer denotes the number of room to which the hallway going out of room i leads.
The following K lines are queries of several couples. Each query consists of two positive integers in a single line denoting the numbers of rooms where the lovers currently are: first the boy, then the girl.
  Please process until EOF (End Of File).
 

Output
  For each test case you should output exactly K lines, one line per query. Each line consists two integers separated by a space: the integer A and B for this couple.
  See samples for detailed information.
 

Sample Input
  
12 5 4 3 5 5 1 1 12 12 9 9 7 1 7 2 8 11 1 2 9 10 10 5 12 5 4 3 5 5 1 1 12 12 9 9 7 1 7 2 8 11 1 2 9 10 10 5
 

Sample Output
  
2 3 1 2 2 2 0 1 -1 -1 2 3 1 2 2 2 0 1 -1 -1
 

Source



代码:

#pragma comment(linker,"/STACK:1024000000,1024000000")
#include<cstdio>
#include<vector>
using namespace std;
const int N=500010;
struct node
{
	int x,y;
	node(){}
	node(int _x,int _y){x=_x;y=_y;}
};
struct tree
{
	int set[N];
	void init(int n)
	{
		int i;
		for(i=1;i<=n;i++) set[i]=i;
	}
	int find(int x)
	{
		if(set[x]!=x) set[x]=find(set[x]);
		return set[x];
	}
}a,b;
int n,k,pre[N],root[N],dep[N],lca[N],cir[N];
vector<int> edge[N];
vector<node> query[N];
int isroot[N],x[N],y[N];
bool vis[N];
void Input()
{
	int i,p,q;
	a.init(n);
	for(i=1;i<=n;i++)
	{
		edge[i].clear();
		query[i].clear();
	}
	for(i=1;i<=n;i++)
	{
		scanf("%d",&pre[i]);
		edge[pre[i]].push_back(i);
		p=a.find(i);
		q=a.find(pre[i]);
		a.set[p]=q;
	}
	for(i=0;i<k;i++)
	{
		scanf("%d%d",&x[i],&y[i]);
		query[x[i]].push_back(node(y[i],i));
		query[y[i]].push_back(node(x[i],i));
	}
}
void LCA(int u,int depth,int Root)
{
	int i,v,x,y;
	dep[u]=depth;
	root[u]=Root;
	for(i=0;i<edge[u].size();i++)
	{
		v=edge[u][i];
		if(isroot[v]!=-1||u==v) continue;
		LCA(v,depth+1,Root);
		b.set[v]=u;
	}
	vis[u]=true;
	for(i=0;i<query[u].size();i++)
	{
		x=query[u][i].x;
		y=query[u][i].y;
		if(vis[x]&&root[u]==root[x]) lca[y]=b.find(x);
	}
}
void Output()
{
	int i,j,u,v,rootX,rootY,size,X,Y,A,B;
	for(i=0;i<k;i++)
	{
		if(a.find(x[i])!=a.find(y[i])) {puts("-1 -1");continue;}
		if(root[x[i]]==root[y[i]])
		{
			j=lca[i];
			printf("%d %d\n",dep[x[i]]-dep[j],dep[y[i]]-dep[j]);
			continue;
		}
		u=dep[x[i]];
		v=dep[y[i]];
		rootX=root[x[i]];
		rootY=root[y[i]];
		size=cir[a.find(rootX)];
		X=(isroot[rootY]-isroot[rootX]+size)%size;
		Y=(isroot[rootX]-isroot[rootY]+size)%size;
		if(max(u+X,v)<max(u,v+Y)) A=u+X,B=v;
		else if(max(u+X,v)>max(u,v+Y)) A=u,B=v+Y;
		else if(min(u+X,v)<min(u,v+Y)) A=u+X,B=v;
		else if(min(u+X,v)>min(u,v+Y)) A=u,B=v+Y;
		else A=u+X,B=v;
		printf("%d %d\n",A,B);
	}
}
int main()
{
	while(~scanf("%d%d",&n,&k))
	{
		Input();
		int i,j,t,c;
		memset(isroot,-1,sizeof(isroot));
		memset(vis,false,sizeof(vis));
		for(i=1;i<=n;i++) if(a.set[i]==i)
		{
			t=i;
			while(1)
			{
				if(vis[t]) break;
				vis[t]=true;
				t=pre[t];
			}
			c=0;
			isroot[t]=c++;
			for(j=pre[t];j!=t;j=pre[j]) isroot[j]=c++;
			cir[i]=c;
		}
		memset(lca,-1,sizeof(lca));
		memset(vis,false,sizeof(vis));
		b.init(n);
		for(i=1;i<=n;i++) if(isroot[i]!=-1) LCA(i,0,i);
		Output();
	}
	return 0;
}


隔离型全桥LLC谐振变化器建模及参数设计资料【仿真+设计报告+计算书】 内容概要:本文档系统性地提供了隔离型全桥LLC谐振变换器的建模与参数设计全套资料,涵盖Simulink、Plecs和PSIM等多种主流仿真平台的实现模型,配套完整的闭环控制设计报告与Mathcad计算书。内容深入聚焦LLC谐振变换器的核心技术环节,包括软开关实现机制、变频与移相混合控制策略、闭环稳定性分析、谐振参数优化设计及软启动过程建模等关键方面。资料不仅包含典型拓扑结构的仿真验证,还整合了多相交错、双向CLLC、恒压恒流双闭环等进阶控制方案,辅以详细的数学推导与工程设计流程,全面支撑从理论分析到实际电源系统开发的全过程。; 适合人群:面向具备电力电子、自动化或电气工程等相关专业背景,从事开关电源、新能源变换系统、高效率DC-DC转换器研发的工程师、高校研究生及科研人员。; 使用场景及目标:① 深入掌握全桥LLC谐振变换器的工作原理与精确建模方法;② 学习并实践基于多平台的闭环控制系统仿真与动态性能优化;③ 借助Mathcad计算书完成实际工程中谐振腔参数、磁性元件与开关频率的系统化设计;④ 支持高水平科研论文撰写、学位课题研究或工业级电源产品的开发与验证。; 阅读建议:建议结合仿真模型、设计报告与计算书三位一体同步研习,重点剖析控制策略的实现逻辑与参数敏感性分析,动手运行并修改仿真文件以深入理解系统动态响应,同时可参照文档中丰富的电力电子拓扑案例进行横向对比与技术拓展。 立即下载

相关推荐

全桥LLC谐振(变频+移相混合控制)变换器闭环仿真模型(Simulink仿真实现)

内容概要:本文详细介绍了基于Simulink平台构建的全桥LLC谐振变换器闭环仿真模型,采用变频与移相混合控制策略,实现高效电能转换与系统稳定运行。该模型涵盖主电路建模、闭环控制环路设计、关键参数整定及动态响应分析等核心环节,重点突出通过闭环反馈机制提升输出精度、负载适应能力与系统鲁棒性。同时,模型充分体现了软开关技术(如零电压开关ZVS)的实现原理,有效降低开关损耗,提高电源效率。配套提供的参数设计报告与仿真文件有助于深入理解LLC谐振变换器的工作机理及其在实际工程中的设计流程与优化方法。; 适合人群:适用于电力电子、电气工程及其自动化等相关领域的高校本科生、研究生,以及从事高频开关电源、新能源变换器研发的工程技术人员,具备电路理论基础和Simulink仿真经验者更佳。; 使用场景及目标:①掌握全桥LLC谐振变换器的建模与闭环仿真方法;②深入理解变频控制与移相控制相结合的混合调制策略在高效率电源中的应用优势;③用于科研项目、学位论文或毕业设计中的高性能DC-DC变换器研究;④作为教学案例展示高频软开关电源的动态特性与闭环控制实现方式; 阅读建议:建议结合所提供的设计报告与仿真模型同步操作,逐步调整控制器参数(如PI参数、频率范围、移相角等),观察系统在不同负载与输入条件下的动态响应,从而深化对谐振频率调节、软开关实现条件、闭环稳定性判据等关键技术要点的理解。

LCA HDU 4297 One and One Story

One and One Story Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 327680/327680 K (Java/Others) Total Submission(s): 760    Accepted Submission(s): 353 Problem Description     Have

We Can 757

HTML5期末大作业:水果超市网站设计——水果超市(6页) HTML+CSS+JavaScript 学生DW网页设计作业成品 web课程设计网页规划与设计 网购商城设置网页

HTML5期末大作业:水果超市网站设计——水果超市(6页) HTML+CSS+JavaScript 学生DW网页设计作业成品 web课程设计网页规划与设计 网购商城设置网页 常见网页设计作业题材有 个人、 美食、 公司、 学校、 旅游、 电商、 宠物、 电器、 茶叶、 家居、 酒店、 舞蹈、 动漫、 明星、 服装、 体育、 化妆品、 物流、 环保、 书籍、 婚纱、 军事、 游戏、 节日、 戒烟、 电影、 摄影、 文化、 家乡、 鲜花、 礼品、 汽车、 其他 等网页设计题目, A+水平作业, 可满足大

1714

HDU 4297-One and One Story解题报告

链接:http://acm.hdu.edu.cn/showproblem.php?pid=4297 这道题所给的图是一个森林,每一个子图都必有一个环(因为总边数为n),可以把环当做这棵树的根节点,那么如果两个点不在一棵树上,一定互相不可达,如果在一棵树上,如果两个点在同一棵子树上,那么一起到的点就是LCA,所以要维护森林的LCA,如果不在同一棵子树上,则要到各自的根节点,然后沿着环方向...

weixin_30653097的博客 360

硬件原理图:从软件思维到硬件接口的嵌入式开发破局指南

本文为软件开发者提供了读懂硬件原理图的嵌入式开发破局指南。文章将硬件原理图类比为“硬件系统的架构图”,引导读者将软件API调用思维迁移到硬件接口理解上,详细解析了电阻、电容、二极管等常见元器件的“硬件API”功能与选型逻辑,并通过实战电路拆解,阐述了从原理图分析到驱动代码编写的完整思维链条,帮助开发者建立软硬件协同的系统级视角。

lg888的博客 496

ChromeOS安装教程

ChromeOS,是基于Linux内核研发的ChromiumOS开源系统的闭源系统,最大的特色就是内置了Chrome浏览器,早期主要以Web云端应用程序为主,后来逐渐引入了Android子系统和Linux子系统。本文主要简述摸索的家用笔记本安装ChromeOS安装方法,供各位玩机朋友参考。

weixin_45751495的博客 8117

hdu 4297 One and One Story(维护森林中的LCA)

题意:有n个房间,每个房间有且只有一条出边指向另一个房间,现给出两个人在两个房间,问让他俩汇合要走的最少的路径数 解法:观察图的形态,由于n个点n条边,且每个点出度为1,因此可以认为是一个森林,森林里每棵树都加了一条边形成了一个环,且环是根节点(可以认为缩点后没有出边,即没有父节点)。 显然两点属于不同树的时候不可达;因为图的特殊性,因此没有用强连通做,而是用了并查集判环,也便于给环上每个点标

新博客地址:sensirly.github.io 2479

3GPP协议解读_物理层系列(一)_物理层协议怎么看?

5G NR相关协议一般都在38系列,点进去以后可以看到,38.2xx系列为物理层相关协议,为了掌握物理层相关知识,应该怎么看协议呢?我建议从38.201读起,对38.2xx系列协议有一个整体的把握。

JCMLSY的博客 1329

HDU 4297 One and One Story(图-最近公共祖先)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4297 题意:给出n个点的有向图,每个点的出度均为1.有m个询问,每个询问两个数(u,v),表示两个人一个在u一个在v。对于每个询问,请你选择一个点P使得u、v均能到达P。设u到达P需要A步,v到达P需要B步。求一个P使得max(A,B)最小?若答案不唯一,输出min(A,B)最小的;若答案还不唯一,...

weixin_34178244的博客 239

完整内、外期货量化交易系统源码可售

支持客户登录校验,支持所有的实时行情和汇总报价功能、实时资讯(报价,列表,分时,分钟成交明晰,),多线程支持盘后收盘作业下载(日线,5分钟线,15分钟, 30分钟,60分钟线,),支持从服务器下载相关运行配置(来自服务器动态配置信息,如收盘日期等),实现状态条显示。收盘作业包括日线、5分钟线、15分钟线、30分钟、60分钟线、2小时线、4小时线每日分时走势。综合信息栏显示用户账户信息、合约信息、当日委托单记录、当日成交记录、当日平仓记录、当日跟单记录、当日(月/周)排行榜、下单栏、持仓信息;

qq_35600909的博客 1805

infercnv的实操

摘要: 博主在infercnv分析中遇到执行困难,外包服务不可靠(未按要求使用HMM方法)。通过优化策略(逐样本处理、精简细胞至1000个、固定随机种子)解决了运行问题,但HMM功能仍无法实现。最终参考Cell期刊标准设置阈值完成分析,后续将继续更新进展。该案例凸显了生物信息分析中自主优化的重要性。(150字)

xiaoyusang的博客 308

HDU 4297 One and One Story 树lca转rmq 并查集维护根节点环

题意:给定一个有向图,每个节点只有一条出边,现在两个人在两个节点沿着有向边走,按照题意输出相遇时两个人走的路径。 题解:这个有向图很特别,由于每个节点只有一条出边,所以如果形成一个环的话就只能有指向这个环的边,同时一个子图内最多存在一个环,tarjan搞掉环,          建反图虚拟根节点转换成一棵树,根节点如果是环的环用带关系的并查集维护,然后lca->rmq,在线得到答案。

Uhh, call me zacky NOW!!! 1259

从0到1:用Claude 3.7十日拿下教育部课题申报书(附可修改LaTeX模板)

🟣"作为教育部人文社科项目评审专家,请根据近三年立项数据分析,为[您的学科方向]领域推荐5个具有创新性且符合'十四五'规划的重点选题,要求选题体现交叉学科特征,并标注潜在理论突破点"🟣"根据前期研究基础,创建包含4个研究模块、12个关键节点的三维技术路线图,要求体现实验仿真-实证研究-理论建模的螺旋递进关系,并标注每个节点的预期成果形态"🟣"现在切换至教育部学科评审组组长模式,从选题价值、创新程度、研究可行性三个维度对本申报书进行盲审,生成包含9个扣分风险点的诊断报告及修改优先级排序"

智能AI让学术科研更容易 545

HDU 4297 One and One Story [有向带环图LCA]

  给一个有向图,每个顶点的出度为1,A和B是图中的两个顶点,A和B每次只能走一步或者不走,设他们相遇时A走了X步,B走了Y步,使max(x,y)最大,有多解时,使min(x,y)最小,如果还有多解,使x>=y。   其实这个图最特殊的地方就是它每个顶点的出度仅为1。我们都知道树的特性是除了根节点外每个顶点的入度为1,那我们把这个图全部建反向边,也就是说每个顶点的入度为1。但是这个图是有环...

weixin_34226182的博客 172

Python与CAD系列基础篇(十)图形复制、移动、删除

①通过pyautocad连接AutoCAD进行处理②通过ezdxf处理dxf格式文件。进行图形复制、移动、删除的方法。pyautocad方式。pyautocad方式。

weixin_43894929的博客 2210

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

hdu 4297 One and One Story (维护森林中的LCA)

题意:有n个房间,每个房间有且只有一条出边指向另一个房间,现给出两个人在两个房间,问让他俩汇合要走的最少的路径数 解法:观察图的形态,由于n个点n条边,且每个点出度为1,因此可以认为是一个森林,森林里每棵树都加了一条边形成了一个环,且环是根节点(可以认为缩点后没有出边,即没有父节点)。 显然两点属于不同树的时候不可达;因为图的特殊性,因此没有用强连通做,而是用了并查集判环,也便于给环上每个点标

liuzhushiqiang的专栏 1454

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

HDU 4297 One and One Story (LCA->RMQ)

题意就是找森林里的LCA,构图完成了这个题基本就没问题了。 已知的是所给的图上是可能有环的。那么可以对这些环进行类似缩点的操作(当然不是tarjan),设一个虚拟根0点,链接环上的每一个点。 对于不在环上的点直接加无向边建树就行。 预处理出每个环包含哪些点,每个环中点的顺序(环是有方向的) 对得到的树进行LCA到RMQ的转化,同时记录当前点到0点的距离,O(nlogn)的时间预处理,O(1...

weixin_34176694的博客 297

深度学习工具包 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'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('DeepLearnToolbox'));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('state',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'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',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 = 'sigm';%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, 'Too big error');```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('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';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)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';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, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% 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'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 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, 'Too big error');```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('state',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, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',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, 'Too big error');%% ex3 neural net with dropoutrand('state',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, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % 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, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % 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, 'Too big error');%% 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('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % 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, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

HDU 4297 One and One Story 分类讨论, LCA 2012年成都网络赛J题

题目大意: 就是现在有一个有向图, 每个点出度都是1(只有一条出边), 这个图可以有环, 也可以有自环, 图的点的个数 N 然后有K次询问 (K 如果不可能到同一个房间, 那么输出-1 -1, 否则如果男主需要走A步女主需要走B步, 那么输出max(A, B)最小的方案, 如果有多种输出min(A, B)最小的方案, 如果依旧有多种, 输出B比较小的方案 大致思路: 首先这个

Gatevin的专栏 870

hdu One and One Story tarjan缩点+rmq+LCA

http://acm.hdu.edu.cn/showproblem.php?pid=4297 题意: 给出n个点的有向图,每个点的出度均为1.有m个询问,每个询问两个数(u,v),表示两个人一个在u一个在v。 对于每个询问,请你选择一个点P使得u、v均能到达P。设u到达P需要A步,v到达P需要B步。求一个P使得max(A,B)最小? 若答案不唯一,输出min(A,B)最小的;若答案还不唯一...

weixin_30569153的博客 99
上一篇: hdu 4296 Buildings
下一篇: hdu 4295 4 substrings problem
libing923
博客等级 码龄15年 12粉丝 71原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值