結果
| 問題 |
No.762 PDCAパス
|
| コンテスト | |
| ユーザー |
iqueue02
|
| 提出日時 | 2019-10-26 14:36:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 64 ms / 2,000 ms |
| コード長 | 826 bytes |
| コンパイル時間 | 1,815 ms |
| コンパイル使用メモリ | 170,900 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-14 08:03:56 |
| 合計ジャッジ時間 | 5,205 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1e9+7;
int dp[100010];
int main(){
int n, m;
cin >> n >> m;
string s;
cin >> s;
vector<P> pd, dc, ca;
rep(i,m) {
int u, v;
cin >> u >> v;
u--; v--;
if (s[u] < s[v]) swap(u,v);
if (s[u] == 'P' && s[v] == 'D') pd.push_back({u,v}), dp[u] = 1;
if (s[u] == 'D' && s[v] == 'C') dc.push_back({u,v});
if (s[u] == 'C' && s[v] == 'A') ca.push_back({u,v});
}
for (auto e : pd) {
(dp[e.second] += dp[e.first]) %= mod;
}
for (auto e : dc) {
(dp[e.second] += dp[e.first]) %= mod;
}
int res = 0;
for (auto e : ca) {
(res += dp[e.first]) %= mod;
}
cout << res << endl;
return 0;
}
iqueue02