Submission #1032527

# Submission time Handle Problem Language Result Execution time Memory
1032527 2024-07-23T23:52:01 Z vjudge1 Xylophone (JOI18_xylophone) C++17
100 / 100
83 ms 21416 KB
#include<bits/stdc++.h>
using namespace std;
static int A[5000];
int sv[5010][5010],CC=0;
int query(int,int);
void answer(int,int);
void solve(int);
int myqry(int l,int r){
    if(l>r)swap(l,r);
    if(l==r)return 0;
    if(sv[l][r])return sv[l][r];
    assert(++CC<=10000);
    return sv[l][r]=query(l,r);
}
int ans[5010];
int makesense(int a,int b,int c,int ac){
    return ac==max({a,b,c})-min({a,b,c});
}

void solve(int N) {
    ans[2]=myqry(1,2);
    for(int i=3;i<=N;i++){
        int k=myqry(i-1,i);
        int c=myqry(i-2,i);
        if(makesense(ans[i-1]-k,ans[i-1],ans[i-2],c))
            ans[i]=ans[i-1]-k;
        else ans[i]=ans[i-1]+k;
    }
    int d=min_element(ans+1,ans+N+1)-max_element(ans+1,ans+N+1);
    if(d>0)
        for(int i=1;i<=N;i++)
            ans[i]=-ans[i];
    int c=*min_element(ans,ans+N);
    for(int i=1;i<=N;i++)
        answer(i,ans[i]-c+1);
}

Compilation message

xylophone.cpp:4:12: warning: 'A' defined but not used [-Wunused-variable]
    4 | static int A[5000];
      |            ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 2 ms 600 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 1 ms 764 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 1 ms 756 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 2 ms 600 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 1 ms 764 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 1 ms 756 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 3 ms 1112 KB Output is correct
17 Correct 5 ms 2136 KB Output is correct
18 Correct 9 ms 3672 KB Output is correct
19 Correct 10 ms 4428 KB Output is correct
20 Correct 8 ms 4436 KB Output is correct
21 Correct 13 ms 4728 KB Output is correct
22 Correct 11 ms 4440 KB Output is correct
23 Correct 11 ms 4528 KB Output is correct
24 Correct 13 ms 4524 KB Output is correct
25 Correct 8 ms 4444 KB Output is correct
26 Correct 9 ms 4440 KB Output is correct
27 Correct 9 ms 4416 KB Output is correct
28 Correct 10 ms 4440 KB Output is correct
29 Correct 9 ms 4404 KB Output is correct
30 Correct 8 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 2 ms 600 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 1 ms 764 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 1 ms 756 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 3 ms 1112 KB Output is correct
17 Correct 5 ms 2136 KB Output is correct
18 Correct 9 ms 3672 KB Output is correct
19 Correct 10 ms 4428 KB Output is correct
20 Correct 8 ms 4436 KB Output is correct
21 Correct 13 ms 4728 KB Output is correct
22 Correct 11 ms 4440 KB Output is correct
23 Correct 11 ms 4528 KB Output is correct
24 Correct 13 ms 4524 KB Output is correct
25 Correct 8 ms 4444 KB Output is correct
26 Correct 9 ms 4440 KB Output is correct
27 Correct 9 ms 4416 KB Output is correct
28 Correct 10 ms 4440 KB Output is correct
29 Correct 9 ms 4404 KB Output is correct
30 Correct 8 ms 4444 KB Output is correct
31 Correct 19 ms 9040 KB Output is correct
32 Correct 29 ms 12880 KB Output is correct
33 Correct 41 ms 17840 KB Output is correct
34 Correct 51 ms 20564 KB Output is correct
35 Correct 48 ms 20736 KB Output is correct
36 Correct 55 ms 20968 KB Output is correct
37 Correct 56 ms 20908 KB Output is correct
38 Correct 52 ms 20860 KB Output is correct
39 Correct 45 ms 20708 KB Output is correct
40 Correct 63 ms 20820 KB Output is correct
41 Correct 61 ms 20464 KB Output is correct
42 Correct 67 ms 20812 KB Output is correct
43 Correct 66 ms 20656 KB Output is correct
44 Correct 57 ms 20832 KB Output is correct
45 Correct 75 ms 20560 KB Output is correct
46 Correct 83 ms 20652 KB Output is correct
47 Correct 53 ms 20560 KB Output is correct
48 Correct 59 ms 20816 KB Output is correct
49 Correct 65 ms 20572 KB Output is correct
50 Correct 60 ms 20468 KB Output is correct
51 Correct 64 ms 21416 KB Output is correct
52 Correct 66 ms 20708 KB Output is correct
53 Correct 78 ms 20816 KB Output is correct
54 Correct 64 ms 20740 KB Output is correct
55 Correct 61 ms 21020 KB Output is correct
56 Correct 58 ms 20512 KB Output is correct
57 Correct 65 ms 20768 KB Output is correct
58 Correct 74 ms 20544 KB Output is correct
59 Correct 61 ms 20800 KB Output is correct
60 Correct 75 ms 20560 KB Output is correct