Submission #542660

#TimeUsernameProblemLanguageResultExecution timeMemory
542660__VariattoSecret (JOI14_secret)C++17
0 / 100
467 ms4316 KiB
#include <bits/stdc++.h> #include "secret.h" using namespace std; #define pb push_back #define fi first #define se second #define ll long long const int MAX=1e3+10, L=10; int n, daq[MAX][L+2], q, a, b, t[MAX], pot; /*int Secret(int a, int b){ return a*b; } */int Query(int l, int r){ if(l==r) return t[l]; int x=32-__builtin_clz(l^r); return Secret(daq[l][x], daq[r][x]); } void rek(int pocz, int kon, int nr){ if(pocz==kon){ daq[pocz][nr]=t[pocz]; return; } int sr=(pocz+kon)/2; daq[sr][nr]=t[sr]; for(int i=sr-1; i>=pocz; i--) daq[i][nr]=Secret(t[i], daq[i+1][nr]); if(sr+1<=kon) daq[sr+1][nr]=t[sr+1]; for(int i=sr+2; i<=kon; i++) daq[i][nr]=Secret(daq[i-1][nr], t[i]); rek(pocz, sr, nr-1); rek(sr+1, kon, nr-1); } void Init(int N, int A[]){ n=N; for(int i=0; i<n; i++) t[i]=A[i]; while((1<<pot)<n) pot++; rek(0, n-1, pot); } /*int main(){ ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); int n1; cin>>n1; int A1[n1]; for(int i=0; i<n1; i++) cin>>A1[i]; Init(n1, A1); int q1; cin>>q1; while(q1--){ int a, b; cin>>a>>b; cout<<Query(a, b)<<"\n"; } } */
#Verdict Execution timeMemoryGrader output
Fetching results...