Codeforces Round 1133 (Div. 1, Div. 2) is coming soon! Register here. ×

Not_Hadid_007's blog

By Not_Hadid_007, history, 10 minutes ago, In English

Getting a Wrong Answer (WA) on Codeforces doesn't always mean your algorithm is wrong. Sometimes, small implementation mistakes are the real problem.

Here are 6 common mistakes to watch out for when coding in C.

  1. Integer Overflow

Using "int" for values that exceed its range can produce incorrect results. Use "long long" when necessary.

  1. Wrong Format Specifiers

Match your format specifiers with the data types.

  • "int" → "%d"
  • "long long" → "%lld"
  • "double" in "scanf()" → "%lf"
  1. Output Formatting

Extra spaces, missing newlines, or unnecessary messages can cause WA. Follow the exact output format.

  1. Integer Division

In C, "5 / 2" produces "2", not "2.5". Use floating-point arithmetic when decimals are required.

  1. Boundary Cases

Don't test only ordinary inputs. Check minimum values, maximum values, zero, and other special cases allowed by the constraints.

  1. Incorrect "scanf()" Usage

Remember the address operator ("&") when reading variables.

scanf("%d", &a); // Correct

Before Submitting

  • Check constraints and data types.
  • Verify format specifiers.
  • Check output formatting.
  • Test boundary cases.
  • Double-check input statements.

Remember: A small bug can cause a Wrong Answer. Learn to identify the mistake, understand it, and avoid repeating it.

Happy coding!

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
10 minutes ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by Not_Hadid_007 (previous revision, new revision, compare).