이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
using namespace std;
vector<int> X, Y;
int uni = 20;
int Solve(int gd, int bd){
int id = X.size() + 1;
X.pb(0); Y.pb(0);
if(gd + bd == 2){
X[id - 1] = bd ? -1 : uni;
Y[id - 1] = gd ? uni : -1;
return -id;
}
if(gd == 0){
X[id - 1] = -1;
Y[id - 1] = -1;
return -id;
}
int n2 = (gd + bd) / 2;
if(gd <= bd){
X[id - 1] = Solve(0, n2);
Y[id - 1] = Solve(gd, n2 - gd);
} else {
X[id - 1] = Solve(n2 - bd, bd);
Y[id - 1] = Solve(n2, 0);
}
return -id;
}
void create_circuit(int m, vector<int> A) {
X.clear();
Y.clear();
A.pb(0);
// reverse(A.begin(), A.end());
int n = A.size();
int sz = n;
for(int i = 0; i < 30; i++){
if((1 << i) >= n){
sz = (1 << i);
break;
}
}
int rt = Solve(n, sz - n);
int S = X.size();
// cerr << "$ " << S << '\n';
// for(int i = 0; i < S; i++)
// cerr << X[i] << ' ' << Y[i] << '\n';
// cerr << "-----------\n";
vector<int> mk(S, 1);
for(int tri : A){
int nw = -1, nrm;
while(true){
// cerr << "! " << nw << '\n';
nrm = -(nw + 1);
int nx = mk[nrm] ? X[nrm] : Y[nrm];
assert(nx < 0 || nx == uni);
if(nx == uni){
(mk[nrm] ? X[nrm] : Y[nrm]) = tri;
mk[nrm] ^= 1;
break;
} else {
nw = nx;
}
mk[nrm] ^= 1;
}
}
vector<int> C(m + 1, -1);
// cerr << "$ " << S << '\n';
// for(int i = 0; i < S; i++)
// cerr << X[i] << ' ' << Y[i] << '\n';
// cerr << "-----------\n";
answer(C, X, Y);
}
컴파일 시 표준 에러 (stderr) 메시지
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:55:6: warning: unused variable 'rt' [-Wunused-variable]
55 | int rt = Solve(n, sz - 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... |