結果

問題 No.762 PDCAパス
ユーザー 25__toma25__toma
提出日時 2019-03-26 04:55:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 1,018 bytes
コンパイル時間 1,608 ms
コンパイル使用メモリ 169,216 KB
実行使用メモリ 9,728 KB
最終ジャッジ日時 2024-04-19 07:38:08
合計ジャッジ時間 4,821 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 39 ms
5,376 KB
testcase_23 AC 41 ms
5,376 KB
testcase_24 AC 66 ms
9,728 KB
testcase_25 AC 70 ms
9,600 KB
testcase_26 AC 45 ms
5,376 KB
testcase_27 AC 45 ms
5,376 KB
testcase_28 AC 87 ms
9,216 KB
testcase_29 AC 89 ms
9,344 KB
testcase_30 AC 84 ms
8,064 KB
testcase_31 AC 86 ms
8,064 KB
testcase_32 AC 87 ms
8,064 KB
testcase_33 AC 77 ms
7,040 KB
testcase_34 AC 80 ms
6,944 KB
testcase_35 AC 79 ms
6,912 KB
testcase_36 AC 67 ms
5,376 KB
testcase_37 AC 65 ms
5,376 KB
testcase_38 AC 66 ms
5,376 KB
testcase_39 AC 65 ms
5,376 KB
testcase_40 AC 77 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include"bits/stdc++.h"

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
	int N, M;
	string S;
	cin >> N >> M >> S;
	vector<ll> score(N);
	vector<vector<int>> edges(N);
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}

	ll res = 0;
	REP(from, N)if (S[from] == 'C')for (auto to : edges[from])if (S[to] == 'A')score[from]++;
	REP(from, N)if (S[from] == 'D')for (auto to : edges[from])if (S[to] == 'C')score[from] = (score[from] + score[to]) % MOD;
	REP(from, N)if (S[from] == 'P')for (auto to : edges[from])if (S[to] == 'D')res = (res + score[to]) % MOD;
	cout << res << endl;

	return 0;
}
0