Submission #709846

# Submission time Handle Problem Language Result Execution time Memory
709846 2023-03-14T16:51:26 Z mars4 Secret (JOI14_secret) C++17
0 / 100
523 ms 4764 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;
		}
		if(l==r)
		{
			st[l][level]=a[l];
			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 144 ms 2480 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
2 Runtime error 152 ms 4764 KB Execution killed with signal 11
3 Incorrect 138 ms 2512 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 547426536.
4 Incorrect 485 ms 4388 KB Wrong Answer: Query(877, 959) - expected : 912310978, actual : 598262492.
5 Incorrect 474 ms 4348 KB Wrong Answer: Query(761, 790) - expected : 112945480, actual : 12677192.
6 Incorrect 496 ms 4352 KB Wrong Answer: Query(653, 654) - expected : 227441904, actual : 504581687.
7 Correct 523 ms 4400 KB Output is correct - number of calls to Secret by Init = 7987, maximum number of calls to Secret by Query = 1
8 Correct 493 ms 4392 KB Output is correct - number of calls to Secret by Init = 7987, maximum number of calls to Secret by Query = 1
9 Correct 475 ms 4436 KB Output is correct - number of calls to Secret by Init = 7987, maximum number of calls to Secret by Query = 1
10 Correct 468 ms 4368 KB Output is correct - number of calls to Secret by Init = 7987, maximum number of calls to Secret by Query = 1