結果

問題 No.762 PDCAパス
ユーザー 41Toame41Toame
提出日時 2018-12-22 19:16:10
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 987 bytes
コンパイル時間 1,805 ms
コンパイル使用メモリ 162,312 KB
実行使用メモリ 12,564 KB
最終ジャッジ日時 2023-10-26 02:09:41
合計ジャッジ時間 7,781 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
12,564 KB
testcase_01 AC 4 ms
5,832 KB
testcase_02 AC 3 ms
5,832 KB
testcase_03 AC 3 ms
5,828 KB
testcase_04 AC 4 ms
5,828 KB
testcase_05 AC 4 ms
5,828 KB
testcase_06 AC 4 ms
5,828 KB
testcase_07 AC 3 ms
5,828 KB
testcase_08 AC 3 ms
5,828 KB
testcase_09 AC 3 ms
5,832 KB
testcase_10 AC 4 ms
5,832 KB
testcase_11 AC 3 ms
5,832 KB
testcase_12 AC 4 ms
5,832 KB
testcase_13 AC 4 ms
5,828 KB
testcase_14 AC 4 ms
5,828 KB
testcase_15 AC 3 ms
5,832 KB
testcase_16 AC 4 ms
5,832 KB
testcase_17 AC 3 ms
5,832 KB
testcase_18 AC 4 ms
5,832 KB
testcase_19 AC 3 ms
5,832 KB
testcase_20 AC 3 ms
5,832 KB
testcase_21 AC 3 ms
5,832 KB
testcase_22 AC 1,095 ms
6,524 KB
testcase_23 AC 1,094 ms
6,524 KB
testcase_24 AC 38 ms
9,064 KB
testcase_25 AC 38 ms
9,064 KB
testcase_26 TLE -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

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
vector<int> v[100010];
string S;
char s[3] = {'D', 'C', 'A'};
int ans = 0;

void search(int a, int depth) {
    if (depth == 3) {
        ans++;
        return;
    }
    for(auto e : v[a]){
        if (S[e] == s[depth]) search(e, depth + 1);
    }
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M; cin >> N >> M;
    cin >> S;
    rep(i, M) {
        int a, b; cin >> a >> b;
        a--; b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    rep(i, N) {
        if (S[i] == 'P') search(i, 0);
    }
    cout << ans << endl;

    return 0;
}
0