wuhudsm's blog

By wuhudsm, history, 14 months ago, In English

A
Problem author: wuhudsm,adventofcode

code
solution

B
Problem author: wuhudsm

code
solution

C
Problem author: wuhudsm

code
solution

D
Problem author: KitasCraft

code
solution
note from the author

E1 and E2
Problem author: Error_Yuan

code (Hard Version)
solution (Easy Version)
solution (Hard Version)

F
Problem author: k1r1t0

code
solution

Full text and comments »

  • Vote: I like it
  • +19
  • Vote: I do not like it

By wuhudsm, history, 15 months ago, In English

Hello, Codeforces!

We are happy to invite you to TheForces Round #23 (Balanced-Forces), which will take place on Sep/08/2023 17:35 (Moscow time)

What is TheForces Round?

You will have 120 minutes to solve 6 problems.One of these problems is divided into two subtasks.

The round is TheForces rated! After the round you can find your rating changes here.

In addtion, we're glad to invite you to Error_Yuan's official round: Codeforces Round 896 (Div. 1) & Codeforces Round 896 (Div. 2) :)

Discord Server (1000+ people)

Contests' archive

Full text and comments »

  • Vote: I like it
  • +91
  • Vote: I do not like it

By wuhudsm, history, 15 months ago, In English

(Last updated time:$$$2023/8/31,14$$$ problems)

Hi guys,here I'd like to share some of my problems(will continue to be updated, depending on your feedback).

All the problems are created by myself.

They contain my aesthetic of problems: the neater,the better. Interest and educational significance are also important.

You can find the editorial for all the problems in the link,so I will only write down some interesting points under the statement.

Let's go :)

1.Increasing and Decreasing

Construct an array $$$a$$$ consisting of $$$n$$$ integers which satisfies the following conditions:

  • $$$a_1=x,a_n=y$$$;
  • $$$a$$$ is strictly increasing;
  • if we denote $$$b_i=a_{i+1}-a_{i}$$$ for $$$1 \leq i \leq n-1$$$, then $$$b$$$ is strictly decreasing.
Constraint
Difficulty
Point

2.(Yet Another) Increasing and Decreasing

Construct an array $$$a$$$ consisting of $$$n$$$ integers which satisfies the following conditions:

  • $$$a_1=x,a_n<2^{30}$$$;
  • $$$a$$$ is strictly increasing;
  • if we denote $$$b_i=a_{i+1}⊕a_{i}$$$ for $$$1 \leq i \leq n-1$$$, then $$$b$$$ is strictly decreasing($$$⊕$$$ is bitwise-xor).
Constraint
Difficulty
Point

3.Mex Path

You are given a $$$2 \cdot n$$$ grid $$$a$$$. On the grid,there is a non-negative integer $$$a_{i,j}$$$ in row $$$i$$$ and line $$$j$$$.

You must walk from $$$(1,1)$$$ to $$$(2,n)$$$. Each cell can be accessed at most once.At each step, you can go up, down, or right(but not to the left or beyond the boundary).

Note the set of numbers on the grid you have walked through is $$$S$$$. Find the biggest $$$mex(S)$$$ you can get.

Constraint
Difficulty
Point

4.Divisor Chain

You are given an integer $$$x$$$. Your task is to reduce $$$x$$$ to $$$1$$$.

To do that, you can do the following operation:

  • select a divisor $$$d$$$ of $$$x$$$, then reduce $$$x$$$ by $$$d$$$.

There is an additional constraint: you cannot select the same value of $$$d$$$ more than twice.

Output any scheme which reduces $$$x$$$ to $$$1$$$ with at most $$$1000$$$ operations.

Constraint
Difficulty
Point1
Point2
Point3

5.Strange Shuffle

There is a big array $$$a$$$ of size $$$n$$$ and $$$a_i=i$$$ initially.

The following process will be repeated cyclically until there is only one element left:

  • Erase $$$a_1$$$.
  • Note $$$x$$$ is the amount of elements in the current $$$a$$$.Move the first $$$⌊x/2⌋$$$ elements after the last $$$x−⌊x/2⌋$$$ elements.
  • Erase $$$a_1$$$.
  • Reverse the whole array.

Find the value of the last remaining element.

Constraint
Difficulty
Point

Now let's increase the difficulty a bit.Here are two interaction problems that I really enjoy :)

6.Get the Segment

There’s a hidden array $$$a$$$ of size $$$n$$$. Each element of the array is either $$$1$$$ or $$$2$$$.

Interact with the judge using queries. Each query is of the form:

l r You choose two positive integers $$$l$$$ and $$$r$$$ $$$(1 \leq l \leq r \leq n)$$$.The judge will reply with $$$\Sigma^{r}_{i=l}a_i$$$.

Use at most $$$40$$$ queries to find a subarray with sum $$$k$$$(given $$$k$$$ guarante such subarray exists).

Constraint
Difficulty
Point

7.Xor X,Get MAX

There’s a hidden array $$$a$$$ consisting of $$$n$$$ distinct non-negative integers.

Interact with the judge using queries. Each query is of the form:

x y: Given two non-negative integers $$$x$$$ and $$$y(0 \le y < 2^{30})$$$ as the query, the hidden array $$$a$$$ is updated by setting $$$a_{x}:=a_{x} \oplus y$$$. After that, the judge will return the maximum value of the updated array.

Make all the elements of the array equal to $$$0$$$ using at most $$$10^5$$$ operations.

Constraint
Difficulty
Point1
Point2

There are also some problems that I think have educational significance.

8.Maximum Sum

You're given an array $$$a$$$ of size $$$n$$$.

You can do the following operation any number of times:

  • Choose any two adjacent element $$$a_i,a_{i+1}$$$;

  • Note $$$g=gcd(a_i,a_{i+1}),l=lcm(a_i,a_{i+1})$$$,set $$$a_i:=g$$$ and $$$a_{i+1}:=l$$$.

Find the maximum value of $$$\Sigma^{n}_{i=1}a_{i}$$$ you can get(mod $$$10^9+7$$$).

Constraint
Difficulty
Point

9.Collinear Points

$$$n$$$ points are given on the coordinate system such that the coordinates of the $$$i^{th}$$$ point are $$$(x_i,y_i)$$$ and $$$x_i \lt x_{i+1}$$$ for all $$$(1\le i \lt n)$$$.

Maintain two types of queries:

  • Type $$$1$$$: You are given $$$5$$$ integers in the form: 1 l r k b. For all $$$l \le i \le r$$$, change the coordinates of the $$$i^{th}$$$ point to $$$(x_i, k\cdot x_i+b)$$$.

  • Type $$$2$$$: You are given $$$3$$$ integers in the form: 2 l r. Find whether the $$$l^{th}, (l+1)^{th},\ldots ,r^{th}$$$ points are collinear (lie on the same straight line).

Constraint
Difficulty
Point1
Point2

10.Revolving Sushi

There are $$$n$$$ circular positions on the table in the sushi restaurant.

Initially, there are $$$x_i$$$ pieces of sushi in the plate at position $$$i$$$.Every second,the plate at position $$$i$$$ will be put into $$$a_i$$$ pieces of sushi.Then:

  • The plate at position $$$1$$$ will move to position $$$2$$$;
  • The plate at position $$$2$$$ will move to position $$$3$$$;
  • ...
  • The plate at position $$$n$$$ will move to position $$$1$$$.

If for each position,the number of sushi is a multiple of $$$k$$$,customers will be happy.

Find the minimum waiting time to make customers happy.If there's no solution,output $$$−1$$$ instead.

Constraint
Difficulty
Point1
Point2

UPD1:Thank you for your feedback :) Here are some updates. I would try to put similar problems together.

11.Interesting Connection

For two positive integers $$$x,y$$$,define $$$con(x,y)$$$ as the number obtained by connecting $$$x$$$ with $$$y$$$.For example, $$$con(20,23)=2023$$$.

You're given two integers $$$n,k$$$.You can choose an array $$$a$$$ of positive integers of size $$$n$$$,which satisfies $$$Σ^n_{i=1}a_i=k$$$.

Define the score as the number of prime numbers among all $$$con(a_i,a_j)(1 \leq i,j \leq n)$$$.Find the minimum score you can get.

Constraint
Difficulty
Point

12.Interesting Operation

Note $$$f(a)=z,f(b)=a,...,$$$and $$$f(z)=y$$$.

