답안 #366272

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
366272 2021-02-13T18:05:57 Z rocks03 비밀 (JOI14_secret) C++14
0 / 100
534 ms 4588 KB
//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
// #include "secret.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define Re(i, a, b) for(int i = (a); i >= (b); i--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int Secret(int, int);

const int MAXK = 10;
const int MAXN = 1e3;
int N, *a, st[MAXK][MAXN];

void solve(int l, int r, int lev){
    if(l == r) return;
    int m = (l + r) / 2;
    st[lev][m] = a[m], st[lev][m + 1] = a[m + 1];
    Re(i, m - 1, l){
        st[lev][i] = Secret(a[i], st[lev][i + 1]);
    }
    rep(i, m + 2, r + 1){
        st[lev][i] = Secret(st[lev][i - 1], a[i]);
    }
    solve(l, m, lev + 1); solve(m + 1, r, lev + 1);
}

int query(int l, int r, int lev, int ql, int qr){
    int m = (l + r) / 2;
    if(ql <= m && m <= qr){
        if(ql == m) return st[lev][qr];
        else if(qr == m) return st[lev][ql];
        else return Secret(st[lev][ql], st[lev][qr]);
    }
    if(qr <= m) return query(l, m, lev + 1, ql, qr);
    else return query(m + 1, r, lev + 1, ql, qr);
}

void Init(int n, int A[]){
    N = n, a = A;
    solve(0, N - 1, 0);
}

int Query(int L, int R){
    if(L == R) return a[L];
    else return query(0, N - 1, 0, L, R);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 143 ms 2560 KB Wrong Answer: Query(255, 409) - expected : 307522235, actual : 827471512.
2 Incorrect 133 ms 2476 KB Wrong Answer: Query(127, 153) - expected : 342921603, actual : 708520034.
3 Incorrect 135 ms 2412 KB Wrong Answer: Query(128, 153) - expected : 959658850, actual : 764916540.
4 Incorrect 534 ms 4332 KB Wrong Answer: Query(374, 396) - expected : 402362963, actual : 564777122.
5 Incorrect 511 ms 4460 KB Wrong Answer: Query(703, 706) - expected : 857111674, actual : 255976226.
6 Incorrect 502 ms 4460 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 870639733.
7 Correct 515 ms 4332 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 521 ms 4320 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 514 ms 4332 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 508 ms 4588 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1