Submission #88413

#TimeUsernameProblemLanguageResultExecution timeMemory
88413KoscheiTurnir (COCI17_turnir)C++17
100 / 100
359 ms28156 KiB
#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 timeMemoryGrader output
Fetching results...