結果

問題 No.762 PDCAパス
ユーザー MayimgMayimg
提出日時 2019-02-22 13:46:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 697 bytes
コンパイル時間 2,438 ms
コンパイル使用メモリ 200,520 KB
実行使用メモリ 10,952 KB
最終ジャッジ日時 2023-08-16 01:30:05
合計ジャッジ時間 8,301 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
10,104 KB
testcase_01 AC 4 ms
5,832 KB
testcase_02 AC 3 ms
5,720 KB
testcase_03 AC 4 ms
5,708 KB
testcase_04 AC 3 ms
5,824 KB
testcase_05 AC 3 ms
5,788 KB
testcase_06 AC 3 ms
5,684 KB
testcase_07 AC 3 ms
5,764 KB
testcase_08 AC 3 ms
5,688 KB
testcase_09 AC 3 ms
5,728 KB
testcase_10 AC 3 ms
5,772 KB
testcase_11 AC 3 ms
5,692 KB
testcase_12 AC 3 ms
5,796 KB
testcase_13 AC 3 ms
5,728 KB
testcase_14 AC 3 ms
5,920 KB
testcase_15 AC 3 ms
5,704 KB
testcase_16 AC 4 ms
5,860 KB
testcase_17 AC 4 ms
5,792 KB
testcase_18 AC 4 ms
5,696 KB
testcase_19 AC 3 ms
5,712 KB
testcase_20 AC 3 ms
5,768 KB
testcase_21 AC 3 ms
5,704 KB
testcase_22 TLE -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
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 #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int n, m;
string s, t = "PDCA";
vector<int> g[100005];
int dfs(int cur, int depth) {
	if (s[cur] != t[depth]) return 0;
	else {
		if (depth == 3) return 1;
		int res = 0;
		for (int nbr : g[cur]) {
			res += dfs(nbr, depth + 1);
			res %= mod;
		}
		return res;
	}
}
signed main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	cin >> s;
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'P') ans = ans + dfs(i, 0) % mod;
	}
	cout << ans << endl;
	return 0;	
}
0