結果
問題 | No.762 PDCAパス |
ユーザー |
![]() |
提出日時 | 2018-12-10 00:55:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 24 ms / 2,000 ms |
コード長 | 1,470 bytes |
コンパイル時間 | 1,084 ms |
コンパイル使用メモリ | 124,220 KB |
最終ジャッジ日時 | 2025-01-06 18:47:30 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include<iostream>#include<vector>#include<algorithm>#include<set>#include<map>#include<unordered_map>#include<queue>#include<iomanip>#include<math.h>#include<bitset>#include<cassert>#include<random>#include<time.h>#include<functional>using namespace std;using ll=long long;using ld=long double;using P=pair<ll,ll>;#define MOD 1000000007LL#define INF 1000000000LL#define EPS 1e-10#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)#define REP(i,n) FOR(i,0,n)#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}#define ALL(v) v.begin(),v.end()#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end());#define pb push_back/* --------------------------------------- */int main() {cin.tie(0);ios::sync_with_stdio(false);ll n, m;cin >> n >> m;string s;cin >> s;vector<P> edge(m);vector<ll> cntp(n, 0);vector<ll> cnta(n, 0);REP(i, m) {ll u, v;cin >> u >> v;u--; v--;edge[i] = P(u, v);if(s[u] == 'P') cntp[v]++;if(s[u] == 'A') cnta[v]++;if(s[v] == 'P') cntp[u]++;if(s[v] == 'A') cnta[u]++;}ll ans = 0;REP(i, m) {if(s[edge[i].first] == 'D' && s[edge[i].second] == 'C') {ans += cntp[edge[i].first] * cnta[edge[i].second];ans %= MOD;}if(s[edge[i].first] == 'C' && s[edge[i].second] == 'D') {ans += cnta[edge[i].first] * cntp[edge[i].second];ans %= MOD;}}cout << ans << endl;return 0;}/* --------------------------------------- */