Errichto's blog

By Errichto, 5 years ago, In English

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.

General advice:

  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?

  1. If you think your question is small and easy to answer, consider asking in the discord channel, link.
  2. Write a blog instead of asking some random red guy in priv. This way more people can see it and more people can read the answer and learn something.
  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:

"Can I ask a question?"

This happens often in priv. Just ask your question instead of wasting my time. Also, http://www.nohello.com/.

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.

What should I add here? Suggestions in comments or priv, please. And when you see a badly asked question or somebody bothers you in priv, feel free to link to this blog.

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

| Write comment?
»
5 years ago, # |
  Vote: I like it +13 Vote: I do not like it

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.

»
5 years ago, # |
  Vote: I like it +55 Vote: I do not like it

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.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +27 Vote: I do not like it

    Uuuuuu... get rekt Errichto.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it +7 Vote: I do not like it

      ;_;

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it +10 Vote: I do not like it

        yes sir, if you have too much free time to write this, you should join me to fight the organization!

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

    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.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      If you don't care about your contribution, why don't you give it away for charity?

  • »
    »
    5 years ago, # ^ |
    Rev. 2   Vote: I like it +1 Vote: I do not like it

»
5 years ago, # |
  Vote: I like it +17 Vote: I do not like it

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.

»
5 years ago, # |
  Vote: I like it +27 Vote: I do not like it

I broke all your rules in one conversation xD

good times

»
4 years ago, # |
Rev. 2   Vote: I like it -29 Vote: I do not like it

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 = jaja

b = baj

Output:

True

Explanation: we can concatenate 3 bs: bajbajbaj to have a subsequence of a.

Follow up: what is the minimum of such concatenation of b

Link: https://leetcode.com/discuss/interview-experience/423119/Google-or-L3-or-Japan-or-Oct-2019-Reject

Please let me know if this is the correct format to ask for help. Thank you very much. Sincerely, Huy

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Thanks a lot

»
3 years ago, # |
  Vote: I like it -21 Vote: I do not like it

I am stuck on my MOI exercice could you help me The probleme here

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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.