이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "swaps.h"
#ifdef MINA
#include "grader.cpp"
#endif
using namespace std;
typedef int64_t ll;
vector<array<int, 2>> ops[50];
int sz, n;
int bitonic(int l, int r, bool inc, int lvl) {
if (l == r) {
return lvl;
}
int md = (l + r) >> 1, mx;
mx = bitonic(l, md, inc, lvl);
bitonic(md + 1, r, !inc, lvl);
assert(mx + 1 < 50);
for (int i = l; i <= md; i++) {
int x = i, y = i + md + 1 - l;
if (!inc) {
ops[mx + 1].push_back({x, y});
} else {
ops[mx + 1].push_back({y, x});
}
}
bitonic(l, md, inc, mx + 1);
return bitonic(md + 1, r, inc, mx + 1);
}
void solve(int N, int v) {
n = N;
if (n == 1) {
answer({1});
return;
}
sz = 1 << (__lg(n - 1) + 1);
vector<int> a(sz);
for (int i = 0; i < sz; i++) {
a[i] = i + 1;
}
int dep = bitonic(0, sz - 1, 1, -1);
assert(dep < v);
for (int j = 0; j < 50; j++) {
if (ops[j].empty()) continue;
for (auto [x, y] : ops[j]) {
if (a[x] <= n && a[y] <= n) {
schedule(a[x], a[y]);
}
}
vector<int> ret = visit();
int cnt = 0;
for (auto [x, y] : ops[j]) {
if (a[x] > n) {
continue;
}
if (a[y] > n) {
swap(a[x], a[y]);
continue;
}
if (ret[cnt]) {
swap(a[x], a[y]);
}
cnt++;
}
}
while (a.size() > n) a.pop_back();
answer(a);
}
컴파일 시 표준 에러 (stderr) 메시지
swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:66:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
66 | while (a.size() > n) a.pop_back();
| ~~~~~~~~~^~~
# | 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... |
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |