結果
| 問題 | 
                            No.1340 おーじ君をさがせ
                             | 
                    
| コンテスト | |
| ユーザー | 
                             tnakao0123
                         | 
                    
| 提出日時 | 2021-01-19 16:59:04 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,703 bytes | 
| コンパイル時間 | 800 ms | 
| コンパイル使用メモリ | 96,496 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-12-17 13:26:16 | 
| 合計ジャッジ時間 | 3,780 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 39 WA * 20 | 
ソースコード
/* -*- coding: utf-8 -*-
 *
 * 1340.cc:  No.1340 おーじ君をさがせ - yukicoder
 */
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;
/* constant */
const int MAX_N = 100;
/* typedef */
typedef long long ll;
typedef bool vec[MAX_N];
typedef vec mat[MAX_N];
/* global variables */
mat ma, mb;
/* subroutines */
inline void initmat(const int n, mat a) { memset(a, 0, sizeof(mat)); }
inline void unitmat(const int n, mat a) {
  initmat(n, a);
  for (int i = 0; i < n; i++) a[i][i] = true;
}
inline void copymat(const int n, const mat a, mat b) {
  memcpy(b, a, sizeof(mat));
}
inline void mulmat(const int n, const mat a, const mat b, mat c) {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      c[i][j] = false;
      for (int k = 0; k < n; k++)
        c[i][j] |= (a[i][k] & b[k][j]);
    }
}
inline void powmat(const int n, const mat a, ll b, mat c) {
  mat s, t;
  copymat(n, a, s);
  unitmat(n, c);
  while (b > 0) {
    if (b & 1) {
      mulmat(n, c, s, t);
      copymat(n, t, c);
    }
    mulmat(n, s, s, t);
    copymat(n, t, s);
    b >>= 1;
  }
}
/* subroutines */
/* main */
int main() {
  int n, m;
  ll t;
  scanf("%d%d%lld", &n, &m, &t);
  initmat(n, ma);
  while (m--) {
    int a, b;
    scanf("%d%d", &a, &b);
    ma[a][b] = true;
  }
  powmat(n, ma, t, mb);
  int c = 0;
  for (int i = 0; i < n; i++)
    if (mb[i][0]) c++;
  printf("%d\n", c);
  return 0;
}
            
            
            
        
            
tnakao0123