結果

問題 No.1340 おーじ君をさがせ
ユーザー たたき@競プロたたき@競プロ
提出日時 2023-09-07 20:14:24
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 1,940 bytes
コンパイル時間 7,650 ms
コンパイル使用メモリ 308,032 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-07 20:14:36
合計ジャッジ時間 9,744 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 16 ms
4,376 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 12 ms
4,376 KB
testcase_14 AC 32 ms
4,376 KB
testcase_15 AC 29 ms
4,380 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 10 ms
4,380 KB
testcase_18 AC 16 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 20 ms
4,376 KB
testcase_22 AC 49 ms
4,376 KB
testcase_23 AC 20 ms
4,376 KB
testcase_24 AC 89 ms
4,380 KB
testcase_25 AC 6 ms
4,376 KB
testcase_26 AC 4 ms
4,380 KB
testcase_27 AC 3 ms
4,380 KB
testcase_28 AC 6 ms
4,376 KB
testcase_29 AC 3 ms
4,380 KB
testcase_30 AC 21 ms
4,380 KB
testcase_31 AC 92 ms
4,376 KB
testcase_32 AC 86 ms
4,380 KB
testcase_33 AC 86 ms
4,376 KB
testcase_34 AC 76 ms
4,376 KB
testcase_35 AC 93 ms
4,376 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 4 ms
4,376 KB
testcase_38 AC 91 ms
4,380 KB
testcase_39 AC 26 ms
4,376 KB
testcase_40 AC 26 ms
4,380 KB
testcase_41 AC 26 ms
4,380 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 1 ms
4,380 KB
testcase_46 AC 18 ms
4,376 KB
testcase_47 AC 18 ms
4,376 KB
testcase_48 AC 20 ms
4,380 KB
testcase_49 AC 20 ms
4,380 KB
testcase_50 AC 20 ms
4,380 KB
testcase_51 AC 20 ms
4,380 KB
testcase_52 AC 39 ms
4,376 KB
testcase_53 AC 38 ms
4,376 KB
testcase_54 AC 39 ms
4,380 KB
testcase_55 AC 30 ms
4,376 KB
testcase_56 AC 1 ms
4,376 KB
testcase_57 AC 2 ms
4,376 KB
testcase_58 AC 2 ms
4,376 KB
testcase_59 AC 11 ms
4,376 KB
testcase_60 AC 2 ms
4,380 KB
testcase_61 AC 11 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint=modint998244353; //1000000007;
using ll=long long;
using pp=pair<ll,ll>;
#define sr string 
#define vc vector
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define pque priority_queue
#define bpc(a) __builtin_popcount(a)
// https://youtu.be/ylWYSurx10A?t=2352
template<typename T>
struct Matrix {
  int h, w;
  vector<vector<T>> d;
  Matrix() {}
  Matrix(int h, int w, T val=0): h(h), w(w), d(h, vector<T>(w,val)) {}
  Matrix& unit() {
    assert(h == w);
    rep(i,h) d[i][i] = 1;
    return *this;
  }
  const vector<T>& operator[](int i) const { return d[i];}
  vector<T>& operator[](int i) { return d[i];}
  Matrix operator*(const Matrix& a) const {
    assert(w == a.h);
    Matrix r(h, a.w);
    rep(i,h)rep(k,w)rep(j,a.w) {
      r[i][j] |= d[i][k]*a[k][j];
    }
    return r;
  }
  Matrix pow(long long t) const {
    assert(h == w);
    if (!t) return Matrix(h,h).unit();
    if (t == 1) return *this;
    Matrix r = pow(t>>1);
    r = r*r;
    if (t&1) r = r*(*this);
    return r;
  }
  // https://youtu.be/-j02o6__jgs?t=11273
  /* mint only
  mint det() {
    assert(h == w);
    mint res = 1;
    rep(k,h) {
      for (int i = k; i < h; ++i) {
        if (d[i][k] == 0) continue;
        if (i != k) {
          swap(d[i],d[k]);
          res = -res;
        }
      }
      if (d[k][k] == 0) return 0;
      res *= d[k][k];
      mint inv = mint(1)/d[k][k];
      rep(j,h) d[k][j] *= inv;
      for (int i = k+1; i < h; ++i) {
        mint c = d[i][k];
        for (int j = k; j < h; ++j) d[i][j] -= d[k][j]*c;
      }
    }
    return res;
  }
  //*/
};
int main(){
  int n,m; ll t;cin>>n>>m>>t;
  Matrix<int>v(n,n);
  rep(i,m){
    int a,b;cin>>a>>b;
    v[b][a]=1;
  }
  v=v.pow(t);
  int ans=0;
  rep(i,n)ans+=v[i][0];
  cout<<ans;
}
0