Hi,

I am happy to announce that Lyft Level 5 Challenge 2018 — Final Round will be held in Palo Alto on Nov/04/2018 21:10 (Moscow time). The official round contains **six** problems and will last for **two** hours.

Winners will receive:

- First place: $2000
- Second place: $1000
- Third place: $500

Here is the list of onsite finalists:

If you are interested in an internship or a job at Lyft, follow the link below.

If you are not participating in the Final Round, you will be able to take part in **rated** open divisions. Each of them contains six problems and will last for **two and a half hours**.

This round was prepared by aitch, lewin, majk, Noam527, StasyaCat, and I.

Thank you to 300iq, _kun_, BigBag, danya.smelskiy, Fekete, MrDindows, Nasic_number_one, Sonechko, winger, zubec for help with testing.

Special thanks to KAN for helping me with coordinating, MikeMirzayanov for Polygon and Codeforces, and Lyft for organizing this competition.

If you have never solved interactive problems before, please read this.

Scoring distribution:

Div1 and onsite:

**750-1250-1500-2000-2750-3000**

Div2:

**500-1000-1750-2250-2500-3000**

We have onsite issues, the contest was postponed by at least 5 minutes.

Because of the onsite round, the system testing will be in an hour after the round.

Contest is over!

Congratulations to the winners!

Onsite competition:

1 | tourist |

2 | scott_wu |

3 | ecnerwala |

4 | RomaWhite |

5 | Errichto |

6 | ACRush |

7 | Arterm |

Div 1:

1 | Radewoosh |

2 | mnbvmar |

3 | Benq |

4 | CongLingDanPaiShang3k5 |

5 | Reyna |

Div 2:

1 | mrscherry |

2 | Kekmaster |

3 | brandonzhang |

4 | MAUZER |

5 | ---Grigor--- |

Editorial is available here.

Are you looking for photos from the onsite round? It is here.

Is there going to be a livestream of the onsite finals?

Unfortunately no.

:))

Oh, very awkward time for China and Siberia.

Hello, I have cancelled the onsite final due to unexpected time conflict. I have sent email to Lyft Level 5 staff who informed me about event logistics, but they have never replied me. Could you please remove me from the list and allow me to participate in the open mirror? lyft

Update: they just replied me.Why is the official round shorter than the div1 round? Is it rated huh?

The first division will be easier because of this extra half of hour. And yes, all three rounds will be rated.

if comments on the codeforce is directly uploaded whether admin will be accepted then only upload it,,can u say anyone?

Mate, what do you want to say exactly? If you want to ask whether your comment is first verified by admins and then uploaded then it is not the case. If that would have been the case then some people wouldn't shit here anything they want.

Regarding to random hoodies from the last round, which will be the score from which the seed is generated?

The winner's score from onsite or some other score?

Good question!

We are using the onsite round.

Can someone explain how organizers are able to check if participants solve problems themselves, not with a team of helpers, which is quite important when people are struggling for financial prize.

Because they're all there in person

It's an on-site round. Under the supervision of course.

It feels there are too many setters and testers in this round.

I don't see a problem with having more people organizing.

Sometime Competition made me question my existence. :(

Any updates for the t-shirts of the elimination round?

We will work on them starting next week.

Ok, so there is now daylight savings time shift... so it's at 10 am PST now? Or still 11?

I don't think the countdown is affected by daylight savings.

Please update the Scoring distribution...

And one more ques , All the problems of this round will be interactive problem, won't it?

I am just waiting for tourist......... what he will do today......

Why YerzhanU's handle with star?

I guess YerzhanU and ikatanic are no longer eligible since Lyft acquired our startup last week: https://techcrunch.com/2018/10/23/lyft-is-buying-london-ar-startup-blue-vision-labs-to-fuel-its-autonomous-car-efforts/

Yeah, I heard that news and was wondered what is a coincidence :)

That's a happy coincidence!

I think that today tourist will come back

Damn.

Atleast5 minutes :(:(

Finally some questions with creativity shout out to lyft :)

What could be pretest 12 for Problem C? i kept getting WA !

I think it is something like that:

Oh God 10 more seconds please...

Same here. I fixed a bug in my solution about 30 seconds before the end, but didn't get time to submit.

how to solve Div2 C ?

Realise that you only need horizontal lines with that starts from 1. Sort horizontal lines and vertical lines, and then iterate trough verticals, and figure out if you don't use first i verticals, what is the answer. Output is minimal answer from all.

I was trying to solve it like that but Idk what I'm missing

after deleting all lines that starts with 1 and end with 1e9 and considering only the lines that start with 1 what's next ?

I thought I need to see the longest horizental line and delete all vertical lines that blocks it but that was wrong ofcourse

it's like dp or what how could we get the min

Nothing that's it, maybe you just forgot about some condition, like me (wa on 12). But that is main idea.

If you delete first A vertical lines (A+1'th is not deleted) then you have to delete horizontal lines too but only those such that x1=1 and x2>=x value of A+1'th vertical line

What if there are no Vertical lines?

Then just count the number of horizontal lines with x1=1 and x2=INF

Ok, Thank you.

friendship ended with algorithms, ad-hoc is new best friend

Is C can be solved with segment tree ?

I tried using 2 segment tree but didn't manage to get AC , but i think it can be solved using segment tree .

Why 2? my idea is to add 1 to range [x1, x2] for horizontal spells and add 1 to range [x, 1e9] for vertical spells, then find the minimum, can any body confirm ?

how do you find the minimum ?

Yeah, your right!

Yes, though not necessarily. Prefix sum is enough.

Can you please elaborate?

Let's denote

`f[i]`

as the number of horizontal lines that need to be removed, if we've removedivertical lines beforehand. Obviously, the removed vertical lines have to be the leftmost ones.About the horizontal lines, it's certain that we will only remove such with leftmost x-coordinate equals to 1. Now we have to find out the maximum

i(the number of removed vertical lines) such as that horizontal line still blocks our way — this can be done through binary search the rightmost x-coordinate of that line — let's denote the found valuex.Then, all

f(i) with 0 ≤i≤xwill be increased by 1.Isn't Timus 1003 same as div. 1 D?

That one is somewhat easier, because there you can also do some sort of binary search. Div1D forces you to write an "augmented DSU". Though they are clearly similar.

The problem is mine. I didn't intend to copy from any problem, and also none of the testers brought up any related problem. The problem is different, but I admit it can still help.

Also, the problem is still solvable with merge small to big, so no need for augmented DSU (although I think it is simpler to code).

Can you please provide the solution using small to big? During the contest I too tried with the same approach but could not find the bug in my implemented code till the end.

This is exactly the same question as in the IIT Kgp regionals for 2017/18. That was for a tree but the solution is exactly the same.

I really liked C, it was a little bit hard to solve it but the idea is nice. Hard contest overall!

So how did you solve it?

First sort the vertical lines by position and horizontal lines by size

`(x2 - x1 + 1)`

, when taking the horizontal lines you just need the ones that start at 1, why? because if a horizontal line has`x1 >= 2`

you can always escape through 1.This is the trick of this problem. :)

Now you will try to brute force, you will try to remove first vertical line and see if you can reach the top row of the chessboard, after this the second vertical line and so on. Each time you have to count the number of horizontal lines those size is larger or equal with

`v[i]`

(use binary search)and check if this is better than the current answer.by

`v[i]`

i mean the position of vertical line with index`i`

after sorting.Hope you understood.

problem E is cool, I wish I'd submit it.

How to solve div2E(div1C)? I thought I could solve this problem :(

As an observation, there will always be

kextreme points in a convex polygon (k≤ 4), so everyf(x) withx≥kwill return the maximum answer.The solution for

f(3) and convex polygon with 4 extreme points can be brute-forced. Simply traverse through all points, and with each point, match it with 2 out of 4 extreme points of the polygon.Total complexity is

O(6 *n), can be reduced toO(n) by further geometrical observations.wait what?

I thought for n = 4 it was just the rectangle with side lengths of max x — min x, max y — min y?

It's correct for

f(4) and further.We still have

f(3) left to calculate.How to solve div2 B as i was using binary search and overall time complexity was O(mlogn)45304679 it was giving me tle

The input seems quite large. Did you use fast I/O methods in your solution?

i just used scanf , printf afterwards but could not succeed.

If I were you I'd go binary search as well. Without your solution (submission pages are inaccessible now), I cannot say for sure what you've done wrong.

actually my code was perfect but i was passing copy of array in function but when i changed that to reference it worked and i got fucked up

have you seen my code though

Ohhh, I was confused about this for a while, but then I realized that the set of points had to be convex. That makes the problem a lot easier XP

You need to consider at most 8 extreme points because there can exist two points with

x=maxx_{i}, but it is preferable to choose only one of them, and the same holds for y.I think you can choose any one from each pair and get the same answer.

No, because if you choose triple "upmost, downmost and leftmost" points, then you care about x coordinate of both upmost and leftmost: the larger it is, the bigger is "Manhattan perimeter". So if you have pair of both upmost and downmost points, you must choose the rightmost of them

I am only considering the case when we are calculating f(k) where k>=4. The difference in x-coordinate of the two upmost points will be compensated when we are going to take the manhattan distance with the rightmost point. For f(3) as akikaze mentioned, we will have to check all points with each pair from the 4 extreme points.

Yes, and my point is that it is not enough to test all pairs out of 4 extreme points. Instead, we should consider pairs of 8 extreme points and test them all against N points.

Well, then I guess the problem has weak test cases. https://codeforces.com/contest/1075/submission/45296802

No, checking 4 points is enough because those other rightmost points will eventually be one of the n-4 alternative third points, and the rightmost of both on it's own is enough.

Not obvious, but I believe :)

Nice Explanation!

Can someone explain how to solve Div1 A/Div2 C (The Tower is Going Home) problem?

If a horizontal wall doesn't start at 0, we can always go around it, so discard those. Also, y-coordinate of horizontal walls doesn't matter.

Sort horizontal walls by their right end's x-coordinate, and vertical walls by their x-coordinate. Loop over how many horizontal walls we discard. Obviously the optimal ones to discard are always the one with maximal x-coordinate. Then, binary search how many vertical intervals we have to remove, so that we can reach the top row, when we have removed the given amount of horizontal intervals.

Thank you!

How do we solve div1 D? I was thinking something like dynamic segment tree but I ended up with nothing.

When you know that xor on segment [l, r) is equal to x, you add edge between vertex l and r with cost x. Now to answer query [l, r) you need to find xor on the path between l and r (xor on costs of the edges). This can be done similar to LCA.

Consider the prefix xor-sum array

p_{0},p_{1}, ...,p_{n}. Now the problem is basically giving you equations and asking for . Consider a graph onn+ 1 nodes whereuandvare connected by an edge of costwiff . Then query is xor-sum of path fromutov. You can handle these with DSU (recompute distance from root for smaller tree when merging two trees).Cooooooooooooooooool!

Someone Please Explain how to solve Div2C ?

Take all the vertical lines and sort them in increasing order.Now suppose you are considering a vertical line i,then you have to remove i-1 vertical lines + horizontal lines starting from 1 and ending at some position greater then i.This way,you can select minimum lines to delete. Corner cases can be handled separately.

What are the corner cases ? My approach is same. But got WA on test 6.

Is this solution for D?

Ask "B y1" and answer for this is p

1) If p exist in first set then we are done

2) Else, find closest node to p such that it belongs to first set. Call it q. Ask for "A q" and answer for this is T. If T exist in second test then solution is q else there are no common nodes.

That was my solution and it passed pretests.

Duuuuude that's not fair, literally needed 5 more seconds

Yes that is correct.

When you're trying to submit this for more than an hour but you get 13 WAs instead of an AC :(

When you open submit page and it says contest ended

What if multiple closest nodes to p?

It's not possible, think about it ;)

Yea, correct.

Very well explained problems. Even though some of the problems were long and complicated, the statements were quite clear and the sample test cases did the rest. Kudos to the problem setters!

Can admin allow access to submission pages? Thanks

How to solve div2 B as i was using binary search and overall time complexity was O(mlogn)45299906 it was giving me tle

Just find the immediate left and immediate right driver for each rider. You can do this by first scanning the array from left to right to find the immediate left driver for each rider. Then scan the array from right to left to find the immediate right driver for each rider. While doing so, maintain the distance as well as the position of the driver. Now for each rider, compare the left and the right distance, whichever is shorter, increase the count for that driver's position.

I solve C but can't solve B... too sad. maximum question=5, n=1000, so I try to think about O(lgn/2) solution lol

I think this is correct solution http://codeforces.com/blog/entry/62929?#comment-469374

