# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1021708 | lHog | Monthly railway pass (LMIO18_menesinis_bilietas) | C++17 | 3053 ms | 26456 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;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> veci;
typedef vector<ll> vecll;
#define mp make_pair
#define fi first
#define se second
// debug needs a semicolon !!!
#define debug(x) cerr<<# x<<" is "<<x<<'\n'
#define vec vector
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n, m;
cin >> n >> m;
veci a[n];
for (int i=0; i<n; i++) {
int x;
cin >> x;
a[i].push_back(x);
char USELESS;
cin >> USELESS;
}
queue<int> tv;
tv.push(0);
bool visited[n]={1};
while (!tv.empty()) {
int x = tv.front();
tv.pop();
for (int i=0; i<a[x].size(); i++) {
if (!visited[a[x][i]]) {
tv.push(i);
}
}
}
for (int i=0; i<n; i++) {
if (!visited[i]) {
cout << 0;
return 0;
}
}
cout << 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... |