# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
143027 | Azert | Turnir (COCI17_turnir) | C++14 | 383 ms | 21772 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 1e5;
int n;
int Pow[22], res[N];
pair <int, int> a[N];
int main() {
Pow[0] = 1;
for (int i = 1; i <= 20; i++) Pow[i] = 2 * Pow[i - 1];
scanf("%d", &n);
int len = Pow[n];
for (int i = 1; i <= len; i++) scanf("%d", &a[i].first), a[i].second = i;
sort(a + 1, a + len + 1);
int Med = Pow[n], cnt = 0;
for (int i = len; i >= 1; i--) {
int newMed = (i < Med)? Med/2 : Med;
if (newMed != Med) cnt++;
if (a[i].first == a[i + 1].first) res[a[i].second] = res[a[i + 1].second];
else {
res[a[i].second] = cnt;
}
Med = newMed;
}
for (int i = 1; i <= len; i++) printf("%d ", res[i]);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |