結果
問題 | No.274 The Wall |
ユーザー |
|
提出日時 | 2018-01-09 15:22:03 |
言語 | Ruby (3.4.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,006 bytes |
コンパイル時間 | 250 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 46,848 KB |
最終ジャッジ日時 | 2024-12-23 14:24:06 |
合計ジャッジ時間 | 15,588 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 12 WA * 9 TLE * 1 |
コンパイルメッセージ
Syntax OK
ソースコード
N,M = $stdin.gets.chomp.split(" ").map{ |a| a.to_i }lines = []N.times {l,r = $stdin.gets.chomp.split(" ").map{ |a| a.to_i }lines << [l,r]}#p linesconnection = (0...lines.size).map { |i|l0,r0 = *lines[i]vl0,vr0 = M-1-l0,M-1-r0(0...lines.size).map { |j|next nil if i == jl1,r1 = *lines[j]ok1 = (r0 < l1 || r1 < l0)ok2 = (vr0 < l1 || r1 < vl0)casewhen ok1 && !ok2; +1when !ok1 && ok2; -1when ok1 && ok2; nilwhen !ok1 && !ok2puts "NO"exitend}}#p connectionstatus = (0..N).map{ nil }connection.each_with_index { |line,i|status[i] = status[i] || +1line.each_with_index{ |c,j|casewhen i == j; nextwhen c == +1 && status[j] == nil; status[j] = +status[i]when c == +1 && status[j] != status[i]puts "NO"exitwhen c == -1 && status[j] == nil; status[j] = -status[i]when c == -1 && status[j] == status[i]puts "NO"exitend}}#p statusputs "YES"