結果

問題 No.1749 ラムドスウイルスの感染拡大
ユーザー yukihira_potyukihira_pot
提出日時 2021-11-19 22:55:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 1,449 bytes
コンパイル時間 1,845 ms
コンパイル使用メモリ 171,056 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 09:54:22
合計ジャッジ時間 3,359 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 8 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 9 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 6 ms
4,380 KB
testcase_18 AC 7 ms
4,380 KB
testcase_19 AC 6 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 8 ms
4,380 KB
testcase_29 AC 8 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
    }
}
0