QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#520872#8650. Island Hoppinggreen_gold_dog#13 6ms4168kbC++201.2kb2024-08-15 16:55:062024-08-15 16:55:06

Judging History

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

  • [2024-08-15 16:55:06]
  • 评测
  • 测评结果:13
  • 用时:6ms
  • 内存:4168kb
  • [2024-08-15 16:55:06]
  • 提交

answer

#include "island.h"
#include<bits/stdc++.h>

using namespace std;

typedef int ll;

map<pair<ll, ll>, ll> mind;

ll get(ll x, ll y) {
	if (mind.find(make_pair(x, y)) != mind.end()) {
		return mind[make_pair(x, y)];
	}
	return mind[make_pair(x, y)] = query(x + 1, y + 1) - 1;
}

void ans(ll x, ll y) {
	answer(x + 1, y + 1);
}

struct DSU {
	vector<ll> p;
	DSU(ll n) {
		p.resize(n);
		for (ll i = 0; i < n; i++) {
			p[i] = i;
		}
	}
	ll get(ll v) {
		return (v == p[v] ? v : p[v] = get(p[v]));
	}
	bool unite(ll a, ll b) {
		a = get(a);
		b = get(b);
		if (a == b) {
			return false;
		}
		p[a] = b;
		return true;
	}
};

void solve(ll n, ll l) {
	vector<vector<ll>> to(n);
	vector<ll> col(n, 0);
	ll ost = n - 1;
	DSU d(n);
	for (ll i = 0; i < n; i++) {
		ll start = 0;
		for (auto j : to[i]) {
			if (j < i) {
				start++;
			}
		}
		while (start < n - 1 && start < 2 && ost > 0) {
			ll x = get(i, start);
			if (d.get(x) == d.get(i)) {
				break;
			}
			if (x < i) {
				break;
			}
			if (get(x, col[x]) == i) {
				col[x]++;
				ost--;
				to[i].push_back(x);
				to[x].push_back(i);
				d.unite(x, i);
			} else {
				break;
			}
			start++;
		}
	}
	for (ll i = 0; i < n; i++) {
		for (auto j : to[i]) {
			if (j > i) {
				ans(i, j);
			}
		}
	}
}

详细

Subtask #1:

score: 2
Accepted

Test #1:

score: 2
Accepted
time: 1ms
memory: 4112kb

input:

3 9
3
1
2
3
2
0
0

output:

1 1
3 1
1 2
2 1
3 2
-1 3
-2 3
0 0

result:

ok 

Test #2:

score: 2
Accepted
time: 1ms
memory: 3820kb

input:

3 9
3
1
2
3
2
0
0

output:

1 1
3 1
1 2
2 1
3 2
-1 3
-2 3
0 0

result:

ok 

Test #3:

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

input:

3 9
2
1
3
2
3
0
0

output:

1 1
2 1
1 2
3 1
2 2
-1 2
-2 3
0 0

result:

ok 

Subtask #2:

score: 4
Accepted

Test #4:

score: 4
Accepted
time: 2ms
memory: 3812kb

input:

299 89401
79
1
213
1
242
2
286
2
192
3
244
3
69
4
227
4
99
5
233
5
29
6
244
6
272
7
277
7
54
8
83
8
67
9
149
9
72
10
276
10
163
11
278
11
196
12
226
12
216
13
239
13
60
14
268
14
225
15
293
15
101
16
113
16
43
17
159
17
23
18
219
18
63
19
222
19
89
20
213
20
38
21
59
21
97
22
134
22
101
23
167
24
23...

output:

1 1
79 1
1 2
213 1
2 1
242 1
2 2
286 1
3 1
192 1
3 2
244 1
4 1
69 1
4 2
227 1
5 1
99 1
5 2
233 1
6 1
29 1
6 2
244 2
7 1
272 1
7 2
277 1
8 1
54 1
8 2
83 1
9 1
67 1
9 2
149 1
10 1
72 1
10 2
276 1
11 1
163 1
11 2
278 1
12 1
196 1
12 2
226 1
13 1
216 1
13 2
239 1
14 1
60 1
14 2
268 1
15 1
225 1
15 2
293...

result:

ok 

Test #5:

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

input:

300 90000
15
1
220
1
17
2
130
2
10
3
200
3
153
4
269
4
43
5
147
5
12
6
36
6
32
7
50
7
178
8
218
8
14
9
181
9
174
10
79
11
208
11
261
12
44
13
260
13
295
14
199
15
229
16
288
16
53
17
256
18
266
18
66
19
236
19
159
20
295
20
190
21
280
21
144
22
201
22
185
23
265
23
60
24
136
24
254
25
264
25
39
26
2...

output:

1 1
15 1
1 2
220 1
2 1
17 1
2 2
130 1
3 1
10 1
3 2
200 1
4 1
153 1
4 2
269 1
5 1
43 1
5 2
147 1
6 1
12 1
6 2
36 1
7 1
32 1
7 2
50 1
8 1
178 1
8 2
218 1
9 1
14 1
9 2
181 1
10 2
174 1
11 1
79 1
11 2
208 1
12 2
261 1
13 1
44 1
13 2
260 1
14 2
295 1
15 2
199 1
16 1
229 1
16 2
288 1
17 2
53 1
18 1
256 1
...

result:

ok 

Test #6:

score: 4
Accepted
time: 3ms
memory: 3812kb

input:

300 90000
171
1
201
1
20
2
209
2
47
3
131
3
17
4
250
4
208
5
284
5
27
6
83
6
25
7
61
7
119
8
196
8
40
9
157
9
167
10
196
10
62
11
100
11
209
12
256
12
163
13
184
13
65
14
297
14
157
15
193
15
99
16
161
16
272
17
198
18
267
18
29
19
158
19
261
20
36
21
237
21
57
22
171
22
73
23
214
23
119
24
246
24
1...

output:

1 1
171 1
1 2
201 1
2 1
20 1
2 2
209 1
3 1
47 1
3 2
131 1
4 1
17 1
4 2
250 1
5 1
208 1
5 2
284 1
6 1
27 1
6 2
83 1
7 1
25 1
7 2
61 1
8 1
119 1
8 2
196 1
9 1
40 1
9 2
157 1
10 1
167 1
10 2
196 2
11 1
62 1
11 2
100 1
12 1
209 2
12 2
256 1
13 1
163 1
13 2
184 1
14 1
65 1
14 2
297 1
15 1
157 2
15 2
193 ...

result:

ok 

Test #7:

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

input:

300 90000
176
1
297
1
43
2
45
2
168
3
254
3
100
4
285
4
290
5
291
5
171
6
234
6
121
7
299
7
196
8
238
8
199
9
210
9
189
10
232
10
12
11
261
11
284
12
238
13
251
13
67
14
173
14
17
15
288
15
24
16
115
16
242
17
90
18
166
18
125
19
142
19
56
20
161
20
138
21
276
21
165
22
170
22
111
23
124
23
133
24
1...

output:

1 1
176 1
1 2
297 1
2 1
43 1
2 2
45 1
3 1
168 1
3 2
254 1
4 1
100 1
4 2
285 1
5 1
290 1
5 2
291 1
6 1
171 1
6 2
234 1
7 1
121 1
7 2
299 1
8 1
196 1
8 2
238 1
9 1
199 1
9 2
210 1
10 1
189 1
10 2
232 1
11 1
12 1
11 2
261 1
12 2
284 1
13 1
238 2
13 2
251 1
14 1
67 1
14 2
173 1
15 1
17 1
15 2
288 1
16 1...

result:

ok 

Test #8:

score: 4
Accepted
time: 5ms
memory: 3884kb

input:

300 90000
96
1
162
1
28
2
282
2
19
3
239
3
107
4
161
4
160
5
165
5
259
6
271
6
34
7
90
7
114
8
169
8
78
9
188
9
92
10
146
10
219
11
226
11
100
12
258
12
61
13
140
13
129
14
174
14
44
15
251
15
196
16
283
16
39
17
199
17
125
18
154
18
127
19
24
20
300
20
73
21
205
21
77
22
171
22
130
23
193
23
68
24
...

output:

1 1
96 1
1 2
162 1
2 1
28 1
2 2
282 1
3 1
19 1
3 2
239 1
4 1
107 1
4 2
161 1
5 1
160 1
5 2
165 1
6 1
259 1
6 2
271 1
7 1
34 1
7 2
90 1
8 1
114 1
8 2
169 1
9 1
78 1
9 2
188 1
10 1
92 1
10 2
146 1
11 1
219 1
11 2
226 1
12 1
100 1
12 2
258 1
13 1
61 1
13 2
140 1
14 1
129 1
14 2
174 1
15 1
44 1
15 2
251...

result:

ok 

Subtask #3:

score: 7
Accepted

Test #9:

score: 7
Accepted
time: 0ms
memory: 4164kb

input:

299 598
43
1
151
1
91
2
119
2
7
3
130
3
115
4
139
4
50
5
109
5
157
6
176
6
181
7
106
8
138
8
147
9
235
9
44
10
197
10
31
11
64
11
150
12
210
12
195
13
271
13
113
14
196
14
265
15
295
15
171
16
251
16
47
17
145
17
103
18
106
18
35
19
270
19
199
20
259
20
27
21
283
21
70
22
144
22
274
23
298
23
82
24
...

output:

1 1
43 1
1 2
151 1
2 1
91 1
2 2
119 1
3 1
7 1
3 2
130 1
4 1
115 1
4 2
139 1
5 1
50 1
5 2
109 1
6 1
157 1
6 2
176 1
7 2
181 1
8 1
106 1
8 2
138 1
9 1
147 1
9 2
235 1
10 1
44 1
10 2
197 1
11 1
31 1
11 2
64 1
12 1
150 1
12 2
210 1
13 1
195 1
13 2
271 1
14 1
113 1
14 2
196 1
15 1
265 1
15 2
295 1
16 1
1...

result:

ok 

Test #10:

score: 7
Accepted
time: 0ms
memory: 3816kb

input:

300 600
26
1
95
1
33
2
74
2
65
3
160
3
25
4
186
4
30
5
158
5
147
6
251
6
152
7
226
7
62
8
178
8
55
9
226
9
96
10
228
10
61
11
256
11
135
12
234
12
103
13
172
13
165
14
203
14
40
15
109
15
107
16
176
16
78
17
272
17
215
18
299
18
92
19
110
19
50
20
108
20
112
21
200
21
56
22
229
22
48
23
282
23
68
24...

output:

1 1
26 1
1 2
95 1
2 1
33 1
2 2
74 1
3 1
65 1
3 2
160 1
4 1
25 1
4 2
186 1
5 1
30 1
5 2
158 1
6 1
147 1
6 2
251 1
7 1
152 1
7 2
226 1
8 1
62 1
8 2
178 1
9 1
55 1
9 2
226 2
10 1
96 1
10 2
228 1
11 1
61 1
11 2
256 1
12 1
135 1
12 2
234 1
13 1
103 1
13 2
172 1
14 1
165 1
14 2
203 1
15 1
40 1
15 2
109 1
...

result:

ok 

Test #11:

score: 7
Accepted
time: 3ms
memory: 3872kb

input:

300 600
44
1
267
1
251
2
287
2
33
3
141
3
107
4
235
4
74
5
244
5
15
6
139
6
118
7
198
7
34
8
76
8
40
9
227
9
138
10
211
10
43
11
274
11
18
12
279
12
58
13
77
13
49
14
83
14
171
15
108
16
166
16
109
17
165
17
60
18
158
19
295
19
253
20
282
20
32
21
94
21
87
22
275
22
131
23
143
23
68
24
277
24
156
25...

output:

1 1
44 1
1 2
267 1
2 1
251 1
2 2
287 1
3 1
33 1
3 2
141 1
4 1
107 1
4 2
235 1
5 1
74 1
5 2
244 1
6 1
15 1
6 2
139 1
7 1
118 1
7 2
198 1
8 1
34 1
8 2
76 1
9 1
40 1
9 2
227 1
10 1
138 1
10 2
211 1
11 1
43 1
11 2
274 1
12 1
18 1
12 2
279 1
13 1
58 1
13 2
77 1
14 1
49 1
14 2
83 1
15 2
171 1
16 1
108 1
1...

result:

ok 

Test #12:

score: 7
Accepted
time: 2ms
memory: 3884kb

input:

300 600
30
1
281
1
176
2
216
2
7
3
51
3
130
4
241
4
137
5
179
5
275
6
297
6
144
7
59
8
157
8
118
9
274
9
35
10
148
10
33
11
141
11
37
12
85
12
171
13
279
13
43
14
217
14
136
15
152
15
105
16
161
16
195
17
199
17
41
18
299
18
47
19
240
19
47
20
139
20
146
21
171
21
279
22
291
22
193
23
204
23
260
24
...

output:

1 1
30 1
1 2
281 1
2 1
176 1
2 2
216 1
3 1
7 1
3 2
51 1
4 1
130 1
4 2
241 1
5 1
137 1
5 2
179 1
6 1
275 1
6 2
297 1
7 2
144 1
8 1
59 1
8 2
157 1
9 1
118 1
9 2
274 1
10 1
35 1
10 2
148 1
11 1
33 1
11 2
141 1
12 1
37 1
12 2
85 1
13 1
171 1
13 2
279 1
14 1
43 1
14 2
217 1
15 1
136 1
15 2
152 1
16 1
105...

