답안 #102451

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
102451 2019-03-25T04:09:25 Z user202729 Xylophone (JOI18_xylophone) C++17
100 / 100
79 ms 504 KB
#include "xylophone.h"

#include<vector>
#include<algorithm>

void solve(int n){
	std::vector<int> ans(n);
	int lastdiff=ans[1]=query(1,2);
	int lastsign=1;
	for(int i=2;i<n;++i){
		int diff=query(i,i+1);
		int sign=lastsign;
		if(lastdiff+diff>=n||query(i-1,i+1)!=lastdiff+diff)
			sign=-sign;
		ans[i]=ans[i-1]+sign*diff;

		lastsign=sign;
		lastdiff=diff;
	}

	int offset=1-*std::min_element(begin(ans),end(ans));
	for(int& x:ans)x+=offset;

	if(std::find(begin(ans),end(ans),1)>std::find(begin(ans),end(ans),n))
		for(int& x:ans)x=n+1-x;

	for(int i=0;i<n;++i)
		answer(i+1,ans[i]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 4 ms 384 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 384 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 3 ms 256 KB Output is correct
11 Correct 3 ms 384 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 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 4 ms 384 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 384 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 3 ms 256 KB Output is correct
11 Correct 3 ms 384 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 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 6 ms 312 KB Output is correct
18 Correct 15 ms 384 KB Output is correct
19 Correct 19 ms 384 KB Output is correct
20 Correct 17 ms 256 KB Output is correct
21 Correct 14 ms 384 KB Output is correct
22 Correct 14 ms 256 KB Output is correct
23 Correct 16 ms 384 KB Output is correct
24 Correct 13 ms 256 KB Output is correct
25 Correct 14 ms 256 KB Output is correct
26 Correct 17 ms 384 KB Output is correct
27 Correct 19 ms 256 KB Output is correct
28 Correct 8 ms 396 KB Output is correct
29 Correct 15 ms 384 KB Output is correct
30 Correct 12 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 4 ms 384 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 384 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 3 ms 256 KB Output is correct
11 Correct 3 ms 384 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 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 6 ms 312 KB Output is correct
18 Correct 15 ms 384 KB Output is correct
19 Correct 19 ms 384 KB Output is correct
20 Correct 17 ms 256 KB Output is correct
21 Correct 14 ms 384 KB Output is correct
22 Correct 14 ms 256 KB Output is correct
23 Correct 16 ms 384 KB Output is correct
24 Correct 13 ms 256 KB Output is correct
25 Correct 14 ms 256 KB Output is correct
26 Correct 17 ms 384 KB Output is correct
27 Correct 19 ms 256 KB Output is correct
28 Correct 8 ms 396 KB Output is correct
29 Correct 15 ms 384 KB Output is correct
30 Correct 12 ms 384 KB Output is correct
31 Correct 31 ms 384 KB Output is correct
32 Correct 45 ms 256 KB Output is correct
33 Correct 74 ms 384 KB Output is correct
34 Correct 49 ms 504 KB Output is correct
35 Correct 69 ms 384 KB Output is correct
36 Correct 56 ms 384 KB Output is correct
37 Correct 37 ms 256 KB Output is correct
38 Correct 65 ms 320 KB Output is correct
39 Correct 73 ms 256 KB Output is correct
40 Correct 45 ms 424 KB Output is correct
41 Correct 55 ms 384 KB Output is correct
42 Correct 37 ms 324 KB Output is correct
43 Correct 39 ms 384 KB Output is correct
44 Correct 45 ms 384 KB Output is correct
45 Correct 58 ms 424 KB Output is correct
46 Correct 77 ms 328 KB Output is correct
47 Correct 65 ms 320 KB Output is correct
48 Correct 73 ms 504 KB Output is correct
49 Correct 57 ms 404 KB Output is correct
50 Correct 70 ms 256 KB Output is correct
51 Correct 72 ms 384 KB Output is correct
52 Correct 79 ms 324 KB Output is correct
53 Correct 56 ms 376 KB Output is correct
54 Correct 70 ms 256 KB Output is correct
55 Correct 50 ms 384 KB Output is correct
56 Correct 69 ms 256 KB Output is correct
57 Correct 70 ms 256 KB Output is correct
58 Correct 78 ms 324 KB Output is correct
59 Correct 66 ms 384 KB Output is correct
60 Correct 50 ms 384 KB Output is correct