# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
944050 | artixkrishna | Turnir (COCI17_turnir) | C++14 | 430 ms | 17592 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 <string>
#include <vector>
#include <map>
#include <cstdlib>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long llint;
typedef pair <int, int> pii;
const int MAXN = 20;
int n;
int a[1 << MAXN];
int calc (int x) {
if (x == 0) return 0;
for (int i = n-1; i >= 0; --i) {
if ((1 << i) < x) x -= (1 << i);
else return n - i;
}
return n;
}
int main (void){
scanf("%d", &n);
vector <int> V;
for (int i = 0; i < (1 << n); ++i) {
scanf("%d", &a[i]);
V.push_back(a[i]);
}
sort(V.begin(), V.end());
for (int i = 0; i < (1 << n); ++i) {
printf("%d ", calc(V.end() - upper_bound(V.begin(), V.end(), a[i])));
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |