Submission #170583

#TimeUsernameProblemLanguageResultExecution timeMemory
170583mdn2002Turnir (COCI17_turnir)C++14
90 / 100
353 ms12664 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000010; int n, k; int ar[MAXN]; int sar[MAXN]; int main() { scanf("%d", &k); n = 1 << k; for (int i = 0; i < n; i++) { scanf("%d", &ar[i]); sar[i] = ar[i]; } sort(sar, sar + n); sar[n] = INT_MAX; for (int i = 0; i < n; i++) { int x = ar[i]; int lo = 0, hi = n; while (lo < hi) { int mid = lo + (hi - lo) / 2; if (sar[mid] > x) { hi = mid; } else { lo = mid + 1; } } int cur = lo - 1; int ans = k; while (cur) { cur--; ans--; cur /= 2; } if (i) printf(" "); printf("%d", ans); } puts(""); }

Compilation message (stderr)

turnir.cpp: In function 'int main()':
turnir.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &k);
  ~~~~~^~~~~~~~~~
turnir.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &ar[i]);
   ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...