# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
494021 | aurims | Monthly railway pass (LMIO18_menesinis_bilietas) | C++14 | 555 ms | 34240 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>
#define MAX 500000
#define pb push_back
using namespace std;
/*
input
6 4
1 2 T
2 3 T
2 4 T
5 6 T
*/
vector<int> adj[MAX];
bool aplankytas[MAX];
int sk = 0;
void dfs(int v)
{
if(aplankytas[v]) return;
aplankytas[v] = true;
sk++;
for( int kaimynas : adj[v] )
dfs(kaimynas);
}
bool jungus(int n)
{
for(int i = 1; i <= n; i++)
aplankytas[i] = false;
sk = 0;
dfs(1);
if(sk == n) return n;
else return 0;
}
int main()
{
int N, M;
cin >> N >> M;
int ans = 0;
for(int i = 0; i < M; i++)
{
int a, b;
char t;
cin >> a >> b >> t;
adj[a].pb(b);
if(a != b) adj[b].pb(a);
}
cout << jungus(N);
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... |