# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
904324 | nguyen31hoang08minh2003 | Turnir (COCI17_turnir) | C++17 | 241 ms | 25888 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>
template<class A, class B>
bool maximize(A &a, const B& b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template<class A, class B>
bool minimize(A &a, const B& b) {
if (a > b) {
a = b;
return true;
}
return false;
}
using namespace std;
constexpr int MAX_N = 20;
int N, n;
vector<int> numbers, indices, floorLog2, result;
signed main() {
#ifdef LOCAL
freopen("input.INP", "r", stdin);
#endif // LOCAL
cin.tie(0) -> sync_with_stdio(0);
cout.tie(0);
cin >> N;
n = 1 << N;
numbers.resize(n);
result.resize(n);
indices.resize(n);
floorLog2.resize(n + 1);
for (int i = 2; i <= n; ++i)
floorLog2[i] = floorLog2[i >> 1] + 1;
for (int i = 0; i < n; ++i) {
cin >> numbers[i];
indices[i] = i;
}
sort(indices.begin(), indices.end(), [&](const int &l, const int &r) -> bool {
return numbers[l] < numbers[r];
});
for (int l = 0, r = 0, answer; r < n;) {
for (; r < n && numbers[indices[l]] == numbers[indices[r]]; ++r);
answer = N - floorLog2[r];
for (; l < r; ++l)
result[indices[l]] = answer;
}
for (int i = 0; i < n; ++i)
cout << result[i] << ' ';
cout << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |