#include "xylophone.h"
#include "bits/stdc++.h"
using namespace std;
int my_query(int l, int r, vector <int> &a) {
int mx = -1e9, mn = 1e9;
for (int i = l; i <= r; ++i) {
mx = max(mx, a[i]);
mn = min(mn, a[i]);
}
return mx - mn;
}
void solve(int n) {
vector <int> a(n + 1);
a[1] = 0;
a[2] = query(1, 2);
for (int i = 3; i <= n; ++i) {
int x = query(i - 2, i);
int y = query(i - 1, i);
for (int z = -n; z <= n; ++z) {
a[i] = z;
if (my_query(i - 2, i, a) == x && my_query(i - 1, i, a) == y) {
break;
}
}
}
int mn = 1e9;
for (int i = 1; i <= n; ++i) mn = min(mn, a[i]);
for (int i = 1; i <= n; ++i) a[i] -= mn - 1;
bool fl = false;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
if (a[i] == 1 && a[j] == n) {
if (i > j) {
fl = true;
}
}
}
}
if (fl) {
for (int i = 1; i <= n; ++i) {
a[i] = n - a[i] + 1;
}
}
for (int i = 1; i <= n; ++i) {
answer(i, a[i]);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
252 KB |
Output is correct |
4 |
Correct |
4 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
248 KB |
Output is correct |
7 |
Correct |
4 ms |
248 KB |
Output is correct |
8 |
Correct |
4 ms |
248 KB |
Output is correct |
9 |
Correct |
4 ms |
376 KB |
Output is correct |
10 |
Correct |
4 ms |
248 KB |
Output is correct |
11 |
Correct |
3 ms |
248 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
4 ms |
376 KB |
Output is correct |
14 |
Correct |
4 ms |
244 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
252 KB |
Output is correct |
4 |
Correct |
4 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
248 KB |
Output is correct |
7 |
Correct |
4 ms |
248 KB |
Output is correct |
8 |
Correct |
4 ms |
248 KB |
Output is correct |
9 |
Correct |
4 ms |
376 KB |
Output is correct |
10 |
Correct |
4 ms |
248 KB |
Output is correct |
11 |
Correct |
3 ms |
248 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
4 ms |
376 KB |
Output is correct |
14 |
Correct |
4 ms |
244 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
6 ms |
248 KB |
Output is correct |
17 |
Correct |
13 ms |
376 KB |
Output is correct |
18 |
Correct |
20 ms |
248 KB |
Output is correct |
19 |
Correct |
17 ms |
320 KB |
Output is correct |
20 |
Correct |
29 ms |
248 KB |
Output is correct |
21 |
Correct |
29 ms |
252 KB |
Output is correct |
22 |
Correct |
23 ms |
248 KB |
Output is correct |
23 |
Correct |
29 ms |
376 KB |
Output is correct |
24 |
Correct |
17 ms |
252 KB |
Output is correct |
25 |
Correct |
31 ms |
376 KB |
Output is correct |
26 |
Correct |
28 ms |
296 KB |
Output is correct |
27 |
Correct |
33 ms |
248 KB |
Output is correct |
28 |
Correct |
34 ms |
248 KB |
Output is correct |
29 |
Correct |
31 ms |
248 KB |
Output is correct |
30 |
Correct |
19 ms |
316 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
252 KB |
Output is correct |
4 |
Correct |
4 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
248 KB |
Output is correct |
7 |
Correct |
4 ms |
248 KB |
Output is correct |
8 |
Correct |
4 ms |
248 KB |
Output is correct |
9 |
Correct |
4 ms |
376 KB |
Output is correct |
10 |
Correct |
4 ms |
248 KB |
Output is correct |
11 |
Correct |
3 ms |
248 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
4 ms |
376 KB |
Output is correct |
14 |
Correct |
4 ms |
244 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
6 ms |
248 KB |
Output is correct |
17 |
Correct |
13 ms |
376 KB |
Output is correct |
18 |
Correct |
20 ms |
248 KB |
Output is correct |
19 |
Correct |
17 ms |
320 KB |
Output is correct |
20 |
Correct |
29 ms |
248 KB |
Output is correct |
21 |
Correct |
29 ms |
252 KB |
Output is correct |
22 |
Correct |
23 ms |
248 KB |
Output is correct |
23 |
Correct |
29 ms |
376 KB |
Output is correct |
24 |
Correct |
17 ms |
252 KB |
Output is correct |
25 |
Correct |
31 ms |
376 KB |
Output is correct |
26 |
Correct |
28 ms |
296 KB |
Output is correct |
27 |
Correct |
33 ms |
248 KB |
Output is correct |
28 |
Correct |
34 ms |
248 KB |
Output is correct |
29 |
Correct |
31 ms |
248 KB |
Output is correct |
30 |
Correct |
19 ms |
316 KB |
Output is correct |
31 |
Correct |
77 ms |
248 KB |
Output is correct |
32 |
Correct |
124 ms |
332 KB |
Output is correct |
33 |
Correct |
232 ms |
328 KB |
Output is correct |
34 |
Correct |
295 ms |
376 KB |
Output is correct |
35 |
Correct |
292 ms |
404 KB |
Output is correct |
36 |
Correct |
339 ms |
376 KB |
Output is correct |
37 |
Correct |
269 ms |
376 KB |
Output is correct |
38 |
Correct |
377 ms |
376 KB |
Output is correct |
39 |
Correct |
305 ms |
248 KB |
Output is correct |
40 |
Correct |
259 ms |
332 KB |
Output is correct |
41 |
Correct |
298 ms |
404 KB |
Output is correct |
42 |
Correct |
343 ms |
376 KB |
Output is correct |
43 |
Correct |
270 ms |
376 KB |
Output is correct |
44 |
Correct |
377 ms |
336 KB |
Output is correct |
45 |
Correct |
304 ms |
376 KB |
Output is correct |
46 |
Correct |
319 ms |
424 KB |
Output is correct |
47 |
Correct |
185 ms |
292 KB |
Output is correct |
48 |
Correct |
195 ms |
340 KB |
Output is correct |
49 |
Correct |
181 ms |
292 KB |
Output is correct |
50 |
Correct |
316 ms |
248 KB |
Output is correct |
51 |
Correct |
304 ms |
336 KB |
Output is correct |
52 |
Correct |
338 ms |
248 KB |
Output is correct |
53 |
Correct |
321 ms |
332 KB |
Output is correct |
54 |
Correct |
222 ms |
376 KB |
Output is correct |
55 |
Correct |
280 ms |
380 KB |
Output is correct |
56 |
Correct |
275 ms |
376 KB |
Output is correct |
57 |
Correct |
250 ms |
376 KB |
Output is correct |
58 |
Correct |
392 ms |
376 KB |
Output is correct |
59 |
Correct |
277 ms |
332 KB |
Output is correct |
60 |
Correct |
273 ms |
332 KB |
Output is correct |