[Question]
  [
In this challenge you will receive a list of pairs of non-negative integers representing a mushroom forest. Each pair represents a mushroom whose center is at that horizontal coordinate. The only part of the mushroom we care about is the cap (the flat bit at the top).
The first integer in each pair represents which row the cap is placed in. i.e. the height of the mushroom.
The second integer represents the radius of the cap. If it's zero then there just isn't a mushroom in that position. Other for size \$n\$ a total of \$2n-1\$ spaces are occupied centered at the index of the pair. For example `1` means that its cap only occupies a space above it, a `2` means it occupies a space above it and the spaces one unit to the left and right.
As an example here's an example with the forest drawn:
```
=-=-= =-=-=-=-=-=-= =
  |         |       |
  | =-=-=   |   =-=-=
  |   |     |     | |
  =-=-=     =-=-=-=-=
  | | |     |   | | |
[ 2,0,1,0,0,2,0,0,1,2 ] <- Heights
[ 2,2,2,0,0,4,0,3,2,1 ] <- Widths
```
(For clarity, stems are drawn with `|` and extra spacer rows are added between layers)
Your task is to determine from an input list whether there are any collisions between mushroom caps. That is if there is any pair of mushrooms that both occupy 1 or more common spaces.
You should output one of two distinct values. One if there is a collision and the other if there is not.
You may take input instead of a list of pairs as two separate lists of the same length.
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so the goal is to minimize the size of your source code as measured in bytes.
## Test cases
Test cases are provided with an illustration.
### No collision
```
=-=-= =-=-=-=-=-=-= =
  |         |       |
  | =-=-=   |   =-=-=
  |   |     |     | |
  =-=-=     =-=-=-=-=
  | | |     |   | | |
[ 2,0,1,0,0,2,0,0,1,2 ] <- Heights
[ 2,2,2,0,0,4,0,3,2,1 ] <- Widths
  =-=-= =
    |   |
=-=-= =-=-=-=-=
  | |   | |
[ 0,1,0,1,0 ] <- Heights
[ 2,2,0,1,3 ] <- Widths
    =-=-=-=-=-=-=
          |
  =-=-=-=-=-=-=
        | |
    =-=-= |
      | | |
    = | | |
    | | | |
=-=-= | | |
  | | | | |
[ 0,1,2,3,4 ] <- Heights
[ 2,1,2,4,4 ] <- Widths
```
### With Collisions
Locations with a collision are marked with `X`.
```
 =-X-X-=
   | |
   | |
   | |
[0,1,1] <- Heights
[0,2,2] <- Widths
   X-=-=-=-=-=-=
   |     |
[0,0,0,0,0] <- Heights
[0,1,0,0,4] <- Widths
 =-=-X-=-=-=-=
   |     |
[0,0,0,0,0] <- Heights
[0,2,0,0,3] <- Widths
```
```
  
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), 31 bytes
```
{a~?a:,/x,''(!#y)+(?,/-:\!:)'y}
```
[Try it online!](https://ngn.codeberg.page/k#eJxdTTEOgCAM3HlFjQMaMdjSCQYfogwsvkFj9O0WwcU011zvLr3Nn+mekzd2N1p3TXv0QzcbO/q18b0+LqW2hWACFExA70agQED1YoETjlGiJSgIxUZwn0ySYpEzY+CoVDUw5MdUcnXC18h/uZS6+ADotiRa)
-4 bytes thanks to @ovs! Golfed even more with inspiration from @UnrelatedString's approach.
## Explanation
Height list is *x*, width list is *y*.
* `(?,/-:\!:)'y` convert each width to range `(-width, width)`
* `(!#y)+` add indices
* `x,''` add corresponding height to each index in each width range
* `a~?a:,/` flatten, check for duplicates
[Answer]
# [MathGolf](https://github.com/maxbergmark/mathgolf/blob/master/math_golf.txt), 22 [bytes](https://github.com/maxbergmark/mathgolf/blob/master/code_page.py)
```
mÆ╤╞╡ï+m▐ò┤\h?a*^~]_▀=
```
Port of [my 05AB1E answer](https://codegolf.stackexchange.com/a/249028/52210) (the 19-bytes version; since the 22-bytes version was using a group-by, which MathGolf lacks and I also couldn't find any suitable alternative for with its available builtins after some trial-and-error for more than an hour.. :/)
Just like my 05AB1E answer: input as two separated (equal-length) lists, first being the list of widths, second the heights.
[Try it online.](https://tio.run/##y00syUjPz0n7/z/3cNujqUseTZ33aOrCw@u1cx9Nm3B406MpS2Iy7BO14upi4x9Na7D9/z/aSAcEDYDQBIiNgWzDWIVokIghWBQiZ6hjFMsVDVFpqGMMVAGRB2KwOFAeqN8EKm4ENMcEKA7SbQQVMwTzIWZC1EEhVB2IbYwiDgA)
**Explanation:**
Basically the same three steps as my 05AB1E answer:
Step 1: Change each value in the input to a list of indices it can reach:
```
m          # Map over the first (implicit) input-list of widths,
 Æ         # using 5 bytes as inner code-block:
  ╤        #  Convert it to a list in the range [-n,n]
   ╞╡      #  Remove the first/last items to change it to range (-n,n)
     ï+    #  Add the 0-based map index to each value as offset
```
[Try just this first step.](https://tio.run/##y00syUjPz0n7/z/3cNujqUseTZ33aOrCw@u1//@PNtIBQQMgNAFiYyDbMFYhGiRiCBaFyBnqGMVyRUNUGuoYA1VA5IEYLA6UB@o3gYobAc0xAYqDdBtBxQzBfIiZEHVQCFUHYhujiAMA)
Step 2: Pair each inner index with the height of the second input:
```
m▐         # Append each value in the second (implicit) input-list of heights to
           # the (-n,n)-list at the same position
  ò        # Loop over the lists, using 8 bytes as inner code-block:
   ┤       #  Extract tail; push remainder-list and last item separated
    \      #  Swap so the remainder-list is at the top
     h     #  Push its length (without popping)
      ?    #  Triple-swap the [tail,list,length] to [list,length,tail]
       a   #  Wrap the tail into a list
        *  #  Repeat it the length amount of times
         ^ #  Zip to create pairs of the list with these repeated tails
```
[Try just the first two steps.](https://tio.run/##y00syUjPz0n7/z/3cNujqUseTZ33aOrCw@u1cx9Nm3B406MpS2Iy7BO14v7/jzbSAUEDIDQBYmMg2zBWIRokYggWhcgZ6hjFckVDVBrqGANVQOSBGCwOlAfqN4GKGwHNMQGKg3QbQcUMwXyImRB1UAhVB2Ibo4gDAA)
Step 3: Check if all (flattened) pairs are unique, and output the result:
```
   ~       #  Still in the loop of step 2: dump the pairs to the stack
]          # After the loop: wrap all pairs on the stack into a list
 _▀=       # Check if all pairs are unique:
 _         #  Duplicate the list of pairs
  ▀        #  Uniquify the copy
   =       #  Check if both lists are still the same
           # (after which the entire stack is output implicitly as result)
```
[Answer]
# [Python](https://www.python.org), ~~153~~ ~~105~~ 86 bytes
*-19 bytes thanks to [@Unrelated String](https://codegolf.stackexchange.com/users/85334/unrelated-string)*
```
lambda l:len(d:=[(h,z)for i,(h,x)in enumerate(l)for z in range(-x-~i,x+i)])==len({*d})
```
[Attempt This Online!](https://ato.pxeger.com/run?1=fVDbSsQwEMXH5ivmMdEUbLaIFPIbvtQi0aY20M2WNouxoj_iS0H0n_RrzGVtd1-EYWY458xwOO9f_bNpd3r-aPjt59406fX3TSe297WAruikxnXBS9zSiTS7ARR1qyVKg9T7rRyEkbgLzAQOHIR-lDi16Zui9kKRinDuf7yc168kfv85uzJyNHcPYpQjcChRgktG4ZJCFror9rc4hFUUPM-O4Dz0TUCyilD_Yrn3fb2JwOZExMJtfhBFIPfAsSjzdPTCVmKtA714zv8RLcaDjwohH1hL4clntqZRoMS6RBo8qR57mhCU9IPSBluCYnzzHOcv)
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~22~~ 19 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
εD(Ÿ¦¨N+INèδ‚}€`DÙQ
```
-3 bytes using a similar approach as [*@UnrelatedString*'s Python answer](https://codegolf.stackexchange.com/questions/249026/check-a-mushroom-forest/249027#comment556224_249027)
Input as two separated (equal-length) lists, first being the list of widths, second the heights.
[Try it online](https://tio.run/##yy9OTMpM/f//3FYXjaM7Di07tMJP29Pv8IpzWx41zKp91LQmweXwzMD//6ONdEDQAAhNgNgYyDaM5YoGiRiCRSFyhjpGsQA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfWVC6P9zW100ju44tOzQCj/tCL/DK85tedQwq/ZR05oEl8MzA//r/I@OjjbSAUEDIDQBYmMg2zBWJxokYggWhcgZ6hjFxuooQJSDuMZARRAlQAyTAqoCmmIClTICmmYCkQIZYwQVNoQJQcyHqIZChGoQ1xhVKhYA).
**Explanation:**
Step 1: [Exact same first step as in the previous related challenge](https://codegolf.stackexchange.com/a/248968/52210): Change each value in the input to a list of indices it can reach:
```
ε         # Map over each value of the (implicit) input-list:
 D(       #  Create a negative copy
   Ÿ      #  Pop both, and push a list in the range [n,-n]
    ¦¨    #  Remove the first and last to make the range (n,-n)
          #  (or empty the list if n=0)
      N+  #  Add the current map-index as offset
```
[Try just this first step.](https://tio.run/##yy9OTMpM/f//3FYXjaM7Di07tMJP@///aCMdEDQAQhMgNgayDWO5okEihmBRiJyhjlEsAA)
Step 2: Pair each inner index with the height of the second input:
```
 I        #  Push the second input-list of heights
  Nè      #  Use the map-index to get the current height
    δ     #  Apply double-vectorized:
     ‚    #   Pair this height with each index in the (n,-n) range
}         # Close the map
```
[Try just the first two steps.](https://tio.run/##yy9OTMpM/f//3FYXjaM7Di07tMJP29Pv8IpzWx41zKr9/z/aSAcEDYDQBIiNgWzDWK5okIghWBQiZ6hjFAsA)
Step 3: Check if all (flattened) pairs are unique, and output the result:
```
€`        # Flatten the list of lists of pairs one level down
  DÙQ     # Check if all pairs are unique:
  D       #  Duplicate the list
   Ù      #  Uniquify this copy
    Q     #  Check if both lists are still the same
          # (after which the result is output implicitly)
```
[Answer]
# [Haskell](https://www.haskell.org), ~~112~~ ~~85~~ 75 bytes
*-37 bytes thanks to [@Wheat Wizard](https://codegolf.stackexchange.com/users/56656/wheat-wizard)'s tips*
```
import Data.List
f k|z<-do(i,(y,x))<-zip[0..]k;(y,)<$>[2-x+i..x+i]=z==nub z
```
[Attempt This Online!](https://ato.pxeger.com/run?1=fVHLSsQwFMVtvuIyzKLBNEwzXQi2rtypG3UhlDDEscXQJ0kKM8U_cTMb8QP8Gv0a06a2OgvD5RDOPfdwc_L6_ix0nhbFR7LwH-7bpkjv0q2RdaUX_PDWmsw_-7ySZVMrA5fCCHottUEZ5C9d5D_VniTenuwwjvxONsmKUp6fWwZHy4uE-btTSakFHndxXLWP0DnLr5Nbk2qz2QqdaoghQWCPlzACKwLBgLbYz8UyjBPo--wXHQ64HpiAYzK6TBY9zmOOWB_r2OAQjjpHhD1xpAt6hVuK_enNNSqm_cP_ddM77E4cIWWDKEUDXlttW6X2sAQvA4qBgs0Ww5wYQqWQlZPfbKBRsjKgXLSH8de-AQ)
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), ~~22~~ ~~21~~ 18 bytes
```
{Is.e,RGtr-keAb+kH
```
[Try it online!](https://tio.run/##K6gsyfj/v9qzWC9VJ8i9pEg3O9UxSTvb4///aA0jHSNNHQ0DMGkIZRvASSMdEyQRY7gaIx1DzVgA "Pyth – Try It Online") or [Verify all test cases](https://tio.run/##K6gsyfiv/L/as1gvVSfIvaRINzvVMUk72yNQwdb1//9oDSMdI00dDQMwaQhlG8BJIx0TJBFjuBojHUPNWK5oLPoMgTIQtcjyhmA9ILYx2EQTIAmRN4DrB5EIMQOoOQZIpAmKvBGGPNBOAA "Pyth – Try It Online")
### Explanation
`.e` enumerates over the implicit input with index `k` and value `b`.
`Ab` sets `G` and `H` to the elements of `b` (in this case, height and width respectively)
`tr-keAb+kH` builds a range from **k-H+1** to **k+H** (half inclusive)
`,RG` appends the height to each element of that list, resulting in a list of coordinates for the current mushroom.
`s` flattens the list by one level. And `{I` checks whether the list remains invariant under deduplication, meaning that no two mushrooms share a coordinate.
[Answer]
# JavaScript (ES6), 58 bytes
Expects `(heights)(widths)`. Returns a Boolean value.
```
h=>w=>w.some((w,x)=>h[H=~h[x]]&(h[H]|=m=4**w/2-1<<x>>w,m))
```
[Try it online!](https://tio.run/##jY/BDoIwDIbvPAUns5GBbOzIdvYdyA4EQTTAjBjHwfjqs2wQEyOJ2br0X7/@aS/loxyr2/l6jwd9rG0jbCukgZuMuq8RMmTCQrbFQbzaYlJqhyBXT9ELHkVmz2Ka55OUhvQY20oPo@7qpNMn1KAiZCQlFCIlzL2UsFBhV2DLF4fIIKdQwMG3gW@H@LTNMtuEGZjxFZ4ldxIHP2nqyXk8tmG5nBX02/D/YL@hG9a@AQ "JavaScript (Node.js) – Try It Online")
### How?
This is using the same method as in [my answer to the other challenge](https://codegolf.stackexchange.com/a/248986/58563). But since there's no search involved, we can just store the bitmasks in one of the input arrays with negative indices.
---
# JavaScript (ES6), 65 bytes
Expects `(heights)(widths)`. Returns a Boolean value.
```
h=>w=>w.some((p,i)=>w.some((q,j)=>p*q&&h[i]==h[j]&j>i&i+p-1>j-q))
```
[Try it online!](https://tio.run/##jY/BDoMgDIbvPoUnAhsaQa74IsaDcTohTlCX7fFZBY3JMpMF2vDTr39aXb/qpZmVfSajubWuk66XxRtuuphHi7GlihxqohqUvUwI9aWqpOxLXSFdKKSuNmGFTiZCXGPGxQxtOpg77nAZc5pRBpFR7jOjPK6IL/DtS0Dk8GZQING3QWiHONpWmZ/CHMzEDq9SeEminzQL5DoeP7Hczg6GbcR/cNjQD@s@ "JavaScript (Node.js) – Try It Online")
### Commented
```
h =>                // h[] = array of heights
w =>                // w[] = array of widths
w.some((p, i) =>    // for each mushroom of width p at index i:
  w.some((q, j) =>  //   look for another mushroom of width q at index j:
    p * q           //     such that they both actually exist,
    && h[i] == h[j] //     they have the same height,
    & j > i         //     the 2nd one is located after the 1st one,
    & i + p - 1     //     and the right part of the 1st one intersects
      > j - q       //     with the left part of the 2nd one
  )                 //   end of inner some()
)                   // end of outer some()
```
[Answer]
# [Desmos](https://desmos.com/calculator), 156 bytes
```
l=W.length
k=max(0,i-W[i])
L=[1...n]
g(n)=L[L0+n>0]0
f(H,W)=0^{0^{[max(∑_{i=1}^ljoin(g(k),g(W[i]+i-1-k)+1,g(l))[1...l]0^{(h-H[i])^2})forh=H[1...]].max-1}}
```
My attempt at solving this challenge without looking at the other answers lolol. You can see how terribly that came out just by how long the answer is.
The function `f` takes in the height list first and the width list second, and returns `0` for no collisions, `1` if there is a collision.
Also the `H[1...]` can't be golfed to `H` (I checked), because apparently `H` is recognized as a number, not a list, so the list comprehension errors out. `H[1...]` circumvents this error by forcing Desmos to recognize `H` as a list.
[Try It On Desmos!](https://www.desmos.com/calculator/8tqo5bq7yn)
[Try It On Desmos! - Prettified](https://www.desmos.com/calculator/mbr5uifcgl)
I have added an explanation of my code below because I'm bored :P.
### Explanation
The general rundown of my strategy is for each height, construct lists of `1`'s and `0`'s which correspond to the spaces that each mushroom takes up for that particular height. Then, all these lists are summed together. If there is a collision at that height, then there will be a number \$>1\$ in the list.
Now, to explain each part of the code.
```
L=[1...n]
g(n)=L[L0+n>0]0
```
`g` is a function that will return a list of `n` zeroes.
```
f(H,W)=0^{[max(∑_{i=1}^ljoin(g(k),g(W[i]+i-1-k)+1,g(l))[1...l]0^{(h-H[i])^2})forh=H[1...]].max-1}
```
`f` is the function that returns the answer. Let's break it down:
```
... [ ... forh=H[1...]]
```
For `h` in list `H` (looping over all heights)...
```
... ∑_{i=1}^l ...
```
Take the summation from `i=1` to the length of list `W` of (looping over indices of the width list)...
```
join(g(k),g(W[i]+i-1-k)+1,g(l))[1...l]
```
A list of `1`'s and `0`'s, representing the spaces that the mushroom at index `i` in the width list takes up, with `1` representing the space taken up by the mushroom. This list is constructed by joining three individual lists into one list: `g(k)`, `g(W[i]+i-1-k)+1`, and `g(l)`.
The first list, `g(k)`, consists of the `0`'s before the range of `1`'s which represent the mushroom. The number of `0`'s needed can be calculated by subtracting the width of the mushroom `W[i]` from its index `i` (The mushroom extends `W[i]-1` spaces to the left from the center space, so `i-W[i]` is essentially calculating the index of the last `0` right before the mushroom.). The issue with this is that some mushrooms extend past the front of the list, which will make `i-W[i]` negative. While this is no problem for `g` (it returns an empty list for negative inputs), it may cause issues for length calculations later on (i.e. the list of `1`'s right after), so instead we store the length of the list as `k=max(0,i-W[i])`, and call `g(k)` to construct the list of `0`'s.
The second list, `g(W[i]+i-1-k)+1`, constructs a list of `1`'s which represent the space that the mushroom takes up. `g` returns a list of `0`'s, so we convert that to a list of `1`'s by adding 1 to the list. At first, it might be obvious to do `g(2W[i]-1)+1` as each mushroom takes up \$2w-1\$ spaces. But this runs into the problem of width 0, as `g(-1)+1` is just an empty list, but what we actually wanted was the list `[0]`. Also, the bigger problem is that it doesn't account for mushrooms extending past the front of the list, and will have too many `1`'s for those mushrooms. To counteract this problem, note that the length of the list up to the end of the mushroom has to be `i+W[i]-1` (the mushroom extends `W[i]-1` spaces to the right of its center, `i`, so the index of the last `1` in the mushroom is `i+W[i]-1`). The first list already accounted for `k` of the elements, so the second list will have a length of `i+W[i]-1-k` to account for the rest of the elements.
The last list, `g(l)`, is simply to pad the end of the list with enough `0`'s to make the list have a length of at least `l=W.length` for the slice (explained below).
`[1...l]` is a slice that takes the first `l` elements of the list. This is to ensure that all the lists being summed have the same length, as Desmos gives an error if they aren't all the same length.
```
0^{(h-H[i])^2}
```
This checks if the height of the mushroom at index `i` is the same as the current height `h` (if we don't have this code, then the function would detect for collisions as if they were all on the same height). `(h-H[i])^2` returns `0` if the current height `h` is the same as the mushroom's height `H[i]`. Otherwise, it returns a positive integer. Then, `0^{(h-H[i])^2}` returns `1` if `(h-H[i])^2` is `0`, and `0` if `(h-H[i])^2` is a positive integer.
Putting that all together, `0^{(h-H[i])^2}` returns `1` if `h` equals `H[i]`, and returns `0` otherwise. When multiplying this value with the list, if it is `1`, then nothing happens to the list, but if it is `0`, then all the entries in the list become `0`, which essentially means that the list won't contribute to the summation at all. This causes any mushroom that isn't at the current height of the loop to be nullified, leaving only the mushrooms which are at the current height to contribute to the summation.
```
0^{0^{[max( ... ) ... ].max-1}}
```
Recall that if the summed list contains any number \$>1\$, then that means there is a collision. If there are any numbers \$>1\$, then the `max` of the summed list will be \$>1\$. The list comprehension will create a list of maximums for each height in `H`. By taking the maximum of the list comprehension, we can then detect if there were any collisions in any of the heights if the maximum is \$>1\$. We can do this by first subtracting one from the maximum, and then wrapping `0^{0^{ ... }}` around it. `0^{0^n}` for any integer `n` returns `1` if `n` is positive, and `0` if `n` is `0` or negative. This means if the maximum is `0` or `1`, the function will return `0`, because both `0^{0^{-1}}` and `0^{0^0}` return `0`. If the maximum is `2` or above, then the function will return `1`.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 26 bytes
```
⊙η∧ι⊙…ηκ∧λ∧⁼§θκ§θμ›⁺ιλ⊕⁻κμ
```
[Try it online!](https://tio.run/##RUxNC4MwDL37KzxG6MB2u@0kMoaHgXfxUGpAMdZZ65i/vosfsMDLy/sgptXOjJpCKF1nPWR2hVbEmW2g22iFfDWEeTu@N79PjowOekyLphkyX9gGvzCdhb8cEtZPh9qjg5KWeftK7BXWOBzQemzg1VkO@r19zj2EKqpiJVIhGalQ@5ZCxXUk9kSd3o1x5VtyUofLh34 "Charcoal – Try It Online") Link is to verbose version of code. Outputs a Charcoal boolean, i.e. `-` if there's a collision, nothing if not. Explanation:
```
 η                          Input widths
⊙                           Any element satisfies
   ι                        Current width
  ∧                         Logical And
      η                     Input widths
     …                      Truncated to length
       κ                    Outer index
    ⊙                       Any element satisfies
         λ                  Current width
        ∧                   Logical And
             θ              Input heights
            §               Indexed by
              κ             Outer index
           ⁼                Equals
                θ           Input heights
               §            Indexed by
                 μ          Inner index
          ∧                 Logical And
                    ι       Outer width
                   ⁺        Plus
                     λ      Inner width
                  ›         Is greater than
                        κ   Outer index
                       ⁻    Minus
                         μ  Inner index
                      ⊕     Incremented
```
[Bonus program!](https://tio.run/##bU9Na4NAED3HXzF4GmEFtT314xASShOwhNDSg3iwOtEl667RVVJKf7udmPTQj4EZhjfvzZvJq6zNTabGMTYD4ROVmSWMPAGhd@tsWqktJhvVdzgVNwFXwNpIjQfBresx04UU7nx4JFlWtnMZ@VdQ/Ra8ysJWzE/ZaWdawC0N1HaEK52zVg60zXRJGAiIs6Os@xoPHgdM5Aepi7lSpzskY3IHOLcrXdDx5LRn6MOZrfu6eTa4NP2bogL3bB6w2@z82M1LI4DNWqpJW55/83jhiRX3ysrmTPUFLN5zRYvKNOje@/zVkv4qf54wrfkcx8RJIBKBCDkDEU01FBGkjpgm0QW75rziPuRJOvqD@gI "Charcoal – Try It Online")
[Answer]
# [Factor](https://factorcode.org) + `math.unicode`, 100 bytes
```
[ [ swap dup neg (a,b) n+v ] map-index zip expand-keys-push-at values [ concat dup members = ] ∀ ]
```
[Attempt This Online!](https://ato.pxeger.com/run?1=dVGxTsMwEBVrvuJGECRK0g4IBCtiYQGmqIObXNqojWNiO6RUkRj5B5YssPFBMPIlPdtJpQph6-y753fvTr73z5ylqqr7n6OHx_vbu5sLWGHNcQ0lU0t7BDXjC5TOb9CwJUh80shTgpmUVTpeAbaqZuZZDQmaF2mVIYgaldqIuuAKLj1v6wGtLe0YQojIQusZP4bO4vGATMkm5EeEd_s8l2VsZJto8ocTEzYdOCaa2qjzDkiRJYRW5lBg3N2-ZDgI_MdxTbtGug-tcv_8O0sgAfnMBGRaAMcFHLOz-Qnw0wZm9FHCL3iGLbwUArAVjGf-CjfSF1oufaagYWtNf51AWvGUYqNSYjlHGsUVKfy-vcLM1frK3SyuSRUCh_W9u3c)
Oh how I wish there was a word for `expand-keys-push-at values` that was around 6 bytes instead of 26. This uses the algorithm described in Kevin Cruijssen's [05AB1E answer](https://codegolf.stackexchange.com/a/249028/97916).
[Answer]
# [R](https://www.r-project.org), 100 bytes
```
\(h,w,a=\(x,y,z)`if`(z>=0,complex(0,x,-z:z+y),y),p=mapply(a,h+1,seq(!h),w-1))any(table(unlist(p))>1)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=bU9LDoIwEN17C3czYUjawsKYwElYUBECCWAVCJ-ruEETL-FNvI2txc_CtNP2fdo3PV9O8zULbl2buZvHPoKcepJBBAONNGFcZDFMYcAoOVSqTAdgNJA7bSdnRNJTBZVUqhxBUu5watIjrHOk3uWIsh6hlbsyha4ui6YFhRhyXLLuGSQgiBHXxUi8Vk4CydBiIXxdnj7r51bmgrXretsM8H5Eoe2-FQ3wNfiK3AgmS3zIZVjBtuL_F21DJsv-YJ7t_gQ)
Complex numbers!
[Answer]
# [BQN](https://mlochbaum.github.io/BQN/), 36 bytes
```
(∨˝⍟2((∧´+´>≠⋈⌈´)¨·∾´↑¨∘↓)˘)∘⍉=⌜⟜⍷⊸×
```
Dyadic function; takes a list of heights as its left argument and a list of widths as its right argument. Returns 0 for no collisions or 1 for one or more collisions, wrapped in a [unit array](https://mlochbaum.github.io/BQN/doc/enclose.html#whats-a-unit).
[Try it at BQN online!](https://mlochbaum.github.io/BQN/try.html#code=RiDihpAgKOKIqMud4o2fMigo4oinwrQrwrQ+4omg4ouI4oyIwrQpwqjCt+KIvsK04oaRwqjiiJjihpMpy5gp4oiY4o2JPeKMnOKfnOKNt+KKuMOXCgpoZWlnaHRzIOKGkCDin6gKIFsyLDAsMSwwLDAsMiwwLDAsMSwyXSwKIFswLDEsMCwxLDBdLAogWzAsMSwyLDMsNF0sCiBbMCwxLDFdLAogWzAsMCwwLDAsMF0sCiBbMCwwLDAsMCwwXQrin6kKd2lkdGhzIOKGkCDin6gKIFsyLDIsMiwwLDAsNCwwLDMsMiwxXSwKIFsyLDIsMCwxLDNdLAogWzIsMSwyLDQsNF0sCiBbMCwyLDJdLAogWzAsMSwwLDAsNF0sCiBbMCwyLDAsMCwzXQrin6kKCmhlaWdodHMgRsKoIHdpZHRocw==)
### Explanation
```
=⌜⟜⍷⊸×
```
Splay the widths out into different columns of a 2D array, one column for each distinct height in the heights list.
```
(...)∘⍉
```
Transpose so each list of widths-at-a-given-height is now a row. Then:
```
(...)˘
```
Map over each row:
```
·∾´↑¨∘↓
```
Generate a list of all sublists; then:
```
(...)¨
```
Map this function to each sublist:
```
∧´+´>≠⋈⌈´
```
Is the sum of the sublist greater than both the length of the sublist and the max of the sublist?
This function will always return 1 for any sublist that:
* Starts and ends with a nonzero mushroom width, and
* Has all zeros between the two nonzero values, if
* The two mushrooms overlap
It will also return 1 for certain other sublists, but only if they contain a sublist that matches the above criteria. Thus, if there are any 1's in the results, that indicates the existence of some overlapping pair of mushrooms.
```
∨˝⍟2
```
We have a 2D array of 0's and 1's; fold its leading axis on logical OR twice, giving a 0D array containing 1 if there were any 1's and 0 otherwise.
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 19 bytes
```
¨2$:NrḢ+⁰ntiv";ÞfÞu
```
[Try it online](https://vyxal.pythonanywhere.com/#WyIiLCIiLCLCqDIkOk5y4biiK+KBsG50aXZcIjvDnmbDnnUiLCIiLCJbMiwyLDIsMCwwLDQsMCwzLDIsMV1cblsyLDAsMSwwLDAsMiwwLDAsMSwyXSJd) or [verify all test cases](https://vyxal.pythonanywhere.com/#WyJQIiwixpvDt8KjIiwiwqgyJDpOcuG4oivCpW50aXZcIjvDnmbDnnUiLCI7WmAgPT4gYHZq4oGLIiwiW1tbMiwyLDIsMCwwLDQsMCwzLDIsMV0sWzIsMCwxLDAsMCwyLDAsMCwxLDJdXSwgW1syLDIsMCwxLDNdLFswLDEsMCwxLDBdXSwgW1syLDEsMiw0LDRdLFswLDEsMiwzLDRdXSwgW1swLDIsMl0sWzAsMSwxXV0sIFtbMCwxLDAsMCw0XSxbMCwwLDAsMCwwXV0sIFtbMCwyLDAsMCwzXSxbMCwwLDAsMCwwXV1dIl0=).
Port of 05AB1E. Too bad we don't have a loop index variable. Then it could be 16 bytes.
```
¨2$:NrḢ+⁰ntiv";ÞfÞu
¨2                  # Open a dyadic map lambda: Map over the implicit first input, pushing both item and index
  $                 #  Swap so the item is at the top
   :Nr              #  Range [n, -n)
      Ḣ             #  Remove the first item to make this (n, -n)
       +            #  Add the index
        ⁰nti        #  Index the loop-index into the second input
            v"      #  Pair each in the list with this
              ;     # Close map
               Þf   # Flatten one level
                 Þu # Is this unique?
```
[Answer]
# [Python 3](https://docs.python.org/3/) with NumPy, 83 bytes
```
def f(h,w):
 for j in h:x,=(w*(h==j)>0).nonzero();1**((x-w[x])[1:]+1-(w[x]+x)[:-1])
```
[Try it online!](https://tio.run/##fVHRjoMgEHyWr9j4BBYvBX2i8X7EmIvpYbSJQJCL2p@3gp72Xi7ZbGBmdpkMZnatVtmyfMsGGtzSkQgEjbbwgE5BKyZa4DHBbVE8yOeVfCitntJqTG4sSTCe0rGcKlIyUV1Yiv3lMpFSpKwiS2N1D@qnNzN0vdHWQW1tPSPk5OC@7vUgByigRBEuOYUrBRb6Wvz3sCK8ouB5/gbnoWcBWV@ifsUx7/s5swHZHxEPs/ku2oDcA@8i5unNCz@Js3b68Jz/IzqMBx8VQj7hlsLoQz7TEChydhYNTvra4BAWDX9CyM3YTjkcz3KICYrkdJfGiR1UOibLCw "Python 3 – Try It Online")
Takes two array arguments and signals by error/no error.
[Answer]
# [C (clang)](http://clang.llvm.org/), 128 bytes
```
i;j;k;*c;r;f(*h,*w,n){for(r=i=0;i<n;++i)for(c=calloc(n,8)+n,j=i;j<n;++j)for(k=-~j-w[j];h[i]==h[j]&k<j+w[j];)r|=++c[k++]>1;*h=r;}
```
[Try it online!](https://tio.run/##rZRtr5owFMff30/RkbhQKJmWh2yrvXux7FMgWbTiBdRqwKRuzn30uUIplO4me7ERrIdzfv2fc9oCC9hhzV8ej5JUZE88Rmqyc70CeQJxeNudaremJZ2TcsmJ75ew9TDK1ofDibkcvYc@RxWVs7t41cX3NPhZBSKtMlKkZUZpIc23@2Xldz5Y/6C@z9K972fPC@IVtCb3R8kv4LguuQvB7QnIq3Vc8ubytVikGaDghhGYI7DoRnljbUgPvpORFyOPDSzqxrDzLEy@wIofxNtxIohNQQWEE4XQVMBdlmiiEA4KCogsoIhMhUl5Ygxhq9MiHkLjPZkbW63N7bzJ3xQSM7sCZO96h7xeRkH9diG9rtoItRFpI9ZGopL1OsLQEVpHaB2hdYTWEVpHJGNNysOVVFN@z087t68MvuufPe1AYEJgm8A2EdpEaBORTUQ2EdtEbBOJTSTQaDC/nnN2ybeqxYU6M8b2dSA78eYCWLGuPTnmbJ/XindW1y94df3wWf5iBwHzOXT62fI9Bm6bq@Tb/CqnzUlvLnWluoqx1MFDgPxWtDTsxNQLPRyZQsr1x6aDMjKNCx0Xr8UB12H@R3isuq9YVsu7YuDAtNe5ltDOdWbNbCtXoPzULsNHJ5V/7RcLjoqazFbcgf81kZgmasU2KTeaOeZHdv7mbmRN8q31uJm@9QoEuCXQyGq8zdSXS9@b4cTYKzb0B4JnMNuCWSMblYcRDWemoTTP/qH1IAicVxZ0XM/70/3xi@0O65fmEYjf "C (clang) – Try It Online")
Inputs a pointer to an array of mushroom heights \$h\$, a pointer to an array of mushroom widths \$w\$, and the length of the arrays (since pointers in C carry no length info).  
Returns, through the input pointer \$h\$, \$0\$ if there aren't any collisions between mushroom caps and \$1\$ otherwise.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 15 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
Ḥ’R_"ƲĖS€;€"ẎQƑ
```
A dyadic Link that accepts the widths on the left and the heights on the right and yields `0` if there are collisions or `1` if not.
**[Try it online!](https://tio.run/##y0rNyan8///hjiWPGmYGxSsd23RkWvCjpjXWQKz0cFdf4LGJ////jzbSAUEDIDQBYmMg2zAWJGqgYwgWhcgZ6hjFAgA "Jelly – Try It Online")** Or see the [test-suite](https://tio.run/##y0rNyan8///hjiWPGmYGxSsd23RkWvCjpjXWQKz0cFdf4LGJ/w8vd9AHcv//j46ONtIx0DEEYgMdIzBpqGMUy6WgAxQ3goqYALExkG0YG8ulEx0NUQ7EcGUgnjFC0gio2gQqCeKZAHlwSUOwBMgyI5ggFEIlIG4xwS4JcRDIrlgA "Jelly – Try It Online").
### How?
```
Ḥ’R_"ƲĖS€;€"ẎQƑ - Link: widths, heights
     Ʋ          - last four links as a monad - f(widths):
                      e.g. widths = [3,2,0,1]
Ḥ               -   double          [6,4,0,2]
 ’              -   decrement       [5,3,-1,1]
  R             -   range           [[1,2,3,4,5],[1,2,3],[],[1]]
    "           -   zip with:
   _            -     subtract      [[-2,-1,0,1,2],[-1,0,1],[],[0]]
      Ė         - enumerate         [[1,[-2,-1,0,1,2],],[2,[-1,0,1]],[3,[]],[4,[0]]]
       S€       - sum each          [[-1,0,1,2,3],[1,2,3],[],[4]]
           "    - zip with heights applying:
         ;€     -   concatenate (the current height) to each
            Ẏ   - tighten
              Ƒ - is invariant under?
             Q  -   deduplicate
```
]