QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#375697#2833. HamiltonTx_LcyWA 1ms3924kbC++141.0kb2024-04-03 14:57:562024-04-03 14:57:57

Judging History

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

  • [2024-04-03 14:57:57]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3924kb
  • [2024-04-03 14:57:56]
  • 提交

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;
		rep(i,3,n){
			int pl=0;
			rep(j,1,i-3)
				if (a[p[j]][p[j%n+1]] && !a[p[j%n+1]][p[j%n+2]]){pl=j+1;break;}
			if (pl){
				if (!a[p[i]][p[pl%n+1]]) add(pl,i);
				else add(pl%n+1,i);
			}else add(i-1,i);
		}
		rep(i,1,n) 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;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3924kb

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: 1ms
memory: 3876kb

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