跳到正文

个人记录

Osijek Competitive Programming Camp 2023 Day 1: Anton Trygub Contest 1 Solutions

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

文章信息

发布
2024年1月22日
收录
2025年12月12日
更新
2026年11月16日
篇幅
约 16 分钟

版本

  1. v1当前

Score: Difficulty/Quality

Problem A. Adjacent Product Sum

Scoring: 3/43/4;

Sort from largest to smallest, with answers shaped like: (…,a5,a3,a1,a2,a4… )(\dots,a_5,a_3,a_1,a_2,a_4\dots).

Problem B. Binary Arrays and Sliding Sums

Score: 6/76/7;

Assume that d=gcd⁡(n,k)d=\gcd(n,k) is a group that divides the ring into nd\dfrac nd groups. Call the corresponding positions within a group identical (i.e., all 00 or all 11) to be of the same class of bits.

We find that two bb are identical if different classes of bits are identical and there are the same number of 0/10/1 similar bits. We conclude that the above case must also be satisfied for two bb to be identical (since we can infer from bi,bi+1b_i,b_{i+1} that the difference between two numbers with kk neighboring differences).

We enumerate the number of similar bits, and the answer can be O(d)\mathcal O(d) calculated. You need to apply some basic combinatorial constants to O(1)\mathcal O(1) the solution.

Problem C. Counting Hamiltonian Cycles

Score: 7/87/8;

Consider i→i+1i\to i+1 that has been passed through max⁡(1,lefti−righti)\max (1,left_i-right_i) at least once. where lefti,rightileft_i,right_i denotes the number of B,W\texttt{B},\texttt{W} in [1,n][1,n], i.e., si=lefti−rightis_i=left_i-right_i.

Maintaining the current set of chains from front to back, then consider the effect of adding a B\texttt{B}:

  • If si−1>0s_{i-1}>0, then it is equivalent to one more B\texttt B chain.
  • If si=0s_{i}=0, it is equivalent to being able to receive either the head or the tail of the current chain.
  • If si<0s_{i}<0, then it is equivalent to letting the two chains fit together.

Considering an undirected graph would introduce some duplication, so consider a directed graph, and answer /2/2.

Problem D. Distance Parities

Score: 5/75/7;

Join the i,ji,j edges of si,j=1s_{i,j}=1. Determine if for each si,j=0s_{i,j}=0 there exists a kk such that si,k=sj,k=1s_{i,k}=s_{j,k}=1 that is.

Problem E. Excellent XOR Problem

Score: 3/53/5;

If the overall XOR\text{XOR} is not 00 it is done.

Otherwise, judging whether a prefix-suffix can be divided is done.

Problem F. F*** 3-Colorable Graphs

Score: 5/75/7;

Connect at least two edges. (Otherwise if there is only one (u,v)(u,v), coloring uu to color 11, the left part of the original graph to color 22, and the right part to color 33 does not satisfy) We only need to construct K4K_4.

If there exists u,v∈L,p,q∈Ru,v\in \textbf{L},p,q\in\textbf{R} and (u,p),(u,q),(v,p),(v,q)∈E(u,p),(u,q),(v,p),(v,q)\in\textbf E then it can be solved 22 times.

Otherwise, since there is necessarily a 3−3- chain of connectivity, it can be solved 33 times.

Problem G. Graph Problem With Small n\bm{n}

Score: 6.5/66.5/6;

Suppose fSf_{S} denotes the set of possible final endpoints starting from 11 and having passed the set of points SS. The complexity of finding fSf_S directly is O(2nn)\mathcal O(2^nn).

Consider the Hamiltonian of i→ji\to j, then enumerating the set of points SS for i→1i\to 1, 1→j1\to j should be U/SU/S. This is equivalent to asking if there are two sets of i,ji,j that merge into UU. We can do O(2nn2ω)\mathcal O(\dfrac{2^nn^2}{\omega}) by putting it in bitset.

Problem H. Help Me to Get This Published

Rating: 9/109/10;

Thesis Question.

The KnK_n side staining of a first heterochromatic triangle is called:** Gray staining**. The sufficient property about the heterochromatic degree d(n)d(n) of Gry’s staining was only unearthed through this question. Thanks to Anton Trygub.

[Property 1] In Glay staining, if the number of colors ≥3\geq 3, there must be a disjunctive graph of color sheets.

The proof is simple and left to the reader.

Assume later that color aa is disjoint and that AA is any connected branch of aa. Assume below that c(u,v)c(u,v) denotes the color of the u,vu,v edge.

[Property 2] In Glay coloring, suppose u,v∈A,w∉Au,v\in A,w\not\in A, then c(u,w)=c(v,w)c(u,w)=c(v,w).

Proof: if c(u,v)=ac(u,v)=a because c(u,w),c(v,w)≠ac(u,w),c(v,w)\not =a (otherwise w∈Aw\in A) then it follows that c(u,w)=c(v,w)c(u,w)=c(v,w). Since AA is a connected branch of aa, the conclusion holds.

[Property 3] In Glay coloring, ∑12d(u)≥1\sum \dfrac{1}{2^{d(u)}}\geq 1.

PROOF: Generalize to nn if n≤3n\leq3 is obvious.

If there are only fewer than or equal to 22 colors in the graph, then ∑12d(u)≥n4≥1\sum \dfrac{1}{2^{d(u)}}\geq \dfrac n4\geq 1.

If there are more than or equal to 33 colors in the graph, then by [Property 1], take AA and assume that kk is the number of distinct numbers in c(u,w)c(u,w) (u∈A,w∉Au\in A,w\not\in A), then:

  • If AA is reduced to a point, by induction there is: ∑u∉A12d(u)+12k≥1\sum_{u\not\in A} \dfrac{1}{2^{d(u)}}+\dfrac{1}{2^k}\geq 1.
  • If we look only inside AA, by induction: ∑u∈A12dA(u)≥1\sum _{u\in A} \dfrac{1}{2^{d_A(u)}}\geq 1.

So:

∑12d(u)=∑u∈A12d(u)+∑u∉A12d(u)≥∑u∈A12dA(u)+k+∑u∉A12d(u)≥12k+∑u∉A12d(u)≥1\sum\dfrac{1}{2^{d(u)}}=\sum_{u\in A}\dfrac{1}{2^{d(u)}}+\sum_{u\not\in A}\dfrac{1}{2^{d(u)}}\geq \sum_{u\in A} \dfrac{1}{2^{d_A(u)+k}} +\sum_{u\not\in A}\dfrac{1}{2^{d(u)}}\geq \dfrac{1}{2^k}+\sum_{u\not\in A}\dfrac{1}{2^{d(u)}}\geq 1

Proof.

Assume below that d(1)≤d(2)≤⋯≤d(n)d(1)\leq d(2)\leq\dots\leq d(n).

[Property 4] In Glay coloring if there exists d(n)=n−1d(n)=n-1, then d(i)=id(i)=i (i=1,2,…,n−1i=1,2,\dots,n-1).

Proof: it is clear that

[Property 5] For any k∈[1,n]k\in[1,n] there are:

∑i=kn12d(i)≥12d(k−1)\sum_{i=k}^n\dfrac{1}{2^{d(i)}}\geq\dfrac{1}{2^{d(k-1)}}

This is a sufficient condition for the sequence of Gladius numbers to be legal.

Proof: Notice that the number of different colors of kk edges to 1∼k−11\sim k-1 cannot exceed d(k−1)d(k-1), and it is sufficient to use [Conclusion 3] for subgraphs of k∼nk\sim n.

The construction is roughly the same as staining the n−1n-1 grays, pulling out any ii, cloning ii to an i′i', and then adjusting the color between i,i′i,i' can be done to one of the two:

  • d(u)→d(u),d(u)d(u)\to d(u),d(u);
  • d(u)→d(u)+1,d(u)+1d(u)\to d(u)+1,d(u)+1.

In this problem, dp is designed according to Property 5, and fi,j,kf_{i,j,k} denotes the current number of points enumerated to ii, the jj points already used, and the current number of programs for [∑2i−d(u)]=k[\sum 2^{i-d(u)}]=k. Can do O(n4)\mathcal O(n^4).

Problem I. Increasing Grid

Scoring: 5/75/7;

Clearly ai,j∈{i+j−1,i+j}a_{i,j}\in\{i+j-1,i+j\}, we label the former red and the latter blue, then for the partition line dp that is.

Problem J. Jewel of Data Structure Problems

Score: 6/66/6;

Notice that the answers are between −1,n−2,n−1,n-1,n-2,n-1,n.

  • If the current permutation is 1,2,…,n1,2,\dots,n, then the answer is −1-1;
  • If the current permutation is legal, the answer is nn;
  • If everyone’s contribution to the reverse-ordered pair is even, the answer is n−2n-2;
  • Otherwise the answer is n−1n-1.

The parity of a reverse-order pair is equivalent to the parity of n−cyclen-cycle, where cyclecycle is the number of cycles of pp.

The parity of each individual’s contribution to the reverse-ordered pair is the parity of i−pii-p_i.

This allows for linearity.

Problem K. King of Swapping

Score: 4/54/5;

Legitimate equivalence to the original graph strong connectivity.

Problem L. Least Annoying Constructive Problem.

Score: 7/87/8;

If nn is even, then it is sufficient to construct nn perfect matches as in KnK_n.

If nn is odd, it is also correct to isolate a point for perfect matching.

Problem M. Most Annoying Constructive Problem

Score: 10/510/5;

The problem is, as the name suggests, annoying.

It can be shown that there are more than [n−12][\dfrac{n-1}2] non-trivial even segments.

Then it’s followed by an inductive construction, which I don’t quite understand.

Problem N. No Zero-Sum Subsegment

Score: 7/87/8;

A very annoying question.

Consider prefix sums, equivalent to a,b,c,da,b,c,d jumps in the −2,−1,1,2-2,-1,1,2 direction, requiring a scheme that cannot pass through duplicate points.

Consider how you can depart:

  • Depart using kk pieces of −2-2, 11 pieces of −1-1, and k+1k+1 pieces of +2+2;
  • Use kk pieces of −2-2, 11 pieces of 11, and kk pieces of +2+2.

The same thing happens at the end.

The middle walk is necessarily:

  • +1+1;
  • +2+2;
  • +2,−1,+2+2,-1,+2;

These combinations can be counted quickly by combining numbers.

We just need to enumerate roughly 44 cases to do the math.

Complexity: O(1)\mathcal O(1).

原文
存档评论2 条抓取于