省前训练...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-勿在浮沙筑高台 没有时间重新复制代码,只能一股脑的复制,所以代 ...
随机推荐
- iOS 获取联系人,并调用系统地址簿UI
1.加入 AddressBook库 推断授权状态 -(bool)checkAddressBookAuthorizationStatus { //取得授权状态 ABAuthorizationStatus ...
- 特征选择(三)-K-L变换
上一讲说到,各个特征(各个分量)对分类来说,其重要性当然是不同的. 舍去不重要的分量,这就是降维. 聚类变换觉得:重要的分量就是能让变换后类内距离小的分量. 类内距离小,意味着抱团抱得紧. 可是,抱团 ...
- SessionA和pplication网上聊天室的网络范例
login.aspx码,如以下: <%@ Page Language="C#" AutoEventWireup="true" CodeFile=" ...
- js右侧悬浮框
示例:屏幕右侧悬浮框 原理:oDiv.style.top = document.documentElement.clientHeight - oDiv.offsetHeight + scrollTop ...
- 揭秘传智播客毕业班的超级薪水7k内幕系列II----Offer工资表5.7k,为什么不能让老师就业就业
在上海传智播客宋学生Java六期学员.在班级尚未毕业阶段,私自投递简历,而且逃课去面试,获得某国企的Offer.入职薪资5.7K,,兼有五险一金.饭补等齐全福利,因就业老师要求班级同学未毕业不要急于就 ...
- UI —— 计算器
#import <UIKit/UIKit.h> @interface MyViewController :UIViewController { NSInteger _firstName; ...
- pragma once与#ifndef的作用有什么区别
#pragma once 这是一个比较常用的指令,只要在头文件的最开始加入这条指令就能够保证头文件被编译一次 #pragma once用来防止某个头文件被多次include,#ifndef,#defi ...
- 1.网络工具:ifconfig,ping,netstate,Redhat命令和图形化设置ip,finger,nslookup
1 ip ad查看网卡编号 2.ifconfig查看网卡信息 3.关闭网卡 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdG90b3R1enVvcX ...
- C# WinForm dataGridView 技巧小结
1.不显示第一个空白列RowHeaderVisible属性设置为false 2.点击cell选取整行SelectinModel属性FullRowSelectRowSelectinModel属性设置或用 ...
- HSQLDB相关信息及用法汇总
运行模式 说明 启动命令 JDBC例 内存(Memory-Only)模式 所有数据都在内存里操作.应用程序退出后则数据被销毁.无需另外启动HSQLDB Server 启动方式1:通过程序中首次调用Co ...