結果

問題 No.762 PDCAパス
ユーザー 41Toame41Toame
提出日時 2018-12-22 20:23:52
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 1,242 bytes
コンパイル時間 1,532 ms
コンパイル使用メモリ 163,492 KB
実行使用メモリ 10,224 KB
最終ジャッジ日時 2023-10-26 02:11:15
合計ジャッジ時間 4,083 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,572 KB
testcase_01 AC 3 ms
7,572 KB
testcase_02 AC 3 ms
7,572 KB
testcase_03 AC 3 ms
7,572 KB
testcase_04 AC 3 ms
7,572 KB
testcase_05 AC 3 ms
7,568 KB
testcase_06 AC 3 ms
7,572 KB
testcase_07 AC 3 ms
7,572 KB
testcase_08 AC 3 ms
7,572 KB
testcase_09 AC 3 ms
7,572 KB
testcase_10 AC 3 ms
7,572 KB
testcase_11 AC 2 ms
7,572 KB
testcase_12 AC 3 ms
7,576 KB
testcase_13 AC 3 ms
7,572 KB
testcase_14 AC 3 ms
7,568 KB
testcase_15 AC 3 ms
7,572 KB
testcase_16 AC 3 ms
7,576 KB
testcase_17 AC 3 ms
7,572 KB
testcase_18 AC 3 ms
7,572 KB
testcase_19 AC 3 ms
7,572 KB
testcase_20 AC 3 ms
7,572 KB
testcase_21 AC 3 ms
7,572 KB
testcase_22 AC 23 ms
9,192 KB
testcase_23 AC 22 ms
9,192 KB
testcase_24 AC 24 ms
10,224 KB
testcase_25 AC 24 ms
10,224 KB
testcase_26 AC 28 ms
9,352 KB
testcase_27 AC 28 ms
9,332 KB
testcase_28 AC 27 ms
10,144 KB
testcase_29 AC 29 ms
10,148 KB
testcase_30 AC 28 ms
10,012 KB
testcase_31 AC 27 ms
10,016 KB
testcase_32 AC 28 ms
10,016 KB
testcase_33 AC 27 ms
9,764 KB
testcase_34 AC 28 ms
9,764 KB
testcase_35 AC 28 ms
9,768 KB
testcase_36 AC 26 ms
9,388 KB
testcase_37 AC 26 ms
9,392 KB
testcase_38 AC 26 ms
9,392 KB
testcase_39 AC 27 ms
9,392 KB
testcase_40 AC 26 ms
9,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int a[2][100010], b[2][100010];
vector<int> c[100010];
int DCA[100010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ans = 0;
    int N, M; cin >> N >> M;
    string S; cin >> S;

    rep(i, M) {
        cin >> a[0][i] >> b[0][i];
        a[0][i]--; b[0][i]--;
    }
    rep(i, M) {
        a[1][i] = b[0][i];
        b[1][i] = a[0][i];
    }

    rep(j, 2) rep(i, M) if (S[a[j][i]] == 'D' && S[b[j][i]] == 'C') c[b[j][i]].push_back(a[j][i] + 1);
    rep(j, 2) rep(i, M) rep(k, c[a[j][i]].size()) if (S[b[j][i]] == 'A' && c[a[j][i]][k] != 0) DCA[c[a[j][i]][k] - 1]++;
    //rep(i, N) cout << DCA[i] << endl;
    rep(j, 2){
        rep(i, M) {
            if (S[a[j][i]] == 'P' && S[b[j][i]] == 'D') ans = (ans + DCA[b[j][i]]) % mod; 
        }
    }
    cout << ans << endl;

    return 0;
}
0