結果

問題 No.1340 おーじ君をさがせ
ユーザー 夜
提出日時 2021-02-16 18:10:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,661 bytes
コンパイル時間 1,247 ms
コンパイル使用メモリ 101,592 KB
実行使用メモリ 5,292 KB
最終ジャッジ日時 2023-10-11 07:37:51
合計ジャッジ時間 11,700 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,356 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,352 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,352 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,352 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 56 ms
4,352 KB
testcase_14 AC 157 ms
4,352 KB
testcase_15 AC 152 ms
4,348 KB
testcase_16 WA -
testcase_17 AC 43 ms
4,352 KB
testcase_18 AC 87 ms
4,352 KB
testcase_19 AC 5 ms
4,348 KB
testcase_20 WA -
testcase_21 AC 80 ms
4,348 KB
testcase_22 AC 212 ms
4,352 KB
testcase_23 AC 79 ms
4,352 KB
testcase_24 AC 409 ms
4,356 KB
testcase_25 AC 11 ms
4,352 KB
testcase_26 AC 8 ms
4,352 KB
testcase_27 AC 6 ms
4,352 KB
testcase_28 AC 15 ms
4,352 KB
testcase_29 AC 4 ms
4,352 KB
testcase_30 AC 88 ms
4,352 KB
testcase_31 AC 487 ms
4,348 KB
testcase_32 AC 375 ms
4,348 KB
testcase_33 AC 376 ms
4,348 KB
testcase_34 AC 334 ms
4,352 KB
testcase_35 AC 406 ms
4,356 KB
testcase_36 AC 2 ms
4,352 KB
testcase_37 AC 4 ms
4,352 KB
testcase_38 AC 490 ms
4,352 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 2 ms
4,348 KB
testcase_45 AC 2 ms
4,352 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 117 ms
4,348 KB
testcase_50 AC 103 ms
4,348 KB
testcase_51 AC 107 ms
4,352 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 2 ms
4,348 KB
testcase_57 WA -
testcase_58 AC 1 ms
4,348 KB
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	long long mod = 1000000007;
	int m_size;
	cin >> m_size;
	int m;
	cin >> m;
	vector<vector<long long>> mat(220);
	long long y;
	cin >> y;
	vector<vector<long long>> ans(220);
	for (int i = 0; i < m_size; i++) {
		for (int j = 0; j < m_size; j++) {
			mat[i].emplace_back(0);
			ans[i].emplace_back(0);
		}
	}
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		mat[a][b] = 1;
		ans[a][b] = 1;
	}
	y--;
	while (y > 0) {
		if ((y & 1) == 1) {
			vector<vector<long long>> ans_mem(220);
			for (int i = 0; i < m_size; i++) {
				for (int j = 0; j < m_size; j++) {
					ans_mem[i].emplace_back(0);
				}
			}
			for (int i = 0; i < m_size; i++) {
				for (int j = 0; j < m_size; j++) {
					for (int k = 0; k < m_size; k++) {
						ans_mem[i][j] += ans[i][k] * mat[k][j] % mod;
						ans_mem[i][j] %= mod;
					}
				}
			}
			ans = ans_mem;
		}
		vector<vector<long long>> mat_mem(220);
		for (int i = 0; i < m_size; i++) {
			for (int j = 0; j < m_size; j++) {
				mat_mem[i].emplace_back(0);
			}
		}
		for (int i = 0; i < m_size; i++) {
			for (int j = 0; j < m_size; j++) {
				for (int k = 0; k < m_size; k++) {
					mat_mem[i][j] += mat[i][k] * mat[k][j] % mod;
					mat_mem[i][j] %= mod;
				}
			}
		}
		mat = mat_mem;
		y >>= 1;
	}
	int co = 0;
	for (int i = 0; i < m_size; i++) {
		if (ans[i][0] != 0) {
			co++;
		}
	}
	cout << co << endl;
}
0