Submission #1255119

#TimeUsernameProblemLanguageResultExecution timeMemory
1255119aegXylophone (JOI18_xylophone)C++20
100 / 100
26 ms472 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; void solve(int N) { vector<int> a(N - 1); vector<int> b(N - 2); for (int i = 0; i < N - 1; i++) { a[i] = query(i + 1, i + 2); } for (int i = 0; i < N - 2; i++) { b[i] = query(i + 1, i + 3); } vector<int> ans(N); ans[0] = 0; ans[1] = a[0]; for (int i = 2; i < N; i++) { bool inc = ans[i - 1] > ans[i - 2]; bool notsame = (b[i - 2] != (a[i - 2] + a[i - 1])); bool continc = (notsame xor inc); if(continc) ans[i] = ans[i - 1] + a[i - 1]; else ans[i] = ans[i - 1] - a[i - 1]; } int minpos = min_element(ans.begin(), ans.end()) - ans.begin(); int maxpos = max_element(ans.begin(), ans.end()) - ans.begin(); if (minpos > maxpos) { for(int i = 0; i < N; i ++) ans[i] *= -1; swap(minpos, maxpos); } for (int i = 1; i <= N; i++) { answer(i, ans[i - 1] + (-1 * ans[minpos]) + 1); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...