結果

問題 No.762 PDCAパス
ユーザー matsukin1111matsukin1111
提出日時 2019-04-10 12:19:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,287 bytes
コンパイル時間 959 ms
コンパイル使用メモリ 94,768 KB
実行使用メモリ 9,244 KB
最終ジャッジ日時 2023-09-21 01:44:23
合計ジャッジ時間 9,778 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,840 KB
testcase_01 AC 3 ms
5,784 KB
testcase_02 AC 4 ms
5,736 KB
testcase_03 AC 3 ms
5,744 KB
testcase_04 AC 3 ms
5,724 KB
testcase_05 AC 3 ms
5,784 KB
testcase_06 AC 3 ms
5,776 KB
testcase_07 AC 3 ms
5,772 KB
testcase_08 AC 3 ms
5,792 KB
testcase_09 AC 3 ms
5,744 KB
testcase_10 AC 3 ms
5,744 KB
testcase_11 AC 4 ms
5,772 KB
testcase_12 AC 3 ms
5,740 KB
testcase_13 AC 3 ms
5,792 KB
testcase_14 AC 3 ms
5,768 KB
testcase_15 AC 3 ms
5,776 KB
testcase_16 AC 4 ms
5,732 KB
testcase_17 AC 3 ms
5,780 KB
testcase_18 AC 3 ms
5,740 KB
testcase_19 AC 3 ms
5,860 KB
testcase_20 AC 3 ms
5,776 KB
testcase_21 AC 3 ms
6,012 KB
testcase_22 AC 1,616 ms
7,404 KB
testcase_23 AC 1,616 ms
7,464 KB
testcase_24 AC 68 ms
9,072 KB
testcase_25 AC 69 ms
9,244 KB
testcase_26 TLE -
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 #

#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };

ll n, m;
string s;
vector<ll>e[101010];
ll used[101010];


ll dfs(ll v,char c) {
	if (c == 'A')return 1;

	ll temp = 0;
	fore(x,e[v]) {
		if ((c == 'P' && s[x] == 'D') || (c == 'D' && s[x] == 'C') || (c == 'C' && s[x] == 'A')) {
			temp += dfs(x,s[x]);
		}
	}
	return temp;
}



int main() {
	cin >> n >> m >> s;

	rep(i, 0, m) {
		ll u, v;
		cin >> u >> v;
		u--, v--;
		e[u].pb(v);
		e[v].pb(u);
	}

	ll ans = 0;
	rep(i, 0, n) {
		if (s[i] == 'P') {
			ans += dfs(i,'P');
			ans %= MOD;
		}
	}
	cout << ans << endl;
	
	return 0;
}
0