#include <bits/stdc++.h>
#include <secret.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back //emplace_back
#define pp pop_back
#define pii pair<ll, ll> //pair<int, int>
#define all(x) (x).begin(),(x).end()
#define mp(a,b) make_pair(a , b)
#define lb lower_bound
#define ub upper_bound
#define sz(x) (ll)(x).size()
#define F first
#define S second x) (x).begin()
#define For(x, n) for(int (x) = 0 ; (x) < (n) ; (x)++)
#define debug(x) cout << #x << " : " << x << endl << flush
#define endl '\n'
#define arr(x) array<ll , (x)>
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);
ll Sum(ll a , ll b , ll MOD)
{
a %= MOD;
b %= MOD;
a += b;
return a % MOD;
}
ll Mul(ll a , ll b , ll MOD)
{
a %= MOD;
b %= MOD;
a *= b;
return a % MOD;
}
ll Pow(ll a , ll b , ll MOD)
{
ll res = 1;
while(b)
{
if((b & 1))res = Mul(res , a , MOD);
a = Mul(a , a , MOD);
b >>= 1;
}
return res;
}
ll Min(ll a , ll b)
{
if(a > b)return b;
return a;
}
ll Max(ll a , ll b)
{
if(a > b)return a;
return b;
}
ll Ceil(ll a , ll b)
{
if(b < 0)
a *= -1, b *= -1;
if(a < 0)return a/b;
return(a + (b-1))/b;
}
/////////////////////
//VALS
const ll maxn = 1024;
ll a[maxn];
ll n = 1023;
ll ans[maxn][maxn];
/////////////////////
//FUNS
void f(ll L = 0, ll R = 1023)
{
int mid = (L + R) / 2;
ans[mid][mid] = a[mid];
ans[mid + 1][mid + 1] = a[mid + 1];
for (int i = mid + 2; i <= R; i++)
ans[mid + 1][i] = Secret(ans[mid + 1][i - 1], a[i]);
for (int i = mid - 1; i >= L; i--)
ans[mid][i] = Secret(ans[mid][i + 1], a[i]);
if (L < mid) f(L, mid);
if (mid + 1 < R) f(mid + 1, R);
}
void Init(int N, int A[])
{
For(i,N)a[i] = A[i];
f();
}
int Query(int L, int R)
{
int a = 0, b = 1023;
while (b - a >= 0)
{
int mid = (a + b) >> 1;
if (mid >= L && mid < R)
return Secret(ans[mid][L], ans[mid + 1][R]);
if(mid == R) return ans[mid][L];
if (mid < L) a = mid + 1;
else b = mid;
}
return ans[a][b];
}
/////////////////////
/*
ZZZZZZZ A M M IIIIIII N N
Z A A M M M M I NN N
Z A A M M M M I N N N
Z AAAAAAA M M M I N N N
Z A A M M I N N N
Z A A M M I N NN
ZZZZZZZ A A M M IIIIIII N N TREE
*/
Compilation message
secret.cpp: In function 'void Init(int, int*)':
secret.cpp:18:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
18 | #define For(x, n) for(int (x) = 0 ; (x) < (n) ; (x)++)
| ^
secret.cpp:102:2: note: in expansion of macro 'For'
102 | For(i,N)a[i] = A[i];
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
103 ms |
11600 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015. |
2 |
Incorrect |
108 ms |
11596 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560. |
3 |
Incorrect |
104 ms |
11608 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 162768982. |
4 |
Incorrect |
388 ms |
11620 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 546373765. |
5 |
Incorrect |
381 ms |
11608 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 707448136. |
6 |
Incorrect |
378 ms |
11620 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 302576192. |
7 |
Incorrect |
374 ms |
11608 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 54559803. |
8 |
Incorrect |
378 ms |
11604 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 822146056. |
9 |
Incorrect |
381 ms |
11600 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 408296780. |
10 |
Incorrect |
377 ms |
11532 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 67347979. |