河南省第十一届ACM大学生程序设计竞赛 部分题解

ICPC/CCPC赛事全攻略:从网络赛到总决赛的备赛指南 算法竞赛是计算机领域检验逻辑思维与工程实现能力的重要方式,其核心在于通过限时编程解决复杂问题,强调算法设计、代码效率与团队协作。这种竞赛形式不仅为高校挖掘了顶尖技术人才,更成为保研、校招和科研能力评估的重要参考。从区域赛到全球总决赛,选手需经历网络赛选拔、现场赛角逐等层层筛选,其中网络赛题解、邀请赛真题与省赛记录成为备赛核心资源。ICPC作为全球性赛事,其亚洲赛区竞争激烈;而CCPC则立足国内,为更多高校提供竞技舞台。无论是参考“icpc网络赛2025题解”复盘思路,还是研究“2021年河南省CCPC真题” 阅读详情

题目链接

A 计划日

#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;

bool leapyear(int y)
{
	if (y % 400 == 0 || y % 4 == 0 && y % 100 != 0)
		return true;
	return false;
}
int main()
{
#ifdef LOCAL
	//freopen("C:/input.txt", "r", stdin);
#endif
	int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
	int T;
	cin >> T;
	while (T--)
	{
		int y, m, d, w, n;
		scanf("%4d%2d%2d %d %d", &y, &m, &d, &w, &n);
		//cout << y << " " << m << " " << d << endl;
 		--w;
		while (n--)
		{
			d++;
			if (d > month[m] + (m == 2 && leapyear(y)))
				d = 1, m++;
			if (m > 12)
				y++, m = 1;
			w = (w + 1) % 7;
		}
		printf("%04d%02d%02d %d\n", y, m, d, w + 1);
	}

	return 0;	
}

B 治安管理 <前缀和>

#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int N = 1e5 + 10;
int sum[N], a[N], b[N];

int main()
{
#ifdef LOCAL
	freopen("C:/input.txt", "r", stdin);
#endif
	int T;
	cin >> T;
	while (T--)
	{
		memset(sum, 0, sizeof(sum));
		int n, m, s, f;
		cin >> n >> m >> s >> f;
		for (int i = 0; i < n; ++i)
			scanf("%d", &a[i]);
		for (int i = 0; i < n; ++i)
			scanf("%d", &b[i]);
		for (int i = 0; i < n; ++i)
			sum[a[i]]++, sum[b[i]]--;
		int mx = 0, mi = INF;
		for (int i = 0; i < N; ++i)
		{
			sum[i] += sum[i - 1];
			if (i >= s && i < f)
				mx = max(mx, sum[i]), mi = min(mi, sum[i]);
		}
		if (mi >= m)
			printf("YES %d\n", mx);
		else
			printf("NO %d\n", mi);
	}

	return 0;	
}

C 山区修路 <dp>

状态转移时使用u、d两个数组求出上个状态高度从第到高、从高到低的最小值前缀。然后进行转移减少复杂度。

#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int N = 1e5 + 10;
int f[N][110]; //第i个位置为j高度的代价
int u[110], d[110];
int a[N];

int main()
{
#ifdef LOCAL
	freopen("C:/input.txt", "r", stdin);
#endif
	int T;
	cin >> T;
	while (T--)
	{
		memset(f, 0x3f, sizeof(f));
		memset(u, 0, sizeof(u));
		memset(d, 0, sizeof(d));
		int n, x;
		cin >> n >> x;
		for (int i = 1; i <= n; ++i)
			scanf("%d", &a[i]);
		u[0] = d[101] = INF;
		for (int i = 1; i <= n; ++i) //位置 
		{
			for (int j = a[i]; j <= 100; ++j) //当前高度
			{
				f[i][j] = (a[i] - j) * (a[i] - j);
				f[i][j] += min(u[j], d[j]); //前面状态转移到j高度的代价 
			}
			memset(u, 0x3f, sizeof(u)); //最值前缀
			memset(d, 0x3f, sizeof(d));
			for (int j = 1; j <= 100; ++j)
				u[j] = min(u[j - 1] + x, f[i][j]);
			for (int j = 100; j >= 1; --j)
				d[j] = min(d[j + 1] + x, f[i][j]);
		}
		int ans = INF;
		for (int i = 1; i <= 100; ++i)
			ans = min(ans, f[n][i]);
		cout << ans << endl;
	}

	return 0;
}

D 求XF+闭包 <模拟>

#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
string a[50], b[50], ans;
int n, m, k;

