結果

問題 No.762 PDCAパス
ユーザー chocoruskchocorusk
提出日時 2018-12-10 00:08:51
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 1,069 bytes
コンパイル時間 944 ms
コンパイル使用メモリ 95,832 KB
実行使用メモリ 9,760 KB
最終ジャッジ日時 2023-10-14 21:59:33
合計ジャッジ時間 4,147 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,452 KB
testcase_01 AC 3 ms
6,588 KB
testcase_02 AC 4 ms
6,636 KB
testcase_03 AC 3 ms
6,448 KB
testcase_04 AC 3 ms
6,660 KB
testcase_05 AC 4 ms
6,452 KB
testcase_06 AC 3 ms
6,580 KB
testcase_07 AC 3 ms
6,440 KB
testcase_08 AC 4 ms
6,444 KB
testcase_09 AC 3 ms
6,528 KB
testcase_10 AC 3 ms
6,516 KB
testcase_11 AC 3 ms
6,660 KB
testcase_12 AC 3 ms
6,528 KB
testcase_13 AC 3 ms
6,440 KB
testcase_14 AC 3 ms
6,444 KB
testcase_15 AC 3 ms
6,580 KB
testcase_16 AC 3 ms
6,788 KB
testcase_17 AC 4 ms
6,680 KB
testcase_18 AC 3 ms
6,452 KB
testcase_19 AC 4 ms
6,660 KB
testcase_20 AC 3 ms
6,460 KB
testcase_21 AC 3 ms
6,512 KB
testcase_22 AC 42 ms
7,376 KB
testcase_23 AC 41 ms
7,392 KB
testcase_24 AC 69 ms
9,760 KB
testcase_25 AC 67 ms
9,736 KB
testcase_26 AC 42 ms
7,596 KB
testcase_27 AC 43 ms
7,672 KB
testcase_28 AC 93 ms
9,336 KB
testcase_29 AC 90 ms
9,396 KB
testcase_30 AC 84 ms
8,980 KB
testcase_31 AC 80 ms
9,060 KB
testcase_32 AC 88 ms
9,148 KB
testcase_33 AC 75 ms
8,688 KB
testcase_34 AC 82 ms
8,668 KB
testcase_35 AC 75 ms
8,668 KB
testcase_36 AC 61 ms
7,984 KB
testcase_37 AC 62 ms
7,980 KB
testcase_38 AC 63 ms
8,036 KB
testcase_39 AC 62 ms
8,212 KB
testcase_40 AC 64 ms
7,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
	ll ct[100000]={};
	int n, m;
	cin>>n>>m;
	string s;
	cin>>s;
	vector<int> g[100000];
	for(int i=0; i<m; i++){
		int u, v;
		cin>>u>>v;
		u--; v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for(int i=0; i<n; i++){
		if(s[i]=='P'){
			ct[i]=1;
			for(auto y:g[i]){
				if(s[y]=='D'){
					ct[y]++;
				}
			}
		}
	}
	for(int i=0; i<n; i++){
		if(s[i]=='D'){
			for(auto y:g[i]){
				if(s[y]=='C'){
					ct[y]+=ct[i];
				}
			}
		}
	}
	ll ans=0;
	for(int i=0; i<n; i++){
		if(s[i]=='C'){
			for(auto y:g[i]){
				if(s[y]=='A'){
					ct[y]+=ct[i];
				}
			}
		}
	}
	for(int i=0; i<n; i++){
		if(s[i]=='A') ans=(ans+ct[i])%MOD;
	}
	cout<<ans<<endl;
	return 0;
}
0