結果
問題 | No.1340 おーじ君をさがせ |
ユーザー |
👑 ![]() |
提出日時 | 2021-01-16 12:30:05 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 926 bytes |
コンパイル時間 | 1,883 ms |
コンパイル使用メモリ | 196,556 KB |
最終ジャッジ日時 | 2025-01-17 21:26:32 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 59 |
ソースコード
#include <bits/stdc++.h> using namespace std; struct matrix{ vector<bitset<100>> a; matrix():a(100){} matrix operator*(const matrix& x) const { matrix ans; for(int i = 0; i < 100; i++) for(int j = 0; j < 100; j++) if(a[i][j]) ans[i] |= x[j]; return ans; } bitset<100>& operator[](int x){ return a[x]; } const bitset<100>& operator[](int x) const { return a[x]; } matrix pow(uint64_t x) const { matrix ans, a = *this; for(int i = 0; i < 100; i++) ans[i][i] = 1; while(x){ if(x & 1) ans = ans * a; a = a * a; x >>= 1; } return ans; } }; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int N, M; long T; cin >> N >> M >> T; matrix a; while(M--){ int x, y; cin >> x >> y; a[x][y] = 1; } cout << a.pow(T)[0].count() << endl; }