結果

問題 No.1340 おーじ君をさがせ
ユーザー tnakao0123tnakao0123
提出日時 2021-01-19 16:59:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,703 bytes
コンパイル時間 724 ms
コンパイル使用メモリ 92,512 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-22 14:18:11
合計ジャッジ時間 6,191 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 10 ms
4,380 KB
testcase_14 AC 27 ms
4,380 KB
testcase_15 AC 27 ms
4,376 KB
testcase_16 WA -
testcase_17 AC 8 ms
4,380 KB
testcase_18 AC 13 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 WA -
testcase_21 AC 15 ms
4,376 KB
testcase_22 AC 42 ms
4,380 KB
testcase_23 AC 15 ms
4,380 KB
testcase_24 AC 77 ms
4,500 KB
testcase_25 AC 4 ms
4,384 KB
testcase_26 AC 3 ms
4,376 KB
testcase_27 AC 3 ms
4,380 KB
testcase_28 AC 4 ms
4,376 KB
testcase_29 AC 3 ms
4,376 KB
testcase_30 AC 16 ms
4,376 KB
testcase_31 AC 79 ms
4,376 KB
testcase_32 AC 73 ms
4,380 KB
testcase_33 AC 72 ms
4,376 KB
testcase_34 AC 65 ms
4,376 KB
testcase_35 AC 79 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 3 ms
4,376 KB
testcase_38 AC 78 ms
4,380 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 1 ms
4,380 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 19 ms
4,380 KB
testcase_50 AC 19 ms
4,384 KB
testcase_51 AC 19 ms
4,380 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 1 ms
4,376 KB
testcase_57 AC 2 ms
4,376 KB
testcase_58 AC 1 ms
4,384 KB
testcase_59 WA -
testcase_60 AC 1 ms
4,376 KB
testcase_61 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- 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;
}
0