이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
void create_circuit(int M, vi A)
{
int N = A.size(), S = 0;
A.push_back(0);
vi C(M + 1), X(S), Y(S);
auto addSwitch = [&S, &X, &Y](int x, int y)
{
S++;
X.push_back(x);
Y.push_back(y);
return -S;
};
vvi toMap(M + 1, vi());
toMap[0].push_back(A[0]);
for (int i = 0; i < N; i++)
toMap[A[i]].push_back(A[i + 1]);
for (int trg = 0; trg <= M; trg++)
{
vi &endpoints = toMap[trg];
if (endpoints.size() == 1)
C[trg] = endpoints[0];
if (endpoints.size() == 2)
C[trg] = addSwitch(endpoints[0], endpoints[1]);
if (endpoints.size() == 3)
{
// 0 back 1 2
int bottom1 = addSwitch(endpoints[0], -(S + 1));
int bottom2 = addSwitch(endpoints[1], endpoints[2]);
C[trg] = addSwitch(bottom1, bottom2);
}
if (endpoints.size() == 4)
{
// 0 2 1 3
int bottom1 = addSwitch(endpoints[0], endpoints[2]);
int bottom2 = addSwitch(endpoints[1], endpoints[3]);
C[trg] = addSwitch(bottom1, bottom2);
}
}
answer(C, X, Y);
}
# | 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... |