結果
問題 | No.245 貫け! |
ユーザー |
|
提出日時 | 2015-07-17 21:39:05 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 28 ms / 5,000 ms |
コード長 | 1,447 bytes |
コンパイル時間 | 11,844 ms |
コンパイル使用メモリ | 225,516 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-10 19:14:47 |
合計ジャッジ時間 | 12,264 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
ソースコード
package mainimport ("fmt""bufio""os""strconv")type Point struct {X intY int}type Vector struct {X intY int}type Line struct{A PointB Point}func vec(p1 Point, p2 Point) Vector {return Vector{p2.X - p1.X, p2.Y - p1.Y}}func cross(p1 Vector, p2 Vector) int {return p1.X * p2.Y - p1.Y * p2.X}func intersect(p1 Point, p2 Point, l Line) bool {return cross(vec(p1, p2), vec(p1, l.A))*cross(vec(p1, p2), vec(p1, l.B)) <= 0}func main() {var N intfmt.Scanf("%d", &N)var p = make([]Point, 2*N)var lines = make([]Line, N)for i := 0; i < N; i++ {fmt.Scanf("%d %d %d %d", &p[2*i].X, &p[2*i].Y, &p[2*i+1].X, &p[2*i+1].Y)lines[i].A = p[2*i]lines[i].B = p[2*i+1]}mx := 0for i := 0; i < 2*N; i++ {for j := 0; j < 2*N; j++ {if p[i] == p[j] {continue}count := 0for k := 0; k < N; k+=1 {if intersect(p[i], p[j], lines[k]) {count+=1}}mx = max(mx, count)}}fmt.Println(mx)}var s = bufio.NewScanner(os.Stdin)func next() string {s.Split(bufio.ScanWords)s.Scan()return s.Text()}func nextLine() string {s.Split(bufio.ScanLines)s.Scan()return s.Text()}func nextInt() int {i, e := strconv.Atoi(next())if e != nil {panic(e)}return i}func nextLong() int64 {i, e := strconv.ParseInt(next(), 10, 64)if e != nil {panic(e)}return i}func max(a int, b int) int {if a < b {return b}return a}