結果

問題 No.635 自然門松列
ユーザー finefine
提出日時 2018-01-21 02:21:03
言語 Ruby
(3.3.0)
結果
AC  
実行時間 83 ms / 650 ms
コード長 1,014 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 11,572 KB
実行使用メモリ 15,360 KB
最終ジャッジ日時 2023-09-05 13:11:16
合計ジャッジ時間 3,212 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,192 KB
testcase_01 AC 80 ms
15,048 KB
testcase_02 AC 80 ms
15,128 KB
testcase_03 AC 81 ms
15,284 KB
testcase_04 AC 80 ms
15,360 KB
testcase_05 AC 82 ms
15,080 KB
testcase_06 AC 82 ms
15,252 KB
testcase_07 AC 80 ms
15,188 KB
testcase_08 AC 79 ms
15,080 KB
testcase_09 AC 79 ms
15,076 KB
testcase_10 AC 81 ms
15,052 KB
testcase_11 AC 82 ms
15,252 KB
testcase_12 AC 83 ms
15,304 KB
testcase_13 AC 82 ms
15,312 KB
testcase_14 AC 82 ms
15,056 KB
testcase_15 AC 80 ms
15,132 KB
testcase_16 AC 80 ms
15,256 KB
testcase_17 AC 81 ms
15,132 KB
testcase_18 AC 81 ms
15,288 KB
testcase_19 AC 81 ms
15,132 KB
testcase_20 AC 81 ms
15,132 KB
testcase_21 AC 82 ms
15,044 KB
testcase_22 AC 80 ms
15,236 KB
testcase_23 AC 83 ms
15,088 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

INF = 1000000000
def solve(x1, x2, x3, y1, y2, y3)
    if (x1 == x2 && y1 == y2) || (x3 == x2 && y3 == y2) || (x1 == x3 && y1 == y3)
        return false
    end
    v1 = y1 * INF + x1
    v2 = y2 * INF + x2
    v3 = y3 * INF + x3
    if (v2 < v1 && v2 < v3) || (v2 > v1 && v2 > v3)
        return true
    end
    if y1 == y2 && y3 == y2
        return false
    end
    if y1 == y3
    	return false
    end
    if y1 == y2
    	f3 = -1.0 * (x3 - x2) / (y3 - y2)
    	return f3 > 0
    elsif y3 == y2
    	f1 = -1.0 * (x1 - x2) / (y1 - y2)
    	return f1 > 0
    else
	    f1 = -1.0 * (x1 - x2) / (y1 - y2)
	    f3 = -1.0 * (x3 - x2) / (y3 - y2)
	    if [f1, f3].max >= 0
	        if [f1, f3].max == 0
	            return (x2 < x1 && x2 < x3) || (x2 > x1 && x2 > x3)
	        elsif f1 == f3
	            return false
	        else
	            return true
	        end
	    else
	        return false
	    end
    end

end

n = gets.to_i
n.times do |i|
    puts solve(*gets.split.map(&:to_i)) ? "YES" : "NO"
end
0