A:Tokitsukaze and Enhancement

当时看错条件了。。以为A>C>B>D。就胡写了判断条件。

 #include<bits/stdc++.h>
using namespace std; bool work(int a,int b) {
if(a==-) return false;
if(b==-) return true;
if(a==&&(b==||b==||b==)) return true;
if(a==&&(b==||b==)) return true;
if(a==&&b==) return true;
return false;
}
map<int,char> mp;
int main() {
mp[]='A';
mp[]='C';
mp[]='B';
mp[]='D';
int x;
scanf("%d",&x);
int ans=-,pos=-;
char strans;
for(int i=;i<=;i++) {
int tmp=(x+i)%;
if(work(tmp,ans)) {
ans=tmp;
pos=i;
strans=mp[tmp];
}
}
printf("%d %c",pos,strans);
}

胡搞

看了题解,感觉还是思考太少。

根据余数,取最好的即可。

 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+; int main() {
int x;
scanf("%d",&x);
x%=;
if(x==) printf("%d %c\n",,'A');
else if(x==) printf("%d %c\n",,'B');
else if(x==) printf("%d %c\n",,'A');
else printf("%d %c\n",,'A');
}

B:Tokitsukaze and Mahjong

数字对应放到s,m,p组里,然后暴力找胜利的最少添加数。

 #include<bits/stdc++.h>
using namespace std; string s1,s2,s3; vector<int> t[];
int id(char c) {
if(c=='s') return ;
if(c=='m') return ;
if(c=='p') return ;
} int a[]; int main() {
cin>>s1>>s2>>s3;
int id1,id2,id3;
id1=id(s1[]);
id2=id(s2[]);
id3=id(s3[]);
t[id1].push_back(s1[]-'');
t[id2].push_back(s2[]-'');
t[id3].push_back(s3[]-'');
int ans=;
// for(int i=0;i<t[1].size();i++) printf("%d ",t[1][i]);
for(int i=;i<=;i++) {
memset(a,,sizeof(a));
for(int j=;j<t[i].size();j++) {
a[t[i][j]]++;
}
for(int j=;j<=;j++) {
//printf("%d\n",a[j]);
ans=min(ans,-a[j]);
}
int cnt;
for(int j=;j<=;j++) {
cnt=;
for(int k=j;k<=j+&&k<=;k++) {
if(a[k]>) cnt++;
}
//printf("%d**\n",cnt);
ans=min(ans,-cnt);
}
}
printf("%d\n",ans); }

C:Tokitsukaze and Discard Items

删除的数字是递增的,处理出当前要删除数字所在块的最后一个数字,然后删除,直到全部删除。

 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+; ll n,m,k,a[maxn];
int main() {
scanf("%lld%lld%lld",&n,&m,&k);
for(int i=;i<=m;i++) scanf("%lld",&a[i]);
int sum=; //删除总数
int ans=;
int now=;
while(now<=m) {
// 没想到
ll r=((a[now]-sum-)/k+)*k+sum;
while(now<=m&&a[now]<=r) {
sum++;
now++;
}
ans++;
}
printf("%d\n",ans);
}

D:Tokitsukaze, CSL and Stone Game

博弈果断一点不会。分析:

首先判断先手必败的条件

1、有三堆及以上数量相等的石头,即  x  x  x

2、有两对及以上两堆数量相等的石头,即  x x  y y

3、有两堆及以上的空堆 ,即 0  0  0

4、有相等的堆且存在数量减一的堆,即   x  x  x-1

除了以上情况,最后会变成这样的状态 (先手必胜)

0   1   2  3  ……   n-1

所以判断形成这样的步数的奇偶即可。

 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+; int n,a[maxn];
map<int,int> mp; int main() {
scanf("%d",&n);
int ok=;
for(int i=;i<=n;i++) {
scanf("%d",&a[i]);
mp[a[i]]++;
ok&=(mp[a[i]]<=); // x x x
}
int cnt=;
map<int,int>::iterator it;
for(it=mp.begin();it!=mp.end();it++) {
if(it->second>=) cnt++; // x x y y
}
ok&=(cnt<=);
for(it=mp.begin();it!=mp.end();it++) {
if(it->second==) {
ok&=(mp.count(it->first-)==); // x x x-1
if(it->first==) ok=; // 0 0
}
}
if(!ok) return *puts("cslnb");
// 0 1 2 3 …… n-1
sort(a+,a+n+);
ll s=;
for(int i=;i<=n;i++) {
s+=a[i]-(i-);
}
s%=;
return *puts(s?"sjfnb":"cslnb");
}

E:Tokitsukaze and Duel

分析:

先手如果第一步不能获胜,以后就不可能获胜。

后手如果第一步不能获胜,以后也不可能获胜,因为对方可以反转相同的维持局面。

先手获胜:可以通过前缀和预处理出先手是否必胜。

如果后手想要获胜,那么

1、k != 1   无限跳转

2、2*k >= n  因为到后手必定有一段连续的k个0或1,如果后手能获胜,必须能覆盖掉整个串

然后先手若不能第一步获胜,他必定会取中间的k个连续位置,所以要处理左右两个区间a、b

int len = n - k - 1;

a[1]==a[n]  ||  a[len] == a[len+1]   ||   a[n-len] == a[n-len+1]  时  后手也不能获胜

