# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
499839 |
2021-12-29T18:44:33 Z |
mars4 |
Secret (JOI14_secret) |
C++17 |
|
493 ms |
4432 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "secret.h"
using namespace std;
using namespace __gnu_pbds;
#define ff first
#define ss second
#define ll int64_t
#define ld long double
#define nl cout<<"\n"
#define all(v) v.begin(),v.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define forn(i,a,b) for(int64_t i=int64_t(a);i<int64_t(b);++i)
#define forb(i,a,b) for(int64_t i=int64_t(a);i>=int64_t(b);--i)
#define fastio() ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod 1'000'000'007
#define mod2 998'244'353
#define inf 1'000'000'000'000'007
#define pi 3.14159265358979323846
template<class key,class cmp=std::less<key>>
using ordered_set=tree<key,null_type,cmp,rb_tree_tag,tree_order_statistics_node_update>;
template<class L,class R> ostream& operator<<(ostream& out,pair<L,R> &p) {return out<<"("<<p.ff<<", "<<p.ss<<")";}
template<class T> ostream& operator<<(ostream& out,vector<T> &v) {out<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())out<<", ";out<<*it;}return out<<"]";}
template<class T> ostream& operator<<(ostream& out,deque<T> &v) {out<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())out<<", ";out<<*it;}return out<<"]";}
template<class T> ostream& operator<<(ostream& out,set<T> &s) {out<<"{";for(auto it=s.begin();it!=s.end();++it){if(it!=s.begin())out<<", ";out<<*it;}return out<<"}";}
template<class L,class R> ostream& operator<<(ostream& out,map<L,R> &m) {out<<"{";for(auto it=m.begin();it!=m.end();++it){if(it!=m.begin())out<<", ";out<<*it;}return out<<"}";}
void dbg_out() {cerr<<"]\n";}
template<typename Head,typename... Tail>
void dbg_out(Head H,Tail... T) {cerr<<H;if(sizeof...(Tail))cerr<<", ";dbg_out(T...);}
#ifdef LOCAL
#define dbg(...) cerr<<"["<<#__VA_ARGS__<<"] = [",dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
//---------------------------------mars4---------------------------------
class Segtree
{
ll N;
public:
vector<int> segtree;
void init(ll n,ll val=0)
{
N=n;
segtree=vector<int>(N<<1,val);
}
void build(int A[])
{
forn(i,0,N)
segtree[i+N]=A[i];
forb(i,N-1,1)
segtree[i]=Secret(segtree[i<<1],segtree[i<<1|1]);
}
int query(ll l,ll r)
{
ll resl=-1;
ll resr=-1;
for(l+=N,r+=N+1;l<r;l>>=1,r>>=1)
{
if(l&1)
{
if(resl==-1)
{
resl=segtree[l++];
}
else
{
resl=Secret(resl,segtree[l++]);
}
}
if(r&1)
{
if(resr==-1)
{
resr=segtree[--r];
}
else
{
resr=Secret(segtree[--r],resr);
}
}
}
if(resl==-1)
{
return resr;
}
if(resr==-1)
{
return resl;
}
return Secret(resl,resr);
}
};
Segtree s;
void Init(int N,int A[])
{
s.init(N);
s.build(A);
}
int Query(int L,int R)
{
return s.query(L,R);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
177 ms |
2360 KB |
Output is partially correct - number of calls to Secret by Init = 510, maximum number of calls to Secret by Query = 14 |
2 |
Partially correct |
170 ms |
2328 KB |
Output is partially correct - number of calls to Secret by Init = 511, maximum number of calls to Secret by Query = 14 |
3 |
Partially correct |
158 ms |
2324 KB |
Output is partially correct - number of calls to Secret by Init = 512, maximum number of calls to Secret by Query = 13 |
4 |
Partially correct |
468 ms |
4276 KB |
Output is partially correct - number of calls to Secret by Init = 998, maximum number of calls to Secret by Query = 15 |
5 |
Partially correct |
464 ms |
4192 KB |
Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 14 |
6 |
Partially correct |
436 ms |
4244 KB |
Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 4 |
7 |
Partially correct |
493 ms |
4432 KB |
Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 16 |
8 |
Partially correct |
491 ms |
4380 KB |
Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 16 |
9 |
Partially correct |
486 ms |
4252 KB |
Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 15 |
10 |
Partially correct |
484 ms |
4328 KB |
Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 16 |