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

Overlooked's blog

By Overlooked, history, 5 months ago, In English

Imagine the following problem:

You are given an array of length N. The length is dynamic and may increase or decrease over time. Each element is supposed to be either:

  • M (male)
  • F (female)

A query asks for the number of F elements, because only they qualify for the women's championship.

A straightforward solution is to count the number of F values.

The Humanity Judge says:

Accepted.

The European Judge says:

Wrong Answer.

You check the statement again. You check your code. You check the tests. Everything looks correct.

Then the judge explains:

You forgot about non-binary participants.

At this point you realize what happened. Instead of actually counting F, your solution did:

answer = array_size - count(M);

which works perfectly under the assumption that every element is either M or F. Unfortunately, reality introduced a third value.

Now array_size - count(M) counts both F and non-binary elements. So your solution is no longer counting women.

It is counting: cpp not_men

which is a completely different query. The Humanity Judge accepts the binary model.

The European Judge insists that the complement of M is not necessarily F.

And thus a simple counting problem becomes a lesson in set theory, logic, and modern contest judging.

Moral of the story: Never assume

Universe = {M, F}

unless it is explicitly stated in the problem statement.

Otherwise, your Accepted solution may suddenly become a Wrong Answer on hidden tests.```

Full text and comments »

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