이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>
typedef long long llong;
const int MAXN = 400000 + 10;
const int INF = 1e9;
int n, m, cnt;
std::vector <int> a, c, x, y;
int build(int l, int r, int excess)
{
if (r < excess)
{
return -1;
}
if (l == r)
{
return 0;
}
int node = ++cnt;
x.push_back(0);
y.push_back(0);
int mid = l + r >> 1;
x[node - 1] = build(l, mid, excess);
y[node - 1] = build(mid + 1, r, excess);
return -node;
}
bool state[MAXN];
bool push(int node, int value)
{
if (state[node] ? (y[node - 1] == -1) : (x[node - 1] == -1))
{
state[node] ^= 1;
return false;
}
if (state[node] ? (y[node - 1] == 0) : (x[node - 1] == 0))
{
if (state[node]) y[node - 1] = value;
else x[node - 1] = value;
state[node] ^= 1;
return true;
}
if (state[node])
{
bool res = push(-y[node - 1], value);
state[node] ^= 1;
return res;
} else
{
bool res = push(-x[node - 1], value);
state[node] ^= 1;
return res;
}
}
void create_circuit(int M, std::vector <int> A)
{
a = A;
m = M;
a.push_back(0);
int bits = 0;
int n = a.size();
while ((1 << bits) < n)
{
bits++;
}
build(0, (1 << bits) - 1, (1 << bits) - n);
for (int i = 0 ; i < n ; ++i)
{
while (!push(1, a[i]));
}
std::vector <int> c(m + 1, -1);
answer(c, x, y);
}
컴파일 시 표준 에러 (stderr) 메시지
doll.cpp: In function 'int build(int, int, int)':
doll.cpp:30:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
30 | int mid = 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... |