#include <bits/stdc++.h>
using namespace std;
#include "doll.h"
void create_circuit(int M, std::vector<int> A) {
int N = A.size();
A.push_back(0);
std::vector<int> C(M + 1);
vector<int> nexts[M];
for (int i = 0; i < N; i++){
nexts[A[i]].push_back(A[i+1]);
}
int S = 0;
for (int i = 1; i <= M; i++){
if (nexts[i].size() == 1) continue;
if (nexts[i].size() == 2) S++;
//else S += 3;
}
C[0] = A[0];
std::vector<int> X(S), Y(S);
int curswitch = -1;
for (int i = 1; i <= M; ++i) {
if (nexts[i].size() == 1){
C[i] = nexts[i][0];
}
else if (nexts[i].size() == 2){
C[i] = curswitch;
int id = -1*(curswitch--) - 1;
X[id] = nexts[i][0];
Y[id] = nexts[i][1];
}
}
//for (auto x : C) printf("%d ",x); printf("\n");
//for (auto x : X) printf("%d ",x); printf("\n");
//for (auto x : Y) printf("%d ",x); printf("\n");
answer(C, X, Y);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |