結果

問題 No.762 PDCAパス
ユーザー finefine
提出日時 2018-12-12 18:49:01
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 1,021 bytes
コンパイル時間 1,661 ms
コンパイル使用メモリ 173,884 KB
実行使用メモリ 10,304 KB
最終ジャッジ日時 2023-10-25 08:32:57
合計ジャッジ時間 4,125 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 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 2 ms
4,348 KB
testcase_14 AC 2 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 17 ms
4,348 KB
testcase_23 AC 17 ms
4,348 KB
testcase_24 AC 42 ms
10,304 KB
testcase_25 AC 43 ms
10,304 KB
testcase_26 AC 18 ms
4,564 KB
testcase_27 AC 18 ms
4,564 KB
testcase_28 AC 50 ms
10,040 KB
testcase_29 AC 52 ms
10,040 KB
testcase_30 AC 46 ms
8,720 KB
testcase_31 AC 49 ms
8,456 KB
testcase_32 AC 52 ms
8,720 KB
testcase_33 AC 42 ms
7,400 KB
testcase_34 AC 41 ms
7,400 KB
testcase_35 AC 41 ms
7,400 KB
testcase_36 AC 29 ms
5,412 KB
testcase_37 AC 29 ms
5,412 KB
testcase_38 AC 29 ms
5,412 KB
testcase_39 AC 29 ms
5,412 KB
testcase_40 AC 29 ms
5,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    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<ll> cntp(n, 0);
    for (int i = 0; i < n; i++) {
        if (s[i] != 'P') continue;
        for (int j : g[i]) {
            cntp[j] += (s[j] == 'D');
        }
    }

    vector<ll> cnta(n, 0);
    for (int i = 0; i < n; i++) {
        if (s[i] != 'C') continue;
        for (int j : g[i]) {
            cnta[i] += (s[j] == 'A');
        }
    }

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] != 'D') continue;
        for (int j : g[i]) {
            if (s[j] != 'C') continue;
            (ans += cntp[i] * cnta[j] % MOD) %= MOD;
        }
    }
    cout << ans << endl;
    return 0;
}
0