# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
920977 | 2024-02-03T08:36:17 Z | zhehan | Monthly railway pass (LMIO18_menesinis_bilietas) | C++14 | 1274 ms | 162304 KB |
#include <bits/stdc++.h> using namespace std; int parent[500000]; int f(int a){ if(parent[a]=a){ return a; } return parent[a]=f(parent[a]); } void u(int a,int b){ parent[f(a)]=f(b); } int main() { int n,m; cin>>n>>m; for(int i{1};i<n+1;++i){ parent[i]=i; } map<int,vector<int>> ma; for(int i{};i<m;++i){ int a,b; char c; cin>>a>>b>>c; if(c=='T'){ u(a,b); }else{ ma[a].push_back(b); ma[b].push_back(a); } } map<int,set<int>> mf; map<int,int> cc; for(int i{1};i<n+1;++i){ cc[parent[i]]++; for(auto e:ma[i]){ mf[parent[i]].insert(parent[e]); } } int counter=0; for(auto e:mf){ if(mf.size()==e.second.size()+1){ counter+=cc[e.first]; } } cout<<counter; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 356 ms | 32848 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 265 ms | 61008 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 6 ms | 1372 KB | Output is correct |
5 | Correct | 3 ms | 1884 KB | Output is correct |
6 | Correct | 466 ms | 48412 KB | Output is correct |
7 | Correct | 1274 ms | 162304 KB | Output is correct |
8 | Correct | 21 ms | 6236 KB | Output is correct |
9 | Correct | 34 ms | 7676 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 6 ms | 1372 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 344 KB | Output is correct |
6 | Incorrect | 2 ms | 604 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 344 KB | Output is correct |
3 | Incorrect | 2 ms | 604 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 344 KB | Output is correct |
3 | Incorrect | 2 ms | 604 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |