Submission #1052694

# Submission time Handle Problem Language Result Execution time Memory
1052694 2024-08-10T19:34:33 Z zsombor Xylophone (JOI18_xylophone) C++17
100 / 100
55 ms 600 KB
#include <bits/stdc++.h>
#include "xylophone.h"
using namespace std;

int n, mn, i_1, i_n;
vector<int> a(6e3, 0);
vector<int> v1(6e3, 0);
vector<int> v2(6e3, 0);

void solve(int N) {
    n = N;
    for (int i = 1; i <= n - 1; i++) v1[i] = query(i, i + 1);
    for (int i = 1; i <= n - 2; i++) v2[i] = query(i, i + 2);
    a[2] = v1[1];
    for (int i = 3; i <= n; i++) {
        if (a[i - 2] < a[i - 1]) {
            a[i] = a[i - 1] + (v2[i - 2] == v1[i - 2] + v1[i - 1] ? v1[i - 1] : -v1[i - 1]);
        } else {
            a[i] = a[i - 1] + (v2[i - 2] == v1[i - 2] + v1[i - 1] ? -v1[i - 1] : v1[i - 1]);
        }
        mn = min(mn, a[i]);
    }
    for (int i = 1; i <= n; i++) {
        a[i] += 1 - mn;
        if (a[i] == 1) i_1 = i;
        if (a[i] == n) i_n = i;
    }
    for (int i = 1; i <= n; i++) {
        if (i_1 > i_n) a[i] = n + 1 - a[i];
        answer(i, a[i]);
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 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 2 ms 344 KB Output is correct
6 Correct 1 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 2 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 1 ms 340 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 2 ms 344 KB Output is correct
6 Correct 1 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 2 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 2 ms 344 KB Output is correct
17 Correct 5 ms 344 KB Output is correct
18 Correct 6 ms 512 KB Output is correct
19 Correct 9 ms 344 KB Output is correct
20 Correct 8 ms 344 KB Output is correct
21 Correct 12 ms 600 KB Output is correct
22 Correct 8 ms 344 KB Output is correct
23 Correct 9 ms 344 KB Output is correct
24 Correct 5 ms 344 KB Output is correct
25 Correct 6 ms 508 KB Output is correct
26 Correct 7 ms 344 KB Output is correct
27 Correct 8 ms 344 KB Output is correct
28 Correct 10 ms 512 KB Output is correct
29 Correct 8 ms 504 KB Output is correct
30 Correct 10 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 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 2 ms 344 KB Output is correct
6 Correct 1 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 2 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 2 ms 344 KB Output is correct
17 Correct 5 ms 344 KB Output is correct
18 Correct 6 ms 512 KB Output is correct
19 Correct 9 ms 344 KB Output is correct
20 Correct 8 ms 344 KB Output is correct
21 Correct 12 ms 600 KB Output is correct
22 Correct 8 ms 344 KB Output is correct
23 Correct 9 ms 344 KB Output is correct
24 Correct 5 ms 344 KB Output is correct
25 Correct 6 ms 508 KB Output is correct
26 Correct 7 ms 344 KB Output is correct
27 Correct 8 ms 344 KB Output is correct
28 Correct 10 ms 512 KB Output is correct
29 Correct 8 ms 504 KB Output is correct
30 Correct 10 ms 504 KB Output is correct
31 Correct 23 ms 484 KB Output is correct
32 Correct 31 ms 484 KB Output is correct
33 Correct 27 ms 344 KB Output is correct
34 Correct 31 ms 344 KB Output is correct
35 Correct 48 ms 480 KB Output is correct
36 Correct 37 ms 484 KB Output is correct
37 Correct 34 ms 344 KB Output is correct
38 Correct 42 ms 344 KB Output is correct
39 Correct 44 ms 480 KB Output is correct
40 Correct 45 ms 484 KB Output is correct
41 Correct 38 ms 344 KB Output is correct
42 Correct 55 ms 592 KB Output is correct
43 Correct 48 ms 484 KB Output is correct
44 Correct 42 ms 488 KB Output is correct
45 Correct 48 ms 488 KB Output is correct
46 Correct 39 ms 480 KB Output is correct
47 Correct 52 ms 488 KB Output is correct
48 Correct 43 ms 500 KB Output is correct
49 Correct 42 ms 500 KB Output is correct
50 Correct 42 ms 484 KB Output is correct
51 Correct 39 ms 488 KB Output is correct
52 Correct 44 ms 344 KB Output is correct
53 Correct 33 ms 592 KB Output is correct
54 Correct 43 ms 592 KB Output is correct
55 Correct 42 ms 484 KB Output is correct
56 Correct 52 ms 484 KB Output is correct
57 Correct 42 ms 344 KB Output is correct
58 Correct 37 ms 484 KB Output is correct
59 Correct 37 ms 500 KB Output is correct
60 Correct 55 ms 484 KB Output is correct