답안 #87040

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
87040 2018-11-29T09:22:42 Z 7Polygonz Turnir (COCI17_turnir) C++11
100 / 100
638 ms 23900 KB
using namespace std ;
#include <bits/stdc++.h> /* #7th-Polygon */

const int N = 1 << 20 ;

int n , a[N] , b[N] ;

int GetBit(int mask)
{
    for (int i = n ; i >= 0 ; --i)
        if (mask & (1 << i))
            return n - i ;
    return n ;
}

int main()
{
    ios::sync_with_stdio(false) ;
    cout.tie(nullptr) ;
    cin.tie(nullptr) ;

    cin >> n ;
    for (int i = 0 ; i < (1 << n) ; ++i)
        cin >> a[i] ;

    memcpy(b , a , sizeof(b)) ;
    sort(b , b + (1 << n)) ;

    for (int i = 0 ; i < (1 << n) ; ++i)
        cout << GetBit(upper_bound(b , b + (1 << n) , a[i]) - b) << " " ;

    return 0 ;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4472 KB Output is correct
2 Correct 6 ms 4472 KB Output is correct
3 Correct 7 ms 4552 KB Output is correct
4 Correct 9 ms 4760 KB Output is correct
5 Correct 19 ms 5044 KB Output is correct
6 Correct 34 ms 5636 KB Output is correct
7 Correct 69 ms 6816 KB Output is correct
8 Correct 139 ms 8808 KB Output is correct
9 Correct 308 ms 13820 KB Output is correct
10 Correct 638 ms 23900 KB Output is correct