Submission #167346

#TimeUsernameProblemLanguageResultExecution timeMemory
167346sansTurnir (COCI17_turnir)C++14
100 / 100
1789 ms38408 KiB
#include <cstdio>
#include <numeric>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

#define sp ' '
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy)
#define prn(XX) cout << XX << endl
#define prs(XX) cout << XX << " "

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;

const int MOD = 1e9 + 7;
const int INF = 2e9 + 13;
const int mINF = -2e9 - 13;
const double PI = 3.14159265358979;
const double EPS = 1e-9;

int main(int argc, char **argv){
    int n, N; vector<int> p, u, ps;
    scanf("%d", &n); N = 1 << n; p.resize(N); u.resize(n);
    for(auto &x: p) scanf("%d", &x); ps = p; sort(ps.begin(), ps.end());
    
    int NN = N; u[0] = 0;
    for(int i = 1; i < n; ++i){
        NN >>= 1;
        u[i] = u[i-1] + NN; 
    }

    map<int, int> ans;
    for(int i = 0; i < N; ++i){
        int x = ps.end() - upper_bound(ps.begin(), ps.end(), ps[i]);
        int l = (lower_bound(u.begin(), u.end(), x) - u.begin());
        ans[ps[i]] = l;
    }
    for(int i = 0; i < N; ++i) printf("%d ", ans[p[i]]);
    printf("\n");

    return 0;
}

//cikisir

Compilation message (stderr)

turnir.cpp: In function 'int main(int, char**)':
turnir.cpp:35:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for(auto &x: p) scanf("%d", &x); ps = p; sort(ps.begin(), ps.end());
     ^~~
turnir.cpp:35:38: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     for(auto &x: p) scanf("%d", &x); ps = p; sort(ps.begin(), ps.end());
                                      ^~
turnir.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n); N = 1 << n; p.resize(N); u.resize(n);
     ~~~~~^~~~~~~~~~
turnir.cpp:35:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(auto &x: p) scanf("%d", &x); ps = p; sort(ps.begin(), ps.end());
                     ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...