結果

問題 No.762 PDCAパス
ユーザー simansiman
提出日時 2021-05-07 12:12:27
言語 Ruby
(3.3.0)
結果
AC  
実行時間 431 ms / 2,000 ms
コード長 675 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 11,504 KB
実行使用メモリ 40,880 KB
最終ジャッジ日時 2023-10-13 03:08:52
合計ジャッジ時間 11,186 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
15,292 KB
testcase_01 AC 84 ms
15,376 KB
testcase_02 AC 85 ms
15,396 KB
testcase_03 AC 85 ms
15,372 KB
testcase_04 AC 85 ms
15,568 KB
testcase_05 AC 86 ms
15,392 KB
testcase_06 AC 87 ms
15,440 KB
testcase_07 AC 87 ms
15,536 KB
testcase_08 AC 85 ms
15,308 KB
testcase_09 AC 85 ms
15,348 KB
testcase_10 AC 86 ms
15,524 KB
testcase_11 AC 87 ms
15,384 KB
testcase_12 AC 85 ms
15,328 KB
testcase_13 AC 85 ms
15,440 KB
testcase_14 AC 86 ms
15,316 KB
testcase_15 AC 85 ms
15,552 KB
testcase_16 AC 85 ms
15,500 KB
testcase_17 AC 85 ms
15,548 KB
testcase_18 AC 85 ms
15,360 KB
testcase_19 AC 84 ms
15,300 KB
testcase_20 AC 85 ms
15,544 KB
testcase_21 AC 85 ms
15,484 KB
testcase_22 AC 270 ms
17,916 KB
testcase_23 AC 272 ms
17,848 KB
testcase_24 AC 413 ms
40,880 KB
testcase_25 AC 419 ms
40,848 KB
testcase_26 AC 298 ms
17,348 KB
testcase_27 AC 296 ms
17,356 KB
testcase_28 AC 431 ms
36,920 KB
testcase_29 AC 415 ms
37,248 KB
testcase_30 AC 405 ms
32,616 KB
testcase_31 AC 406 ms
32,700 KB
testcase_32 AC 409 ms
32,604 KB
testcase_33 AC 385 ms
29,500 KB
testcase_34 AC 379 ms
29,496 KB
testcase_35 AC 388 ms
29,516 KB
testcase_36 AC 323 ms
21,192 KB
testcase_37 AC 323 ms
21,236 KB
testcase_38 AC 327 ms
21,200 KB
testcase_39 AC 323 ms
21,288 KB
testcase_40 AC 329 ms
21,284 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

MOD = 10 ** 9 + 7
N, M = gets.split.map(&:to_i)
S = gets.chomp
E = Hash.new { |h, k| h[k] = [] }

M.times do
  u, v = gets.split.map(&:to_i)
  u -= 1
  v -= 1

  E[u] << v
  E[v] << u
end

counter = Hash.new(0)
que = []

S.chars.each_with_index do |s, idx|
  next if s != 'P'

  que << idx
  counter[idx] += 1
end

L = ['D', 'C', 'A']

3.times do |i|
  temp_counter = Hash.new(0)
  temp_que = Hash.new

  until que.empty?
    v = que.shift

    E[v].each do |u|
      next if S[u] != L[i]

      temp_counter[u] += counter[v]
      temp_counter[u] %= MOD
      temp_que[u] = true
    end
  end

  counter = temp_counter
  que = temp_que.keys
end

pp counter.values.sum % MOD
0