# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1162761 | vj09743 | Mechanical Doll (IOI18_doll) | C++20 | 0 ms | 0 KiB |
//
// Created by Viraj Verma on 06/03/2025.
//
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
void create_circuit() {
int M;
int N;
cin>>M>>N;
unordered_map<int, vector<int>> adjacency_list(M);
vector<int> c (M+1);
vector<int> travel_guide;
int place = 0;
for (int i = 0; i<N; i++) {
int destination;
cin>>destination;
adjacency_list[place].push_back(destination);
place = destination;
}
adjacency_list[place].push_back(0);
int switch_namer = -1;
vector<int> X;
vector<int> Y;
for (int i = 0; i <= M; i++) {
vector<int> adjacents = adjacency_list[i];
if (adjacents.size() == 1) {
c[i] = adjacents[0];
}