結果

問題 No.1340 おーじ君をさがせ
ユーザー 👑 PCTprobabilityPCTprobability
提出日時 2021-01-15 23:52:33
言語 C++17(clang)
(14.0.0 + boost 1.83.0)
結果
AC  
実行時間 310 ms / 2,000 ms
コード長 1,865 bytes
コンパイル時間 4,079 ms
コンパイル使用メモリ 134,680 KB
実行使用メモリ 8,584 KB
最終ジャッジ日時 2023-08-18 16:48:38
合計ジャッジ時間 8,088 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 58 ms
4,508 KB
testcase_12 AC 10 ms
4,376 KB
testcase_13 AC 43 ms
4,584 KB
testcase_14 AC 120 ms
5,748 KB
testcase_15 AC 105 ms
5,264 KB
testcase_16 AC 8 ms
4,380 KB
testcase_17 AC 34 ms
4,376 KB
testcase_18 AC 64 ms
4,524 KB
testcase_19 AC 4 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 59 ms
5,048 KB
testcase_22 AC 160 ms
6,532 KB
testcase_23 AC 66 ms
4,936 KB
testcase_24 AC 308 ms
8,200 KB
testcase_25 AC 8 ms
4,380 KB
testcase_26 AC 5 ms
4,376 KB
testcase_27 AC 4 ms
4,376 KB
testcase_28 AC 10 ms
4,376 KB
testcase_29 AC 3 ms
4,376 KB
testcase_30 AC 64 ms
5,236 KB
testcase_31 AC 304 ms
8,584 KB
testcase_32 AC 289 ms
8,148 KB
testcase_33 AC 284 ms
8,080 KB
testcase_34 AC 254 ms
7,856 KB
testcase_35 AC 310 ms
8,036 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 307 ms
8,556 KB
testcase_39 AC 77 ms
4,608 KB
testcase_40 AC 79 ms
4,740 KB
testcase_41 AC 75 ms
4,688 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 1 ms
4,380 KB
testcase_46 AC 54 ms
4,452 KB
testcase_47 AC 56 ms
4,432 KB
testcase_48 AC 64 ms
4,376 KB
testcase_49 AC 66 ms
4,828 KB
testcase_50 AC 66 ms
4,628 KB
testcase_51 AC 66 ms
4,608 KB
testcase_52 AC 135 ms
5,804 KB
testcase_53 AC 130 ms
5,868 KB
testcase_54 AC 131 ms
5,936 KB
testcase_55 AC 98 ms
5,108 KB
testcase_56 AC 2 ms
4,376 KB
testcase_57 AC 1 ms
4,380 KB
testcase_58 AC 2 ms
4,380 KB
testcase_59 AC 36 ms
4,376 KB
testcase_60 AC 1 ms
4,376 KB
testcase_61 AC 37 ms
4,380 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));
      for(int i=0;i<n;i++){
        d[i][i]=1;
      }
      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