# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1100472 |
2024-10-14T03:43:35 Z |
anhphant |
Secret (JOI14_secret) |
C++14 |
|
312 ms |
4936 KB |
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
typedef long long ll;
int N, A[1000007], Q;
ll dat[17][1007], mask[1007];
vector<ll> v;
// int Secret(int a, int b) {
// return a + b;
// }
void divi(ll l, ll r, ll lev, int A[]) {
if (l == r) return;
ll mid = (l + r) / 2;
dat[lev][mid] = A[mid];
for(int i = mid - 1; i >= l; --i) {
dat[lev][i] = Secret(A[i], dat[lev][i + 1]);
}
dat[lev][mid + 1] = A[mid + 1];
for(int i = mid + 2; i <= r; ++i) {
dat[lev][i] = Secret(dat[lev][i - 1], A[i]);
}
for(int i = mid + 1; i <= r; ++i) mask[i] ^= (1 << lev);
divi(l, mid, lev + 1, A);
divi(mid + 1, r, lev + 1, A);
}
void Init(int N, int a[]) {
for(int i = 1; i <= N; ++i) A[i] = a[i - 1];
divi(1, N, 0, A);
for(int i = 1; i <= N; ++i) v.push_back(A[i]);
}
int Query(int l, int r) {
l++;
r++;
if (l == r) return v[l - 1];
int bits = __builtin_ctz(mask[l] ^ mask[r]);
return Secret(dat[bits][l], dat[bits][r]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
82 ms |
4688 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
89 ms |
4712 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
84 ms |
4688 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
312 ms |
4688 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
308 ms |
4688 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
301 ms |
4688 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
297 ms |
4680 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 |
4712 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
299 ms |
4612 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
308 ms |
4936 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |