Codeforces Round#573(Div 2)

又是深夜肝题,不过这次被疯狂卡题,涨分+0(小幸运)

A.Tokitsukaze and Enhancement

题意:对于一个数,如果对4取余之后,余数为1,3,2,0时,等级为$A,B,C,D$,优先级降低。给你一个数,你能加0,1,2,你能达到的最高等级是什么。

思路:暴力模拟,还可以找规律直接输出的

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int cal(int x){
if(x%4==1) return 4;
else if(x%4==3) return 3;
else if(x%4==2) return 2;
else return 1;
}
int main(){
int n;
scanf("%d",&n);
int x1=n,x2=n+1,x3=n+2;
int a1=cal(x1),a2=cal(x2),a3=cal(x3);
if(a1 > a2 && a1>a3){
printf("0 %c",'A'+4-a1);
}
else if(a2>a1 & a2>a3){
printf("1 %c",'A'+4-a2);
}
else{
printf("2 %c",'A'+4-a3);
}
}

B.Tokitsukaze and Mahjong

题意:有三种花色的麻将${m,p,s }$,每个花色有1-9的数字,问你最少还要抓多少个牌就可以凑成同花顺含三个或者三个一模一样的牌。

思路:模拟题。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int s[11],m[11],p[11];
int cal(char c){
if(c == 's') return 1;
else if(c == 'm') return 2;
else return 3;
}
bool ok(){
for(int i=1; i<=9; i++) if(s[i]==3) return true;
for(int i=1; i<=9; i++) if(m[i]==3) return true;
for(int i=1; i<=9; i++) if(p[i]==3) return true;
for(int i=1; i<=7; i++){
if(s[i]==1 && s[i+1]==1 && s[i+2]==1) return true;
}
for(int i=1; i<=7; i++){
if(m[i]==1 && m[i+1]==1 && m[i+2]==1) return true;
}
for(int i=1; i<=7; i++){
if(p[i]==1 && p[i+1]==1 && p[i+2]==1) return true;
}
return false;
}
bool okk(){
for(int i=1; i<=8; i++){
if(s[i]==1 && s[i+1]==1) return true;
}
for(int i=1; i<=8; i++){
if(m[i]==1 && m[i+1]==1) return true;
}
for(int i=1; i<=8; i++){
if(p[i]==1 && p[i+1]==1) return true;
}
return false;
}
bool okkk(){
for(int i=1; i<=7; i++){
if(s[i]==1 && s[i+2]==1) return true;
}
for(int i=1; i<=7; i++){
if(m[i]==1 && m[i+2]==1) return true;
}
for(int i=1; i<=7; i++){
if(p[i]==1 && p[i+2]==1) return true;
}
return false;
}
bool okkkk(){
for(int i=1; i<=9; i++){
if(s[i]==2) return true;
}
for(int i=1; i<=9; i++){
if(m[i]==2) return true;
}
for(int i=1; i<=9; i++){
if(p[i]==2) return true;
}
return false;
}
int main(){
char c1,c2,c3;
int x,y,z;
scanf("%d%c %d%c %d%c",&x,&c1,&y,&c2,&z,&c3);
if(cal(c1)==1) s[x]++;
else if(cal(c1)==2) m[x]++;
else p[x]++;
if(cal(c2)==1) s[y]++;
else if(cal(c2)==2) m[y]++;
else p[y]++;
if(cal(c3)==1) s[z]++;
else if(cal(c3)==2) m[z]++;
else p[z]++;
if(ok()) puts("0");
else{
if(okk() || okkk() || okkkk()) puts("1");
else puts("2");
}
}

C.Tokitsukaze and Discard Items

题意:很多页面,对于每一个页面进行删除特殊数的操作,每删除一个页面的数就要从后面移动若干个数来填补,问你最终我要进行几次删除操作。

思路:由于n最多有$10^{18}$,直接在n中查找肯定不行,所以直接对m个特殊的数操作,然后就是一道模拟题。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=1e5+10;
ll n,k,m;
ll a[maxn];
int main(){
scanf("%lld %lld %lld",&n,&m,&k);
for(ll i=0; i<m; i++){
scanf("%lld",&a[i]);
}
ll ans=0;
ll sum=0;
ll l=0;
for(ll i=0; i<m; i++){
if(a[i]-ans<=k){
l++;
if(sum == 0) sum++;
continue;
}
else{
ans+=l;
if(a[i]-ans>k){
ll tmp=(a[i]-ans-1)/k;
ans+=(tmp*k);
}
//printf("%lld\n",ans);
l=1;
sum++;
}
}
printf("%lld\n",sum);
}

D.Tokitsukaze, CSL and Stone Game

题意:两个人玩n堆石子游戏,每个人拿一颗,如果轮到一个人没石子拿了或者拿了之后存在两堆石子的数量一样,就输,问你谁赢?

思路:如果对于第一个人无论怎么取都输了,那么就直接输出第二个人赢,否则就一定会到0,1,2,3,…,n-1状态,那么只要看到这个状态拿石子数量的奇偶性即可。

对于第一个人的必输状态有如下四种

$cnt_0 \geq 2 $

$\exists x \ ,\ cnt_x \geq 3$

$\exists {x,y} ,\ cnt_x \geq 2 \ and\ cnt_y \geq 2$

$\exists{x}, \ cnt_x\geq2 \ and \ cnt_{x-1}\geq1$

判断即可。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
map<ll,ll>ma;
int main(){
scanf("%lld",&n);
ll sum=0,x;
ll aa=0;
bool flag=false;
for(ll i=0; i<n; i++){
scanf("%lld",&x);
ma[x]++;
if(ma[x]==3 || (ma[x]>=2&&ma[x-1]>0) || (ma[x]>0 && ma[x+1]>=2)) flag=true;
if(ma[x]==2) aa++;
sum+=x;
}
if(flag || aa>=2 || ma[0]>=2){
puts("cslnb");
return 0;
}
ll tmp=(0+n-1)*n/2;
sum-=tmp;
if(sum&1) puts("sjfnb");
else puts("cslnb");
}
thanks!