Submission #213556

#TimeUsernameProblemLanguageResultExecution timeMemory
213556erd1Xylophone (JOI18_xylophone)C++14
100 / 100
121 ms1144 KiB
#include "xylophone.h" #include<bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() #define ff first #define ss second #define pb push_back static int A[5000]; map<pair<int, int>, int> qs; int ask(int l, int r){ l++; r++; if(qs[{l, r}])return qs[{l, r}]; return qs[{l, r}] = query(l, r); } vector<int> ans; void solve(int N) { int ldir = 1; ans.pb(0); ans.pb(ask(0, 1)); for(int i = 2; i < N; i++){ if(ask(i-2, i) != ask(i-1, i)+ask(i-2, i-1))ldir = -ldir; ans.pb(ans.back()+ask(i-1, i)*ldir); } //for(auto i: ans)cout << i << endl; int a = *min_element(ans.begin(), ans.end()); for(auto& i: ans)i-=a-1; //for(auto i: ans)cout << i << endl; if(min_element(all(ans)) > max_element(all(ans))) for(auto& i: ans)i = N+1-i; //for(auto i: ans)cout << i << endl; for(int i = 0; i < N; i++) { answer(i+1, ans[i]); } }

Compilation message (stderr)

xylophone.cpp:8:12: warning: 'A' defined but not used [-Wunused-variable]
 static int A[5000];
            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...