답안 #944050

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
944050 2024-03-12T07:34:30 Z artixkrishna Turnir (COCI17_turnir) C++14
100 / 100
430 ms 17592 KB
#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

turnir.cpp: In function 'int main()':
turnir.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
turnir.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     scanf("%d", &a[i]);
      |     ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 10 ms 1040 KB Output is correct
6 Correct 20 ms 1496 KB Output is correct
7 Correct 42 ms 2504 KB Output is correct
8 Correct 92 ms 6340 KB Output is correct
9 Correct 214 ms 10000 KB Output is correct
10 Correct 430 ms 17592 KB Output is correct