답안 #751929

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
751929 2023-06-01T20:27:26 Z Desh03 비밀 (JOI14_secret) C++17
0 / 100
458 ms 12316 KB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;

vector<vector<int>> mid, v;

void dc(int l, int r, int a[]) {
    if (l > r) return;
    int m = l + r >> 1;
    for (int i = l; i <= r; i++)
        v[i][i] = a[i];
    for (int i = l; i <= m - 1; i++)
        for (int j = m + 1; j <= r; j++)
            mid[i][j] = m;
    for (int i = m - 1; i >= l; i--)
        v[i][m] = Secret(a[i], v[i + 1][m]);
    for (int i = m + 2; i <= r; i++)
        v[m + 1][i] = Secret(v[m + 1][i - 1], a[i]);
    dc(l, m - 1, a);
    dc(m + 1, r, a);
}

void Init(int n, int a[]) {
    mid = v = vector<vector<int>> (n, vector<int> (n, -1));
    dc(0, n - 1, a);
}

int Query(int l, int r) {
    if (v[l][r] != -1) return v[l][r];
    int m = mid[l][r];
    return Secret(v[l][m], v[m + 1][r]);
}

Compilation message

secret.cpp: In function 'void dc(int, int, int*)':
secret.cpp:9:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    9 |     int m = l + r >> 1;
      |             ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 114 ms 4464 KB Wrong Answer [1]
2 Incorrect 113 ms 4380 KB Wrong Answer [1]
3 Incorrect 124 ms 4464 KB Wrong Answer [1]
4 Incorrect 454 ms 12272 KB Wrong Answer [1]
5 Incorrect 423 ms 12088 KB Wrong Answer [1]
6 Incorrect 446 ms 12136 KB Wrong Answer [1]
7 Correct 452 ms 12288 KB Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1
8 Correct 438 ms 12316 KB Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1
9 Correct 453 ms 12172 KB Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1
10 Correct 458 ms 12076 KB Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1