답안 #487171

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
487171 2021-11-14T18:48:45 Z Victor 비밀 (JOI14_secret) C++17
0 / 100
422 ms 4452 KB
#include "secret.h"

#include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define per(i, a, b) for (int i = (b - 1); i >= (a); --i)
#define trav(a, x) for (auto &a : x)

#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define pb push_back
#define debug(x) cout << #x << " = " << x << endl

#define umap unordered_map
#define uset unordered_set

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;

const int INF = 1'000'000'007;

int precomp[11][1001], nums[1001];
int n;

void dnc(int lo, int hi, int level) {
    if (lo >= hi) return;

    int mid = (lo + hi) / 2;
    assert(precomp[level][mid]==-1);
    precomp[level][mid] = nums[mid];
    per(i, lo, mid) assert(precomp[level][i]==-1), precomp[level][i] = Secret(nums[i], precomp[level][i + 1]);

    assert(precomp[level][mid+1]==-1);
    precomp[level][mid + 1] = nums[mid + 1];
    rep(i, mid + 2, hi + 1) assert(precomp[level][i]==-1), precomp[level][i] = Secret(nums[i], precomp[level][i - 1]);

    dnc(lo, mid, level - 1);
    dnc(mid + 1, hi, level - 1);
}

void Init(int N, int A[]) {
    memset(precomp,-1,sizeof(precomp));
    rep(i, 0, N) nums[i] = A[i];
    dnc(0, N - 1, 10);
    n = N;
}

int Query(int L, int R) {
    if (L == R) return nums[L];

    int lo = 0, hi = n - 1, level = 10;
    while (1) {
        int mid = (lo + hi) / 2;
        if (L <= mid && mid < R) return Secret(precomp[level][L], precomp[level][R]);
        if (R <= mid)
            hi = mid;
        else
            lo = mid + 1;
        --level;
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 117 ms 2312 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 809782271.
2 Incorrect 111 ms 2372 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 68749376.
3 Incorrect 112 ms 2308 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 136349820.
4 Incorrect 418 ms 4416 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 650789536.
5 Incorrect 412 ms 4252 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 377506838.
6 Incorrect 422 ms 4288 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 61461050.
7 Incorrect 419 ms 4328 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 687550570.
8 Incorrect 417 ms 4300 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 145923264.
9 Incorrect 419 ms 4452 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 18757135.
10 Incorrect 418 ms 4292 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 70590726.