QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#22014#2833. HamiltonLFCodeWA 5ms5856kbC++141.7kb2022-03-08 21:58:562022-04-30 00:41:04

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-30 00:41:04]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:5856kb
  • [2022-03-08 21:58:56]
  • 提交

answer

#include<bits/stdc++.h>
#include<cstdio>
#include<cctype>
#define ll long long
#define PI pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define ui unsigned int
#define pb push_back
#define llu long long unsigned
using namespace std;
const int MB=1<<20;
struct FastIO{
	char ib[MB+100],*p,*q;
	char ob[MB+100],*r,stk[128];
	int tp;
	FastIO(){p=q=ib,r=ob,tp=0;}
	~FastIO(){fwrite(ob,1,r-ob,stdout);}
	char read_char(){if(p==q){p=ib,q=ib+fread(ib,1,MB,stdin);if(p==q)return 0;}return *p++;}
	template<typename T>
	void read_int(T& x){char c=read_char(),l=0;for(x=0;!isdigit(c);c=read_char())l=c;for(;isdigit(c);c=read_char())x=x*10-'0'+c;if(l=='-')x=-x;}
	void write_char(char c){if(r-ob==MB)r=ob,fwrite(ob,1,MB,stdout);*r++=c;}
	template<typename T>
	void write_int(T x){if(x<0)write_char('-'),x=-x;do stk[++tp]=x%10+'0';while(x/=10);while(tp)write_char(stk[tp--]);}
}IO;
//IO.read_int(a);c=IO.read_char();IO.write_int(a);//IO.write_char(c);
const int N=2010;
int T,n,a[N];
char ch[N][N];
vector<int> ovo;
int main(){
//	scanf("%d",&T);
	while(scanf("%d",&n)!=EOF){
		for(int i=1;i<=n;i++){
			scanf("%s",ch[i]+1);
		}
		ovo.clear();
		ovo.pb(1);ovo.pb(2);
		for(int i=3;i<=n;i++){
			int bef=ovo[i-2];
			if(ch[i][bef]==1&&ch[i][ovo[0]]==0){
				ovo.insert(ovo.begin(),i);
			}
			else 
			for(int o=1;o<i-1;o++){
				if(ch[ovo[o-1]][ovo[o]]!=ch[ovo[o]][ovo[(o+1)%(i-1)]]){
					if(ch[ovo[o]][i]==1){
						ovo.insert(ovo.begin()+o,i);
					}
					else{
						ovo.insert(ovo.begin()+o+1,i);
					}
				}
			}
			if(ovo.size()==i-1){
				ovo.pb(i);
			}
		}
		for(auto i:ovo)printf("%d ",i);
		printf("\n");
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 5ms
memory: 5820kb

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: 5856kb

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