求助
查看原帖
求助
1101201
Wang_xin_chen楼主2024/7/23 09:01
#include<bits/stdc++.h>
using namespace std;
const int maxn=105;
int t,n,m,r,s;
int c[2],p[2][maxn],f[2][maxn];
bool v[2][maxn];
int fun2(int st,int flst,int plst){
    int ret=-1;
    for(int i=1;i<=n;i++){
        if(v[i]==0){
            if(p[0][i]<=flst) continue;
            if(f[0][i]!=plst) continue;
            if(ret==-1) ret=i;
            else if(p[st][i]<p[st][ret])  ret=i;
        }
    }
    return ret;
}
int fun(int st){
    int id=-1;
    while(p[st][id]==1) id++;
    for(int i=1;i<=n;i++){
        if(p[st][i]<p[st][id]||(p[st][i]==p[st][id]&&f[st][i]==f[st][id])){
            id=i;
        }
    }
    int plst=p[st][id],flst=f[st][id];
    v[st][id]=1;
    c[st]--;
    if(c[st]==0) return st;
    st=1-st;
    while((id=fun2(st,flst,plst))!=1){
        plst=p[st][id];
        v[st][id]=true;
        c[st]--;
        if(c[st]==0) return st;
        st=1-st;
    }
    return 1-st;
}
int main(){
    cin>>t;
    while(t--){
        cin>>n>>m>>r>>s;
        for(int i=1;i<=n;i++) cout<<f[0][i];
        for(int i=1;i<=n;i++) cout<<p[0][i];
        for(int i=1;i<=n;i++) cout<<f[1][i];
        for(int i=1;i<=n;i++) cout<<p[1][i];
        s-=1;
        c[0]=c[1]=n;
        for(int i=1;i<=n;i++) v[0][i]=v[1][i]=0;
        while(c[0]&&c[1]) s=fun(s);
        if(s==1) cout<<"FR wins!"<<endl;
        else cout<<"FS wins!"<<endl;
    }
    return 0;
}
2024/7/23 09:01
加载中...