QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#451027 | #2833. Hamilton | grass8cow# | WA | 1ms | 3984kb | C++17 | 920b | 2024-06-22 20:32:47 | 2024-06-22 20:32:47 |
Judging History
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++){
int u=p[i];
if(!t1||a[q1[t1]][u]-'0'==o)q1[++t1]=u;
else if(!t2||a[q2[t2]][u]-'0'==o)q2[++t2]=u;
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;
}
}
}
puts("-1");
}
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: 1ms
memory: 3984kb
input:
3 001 000 100 4 0000 0000 0000 0000
output:
1 2 3 3 1 2 4
result:
ok 2 cases.
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3976kb
input:
3 000 000 000 3 010 100 000 3 011 100 100 3 011 101 110
output:
1 2 3 3 1 2 2 3 1 3 1 2
result:
wrong answer case #2: found 2 indices