QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#93985#216. Sonda [A]Crysfly0 11ms4928kbC++172.8kb2023-04-04 15:34:152023-04-04 15:34:18

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-04 15:34:18]
  • 评测
  • 测评结果:0
  • 用时:11ms
  • 内存:4928kb
  • [2023-04-04 15:34:15]
  • 提交

answer

#include "sonlib.h"
// what is matter? never mind.
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef vector<pii>vpii;

#define maxn 1000005
#define inf 0x3f3f3f3f

int n;
int e[505][505];
int vis[505],vis2[505],ok[505];

int mov(int d,int E=-1){
	int res=MoveProbe(d);
	if(E!=-1) assert(res==E);
	return res;
}
void adde(int u,int v){
	e[u][v]=e[v][u]=1;
	ok[u]=ok[v]=1;
}
void no(int u,int v){
	e[u][v]=e[v][u]=-1;
}

void tri(int a,int b,int c);

void work(int u,int beg){
	if(vis[u])return;
	vis[u]=vis2[u]=1;
	For(i,1,n){
		if(ok[i]||e[u][i]==-1)continue;
		if(!mov(i)) no(u,i);
		else{
			adde(u,i);
			tri(i,u,beg);
			mov(u);
		}
	}
}
void tri(int a,int b,int c){
	if(vis2[a])return;
	vis2[a]=1;
	mov(b,0); work(b,a);
	mov(a,1);
	mov(c,0);
	if(mov(b)){
		// triangle
		adde(a,c);
		mov(a,0),work(a,b);
		mov(b,1),mov(c,0),work(c,b);
		mov(a,1);
		return;
	}
	else mov(a,1),no(a,c);
	vis[a]=vis2[a]=1;
	// query out all (a,i)
	For(i,1,n){
		if(ok[i]||e[a][i]==-1)continue;
		mov(i,0);
		if(mov(c)){
			adde(a,i),adde(c,i);
			mov(i,0); work(i,a);
			mov(a,1);
			continue;
		}
		if(mov(b)){
			adde(a,i),adde(b,i),no(c,i);
			mov(i,0),work(i,b);
			mov(a,1);
			continue;
		}
		if(mov(c)){
			no(a,i);
			tri(c,b,a);
			mov(b),mov(a);
			continue;
		}
		adde(a,i),no(b,i),no(c,i);
		work(i,a);
		mov(a);
	}
	if(!vis2[c]){
		mov(b,0),mov(c,1);
		tri(c,b,a);
		mov(b,0),mov(a,1);
	}
}

bool done[maxn];
void dfs(int u){
	Examine(); done[u]=1;
	For(i,1,n) if(!done[i] && e[u][i]==1) mov(i),dfs(i),mov(u); 
}

vi path(){
	vi o;
	For(i,0,n-1){
		For(j,0,n-2){
			int u=(i+j)%(n-2)+2;
			if(mov(u)){
				vi o;
				o.pb(1);
				For(k,0,j)o.pb((i+k)%(n-2)+2);
				reverse(o.begin(),o.end());
				return o;
			}
		}
		mov(1,1);
	}
	return {};
} 

void end_tri(int a,int b,int c){
	adde(a,b),adde(b,c);
	tri(a,b,c);
	dfs(a); exit(0);
}

vi p;

signed main()
{
	n=GetN();
	p=path();
	if(!p.size()){
		For(i,2,n)adde(1,i);
		dfs(1); exit(0);
	}
	int s=p[0],t=p.back();
	p.pop_back(),p.erase(p.begin());
	while(p.size()>1){
		bool close=0;
		For(i,0,(int)p.size()-1){
			if(mov(p[i])){
				t=s,s=p[i];
				p.resize(i);
				reverse(p.begin(),p.end());
				close=1;
				break;
			}
		}
		if(close)continue;
		mov(t,1);
		swap(s,t),reverse(p.begin(),p.end());
		for(auto x:p){
			mov(x,0);
			if(mov(t)) end_tri(s,x,t);
		}
	}
	end_tri(s,p[0],t);
//	if(GetSubtask()!=2)exit(233);
//	adde(1,2),adde(2,3);
//	tri(1,2,3);
//	dfs(1);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3664kb

input:

3 2 1
1 2
1 3

output:

ERROR: ruch z punktu 2 do siebie samego

result:

wrong answer 

Subtask #2:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 2ms
memory: 3692kb

input:

3 3 2
2 1
1 3
2 3

output:

ERROR: ruch z punktu 2 do siebie samego

result:

wrong answer 

Subtask #3:

score: 0
Wrong Answer

Test #41:

score: 0
Wrong Answer
time: 2ms
memory: 3612kb

input:

3 3 3
1 2
2 3
3 1

output:

ERROR: ruch z punktu 2 do siebie samego

result:

wrong answer 

Subtask #4:

score: 0
Wrong Answer

Test #64:

score: 0
Wrong Answer
time: 2ms
memory: 3612kb

input:

3 2 0
1 2
1 3

output:

ERROR: ruch z punktu 2 do siebie samego

result:

wrong answer 

Subtask #5:

score: 0
Wrong Answer

Test #87:

score: 1
Accepted
time: 1ms
memory: 3684kb

input:

29 127 0
1 2
1 3
1 4
1 5
1 7
1 9
1 10
1 16
1 19
1 27
1 29
2 7
2 9
2 10
2 12
2 13
2 15
2 16
2 22
2 23
3 4
3 5
3 6
3 10
3 13
3 14
3 16
3 17
3 19
3 24
3 25
3 29
4 5
4 8
4 9
4 10
4 12
4 14
4 19
4 20
4 21
4 22
4 24
4 25
5 11
5 18
5 23
6 7
6 17
6 20
6 22
6 27
7 8
7 10
7 17
7 19
7 20
8 10
8 11
8 13
8 18
8 ...

output:

OK, 497 wywolan MoveProbe()

result:

ok 

Test #88:

score: 0
Accepted
time: 2ms
memory: 3720kb

input:

30 431 0
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
2 11
2 12
2 13
2 14
2 15
2 16
2 17
2 18
2 19
2 20
2 21
2 22
2 23
2 24
2 25
2 26
2 27
2 28
2 29
2 30
3 4
3 5
3 6
3 7
3 8
3...

output:

OK, 301 wywolan MoveProbe()

result:

ok 

Test #89:

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

input:

30 57 0
1 2
1 4
1 10
1 14
1 20
1 30
2 10
2 15
2 27
2 30
3 6
3 16
3 23
4 6
5 13
5 19
5 29
6 20
6 22
6 24
7 16
7 22
7 26
8 23
9 20
10 20
10 24
10 28
11 24
12 17
12 23
12 30
13 15
13 17
13 23
13 25
14 21
15 18
15 24
16 19
16 22
16 28
17 18
17 20
17 21
17 29
18 20
18 29
19 21
19 29
21 27
22 27
22 29
23 ...

output:

OK, 869 wywolan MoveProbe()

result:

ok 

Test #90:

score: -1
Wrong Answer
time: 2ms
memory: 3612kb

input:

30 29 0
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30

output:

ERROR: ruch z punktu 2 do siebie samego

result:

wrong answer 

Subtask #6:

score: 0
Wrong Answer

Test #104:

score: 0
Wrong Answer
time: 2ms
memory: 3680kb

input:

80 79 0
1 64
64 41
41 74
74 23
23 49
49 19
19 42
42 27
27 11
11 18
18 45
45 69
69 12
12 31
31 8
8 29
29 57
57 13
13 76
76 38
38 14
14 16
16 51
51 5
5 75
75 46
46 58
58 7
7 61
41 78
13 28
1 54
46 2
29 35
69 73
1 43
13 44
23 77
69 79
27 63
41 24
31 68
7 48
27 60
46 30
18 32
1 21
46 36
69 53
27 10
18 6...

output:

ERROR: ruch z punktu 21 do siebie samego

result:

wrong answer 

Subtask #7:

score: 0
Dangerous Syscalls

Test #121:

score: 1
Accepted
time: 0ms
memory: 4020kb

input:

150 1602 0
1 7
1 17
1 18
1 24
1 41
1 42
1 46
1 47
1 48
1 51
1 64
1 66
1 71
1 76
1 78
1 80
1 87
1 98
1 117
1 118
1 132
1 137
1 142
1 148
2 3
2 5
2 7
2 17
2 18
2 25
2 37
2 61
2 67
2 101
2 120
2 125
2 140
3 8
3 15
3 25
3 33
3 34
3 37
3 38
3 61
3 66
3 72
3 75
3 76
3 81
3 85
3 88
3 93
3 103
3 108
3 111
3...

output:

OK, 3719 wywolan MoveProbe()

result:

ok 

Test #122:

score: 0
Accepted
time: 3ms
memory: 4072kb

input:

150 11175 0
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1...

output:

OK, 1629 wywolan MoveProbe()

result:

ok 

Test #123:

score: 0
Accepted
time: 2ms
memory: 4072kb

input:

150 341 0
1 4
1 55
1 56
1 110
1 118
1 140
2 114
2 131
2 148
3 14
3 69
3 121
4 12
4 20
4 117
5 21
5 24
6 18
6 29
6 50
6 74
6 104
7 10
7 36
7 55
7 68
7 82
7 93
7 113
7 114
8 45
8 129
9 20
9 120
10 78
10 92
11 57
11 80
11 95
11 109
11 136
11 144
12 104
12 132
13 41
13 62
13 83
13 108
14 30
14 69
14 126...

output:

OK, 16797 wywolan MoveProbe()

result:

ok 

Test #124:

score: 0
Accepted
time: 2ms
memory: 4004kb

input:

149 155 0
1 110
110 59
1 78
110 92
59 139
1 30
59 114
1 93
114 67
1 143
59 119
92 27
93 50
27 61
93 98
50 66
98 60
110 97
61 144
92 89
60 99
144 26
110 138
26 136
61 76
114 39
136 135
27 103
103 51
76 63
98 2
139 7
2 17
1 24
103 84
1 111
50 70
99 21
143 31
78 113
113 52
139 12
7 83
143 81
21 141
17 ...

output:

OK, 35988 wywolan MoveProbe()

result:

ok 

Test #125:

score: 0
Accepted
time: 2ms
memory: 4020kb

input:

150 150 0
1 100
100 10
10 61
61 94
94 121
121 122
122 13
13 15
15 44
44 39
39 108
108 76
76 4
4 127
127 57
57 9
9 54
54 71
71 31
31 98
98 125
125 32
32 111
111 86
86 110
110 79
79 103
103 63
63 28
28 72
72 80
80 30
80 59
59 33
33 90
90 136
136 109
136 40
40 5
5 67
67 85
85 101
101 34
34 74
74 58
58 ...

output:

OK, 23881 wywolan MoveProbe()

result:

ok 

Test #126:

score: -1
Dangerous Syscalls

input:

150 149 0
1 51
51 81
81 37
37 67
67 130
130 99
99 120
120 54
54 50
50 24
24 83
83 43
43 101
101 90
90 127
127 138
138 93
93 111
111 70
70 92
92 11
11 56
56 17
17 32
32 26
26 9
9 97
97 136
136 29
29 107
107 123
123 133
133 40
40 7
7 2
2 105
105 45
45 145
145 61
61 98
98 15
15 3
3 82
82 58
58 131
131 ...

output:

Unauthorized output

result:


Subtask #8:

score: 0
Wrong Answer

Test #139:

score: 1
Accepted
time: 1ms
memory: 4396kb

input:

246 281 0
1 2
2 3
2 4
2 5
2 6
1 7
7 8
7 10
7 11
8 9
1 12
12 14
12 15
12 16
13 14
1 17
17 18
17 19
17 20
17 21
18 19
1 22
22 23
22 24
22 26
23 25
1 27
27 29
27 30
27 31
28 30
1 32
32 33
32 34
32 35
32 36
33 35
1 37
37 38
37 41
38 39
38 40
1 42
42 44
42 46
43 44
43 45
1 47
47 48
47 49
47 51
48 49
48 5...

output:

OK, 107245 wywolan MoveProbe()

result:

ok 

Test #140:

score: 0
Accepted
time: 1ms
memory: 4356kb

input:

246 291 0
1 2
2 3
2 6
3 4
4 5
1 7
7 9
7 11
8 9
9 10
1 12
12 13
12 14
12 16
13 14
14 15
1 17
17 20
17 21
18 19
19 20
1 22
22 23
22 25
22 26
23 24
24 25
1 27
27 29
27 30
27 31
28 29
29 30
1 32
32 33
32 34
32 35
32 36
33 34
34 35
1 37
37 38
37 41
38 40
39 40
1 42
42 44
42 46
43 45
44 45
1 47
47 48
47 4...

output:

OK, 99088 wywolan MoveProbe()

result:

ok 

Test #141:

score: 0
Accepted
time: 2ms
memory: 4356kb

input:

246 306 0
1 2
2 3
2 5
3 5
3 6
4 5
1 7
7 9
7 10
8 10
8 11
9 10
1 12
12 13
12 14
12 15
13 15
13 16
14 15
1 17
17 21
18 20
18 21
19 20
1 22
22 23
22 26
23 25
23 26
24 25
1 27
27 29
27 31
28 30
28 31
29 30
1 32
32 33
32 34
32 36
33 35
33 36
34 35
1 37
37 40
37 41
38 40
38 41
39 40
1 42
42 43
42 45
42 46...

output:

OK, 87363 wywolan MoveProbe()

result:

ok 

Test #142:

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

input:

246 330 0
1 2
2 4
2 6
3 5
4 5
5 6
1 7
7 8
7 9
7 11
8 10
9 10
10 11
1 12
12 15
12 16
13 15
14 15
15 16
1 17
17 18
17 20
17 21
18 20
19 20
20 21
1 22
22 24
22 25
22 26
23 25
24 25
25 26
1 27
27 28
27 29
27 30
27 31
28 30
29 30
30 31
1 32
32 33
33 34
33 35
34 35
35 36
1 37
37 39
38 39
38 40
39 40
40 41...

output:

OK, 87435 wywolan MoveProbe()

result:

ok 

Test #143:

score: 0
Accepted
time: 1ms
memory: 4404kb

input:

250 5371 0
1 3
1 7
1 12
1 13
1 23
1 30
1 34
1 35
1 36
1 37
1 47
1 52
1 53
1 57
1 60
1 61
1 65
1 70
1 74
1 110
1 113
1 115
1 125
1 134
1 136
1 138
1 143
1 148
1 172
1 184
1 192
1 197
1 199
1 200
1 202
1 209
1 212
1 216
1 227
1 245
2 24
2 44
2 48
2 52
2 60
2 63
2 72
2 77
2 89
2 91
2 93
2 95
2 98
2 104...

output:

OK, 6136 wywolan MoveProbe()

result:

ok 

Test #144:

score: 0
Accepted
time: 5ms
memory: 4408kb

input:

250 31125 0
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1...

output:

OK, 2729 wywolan MoveProbe()

result:

ok 

Test #145:

score: -1
Wrong Answer
time: 0ms
memory: 3924kb

input:

250 254 0
1 70
1 172
1 34
1 195
70 28
1 250
1 39
1 83
1 50
70 205
1 100
1 221
1 179
70 143
1 64
1 149
1 222
1 166
1 110
1 41
50 208
195 185
250 176
34 31
172 148
28 211
1 53
1 89
34 190
1 174
1 134
70 58
1 67
172 49
172 81
1 44
70 74
1 94
1 162
1 66
70 127
1 71
1 8
195 186
1 175
70 181
1 107
64 29
1...

output:

ERROR: ruch z punktu 8 do siebie samego

result:

wrong answer 

Subtask #9:

score: 0
Wrong Answer

Test #157:

score: 1
Accepted
time: 4ms
memory: 4848kb

input:

346 437 0
1 2
2 3
2 5
3 4
3 5
4 6
1 7
7 9
7 10
8 9
8 10
9 11
1 12
12 13
12 14
12 15
13 14
13 15
14 16
1 17
17 21
18 19
18 20
19 21
1 22
22 23
22 26
23 24
23 25
24 26
1 27
27 29
27 31
28 29
28 30
29 31
1 32
32 33
32 34
32 36
33 34
33 35
34 36
1 37
37 40
37 41
38 39
38 40
39 41
1 42
42 43
42 45
42 46
...

output:

OK, 179153 wywolan MoveProbe()

result:

ok 

Test #158:

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

input:

346 456 0
1 2
2 6
3 4
4 5
4 6
1 7
7 8
7 11
8 9
9 10
9 11
1 12
12 14
12 16
13 14
14 15
14 16
1 17
17 18
17 19
17 21
18 19
19 20
19 21
1 22
22 25
22 26
23 24
24 25
24 26
1 27
27 28
27 30
27 31
28 29
29 30
29 31
1 32
32 34
32 35
32 36
33 34
34 35
34 36
1 37
37 38
37 39
37 40
37 41
38 39
39 40
39 41
1 4...

output:

OK, 170266 wywolan MoveProbe()

result:

ok 

Test #159:

score: 0
Accepted
time: 4ms
memory: 4780kb

input:

346 455 0
1 2
2 4
3 5
3 6
4 5
4 6
1 7
7 8
7 9
8 10
8 11
9 10
9 11
1 12
12 15
13 15
13 16
14 15
14 16
1 17
17 18
17 20
18 20
18 21
19 20
19 21
1 22
22 24
22 25
23 25
23 26
24 25
24 26
1 27
27 28
27 29
27 30
28 30
28 31
29 30
29 31
1 32
32 36
33 35
33 36
34 35
34 36
1 37
37 38
37 41
38 40
38 41
39 40
...

output:

OK, 171999 wywolan MoveProbe()

result:

ok 

Test #160:

score: 0
Accepted
time: 2ms
memory: 4780kb

input:

346 436 0
1 2
2 3
2 4
2 5
2 6
3 6
5 6
1 7
7 8
8 9
8 11
10 11
1 12
12 14
13 14
13 16
15 16
1 17
17 18
17 19
18 19
18 21
20 21
1 22
22 25
23 24
23 26
25 26
1 27
27 28
27 30
28 29
28 31
30 31
1 32
32 34
32 35
33 34
33 36
35 36
1 37
37 38
37 39
37 40
38 39
38 41
40 41
1 42
42 46
43 44
43 46
45 46
1 47
4...

output:

OK, 175058 wywolan MoveProbe()

result:

ok 

Test #161:

score: 0
Accepted
time: 4ms
memory: 4848kb

input:

350 7941 0
1 4
1 5
1 19
1 35
1 37
1 44
1 55
1 56
1 60
1 69
1 72
1 73
1 75
1 78
1 88
1 98
1 102
1 106
1 118
1 124
1 126
1 139
1 140
1 144
1 146
1 147
1 148
1 182
1 183
1 185
1 187
1 188
1 194
1 201
1 228
1 234
1 243
1 249
1 256
1 263
1 275
1 276
1 288
1 294
1 336
1 340
1 343
1 349
2 10
2 21
2 22
2 38...

output:

OK, 11037 wywolan MoveProbe()

result:

ok 

Test #162:

score: 0
Accepted
time: 11ms
memory: 4928kb

input:

350 61075 0
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1...

output:

OK, 3829 wywolan MoveProbe()

result:

ok 

Test #163:

score: -1
Wrong Answer
time: 0ms
memory: 4140kb

input:

349 354 0
1 62
1 43
1 200
1 13
1 85
1 244
1 243
1 316
1 291
62 136
1 283
1 161
1 93
1 65
1 311
1 348
1 90
1 320
1 107
1 96
1 127
1 182
1 35
1 234
13 272
1 278
1 223
1 303
62 250
1 155
1 184
1 59
62 89
62 301
1 340
1 202
1 126
1 128
1 134
62 193
1 87
1 130
1 218
1 334
1 144
1 164
1 79
1 257
1 171
62 ...

output:

ERROR: ruch z punktu 3 do siebie samego

result:

wrong answer 

Subtask #10:

score: 0
Wrong Answer

Test #174:

score: 0
Wrong Answer
time: 3ms
memory: 4304kb

input:

400 399 0
1 286
286 266
266 368
368 104
104 214
214 154
154 206
206 255
255 336
336 246
246 106
106 372
372 153
153 159
159 383
383 12
12 209
209 37
37 130
130 165
165 20
20 207
207 345
345 126
126 185
185 94
94 374
374 192
192 396
396 127
127 253
253 134
134 135
135 24
24 276
276 132
132 329
329 2
...

output:

ERROR: ruch z punktu 45 do siebie samego

result:

wrong answer