답안 #67717

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
67717 2018-08-15T09:07:11 Z chpipis Xylophone (JOI18_xylophone) C++11
100 / 100
167 ms 716 KB
#include "xylophone.h"
#include <bits/stdc++.h>
 
using namespace std;
 
const int MAXN = 5005;
 
int ar[MAXN];
 
void solve(int n) {
	memset(ar, -1, sizeof ar);
	
	ar[1] = 0;
	ar[2] = query(1, 2);
 
	for (int i = 2; i + 1 <= n; i++) {
		int a = ar[i], b = ar[i - 1];
		int one = query(i, i + 1);
		int two = query(i - 1, i + 1);
		if (a < b) {
			if (a - one + two == b)
				ar[i + 1] = a - one;
			else
				ar[i + 1] = a + one;
		} else {
			if (a + one - two == b)
				ar[i + 1] = a + one;
			else
				ar[i + 1] = a - one;
		}
	}
 
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			if (abs(ar[i] - ar[j]) != n - 1)
				continue;
			int add = 1 - min(ar[i], ar[j]);
			for (int k = 1; k <= n; k++) {
				ar[k] += add;
			}
			if (ar[i] > ar[j]) {
				for (int k = 1; k <= n; k++) {
					ar[k] = n + 1 - ar[k];
				}
			}
		}
	}
 
	for (int i = 1; i <= n; i++) {
		answer(i, ar[i]);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 4 ms 388 KB Output is correct
4 Correct 4 ms 388 KB Output is correct
5 Correct 4 ms 440 KB Output is correct
6 Correct 3 ms 440 KB Output is correct
7 Correct 4 ms 496 KB Output is correct
8 Correct 4 ms 496 KB Output is correct
9 Correct 4 ms 572 KB Output is correct
10 Correct 3 ms 576 KB Output is correct
11 Correct 4 ms 576 KB Output is correct
12 Correct 4 ms 700 KB Output is correct
13 Correct 6 ms 700 KB Output is correct
14 Correct 4 ms 700 KB Output is correct
15 Correct 5 ms 700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 4 ms 388 KB Output is correct
4 Correct 4 ms 388 KB Output is correct
5 Correct 4 ms 440 KB Output is correct
6 Correct 3 ms 440 KB Output is correct
7 Correct 4 ms 496 KB Output is correct
8 Correct 4 ms 496 KB Output is correct
9 Correct 4 ms 572 KB Output is correct
10 Correct 3 ms 576 KB Output is correct
11 Correct 4 ms 576 KB Output is correct
12 Correct 4 ms 700 KB Output is correct
13 Correct 6 ms 700 KB Output is correct
14 Correct 4 ms 700 KB Output is correct
15 Correct 5 ms 700 KB Output is correct
16 Correct 4 ms 700 KB Output is correct
17 Correct 10 ms 700 KB Output is correct
18 Correct 11 ms 716 KB Output is correct
19 Correct 24 ms 716 KB Output is correct
20 Correct 17 ms 716 KB Output is correct
21 Correct 18 ms 716 KB Output is correct
22 Correct 19 ms 716 KB Output is correct
23 Correct 18 ms 716 KB Output is correct
24 Correct 22 ms 716 KB Output is correct
25 Correct 16 ms 716 KB Output is correct
26 Correct 17 ms 716 KB Output is correct
27 Correct 18 ms 716 KB Output is correct
28 Correct 22 ms 716 KB Output is correct
29 Correct 18 ms 716 KB Output is correct
30 Correct 25 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 4 ms 388 KB Output is correct
4 Correct 4 ms 388 KB Output is correct
5 Correct 4 ms 440 KB Output is correct
6 Correct 3 ms 440 KB Output is correct
7 Correct 4 ms 496 KB Output is correct
8 Correct 4 ms 496 KB Output is correct
9 Correct 4 ms 572 KB Output is correct
10 Correct 3 ms 576 KB Output is correct
11 Correct 4 ms 576 KB Output is correct
12 Correct 4 ms 700 KB Output is correct
13 Correct 6 ms 700 KB Output is correct
14 Correct 4 ms 700 KB Output is correct
15 Correct 5 ms 700 KB Output is correct
16 Correct 4 ms 700 KB Output is correct
17 Correct 10 ms 700 KB Output is correct
18 Correct 11 ms 716 KB Output is correct
19 Correct 24 ms 716 KB Output is correct
20 Correct 17 ms 716 KB Output is correct
21 Correct 18 ms 716 KB Output is correct
22 Correct 19 ms 716 KB Output is correct
23 Correct 18 ms 716 KB Output is correct
24 Correct 22 ms 716 KB Output is correct
25 Correct 16 ms 716 KB Output is correct
26 Correct 17 ms 716 KB Output is correct
27 Correct 18 ms 716 KB Output is correct
28 Correct 22 ms 716 KB Output is correct
29 Correct 18 ms 716 KB Output is correct
30 Correct 25 ms 716 KB Output is correct
31 Correct 40 ms 716 KB Output is correct
32 Correct 73 ms 716 KB Output is correct
33 Correct 82 ms 716 KB Output is correct
34 Correct 70 ms 716 KB Output is correct
35 Correct 111 ms 716 KB Output is correct
36 Correct 87 ms 716 KB Output is correct
37 Correct 113 ms 716 KB Output is correct
38 Correct 59 ms 716 KB Output is correct
39 Correct 82 ms 716 KB Output is correct
40 Correct 107 ms 716 KB Output is correct
41 Correct 75 ms 716 KB Output is correct
42 Correct 138 ms 716 KB Output is correct
43 Correct 71 ms 716 KB Output is correct
44 Correct 88 ms 716 KB Output is correct
45 Correct 116 ms 716 KB Output is correct
46 Correct 146 ms 716 KB Output is correct
47 Correct 129 ms 716 KB Output is correct
48 Correct 96 ms 716 KB Output is correct
49 Correct 100 ms 716 KB Output is correct
50 Correct 164 ms 716 KB Output is correct
51 Correct 167 ms 716 KB Output is correct
52 Correct 96 ms 716 KB Output is correct
53 Correct 130 ms 716 KB Output is correct
54 Correct 113 ms 716 KB Output is correct
55 Correct 151 ms 716 KB Output is correct
56 Correct 144 ms 716 KB Output is correct
57 Correct 75 ms 716 KB Output is correct
58 Correct 75 ms 716 KB Output is correct
59 Correct 105 ms 716 KB Output is correct
60 Correct 91 ms 716 KB Output is correct