답안 #1116914

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1116914 2024-11-22T14:47:06 Z Sofiatpc Xylophone (JOI18_xylophone) C++17
47 / 100
175 ms 592 KB
#include <bits/stdc++.h>
#include "xylophone.h"

using namespace std;

int v[5005];

int calc(int a, int b, int x, int y){
	if(abs(a-b) != y && x != y){
		if(a > b)return b-x;
		return b+x;
	}else{
		if(a > b)return b+x;
		return b-x;
	}
}

void solve(int n) {
	int l = 1, r = n;
	while(l!= r){
		int mid = (l+r+1)/2;
		if(query(mid,n) == n-1)l = mid;
		else r = mid-1;
	}

	v[l] = 1;
	v[l+1] = 1+query(l,l+1);

	for(int i = l+2; i <= n; i++){
		int x = query(i-1,i);
		if(n > 4500 && x > (n-n/50)){
			if(v[i-2] > v[i-1])v[i] = v[i-1]+x;
			v[i] = v[i-1]-x;
		}else v[i] = calc(v[i-2],v[i-1], x, query(i-2,i));
	}

	if(l != 1){
		v[l-1] = 1+query(l-1,l);
		for(int i = l-2; i >= 1; i--){
			int x = query(i,i+1);
			if(n > 4500 && x > (n-n/50)){
				if(v[i+2] > v[i+1])v[i] = v[i+1]+x;
				v[i] = v[i+1]-x;
			}else v[i] = calc(v[i+2], v[i+1], query(i,i+1), query(i,i+2));
		}
	}

	for(int i = 1; i <= n; i++)
		answer(i,v[i]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 2 ms 336 KB Output is correct
4 Correct 4 ms 336 KB Output is correct
5 Correct 6 ms 336 KB Output is correct
6 Correct 4 ms 336 KB Output is correct
7 Correct 5 ms 336 KB Output is correct
8 Correct 5 ms 336 KB Output is correct
9 Correct 5 ms 336 KB Output is correct
10 Correct 3 ms 336 KB Output is correct
11 Correct 4 ms 336 KB Output is correct
12 Correct 4 ms 336 KB Output is correct
13 Correct 4 ms 336 KB Output is correct
14 Correct 3 ms 336 KB Output is correct
15 Correct 4 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 2 ms 336 KB Output is correct
4 Correct 4 ms 336 KB Output is correct
5 Correct 6 ms 336 KB Output is correct
6 Correct 4 ms 336 KB Output is correct
7 Correct 5 ms 336 KB Output is correct
8 Correct 5 ms 336 KB Output is correct
9 Correct 5 ms 336 KB Output is correct
10 Correct 3 ms 336 KB Output is correct
11 Correct 4 ms 336 KB Output is correct
12 Correct 4 ms 336 KB Output is correct
13 Correct 4 ms 336 KB Output is correct
14 Correct 3 ms 336 KB Output is correct
15 Correct 4 ms 336 KB Output is correct
16 Correct 7 ms 336 KB Output is correct
17 Correct 17 ms 336 KB Output is correct
18 Correct 25 ms 432 KB Output is correct
19 Correct 29 ms 336 KB Output is correct
20 Correct 35 ms 440 KB Output is correct
21 Correct 39 ms 592 KB Output is correct
22 Correct 39 ms 592 KB Output is correct
23 Correct 28 ms 504 KB Output is correct
24 Correct 45 ms 336 KB Output is correct
25 Correct 28 ms 336 KB Output is correct
26 Correct 36 ms 448 KB Output is correct
27 Correct 45 ms 336 KB Output is correct
28 Correct 25 ms 336 KB Output is correct
29 Correct 30 ms 336 KB Output is correct
30 Correct 34 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 2 ms 336 KB Output is correct
4 Correct 4 ms 336 KB Output is correct
5 Correct 6 ms 336 KB Output is correct
6 Correct 4 ms 336 KB Output is correct
7 Correct 5 ms 336 KB Output is correct
8 Correct 5 ms 336 KB Output is correct
9 Correct 5 ms 336 KB Output is correct
10 Correct 3 ms 336 KB Output is correct
11 Correct 4 ms 336 KB Output is correct
12 Correct 4 ms 336 KB Output is correct
13 Correct 4 ms 336 KB Output is correct
14 Correct 3 ms 336 KB Output is correct
15 Correct 4 ms 336 KB Output is correct
16 Correct 7 ms 336 KB Output is correct
17 Correct 17 ms 336 KB Output is correct
18 Correct 25 ms 432 KB Output is correct
19 Correct 29 ms 336 KB Output is correct
20 Correct 35 ms 440 KB Output is correct
21 Correct 39 ms 592 KB Output is correct
22 Correct 39 ms 592 KB Output is correct
23 Correct 28 ms 504 KB Output is correct
24 Correct 45 ms 336 KB Output is correct
25 Correct 28 ms 336 KB Output is correct
26 Correct 36 ms 448 KB Output is correct
27 Correct 45 ms 336 KB Output is correct
28 Correct 25 ms 336 KB Output is correct
29 Correct 30 ms 336 KB Output is correct
30 Correct 34 ms 336 KB Output is correct
31 Correct 94 ms 436 KB Output is correct
32 Correct 120 ms 440 KB Output is correct
33 Incorrect 175 ms 444 KB Wrong Answer [2]
34 Halted 0 ms 0 KB -