Task: | Building Teams |
Sender: | Niilo |
Submission time: | 2024-09-09 16:56:26 +0300 |
Language: | C++ (C++17) |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'void f(int, int)': input/code.cpp:17:22: error: cannot convert 'std::vector<int>' to 'int' in initialization 17 | for (int j : A) { | ^
Code
#include <bits/stdc++.h> using namespace std; vector<int> A[200'001]; int Z[200'001]; void f(int i, int z) { if (Z[i]) { if (Z[i] != z) { cout << "IMPOSSIBLE"; exit(0); } return; } Z[i] = z; z = z == 1 ? 2 : 1; for (int j : A) { f(j,z); } } int main() { int n, m; cin >> n >> m; for (int i = 0; i < m; ++i) { int a, b; cin >> a >> b; A[a].push_back(b); A[b].push_back(a); } for (int i = 0; i < n; ++i) { if (!Z[i]) f(i, 1); } for (int i = 0; i < n; ++i) { cout << (Z[i] ? "1 " : "2 "); } }