답안 #856139

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
856139 2023-10-02T17:33:09 Z vjudge1 Turnir (COCI17_turnir) C++17
90 / 100
756 ms 65536 KB
#include <bits/stdc++.h>
using namespace std;
#define sp << " " << 
#define int long long
#define vi vector<int>
#define pb push_back
#define F(xxx,yyy) for (int xxx=1;xxx<=yyy;xxx++)
#define pii pair<int,int>
#define all(x) x.begin()+1,x.end()
const int N = 4e5+1;


void solve() {
	int n;
	cin >> n;
	int N = n;
	n = 1;
	F(i,N) n*=2;
	vi a(n+1);
	F(i,n) cin >> a[i];
	map<int32_t,int32_t> mp,mp2;
	F(i,n) mp[a[i]]++;
	vi bg(n+1);
	vector<pii> ps(n+1);
	F(i,n) ps[i] = {a[i],i};
	sort(ps.begin()+1,ps.end());
	F(i,n) mp2[ps[i].first]++,bg[ps[i].second] = i-mp2[ps[i].first]+mp[ps[i].first]-1;
	vi ans(n+1);
	F(i,n) {
		for (int j=0;j<=N;j++) {
			if (bg[i] >= (1<<j)-1) ans[i] = N-j;
		}
	}
	F(i,n) cout << ans[i] << " ";
	cout << endl;
}     	
                 
                 
                 
                 
                 
                 
                 
                 
                                
signed main() { 
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    //cin >> t; 
    while (t --> 0) solve();
}


# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 15 ms 2648 KB Output is correct
6 Correct 41 ms 7300 KB Output is correct
7 Correct 91 ms 11604 KB Output is correct
8 Correct 108 ms 12884 KB Output is correct
9 Correct 475 ms 54436 KB Output is correct
10 Runtime error 756 ms 65536 KB Execution killed with signal 9