Submission #988449

#TimeUsernameProblemLanguageResultExecution timeMemory
988449Zbyszek99Xylophone (JOI18_xylophone)C++17
100 / 100
84 ms1184 KiB
#include <bits/stdc++.h> #include "xylophone.h" #define ll long long #define ld long double #define ff first #define ss second #define pii pair<int,int> #define pll pair<long long, long long> #define pb push_back #define rep(i, b) for(int i = 0; i < (b); ++i) #define rep2(i,a,b) for(int i = a; i <= (b); ++i) #define rep3(i,a,b,c) for(int i = a; i <= (b); i+=c) #define count_bits(x) __builtin_popcountll((x)) #define all(x) (x).begin(),(x).end() #define size(x) (int)(x).size() #define forall(it,x) for(auto& it:(x)) using namespace std; //mt19937 mt;void random(){mt.seed(chrono::time_point_cast<chrono::milliseconds>(chrono::high_resolution_clock::now()).time_since_epoch().count());} //ll rand(ll a, ll b) {return a + (mt() % (b-a+1));} const int INF = 1e9+50; const ll INF_L = 1e18+40; const ll MOD = 1e9+7; int ans[5001]; void solve(int n) { ans[1] = 0; ans[2] = query(1,2); int pop = ans[2]; rep2(i,3,n) { int k1 = query(i-1,i); int k2 = query(i-2,i); if(pop + k1 == k2) { if(ans[i-2] < ans[i-1]) { ans[i] = ans[i-1] + k1; } else { ans[i] = ans[i-1] - k1; } } else { if(ans[i-2] < ans[i-1]) { ans[i] = ans[i-1] - k1; } else { ans[i] = ans[i-1] + k1; } } pop = k1; } pii mini = {1e9,0}; pii maks = {-1e9,0}; rep2(i,1,n) { mini = min(mini,{ans[i],i}); maks = max(maks,{ans[i],i}); // cout << ans[i] << " ans\n"; } if(mini.ss > maks.ss) { rep2(i,1,n) ans[i] *= -1; maks.ff *= -1; mini.ff *= -1; swap(mini,maks); } int od = 1-mini.ff; // cout << od << " " << maks.ss << " " << mini.ss << " " << mini.ff << " mini\n"; rep2(i,1,n) ans[i] += od; rep2(i,1,n) answer(i,ans[i]); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...