답안 #914819

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
914819 2024-01-22T17:40:52 Z mike 비밀 (JOI14_secret) C++14
0 / 100
385 ms 9008 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);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 100 ms 6744 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 319912893.
2 Incorrect 101 ms 6744 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 68749376.
3 Incorrect 105 ms 8868 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 145096996.
4 Incorrect 373 ms 8788 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 327860453.
5 Incorrect 385 ms 8788 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 377506838.
6 Incorrect 372 ms 8760 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 722663411.
7 Incorrect 380 ms 9008 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 687550570.
8 Incorrect 374 ms 8796 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 145923264.
9 Incorrect 382 ms 8788 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 18757135.
10 Incorrect 375 ms 8788 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 70590726.