// we all are lost trying to be someone.
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_studio(0); cin.tie(0);
#define sz(x) int(x.size())
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pb push_back
#define ss second
#define ff first
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
const int MAX=1e6;
const int inf=1e9;
const int mod=1e9+7;
vector<ll> gfo[MAX];
bool vst[MAX];
void dfs(ll u){
vst[u]=true;
for(ll v:gfo[u]){
if(!vst[v]){
dfs(v);
}
}
}
void solve(){
ll n, m, u, v;
char x;
cin>>n>>m;
for(ll i=0; i<m; i++){
cin>>u>>v>>x;
gfo[u].pb(v);
gfo[v].pb(u);
}
dfs(1);
bool nice=true;
for(ll i=1; i<=n; i++){
if(!vst[i]){
nice=false;
break;
}
}
if(nice)cout<<n<<endl;
else cout<<0<<endl;
return;
}
int main(){
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
414 ms |
41552 KB |
Output is correct |
2 |
Correct |
12 ms |
23736 KB |
Output is correct |
3 |
Correct |
12 ms |
23764 KB |
Output is correct |
4 |
Correct |
11 ms |
23764 KB |
Output is correct |
5 |
Correct |
11 ms |
23764 KB |
Output is correct |
6 |
Correct |
103 ms |
30964 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
23764 KB |
Output is correct |
2 |
Correct |
11 ms |
23764 KB |
Output is correct |
3 |
Incorrect |
11 ms |
23764 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
23736 KB |
Output is correct |
2 |
Correct |
12 ms |
23764 KB |
Output is correct |
3 |
Incorrect |
11 ms |
23764 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
23736 KB |
Output is correct |
2 |
Correct |
12 ms |
23764 KB |
Output is correct |
3 |
Incorrect |
11 ms |
23764 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
414 ms |
41552 KB |
Output is correct |
2 |
Correct |
12 ms |
23736 KB |
Output is correct |
3 |
Correct |
12 ms |
23764 KB |
Output is correct |
4 |
Correct |
11 ms |
23764 KB |
Output is correct |
5 |
Incorrect |
11 ms |
23764 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |