結果

問題 No.635 自然門松列
ユーザー maimai
提出日時 2017-03-31 21:00:50
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 1,226 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 11,208 KB
実行使用メモリ 15,840 KB
最終ジャッジ日時 2023-10-11 12:56:13
合計ジャッジ時間 5,677 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 89 ms
15,640 KB
testcase_02 AC 86 ms
15,204 KB
testcase_03 AC 110 ms
15,508 KB
testcase_04 AC 106 ms
15,636 KB
testcase_05 AC 140 ms
15,464 KB
testcase_06 AC 147 ms
15,392 KB
testcase_07 AC 142 ms
15,464 KB
testcase_08 AC 97 ms
15,256 KB
testcase_09 AC 90 ms
15,312 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 230 ms
15,560 KB
testcase_13 AC 228 ms
15,392 KB
testcase_14 AC 226 ms
15,416 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def scan; gets.split.map{|e|Rational(e)};end

# 🎍
def kadomatu?(a,b,c)
    a!=b&&b!=c&&c!=a&&((a<b&&b>c)||(a>b&&b<c))
end

def solve1(x1,x2,x3,y1,y2,y3)
    STDERR.puts [x1,x2,x3,y1,y2,y3]*" "
    
    # 解法
    # 二分探索する.
    # tL = 0 , tH = (大きな数値)から開始する.
    # tLのときに竹の長さが昇順だったとすると,tHは降順になっているはずである.
    # どこかで昇順と降順が切り替わっているはずなので,その時刻を探し,🎍になっているかどうか検証する.
    tl = Rational(0)
    th = Rational(1e15)
    
    80.times{
        tc = (tl+th)/2
        if kadomatu?(x1+y1*tc, x2+y2*tc, x3+y3*tc)
            STDERR.puts "found #{tc.to_f}"
            return "YES" 
        end
        
        # 時刻0の『昇順/降順』と時刻tcの『昇順/降順』が等しいなら
        if (x1 < x3) == (x1+y1*tc < x3+y3*tc)
            tl = tc
        else
            th = tc
        end
    }
    STDERR.puts "#{tl.to_f} < t < #{th.to_f}"
    return "NO"
    
end


def solve(x1,x2,x3,y1,y2,y3)
    solve1(x1,x2,x3,y1,y2,y3)
end


n=gets.to_i
n.times{
    x1,x2,x3,y1,y2,y3 = scan
    puts solve(x1,x2,x3,y1,y2,y3)
}
0