結果
| 問題 |
No.762 PDCAパス
|
| コンテスト | |
| ユーザー |
matsukin1111
|
| 提出日時 | 2019-04-10 12:19:02 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,287 bytes |
| コンパイル時間 | 968 ms |
| コンパイル使用メモリ | 97,132 KB |
| 実行使用メモリ | 14,928 KB |
| 最終ジャッジ日時 | 2024-07-06 20:28:22 |
| 合計ジャッジ時間 | 9,032 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 TLE * 1 -- * 14 |
ソースコード
#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;
}
matsukin1111