結果

問題 No.1340 おーじ君をさがせ
ユーザー ocvret_ocvret_
提出日時 2021-01-16 01:30:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,214 bytes
コンパイル時間 1,734 ms
コンパイル使用メモリ 172,012 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-17 20:14:28
合計ジャッジ時間 5,640 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,380 KB
testcase_07 WA -
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 21 ms
4,380 KB
testcase_12 WA -
testcase_13 AC 17 ms
4,376 KB
testcase_14 AC 43 ms
4,376 KB
testcase_15 AC 36 ms
4,376 KB
testcase_16 WA -
testcase_17 AC 14 ms
4,376 KB
testcase_18 AC 23 ms
4,376 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 WA -
testcase_21 AC 31 ms
4,376 KB
testcase_22 AC 78 ms
4,380 KB
testcase_23 AC 31 ms
4,380 KB
testcase_24 AC 145 ms
4,380 KB
testcase_25 AC 6 ms
4,376 KB
testcase_26 AC 5 ms
4,384 KB
testcase_27 AC 4 ms
4,380 KB
testcase_28 AC 9 ms
4,380 KB
testcase_29 AC 4 ms
4,376 KB
testcase_30 AC 34 ms
4,380 KB
testcase_31 AC 148 ms
4,380 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 4 ms
4,376 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 2 ms
4,376 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 AC 29 ms
4,380 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 1 ms
4,376 KB
testcase_57 AC 2 ms
4,376 KB
testcase_58 AC 2 ms
4,380 KB
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
// #include<atcoder/all>

using namespace std;
// using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


// 2020/12/31
void matrix_mul(vector<vector<bool>> &v,vector<vector<bool>> &w){
  int n = v.size(),m = w[0].size(),l = w.size();
  vector<vector<bool>> res(n,vector<bool>(m));
  for(int i = 0;i < n;i++)for(int j = 0;j < m;j++){
    bool k = 0;
    for(int g = 0;g < l;g++)k |= (v[i][g] && w[g][j]);
    res[i][j] = k;
  }
  swap(res,v);
}

//正方行列のみだよ
void matrix_pow(vector<vector<bool>> &v,ll K){
  int n = v.size();
  vector<vector<bool>> res(n,vector<bool>(n,1));
  while(K){
    if(K & 1)matrix_mul(res,v);
    matrix_mul(v,v);
    K >>= 1;
  }
  swap(res,v);
}

int main(){
  
  ll n,m,T;
  cin >> n >> m >> T;
  vector<vector<bool>> v(n,vector<bool>(n,0));
  rep(i,m){
    int a,b;cin >> a >> b;
    v[b][a] = 1;
  }
  matrix_pow(v,T);
  vector<vector<bool>> res(n,vector<bool>(1,0));
  res[0][0] = 1;
  matrix_mul(v,res);
  int ans = 0;
  rep(i,n)if(v[i][0])ans++;
  cout << ans << "\n";

  

  return 0;
}
0