hdu5652 India and China Origins BFS+二分 或 二维的并查集

库存管理基于Excel的多商品组合订单需求拆解模型:SKU级供需预测与四情景压力测试系统设计 Excel 多商品组合订单的需求拆解|Excel模型与模拟数据 内容概要:本文档围绕Excel中多商品组合订单的基础SKU需求拆解,构建从订单行、组合用量表到仓库周需求、期初可供、计划到货及欠交结转的完整计算链条。通过四种组合、六种SKU、两座仓库和八个业务周的模拟数据,演示如何将组合套数准确转换为SKU件数,防止重复扣减与错误状态纳入,并按周递推供需覆盖与欠交变化。文档提供结构化输入校验、公式体系、守恒检查与四情景复算机制,确保结果可追溯、可核对。全部数据为基于固定随机种子生成的原创模拟记录,配套可编辑Excel工作簿与独立Python程序实现双向验证。 适合人群:适用于负责订单汇总、组合商品管理、库存分析、仓配协同、需求计划及业务分析文档编制的相关人员。日常使用者需掌握Excel基本操作如单元格引用、筛选与求和;具备Python基础者可配合标准库运行程序进行批量验证或数据重生成。业务管理岗可重点阅读结果与风险章节,结合工作表索引追踪数值来源。 使用场景及目标:适用于活动套单、同单含组合与单品、多仓备货、到货周期偏移及需求波动等场景。目标是实现组合订单向基础SKU的精准拆解,按周粒度完成供需匹配与欠交递推,识别输入冲突与窗口外到货影响,支持需求增幅、到货延期等多情景模拟分析,所有结论均可从源订单、BOM、Excel公式或独立程序追溯验证。 其他说明:项目交付包含A4文档、可编辑Excel、完整Python代码、CSV输入表、计算快照、四情景结果、测试记录、README指引及作者验收记录。采用固定随机种子确保数据一致性,强调输入有效性校验与双守恒(供给与需求)原则。Excel工作簿采用三层结构(源输入—公式计算—结果展示),支持手动编辑与自动重算,但扩容需重新生成网格。独立Python程序可用于交叉验证,保障模型可靠性。 立即下载

India and China Origins

Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1165    Accepted Submission(s): 382


Problem Description
A long time ago there are no himalayas between India and China, the both cultures are frequently exchanged and are kept in sync at that time, but eventually himalayas rise up. With that at first the communation started to reduce and eventually died.



Let's assume from my crude drawing that the only way to reaching from India to China or viceversa is through that grid, blue portion is the ocean and people haven't yet invented the ship. and the yellow portion is desert and has ghosts roaming around so people can't travel that way. and the black portions are the location which have mountains and white portions are plateau which are suitable for travelling. moutains are very big to get to the top, height of these mountains is infinite. So if there is mountain between two white portions you can't travel by climbing the mountain.
And at each step people can go to 4 adjacent positions.

Our archeologists have taken sample of each mountain and estimated at which point they rise up at that place. So given the times at which each mountains rised up you have to tell at which time the communication between India and China got completely cut off.
 

Input
There are multi test cases. the first line is a sinle integer $T$ which represents the number of test cases.

For each test case, the first line contains two space seperated integers $N, M$. next $N$ lines consists of strings composed of $0, 1$ characters. $1$ denoting that there's already a mountain at that place, $0$ denoting the plateau. on $N + 2$ line there will be an integer $Q$ denoting the number of mountains that rised up in the order of times. Next $Q$ lines contain $2$ space seperated integers $X, Y$ denoting that at ith year a mountain rised up at location $X, Y$.

$T \leq 10$

$1 \leq N \leq 500$

$1 \leq M \leq 500$

$1 \leq Q \leq N*M$

$0 \leq X < N$

$0 \leq Y < M$
 

Output
Single line at which year the communication got cut off.

print -1 if these two countries still connected in the end.

Hint:



From the picture above, we can see that China and India have no communication since 4th year.
 

Sample Input
  
1 4 6 011010 000010 100001 001000 7 0 3 1 5 1 3 0 0 1 2 2 4 2 1
 

