답안 #914824

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
914824 2024-01-22T17:45:51 Z mike 비밀 (JOI14_secret) C++14
0 / 100
380 ms 13072 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(arr[c], tree[pos][c-1]);
    }
    segment_tree(pos*2, ini, mitad-1);
    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-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, 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);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 103 ms 8784 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 18023524.
2 Incorrect 107 ms 8788 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 673849481.
3 Incorrect 101 ms 8784 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 145096996.
4 Incorrect 373 ms 12884 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 327860453.
5 Incorrect 375 ms 12888 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 339249436.
6 Incorrect 380 ms 12892 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 413173002.
7 Incorrect 379 ms 12892 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 3868680.
8 Incorrect 375 ms 12884 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 884260864.
9 Incorrect 379 ms 13072 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 559157025.
10 Incorrect 378 ms 12892 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 813114883.