QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#506488#2833. Hamiltonliyixin0514WA 0ms3836kbC++141.1kb2024-08-05 18:03:242024-08-05 18:03:24

Judging History

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

  • [2024-08-05 18:03:24]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3836kb
  • [2024-08-05 18:03:24]
  • 提交

answer

#include<bits/stdc++.h>
// #define LOCAL
#define sf scanf
#define pf printf
#define rep(x,y,z) for(int x=y;x<=z;x++)
using namespace std;
typedef long long ll;
const int N=2e3+5;
int n;
int c[N][N];
int a[N],b[N];
int pos=2;
int read(){
    char ch=getchar();
    while(ch!='0'&&ch!='1') ch=getchar();
    return ch-'0';
}
void insert(int x,int y,int z){
    a[x]=y,a[y]=z;
    b[y]=x,b[z]=y;
}
int main(){
    #ifdef LOCAL
    freopen("in.txt","r",stdin);
    freopen("my.out","w",stdout);
    #endif
    while(cin>>n){
        rep(i,1,n) rep(j,1,n) c[i][j]=read();
        a[1]=2,a[2]=1;
        b[1]=2,b[2]=1;
        pos=1;
        rep(i,3,n){
            if(c[pos][i]==c[pos][b[pos]]){
                insert(pos,i,a[pos]);
            }else{
                insert(b[pos],i,pos);
            }
            rep(j,1,i){
                if(c[i][b[i]]!=c[i][a[i]]){
                    pos=i;break;
                }
            }
        }
        rep(i,1,n) {
            pf("%d ",pos);
            pos=a[pos];
        }
        pf("\n");
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
001
000
100
4
0000
0000
0000
0000

output:

3 1 2 
1 4 3 2 

result:

ok 2 cases.

Test #2:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

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

output:

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

result:

ok 4 cases.

Test #3:

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

input:

4
0000
0000
0000
0000
4
0000
0001
0000
0100
4
0100
1010
0100
0000
4
0111
1000
1000
1000
4
0010
0011
1101
0110
4
0111
1011
1100
1100
4
0111
1011
1101
1110
4
0000
0011
0101
0110
4
0101
1010
0100
1000
4
0011
0011
1100
1100
4
0010
0001
1000
0100

output:

1 4 3 2 
1 4 3 2 
3 1 2 4 
4 3 2 1 
4 1 2 3 
4 3 2 1 
1 4 3 2 
4 3 2 1 
3 1 2 4 
1 4 2 3 
3 4 1 2 

result:

wrong answer case #3: found 2 indices