Submission #312933

#TimeUsernameProblemLanguageResultExecution timeMemory
312933TemmieXylophone (JOI18_xylophone)C++17
0 / 100
1 ms384 KiB
#include "xylophone.h" #include <bits/stdc++.h> void solve(int n) { std::ios::sync_with_stdio(0); std::cin.tie(0); std::vector <int> d1, d2, ans(n); for (int i = 0; i < n - 1; i++) { d1.push_back(query(i + 1, i + 2)); d2.push_back(query(i + 1, i + 3)); } ans[0] = 0; ans[1] = d1[0]; for (int i = 2; i < n; i++) { ans[i] = ans[i - 1]; if (d1[i - 2] + d1[i - 1] == d2[i - 2]) { if(ans[i - 2] < ans[i - 1]) ans[i] += d1[i - 1]; else ans[i] -= d1[i - 1]; } else { if (ans[i - 2] < ans[i - 1]) ans[i] -= d1[i - 1]; else ans[i] += d1[i - 1]; } } int l = 1 << 30; for (int x : ans) l = std::min(l, x); for (int& x : ans) x -= l - 1; if (min_element(ans.begin(), ans.end()) > max_element(ans.begin(), ans.end())) { for (int& x : ans) x = n - x + 1; } for (int i = 0; i < n; i++) answer(i + 1, ans[i]); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...