# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
219442 | IgorI | 자동 인형 (IOI18_doll) | C++17 | 156 ms | 15812 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <doll.h>
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
/*void answer(vector<int> c, vector<int> x, vector<int> y)
{
//cout << "final : " << c.size() << " " << x.size() << " " << y.size() << endl;
for (int i = 0; i < c.size(); i++) cout << c[i] << "\n";
for (int i = 0; i < x.size(); i++) cout << x[i] << " " << y[i] << "\n";
exit(0);
}*/
vector<int> c, x, y;
vector<int> bitreverse(int k)
{
vector<int> c;
for (int i = 0; i < (1 << k); i++)
{
int y = 0;
for (int j = 0; j < k; j++)
{
y = 2 * y + (((1 << j) & i) > 0);
}
c.push_back(y);
}
return c;
}
void build(int f, vector<int> v)
{
//cout << f << " -> ";
//for (int i = 0; i < v.size(); i++) cout << v[i] << " ";
//cout << endl;
if (v.size() == 1)
{
c[f] = v[0];
return;
}
for (int i = 1; i < 20; i++)
{
if (v.size() <= (1 << i))
{
vector<int> tree = {f};
while (tree.size() < (1 << i))
{
x.push_back(0);
y.push_back(0);
tree.push_back(-x.size());
}
while (tree.size() < 2 * (1 << i))
{
tree.push_back(tree[1]);
}
vector<int> reach = bitreverse(i);
int free = (1 << i) - v.size();
for (int j = 0; j < reach.size(); j++)
{
if (reach[j] >= free)
{
tree[(1 << i) + j] = v[reach[j] - free];
}
}
c[tree[0]] = tree[1];
for (int i = 1; 2 * i + 1 < tree.size(); i++)
{
x[-tree[i] - 1] = tree[2 * i];
y[-tree[i] - 1] = tree[2 * i + 1];
}
break;
}
}
}
void create_circuit(int m, vector<int> a)
{
c.resize(m + 1);
vector<vector<int> > go(m + 1);
a.push_back(0);
go[0].push_back(a[0]);
for (int i = 0; i + 1 < a.size(); i++)
{
go[a[i]].push_back(a[i + 1]);
}
for (int i = 0; i < m + 1; i++)
{
if (go[i].size() == 0) go[i] = {0};
}
for (int i = 0; i < m + 1; i++)
{
build(i, go[i]);
}
answer(c, x, y);
}
/*int main()
{
int m, n;
cin >> m >> n;
vector<int> a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
create_circuit(m, a);
}*/
컴파일 시 표준 에러 (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... |