답안 #884398

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
884398 2023-12-07T09:36:36 Z gutzzy Turnir (COCI17_turnir) C++14
100 / 100
405 ms 21584 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));
    
    int iguals = 0;
    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 num = nums[i].first;
            int pos = nums[i].second;
            ans[pos] = n - floor(log2(i+1));
        }
    }
    
    for(auto a:ans) cout << a << " ";
    cout << endl;

    return 0;
}

Compilation message

turnir.cpp: In function 'int main()':
turnir.cpp:24:17: warning: unused variable 'num' [-Wunused-variable]
   24 |             int num = nums[i].first;
      |                 ^~~
turnir.cpp:17:9: warning: unused variable 'iguals' [-Wunused-variable]
   17 |     int iguals = 0;
      |         ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 440 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 14 ms 960 KB Output is correct
6 Correct 24 ms 1724 KB Output is correct
7 Correct 47 ms 2980 KB Output is correct
8 Correct 92 ms 5292 KB Output is correct
9 Correct 202 ms 11088 KB Output is correct
10 Correct 405 ms 21584 KB Output is correct