Submission #1290624

#TimeUsernameProblemLanguageResultExecution timeMemory
1290624mhaerXylophone (JOI18_xylophone)C++20
0 / 100
1 ms332 KiB
#include "xylophone.h" #include <bits/stdc++.h> #define ll long long using namespace std; static int A[5000]; set<int> found; void solve(int N) { vector<int> fark1(N); vector<int> fark2(N-1); for (int i = 1;i <= N-1;i++) { fark1[i] = query(i, i+1); } for (int i = 1;i <= N-2;i++) { fark2[i] = query(i, i+2); } vector<bool> direction(N); for (int i = 1;i <= N-2;i++) { direction[i+1] = direction[i]; if (fark2[i] != (fark1[i] + fark1[i+1])) { direction[i+1] = !direction[i+1]; } } vector<int> pref(N); // for (bool i : direction) { // cout << i << " "; // } // cout << "\n"; pref[0] = 1; for (int i = 1;i < N;i++) { pref[i] = pref[i-1] + fark1[i] * (direction[i] == false ? 1 : -1); } int min_ = 0; int max_ = 0; for (int i = 0;i < N;i++) { if (pref[i] > pref[max_]) { max_ = i; } if (pref[i] < pref[min_]) { min_ = i; } } if (min_ > max_) { for (int& i : pref) i = N-i; } for (int i = 0;i < N;i++) { answer(i+1, pref[i]); } // for (int i : pref) cout << i << " "; // cout << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...