CCPC24 Harbin Solution Set

· · 个人记录

由于某种原因,我藏起来了原来自己写的中文题解。需要的同学可以私信我。

Feeling pretty good about this game, ah, got the questions roughly filled in.

Gave a quality scoring system of my own:

Scoring - Defense - Milk Dragon - okay - smart - -Goddess - can't make it up

Will only rate questions that I don't find that easy. It's important to note that mending not moving doesn't mean it's any more godly than a godly question.

For example, many Ynoi questions I would consider to be scored and mended.

Problem A. Build a Computer

Build an automaton that recognizes all the numbers in [L,R].

Score: milky dragon.

If you've studied a bit of automata theory, you know to go ahead and build a trie first, and merge two trie nodes if they both get the same state by going the same way. Just maintain it with a tree hash.

It's even done with minimal nodes.

Problem B. Concave Hull

Find the concave bag with the largest area.

Score: milking the dragon.

Feel like I'm sugar pilling.

You start by building a convex bag C_1 for all the points, and another convex bag C_2 for the points that are not on the convex bag. Then the concave bag must be shaped like C_1 with an edge cut out plus a point at C_2.

Scan the line for the edge of C_1 and double pointer to C_2 to deduct the point with the smallest area.

Problem C. Giving Directions in Harbin

Simulation.

Problem D. A Simple String Problem

Find the longest AA string in a grid of characters 2\times n, each time the path goes down or right.

Score: Clever.

Consider the 1\times n case, where the solution is to enumerate ans and then chunk it with ans as the block length. Just do lcp and lcs.

Then the case of 2\times n is similar. Enumerate ans and chunk by ans and you're done.

Time complexity: \mathcal O(n\log n).

Problem E. Marble Race

Given a table of n\times m numbers. Guarantee that n is odd. Take one at random from each row and find the expectation of the median.

Score: Clever.

Enumerate x, treating <x as 0 and \geq x as 1. Just consider how many cases there are where more than \dfrac{(n+1)}{2} 1 are selected.

It can be straightforward to dp or generate a function assuming there are a_i 1 and b_i 0 in the ith row. The answer is [x^{\frac{n+1}{2}}]\prod(a_ix+b_i).

Consider that only the pair (a_i,b_i) changes as x changes. So it's straightforward \mathcal O(n) to do the polynomial division and multiply back the complexity.

Time complexity: \mathcal O(n^2m).

Problem F. 1D Galaxy

Score: complementary immobility.

Problem G. Welcome to Join thr Online Meeting

Direct dfs is fine.

Problem H. Subsequence Counting

Define s to be a sequence of n (l,v) denoting l numbers v stitched together. Let L=\sum l_i.

Define s' to satisfy s'_{ki\bmod L}=s_i. Find the number of s' neutron sequences that are t.

Score: gods.

Suppose kd\equiv 1\pmod L.

You first write it in matrix multiplication form, then we are asking for \prod M_{di\bmod L}. where M is composed of a number of consecutive segments.

Remember the form \prod M_{di\bmod L}=f(k,d,M). Consider applying an Euclidean-like form.

Time complexity: \mathcal O(nm^3\log L). Constant is extremely small.

Problem I. A Brand New Geomatric Problem

Given a reproducible set S, you can perform two operations:

  • Delete a number;
  • add a number;

Given a=\sum S and b=\prod S. Find the minimum operand.

RATING: Godsend.

We need only consider d_i for all factors of b.

First 1 can be pushed out through a and we leave it at that.

You find out that the burst search is actually quick for d_i when it's larger. But d_i can be very slow when it contains a lot of small numbers like 2,3,5.

So, we do a dp on d_i\leq B part of the line, for >B part of the explosion search will be very fast.

Time complexity: \mathcal O(\text{can pass}).

Problem J. New Energy Vehicles

Score: not bad.

Greedy for a bit.

Problem K. Farm Management

Rating: okay.

Greed is gone.

Problem L. A Game On Tree

dfs Gone in two swipes.

Problem M. Weird Ceiling

Check in.