QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#451023#2833. Hamiltongrass8cow#WA 0ms4056kbC++17874b2024-06-22 20:30:262024-06-22 20:30:26

Judging History

你现在查看的是最新测评结果

  • [2024-06-22 20:30:26]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4056kb
  • [2024-06-22 20:30:26]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n;
char a[2010][2010];
int q1[2010],q2[2010],t1,t2,p[2010];
mt19937 rnd(time(0));
void sol(){
    for(int i=1;i<=n;i++)scanf("%s",a[i]+1);
    for(int o=0;o<2;o++){
        t1=t2=0;
        for(int i=1;i<=n;i++)p[i]=i;
        int ste=2000;
        while(ste--){
            shuffle(p+1,p+n+1,rnd),t1=t2=0;
            bool gg=0;
            for(int i=1;i<=n;i++){
                if(!t1||a[q1[t1]][i]-'0'==o)q1[++t1]=i;
                else if(!t2||a[q2[t2]][i]-'0'==o)q2[++t2]=i;
                else{gg=1;break;}
            }
            if(!gg){
                for(int i=1;i<=t1;i++)printf("%d ",q1[i]);
                for(int i=1;i<=t2;i++)printf("%d ",q2[i]);
                puts("");return;
            }
        }
    }
}
int main(){
    while(~scanf("%d",&n))sol();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 4056kb

input:

3
001
000
100
4
0000
0000
0000
0000

output:

1 2 3 
1 2 3 4 

result:

ok 2 cases.

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3984kb

input:

3
000
000
000
3
010
100
000
3
011
100
100
3
011
101
110

output:

1 2 3 
1 3 2 
1 2 3 
1 2 3 

result:

wrong answer case #3: found 2 indices