Submission #1010750

#TimeUsernameProblemLanguageResultExecution timeMemory
1010750vjudge1timeismoney (balkan11_timeismoney)C++11
5 / 100
3 ms860 KiB
#include<bits/stdc++.h> using namespace std; long long n,m,ai,bi,ti,ci,sum,par[201]; vector<pair<int,int> >v[201]; vector<pair<long long,pair<int,int> > >edging; vector<pair<int,int> >answer; int get(int x){ if(par[x]==x)return x; return par[x]=get(par[x]); } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin>>n>>m; for(int i=0;i<n;i++)par[i]=i; for(int i=0;i<m;i++){ cin>>ai>>bi>>ti>>ci; v[ai].push_back({bi,ci}); v[bi].push_back({ai,ci}); edging.push_back({ci,{ai,bi}}); } sort(edging.begin(),edging.end()); for(int i=0;i<m;i++){ long long ci=edging[i].first; int ai=edging[i].second.first; int bi=edging[i].second.second; if(get(ai)!=get(bi)){ answer.push_back({edging[i].second.first,edging[i].second.second}); par[ai]=get(bi); sum+=ci; } } cout<<sum<<' '<<sum<<'\n'; for(int i=0;i<answer.size();i++)cout<<answer[i].first<<' '<<answer[i].second<<'\n'; return 0; }

Compilation message (stderr)

timeismoney.cpp: In function 'int main()':
timeismoney.cpp:34:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |  for(int i=0;i<answer.size();i++)cout<<answer[i].first<<' '<<answer[i].second<<'\n';
      |              ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...