# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
368121 |
2021-02-19T15:24:18 Z |
Sorting |
Secret (JOI14_secret) |
C++17 |
|
514 ms |
4460 KB |
#include "secret.h"
#include <bits/stdc++.h>
const int N = 1000;
const int LOGN = 11;
int n, *a;
int d[LOGN][N], mask[N];
void dnc(int l, int r, int bit){
if(l == r) return;
int mid = (l + r) >> 1;
d[bit][mid] = a[mid];
for(int i = mid - 1; i >= l; --i)
d[bit][i] = Secret(a[i], d[bit][i + 1]);
d[bit][mid + 1] = a[mid + 1];
for(int i = mid + 2; i <= r; ++i)
d[bit][i] = Secret(d[bit][i - 1], a[i]);
for(int i = mid + 1; i <= r; ++i)
mask[i] ^= 1 << bit;
dnc(l, mid, bit + 1), dnc(mid + 1, r, bit + 1);
}
void Init(int N, int A[]){
n = N, a = A;
dnc(0, n - 1, 0);
}
int Query(int l, int r){
if(l == r) return a[r];
int bits = __builtin_ctz(mask[l] ^ mask[r]);
return Secret(d[bits][l], d[bits][r]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
140 ms |
2412 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
142 ms |
2412 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
146 ms |
2668 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
501 ms |
4332 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
502 ms |
4460 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
503 ms |
4460 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
503 ms |
4332 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
503 ms |
4460 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
514 ms |
4424 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
502 ms |
4380 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |