# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
198451 | 2020-01-26T05:43:28 Z | oolimry | Monthly railway pass (LMIO18_menesinis_bilietas) | C++14 | 598 ms | 68972 KB |
#include <bits/stdc++.h> using namespace std; static int p[500005]; int numSets; int findSet(int u){ if(p[u] == u) return u; else{ p[u] = findSet(p[u]); return p[u]; } } void unionSet(int u, int v){ u = findSet(u); v = findSet(v); if(u == v) return; p[u] = v; numSets--; } typedef pair<int,int> ii; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; numSets = n; unordered_set<int> edges[n]; for(int i = 0;i < n;i++) p[i] = i; vector<ii> bus; for(int i = 0;i < m;i++){ int u, v; char c; cin >> u >> v >> c; u--; v--; if(c == 'T'){ unionSet(u,v); } else{ bus.push_back(ii(u,v)); } } for(ii e : bus){ int u = findSet(e.first); int v = findSet(e.second); if(u == v) continue; edges[u].insert(v); edges[v].insert(u); } int ans = 0; for(int i = 0;i < n;i++){ if(numSets - 1 == edges[findSet(i)].size()) ans++; } cout << ans << "\n"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 197 ms | 17916 KB | Output is correct |
2 | Correct | 6 ms | 376 KB | Output is correct |
3 | Correct | 5 ms | 376 KB | Output is correct |
4 | Correct | 27 ms | 27896 KB | Output is correct |
5 | Correct | 5 ms | 1016 KB | Output is correct |
6 | Correct | 45 ms | 760 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 27896 KB | Output is correct |
2 | Correct | 6 ms | 376 KB | Output is correct |
3 | Correct | 6 ms | 376 KB | Output is correct |
4 | Correct | 9 ms | 1144 KB | Output is correct |
5 | Correct | 5 ms | 1016 KB | Output is correct |
6 | Correct | 598 ms | 35812 KB | Output is correct |
7 | Correct | 521 ms | 68972 KB | Output is correct |
8 | Correct | 16 ms | 2808 KB | Output is correct |
9 | Correct | 24 ms | 4216 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 6 ms | 376 KB | Output is correct |
4 | Correct | 6 ms | 504 KB | Output is correct |
5 | Correct | 7 ms | 504 KB | Output is correct |
6 | Correct | 7 ms | 632 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Correct | 9 ms | 760 KB | Output is correct |
10 | Correct | 5 ms | 376 KB | Output is correct |
11 | Correct | 6 ms | 504 KB | Output is correct |
12 | Correct | 5 ms | 376 KB | Output is correct |
13 | Correct | 6 ms | 504 KB | Output is correct |
14 | Correct | 6 ms | 376 KB | Output is correct |
15 | Correct | 7 ms | 504 KB | Output is correct |
16 | Correct | 6 ms | 376 KB | Output is correct |
17 | Correct | 5 ms | 376 KB | Output is correct |
18 | Correct | 6 ms | 376 KB | Output is correct |
19 | Correct | 6 ms | 376 KB | Output is correct |
20 | Correct | 9 ms | 1144 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 6 ms | 376 KB | Output is correct |
4 | Correct | 6 ms | 504 KB | Output is correct |
5 | Correct | 7 ms | 504 KB | Output is correct |
6 | Correct | 7 ms | 632 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Correct | 9 ms | 760 KB | Output is correct |
10 | Correct | 5 ms | 376 KB | Output is correct |
11 | Correct | 6 ms | 504 KB | Output is correct |
12 | Correct | 5 ms | 376 KB | Output is correct |
13 | Correct | 6 ms | 504 KB | Output is correct |
14 | Correct | 6 ms | 376 KB | Output is correct |
15 | Correct | 7 ms | 504 KB | Output is correct |
16 | Correct | 14 ms | 1144 KB | Output is correct |
17 | Correct | 108 ms | 8808 KB | Output is correct |
18 | Correct | 44 ms | 4080 KB | Output is correct |
19 | Correct | 199 ms | 14312 KB | Output is correct |
20 | Correct | 34 ms | 2924 KB | Output is correct |
21 | Correct | 161 ms | 12904 KB | Output is correct |
22 | Correct | 6 ms | 376 KB | Output is correct |
23 | Correct | 5 ms | 376 KB | Output is correct |
24 | Correct | 6 ms | 376 KB | Output is correct |
25 | Correct | 6 ms | 376 KB | Output is correct |
26 | Correct | 9 ms | 1144 KB | Output is correct |
27 | Correct | 5 ms | 1016 KB | Output is correct |
28 | Correct | 16 ms | 2808 KB | Output is correct |
29 | Correct | 24 ms | 4216 KB | Output is correct |
30 | Correct | 45 ms | 760 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 6 ms | 376 KB | Output is correct |
4 | Correct | 6 ms | 504 KB | Output is correct |
5 | Correct | 7 ms | 504 KB | Output is correct |
6 | Correct | 7 ms | 632 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Correct | 9 ms | 760 KB | Output is correct |
10 | Correct | 5 ms | 376 KB | Output is correct |
11 | Correct | 6 ms | 504 KB | Output is correct |
12 | Correct | 5 ms | 376 KB | Output is correct |
13 | Correct | 6 ms | 504 KB | Output is correct |
14 | Correct | 6 ms | 376 KB | Output is correct |
15 | Correct | 7 ms | 504 KB | Output is correct |
16 | Correct | 14 ms | 1144 KB | Output is correct |
17 | Correct | 108 ms | 8808 KB | Output is correct |
18 | Correct | 44 ms | 4080 KB | Output is correct |
19 | Correct | 199 ms | 14312 KB | Output is correct |
20 | Correct | 34 ms | 2924 KB | Output is correct |
21 | Correct | 161 ms | 12904 KB | Output is correct |
22 | Correct | 197 ms | 17916 KB | Output is correct |
23 | Correct | 6 ms | 376 KB | Output is correct |
24 | Correct | 5 ms | 376 KB | Output is correct |
25 | Correct | 27 ms | 27896 KB | Output is correct |
26 | Correct | 6 ms | 376 KB | Output is correct |
27 | Correct | 6 ms | 376 KB | Output is correct |
28 | Correct | 9 ms | 1144 KB | Output is correct |
29 | Correct | 5 ms | 1016 KB | Output is correct |
30 | Correct | 598 ms | 35812 KB | Output is correct |
31 | Correct | 521 ms | 68972 KB | Output is correct |
32 | Correct | 33 ms | 4724 KB | Output is correct |
33 | Correct | 214 ms | 18916 KB | Output is correct |
34 | Correct | 80 ms | 15352 KB | Output is correct |
35 | Correct | 16 ms | 2808 KB | Output is correct |
36 | Correct | 24 ms | 4216 KB | Output is correct |
37 | Correct | 45 ms | 760 KB | Output is correct |