Submission #914809

# Submission time Handle Problem Language Result Execution time Memory
914809 2024-01-22T17:27:07 Z vjudge1 Secret (JOI14_secret) C++17
Compilation error
0 ms 0 KB
#include <vector>
#include <iostream>

#include "secret.h"

using namespace std;

int Secret(int x, int y){
    return min(x+y-y%2, 1000000000);
}

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){
        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(arr[c], tree[pos][c-1]);
    }
    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);
}

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+1, fin, l, r);
    }
    else
        return ayuda(pos*2, ini, mitad, 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

/usr/bin/ld: /tmp/ccOkshgC.o: in function `Secret(int, int)':
secret.cpp:(.text+0x0): multiple definition of `Secret(int, int)'; /tmp/ccIIXAuE.o:grader-full.cpp:(.text+0x2d0): first defined here
collect2: error: ld returned 1 exit status