結果
問題 | No.1340 おーじ君をさがせ |
ユーザー |
👑 ![]() |
提出日時 | 2021-01-15 22:20:20 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 30 ms / 2,000 ms |
コード長 | 730 bytes |
コンパイル時間 | 3,513 ms |
コンパイル使用メモリ | 193,172 KB |
最終ジャッジ日時 | 2025-01-17 19:40:09 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 59 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:24:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 24 | scanf("%d%d%llu",&N,&V,&T); | ~~~~~^~~~~~~~~~~~~~~~~~~~~ main.cpp:25:27: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 25 | rep(i,V){ int u,v; scanf("%d%d",&u,&v); G.A[u][v]=1; } | ~~~~~^~~~~~~~~~~~~~
ソースコード
#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;}