# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
722783 | 2023-04-12T20:35:43 Z | groshi | Monthly railway pass (LMIO18_menesinis_bilietas) | C++17 | 472 ms | 55780 KB |
#include<bits/stdc++.h> using namespace std; struct wi{ vector<int> Q,inne; int odw=0,byl=0; }*w; set<int> secik; int mam=1; void reku(int x) { w[x].odw=mam; for(int i=0;i<w[x].Q.size();i++) { int pom=w[x].Q[i]; if(w[pom].odw) continue; reku(pom); } } int wiel=0; void reku2(int x) { w[x].byl=1; wiel++; for(int i=0;i<w[x].inne.size();i++) secik.insert(w[w[x].inne[i]].odw); for(int i=0;i<w[x].Q.size();i++) { int pom=w[x].Q[i]; if(w[pom].byl) continue; reku2(pom); } } int32_t main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); int n,m,x,y; char co; cin>>n>>m; w=new wi[n+3]; for(int i=1;i<=m;i++) { cin>>x>>y>>co; if(co=='T') { w[x].Q.push_back(y); w[y].Q.push_back(x); } else{ w[x].inne.push_back(y); w[y].inne.push_back(x); } } for(int i=1;i<=n;i++) if(w[i].odw) continue; else{ reku(i); mam++; } int wynik=0; for(int i=1;i<=n;i++) { if(w[i].byl) continue; secik.clear(); wiel=0; reku2(i); secik.insert(w[i].odw); if(secik.size()==mam-1) wynik+=wiel; } cout<<wynik; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 381 ms | 31844 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 27 ms | 26068 KB | Output is correct |
5 | Correct | 1 ms | 980 KB | Output is correct |
6 | Correct | 44 ms | 3444 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 26068 KB | Output is correct |
2 | Correct | 1 ms | 980 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 3 ms | 468 KB | Output is correct |
6 | Correct | 213 ms | 8908 KB | Output is correct |
7 | Correct | 472 ms | 55780 KB | Output is correct |
8 | Correct | 7 ms | 2388 KB | Output is correct |
9 | Correct | 13 ms | 2432 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 3 ms | 468 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 2 ms | 340 KB | Output is correct |
10 | Correct | 3 ms | 468 KB | Output is correct |
11 | Correct | 2 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 4 ms | 468 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 408 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 2 ms | 464 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 2 ms | 340 KB | Output is correct |
5 | Correct | 3 ms | 468 KB | Output is correct |
6 | Correct | 2 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 4 ms | 468 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 408 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 2 ms | 464 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 3 ms | 468 KB | Output is correct |
21 | Correct | 1 ms | 980 KB | Output is correct |
22 | Correct | 7 ms | 2388 KB | Output is correct |
23 | Correct | 13 ms | 2432 KB | Output is correct |
24 | Correct | 44 ms | 3444 KB | Output is correct |
25 | Correct | 8 ms | 1108 KB | Output is correct |
26 | Correct | 115 ms | 10788 KB | Output is correct |
27 | Correct | 37 ms | 3904 KB | Output is correct |
28 | Correct | 72 ms | 4980 KB | Output is correct |
29 | Correct | 30 ms | 3088 KB | Output is correct |
30 | Correct | 74 ms | 5908 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 2 ms | 340 KB | Output is correct |
5 | Correct | 3 ms | 468 KB | Output is correct |
6 | Correct | 2 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 4 ms | 468 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 408 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 2 ms | 464 KB | Output is correct |
16 | Correct | 8 ms | 1108 KB | Output is correct |
17 | Correct | 115 ms | 10788 KB | Output is correct |
18 | Correct | 37 ms | 3904 KB | Output is correct |
19 | Correct | 72 ms | 4980 KB | Output is correct |
20 | Correct | 30 ms | 3088 KB | Output is correct |
21 | Correct | 74 ms | 5908 KB | Output is correct |
22 | Correct | 381 ms | 31844 KB | Output is correct |
23 | Correct | 0 ms | 212 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 27 ms | 26068 KB | Output is correct |
26 | Correct | 0 ms | 212 KB | Output is correct |
27 | Correct | 1 ms | 340 KB | Output is correct |
28 | Correct | 3 ms | 468 KB | Output is correct |
29 | Correct | 1 ms | 980 KB | Output is correct |
30 | Correct | 213 ms | 8908 KB | Output is correct |
31 | Correct | 472 ms | 55780 KB | Output is correct |
32 | Correct | 7 ms | 2388 KB | Output is correct |
33 | Correct | 13 ms | 2432 KB | Output is correct |
34 | Correct | 44 ms | 3444 KB | Output is correct |
35 | Correct | 32 ms | 4232 KB | Output is correct |
36 | Correct | 247 ms | 19688 KB | Output is correct |
37 | Correct | 191 ms | 20880 KB | Output is correct |