Submission #75825

# Submission time Handle Problem Language Result Execution time Memory
75825 2018-09-11T08:29:53 Z charlies_moo Turnir (COCI17_turnir) C++
100 / 100
718 ms 28236 KB
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int n;
int ans[(1<<20)+5];

struct Node
{
	int num,idx;
}a[(1<<20)+5];

bool cmp(Node a,Node b)
{
	return a.num<b.num;
}

int main()
{
	cin>>n;
	int deep=n,from_=1,bound=2;
	n=1<<n;
	for(int i=1;i<=n;i++)
	{
		a[i].idx=i;
		cin>>a[i].num;
	}
	sort(a+1,a+n+1,cmp);
	for(int i=2;i<=n;i++)
	{
		if(a[from_].num!=a[i].num)
		{
			for(int j=from_;j<i;j++)
				ans[a[j].idx]=deep;
			from_=i;
		}
		if(i==bound)
		{
			deep--;
			bound*=2;
		}
	}
	for(int i=from_;i<=n;i++)
		ans[a[i].idx]=0;
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<' ';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 6 ms 688 KB Output is correct
5 Correct 20 ms 1260 KB Output is correct
6 Correct 41 ms 1996 KB Output is correct
7 Correct 77 ms 3892 KB Output is correct
8 Correct 140 ms 6744 KB Output is correct
9 Correct 339 ms 13888 KB Output is correct
10 Correct 718 ms 28236 KB Output is correct