Submission #143027

#TimeUsernameProblemLanguageResultExecution timeMemory
143027AzertTurnir (COCI17_turnir)C++14
100 / 100
383 ms21772 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 1e5; int n; int Pow[22], res[N]; pair <int, int> a[N]; int main() { Pow[0] = 1; for (int i = 1; i <= 20; i++) Pow[i] = 2 * Pow[i - 1]; scanf("%d", &n); int len = Pow[n]; for (int i = 1; i <= len; i++) scanf("%d", &a[i].first), a[i].second = i; sort(a + 1, a + len + 1); int Med = Pow[n], cnt = 0; for (int i = len; i >= 1; i--) { int newMed = (i < Med)? Med/2 : Med; if (newMed != Med) cnt++; if (a[i].first == a[i + 1].first) res[a[i].second] = res[a[i + 1].second]; else { res[a[i].second] = cnt; } Med = newMed; } for (int i = 1; i <= len; i++) printf("%d ", res[i]); }

Compilation message (stderr)

turnir.cpp: In function 'int main()':
turnir.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
turnir.cpp:15:60: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 1; i <= len; i++) scanf("%d", &a[i].first), a[i].second = i;
                                    ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...