Submission #776657

#TimeUsernameProblemLanguageResultExecution timeMemory
776657ymmXylophone (JOI18_xylophone)C++17
100 / 100
96 ms428 KiB
#include "xylophone.h" #include <bits/stdc++.h> #define Loop(x, l, r) for (ll x = (l); x < (r); ++x) typedef long long ll; typedef std::pair<int,int> pii; using namespace std; static int A[5000]; void solve(int N) { A[1] = query(1, 2); Loop (i,2,N) { int x = query(i, i+1); int y = query(i-1, i+1); if (max(A[i-2], A[i-1]+x) - min(A[i-2], A[i-1]) == y) A[i] = A[i-1]+x; else A[i] = A[i-1]-x; } pii mn = {1,1}; pii mx = {-1,-1}; Loop (i,0,N) { mn = min(mn, {A[i], i}); mx = max(mx, {A[i], i}); } Loop (i,0,N) A[i] -= mn.first; if (mn.second > mx.second) { Loop (i,0,N) A[i] = N-1-A[i]; } //Loop (i,0,N) // cerr << A[i]+1 << ' '; //cerr << '\n'; Loop (i,0,N) answer(i+1, A[i]+1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...