跳到正文

个人记录

CCPC24 Harbin Solution Set

Otomachi_Una_约 10 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年4月21日
篇幅
约 10 分钟
获赞
2

版本

  1. v1当前

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

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][L,R].

1≤L,R≤1061\leq L,R\leq 10^6. The number of automaton points does not exceed 100100.

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.

1≤n≤1051\leq n\leq 10^5.

Score: milking the dragon.

Feel like I’m sugar pilling.

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

Scan the line for the edge of C1C_1 and double pointer to C2C_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 AAAA string in a grid of characters 2×n2\times n, each time the path goes down or right.

1≤n≤2×1051\leq n\leq 2\times10^5.

Score: Clever.

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

Then the case of 2×n2\times n is similar. Enumerate ansans and chunk by ansans and you’re done.

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

Problem E. Marble Race

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

n,m≤500n,m\leq 500.

Score: Clever.

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

It can be straightforward to dp or generate a function assuming there are aia_i 11 and bib_i 00 in the iith row. The answer is [xn+12]∏(aix+bi)[x^{\frac{n+1}{2}}]\prod(a_ix+b_i).

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

Time complexity: O(n2m)\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 ss to be a sequence of nn (l,v)(l,v) denoting ll numbers vv stitched together. Let L=∑liL=\sum l_i.

Define s′s' to satisfy ski mod L′=sis'_{ki\bmod L}=s_i. Find the number of s′s' neutron sequences that are tt.

n≤2×103n\leq 2\times 10^3, 1≤m≤101\leq m\leq 10, 1≤k<L≤1091\leq k<L\leq 10^9, gcd⁡(k,L)=1\gcd(k,L)=1.

Score: gods.

Suppose kd≡1(modL)kd\equiv 1\pmod L.

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

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

  • If 2d>k2d>k. We invert MM in all but the first place to get M′M'. Then there is clearly f(k,d,M)=f(k,k−d,M′)f(k,d,M)=f(k,k-d,M').
  • Instead, we can divide these things dd into segments and stack them to form a ?? rectangle of dd rows and dd columns. Then ∏M\prod M is actually some sort of sequential right-multiplication of the entire column. So if we can find the composition of each column’s consecutive segments NN we have f(k,d,M)=f(d,d−k mod d,N)f(k,d,M)=f(d,d-k\bmod d,N). Here the process of finding each column of consecutive segments is easy to maintain using a line tree. Easy to state: ∣N∣≤∣M∣+O(1)|N|\leq |M|+\mathcal O(1).

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

Problem I. A Brand New Geomatric Problem

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

  • Delete a number;
  • add a number;

Given a=∑Sa=\sum S and b=∏Sb=\prod S. Find the minimum operand.

1≤a,b≤10101\leq a,b\leq 10^{10}, 1≤n≤1051\leq n\leq 10^5.

RATING: Godsend.

We need only consider did_i for all factors of bb.

First 11 can be pushed out through aa and we leave it at that.

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

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

Time complexity: O(can pass)\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.

原文