Submission #920965

#TimeUsernameProblemLanguageResultExecution timeMemory
920965WongYiKaiMonthly railway pass (LMIO18_menesinis_bilietas)C++14
16 / 100
314 ms83384 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll visited[600000]; ll type[600000]; ll c=1; ll sets[600000]; vector<ll> adj[600000],adj2[600000]; void dfs(ll vertex){ visited[vertex] = 1; type[vertex] = c; sets[c]++; for (auto item:adj[vertex]){ if (visited[item]==0){ dfs(item); } } } int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n,m; cin >> n >> m; for (int i=0;i<m;i++){ ll a,b; char t; cin >> a >> b >> t; if (t=='T'){ adj[a].push_back(b); adj[b].push_back(a); } else { adj2[a].push_back(b); adj2[b].push_back(a); } } for (int i=1;i<=n;i++){ if (visited[i]==0){ dfs(i); c++; } } vector<ll> con[c+5]; for (int i=1;i<=n;i++){ for (auto item:adj2[i]){ if (type[i]!=type[item]){ con[type[i]].push_back(type[item]); } } } c--; ll total=0; for (int i=1;i<=c;i++){ //cout << con[i].size() << "\n"; if (con[i].size() == c-1) total += sets[i]; } cout << total; }

Compilation message (stderr)

menesinis_bilietas.cpp: In function 'int main()':
menesinis_bilietas.cpp:57:21: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   57 |   if (con[i].size() == c-1) total += sets[i];
      |       ~~~~~~~~~~~~~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...