Submission #414167

# Submission time Handle Problem Language Result Execution time Memory
414167 2021-05-30T07:47:20 Z Nicholas_Patrick Xylophone (JOI18_xylophone) C++17
100 / 100
130 ms 376 KB
#include "xylophone.h"
#include <algorithm>
using namespace std;

static int A[5000];

void solve(int N) {
	int A[5000];
	A[0]=0;
	A[1]=query(1, 2);
	for(int i=3; i<=N; i++){
		int rec1=query(i-1, i);
		int a=A[i-2]+rec1, b=A[i-2]-rec1;
		if(a==A[i-3]){
			A[i-1]=b;
			continue;
		}
		if(b==A[i-3]){
			A[i-1]=a;
			continue;
		}
		int rec2=query(i-2, i);
		if(A[i-3]<A[i-2]){
			A[i-1]=rec2==a-A[i-3]?a:b;
		}else{
			A[i-1]=rec2==A[i-3]-b?b:a;
		}
	}
	int mi=*min_element(A, A+N);
	for(int i=N; i--;)
		A[i]=A[i]-mi+1;
	if(find(A, A+N, 1)-A>find(A, A+N, N)-A){
		for(int i=N; i--;)
			A[i]=N+1-A[i];
	}
	for(int i=0; i<N; i++)
		answer(i+1, A[i]);
}

Compilation message

xylophone.cpp:5:12: warning: 'A' defined but not used [-Wunused-variable]
    5 | static int A[5000];
      |            ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 268 KB Output is correct
2 Correct 1 ms 264 KB Output is correct
3 Correct 2 ms 200 KB Output is correct
4 Correct 3 ms 200 KB Output is correct
5 Correct 3 ms 200 KB Output is correct
6 Correct 3 ms 200 KB Output is correct
7 Correct 3 ms 200 KB Output is correct
8 Correct 3 ms 200 KB Output is correct
9 Correct 2 ms 200 KB Output is correct
10 Correct 4 ms 200 KB Output is correct
11 Correct 3 ms 200 KB Output is correct
12 Correct 3 ms 200 KB Output is correct
13 Correct 3 ms 200 KB Output is correct
14 Correct 2 ms 268 KB Output is correct
15 Correct 3 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 268 KB Output is correct
2 Correct 1 ms 264 KB Output is correct
3 Correct 2 ms 200 KB Output is correct
4 Correct 3 ms 200 KB Output is correct
5 Correct 3 ms 200 KB Output is correct
6 Correct 3 ms 200 KB Output is correct
7 Correct 3 ms 200 KB Output is correct
8 Correct 3 ms 200 KB Output is correct
9 Correct 2 ms 200 KB Output is correct
10 Correct 4 ms 200 KB Output is correct
11 Correct 3 ms 200 KB Output is correct
12 Correct 3 ms 200 KB Output is correct
13 Correct 3 ms 200 KB Output is correct
14 Correct 2 ms 268 KB Output is correct
15 Correct 3 ms 200 KB Output is correct
16 Correct 4 ms 200 KB Output is correct
17 Correct 10 ms 200 KB Output is correct
18 Correct 22 ms 200 KB Output is correct
19 Correct 17 ms 200 KB Output is correct
20 Correct 10 ms 280 KB Output is correct
21 Correct 28 ms 268 KB Output is correct
22 Correct 16 ms 200 KB Output is correct
23 Correct 13 ms 292 KB Output is correct
24 Correct 19 ms 200 KB Output is correct
25 Correct 28 ms 272 KB Output is correct
26 Correct 27 ms 200 KB Output is correct
27 Correct 17 ms 200 KB Output is correct
28 Correct 26 ms 200 KB Output is correct
29 Correct 18 ms 200 KB Output is correct
30 Correct 26 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 268 KB Output is correct
2 Correct 1 ms 264 KB Output is correct
3 Correct 2 ms 200 KB Output is correct
4 Correct 3 ms 200 KB Output is correct
5 Correct 3 ms 200 KB Output is correct
6 Correct 3 ms 200 KB Output is correct
7 Correct 3 ms 200 KB Output is correct
8 Correct 3 ms 200 KB Output is correct
9 Correct 2 ms 200 KB Output is correct
10 Correct 4 ms 200 KB Output is correct
11 Correct 3 ms 200 KB Output is correct
12 Correct 3 ms 200 KB Output is correct
13 Correct 3 ms 200 KB Output is correct
14 Correct 2 ms 268 KB Output is correct
15 Correct 3 ms 200 KB Output is correct
16 Correct 4 ms 200 KB Output is correct
17 Correct 10 ms 200 KB Output is correct
18 Correct 22 ms 200 KB Output is correct
19 Correct 17 ms 200 KB Output is correct
20 Correct 10 ms 280 KB Output is correct
21 Correct 28 ms 268 KB Output is correct
22 Correct 16 ms 200 KB Output is correct
23 Correct 13 ms 292 KB Output is correct
24 Correct 19 ms 200 KB Output is correct
25 Correct 28 ms 272 KB Output is correct
26 Correct 27 ms 200 KB Output is correct
27 Correct 17 ms 200 KB Output is correct
28 Correct 26 ms 200 KB Output is correct
29 Correct 18 ms 200 KB Output is correct
30 Correct 26 ms 200 KB Output is correct
31 Correct 20 ms 268 KB Output is correct
32 Correct 53 ms 200 KB Output is correct
33 Correct 95 ms 272 KB Output is correct
34 Correct 118 ms 200 KB Output is correct
35 Correct 46 ms 288 KB Output is correct
36 Correct 67 ms 200 KB Output is correct
37 Correct 106 ms 276 KB Output is correct
38 Correct 127 ms 268 KB Output is correct
39 Correct 92 ms 200 KB Output is correct
40 Correct 100 ms 268 KB Output is correct
41 Correct 91 ms 276 KB Output is correct
42 Correct 53 ms 200 KB Output is correct
43 Correct 129 ms 284 KB Output is correct
44 Correct 88 ms 288 KB Output is correct
45 Correct 130 ms 284 KB Output is correct
46 Correct 94 ms 288 KB Output is correct
47 Correct 115 ms 376 KB Output is correct
48 Correct 46 ms 288 KB Output is correct
49 Correct 89 ms 200 KB Output is correct
50 Correct 92 ms 200 KB Output is correct
51 Correct 108 ms 272 KB Output is correct
52 Correct 93 ms 268 KB Output is correct
53 Correct 79 ms 200 KB Output is correct
54 Correct 95 ms 272 KB Output is correct
55 Correct 81 ms 200 KB Output is correct
56 Correct 77 ms 200 KB Output is correct
57 Correct 82 ms 276 KB Output is correct
58 Correct 112 ms 284 KB Output is correct
59 Correct 83 ms 284 KB Output is correct
60 Correct 129 ms 276 KB Output is correct