답안 #88413

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
88413 2018-12-05T18:03:12 Z Koschei Turnir (COCI17_turnir) C++17
100 / 100
359 ms 28156 KB
#include <iostream>
#include <vector>
#include <cmath>
#include <utility>
#include <algorithm>

using namespace std;

const int MAXN = 20;

int n, c = 1, a, l, h = -1;
int out[(1 << MAXN)+1];
vector< pair<int, int> > br;

int main()
{
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < (1 << n); i++)
	{
		cin >> a;
		br.push_back(make_pair(a, i));
	}
	sort(br.begin(), br.end());
	for (int i = 0; i < (1 << n); i++)
	{
		if (i)
		{
			if (br[i].first == h) c++;
			else
			{
				l = floor(log2(i));
				for (int j = i-1; j >= i-c; j--) out[br[j].second] = l;
				c = 1;
			}
		} 
		h = br[i].first;
	}
	for (int j = (1 << n)-1; j >= (1 << n)-c; j--) out[br[j].second] = n;
	for (int i = 0; i < (1 << n); i++) cout << n - out[i] << ' ';
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 4 ms 728 KB Output is correct
5 Correct 12 ms 1260 KB Output is correct
6 Correct 22 ms 2184 KB Output is correct
7 Correct 46 ms 3848 KB Output is correct
8 Correct 81 ms 6956 KB Output is correct
9 Correct 177 ms 14120 KB Output is correct
10 Correct 359 ms 28156 KB Output is correct