이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include<bits/stdc++.h>
using namespace std;
vector<int> x, y, a, flg;
int h, v, n;
const int undef = 7e6+5;
int cn = 0;
int cnt = 0;
void fin(int x, int p, int am, int val, bool ok){
if(!am){
cnt--;
if(ok){
Y[p] = -1;
}
else X[p] = -1;
fin(0,0,n,v,0);
return;
}
if(!val){
cnt--;
if(ok){
Y[p] = A[cn++];
}
else X[p] = A[cn++];
fin(0,0,n,v,0);
return;
}
if(X.size() < x){
X.push_back(UNDEF);
Y.push_back(UNDEF);
FLG.push_back(0);
X.back() = ++cnt;
fin(cnt,x,max(0,am-val),val>>1,0);
return;
}
FLG[x]^=1;
if(FLG[x]){
if(Y[x] == UNDEF){
Y.back() = ++cnt;
fin(cnt,x,min(am,val),val>>1,1);
}
else{
fin(-Y[x]-1,x,min(am,val),val>>1,1);
}
return;
}
else{
fin(-X[x]-1,x,max(0,am-val),val>>1,0);
}
}
void create_circuit(int m, vector<int> _A) {
_A.push_back(0);
n = A.size();
A = _A;
vector<int> C(m+1,-1);
h = ceil(log2(n));
v = (1<<(h-1));
fin(0,0,n,v,0);
answer(C, X, Y);
}
컴파일 시 표준 에러 (stderr) 메시지
doll.cpp: In function 'void fin(int, int, int, int, bool)':
doll.cpp:18:4: error: 'Y' was not declared in this scope
18 | Y[p] = -1;
| ^
doll.cpp:20:8: error: 'X' was not declared in this scope
20 | else X[p] = -1;
| ^
doll.cpp:27:4: error: 'Y' was not declared in this scope
27 | Y[p] = A[cn++];
| ^
doll.cpp:27:11: error: 'A' was not declared in this scope
27 | Y[p] = A[cn++];
| ^
doll.cpp:29:8: error: 'X' was not declared in this scope
29 | else X[p] = A[cn++];
| ^
doll.cpp:29:15: error: 'A' was not declared in this scope
29 | else X[p] = A[cn++];
| ^
doll.cpp:33:5: error: 'X' was not declared in this scope
33 | if(X.size() < x){
| ^
doll.cpp:34:15: error: 'UNDEF' was not declared in this scope
34 | X.push_back(UNDEF);
| ^~~~~
doll.cpp:35:3: error: 'Y' was not declared in this scope
35 | Y.push_back(UNDEF);
| ^
doll.cpp:36:3: error: 'FLG' was not declared in this scope
36 | FLG.push_back(0);
| ^~~
doll.cpp:41:2: error: 'FLG' was not declared in this scope
41 | FLG[x]^=1;
| ^~~
doll.cpp:43:6: error: 'Y' was not declared in this scope
43 | if(Y[x] == UNDEF){
| ^
doll.cpp:43:14: error: 'UNDEF' was not declared in this scope
43 | if(Y[x] == UNDEF){
| ^~~~~
doll.cpp:53:8: error: 'X' was not declared in this scope
53 | fin(-X[x]-1,x,max(0,am-val),val>>1,0);
| ^
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:59:6: error: 'A' was not declared in this scope
59 | n = A.size();
| ^
doll.cpp:65:12: error: 'X' was not declared in this scope
65 | answer(C, X, Y);
| ^
doll.cpp:65:15: error: 'Y' was not declared in this scope
65 | answer(C, X, Y);
| ^