2020牛客暑期多校训练营(第八场)G Game SET

2020牛客暑期多校训练营(第八场)G Game SET_第1张图片2020牛客暑期多校训练营(第八场)G Game SET_第2张图片
在这里插入图片描述

string tmp[5][5]{{"one","two","three"},{"diamond","squiggle","oval"},{"solid","striped","open"},{"red","green","purple"}};
map<string,int>id;
char s[100];
int n,a[300][10];
void solve(){
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
            for(int k=j+1;k<=n;k++){
                int f=1;
                for(int l=1;l<=4;l++){
                    if(a[i][l]==0||a[j][l]==0||a[k][l]==0)continue;
                    if(a[i][l]==a[j][l]&&a[j][l]==a[k][l])continue;
                    if(a[i][l]!=a[j][l]&&a[i][l]!=a[k][l]&&a[j][l]!=a[k][l])continue;
                    f=0;
                }
                if(f){
                    printf("%d %d %d\n",i,j,k);
                    return ;
                }
 
            }
     printf("-1\n");
     return;
}
int main(){
    id["*"]=0;
    for(int i=0;i<4;i++)
        for(int j=0;j<3;j++)
            id[tmp[i][j]]=j+1;
    int T;
    scanf("%d",&T);
    for(int cas=1;cas<=T;cas++){
        scanf("%d",&n);
        for(int i=1;i<=n;i++){
            scanf("%s",s);
            int len=strlen(s);
            string now="";
            int nowi=1,j=1;
            while(nowi<len){
                while(nowi<len&&s[nowi]!=']'){
                    now+=s[nowi];
                    nowi++;
                }
                a[i][j++]=id[now];
                now="";
                nowi+=2;
            }
        }
        printf("Case #%d: ",cas);
        solve();
    }
    return 0;
}

你可能感兴趣的:(2020牛客暑期多校训练营(第八场)G Game SET)