Submission #1052630

#TimeUsernameProblemLanguageResultExecution timeMemory
1052630turskaRailway (BOI17_railway)C++17
100 / 100
137 ms31176 KiB
#include <bits/stdc++.h> using namespace std; #define P push_back #define N 100001 #define I int I n, m, k, u, v, s, h; vector<pair<I, I>> adj[N]; vector<I> q[N]; I z[N]; vector<I> A; map<I, I> G(I v, I p) { map<I, I> a; for (auto [u, i]: adj[v]) if (u!=p) { map<I, I> b = G(u, v); if (b.size()>=k) A.P(i); if (a.size() < b.size()) a.swap(b); for (auto [k, v]: b) if (a[k]+v==z[k]) a.erase(k); else a[k] += v; } for (auto u: q[v]) { a[u]++; if (a[u] == z[u]) a.erase(u); } return a; } I main() { cin >> n >> m >> k; for (I i=0; i<n-1; i++) { cin >> u >> v; adj[u].P({v, i}); adj[v].P({u, i}); } for (I i=0; i<m; i++) { cin >> s; z[i] = s; for (I j=0; j<s; j++) { cin >> h; q[h].P(i); } } G(1, 1); sort(A.begin(), A.end()); cout << A.size() << '\n'; for (auto i: A) cout << i+1 << ' '; }

Compilation message (stderr)

railway.cpp: In function 'std::map<int, int> G(int, int)':
railway.cpp:15:21: warning: comparison of integer expressions of different signedness: 'std::map<int, int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   15 |         if (b.size()>=k)  A.P(i);
      |             ~~~~~~~~^~~
#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...