結果
問題 | No.1340 おーじ君をさがせ |
ユーザー | magurofly |
提出日時 | 2021-01-19 23:24:37 |
言語 | Ruby (3.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,238 bytes |
コンパイル時間 | 452 ms |
コンパイル使用メモリ | 11,496 KB |
実行使用メモリ | 26,860 KB |
最終ジャッジ日時 | 2023-08-22 18:59:51 |
合計ジャッジ時間 | 8,425 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 79 ms
15,096 KB |
testcase_02 | AC | 79 ms
15,144 KB |
testcase_03 | AC | 80 ms
15,024 KB |
testcase_04 | WA | - |
testcase_05 | AC | 80 ms
15,264 KB |
testcase_06 | AC | 80 ms
15,172 KB |
testcase_07 | WA | - |
testcase_08 | AC | 79 ms
15,196 KB |
testcase_09 | AC | 79 ms
15,144 KB |
testcase_10 | WA | - |
testcase_11 | AC | 96 ms
19,548 KB |
testcase_12 | WA | - |
testcase_13 | AC | 91 ms
18,664 KB |
testcase_14 | AC | 109 ms
23,468 KB |
testcase_15 | AC | 84 ms
16,484 KB |
testcase_16 | WA | - |
testcase_17 | AC | 83 ms
15,976 KB |
testcase_18 | AC | 91 ms
18,672 KB |
testcase_19 | AC | 83 ms
15,312 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 92 ms
15,356 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | AC | 87 ms
15,024 KB |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | AC | 156 ms
24,320 KB |
testcase_33 | AC | 152 ms
24,748 KB |
testcase_34 | AC | 158 ms
25,296 KB |
testcase_35 | WA | - |
testcase_36 | AC | 80 ms
15,148 KB |
testcase_37 | AC | 93 ms
15,176 KB |
testcase_38 | AC | 99 ms
16,160 KB |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | AC | 80 ms
15,276 KB |
testcase_43 | AC | 79 ms
15,168 KB |
testcase_44 | AC | 79 ms
15,292 KB |
testcase_45 | AC | 78 ms
15,140 KB |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | AC | 121 ms
25,396 KB |
testcase_53 | AC | 119 ms
25,004 KB |
testcase_54 | WA | - |
testcase_55 | AC | 118 ms
25,536 KB |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | AC | 79 ms
15,296 KB |
testcase_61 | WA | - |
コンパイルメッセージ
Syntax OK
ソースコード
class BitAndOrMatrix attr_reader :n, :bits def initialize(n, bits) @n, @bits = n, bits @u = (1 << n) - 1 @v = ((@u + 1)**n - 1) / @u end def self.rows(rows) n, bits = rows.size, 0 rows.each_with_index do |row, i| x = 0 row.each_with_index do |a, j| x |= a << j end bits |= x << n * i end new(n, bits) end def self.id(n) new(n, ((1 << (n + 1) * n) - 1) / ((1 << n + 1) - 1)) end def [](i, j) @bits >> i * @n + j & 1 end def +(other) self.class.new(@n, @bits | other.bits) end def *(other) a, b = @bits, other.bits bits = 0 while a > 0 and b > 0 bits ^= ((a & @v) * @u) & ((b & @u) * @v) a >>= 1 b >>= n end self.class.new(@n, bits) end def **(e) r = self.class.id(@n) x = self while e > 0 r *= x if (e & 1) == 1 x *= x e >>= 1 end r end def to_a (0 ... @n).map { |i| (0 ... @n).map { |j| self[i, j] } } end end N, M, T = gets.split.map(&:to_i) rows = Array.new(N) { [0] * N } M.times do a, b = gets.split.map(&:to_i) rows[b][a] = 1 end ans = BitAndOrMatrix.rows(rows) ** T #STDERR.puts ans.to_a.map(&:inspect) puts ans.to_a.transpose[0].sum