# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
143027 | Azert | Turnir (COCI17_turnir) | C++14 | 383 ms | 21772 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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]);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |