I tried the problem Jury Meeting here: https://codeforces.com/problemset/problem/853/B.
I find the editorial extremely confusing, especially since there’s no code attached to it.
I don’t follow the text explanation of the O(m^2 + n) prefix and suffix array solution. Here’s what I’ve understood so far; please help me fill in the gaps.
In the sample test case, I’ve sorted the To and From flights by day. Note that the format of the flights is \{day, city, cost\}.
Flights leaving from home, coming TO the capital:
1 1 5000
2 2 6000
3 2 5500
I think the prefix contains as few flights as possible while including the cheapest flights for each city. Is that correct?
1 1 5000 (cheapest FROM flight for city 1)
2 2 6000
3 2 5500 (cheapest FROM flight for city 2)
I don’t understand what d represents. I think it’s the earliest flight of city n in the prefix? Since all jury members meet for k consecutive days, the earliest flight in the suffix must be at least d + k + 1.
- Under that assumption, d=2.
Flights FROM the capital, heading back home:
8 2 6500
9 1 7000
15 2 9000
I think the suffix contains as many flights as possible so that every flight’s day is more than d + k. Is that correct?
- Under my previous definition of d, each day in the suffix must be at least 2 + 5 + 1 = 8.
8 2 6500 (cheapest FROM flight for city 2)
9 1 7000 (cheapest FROM flight for city 1)
15 2 9000
Please explain the parts that I am missing. If we were to brute force every pair of flights in these two lists, the prefix and suffix should have maximal accommodation? How is this true in my interpretation?
I still don’t get what d is. The cheapest TO flight for city a may not be compatible with the cheapest FROM flight for city a, right? Please describe, systematically, how exactly we check the prefix and suffix lists for a solution.
I don’t understand the m\log m + n solution at all – there’s too much text without any code.
Can you please provide the official working solution to his problem? Otherwise, please provide your working solution using the editorial’s implementation.
I am new to Codeforces; how do I check for user solutions to a particular problem? Particularly, how do I find the official solution that was coded by the person who wrote the editorial?
Thank you.