QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#22040#2833. HamiltonLFCodeWA 2ms5876kbC++142.3kb2022-03-09 08:23:592022-04-30 00:42:44

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:44]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:5876kb
  • [2022-03-09 08:23:59]
  • 提交

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];
int ovo[N*2];
int front,back;
int main(){
//	scanf("%d",&T);
	while(scanf("%d",&n)!=EOF){
		memset(ovo,0,sizeof(ovo));
		for(int i=1;i<=n;i++){
			scanf("%s",ch[i]+1);
		}
		if(ch[1][2]=='1'){
			front=N,back=N+1;
			ovo[front]=1;ovo[back]=2;
		}
		else{
			front=N-1,back=N;
			ovo[front]=1;ovo[back]=2;
		}
		int mid=N;
		for(int i=3;i<=n;i++){
			if(ch[ovo[mid]][i]=='1'){
				for(int io=1;io<=mid-1;io++){
					ovo[io]=ovo[io+1];
				}
				ovo[mid-1]=i;
				front--;
				int bef=ovo[mid-2];
				if(front==mid-1)bef=ovo[back];
				if(ch[ovo[mid-1]][bef]=='1'){
					if(bef==ovo[back]){
						front++;
						back++;
						ovo[back]=i;
					}
					else{
						mid-=2;
					}
				}
				else{
					if(bef==ovo[back]){
						front--;
						ovo[front]=ovo[back];
						back--;
						mid--;
					}
					else{
						mid--;
					}
				}
			}
			else{
				for(int io=N*2-1;io>=mid+1;io--){
					ovo[io]=ovo[io-1];
				}
				ovo[mid+1]=i;
				back++;
				int bef=ovo[mid+2];
				if(back==mid+1)bef=ovo[front];
				if(ch[ovo[mid+1]][bef]=='1'){
					mid++;
				}
				else{
					if(bef==ovo[front]){
						mid++;
					}
					else{
						mid+=2;
					}
				}
			}
		}
		for(int i=front;i<=back;i++)printf("%d ",ovo[i]);
		printf("\n");
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 5876kb

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: 0
Accepted
time: 0ms
memory: 5804kb

input:

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

output:

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

result:

ok 4 cases.

Test #3:

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

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 
1 3 4 2 
2 3 4 1 
1 4 3 2 
3 4 1 2 
1 2 3 4 
1 4 3 2 
1 3 4 2 
1 3 2 4 
1 2 3 4 

result:

wrong answer case #5: found 2 indices