20191028 Codeforces Round #534 (Div. 1) - Virtual Participation
菜是原罪。
英语不好更是原罪。
\(\mathrm{A - Grid game}\)
题解
\(4 \times 4\) 的格子,两种放法。
发现这两种在一起时候很讨厌,于是强行拆分这个格子
上面 \(2 \times 4\) 给横的,下面给竖的。
\(\mathrm{Code}\)
#include<bits/stdc++.h>
using namespace std;
template <typename Tp>
void read(Tp &x){
x=0;char ch=1;int fh;
while(ch!='-'&&(ch>'9'||ch<'0')) ch=getchar();
if(ch=='-') ch=getchar(),fh=-1;
else fh=1;
while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
x*=fh;
}
int n;
char s[1007];
int a[8][8];
void del(){
for(int i=1;i<=4;i++){
int sum=0;
for(int j=1;j<=4;j++){
sum+=a[i][j];
}
if(sum==4){
for(int j=1;j<=4;j++) a[i][j]=0;
}
}
}
int ex1[3][3],ex2[3][3];
void solve(int x){
if(x==1){
if(!ex1[1][1]){
printf("%d %d\n",1,1);
ex1[1][1]=1;
}
else if(!ex1[1][2]){
printf("%d %d\n",1,3);
ex1[1][2]=1;
}
else if(!ex1[2][1]){
printf("%d %d\n",2,1);
ex1[2][1]=1;
}
else if(!ex1[2][2]){
printf("%d %d\n",2,3);
ex1[2][2]=1;
}
if(ex1[1][1]&&ex1[1][2]) ex1[1][1]=ex1[1][2]=0;
if(ex1[2][1]&&ex1[2][2]) ex1[2][1]=ex1[2][2]=0;
}
else{
if(!ex2[1][1]){
printf("%d %d\n",3,1);
ex2[1][1]=1;
}
else if(!ex2[1][2]){
printf("%d %d\n",3,2);
ex2[1][2]=1;
}
else if(!ex2[2][1]){
printf("%d %d\n",3,3);
ex2[2][1]=1;
}
else if(!ex2[2][2]){
printf("%d %d\n",3,4);
ex2[2][2]=1;
}
if(ex2[1][1]&&ex2[1][2]&&ex2[2][1]&&ex2[2][2]) ex2[1][1]=ex2[1][2]=ex2[2][1]=ex2[2][2]=0000;
// if(ex1[1][1]&&ex1[1][2]) ex1[1][1]=ex1[1][2]=0;
// if(ex1[2][1]&&ex1[2][2]) ex1[2][1]=ex1[2][2]=0;
}
}
int main(){
cin>>(s+1);
n=strlen(s+1);memset(a,1,sizeof(a));
for(int i=1;i<=4;i++) for(int j=1;j<=4;j++) a[i][j]=0;
for(int qwq=1;qwq<=n;qwq++){
int k=s[qwq]-'0';
solve(k);
}
return 0;
}
\(\mathrm{B - Game with modulo}\)
题解
真是一个神仙交互题。
首先需要想到一个结论,函数 \(f(x)=x \bmod a\) 是一个周期函数, \(T=a\) 。
这个题目一开始的想法就是二分,但是由于 \(a\) 取模的问题,不太满足可二分性。
但是在一个周期内,是可以二分的。
于是倍增确定 \(a\) 的取值范围,二分答案。
\(60\) 次询问卡的紧紧的...
cyz同学问了 \(61\) 次...
\(\mathrm{Code}\)
#include<bits/stdc++.h>
using namespace std;
template <typename Tp>
void read(Tp &x){
x=0;char ch=1;int fh;
while(ch!='-'&&(ch>'9'||ch<'0')) ch=getchar();
if(ch=='-') ch=getchar(),fh=-1;
else fh=1;
while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
x*=fh;
}
string s;
int main(){
while(1){
cin>>s;
if(s=="end") break;
if(s=="mistake") break;
int l=0,r=1;
while(1){
printf("? %d %d\n",l,r);
fflush(stdout);
cin>>s;
if(s=="y") l=r,r*=2;
else break;
}
int ans;
while(l<r-1){
int mid=(l+r)>>1;
printf("? %d %d\n",mid,l);
fflush(stdout);
cin>>s;
if(s=="x") l=mid;
else r=mid;
}
++l;
printf("! %d\n",l);
fflush(stdout);
}
return 0;
}
\(\mathrm{C - Johnny Solving}\)
题解
首先 STO hkk。
hkk:由于这个和环有关,所以可以想到生成树。
随便画个生成树,可以得到如果有深度超过 \(\frac{n}{k}\) 的点,则肯定有成立的路径。
否则叶子结点一定超过 \(k\) 个。
又有每个点的度超过 \(3\) ,则在 \(dfs\) 树上至少有两条返祖边,构成 \(3\) 个环,且至少有一个长度不是 \(3\) 的倍数。
于是构建出 \(dfs\) 树,搞一搞即可。
xxxxx
即得易见平凡,由上自证显然,留作习题答案略,读者自证不难。
反之亦然同理,推论自然成立,略去过程Q.E.D,由上可知证毕。
xxxxx
\(\mathrm{Code}\)
#include<bits/stdc++.h>
using namespace std;
template <typename Tp>
void read(Tp &x){
x=0;char ch=1;int fh;
while(ch!='-'&&(ch>'9'||ch<'0')) ch=getchar();
if(ch=='-') ch=getchar(),fh=-1;
else fh=1;
while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
x*=fh;
}
const int maxn=250007;
int n,m,k;
int lim;
int Head[maxn],Next[1000007],to[1000007],tot=1;
void add(int x,int y){
to[++tot]=y,Next[tot]=Head[x],Head[x]=tot;
}
int dfn[maxn],dep[maxn];
int fa[maxn],mx,pos;
bool vis[maxn];
vector<int>lea;
void dfs(int x,int f,int dp){
fa[x]=f,dep[x]=dp,vis[x]=1;
if(dep[x]>mx){
mx=dep[x],pos=x;
if(mx>=(n+k-1)/k){
puts("PATH");
printf("%d\n",mx);
int p=x;
while(p){
printf("%d ",p);p=fa[p];
}
puts("");exit(0);
}
}
bool res=false;
for(int i=Head[x];i;i=Next[i]){
int y=to[i];
if(vis[y]) continue;
dfs(y,x,dp+1);res=true;
}
if(!res) lea.push_back(x);
}
bool comp(int a,int b){
return dep[a]<dep[b];
}
int main(){
read(n);read(m);read(k);
if(n%k) lim=n/k;
else lim=n/k+1;
for(int i=1,x,y;i<=m;i++){
read(x);read(y);
add(x,y);add(y,x);
}
dfs(1,0,1);
puts("CYCLES");
bool res;
for(int i=0;i<k;i++){
int x=lea[i];
res=false;vector<int>v;v.clear();
for(int i=Head[x];i;i=Next[i]){
int y=to[i];
if(v.size()!=2) v.push_back(y);
if(y==fa[x]||(dep[x]-dep[y]+1)%3==0) continue;
printf("%d\n",dep[x]-dep[y]+1);
int p=x;
while(p!=fa[y]){
printf("%d ",p);
p=fa[p];
}
puts("");
res=1;break;
}
if(res) continue;
sort(v.begin(),v.end(),comp);
printf("%d\n",dep[v[1]]-dep[v[0]]+2);
int a=v[0],b=v[1];
while(fa[a]!=fa[b]) printf("%d ",b),b=fa[b];
printf("%d %d\n",b,x);
}
return 0;
}
\(\mathrm{D-Professional layer}\)
题解
一个萌萌萌新的看题解心路...
截止2019.10.30 17:45,我还没有A掉这道题...

\(\mathrm{Code}\)
\(\mathrm{E-Radix sum}\)
神仙多项式题,不会。
20191028 Codeforces Round #534 (Div. 1) - Virtual Participation的更多相关文章
- 20191031 Codeforces Round #539 (Div. 1) - Virtual Participation
这场怎么全是数据结构题...
- Codeforces Round #534 (Div. 2) D. Game with modulo(取余性质+二分)
D. Game with modulo 题目链接:https://codeforces.com/contest/1104/problem/D 题意: 这题是一个交互题,首先一开始会有一个数a,你最终的 ...
- CF1103D Codeforces Round #534 (Div. 1) Professional layer 状压 DP
题目传送门 https://codeforces.com/contest/1103/problem/D 题解 失去信仰的低水平选手的看题解的心路历程. 一开始看题目以为是选出一些数,每个数可以除掉一个 ...
- CF1103C Johnny Solving (Codeforces Round #534 (Div. 1)) 思维+构造
题目传送门 https://codeforces.com/contest/1103/problem/C 题解 这个题还算一个有难度的不错的题目吧. 题目给出了两种回答方式: 找出一条长度 \(\geq ...
- Codeforces Round #534 (Div. 1)
A 构造题 有一个44的方格 每次放入一个横向12或竖向2*1的方格 满了一行或一列就会消掉 求方案 不放最后一行 这样竖行就不会消 然后竖着的放前两行 横着的放第三行 循环放就可以啦 #includ ...
- Codeforces Round #534 (Div. 2)D. Game with modulo-1104-D(交互+二分+构造)
D. Game with modulo time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #534 (Div. 2)
B. Game with string 题意: 给出一个字符串s只包括小写字母.当轮到一个玩家的时候,他可以选择两个连续且相等的字母并且删除它.当一个玩家没得删的时候他就输了. 题解: 乍一看有点懵, ...
- Codeforces Round #534 (Div. 2) Solution
A. Splitting into digits Solved. #include <bits/stdc++.h> using namespace std; int n; void sol ...
- [ACM]Codeforces Round #534 (Div. 2)
A. Splitting into digits Vasya has his favourite number n. He wants to split it to some non-zero dig ...
随机推荐
- AcWing 45. 之字形打印二叉树
地址 https://www.acwing.com/problem/content/description/43/ 题目描述请实现一个函数按照之字形顺序从上向下打印二叉树. 即第一行按照从左到右的顺序 ...
- LeetCode 5126. 有序数组中出现次数超过25%的元素 Element Appearing More Than 25% In Sorted Array
地址 https://leetcode-cn.com/contest/biweekly-contest-15/problems/element-appearing-more-than-25-in-so ...
- R-长尾词练习
一. 长尾关键词的特征 长尾关键词通常比较长,往往是2-3个词组成,甚至是短语,存在于内容页面,除了内容页的标题,还存在于内容中. 长尾关键词搜索量虽然非常少,而且不稳定.但是搜索量甚至超越热门目标关 ...
- Spring Batch与ETL工具比较
在实际应用中,在批处理中用得较多的是场景是数据同步.在做数据集成工作中,常常需要从源位置把数据同步到目标位置,以便于进行后续的逻辑操作.在做这种批处理工具时,在网上查资料,发现用得比较多的是kettl ...
- vscode源码分析【三】程序的启动逻辑,性能问题的追踪
第一篇: vscode源码分析[一]从源码运行vscode 第二篇:vscode源码分析[二]程序的启动逻辑,第一个窗口是如何创建的 启动追踪 代码文件:src\main.js 如果指定了特定的启动参 ...
- IT兄弟连 HTML5教程 HTML5的曲折发展过程 浏览器之间的大战
播放电影和音乐要使用播放器,浏览网页就需要使用浏览器.浏览器虽然只是一个设备,并不是开发语言,但在Web开发中必不可少,因为浏览器要去解析HTML5.CSS3和JavaScript等语言用于显示网页, ...
- vscode开发微信小程序使用less(插件Easy WXLESS)
1.搜索按照Easy WXLESS 2.在文件中加入下面的一行代码:就会在同级目录下同步代码到.wss // out: index.wxss 更多的写法可以查官网:https://marketplac ...
- JavaFx出现错误Caused by: java.lang.NullPointerException: Location is required的解决方法
问题截图: "C:\Program Files\Java\jdk1.8.0_131\bin\java.exe" "-javaagent:I:\IntelliJ IDEA ...
- python基础(11):函数(一)
1. 什么是函数 1.我们到⽬前为⽌,已经可以完成⼀些软件的基础功能了.那么我们来完成这样⼀个功能: 约会: print("拿出⼿机") print("打开陌陌" ...
- Linux软件安装——服务管理
Linux软件安装——服务管理 摘要:本文主要学习了Linux中有关服务管理的知识. 什么是服务 服务一般是放置在后台运行的一个或多个进分程,为用户或系统提供某项特定的服务,有些是系统服务,有些则是独 ...