#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";
}
}*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
116 ms |
2480 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 844324492. |
2 |
Incorrect |
128 ms |
2492 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 838967753. |
3 |
Incorrect |
128 ms |
2452 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 569191696. |
4 |
Incorrect |
458 ms |
4424 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 382870082. |
5 |
Incorrect |
458 ms |
4360 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 488130846. |
6 |
Incorrect |
474 ms |
4480 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 59993545. |
7 |
Incorrect |
476 ms |
4516 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 0. |
8 |
Incorrect |
460 ms |
4460 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 7677179. |
9 |
Incorrect |
490 ms |
4396 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 747052385. |
10 |
Incorrect |
517 ms |
4376 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 743066864. |