bool solve()
{
	for (int i = 0; i < k; ++i)
	{
		//cout << a[i] << " " << b[i] << endl;
		int flag = 1;
		for (int j = 0; j < a[i].size(); ++j)
			if (ans.find(a[i][j]) == -1)
				flag = 0;
		if (flag)
		{
			int sz = ans.size();
			ans += b[i];
			sort(ans.begin(), ans.end());
			ans.erase(unique(ans.begin(), ans.end()), ans.end());
			if (sz < ans.size())
				return 1;
		}
	}
	return 0;
}
int main()
{
#ifdef LOCAL
	freopen("C:/input.txt", "r", stdin);
#endif
	int T;
	cin >> T;
	while (T--)
	{
		cin >> n >> m >> k;
		cin >> ans >> ans;
		for (int i = 0; i < k; ++i)
			cin >> a[i] >> b[i];
		while (solve());
		cout << ans << endl;
	}

	return 0;
}

E 物流配送 <费用流>

把每个点的需求量和原有量进行比较,原有较多的作为源点,需求较多的作为汇点。建立超级源点和所有源点相连,容量为原有量-需求量,代价为0,建立超级汇点类似操作。
题目所给边建立双向边,代价为题目所给容量无穷大。最后跑最小费用最大流,最小代价即为答案。

#include <stdio.h>
#include <bits/stdc++.h>
#define fst first
#define sed second
using namespace std;
typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int N = 1e3 + 10;
int a[N], b[N];
bool vis[N];
int dis[N], pre[N];

struct edge
{
	int v, w, c, nxt; //容量 代价
}e[N * 8];
int h[N], idx;

void AddEdge(int u, int v, int w, int c)
{
	e[idx] = { v, w, c, h[u] };
	h[u] = idx++;
}
bool SPFA(int st, int ed)
{
	queue<int> q;
	memset(dis, 0x3f, sizeof(dis));
	memset(pre, -1, sizeof(pre));
	dis[st] = 0;
	vis[st] = 1;
	q.push(st);
	while (!q.empty())
	{
		int u = q.front(); q.pop(), vis[u] = 0;
		for (int i = h[u]; ~i; i = e[i].nxt)
		{
			int v = e[i].v, w = e[i].w, c = e[i].c; //w流量 c代价
			if (dis[v] > dis[u] + c && w)
			{
				dis[v] = dis[u] + c;
				pre[v] = i;
				if (!vis[v])
					q.push(v), vis[v] = 1;
			}
		}
	}
	return pre[ed] != -1;
}
void MCMF(int st, int ed, ll &cost)
{
	cost = 0;
	while (SPFA(st, ed))
	{
		int mi = INF;
		for (int i = pre[ed]; ~i; i = pre[e[i ^ 1].v])
			mi = min(mi, e[i].w);
		for (int i = pre[ed]; ~i; i = pre[e[i ^ 1].v])
		{
			e[i].w -= mi, e[i ^ 1].w += mi;
			cost += 1LL * mi * e[i].c;
		}
	}
}
int main()
{
#ifdef LOCAL
	freopen("C:/input.txt", "r", stdin);
#endif
	memset(h, -1, sizeof(h));
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
	for (int i = 1; i <= n; ++i)
	{
		scanf("%d", &b[i]);
		if (a[i] > b[i]) //源点
		{
			AddEdge(0, i, a[i] - b[i], 0); //无代价权值差容量
			AddEdge(i, 0, 0, 0);
		}
		else if (a[i] < b[i]) //汇点
		{
			AddEdge(i, n + 1, b[i] - a[i], 0);
			AddEdge(n + 1, i, 0, 0);
		}
	}
	for (int i = 1; i < n; ++i)
	{
		int u, v, w;
		scanf("%d%d%d", &u, &v, &w);
		AddEdge(u, v, INF, w);
		AddEdge(v, u, 0, -w);
		AddEdge(v, u, INF, w);
		AddEdge(u, v, 0, -w);
	}
	ll cost = 0;
	MCMF(0, n + 1, cost);
	cout << cost << endl;

	return 0;
}

G Checkpoints <tarjan>

如果能从起点到终点再回到起点则起点和终点在同一个强连通分量内。找出起点和终点的强连通分量。尝试暴力删除一些点。
如果删除再次Tarjan得到强连通分量,如果起点和终点依然在同一个强连通内则说明方案可行,并且标记当前节点下次不再处理。
因为此次处理会把所有包含删除当前点的状态都遍历到。

