제출 #499925

#제출 시각아이디문제언어결과실행 시간메모리
499925mars4비밀 (JOI14_secret)C++17
100 / 100
459 ms4376 KiB
#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; ll mlevel; vector<vector<ll>> st; vector<ll> a; void build(ll l,ll r,ll level,int A[]) { if(l==r) { mlevel=level; 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; forn(i,0,n) { a.push_back(A[i]); } st=vector<vector<ll>>(65-__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++; } return a[l]; }
#Verdict Execution timeMemoryGrader output
Fetching results...