QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#409574#6774. Ancient Machine 2JohnAlfnov0 13ms4156kbC++202.0kb2024-05-12 11:37:492024-05-12 11:37:51

Judging History

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

  • [2024-05-12 11:37:51]
  • 评测
  • 测评结果:0
  • 用时:13ms
  • 内存:4156kb
  • [2024-05-12 11:37:49]
  • 提交

answer

#include<bits/stdc++.h>
#include "ancient2.h"
using namespace std;
int an[1005];
int ss[1005],nxt[1005];
bitset<1005>e[1005];
int ee[1005];
string Solve(int N){
	for(int i=1;i<=1000;++i)e[i].reset(),ee[i]=0;
	for(int i=1;i<=100;++i){
		vector<int>A;
		vector<int>B;
		for(int j=0;j<i-1;++j){
			A.emplace_back(j+1);
			B.emplace_back(j+1);
		}
		A.emplace_back(i);B.emplace_back(i+1);
		A.emplace_back(i);B.emplace_back(i);
		A.emplace_back(i+1);B.emplace_back(i+1);
		int x=Query(i+2,A,B);
		if(x==i)an[i]=0;
		else an[i]=1;
	}
	for(int i=N;i>N-100;--i){
		int l=N-i+1;
		for(int j=1;j<=l;++j){
			if(j==1)ss[j]=0;
			else ss[j]=an[i+j-1];
		}
		nxt[1]=0;
		for(int j=2;j<=l;++j){
			int r=nxt[j-1];
			while(r&&ss[r+1]!=ss[j])r=nxt[r];
			if(ss[r+1]==ss[j])nxt[j]=r+1;
			else nxt[j]=0;
		}
		vector<int>A,B;
		for(int j=0;j<=l;++j){
			int n0=0,n1=0;
			if(j<l&&ss[j+1]==0)n0=j+1;
			else{
				int r=nxt[j];
				while(r&&ss[r+1]!=0)r=nxt[r];
				if(ss[r+1]==0)n0=r+1;
				else n0=0;
			}
			if(j<l&&ss[j+1]==1)n1=j+1;
			else{
				int r=nxt[j];
				while(r&&ss[r+1]!=1)r=nxt[r];
				if(ss[r+1]==1)n1=r+1;
				else n1=0;
			}
			A.emplace_back(n0);
			B.emplace_back(n1);
		}
		int x=Query(l+1,A,B);
		if(x==l)an[i]=0;
		else an[i]=1;
	}
	for(int p=1;p<=51;++p)for(int q=0;q<p;++q){
		bitset<1005>bs;
		for(int i=1;i<=N;++i)if(i>100&&i<=N-100&&(i-1)%p==q)bs.set(i);
		int yh=0,wz=0;
		for(int i=N;i>=1;--i)if(bs[i]){
			if(!ee[i]){
				wz=i;
				break;
			}
			bs^=e[i];yh^=(ee[i]==1?1:0);
		}
		if(wz){
			vector<int>A(2*p),B(2*p);
			for(int i=0;i<p;++i)A[i]=B[i]=(i+1)%p;
			for(int i=p;i<2*p;++i)A[i]=B[i]=(i+1)%p+p;
			swap(B[q],B[q+p]);
			int x=Query(2*p,A,B);
			if(x>=p)yh^=1;
		}
		e[wz]=bs;ee[wz]=(yh==1?1:-1);
	}
	for(int i=101;i<=N-100;++i){
		bitset<1005>bs;
		bs[i]=1;
		int yh=0;
		for(int i=N;i>=1;--i)if(bs[i]){
			bs^=e[i];yh^=(ee[i]==1?1:0);
		}
		an[i]=yh;
	}
	string st;
	for(int i=1;i<=N;++i)st+=an[i]+'0';
	return st;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 13ms
memory: 4156kb

input:

1000
2
3
4
5
6
7
8
9
10
11
12
13
14
14
16
16
18
18
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
39
40
41
42
43
44
45
46
47
48
50
51
52
53
53
55
55
57
57
59
59
61
61
62
64
64
65
66
67
68
69
70
71
72
74
75
76
77
78
79
79
80
81
82
83
84
85
86
87
89
89
90
91
92
93
94
95
97
98
99
100
100
1...

output:

Q
3
1
1
2
2
1
2
Q
4
1
2
2
3
1
3
2
3
Q
5
1
2
3
3
4
1
2
4
3
4
Q
6
1
2
3
4
4
5
1
2
3
5
4
5
Q
7
1
2
3
4
5
5
6
1
2
3
4
6
5
6
Q
8
1
2
3
4
5
6
6
7
1
2
3
4
5
7
6
7
Q
9
1
2
3
4
5
6
7
7
8
1
2
3
4
5
6
8
7
8
Q
10
1
2
3
4
5
6
7
8
8
9
1
2
3
4
5
6
7
9
8
9
Q
11
1
2
3
4
5
6
7
8
9
9
10
1
2
3
4
5
6
7
8
10
9
10
Q
12
1
...

result:

wrong answer Wrong Answer [3]