이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> x, y, c;
vector<bool> state;
int n, k, e, nodes = 1;
void create_tree(int node, int sz)
{
if(sz == 2)
{
if(e & 1)
{
x[node] = 1;
y[node] = 0;
}
else x[node] = y[node] = 0;
return;
}
if(e & (sz/2))
x[node] = 1;
else
{
x[node] = ++nodes;
create_tree(nodes, sz/2);
}
y[node] = ++nodes;
create_tree(nodes, sz/2);
}
void place(int number, int node = 1)
{
if(state[node] == 0)
{
state[node] = 1;
if(x[node] == 0)
{
x[node] = number;
return;
}
else place(number, x[node]);
}
else
{
state[node] = 0;
if(y[node] == 0)
{
y[node] = number;
return;
}
else place(number, y[node]);
}
}
void create_circuit(int M, vector<int> A)
{
n = A.size();
c.resize(M+1);
x.resize(10*n);
y.resize(10*n);
state.resize(10*n);
for(k=1; (1<<k) < n; ++k);
e = (1<<k) - n;
create_tree(1, (1<<k));
int i;
for(i=1; i<n; ++i)
place(-A[i]);
place(0);
for(i=1; i<=nodes; ++i)
x[i] = -x[i], y[i] = -y[i];
c[0] = A[0];
for(i=1; i<=M; ++i)
c[i] = -1;
x.erase(x.begin());
y.erase(y.begin());
while(x.size() > nodes) x.pop_back();
while(y.size() > nodes) y.pop_back();
answer(c, x, y);
}
컴파일 시 표준 에러 (stderr) 메시지
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:96:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
96 | while(x.size() > nodes) x.pop_back();
| ~~~~~~~~~^~~~~~~
doll.cpp:97:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
97 | while(y.size() > nodes) y.pop_back();
| ~~~~~~~~~^~~~~~~
# | 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... |