답안 #656877

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
656877 2022-11-08T12:51:57 Z Danilo21 비밀 (JOI14_secret) C++17
100 / 100
472 ms 12364 KB
#include <bits/stdc++.h>
#include "secret.h"

#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define en '\n'
#define sp ' '
#define tb '\t'
#define ri(n) int n; cin >> n
#define rl(n) ll n; cin >> n
#define rs(s) string s; cin >> s
#define rc(c) char c; cin >> c
#define rv(v) for (auto &x : v) cin >> x
#define pven(v) for (auto x : v) cout << x << en
#define pv(v) for (auto x : v) cout << x << sp; cout << en
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yes cout << "YES" << en
#define no cout << "NO" << en
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define ssort(a, b) if (a < b) swap(a, b)
#define bitcnt(a) __builtin_popcountll(a)
#define bithigh(a) 63-__builtin_clzll(a)
#define lg bithigh
ll highpow(ll a) { return 1LL << (ll)lg(a); }

using namespace std;

const ll LINF = 4e18;
const int mxN = 1e3+10, INF = 2e9;
ll n, m, a[mxN], table[mxN][mxN];

void Build(int l, int r){

    if (l == r) return;
    int m = (l + r)>>1;
    for (int i = m-1; i >= l; i--)
        if (!~table[i][m])
            table[i][m] = Secret(a[i], table[i+1][m]);
    for (int i = m+2; i <= r; i++)
        if (!~table[m+1][i])
            table[m+1][i] = Secret(table[m+1][i-1], a[i]);
    Build(l, m); Build(m+1, r);
}

void Init(int N, int A[]) {
    memset(table, -1, sizeof(table));
    n = N;
    for (int i = 0; i < n; i++)
        a[i] = table[i][i] = A[i];
    Build(0, n-1);
}

int Query(int L, int R) {
    if (~table[L][R]) return table[L][R];
    for (int i = L; i < R; i++)
        if (~table[L][i] && ~table[i+1][R])
            return Secret(table[L][i], table[i+1][R]);
}

Compilation message

secret.cpp: In function 'long long int highpow(long long int)':
secret.cpp:27:22: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   27 | #define bithigh(a) 63-__builtin_clzll(a)
      |                      ^
secret.cpp:28:12: note: in expansion of macro 'bithigh'
   28 | #define lg bithigh
      |            ^~~~~~~
secret.cpp:29:38: note: in expansion of macro 'lg'
   29 | ll highpow(ll a) { return 1LL << (ll)lg(a); }
      |                                      ^~
secret.cpp: In function 'int Query(int, int)':
secret.cpp:63:1: warning: control reaches end of non-void function [-Wreturn-type]
   63 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 139 ms 10456 KB Output is correct - number of calls to Secret by Init = 3084, maximum number of calls to Secret by Query = 1
2 Correct 128 ms 10412 KB Output is correct - number of calls to Secret by Init = 3092, maximum number of calls to Secret by Query = 1
3 Correct 125 ms 10508 KB Output is correct - number of calls to Secret by Init = 3101, maximum number of calls to Secret by Query = 1
4 Correct 472 ms 12364 KB Output is correct - number of calls to Secret by Init = 6989, maximum number of calls to Secret by Query = 1
5 Correct 429 ms 12364 KB Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1
6 Correct 454 ms 12320 KB Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1
7 Correct 437 ms 12236 KB Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1
8 Correct 464 ms 12248 KB Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1
9 Correct 433 ms 12344 KB Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1
10 Correct 445 ms 12236 KB Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1