Submission #1013334

#TimeUsernameProblemLanguageResultExecution timeMemory
1013334AverageAmogusEnjoyerSecret (JOI14_secret)C++17
0 / 100
298 ms4588 KiB
#include <bits/stdc++.h> #include "secret.h" using namespace std; using ll = long long; template<class T> bool cmin(T &i, T j) { return i > j ? i=j,true:false; } template<class T> bool cmax(T &i, T j) { return i < j ? i=j,true:false; } mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); int rng() { return abs((int)mrand()); } // Current challenge: finish CSES problemset!! constexpr int nax = 1000, lg = 10; int cnt; int res[lg][nax]; int mask[nax]; int a[nax]; /* int Secret(int x,int y) { cnt++; return x+y; } */ void build(int l,int r,int pw) { if (l == r) { return; } int m = (l+r)/2; res[pw][m] = a[m]; for (int i=m-1;i>=l;i--) { res[pw][i] = Secret(res[pw][i+1],a[i]); } res[pw][m+1] = a[m+1]; for (int i=m+2;i<=r;i++) { res[pw][i] = Secret(res[pw][i-1],a[i]); } for (int i=m+1;i<=r;i++) { mask[i] ^= 1 << pw; } build(l,m,pw+1); build(m+1,r,pw+1); } void Init(int n,int _a[]) { for (int i=0;i<n;i++) { a[i] = _a[i]; } build(0,n-1,0); } int Query(int l,int r) { if (l == r) { return a[l]; } int bits = __builtin_ctz(mask[l] ^ mask[r]); return Secret(res[bits][l],res[bits][r]); } /* int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; int _a[n]; for (int i=0;i<n;i++) { cin >> _a[i]; } Init(n,_a); cout << cnt << endl; } */
#Verdict Execution timeMemoryGrader output
Fetching results...