Submission #1162757

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
11627572025-03-06 17:53:23vj09743Mechanical Doll (IOI18_doll)C++20
Compilation error
0 ms0 KiB
//
// Created by Viraj Verma on 06/03/2025.
//
#include <iostream>
using namespace std;
int main() {
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;
for (int i = 0; i <= M; i++) {
vector<int> adjacents = adjacency_list[i];
if (adjacents.size() == 1) {
c[i] = adjacents[0];
}
else if (adjacents.size() == 2) {
c[i] = int(switch_namer);
switch_namer--;
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

doll.cpp: In function 'int main()':
doll.cpp:10:24: error: 'vector' was not declared in this scope
   10 |     unordered_map<int, vector<int>> adjacency_list(M);
      |                        ^~~~~~
doll.cpp:5:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    4 | #include <iostream>
  +++ |+#include <vector>
    5 | using namespace std;
doll.cpp:10:5: error: 'unordered_map' was not declared in this scope
   10 |     unordered_map<int, vector<int>> adjacency_list(M);
      |     ^~~~~~~~~~~~~
doll.cpp:5:1: note: 'std::unordered_map' is defined in header '<unordered_map>'; did you forget to '#include <unordered_map>'?
    4 | #include <iostream>
  +++ |+#include <unordered_map>
    5 | using namespace std;
doll.cpp:10:19: error: expected primary-expression before 'int'
   10 |     unordered_map<int, vector<int>> adjacency_list(M);
      |                   ^~~
doll.cpp:11:12: error: expected primary-expression before 'int'
   11 |     vector<int> c (M+1);
      |            ^~~
doll.cpp:12:12: error: expected primary-expression before 'int'
   12 |     vector<int> travel_guide;
      |            ^~~
doll.cpp:17:9: error: 'adjacency_list' was not declared in this scope
   17 |         adjacency_list[place].push_back(destination);
      |         ^~~~~~~~~~~~~~
doll.cpp:20:5: error: 'adjacency_list' was not declared in this scope
   20 |     adjacency_list[place].push_back(0);
      |     ^~~~~~~~~~~~~~
doll.cpp:23:16: error: expected primary-expression before 'int'
   23 |         vector<int> adjacents = adjacency_list[i];
      |                ^~~
doll.cpp:24:13: error: 'adjacents' was not declared in this scope
   24 |         if (adjacents.size() == 1) {
      |             ^~~~~~~~~
doll.cpp:25:13: error: 'c' was not declared in this scope
   25 |             c[i] = adjacents[0];
      |             ^
doll.cpp:28:13: error: 'c' was not declared in this scope
   28 |             c[i] = int(switch_namer);
      |             ^
doll.cpp:32:13: error: 'c' was not declared in this scope
   32 |             c[i] = 1;
      |             ^
doll.cpp:35:14: error: 'c' was not declared in this scope
   35 |     for_each(c.begin(), c.end(), [](int &i){cout<<i<<" ";});
      |              ^