This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
vector <long long> adjlist[1000001];
bool visited [1000001];
void dfs(long long cur){
for(const long long&e:adjlist[cur]){
if(!visited[e]){
visited[e]=1;
dfs(e);
}
}
}
int main() {
long long n,e,a,b,s=0;
cin>>n>>e;
char mmmm;
for(long long i=0;i<e;i++){
cin>>a>>b>>mmmm;
adjlist[a].push_back(b);
adjlist[b].push_back(a);
}
for(long long i=0;i<n;i++){
if(!visited[i]){
dfs(i);
s++;
}
}
if (s == 1) cout << n;
else cout << 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |