結果

問題 No.762 PDCAパス
ユーザー t33ft33f
提出日時 2018-12-10 20:31:30
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 763 bytes
コンパイル時間 931 ms
コンパイル使用メモリ 71,832 KB
実行使用メモリ 12,352 KB
最終ジャッジ日時 2023-10-14 22:17:14
合計ジャッジ時間 4,253 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,816 KB
testcase_01 AC 4 ms
8,800 KB
testcase_02 AC 5 ms
8,840 KB
testcase_03 AC 4 ms
8,796 KB
testcase_04 AC 4 ms
8,864 KB
testcase_05 AC 4 ms
8,800 KB
testcase_06 AC 4 ms
8,864 KB
testcase_07 AC 4 ms
8,860 KB
testcase_08 AC 5 ms
8,860 KB
testcase_09 AC 4 ms
8,796 KB
testcase_10 AC 4 ms
8,868 KB
testcase_11 AC 4 ms
8,880 KB
testcase_12 AC 4 ms
8,840 KB
testcase_13 AC 4 ms
9,004 KB
testcase_14 AC 4 ms
8,860 KB
testcase_15 AC 4 ms
8,876 KB
testcase_16 AC 5 ms
8,864 KB
testcase_17 AC 4 ms
8,860 KB
testcase_18 AC 4 ms
8,856 KB
testcase_19 AC 5 ms
8,860 KB
testcase_20 AC 5 ms
8,796 KB
testcase_21 AC 4 ms
8,924 KB
testcase_22 AC 42 ms
9,964 KB
testcase_23 AC 42 ms
9,804 KB
testcase_24 AC 74 ms
12,352 KB
testcase_25 AC 72 ms
12,088 KB
testcase_26 AC 43 ms
10,248 KB
testcase_27 AC 44 ms
9,968 KB
testcase_28 AC 98 ms
11,688 KB
testcase_29 AC 98 ms
11,688 KB
testcase_30 AC 90 ms
11,324 KB
testcase_31 AC 94 ms
11,400 KB
testcase_32 AC 92 ms
11,272 KB
testcase_33 AC 84 ms
10,964 KB
testcase_34 AC 82 ms
10,964 KB
testcase_35 AC 83 ms
10,960 KB
testcase_36 AC 65 ms
10,352 KB
testcase_37 AC 66 ms
10,384 KB
testcase_38 AC 65 ms
10,664 KB
testcase_39 AC 66 ms
10,632 KB
testcase_40 AC 65 ms
10,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <iostream>
#define M 1000000007
using namespace std;
int main(int argc, char** argv) {
    int n, m;
    string s;
    cin >> n >> m >> s;
    vector<int> adj[100100];

    for (int i = 0; i < m; i++) {
        int x, y; cin >> x >> y;
        adj[x].push_back(y); adj[y].push_back(x);
    }
    long long dp[4][100100] = {};
    const string target = "ACDP";
    for (int j = 1; j <= n; j++) if (s[j-1] == 'A') dp[0][j] = 1;
    for (int i = 1; i < 4; i++)
        for (int j = 1; j <= n; j++) {
            if (s[j-1] == target[i])
                for (int k : adj[j]) dp[i][j] += dp[i-1][k];
            dp[i][j] %= M;
        }
    long long ans = 0;
    for (int j = 1; j <= n; j++) ans += dp[3][j];
    cout << ans % M << endl;
}
0