이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "doll.h"
//#include "grader.cpp"
using namespace std;
const int maxn = (int)1e5 + 7;
int sz;
void solve4(int M, vector<int> A) {
int N = A.size();
vector<int> C(M + 1);
vector<int> X, Y;
C[0] = A[0];
int tmp = N - 1;
while (tmp > 0) {
sz++;
tmp >>= 1;
}
if (sz) C[1] = -1;
else C[1] = 0;
X.resize(sz);
Y.resize(sz);
tmp = N - 1;
for (int i = 1; i <= sz; i++) {
if ((tmp >> (sz - i)) & 1) {
X[i - 1] = A[0];
} else {
X[i - 1] = -1;
}
Y[i - 1] = ((i == sz) ? 0 : -(i + 1));
}
answer(C, X, Y);
}
void solve123(int M, vector<int> A) {
int N = A.size();
vector<int> C(M + 1);
vector<int> X, Y;
vector<int> vec[M + 1];
C[0] = A[0];
for (int i = 0; i < N; i++) {
vec[A[i]].push_back((i + 1 == N) ? 0 : A[i + 1]);
}
for (int i = 1; i <= M; i++) {
if (vec[i].size() == 1) {
C[i] = vec[i][0];
} else if (vec[i].size() == 2) {
C[i] = -(++sz);
X.push_back(vec[i][0]);
Y.push_back(vec[i][1]);
} else if (vec[i].size() == 3) {
C[i] = -(++sz);
X.push_back(-(++sz));
Y.push_back(-(++sz));
X.push_back(0);
X.push_back(0);
Y.push_back(0);
Y.push_back(0);
Y[sz - 1] = vec[i][2];
Y[sz - 2] = vec[i][1];
X[sz - 1] = vec[i][0];
X[sz - 2] = C[i];
} else if (vec[i].size() == 4) {
C[i] = -(++sz);
X.push_back(-(++sz));
Y.push_back(-(++sz));
X.push_back(0);
X.push_back(0);
Y.push_back(0);
Y.push_back(0);
Y[sz - 1] = vec[i][3];
Y[sz - 2] = vec[i][2];
X[sz - 1] = vec[i][1];
X[sz - 2] = vec[i][0];
}
}
answer(C, X, Y);
}
void create_circuit(int M, vector<int> A) {
if (M == 1) {
solve4(M, A);
} else {
solve123(M, A);
}
}
# | 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... |