답안 #943793

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
943793 2024-03-12T00:38:06 Z pcc Xylophone (JOI18_xylophone) C++17
100 / 100
65 ms 700 KB
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;

static int A[5000];

void solve(int N) {
	int arr[N+1],sign[N+1],brr[N+1],ans[N+1];
	for(auto &i:sign)i = 1;
	for(int i = 2;i<=N;i++)arr[i] = query(i-1,i);
	for(int i = 3;i<=N;i++)brr[i] = query(i-2,i);
	for(int i = 3;i<=N;i++){
		if(arr[i]+arr[i-1] == brr[i]){
			sign[i] = sign[i-1];
		}
		else{
			sign[i] = -sign[i-1];
		}
		//else assert(false);
	}
	//for(int i = 1;i<=N;i++)cout<<sign[i]<<' ';cout<<endl;
	for(int i = 2;i<=N;i++){
		arr[i] = arr[i]*sign[i]+arr[i-1];
	}
	//for(int i = 1;i<=N;i++)cout<<arr[i]<<' ';cout<<endl;
	int sh = 1-*min_element(arr+1,arr+N+1);
	for(int i = 1;i<=N;i++)arr[i] += sh;
	if(min_element(arr+1,arr+N+1)-arr>max_element(arr+1,arr+N+1)-arr){
		for(int i = 1;i<=N;i++)arr[i] = N+1-arr[i];
	}

	for(int i = 1; i <= N; i++) {
		answer(i,arr[i]);
	}
	return;

}

Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:8:34: warning: unused variable 'ans' [-Wunused-variable]
    8 |  int arr[N+1],sign[N+1],brr[N+1],ans[N+1];
      |                                  ^~~
xylophone.cpp: At global scope:
xylophone.cpp:5:12: warning: 'A' defined but not used [-Wunused-variable]
    5 | static int A[5000];
      |            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 2 ms 344 KB Output is correct
17 Correct 4 ms 344 KB Output is correct
18 Correct 8 ms 344 KB Output is correct
19 Correct 8 ms 444 KB Output is correct
20 Correct 7 ms 444 KB Output is correct
21 Correct 11 ms 440 KB Output is correct
22 Correct 11 ms 436 KB Output is correct
23 Correct 10 ms 444 KB Output is correct
24 Correct 11 ms 444 KB Output is correct
25 Correct 7 ms 444 KB Output is correct
26 Correct 8 ms 440 KB Output is correct
27 Correct 8 ms 700 KB Output is correct
28 Correct 8 ms 440 KB Output is correct
29 Correct 9 ms 444 KB Output is correct
30 Correct 10 ms 448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 2 ms 344 KB Output is correct
17 Correct 4 ms 344 KB Output is correct
18 Correct 8 ms 344 KB Output is correct
19 Correct 8 ms 444 KB Output is correct
20 Correct 7 ms 444 KB Output is correct
21 Correct 11 ms 440 KB Output is correct
22 Correct 11 ms 436 KB Output is correct
23 Correct 10 ms 444 KB Output is correct
24 Correct 11 ms 444 KB Output is correct
25 Correct 7 ms 444 KB Output is correct
26 Correct 8 ms 440 KB Output is correct
27 Correct 8 ms 700 KB Output is correct
28 Correct 8 ms 440 KB Output is correct
29 Correct 9 ms 444 KB Output is correct
30 Correct 10 ms 448 KB Output is correct
31 Correct 26 ms 432 KB Output is correct
32 Correct 35 ms 448 KB Output is correct
33 Correct 37 ms 464 KB Output is correct
34 Correct 55 ms 464 KB Output is correct
35 Correct 55 ms 468 KB Output is correct
36 Correct 48 ms 468 KB Output is correct
37 Correct 42 ms 468 KB Output is correct
38 Correct 59 ms 484 KB Output is correct
39 Correct 54 ms 468 KB Output is correct
40 Correct 57 ms 480 KB Output is correct
41 Correct 47 ms 468 KB Output is correct
42 Correct 56 ms 484 KB Output is correct
43 Correct 50 ms 468 KB Output is correct
44 Correct 60 ms 464 KB Output is correct
45 Correct 65 ms 468 KB Output is correct
46 Correct 59 ms 492 KB Output is correct
47 Correct 62 ms 504 KB Output is correct
48 Correct 35 ms 468 KB Output is correct
49 Correct 44 ms 484 KB Output is correct
50 Correct 41 ms 484 KB Output is correct
51 Correct 39 ms 504 KB Output is correct
52 Correct 45 ms 484 KB Output is correct
53 Correct 39 ms 540 KB Output is correct
54 Correct 54 ms 484 KB Output is correct
55 Correct 54 ms 516 KB Output is correct
56 Correct 41 ms 484 KB Output is correct
57 Correct 34 ms 468 KB Output is correct
58 Correct 38 ms 484 KB Output is correct
59 Correct 43 ms 464 KB Output is correct
60 Correct 56 ms 468 KB Output is correct