Submission #1116496

#TimeUsernameProblemLanguageResultExecution timeMemory
1116496ThegeekKnight16Xylophone (JOI18_xylophone)C++17
100 / 100
202 ms584 KiB
#include <bits/stdc++.h> #include "xylophone.h" using namespace std; void solve(int N) { vector<int> A(N+1); A[1] = 0; A[2] = query(1, 2); for (int i = 2; i < N; i++) { int d13 = query(i-1, i+1), d23 = query(i, i+1); int d12 = abs(A[i]-A[i-1]); int sign = (A[i]-A[i-1])/d12; if (d13 == d12 + d23) A[i+1] = A[i] + sign * d23; else A[i+1] = A[i] - sign * d23; } int idMin = min_element(A.begin()+1, A.end()) - A.begin(), idMax = max_element(A.begin()+1, A.end()) - A.begin(); if (idMin > idMax) {swap(idMin, idMax); for (auto &x : A) x = -x;} int aux = A[idMin]; for (auto &x : A) x += 1-aux; for (int i = 1; i <= N; i++) answer(i, A[i]); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...