Submission #480733

#TimeUsernameProblemLanguageResultExecution timeMemory
480733socpitetimeismoney (balkan11_timeismoney)C++14
60 / 100
35 ms684 KiB
#include<bits/stdc++.h> using namespace std; #define oo 1000000000000000 #define f first #define s second vector<int> up; int Find(int x){ if(up[x] < 0)return x; else{ up[x]=Find(up[x]); return up[x]; } } void Union(int a, int b){ a = Find(a); b = Find(b); up[b]=a; } long long n, m; vector<pair<pair<int, int>,pair<long long, long long>>> edges; vector<pair<int, int>> ans; long long tim = 0, money = 0, currpos, best; int main(){ cin >> n >> m; edges.resize(m); up.assign(n, -1); for(int i = 0; i < m; i++){ cin >> edges[i].f.f >> edges[i].f.s >> edges[i].s.f >> edges[i].s.s; } for(int j = 0; j < n-1; j++){ best = oo; for(int i = 0; i < m; i++){ if(Find(edges[i].f.f) == Find(edges[i].f.s))continue; else{ if(tim*edges[i].s.s + money*edges[i].s.f + edges[i].s.s*edges[i].s.f < best){ best = tim*edges[i].s.s + money*edges[i].s.f + edges[i].s.s*edges[i].s.f; currpos = i; } } } tim += edges[currpos].s.f; money += edges[currpos].s.s; Union(edges[currpos].f.f, edges[currpos].f.s); ans.push_back(edges[currpos].f); } cout << tim << " " << money << endl; for(int i =0; i < ans.size(); i++){ cout << ans[i].f << " " << ans[i].s << endl; } }

Compilation message (stderr)

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