# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
755548 | boris_mihov | 자동 인형 (IOI18_doll) | C++17 | 74 ms | 12480 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include <algorithm>
#include <iostream>
#include <cassert>
#include <numeric>
#include <vector>
typedef long long llong;
const int MAXN = 100000 + 10;
const int MAXS = 400000 + 10;
const int INF = 1e9;
int n, m, cnt;
std::vector <int> x, y, c;
std::vector <int> g[MAXN];
void rec(int l, int r, int node, int root)
{
if (r - l + 1 == 2)
{
x[root - 1] = g[node][l];
y[root - 1] = g[node][r];
return;
}
if (__builtin_popcount(r - l + 1) == 2 && ((r - l + 1) & 1))
{
x.push_back(0);
y.push_back(0);
x[root - 1] = -(++cnt);
y[root - 1] = g[node][r];
rec(l, r - 1, node, cnt);
return;
}
if (__builtin_popcount(r - l + 1) == 1)
{
x.push_back(0);
y.push_back(0);
x.push_back(0);
y.push_back(0);
x[root - 1] = cnt - 1;
y[root - 1] = cnt;
int mid = (l + r) / 2;
rec(l, mid, node, cnt - 1);
rec(mid + 1, r, node, cnt);
return;
}
int clz = __builtin_clz(r - l + 1);
assert((r - l + 1) & (1 << 32 - clz));
x.push_back(0);
y.push_back(0);
x.push_back(0);
y.push_back(0);
x[root - 1] = cnt - 1;
y[root - 1] = cnt;
rec(l, l + (1 << 32 - clz) - 1, node, cnt - 1);
rec(l + (1 << 32 - clz), r, node, cnt);
}
void create_circuit(int M, std::vector <int> A)
{
m = M; n = A.size();
for (int i = 1 ; i <= n ; ++i)
{
g[A[i - 1]].push_back(A[i]);
}
c.resize(m + 1); c[0] = A[0];
g[A[n]].push_back(0);
for (int i = 1 ; i <= m ; ++i)
{
if (g[i].empty())
{
continue;
}
if (g[i].size() == 1)
{
c[i] = g[i][0];
} else
{
c[i] = -(++cnt);
x.push_back(0);
y.push_back(0);
rec(0, g[i].size() - 1, i, cnt);
}
}
answer(c, x, y);
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |