結果
問題 | No.1749 ラムドスウイルスの感染拡大 |
ユーザー |
![]() |
提出日時 | 2021-11-19 22:55:22 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 2,000 ms |
コード長 | 1,449 bytes |
コンパイル時間 | 1,384 ms |
コンパイル使用メモリ | 166,008 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-01-01 21:05:49 |
合計ジャッジ時間 | 2,456 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;using Graph = vector<vector<int> >;using PI = pair<int, int>;using PL = pair<ll, ll>;#define rep(i, a, b) for(int i = a; i < b; i++)#define rep_ll(i, a, b) for(ll i = a; i < b; i++)#define rrep(i, a, b) for(int i = a; i >= b; i--)#define fore(i, a) for(auto &i:a)#define all(x) (x).begin(),(x).end()const int INFI = 1 << 29;const ll INFL = 1LL << 59;const ll MOD = 998244353;int main() {cin.tie(0);ios::sync_with_stdio(false);int n, m, t; cin >> n >> m >> t;vector<ll> infected0(n, 0), infected1(n, 0);infected0[0] = 1;vector<vector<ll> > cities(n);rep(i, 0, m) {int s, t; cin >> s >> t;cities[s].push_back(t);cities[t].push_back(s);}rep(i, 0, t) {if (i % 2 == 0) {rep(j, 0, n) {infected1[j] = 0;for (auto k : cities[j]) {infected1[j] += infected0[k];infected1[j] %= MOD;}}}else {rep(j, 0, n) {infected0[j] = 0;for (auto k : cities[j]) {infected0[j] += infected1[k];infected0[j] %= MOD;}}}}if (t % 2 == 0) {cout << infected0[0] << endl;}else {cout << infected1[0] << endl;}}