# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
368118 |
2021-02-19T15:22:35 Z |
Sorting |
Secret (JOI14_secret) |
C++17 |
|
512 ms |
4588 KB |
#include "secret.h"
#include <bits/stdc++.h>
const int N = 1000;
const int LOGN = 10;
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 <= n; ++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 |
142 ms |
2540 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
154 ms |
2668 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
142 ms |
2540 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
504 ms |
4588 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Incorrect |
503 ms |
4588 KB |
Wrong Answer: Query(0, 508) - expected : 315104342, actual : 852237430. |
6 |
Correct |
512 ms |
4588 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Incorrect |
511 ms |
4460 KB |
Wrong Answer: Query(0, 993) - expected : 589312106, actual : 649633826. |
8 |
Correct |
506 ms |
4388 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Incorrect |
510 ms |
4460 KB |
Wrong Answer: Query(0, 930) - expected : 424418475, actual : 969806894. |
10 |
Incorrect |
497 ms |
4460 KB |
Wrong Answer: Query(0, 893) - expected : 611994251, actual : 3098823. |