My idea was that there should be an intersection when c and d belong to different sides split by a and b.
The approach mentioned in Editorial is to walk around the clock from 1 to 12. If two red strings or two blue strings appear in a row, there is no intersection.
Here is my implementation of that approach. The editorial shows a more concise way, but for now, I'll put it to follow my natural thought process.
package main
import (
"fmt"
)
func intersect(a int, b int, c int, d int) bool {
before := 0
for i := 0; i < 12; i++ {
if i == a {
if before == b {
return false
}
before = a
} else if i == b {
if before == a {
return false
}
before = b
} else if i == c {
if before == d {
return false
}
before = c
} else if i == d {
if before == c {
return false
}
before = d
}
}
return true
}
func main() {
var t int
fmt.Scan(&t)
var a, b, c, d int
for i := 0; i < t; i++ {
fmt.Scan(&a, &b, &c, &d)
if intersect(a, b, c, d) {
fmt.Println("YES")
} else {
fmt.Println("NO")
}
}
}
https://codeforces.com/blog/entry/129364
For each query, we binary search to find the last sign we passed (since the array a is sorted).
I understand binary search, but I could not come up with using it during the contest.
Let's try to implement this approach tomorrow.
The Document Object Model (DOM) is a programming interface for web documents.
The DOM represents the web page content and structure as a tree, and each element in the HTML document is treated as a node in the tree.
As I look at the web page of University of Wachinton, the tree structure might look like
document
└── html
├── body
│ ├── h1
│ │ └── This is a heading
│ └── p
│ ├── This is
│ ├── a
│ └── b
│ └── body
└── head
└── title
└── this is a title
JavaScript can access and manipulate the DOM tree. This allows us to dynamically change the content, style, and behavior of a web page.
Benefits of DOM
Yogurt 300 Lunchable 250 Chicken 350 Sushi bowl 800
Total 1700 kcal
TODO: