| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 428638 | shenxy | Cheerleaders (info1cup20_cheerleaders) | C++11 | 1511 ms | 141148 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
long long inv[17], niv[17];
struct seg {
int s, v;
seg *l, *r;
seg(int _s) {
s = _s, v = 0;
if (s) {
l = new seg(s - 1);
r = new seg(s - 1);
}
}
void update(int i) {
if (s) {
if (i < (1 << (s - 1))) l -> update(i), inv[s - 1] += r -> v;
else r -> update(i - (1 << (s - 1))), niv[s - 1] += l -> v;
v = l -> v + r -> v;
} else ++v;
}
} *root;
int main() {
int N, h;
scanf("%d", &N);
if (N == 0) {
printf("0\n11");
return 0;
}
int a[1 << N];
long long ans[N];
vector<int> res[N];
fill_n(ans, N, 0);
for (int i = 0; i < (1 << N); ++i) scanf("%d", &h), a[h] = i;
for (int i = 0; i < N; ++i) {
for (int j = 0; j < i; ++j) res[i].push_back(2);
root = new seg(N);
fill_n(inv, N, 0);
fill_n(niv, N, 0);
for (int j = 0; j < (1 << N); ++j) root -> update(a[j]);
for (int j = 0; j < N; ++j) {
res[i].push_back(2);
if (inv[j] > niv[j]) res[i].push_back(1), ans[i] += niv[j];
else ans[i] += inv[j];
}
for (int j = 0; j < (1 << N); ++j) a[j] = (a[j] >> 1) + ((1 & a[j]) << (N - 1));
}
printf("%lld\n", *min_element(ans, ans + N));
for (int i: res[min_element(ans, ans + N) - ans]) printf("%d", i);
return 0;
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
