답안 #150989

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
150989 2019-09-01T14:01:09 Z osaaateiasavtnl 비밀 (JOI14_secret) C++14
100 / 100
604 ms 8500 KB
#include<bits/stdc++.h>
#include "secret.h"
using namespace std;
const int N = 1000;
int mem[N][N], memn;
void prec(int l, int r) {
    if (l == r) return;
    int m = (l + r) >> 1;
    prec(l, m); prec(m + 1, r);
    for (int i = m - 1; i >= l; --i) mem[i][m] = Secret(mem[i][i], mem[i + 1][m]);
    for (int i = m + 2; i <= r; ++i) mem[m + 1][i] = Secret(mem[m + 1][i - 1], mem[i][i]);
}   
void Init(int n, int a[]) {
    for (int i = 0; i < n; ++i) mem[i][i] = a[i];
    prec(0, n - 1);
    memn = n;
}   
int get(int tl, int tr, int l, int r) {
    if (tl == tr) return mem[tl][tl];
    int tm = (tl + tr) >> 1;
    if (r <= tm) return get(tl, tm, l, r);
    if (tm < l) return get(tm + 1, tr, l, r);
    return Secret(mem[l][tm], mem[tm + 1][r]);
}   
int Query(int l, int r) { return get(0, memn - 1, l, r); }
# 결과 실행 시간 메모리 Grader output
1 Correct 171 ms 4472 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 175 ms 4344 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 175 ms 4344 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Correct 601 ms 8336 KB Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1
5 Correct 598 ms 8332 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
6 Correct 601 ms 8300 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
7 Correct 603 ms 8184 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 603 ms 8300 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 602 ms 8236 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 604 ms 8500 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1