Submission #594438

#TimeUsernameProblemLanguageResultExecution timeMemory
594438daisy2Turnir (COCI17_turnir)C++14
100 / 100
486 ms21580 KiB
#include<iostream> #include<algorithm> #include<stack> using namespace std; int n,r[1200000],p; pair<int,int> a[1200000]; stack<int> st; int main() { cin>>n; int po=1; for(int i=1;i<=n;i++) po*=2; for(int i=0;i<po;i++) { cin>>a[i].first; a[i].second=i; } sort(a,a+po); for(int i=0;i<po;i++) { if(i!=po-1 && a[i].first==a[i+1].first) {st.push(a[i].second);continue;} r[a[i].second]=n; p=2; while(p-1<=i) { r[a[i].second]--; p*=2; } while(!st.empty()) { r[st.top()]=r[a[i].second]; st.pop(); } } for(int i=0;i<po;i++) cout<<r[i]<<" "; cout<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...