Submission #636414

# Submission time Handle Problem Language Result Execution time Memory
636414 2022-08-29T08:35:42 Z berr Turnir (COCI17_turnir) C++17
100 / 100
605 ms 42208 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin>>n;

//    n-(ondan küçük eleman sayısının logu +1)

    vector<int> a(1<<n), b(1<<n), val((1<<n)), ans((1<<n));

    for(int i=0; i<a.size(); i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }

    int l=0, k=2;
    for(int i=0; i<(1<<n); i++)
    {
  

        if(i+1==k)
        {
            k*=2;
            l++;
        }
              val[i]=l;
        //cout<<val[i]<<" ";
    }
    sort(b.begin(), b.end());

    for(int i=0; i<(1<<n); i++)
    {
        int pos=upper_bound(b.begin(), b.end(), a[i])-b.begin();
        pos--;
        ans[i]=n-val[pos];
    }

    for(auto i: ans) cout<<i<<" ";

}

Compilation message

turnir.cpp: In function 'int32_t main()':
turnir.cpp:13:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for(int i=0; i<a.size(); i++)
      |                  ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 596 KB Output is correct
5 Correct 11 ms 1484 KB Output is correct
6 Correct 24 ms 2892 KB Output is correct
7 Correct 46 ms 5328 KB Output is correct
8 Correct 103 ms 10200 KB Output is correct
9 Correct 235 ms 21216 KB Output is correct
10 Correct 605 ms 42208 KB Output is correct