Submission #596635

#TimeUsernameProblemLanguageResultExecution timeMemory
596635OzyRoad Closures (APIO21_roads)C++17
0 / 100
104 ms19824 KiB
#include "roads.h" #include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for (int i = (a); i <= (b); i++) #define repa(i,a,b) for (int i = (a); i >= (b); i--) #define lli long long int #define debugsl(a) cout << #a << " = " << a << ", " #define debug(a) cout << #a << " = " << a << endl #define MAX 100000 #define des first #define w second vector< pair<lli,lli> > hijos[MAX+2]; lli n,a,b,c,apu1,ind,aristas,resta,sum; vector<lli> activos,inicios; vector<pair<lli,lli> > orden; vector<lli> grafo[MAX+2]; lli visitados[MAX+2]; std::vector <long long> minimum_closure_costs(int N, std::vector<int> U, std::vector<int> V, std::vector<int> W) { vector<long long> res (N, 0); n = N; //asigna hijos rep(i,0,n-2) { a = U[i]+1; b = V[i]+1; c = W[i]; hijos[a].push_back({b,c}); hijos[b].push_back({a,c}); } rep(i,1,n) orden.push_back({hijos[i].size(), i}); sort(orden.begin(), orden.end()); reverse(orden.begin(), orden.end()); apu1 = 0; sum = 0; repa(i,n-1,0) { inicios.clear(); resta = 0; while (apu1 < n && orden[apu1].first > i) { ind = orden[apu1].second; visitados[ind] = i; activos.push_back(ind); inicios.push_back(ind); for (auto h : hijos[ind]) { if (hijos[h.des].size() > i) { if (visitados[h.des] > i) { visitados[h.des] = i; grafo[h.des].clear(); } grafo[ind].push_back(h.des); grafo[h.des].push_back(ind); aristas++; } if (hijos[h.des].size() == i+1) resta++; } apu1++; } resta /= 2; aristas -= resta; sum += activos.size(); res[i] = sum - aristas; } return res; }

Compilation message (stderr)

roads.cpp: In function 'std::vector<long long int> minimum_closure_costs(int, std::vector<int>, std::vector<int>, std::vector<int>)':
roads.cpp:53:41: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   53 |                 if (hijos[h.des].size() > i) {
      |                     ~~~~~~~~~~~~~~~~~~~~^~~
roads.cpp:63:41: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   63 |                 if (hijos[h.des].size() == i+1) resta++;
      |                     ~~~~~~~~~~~~~~~~~~~~^~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...