You're given an string $$$s$$$ of size $$$n$$$.

You can do the following operation any number of times:

  • choose two different indexes $$$i,j(1 \leq i,j≤n)$$$,then make $$$s_i:=f(s_i)$$$ and $$$s_j:=f(s_j)$$$;

Find the minimum number of operations to make all characters in $$$s$$$ to $$$a$$$.If you can not make all characters in $$$s$$$ to $$$a$$$,output $$$−1$$$ instead.

Constraint
Difficulty
Point

13.Array Counting

You're given two integers $$$n,m$$$.

Count the number of different arrays $$$a$$$ of size $$$n$$$ satisfying:

  • All $$$a_i(1≤i≤n)$$$ are positive integers;
  • $$$Σ^n_{i=1}a_i=m$$$;
  • Take $$$a_1,a_2,...,a_n$$$ as the length of $$$n$$$ edges,the $$$n$$$ edges can form an $$$n$$$-sided shape.
Constraint
Difficulty
Point1
Point2
Point3

14.Restore the Permutation

Given an array $$$a$$$ of size $$$n$$$, restore the lexicographically smallest permutation $$$p$$$ based on the array $$$a$$$.

For all $$$a_i(1 \leq i \leq n)$$$:

  • if $$$a_i=-1$$$,it doesn't give us any information;

  • if $$$a_i=0$$$,it means $$$p_i>p_j$$$ for all $$$1 \leq j <i$$$;

  • if $$$a_i>0$$$,it means $$$max(j)=a_i,$$$where $$$1 \leq j <i$$$ and $$$p_i<p_j$$$.

Constraint
Difficulty
Point

Full text and comments »

  • Vote: I like it
  • +156
  • Vote: I do not like it

By wuhudsm, history, 15 months ago, In English

A

code
solution

B

code
solution

C

code
solution

D

code
solution

E

code
solution

F

code
solution

Full text and comments »

  • Vote: I like it
  • +20
  • Vote: I do not like it

By wuhudsm, 15 months ago, In English

Hello, Codeforces!

We are happy to invite you to TheForces Round #22 (Interesting-Forces), which will take place on Aug/27/2023 17:35 (Moscow time)

What is TheForces Round?

Editorial

You will have 135 minutes to solve 6 problems.

We strongly recommend you to read all problems.

The round is TheForces rated!, after the round you can find your rating changes here.

Discord Server (1000+ people)

Contests' archive

Full text and comments »

  • Vote: I like it
  • +57
  • Vote: I do not like it

By wuhudsm, history, 16 months ago, In English

A

code
solution

B

code
solution

C

code
solution

D

code
solution

E

code
solution

F

code
solution

G

code
solution

Full text and comments »

  • Vote: I like it
  • +21
  • Vote: I do not like it

By wuhudsm, history, 16 months ago, In English

Hello, Codeforces!

We are happy to invite you to TheForces Round #21 (EDU-Forces), which will take place on 31.07.2023 17:35 (Московское время)

Editorial is out!

What is TheForces Round?

You will have 150 minutes to solve 7 problems.

Some problems may have similar difficulty.We strongly recommend you to read all problems.

The round is TheForces rated:) After the round is over,you can find your rating changes here.

Discord Server (1000+ people)

Contests' archive

Full text and comments »

  • Vote: I like it
  • +82
  • Vote: I do not like it

By wuhudsm, history, 16 months ago, In English

A

code
solution

B

code
solution

C

code
solution

D

code
hint1
hint2
hint3
solution

E

code
solution

F

code
solution

G

code
solution

Full text and comments »

  • Vote: I like it
  • +36
  • Vote: I do not like it

By wuhudsm, history, 16 months ago, In English

Hello, Codeforces!

We are happy to invite you to TheForces Round #20 (7-Problem-Forces), which will take place on Jul/15/2023 17:35 (Moscow time)

What is TheForces Round?

Editorial

You will have 150 minutes to solve 7 problems.

Some problems may have similar difficulty.We strongly recommend you to read all problems.

The round is TheForces rated:) After the round is over,you can find your rating changes here.

Discord Server (1000+ people)

Contests' archive

Full text and comments »

  • Vote: I like it
  • +75
  • Vote: I do not like it

By wuhudsm, 17 months ago, In English

A

code
solution

B

code
solution

C

code
solution

D

code
solution

E

The intended solution is $$$\Theta(n)$$$. However,if your implementation of $$$O(n\log n)$$$ solution is good, it is also possible to pass :)

There're several $$$O(n)$$$ solution.

solution1
code1
Solution2
code2

F

code
solution

Full text and comments »

  • Vote: I like it
  • +43
  • Vote: I do not like it

By wuhudsm, history, 17 months ago, In English

Hello, Codeforces!

We are happy to invite you to TheForces Round #19 (Briefest-Forces), which will take place on Jul/03/2023 18:05 (Moscow time)

What is TheForces Round?

Editorial

You will have 135 minutes to solve 6 problems.

All the statements are very short and brief,and we strongly recommend you to read all problems.

The round is rated:) After the round is over,you can find your rating changes here.

Discord Server (1000+ people)

Contests' archive

Full text and comments »

  • Vote: I like it
  • +111
  • Vote: I do not like it

By wuhudsm, history, 17 months ago, In English

A

code
solution

B

code
solution

C

code
solution

D

code
solution

E

code
solution

Full text and comments »

  • Vote: I like it
  • +20
  • Vote: I do not like it

By wuhudsm, history, 17 months ago, In English

Hello, Codeforces!

We are happy to invite you to TheForces Round #16 (2^4-Forces), which will take place on Jun/11/2023 18:05 (Moscow time)

What is TheForces Round?

You will have 150 minutes to solve 6 problems.

The registration is open now, Don't forget the time!

The difficulty of some problems may be close, so we strongly recommend you to read all statements.

Good luck!

Editorial is out

Discord Server (1000+ people)

Contests' archive

Full text and comments »

  • Vote: I like it
  • +97
  • Vote: I do not like it

By wuhudsm, history, 19 months ago, In English

A

Editorial

B

Editorial

C1

Editorial

C2

Editorial

D

Editorial

E

Editorial

F1

Editorial

F2

Solution1
Solution2

Full text and comments »

  • Vote: I like it
  • +33
  • Vote: I do not like it

By wuhudsm, history, 19 months ago, In English

A

Editorial

B

Editorial

C

Editorial

D

Editorial

E

Editorial

F

Editorial
Bonus

Full text and comments »

  • Vote: I like it
  • +68
  • Vote: I do not like it

By wuhudsm, history, 20 months ago, In English

UPD after one year!

Only a periodic summary. It will be updated continuously.

I'll be glad if someone gets inspired/gives feedback :)

# Date Problem Contest Comment
1 Aug 2022 Ring Game Codechef Starters 53 One of the simplest
2 Aug 2022 Rocket Pack Codechef Starters 53
3 Sep 2022 Energetic Node Codechef Starters 56
4 Oct 2022 Collinear Points Codechef Starters 59 Highly recommend :)
5 Oct 2022 Maximun Sum Codechef Starters 60
6 Oct 2022 Get the Segment Codechef Starters 62 Interactive
7 Sep 2022 Strange BST Codechef Starters 62
8 Dec 2022 Restore the Permutation Codechef Starters 68
9 Dec 2022 Strange Bitwise Operation Codechef Starters 70
10 Dec 2022 Square Loop Codechef Starters 70
11 Jan 2023 A Short Counting Problem Codechef January Long
12 Jan 2023 Xor X,Get Max Codechef Starters 75 Interactive
13 Feb 2023 Bitwise Operations on Circle Codechef Starters 76
14 Mar 2023 Mountain Codechef Starters 79 One of the simplest
15 Apr 2023 Maximum of n Integers TheForces Round #11
16 Apr 2023 Strange Shuffle TheForces Round #11
17 Apr 2023 c0=c1 TheForces Round #11
18 Apr 2023 Big Xor Sum TheForces Round #11
19 Apr 2023 Pre-minimum Score TheForces Round #11
20 Apr 2023 Span Flip TheForces Round #11
21 Apr 2023 A Matchsticks Problem TheForces Round #12
22 Apr 2023 Yet Another Matchsticks Problem TheForces Round #12
23 Apr 2023 Permutaion Construction(easy+hard version) TheForces Round #12
24 Apr 2023 Y Flip TheForces Round #12
25 Apr 2023 Yet Another Y Flip TheForces Round #12
26 Apr 2023 Partition and Alternating Sum(easy+hard version) TheForces Round #12
27 May 2023 Good Operations Codechef Starters 88
28 May 2023 Minimum OR Spanning Tree Codechef Starters 88
29 May 2023 Evil Infection Codechef Starters 89
30 Jun 2023 Partition and Maximize Codechef Starters 95
31 Jun 2023 Guess Game Codechef Starters 95
32 Jun 2023 Infinite Grid TheForces Round #16
33 Jun 2023 Mex Path TheForces Round #16
34 Jun 2023 Get the Long Binary Number TheForces Round #16
35 Jun 2023 Increasing A and Decreasing B TheForces Round #16
36 Jun 2023 Grid Walking+ TheForces Round #16
37 Jul 2023 Tree Construction TheForces Round #19
38 Jul 2023 Max Mobius Sum TheForces Round #19
39 Jul 2023 Tuples TheForces Round #20
40 Jul 2023 2-set Problem TheForces Round #20
41 Jul 2023 Extended Average TheForces Round #20
42 Jul 2023 Array Counting TheForces Round #20
43 Jul 2023 Interesting Index TheForces Round #21
44 Jul 2023 Hacked! TheForces Round #21
45 Jul 2023 Revolving Sushi TheForces Round #21
46 Aug 2023 Increasing and Decreasing Harbour.Space Scholarship Contest 2023-2024 (Div. 1 + Div. 2)
47 Aug 2023 Divisor Chain Harbour.Space Scholarship Contest 2023-2024 (Div. 1 + Div. 2) One of my favorite problems in the official round
48 Aug 2023 Guess Game 2 Harbour.Space Scholarship Contest 2023-2024 (Div. 1 + Div. 2)
49 Aug 2023 Interesting Subsequence TheForces Round #22
50 Aug 2023 Interesting Connection TheForces Round #22
51 Aug 2023 Interesting Operation TheForces Round #22
52 Aug 2023 Interesting Snake Queue TheForces Round #22
53 Aug 2023 Interesting Alternating Sum TheForces Round #22
54 Sep 2023 Two Arrays Game TheForces Round #23
55 Sep 2023 Super Palindrome TheForces Round #23
56 Seq 2023 Concussive Sequence Codechef Starters 100
57 Seq 2023 Interesting Swap Codechef Starters 100 big thx Amir_Parsa for the idea
58 Oct 2023 Left or Right Shift TheForces Round #24
59 Oct 2023 Yet Another ÷2 or +1 Problem TheForces Round #24
60 Oct 2023 Array Construction TheForces Round #25
61 Nov 2023 Submission Bait TheForces Round #26
62 Nov 2023 Interesting Knapsack Codechef Starters 107
63 Nov 2023 Move Negative Stones Codechef Starters 108
64 Dec 2023 Square Count Codechef Starters 111
65 Dec 2023 Permutation Construction Codechef Starters 112
66 Dec 2023 Colorful Paths TheForces Round #27
67 Jan 2024 Two Set Game Codechef Starters 116
68 Feb 2024 Magic Palindrome Codechef Starters 121
69 Feb 2024 Binary Path Codeforces Round 930
70 Feb 2024 Bitwise Operation Wizard Codeforces Round 930 Interactive & One of my favorite problems in the official round
71 Feb 2024 Pokemon Arena Codeforces Round 930 One of my favorite problems in the official round
72 Feb 2024 Yet Yet Another Permutation Problem Codeforces Round 930
73 Mar 2024 Minimum Black Cells TheForces Round #28
74 Mar 2024 Sequence Duplication TheForces Round #28
75 Mar 2024 Perfect Square Matrix TheForces Round #28
76 Mar 2024 Tree Merger TheForces Round #28
77 Mar 2024 RBS Score TheForces Round #28

Full text and comments »

  • Vote: I like it
  • +50
  • Vote: I do not like it

By wuhudsm, history, 23 months ago, In English

It happens when you participate in a contest in a magic color (such as black and red), and then change the color back to your original color after the contest.

You will find it on your contest page:

1.png

Full text and comments »

  • Vote: I like it
  • +22
  • Vote: I do not like it