結果

問題 No.245 貫け!
ユーザー yuruhiyayuruhiya
提出日時 2021-05-06 20:43:06
言語 Crystal
(1.11.2)
結果
WA  
実行時間 -
コード長 516 bytes
コンパイル時間 19,457 ms
コンパイル使用メモリ 255,880 KB
実行使用メモリ 7,576 KB
最終ジャッジ日時 2023-10-12 13:08:57
合計ジャッジ時間 21,254 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 3 ms
4,348 KB
testcase_03 AC 2 ms
4,388 KB
testcase_04 AC 3 ms
4,348 KB
testcase_05 AC 3 ms
4,352 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 3 ms
4,488 KB
testcase_08 AC 3 ms
4,640 KB
testcase_09 WA -
testcase_10 AC 8 ms
5,016 KB
testcase_11 AC 23 ms
5,776 KB
testcase_12 AC 56 ms
7,528 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 55 ms
7,404 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

struct Point
  property x : Int32
  property y : Int32

  def initialize(@x, @y)
  end
end

def intersect(p1, p2, p3, p4)
  ((p1.x - p2.x) * (p3.y - p1.y) + (p1.y - p2.y) * (p1.x - p3.x)) *
    ((p1.x - p2.x) * (p4.y - p1.y) + (p1.y - p2.y) * (p1.x - p4.x)) <= 0
end

n = read_line.to_i
a1, a2 = (1..n).map {
  a, b, c, d = read_line.split.map(&.to_i)
  [Point.new(a, b), Point.new(c, d)]
}.transpose
puts (a1 + a2).permutations(2).max_of { |(p1, p2)|
  (0...n).count { |i|
    intersect(p1, p2, a1[i], a2[i])
  }
}
0