結果

問題 No.762 PDCAパス
ユーザー TAISA_TAISA_
提出日時 2018-12-21 02:01:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 788 bytes
コンパイル時間 4,001 ms
コンパイル使用メモリ 173,248 KB
実行使用メモリ 10,440 KB
最終ジャッジ日時 2023-10-26 01:15:33
合計ジャッジ時間 6,848 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 41 ms
4,568 KB
testcase_23 AC 41 ms
4,568 KB
testcase_24 AC 61 ms
10,440 KB
testcase_25 AC 63 ms
10,440 KB
testcase_26 AC 41 ms
4,792 KB
testcase_27 AC 44 ms
4,796 KB
testcase_28 AC 81 ms
10,176 KB
testcase_29 AC 85 ms
10,176 KB
testcase_30 AC 75 ms
8,592 KB
testcase_31 AC 76 ms
8,592 KB
testcase_32 AC 77 ms
8,592 KB
testcase_33 AC 73 ms
7,536 KB
testcase_34 AC 71 ms
7,536 KB
testcase_35 AC 73 ms
7,536 KB
testcase_36 AC 60 ms
5,424 KB
testcase_37 AC 63 ms
5,424 KB
testcase_38 AC 60 ms
5,424 KB
testcase_39 AC 58 ms
5,424 KB
testcase_40 AC 61 ms
5,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-9;
const ll MOD=1e9+7;
int main(){
    int n,m;cin>>n>>m;
    vector<vector<int>> G(n);
    string s;cin>>s;
    vector<ll> p(n),a(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);
        if(s[u]=='P')p[v]++;
        if(s[u]=='A')a[v]++;
        if(s[v]=='P')p[u]++;
        if(s[v]=='A')a[u]++;
    }    
    ll ans=0;
    for(int i=0;i<n;i++){
        for(auto e:G[i]){
            if(s[i]=='D'&&s[e]=='C'){
                ans+=p[i]*a[e]%MOD;
                ans%=MOD;
            }
        }
    }
    cout<<ans<<endl;
}
0