제출 #967335

#제출 시각아이디문제언어결과실행 시간메모리
967335PringXylophone (JOI18_xylophone)C++17
100 / 100
64 ms940 KiB
#include <bits/stdc++.h>
#include "xylophone.h"
using namespace std;

#ifdef MIKU
string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif

#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
using ll = long long;
typedef pair<int, int> pii;

namespace {
    const int MXN = 5005;
    int a[MXN];
}

void solve(int n) {
    a[1] = 0;
    a[2] = query(1, 2);
    int pre = a[2];
    FOR(i, 3, n + 1) {
        int x = query(i - 2, i), y = query(i - 1, i);
        if (pre + y == x) {
            if (a[i - 2] < a[i - 1]) a[i] = a[i - 1] + y;
            else a[i] = a[i - 1] - y;
        } else {
            if (a[i - 2] < a[i - 1]) a[i] = a[i - 1] - y;
            else a[i] = a[i - 1] + y;
        }
        pre = y;
    }
    int smlid = min_element(a + 1, a + n + 1) - a;
    int bigid = max_element(a + 1, a + n + 1) - a;
    if (smlid > bigid) {
        FOR(i, 1, n + 1) a[i] = -a[i];
    }
    int sml = *min_element(a + 1, a + n + 1);
    FOR(i, 1, n + 1) a[i] += -sml + 1;
    FOR(i, 1, n + 1) answer(i, a[i]);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...