Submission #709841

# Submission time Handle Problem Language Result Execution time Memory
709841 2023-03-14T16:44:56 Z mars4 Secret (JOI14_secret) C++17
0 / 100
436 ms 4772 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 i128            __int128_t
#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 T> ostream& operator<<(ostream& out,ordered_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;
	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)
		{
			st[i][level]=merge(a[i],st[i+1][level]);
		}
		st[mid+1][level]=a[mid+1];
		forn(i,mid+2,r+1)
		{
			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,int n)
	{
		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));
		build(0,N,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,N);
}

int Query(int L, int R)
{
	return ds.query(L,R);
}
# Verdict Execution time Memory Grader output
1 Correct 122 ms 2384 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
2 Runtime error 116 ms 4772 KB Execution killed with signal 11
3 Incorrect 113 ms 2416 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 547426536.
4 Incorrect 428 ms 4400 KB Wrong Answer: Query(877, 959) - expected : 912310978, actual : 598262492.
5 Incorrect 429 ms 4392 KB Wrong Answer: Query(761, 790) - expected : 112945480, actual : 12677192.
6 Incorrect 414 ms 4408 KB Wrong Answer: Query(653, 654) - expected : 227441904, actual : 504581687.
7 Correct 434 ms 4476 KB Output is correct - number of calls to Secret by Init = 7987, maximum number of calls to Secret by Query = 1
8 Correct 436 ms 4440 KB Output is correct - number of calls to Secret by Init = 7987, maximum number of calls to Secret by Query = 1
9 Correct 427 ms 4548 KB Output is correct - number of calls to Secret by Init = 7987, maximum number of calls to Secret by Query = 1
10 Correct 430 ms 4428 KB Output is correct - number of calls to Secret by Init = 7987, maximum number of calls to Secret by Query = 1