제출 #1261832

#제출 시각아이디문제언어결과실행 시간메모리
1261832tminhXylophone (JOI18_xylophone)C++20
0 / 100
0 ms416 KiB
#include "xylophone.h"
#include "bits/stdc++.h"
using namespace std;

#define task ""
#define ll long long
#define endl '\n'
#define fi first
#define se second
#define vall(a) (a).begin(), (a).end()
#define sze(a) (int)a.size()
#define pii pair<int, int>
#define pll pair<ll, ll>


#define ep emplace_back
#define pb push_back
#define pf push_front


const ll mod = 1e9 + 7;
const int N = 5005;
const ll oo = 1e18;

int res[N], check[N];
void solve(int N) {
	int l = 1, r = N - 1, ans = 0;
	while(l <= r) {
		int mid = (l + r) >> 1;
		if (query(1, N) >= (N - 1)) {
			ans = mid;
			l = mid + 1;
		} else {
			r = mid - 1;
		}
	}
	res[ans] = 1;
	check[res[ans]] = 1;
	
	for (int i = ans + 1; i <= N; ++i) {
		int val = query(i - 1, i);
		int val_ = query(ans, i);
		
		res[i] = res[i - 1] + val * (check[val_ + 1] ? -1 : 1);
		check[res[i]] = true;
	}
	for (int i = ans - 1; i >= 1; --i) {
		int val = query(i, i + 1);
		int val_ = query(i, ans);
		
		res[i] = res[i + 1] + val * (check[val_ + 1] ? -1 : 1);
		check[res[i]] = true;
	}
	
	for(int i = 1; i <= N; i++) answer(i, res[i]);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...