結果

問題 No.762 PDCAパス
ユーザー ngtkanangtkana
提出日時 2020-03-14 20:46:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 1,090 bytes
コンパイル時間 2,068 ms
コンパイル使用メモリ 204,540 KB
実行使用メモリ 10,464 KB
最終ジャッジ日時 2023-08-15 14:01:34
合計ジャッジ時間 5,151 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 18 ms
4,808 KB
testcase_23 AC 18 ms
4,920 KB
testcase_24 AC 39 ms
10,136 KB
testcase_25 AC 38 ms
10,192 KB
testcase_26 AC 19 ms
5,428 KB
testcase_27 AC 19 ms
5,504 KB
testcase_28 AC 48 ms
10,464 KB
testcase_29 AC 46 ms
10,284 KB
testcase_30 AC 45 ms
9,392 KB
testcase_31 AC 44 ms
9,504 KB
testcase_32 AC 47 ms
9,356 KB
testcase_33 AC 44 ms
7,980 KB
testcase_34 AC 40 ms
8,080 KB
testcase_35 AC 42 ms
7,976 KB
testcase_36 AC 32 ms
6,528 KB
testcase_37 AC 31 ms
6,532 KB
testcase_38 AC 31 ms
6,488 KB
testcase_39 AC 31 ms
6,556 KB
testcase_40 AC 32 ms
6,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define endl enjoy_codeforces
using lint=long long;
lint mod=1'000'000'007;
void add_eq(lint&x,lint y){x+=y;if(mod<=x)x-=mod;}
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    lint n,m;std::cin>>n>>m;
    std::vector<lint>a(n);
    for(lint i=0;i<n;i++){
        char c;std::cin>>c;
        if(c=='P')a.at(i)=0;
        if(c=='D')a.at(i)=1;
        if(c=='C')a.at(i)=2;
        if(c=='A')a.at(i)=3;
    }
    std::vector<std::vector<lint>>g(n);
    for(lint i=0;i<m;i++){
        lint u,v;std::cin>>u>>v;u--,v--;
        g.at(u).push_back(v);
        g.at(v).push_back(u);
    }
    std::vector<lint>dp(n);
    for(lint i=0;i<n;i++)dp.at(i)=a.at(i)==0;
    for(lint i=0;i<3;i++){
        for(lint j=0;j<n;j++){
            if(a.at(j)!=i)continue;
            for(lint k:g.at(j)){
                if(a.at(k)!=i+1)continue;
                add_eq(dp.at(k),dp.at(j));
            }
        }
    }
    lint ans=0;
    for(lint i=0;i<n;i++){
        if(a.at(i)!=3)continue;
        add_eq(ans,dp.at(i));
    }
    std::cout<<ans<<'\n';
}
0