The Accomodation of Students Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5225 Accepted Submission(s): 2374 Problem Description There are a group of students. Some of them may know each ot…
#include <cstring> #include <iostream> #include <algorithm> using namespace std; , M = ; int n, m; int h[N], e[M], ne[M], idx; int color[N]; void add(int a, int b) { e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ; } bool dfs(int u, int c) {…