답안 #499922

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
499922 2021-12-30T04:24:39 Z mars4 비밀 (JOI14_secret) C++17
0 / 100
454 ms 8784 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---------------------------------

ll n;
vector<vector<ll>> st;

void build(ll l,ll r,ll level,int A[])
{
	if(l==r)
	{
		st[level][l]=A[l];
		return;
	}
	ll mid=(l+r)/2;
	st[level][mid]=A[mid];
	forb(i,mid-1,l)
	{
		st[level][i]=Secret(A[i],st[level][i+1]);
	}
	st[level][mid+1]=A[mid+1];
	forn(i,mid+2,r+1)
	{
		st[level][i]=Secret(st[level][i-1],A[i]);
	}
	build(l,mid,level+1,A);
	build(mid+1,r,level+1,A);
}

void Init(int N,int A[])
{
	n=N;
	st=vector<vector<ll>>(64-__builtin_clzll(N),vector<ll>(N));
	build(0,N-1,0,A);
}

int Query(int L,int R)
{
	ll l=0,r=n-1;
	ll level=0;
	while(l<=r)
	{
		ll mid=(l+r)/2;
		if(L<=mid and R>=mid)
		{
			if(R==mid)
			{
				return st[level][L];
			}
			return Secret(st[level][L],st[level][R]);
		}
		else if(R<mid)
		{
			r=mid;
		}
		else
		{
			l=mid+1;
		}
		level++;
	}
}

Compilation message

secret.cpp: In function 'int Query(int, int)':
secret.cpp:102:1: warning: control reaches end of non-void function [-Wreturn-type]
  102 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 112 ms 4708 KB Execution killed with signal 11
2 Correct 127 ms 2428 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Runtime error 117 ms 4780 KB Execution killed with signal 11
4 Runtime error 417 ms 8628 KB Execution killed with signal 11
5 Runtime error 450 ms 8756 KB Execution killed with signal 11
6 Runtime error 454 ms 8644 KB Execution killed with signal 11
7 Runtime error 432 ms 8648 KB Execution killed with signal 11
8 Runtime error 431 ms 8668 KB Execution killed with signal 11
9 Runtime error 444 ms 8784 KB Execution killed with signal 11
10 Runtime error 429 ms 8712 KB Execution killed with signal 11