Submission #756336

# Submission time Handle Problem Language Result Execution time Memory
756336 2023-06-11T14:15:45 Z Piokemon Xylophone (JOI18_xylophone) C++17
100 / 100
129 ms 432 KB
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int nast[5009];
int trzy[5009];
bool mniej[5009]; // czy mniejszy od nastepnego
int rozn[5009];

void solve(int N) {
    for (int x=1;x<=N-1;x++){
        nast[x] = query(x,x+1);
    }
    for (int x=1;x<=N-2;x++){
        trzy[x] = query(x,x+2);
    }
    mniej[1] = 0; // a1 > a2
    for (int x=2;x<N;x++){
        if (nast[x-1] + nast[x] == trzy[x-1]) mniej[x] = mniej[x-1];
        else mniej[x] = 1-mniej[x-1];
    }
    int mini=0;
    rozn[1] = 0;
    for (int x=1;x<N;x++){
        if (mniej[x]) rozn[x+1] = rozn[x] + nast[x];
        else rozn[x+1] = rozn[x] - nast[x];
        mini = min(mini,rozn[x+1]);
    }
    int rev=0;
    for (int x=1;x<=N;x++){
        if (-mini + 1 + rozn[x] == 1) break;
        if (-mini + 1 + rozn[x] == N){
            rev = 1;
            break;
        }
    }
    int pocz = -mini + 1;
    //for (int x=1;x<=N;x++) cout << rozn[x] << ' ';
    //cout << '\n';
    for (int x=1;x<=N;x++){
        if (rev) answer(x,N + 1 - (pocz+rozn[x]));
        else answer(x,pocz+rozn[x]);
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 4 ms 208 KB Output is correct
5 Correct 2 ms 208 KB Output is correct
6 Correct 2 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 3 ms 308 KB Output is correct
9 Correct 3 ms 208 KB Output is correct
10 Correct 3 ms 208 KB Output is correct
11 Correct 3 ms 208 KB Output is correct
12 Correct 2 ms 208 KB Output is correct
13 Correct 3 ms 208 KB Output is correct
14 Correct 3 ms 208 KB Output is correct
15 Correct 3 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 4 ms 208 KB Output is correct
5 Correct 2 ms 208 KB Output is correct
6 Correct 2 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 3 ms 308 KB Output is correct
9 Correct 3 ms 208 KB Output is correct
10 Correct 3 ms 208 KB Output is correct
11 Correct 3 ms 208 KB Output is correct
12 Correct 2 ms 208 KB Output is correct
13 Correct 3 ms 208 KB Output is correct
14 Correct 3 ms 208 KB Output is correct
15 Correct 3 ms 312 KB Output is correct
16 Correct 3 ms 208 KB Output is correct
17 Correct 10 ms 208 KB Output is correct
18 Correct 17 ms 308 KB Output is correct
19 Correct 22 ms 308 KB Output is correct
20 Correct 20 ms 312 KB Output is correct
21 Correct 21 ms 304 KB Output is correct
22 Correct 16 ms 304 KB Output is correct
23 Correct 9 ms 308 KB Output is correct
24 Correct 16 ms 312 KB Output is correct
25 Correct 21 ms 312 KB Output is correct
26 Correct 27 ms 292 KB Output is correct
27 Correct 21 ms 308 KB Output is correct
28 Correct 22 ms 296 KB Output is correct
29 Correct 13 ms 208 KB Output is correct
30 Correct 16 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 4 ms 208 KB Output is correct
5 Correct 2 ms 208 KB Output is correct
6 Correct 2 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 3 ms 308 KB Output is correct
9 Correct 3 ms 208 KB Output is correct
10 Correct 3 ms 208 KB Output is correct
11 Correct 3 ms 208 KB Output is correct
12 Correct 2 ms 208 KB Output is correct
13 Correct 3 ms 208 KB Output is correct
14 Correct 3 ms 208 KB Output is correct
15 Correct 3 ms 312 KB Output is correct
16 Correct 3 ms 208 KB Output is correct
17 Correct 10 ms 208 KB Output is correct
18 Correct 17 ms 308 KB Output is correct
19 Correct 22 ms 308 KB Output is correct
20 Correct 20 ms 312 KB Output is correct
21 Correct 21 ms 304 KB Output is correct
22 Correct 16 ms 304 KB Output is correct
23 Correct 9 ms 308 KB Output is correct
24 Correct 16 ms 312 KB Output is correct
25 Correct 21 ms 312 KB Output is correct
26 Correct 27 ms 292 KB Output is correct
27 Correct 21 ms 308 KB Output is correct
28 Correct 22 ms 296 KB Output is correct
29 Correct 13 ms 208 KB Output is correct
30 Correct 16 ms 308 KB Output is correct
31 Correct 28 ms 308 KB Output is correct
32 Correct 57 ms 328 KB Output is correct
33 Correct 87 ms 304 KB Output is correct
34 Correct 88 ms 324 KB Output is correct
35 Correct 98 ms 308 KB Output is correct
36 Correct 129 ms 320 KB Output is correct
37 Correct 100 ms 308 KB Output is correct
38 Correct 102 ms 308 KB Output is correct
39 Correct 85 ms 324 KB Output is correct
40 Correct 44 ms 376 KB Output is correct
41 Correct 110 ms 304 KB Output is correct
42 Correct 89 ms 428 KB Output is correct
43 Correct 97 ms 432 KB Output is correct
44 Correct 125 ms 328 KB Output is correct
45 Correct 80 ms 396 KB Output is correct
46 Correct 91 ms 424 KB Output is correct
47 Correct 96 ms 304 KB Output is correct
48 Correct 104 ms 420 KB Output is correct
49 Correct 121 ms 420 KB Output is correct
50 Correct 76 ms 328 KB Output is correct
51 Correct 104 ms 328 KB Output is correct
52 Correct 88 ms 312 KB Output is correct
53 Correct 99 ms 308 KB Output is correct
54 Correct 75 ms 324 KB Output is correct
55 Correct 108 ms 288 KB Output is correct
56 Correct 67 ms 304 KB Output is correct
57 Correct 82 ms 308 KB Output is correct
58 Correct 52 ms 308 KB Output is correct
59 Correct 77 ms 312 KB Output is correct
60 Correct 86 ms 312 KB Output is correct