#include <stdio.h>
#include <bits/stdc++.h>
#define fst first
#define sed second
using namespace std;
typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int N = 110;
int n, m, st, ed;
vector<int> e[N];
int dfn[N], low[N], num, idx; //节点编号 子树能到的最小编号 强连通分量数
bool vis[N], slv[N]; //栈内节点 已处理节点
int stk[N], tot;
int ans;

void Tarjan(int x, int *blo) //结果保存在blo内
{
	dfn[x] = low[x] = ++idx;
	stk[++tot] = x, vis[x] = 1;
	for (int y : e[x])
		if (!dfn[y])
			Tarjan(y, blo), low[x] = min(low[x], low[y]);
		else if (vis[y])
			low[x] = min(low[x], low[y]);
	if (low[x] == dfn[x])
	{
		int y;
		++num;
		do 
		{
			y = stk[tot--], vis[y] = 0;
			blo[y] = num;
		} while (y != x);
	}
}
void solve(int del) //删除了del节点后
{
	int blo[N]; //强连通最小编号 每层独立
	num = idx = 0;
	memset(dfn, 0, sizeof(dfn));
	memset(low, 0, sizeof(low));
	Tarjan(st, blo); //从起点开始得到强连通分量
	if (blo[st] != blo[ed]) //起点终点不是强连通则无法过去再返回
		return ;
	slv[del] = 1; //删除当前节点后依然满足则标记以后不再处理 因为接下来的递归会把包含删除当前节点的所有状态全部处理到
	int cnt = 0; //和起点在同一强连通内的点数
	for (int i = 1; i <= n; ++i)
		if (blo[i] == blo[st])
			++cnt;
	ans = min(ans, cnt);
	for (int i = 1; i <= n; ++i) //尝试删除每个点并递归处理
		if (i != st && i != ed && !slv[i]) //不删除起点终点
		{
			vector<int> cp = e[i]; //拷贝当前节点的边
			e[i].clear(); //并删除
			solve(i); //递归处理
			e[i] = cp; //还原
		}
}
int main()
{
#ifdef LOCAL
	freopen("C:/input.txt", "r", stdin);
#endif
	int T;
	cin >> T;
	while (T--)
	{
		cin >> n >> m >> st >> ed;
		for (int i = 1; i <= n; ++i)
			e[i].clear();
		for (int i = 0; i < m; ++i)
		{
			int u, v;
			scanf("%d%d", &u, &v);
			e[u].push_back(v);
		}
		ans = INF;
		memset(slv, 0, sizeof(slv));
		solve(0);
		cout << ans - 2 << endl; //减去起点终点
	}

	return 0;
}
河南省第十一届ACM程序设计大赛榜单 河南省第十一届ACM程序设计竞赛榜单 河南省第十一届ACM程序设计竞赛榜单 河南省第十一届ACM程序设计竞赛榜单 立即下载

相关推荐

ACM程序设计大赛试题及解析

ACM竞赛的经典试题及解析,从经典中领悟编程的方法技巧,领悟编程的精华...

河南省 第十一届 ACM 省赛 试题

A B D F H 五道水题 都签了就是稳银A. 计划日B. 治安管理C. 山区修路D. 求Xf+闭包 E. 物流配送F.Gene mutationG. CheckpointsH. Attack City and Capture TerrioryI. Image Recognition    J.Jigsaw Puzzle...

Zeolim的博客 3978

历年acm程序设计试题与解答.rar

历年acm程序设计试题与解答

河南省第十一届ACM大学生程序设计竞赛题目

河南省第十一届ACM大学生程序设计竞赛题目 A、计划日 B、治安管理 C、山区修路 E、物流配送 F、Gene mutation G、Checkpoints H、Attack City Capture Territory I、Image Recognition J、Jigsaw Puzzle PS:D题缺失 ...

职业炮灰的博客 7760

SAP COPA实战:手把手教你用CMOD增强搞定自定义特性派生(以客户字段为例)

本文详细介绍了在SAP COPA模块中通过CMOD增强实现自定义特性派生的全流程,以客户字段为例,展示了从特性设计、SPRO配置到特性派生逻辑实现的完整步骤。重点讲解了如何利用CMOD增强技术解决业务需求,提升获利能力段分析的灵活性和准确性。

weixin_30275415的博客 434

S32K144 SDK实战:FTM输入捕获模块的配置与应用

本文详细介绍了S32K144 SDK中FTM输入捕获模块的配置与应用实践。从基础认知到开发环境搭建,再到引脚配置和中断处理技巧,全面解析了如何利用FTM模块实现高精度信号测量。特别适用于电机控制、工业测速等场景,帮助开发者快速掌握S32K144的FTM输入捕获功能。

