Submission #160581

#TimeUsernameProblemLanguageResultExecution timeMemory
160581iefnah06Xylophone (JOI18_xylophone)C++11
0 / 100
2 ms504 KiB
#include "xylophone.h" #include<bits/stdc++.h> using namespace std; void solve(int N) { vector<int> A(N); vector<int> two; vector<int> three; for (int i = 0; i+1 < N; i++) { two.push_back(query(i+1, i+2)); } for (int i = 0; i+2 < N; i++) { three.push_back(query(i+1, i+3)); } A[0] = 0; A[1] = A[0] + two[0]; for (int i = 0; i+2 < N; i++) { if (three[i] == two[i]) { A[i+2] = (A[i] < A[i+1] ? A[i+1] - three[i] : A[i+1] + three[i]); } else { assert(three[i] > two[i]); if (bool(A[i] < A[i+1]) == bool(two[i] + two[i+1] == three[i])) { A[i+2] = A[i+1] + two[i+1]; } else { A[i+2] = A[i+1] - two[i+1]; } } } int mi = *min_element(A.begin(), A.end()); for (int i = 0; i < N; i++) { A[i] -= mi; } assert(set<int>(A.begin(), A.end()).size() == size_t(N) && *max_element(A.begin(), A.end()) == N-1); if (int(find(A.begin(), A.end(), 0) - A.begin()) > int(find(A.begin(), A.end(), N-1) - A.begin())) { for (int i = 0; i < N; i++) { A[i] = N - 1 - A[i]; } } for (int i = 0; i < N; i++) { answer(i+1, A[i]+1); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...