이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include <array>
#include <cmath>
using namespace std;
void create_circuit(int m, std::vector<int> a)
{
vector<int> c(m + 1, -1);
c[0] = a.front();
a.erase(a.begin());
a.push_back(0);
int n = a.size(), p = 1;
while (p < n) p *= 2;
int delta = p - n, ind = 0;
vector<array<int, 2>> adj{{0, 0}};
auto dfs = [&delta, &adj, &ind](auto self, int h) -> int
{
if (h == -1) return 0;
++ind;
int v = ind;
adj.push_back({0, 0});
if (delta & (1 << h))
{
delta ^= 1 << h;
adj[v][0] = -1;
}
else adj[v][0] = -self(self, h - 1);
adj[v][1] = -self(self, h - 1);
return v;
};
dfs(dfs, round(log2(p)) - 1);
vector<bool> state(adj.size());
for (int i : a)
{
auto dfs = [i, &adj, &state](auto self, int v) -> void
{
state[v] = !state[v];
if (adj[v][!state[v]] == 0)
{
adj[v][!state[v]] = i;
return;
}
self(self, -adj[v][!state[v]]);
};
dfs(dfs, 1);
}
vector<int> x((int)adj.size() - 1), y((int)adj.size() - 1);
for (int i = 1; i < adj.size(); ++i)
{
x[i - 1] = adj[i][0];
y[i - 1] = adj[i][1];
}
answer(c, x, y);
}
컴파일 시 표준 에러 (stderr) 메시지
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:49:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | for (int i = 1; i < adj.size(); ++i)
| ~~^~~~~~~~~~~~
# | 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... |