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 ...
随机推荐
- 201871010124 王生涛《面向对象程序设计JAVA》第一周学习总结
项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 https://edu.cnblogs.com/campus/xbsf/ ...
- layUI学习第二日:非模块化方法使用layUI
layUI采用非模块化方式(即所有模块一次性加载),操作示例代码如下(如果问怎么创建项目和工具,参考layUI学习第一日的步骤): 运行的结果如下: 运行的显示不会太持久,过几秒就会消失,具体封装的代 ...
- CSP2019游记(翻车记)
Preface 也许是人生中最重要的一场比赛了(再进不了冬令营我就没了) 结果不论怎样,想必也都是人生中的一次分水岭吧 从暑假开始到今天的一段时间,自己似乎终于找到了学OI的动力与乐趣.能认识到更多志 ...
- Nacos集群搭建过程详解
Nacos的单节点,也就是我们最开始使用的standalone模式,配置的数据是默认存储到内嵌的数据库derby中. 如果我们要搭建集群的话,那么肯定是不能用内嵌的数据库,不然数据无法共享.集群搭建的 ...
- 【Sublime Text】sublime修改默认浏览器及使用不同浏览器打开网页的快捷键设置
#第一步:安装SideBarEnhancements插件 下载插件,需要“翻墙”,故提供一下该插件的github地址:https://github.com/titoBouzout/SideBarEnh ...
- C语言--计算程序执行时间
C语言–计算程序执行时间1. gettimeofday精度1us #include<stdio.h>#include<sys/time.h> int main(){ /* 定义 ...
- js实现图片无缝循环跑马灯
html 代码 <div class="myls-out-div" style="overflow: hidden;"> <ul id=&qu ...
- Core源码(四)IEnumerable
首先我们去core的源码中去找IEnumerable发现并没有,如下 Core中应该是直接使用.net中对IEnumerable的定义 自己实现迭代器 迭代器是通过IEnumerable和IEnume ...
- Java 线程与多线程
Java是一门支持多线程的编程语言! 什么是进程? 计算机中内存.处理器.IO等资源操作都要为进程进行服务. 一个进程上可以创建多个线程,线程比进程更快的处理单元,而且所占用的资源也小,多线程的应用也 ...
- STM32 IAP 升级功能
IAP In Application Programming 可通过USB,CAN,UART,I2C,SPI等接口实现 IAP流程 Bootloader程序:接收升级程序,更新到flash指定地址:跳 ...