Submission #153919

# Submission time Handle Problem Language Result Execution time Memory
153919 2019-09-17T13:34:14 Z Mercenary Secret (JOI14_secret) C++14
0 / 100
619 ms 12496 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[l];
    for(int i = mid + 1 ; i <= r ; ++i){
        s[x][i] = Secret(s[x][i - 1] , a[i]);
    }
    s[x][mid - 1] = a[l - 1];
    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){
        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:36:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int mid = l + r >> 1;
               ~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 163 ms 6524 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 592538551.
2 Incorrect 169 ms 6572 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 482509097.
3 Incorrect 165 ms 6520 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 419637274.
4 Incorrect 619 ms 12296 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 885031616.
5 Incorrect 593 ms 12388 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 103860318.
6 Incorrect 610 ms 12496 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 853994769.
7 Incorrect 600 ms 12364 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 747153432.
8 Incorrect 613 ms 12284 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 636728536.
9 Incorrect 602 ms 12356 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 287049764.
10 Incorrect 598 ms 12352 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 878290506.