QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#375334#2833. Hamiltonwsc2008WA 0ms3788kbC++141.2kb2024-04-03 09:14:032024-04-03 09:14:04

Judging History

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

  • [2024-04-03 09:14:04]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3788kb
  • [2024-04-03 09:14:03]
  • 提交

answer

#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<ll,ll>
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define per(i,a,b) for(ll i=(a);i>=(b);--i)
using namespace std;
bool Mbe;
inline ll read(){
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
const ll N=2e3+9;
ll T,n;
char e[N][N];
void solve(){
	rep(i,1,n)scanf("%s",e[i]+1);
	vector<ll>ans(1,1);
	rep(i,2,n){
		ll fl=1,lst=-1;
		rep(j,0,(ll)ans.size()-2){
			ll es=e[ans[j]][ans[j+1]]-'0';
			if((!(~lst))||es==lst)lst=es;
			else fl=0;
		}
		if(fl)ans.push_back(i);
		else {
			rep(j,0,(ll)ans.size()-3){
				ll es1=e[ans[j]][ans[j+1]]-'0';
				ll es2=e[ans[j+1]][ans[j+2]]-'0';
				if(es1==0||es2==1)continue;
				ll es3=e[ans[j+1]][i]-'0';
				if(!es3)ans.insert(ans.begin()+j,i);
				else ans.insert(ans.begin()+j+1,i);
			}
		}
	}
	for(ll x:ans)write(x),putchar(' ');
	putchar('\n');
}
bool Med;
int main(){
	cerr<<fabs(&Med-&Mbe)/1048576.0<<"MB\n";
	while(cin>>n)solve();
	return 0;
}

详细

Test #1:

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

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: 0ms
memory: 3788kb

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