Submission #1032187

# Submission time Handle Problem Language Result Execution time Memory
1032187 2024-07-23T13:00:11 Z juicy Xylophone (JOI18_xylophone) C++17
100 / 100
71 ms 600 KB
#include <bits/stdc++.h>

#include "xylophone.h"

using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

void solve(int N) {
	vector<int> A(N), qry(N);
	A[1] = qry[1] = query(1, 2);
	for (int i = 2; i < N; ++i) {
		qry[i] = query(i, i + 1);
		int a = A[i - 2], b = A[i - 1], &c = A[i];
		int AB = qry[i - 1], BC = qry[i], AC = query(i - 1, i + 1);
		if (AB == AC) {
			if (a < b) {
				c = b - BC;
			} else {
				c = b + BC;
			}
		} else if (BC == AC) {
			if (a < b) {
				c = b - BC;
			} else {
				c = b + BC;
			}
		} else {
			if (a < b) {
				c = b + BC;
			} else {
				c = b - BC;
			}
		}
	}
	vector<int> ord(N); iota(ord.begin(), ord.end(), 0);
	sort(ord.begin(), ord.end(), [&](int u, int v) {
		return A[u] < A[v];
	});
	if (ord[0] > ord.back()) {
		reverse(ord.begin(), ord.end());
	}
	for (int i = 0; i < N; ++i) {
		answer(ord[i] + 1, i + 1);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 3 ms 600 KB Output is correct
17 Correct 4 ms 344 KB Output is correct
18 Correct 7 ms 344 KB Output is correct
19 Correct 9 ms 444 KB Output is correct
20 Correct 13 ms 344 KB Output is correct
21 Correct 9 ms 344 KB Output is correct
22 Correct 7 ms 344 KB Output is correct
23 Correct 10 ms 440 KB Output is correct
24 Correct 6 ms 344 KB Output is correct
25 Correct 9 ms 344 KB Output is correct
26 Correct 9 ms 344 KB Output is correct
27 Correct 11 ms 344 KB Output is correct
28 Correct 10 ms 600 KB Output is correct
29 Correct 9 ms 344 KB Output is correct
30 Correct 9 ms 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 3 ms 600 KB Output is correct
17 Correct 4 ms 344 KB Output is correct
18 Correct 7 ms 344 KB Output is correct
19 Correct 9 ms 444 KB Output is correct
20 Correct 13 ms 344 KB Output is correct
21 Correct 9 ms 344 KB Output is correct
22 Correct 7 ms 344 KB Output is correct
23 Correct 10 ms 440 KB Output is correct
24 Correct 6 ms 344 KB Output is correct
25 Correct 9 ms 344 KB Output is correct
26 Correct 9 ms 344 KB Output is correct
27 Correct 11 ms 344 KB Output is correct
28 Correct 10 ms 600 KB Output is correct
29 Correct 9 ms 344 KB Output is correct
30 Correct 9 ms 436 KB Output is correct
31 Correct 14 ms 444 KB Output is correct
32 Correct 28 ms 344 KB Output is correct
33 Correct 51 ms 448 KB Output is correct
34 Correct 45 ms 448 KB Output is correct
35 Correct 66 ms 468 KB Output is correct
36 Correct 43 ms 456 KB Output is correct
37 Correct 64 ms 456 KB Output is correct
38 Correct 49 ms 592 KB Output is correct
39 Correct 53 ms 448 KB Output is correct
40 Correct 47 ms 452 KB Output is correct
41 Correct 57 ms 344 KB Output is correct
42 Correct 44 ms 592 KB Output is correct
43 Correct 40 ms 448 KB Output is correct
44 Correct 47 ms 448 KB Output is correct
45 Correct 53 ms 456 KB Output is correct
46 Correct 48 ms 592 KB Output is correct
47 Correct 52 ms 592 KB Output is correct
48 Correct 37 ms 468 KB Output is correct
49 Correct 62 ms 456 KB Output is correct
50 Correct 46 ms 468 KB Output is correct
51 Correct 62 ms 452 KB Output is correct
52 Correct 51 ms 344 KB Output is correct
53 Correct 71 ms 448 KB Output is correct
54 Correct 47 ms 472 KB Output is correct
55 Correct 70 ms 344 KB Output is correct
56 Correct 53 ms 448 KB Output is correct
57 Correct 48 ms 464 KB Output is correct
58 Correct 58 ms 592 KB Output is correct
59 Correct 54 ms 452 KB Output is correct
60 Correct 48 ms 452 KB Output is correct