# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
594438 | daisy2 | Turnir (COCI17_turnir) | C++14 | 486 ms | 21580 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |