답안 #113301

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
113301 2019-05-24T19:58:15 Z popovicirobert Xylophone (JOI18_xylophone) C++14
47 / 100
54 ms 412 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) {

    cnt += 2;

    if(cnt > 10000) {
        while(1) {

        }
    }

    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 + 1, 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 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 3 ms 256 KB Output is correct
12 Correct 6 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 3 ms 256 KB Output is correct
15 Correct 3 ms 384 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 2 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 3 ms 256 KB Output is correct
12 Correct 6 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 3 ms 256 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 4 ms 256 KB Output is correct
17 Correct 11 ms 256 KB Output is correct
18 Correct 12 ms 256 KB Output is correct
19 Correct 20 ms 384 KB Output is correct
20 Correct 24 ms 384 KB Output is correct
21 Correct 17 ms 256 KB Output is correct
22 Correct 21 ms 384 KB Output is correct
23 Correct 17 ms 256 KB Output is correct
24 Correct 16 ms 256 KB Output is correct
25 Correct 10 ms 328 KB Output is correct
26 Correct 15 ms 256 KB Output is correct
27 Correct 8 ms 412 KB Output is correct
28 Correct 14 ms 384 KB Output is correct
29 Correct 18 ms 256 KB Output is correct
30 Correct 23 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 2 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 3 ms 256 KB Output is correct
12 Correct 6 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 3 ms 256 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 4 ms 256 KB Output is correct
17 Correct 11 ms 256 KB Output is correct
18 Correct 12 ms 256 KB Output is correct
19 Correct 20 ms 384 KB Output is correct
20 Correct 24 ms 384 KB Output is correct
21 Correct 17 ms 256 KB Output is correct
22 Correct 21 ms 384 KB Output is correct
23 Correct 17 ms 256 KB Output is correct
24 Correct 16 ms 256 KB Output is correct
25 Correct 10 ms 328 KB Output is correct
26 Correct 15 ms 256 KB Output is correct
27 Correct 8 ms 412 KB Output is correct
28 Correct 14 ms 384 KB Output is correct
29 Correct 18 ms 256 KB Output is correct
30 Correct 23 ms 256 KB Output is correct
31 Correct 41 ms 320 KB Output is correct
32 Correct 22 ms 408 KB Output is correct
33 Correct 30 ms 328 KB Output is correct
34 Incorrect 54 ms 384 KB Wrong Answer [2]
35 Halted 0 ms 0 KB -