# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
143027 | 2019-08-12T16:11:52 Z | Azert | Turnir (COCI17_turnir) | C++14 | 383 ms | 21772 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 348 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 504 KB | Output is correct |
5 | Correct | 13 ms | 1016 KB | Output is correct |
6 | Correct | 24 ms | 1656 KB | Output is correct |
7 | Correct | 47 ms | 2808 KB | Output is correct |
8 | Correct | 90 ms | 5240 KB | Output is correct |
9 | Correct | 186 ms | 10972 KB | Output is correct |
10 | Correct | 383 ms | 21772 KB | Output is correct |