Submission #884414

# Submission time Handle Problem Language Result Execution time Memory
884414 2023-12-07T10:03:25 Z ElenaBM Turnir (COCI17_turnir) C++17
100 / 100
777 ms 14780 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin>> n;
    int pot = pow(2, n);
    vector<pair<int,int>>num(pot);
    for(int i = 0; i < pot; ++i){
        cin>> num[i].first;
        num[i].second = i;
    }
    sort(num.begin(), num.end());
    vector<int>ans(pot);
    for (int i = 0; i < pot; ++i){
        int lev = n, k = 1;
        bool cont = true;
        while(cont){
            int x = pow(2, k) -1;
            if(num[x].first > num[i].first){
                ans[num[i].second] = lev;
                cont = 0;
                break;
            }
            else{
                lev--;
                k++;
                if (lev == 0){
                    ans[num[i].second] = lev;
                    cont = 0;
                }
            }
        }
    }
    for (int i = 0; i < pot; ++i)cout<< ans[i] << ' ';
    cout<< '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 5 ms 348 KB Output is correct
5 Correct 19 ms 860 KB Output is correct
6 Correct 45 ms 1116 KB Output is correct
7 Correct 86 ms 2132 KB Output is correct
8 Correct 171 ms 4016 KB Output is correct
9 Correct 365 ms 7508 KB Output is correct
10 Correct 777 ms 14780 KB Output is correct