QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#375702#2833. HamiltonTx_LcyWA 1ms4044kbC++141.0kb2024-04-03 15:02:172024-04-03 15:02:18

Judging History

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

  • [2024-04-03 15:02:18]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4044kb
  • [2024-04-03 15:02:17]
  • 提交

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