結果

問題 No.762 PDCAパス
ユーザー mtrhmtrh
提出日時 2022-02-12 22:51:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 1,047 bytes
コンパイル時間 6,482 ms
コンパイル使用メモリ 229,480 KB
実行使用メモリ 14,168 KB
最終ジャッジ日時 2023-09-11 11:26:23
合計ジャッジ時間 8,231 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,504 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,384 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,384 KB
testcase_22 AC 40 ms
4,380 KB
testcase_23 AC 40 ms
4,380 KB
testcase_24 AC 85 ms
14,168 KB
testcase_25 AC 85 ms
14,136 KB
testcase_26 AC 41 ms
4,608 KB
testcase_27 AC 41 ms
4,628 KB
testcase_28 AC 107 ms
14,032 KB
testcase_29 AC 103 ms
13,624 KB
testcase_30 AC 95 ms
11,528 KB
testcase_31 AC 99 ms
11,300 KB
testcase_32 AC 95 ms
11,372 KB
testcase_33 AC 82 ms
8,940 KB
testcase_34 AC 85 ms
8,888 KB
testcase_35 AC 84 ms
8,868 KB
testcase_36 AC 64 ms
5,724 KB
testcase_37 AC 63 ms
5,752 KB
testcase_38 AC 64 ms
5,692 KB
testcase_39 AC 63 ms
5,752 KB
testcase_40 AC 64 ms
5,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#include<atcoder/all>
using namespace atcoder;

using ll=long long;

int main(){
    ll mod=1e9+7;
    int N,M;
    string S;
    cin>>N>>M>>S;
    vector<vector<int>> G(N);
    for(int i=0;i<M;i++){
        int u,v;
        cin>>u>>v;
        u--,v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    vector<vector<ll>> dp(N,vector<ll>(3,0));
    for(int i=0;i<N;i++){
        for(int j:G[i]){
            if(S[i]=='P'&&S[j]=='D'){
                dp[j][0]++;
            }
        }
    }
    for(int i=0;i<N;i++){
        for(int j:G[i]){
            if(S[i]=='D'&&S[j]=='C'){
                dp[j][1]+=dp[i][0];
                dp[j][1]%=mod;
            }
        }
    }
    for(int i=0;i<N;i++){
        for(int j:G[i]){
            if(S[i]=='C'&&S[j]=='A'){
                dp[j][2]+=dp[i][1];
                dp[j][2]%=mod;
            }
        }
    }
    ll ans=0;
    for(int i=0;i<N;i++){
        ans+=dp[i][2];
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}
0