Submission #1252775

#TimeUsernameProblemLanguageResultExecution timeMemory
1252775MisterReaperXylophone (JOI18_xylophone)C++20
0 / 100
0 ms416 KiB
#include "xylophone.h" #include <bits/stdc++.h> using i64 = long long; #ifdef DEBUG #include "/home/ahmetalp/Desktop/Workplace/debug.h" #else #define debug(...) void(23) #endif void solve(int N) { if (N == 2) { answer(1, 1); answer(1, 2); return; } std::vector<int> a(N - 1), b(N - 2); for (int i = 0; i < N - 1; ++i) { a[i] = query(i + 1, i + 2); if (i != N - 2) { b[i] = query(i + 1, i + 3); } } bool ord = false; std::vector<int> vals(N); vals[0] = 0; vals[1] = a[0]; for (int i = 2; i < N; ++i) { if (a[i - 2] + a[i - 1] != b[i - 2]) { ord ^= 1; } vals[i] = vals[i - 1] + (!ord ? a[i - 1] : -a[i - 1]); } int mini = std::min_element(vals.begin(), vals.end()) - vals.begin(); int maxi = std::max_element(vals.begin(), vals.end()) - vals.begin(); if (mini > maxi) { for (int i = 0; i < N; ++i) { vals[i] *= -1; } std::swap(mini, maxi); } debug(vals); debug(mini, maxi); for (int i = 0; i < N; ++i) { answer(i + 1, vals[i] - vals[mini] + 1); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...