이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include<bits/stdc++.h>
using namespace std;
#define vec vector
#define int long long
#define map unordered_map
#define EMPTY 0
#define dbg(v) \
cout << "Line(" << __LINE__ << ") -> " << #v << " = " << (v) << endl;
void create_circuit(int32_t M, std::vector<int32_t> A) {
//cerr << "HELLO" << '\n';
int N = A.size();
map<int, int> X, Y;
int hb = -1;
for(int i = 0; i<32; i++) {
if(N & 1ll << i) hb = i;
}
assert(hb != -1);
std::vector<int32_t> C(M + 1, -hb-1);
int si = hb+2;
//dbg(hb);
auto tree = [&](int sz) {
for(int i = 1; i<sz/2; i++) {
X[i+si-1] = -(i*2 + si - 1);
Y[i+si-1] = -(i*2 + 1 + si -1);
}
si += sz-1;
};
for(int i = hb+1; i>=1; i--) {
if((1ll<<(i-1)) & N) {
if(i > 1) {
X[i] = -si;
tree(1ll << (i-1));
}
}
else {
X[i] = -hb-1;
}
Y[i] = -i + 1;
//cerr << X[i] << ' ';
}
//cerr << '\n';
vec<bool> state(N*3+10, false);
vec<int32_t> a = A;
a.push_back(1e9);
int i = 0;
int cur = 0;
int cnt = 0;
do {
cnt++;
//cerr << cur << '\n';
int nxt;
if(cur < 0) {
state[-cur] = !state[-cur];
if(state[-cur]) {
if(X.count(-cur) == 0) {
X[-cur] = a[i++];
}
nxt = X[-cur];
}
else {
if(Y.count(-cur) == 0) {
Y[-cur] = a[i++];
}
nxt = Y[-cur];
}
}
else {
nxt = C[cur];
}
//if(cnt > 15) break;
cur = nxt;
} while(cur != 0);
int S = si;
vec<int32_t> XA(si-1, 1e9);
vec<int32_t> YA(si-1, 1e9);
for(auto [i, val] : X) {
XA[i-1] = val;
}
for(auto [i, val] : Y) {
YA[i-1] = val;
}
answer(C, XA, YA);
}
컴파일 시 표준 에러 (stderr) 메시지
doll.cpp: In function 'void create_circuit(int32_t, std::vector<int>)':
doll.cpp:86:6: warning: unused variable 'S' [-Wunused-variable]
86 | int S = si;
| ^
# | 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... |