답안 #958307

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
958307 2024-04-05T11:17:26 Z JwFXoiz Xylophone (JOI18_xylophone) C++14
47 / 100
58 ms 1004 KB
#include <bits/stdc++.h>
#include "xylophone.h"

using namespace std;

int a[5001];

void calc(int l, int r, int f, int up)
{
	if (r - l <= 1) return;
	if (!f)
	{
		int x = query(l + 1, r);
		int lx = l + 1, rx = r - 1;
		while (lx < rx)
		{
			int mid = (lx + rx + 1) >> 1;
			int y = query(mid, r);
			if (x == y) lx = mid;
			else rx = mid - 1;
		}
		if (up) a[lx] = a[r] + x;
		else a[lx] = a[r] - x;
		calc(l, lx, 0, up ^ 1), calc(lx, r, 0, up);
	}
	else
	{
		int x = query(l, r - 1);
		int lx = l + 1, rx = r - 1;
		while (lx < rx)
		{
			int mid = (lx + rx) >> 1;
			int y = query(l, mid);
			if (x == y) rx = mid;
			else lx = mid + 1;
		}
		if (up) a[lx] = a[l] + x;
		else a[lx] = a[l] - x;
		calc(l, lx, 1, up), calc(lx, r, 1, up ^ 1);
	}
}

void solve(int N)
{
	int l = 1, r = N;
	while (l < r)
	{
		int mid = (l + r + 1) >> 1;
		if (query(mid, N) == N - 1) l = mid;
		else r = mid - 1;
	}
	a[l] = 1;
	calc(0, l, 0, 1), calc(l, N + 1, 1, 1);
	for (int i = 1; i <= N; i++) 
	{
		answer(i, a[i]);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 3 ms 692 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 3 ms 696 KB Output is correct
10 Correct 3 ms 344 KB Output is correct
11 Correct 2 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 3 ms 692 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 3 ms 696 KB Output is correct
10 Correct 3 ms 344 KB Output is correct
11 Correct 2 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
16 Correct 3 ms 344 KB Output is correct
17 Correct 9 ms 344 KB Output is correct
18 Correct 9 ms 436 KB Output is correct
19 Correct 15 ms 500 KB Output is correct
20 Correct 19 ms 444 KB Output is correct
21 Correct 13 ms 444 KB Output is correct
22 Correct 14 ms 436 KB Output is correct
23 Correct 45 ms 740 KB Output is correct
24 Correct 50 ms 1004 KB Output is correct
25 Correct 48 ms 412 KB Output is correct
26 Correct 17 ms 436 KB Output is correct
27 Correct 13 ms 444 KB Output is correct
28 Correct 10 ms 444 KB Output is correct
29 Correct 13 ms 692 KB Output is correct
30 Correct 11 ms 440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 3 ms 692 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 3 ms 696 KB Output is correct
10 Correct 3 ms 344 KB Output is correct
11 Correct 2 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
16 Correct 3 ms 344 KB Output is correct
17 Correct 9 ms 344 KB Output is correct
18 Correct 9 ms 436 KB Output is correct
19 Correct 15 ms 500 KB Output is correct
20 Correct 19 ms 444 KB Output is correct
21 Correct 13 ms 444 KB Output is correct
22 Correct 14 ms 436 KB Output is correct
23 Correct 45 ms 740 KB Output is correct
24 Correct 50 ms 1004 KB Output is correct
25 Correct 48 ms 412 KB Output is correct
26 Correct 17 ms 436 KB Output is correct
27 Correct 13 ms 444 KB Output is correct
28 Correct 10 ms 444 KB Output is correct
29 Correct 13 ms 692 KB Output is correct
30 Correct 11 ms 440 KB Output is correct
31 Correct 27 ms 444 KB Output is correct
32 Correct 36 ms 436 KB Output is correct
33 Incorrect 58 ms 688 KB Wrong Answer [2]
34 Halted 0 ms 0 KB -