結果
| 問題 | No.762 PDCAパス | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-11-17 14:15:04 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 65 ms / 2,000 ms | 
| コード長 | 568 bytes | 
| コンパイル時間 | 1,751 ms | 
| コンパイル使用メモリ | 196,724 KB | 
| 最終ジャッジ日時 | 2025-01-25 18:59:07 | 
| ジャッジサーバーID (参考情報) | judge5 / 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)
using ll=long long;
template<class T>using V=vector<T>;
constexpr ll mod = 1000000007;
int main() {
	int n,m;cin>>n>>m;
	string s;cin>>s;
	V<ll> d(n),c(n);
	V<pair<int,int>> edge(m);
	for(auto& [a,b]:edge){
		cin>>a>>b;
		--a,--b;
		if(s[a]=='P' and s[b]=='D')++d[b];
		if(s[a]=='D' and s[b]=='P')++d[a];
		if(s[a]=='C' and s[b]=='A')++c[a];
		if(s[a]=='A' and s[b]=='C')++c[b];
	}
	ll ans=0;
	for(auto [a,b]:edge)ans=(ans+d[a]*c[b]+d[b]*c[a])%mod;
	cout<<ans<<"\n";
	
	return 0;
}
            
            
            
        