Submission #1021716

#TimeUsernameProblemLanguageResultExecution timeMemory
1021716lHogMonthly railway pass (LMIO18_menesinis_bilietas)C++17
0 / 100
292 ms41812 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...