結果

問題 No.1340 おーじ君をさがせ
ユーザー 👑 PCTprobabilityPCTprobability
提出日時 2021-01-15 23:51:24
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,810 bytes
コンパイル時間 2,309 ms
コンパイル使用メモリ 164,588 KB
実行使用メモリ 8,576 KB
最終ジャッジ日時 2024-05-05 03:06:41
合計ジャッジ時間 7,546 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 57 ms
5,376 KB
testcase_12 AC 10 ms
5,376 KB
testcase_13 AC 42 ms
5,376 KB
testcase_14 AC 115 ms
5,748 KB
testcase_15 AC 95 ms
5,376 KB
testcase_16 AC 7 ms
5,376 KB
testcase_17 AC 32 ms
5,376 KB
testcase_18 AC 57 ms
5,376 KB
testcase_19 AC 4 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 57 ms
5,376 KB
testcase_22 AC 156 ms
6,656 KB
testcase_23 AC 57 ms
5,376 KB
testcase_24 AC 299 ms
8,192 KB
testcase_25 AC 7 ms
5,376 KB
testcase_26 AC 5 ms
5,376 KB
testcase_27 AC 4 ms
5,376 KB
testcase_28 AC 11 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 64 ms
5,376 KB
testcase_31 AC 305 ms
8,576 KB
testcase_32 AC 277 ms
8,192 KB
testcase_33 AC 278 ms
8,064 KB
testcase_34 AC 249 ms
7,808 KB
testcase_35 AC 304 ms
8,064 KB
testcase_36 AC 1 ms
5,376 KB
testcase_37 AC 3 ms
5,376 KB
testcase_38 AC 301 ms
8,576 KB
testcase_39 AC 74 ms
5,376 KB
testcase_40 AC 76 ms
5,376 KB
testcase_41 AC 76 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
testcase_44 AC 2 ms
5,376 KB
testcase_45 AC 1 ms
5,376 KB
testcase_46 AC 54 ms
5,376 KB
testcase_47 AC 57 ms
5,376 KB
testcase_48 AC 65 ms
5,376 KB
testcase_49 AC 64 ms
5,376 KB
testcase_50 AC 63 ms
5,376 KB
testcase_51 AC 64 ms
5,376 KB
testcase_52 AC 128 ms
5,888 KB
testcase_53 AC 129 ms
5,888 KB
testcase_54 AC 133 ms
5,888 KB
testcase_55 AC 102 ms
5,376 KB
testcase_56 AC 1 ms
5,376 KB
testcase_57 AC 2 ms
5,376 KB
testcase_58 AC 2 ms
5,376 KB
testcase_59 AC 36 ms
5,376 KB
testcase_60 WA -
testcase_61 AC 36 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define all(s) (s).begin(),(s).end()
#define vcin(n) for(ll i=0;i<ll(n.size());i++) cin>>n[i]
#define rever(vec) reverse(vec.begin(), vec.end())
#define sor(vec) sort(vec.begin(), vec.end())
#define fi first
#define se second
const ll mod = 998244353;
//const ll mod = 1000000007;
const ll inf = 2000000000000000000ll;
static const long double pi = 3.141592653589793;
template<class T,class U> void chmax(T& t,const U& u){if(t<u) t=u;}
template<class T,class U> void chmin(T& t,const U& u){if(t>u) t=u;}
ll modPow(ll a, ll n, ll mod) { ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1; } return ret; }
vector<vector<ll>> multi(vector<vector<ll>> a, vector<vector<ll>> b){
    ll n = a.size();
    vector<vector<ll>> res(n, vector<ll>(n, 0));
    for (ll i = 0; i < n; ++i){
        for (ll j = 0; j < n; ++j){
            for (ll x = 0; x < n; ++x){
                res[i][j] = ((res[i][j]) | (a[i][x] & b[x][j])) % mod;
            }
        }
    }
    return res;
}
vector<vector<ll>> mul_exp(vector<vector<ll>> adj, ll k, ll n){
    if (k == 0){
      vector<vector<ll>> d(n,vector<ll>(n));
      return d;
    }
    if (k == 1) return adj;
    vector<vector<ll>> res = mul_exp(adj, k / 2, n);
    if (k % 2 == 0) return multi(res, res);
    else return multi(adj, multi(res, res));
}
int main() {
  /* mod は 1e9+7 */
  ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
  cout<< fixed << setprecision(10);
  ll n,m,t;
  cin>>n>>m>>t;
  vector<vector<ll>> dp(n,vector<ll>(n));
  for(int i=0;i<m;i++){
    ll x,y;
    cin>>x>>y;
    dp[y][x]=1;
  }
  auto ans=mul_exp(dp,t,n);
  ll ansi=0;
  for(int i=0;i<n;i++){
    ansi+=ans[i][0];
  }
  cout<<ansi<<endl;
}
0