ABC 305
Table of Contents
https://atcoder.jp/contests/abc305
A. Water Station
https://atcoder.jp/contests/abc305/tasks/abc305_a
B. ABCDEFG
https://atcoder.jp/contests/abc305/tasks/abc305_b
C. Snuke the Cookie Picker
https://atcoder.jp/contests/abc305/tasks/abc305_c
D. Sleep Log
https://atcoder.jp/contests/abc305/tasks/abc305_d
E. Art Gallery on Graph
https://atcoder.jp/contests/abc305/tasks/abc305_e
頂点 $i$ に体力 $h_i$ の警備員がいるとき、隣接する頂点に警備員が移動して体力 $h_i - 1$ の警備員がいるとみなしても良い。 体力が大きい警備員がいる頂点から順に隣接する頂点に移動させて、各頂点に体力が 0 以上の警備員がいる頂点が列挙すべき頂点
void solve() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N, M, K;
cin >> N >> M >> K;
vvint graph(N);
rep(i, M) {
int u, v;
cin >> u >> v;
u--, v--;
graph[u].push_back(v);
graph[v].push_back(u);
}
vll powers(N, -1);
rep(i, K) {
int p, h;
cin >> p >> h;
p--;
powers[p] = h;
}
// power, node id
using P = pair<ll, int>;
priority_queue<P> pq;
rep(i, N) {
if (powers[i] > 0)
pq.push({powers[i], i});
}
while (pq.size()) {
auto [power, id] = pq.top();
pq.pop();
if (powers[id] > power)
continue;
for (int nx : graph[id]) {
if (powers[nx] >= power - 1)
continue;
powers[nx] = power - 1;
pq.push({powers[nx], nx});
}
}
vint ans;
rep(i, N) {
if (powers[i] >= 0)
ans.push_back(i + 1);
}
cout << ans.size() << endl;
print(ans);
}
F. Dungeon Explore
https://atcoder.jp/contests/abc305/tasks/abc305_f
G. Banned Substrings
https://atcoder.jp/contests/abc305/tasks/abc305_g