Submission #113297

# Submission time Handle Problem Language Result Execution time Memory
113297 2019-05-24T19:48:31 Z popovicirobert Xylophone (JOI18_xylophone) C++14
47 / 100
56 ms 512 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;
    }

    vector <bool> vis(n + 1);

    for(i = 1; i <= n; i++) {
        if(vis[sol[i]]) {
            while(1) {

            }
        }
        vis[sol[i]] = 1;
        answer(i, sol[i]);
    }

}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 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 256 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 3 ms 256 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 4 ms 256 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 2 ms 512 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 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 256 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 3 ms 256 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 4 ms 256 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 2 ms 512 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 9 ms 324 KB Output is correct
18 Correct 8 ms 328 KB Output is correct
19 Correct 22 ms 256 KB Output is correct
20 Correct 9 ms 324 KB Output is correct
21 Correct 14 ms 256 KB Output is correct
22 Correct 23 ms 384 KB Output is correct
23 Correct 13 ms 256 KB Output is correct
24 Correct 25 ms 384 KB Output is correct
25 Correct 8 ms 404 KB Output is correct
26 Correct 21 ms 384 KB Output is correct
27 Correct 13 ms 256 KB Output is correct
28 Correct 9 ms 404 KB Output is correct
29 Correct 22 ms 256 KB Output is correct
30 Correct 25 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 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 256 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 3 ms 256 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 4 ms 256 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 2 ms 512 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 9 ms 324 KB Output is correct
18 Correct 8 ms 328 KB Output is correct
19 Correct 22 ms 256 KB Output is correct
20 Correct 9 ms 324 KB Output is correct
21 Correct 14 ms 256 KB Output is correct
22 Correct 23 ms 384 KB Output is correct
23 Correct 13 ms 256 KB Output is correct
24 Correct 25 ms 384 KB Output is correct
25 Correct 8 ms 404 KB Output is correct
26 Correct 21 ms 384 KB Output is correct
27 Correct 13 ms 256 KB Output is correct
28 Correct 9 ms 404 KB Output is correct
29 Correct 22 ms 256 KB Output is correct
30 Correct 25 ms 384 KB Output is correct
31 Correct 43 ms 384 KB Output is correct
32 Correct 31 ms 324 KB Output is correct
33 Correct 31 ms 404 KB Output is correct
34 Incorrect 56 ms 256 KB Wrong Answer [2]
35 Halted 0 ms 0 KB -