結果
問題 |
No.715 集合と二人ゲーム
|
ユーザー |
|
提出日時 | 2018-07-13 23:11:14 |
言語 | Ruby (3.4.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 744 bytes |
コンパイル時間 | 177 ms |
コンパイル使用メモリ | 7,296 KB |
実行使用メモリ | 54,784 KB |
最終ジャッジ日時 | 2024-10-09 05:34:24 |
合計ジャッジ時間 | 12,293 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 29 WA * 31 |
コンパイルメッセージ
Syntax OK
ソースコード
def ascan; gets.split.map(&:to_i); end gets aa = ascan.sort lis = [1] aa.each_cons(2) do |a,b| if (b-a).abs <= 1 lis[-1] += 1 else lis << 1 end end hoge = lis.map{|e| x=e%20;x>8 ? (x-8)%6 : x%4 }.reduce(:^) # p lis.map{|e| e%4} puts hoge == 0 ? :Second : :First #true => first @memo = {} def guchoku(set) return false if set.empty? return @memo[set] if @memo[set] set.each do |e| new_set = set.select{|x| (x-e).abs > 1} return @memo[set] = true if guchoku(new_set) == false end return @memo[set] = false end # 13.upto(13) do |i| # p [i+1, guchoku((1..(1+i)).to_a)] # end # # p guchoku(aa) # 1 2 3 4 5 6 7 8 9 # t t t f t t t f t # 0, 4, 8, 14, 20, 24, 28 # 4 6 6