VK-Cup 2017 qualification 1
VK-Cup,cf里面只有切成俄文才能看到,题目也都是俄文的(百度翻译成英文和中文).
两人组队参赛的,赛期1天,乐多赛赛制(和时间基本无关,交上去挂了扣分)。这次是第一场资格赛。
这次又和ditoly大佬组队啦,队名不知道该叫什么,因为我们真的菜,就取了个名字叫vegetable chicken(菜鸡)
但是题目不会很难,所以都一次过了(真的舒服)
-----------------------------------我是分割线
A.Год поступления в университет(我也不知道是什么啊,我也很绝望啊)
题意:有一个人参加了n(n<=5)个兴趣小组,然后它的入学年份和参加年份差距不会超过x(这东西不告诉你),求入学年份。
做题情况:根本看不懂题意,去问了学长才知道。
题解:最大值加最小值除2
ditoly的代码真的风骚
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int n,x,a=,b=;
for(cin>>n;n--;)cin>>x,a=max(a,x),b=min(b,x);
cout<<((a+b)>>);
}
B. Новость о зачёте(我要是知道这个是什么,我还会这么绝望吗?)
题意:有n个人,第一个人知道了一条消息,每个人最多发送ai条消息,你要让所有人都知道这个消息,求一个方案即可。
题解:贪心一下,每次发给能发最多消息的人。
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<map>
#define MAXN 600000
using namespace std;
inline int read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-') f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-''; ch=getchar();}
return x*f;
}
int a[],n,cnt=;
int ans[][];
struct node{
int a,num;
friend bool operator< (node x,node y)
{
return x.a<y.a;
}
};
queue<int> q;
priority_queue<node> q2; int main()
{
n=read();for(int i=;i<=n;i++)a[i]=read();
for(int i=;i<=a[];i++)q.push();
for(int i=;i<=n;i++)q2.push((node){a[i],i});
while(!q.empty()&&n>)
{
int u=q.front();q.pop();
node v=q2.top();q2.pop();
ans[][++cnt]=u;ans[][cnt]=v.num;
for(int i=;i<=v.a;i++)q.push(v.num);
n--;
}
if(n!=) return *puts("-1");printf("%d\n",cnt);
for(int i=;i<=cnt;i++) printf("%d %d\n",ans[][i],ans[][i]);
return ;
}
C.Цикл в лабиринте(警察叔叔,就是它让我绝望的!)
题意:有一张网格图,有一些点是障碍,有一个机器人在某一个点,每次可以上下左右走,要走k次之后回到起点,求一个字典序最小(D,L,R,U)的方案6
n,m<=1000,k<=10^6
题解:bfs一下每个点到起点的最短距离,每次按字典序搜,能走就走。
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<map>
using namespace std;
inline int read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-') f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-''; ch=getchar();}
return x*f;
}
int n,m,x=,y=,k;
char s[][];
int d[][];
char ans[];
struct node{
int x,y;
}newx;
queue<node> q;
const int dis[][]={{,},{-,},{,},{,-}}; void bfs()
{
q.push((node){x,y});d[x][y]=;
while(!q.empty())
{
newx=q.front();q.pop();
for(int i=;i<;i++)
{
int xx=newx.x+dis[i][];
int yy=newx.y+dis[i][];
if(xx<||yy<||xx>n||yy>m||d[xx][yy]||s[xx][yy]=='*') continue;
d[xx][yy]=d[newx.x][newx.y]+;
q.push((node){xx,yy});
}
}
} int main()
{
n=read();m=read();k=read();
for(int i=;i<=n;i++)scanf("%s",s[i]+);
for(int i=;i<=n&&!x;i++)
for(int j=;j<=m&&!x;j++)
if(s[i][j]=='X')
{x=i;y=j;s[i][j]='.';}
bfs();
for(int i=;i<=k;i++)
{
if(x<n&&s[x+][y]=='.'&&d[x+][y]<=k-i+){ans[i]='D';++x;continue;}
if(y>&&s[x][y-]=='.'&&d[x][y-]<=k-i+){ans[i]='L';--y;continue;}
if(y<m&&s[x][y+]=='.'&&d[x][y+]<=k-i+){ans[i]='R';++y;continue;}
if(x>&&s[x-][y]=='.'&&d[x-][y]<=k-i+){ans[i]='U';--x;continue;}
return *puts("IMPOSSIBLE");
}
for(int i=;i<=k;i++)printf("%c",ans[i]);
return ;
}
D.
给定n个数和k,求有多少对(x,y)满足x<y且第x个数和第y个数二进制下有k位不同。n<=200000,k<=14,ai<=10000
题解:搜索出所有k位的二进制数,最多3500左右,然后枚举ai判断。
复杂度2^14+10000*3500
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<map>
#define ll long long
using namespace std;
inline int read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-') f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-''; ch=getchar();}
return x*f;
} int a[];
int s[];
int num[];
ll ans=;
int n,k,cnt=; void dfs(int i,int j,int x)
{
if(i==){if(j==k)s[++cnt]=x;return;}
dfs(i+,j,x);
dfs(i+,j+,x|a[i]);
} int main()
{
a[]=;for(int i=;i<=;i++)a[i]=a[i-]<<;
n=read();k=read();
dfs(,,);
for(int i=;i<=n;i++){int x=read();num[x]++;}
for(int i=;i<=;i++)if(num[i])
for(int j=;j<=cnt;j++)
{int x=i^s[j];if(x>)continue;
if(k!=) ans+=1LL*num[i]*num[x];
else ans+=1LL*num[i]*(num[i]-);
}
cout<<(ans>>);
return ;
}
VK-Cup 2017 qualification 1的更多相关文章
- VK Cup 2017 - Qualification 1 C 贪心
是一道很有趣的题目 给出地图和起始点 与要求的步数k 要求走k步 正好回到起始点 输出字典序最小的移动路径 DLRU这样 可以想到DU LR都是相同数量的 于是k必须是一个偶数 然后走了弯路QAQ 从 ...
- DP VK Cup 2012 Qualification Round D. Palindrome pairs
题目地址:http://blog.csdn.net/shiyuankongbu/article/details/10004443 /* 题意:在i前面找回文子串,在i后面找回文子串相互配对,问有几对 ...
- VK Cup 2017 - Квалификация 1
CF上的VK Cup 2017资格赛1,好像很水,因为只有俄文所以语言是最大的障碍--不过之后正式赛貌似就有英文了.(比赛貌似只有开俄文模式才看的到--) 时长1天,不随时间扣分.FallDream ...
- Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) 菜鸡只会ABC!
Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) 全场题解 菜鸡只会A+B+C,呈上题解: A. Bear and ...
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3)(A.B.C,3道暴力题,C可二分求解)
A. Is it rated? time limit per test:2 seconds memory limit per test:256 megabytes input:standard inp ...
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) A B C D 水 模拟 二分 贪心
A. Is it rated? time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2)(A.思维题,B.思维题)
A. Vicious Keyboard time limit per test:2 seconds memory limit per test:256 megabytes input:standard ...
- VK Cup 2017 - Round 1
和FallDream组队瞎打一通--B两个人写的都挂了233,最后只剩下FallDream写的A和我写的C,最后我yy了个E靠谱做法结果打挂了,结束之后改了改就A了,难受. AC:AC Rank:18 ...
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) 题解【ABCDE】
A. Vicious Keyboard 题意:给你一个字符串,里面只会包含VK,这两种字符,然后你可以改变一个字符,你要求VK这个字串出现的次数最多. 题解:数据范围很小,暴力枚举改变哪个字符,然后c ...
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) A B C D 暴力 水 二分 几何
A. Vicious Keyboard time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
随机推荐
- jvm垃圾收集器总结jdk1.7
内存 ● 线程私有:程序计数器,虚拟机栈,本地方法栈 ● 线程共享: 方法区,堆 判断存活算法 ● 引用计数法:无法解决循环引用问题. ● 可达性分析算法: 从GCRoot作为起始点,向下搜索,经过的 ...
- nyoj 擅长排列的小名II
擅长排列的小明 II 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 小明十分聪明,而且十分擅长排列计算. 有一天小明心血来潮想考考你,他给了你一个 ...
- python之路--day13-模块
1,什么是模块 模块就是系统功能的集合体,在python中,一个py文件就是一个模块, 例如:module.py 其中module叫做模块名 2,使用模块 2.1 import导入模块 首次带入模块发 ...
- AngularJS1.X学习笔记7-过滤器
最近参加笔试被虐成狗了,感觉自己的算法太弱了.但是还是先花点事件将这个AngularJS学习完.今天学习filter 一.内置过滤器 (1)过滤单个数据值 <!DOCTYPE html> ...
- GIT的安装及命令使用
http://blog.jobbole.com/78960/ 因此:多人协作工作模式一般是这样的: 首先,可以试图用git push origin branch-name推送自己的修改. 如果推送失败 ...
- SpringCloud的Archaius - 动态管理属性配置
参考链接:http://www.th7.cn/Program/java/201608/919853.shtml 一.Archaius是什么? Archaius用于动态管理属性配置文件. 参考自Gett ...
- python网络编程基础(一)
一.C/S架构 客户端/服务端架构 二.OSI七层架构 七层模型,亦称OSI(Open System Interconnection)参考模型,是参考模型是国际标准化组织(ISO)制定的一个用于计算机 ...
- Help Jimmy ~poj-1661 基础DP
Help Jimmy" 是在下图所示的场景上完成的游戏. 场景中包括多个长度和高度各不相同的平台.地面是最低的平台,高度为零,长度无限. Jimmy老鼠在时刻0从高于所有平台的某处开始下落, ...
- ehcache.xml 属性大全
属性大全 name:缓存名称. maxElementsInMemory:缓存最大个数. eternal:对象是否永久有效,一但设置了,timeout将不起作用. timeToIdleSeconds:设 ...
- MyBatis(二):Select语句传递参数的集中方案
从别人说的方案中看出,传递参数方案还挺多,不如自己整理下,以便以后使用过程中有个笔记回忆录. 1.传递一个参数的用法: 配置文件 <select id="getById" r ...