이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
#include "doll.h"
using namespace std;
const int maxn = 5e5 + 10;
vector <int> g[maxn];
int l[maxn], r[maxn];
bool leaf[maxn];
int to[maxn];
int node = 0;
int create(int b, int e, vector <int> &order) {
int cur = ++node;
if(b == e) {
leaf[cur] = true;
order.push_back(cur);
order.push_back(cur);
return cur;
}
int mid = (b + e) >> 1;
vector <int> left, right;
l[cur] = create(b, mid, left);
r[cur] = create(mid + 1, e, right);
for(int i = 0; i < left.size(); i++) {
order.push_back(left[i]);
order.push_back(right[i]);
}
return cur;
}
void getEdges(int root, vector <int> v) {
if(v.empty()) return ;
int sz = 1;
while(sz * 2 < v.size()) sz *= 2;
vector <int> order;
to[root] = -create(1, sz, order);
set <int> cont;
int pt = 0;
for(int i = 0; i < order.size(); i++) {
if(cont.count(order[i])) {
if(i >= order.size() - v.size()) {
r[order[i]] = v[pt++];
} else {
r[order[i]] = to[root];
}
} else {
if(i >= order.size() - v.size()) {
l[order[i]] = v[pt++];
} else {
l[order[i]] = to[root];
}
}
cont.insert(order[i]);
}
}
void create_circuit(int M, std::vector<int> A) {
int N = A.size();
A.insert(A.end(), 0);
getEdges(0, A);
vector <int> C(M + 1);
vector <int> X (node), Y (node);
for(int i = 0; i <= M; i++) {
C[i] = to[0];
}
for(int i = 1; i <= node; i++) {
if(leaf[i]) {
X[i - 1] = l[i];
Y[i - 1] = r[i];
} else {
X[i - 1] = -l[i];
Y[i - 1] = -r[i];
}
}
answer(C, X, Y);
}
컴파일 시 표준 에러 (stderr) 메시지
doll.cpp: In function 'int create(int, int, std::vector<int>&)':
doll.cpp:23:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | for(int i = 0; i < left.size(); i++) {
| ~~^~~~~~~~~~~~~
doll.cpp: In function 'void getEdges(int, std::vector<int>)':
doll.cpp:32:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | while(sz * 2 < v.size()) sz *= 2;
| ~~~~~~~^~~~~~~~~~
doll.cpp:37:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | for(int i = 0; i < order.size(); i++) {
| ~~^~~~~~~~~~~~~~
doll.cpp:39:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | if(i >= order.size() - v.size()) {
| ~~^~~~~~~~~~~~~~~~~~~~~~~~~~
doll.cpp:45:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | if(i >= order.size() - v.size()) {
| ~~^~~~~~~~~~~~~~~~~~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:56:7: warning: unused variable 'N' [-Wunused-variable]
56 | int N = A.size();
| ^
# | 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... |