結果

問題 No.2691 Longest Infection Sequence
ユーザー Iroha_3856Iroha_3856
提出日時 2024-03-22 21:36:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,237 bytes
コンパイル時間 1,967 ms
コンパイル使用メモリ 179,180 KB
実行使用メモリ 39,680 KB
最終ジャッジ日時 2024-03-22 21:36:36
合計ジャッジ時間 3,354 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 21 ms
11,008 KB
testcase_03 AC 84 ms
33,280 KB
testcase_04 WA -
testcase_05 AC 15 ms
8,064 KB
testcase_06 AC 31 ms
14,592 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 71 ms
28,928 KB
testcase_10 AC 58 ms
25,216 KB
testcase_11 AC 30 ms
14,208 KB
testcase_12 AC 32 ms
12,928 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 118 ms
39,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define rep(i, l, r) for (int i = (int)(l); i<(int)(r); i++)
#define ll long long

const ll INF = 2e18;

int A, B, O, W;
vector<vector<int>> G;
vector<bool> seen;
int ans = 1;

void dfs(int v, int cur) {
    seen[v] = true;
    ans = max(ans, cur);
    int cnt = 0;
    for (auto to : G[v]) {
        if (!seen[to]) {
            cnt++;
            dfs(to, cur + 1);
        } 
    }
}

int main() {
    cin >> A >> B >> O >> W;
    G.resize(A+B+O+W);
    rep(i, 0, A) rep(j, 0, A) {
        G[i].push_back(j);
    }
    rep(i, 0, B) rep(j, 0, B) {
        G[A+i].push_back(A+j);
    }
    rep(i, 0, O) rep(j, 0, O) {
        G[A+B+i].push_back(A+B+j);
    }
    rep(i, 0, W) rep(j, 0, W) {
        G[A+B+O+i].push_back(A+B+O+j);
    }
    rep(i, 0, A) rep(j, A+B+O, A+B+O+W) {
        G[i].push_back(j);
    }
    rep(i, A, A+B) rep(j, A+B+O, A+B+O+W) {
        G[i].push_back(j);
    }
    rep(i, A+B+O, A+B+O+W) rep(j, 0, A+B+O) {
        G[i].push_back(j);
    }
    seen.assign(A+B+O+W, false);
    dfs(0, 1);
    seen.assign(A+B+O+W, false);
    dfs(A, 1);
    seen.assign(A+B+O+W, false);
    dfs(A+B, 1);
    seen.assign(A+B+O+W, false);
    dfs(A+B+O, 1);
    cout << ans << endl;
}
0