Submission #25251

# Submission time Handle Problem Language Result Execution time Memory
25251 2017-06-21T04:50:16 Z 시제연(#1061) Secret (JOI14_secret) C++
6 / 100
663 ms 6388 KB
#include "secret.h"
#include <bits/stdc++.h>

using namespace std;

int n;
int arr[1100];

struct node {
    vector<int> l, r;
};

struct idxtree {
    node tree[2100];
    void init(int s, int e, int idx) {
        if (s==e) {
            tree[idx].l.push_back(arr[s]);
            tree[idx].r.push_back(arr[s]);
            return;
        }
        int i, m = (s+e)>>1;
        init(s,m,idx*2);
        init(m+1,e,idx*2+1);
        for (i=s;i<=m;i++) tree[idx].l.push_back(tree[idx*2].l[i-s]);
        for (i=m+1;i<=e;i++) tree[idx].l.push_back(Secret(tree[idx].l.back(),arr[i]));
        for (i=e;i>m;i--) tree[idx].r.push_back(tree[idx*2+1].r[e-i]);
        for (i=m;i>s;i--) tree[idx].r.push_back(Secret(arr[i],tree[idx].r.back()));
        tree[idx].r.push_back(tree[idx].l.back());
    }
    int getv(int s, int e, int idx, int S, int E) {
        int m = (s+e)>>1;
        if (s==e) return arr[s];
        if (e==E) return tree[idx].r[e-S];
        if (s==S) return tree[idx].l[E-s];
        if (E<=m) return getv(s,m,idx*2,S,E);
        else if (m+1<=S) return getv(m+1,e,idx*2+1,S,E);
        else return Secret(getv(s,m,idx*2,S,m),getv(m+1,e,idx*2+1,m+1,E));
    }
} it;

void Init(int N, int A[]) {
    n = N;
    int i;
    for (i=0;i<n;i++) arr[i]=A[i];
    it.init(0,n-1,1);
}

int Query(int L, int R) {
    return it.getv(0,n-1,1,L,R);
}
# Verdict Execution time Memory Grader output
1 Correct 179 ms 6256 KB Output is correct - number of calls to Secret by Init = 4088, maximum number of calls to Secret by Query = 1
2 Correct 189 ms 6256 KB Output is correct - number of calls to Secret by Init = 4097, maximum number of calls to Secret by Query = 1
3 Correct 179 ms 6256 KB Output is correct - number of calls to Secret by Init = 4107, maximum number of calls to Secret by Query = 1
4 Incorrect 643 ms 6388 KB Output isn't correct - number of calls to Secret by Init = 8967, maximum number of calls to Secret by Query = 1
5 Incorrect 643 ms 6388 KB Output isn't correct - number of calls to Secret by Init = 8977, maximum number of calls to Secret by Query = 1
6 Incorrect 613 ms 6388 KB Output isn't correct - number of calls to Secret by Init = 8977, maximum number of calls to Secret by Query = 1
7 Incorrect 639 ms 6388 KB Output isn't correct - number of calls to Secret by Init = 8977, maximum number of calls to Secret by Query = 1
8 Incorrect 616 ms 6388 KB Output isn't correct - number of calls to Secret by Init = 8977, maximum number of calls to Secret by Query = 1
9 Incorrect 663 ms 6388 KB Output isn't correct - number of calls to Secret by Init = 8977, maximum number of calls to Secret by Query = 1
10 Incorrect 639 ms 6388 KB Output isn't correct - number of calls to Secret by Init = 8977, maximum number of calls to Secret by Query = 1