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 ...
随机推荐
- zookeeper安装及环境变量设置
下载 首先去官网下载(自行选择版本):http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.11/然后执行tar -zxvf解压 对于后台安装 ...
- 深度学习之 cnn 进行 CIFAR10 分类
深度学习之 cnn 进行 CIFAR10 分类 import torchvision as tv import torchvision.transforms as transforms from to ...
- VMware vCenter Server 6.5.0 U1
VMware vCenter Server 6.5.0 U1gName: VMware-VCSA-all-6.5.0-8024368.iso Release Date: 2018-03-20 Buil ...
- MySQL 主从复制那些事(一)
本部分主要以理论为主,具体的主从搭建环境,大家可以参考博客其他部分.下面我就给大家数说主从复制那些理论的东西.说的不一定都是正确的,有不同出入的地方,欢迎大家一起交流沟通,以下我把我自己整理出来的主从 ...
- Tess4J OCR简单使用教程
Tess4J简介 Tesseract-OCR支持中文识别,并且开源和提供全套的训练工具,是快速低成本开发的首选.而Tess4J则是Tesseract在Java PC上的应用.在英文和数字识别中性能还是 ...
- Object.defineProperties()和Object.defineProperty()方法
Object.defineProperty() 方法会直接在一个对象上定义一个新属性,或者修改一个对象的现有属性, 并返回这个对象. 语法:Object.defineProperty(obj, pro ...
- tomcat增加处理线程数量
修改server.xml <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" ma ...
- Docker学习(1)安装
1. Docker简介 Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化.容器是完全使用沙箱 ...
- hdu-3348 coins---贪心
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3348 题目大意: 给你一个价格,还有面值分别为1,5,10,50,100(单位:毛)纸币的数量,要你 ...
- hdu1010 Tempter of the Bone---DFS+奇偶剪枝
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1010 题目描述:根据地图,'S'为开始位置,'D'为门的位置,' . '为空地,'X'为墙,不能经过 ...