Submission #563033

#TimeUsernameProblemLanguageResultExecution timeMemory
563033DevigoRoad Closures (APIO21_roads)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int siz = 1e5+1; bool done = 0; int64 cost = 0; vector<bool> rem(siz,0); struct edge { long long w, x, y; }; bool cmp (edge a, edge b) { return a.w < b.w; } void get(int k, vector<int> &degree, vector<edge> &el, int n, int m) { for(int i=0; i<m; i++) { if(rem[i]) continue; bool isb = 0; int u = degree[el[i].x]; int v = degree[el[i].y]; if(u > k || v > k) isb = 1; if(isb) { degree[el[i].x]--; degree[el[i].y]--; rem[i] = 1; cost += el[i].w; } int grt = -1; for(int j=0; j<n; j++) { grt = max(grt,degree[j]); } if(grt <= k) { done = 1; return; } } return; } int64[] minimum_closure_costs(int n, int u[], int v[], int w[]) { vector<int> degree(n,0); vector<edge> el; int m = n-1; for(int i=0; i<m; i++) { degree[u[i]]++; degree[v[i]]++; el.push_back({w[i],u[i],v[i]}); } sort(el.begin(), el.end(), cmp); int64 c[n]; for(int i=m; i>=0; i--) { while(!done) { get(i,degree,el,n,m); } c[i] = cost; done = 0; } return c; }

Compilation message (stderr)

roads.cpp:7:1: error: 'int64' does not name a type; did you mean 'int64_t'?
    7 | int64 cost = 0;
      | ^~~~~
      | int64_t
roads.cpp: In function 'void get(int, std::vector<int>&, std::vector<edge>&, int, int)':
roads.cpp:28:4: error: 'cost' was not declared in this scope; did you mean 'cosl'?
   28 |    cost += el[i].w;
      |    ^~~~
      |    cosl
roads.cpp: At global scope:
roads.cpp:41:1: error: 'int64' does not name a type; did you mean 'int64_t'?
   41 | int64[] minimum_closure_costs(int n, int u[], int v[], int w[]) {
      | ^~~~~
      | int64_t