답안 #94332

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
94332 2019-01-17T18:08:51 Z fedoseevtimofey Xylophone (JOI18_xylophone) C++14
47 / 100
189 ms 404 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);
        set <int> avl;
        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) {
                avl.insert(z);
            }
        }
        assert(avl.size() == 1);
        a[i] = *(avl.begin());
        assert(a[i] != -1);
    }
    for (int i = r + 2; i <= n; ++i) {
        int x = query(i - 1, i);
        int y = query(i - 2, i);
        set <int> avl;
        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) {
                avl.insert(z);
            }
        }
        assert(avl.size() == 1);
        a[i] = *(avl.begin());
        assert(a[i] != -1);
    }
    for (int i = 1; i <= n; ++i) {
        answer(i, a[i]);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 2 ms 248 KB Output is correct
6 Correct 4 ms 248 KB Output is correct
7 Correct 4 ms 376 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 376 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 4 ms 248 KB Output is correct
13 Correct 3 ms 248 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 3 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 2 ms 248 KB Output is correct
6 Correct 4 ms 248 KB Output is correct
7 Correct 4 ms 376 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 376 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 4 ms 248 KB Output is correct
13 Correct 3 ms 248 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 3 ms 248 KB Output is correct
16 Correct 7 ms 248 KB Output is correct
17 Correct 15 ms 376 KB Output is correct
18 Correct 12 ms 396 KB Output is correct
19 Correct 26 ms 316 KB Output is correct
20 Correct 27 ms 248 KB Output is correct
21 Correct 30 ms 296 KB Output is correct
22 Correct 30 ms 376 KB Output is correct
23 Correct 25 ms 376 KB Output is correct
24 Correct 25 ms 376 KB Output is correct
25 Correct 33 ms 248 KB Output is correct
26 Correct 15 ms 320 KB Output is correct
27 Correct 26 ms 252 KB Output is correct
28 Correct 16 ms 404 KB Output is correct
29 Correct 24 ms 248 KB Output is correct
30 Correct 15 ms 396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 2 ms 248 KB Output is correct
6 Correct 4 ms 248 KB Output is correct
7 Correct 4 ms 376 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 376 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 4 ms 248 KB Output is correct
13 Correct 3 ms 248 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 3 ms 248 KB Output is correct
16 Correct 7 ms 248 KB Output is correct
17 Correct 15 ms 376 KB Output is correct
18 Correct 12 ms 396 KB Output is correct
19 Correct 26 ms 316 KB Output is correct
20 Correct 27 ms 248 KB Output is correct
21 Correct 30 ms 296 KB Output is correct
22 Correct 30 ms 376 KB Output is correct
23 Correct 25 ms 376 KB Output is correct
24 Correct 25 ms 376 KB Output is correct
25 Correct 33 ms 248 KB Output is correct
26 Correct 15 ms 320 KB Output is correct
27 Correct 26 ms 252 KB Output is correct
28 Correct 16 ms 404 KB Output is correct
29 Correct 24 ms 248 KB Output is correct
30 Correct 15 ms 396 KB Output is correct
31 Correct 71 ms 376 KB Output is correct
32 Correct 124 ms 376 KB Output is correct
33 Incorrect 189 ms 248 KB Wrong Answer [2]
34 Halted 0 ms 0 KB -