답안 #147585

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
147585 2019-08-30T07:32:02 Z Ruxandra985 Turnir (COCI17_turnir) C++14
100 / 100
379 ms 18776 KB
#include <cstdio>
#include <algorithm>
#define DIM 1048580
using namespace std;
pair <int,int> v[DIM];
int ed[DIM],logg[DIM];
int main()
{
    //freopen ("a.in" , "r" , stdin);
    //freopen ("a.out" , "w" , stdout);
    int n,i,sol,j;
    scanf ("%d",&n);
    for (i=1;i<=(1<<n);i++){
        scanf ("%d",&v[i].first);
        v[i].second = i;
        if (i==1)
            logg[i] = 0;
        else logg[i] = logg[i/2]+1;
    }
    sort (v+1,v+(1<<n)+1);
    for (i=1;i<=(1<<n);i++){
        if (i == (1<<n) || v[i].first != v[i+1].first){
            /// solve
            /// sunt i-1 mai mici
            for ( j = i ; v[j].first == v[i].first && j ; j--)
                ed[v[j].second] = n - logg[i];
        }
    }
    for (i=1;i<=(1<<n);i++)
        printf ("%d ",ed[i]);
    return 0;
}

Compilation message

turnir.cpp: In function 'int main()':
turnir.cpp:11:13: warning: unused variable 'sol' [-Wunused-variable]
     int n,i,sol,j;
             ^~~
turnir.cpp:12:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d",&n);
     ~~~~~~^~~~~~~~~
turnir.cpp:14:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf ("%d",&v[i].first);
         ~~~~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 13 ms 888 KB Output is correct
6 Correct 24 ms 1528 KB Output is correct
7 Correct 46 ms 2552 KB Output is correct
8 Correct 90 ms 4984 KB Output is correct
9 Correct 185 ms 9720 KB Output is correct
10 Correct 379 ms 18776 KB Output is correct