### Errichto's blog

By Errichto, 2 years ago,

What to do when you need help with a problem?

1. If there is an editorial, read it. If you don't know some technique, google it and read a tutorial.
2. Ask a friend for help. It's very useful to find someone in your university/country who also does competitive programming.
3. "I'm getting WA and don't know why."
Try to find a counter-test. Take an accepted code if it's available, and write a brute force otherwise. Test it against your solution on thousands of random tests, especially small ones.
4. "My code doesn't work on this test."
Use some debugging tools (google them for your OS/IDE) or just print values of everything you compute. I use gdb and valgrind. Simulate the program on paper too. This way you should find an exact place where something incorrect happens, or you will see that your approach is completely wrong.
5. "The output differs on my machine and in Codeforces/anotherPlatform."
It's likely "undefined behavior", e.g. you don't initialize a local variable or you don't return anything from a non-void function. It doesn't happen often if you know the language well. Avoid non-integer values if possible, because real values involve the precision error. Try running your program in a few places online like ideone.com or Codeforces custom invocation. Don't use ideone during a contest or somebody will see your code and you will be disqualified! If it's C++, use compilations flags that catch more errors. I use g++ -std=c++17 -Wshadow -Wall -o a a.cpp -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g. It increases the running time though, so compile in a different way if you need the speed.

1. Practice by solving problems with editorials, especially if you don't know people doing CP, e.g. in your university.
2. Solve problems slightly above your level, not something extremely hard. If the solution/editorial is overwhelming, maybe get back to this problem in a few months.

Still want to ask for help?

3. Provide a source of your problem.
If there is no link and a person is not well known in the community, I'm assuming it's from an ongoing contest or it's your homework. I think such blogs should be answered too, but not immediately.
4. Describe what you already came up with.
5. If you have some code, use meaningful variable names and put comments. If you know which part doesn't work, mention it.
6. Either put the code in "block" and "spoiler" tags (you can see them next to bolding and enumeration), or give a link to a submission or an upload in pastebin/ideone/etc.
7. Use proper English. Full words, dots to finish sentences, uppercase to start them. Use a browser that checks your spelling in English.
8. You can read more here.

Also:

Using "bro/sir"

Don't use that. See how others write in Codeforces or any other international forum.

"Why is my blog downvoted?"

You shouldn't care about it. Codeforces votes are strange and random sometimes. Still, use your main account. I prefer answering people that use Codeforces and have some non-empty contest history.

"How to train, get better, etc.?"

Google your question. There were plenty of those in Codeforces and Quora. If you don't want to do that, just read this.

• +127

 » 2 years ago, # |   +13 Great work, I agree in 100%. I especially insist on providing the source of the problem about you ask (or at least, copy it) Sometimes, if a person re-writes the original description, the problem becomes totally incomprehensible or even different in meaning. I'm often eager to help but at times it's impossible for this reason.
 » 2 years ago, # |   +55 Really liked Enchom's comment. Though you are talking not only about "how to write a post if you want to ask for help", you are touching these matters as well. Maybe it will be good to give a link to this comment in your post.On a side note, it is a bit sad for me to see this #IJustWantContribution from you. This post is good though a little messy, but the previous one was nothing useful. Probably the first time I downvoted something from you.
•  » » 2 years ago, # ^ |   +27 Uuuuuu... get rekt Errichto.
•  » » » 2 years ago, # ^ |   +7 ;_;
•  » » » » 2 years ago, # ^ |   +10 yes sir, if you have too much free time to write this, you should join me to fight the organization!
•  » » 2 years ago, # ^ |   +5 I linked to the comment.I perfectly understand disliking my previous blog. Actually, I didn't know how people would react and I still posted that because I don't care about my contribution — so it's quite opposite of what you're saying. The blog content (about improving English) didn't matter much to me. It was more about asking the question from a title and starting some random discussion, likely not important at all and giving nothing to the world. I agree it wasn't useful, but I don't think I shouldn't post it.
•  » » » 2 years ago, # ^ |   0 If you don't care about your contribution, why don't you give it away for charity?
•  » » 2 years ago, # ^ | ← Rev. 2 →   +1
 » 2 years ago, # |   +17 Errichto's mission is great, we all want to be the best, few people give so much of their time to improve others. It is true that it is exciting to receive positive votes, but I strongly believe that time is worth more.
 » 2 years ago, # |   +27 I broke all your rules in one conversation xD good times
 » 16 months ago, # | ← Rev. 2 →   -29 Hi guys, I am a newbie here. I came across a problem that was asked from Google onsite and I do not know how to answer it. The problem statement is as follow:Given two strings a and b, find if a can be subsequence of b or by concatenating b.Input:a = jajab = bajOutput:TrueExplanation: we can concatenate 3 bs: bajbajbaj to have a subsequence of a.Follow up: what is the minimum of such concatenation of bPlease let me know if this is the correct format to ask for help. Thank you very much. Sincerely, Huy
•  » » 16 months ago, # ^ |   -9 Just wait till somebody replies there.
•  » » » 11 days ago, # ^ |   0 Hi sir, still nobody has replied, and I've scratching my head over this particular problem for over a while now. (the problem in the aforementioned comment)
 » 12 months ago, # |   0 Thanks a lot
 » 6 weeks ago, # |   -21 I am stuck on my MOI exercice could you help me The probleme here
 » 11 days ago, # |   0 If someone needs help with some automation to do point 3, you could use our vs code extension called CodePal that has a provision for stress testing , that automatically compares any 2 codes against input generated by a generated file.