# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
40054 |
2018-01-26T05:09:23 Z |
funcsr |
Secret (JOI14_secret) |
C++14 |
|
698 ms |
7740 KB |
#include "secret.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(x) x.begin(), x.end()
#define uniq(x) x.erase(unique(all(x)), x.end())
#define index(x, y) (int)(lower_bound(all(x), y) - x.begin())
#define pb push_back
#define NIL 1145141919
#define MAX_N (1<<10)
typedef pair<int, int> P;
int seg[MAX_N*2-1];
map<P, int> mp;
int ask(int x, int y) {
if (mp.find(P(x, y)) != mp.end()) return mp[P(x, y)];
return mp[P(x, y)] = Secret(x, y);
}
int op(int x, int y) {
if (x == NIL) return y;
if (y == NIL) return x;
return ask(x, y);
}
int query(int a, int b, int k=0, int l=0, int r=MAX_N) {
if (b <= l || r <= a) return NIL;
if (a <= l && r <= b) return seg[k];
return op(query(a, b, k*2+1, l, (l+r)/2), query(a, b, k*2+2, (l+r)/2, r));
}
int N;
void Init(int NN, int A[]) {
N = NN;
fill(seg, seg+MAX_N*2-1, NIL);
rep(i, N) seg[i+MAX_N-1] = A[i];
for (int i=MAX_N-2; i>=0; i--) {
seg[i] = op(seg[i*2+1], seg[i*2+2]);
}
rep(i, N) {
rep(j, 20) {
int p = (1<<j)-1;
if (p >= N) break;
if (p >= i) query(i, p+1);
}
}
rep(i, N) {
rep(j, 20) {
int p = (1<<j);
if (p <= i) query(p, i+1);
}
}
}
int Query(int L, int R) {
int b = L;
rep(j, 20) {
int p = (1<<j)-1;
if (p >= R) break;
if (p >= L) b = p;
}
return op(query(L, b+1), query(b+1, R+1));
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
205 ms |
7212 KB |
Output is partially correct - number of calls to Secret by Init = 6113, maximum number of calls to Secret by Query = 7 |
2 |
Partially correct |
220 ms |
7212 KB |
Output is partially correct - number of calls to Secret by Init = 7145, maximum number of calls to Secret by Query = 2 |
3 |
Partially correct |
213 ms |
7212 KB |
Output is partially correct - number of calls to Secret by Init = 7155, maximum number of calls to Secret by Query = 2 |
4 |
Incorrect |
669 ms |
7740 KB |
Output isn't correct - number of calls to Secret by Init = 13662, maximum number of calls to Secret by Query = 9 |
5 |
Incorrect |
669 ms |
7740 KB |
Output isn't correct - number of calls to Secret by Init = 13678, maximum number of calls to Secret by Query = 8 |
6 |
Incorrect |
661 ms |
7608 KB |
Output isn't correct - number of calls to Secret by Init = 13678, maximum number of calls to Secret by Query = 4 |
7 |
Incorrect |
667 ms |
7476 KB |
Output isn't correct - number of calls to Secret by Init = 13678, maximum number of calls to Secret by Query = 1 |
8 |
Incorrect |
677 ms |
7476 KB |
Output isn't correct - number of calls to Secret by Init = 13678, maximum number of calls to Secret by Query = 1 |
9 |
Incorrect |
698 ms |
7476 KB |
Output isn't correct - number of calls to Secret by Init = 13678, maximum number of calls to Secret by Query = 1 |
10 |
Incorrect |
671 ms |
7476 KB |
Output isn't correct - number of calls to Secret by Init = 13678, maximum number of calls to Secret by Query = 1 |