Submission #153920

# Submission time Handle Problem Language Result Execution time Memory
153920 2019-09-17T13:40:30 Z Mercenary Secret (JOI14_secret) C++14
6 / 100
619 ms 12400 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 INT_MAX;
    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]);
    }
    return min(query(x * 2 , l , mid , L , R) , query(x * 2 + 1 , mid + 1 , r , L , R));
}

int Query(int L, int R) {
    ++L;++R;
    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;
               ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 175 ms 6488 KB Output is correct - number of calls to Secret by Init = 3833, maximum number of calls to Secret by Query = 1
2 Correct 178 ms 6520 KB Output is correct - number of calls to Secret by Init = 3842, maximum number of calls to Secret by Query = 1
3 Correct 176 ms 6520 KB Output is correct - number of calls to Secret by Init = 3851, maximum number of calls to Secret by Query = 1
4 Partially correct 608 ms 12352 KB Output isn't correct - number of calls to Secret by Init = 8456, maximum number of calls to Secret by Query = 1
5 Partially correct 606 ms 12400 KB Output isn't correct - number of calls to Secret by Init = 8466, maximum number of calls to Secret by Query = 1
6 Partially correct 617 ms 12304 KB Output isn't correct - number of calls to Secret by Init = 8466, maximum number of calls to Secret by Query = 1
7 Partially correct 613 ms 12248 KB Output isn't correct - number of calls to Secret by Init = 8466, maximum number of calls to Secret by Query = 1
8 Partially correct 619 ms 12356 KB Output isn't correct - number of calls to Secret by Init = 8466, maximum number of calls to Secret by Query = 1
9 Partially correct 608 ms 12252 KB Output isn't correct - number of calls to Secret by Init = 8466, maximum number of calls to Secret by Query = 1
10 Partially correct 608 ms 12292 KB Output isn't correct - number of calls to Secret by Init = 8466, maximum number of calls to Secret by Query = 1