답안 #823805

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
823805 2023-08-13T07:13:09 Z Alihan_8 비밀 (JOI14_secret) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

#ifndef EVAL
#include "secret.h"
#endif // EVAL

using namespace std;

#define all(x) x.begin(), x.end()
#define pb push_back
#define ln '\n'
//#define int long long

template <class _T>
bool chmin(_T &x, const _T &y){
    bool flag = false;
    if ( x > y ){
        x = y; flag |= true;
    }
    return flag;
}

template <class _T>
bool chmax(_T &x, const _T &y){
    bool flag = false;
    if ( x < y ){
        x = y; flag |= true;
    }
    return flag;
}

const int N = 1e3 + 1;

struct SegTree{
    int T[N * 4], n;
    void build(vector <int> &a){
        n = (int)a.size();
        auto F = [&](auto &F, int v, int l, int r) -> void{
            if ( l == r ){
                T[v] = a[l];
                return;
            }
            int md = (l + r) >> 1;
            F(F, v * 2, l, md), F(F, v * 2 + 1, md + 1, r);
            T[v] = Secret(T[v * 2], T[v * 2 + 1]);
        };
        F(F, 1, 0, n - 1);
    }
    int get(int v, int l, int r, int tl, int tr){
        if ( l > tr or r < tl ){
            return -1;
        }
        if ( l <= tl and r >= tr ){
            return T[v];
        }
        int md = (l + r) >> 1;
        int L = get(v * 2, l, md, tl, tr), R = get(v * 2 + 1, md + 1, r, tl, tr);
        return Secret(L, R);
    }
    int get(int L, int R){
        return get(1, 0, n - 1, L, R);
    }
} tuf;

void Init(int n, int A[]) {
    vector <int> a;
    for ( int i = 0; i < n; i++ ){
        a.pb(A[i]);
    }
    tuf.build(a);
}

int Query(int L, int R) {
    return tuf.get(L, R);
}

Compilation message

secret.cpp: In lambda function:
secret.cpp:45:20: error: there are no arguments to 'Secret' that depend on a template parameter, so a declaration of 'Secret' must be available [-fpermissive]
   45 |             T[v] = Secret(T[v * 2], T[v * 2 + 1]);
      |                    ^~~~~~
secret.cpp:45:20: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
secret.cpp: In member function 'int SegTree::get(int, int, int, int, int)':
secret.cpp:58:16: error: 'Secret' was not declared in this scope
   58 |         return Secret(L, R);
      |                ^~~~~~
secret.cpp: In instantiation of 'SegTree::build(std::vector<int>&)::<lambda(auto:23&, int, int, int)> [with auto:23 = SegTree::build(std::vector<int>&)::<lambda(auto:23&, int, int, int)>]':
secret.cpp:47:25:   required from here
secret.cpp:45:26: error: 'Secret' was not declared in this scope
   45 |             T[v] = Secret(T[v * 2], T[v * 2 + 1]);
      |                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~