Sample Output
  
4
 

Source


BFS + 二分


#include <cstdio>  
#include <iostream>  
#include <cstring>  
#include <cmath>  
#include <algorithm>  
#include <queue>  
using namespace std;
#define maxn 511  
#define move Move  

char mp[maxn][maxn];
int op[maxn*maxn][2];
int n, m, q;
const int move[4][2] = { { 0, 1 }, { 0, -1 }, { 1, 0 }, { -1, 0 } };
bool vis[maxn][maxn];

bool legal(int x, int y) {
	if (x < 0 || y < 0 || x >= n || y >= m)
		return 0;
	return 1;
}
struct node {
	int x, y;
	node(int x, int y) : x(x), y(y) {}
	node() {}
};
node gg[maxn*maxn]; int tou, wei;

bool ok(int pos) {//是否联通  
	memset(vis, 0, sizeof vis);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (mp[i][j] == '1') {//cout << ".." << endl;  
				vis[i][j] = 1;
			}
		}
	}
	for (int i = 1; i <= pos; i++) {
		vis[op[i][0]][op[i][1]] = 1;
	}
	for (int i = 0; i < m; i++) {
		if (!vis[0][i]) {
			tou = wei = 0;
			gg[wei++] = node(0, i);
			vis[0][i] = 1;
			while (tou < wei) {
				node now = gg[tou++]; //cout << now.x << " " << now.y << endl;  
				for (int i = 0; i < 4; i++) {
					node next;
					next.x = now.x + move[i][0];
					next.y = now.y + move[i][1];
					if (!legal(next.x, next.y) || vis[next.x][next.y])
						continue;
					if (next.x == n - 1)
						return 1;
					gg[wei++] = next;
					vis[next.x][next.y] = 1;
				}
			}
		}
	}
	return 0;
}

int main() {
	//freopen ("in.txt", "r", stdin);  
	int t;
	scanf("%d", &t);
	while (t--) {
		scanf("%d%d", &n, &m);
		for (int i = 0; i < n; i++)
			scanf("%s", mp[i]);
		scanf("%d", &q); //cout << q << endl;  
		for (int i = 1; i <= q; i++) {
			scanf("%d%d", &op[i][0], &op[i][1]);
		}
		if (!ok(0)) {
			printf("0\n");
			continue;
		} 
		int l = 1, r = q;
		while (r - l > 1) {
			int mid = (l + r) >> 1;
			if (ok(mid))
				l = mid;
			else r = mid;
		}
		if (!ok(r))
			printf("%d\n", r);
		else
			printf("-1\n");
	}
	return 0;
}


二维上的并查集


/****************
*PID:
*Auth:Jonariguez
*****************
*/
#define lson k*2,l,m  
#define rson k*2+1,m+1,r  
#define rep(i,s,e) for(i=(s);i<=(e);i++)  
#define For(j,s,e) For(j=(s);j<(e);j++)  
#define sc(x) scanf("%d",&x)  
#define In(x) scanf("%I64d",&x)  
#define pf(x) printf("%d",x)  
#define pfn(x) printf("%d\n",(x))  
#define Pf(x) printf("%I64d",(x))  
#define Pfn(x) printf("%I64d\n",(x))  
#define Pc printf(" ")  
#define PY puts("YES")  
#define PN puts("NO")  
#include <stdio.h>  
#include <string.h>  
#include <string>  
#include <math.h>  
#include <set>  
#include <map>  
#include <stack>  
#include <queue>  
#include <vector>  
#include <iostream>  
#include <algorithm>  
using namespace std;
typedef long long LL;
typedef int Ll;
Ll quick_pow(Ll a, Ll b, Ll MOD){ a %= MOD; Ll res = 1; while (b){ if (b & 1)res = (res*a) % MOD; b /= 2; a = (a*a) % MOD; }return res; }

