답안 #354230

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
354230 2021-01-21T15:11:08 Z parsabahrami 비밀 (JOI14_secret) C++17
0 / 100
512 ms 4588 KB
#include "secret.h"
#include <bits/stdc++.h>
 
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
 
#define SZ(x)                       (int) x.size()
#define F                           first
#define S                           second

const int N = 1e3 + 10;
int M[N], B[9][N], A[N], n;

void divide(int l = 0, int r = n, int h = 0) {
    if (r - l < 2) {
        B[h][l] = A[l];
        return;
    }
    int mid = (l + r) >> 1;
    B[h][mid] = A[mid], B[h][mid - 1] = A[mid - 1];
    for (int i = mid - 2; i >= l; i--) B[h][i] = Secret(A[i], B[h][i + 1]);
    for (int i = mid + 1; i < r; i++) B[h][i] = Secret(B[h][i - 1], A[i]);
    for (int i = mid; i < r; i++) M[i] |= 1 << h;
    divide(l, mid, h + 1), divide(mid, r, h + 1);
}

void Init(int _n, int a[]) {
    n = _n;
    for (int i = 0; i < n; i++) A[i] = a[i];
    divide();
}

int Query(int L, int R) {
    if (L == R) return A[L];
    else {
        int c = __builtin_ctz(M[L] ^ M[R]);
        return Secret(B[c][L], B[c][R]);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 134 ms 2540 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 269690879.
2 Incorrect 131 ms 2540 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 150178859.
3 Incorrect 135 ms 2680 KB Wrong Answer: Query(111, 503) - expected : 353540466, actual : 355876922.
4 Incorrect 494 ms 4476 KB Wrong Answer: Query(193, 615) - expected : 280593123, actual : 268665367.
5 Incorrect 499 ms 4588 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 307380480.
6 Incorrect 494 ms 4460 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 950550627.
7 Incorrect 495 ms 4572 KB Wrong Answer: Query(39, 920) - expected : 261655586, actual : 177735760.
8 Incorrect 512 ms 4460 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 552637840.
9 Incorrect 499 ms 4484 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 818294251.
10 Incorrect 496 ms 4460 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 877175172.