Submission #115354

# Submission time Handle Problem Language Result Execution time Memory
115354 2019-06-07T02:41:59 Z dndhk Xylophone (JOI18_xylophone) C++14
47 / 100
94 ms 384 KB
#include "xylophone.h"


int arr[5001];

int zero(int x){
	return (x>0)?x:-x;
}

void solve(int N) {
	int s = 1, e = N, m;
	while(s<e){
		m = (s+e)/2+1;
		if(query(m, N)==N-1)	s = m;
		else	e = m-1;
	}
	arr[s] = 1;
	if(s!=1){
		arr[s-1] = query(s-1, s) + 1;
	}
	for(int i=s-2; i>=1; i--){
		int t = query(i, i+2);
		if(t==zero(arr[i+1]-arr[i+2])){
			int k = query(i, i+1);
			if(arr[i+1]>arr[i+2]){
				arr[i] = arr[i+1] - k;
			}else{
				arr[i] = arr[i+1] + k;
			}
		}else{
			int k = query(i, i+1);
			if(arr[i+1]>arr[i+2]){
				if(k==t){
					arr[i] = arr[i+1] - k;
				}else{
					arr[i] = arr[i+1] + k;
				}
			}else{
				if(k==t){
					arr[i] = arr[i+1] + k;
				}else{
					arr[i] = arr[i+1] - k;
				}
			}
		}
	}
	if(s!=N){
		arr[s+1] = query(s, s+1) + 1;
	}
	for(int i=s+2; i<=N; i++){
		int t = query(i-2, i);
		if(t==zero(arr[i-1]- arr[i-2])){
			int k = query(i-1, i);
			if(arr[i-1]>arr[i-2]){
				arr[i] = arr[i-1] - k;
			}else{
				arr[i]= arr[i-1] + k;
			}
		}else{
			int k = query(i-1, i);
			if(arr[i-1]>arr[i-2]){
				if(k==t){
					arr[i] = arr[i-1] - k;
				}else{
					arr[i] = arr[i-1] + k;
				}
			}else{
				if(k==t){
					arr[i] = arr[i-1] + k;
				}else{
					arr[i] = arr[i-1] - k;
				}
			}
		}
	}
	for(int i=1; i<=N; i++){
		answer(i, arr[i]);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 256 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 4 ms 256 KB Output is correct
15 Correct 4 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 256 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 4 ms 256 KB Output is correct
15 Correct 4 ms 256 KB Output is correct
16 Correct 6 ms 256 KB Output is correct
17 Correct 9 ms 256 KB Output is correct
18 Correct 18 ms 256 KB Output is correct
19 Correct 17 ms 384 KB Output is correct
20 Correct 17 ms 384 KB Output is correct
21 Correct 22 ms 256 KB Output is correct
22 Correct 24 ms 256 KB Output is correct
23 Correct 17 ms 384 KB Output is correct
24 Correct 13 ms 312 KB Output is correct
25 Correct 16 ms 384 KB Output is correct
26 Correct 23 ms 384 KB Output is correct
27 Correct 9 ms 312 KB Output is correct
28 Correct 16 ms 384 KB Output is correct
29 Correct 9 ms 312 KB Output is correct
30 Correct 20 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 256 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 4 ms 256 KB Output is correct
15 Correct 4 ms 256 KB Output is correct
16 Correct 6 ms 256 KB Output is correct
17 Correct 9 ms 256 KB Output is correct
18 Correct 18 ms 256 KB Output is correct
19 Correct 17 ms 384 KB Output is correct
20 Correct 17 ms 384 KB Output is correct
21 Correct 22 ms 256 KB Output is correct
22 Correct 24 ms 256 KB Output is correct
23 Correct 17 ms 384 KB Output is correct
24 Correct 13 ms 312 KB Output is correct
25 Correct 16 ms 384 KB Output is correct
26 Correct 23 ms 384 KB Output is correct
27 Correct 9 ms 312 KB Output is correct
28 Correct 16 ms 384 KB Output is correct
29 Correct 9 ms 312 KB Output is correct
30 Correct 20 ms 384 KB Output is correct
31 Correct 28 ms 312 KB Output is correct
32 Correct 55 ms 384 KB Output is correct
33 Correct 70 ms 376 KB Output is correct
34 Incorrect 94 ms 256 KB Wrong Answer [2]
35 Halted 0 ms 0 KB -