Submission #884399

# Submission time Handle Problem Language Result Execution time Memory
884399 2023-12-07T09:37:16 Z gutzzy Turnir (COCI17_turnir) C++14
100 / 100
415 ms 14780 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> nums(pow(2,n));
    for(int i=0;i<pow(2,n);i++){
        int val;
        cin >> val;
        nums[i] = {val,i};
    }
    sort(nums.begin(),nums.end());
    
    vector<int> ans(pow(2,n));
    
    for(int i=pow(2,n);i>=0;i--){
        if(i!=pow(2,n)-1 and nums[i+1].first==nums[i].first){
            int pos = nums[i].second;
            ans[pos] = ans[nums[i+1].second];
        }
        else{
            int pos = nums[i].second;
            ans[pos] = n - floor(log2(i+1));
        }
    }
    
    for(auto a:ans) cout << a << " ";
    cout << endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 11 ms 860 KB Output is correct
6 Correct 26 ms 1216 KB Output is correct
7 Correct 49 ms 2492 KB Output is correct
8 Correct 90 ms 3876 KB Output is correct
9 Correct 200 ms 7604 KB Output is correct
10 Correct 415 ms 14780 KB Output is correct