結果

問題 No.517 壊れたアクセサリー
ユーザー cielciel
提出日時 2017-05-30 01:15:21
言語 Ruby
(3.3.0)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 335 bytes
コンパイル時間 57 ms
コンパイル使用メモリ 11,908 KB
実行使用メモリ 16,096 KB
最終ジャッジ日時 2023-10-21 17:02:42
合計ジャッジ時間 2,648 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
16,096 KB
testcase_01 AC 86 ms
16,096 KB
testcase_02 AC 93 ms
16,096 KB
testcase_03 AC 84 ms
16,096 KB
testcase_04 AC 84 ms
16,096 KB
testcase_05 AC 86 ms
16,096 KB
testcase_06 AC 85 ms
16,096 KB
testcase_07 AC 84 ms
16,096 KB
testcase_08 AC 84 ms
16,096 KB
testcase_09 AC 84 ms
16,096 KB
testcase_10 AC 85 ms
16,096 KB
testcase_11 AC 85 ms
16,096 KB
testcase_12 AC 87 ms
16,096 KB
testcase_13 AC 86 ms
16,096 KB
testcase_14 AC 85 ms
16,096 KB
testcase_15 AC 87 ms
16,096 KB
testcase_16 AC 85 ms
16,096 KB
testcase_17 AC 86 ms
16,096 KB
testcase_18 AC 87 ms
16,096 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:6: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

#!/usr/bin/ruby
a,b=2.times.map{
	gets.to_i.times.map{gets.chomp}
}
prefix=a.map{|e|e[0]}&b.map{|e|e[0]}
(p -1;exit)if prefix.size>1
prefix=prefix[0]
s=a.find{|e|e[0]==prefix}
t=b.find{|e|e[0]==prefix}
while s.size!=t.size
	s+=a.find{|e|e[0]==t[s.size]} while s.size<t.size
	t+=b.find{|e|e[0]==s[t.size]} while s.size>t.size
end
puts s
0