답안 #914834

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
914834 2024-01-22T18:01:38 Z vjudge1 비밀 (JOI14_secret) C++17
컴파일 오류
0 ms 0 KB
#include <vector>
#include <iostream>


using namespace std;

int tree[4005][1005];
int arr[1005];

int tam;

void segment_tree(int pos, int ini, int fin){
    if(ini == fin){
        tree[pos][ini]=arr[ini];
        return;
    }
    if(ini == fin-1){
        tree[pos][ini]=arr[ini];
        tree[pos][fin]=arr[fin];
        return;
    }
    int mitad=(ini+fin)/2;
    tree[pos][mitad-1]=arr[mitad-1];
    for(int c=mitad-2; c >= ini; c--){
        tree[pos][c]=Secret(arr[c], tree[pos][c+1]);
    }
    tree[pos][mitad]=arr[mitad];
    for(int c=mitad+1; c <= fin; c++){
        tree[pos][c]=Secret(tree[pos][c-1],arr[c]);
    }
    segment_tree(pos*2, ini, mitad);
    segment_tree(pos*2+1, mitad+1, fin);    
}

void Init(int N, int A[]){
    tam=N;
    for(int c=0; c < N; c++){
        arr[c]=A[c];
    }
    segment_tree(1, 0, N-1);
}

int ayuda(int pos, int ini, int fin, int l, int r){
    int mitad=(ini+fin)/2;
    if(l == r)
        return arr[l];
    if(l == r-1)
        return Secret(arr[l], arr[r]);
    if(l < mitad && r >= mitad){
        return Secret(tree[pos][l], tree[pos][r]);
    }
    if(l >= mitad){
        return ayuda(pos*2+1, mitad, fin, l, r);
    }
    else
        return ayuda(pos*2, ini, mitad-1, l , r);
}

int Query(int L, int R){
    if(L == R)
        return arr[L];
    if(L == R-1)
        return Secret(arr[L], arr[R]);
    return ayuda(1, 0, tam, L, R);
}

Compilation message

secret.cpp: In function 'void segment_tree(int, int, int)':
secret.cpp:25:22: error: 'Secret' was not declared in this scope
   25 |         tree[pos][c]=Secret(arr[c], tree[pos][c+1]);
      |                      ^~~~~~
secret.cpp:29:22: error: 'Secret' was not declared in this scope
   29 |         tree[pos][c]=Secret(tree[pos][c-1],arr[c]);
      |                      ^~~~~~
secret.cpp: In function 'int ayuda(int, int, int, int, int)':
secret.cpp:48:16: error: 'Secret' was not declared in this scope
   48 |         return Secret(arr[l], arr[r]);
      |                ^~~~~~
secret.cpp:50:16: error: 'Secret' was not declared in this scope
   50 |         return Secret(tree[pos][l], tree[pos][r]);
      |                ^~~~~~
secret.cpp: In function 'int Query(int, int)':
secret.cpp:63:16: error: 'Secret' was not declared in this scope
   63 |         return Secret(arr[L], arr[R]);
      |                ^~~~~~