답안 #914845

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
914845 2024-01-22T18:19:21 Z mike 비밀 (JOI14_secret) C++14
0 / 100
388 ms 9044 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 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-1, L, R);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 101 ms 6740 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 559309197.
2 Incorrect 102 ms 6684 KB Wrong Answer: Query(236, 238) - expected : 173116186, actual : 800141843.
3 Incorrect 102 ms 6740 KB Wrong Answer: Query(128, 153) - expected : 959658850, actual : 69214536.
4 Incorrect 378 ms 8792 KB Wrong Answer: Query(374, 396) - expected : 402362963, actual : 269681171.
5 Incorrect 374 ms 9044 KB Wrong Answer: Query(584, 592) - expected : 111053842, actual : 895372370.
6 Incorrect 374 ms 8812 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 730510755.
7 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
8 Correct 385 ms 8792 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 388 ms 9040 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 382 ms 8784 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1