Submission #914818

# Submission time Handle Problem Language Result Execution time Memory
914818 2024-01-22T17:39:02 Z mike Secret (JOI14_secret) C++14
0 / 100
20000 ms 8884 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){
        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, 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, 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);
}
# Verdict Execution time Memory Grader output
1 Incorrect 105 ms 6824 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 319912893.
2 Incorrect 113 ms 6736 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 68749376.
3 Incorrect 104 ms 8884 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 145096996.
4 Incorrect 373 ms 8856 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 327860453.
5 Incorrect 373 ms 8784 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 377506838.
6 Execution timed out 20078 ms 8784 KB Time limit exceeded
7 Incorrect 384 ms 8872 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 687550570.
8 Incorrect 386 ms 8820 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 145923264.
9 Incorrect 382 ms 8784 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 18757135.
10 Incorrect 376 ms 8880 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 70590726.