# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
740443 | danikoynov | 자동 인형 (IOI18_doll) | C++14 | 84 ms | 14944 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;
int n, m;
vector < int > g[maxn];
void create_circuit(int M, vector<int> A)
{
n = A.size();
m = M;
vector < int > c(m + 1);
g[0].push_back(A[0]);
for (int i = 1; i < A.size(); i ++)
{
g[A[i - 1]].push_back(A[i]);
}
g[A.back()].push_back(0);
vector < int > x, y;
for (int i = 0; i <= m; i ++)
{
if (g[i].size() == 0)
c[i] = 0;
else
if (g[i].size() == 1)
c[i] = g[i][0];
else
if (g[i].size() == 2)
{
x.push_back(g[i][0]);
y.push_back(g[i][1]);
int dev = x.size();
c[i] = -dev;
}
else
if (g[i].size() == 3)
{
int dev = x.size() + 1;
x.push_back(- (dev + 1));
y.push_back(- (dev + 2));
c[i] = - dev;
x.push_back(g[i][0]);
y.push_back(- dev);
x.push_back(g[i][1]);
y.push_back(g[i][2]);
}
else
{
int dev = x.size() + 1;
x.push_back(- (dev + 1));
y.push_back(- (dev + 2));
c[i] = -dev;
x.push_back(g[i][0]);
y.push_back(g[i][2]);
x.push_back(g[i][1]);
y.push_back(g[i][3]);
}
}
/**for (int i = 0; i <= m; i ++)
cout << c[i] << " ";
cout << endl;
for (int i = 0; i < x.size(); i ++)
cout << x[i] << " " << y[i] << endl;*/
answer(c, x, y);
}
Compilation message (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... |