#pragma GCC optimize("O3,unroll-loops")
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define FOR(i,a) for(int i=0;i<(a);i++)
#define FORE(i,a,b) for(int i=(a);i<(b);i++)
#define cont(x) {for(auto el:x) cout<<el<<' ';cout<<endl;}
#define contp(x) {for(auto el:x) cout<<el.fi<<'-'<<el.se<<' ';cout<<endl;}
#define sp <<" "<<
//#define mid (l+r)/2
#define endl '\n'
#define DEBUG(X) {cout<<#X<<' '<<(X)<<endl;}
#define carp(x,y) ((x%MOD)*(y%MOD))%MOD
#define topla(x,y) ((x%MOD)+(y%MOD))%MOD
typedef vector<int> vi;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<bool> vb;
const int MAXN=1e3+5;
vi a;
int n;
int tut[MAXN][MAXN];
void dq(int l,int r){
int mid=(l+r)/2;
tut[mid][mid]=a[mid];
tut[mid+1][mid+1]=a[mid+1];
for(int i=mid-1;i>=l;i--){
tut[mid][i]=Secret(tut[mid][i+1],a[i]);
}
for(int i=mid+2;i<=r;i++){
tut[mid+1][i]=Secret(tut[mid+1][i-1],a[i]);
}
if(l<mid) dq(l,mid);
if(mid+1<r) dq(mid+1,r);
}
void Init(int N, int A[]) {
n=N;
a.resize(N+1);
FOR(i,N) a[i+1]=A[i];
dq(1,N);
}
int Query(int l, int r) {
int bas=1;
int son=n;
l++;r++;
while(bas!=son){
int mid=(bas+son)/2;
if(l<=mid and mid<r) return Secret(tut[mid][l],tut[mid+1][r]);
else if(mid==r) return tut[mid][l];
else if(mid<l) bas=mid+1;
else son=mid;
}
return tut[l][l];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
80 ms |
4436 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015. |
2 |
Incorrect |
82 ms |
4572 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560. |
3 |
Incorrect |
84 ms |
4392 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500. |
4 |
Incorrect |
318 ms |
8272 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568. |
5 |
Incorrect |
308 ms |
8356 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316. |
6 |
Incorrect |
309 ms |
8276 KB |
Wrong Answer: Query(200, 208) - expected : 277813445, actual : 154975445. |
7 |
Incorrect |
306 ms |
8276 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873. |
8 |
Incorrect |
303 ms |
8260 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792. |
9 |
Incorrect |
308 ms |
8272 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577. |
10 |
Incorrect |
309 ms |
8276 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787. |