답안 #525584

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
525584 2022-02-12T03:52:05 Z huangqr Xylophone (JOI18_xylophone) C++14
100 / 100
108 ms 328 KB
#include "xylophone.h"

static int A[5000];

#include<bits/stdc++.h>
using namespace std;

void solve(int N) {
	int v[10005];
	v[1]=1;
	v[2]=1+query(1,2);
	int mn=1;
	for(int i=3;i<=N;i++){
		int x=query(i-2,i),y=query(i-1,i);
		if(v[i-1]>v[i-2]){
			if(x==y)v[i]=v[i-1]-y;
			else if(x>y&&x==v[i-1]-v[i-2])v[i]=v[i-1]-y;
			else if(x-y==v[i-1]-v[i-2])v[i]=v[i-1]+y;
			else assert(0);
		}
		else{
			if(x==y)v[i]=v[i-1]+y;
			else if(x>y&&x==v[i-2]-v[i-1])v[i]=v[i-1]+y;
			else if(x-y==v[i-2]-v[i-1])v[i]=v[i-1]-y;
			else assert(0);
		}
		mn=min(mn,v[i]);
	}
	for(int i=1;i<=N;i++)v[i]-=(mn-1);
	int pos_1,pos_N;
	for(int i=1;i<=N;i++){
		if(v[i]==1)pos_1=i;
		if(v[i]==N)pos_N=i;
	}
	if(pos_1>pos_N){
		for(int i=1;i<=N;i++)v[i]=N+1-v[i];
	}
	/*for(int i = 1; i <= N; i++) {
		cout<<v[i]<<" ";
		//answer(i, i);
	}*/
	for(int i=1;i<=N;i++)answer(i,v[i]);
}

Compilation message

xylophone.cpp:3:12: warning: 'A' defined but not used [-Wunused-variable]
    3 | static int A[5000];
      |            ^
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:35:2: warning: 'pos_N' may be used uninitialized in this function [-Wmaybe-uninitialized]
   35 |  if(pos_1>pos_N){
      |  ^~
xylophone.cpp:35:2: warning: 'pos_1' may be used uninitialized in this function [-Wmaybe-uninitialized]
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 2 ms 328 KB Output is correct
5 Correct 1 ms 200 KB Output is correct
6 Correct 2 ms 200 KB Output is correct
7 Correct 2 ms 200 KB Output is correct
8 Correct 2 ms 328 KB Output is correct
9 Correct 3 ms 200 KB Output is correct
10 Correct 2 ms 200 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 200 KB Output is correct
13 Correct 3 ms 200 KB Output is correct
14 Correct 2 ms 328 KB Output is correct
15 Correct 2 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 2 ms 328 KB Output is correct
5 Correct 1 ms 200 KB Output is correct
6 Correct 2 ms 200 KB Output is correct
7 Correct 2 ms 200 KB Output is correct
8 Correct 2 ms 328 KB Output is correct
9 Correct 3 ms 200 KB Output is correct
10 Correct 2 ms 200 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 200 KB Output is correct
13 Correct 3 ms 200 KB Output is correct
14 Correct 2 ms 328 KB Output is correct
15 Correct 2 ms 328 KB Output is correct
16 Correct 4 ms 200 KB Output is correct
17 Correct 9 ms 200 KB Output is correct
18 Correct 16 ms 200 KB Output is correct
19 Correct 15 ms 200 KB Output is correct
20 Correct 17 ms 328 KB Output is correct
21 Correct 18 ms 204 KB Output is correct
22 Correct 18 ms 200 KB Output is correct
23 Correct 19 ms 308 KB Output is correct
24 Correct 15 ms 328 KB Output is correct
25 Correct 18 ms 328 KB Output is correct
26 Correct 20 ms 200 KB Output is correct
27 Correct 20 ms 328 KB Output is correct
28 Correct 16 ms 328 KB Output is correct
29 Correct 19 ms 200 KB Output is correct
30 Correct 8 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 2 ms 328 KB Output is correct
5 Correct 1 ms 200 KB Output is correct
6 Correct 2 ms 200 KB Output is correct
7 Correct 2 ms 200 KB Output is correct
8 Correct 2 ms 328 KB Output is correct
9 Correct 3 ms 200 KB Output is correct
10 Correct 2 ms 200 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 200 KB Output is correct
13 Correct 3 ms 200 KB Output is correct
14 Correct 2 ms 328 KB Output is correct
15 Correct 2 ms 328 KB Output is correct
16 Correct 4 ms 200 KB Output is correct
17 Correct 9 ms 200 KB Output is correct
18 Correct 16 ms 200 KB Output is correct
19 Correct 15 ms 200 KB Output is correct
20 Correct 17 ms 328 KB Output is correct
21 Correct 18 ms 204 KB Output is correct
22 Correct 18 ms 200 KB Output is correct
23 Correct 19 ms 308 KB Output is correct
24 Correct 15 ms 328 KB Output is correct
25 Correct 18 ms 328 KB Output is correct
26 Correct 20 ms 200 KB Output is correct
27 Correct 20 ms 328 KB Output is correct
28 Correct 16 ms 328 KB Output is correct
29 Correct 19 ms 200 KB Output is correct
30 Correct 8 ms 324 KB Output is correct
31 Correct 42 ms 308 KB Output is correct
32 Correct 60 ms 308 KB Output is correct
33 Correct 82 ms 308 KB Output is correct
34 Correct 77 ms 328 KB Output is correct
35 Correct 96 ms 308 KB Output is correct
36 Correct 56 ms 328 KB Output is correct
37 Correct 95 ms 304 KB Output is correct
38 Correct 94 ms 328 KB Output is correct
39 Correct 100 ms 328 KB Output is correct
40 Correct 90 ms 304 KB Output is correct
41 Correct 108 ms 320 KB Output is correct
42 Correct 82 ms 320 KB Output is correct
43 Correct 87 ms 304 KB Output is correct
44 Correct 77 ms 324 KB Output is correct
45 Correct 56 ms 312 KB Output is correct
46 Correct 94 ms 328 KB Output is correct
47 Correct 95 ms 320 KB Output is correct
48 Correct 60 ms 328 KB Output is correct
49 Correct 99 ms 328 KB Output is correct
50 Correct 96 ms 328 KB Output is correct
51 Correct 69 ms 328 KB Output is correct
52 Correct 88 ms 308 KB Output is correct
53 Correct 91 ms 304 KB Output is correct
54 Correct 85 ms 304 KB Output is correct
55 Correct 80 ms 328 KB Output is correct
56 Correct 89 ms 316 KB Output is correct
57 Correct 54 ms 316 KB Output is correct
58 Correct 68 ms 308 KB Output is correct
59 Correct 97 ms 320 KB Output is correct
60 Correct 98 ms 304 KB Output is correct