weixin_42566424的博客 218

治安管理 - 第十一届河南省ACM省赛题解

治安管理 - 第十一届河南省ACM省赛题解 judge:第十一届河南省ACM省赛题 时间限制: 3 Sec 内存限制: 128 MB 题目描述 SZ市是中国改革开放建立的经济特区,是中国改革开放的窗口,已发展为有一定影响力的国际化城市,创造了举世瞩目的“SZ速度”。SZ市海、陆、空、铁口岸俱全,是中国拥有口岸数量最多、出入境人员最多、车流量最大的口岸城市. 为了维护SZ经济特区社会治安秩序,保障...

画船听雨眠 521

Lenovo 拯救者15ISK硬件升级实战:从内存到固态硬盘的全面优化

本文详细介绍了为联想拯救者15ISK笔记本电脑进行硬件升级的完整实战指南。通过评估升级可行性,指导如何挑选兼容的内存条与NVMe固态硬盘,并提供详细的拆机安装步骤与系统安装避坑技巧。升级后,笔记本的开机速度、软件加载及多任务处理能力获得飞跃式提升,让老旧设备重获新生。

weixin_29310631的博客 567

问题 : A. 计划日

2018年河南省省赛的第一题,这个算是一道水体。题目描述 为什么花那么多时间、精力还是学不好学不通,如何把握各科目的重难点,期中和期末如何梳理本学期各知识点及内部联系……在孩子学习的过程中,我们该如何帮助孩子快速提高成绩呢? 打造名校进阶计划,让孩子会学习、会考试,实现名校梦想! Dr.Kong, 作为一名从教多年的老师,跟踪了大量成绩好的学生,发现他们的学习习惯非常规律,有方法、有计...

dai_ma_dong的博客 358

永磁同步电机ADRC控制策略优化:从理论到Simulink仿真实践

本文深入探讨了永磁同步电机自抗扰控制(ADRC)策略的优化与实践。针对传统PID在动态响应、抗扰及噪声抑制方面的不足,详细解析了ADRC三大核心组件——跟踪微分器(TD)、扩张状态观测器(ESO)与非线性状态误差反馈(NLSEF)的工作原理。通过手把手的Simulink仿真教程,展示了从算法编写、模型搭建到参数整定的完整流程,并进阶实现了位置-速度双环ADRC协同控制,为高性能电机伺服系统设计提供了从理论到实践的清晰指南。

root9的博客 416

从零到一:RagFlow源码架构深度解析与二次开发实战指南

本文深入解析RagFlow源码架构,提供从环境搭建到二次开发的全流程实战指南。作为企业级AI搜索框架,RagFlow通过模块化设计和多模态处理能力,支持自定义智能体开发与文搜文档功能,帮助开发者高效构建智能搜索系统。

w1x2y3的博客 270

河南省第十一届acm G- Checkpoints

As a landlocked country in central and southern Africa , the political situation has been relatively stable since the implementation of multi-party elections in ZBA in 1991. But the ZBA parliament pas...

xiaozheng的博客 860

LPDDR6与LPDDR5 channel/rank/die/bank技术探讨

LPDDR6与LPDDR5 channel/rank/die/bank技术探讨

zilan23的博客 3664

第四届河南省程序设计大赛 - 部分题解

Substring 时间限制:1000 ms  |  内存限制:65535 KB 难度:1 描述 You are given a string input. You are to find the longest substring of input such that the reversal of the substring is also a substrin

Never say never 1321

Unreal从入门到精通之 UE4 vs UE5 VR性能优化实战

这篇文章分享了UE5 VR项目的性能优化经验。作者通过对比UE4和UE5的VR模板性能,发现UE5默认帧率只有45FPS,远低于UE4的100FPS。主要性能瓶颈来自Lumen全局光照、虚拟阴影贴图等新特性。文章详细列出了12项关键优化设置,包括禁用Lumen、关闭虚拟阴影、使用前向渲染等,并分析了各项调整对性能的影响程度。特别指出删除默认的VolumetricCloud可立即提升5帧。最后建议根据场景需求平衡画质与性能,对于高帧率要求的VR项目,可能需要谨慎使用UE5或关闭其部分高级渲染功能。

TxNet 1392

北斗导航 | raPPPid软件功能模块详解

