답안 #321618

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
321618 2020-11-12T22:54:02 Z Lawliet Xylophone (JOI18_xylophone) C++17
100 / 100
127 ms 632 KB
#include "xylophone.h"
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 5010;

int v[MAXN];
int ans[MAXN], t[MAXN];

int signal(int s)
{
	if( s > 0 ) return 1;
	return -1;
}

void solve(int N) 
{
	v[1] = query( 1 , 2 );
	t[1] = v[1];

	for(int i = 2 ; i < N ; i++)
	{
		v[i] = query( i , i + 1 );
		t[i] = abs( v[i] );

		if( v[i - 1] + v[i] == query( i - 1 , i + 1 ) ) t[i] *= signal( t[i - 1] );
		else t[i] *= signal( -t[i - 1] );
	}

	int mn = 0;

	for(int i = 2 ; i <= N ; i++)
	{
		ans[i] = ans[i - 1] + t[i - 1];
		mn = min( mn , ans[i] );
	}

	for(int i = 1 ; i <= N ; i++)
		ans[i] += -mn + 1;

	bool flag = true;
	int prefixMn = N + 1;

	for(int i = 1 ; i <= N ; i++)
	{
		if( ans[i] == N && prefixMn != 1 ) flag = false;
		prefixMn = min( prefixMn , ans[i] );
	}

	for(int i = 1 ; i <= N && !flag ; i++)
		ans[i] = N - ans[i] + 1;

	for(int i = 1 ; i <= N ; i++)
		answer( i , ans[i] );
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 3 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 2 ms 236 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 3 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 3 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 3 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 2 ms 236 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 3 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 3 ms 364 KB Output is correct
16 Correct 4 ms 364 KB Output is correct
17 Correct 5 ms 380 KB Output is correct
18 Correct 15 ms 364 KB Output is correct
19 Correct 20 ms 364 KB Output is correct
20 Correct 17 ms 364 KB Output is correct
21 Correct 18 ms 364 KB Output is correct
22 Correct 19 ms 364 KB Output is correct
23 Correct 18 ms 364 KB Output is correct
24 Correct 16 ms 512 KB Output is correct
25 Correct 12 ms 492 KB Output is correct
26 Correct 12 ms 380 KB Output is correct
27 Correct 19 ms 492 KB Output is correct
28 Correct 11 ms 380 KB Output is correct
29 Correct 19 ms 364 KB Output is correct
30 Correct 18 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 3 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 2 ms 236 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 3 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 3 ms 364 KB Output is correct
16 Correct 4 ms 364 KB Output is correct
17 Correct 5 ms 380 KB Output is correct
18 Correct 15 ms 364 KB Output is correct
19 Correct 20 ms 364 KB Output is correct
20 Correct 17 ms 364 KB Output is correct
21 Correct 18 ms 364 KB Output is correct
22 Correct 19 ms 364 KB Output is correct
23 Correct 18 ms 364 KB Output is correct
24 Correct 16 ms 512 KB Output is correct
25 Correct 12 ms 492 KB Output is correct
26 Correct 12 ms 380 KB Output is correct
27 Correct 19 ms 492 KB Output is correct
28 Correct 11 ms 380 KB Output is correct
29 Correct 19 ms 364 KB Output is correct
30 Correct 18 ms 364 KB Output is correct
31 Correct 40 ms 364 KB Output is correct
32 Correct 51 ms 492 KB Output is correct
33 Correct 84 ms 364 KB Output is correct
34 Correct 96 ms 364 KB Output is correct
35 Correct 81 ms 500 KB Output is correct
36 Correct 117 ms 364 KB Output is correct
37 Correct 91 ms 500 KB Output is correct
38 Correct 95 ms 364 KB Output is correct
39 Correct 93 ms 632 KB Output is correct
40 Correct 97 ms 364 KB Output is correct
41 Correct 113 ms 628 KB Output is correct
42 Correct 53 ms 380 KB Output is correct
43 Correct 99 ms 492 KB Output is correct
44 Correct 87 ms 492 KB Output is correct
45 Correct 63 ms 492 KB Output is correct
46 Correct 126 ms 620 KB Output is correct
47 Correct 102 ms 364 KB Output is correct
48 Correct 119 ms 492 KB Output is correct
49 Correct 119 ms 364 KB Output is correct
50 Correct 79 ms 364 KB Output is correct
51 Correct 85 ms 492 KB Output is correct
52 Correct 96 ms 620 KB Output is correct
53 Correct 110 ms 620 KB Output is correct
54 Correct 79 ms 492 KB Output is correct
55 Correct 127 ms 492 KB Output is correct
56 Correct 86 ms 364 KB Output is correct
57 Correct 89 ms 492 KB Output is correct
58 Correct 126 ms 364 KB Output is correct
59 Correct 93 ms 492 KB Output is correct
60 Correct 100 ms 620 KB Output is correct