# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
88413 | Koschei | Turnir (COCI17_turnir) | C++17 | 359 ms | 28156 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |