結果

問題 No.762 PDCAパス
ユーザー eQeeQe
提出日時 2020-05-05 02:42:32
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,009 bytes
コンパイル時間 2,674 ms
コンパイル使用メモリ 146,900 KB
実行使用メモリ 12,372 KB
最終ジャッジ日時 2023-09-07 21:37:42
合計ジャッジ時間 11,194 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,056 KB
testcase_01 AC 3 ms
5,816 KB
testcase_02 AC 4 ms
5,904 KB
testcase_03 AC 4 ms
5,748 KB
testcase_04 AC 3 ms
5,816 KB
testcase_05 AC 3 ms
5,728 KB
testcase_06 AC 3 ms
5,880 KB
testcase_07 AC 3 ms
5,772 KB
testcase_08 AC 3 ms
5,788 KB
testcase_09 AC 3 ms
5,752 KB
testcase_10 AC 3 ms
5,724 KB
testcase_11 AC 3 ms
5,712 KB
testcase_12 AC 3 ms
5,752 KB
testcase_13 AC 3 ms
5,756 KB
testcase_14 AC 3 ms
5,748 KB
testcase_15 AC 3 ms
5,764 KB
testcase_16 AC 3 ms
5,820 KB
testcase_17 AC 3 ms
5,788 KB
testcase_18 AC 3 ms
5,760 KB
testcase_19 AC 3 ms
5,728 KB
testcase_20 AC 3 ms
5,788 KB
testcase_21 AC 4 ms
5,756 KB
testcase_22 AC 1,186 ms
7,432 KB
testcase_23 AC 1,188 ms
7,420 KB
testcase_24 AC 70 ms
9,768 KB
testcase_25 AC 69 ms
9,768 KB
testcase_26 TLE -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b)
#define chmin(a, b) (a)=min(a, b)
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

ll N, M;
vector<ll> g[MAX];
ll a[MAX];

ll dfs(ll u) {
  if(a[u]==3) return 1;
  
  ll res=0;
  for(auto v:g[u]) if(a[u]+1==a[v]) moC(res, +, dfs(v));
  
  return res;
}

int main(void) {
  ll i, j, k;
  
  cin >> N >> M;
  string s;
  cin >> s;
  
  for(i=0; i<N; i++) {
    if(s[i]=='P') a[i]=0;
    if(s[i]=='D') a[i]=1;
    if(s[i]=='C') a[i]=2;
    if(s[i]=='A') a[i]=3;
  }
  
  for(i=0; i<M; i++) {
    ll u, v;
    cin >> u >> v; u--; v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  
  ll ans=0;
  for(i=0; i<N; i++) if(a[i]==0) moC(ans, +, dfs(i));
  pt(ans);
  
  
}
 
 
0