結果
問題 |
No.1340 おーじ君をさがせ
|
ユーザー |
👑 ![]() |
提出日時 | 2021-01-16 01:07:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 89 ms / 2,000 ms |
コード長 | 579 bytes |
コンパイル時間 | 478 ms |
コンパイル使用メモリ | 67,328 KB |
最終ジャッジ日時 | 2025-01-17 21:05:53 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 59 |
ソースコード
#include<iostream> using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) struct M{ int A[100][100]={}; }; int N,V; long long T; M G,P[64],dp,buf; void mul(const M& l,const M& r,M& dest){ 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 main(){ cin>>N>>V>>T; rep(i,V){ int u,v; cin>>u>>v; G.A[u][v]=1; } P[0]=G; rep(i,63) mul(P[i],P[i],P[i+1]); dp.A[0][0]=1; rep(i,60) if(T&(1ll<<i)) mul(dp,P[i],dp); int ans=0; rep(i,N) ans+=dp.A[0][i]; cout<<ans<<endl; return 0; }