Submission #467940

# Submission time Handle Problem Language Result Execution time Memory
467940 2021-08-25T16:23:37 Z czhang2718 timeismoney (balkan11_timeismoney) C++14
40 / 100
5 ms 588 KB
#include "bits/stdc++.h"
using namespace std;

#define nl '\n'
int n, m;
const int N=200;
int par[N];
vector<pair<int, pair<int, int>>> edges;

int find(int x){
  if(par[x]==x) return x;
  return par[x]=find(par[x]);
}

bool join(int x, int y){
  if(find(x)==find(y)) return 0;
  par[find(x)]=find(y);
  return 1;
}

int main(){
  cin.tie(0)->sync_with_stdio(0);
  // freopen("input.txt", "r", stdin);
  // freopen("timeismoney.out", "w", stdout);

  cin >> n >> m;
  for(int i=0; i<n; i++) par[i]=i;
  for(int i=0; i<m; i++){
    int u, v, c, t; cin >> u >> v >> t >> c;
    edges.push_back({c, {u, v}});
  }
  int ans=0;
  vector<pair<int, int>> use;
  sort(edges.begin(), edges.end());
  for(auto p:edges){
    int u=p.second.first;
    int v=p.second.second;
    if(join(u, v)) ans+=p.first, use.push_back({u, v});
  }
  cout << ans << " " << ans << nl;
  for(auto e:use) cout << e.first << " " << e.second << nl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 5 ms 588 KB Output is correct
9 Incorrect 0 ms 204 KB Output isn't correct
10 Incorrect 0 ms 204 KB Output isn't correct
11 Incorrect 0 ms 204 KB Output isn't correct
12 Incorrect 0 ms 204 KB Output isn't correct
13 Incorrect 0 ms 204 KB Output isn't correct
14 Incorrect 1 ms 204 KB Output isn't correct
15 Incorrect 1 ms 204 KB Output isn't correct
16 Incorrect 1 ms 332 KB Output isn't correct
17 Incorrect 1 ms 332 KB Output isn't correct
18 Incorrect 1 ms 332 KB Output isn't correct
19 Incorrect 5 ms 588 KB Output isn't correct
20 Incorrect 5 ms 588 KB Output isn't correct