#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
362 ms |
41636 KB |
Output is correct |
2 |
Correct |
10 ms |
23900 KB |
Output is correct |
3 |
Incorrect |
11 ms |
23900 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
11 ms |
23900 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
23900 KB |
Output is correct |
2 |
Incorrect |
11 ms |
23900 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
23900 KB |
Output is correct |
2 |
Incorrect |
11 ms |
23900 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
362 ms |
41636 KB |
Output is correct |
2 |
Correct |
10 ms |
23900 KB |
Output is correct |
3 |
Incorrect |
11 ms |
23900 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |