답안 #884445

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
884445 2023-12-07T11:18:33 Z lalig777 Turnir (COCI17_turnir) C++14
100 / 100
381 ms 14784 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

int main(){
	int n;
	cin>>n;
	int ntotal=1;
	for (int i=0; i<n; i++) ntotal*=2;
	vector<pair<int,int> >nums(ntotal);
    vector<int>nivel(ntotal);
	for (int i=0; i<ntotal; i++){
		cin>>nums[i].first;
		nums[i].second=i;
	}sort(nums.begin(), nums.end());
	int xact=1, xant=0;
	for (int i=0; i<=n; i++){
		for (int j=xant; j<min(xact, ntotal); j++) nivel[nums[j].second]=i;
		xant=xact;
        xact=(xact+1)*2-1;
	}for (int i=ntotal-2; i>=0; i--){
		if (nums[i].first==nums[i+1].first) nivel[nums[i].second]=nivel[nums[i+1].second];
	}for (int i=0; i<ntotal; i++) cout<<n-nivel[i]<<" ";
	cout<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 10 ms 860 KB Output is correct
6 Correct 22 ms 1276 KB Output is correct
7 Correct 47 ms 2220 KB Output is correct
8 Correct 85 ms 3920 KB Output is correct
9 Correct 186 ms 7604 KB Output is correct
10 Correct 381 ms 14784 KB Output is correct