Hi,

I would like to invite you to **Kyoto University Programming Contest (KUPC)**, which will be held on 2 Oct. (4:00 — 9:00 GMT). Problem writers consist of several students in Kyoto University. The contest will be held on AtCoder.

The contest duration is 5 hours, and there will be 11 problems. KUPC has been held every year for about 5 years in Japan, but this is the first time to provide English problem statements.

I participated in the test round of this contest. The first a few problems are easy, so I'm sure everyone can enjoy the contest. On the other hand, a few problems from the last are probably interesting and though enough for high rated coders. We hope lots of people will compete in our contest. Good luck and have fun.

As far as I know, KUPC has been one of the most intetesting contests in Japan. I believe this year's KUPC will be even more enjoyable. So I highly recommend you to participate in the contest :)))) Don't miss it!

Is it rated? I can't find anything in the blog or the contest link.

It is not rated.

Will there be editorials?

If not, how to solve anything starting from Problem E. :)

Wondering how to solve problem E

I thought that for goats close enough(|

dx| ≤ 2 and |dy| ≤ 2), the optimal solution would be the convex hull of surrounding points of these goats. And convex hull shall be caculated respectively for goat flocks (am I right usingflock?) far away. But it was wrong. This solution even passed less data points than another solution calculating convex hull for all goats.Ok after reading someone's code, I think I get the idea (not sure if it's complete) :

Construct a flow graph where the outer layer of the grid (i.e. the area around the grid, outside the grid) is the source, and the Xs are sinks. Let the empty squares has capacity 1 and the Xs has capacity ∞. Also, there is an edge from a square to an adjacent square with capacity ∞. Now, the maximum flow of this graph is the answer.

I think this is true because otherwise there would be an augmenting path from the source to sink, so the sheeps can escape.

Yeah, it's the Max-flow Min-cut theorem

Another construction of flow graph I learned from other's code is like this:

There's a source

srcand a sinkdst.For every cell in the input, there's two vertices, say,

u_{i}andv_{i}, whereiis the id of the cell,H*Wat most. (You can imagine they are two copies of layer of the input)For every 'X', there are two edges: One connecting

srcandu_{i}with capacityinf. Another connectingu_{i}andv_{i}with capacityinf.For every '.', there is an edge connecting

u_{i}andv_{i}with capacity 1.For every cell that is on the border of the input, there is an edge connecting

v_{i}anddstwith capacityinf.For every cell whose id is

i, there are edges connecting its neighbours back fromv_{i}tou_{j}with capacityinf, wherejis the id of its neighbours.But I still can't understand why minimum cut(or maximum flow) is the answer. Though there is some intuition, I can not convince myself about this...

Any ideas on how to solve G? I couldn't figure out how to use the second condition.

The condition is confusing, but the solution isn't: just take all distinct substrings of length L (for the best L).

To prove this, note that the second condition on strings of equal length is just "the strings are different", and if there is any smaller substring in the set, you don't lose anything by adding characters to the beginning or end of it, as you're only making it harder for the second condition to be violated.

I see people with short solutions for H. What is the correct idea to solve the problem?

I might be missing something really obvious but I can't come up with a proof for the solution to C. Can somebody kindly help me out? The solution I 'guessed' was to just use Y=127 every time.

The parity of the number of times each bit is set in the final set of numbers is fixed.

This means that any solution that has more bits set in a position than your solution has at least 2 more bits set in that position, which is impossible since in your solution at most one bit is not set in each position (the one from the number which is not 127).

That's awesome, thanks a lot!

FYI The editorial is out (in Japanese though) : link

It would be nice if someone could explain editorials for HIJK (got stuck halfway using Google Translate)