# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
88413 | Koschei | Turnir (COCI17_turnir) | C++17 | 359 ms | 28156 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 <iostream>
#include <vector>
#include <cmath>
#include <utility>
#include <algorithm>
using namespace std;
const int MAXN = 20;
int n, c = 1, a, l, h = -1;
int out[(1 << MAXN)+1];
vector< pair<int, int> > br;
int main()
{
ios_base::sync_with_stdio(false);
cin >> n;
for (int i = 0; i < (1 << n); i++)
{
cin >> a;
br.push_back(make_pair(a, i));
}
sort(br.begin(), br.end());
for (int i = 0; i < (1 << n); i++)
{
if (i)
{
if (br[i].first == h) c++;
else
{
l = floor(log2(i));
for (int j = i-1; j >= i-c; j--) out[br[j].second] = l;
c = 1;
}
}
h = br[i].first;
}
for (int j = (1 << n)-1; j >= (1 << n)-c; j--) out[br[j].second] = n;
for (int i = 0; i < (1 << n); i++) cout << n - out[i] << ' ';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |