QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#375682 | #2833. Hamilton | wjh213 | WA | 1ms | 3532kb | C++14 | 1.4kb | 2024-04-03 14:50:08 | 2024-04-03 14:50:08 |
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;
}
}
//vector<int> V{1,2,3};
deque<int> Q;
Q.push_back(1);
Q.push_back(2);
Q.push_back(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;
//}
int miao=-1;
int las=Q.front();
Q.pop_front();
for(int j=1;j<i;j++){
int now=Q.front();
Q.pop_front();
if(miao==-1)miao=a[las][now];
else if(a[las][now]!=miao){
fl=false;
Q.push_front(now);
break;
}
Q.push_back(las);
las=now;
}
if(fl){
Q.push_front(las);
Q.push_back(i);
continue;
}
int now=a[las][i];
if(now==a[las][Q.front()])Q.push_back(i);
else Q.push_front(i);
Q.push_back(las);
}
//for(auto it:V){
// cout<<it<<" ";
//}
//cout<<"\n";
int las=Q.front();
Q.pop_front();
int miao=-1;
for(int i=1;i<=n;i++){
int now=Q.front();
Q.pop_front();
if(miao==-1){
miao=a[now][las];
}else{
Q.push_front(now);
break;
}
Q.push_back(las);
las=now;
}
Q.push_front(las);
while(!Q.empty()){
cout<<Q.front()<<" ";
Q.pop_front();
}
cout<<"\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3532kb
input:
3 001 000 100 4 0000 0000 0000 0000
output:
2 3 1 2 3 4 1
result:
wrong answer case #1: found 2 indices