답안 #312947

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
312947 2020-10-14T20:03:48 Z sofapuden Xylophone (JOI18_xylophone) C++14
100 / 100
129 ms 512 KB
#include "xylophone.h"
#include <bits/stdc++.h>

using namespace std;

int A[5005];

void solve(int n) {
	A[1] = 0;
	A[2] = query(1,2);
	for(int i = 2; i < n; ++i){
		int a = query(i,i+1);
		int b = query(i-1,i+1);
		A[i+1] = A[i] + a*(A[i]-A[i-1] < 0 ? 1 : -1)*(b == a + abs(A[i]-A[i-1]) ? -1 : 1);
	}
	int mi = *min_element(A+1, A+1+n);
	int l, r;
	for(int i = 1; i <= n; ++i){
		A[i]-=mi;
		if(A[i] == 0)l = i;
		if(A[i] == n-1)r = i;
	}
	bool ok = l < r;
	for(int i = 1; i <= n; ++i)answer(i,ok ? A[i]+1 : n-A[i]);
}

Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:24:35: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized]
   24 |  for(int i = 1; i <= n; ++i)answer(i,ok ? A[i]+1 : n-A[i]);
      |                             ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
xylophone.cpp:24:35: warning: 'l' may be used uninitialized in this function [-Wmaybe-uninitialized]
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 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 1 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 3 ms 256 KB Output is correct
15 Correct 3 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 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 1 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 3 ms 256 KB Output is correct
15 Correct 3 ms 256 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 9 ms 384 KB Output is correct
18 Correct 17 ms 256 KB Output is correct
19 Correct 22 ms 256 KB Output is correct
20 Correct 22 ms 384 KB Output is correct
21 Correct 10 ms 380 KB Output is correct
22 Correct 23 ms 256 KB Output is correct
23 Correct 16 ms 384 KB Output is correct
24 Correct 10 ms 504 KB Output is correct
25 Correct 16 ms 384 KB Output is correct
26 Correct 18 ms 256 KB Output is correct
27 Correct 19 ms 376 KB Output is correct
28 Correct 19 ms 256 KB Output is correct
29 Correct 16 ms 256 KB Output is correct
30 Correct 20 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 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 1 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 3 ms 256 KB Output is correct
15 Correct 3 ms 256 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 9 ms 384 KB Output is correct
18 Correct 17 ms 256 KB Output is correct
19 Correct 22 ms 256 KB Output is correct
20 Correct 22 ms 384 KB Output is correct
21 Correct 10 ms 380 KB Output is correct
22 Correct 23 ms 256 KB Output is correct
23 Correct 16 ms 384 KB Output is correct
24 Correct 10 ms 504 KB Output is correct
25 Correct 16 ms 384 KB Output is correct
26 Correct 18 ms 256 KB Output is correct
27 Correct 19 ms 376 KB Output is correct
28 Correct 19 ms 256 KB Output is correct
29 Correct 16 ms 256 KB Output is correct
30 Correct 20 ms 256 KB Output is correct
31 Correct 51 ms 376 KB Output is correct
32 Correct 56 ms 376 KB Output is correct
33 Correct 83 ms 376 KB Output is correct
34 Correct 88 ms 376 KB Output is correct
35 Correct 101 ms 508 KB Output is correct
36 Correct 96 ms 512 KB Output is correct
37 Correct 88 ms 376 KB Output is correct
38 Correct 90 ms 376 KB Output is correct
39 Correct 91 ms 508 KB Output is correct
40 Correct 101 ms 384 KB Output is correct
41 Correct 128 ms 380 KB Output is correct
42 Correct 109 ms 380 KB Output is correct
43 Correct 91 ms 376 KB Output is correct
44 Correct 93 ms 376 KB Output is correct
45 Correct 112 ms 380 KB Output is correct
46 Correct 129 ms 376 KB Output is correct
47 Correct 82 ms 376 KB Output is correct
48 Correct 85 ms 504 KB Output is correct
49 Correct 85 ms 380 KB Output is correct
50 Correct 50 ms 508 KB Output is correct
51 Correct 49 ms 384 KB Output is correct
52 Correct 55 ms 380 KB Output is correct
53 Correct 88 ms 376 KB Output is correct
54 Correct 113 ms 384 KB Output is correct
55 Correct 79 ms 384 KB Output is correct
56 Correct 92 ms 376 KB Output is correct
57 Correct 94 ms 376 KB Output is correct
58 Correct 109 ms 504 KB Output is correct
59 Correct 123 ms 384 KB Output is correct
60 Correct 120 ms 376 KB Output is correct