結果

問題 No.3109 Swap members
ユーザー tufusa
提出日時 2025-04-18 23:02:32
言語 Ruby
(3.4.1)
結果
AC  
実行時間 498 ms / 2,000 ms
コード長 227 bytes
コンパイル時間 795 ms
コンパイル使用メモリ 8,192 KB
実行使用メモリ 43,716 KB
最終ジャッジ日時 2025-04-18 23:02:50
合計ジャッジ時間 17,074 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 52
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n, k = gets.split.map(&:to_i)
ss = n.times.map { gets.chomp }
ts = n.times.map { gets.chomp }

tsi = ts.map.with_index.to_h
ss.each_with_index do |nm, i|
  if (tsi[nm] - i) % k != 0
    puts 'No'
    exit
  end
end

puts 'Yes'
0