Submission #283249

# Submission time Handle Problem Language Result Execution time Memory
283249 2020-08-25T12:20:48 Z NintsiChkhaidze Xylophone (JOI18_xylophone) C++14
47 / 100
113 ms 384 KB
#include <iostream>
#include <vector>
#include "xylophone.h"
#define pb push_back
#define f first
#define s second
using namespace std;

int ans[5005];
void solve(int N) {
    int l=1,r=N,v = N - 1;
    while (v == N - 1)
        v = query(l,--r);
    
    if (r + 1 <= N && ans[r + 1] == 0) ans[r + 1] = N;
    
    int indn = r + 1;
    if (indn - 1 > 0 && ans[indn - 1] == 0){
        v = query(indn - 1,indn);
        ans[indn - 1] = N - v;
    }
    if (indn + 1 <= N && ans[indn + 1] == 0){
        v = query(indn,indn + 1);
        ans[indn + 1] = N - v;
    }
    int ind = indn - 2;
    while (ind > 0 && ans[ind] == 0){
        v = query(ind,ind + 1);
        int v1 = query(ind,ind + 2),val=0;
        if (ans[ind + 1] - v > 0) {
            val  = ans[ind + 1] - v;
            int minn = min(min(val,ans[ind + 1]),ans[ind + 2]);
            int maxx = max(max(val,ans[ind + 1]),ans[ind + 2]);
            if (maxx - minn == v1) ans[ind] = val;
        }
        if (ans[ind + 1] + v <= N){
            val  = ans[ind + 1] + v;
            int minn = min(min(val,ans[ind + 1]),ans[ind + 2]);
            int maxx = max(max(val,ans[ind + 1]),ans[ind + 2]);
            if (maxx - minn == v1) ans[ind] = val;
        }
        ind--;
    }
    ind = indn + 2;
    while (ind <= N && ans[ind] == 0){
        v = query(ind - 1,ind);
        int v1 = query(ind - 2,ind),val=0;
        if (ans[ind - 1] - v > 0) {
            val  = ans[ind - 1] - v;
            int minn = min(min(val,ans[ind - 1]),ans[ind - 2]);
            int maxx = max(max(val,ans[ind - 1]),ans[ind - 2]);
            if (maxx - minn == v1) ans[ind] = val;
        }
        if (ans[ind - 1] + v <= N){
            val  = ans[ind - 1] + v;
            int minn = min(min(val,ans[ind - 1]),ans[ind - 2]);
            int maxx = max(max(val,ans[ind - 1]),ans[ind - 2]);
            if (maxx - minn == v1) ans[ind] = val;
        }
        ind++;
    }
    for (int i=1;i<=N;i++)
        answer(i,ans[i]);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
5 Correct 2 ms 256 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 3 ms 256 KB Output is correct
10 Correct 3 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 3 ms 256 KB Output is correct
13 Correct 3 ms 256 KB Output is correct
14 Correct 3 ms 256 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
5 Correct 2 ms 256 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 3 ms 256 KB Output is correct
10 Correct 3 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 3 ms 256 KB Output is correct
13 Correct 3 ms 256 KB Output is correct
14 Correct 3 ms 256 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 11 ms 256 KB Output is correct
18 Correct 17 ms 384 KB Output is correct
19 Correct 21 ms 380 KB Output is correct
20 Correct 24 ms 256 KB Output is correct
21 Correct 24 ms 384 KB Output is correct
22 Correct 25 ms 384 KB Output is correct
23 Correct 19 ms 376 KB Output is correct
24 Correct 21 ms 256 KB Output is correct
25 Correct 35 ms 384 KB Output is correct
26 Correct 19 ms 384 KB Output is correct
27 Correct 22 ms 376 KB Output is correct
28 Correct 26 ms 384 KB Output is correct
29 Correct 18 ms 384 KB Output is correct
30 Correct 12 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
5 Correct 2 ms 256 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 3 ms 256 KB Output is correct
10 Correct 3 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 3 ms 256 KB Output is correct
13 Correct 3 ms 256 KB Output is correct
14 Correct 3 ms 256 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 11 ms 256 KB Output is correct
18 Correct 17 ms 384 KB Output is correct
19 Correct 21 ms 380 KB Output is correct
20 Correct 24 ms 256 KB Output is correct
21 Correct 24 ms 384 KB Output is correct
22 Correct 25 ms 384 KB Output is correct
23 Correct 19 ms 376 KB Output is correct
24 Correct 21 ms 256 KB Output is correct
25 Correct 35 ms 384 KB Output is correct
26 Correct 19 ms 384 KB Output is correct
27 Correct 22 ms 376 KB Output is correct
28 Correct 26 ms 384 KB Output is correct
29 Correct 18 ms 384 KB Output is correct
30 Correct 12 ms 380 KB Output is correct
31 Correct 33 ms 372 KB Output is correct
32 Correct 67 ms 380 KB Output is correct
33 Incorrect 113 ms 376 KB Wrong Answer [2]
34 Halted 0 ms 0 KB -