Submission #1018608

#TimeUsernameProblemLanguageResultExecution timeMemory
1018608dostsSecret (JOI14_secret)C++17
0 / 100
322 ms4520 KiB
#include "secret.h" #include <bits/stdc++.h> //Dost SEFEROĞLU using namespace std; #define int long long #define pii pair<int,int> #define ff first #define ss second #define sp << " " << #define vi vector<int> #define all(xx) xx.begin(),xx.end() #define ps(xxx) cout << (xxx) << endl; int dat[10][1001]; int mask[1001]; int B[1001]; void dnc(int l,int r,int level = 0) { if (l == r) return; int m = (l+r) >> 1; dat[level][m] = B[m]; for (int i=m-1;i>=l;i--) dat[level][i] = Secret(B[i],dat[level][i+1]); dat[level][m+1] = B[m+1]; for (int i=m+2;i<=r;i++) dat[level][i] = Secret(dat[level][i-1],B[i]); for (int i=m+1;i<=r;i++) mask[i]^=(1<<level); dnc(l,m,level+1),dnc(m+1,r,level+1); } void Init(int32_t N, int32_t A[]) { for (int i=0;i<N;i++) B[i+1] = A[i]; dnc(1,N); } int32_t Query(int32_t L, int32_t R) { if (L == R) return B[L]; int tz = __builtin_ctz(mask[L]^mask[R]); return Secret(dat[tz][L],dat[tz][R]); }
#Verdict Execution timeMemoryGrader output
Fetching results...