QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#375702 | #2833. Hamilton | Tx_Lcy | WA | 1ms | 4044kb | C++14 | 1.0kb | 2024-04-03 15:02:17 | 2024-04-03 15:02:18 |
Judging History
answer
//A tree without skin will surely die.
//A man without face will be alive.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mid ((l+r)>>1)
#define lowbit(x) (x&-x)
#define all(x) (x).begin(),(x).end()
#define rep(i,j,k) for (int i=j;i<=k;++i)
#define per(i,j,k) for (int i=j;i>=k;--i)
int const N=2e3+10;
string s[N];
int n,a[N][N],p[N];
inline void add(int x,int y){
rep(i,x+1,n) p[i]=p[i-1];
p[x+1]=y;
}
inline void solve(){
while (cin>>n){
rep(i,1,n) cin>>s[i],s[i]=" "+s[i];
rep(i,1,n) rep(j,1,n) a[i][j]=s[i][j]-'0';
p[1]=1,p[2]=2,p[3]=1;
rep(i,3,n){
int pl=0;
rep(j,1,i-2)
if (a[p[j]][p[j+1]] && !a[p[j+1]][p[j+2]]){pl=j+1;break;}
if (pl){
if (!a[p[i]][p[pl+1]]) add(pl,i);
else add(pl+1,i);
}else add(i,i);
}
rep(i,2,n+1) cout<<p[i]<<' ';
cout<<'\n';
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int t=1;
// cin>>t;
while (t--) solve();
cerr<<"Time: "<<(double)clock()/CLOCKS_PER_SEC<<" s\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 4044kb
input:
3 001 000 100 4 0000 0000 0000 0000
output:
2 1 3 2 1 3 4
result:
wrong answer case #1: found 2 indices