首页 > 代码库 > Educational Codeforces Round 24

Educational Codeforces Round 24

陷入了一种每场比赛打完都不想改题的虚无状态,不能这样,改题改题改题。
昨晚只写了三道题意即题解的题…感觉意识模糊,看了看是unrated就睡了
CF已经连续三场unrated了qwq,我一共就没打过几场
A. Diplomas and Certificates
题意:拿到certificate的人数将会是拿到diploma人数的k倍,但拿到他们的总人数不能超过n/2
把n/2向下取底分成k+1分
#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>using namespace std;typedef long long LL;LL n,k;int main(){    scanf("%I64d%I64d",&n,&k);    LL t1=n/2/(k+1),t2=t1*k;    printf("%I64d %I64d %I64d\n",t1,t2,n-t1-t2);    return 0;}
B. Permutation Game
题意:给出一个排列a1...an,进行m轮游戏,首先选定一个leader作为l[1],l[i+1]=a[l[i]]+l[i]
a[l[i]]+l[i]=l[i+1] 所以 a[l[i]]=l[i+1]-l[i]
如果遇到有冲突的情况特判一下输出-1(一个以上的位置是同一个数或同一个位置几次得到的结果不一样)
#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>#include<vector>using namespace std;int n,m,l[105],a[105];int num[105];vector<int>v;int main(){    scanf("%d%d",&n,&m);    for(int i=1;i<=m;i++)    scanf("%d",&l[i]);    for(int i=1;i<m;i++)    {        int t=l[i+1];        while(t<=l[i])t+=n;        if(a[l[i]]&&a[l[i]]!=t-l[i]){printf("-1\n");return 0;}        if(!a[l[i]])        {            a[l[i]]=t-l[i];            num[a[l[i]]]++;        }    }    for(int i=1;i<=n;i++)    if(num[i]>1){printf("-1\n");return 0;}    else if(!num[i])v.push_back(i);    for(int i=1;i<=n;i++)    {        if(!a[i])a[i]=v.back(),v.pop_back();        printf("%d ",a[i]);    }    return 0;}
C. Sofa Thief
D. Multicolored Cars
题意:有n辆车依次驶过,给定对方选择的一个颜色a,请你选择一个颜色b使得在任一时刻cntb>=cnta
感觉也没什么好说的,线性扫一遍即可,细节的话还是看代码
#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>using namespace std;int n,a,b,num[1000005],x[1000005];bool f[1000005];int main(){    scanf("%d%d",&n,&a);    for(int i=1;i<=n;i++)    {        scanf("%d",&x[i]);        if(a!=x[i]&&num[x[i]]<num[a])f[x[i]]=1;        num[x[i]]++;        if(a!=x[i]&&num[x[i]]<num[a])f[x[i]]=1;    }    if(!num[a]){printf("%d\n",a+1);return 0;}    for(int i=1;i<=n;i++)    {        if(a!=x[i]&&num[x[i]]<num[a])f[x[i]]=1;        if(!f[x[i]]&&x[i]!=a){printf("%d\n",x[i]);return 0;}    }    printf("-1\n");    return 0;}
E. Card Game Again
F. Level Generation
G. Four Melodies

Educational Codeforces Round 24