結果

問題 No.1340 おーじ君をさがせ
ユーザー 👑 NachiaNachia
提出日時 2021-01-15 22:20:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 730 bytes
コンパイル時間 2,435 ms
コンパイル使用メモリ 198,400 KB
実行使用メモリ 6,340 KB
最終ジャッジ日時 2023-08-18 16:38:12
合計ジャッジ時間 5,710 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
6,124 KB
testcase_01 AC 18 ms
6,048 KB
testcase_02 AC 18 ms
6,016 KB
testcase_03 AC 18 ms
6,312 KB
testcase_04 AC 18 ms
6,020 KB
testcase_05 AC 18 ms
6,268 KB
testcase_06 AC 18 ms
6,168 KB
testcase_07 AC 18 ms
6,116 KB
testcase_08 AC 17 ms
6,052 KB
testcase_09 AC 18 ms
6,064 KB
testcase_10 AC 23 ms
6,308 KB
testcase_11 AC 22 ms
6,084 KB
testcase_12 AC 20 ms
6,052 KB
testcase_13 AC 20 ms
6,092 KB
testcase_14 AC 20 ms
6,116 KB
testcase_15 AC 21 ms
6,140 KB
testcase_16 AC 20 ms
6,076 KB
testcase_17 AC 21 ms
6,068 KB
testcase_18 AC 20 ms
6,088 KB
testcase_19 AC 21 ms
6,032 KB
testcase_20 AC 21 ms
6,108 KB
testcase_21 AC 25 ms
6,040 KB
testcase_22 AC 23 ms
6,088 KB
testcase_23 AC 26 ms
6,152 KB
testcase_24 AC 24 ms
6,168 KB
testcase_25 AC 27 ms
6,024 KB
testcase_26 AC 24 ms
6,088 KB
testcase_27 AC 26 ms
6,312 KB
testcase_28 AC 24 ms
6,092 KB
testcase_29 AC 25 ms
6,084 KB
testcase_30 AC 25 ms
6,124 KB
testcase_31 AC 24 ms
6,080 KB
testcase_32 AC 24 ms
6,188 KB
testcase_33 AC 25 ms
6,208 KB
testcase_34 AC 23 ms
6,116 KB
testcase_35 AC 26 ms
6,256 KB
testcase_36 AC 23 ms
6,076 KB
testcase_37 AC 24 ms
6,084 KB
testcase_38 AC 24 ms
6,168 KB
testcase_39 AC 20 ms
6,332 KB
testcase_40 AC 21 ms
6,180 KB
testcase_41 AC 21 ms
6,100 KB
testcase_42 AC 18 ms
6,056 KB
testcase_43 AC 18 ms
6,080 KB
testcase_44 AC 21 ms
6,060 KB
testcase_45 AC 19 ms
6,088 KB
testcase_46 AC 19 ms
6,120 KB
testcase_47 AC 19 ms
6,116 KB
testcase_48 AC 20 ms
6,052 KB
testcase_49 AC 18 ms
6,112 KB
testcase_50 AC 19 ms
6,076 KB
testcase_51 AC 19 ms
6,168 KB
testcase_52 AC 20 ms
6,184 KB
testcase_53 AC 20 ms
6,212 KB
testcase_54 AC 20 ms
6,076 KB
testcase_55 AC 20 ms
6,100 KB
testcase_56 AC 20 ms
6,176 KB
testcase_57 AC 20 ms
6,116 KB
testcase_58 AC 21 ms
6,044 KB
testcase_59 AC 18 ms
6,140 KB
testcase_60 AC 17 ms
6,008 KB
testcase_61 AC 19 ms
6,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

struct matrix{
  int A[100][100]={};
};

void matrix_multiply(const matrix& l,const matrix& r,matrix& dest){
  static matrix buf;
  rep(i,100) rep(j,100){ buf.A[i][j]=0; rep(k,100) buf.A[i][j]|=(l.A[i][k]&r.A[k][j]); }
  dest = buf;
}

int N,V;
ULL T;
matrix G;
matrix P[64];
matrix dp;

int main(){
  scanf("%d%d%llu",&N,&V,&T);
  rep(i,V){ int u,v; scanf("%d%d",&u,&v); G.A[u][v]=1; }
  P[0]=G;
  rep(i,63) matrix_multiply(P[i],P[i],P[i+1]);
  dp.A[0][0]=1;
  rep(i,64) if(T&(1ull<<i)) matrix_multiply(dp,P[i],dp);
  int ans=0; rep(i,N) ans+=dp.A[0][i];
  printf("%d\n",ans);
  return 0;
}
0