# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
594438 | daisy2 | Turnir (COCI17_turnir) | C++14 | 486 ms | 21580 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |