菜是原罪。

英语不好更是原罪。


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

  1. 20191031 Codeforces Round #539 (Div. 1) - Virtual Participation

    这场怎么全是数据结构题...

  2. Codeforces Round #534 (Div. 2) D. Game with modulo(取余性质+二分)

    D. Game with modulo 题目链接:https://codeforces.com/contest/1104/problem/D 题意: 这题是一个交互题,首先一开始会有一个数a,你最终的 ...

  3. CF1103D Codeforces Round #534 (Div. 1) Professional layer 状压 DP

    题目传送门 https://codeforces.com/contest/1103/problem/D 题解 失去信仰的低水平选手的看题解的心路历程. 一开始看题目以为是选出一些数,每个数可以除掉一个 ...

  4. CF1103C Johnny Solving (Codeforces Round #534 (Div. 1)) 思维+构造

    题目传送门 https://codeforces.com/contest/1103/problem/C 题解 这个题还算一个有难度的不错的题目吧. 题目给出了两种回答方式: 找出一条长度 \(\geq ...

  5. Codeforces Round #534 (Div. 1)

    A 构造题 有一个44的方格 每次放入一个横向12或竖向2*1的方格 满了一行或一列就会消掉 求方案 不放最后一行 这样竖行就不会消 然后竖着的放前两行 横着的放第三行 循环放就可以啦 #includ ...

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

  7. Codeforces Round #534 (Div. 2)

    B. Game with string 题意: 给出一个字符串s只包括小写字母.当轮到一个玩家的时候,他可以选择两个连续且相等的字母并且删除它.当一个玩家没得删的时候他就输了. 题解: 乍一看有点懵, ...

  8. Codeforces Round #534 (Div. 2) Solution

    A. Splitting into digits Solved. #include <bits/stdc++.h> using namespace std; int n; void sol ...

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

随机推荐

  1. acwing 471. 棋盘 解题记录

    题解地址  https://www.acwing.com/problem/content/description/473/ 有一个m×m的棋盘,棋盘上每一个格子可能是红色.黄色或没有任何颜色的. 你现 ...

  2. Java中的集合-您必须知道的13件事

    Java Collections Framework是Java编程语言的核心部分之一.集合几乎用于任何编程语言中.大多数编程语言都支持各种类型的集合,例如List, Set, Queue, Stack ...

  3. ModelAndView重定向带参数解决方法

    业务场景:SpringMVC项目使用ModelAndView进行重定向跳转到另外一个action时,需要在url后面带上参数 如果是带参数带一个页面,直接用modelAndView.addObject ...

  4. 安装 Java

    1.rpm下载地址 https://download.oracle.com/otn/java/jdk/7u79-b15/jdk-7u79-linux-x64.rpm?AuthParam=1570520 ...

  5. 错误InnoDB:Attemptedtoopenapreviouslyopenedtablespace.

    2013-08-04 13:48:22 760 [ERROR] InnoDB: Attempted to open a previously opened tablespace. Previous t ...

  6. jQuery Validate表单校验

    jQuery plugin: Validation 使用说明 学习链接及下载地址:http://www.runoob.com/jquery/jquery-plugin-validate.html 一导 ...

  7. Javase之object类的概述

    object类的概述 object类是类层次结构的根类,每个类都使用object作为超类. 即每个类都直接或间接的继承object类. object类中方法介绍 hashCode public int ...

  8. ES6复制拷贝数组,对象,json数组

    扩展运算符的应用spread打散数组[...] (1)复制数组 数组是复合的数据类型,直接复制的话,只是复制了指向底层数据结构的指针,而不是克隆一个全新的数组. const a1 = [1, 2]; ...

  9. 前端开发工具HBuilder使用技巧以及快捷键

    创建HTML结构: h 8 (敲h激活代码块列表,按8选择第8个项目,即HTML代码块,或者敲h t Enter) 中途换行: 'Ctrl+Enter' 设置charset: m e 6 Enter ...

  10. Dynamics CRM 中Web API中的深度创建(Deep Insert)

    我是微软Dynamics 365 & Power Platform方面的工程师罗勇,也是2015年7月到2018年6月连续三年Dynamics CRM/Business Solutions方面 ...