# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1260679 | wedonttalkanymore | Turnir (COCI17_turnir) | C++20 | 269 ms | 49552 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// #define int long long
#define pii pair<ll, ll>
#define fi first
#define se second
const ll N = 2e5 + 5, inf = 1e9, mod = 1e9 + 7, block = 320, lim = 20;
int n;
int ans[1 << 20];
vector <int> fre[1 << 20];
vector <int> comp;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
if (fopen(".inp", "r")) {
freopen(".inp", "r", stdin);
freopen(".out", "w", stdout);
}
cin >> n;
int sz = 1 << n;
for (int i = 0; i < sz; i++) {
int x;
cin >> x;
fre[x].push_back(i);
comp.push_back(x);
}
sort(comp.begin(), comp.end());
comp.erase(unique(comp.begin(), comp.end()), comp.end());
// for (int i = 0; i < sz; i++) cout << a[i].fi << ' ';
// cout << '\n';
int t = 0;
for (int i = 0; i < comp.size(); i++) {
t += fre[comp[i]].size();
int l = 1, r = 32, res = 0;
while(l <= r) {
int mid = (l + r) / 2;
if ((1 << mid) <= t) {
res = mid;
l = mid + 1;
}
else r = mid - 1;
}
for (int x : fre[comp[i]]) {
ans[x] = n - res;
}
}
cout << '\n';
for (int i = 0; i < sz; i++) cout << ans[i] << ' ';
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |