結果

問題 No.762 PDCAパス
ユーザー SSRSSSRS
提出日時 2020-11-26 07:07:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 767 bytes
コンパイル時間 731 ms
コンパイル使用メモリ 77,408 KB
実行使用メモリ 12,684 KB
最終ジャッジ日時 2023-10-01 03:13:22
合計ジャッジ時間 3,696 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 40 ms
4,380 KB
testcase_23 AC 39 ms
4,380 KB
testcase_24 AC 75 ms
12,684 KB
testcase_25 AC 75 ms
12,540 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 98 ms
12,348 KB
testcase_29 AC 94 ms
12,288 KB
testcase_30 AC 86 ms
10,264 KB
testcase_31 AC 87 ms
10,200 KB
testcase_32 AC 90 ms
10,216 KB
testcase_33 AC 79 ms
8,316 KB
testcase_34 AC 80 ms
8,456 KB
testcase_35 AC 79 ms
8,416 KB
testcase_36 AC 61 ms
5,588 KB
testcase_37 AC 61 ms
5,456 KB
testcase_38 AC 62 ms
5,436 KB
testcase_39 AC 61 ms
5,424 KB
testcase_40 AC 63 ms
5,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
const long long MOD = 1000000007;
int main(){
	int N, M;
	cin >> N >> M;
	string S;
	cin >> S;
	vector<vector<int>> E(N);
	for (int i = 0; i < M; i++){
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		E[u].push_back(v);
		E[v].push_back(u);
	}
	string T = "PDCA";
	vector<vector<long long>> dp(4, vector<long long>(N, 0));
	for (int i = 0; i < N; i++){
		if (S[i] == T[0]){
			dp[0][i] = 1;
		}
	}
	for (int i = 0; i < 3; i++){
		for (int j = 0; j < N; j++){
			if (S[j] == T[i]){
				for (int k : E[j]){
					if (S[k] == T[i + 1]){
						dp[i + 1][k] += dp[i][j];
						dp[i + 1][k] %= MOD;
					}
				}
			}
		}
	}
	long long ans = 0;
	for (int i = 0; i < N; i++){
		ans += dp[3][i];
	}
	cout << ans << endl;
}
0