2021.01.01

[] CF142D

考虑以 $F,G$ 之间的距离为石子个数,则直接跑 $K-Nim$ 。

#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<climits>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
inline int read(){
    int f=1,ans=0;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
    return f*ans;
}
const int MAXN=111;
int N,M,A[MAXN],K; char str[MAXN];
int main(){
    N=read(),M=read(),K=read(); bool RR=0,GG=0,GGG=0;
    for(int i=1;i<=N;i++){
        scanf("%s",str+1);
        int totR=0,totG=0,psR=0,psG=0;
        for(int j=1;j<=M;j++){
            if(str[j]=='R') totR++,psR=j;
            if(str[j]=='G') totG++,psG=j,GGG=1;
        }
        if(totR&&totG){A[++A[0]]=max(psR,psG)-min(psR,psG)-1;continue;}
        if(M==totR) RR=1; if(M==totG) GG=1;
    }
    
    if(A[0]){
        bool ff=1;
        for(int i=10;i>=0;i--){
            int tot=0; for(int j=1;j<=A[0];j++) if(A[j]&(1<<i)) tot++;
            ff&=(tot%(K+1)==0);
        }
        if(ff) printf("Second\n");
        else printf("First\n");
        return 0;
    }
    
    if(!GGG){printf("Second\n");return 0;}
    if(!GG&&!RR) printf("Draw\n");else if(GG) printf("Second\n");else if(RR) printf("First\n");return 0;
}
View Code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-05
相关资源
相似解决方案