# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
831073 |
2023-08-19T16:58:06 Z |
starchan |
Secret (JOI14_secret) |
C++17 |
|
0 ms |
0 KB |
#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 secret(int x, int y)
{
if(min(x, 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[m] = a[id];
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);
return;
}
int Query(int l, int r)
{
return work.query(l, r, 1, 0, n-1);
}
Compilation message
secret.cpp: In function 'int Query(int, int)':
secret.cpp:61:32: error: 'n' was not declared in this scope
61 | return work.query(l, r, 1, 0, n-1);
| ^