Submission #914835

# Submission time Handle Problem Language Result Execution time Memory
914835 2024-01-22T18:02:18 Z mike Secret (JOI14_secret) C++14
0 / 100
386 ms 9300 KB
#include <vector>
#include <iostream>

#include "secret.h"

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);
}


# Verdict Execution time Memory Grader output
1 Incorrect 101 ms 6740 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 22181386.
2 Incorrect 101 ms 6740 KB Wrong Answer: Query(236, 238) - expected : 173116186, actual : 1257633.
3 Incorrect 101 ms 6580 KB Wrong Answer: Query(128, 153) - expected : 959658850, actual : 69214536.
4 Incorrect 372 ms 8880 KB Wrong Answer: Query(374, 396) - expected : 402362963, actual : 269681171.
5 Incorrect 371 ms 8792 KB Wrong Answer: Query(584, 592) - expected : 111053842, actual : 895372370.
6 Incorrect 376 ms 8876 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 730510755.
7 Correct 380 ms 8868 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 386 ms 8872 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 385 ms 8788 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 384 ms 9300 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1