답안 #412191

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
412191 2021-05-26T15:27:14 Z nichke Xylophone (JOI18_xylophone) C++14
100 / 100
146 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

void answer(int a, int b);
int query(int a, int b);

void solve(int n) {
	vector<int> ans(n + 1);
	vector<int> d1(n + 1);
	vector<int> d2(n + 1);
	for (int i = 1; i < n; i++) {
		d1[i - 1] = query(i, i + 1);
	}
	for (int i = 2; i < n; i++) {
		d2[i - 2] = query(i - 1, i + 1);
	}
	ans[0] = 0;
	ans[1] = d1[0];
	int tm = 1;
	for (int i = 2; i < n; i++) {
		if (d2[i - 2] != d1[i - 1] + d1[i - 2]) {
			tm *= -1;
		}
		ans[i] = ans[i - 1] + d1[i - 1] * tm;
	}
	int mn = 0, mx = 0;
	int mnv = 0, mxv = 0;
	for (int i = 1; i < n; i++) {
		if (ans[i] < ans[mn]) {
			mn = i;
			mnv = ans[i];
		}
		if (ans[i] > ans[mx]) {
			mx = i;
			mxv = ans[i];
		}
	}
	if (mn < mx) {
		for (int i = 0; i < n; i++) {
			answer(i + 1, ans[i] - mnv + 1);
		}
	} else {
		for (int i = 0; i < n; i++) {
			answer(i + 1, mxv - ans[i] + 1);
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 3 ms 200 KB Output is correct
4 Correct 4 ms 200 KB Output is correct
5 Correct 4 ms 200 KB Output is correct
6 Correct 3 ms 200 KB Output is correct
7 Correct 2 ms 200 KB Output is correct
8 Correct 3 ms 200 KB Output is correct
9 Correct 3 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 4 ms 200 KB Output is correct
13 Correct 2 ms 228 KB Output is correct
14 Correct 4 ms 200 KB Output is correct
15 Correct 3 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 3 ms 200 KB Output is correct
4 Correct 4 ms 200 KB Output is correct
5 Correct 4 ms 200 KB Output is correct
6 Correct 3 ms 200 KB Output is correct
7 Correct 2 ms 200 KB Output is correct
8 Correct 3 ms 200 KB Output is correct
9 Correct 3 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 4 ms 200 KB Output is correct
13 Correct 2 ms 228 KB Output is correct
14 Correct 4 ms 200 KB Output is correct
15 Correct 3 ms 200 KB Output is correct
16 Correct 7 ms 200 KB Output is correct
17 Correct 13 ms 200 KB Output is correct
18 Correct 24 ms 200 KB Output is correct
19 Correct 20 ms 200 KB Output is correct
20 Correct 27 ms 200 KB Output is correct
21 Correct 22 ms 200 KB Output is correct
22 Correct 27 ms 284 KB Output is correct
23 Correct 17 ms 200 KB Output is correct
24 Correct 26 ms 200 KB Output is correct
25 Correct 19 ms 200 KB Output is correct
26 Correct 28 ms 280 KB Output is correct
27 Correct 19 ms 200 KB Output is correct
28 Correct 33 ms 292 KB Output is correct
29 Correct 26 ms 200 KB Output is correct
30 Correct 18 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 3 ms 200 KB Output is correct
4 Correct 4 ms 200 KB Output is correct
5 Correct 4 ms 200 KB Output is correct
6 Correct 3 ms 200 KB Output is correct
7 Correct 2 ms 200 KB Output is correct
8 Correct 3 ms 200 KB Output is correct
9 Correct 3 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 4 ms 200 KB Output is correct
13 Correct 2 ms 228 KB Output is correct
14 Correct 4 ms 200 KB Output is correct
15 Correct 3 ms 200 KB Output is correct
16 Correct 7 ms 200 KB Output is correct
17 Correct 13 ms 200 KB Output is correct
18 Correct 24 ms 200 KB Output is correct
19 Correct 20 ms 200 KB Output is correct
20 Correct 27 ms 200 KB Output is correct
21 Correct 22 ms 200 KB Output is correct
22 Correct 27 ms 284 KB Output is correct
23 Correct 17 ms 200 KB Output is correct
24 Correct 26 ms 200 KB Output is correct
25 Correct 19 ms 200 KB Output is correct
26 Correct 28 ms 280 KB Output is correct
27 Correct 19 ms 200 KB Output is correct
28 Correct 33 ms 292 KB Output is correct
29 Correct 26 ms 200 KB Output is correct
30 Correct 18 ms 200 KB Output is correct
31 Correct 53 ms 296 KB Output is correct
32 Correct 75 ms 308 KB Output is correct
33 Correct 95 ms 328 KB Output is correct
34 Correct 146 ms 332 KB Output is correct
35 Correct 129 ms 340 KB Output is correct
36 Correct 125 ms 336 KB Output is correct
37 Correct 110 ms 336 KB Output is correct
38 Correct 92 ms 328 KB Output is correct
39 Correct 102 ms 336 KB Output is correct
40 Correct 97 ms 340 KB Output is correct
41 Correct 110 ms 348 KB Output is correct
42 Correct 62 ms 328 KB Output is correct
43 Correct 97 ms 332 KB Output is correct
44 Correct 95 ms 344 KB Output is correct
45 Correct 109 ms 336 KB Output is correct
46 Correct 132 ms 332 KB Output is correct
47 Correct 125 ms 332 KB Output is correct
48 Correct 136 ms 336 KB Output is correct
49 Correct 103 ms 344 KB Output is correct
50 Correct 83 ms 332 KB Output is correct
51 Correct 139 ms 332 KB Output is correct
52 Correct 138 ms 328 KB Output is correct
53 Correct 134 ms 328 KB Output is correct
54 Correct 88 ms 328 KB Output is correct
55 Correct 125 ms 332 KB Output is correct
56 Correct 47 ms 328 KB Output is correct
57 Correct 59 ms 348 KB Output is correct
58 Correct 128 ms 336 KB Output is correct
59 Correct 48 ms 340 KB Output is correct
60 Correct 100 ms 328 KB Output is correct