# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
934975 |
2024-02-28T09:41:32 Z |
vjudge1 |
Secret (JOI14_secret) |
C++17 |
|
401 ms |
11920 KB |
#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;
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[])
{
n = N;
For(i,N)a[i] = A[i];
f();
}
int Query(int L, int R)
{
int a = 0, b = n - 1;
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:103:2: note: in expansion of macro 'For'
103 | For(i,N)a[i] = A[i];
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
111 ms |
11600 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015. |
2 |
Incorrect |
106 ms |
11640 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560. |
3 |
Incorrect |
104 ms |
11604 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 536870912. |
4 |
Incorrect |
382 ms |
11700 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 536870912. |
5 |
Incorrect |
374 ms |
11696 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 536870912. |
6 |
Incorrect |
380 ms |
11696 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 942318537. |
7 |
Incorrect |
377 ms |
11860 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 0. |
8 |
Incorrect |
401 ms |
11596 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 536870912. |
9 |
Incorrect |
389 ms |
11920 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 0. |
10 |
Incorrect |
376 ms |
11688 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 0. |