Submission #499846

# Submission time Handle Problem Language Result Execution time Memory
499846 2021-12-29T19:04:24 Z mars4 Secret (JOI14_secret) C++17
6 / 100
454 ms 4360 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---------------------------------

template<class T=int64_t> class DisjointSparse
{
	ll N;
	ll K;
	int ed;
	vector<T> a;

	T merge(T a,T b)
	{
		return Secret(a,b);
	}

	void build(ll l,ll r,ll level)
	{
		if(level<0)
		{
			return;
		}
		ll mid=(l+r)/2;
		st[mid][level]=a[mid];
		forb(i,mid-1,l)
		{
			if(i==N-1)
			{
				st[i][level]=ed;
			}
			if(i<N-1)
			{
				st[i][level]=merge(a[i],st[i+1][level]);
			}
		}
		st[mid+1][level]=a[mid+1];
		forn(i,mid+2,r+1)
		{
			if(i<N)
			{
				st[i][level]=merge(st[i-1][level],a[i]);
			}
		}
		build(l,mid,level-1);
		build(mid+1,r,level-1);
	}

	public:
	vector<vector<T>> st;

	void init(vector<T> &a)
	{
		N=(ll)a.size();
		this->a=a;
		K=1;
		while((1ll<<K)<N)
		{
			K++;
		}
		this->a.resize(1ll<<K);
		st=vector<vector<T>>(1ll<<K,vector<T>(K));
		ed=Secret(a[N-1],0);
		build(0,(1ll<<K)-1,K-1);
	}

	T query(ll l,ll r)
	{
		if(l==r)
		{
			return a[l];
		}
		ll level=63-__builtin_clzll(l^r);
		return merge(st[l][level],st[r][level]);
	}
};

DisjointSparse<int> ds;

void Init(int N,int A[])
{
	vector<int> a(N);
	forn(i,0,N)
	{
		a[i]=A[i];
	}
	ds.init(a);
}

int Query(int L,int R)
{
	return ds.query(L,R);
}
# Verdict Execution time Memory Grader output
1 Correct 120 ms 2380 KB Output is correct - number of calls to Secret by Init = 3579, maximum number of calls to Secret by Query = 1
2 Correct 127 ms 2364 KB Output is correct - number of calls to Secret by Init = 3587, maximum number of calls to Secret by Query = 1
3 Correct 144 ms 2432 KB Output is correct - number of calls to Secret by Init = 4098, maximum number of calls to Secret by Query = 1
4 Correct 439 ms 4352 KB Output is correct - number of calls to Secret by Init = 7992, maximum number of calls to Secret by Query = 1
5 Partially correct 454 ms 4304 KB Output isn't correct - number of calls to Secret by Init = 8001, maximum number of calls to Secret by Query = 1
6 Partially correct 424 ms 4360 KB Output isn't correct - number of calls to Secret by Init = 8001, maximum number of calls to Secret by Query = 1
7 Partially correct 444 ms 4320 KB Output isn't correct - number of calls to Secret by Init = 8001, maximum number of calls to Secret by Query = 1
8 Partially correct 442 ms 4232 KB Output isn't correct - number of calls to Secret by Init = 8001, maximum number of calls to Secret by Query = 1
9 Partially correct 433 ms 4340 KB Output isn't correct - number of calls to Secret by Init = 8001, maximum number of calls to Secret by Query = 1
10 Partially correct 437 ms 4340 KB Output isn't correct - number of calls to Secret by Init = 8001, maximum number of calls to Secret by Query = 1