const int maxn = 500 + 10;
int mp[maxn][maxn], X[maxn*maxn], Y[maxn*maxn];
int n, m, par[maxn*maxn], par2[maxn*maxn];
char str[maxn];
int dx[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[8] = { 1, 0, -1, 0, 1, -1, 1, -1 };

struct node{
	int x, y;
}s[maxn];

void Init(){
	for (int i = 0; i <= n*m; i++){
		par[i] = i; par2[i] = i;
	}
}

int ID(int i, int j) {
	return i*m + j;
}

int Find(int x) {
	return x == par[x] ? x : par[x] = Find(par[x]);
}

int Find2(int x){
	return x == par2[x] ? x : par2[x] = Find2(par2[x]);
}

void Union(int u, int v) {
	u = Find(u); v = Find(v);
	if (u%m<v%m) par[v] = u;//维护最左列  
	else par[u] = v;
}

void Union2(int u, int v) {
	u = Find2(u); v = Find2(v);
	if (u%m>v%m) par2[v] = u; //维护最右列  
	else par2[u] = v;
}

int main()
{
	int i, j, T;
	scanf("%d", &T);
	while (T--) {
		scanf("%d%d", &n, &m);
		Init();
		for (i = 0; i<n; i++) {
			scanf("%s", str);
			for (j = 0; j<m; j++)
				mp[i][j] = (str[j] - '0');
		}
		for (i = 0; i<n; i++) {
			for (j = 0; j<m; j++) {
				if (mp[i][j] == 1) {
					for (int k = 0; k<8; k++) {
						int x = i + dx[k], y = j + dy[k];
						if (x<0 || x >= n || y<0 || y >= m || mp[x][y] == 0) continue;
						Union(ID(i, j), ID(x, y));
						Union2(ID(i, j), ID(x, y));
					}
				}
			}
		}
		for (i = 0; i<n; i++) {
			for (j = 0; j<m; j++)
				Find(ID(i, j)); Find2(ID(i, j));
		}  //???
		int q;
		scanf("%d", &q);
		for (i = 1; i <= q; i++) {
			scanf("%d%d", &X[i], &Y[i]);
		}
		for (i = 1; i <= q; i++) {
			mp[X[i]][Y[i]] = 1;
			for (int k = 0; k<8; k++) {
				int x = X[i] + dx[k], y = Y[i] + dy[k];
				if (x<0 || x >= n || y<0 || y >= m || mp[x][y] == 0) continue;
				Union(ID(X[i], Y[i]), ID(x, y));
				Union2(ID(X[i], Y[i]), ID(x, y));
			}
			int t = Find(ID(X[i], Y[i])), d = Find2(ID(X[i], Y[i]));
			if (t%m == 0 && d%m == m - 1)
				break;
		}
		if (i <= q)
			printf("%d\n", i);
		else puts("-1");
	}
	return 0;
}



东汉AD35年世界历史地图矢量文件SHP格式.zip 本资源为《东汉AD35年世界历史地图矢量文件SHP格式》压缩包,文件大小约 29.99 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见JSON 文件、属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。 立即下载

相关推荐

AI第三篇:ScaBench-用真实审计竞赛数据构建可复现的 AI 审计评测集

AI第三篇:ScaBench-用真实审计竞赛数据构建可复现的 AI 审计评测集

HDU5652India and China Origins

India and China Origins   Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1995    Accepted Submission(s): 685     Problem Description A l...

Low Coder的博客 385

一文读懂Cache一致性原理

本文介绍了为什么需要维护cache一致性、一致性协议的本质和类别,以及如何设计一致性协议。

W1Z1Q的专栏 6893

hdu5652 India and China Origins(并查集)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5652 题目大意:从indian到china隔着喜马拉雅山,喜马拉雅山不是一开始就产生的,大家地理都学过,喜马拉雅山是板块之间的挤压慢慢形成的,啊,扯得有点远。给你一开始喜马拉雅山的样子,然后每年都会生成新的山峰,问你第几年印度和中国不能往来。如果一直都可以往来,那么就输出-1; 题目分析:乍一看是

china震震的博客 411

【faers数据库-R语言】

摘要:本文详细介绍了FAERS数据库不良反应信号挖掘的完整流程,包括数据解压导入(R代码示例)、数据结构理解、数据清洗(缺失值处理、标准化、合并和编码映射)、信号挖掘准备(药物-反应组合表创建)以及信号强度指标计算(PRR和ROR)。重点阐述了数据清洗的关键步骤,如缺失值处理(colSums(is.na()))、数据标准化(toupper()、as.Date())和表合并(merge()),并提供了完整的R语言实现代码。最后强调结果需结合临床知识解读,建议使用data.table等高效工具处理大数据。整个流

weixin_46587777的博客 1515

CD-HIT的使用

继续我的生信笔记系列。从某网站的附带文献中读到该工具,搜索了一下,发现网上的大佬们都在讲如何用它去冗余,相对官方页面的介绍而言很是片面,于是刚好有聚类的需求的我准备对其全体功能做做实验,学习一下由李伟忠博士在伯纳姆研究所(现为桑福德伯纳姆医学研究所)亚当·戈兹克博士的实验室开发的牛工具。 首先是官方介绍: CD-HIT是一个非常广泛使用的程序,用于蛋白质或核苷酸序列的聚类和比较。最初由李伟忠博士在伯纳姆研究所(现为桑福德伯纳姆医学研究所)亚当·戈兹克博士的实验室开发,CD-HIT速度非常快,可以处理非常

一名学术waste的note pro 1万+

2016蓝桥杯省赛C/C++B组7题剪邮票 DFS枚举组合情况BFS判联通

剪邮票 如【图1.jpg】, 有12张连在一起的12生肖的邮票。 现在你要从中剪下5张来,要求必须是连着的。 (仅仅连接一个角不算相连) 比如,【图2.jpg】,【图3.jpg】中,粉红色所示部分就是合格的剪取。 请你计算,一共有多少种不同的剪取方法。 请填写表示方案数目的整数。 注意:你提交的应该是一个整数,不要填写任何多余的内容或说明性文字。

EventQueue的博客 6974

【深度排查】VScode 远程 SSH 连接失败:从网络握手到服务部署的全链路诊断指南

本文详细解析了VScode远程SSH连接失败的常见原因及解决方案,从基础网络排查到SSH服务配置,再到VScode特有的问题处理。特别针对Ubuntu和TrueNAS系统提供了具体配置建议,帮助开发者快速解决'Could not establish connection'等连接问题,提升远程开发效率。

weixin_30301449的博客 455

蓝桥杯练习系统试题集 算法提高 ADV-147 学霸的迷宫

问题描述   学霸抢走了大家的作业,班长为了帮同学们找回作业,决定去找学霸决斗。但学霸为了不要别人打扰,住在一个城堡里,城堡外面是一个二维的格子迷宫,要进城堡必须得先通过迷宫。因为班长还有妹子要陪,磨刀不误砍柴功,他为了节约时间,从线人那里搞到了迷宫的地图,准备提前计算最短的路线。可是他现在正向妹子解释这件事情,于是就委托你帮他找一条最短的路线。 输入格式   第一行两个整数n,

EventQueue的博客 3383

DeepSeek Harness接入QQ实战:把DSH变成赛博群友

大模型应用正从单机问答走向多平台集成,如何将模型能力嵌入即时通讯工具成为工程实践的热点。消息接入、会话管理、插件扩展是构建智能群聊机器人的核心三要素。DeepSeek Harness(DSH)作为一款模型会话工作流管理工具,凭借多会话管理、模型调用编排以及灵活的插件机制,能够在QQ群聊场景中实现“接收消息→模型生成→回复推送”的完整闭环。本文从基础概念切入,详解DSH接入QQ的两种实现路线——外部API转发与原生插件适配,覆盖环境准备、启动调试、接口调用与性能观察,并给出常见问题排查清单。无论是本地AI助理

weixin_27427619的博客 2145

前端视频压缩实战:除了ffmpeg.wasm,我们还有哪些轻量级方案可以选?

本文探讨了前端视频压缩的多种轻量级方案,包括ffmpeg.wasm、WebCodecs API、Canvas+WebAssembly及云服务API,分析了各方案的技术特性、性能表现和适用场景,帮助开发者根据项目需求选择最优解。特别针对ffmpeg.wasm的体积和性能问题提供了优化建议,并对比了云端协同方案的成本效益。

weixin_33688840的博客 452

团体程序设计天梯赛-练习集 L2-006 树的遍历 根据后序中序建树+BFS

L2-006. 树的遍历 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 给定一棵二叉树的后序遍历和中序遍历,请你输出其层序遍历的序列。这里假设键值都是互不相等的正整数。 输入格式: 输入第

EventQueue的博客 2221

从源码编译CesiumForUnreal

从源码编译CesiumForUnreal插件

专注GIS开发 5651

蓝桥杯 历届试题 九宫重排 BFS Java

标准的BFS题,将九宫格哈希以后记录搜索的状态,用Set边搜索边去重,写的代码用了点面向对象的东西     AC代码: import java.util.*; public class Main { //f为初始状态,e为最终状态 static int f[][] = new int[3][3], e[][] = new int[3][3]; //将'.'表示成9这个数字 s

EventQueue的博客 1720

linux cma alloc fail 问题分析

摘要:日志显示CMA连续内存分配失败(错误码-ENOMEM),请求128页(512KB)内存时因CMA区域不足或内存碎片导致失败。分析发现系统CMA总内存131072KB,空闲65536KB。解决方案包括:1)手动触发内存碎片整理;2)修改设备树或内核配置增大CMA区域(如从16MB增至20MB)。通过调整CONFIG_CMA_SIZE_MBYTES或设备树中的size参数可解决该问题。

陌上花开缓缓归以的博客 812

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

pat甲级 1020. Tree Traversals map递归建树 + BFS

先用map建立一棵二叉树,mr存右孩子节点,ml存左孩子节点,然后输出BFS路径就行了 #include #include #include #include #include using namespace std; int N; int po[35], in[35], prin[35]; int root, ip, len; map ml, mr; int solve

EventQueue的博客 903

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

团体程序设计天梯赛 L3-008. 喊山 BFS

L3-008. 喊山 时间限制 150 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 喊山,是人双手围在嘴边成喇叭状,对着远方高山发出“喂—喂喂—喂喂喂……”的呼唤。呼唤声通过空气的传递,回荡于深谷之间,传送到人们耳中

EventQueue的博客 782

深度学习工具包 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")

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

pat 1127. ZigZagging on a Tree (30) 递归建树 + BFS

1127. ZigZagging on a Tree (30) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Suppose that all the keys in a binary

EventQueue的博客 745

hdu1181 变形课 BFS 判断连通性

变形课 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others) Total Submission(s): 20132    Accepted Submission(s): 7240 Problem Description 呃......变形课上Harry碰到了一

EventQueue的博客 741

hdu1195 Open the Lock 广搜BFS 四维数组标记

Open the Lock Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5732    Accepted Submission(s): 2540 Problem Description Now an emerg

EventQueue的博客 704

poj3414 Pots BFS

Pots Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13400   Accepted: 5641   Special Judge Description You are given two pots, having the volume of A an

EventQueue的博客 648

hdu2614 Beat BFS or DFS

Beat Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1286    Accepted Submission(s): 751 Problem Description Zty is a man that alwa

EventQueue的博客 646

hdu5025 Saving Tang Monk BFS

Saving Tang Monk Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 2360    Accepted Submission(s): 848 Problem Description 《Journey t

EventQueue的博客 568

poj3278 Catch That Cow

本来用DFS做的,总是超时,拿别人AC的程序一测数据结果还一样,但是就是超时,这道题用DFS做要有很多剪枝,不然会有很多的重复,比如第x步走过点m,回溯后再DFS第y步的时候又走过m点,会有大量重复情况,还是BFS比较好剪枝 /* Catch That Cow Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 6327

EventQueue的博客 564

codeforces723D Lakes in Berland 搜索

D. Lakes in Berland time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The map of Berland is a rectangle of th

EventQueue的博客 532
上一篇: hdu1698 Just a Hook 线段树延迟标记区间更新 求加权区间总和
下一篇: poj3468 A Simple Problem with Integers 线段树延迟标记区间更新区间求和
Daemoonn
博客等级 码龄11年 42粉丝 198原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址