제출 #646267

#제출 시각아이디문제언어결과실행 시간메모리
646267inksamuraiDojave (COCI17_dojave)C++17
28 / 140
195 ms44388 KiB
#include <bits/stdc++.h> using namespace std; #define int ll #define rep(i,n) for(int i=0;i<n;i++) #define per(i,n) for(int i=n-1;i>=0;i--) #define rng(i,c,n) for(int i=c;i<n;i++) #define pb push_back #define sz(a) (int)a.size() #define vec(...) vector<__VA_ARGS__> #define _3dSgv16 ios::sync_with_stdio(0),cin.tie(0) typedef long long ll; using vi=vector<int>; void print(){cout<<'\n';} template<class h,class...t> void print(const h&v,const t&...u){cout<<v<<' ',print(u...);} // e signed main(){ _3dSgv16; int ln; cin>>ln; const int n=1<<ln; vi a(n); rep(i,n){ cin>>a[i]; } vi ps; rep(i,n){ ps.pb((!sz(ps)?0:ps.back())^a[i]); } vi ids(n); rep(i,n){ ids[a[i]]=i; } vi rbe(n); rep(i,n){ rbe[i]=ids[(n-1)^a[i]]; } int ans=n*(n+1)/2; const int m=4; rep(d,m){ priority_queue<int> pq; int r=-1; for(int i=d;i<n;i+=m){ if(i>=r){ ans-=sz(pq); } // cut on i-th position pq.push(i); for(int j=i+1;j<=min(n-1,i+m);j++){ r=max(r,rbe[j]); while(sz(pq) and rbe[j]<=pq.top()){ pq.pop(); } } } } // rep(i,n){ // cout<<rbe[i]<<" "; // } // print(); int ma=-1; rep(i,n){ ma=max(ma,rbe[i]); if(i%4==3){ if(ma<=i){ // cout<<i<<" "; ans-=1; } } } print(ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...