結果

問題 No.762 PDCAパス
ユーザー aaaaaaiuaaaaaaiu
提出日時 2019-08-21 16:24:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 752 bytes
コンパイル時間 2,186 ms
コンパイル使用メモリ 199,268 KB
実行使用メモリ 9,984 KB
最終ジャッジ日時 2024-04-17 11:44:39
合計ジャッジ時間 5,301 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 3 ms
6,944 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 1 ms
6,944 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 45 ms
6,940 KB
testcase_23 AC 45 ms
6,940 KB
testcase_24 AC 72 ms
9,856 KB
testcase_25 AC 70 ms
9,984 KB
testcase_26 AC 46 ms
6,940 KB
testcase_27 AC 46 ms
6,944 KB
testcase_28 AC 91 ms
9,472 KB
testcase_29 AC 94 ms
9,472 KB
testcase_30 AC 84 ms
8,320 KB
testcase_31 AC 86 ms
8,448 KB
testcase_32 AC 84 ms
8,576 KB
testcase_33 AC 78 ms
7,424 KB
testcase_34 AC 77 ms
7,424 KB
testcase_35 AC 82 ms
7,424 KB
testcase_36 AC 66 ms
6,940 KB
testcase_37 AC 68 ms
6,944 KB
testcase_38 AC 67 ms
6,944 KB
testcase_39 AC 66 ms
6,944 KB
testcase_40 AC 68 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int n,m;
    cin>>n>>m;
    string s;cin>>s;
    vector<int> g[n];
    ll dp[n]{};
    for (int i=0;i<m;i++) {
        int v,u;cin>>v>>u;
        v--,u--;
        if (s[v]=='P') dp[v]=1;
        if (s[u]=='P') dp[u]=1;
        g[v].push_back(u);
        g[u].push_back(v);
    }
    string pdca="PDCA";
    ll ans=0;
    int mod=1e9+7;
    for (int i=0;i<3;i++)
        for (int j=0;j<n;j++)
            if (s[j]==pdca[i])
                for (int u:g[j])
                    if (s[u]==pdca[i+1]) {
                        if (i==2) ans=(ans+dp[j])%mod;
                        else dp[u]=(dp[u]+dp[j])%mod;
                    }
    cout<<ans<<endl;
    return 0;
}
0