답안 #113298

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

using namespace std;

//static int A[5000];

int cnt = 0;

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++) {

        if(sol[i] < 1 || sol[i] > n) {
            while(1) {

            }
        }

        answer(i, sol[i]);
    }

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