Submission #914836

# Submission time Handle Problem Language Result Execution time Memory
914836 2024-01-22T18:05:58 Z mike Secret (JOI14_secret) C++14
Compilation error
0 ms 0 KB
#include <vector>
#include <iostream>

#include "secret.h"

using namespace std;


int tree[4005][1005];
int arr[1005];  }
    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-1, L, R);
}

Compilation message

secret.cpp:10:17: error: expected declaration before '}' token
   10 | int arr[1005];  }
      |                 ^
secret.cpp:11:5: error: expected unqualified-id before 'if'
   11 |     if(ini == fin-1){
      |     ^~
secret.cpp:16:16: error: 'ini' was not declared in this scope; did you mean 'int'?
   16 |     int mitad=(ini+fin)/2;
      |                ^~~
      |                int
secret.cpp:16:20: error: 'fin' was not declared in this scope
   16 |     int mitad=(ini+fin)/2;
      |                    ^~~
secret.cpp:17:5: error: 'tree' does not name a type
   17 |     tree[pos][mitad-1]=arr[mitad-1];
      |     ^~~~
secret.cpp:18:5: error: expected unqualified-id before 'for'
   18 |     for(int c=mitad-2; c >= ini; c--){
      |     ^~~
secret.cpp:18:24: error: 'c' does not name a type
   18 |     for(int c=mitad-2; c >= ini; c--){
      |                        ^
secret.cpp:18:34: error: 'c' does not name a type
   18 |     for(int c=mitad-2; c >= ini; c--){
      |                                  ^
secret.cpp:21:5: error: 'tree' does not name a type
   21 |     tree[pos][mitad]=arr[mitad];
      |     ^~~~
secret.cpp:22:5: error: expected unqualified-id before 'for'
   22 |     for(int c=mitad+1; c <= fin; c++){
      |     ^~~
secret.cpp:22:24: error: 'c' does not name a type
   22 |     for(int c=mitad+1; c <= fin; c++){
      |                        ^
secret.cpp:22:34: error: 'c' does not name a type
   22 |     for(int c=mitad+1; c <= fin; c++){
      |                                  ^
secret.cpp:25:17: error: expected constructor, destructor, or type conversion before '(' token
   25 |     segment_tree(pos*2, ini, mitad);
      |                 ^
secret.cpp:26:17: error: expected constructor, destructor, or type conversion before '(' token
   26 |     segment_tree(pos*2+1, mitad+1, fin);
      |                 ^
secret.cpp:27:1: error: expected declaration before '}' token
   27 | }
      | ^
secret.cpp: In function 'void Init(int, int*)':
secret.cpp:30:5: error: 'tam' was not declared in this scope; did you mean 'tm'?
   30 |     tam=N;
      |     ^~~
      |     tm
secret.cpp:34:5: error: 'segment_tree' was not declared in this scope
   34 |     segment_tree(1, 0, N-1);
      |     ^~~~~~~~~~~~
secret.cpp: In function 'int Query(int, int)':
secret.cpp:58:24: error: 'tam' was not declared in this scope; did you mean 'tm'?
   58 |     return ayuda(1, 0, tam-1, L, R);
      |                        ^~~
      |                        tm