# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
831080 | starchan | Secret (JOI14_secret) | C++17 | 427 ms | 4344 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include "secret.h"
using namespace std;
#define in pair<int, int>
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define INF (int)1e17
#define MX (int)5e3+5
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
int XXX;
int secret(int x, int y)
{
if(x == -1 || y == -1)
return x+y+1;
else
return Secret(x, y);
}
struct segment_tree
{
vector<int> tree;
void build(const int a[], int id, int l, int r)
{
int m = (l+r)/2;
if(l==r)
{
tree[id] = a[m];
return;
}
build(a, 2*id, l, m);
build(a, 2*id+1, m+1, r);
tree[id] = secret(tree[2*id], tree[2*id+1]);
return;
}
void init(int n, const int a[])
{
tree.resize(MX);
build(a, 1, 0, n-1);
return;
}
int query(int ql, int qr, int id, int l, int r)
{
if(qr < l || r < ql)
return -1;
if(ql <= l && r <= qr)
return tree[id];
int m = (l+r)/2;
int x = query(ql, qr, 2*id, l, m);
int y = query(ql, qr, 2*id+1, m+1, r);
return secret(x, y);
}
};
segment_tree work;
void Init(int n, int a[])
{
work.init(n, a);
XXX = n;
return;
}
int Query(int l, int r)
{
return work.query(l, r, 1, 0, XXX-1);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |