답안 #751927

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
751927 2023-06-01T20:15:11 Z Desh03 비밀 (JOI14_secret) C++17
0 / 100
421 ms 12192 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;
    v[m][m] = a[m];
    if (m < r) v[m + 1][m + 1] = a[m + 1];
    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(a[i], v[m + 1][i - 1]);
    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 111 ms 4448 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 809782271.
2 Incorrect 110 ms 4428 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 68749376.
3 Incorrect 112 ms 4432 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 136349820.
4 Incorrect 415 ms 12108 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 650789536.
5 Incorrect 406 ms 12168 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 377506838.
6 Incorrect 411 ms 12192 KB Wrong Answer: Query(200, 208) - expected : 277813445, actual : 415063604.
7 Incorrect 421 ms 12104 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 687550570.
8 Incorrect 418 ms 12116 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 145923264.
9 Incorrect 419 ms 12108 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 18757135.
10 Incorrect 415 ms 12172 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 70590726.