# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
99165 |
2019-03-01T10:29:40 Z |
WLZ |
비밀 (JOI14_secret) |
C++17 |
|
588 ms |
8460 KB |
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
vector< vector<int> > a;
void build(int l, int r, int A[]) {
if (r - l <= 1) {
return;
}
int mid = (l + r) / 2;
for (int i = mid - 1; i >= l; i--) {
a[i][mid] = Secret(A[i], a[i + 1][mid]);
}
for (int i = mid + 2; i <= r; i++) {
a[mid + 1][i] = Secret(a[mid + 1][i - 1], A[i]);
}
build(l, mid, A);
build(mid + 1, r, A);
}
void Init(int N, int A[]) {
a.assign(N, vector<int>(N, -1));
for (int i = 0; i < N; i++) {
a[i][i] = a[i][i] = A[i];
}
build(0, N - 1, A);
}
int Query(int L, int R) {
if (L == R) {
return a[L][R];
}
if (a[L][R] != -1) {
return a[L][R];
}
for (int mid = L; mid < R; mid++) {
if (a[L][mid] != -1 && a[mid + 1][R] != -1) {
return Secret(a[L][mid], a[mid + 1][R]);
}
}
return -1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
164 ms |
3788 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
156 ms |
3548 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
147 ms |
3576 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
516 ms |
8412 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
524 ms |
8440 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
514 ms |
8340 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
536 ms |
8332 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
547 ms |
8420 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
576 ms |
8404 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
588 ms |
8460 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |