답안 #476780

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
476780 2021-09-28T13:56:16 Z Karliver 비밀 (JOI14_secret) C++17
0 / 100
529 ms 4604 KB
    
#include <bits/stdc++.h>
#include "secret.h"

#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(20) << (x)
#define all(v) (v).begin(), (v).end()
using namespace  std;
#define forn(i,n) for (int i = 0; i < (n); ++i)
#define rforn(i, n) for(int i = (n) - 1;i >= 0;--i)
using ll = long long;
int mod = (ll)1e9 + 7;
#define PI acos(-1)
typedef pair<int, int> pairs;

const int INF = 1e9 + 1;
const int N = 1002;
const double eps = 1e-7;

template <class T> using V = vector<T>;  
template <class T> using VV = V<V<T>>;  

template <typename XPAX>
void ckma(XPAX &x, XPAX y) {
    x = (x < y ? y : x);
}
template <typename XPAX>
void ckmi(XPAX &x, XPAX y) {
    x = (x > y ? y : x);
}
int F[N][20];
int mask[N];
V<int> A(N);
int n;
void divi(int l, int r, int lev) {
    if(l == r)
        return;

    int rm = (l + r) / 2;
    F[rm][lev] = A[rm];
    F[rm + 1][lev] = A[rm + 1];
    for(int i = rm - 1;i >= l;--i)
        F[i][lev] = Secret(A[i], F[i + 1][lev]);

    for(int i = rm + 2;i <= r;++i)
        F[i][lev] = Secret(A[i], F[i - 1][lev]);

    for(int i = rm + 1;i <= r;++i)
        mask[i] ^= 1 << lev;

    divi(l, rm, lev + 1);
    divi(rm + 1, r, lev + 1);
}
void Init(int D, int s[]) {
    forn(i, D) A[i] = s[i];
    memset(F, 0, sizeof F);
    n = D;
    divi(0, n - 1, 0);
}
int Query(int L, int R) {
    if(L == R)
        return A[L];

    int b = __builtin_ctz((mask[L] ^  mask[R]));

    return Secret(F[L][b], F[R][b]);
}

# 결과 실행 시간 메모리 Grader output
1 Incorrect 131 ms 2472 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 809782271.
2 Incorrect 134 ms 2536 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 68749376.
3 Incorrect 135 ms 2444 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 136349820.
4 Incorrect 504 ms 4440 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 650789536.
5 Incorrect 494 ms 4604 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 377506838.
6 Incorrect 496 ms 4380 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 61461050.
7 Incorrect 529 ms 4428 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 687550570.
8 Incorrect 502 ms 4372 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 145923264.
9 Incorrect 497 ms 4420 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 18757135.
10 Incorrect 512 ms 4352 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 70590726.