Submission #94331

# Submission time Handle Problem Language Result Execution time Memory
94331 2019-01-17T18:07:25 Z fedoseevtimofey Xylophone (JOI18_xylophone) C++14
47 / 100
96 ms 424 KB
#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) {
    int r = n;
    while (query(1, r) == n - 1) --r;
    ++r;
    vector <int> a(n + 1, -1);
    a[r] = n;
    if (r != n) {
        a[r + 1] = n - query(r, r + 1);
    }
    if (r != 1) {
        a[r - 1] = n - query(r - 1, r);
    }
    for (int i = r - 2; i >= 1; --i) {
        int x = query(i, i + 1);
        int y = query(i, i + 2);
        for (int z = n; z >= 1; --z) {
            a[i] = z;
            if (my_query(i, i + 1, a) == x && my_query(i, i + 2, a) == y) {
                break;
            }
        }
        assert(a[i] != -1);
    }
    for (int i = r + 2; i <= n; ++i) {
        int x = query(i - 1, i);
        int y = query(i - 2, i);
        for (int z = n; z >= 1; --z) {
            a[i] = z;
            if (my_query(i - 1, i, a) == x && my_query(i - 2, i, a) == y) {
                break;
            }
        }
        assert(a[i] != -1);
    }
    for (int i = 1; i <= n; ++i) {
        answer(i, a[i]);
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 3 ms 248 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 4 ms 376 KB Output is correct
8 Correct 2 ms 248 KB Output is correct
9 Correct 3 ms 248 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 3 ms 248 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 4 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 3 ms 248 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 4 ms 376 KB Output is correct
8 Correct 2 ms 248 KB Output is correct
9 Correct 3 ms 248 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 3 ms 248 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 4 ms 376 KB Output is correct
16 Correct 7 ms 248 KB Output is correct
17 Correct 15 ms 248 KB Output is correct
18 Correct 19 ms 248 KB Output is correct
19 Correct 12 ms 312 KB Output is correct
20 Correct 22 ms 376 KB Output is correct
21 Correct 13 ms 316 KB Output is correct
22 Correct 22 ms 248 KB Output is correct
23 Correct 24 ms 248 KB Output is correct
24 Correct 21 ms 248 KB Output is correct
25 Correct 24 ms 312 KB Output is correct
26 Correct 11 ms 316 KB Output is correct
27 Correct 27 ms 248 KB Output is correct
28 Correct 30 ms 376 KB Output is correct
29 Correct 11 ms 316 KB Output is correct
30 Correct 23 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 3 ms 248 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 4 ms 376 KB Output is correct
8 Correct 2 ms 248 KB Output is correct
9 Correct 3 ms 248 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 3 ms 248 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 4 ms 376 KB Output is correct
16 Correct 7 ms 248 KB Output is correct
17 Correct 15 ms 248 KB Output is correct
18 Correct 19 ms 248 KB Output is correct
19 Correct 12 ms 312 KB Output is correct
20 Correct 22 ms 376 KB Output is correct
21 Correct 13 ms 316 KB Output is correct
22 Correct 22 ms 248 KB Output is correct
23 Correct 24 ms 248 KB Output is correct
24 Correct 21 ms 248 KB Output is correct
25 Correct 24 ms 312 KB Output is correct
26 Correct 11 ms 316 KB Output is correct
27 Correct 27 ms 248 KB Output is correct
28 Correct 30 ms 376 KB Output is correct
29 Correct 11 ms 316 KB Output is correct
30 Correct 23 ms 248 KB Output is correct
31 Correct 54 ms 424 KB Output is correct
32 Correct 96 ms 312 KB Output is correct
33 Incorrect 79 ms 400 KB Wrong Answer [2]
34 Halted 0 ms 0 KB -