답안 #958303

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
958303 2024-04-05T10:50:51 Z JwFXoiz Xylophone (JOI18_xylophone) C++14
0 / 100
1 ms 600 KB
#include <bits/stdc++.h>
#include "xylophone.h"

using namespace std;

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;
	}
	int a[N + 1];
	a[l] = 1;
	int up = 1, last = -1, p = l;
	for (int i = l + 1; i <= N; i++)
	{
		int x = query(p, i);
		if (x == last) 
		{
			p = i - 1, up ^= 1;
			x = query(p, i);
		}
		last = x;
		if (up) a[i] = a[p] + x;
		else a[i] = a[p] - x;
	}
	up = 1, last = -1, p = l;
	for (int i = l - 1; i >= 1; i--)
	{
		int x = query(i, p);
		if (x == last)
		{
			p = i + 1, up ^= 1;
			x = query(i, p);
		}
		last = x;
		if (up) a[i] = a[p] + x;
		else a[i] = a[p] - x;
	}
	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 Incorrect 1 ms 600 KB Wrong Answer [7]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 1 ms 600 KB Wrong Answer [7]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 1 ms 600 KB Wrong Answer [7]
4 Halted 0 ms 0 KB -