QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#22036#2833. HamiltonLFCodeWA 3ms5820kbC++141.7kb2022-03-09 07:41:202022-04-30 00:42:20

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:42:20]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:5820kb
  • [2022-03-09 07:41:20]
  • 提交

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);
					}
					break;
				}
			}
			if(ovo.size()==i-1){
				if(ch[i][ovo[0]]=='0')ovo.pb(i);
				else ovo.insert(ovo.begin(),i);
			}
		}
		for(auto i:ovo)printf("%d ",i);
		printf("\n");
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
001
000
100
4
0000
0000
0000
0000

output:

3 1 2 
1 2 3 4 

result:

ok 2 cases.

Test #2:

score: 0
Accepted
time: 0ms
memory: 5768kb

input:

3
000
000
000
3
010
100
000
3
011
100
100
3
011
101
110

output:

1 2 3 
1 2 3 
3 1 2 
3 1 2 

result:

ok 4 cases.

Test #3:

score: -100
Wrong Answer
time: 2ms
memory: 5788kb

input:

4
0000
0000
0000
0000
4
0000
0001
0000
0100
4
0100
1010
0100
0000
4
0111
1000
1000
1000
4
0010
0011
1101
0110
4
0111
1011
1100
1100
4
0111
1011
1101
1110
4
0000
0011
0101
0110
4
0101
1010
0100
1000
4
0011
0011
1100
1100
4
0010
0001
1000
0100

output:

1 2 3 4 
1 2 3 4 
3 1 4 2 
3 1 2 4 
3 1 4 2 
4 3 1 2 
4 3 1 2 
3 1 4 2 
3 4 1 2 
4 3 1 2 
4 3 1 2 

result:

wrong answer case #5: found 2 indices