結果
問題 | No.2431 Viral Hotel |
ユーザー | nono00 |
提出日時 | 2023-08-19 01:55:12 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 135 ms / 2,000 ms |
コード長 | 2,773 bytes |
コンパイル時間 | 3,237 ms |
コンパイル使用メモリ | 262,712 KB |
実行使用メモリ | 15,404 KB |
最終ジャッジ日時 | 2024-11-28 14:29:35 |
合計ジャッジ時間 | 7,524 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 105 ms
10,408 KB |
testcase_01 | AC | 87 ms
10,032 KB |
testcase_02 | AC | 93 ms
10,448 KB |
testcase_03 | AC | 108 ms
11,080 KB |
testcase_04 | AC | 114 ms
12,108 KB |
testcase_05 | AC | 129 ms
12,092 KB |
testcase_06 | AC | 17 ms
6,820 KB |
testcase_07 | AC | 17 ms
6,816 KB |
testcase_08 | AC | 17 ms
6,816 KB |
testcase_09 | AC | 2 ms
6,820 KB |
testcase_10 | AC | 2 ms
6,816 KB |
testcase_11 | AC | 2 ms
6,816 KB |
testcase_12 | AC | 135 ms
14,864 KB |
testcase_13 | AC | 111 ms
10,760 KB |
testcase_14 | AC | 50 ms
7,556 KB |
testcase_15 | AC | 18 ms
6,816 KB |
testcase_16 | AC | 64 ms
11,008 KB |
testcase_17 | AC | 40 ms
6,820 KB |
testcase_18 | AC | 103 ms
13,820 KB |
testcase_19 | AC | 67 ms
9,392 KB |
testcase_20 | AC | 30 ms
6,816 KB |
testcase_21 | AC | 24 ms
6,816 KB |
testcase_22 | AC | 65 ms
8,648 KB |
testcase_23 | AC | 71 ms
8,392 KB |
testcase_24 | AC | 40 ms
7,300 KB |
testcase_25 | AC | 98 ms
9,936 KB |
testcase_26 | AC | 59 ms
8,680 KB |
testcase_27 | AC | 64 ms
8,048 KB |
testcase_28 | AC | 50 ms
7,284 KB |
testcase_29 | AC | 51 ms
7,192 KB |
testcase_30 | AC | 59 ms
7,400 KB |
testcase_31 | AC | 81 ms
10,192 KB |
testcase_32 | AC | 22 ms
6,816 KB |
testcase_33 | AC | 46 ms
6,820 KB |
testcase_34 | AC | 5 ms
6,816 KB |
testcase_35 | AC | 16 ms
6,816 KB |
testcase_36 | AC | 94 ms
10,356 KB |
testcase_37 | AC | 58 ms
8,412 KB |
testcase_38 | AC | 26 ms
6,816 KB |
testcase_39 | AC | 2 ms
6,820 KB |
testcase_40 | AC | 2 ms
6,816 KB |
testcase_41 | AC | 2 ms
6,820 KB |
testcase_42 | AC | 2 ms
6,816 KB |
testcase_43 | AC | 114 ms
15,404 KB |
testcase_44 | AC | 69 ms
9,188 KB |
testcase_45 | AC | 52 ms
7,880 KB |
ソースコード
#include <bits/stdc++.h> namespace nono { enum class EventType { RECOVER = 0, INFECT = 1, INFECTED = 2, }; enum class State { FINE, RECOVER, INFECTED, GOODBYE, }; struct Event { long long time; EventType type; int index; Event(long long time, EventType type, int index): time(time), type(type), index(index) {} friend auto operator<=>(const Event& lhs, const Event& rhs) = default; }; void solve() { int N, K, M, P; std::cin >> N >> K >> M >> P; std::vector graph(N, std::vector<int>()); for (int i = 0; i < M; i++) { int u, v; std::cin >> u >> v; u--; v--; graph[u].push_back(v); graph[v].push_back(u); } std::vector<long long> S(N); for (int i = 0; i < N; i++) std::cin >> S[i]; std::priority_queue<Event, std::vector<Event>, std::greater<Event>> events; for (int i = 0; i < K; i++) { int x; std::cin >> x; x--; events.emplace(0, EventType::INFECTED, x); } std::vector<State> states(N, State::FINE); while (not events.empty()) { auto [now, type, i] = events.top(); events.pop(); if (states[i] == State::GOODBYE) continue; if (type == EventType::RECOVER) { if (states[i] == State::GOODBYE) continue; states[i] = State::RECOVER; } else if (type == EventType::INFECT) { for (int to: graph[i]) { if (states[to] == State::FINE or states[to] == State::INFECTED) { events.emplace(now, EventType::INFECTED, to); } } } else if (type == EventType::INFECTED) { if (states[i] == State::FINE) { states[i] = State::INFECTED; events.emplace(now + S[i], EventType::INFECT, i); events.emplace(now + P, EventType::RECOVER, i); } else if (states[i] == State::INFECTED) { states[i] = State::GOODBYE; } } } int ans = 0; for (int i = 0; i < N; i++) { if (states[i] == State::GOODBYE) ans++; // if (states[i] == State::GOODBYE) { // std::cout << "GOODBYE" << ' '; // } else if (states[i] == State::FINE) { // std::cout << "FINE" << ' '; // } else if (states[i] == State::INFECTED) { // std::cout << "INFECTED" << ' '; // } else { // std::cout << "RECOVER" << ' '; // } } // std::cout << std::endl; std::cout << ans << std::endl; } } // namespace nono int main() { std::cin.tie(0)->sync_with_stdio(0); std::cout << std::fixed << std::setprecision(15); int t = 1; // std::cin >> t; while (t--) nono::solve(); }