cf573div2

//cf573div2d
//
题意输入n a1-an堆石头, sjf先手 每次只能拿走一块石头(任意堆) , //当轮到谁 所有堆石头都为0 或 有两堆石头数相同时( 0 0)即输 #include<bits/stdc++.h> using namespace std; const int MA = 1e5+100; int a[MA], n; int main(){ scanf("%d",&n); int flag = 1; int cnt = 0; map<int, int>mp; for(int i = 0; i < n; i++) { int k; scanf("%d", &a[i]); mp[a[i]]++; flag &= (mp[a[i]] < 3);// situation 2 } for(auto it:mp) { if(it.second > 1) cnt++; } flag &= (cnt < 2);// situation 3 for(auto it:mp) { if(it.second > 1){ flag &= (mp.count(it.first-1) == 0);//situation 4 if(it.first == 0) flag = 0;//situation 1 } } if(!flag) return 0 * puts("cslnb"); // 四种 sjf 还没开始就输了的情况 // 1 cnt[0] > 1 cnt为出现次数, such as 0 0 0 1 // 2 cnt[x] > 2, such as 3 3 3 // 3 cnt[x] > 1 && cnt[y] > 1 ,such as 2 2 3 3 // 4 cnt[x] > 1 && cnt[x-1] > 0 ,such as 3 3 2 // 模拟 最后变成一个 0 1 2 3 4 5 6 .。。。。。 n-1 序列,差值为可移动的次数 // 模2 以后 若为奇数则 sjfnb, 否则cslnb sort(a, a+n); int s = 0; for(int i = 0; i < n; i++) { //assert(a[i] >= i); //>>????likely unnecessary s += a[i]-(i); } s %= 2; return 0 * puts(s ? "sjfnb": "cslnb"); } /* 1 0 cslnb 2 1 0 cslnb 3 2 3 1 output sjfnb */

https://codeforces.com/contest/1191/problem/D

cf573div2c:
//有 n 个数, 按 k 分为若干个区间, 删除 m 个特殊数,  每次只能去除一个区间的特殊数字, 问需要多少次, 模拟。。。。
#include<algorithm>// orderly cf573div2c #include<iostream>// enmmmmm, just simulate the process of discarding. #include<cstdio> typedef long long ll; using namespace std; const int MA = 1e5+100; ll a[MA],n,k; int main(){ int m, cnt = 0, sum = 0, num = 0; scanf("%lld%d%lld", &n, &m, &k); for(int i = 0; i < m; i++) scanf("%lld", &a[i]); while(num <= m){ ll r = ((a[num]-sum-1)/k+1)*k+sum;// -1 本身也占个位子 r 为每次删除区间的右端点 while(num <= m && r >= a[num]){ num++; sum++; } cnt++; } printf("%d ", cnt); return 0; } /* inputCopy 10 4 5 3 5 7 10 outputCopy 3 inputCopy 13 4 5 7 8 9 10 outputCopy 1 */

cf573div2b:
//三种情况 0 1 2
//添加几块砖 能达到 达到 全部相同(1s 1s 1s ) 或者 同花顺但必须是连续的 (1s 2s 3s 可) (1s 3s 5s 不可)
#include<iostream>
#include<cstdio>
typedef long long ll;// cf573div2b
using namespace std;
//1s 2s 3s
int main()
{    
    int c[4][10] = {}, ans = 4, idx[120] ;// {}  数组即初始化为0, 否则出现奇奇怪怪的初值
    //c[4][9] not init error
    idx['s'] = 1;
    idx['p'] = 2;
    idx['m'] = 3;
    for(int i = 0; i < 3; i++) {
        char s[3];
        scanf("%s", s);
        ++c[ idx[s[1]] ][s[0] - '0'];
    }

    //for(int i = 1; i < 4; i++){for(int j = 1;  j < 10; j++)printf("%d	", c[i][j]);printf("
");}

    for(int i = 1; i < 4; i++)
        for(int j = 1;  j < 10; j++){
            ans = min(ans, 3-c[i][j]);// 三个 x
            if(j+2 < 10)
                 ans = min(ans, 3-!!c[i][j]-!!c[i][j+1]-!!c[i][j+2]);// 同花顺系列
        }
    printf("%d
", ans);
    return 0;
}

cf573div2a:

#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
    int n; cin >>n;
    if(n%4 == 1) cout<<"0 A
";
    else if(n%4 == 2) cout<<"1 B
";
    else if(n%4 == 3) cout<<"2 A
";
    else cout<<"1 A
";
    return 0;
}
 
原文地址:https://www.cnblogs.com/163467wyj/p/11446290.html