# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
147585 | Ruxandra985 | Turnir (COCI17_turnir) | C++14 | 379 ms | 18776 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |