답안 #68490

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
68490 2018-08-17T08:17:17 Z losmi247 비밀 (JOI14_secret) C++14
0 / 100
684 ms 4640 KB
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
int Q,l,r;
int drvo[2000005];
int n,a[2000005];
void update(int i,int j,int poz,int val,int node){
    if(i == j){
        drvo[node] = val;
        return;
    }
    int mid = i+(j-i)/2;
    if(poz <= mid){
        update(i,mid,poz,val,2*node+1);
    }
    else{
        update(mid+1,j,poz,val,2*node+2);
    }
    drvo[node] = Secret(drvo[2*node+1],drvo[2*node+2]);
}
void build(int i,int j,int node){
    if(i == j){
        drvo[node] = a[i];
        return;
    }
    int mid = i+(j-i)/2;
    build(i,mid,2*node+1);
    build(mid+1,j,2*node+2);
    drvo[node] = Secret(drvo[2*node+1],drvo[2*node+2]);
}
int get(int i,int j,int l,int r,int node){
    if(j < l || i > r){
        return -1;
    }
    if(l <= i && r >= j){
        return drvo[node];
    }
    int mid = i+(j-i)/2;
    int p1 = get(i,mid,l,r,2*node+1),p2=get(mid+1,j,l,r,2*node+2);
    if(p1 == -1){
        return p2;
    }
    else if(p2 == -1){
        return p1;
    }
    else{
        return Secret(get(i,mid,l,r,2*node+1),get(mid+1,j,l,r,2*node+2));
    }
}
int Query(int L,int R){
    return get(0,n-1,L,R,0);
}
void Init(int N,int A[]){
    n = N;
    /*for(int i = 0; i < N; i++){
        update(0,n-1,i,A[i],0);
        a[i] = A[i];
    }*/
    build(0,n-1,0);
    cin >> Q;
    while(Q--){
        cin >> l >> r;
        cout << Query(l,r) << endl;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 158 ms 2424 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 536870912.
2 Incorrect 162 ms 2536 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 0.
3 Incorrect 168 ms 2536 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 536870912.
4 Incorrect 684 ms 4508 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 536870912.
5 Incorrect 626 ms 4508 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 536870912.
6 Incorrect 668 ms 4612 KB Wrong Answer: Query(915, 915) - expected : 282904741, actual : 0.
7 Incorrect 630 ms 4612 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 0.
8 Incorrect 618 ms 4640 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 536870912.
9 Incorrect 626 ms 4640 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 0.
10 Incorrect 653 ms 4640 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 0.