QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#394001 | #2833. Hamilton | zyz07 | WA | 1ms | 3828kb | C++17 | 1.0kb | 2024-04-19 20:28:54 | 2024-04-19 20:28:54 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define For(Ti,Ta,Tb) for(auto Ti=(Ta);Ti<=(Tb);++Ti)
#define Dec(Ti,Ta,Tb) for(auto Ti=(Ta);Ti>=(Tb);--Ti)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define range(Tx) begin(Tx),end(Tx)
using ll=long long;
const int N=2005;
int n,a[N][N];
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
while(cin>>n){
For(i,1,n){
string s;
cin>>s;
For(j,1,n){
a[i][j]=s[j-1]-'0';
}
}
vector<int> ans{1,2,3};
For(u,4,n){
bool flg=0;
For(i,0,u-2){
int x=ans[i],y=ans[(i+1)%(u-1)],z=ans[(i+2)%(u-1)];
if(a[x][y]!=a[y][z]){
if(a[u][y]==a[x][y]){
ans.insert(ans.begin()+(i+2)%(u-1),u);
}else{
ans.insert(ans.begin()+(i+1)%(u-1),u);
}
flg=1;
break;
}
}
if(!flg){
ans.push_back(u);
}
}
For(i,0,n-1){
int x=ans[i],y=ans[(i+1)%n];
if(!a[x][y]){
rotate(ans.begin(),ans.begin()+i,ans.end());
break;
}
}
for(int x:ans){
cout<<x<<' ';
}
cout<<'\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3828kb
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: 0
Accepted
time: 0ms
memory: 3660kb
input:
3 000 000 000 3 010 100 000 3 011 100 100 3 011 101 110
output:
1 2 3 2 3 1 2 3 1 1 2 3
result:
ok 4 cases.
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3600kb
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 2 3 4 1 2 3 4 2 4 3 1 4 2 3 1 1 4 2 3 3 4 1 2 1 2 3 4 1 4 2 3 2 4 3 1 1 4 2 3 4 1 2 3
result:
wrong answer case #8: found 2 indices