不是太懂,画图。。。

 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+; int n,k,a[maxn],sum[maxn]; int query(int l,int r) {
if(l>r) return ;
return sum[r]-sum[l-];
} bool check1() {
for(int i=;i+k-<=n;i++) {
int tmp=query(,i-)+query(i+k,n);
if(tmp==||tmp+k==n) return true;
}
return false;
} bool check2() {
if(k==||*k<n) return false;
int len=n-k-;
for(int i=;i<=len;i++) {
if(a[i]!=a[i-]||a[n-i+]!=a[n-i+]) return false;
}
if(a[]==a[n]||a[len]==a[len+]||a[n-len]==a[n-len+]) return false;
return true;
} int main() {
scanf("%d%d",&n,&k);
for(int i=;i<=n;i++) scanf("%1d",&a[i]);
for(int i=;i<=n;i++) sum[i]=sum[i-]+a[i];
if(check1()) puts("tokitsukaze");
else if(check2()) puts("quailty");
else puts("once again");
return ;
}

Codeforces Round #573 (Div. 2)的更多相关文章

  1. Codeforces Round #573 (Div. 1) 差F

    Codeforces Round #573 (Div. 1) E 题意:二维平面上有 n 个点,你可以放至多 m 条直线使得 (0,0) 与每个点的连线至少与一条直线相交.求原点与所有直线的距离最小值 ...

  2. Codeforces Round 573 (Div.1) 题解

    这场怎么说呢……有喜有悲吧. 开场先秒了 A.看到 B,感觉有点意思,WA 了 2 发后也过了. 此时还在 rk 前 200. 开 C,一看就不可做.跟榜,切 D 人数是 C 的两倍. 开 D.一眼感 ...

  3. Codeforces Round #573 (Div. 2) Tokitsukaze and Mahjong 水题

    B. Tokitsukaze and Mahjong time limit per test1 second memory limit per test256 megabytes Tokitsukaz ...

  4. Codeforces Round #573 (Div. 1)

    Preface 军训终于结束了回来补一补之前的坑发现很多题目题意都忘记了 这场感觉难度适中,F由于智力不够所以弃了,E的话石乐志看了官方英文题解才发现自己已经胡了一大半就差实现了233 水平下降严重. ...

  5. Codeforces Round #573 (Div. 2) D. Tokitsukaze, CSL and Stone Game (博弈,思维)

    D. Tokitsukaze, CSL and Stone Game time limit per test1 second memory limit per test256 megabytes in ...

  6. Codeforces Round #573 (Div. 2) E. Tokitsukaze and Duel (博弈)

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  7. Codeforces Round #573 (Div. 2) D题题解

    一.题目 ​ Tokitsukaze, CSL and Stone Game ​ Tokitsukaze和CSL正在玩一些石头游戏. ​ 一开始,有n堆的石头,第i堆石头数记为 \(a_i\),两人轮 ...

  8. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  9. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

随机推荐

  1. 函数的作用域、作用域链以及return关键字

    1.作用域 全局作用域:在函数外部使用var关键字定义的变量 局部作用域:在函数内部使用var关键字定义的变量 特点   (1)局部变量无法直接影响全局变量    (2)在局部作用域中可以使用全局作用 ...

  2. P++ 1.0.5

    #include<bits/stdc++.h> #define begin { #define end } #define while while( #define if if( #def ...

  3. JAVA 垃圾回收读书笔记

    对象已死 在JAVA代码运行中,会不停的创建对象,因为内存空间不是无限的,Java虚拟机必须不停的回收无用的数据空间.那么虚拟机是怎么判断对象空间是需要被回收的呢,也就是怎么样的数据算是垃圾数据呢? ...

  4. BZOJ 3245 最快路线

    和道路升级差不多,只是用的spfa; 十分有毒,在BZOJ上一直WA,对拍拍出来是一样的却告诉我不一样,然后发现自己把'\n'写成了‘\b’... #include<cstdio> #in ...

  5. MySQL 中LIMIT的使用详解

    在使用数据库过程中,常会遇到查询或者导出某个数据表或者查询集的前几条或者后几条记录,LIMIT可以很好的满足需求. LIMIT基本语法: 如果只给定一个参数,表示记录数. mysql; ) 相当于 m ...

  6. memcache课程---4、php+memcache如何让用户跨域登录

    memcache课程---4.php+memcache如何让用户跨域登录 一.总结 一句话总结: 让所有服务器共用一台memcache缓存,即可达到跨域的目的 1.session跨域:修改php配置文 ...

  7. JDK源码阅读--ArrayList

    public class ArrayList<E> extends AbstractList<E> implements List<E>, RandomAccess ...

  8. typedef int (init_fnc_t) (void)和typedef int (*init_fnc_t) (void)

    1.typedef  int (init_fnc_t) (void);表示定义init_fnc_t为函数类型,该函数返回int型,无参数.而“init_fnc_t  *init_sequence[]= ...

  9. exiftool(-k)与gui的联合使用

    首先下载一个exiftool下载后改名字https://sno.phy.queensu.ca/~phil/exiftool/ 根据自己的操作系统选择,我需要这个 然后下载guihttp://u88.n ...

  10. GitHub:如何构建一个股票市场知识图谱?(附代码&链接)

    来源:专知 本文约 600007 董事⻓/董事 高燕 女 60 600007 执⾏董事 刘永政 男 50 600008 董事⻓/董事 ··· ··· ··· ··· ··· 注:建议表头最好用相应的英 ...