Submission #476790

# Submission time Handle Problem Language Result Execution time Memory
476790 2021-09-28T14:03:35 Z Karliver Secret (JOI14_secret) C++14
0 / 100
514 ms 4416 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 MX = 1005;
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[MX][12];
int mask[MX];
int X[MX];

void divi(int l, int r, int lev) {
    if(l == r) {
        return;
    }

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

    for(int i = rm + 2;i <= r;++i)
        F[i][lev] = Secret(X[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 N, int A[]) {
    forn(i, N) X[i] = A[i];
    
    
    divi(0, N - 1, 0);
}
int Query(int L, int R) {
    if(L == R) {
        return X[L];
    }
    int b = __builtin_ctz((mask[L] ^  mask[R]));

    return Secret(F[L][b], F[R][b]);
}
# Verdict Execution time Memory Grader output
1 Incorrect 135 ms 2372 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 809782271.
2 Incorrect 136 ms 2280 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 68749376.
3 Incorrect 136 ms 2392 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 136349820.
4 Incorrect 507 ms 4264 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 650789536.
5 Incorrect 502 ms 4416 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 377506838.
6 Incorrect 502 ms 4256 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 61461050.
7 Incorrect 505 ms 4264 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 687550570.
8 Incorrect 511 ms 4292 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 145923264.
9 Incorrect 514 ms 4296 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 18757135.
10 Incorrect 513 ms 4384 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 70590726.