답안 #363140

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
363140 2021-02-05T07:02:40 Z Bill_00 Xylophone (JOI18_xylophone) C++14
100 / 100
131 ms 748 KB
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
static int A[5000];
 
void solve(int n) {
	if(n==2){
		answer(1,1);
		answer(2,n);
		return;
	}
	int a[5005],b[5005],c[5005];
	for(int i=1;i<n;i++){
		a[i]=query(i,i+1);
	}
	int val=query(1,3);
	if(val==a[1]+a[2]){
		b[1]=1;
		b[2]=1;
	}
	else{
		b[1]=1;
		b[2]=-1;
	}
	for(int i=2;i<n-1;i++){
		int val=query(i,i+2);
		if(val==a[i]+a[i+1]){
			if(b[i]==1) b[i+1]=1;
			else b[i+1]=-1;
		}
		else{
			if(b[i]==1) b[i+1]=-1;
			else b[i+1]=1;
		}
	}
	c[1]=0;
	for(int i=2;i<=n;i++){
		c[i]=c[i-1]+a[i-1]*b[i-1];
	}
	pair<int,int>mx={-(n+1),-1},mn={n+1,-1};
	for(int i=1;i<=n;i++){
		mx=max(mx,{c[i],i});
		mn=min(mn,{c[i],i});
	}
	if(mx.second<mn.second){
		for(int i=1;i<=n;i++){
			c[i]=-c[i];
		}
      	mn.first=-mx.first;
	}
	int ihesgegch=1-mn.first;
	for(int i=1;i<=n;i++){
		answer(i,c[i]+ihesgegch);
	}
}

Compilation message

xylophone.cpp:4:12: warning: 'A' defined but not used [-Wunused-variable]
    4 | static int A[5000];
      |            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 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 3 ms 364 KB Output is correct
11 Correct 3 ms 364 KB Output is correct
12 Correct 3 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 3 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 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 3 ms 364 KB Output is correct
11 Correct 3 ms 364 KB Output is correct
12 Correct 3 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 3 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 6 ms 364 KB Output is correct
17 Correct 9 ms 388 KB Output is correct
18 Correct 21 ms 364 KB Output is correct
19 Correct 24 ms 364 KB Output is correct
20 Correct 17 ms 384 KB Output is correct
21 Correct 24 ms 364 KB Output is correct
22 Correct 24 ms 492 KB Output is correct
23 Correct 25 ms 364 KB Output is correct
24 Correct 12 ms 384 KB Output is correct
25 Correct 24 ms 364 KB Output is correct
26 Correct 24 ms 364 KB Output is correct
27 Correct 20 ms 364 KB Output is correct
28 Correct 11 ms 384 KB Output is correct
29 Correct 16 ms 492 KB Output is correct
30 Correct 15 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 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 3 ms 364 KB Output is correct
11 Correct 3 ms 364 KB Output is correct
12 Correct 3 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 3 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 6 ms 364 KB Output is correct
17 Correct 9 ms 388 KB Output is correct
18 Correct 21 ms 364 KB Output is correct
19 Correct 24 ms 364 KB Output is correct
20 Correct 17 ms 384 KB Output is correct
21 Correct 24 ms 364 KB Output is correct
22 Correct 24 ms 492 KB Output is correct
23 Correct 25 ms 364 KB Output is correct
24 Correct 12 ms 384 KB Output is correct
25 Correct 24 ms 364 KB Output is correct
26 Correct 24 ms 364 KB Output is correct
27 Correct 20 ms 364 KB Output is correct
28 Correct 11 ms 384 KB Output is correct
29 Correct 16 ms 492 KB Output is correct
30 Correct 15 ms 364 KB Output is correct
31 Correct 40 ms 396 KB Output is correct
32 Correct 36 ms 404 KB Output is correct
33 Correct 65 ms 620 KB Output is correct
34 Correct 59 ms 512 KB Output is correct
35 Correct 131 ms 364 KB Output is correct
36 Correct 94 ms 492 KB Output is correct
37 Correct 114 ms 508 KB Output is correct
38 Correct 85 ms 512 KB Output is correct
39 Correct 88 ms 492 KB Output is correct
40 Correct 93 ms 364 KB Output is correct
41 Correct 87 ms 364 KB Output is correct
42 Correct 98 ms 620 KB Output is correct
43 Correct 82 ms 364 KB Output is correct
44 Correct 104 ms 528 KB Output is correct
45 Correct 77 ms 748 KB Output is correct
46 Correct 117 ms 492 KB Output is correct
47 Correct 94 ms 364 KB Output is correct
48 Correct 98 ms 492 KB Output is correct
49 Correct 82 ms 364 KB Output is correct
50 Correct 117 ms 620 KB Output is correct
51 Correct 92 ms 492 KB Output is correct
52 Correct 119 ms 612 KB Output is correct
53 Correct 90 ms 364 KB Output is correct
54 Correct 85 ms 620 KB Output is correct
55 Correct 126 ms 620 KB Output is correct
56 Correct 85 ms 384 KB Output is correct
57 Correct 65 ms 512 KB Output is correct
58 Correct 95 ms 364 KB Output is correct
59 Correct 114 ms 364 KB Output is correct
60 Correct 78 ms 492 KB Output is correct