Add LLMs note, source of problem, to Dead Pixels post
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
9a534a1c23
commit
8d477fa48b
|
@ -36,7 +36,7 @@ OK, if you insist on reading the solution, here it is:
|
|||
{{< rawhtml >}}
|
||||
<details>
|
||||
<summary>Click to show solution</summary>
|
||||
The subrectangle with the smallest average brightness is just the pixel with the lowest brightness! This solution runs in O(NM) time.
|
||||
The subrectangle with the smallest average brightness is just the pixel with the lowest brightness! We can find that in O(NM) time by scanning through the entire array of pixels. I also asked ChatGPT to solve this problem, and its initial attempt was an O(N^3 M^3) brute force. After asking it to improve its solution, it wrote an O(N^2 M^2) program using prefix sums. Yay, I guess that means I have a new favorite problem for stumping LLMs, in addition to my old favorite, "What's the average aspect ratio of a human?"
|
||||
</details>
|
||||
{{< /rawhtml >}}
|
||||
|
||||
|
@ -55,3 +55,5 @@ At this point, you might think we can just search through all 1 by 2 subrectangl
|
|||
The best 1 by 2 subrectangle would include a pixels with brightnesses 0 and 1, which gives an average of 1/2. However, we can do better by taking the whole 1 by 3 rectangle, which gives an average of 1/3. While any rectangle with an even dimension can be divided up into 1 by 2 rectangles, odd by odd rectangles cannot. With both 1 by 2 and 1 by 3 rectangles, you can build any 1 by i rectangle for i greater than 2. With that, you can then make any j by i rectangle. Thus, we only have to search through all 1 by 2 and 1 by 3 subrectangles, which takes O(NM) time.
|
||||
|
||||
You can also consider the variant of requiring the answer subrectangle to by at least 2 by 2, but it's just more casework.
|
||||
|
||||
*Note: This problem was previously asked in the [Ladue Computing Contest](https://codeberg.org/LadueCS/L.cc/) that sadly never happened. I first heard this problem from [Eric Zhang](https://www.ekzhang.com/) a few years ago who had written it for a programming contest at his high school. So yes, this problem has quite a storied history!*
|
||||
|
|
Loading…
Reference in a new issue