QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#375632 | #2833. Hamilton | wjh213 | WA | 0ms | 3584kb | C++14 | 780b | 2024-04-03 14:23:31 | 2024-04-03 14:23:32 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int const MAX=2005;
bool a[MAX][MAX];
signed main(){
int n;
while(cin>>n){
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
char c;
cin>>c;
a[i][j]=c=='1'?1:0;
}
}
if(n<=3){
for(int i=1;i<=n;i++){
cout<<i<<" ";
}
cout<<"\n";
continue;
}
vector<int> V{1,2,3};
for(int i=4;i<=n;i++){
bool fl=true,ind=0;
for(int j=1;j+1<V.size();j++){
if(a[V[j]][V[j+1]]!=a[V[j-1]][V[j]])fl=false,ind=j;
}
if(fl){
V.push_back(i);
continue;
}
int now=a[V[ind]][i];
if(now==a[V[ind-1]][V[ind]])V.insert(V.begin()+ind+1,now);
else V.insert(V.begin()+ind,now);
}
for(auto it:V){
cout<<it<<" ";
}
cout<<"\n";
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3584kb
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: 3532kb
input:
3 000 000 000 3 010 100 000 3 011 100 100 3 011 101 110
output:
1 2 3 1 2 3 1 2 3 1 2 3
result:
wrong answer case #3: found 2 indices