QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#409542#6774. Ancient Machine 2JohnAlfnov0 26ms4088kbC++201.2kb2024-05-12 11:01:482024-05-12 11:01:49

Judging History

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

  • [2024-05-12 11:01:49]
  • 评测
  • 测评结果:0
  • 用时:26ms
  • 内存:4088kb
  • [2024-05-12 11:01:48]
  • 提交

answer

#include<bits/stdc++.h>
#include "ancient2.h"
using namespace std;
int an[1005];
int ss[1005],nxt[1005];
string Solve(int N){
	for(int i=1;i<=500;++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-500;--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]!=0)r=nxt[r];
				if(ss[r+1]==1)n0=r+1;
				else n0=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;
	}
	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: 26ms
memory: 4088kb

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]