답안 #257197

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
257197 2020-08-03T18:31:52 Z a_player Xylophone (JOI18_xylophone) C++14
100 / 100
135 ms 632 KB
#ifndef A
#include "xylophone.h"
#endif
#include <bits/stdc++.h>

using namespace std;
const int nax=5e3+3;
int d[nax],t[nax];
int m[nax];
int p[nax];
void solve(int N) {

	for(int i=0;i<N-1;i++)d[i]=query(i+1,i+2);
	for(int i=0;i<N-2;i++)t[i]=query(i+1,i+3);
	m[0]=d[0];
	if(t[0]==d[0]+d[1])m[1]=d[1];
	else m[1]=-d[1];
	for(int i=1;i<N-2;i++){
		int s=m[i]/abs(m[i]);
		if(t[i]==d[i]+d[i+1])m[i+1]=s*d[i+1];
		else m[i+1]=-s*d[i+1];
	}
	for(int i=1;i<N;i++)p[i]=p[i-1]+m[i-1];
	int mini=*min_element(p,p+N);
	for(int i=0;i<N;i++)p[i]+=-mini+1;
	bool flag=false;
	bool uno=false;
	for(int i=0;i<N;i++){
		if(p[i]==1)uno=true;
		if(p[i]>N)flag=true;
		if(p[i]==N&&!uno)flag=true;
	}
	if(!flag){
		for(int i=0;i<N;i++)answer(i+1,p[i]);
		return;
	}
	for(int i=1;i<N;i++)p[i]=p[i-1]-m[i-1];
	 mini=*min_element(p,p+N);
	for(int i=0;i<N;i++)p[i]+=-mini+1;
	for(int i=0;i<N;i++)answer(i+1,p[i]);

}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 8 ms 384 KB Output is correct
18 Correct 13 ms 384 KB Output is correct
19 Correct 19 ms 384 KB Output is correct
20 Correct 19 ms 384 KB Output is correct
21 Correct 18 ms 376 KB Output is correct
22 Correct 16 ms 376 KB Output is correct
23 Correct 23 ms 376 KB Output is correct
24 Correct 16 ms 384 KB Output is correct
25 Correct 24 ms 376 KB Output is correct
26 Correct 18 ms 376 KB Output is correct
27 Correct 24 ms 376 KB Output is correct
28 Correct 24 ms 384 KB Output is correct
29 Correct 21 ms 384 KB Output is correct
30 Correct 24 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 8 ms 384 KB Output is correct
18 Correct 13 ms 384 KB Output is correct
19 Correct 19 ms 384 KB Output is correct
20 Correct 19 ms 384 KB Output is correct
21 Correct 18 ms 376 KB Output is correct
22 Correct 16 ms 376 KB Output is correct
23 Correct 23 ms 376 KB Output is correct
24 Correct 16 ms 384 KB Output is correct
25 Correct 24 ms 376 KB Output is correct
26 Correct 18 ms 376 KB Output is correct
27 Correct 24 ms 376 KB Output is correct
28 Correct 24 ms 384 KB Output is correct
29 Correct 21 ms 384 KB Output is correct
30 Correct 24 ms 376 KB Output is correct
31 Correct 36 ms 376 KB Output is correct
32 Correct 69 ms 504 KB Output is correct
33 Correct 107 ms 392 KB Output is correct
34 Correct 133 ms 376 KB Output is correct
35 Correct 135 ms 376 KB Output is correct
36 Correct 87 ms 376 KB Output is correct
37 Correct 125 ms 376 KB Output is correct
38 Correct 95 ms 376 KB Output is correct
39 Correct 92 ms 376 KB Output is correct
40 Correct 84 ms 396 KB Output is correct
41 Correct 91 ms 392 KB Output is correct
42 Correct 130 ms 392 KB Output is correct
43 Correct 87 ms 528 KB Output is correct
44 Correct 85 ms 504 KB Output is correct
45 Correct 84 ms 376 KB Output is correct
46 Correct 89 ms 384 KB Output is correct
47 Correct 85 ms 376 KB Output is correct
48 Correct 86 ms 508 KB Output is correct
49 Correct 88 ms 504 KB Output is correct
50 Correct 102 ms 376 KB Output is correct
51 Correct 59 ms 376 KB Output is correct
52 Correct 123 ms 384 KB Output is correct
53 Correct 85 ms 384 KB Output is correct
54 Correct 79 ms 632 KB Output is correct
55 Correct 88 ms 380 KB Output is correct
56 Correct 85 ms 376 KB Output is correct
57 Correct 76 ms 632 KB Output is correct
58 Correct 84 ms 376 KB Output is correct
59 Correct 86 ms 376 KB Output is correct
60 Correct 90 ms 504 KB Output is correct