/*
Author : detective conan
Problem : JOI18_Xylophone
Created : 17/03/2025 13:42 UTC+7
*/
#include <bits/stdc++.h>
#define FOR(i, s, t) for(int i = s; i <= t; ++i)
#define rep(i, s, t) for(int i = s; i >= t; --i)
#define DB(n, s) cout << n << s
#define ANS(n, s) DB(n, s)
#define mod 1e9 + 7
#define HAVE_TESTCASE false
#define conan cin.tie(nullptr)->sync_with_stdio(false)
#define sum(a, b) ((a%mod) + (b%mod))%mod
#define mul(a, b) ((a%mod) * (b%mod))
#define pb push_back
#define eb emplace_back
#define em emplace
using namespace std;
using u32 = unsigned;
using i64 = int64_t;
using u64 = unsigned i64;
using namespace std;
#include "xylophone.h"
int ans[5005], dif[5005], mnp = 1, mxp = 1, mn, mx;
void solve(int N) {
ans[1] = 0, ans[2] = query(1, 2), dif[2] = ans[2];
FOR(i, 3, N){
int s = query(i - 2, i);
int t = query(i - 1, i);
dif[i] = t;
if(s == dif[i]){
if(ans[i - 2] >= ans[i - 1]) ans[i] = ans[i - 1] + t;
else ans[i] = ans[i - 1] - t;
}
else if(dif[i-1] + t == s) {
if(ans[i - 2] >= ans[i - 1]) ans[i] = ans[i - 1] - t;
else ans[i] = ans[i - 1] + t;
}
else {
if(ans[i - 2] >= ans[i - 1]) ans[i] = ans[i - 1] + t;
else ans[i] = ans[i - 1] - t;
}
if(ans[i] < mn) mn = ans[i], mnp = i;
if(ans[i] > mx) mx = ans[i], mxp = i;
}
FOR(i, 1, N) ans[i] += 1 - mn;
if(mnp > mxp) {
FOR(i, 1, N) ans[i] = N - ans[i] + 1;
}
FOR(i, 1, N) answer(i, ans[i]);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |