# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
737991 | anusha777 | Secret (JOI14_secret) | C++14 | 432 ms | 4300 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 "secret.h"
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL)
#define sz(x) (int)((x).size())
#define pb push_back
#define vi vector<int>
#define vb vector<bool>
#define vvb vector<vb>
#define pi pair<int,int>
#define vpi vector<pi>
#define vvi vector<vi>
#define vc vector<char>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pbb() pop_back()
#define f first
#define s second
#define ll long long
//#define int long long
#define ull unsigned long long
#define line cout<<"_____________________________"<<endl;
#define hash cout<<"################"<<endl;
#define forr(i, a, b) for(int i=a; i<b; i++)
using namespace std;
const int N=1e5+1, mod=1e9+7, inf=1e18+1;
vi a;
int n;
void Set(int x, int v, int i , int l, int r)
{
if(r-l==1)
{
a[x]=v;
return;
}
int m= (l+r)/2;
if(i<m) Set(2*x+1, v, i, l , m);
else Set(2*x+2, v, i, m , r);
a[x]= Secret(a[2*x+1], a[2*x+2]);
}
void Init(int m, int A[])
{
n=1;
while(n<m) n*=2;
a.resize(2*n-1);
forr(i, 0, n) Set(0, A[i], i, 0, n);
}
int query(int x, int lx, int rx, int l, int r)
{
if(l>=rx or lx>=r) return -1;
if(l>=lx and r<=rx) return a[x];
int mx= (lx+rx)/2;
int v1= query(2*x+1, lx, mx, l, r), v2= query(2*x+2, mx, rx, l, r);
if(v1!=-1 and v2!=-1) return Secret(v1, v2);
if(v1==-1) return v2;
return v1;
}
int Query(int l, int r)
{
return query(0, 0, n, l, r+1);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |