Submission #704247

#TimeUsernameProblemLanguageResultExecution timeMemory
704247vjudge1Xylophone (JOI18_xylophone)C++17
100 / 100
97 ms332 KiB
#include <bits/stdc++.h> #include "xylophone.h" using namespace std; typedef long long ll; int ask(int a, int b){ int l = min(a, b) + 1, r = max(a, b) + 1; return query(l, r); } void ans(int idx, int val){ answer(idx+1, val+1); } void solve(int n){ vector<int> result(n); result[1] = ask(0, 1); int pdist = result[1]; for (int i=2; i<n; i++){ int to1 = ask(i-1, i); int to2 = ask(i-2, i); if (to1 + pdist == to2){ if (result[i-2] < result[i-1]) result[i] = result[i-1] + to1; else result[i] = result[i-1] - to1; } else{ if (result[i-2] < result[i-1]) result[i] = result[i-1] - to1; else result[i] = result[i-1] + to1; } pdist = to1; } int zrelem = min_element(result.begin(), result.end()) - result.begin(); int nelem = max_element(result.begin(), result.end()) - result.begin(); if (zrelem > nelem){ for (int i=0; i<n; i++) result[i] = -result[i]; } int offset = *min_element(result.begin(), result.end()); for (int i=0; i<n; i++){ result[i] -= offset; } for (int i=0; i<n; i++) ans(i, result[i]); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...