답안 #153922

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
153922 2019-09-17T13:43:47 Z Mercenary 비밀 (JOI14_secret) C++14
6 / 100
620 ms 12300 KB
#include "secret.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;

int n;
int s[4 * maxn][maxn];
int a[maxn];

void Build(int x , int l , int r){
    int mid = l + r >> 1;
    s[x][mid] = a[mid];
    for(int i = mid + 1 ; i <= r ; ++i){
        s[x][i] = Secret(s[x][i - 1] , a[i]);
    }
    s[x][mid - 1] = a[mid - 1];
//    if(mid == 6)cout << s[6][]
    for(int i = mid - 2 ; i >= l ; --i){
        s[x][i] = Secret(a[i] , s[x][i + 1]);
    }
    if(l == r){
        return ;
    }
    Build(x * 2 , l , mid);
    Build(x * 2 + 1 , mid + 1 , r);
}

void Init(int N, int A[]) {
    n = N;
    for(int i = n ; i >= 1 ; --i){
        a[i] = A[i - 1];
    }
    Build(1 , 1 , n);
}

int query(int x , int l , int r , int L , int R){
    int mid = l + r >> 1;
    if(l > R || L > r)return -1;
    if(L <= mid && mid <= R){
//        cout << mid << " " << " " << l << " " << r << " " << s[x][R] << endl;
        if(L == mid){
            return s[x][R];
        }
        return Secret(s[x][L],s[x][R]);
    }
    int lef = query(x * 2 , l , mid , L , R);
    if(lef != -1)return lef;
    return query(x * 2 + 1 , mid + 1 , r , L , R);
}

int Query(int L, int R) {
    ++L;++R;
    int res = query(1 , 1 , n , L , R);
    if(res == -1)assert(0);
    return query(1 , 1 , n , L , R);
}

Compilation message

secret.cpp: In function 'void Build(int, int, int)':
secret.cpp:11:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int mid = l + r >> 1;
               ~~^~~
secret.cpp: In function 'int query(int, int, int, int, int)':
secret.cpp:37:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int mid = l + r >> 1;
               ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 181 ms 6392 KB Output is partially correct - number of calls to Secret by Init = 3833, maximum number of calls to Secret by Query = 2
2 Partially correct 184 ms 6512 KB Output is partially correct - number of calls to Secret by Init = 3842, maximum number of calls to Secret by Query = 2
3 Partially correct 182 ms 6472 KB Output is partially correct - number of calls to Secret by Init = 3851, maximum number of calls to Secret by Query = 2
4 Partially correct 612 ms 12180 KB Output isn't correct - number of calls to Secret by Init = 8456, maximum number of calls to Secret by Query = 2
5 Partially correct 609 ms 12204 KB Output isn't correct - number of calls to Secret by Init = 8466, maximum number of calls to Secret by Query = 2
6 Partially correct 613 ms 12180 KB Output isn't correct - number of calls to Secret by Init = 8466, maximum number of calls to Secret by Query = 2
7 Partially correct 620 ms 12232 KB Output isn't correct - number of calls to Secret by Init = 8466, maximum number of calls to Secret by Query = 2
8 Partially correct 613 ms 12168 KB Output isn't correct - number of calls to Secret by Init = 8466, maximum number of calls to Secret by Query = 2
9 Partially correct 613 ms 12280 KB Output isn't correct - number of calls to Secret by Init = 8466, maximum number of calls to Secret by Query = 2
10 Partially correct 616 ms 12300 KB Output isn't correct - number of calls to Secret by Init = 8466, maximum number of calls to Secret by Query = 2