結果

問題 No.762 PDCAパス
ユーザー tokutoku
提出日時 2019-02-18 23:43:31
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,206 bytes
コンパイル時間 1,502 ms
コンパイル使用メモリ 163,296 KB
実行使用メモリ 8,960 KB
最終ジャッジ日時 2024-04-17 05:09:15
合計ジャッジ時間 10,385 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,632 KB
testcase_01 AC 3 ms
5,760 KB
testcase_02 AC 3 ms
5,760 KB
testcase_03 AC 4 ms
5,632 KB
testcase_04 AC 3 ms
5,760 KB
testcase_05 AC 4 ms
5,760 KB
testcase_06 AC 3 ms
5,632 KB
testcase_07 AC 4 ms
5,760 KB
testcase_08 AC 4 ms
5,504 KB
testcase_09 AC 4 ms
5,632 KB
testcase_10 AC 4 ms
5,632 KB
testcase_11 AC 3 ms
5,760 KB
testcase_12 AC 4 ms
5,760 KB
testcase_13 AC 4 ms
5,760 KB
testcase_14 AC 3 ms
5,632 KB
testcase_15 AC 3 ms
5,504 KB
testcase_16 AC 3 ms
5,632 KB
testcase_17 AC 4 ms
5,760 KB
testcase_18 AC 4 ms
5,632 KB
testcase_19 AC 4 ms
5,632 KB
testcase_20 AC 4 ms
5,760 KB
testcase_21 AC 3 ms
5,760 KB
testcase_22 AC 826 ms
6,784 KB
testcase_23 AC 826 ms
6,784 KB
testcase_24 AC 65 ms
8,960 KB
testcase_25 AC 60 ms
8,960 KB
testcase_26 TLE -
testcase_27 TLE -
testcase_28 AC 83 ms
8,704 KB
testcase_29 AC 80 ms
8,704 KB
testcase_30 AC 78 ms
8,116 KB
testcase_31 AC 77 ms
8,192 KB
testcase_32 AC 75 ms
8,192 KB
testcase_33 AC 72 ms
7,808 KB
testcase_34 AC 73 ms
7,892 KB
testcase_35 AC 76 ms
7,808 KB
testcase_36 AC 68 ms
7,168 KB
testcase_37 AC 70 ms
7,168 KB
testcase_38 AC 70 ms
7,168 KB
testcase_39 AC 69 ms
7,168 KB
testcase_40 AC 69 ms
7,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;

VI a[100005];
string s;

ll ans = 0;

void dfs(int b, int c) {
	for (int i : a[b]) {
		if (c == 1 && s[i] == 'D')dfs(i, 2);
		else if (c == 2 && s[i] == 'C')dfs(i, 3);
		else if (c == 3 && s[i] == 'A')ans++;
	}
}


int main() {

	int n, m;
	cin >> n >> m >> s;

	REP(i, m) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		a[u].push_back(v);
		a[v].push_back(u);
	}

	REP(i, n) {
		if (s[i] == 'P') dfs(i, 1);
	}

	cout << ans << endl;

	

	return 0;
	
}
0