result:

ok 

Test #13:

score: 7
Accepted
time: 3ms
memory: 3948kb

input:

300 600
75
1
115
1
203
2
228
2
242
3
298
3
122
4
269
4
165
5
260
5
66
6
295
6
35
7
89
7
36
8
125
8
179
9
281
9
190
10
230
10
64
11
148
11
18
12
218
12
80
13
84
13
22
14
158
14
103
15
248
15
45
16
208
16
21
17
91
17
272
18
72
19
228
19
258
20
292
20
85
21
248
22
119
23
298
23
49
24
279
24
119
25
203
...

output:

1 1
75 1
1 2
115 1
2 1
203 1
2 2
228 1
3 1
242 1
3 2
298 1
4 1
122 1
4 2
269 1
5 1
165 1
5 2
260 1
6 1
66 1
6 2
295 1
7 1
35 1
7 2
89 1
8 1
36 1
8 2
125 1
9 1
179 1
9 2
281 1
10 1
190 1
10 2
230 1
11 1
64 1
11 2
148 1
12 1
18 1
12 2
218 1
13 1
80 1
13 2
84 1
14 1
22 1
14 2
158 1
15 1
103 1
15 2
248 ...

result:

ok 

Test #14:

score: 7
Accepted
time: 6ms
memory: 4168kb

input:

300 600
232
1
264
1
70
2
250
2
26
3
223
3
187
4
296
4
129
5
240
5
145
6
166
6
177
7
274
7
117
8
214
8
162
9
238
9
190
10
212
10
93
11
242
11
20
12
112
12
54
13
258
13
67
14
147
14
135
15
200
15
83
16
155
16
169
17
201
17
116
18
182
18
233
19
245
19
183
20
180
21
225
21
63
22
275
22
67
23
77
23
95
24...

output:

1 1
232 1
1 2
264 1
2 1
70 1
2 2
250 1
3 1
26 1
3 2
223 1
4 1
187 1
4 2
296 1
5 1
129 1
5 2
240 1
6 1
145 1
6 2
166 1
7 1
177 1
7 2
274 1
8 1
117 1
8 2
214 1
9 1
162 1
9 2
238 1
10 1
190 1
10 2
212 1
11 1
93 1
11 2
242 1
12 1
20 1
12 2
112 1
13 1
54 1
13 2
258 1
14 1
67 1
14 2
147 1
15 1
135 1
15 2
...

result:

ok 

Subtask #4:

score: 0
Wrong Answer

Test #15:

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

input:

299 89401
29
1
35
1
153
2
230
2
166
3
181
3
54
4
266
4
65
5
159
5
75
6
176
6
166
7
241
7
9
8
83
8
250
9
88
10
141
10
19
11
68
19
193
12
224
12
154
13
215
13
26
14
228
14
73
15
221
15
271
16
50
53
231
17
239
17
44
18
107
18
68
265
20
269
20
264
21
275
21
83
22
289
22
111
23
234
23
179
24
262
24
41
25...

output:

1 1
29 1
1 2
35 1
2 1
153 1
2 2
230 1
3 1
166 1
3 2
181 1
4 1
54 1
4 2
266 1
5 1
65 1
5 2
159 1
6 1
75 1
6 2
176 1
7 1
166 2
7 2
241 1
8 1
9 1
8 2
83 1
9 2
250 1
10 1
88 1
10 2
141 1
11 1
19 1
11 2
68 1
12 1
193 1
12 2
224 1
13 1
154 1
13 2
215 1
14 1
26 1
14 2
228 1
15 1
73 1
15 2
221 1
16 1
271 1
...

result:

wrong answer Wrong Answer [7]

Subtask #5:

score: 0
Wrong Answer

Test #23:

score: 0
Wrong Answer
time: 5ms
memory: 3944kb

input:

299 897
140
1
269
1
39
2
121
2
67
3
86
3
214
4
262
4
234
5
244
5
122
6
146
6
174
7
240
7
227
8
237
8
206
9
281
9
65
10
275
10
41
11
254
11
211
12
272
12
117
13
199
13
51
14
165
14
152
15
207
15
195
16
235
16
28
17
225
17
143
18
231
18
127
19
156
19
64
20
166
20
144
21
194
21
119
22
196
22
201
23
298...

output:

1 1
140 1
1 2
269 1
2 1
39 1
2 2
121 1
3 1
67 1
3 2
86 1
4 1
214 1
4 2
262 1
5 1
234 1
5 2
244 1
6 1
122 1
6 2
146 1
7 1
174 1
7 2
240 1
8 1
227 1
8 2
237 1
9 1
206 1
9 2
281 1
10 1
65 1
10 2
275 1
11 1
41 1
11 2
254 1
12 1
211 1
12 2
272 1
13 1
117 1
13 2
199 1
14 1
51 1
14 2
165 1
15 1
152 1
15 2
...

result:

wrong answer Wrong Answer [7]

Subtask #6:

score: 0
Wrong Answer

Test #32:

score: 0
Wrong Answer
time: 5ms
memory: 3868kb

input:

300 90000
133
1
179
1
82
2
47
82
65
3
165
65
266
4
283
4
29
5
40
5
24
6
35
6
28
7
234
7
86
8
199
86
186
9
299
54
109
10
231
10
29
11
221
11
105
12
112
12
128
13
277
13
117
14
126
14
108
15
231
108
247
16
118
77
131
12
234
18
7
94
19
210
19
141
20
181
20
160
21
197
21
26
22
208
22
219
23
235
104
268
...

output:

1 1
133 1
1 2
179 1
2 1
82 1
2 2
47 1
3 1
65 1
3 2
165 1
4 1
266 1
4 2
283 1
5 1
29 1
5 2
40 1
6 1
24 1
6 2
35 1
7 1
28 1
7 2
234 1
8 1
86 1
8 2
199 1
9 1
186 1
9 2
299 1
10 1
109 1
10 2
231 1
11 1
29 2
11 2
221 1
12 1
105 1
12 2
112 1
13 1
128 1
13 2
277 1
14 1
117 1
14 2
126 1
15 1
108 1
15 2
231 ...

result:

wrong answer Wrong Answer [7]

Subtask #7:

score: 0
Wrong Answer

Test #58:

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

input:

300 900
201
1
228
1
88
2
262
88
97
3
104
3
35
4
183
4
96
5
98
5
70
6
138
6
60
7
141
7
23
8
80
8
46
9
51
39
76
10
171
10
43
11
180
11
69
12
203
12
141
13
173
13
95
14
168
91
159
15
166
132
264
16
89
110
196
17
233
17
119
18
293
18
32
19
191
19
176
20
30
106
235
21
261
21
152
22
230
22
80
67
24
247
24...

output:

1 1
201 1
1 2
228 1
2 1
88 1
2 2
262 1
3 1
97 1
3 2
104 1
4 1
35 1
4 2
183 1
5 1
96 1
5 2
98 1
6 1
70 1
6 2
138 1
7 1
60 1
7 2
141 1
8 1
23 1
8 2
80 1
9 1
46 1
9 2
51 1
10 1
76 1
10 2
171 1
11 1
43 1
11 2
180 1
12 1
69 1
12 2
203 1
13 1
141 2
13 2
173 1
14 1
95 1
14 2
168 1
15 1
159 1
15 2
166 1
16 ...

result:

wrong answer Wrong Answer [7]

Subtask #8:

score: 0
Wrong Answer

Test #84:

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

input:

299 598
86
1
94
1
79
2
228
2
49
3
166
3
124
4
138
83
257
5
262
5
51
6
129
6
214
7
55
51
20
8
206
8
50
9
64
9
177
10
262
77
200
11
209
11
238
12
150
35
66
13
223
13
15
14
92
15
92
38
16
68
38
229
17
254
187
175
18
263
18
193
19
31
91
28
20
148
21
33
148
45
22
197
45
234
23
160
222
32
24
105
9
231
25
...

output:

1 1
86 1
1 2
94 1
2 1
79 1
2 2
228 1
3 1
49 1
3 2
166 1
4 1
124 1
4 2
138 1
5 1
257 1
5 2
262 1
6 1
51 1
6 2
129 1
7 1
214 1
7 2
55 1
8 1
20 1
8 2
206 1
9 1
50 1
9 2
64 1
10 1
177 1
10 2
262 2
11 1
200 1
11 2
209 1
12 1
238 1
12 2
150 1
13 1
66 1
13 2
223 1
14 1
15 1
14 2
92 1
15 2
16 1
38 1
16 2
68...

result:

wrong answer Wrong Answer [7]