Submission #165321

# Submission time Handle Problem Language Result Execution time Memory
165321 2019-11-26T11:45:26 Z jovan_b Secret (JOI14_secret) C++17
0 / 100
616 ms 9776 KB
#include <bits/stdc++.h>
using namespace std;
#include "secret.h"
typedef long double ld;
typedef long long ll;

ll niz[1005];
ll res[1005][1005];
int n;

pair <int, int> fajnd(int l, int r, int tl, int tr){
    if(r-l <= 1) return {l, r-l+1};
    int mid = (l+r)/2;
    if(l <= tl && tr <= r && tl <= mid && r >= mid+1) return {mid, r-l+1};
    pair <int, int> x = fajnd(l, mid, tl, tr);
    pair <int, int> y = fajnd(mid+1, r, tl, tr);
    if(x.second > y.second) return x;
    return y;
}

void process(int l, int r){
    int mid = (l+r)/2;
  	if(l == r) return;
    res[mid][mid] = niz[mid];
    res[mid+1][mid+1] = niz[mid+1];
    for(ll j=mid-1; j>=l; j--){
        res[j][mid] = Secret(niz[j], res[j+1][mid]);
    }
    for(ll j=mid+2; j<=r; j++){
        res[mid+1][j] = Secret(res[mid+1][j-1], niz[j]);
    }
    process(l, mid);
    process(mid+1, r);
}

void Init(int N, int A[]){
    n = N;
    for(ll i=0; i<N; i++) niz[i] = A[i];
    process(0, n-1);
}

int Query(int L, int R){
    if(L == R) return niz[L];
    if(R == L+1) return Secret(niz[L], niz[R]);
    pair <int, int> g = fajnd(0, n-1, L, R);
    int i = g.first;
    return Secret(res[L][i], res[i+1][R]);
}
# Verdict Execution time Memory Grader output
1 Incorrect 165 ms 4908 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 587620235.
2 Incorrect 165 ms 4828 KB Wrong Answer: Query(102, 157) - expected : 32612619, actual : 962726377.
3 Incorrect 165 ms 4984 KB Wrong Answer: Query(334, 369) - expected : 363022362, actual : 16889894.
4 Incorrect 606 ms 9704 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 846921768.
5 Incorrect 605 ms 9696 KB Wrong Answer: Query(263, 292) - expected : 653448456, actual : 710055954.
6 Incorrect 609 ms 9720 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 949167361.
7 Correct 616 ms 9748 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 608 ms 9724 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 616 ms 9592 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 611 ms 9776 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1