답안 #113291

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
113291 2019-05-24T19:15:06 Z popovicirobert Xylophone (JOI18_xylophone) C++14
47 / 100
89 ms 384 KB
#include "xylophone.h"
#include <bits/stdc++.h>

using namespace std;

//static int A[5000];

inline int get(int a, int b, int pa, int pb, int pc) {

    int bc = query(min(pb, pc), max(pb, pc)), ac = query(min(pa, pc), max(pa, pc));

    if(a < b) {
        if(bc == ac) {
            return b - bc;
        }
        if(ac == abs(a - b)) {
            return b - bc;
        }
        return b + bc;
    }
    else {
        if(bc == ac) {
            return b + bc;
        }
        if(ac == abs(a - b)) {
            return b + bc;
        }
        return b - bc;
    }
}

void solve(int n) {

    int pos = n, i;

    for(int step = 1 << 15; step; step >>= 1) {
        if(pos - step >= 1 && query(pos - step, n) < n - 1) {
            pos -= step;
        }
    }

    pos--; // 1

    vector <int> sol(n + 2);

    sol[pos] = 1;

    if(pos > 1) {
        sol[pos - 1] = 1 + query(pos - 1, pos);
    }

    int a = sol[pos], b = sol[pos - 1];

    for(i = pos - 2; i >= 1; i--) {
        int c = get(a, b, i + 2, i + 1, i);
        sol[i] = c;
        a = b;
        b = c;
    }

    if(pos < n) {
        sol[pos + 1] = 1 + query(pos, pos + 1);
    }

    a = sol[pos], b = sol[pos + 1];

    for(i = pos + 2; i <= n; i++) {
        int c = get(a, b, i - 2, i - 1, i);
        sol[i] = c;
        a = b;
        b = c;
    }

    for(i = 1; i <= n; i++) {
        answer(i, sol[i]);
    }

}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 3 ms 256 KB Output is correct
11 Correct 4 ms 304 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 256 KB Output is correct
14 Correct 4 ms 256 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 3 ms 256 KB Output is correct
11 Correct 4 ms 304 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 256 KB Output is correct
14 Correct 4 ms 256 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 9 ms 256 KB Output is correct
18 Correct 16 ms 256 KB Output is correct
19 Correct 15 ms 384 KB Output is correct
20 Correct 15 ms 256 KB Output is correct
21 Correct 8 ms 324 KB Output is correct
22 Correct 8 ms 320 KB Output is correct
23 Correct 19 ms 256 KB Output is correct
24 Correct 16 ms 256 KB Output is correct
25 Correct 13 ms 384 KB Output is correct
26 Correct 19 ms 268 KB Output is correct
27 Correct 30 ms 384 KB Output is correct
28 Correct 25 ms 384 KB Output is correct
29 Correct 19 ms 256 KB Output is correct
30 Correct 13 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 3 ms 256 KB Output is correct
11 Correct 4 ms 304 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 256 KB Output is correct
14 Correct 4 ms 256 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 9 ms 256 KB Output is correct
18 Correct 16 ms 256 KB Output is correct
19 Correct 15 ms 384 KB Output is correct
20 Correct 15 ms 256 KB Output is correct
21 Correct 8 ms 324 KB Output is correct
22 Correct 8 ms 320 KB Output is correct
23 Correct 19 ms 256 KB Output is correct
24 Correct 16 ms 256 KB Output is correct
25 Correct 13 ms 384 KB Output is correct
26 Correct 19 ms 268 KB Output is correct
27 Correct 30 ms 384 KB Output is correct
28 Correct 25 ms 384 KB Output is correct
29 Correct 19 ms 256 KB Output is correct
30 Correct 13 ms 256 KB Output is correct
31 Correct 31 ms 320 KB Output is correct
32 Correct 21 ms 324 KB Output is correct
33 Correct 89 ms 256 KB Output is correct
34 Incorrect 61 ms 256 KB Wrong Answer [2]
35 Halted 0 ms 0 KB -