#include "secret.h"
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
#define f first
#define s second
#define pii pair<int,int>
using namespace std;
map<pii, int> mp;
const int NMAX = 10001;
int a[NMAX];
int n;
void build(int l, int r){
int m = (l + r) / 2;
if(l == r){
mp[{l, r}] = a[l];
return;
}
build(l, m);
build(m + 1, r);
if(l == 0 && r == n - 1) return;
for(int i = l; i <= m; i++){
int x = mp[{i, m}];
int y = mp[{m + 1, r}];
mp[{i, r}] = Secret(x, y);
}
for(int i = r; i >= m + 1; i--){
int x = mp[{l, m}];
int y = mp[{m + 1, i}];
mp[{l, i}] = Secret(x, y);
}
}
void Init(int N, int A[]) {
n = N;
for(int i = 0; i < n; i++) a[i] = A[i];
//cout << 1;
build(0, n - 1);
}
int Query(int L, int R) {
//cout << n << "\n";
int l = 0, r = n - 1;
if(L == R){
return a[R];
}
while(true){
int m = (l + r) / 2;
if(R <= m) {
r = m;
continue;
}
if(L > m){
l = m + 1;
continue;
}
break;
}
int m = (l + r) / 2;
int x = mp[{L, m}];
int y = mp[{m + 1, R}];
return Secret(x, y);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
132 ms |
2688 KB |
Output is correct - number of calls to Secret by Init = 4087, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
127 ms |
2696 KB |
Output is correct - number of calls to Secret by Init = 4096, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
128 ms |
2636 KB |
Output is correct - number of calls to Secret by Init = 4106, maximum number of calls to Secret by Query = 1 |
4 |
Partially correct |
446 ms |
4860 KB |
Output isn't correct - number of calls to Secret by Init = 8966, maximum number of calls to Secret by Query = 1 |
5 |
Partially correct |
440 ms |
4920 KB |
Output isn't correct - number of calls to Secret by Init = 8976, maximum number of calls to Secret by Query = 1 |
6 |
Partially correct |
445 ms |
4932 KB |
Output isn't correct - number of calls to Secret by Init = 8976, maximum number of calls to Secret by Query = 1 |
7 |
Partially correct |
462 ms |
4912 KB |
Output isn't correct - number of calls to Secret by Init = 8976, maximum number of calls to Secret by Query = 1 |
8 |
Partially correct |
447 ms |
5028 KB |
Output isn't correct - number of calls to Secret by Init = 8976, maximum number of calls to Secret by Query = 1 |
9 |
Partially correct |
465 ms |
4864 KB |
Output isn't correct - number of calls to Secret by Init = 8976, maximum number of calls to Secret by Query = 1 |
10 |
Partially correct |
461 ms |
5224 KB |
Output isn't correct - number of calls to Secret by Init = 8976, maximum number of calls to Secret by Query = 1 |