이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "doll.h"
using namespace std;
const int MX = 4e5 + 1000;
int ptr = 0;
int x[MX], y[MX], c[MX];
//void answer(vector<int> c, vector<int> x, vector<int> y) {
// cout << 9 << ' ' << x.size() << endl;
// for(auto it: c) cout << it << ' '; cout << endl;
// for(auto it: x) cout << it << ' '; cout << endl;
// for(auto it: y) cout << it << ' '; cout << endl;
//}
int build(vector<int> v) {
if(v.size() == 1) return v[0];
// if(ptr != 0 and *max_element(v.begin(), v.end()) == *min_element(v.begin(), v.end()) and v[0] == -1) return v[0];
int d = --ptr;
vector<int> a, b;
for(int i = 0; i < v.size(); i ++) {
if(i & 1) b.push_back(v[i]);
else a.push_back(v[i]);
}
x[-d] = build(a);
y[-d] = build(b);
return d;
}
void create_circuit(int n, vector<int> v) {
vector<int> a(v.begin() + 1, v.end()); a.push_back(0);
int k = max(2, 1 << __lg(a.size() * 2 - 1));
vector<int> tmp(k), GG(k, 0);
int need = k - a.size();
for(int i = 0; i < need; i ++) tmp[i] = -1;
for(int i = 0; i < a.size(); i ++) tmp[i + need] = a[i];
for(auto it: tmp) cout << it << ' '; cout << endl;
//exit(0);
// for(int i = k / 2; i >= 1; i >>= 1) {
// for(int j = 0; j < k; j += i) {
// if(!GG[j] and need) {
// GG[j] = true, tmp[j] = -1, need --;
// }
// }
// }
// for(int i = k - 1; i >= 0; i --) {
// if(!GG[i]) tmp[i] = a.back(), a.pop_back();
// }
build(tmp); c[0] = v[0];
for(int i = 1; i <= n; i ++) c[i] = -1;
answer(
vector<int>(c, c + n + 1),
vector<int>(x + 1, x + 1 - ptr),
vector<int>(y + 1, y + 1 - ptr)
);
}
//main () {
// // create_circuit(4, {1, 2, 1, 3});
// create_circuit(9, {2, 9, 8, 1, 3, 7, 6, 4, 5});
//}
컴파일 시 표준 에러 (stderr) 메시지
doll.cpp: In function 'int build(std::vector<int>)':
doll.cpp:18:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | for(int i = 0; i < v.size(); i ++) {
| ~~^~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:32:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for(int i = 0; i < a.size(); i ++) tmp[i + need] = a[i];
| ~~^~~~~~~~~~
doll.cpp:33:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
33 | for(auto it: tmp) cout << it << ' '; cout << endl;
| ^~~
doll.cpp:33:39: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
33 | for(auto it: tmp) cout << it << ' '; cout << endl;
| ^~~~
# | 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... |