Submission #1018605

#TimeUsernameProblemLanguageResultExecution timeMemory
1018605dostsSecret (JOI14_secret)C++17
0 / 100
320 ms4548 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) { dat[level][l] = B[l]; return; } int m = (l+r) >> 1; for (int i=m+1;i<=r;i++) mask[i]^=(1<<level); 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]); 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] = 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...