hiho week 161 register

Ended

Participants:317

Verdict:Accepted
Score:100 / 100
Submitted:2017-08-01 23:09:05

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "iostream"
#include "vector"
using namespace std;
vector<int>v[502];
int t;
int n, m,a,b;
int visited[502];
void dfs(int enter) {
    if (visited[enter])return;
    visited[enter] = 1;
    for (int i = 0; i < v[enter].size(); i++) {
        dfs(v[enter][i]);
    }
}
int main()
{
    cin >> t;
    while (t--) {
        cin >> n >> m;
        int t;
        for(int i=0;i<m;i++) {
            cin >> a >> b;
            t = a;
            v[a].push_back(b);
            v[b].push_back(a);
        }
        dfs(t);
        bool ans = true;
        for (int i = 1; i <= n; i++) {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX