結果
問題 | No.629 グラフの中に眠る門松列 |
ユーザー |
![]() |
提出日時 | 2019-03-25 09:33:11 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 38 ms / 4,000 ms |
コード長 | 748 bytes |
コンパイル時間 | 10,404 ms |
コンパイル使用メモリ | 223,084 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-07 05:19:40 |
合計ジャッジ時間 | 12,241 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 36 |
ソースコード
package main import "fmt" func main() { var n, m, a, b int _, _ = fmt.Scan(&n, &m) nodes := make([]int, n) for i := range nodes { _, _ = fmt.Scan(&a) nodes[i] = a } paths := make(map[int][]int, 0) for i := 0; i < m; i++ { _, _ = fmt.Scan(&a, &b) a-- b-- paths[a] = append(paths[a], b) paths[b] = append(paths[b], a) } // fmt.Println(nodes, paths) for i, x1 := range nodes { for _, j := range paths[i] { x2 := nodes[j] if x1 == x2 { continue } for _, k := range paths[j] { x3 := nodes[k] // fmt.Println(x1, x2, x3) if i == k || x1 == x3 || x2 == x3 || (x1 < x2 && x2 < x3) || (x1 > x2 && x2 > x3) { continue } fmt.Println("YES") return } } } fmt.Println("NO") }