結果

問題 No.1041 直線大学
ユーザー kou_kkkkou_kkk
提出日時 2024-04-28 01:43:04
言語 Nim
(2.2.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 617 bytes
コンパイル時間 4,407 ms
コンパイル使用メモリ 66,516 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-16 09:46:28
合計ジャッジ時間 5,474 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils, strutils

let
  n = parseInt readLine stdin
  xys = n.newSeqWith stdin.readLine.split.map parseFloat

var
  ans = 2
  cnt: int

for i in 0 ..< n.pred 2:
  for j in i.succ ..< n.pred:
    let
      x1 = xys[i][0]
      y1 = xys[i][1]
      x2 = xys[j][0]
      y2 = xys[j][1]
      dx = x2 - x1
      dy = y2 - y1
    cnt = 2
    
    for k in j.succ ..< n:
      let
        x3 = xys[k][0]
        y3 = xys[k][1]
      if dx == 0 and x1 == x3:
        inc cnt
      elif dy == 0 and y1 == y3:
        inc cnt
      elif dy / dx * (x3 - x1) == y3 - y1:
        inc cnt

    ans = ans.max cnt

echo ans
0