Submission #1092791

#TimeUsernameProblemLanguageResultExecution timeMemory
1092791juicyRailway (BOI17_railway)C++17
100 / 100
117 ms39124 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "debug.h" #else #define debug(...) 42 #endif const int N = 1e5 + 5; int n, m, k; int s[N]; map<int, int> mp[N]; vector<int> res; vector<array<int, 2>> g[N]; void dfs(int u, int id) { for (auto [v, nxt] : g[u]) { if (nxt ^ id) { dfs(v, nxt); if (mp[u].size() < mp[v].size()) { mp[u].swap(mp[v]); } for (auto [c, x] : mp[v]) { mp[u][c] += x; if (mp[u][c] == s[c]) { mp[u].erase(c); } } map<int, int>().swap(mp[v]); } } if (mp[u].size() >= k) { res.push_back(id); } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> m >> k; for (int i = 1; i < n; ++i) { int u, v; cin >> u >> v; g[u].push_back({v, i}); g[v].push_back({u, i}); } for (int i = 1; i <= m; ++i) { cin >> s[i]; for (int j = 0; j < s[i]; ++j) { int u; cin >> u; ++mp[u][i]; } } dfs(1, 0); sort(res.begin(), res.end()); cout << res.size() << "\n"; for (int x : res) { cout << x << " "; } return 0; }

Compilation message (stderr)

railway.cpp: In function 'void dfs(int, int)':
railway.cpp:35:20: warning: comparison of integer expressions of different signedness: 'std::map<int, int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |   if (mp[u].size() >= k) {
      |       ~~~~~~~~~~~~~^~~~
#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...