Submission #63725

#TimeUsernameProblemLanguageResultExecution timeMemory
63725FLDutchmanXylophone (JOI18_xylophone)C++14
100 / 100
123 ms716 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; typedef int INT; #define int long long #define FOR(i, l, r) for(int i = (l); i < (r); i++) #define fst first #define snd second typedef vector<int> vi; typedef pair<int, int> ii; vi A; void solve(INT N) { A.resize(N); A[0] = 0; A[1] = query(1, 2); FOR(i, 2, N){ int a = query(i, i+1); int b = query(i-1, i+1); int p1 = A[i-1] + a, p2 = A[i-1] - a; if(abs( max(A[i-2], max(p1, A[i-1])) - min(min(A[i-2], A[i-1]), p1) ) == b) A[i] = p1; else A[i] = p2; } //for(int a : A) cout << a << " "; //cout << endl; ii mi = {1e9, -1}, ma = {-1e9, -1}; FOR(i, 0, N) mi = min(mi, {A[i], i}), ma = max(ma, {A[i], i}); //cout << mi.fst << " " << ma.fst << endl; //cout << mi.snd << " " << ma.snd << endl; if(mi.snd > ma.snd) { //cout << "Reversing " << endl; for(int &a : A) a = -a; mi.fst = -ma.fst; } //cout << 1 - mi.fst << endl; for(int &a : A) a += 1 - mi.fst; //for(int a : A) cout << a << " "; //cout << endl; FOR(i, 0, N){ //cout << A[i] << " "; answer(i+1, A[i]); } // cout << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...