이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include <cassert>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <utility>
#include <algorithm>
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
int target[1<<18], bitcnt, N, startpos, cnt;
vector<int> a, X, Y;
vector<pii> perm;
vector<int> seq[19];
// Returns ID to new node created
int create(int l, int r) {
if (r < startpos) {
return -1;
}
if (l == r) {
return target[l];
}
int id = cnt++;
X.push_back(0);
Y.push_back(0);
int mid = (l + r) / 2;
int xv = create(l, mid);
int yv = create(mid+1, r);
X[id] = xv, Y[id] = yv;
return -(id+1);
}
void create_circuit(int M, std::vector<int> A) {
N = A.size() + 1; // N = N+1 :thonk:
a = vector<int>(A);
a.push_back(0);
std::vector<int> C(M + 1);
C[0] = -1;
for (int i = 1; i <= M; ++i) {
C[i] = -1;
}
bitcnt = 32 - __builtin_clz(N);
seq[0].push_back(0);
for (int i = 1; i <= bitcnt; i++) {
for (int x : seq[i-1]) {
seq[i].push_back(x);
seq[i].push_back(x + (1 << (i-1)));
}
}
startpos = (1 << bitcnt) - N;
for (int i = startpos; i < seq[bitcnt].size(); i++) {
perm.push_back({ seq[bitcnt][i], i });
}
assert(perm.size() == N);
sort(perm.begin(), perm.end());
for (int i = 0; i < N; i++) {
target[perm[i].se] = a[i];
}
create(0, (1 << bitcnt) - 1);
answer(C, X, Y);
}
컴파일 시 표준 에러 (stderr) 메시지
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:55:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
55 | for (int i = startpos; i < seq[bitcnt].size(); i++) {
| ~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
from doll.cpp:2:
doll.cpp:58:21: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
58 | assert(perm.size() == N);
| ~~~~~~~~~~~~^~~~
# | 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... |