답안 #709850

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
709850 2023-03-14T17:00:04 Z mars4 비밀 (JOI14_secret) C++17
6 / 100
461 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 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)
		{
			if(i==N-1)
			{
				st[i][level]=a[i];
			}
			else 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]);
			}
			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));
		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);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 136 ms 2364 KB Output is correct - number of calls to Secret by Init = 5371, maximum number of calls to Secret by Query = 1
2 Correct 122 ms 2324 KB Output is correct - number of calls to Secret by Init = 5379, maximum number of calls to Secret by Query = 1
3 Partially correct 125 ms 2360 KB Output isn't correct - number of calls to Secret by Init = 8194, maximum number of calls to Secret by Query = 1
4 Partially correct 459 ms 4380 KB Output isn't correct - number of calls to Secret by Init = 12088, maximum number of calls to Secret by Query = 1
5 Partially correct 433 ms 4356 KB Output isn't correct - number of calls to Secret by Init = 12097, maximum number of calls to Secret by Query = 1
6 Partially correct 461 ms 4328 KB Output isn't correct - number of calls to Secret by Init = 12097, maximum number of calls to Secret by Query = 1
7 Partially correct 433 ms 4364 KB Output isn't correct - number of calls to Secret by Init = 12097, maximum number of calls to Secret by Query = 1
8 Partially correct 444 ms 4432 KB Output isn't correct - number of calls to Secret by Init = 12097, maximum number of calls to Secret by Query = 1
9 Partially correct 451 ms 4332 KB Output isn't correct - number of calls to Secret by Init = 12097, maximum number of calls to Secret by Query = 1
10 Partially correct 439 ms 4320 KB Output isn't correct - number of calls to Secret by Init = 12097, maximum number of calls to Secret by Query = 1