It can be done in at most two queries:

We are given at least one node X that is in Li's subtree (with his labeling). We ask B X. If the given label is one of our chosen vertexes, great. Otherwise, we are given node Z (in our labeling).

We find the closest node to Z that is in our chosen subtree. Let's call it Y. Now suppose there is a node X in the intersection of the two subtrees. Since node Y is on the path between X and Z, then it must be in Li's subtree aswell, so Y must be a common vertex if an intersection exists. So we just ask A Y: if the given label is one of

y_{1},y_{2}, ...,y_{k2}then Y is in the intersection. Otherwise output -1

Div 2 C ? is this related to disjoint union? or else whats the best solution?

Look at this : http://codeforces.com/blog/entry/62929?#comment-469369

Solution is very very simple...much simplier than it seems

Thats it =)

Problem seems much more complicated than it realy is

Not sure if I should sleep or wait for systests

Exactly...!! Lol..

ObservationForces!!

What would be your ideal problem set then?

The way I see it, to solve any nontrivial problem you need to make several observations. What is the alternative? Implement well-known but difficult algorithms? Because in my opinion the former is vastly superior to the latter.

Exactly! If the problems do not require new and different observations, one that knows the required algorithms will just be in a typing competition (if one don't just copy and paste codes).

Why did you think that was a negative comment? It's not like I wrote 'SpeedForces' or 'ImplementationForces'. I have huge respect for problem setters who can make tough problems that don't require complex algorithms or data structures.

Why is there such a long delay for system tests too start? Should I just go to sleep?

`Because of the onsite round, the system testing will be in an hour after the round.`

It's already over anyway.

Who won the

onsitefinals????Guess who =)

STANDINGS : https://ibb.co/gRDGdL

Final Standings

Great Problem Set!!! Kudos to the authors!!!!!!!

Div2 C. Why my solution failed on test no. 17 I used Difference array and Binary search.? http://codeforces.com/contest/1075/submission/45302142

There are written "wrong answer", answer should be 17444, yours is differ

What was the thing that you were missing? I have same approch and getting WA on test case 17.

Because we calculated answer for all the horizontal lines.only horizontal lines starting with 1 should be taken. Link to Accepted solution with same approach http://codeforces.com/contest/1075/submission/45376580

Got it thanks.

Div2-C is so funny — seems like something complex and then you realize that solution is so simple, that half of data even can be skipped like parametre y in horizontal spells... Unfortunately i realized it after contest was finished...

Two Div.2 problems were about chess. That reminded me that World Chess Championship will start in a few days :)

Getting MLE in DIV-2(D) . submission — 45317188 . Why?

The judge responded with -1 and you didnt terminate your program so you got any verdict.

Thanks for your reply.

I've checked it 45319433 . If my tracing is correct, the judge didn't reply with -1.

Possibly your BFS loops infinitely, you don't really check whether you're not visiting your parent again.

Thanks. accepted!! :)

Hurray :-)

how this test Output (0) ?? not (1) 4 6 3 6 9 12 1 2 2 2 3 2 2 3 4 3 1000000000 2 3 1000000000 3 3 1000000000 4 arsijo

For DIV2 C.

Is this a valid input?

`1 2`

`4`

`1 2 2`

`3 4 2`

If yes, then answer should be 1?

No, this is not valid.

According to the problem statement "The peculiarity of these spells is that it is impossible for a certain pair of such spells to have a common point". In that testcase, there is one common point (2, 2). Therefore, it is not valid.

Can anyone tell me WA on test 11 45992429 1075C - The Tower is Going Home ?

UPDATEACCEPTEDthe wrong was that i wasn't sorting vertical lines