結果

問題 No.743 Segments on a Polygon
ユーザー manhattanermanhattaner
提出日時 2018-10-31 23:01:55
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 490 bytes
コンパイル時間 1,267 ms
コンパイル使用メモリ 11,192 KB
実行使用メモリ 33,684 KB
最終ジャッジ日時 2023-08-12 12:27:23
合計ジャッジ時間 7,820 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, M = gets.split.map(&:to_i)

edges = []

edges = [*1..N].map{
    p1, p2 = gets.split.map(&:to_i)
    if p1 < p2 then
        [p1, p2]
    else
        [p2, p1]
    end
}.sort_by{|p| p[0]}

n_cross = 0

for i in 0...edges.size do
    car_path = edges[i]
    for j in i...edges.size do
        from, to = edges[j]
        if car_path[0] < from && from < car_path[1] &&
            (to < car_path[0] || car_path[1] < to) then
                n_cross += 1
        end
    end
end

p n_cross
0