Submission #542675

#TimeUsernameProblemLanguageResultExecution timeMemory
542675__VariattoSecret (JOI14_secret)C++17
0 / 100
517 ms4516 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 ll MAX=1e3+10, L=10; ll n, daq[MAX][L+2], q, a, b, t[MAX], pot, skad[MAX][L+2]; /*ll Secret(ll a, ll b){ return a*b; } */int znajdz(int pocz, int kon, int l, int r){ int sr=(pocz+kon)/2; if(pocz>=l && kon<=r && sr>=l && sr<=r) return sr; if(sr<l) return znajdz(sr+1, kon, l, r); else return znajdz(pocz, sr, l, r); } int Query(int l, int r){ if(l==r) return t[l]; ll x=znajdz(0, n-1, l, r); if(r==skad[r][x]) return daq[l][x]; //cout<<x<<" "<<skad[r][x]<<" "<<skad[l][x]<<"\n"; 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; } ll sr=(pocz+kon)/2; daq[sr][nr]=t[sr], skad[sr][nr]=sr; //cout<<sr<<" "<<nr<<"\n"; if(sr+1<=kon) daq[sr+1][nr]=t[sr+1], skad[sr+1][nr]=sr; for(ll i=sr-1; i>=pocz; i--) daq[i][nr]=Secret(t[i], daq[i+1][nr]), skad[i][nr]=sr; for(ll i=sr+2; i<=kon; i++) daq[i][nr]=Secret(daq[i-1][nr], t[i]), skad[i][nr]=sr; rek(pocz, sr, nr+1); rek(sr+1, kon, nr+1); } void Init(int N, int A[]){ n=N; for(ll i=0; i<n; i++) t[i]=A[i]; rek(0, n-1, 1); } /*int main(){ //ios_base::sync_with_stdio(false); //cin.tie(0), cout.tie(0); int n1; cin>>n1; int A1[n1]; for(ll i=0; i<n1; i++) cin>>A1[i]; Init(n1, A1); ll q1; cin>>q1; while(q1--){ ll a, b; cin>>a>>b; cout<<Query(a, b)<<"\n"; } }*/
#Verdict Execution timeMemoryGrader output
Fetching results...