제출 #1052621

#제출 시각아이디문제언어결과실행 시간메모리
1052621turskaRailway (BOI17_railway)C++17
100 / 100
193 ms45444 KiB
#include <bits/stdc++.h> using namespace std; #define all(v) (v).begin(), (v).end() int n, m, k; vector<int> adj[100001]; vector<int> q[100001]; int z[100001]; vector<int> ans; map<pair<int, int>, int> e; map<int, int> dfs(int v, int p) { map<int, int> a; for (auto u: adj[v]) { if (u==p) continue; map<int, int> b = dfs(u, v); if (b.size()>=k) { ans.push_back(e[{v, u}]); } 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; } int main() { cin >> n >> m >> k; for (int i=0; i<n-1; i++) { int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u); e[{u, v}] = i+1; e[{v, u}] = i+1; } for (int i=0; i<m; i++) { int s; cin >> s; z[i] = s; for (int j=0; j<s; j++) { int k; cin >> k; q[k].push_back(i); } } dfs(1, 1); sort(all(ans)); cout << ans.size() << '\n'; for (auto i: ans) cout << i << ' '; }

컴파일 시 표준 에러 (stderr) 메시지

railway.cpp: In function 'std::map<int, int> dfs(int, int)':
railway.cpp:22:21: warning: comparison of integer expressions of different signedness: 'std::map<int, int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |         if (b.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...