結果

問題 No.762 PDCAパス
ユーザー kotatsugamekotatsugame
提出日時 2018-12-13 00:29:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 547 bytes
コンパイル時間 765 ms
コンパイル使用メモリ 71,068 KB
実行使用メモリ 13,664 KB
最終ジャッジ日時 2023-10-25 08:40:16
合計ジャッジ時間 4,388 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,384 KB
testcase_01 AC 4 ms
8,384 KB
testcase_02 AC 4 ms
8,388 KB
testcase_03 AC 4 ms
8,384 KB
testcase_04 AC 4 ms
8,384 KB
testcase_05 AC 4 ms
8,380 KB
testcase_06 AC 4 ms
8,384 KB
testcase_07 AC 4 ms
8,384 KB
testcase_08 AC 3 ms
8,384 KB
testcase_09 AC 4 ms
8,384 KB
testcase_10 AC 3 ms
8,384 KB
testcase_11 AC 4 ms
8,384 KB
testcase_12 AC 4 ms
8,384 KB
testcase_13 AC 4 ms
8,384 KB
testcase_14 AC 3 ms
8,380 KB
testcase_15 AC 4 ms
8,388 KB
testcase_16 AC 4 ms
8,388 KB
testcase_17 AC 4 ms
8,388 KB
testcase_18 AC 4 ms
8,388 KB
testcase_19 AC 4 ms
8,388 KB
testcase_20 AC 3 ms
8,388 KB
testcase_21 AC 4 ms
8,388 KB
testcase_22 AC 48 ms
9,324 KB
testcase_23 AC 48 ms
9,324 KB
testcase_24 AC 79 ms
13,664 KB
testcase_25 AC 78 ms
13,664 KB
testcase_26 AC 48 ms
9,536 KB
testcase_27 AC 48 ms
9,536 KB
testcase_28 AC 102 ms
13,320 KB
testcase_29 AC 103 ms
13,320 KB
testcase_30 AC 101 ms
12,900 KB
testcase_31 AC 102 ms
12,896 KB
testcase_32 AC 102 ms
12,904 KB
testcase_33 AC 95 ms
10,548 KB
testcase_34 AC 88 ms
10,548 KB
testcase_35 AC 91 ms
10,548 KB
testcase_36 AC 74 ms
9,920 KB
testcase_37 AC 73 ms
9,916 KB
testcase_38 AC 72 ms
9,916 KB
testcase_39 AC 72 ms
9,920 KB
testcase_40 AC 72 ms
9,916 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;
long m=1e9+7,dp[1<<17][4];
vector<int>G[1<<17];
int n,M;
string s;
main()
{
	cin>>n>>M>>s;
	for(int i=0;i<M;i++)
	{
		int a,b;cin>>a>>b;a--,b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for(int i=0;i<n;i++)if(s[i]=='P')dp[i][0]=1;
	for(int j=0;j<3;j++)
	{
		for(int i=0;i<n;i++)
		{
			for(int k=0;k<G[i].size();k++)
				if(s[G[i][k]]=="PDCA"[j+1])
					dp[G[i][k]][j+1]=(dp[G[i][k]][j+1]+dp[i][j])%m;
		}
	}
	long ans=0;
	for(int i=0;i<n;i++)ans=(ans+dp[i][3])%m;
	cout<<ans<<endl;
}
0