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的更多相关文章

  1. VK Cup 2017 - Qualification 1 C 贪心

    是一道很有趣的题目 给出地图和起始点 与要求的步数k 要求走k步 正好回到起始点 输出字典序最小的移动路径 DLRU这样 可以想到DU LR都是相同数量的 于是k必须是一个偶数 然后走了弯路QAQ 从 ...

  2. DP VK Cup 2012 Qualification Round D. Palindrome pairs

    题目地址:http://blog.csdn.net/shiyuankongbu/article/details/10004443 /* 题意:在i前面找回文子串,在i后面找回文子串相互配对,问有几对 ...

  3. VK Cup 2017 - Квалификация 1

    CF上的VK Cup 2017资格赛1,好像很水,因为只有俄文所以语言是最大的障碍--不过之后正式赛貌似就有英文了.(比赛貌似只有开俄文模式才看的到--) 时长1天,不随时间扣分.FallDream ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. VK Cup 2017 - Round 1

    和FallDream组队瞎打一通--B两个人写的都挂了233,最后只剩下FallDream写的A和我写的C,最后我yy了个E靠谱做法结果打挂了,结束之后改了改就A了,难受. AC:AC Rank:18 ...

  9. Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) 题解【ABCDE】

    A. Vicious Keyboard 题意:给你一个字符串,里面只会包含VK,这两种字符,然后你可以改变一个字符,你要求VK这个字串出现的次数最多. 题解:数据范围很小,暴力枚举改变哪个字符,然后c ...

  10. 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 ...

随机推荐

  1. vue mint-ui 三级地址联动

    我也是第一次写这种地址联动的 刚开始的时候 我还以为直接用select来写 后来公司的ios告知并不是这样的 他说应该时这样的 于是第一想法 赶紧找插件吧 但是找了一会未果  就问了公司大神 他刚开始 ...

  2. Python内置函数(52)——getattr

    英文文档: getattr(object, name[, default]) Return the value of the named attribute of object. name must ...

  3. GIT入门笔记(6)- 向版本库添加文本文件

    1.把文本文件添加到版本库? 所有的版本控制系统,其实只能跟踪文本文件的改动,比如TXT文件,网页,所有的程序代码等等,Git也不例外. 版本控制系统可以告诉你每次的改动,比如在第5行加了一个单词&q ...

  4. ios开发常识(1)开发语言和参考资料

    学iphone开发用的语言是object-c,object-c和c++,java还是有很大区别,如果你坚持学习iphone开发的话可以不学c++,java,直接学习这个语言,先入为主,可能觉得这个语言 ...

  5. python 爬取百度翻译进行中英互译

    感谢RoyFans 他的博客地址http://www.cnblogs.com/royfans/p/7417914.html import requests def py(): url = 'http: ...

  6. Linux探索之路1---CentOS入坑笔记整理

    前言 上次跟运维去行方安装行内环境,发现linux命令还是不是很熟练.特别是用户权限分配以及vi下的快捷操作.于是决定在本地安装一个CentOS虚拟机,后面有时间就每天学习一点Linux常用命令. 作 ...

  7. python Django知识点总结

    python Django知识点总结 一.Django创建项目: CMD 终端:Django_admin startproject sitename(文件名) 其他常用命令: 其他常用命令: 通过类创 ...

  8. python中文编码坑

    打印list的时候unicode对象不会自动转为中文!

  9. hive优化之——控制hive任务中的map数和reduce数

    一.    控制hive任务中的map数: 1.    通常情况下,作业会通过input的目录产生一个或者多个map任务.主要的决定因素有: input的文件总个数,input的文件大小,集群设置的文 ...

  10. springboot集成jpa

    spring data jpa简介 spring data jpa是spring基于hibernate及jpa规范封装出来的一套持久层框架.该框架极大的降低了开发者工作量,提升开发效率.提供的关键字可 ...