# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
639175 |
2022-09-08T20:02:12 Z |
phoenix |
Secret (JOI14_secret) |
C++17 |
|
449 ms |
4416 KB |
#include<bits/stdc++.h>
#include "secret.h"
using namespace std;
const int N = 1000;
const int logN = 11;
int lef[ N ][ logN ], rig[ N ][ logN ];
void build(int l, int r, int lev, int a[]) {
if(l == r) {
lef[ l ][ lev ] = a[ l ];
rig[ r ][ lev ] = a[ r ];
return;
}
int m = (l + r) / 2;
for(int i = m + 1;i <= r;i++) {
if(i == m + 1) rig[ i ][ lev ] = a[ i ];
else rig[ i ][ lev ] = Secret(rig[i - 1][ lev ], a[ i ]);
}
for(int i = m;i >= l;i--) {
if(i == m) lef[ i ][ lev ] = a[ i ];
else lef[ i ][ lev ] = Secret(a[ i ], lef[i + 1][ lev ]);
}
build(l, m, lev + 1, a);
build(m + 1, r, lev + 1, a);
}
int query(int ql, int qr, int l, int r, int lev) {
if(l == r)
return lef[ l ][ lev ];
int m = (l + r) / 2;
if(ql <= m && m < qr) {
return Secret(lef[ ql ][ lev ], rig[ qr ][ lev ]);
}
if(qr <= m)
return query(ql, qr, l, m, lev + 1);
return query(ql, qr, m + 1, r, lev + 1);
}
int n;
void Init(int nn, int a[]) {
n = nn;
build(0, n - 1, 0, a);
}
int Query(int l, int r) {
return query(l, r, 0, n - 1, 0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
121 ms |
2380 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
122 ms |
2432 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
126 ms |
2472 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
430 ms |
4304 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
428 ms |
4360 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
449 ms |
4416 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
437 ms |
4260 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
443 ms |
4260 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
435 ms |
4292 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
437 ms |
4368 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |