結果

問題 No.1340 おーじ君をさがせ
ユーザー ks2mks2m
提出日時 2021-01-15 22:43:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,104 ms / 2,000 ms
コード長 1,731 bytes
コンパイル時間 3,053 ms
コンパイル使用メモリ 78,808 KB
実行使用メモリ 77,684 KB
最終ジャッジ日時 2024-05-05 03:55:03
合計ジャッジ時間 20,578 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
36,940 KB
testcase_01 AC 46 ms
36,704 KB
testcase_02 AC 47 ms
37,060 KB
testcase_03 AC 47 ms
37,248 KB
testcase_04 AC 51 ms
36,940 KB
testcase_05 AC 47 ms
37,028 KB
testcase_06 AC 47 ms
37,020 KB
testcase_07 AC 49 ms
37,044 KB
testcase_08 AC 48 ms
36,664 KB
testcase_09 AC 48 ms
37,060 KB
testcase_10 AC 89 ms
38,948 KB
testcase_11 AC 77 ms
39,664 KB
testcase_12 AC 136 ms
43,044 KB
testcase_13 AC 52 ms
37,588 KB
testcase_14 AC 82 ms
39,480 KB
testcase_15 AC 53 ms
37,756 KB
testcase_16 AC 144 ms
42,240 KB
testcase_17 AC 53 ms
37,540 KB
testcase_18 AC 54 ms
37,528 KB
testcase_19 AC 53 ms
37,324 KB
testcase_20 AC 96 ms
39,532 KB
testcase_21 AC 485 ms
58,376 KB
testcase_22 AC 699 ms
60,868 KB
testcase_23 AC 454 ms
55,080 KB
testcase_24 AC 1,104 ms
77,684 KB
testcase_25 AC 199 ms
44,420 KB
testcase_26 AC 191 ms
44,108 KB
testcase_27 AC 181 ms
42,556 KB
testcase_28 AC 246 ms
45,264 KB
testcase_29 AC 139 ms
41,332 KB
testcase_30 AC 458 ms
55,224 KB
testcase_31 AC 1,087 ms
74,552 KB
testcase_32 AC 138 ms
44,136 KB
testcase_33 AC 147 ms
43,756 KB
testcase_34 AC 399 ms
52,072 KB
testcase_35 AC 410 ms
54,268 KB
testcase_36 AC 47 ms
36,800 KB
testcase_37 AC 134 ms
42,148 KB
testcase_38 AC 139 ms
43,512 KB
testcase_39 AC 954 ms
73,984 KB
testcase_40 AC 949 ms
73,856 KB
testcase_41 AC 921 ms
73,800 KB
testcase_42 AC 47 ms
37,116 KB
testcase_43 AC 46 ms
37,200 KB
testcase_44 AC 52 ms
37,028 KB
testcase_45 AC 52 ms
37,028 KB
testcase_46 AC 709 ms
71,980 KB
testcase_47 AC 725 ms
71,708 KB
testcase_48 AC 829 ms
71,944 KB
testcase_49 AC 871 ms
69,836 KB
testcase_50 AC 945 ms
69,680 KB
testcase_51 AC 948 ms
69,724 KB
testcase_52 AC 96 ms
39,876 KB
testcase_53 AC 91 ms
39,736 KB
testcase_54 AC 91 ms
39,980 KB
testcase_55 AC 400 ms
57,764 KB
testcase_56 AC 49 ms
37,164 KB
testcase_57 AC 50 ms
36,996 KB
testcase_58 AC 47 ms
37,116 KB
testcase_59 AC 98 ms
40,368 KB
testcase_60 AC 46 ms
37,248 KB
testcase_61 AC 92 ms
40,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		long t = Long.parseLong(sa[2]);
		List<List<Integer>> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			list.add(new ArrayList<>());
		}
		for (int i = 0; i < m; i++) {
			sa = br.readLine().split(" ");
			int a = Integer.parseInt(sa[0]);
			int b = Integer.parseInt(sa[1]);
			list.get(a).add(b);
		}
		br.close();

		int e = 63;
		List<List<Set<Integer>>> dp = new ArrayList<>(e);
		List<Set<Integer>> wk = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			Set<Integer> set = new HashSet<>();
			set.addAll(list.get(i));
			wk.add(set);
		}
		dp.add(wk);
		for (int i = 1; i < e; i++) {
			wk = new ArrayList<>(n);
			List<Set<Integer>> pre = dp.get(i - 1);
			for (int j = 0; j < n; j++) {
				Set<Integer> set = new HashSet<>();
				Set<Integer> ps = pre.get(j);
				for (int k : ps) {
					set.addAll(pre.get(k));
				}
				wk.add(set);
			}
			dp.add(wk);
		}

		List<Integer> ans = new ArrayList<>();
		ans.add(0);
		for (int i = 0; i < e; i++) {
			if ((t >> i & 1) == 0) {
				continue;
			}
			List<Integer> next = new ArrayList<>();
			List<Set<Integer>> di = dp.get(i);
			for (int j = 0; j < n; j++) {
				for (int k : ans) {
					if (di.get(k).contains(j)) {
						next.add(j);
						break;
					}
				}
			}
			ans = next;
		}
		System.out.println(ans.size());
	}
}
0