#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 nr){
int sr=(pocz+kon)/2;
if(pocz>=l && kon<=r && sr>=l && sr<=r) return nr;
if(sr<l) return znajdz(sr+1, kon, l, r, nr+1);
else return znajdz(pocz, sr, l, r, nr+1);
}
int Query(int l, int r){
if(l==r) return t[l];
ll x=znajdz(0, n-1, l, r, 1);
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 time |
Memory |
Grader output |
1 |
Incorrect |
117 ms |
2428 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 175308899. |
2 |
Incorrect |
120 ms |
2428 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 306437344. |
3 |
Incorrect |
117 ms |
2380 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 814958049. |
4 |
Incorrect |
430 ms |
4428 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 113654935. |
5 |
Incorrect |
456 ms |
4444 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 988266326. |
6 |
Incorrect |
441 ms |
4432 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 302011346. |
7 |
Incorrect |
457 ms |
4376 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 897938834. |
8 |
Incorrect |
443 ms |
4436 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 322810476. |
9 |
Incorrect |
437 ms |
4516 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 261536590. |
10 |
Incorrect |
441 ms |
4392 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 888678686. |