# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
639616 | teesla | Monthly railway pass (LMIO18_menesinis_bilietas) | C++14 | 477 ms | 30668 KiB |
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;
const int maxn=5*1e5+10;
int n,m;
vector<int> adj[maxn];
int visitado[maxn];
void dfs(int x){
visitado[x]=1;
for(int i=0; i<adj[x].size(); i++){
int viz=adj[x][i];
if(visitado[viz]==1)continue;
dfs(viz);
}
return;
}
int main(){
cin >> n>> m;
for(int i=0; i<m; i++){
int a,b;
char c;
cin >> a >> b >> c;
adj[a].push_back(b);
adj[b].push_back(a);
}
dfs(1);
int res=n;
for(int i=1; i<=n; i++) if(visitado[i]==0) res=0;
cout << res<<endl;
return 0;
}
Compilation message (stderr)
# | 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... |