結果

問題 No.762 PDCAパス
ユーザー hamrayhamray
提出日時 2019-06-17 09:03:19
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 3,091 bytes
コンパイル時間 869 ms
コンパイル使用メモリ 104,144 KB
実行使用メモリ 7,292 KB
最終ジャッジ日時 2023-08-17 14:22:40
合計ジャッジ時間 3,834 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,328 KB
testcase_01 AC 3 ms
5,260 KB
testcase_02 AC 3 ms
5,236 KB
testcase_03 AC 3 ms
5,292 KB
testcase_04 AC 2 ms
5,248 KB
testcase_05 AC 3 ms
5,304 KB
testcase_06 AC 3 ms
5,292 KB
testcase_07 AC 3 ms
5,312 KB
testcase_08 AC 3 ms
5,320 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 3 ms
5,128 KB
testcase_11 AC 3 ms
5,332 KB
testcase_12 AC 4 ms
5,392 KB
testcase_13 AC 3 ms
5,148 KB
testcase_14 AC 3 ms
5,428 KB
testcase_15 AC 4 ms
5,388 KB
testcase_16 AC 3 ms
5,320 KB
testcase_17 AC 3 ms
5,388 KB
testcase_18 AC 3 ms
5,300 KB
testcase_19 AC 3 ms
5,292 KB
testcase_20 AC 3 ms
5,448 KB
testcase_21 AC 3 ms
5,328 KB
testcase_22 AC 42 ms
6,024 KB
testcase_23 AC 42 ms
6,020 KB
testcase_24 AC 48 ms
7,292 KB
testcase_25 AC 48 ms
7,268 KB
testcase_26 AC 42 ms
6,968 KB
testcase_27 AC 43 ms
6,976 KB
testcase_28 AC 59 ms
6,804 KB
testcase_29 AC 60 ms
6,964 KB
testcase_30 AC 58 ms
6,672 KB
testcase_31 AC 58 ms
6,748 KB
testcase_32 AC 59 ms
6,640 KB
testcase_33 AC 58 ms
6,480 KB
testcase_34 AC 58 ms
6,520 KB
testcase_35 AC 59 ms
6,552 KB
testcase_36 AC 53 ms
5,996 KB
testcase_37 AC 53 ms
6,048 KB
testcase_38 AC 54 ms
6,064 KB
testcase_39 AC 53 ms
6,052 KB
testcase_40 AC 54 ms
6,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <climits>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
struct Edge {
    int to, cost;
    Edge(int to, int cost): to(to), cost(cost) {}
};

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<Edge>> AdjList;
AdjList graph;

const int INF = 100000000;

LL N, M;
int h[155];
vector<vector<int>> P(100010);
LL dp[100010];
int main() {
    //cout << fixed << setprecision(15);

    cin >> N >> M;

    string S; cin >> S;

    vector<pair<int, int>> path_pd, path_dc, path_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'){
            dp[u] = 1;
            path_pd.emplace_back(u, v);
        }else if(S[u] == 'D' && S[v] == 'C'){
            path_dc.emplace_back(u, v);
        }else if(S[u] =='C' && S[v] == 'A') {
            path_ca.emplace_back(u, v);
        }
    }

    for(auto e: path_pd){
        dp[e.second] = (dp[e.second] + dp[e.first])%MOD;
    }
    for(auto e: path_dc){
        dp[e.second] = (dp[e.second] + dp[e.first])%MOD;
    }
    int ans=0;
    for(auto e: path_ca){
        ans = (ans + dp[e.first])%MOD;
    }

    cout << ans << endl;
    return 0;
}
0