raPPPid(Rapid Precise Point Positioning with integer ambiguity resolution,快速精密单点定位与整周模糊度解算)是由维也纳工业大学(TU Wien)大地测量与地理信息系开发的MATLAB开源PPP软件包。它是VieVS(Vienna VLBI and Satellite Software,维也纳VLBI与卫星软件)的PPP模块,由Marcus Franz Glaner和Robert Weber主导开发。

尘世冰封的专栏 602

河南省第九届ACM程序设计竞赛 部分题解

A 表达式求值 <逆波兰> #include <stdio.h> #include <bits/stdc++.h> #define fst first #define sed second using namespace std; typedef long long ll; const int INF = 0x3f3f3f3f; const ll LINF =...

CaprYang的博客 1327

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

河南省第三届ACM/ICPC大学生程序设计竞赛题解

河南省第三届省赛 感觉这一套题挺简单的,大部分都是模拟题,最难的就是线段树了。每题都是多组数据输入,然而题目并没有说明。 A 房间安排 区间问题,离开的那一天房间数设成负的,然后按日期进行排序,日期相同的话房间数小的放前面(先退房),循环找最大值即可。 感觉和2020河南ccpc省赛发通知差不多。 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int

海马有力量的博客 792

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

2020年河南省CCPC大学生程序设计竞赛————I.太阳爆炸

题目链接 http://acm.zzuli.edu.cn/problem.php?id=2698 思路       一个经典的概率题,n个子弹,每个子弹打中的概率为p,打死目标至少需要k枚子弹,问打中的概率是多少,在本题,p是((r1+r)∗(r1+r))/(r2∗r2)((r1+r)*(r1+r))/(r2*r2)((r1+r)∗(r1+r))/(r2∗r2),k是 (h+a−1)/a(h+a-1)/a(h+a−1)/a(实现向上取整),那么如果

洞·爺·湖的博客 583

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

“玲珑杯”郑州轻工业学院第九届ACM程序设计大赛圆满结束

“玲珑杯”郑州轻工业学院第九届ACM程序设计大赛圆满结束,玲珑OJ官网博客奉上大赛题目,以及对应题解!

lonlife_acm的博客 969

河南第十二届ICPC参赛小记

河南省第十届ICPC参赛感受 第一天中午到比赛点报道,没有午餐券差评。下午热身赛,hxw巨巨和我们说,热身赛就是试一试环境,然后我还真信了,热身赛 != 签到题 最后,未来酒店好评,奖牌尺寸好评。 ...

zhmeng 395

郑州大学“战疫杯”大学生程序设计在线邀请赛(2)(C++题解+详细思路)2022年5月10日

目录 1 公司的Logo 2 解封日期 3 语音设备是否正常? 1 公司的Logo 为了感谢河南省八六三软件有限公司对战疫杯ACM在线程序设计竞赛的大力支持,小Y决定为公司制作个logo。 logo通常要用在各种不同的场景,因此logo的尺寸必须是可变的。现给你原始的logo,以及其改变尺寸的例子,你能寻找规律并输出任意缩放后的logo图案吗? 原始logo: ### ### ### # # # # ### ### ### # # # # # ### ### ### 将

m0_61409183的博客 3048

河南省第十一届ACM总结

今天在信阳师范打完了ACM。有点遗憾,差一题拿金吧。从去年的打铁到今年的银牌,也成长了很多,也学会了很多东西,感谢我的队友带我拿银。都尽力了,有点小遗憾,但是不后悔吧。没有过多的罚时,只是在时间分配上还不是很合理。我不知道我还能不能再打一次,如果可以,希望能拿金吧。今年也出了一个新的突破题吧。是我刷往年省赛没有碰到的过。可能去年出了,但是找不到提交的地方。简单说两个题吧。H题  好像是博弈论,队友...

Evildoer_llc的博客 774

第十一届山东省大学生程序设计竞赛 K Piggy Calculator 笛卡尔树+倍增

link 题意:定义运算符号x(i), A x(i) B =(A+B)*i,i越大优先级越大,其次从左往右。,给定一个只有该符号的式子,q次询问求区间表达式的值。 题解:对符号建笛卡尔树,区间操作转化为在树上跑链的操作(要先维护前驱结点),存储一些信息后倍增就可以了。 #include<bits/stdc++.h> #define mp make_pair #define pb push_back #define SZ(x) (int)(x.size()) #define all(x) x.

qq_43914084的博客 524
上一篇: “卓见杯”第五届CCPC中国大学生程序设计竞赛河南省赛 题解
下一篇: 郑州轻工业大学“CCPC2019-河南省赛”选拔赛(2) 部分题解
CaprYang
博客等级 码龄8年 148粉丝 277原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值