# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
170583 | mdn2002 | Turnir (COCI17_turnir) | C++14 | 353 ms | 12664 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 MAXN = 1000010;
int n, k;
int ar[MAXN];
int sar[MAXN];
int main()
{
scanf("%d", &k);
n = 1 << k;
for (int i = 0; i < n; i++) {
scanf("%d", &ar[i]);
sar[i] = ar[i];
}
sort(sar, sar + n);
sar[n] = INT_MAX;
for (int i = 0; i < n; i++) {
int x = ar[i];
int lo = 0, hi = n;
while (lo < hi) {
int mid = lo + (hi - lo) / 2;
if (sar[mid] > x) {
hi = mid;
}
else {
lo = mid + 1;
}
}
int cur = lo - 1;
int ans = k;
while (cur) {
cur--;
ans--;
cur /= 2;
}
if (i) printf(" ");
printf("%d", ans);
}
puts("");
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |