이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
namespace solution {
vi c, x, y;
int s;
vector<bool> q;
int swicch(int l, int r) {
int p = l + r >> 1;
int i = s++;
x.push_back(0);
y.push_back(0);
q.push_back(false);
if(l + r == 2) {
if(l) x[i] = -1;
return -(i + 1);
}
if(l >= p) {
x[i] = -1;
y[i] = swicch(l - p, r);
return -(i + 1);
}
x[i] = swicch(l, r - p);
y[i] = swicch(0, p);
return -(i + 1);
}
void push(int i, int v) {
int &j = (q[i] ? y[i] : x[i]);
q[i] = !q[i];
if(!j) {j = v; return;}
push(-(j + 1), v);
}
}
void create_circuit (int m, vi a) {
using namespace solution;
int n = a.size();
s = 0;
x.clear(); x.reserve(n * 4);
y.clear(); y.reserve(n * 4);
q.clear(); q.reserve(n * 4);
if(n == 1) {
c.assign(m + 1, 0);
c[0] = a[0];
answer(c, x, y);
return;
}
c.assign(m + 1, -1);
c[0] = a[0];
int e = 0;
for(; __builtin_popcount(e + n) > 1; ++e);
swicch(e, n);
for(int i = 1; i < n; ++i) push(0, a[i]);
answer(c, x, y);
}
컴파일 시 표준 에러 (stderr) 메시지
doll.cpp: In function 'int solution::swicch(int, int)':
doll.cpp:13:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
13 | int p = l + r >> 1;
| ~~^~~
# | 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... |