結果
| 問題 |
No.762 PDCAパス
|
| コンテスト | |
| ユーザー |
TAISA_
|
| 提出日時 | 2018-12-21 02:01:57 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 84 ms / 2,000 ms |
| コード長 | 788 bytes |
| コンパイル時間 | 1,542 ms |
| コンパイル使用メモリ | 174,124 KB |
| 実行使用メモリ | 10,368 KB |
| 最終ジャッジ日時 | 2024-09-25 09:15:44 |
| 合計ジャッジ時間 | 4,085 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-9;
const ll MOD=1e9+7;
int main(){
int n,m;cin>>n>>m;
vector<vector<int>> G(n);
string s;cin>>s;
vector<ll> p(n),a(n);
for(int i=0;i<m;i++){
int u,v;cin>>u>>v;--u;--v;
G[u].push_back(v);
G[v].push_back(u);
if(s[u]=='P')p[v]++;
if(s[u]=='A')a[v]++;
if(s[v]=='P')p[u]++;
if(s[v]=='A')a[u]++;
}
ll ans=0;
for(int i=0;i<n;i++){
for(auto e:G[i]){
if(s[i]=='D'&&s[e]=='C'){
ans+=p[i]*a[e]%MOD;
ans%=MOD;
}
}
}
cout<<ans<<endl;
}
TAISA_