Submission #1032187

#TimeUsernameProblemLanguageResultExecution timeMemory
1032187juicyXylophone (JOI18_xylophone)C++17
100 / 100
71 ms600 KiB
#include <bits/stdc++.h> #include "xylophone.h" using namespace std; #ifdef LOCAL #include "debug.h" #else #define debug(...) 42 #endif void solve(int N) { vector<int> A(N), qry(N); A[1] = qry[1] = query(1, 2); for (int i = 2; i < N; ++i) { qry[i] = query(i, i + 1); int a = A[i - 2], b = A[i - 1], &c = A[i]; int AB = qry[i - 1], BC = qry[i], AC = query(i - 1, i + 1); if (AB == AC) { if (a < b) { c = b - BC; } else { c = b + BC; } } else if (BC == AC) { if (a < b) { c = b - BC; } else { c = b + BC; } } else { if (a < b) { c = b + BC; } else { c = b - BC; } } } vector<int> ord(N); iota(ord.begin(), ord.end(), 0); sort(ord.begin(), ord.end(), [&](int u, int v) { return A[u] < A[v]; }); if (ord[0] > ord.back()) { reverse(ord.begin(), ord.end()); } for (int i = 0; i < N; ++i) { answer(ord[i] + 1, i + 1); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...