답안 #1085983

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1085983 2024-09-09T08:50:28 Z Icelast 비밀 (JOI14_secret) C++17
6 / 100
314 ms 4692 KB
#include "secret.h"
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll maxn = 2*1e5+5, INF = 4e18+9;
struct MeowTree{
    struct Info{
        int v = 0;
    };
    struct Node{
        vector<int> lt, rt;
        int mid;
    };
    int n, N;
    vector<Node> T;
    MeowTree(int n, vector<int> a) : n(n){
        N = 1;
        while(N < n){
            N*=2;
        }
        T.resize(N*2);
        auto build = [&](auto build, int node, int low, int high) -> void{
            int mid = (low+high)/2;
            T[node].mid = mid;
            if(low == high){
                T[node].lt.push_back(a[mid]);
                return;
            }
            T[node].lt.push_back(a[mid]);
            T[node].rt.push_back(a[mid+1]);
            for(int i = mid-1; i >= low; i--){
                T[node].lt.push_back(Secret(a[i], T[node].lt.back()));
            }
            for(int i = mid+2; i <= min(n, high); i++){
                T[node].rt.push_back(Secret(T[node].rt.back(), a[i]));
            }
            build(build, node*2, low, mid);
            build(build, node*2+1, mid+1, high);
        };
        build(build, 1, 1, N);
    }
    int query(int l, int r){
        if(l == r) return T[l+N-1].lt[0];
        int low = l+N-1, high = r+N-1;
        while(low != high){
            if(low > high) swap(low, high);
            high/=2;
        }
        int node = low, mid = T[node].mid;
        return Secret(T[node].lt[mid-l], T[node].rt[r-mid-1]);
    }
};
MeowTree T(1, {1});
void Init(int n, int A[]) {
    vector<int> a(n+1);
    for(int i = 0; i < n; i++){
        a[i+1] = A[i];
    }
    T = MeowTree(n, a);
}
int Query(int l, int r) {
    l++;
    r++;
    return T.query(l, r);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 83 ms 2908 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 82 ms 2804 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 84 ms 3008 KB Output is correct - number of calls to Secret by Init = 5890, maximum number of calls to Secret by Query = 1
4 Partially correct 302 ms 4688 KB Output isn't correct - number of calls to Secret by Init = 8023, maximum number of calls to Secret by Query = 1
5 Partially correct 300 ms 4532 KB Output isn't correct - number of calls to Secret by Init = 8030, maximum number of calls to Secret by Query = 1
6 Partially correct 301 ms 4688 KB Output isn't correct - number of calls to Secret by Init = 8030, maximum number of calls to Secret by Query = 1
7 Partially correct 314 ms 4688 KB Output isn't correct - number of calls to Secret by Init = 8030, maximum number of calls to Secret by Query = 1
8 Partially correct 303 ms 4692 KB Output isn't correct - number of calls to Secret by Init = 8030, maximum number of calls to Secret by Query = 1
9 Partially correct 304 ms 4596 KB Output isn't correct - number of calls to Secret by Init = 8030, maximum number of calls to Secret by Query = 1
10 Partially correct 305 ms 4688 KB Output isn't correct - number of calls to Secret by Init = 8030, maximum number of calls to Secret by Query = 1