#include "secret.h"
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define pb push_back
#define endl '\n'
#define pii pair<ll,ll >
#define F first
#define S second
#define double long double
#define all(x) (x).begin(),(x).end()
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll , null_type , less_equal<ll> ,rb_tree_tag ,tree_order_statistics_node_update >ordered_set;
const int MOD=998244353 ;
const int N=1e6+ 7;
const ll INF= 1e18+10;
struct trp{ll F,S,T;};
ll po(ll x,ll y)
{
ll ans = 1;
while(y){
if( y & 1 ) ans *=x;
y /= 2;
x *=x;
x %= MOD;
ans %= MOD;
}
return ans;
}
int n;
ll suf[N][20];
ll pref[N][20];
vector<int>v;
void get(ll l,ll r,ll lg)
{
if(l == r) return;
ll m = (l+r)/2;
suf[m][lg] = v[m];
pref[m+1][lg] = v[m+1];
ll j = 1;
for(ll i= m-1;i>=l;i--){
suf[i][lg] = Secret(suf[i+1][lg] , v[i]);
}
j = 1;
for(ll i=m+2;i<=r;i++){
pref[i][lg] = Secret(pref[i-1][lg] , v[i]);
}
get(l,m,lg+1);
get(m+1,r,lg+1);
}
void Init(int f , int *a)
{
n = f;
for(ll i=0;i<n;i++) v.pb(a[i]);
get(0,n-1,0);
}
ll get_ans(ll segl,ll segr,ll l,ll r,ll lg)
{
ll m = (segl + segr)/2;
if( m+1 == l ) return pref[r][lg];
if( m == r ) return suf[l][lg];
if(m >= l && m < r){
return Secret(suf[l][lg] , pref[r][lg]);
}
if(l > m) return get_ans(m+1,segr,l,r,lg+1);
else return get_ans(segl,m,l,r,lg+1);
}
int Query(int l, int r)
{
if(l == r) return v[l];
return get_ans(0,n-1 , l,r , 0);
}
Compilation message
secret.cpp: In function 'void get(long long int, long long int, long long int)':
secret.cpp:48:8: warning: variable 'j' set but not used [-Wunused-but-set-variable]
48 | ll j = 1;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
111 ms |
2452 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015. |
2 |
Incorrect |
125 ms |
2500 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560. |
3 |
Incorrect |
111 ms |
2544 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500. |
4 |
Incorrect |
412 ms |
4632 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568. |
5 |
Incorrect |
451 ms |
4588 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316. |
6 |
Incorrect |
428 ms |
4592 KB |
Wrong Answer: Query(200, 208) - expected : 277813445, actual : 154975445. |
7 |
Incorrect |
419 ms |
4568 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873. |
8 |
Incorrect |
434 ms |
4604 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792. |
9 |
Incorrect |
421 ms |
4536 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577. |
10 |
Incorrect |
425 ms |
4716 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787. |