Блог пользователя susenyang

Автор susenyang, история, 2 недели назад, По-английски

Hello Codeforces Community! I'm susenyang, and I'm excited to share a contest with you again!

This contest is The 15th Huazhong Agricultural University Programming Contest, an official contest hosted by my university. You will have $$$5$$$ hours to solve $$$13$$$ problems.The round will be hosted by rules of ICPC and the penalty is 20 minutes per wrong submission.

This year, I did not participate in problem setting; instead, I took part in the competition as a contestant. The following are the authors of this contest:

We would like to thank:

We provide PDF Statements and Tutorial in both English and Chinese. Since the problem authors are all Chinese, we have to use ChatGPT to translate it. If you are confused about any description in them, feel free to comment!

Additional: Link to the 14th.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +19
  • Проголосовать: не нравится

Автор susenyang, история, 5 месяцев назад, По-английски

weedy post the blog Issues with Building PDF Statements on Polygon 2 months ago.

To summarize this blog post: authors who need to write problem statements in non-Latin languages have recently encountered rendering bugs on Polygon, especially in newly created problems. These issues include inconsistent fonts and bold text failing to render properly.

This problem has not been fixed yet, so if you need to generate PDFs on Polygon in the near future, you may be affected.

Fortunately, compiling LaTeX locally is both simple and fully workable.

First, make sure you have a basic LaTeX environment installed on your machine. Then package all problems in the contest on Polygon, and finally click "Download Package" on the contest page.

For example, in one of my contests, I just go to the statements/chinese/ directory and run:

chmod +x doall.sh
./doall.sh

If the compilation fails, try replacing

latex statements.tex
latex statements.tex

with

pdflatex statements.tex
pdflatex statements.tex

Hope this helps!

Полный текст и комментарии »

  • Проголосовать: нравится
  • +14
  • Проголосовать: не нравится

Автор susenyang, история, 8 месяцев назад, По-английски

Recently, I’ve been reorganizing my algorithm templates, which include some data structures and graph algorithms. Since my coding style tends to favor using std::vector instead of C-style arrays, I want my templates to be more encapsulated. I admit I’m not very familiar with this style of templates, so I thought of using AI to help me refine them. Below is a template for finding the LCA using Heavy-Light Decomposition:

LCA (Now)

My previous templates looked like this:

LCA (Old)

Meanwhile, I also directly generated the following template using ChatGPT-5:

LCA (by ChatGPT)

As we can see, this template doesn’t really have any issues. In fact, in terms of readability, it is already better than most beginners’ code — or at least easier to maintain.

The above examples illustrate that AI has indeed proven to be very effective in maintaining algorithm templates (perhaps partly because such templates already appear in its training data). Whether it is using AI to polish existing templates, assist in modifying them, or directly generate a new one, AI shows strong usability.

Of course, in theory, using AI-generated code during contests is clearly not allowed. But my real question lies in the boundary of using such “templates generated by AI in advance.” On one hand, they are indeed produced by AI; on the other hand, they are prepared before the contest, just like how most participants maintain their own template libraries to bring into competitions.

As a beginner, I would also like to emphasize that AI has lowered the barrier to learning. With AI tools, we can more easily obtain high-quality reference code, and even detect and correct subtle mistakes we might otherwise overlook. At the very least, outside of contests, they can serve as effective learning tools.

Therefore, I started this discussion to hear opinions from the Codeforces community:

Should we allow the use of AI-generated templates?

  • Absolutely not
  • Allow polishing or debugging templates with AI
  • Allow directly using AI-generated templates

If AI templates are allowed, in which scenarios should they be acceptable?

  • Only in pre-contest preparation (AI-assisted template maintenance)
  • Also during contests (AI-generated or AI-debugged templates)

Should templates indicate when they are generated or refined by AI?

  • No, treat them the same as normal templates
  • Yes, explicitly state AI assistance in the template

For options not covered above, share it in the comments.

UPD: One feasible approach is to upload these templates to GitHub in advance. The commit history on GitHub can serve as evidence that the templates were prepared beforehand.

Spoiler

Полный текст и комментарии »

  • Проголосовать: нравится
  • +11
  • Проголосовать: не нравится

Автор susenyang, история, 11 месяцев назад, По-английски

While using Polygon to package a problem, I encountered the following error:

MikeMirzayanov please look into this issue.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +19
  • Проголосовать: не нравится

Автор susenyang, история, 12 месяцев назад, По-английски

Hello Codeforces Community! I'm susenyang, and I'm excited to share a contest with you!

This contest is The 14th Huazhong Agricultural University Programming Contest, an official contest hosted by my university. I believe it's a great contest, and I hope you'll enjoy it. You will have $$$5$$$ hours to solve $$$13$$$ problems.

The round will be hosted by rules of ICPC and the penalty is 20 minutes per wrong submission.

Author List: susenyang, Linear_L, zycpdd, 23337456, tryandtryagain, alicespring

We would like to thank:

If you have any suggestions, please feel free to leave them in the comments. Your feedback will be invaluable to us!

We provide PDF Statements in both English and Chinese, as well as a Chinese version of the Solution. The English version of the Solution will be updated later.

Besides, we also have a warm-up contest. If you are interested in it, please click this link.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +23
  • Проголосовать: не нравится

Автор susenyang, история, 12 месяцев назад, По-английски

About this blog

In Teza Round 1 (Codeforces Round 1015, Div. 1 + Div. 2), I finally reached the stage of Candidate Master. Candidate Master has a special meaning to me. May be I saw it as my official introduction to the programming competition. And now I have reached it.

This blog post is about my memories and reflections on reaching CM, as well as some of my own experiences.

My journey to CM

My first codeforces round is Codeforces Round 886 (Div. 4), and I solved 5 problems in this round. Perhaps thanks to the experience of high school math competition (my high school math competition career was not outstanding, and finally only the provincial second prize), getting Pupil and Specialist was easy to me. I have summarized my growing up experience into the following list:

  • 2023/7/21 My first codeforces round Codeforces Round 886 (Div. 4)
  • 2023/8/7 Pupil
  • 2023/9/10 Sepcialist
  • 2023/10/28 Expert
  • 2023/10/30 Back to Specialist
  • 2023/12/30 Expert again
  • 2025/2/11 Candidate Master (roll back)
  • 2025/2/16 Back to Expert
  • 2025/4/5 Candidate Master again

In fact, I was very eager to make the breakthrough from blue to purple. Since 2024/12/20 broke through 1800 points and came to 1854 points, every round I played was a challenge to purple. And now, I managed to do it. My rating changes polylines

My experiences

How to become Pupil/Specialist/Expert/Candidate Master?

Some guys have talked with me about this problem. Based on my experience, I think the only way to improve is to practice. "Practice makes perfect."" It is famous, and only a few coder can improve without enough practice.

However, practice is only a necessary condition, not a sufficient condition. I always find that someone solved thousands of problems but feel hard to improve. Scientific training is the key to advancement. In my opinion, the scientific training method is: try to do a problem with a rating of 200-400 points higher than your current rating. If you fail to solve the problem in 60 minutes, read the solution and think through the solution. This time is flexible, the reason why I choose 60 minutes is that for me, the problem that has not been solved in 40 minutes in the competition is invalid, so I will add some time on the basis of 40 minutes. Too simple questions are easy to do, but have no effect on improving ability. Too difficult questions higher than we can strive to achieve the height of thinking, will only increase anxiety in the process of learning. I think 200-400 is suitable.

What algorithm should I master to reach Pupil/Specialist/Expert/Candidate Master?

I think some "algorithms", like prefix, binary search, dfs/bfs, dp (basic Knapsack and basic dp on tree), greedy, are mindset in fact. They are actually the most frequently used because they are the most basic. Besides, I know very few algorithms.

I can no longer agree with this blog. I can't seem to do elimination, so I list what I can master:

  • Enumerate
  • Simulate
  • Divide and conquer
  • greedy
  • Sort (only std::sort in $$$O(n\log n)$$$)
  • Prefix
  • Binary
  • Two-pointer
  • Binary-lifting (Only ST-table)
  • DFS and BFS
  • dp (knapsack dp, interval dp, dp on tree, state dp, count dp, probability dp)
  • Trie and KMP (I don't understand it. I can use it only)
  • Manacher (I've only done template problems)
  • Qucik power
  • Modular multiplicative inverse
  • Linear-sieve
  • Basic-combination
  • STL (std::vector, std::map, std::queue, std::set, std::priority_queue, std::stack)
  • Monotonous-stack and monotonous-queue
  • A little decompose
  • Fenwick tree and segment tree (I can use it only)
  • DSU
  • LCA
  • Minimum Spanning Tree
  • Shortest-path (Only Dijkstra in $$$O(m \log m)$$$)

I think it is enough to reach Candidate Master. Although most of them are the content is the content of the popularization group in CNOI (just like CSP-J).

What is the relationship between Codeforces and ICPC?

Codeforces is Codeforces, ICPC is ICPC.

I know many people will ask, what can three Pupil/Specialist/Expert/Candidate Master achieve in the ICPC East Asia Regional Competition? Stop to image about it. This is because problems are totally different in Codeforces and ICPC.

In general, Codeforces problems are more "lightweight," whereas ICPC requires a longer chain of thought. If you are doing ICPC for the first time, you may not feel comfortable. This is because in ICPC, a certain amount of team cooperation is required. After all, ICPC is a game for three people.

If you want to do well in ICPC, try Gym and search "ICPC", choose "Virtual Participation".

Recommended session

Conclusion

This is all I can think of that I need to share and express. Enjoy programming as much as possible. Code is fascinating.

Another reason I want to stop to share

Полный текст и комментарии »

  • Проголосовать: нравится
  • +64
  • Проголосовать: не нравится

Автор susenyang, история, 13 месяцев назад, По-английски

I want to share my construct method for 2092D - Mishkin Energizer. I think it is easy to understand and enlightening.

The first thing that caught my eye was this $$$2n$$$ constraint. At the same time, the problem asks us to make the number of the three letters equal. I'm going to use $$$\texttt{A}$$$,$$$\texttt{B}$$$,$$$\texttt{C}$$$ instead of $$$\texttt{L}$$$,$$$\texttt{I}$$$,$$$\texttt{T}$$$ for the sake of clarity.

Suppose that we have $$$\texttt{A}$$$ with the amount of $$$a$$$, and $$$\texttt{B}$$$ with the amount of $$$b$$$, $$$\texttt{C}$$$ with the amount of $$$c$$$. So $$$a+b+c=n$$$. I found that if we make them all appear $$$n$$$ times in the last sequence, the number of operations we need is exactly $$$2n$$$.

I like it because it havs the beauty of circular symmetry which fits my gut. Let's think about how do we get there.

I don't like too complicated operation because it always lead to classification discussion. In contests that require speed, classification discussions are often error-prone and time-wasteful. For a d2D, I tend to organize a complete idea before writing code.

Suppose we had one $$$\texttt{AB}$$$. I hope it can create enough of what I want.

First of all, we can only insert $$$\texttt{C}$$$ into it and it becomes $$$\texttt{ACB}$$$. What should we do? I don't want to destroy the structure of $$$\texttt{AB}$$$ so I insert another $$$\texttt{A}$$$ between $$$\texttt{C}$$$ and $$$\texttt{B}$$$. Now it is $$$\texttt{ACAB}$$$. Can we have more $$$\texttt{CA}$$$? Of course we can. If we repeat the operation above, we will get $$$\texttt{ACACACACACACACAB}$$$.

In other words, we can use a $$$\texttt{AB}$$$ to generate enough $$$\texttt{CA}$$$. This is a major breakthrough in our thinking.

Let's go back and think about the limitations of the problem. If we want to get all of the letter appear $$$n$$$ times, we need create $$$(n - a)$$$ $$$\texttt{A}$$$, $$$(n - b)$$$ $$$\texttt{B}$$$ and $$$(n - c)$$$ $$$\texttt{C}$$$. If we can If we were free to create $$$\texttt{CA}$$$, $$$\texttt{AB}$$$ and $$$\texttt{BC}$$$, we can manage to do it! That's because if we create $$$x$$$ $$$\texttt{BC}$$$, $$$y$$$ $$$\texttt{CA}$$$ and $$$z$$$ $$$\texttt{AB}$$$, just need:

$$$ \begin{cases} y + z &= n - a \\ z + x &= n - b \\ x + y &= n - c \end{cases} $$$

so

$$$ \begin{cases} x &= a \\ y &= b \\ z &= c \end{cases} $$$

because $$$a+b+c=n$$$.

Right now, we're just one step away from success which is to generate enough $$$\texttt{BC}$$$ and $$$\texttt{AB}$$$. When we get $$$\texttt{ACACACACACACACAB}$$$, we will find it easy to get $$$\texttt{ABCACACACACACACAB}$$$ and $$$\texttt{ACBCACACACACACACAB}$$$ next. It seems that $$$\texttt{AC}$$$ can create $$$\texttt{CB}$$$ which makes it become $$$\texttt{ACBC}$$$ and protect $$$\texttt{AC}$$$ to create more $$$\texttt{CB}$$$. In the same way, $$$\texttt{BA}$$$ can be generated infinitely by $$$\texttt{AC}$$$. Now we can solve this problem.

In the process of implementation, as soon as we meet two adjacent and different letters, we let the left be $$$\texttt{A}$$$ and the right be $$$\texttt{B}$$$. Through the above analysis, we can construct a scheme that conforms to the constraints. If we failed to meet two adjacent and different letters, it means that all of the letters are the same so we can't make any operation at all, which lead to the output of $$$\texttt{-1}$$$.

My code in the contest:

#include <bits/stdc++.h>

using i64 = long long;

constexpr int N = 2e5 + 10;

void solve() {
	int n;
	std::cin >> n;

	std::string s;
	std::cin >> s;

	std::map<char, int> cnt;
	for (int i = 0; i < n; i++) {
		cnt[s[i]]++;
	}

	std::vector<int> op;
	for (int i = 0; i + 1 < n; i++) {
		if (s[i] != s[i + 1]) {
			for (int c = 0; c < 2 * cnt[s[i + 1]]; c++) {
				op.push_back(i + c);
			}
			for (int c = 0; c < 2 * cnt[s[i]]; c++) {
				op.push_back(i + 2 * cnt[s[i + 1]]);
			}

			char tar = '0';
			std::string tmp = "LIT";
			for (int x = 0; x < 3; x++) {
				if (tmp[x] != s[i] && tmp[x] != s[i + 1]) {
					tar = tmp[x];
					break;
				}
			}
			for (int c = 0; c < 2 * cnt[tar]; c++) {
				op.push_back(i + c);
			}

			std::cout << 2 * n << '\n';
			for (const auto &num : op) {
				std::cout << num + 1 << '\n';
			}
			return;
		}
	}
	std::cout << -1 << '\n';
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	int t = 1;
	std::cin >> t;
	while (t--) {
		solve();
	}

	return 0;
}

Полный текст и комментарии »

  • Проголосовать: нравится
  • +34
  • Проголосовать: не нравится

Автор susenyang, история, 13 месяцев назад, По-английски

Just now, I discovered that I couldn't generate invite links or target certain users.

If I invite a user in a directional way, it pops up: Can't perform requested action

I want to know what lead to it and how to solve this problem?

I need this feature a little bit, please take a look at this blog post. Thank you MikeMirzayanov.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

Автор susenyang, история, 13 месяцев назад, По-английски

My coffee cup is not empty but I feel pity for the delay of the following round.

It was not the mistake of the problem authors and they have pay a lot for this round. I think they may be more sad than us so don't downvote the announcement plz.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +18
  • Проголосовать: не нравится

Автор susenyang, история, 14 месяцев назад, По-английски

I have been eager to enable coach mode because I want to share a freshman-contest of my school on the gym. Since I came up with this idea, I have tried to became a purple coder.

If you visit my profile, you may find that I have reach it after Codeforces Round 1004 (Div. 2). There was a funny fact that before the rating roll back, my rating was 1899. So after this contest, I have participated in Codeforces Round 1005 (Div. 2) and Educational Codeforces Round 174 (Rated for Div. 2). I have successfully lose 90 ratings in these contests.

After the roll back, my max rating became 1909 and I have became a candidate master. However, I can't enable the coach mode because my rating was lower than 1900 now.

Anyhow, I will try to achieve this goal again and share the contest with you. Thanks for Codeforces and You.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +2
  • Проголосовать: не нравится

Автор susenyang, история, 19 месяцев назад, По-английски

After Creating a private contest, I tried to add my problem in Polygon to Codeforces but failed. So I have created a new contest in Polygon and added the problem "example-a-plus-b*" only. However, I can't add this problem as well. So I want to know what should I do in this case.

Additionally, I have added "codeforces" as a reader.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +26
  • Проголосовать: не нравится