#include <bits/stdc++.h>
// #include <atcoder/string>
// #include <atcoder/lazysegtree>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;
// using mint = atcoder::modint998244353;
int INF = numeric_limits<int>::max() >> 1;
ll INFL = numeric_limits<ll>::max() >> 1;
ll mod = 998244353;
map<pll, ll> mp;
vector<int> v;
int total = 0;
int Secret(int X, int Y);
void askingInit(int l, int r, int A[])
{
if (r - l <= 1)
{
return;
}
int mid = (l + r) / 2;
ll prevVal = A[mid];
for (int i = mid - 1; i >= l; i--)
{
prevVal = Secret(A[i], prevVal);
mp[{i,mid}] = prevVal;
}
prevVal = A[mid + 1];
for (int i = mid + 2; i <= r; i++)
{
prevVal = Secret(A[i], prevVal);
mp[{mid+1,i}] = prevVal;
}
askingInit(l, mid, A);
askingInit(mid + 1, r, A);
}
void Init(int N, int A[])
{
askingInit(0, N - 1, A);
v.resize(N);
for (int i = 0; i < N; i++)
{
v[i] = A[i];
}
// cout << total << endl;
}
int get(int L, int R)
{
if (L == R)
{
return v[L];
}
if (mp.find({L, R}) == mp.end())
{
return -1;
}
return mp[{L, R}];
}
int Query(int L, int R)
{
int val1, val2;
if ((val1 = get(L, R)) != -1)
{
return val1;
}
for (int i = L; i < R; i++)
{
if ((val1 = get(L, i)) != -1 && (val2 = get(i + 1, R)) != -1)
{
return Secret(val1, val2);
}
}
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
114 ms |
2584 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 554110774. |
2 |
Incorrect |
116 ms |
2636 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 68749376. |
3 |
Incorrect |
113 ms |
2688 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 136349820. |
4 |
Incorrect |
422 ms |
4824 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 650789536. |
5 |
Incorrect |
414 ms |
4812 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 377506838. |
6 |
Incorrect |
436 ms |
4684 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 61461050. |
7 |
Incorrect |
435 ms |
4832 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 687550570. |
8 |
Incorrect |
426 ms |
4712 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 145923264. |
9 |
Incorrect |
420 ms |
4784 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 18757135. |
10 |
Incorrect |
425 ms |
4688 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 70590726. |