# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1069471 |
2024-08-22T01:28:21 Z |
Boycl07 |
Secret (JOI14_secret) |
C++17 |
|
338 ms |
4604 KB |
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 1; (i) <= (n); ++i)
#define forn(i, l, r) for(int i = (l); i <= (r); ++i)
#define ford(i, r, l) for(int i = (r); i >= (l); --i)
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define FORD(i, n) for(int i = ((n) - 1); i >= 0; --i)
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define endl "\n"
#define task "FFILL"
#define sz(a) int(a.size())
#define C(x, y) make_pair(x, y)
#define all(a) (a).begin(), (a).end()
#define bit(i, mask) (mask >> i & 1)
template<typename T> bool maximize(T &res, const T &val) { if (res < val){ res = val; return true; }; return false; }
template<typename T> bool minimize(T &res, const T &val) { if (res > val){ res = val; return true; }; return false; }
const int Max_N = 1e3 + 1;
const int LOG = 9;
int n, a[Max_N];
int st[Max_N][LOG + 1], pos[Max_N];
void dnc(int l, int r, int stage)
{
if(l == r) return;
int mid = l + r >> 1;
st[mid][stage] = a[mid];
st[mid + 1][stage] = a[mid + 1]; pos[mid + 1] |= (1 << stage);
ford(i, mid - 1, l) st[i][stage] = Secret(a[i], st[i + 1][stage]);
forn(i, mid + 2, r) st[i][stage] = Secret(st[i - 1][stage], a[i]), pos[i] |= (1 << stage);
dnc(l, mid, stage + 1);
dnc(mid + 1, r, stage + 1);
}
void Init(int N, int A[])
{
n = N;
FOR(i, n) a[i] = A[i];
dnc(0, n - 1, 0);
}
int Query(int l, int r)
{
if(l == r) return a[l];
int stage = __builtin_ctz(pos[l] ^ pos[r]);
return Secret(st[l][stage], st[r][stage]);
}
Compilation message
secret.cpp: In function 'void dnc(int, int, int)':
secret.cpp:37:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
37 | int mid = l + r >> 1;
| ~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
91 ms |
2652 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
85 ms |
2832 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
85 ms |
2812 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
317 ms |
4432 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
321 ms |
4432 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
310 ms |
4356 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
316 ms |
4604 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
307 ms |
4436 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
338 ms |
4432 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
310 ms |
4348 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |