結果

問題 No.762 PDCAパス
ユーザー kriiikriii
提出日時 2018-12-10 00:15:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 745 bytes
コンパイル時間 443 ms
コンパイル使用メモリ 49,368 KB
実行使用メモリ 10,140 KB
最終ジャッジ日時 2023-10-14 21:59:47
合計ジャッジ時間 3,039 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,304 KB
testcase_01 AC 4 ms
5,316 KB
testcase_02 AC 3 ms
5,352 KB
testcase_03 AC 3 ms
5,296 KB
testcase_04 AC 4 ms
5,304 KB
testcase_05 AC 3 ms
5,348 KB
testcase_06 AC 3 ms
5,364 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 4 ms
5,396 KB
testcase_09 AC 3 ms
5,332 KB
testcase_10 AC 3 ms
5,344 KB
testcase_11 AC 3 ms
5,344 KB
testcase_12 AC 3 ms
5,384 KB
testcase_13 AC 4 ms
5,308 KB
testcase_14 AC 3 ms
5,368 KB
testcase_15 AC 3 ms
5,308 KB
testcase_16 AC 4 ms
5,316 KB
testcase_17 AC 4 ms
5,396 KB
testcase_18 AC 3 ms
5,360 KB
testcase_19 AC 3 ms
5,316 KB
testcase_20 AC 3 ms
5,372 KB
testcase_21 AC 4 ms
5,388 KB
testcase_22 AC 20 ms
6,336 KB
testcase_23 AC 20 ms
6,304 KB
testcase_24 AC 43 ms
10,080 KB
testcase_25 AC 43 ms
10,140 KB
testcase_26 AC 22 ms
6,512 KB
testcase_27 AC 21 ms
6,476 KB
testcase_28 AC 59 ms
9,796 KB
testcase_29 AC 58 ms
9,764 KB
testcase_30 AC 51 ms
9,028 KB
testcase_31 AC 52 ms
8,932 KB
testcase_32 AC 52 ms
8,940 KB
testcase_33 AC 46 ms
8,312 KB
testcase_34 AC 45 ms
8,288 KB
testcase_35 AC 45 ms
8,316 KB
testcase_36 AC 33 ms
7,064 KB
testcase_37 AC 34 ms
7,040 KB
testcase_38 AC 34 ms
7,132 KB
testcase_39 AC 34 ms
7,072 KB
testcase_40 AC 34 ms
7,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <vector>
using namespace std;

vector<int> G[100100];
int N,M,D[4][100100]; char S[100100];

int main()
{
	scanf ("%d %d %s",&N,&M,S+1);
	for (int i=0;i<M;i++){
		int x,y; scanf ("%d %d",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
	}

	const int mod = 1000000007;
	for (int i=1;i<=N;i++) if (S[i] == 'P') D[0][i] = 1;
	for (int i=1;i<=N;i++) if (S[i] == 'D') for (int j : G[i]) D[1][i] = (D[1][i] + D[0][j]) % mod;
	for (int i=1;i<=N;i++) if (S[i] == 'C') for (int j : G[i]) D[2][i] = (D[2][i] + D[1][j]) % mod;
	for (int i=1;i<=N;i++) if (S[i] == 'A') for (int j : G[i]) D[3][i] = (D[3][i] + D[2][j]) % mod;
	int ans = 0;
	for (int i=1;i<=N;i++) ans = (ans + D[3][i]) % mod;
	printf ("%d\n",ans);

	return 0;
}
0