省前训练...Orz
A. 异形卵
64-bit integer IO format: Java class name:
我们探索宇宙,是想了解浩瀚星空的奥妙,但我们却很少意识到宇宙深处藏匿的危险,它们无时无刻不紧盯着我们的地球。如果外星人拜访我们,结果可能与哥伦布当年踏足美洲大陆不会有什么两样,这是历史,也是现实。
在ZDM-777星球上发现的休眠异形卵,其外表与常见的卵不同,表面被一层石墨覆盖。当人走近时,那层石墨开始消融,能看到里面的异形卵正在活动,异形卵是活物,具备一些热量或压力传感器这些基本的中枢神经系统,通过感知周围的热量,选择热量最大处寄生。不过,假如周围有不适合被寄生处,异形卵就选择休眠。
周围的热量可以用一串整数a1,a2,……,an来表示,异形卵具有一定的长度L,异形卵总是选择ai+ai+1+…+ai+L-1达到最大值处寄生。若周围的热量低于0,异形卵则选择休眠。
异形卵是如何感知它的寄生处呢?我们探索宇宙,是想了解浩瀚星空的奥妙,但我们却很少意识到宇宙深处藏匿的危险,它们无时无刻不紧盯着我们的地球。如果外星人拜访我们,结果可能与哥伦布当年踏足美洲大陆不会有什么两样,这是历史,也是现实。
在ZDM-777星球上发现的休眠异形卵,其外表与常见的卵不同,表面被一层石墨覆盖。当人走近时,那层石墨开始消融,能看到里面的异形卵正在活动,异形卵是活物,具备一些热量或压力传感器这些基本的中枢神经系统,通过感知周围的热量,选择热量最大处寄生。不过,假如周围有不适合被寄生处,异形卵就选择休眠。
周围的热量可以用一串整数a1,a2,……,an来表示,异形卵具有一定的长度L,异形卵总是选择ai+ai+1+…+ai+L-1达到最大值处寄生。若周围的热量低于0,异形卵则选择休眠。
异形卵是如何感知它的寄生处呢?
Input
接下来对每组测试数据有2行,第1行: L N
第2行:a1 a2 …… aN
【约束条件】
2≤K≤5 L≤N, 1≤L≤10 1≤N≤1000 -100≤ ai≤100
数据之间有一个空格。
Output
Sample Input
2
3 5
30 0 100 -30 100
3 5
-100 80 -80 -100 80
Sample Output
3
0
代码:
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <iostream>
using namespace std;
#define for0(i, n) for(int i=0; i<(n); ++i)
#define for1(i,a,n) for(int i=(a);i<=(n);++i)
#define for2(i,a,n) for(int i=(a);i<(n);++i)
#define for3(i,a,n) for(int i=(a);i>=(n);--i)
#define for4(i,a,n) for(int i=(a);i>(n);--i)
#define CC(i,a) memset(i,a,sizeof(i))
#define ll long long
#define MOD 1000000007
#define inf 0x3f3f3f3f int a[]; int main()
{
int l,n,i,j,k;
scanf("%d",&k);
while(k--){
int x;
int sum=-;
scanf("%d%d",&l,&n);
for(i=; i<n; i++)
scanf("%d",&a[i]);
for(i=; i<=n-l; i++){
int p=;
for(j=; j<l; j++){
p+=a[i+j];
}
if(p>sum){
sum=p;
x=i;
}
}
if(sum!=-)
printf("%d\n",x+);
else
printf("0\n");
}
}
G. 摘枇杷
64-bit integer IO format: Java class name:
理工学院的枇杷快熟了,ok,大家都懂得。而且大家都知道,学校的枇杷树都是一列一列的。现在小Y同学已经在筹划怎么摘枇杷了。现在我们假设有一列枇杷树,而且每棵枇杷树上枇杷果的数量小Y都已经知道了。
假设现在有n棵枇杷树,小Y可以把这n棵枇杷树分成m组,每组枇杷果的数量是这组内每棵枇杷树上枇杷果数量的和。注意,每组的枇杷树必须是连续的。(每组最少1棵树,最多n棵树)。小Y把枇杷往寝室拿的时候是一组一组拿的,所花费的力气等于这m组中枇杷果最多的那组枇杷果的数量。现在小Y想花尽量少的力气把这些枇杷果拿回寝室。
Input
每组测试数据第一行有两个数n(n <= 1000)和m(1 <=m <= n)
第二行有n个数,分别代表每颗树上枇杷果的数量
Output
Sample Input
3 2
1 2 3
7 5
1 4 3 1 5 2 4
Sample Output
3
5
代码:
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <iostream>
using namespace std;
#define for0(i, n) for(int i=0; i<(n); ++i)
#define for1(i,a,n) for(int i=(a);i<=(n);++i)
#define for2(i,a,n) for(int i=(a);i<(n);++i)
#define for3(i,a,n) for(int i=(a);i>=(n);--i)
#define for4(i,a,n) for(int i=(a);i>(n);--i)
#define CC(i,a) memset(i,a,sizeof(i))
#define ll long long
#define MOD 1000000007
#define inf 0x3f3f3f3f int a[];
int n,m,maxx,sum; bool pd(int x)
{
int s=,ans=;
for(int i=; i<n; i++){
if(a[i]>x)
return false;
if(s+a[i]>x){
ans++;
s=a[i];
if(ans>m-)
return false;
}
else
s+=a[i];
}
return true;
} int get()
{
int l,r,mid;
l=maxx,r=sum;
while(l<=r){
mid=(l+r)/;
if(pd(mid))
r=mid-;
else
l=mid+;
}
return l;
} int main()
{
while(~scanf("%d%d",&n,&m)){
maxx=,sum=;
for(int i=; i<n; i++){
scanf("%d",&a[i]);
sum+=a[i];
maxx=max(maxx,a[i]);
}
printf("%d\n",get());
}
return ;
}
E. CardTrick
64-bit integer IO format: Java class name:
The magician shuffles a smallpack of cards, holds it face down and performs the following procedure:
- The top card is moved to the bottom of the pack. The new top card is dealt face up onto the table. It is the Ace of Spades.
- Two cards are moved one at a time from the top to the bottom. The next card is dealt face up onto the table. It is the Two of Spades.
- Three cards are moved one at a time…
- This goes on until the nth and last card turns out to be the n of Spades.
This impressive trick works ifthe magician knows how to arrange the cards beforehand (and knows how to give afalse shuffle). Your program has to determine the initial order of the cardsfor a given number of cards, 1 ≤ n ≤ 13.
Input
Output
Sample Input
2
4
5
Sample Output
2 1 4 3
3 1 4 5 2
代码:
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iostream>
using namespace std;
#define for0(i, n) for(int i=0; i<(n); ++i)
#define for1(i,a,n) for(int i=(a);i<=(n);++i)
#define for2(i,a,n) for(int i=(a);i<(n);++i)
#define for3(i,a,n) for(int i=(a);i>=(n);--i)
#define for4(i,a,n) for(int i=(a);i>(n);--i)
#define CC(i,a) memset(i,a,sizeof(i))
#define ll long long
#define MOD 1000000007
#define inf 0x3f3f3f3f int a[]; int main()
{
int n,m;
queue<int> q;
scanf("%d",&n);
while(n--){
scanf("%d",&m);
for(int i=; i<m; i++){
q.push(i);
}
int num=;
while(!q.empty()){
for(int i=; i<num; i++){
int x=q.front();
q.pop();
q.push(x);
}
int y=q.front();
q.pop();
a[y]=num++;
}
printf("%d",a[]);
for(int i=; i<m; i++)
printf(" %d",a[i]);
printf("\n");
}
return ;
}
A. 走迷宫
64-bit integer IO format: Java class name:
这个迷宫可以向上走,向下走,向右走,向左走,但是不能穿越对角线。走迷宫的取胜规则很有意思,看谁能更快地找到一条路径,其路径上单元格最大难度值与最小难度值之差是最小的。当然了,或许这样的路径不是最短路径。
机器人卡多现在在迷宫的左上角(第一行,第一列)而出口在迷宫的右下角(第N行,第N列)。
卡多很聪明,很快就找到了这样的一条路径。你能找到吗?
Input
第一行: N 表示迷宫是N*N方阵 (2≤ N≤ 100)
接下来有N行, 每一行包含N个整数,用来表示每个单元格中难度 (0≤任意难度≤120)。
Output
Sample Input
5
1 1 3 6 8
1 2 2 5 5
4 4 0 3 3
8 0 2 3 4
4 3 0 2 1
Sample Output
2
代码:
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iostream>
using namespace std;
#define for0(i, n) for(int i=0; i<(n); ++i)
#define for1(i,a,n) for(int i=(a);i<=(n);++i)
#define for2(i,a,n) for(int i=(a);i<(n);++i)
#define for3(i,a,n) for(int i=(a);i>=(n);--i)
#define for4(i,a,n) for(int i=(a);i>(n);--i)
#define CC(i,a) memset(i,a,sizeof(i))
#define LL long long
#define MOD 1000000007
#define inf 0x3f3f3f3f int mp[][],vis[][];
int dx[]={,,-,};
int dy[]={,-,,};
int n,l,r; int dfs(int x,int y,int l,int r)
{
int px,py;
if(x>n || y>n || x< || y<) return ;
if(mp[x][y]<l || mp[x][y]>r) return ;
if(vis[x][y]) return ;
if(x==n && y==n) return ;
vis[x][y]=;
for(int i=; i<; i++){
px=x+dx[i];
py=y+dy[i];
if(dfs(px,py,l,r))
return ;
}
return ;
} bool pd(int x)
{
for(int i=; i<=(-x); i++){
memset(vis,,sizeof(vis));
if(dfs(,,i,i+x))
return true;
}
return false;
} int main()
{
while(~scanf("%d",&n)){
for(int i=; i<=n; i++)
for(int j=; j<=n; j++)
cin>>mp[i][j];
l=abs(mp[n][n]-mp[][]);
//printf("%d\n",l);
r=;
while(l<r){
int mid=(l+r)/;
if(pd(mid))
r=mid;
else
l=mid+;
//printf("%d\n",l);
//printf("%d\n",r);
}
printf("%d\n",l);
}
}
D. Substring
64-bit integer IO format: Java class name:
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 substring of input. In case of a tie, return the string that occurs earliest in input.
Note well: The substring and its reversal may overlap partially or completely. The entire original string is itself a valid substring . The best we can do is find a one character substring, so we implement the tie-breaker rule of taking the earliest one first.
Input
Output
Sample Input
3
ABCABA
XYZ
XCVCX
Sample Output
ABA
X
XCVCX
代码:
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iostream>
using namespace std;
#define for0(i, n) for(int i=0; i<(n); ++i)
#define for1(i,a,n) for(int i=(a);i<=(n);++i)
#define for2(i,a,n) for(int i=(a);i<(n);++i)
#define for3(i,a,n) for(int i=(a);i>=(n);--i)
#define for4(i,a,n) for(int i=(a);i>(n);--i)
#define CC(i,a) memset(i,a,sizeof(i))
#define LL long long
#define MOD 1000000007
#define inf 0x3f3f3f3f int dp[][];
char x[],y[]; int main()
{
int t;
scanf("%d",&t);
while(t--){
int maxx=,path=;
memset(dp,,sizeof(dp));
scanf("%s",x);
int len=strlen(x);
int k=len-;
for(int i=; i<len&&k>=; i++)
y[i]=x[k--];
y[len]='\0';
for(int i=; i<len; i++)
for(int j=; j<len; j++){
if(x[i]==y[j])
dp[i+][j+]=dp[i][j]+;
if(dp[i+][j+]>maxx){
maxx=dp[i+][j+];
path=i;
}
}
for(int i=path-maxx+; i<=path; i++){
printf("%c",x[i]);
}
printf("\n");
}
}
E. BOBSLEDDING
64-bit integer IO format: Java class name:
Dr.Kong has entered a bobsled competition because he hopes his hefty weight will give his an advantage over the L meter course (2 <= L<= 1000). Dr.Kong will push off the starting line at 1 meter per second, but his speed can change while he rides along the course. Near the middle of every meter Bessie travels, he can change his speed either by using gravity to accelerate by one meter per second or by braking to stay at the same speed or decrease his speed by one meter per second.
Naturally, Dr.Kong must negotiate N (1 <= N <= 500) turns on the way down the hill. Turn i is located T_i meters from the course start (1 <= T_i <= L-1), and he must be enter the corner meter at a peed of at most S_i meters per second (1 <= S_i <= 1000). Dr.Kong can cross the finish line at any speed he likes.
Help Dr.Kong learn the fastest speed he can attain without exceeding the speed limits on the turns.
Consider this course with the meter markers as integers and the turn speed limits in brackets (e.g., '[3]'):
0 1 2 3 4 5 6 7[3] 8 9 10 11[1] 12 13[8] 14
(Start) |------------------------------------------------------------------------| (Finish)
Below is a chart of Dr.Kong 's speeds at the beginning of each meter length of the course:
Max: [3] [1] [8]
Mtrs: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Spd: 1 2 3 4 5 5 4 3 4 3 2 1 2 3 4
His maximum speed was 5 near the beginning of meter 4.
Input
Line 1: Two space-separated integers: L and N
Lines 2..N+1: Line i+1 describes turn i with two space-separated integers: T_i and S_i
Output
Sample Input
14 3
7 3
11 1
13 8
Sample Output
5
代码:
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iostream>
using namespace std;
#define for0(i, n) for(int i=0; i<(n); ++i)
#define for1(i,a,n) for(int i=(a);i<=(n);++i)
#define for2(i,a,n) for(int i=(a);i<(n);++i)
#define for3(i,a,n) for(int i=(a);i>=(n);--i)
#define for4(i,a,n) for(int i=(a);i>(n);--i)
#define CC(i,a) memset(i,a,sizeof(i))
#define LL long long
#define MOD 1000000007
#define inf 0x3f3f3f3f int ao[]; int main()
{
int l,n,x,y;
while(~scanf("%d%d",&l,&n)){
memset(ao,,sizeof(ao));
int p,sd;
for(int i=; i<n; i++){
scanf("%d%d",&x,&y);
ao[x]=y;
}
sd=,p=;
for(int i=; i<=l; i++){
if(ao[i]==)
ao[i]=sd;
else{
if(ao[i]>ao[i-])
ao[i]=ao[i-]+;
else{
p=i;
while(ao[p-]-ao[p]>){
ao[p-]=ao[p]+;
p--;
}
}
}
sd=ao[i]+;
}
int maxx=;
for(int i=; i<=l; i++)
maxx=max(maxx,ao[i]);
printf("%d\n",maxx);
}
}
省前训练...Orz的更多相关文章
- NOI前训练日记
向别人学习一波,记点流水帐.17.5.29开坑. 5.29 早晨看了道据说是树状数组优化DP的题(hdu5542),然后脑补了一个复杂度500^3的meet in the middle.然后死T... ...
- 谈谈模型融合之一 —— 集成学习与 AdaBoost
前言 前面的文章中介绍了决策树以及其它一些算法,但是,会发现,有时候使用使用这些算法并不能达到特别好的效果.于是乎就有了集成学习(Ensemble Learning),通过构建多个学习器一起结合来完成 ...
- 转自 z55250825 的几篇关于FFT的博文(一)
关于FFT,咱们都会迫不及待地 @ .....(大雾)(貌似被玩坏了...) .....0.0学习FFT前先orz FFT君. 首先先是更详细的链接(手写版题解点赞0v ...
- 使用CNN(convolutional neural nets)关键的一点是检测到的面部教程(四):学习率,学习潜能,dropout
第七部分 让 学习率 和 学习潜能 随时间的变化 光训练就花了一个小时的时间.等结果并非一个令人心情愉快的事情.这一部分.我们将讨论将两个技巧结合让网络训练的更快! 直觉上的解决的方法是,開始训练时取 ...
- 谷歌开发者:看可口可乐公司是怎么玩转TensorFlow的?
在这篇客座文章中,可口可乐公司的 Patrick Brandt 将向我们介绍他们如何使用 AI 和 TensorFlow 实现无缝式购买凭证. 可口可乐的核心忠诚度计划于 2006 年以 MyCoke ...
- TensorFlow从1到2(九)迁移学习
迁移学习基本概念 迁移学习是这两年比较火的一个话题,主要原因是在当前的机器学习中,样本数据的获取是成本最高的一块.而迁移学习可以有效的把原有的学习经验(对于模型就是模型本身及其训练好的权重值)带入到新 ...
- Paper | 量化CV任务的关联性,寻找最佳迁移策略(Taskonomy)
目录 1. 问题 2. 方法 3. 实验设计 3.1. 解决词典内部(一组已知)任务的能力 3.2. 解决新任务(少量标记数据)的能力 4. 讨论和启发 论文:Taskonomy: Disentang ...
- Generative Adversarial Nets[Wasserstein GAN]
本文来自<Wasserstein GAN>,时间线为2017年1月,本文可以算得上是GAN发展的一个里程碑文献了,其解决了以往GAN训练困难,结果不稳定等问题. 1 引言 本文主要思考的是 ...
- ORB原理与源码解析
转载: http://blog.csdn.net/luoshixian099/article/details/48523267 CSDN-勿在浮沙筑高台 没有时间重新复制代码,只能一股脑的复制,所以代 ...
随机推荐
- Unity UGUI——开源
开源许可证:MIT/X11 来源托管网站:BitBucket
- Cocos-2dx-Lua中使用Luaj的完整示例(转)
如何使用Luaj进行java与Lua之间的交互调用 一.主要分为两个大步骤,Lua工程的修改,android工程的修改 二.工程环境 开发工具:Cocos-Code-IDE Lua版本 : Lua 5 ...
- AutoFac使用方法总结:Part II
事件 AutoFac支持三种事件:OnActivating,OnActivated,OnRelease.OnActivating在注册组件使用之前会被调用,此时可以替换实现类或者进行一些其他的初始化工 ...
- .c和.h档
可一再声明,但不是很多定义 对于一个项目,我们应该要非常好的处理众多的.c和.h文件 1.通过头文件调用库功能:#include <stdio.h> 在非常多场合,源码不便(或 ...
- Android 屏幕实现水龙头事件
在android下,事件的发生是在监听器下进行,android系统能够响应按键事件和触摸屏事件.事件说明例如以下: onClick(View v)一个普通的点击button事件 boolean onK ...
- 单选框和下拉框的jquery操作
单选框 <input type="radio" name="rdSendType" value="email" checked=&qu ...
- 1159 Palindrome(最小插入回文串)
标题效果 定的字符串长度的串和内容.中的字符可以在任何位置被插入.它至少需要为数字,这使得编程回文串串. 回文序列从左至右,从右到左和读取相同. 例如. aaaacbbbb它是一个回文串 aaab前面 ...
- java学习笔记2015-6-6
类与对象 (概念型 Demo演示) 面向对象 java C++ 包裹 承受 多态 分类 物 面向过程 C 结构体 1.获取用户输入 2.逻辑推断 ...
- earlysuspend调用过程
1. 电源管理的状态 Android的Linux内核为系统提供了4种电源状态,内核的源码为当中的3种定义了名字和相应的宏定义,名字定义在kernel/power/suspend.c中: constch ...
- 认识node.js:express(一)
express是node.js官方推荐的框架. 安装 npm install express -g 命令中的 “-g” 表示全局(global) 由于新版本(4.x.x)的express的命令集中到了 ...