ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1680. The First Nonqualifying

java.util.HashSet.add() method
Posted by Moonstone 7 Jun 2010 14:06
When I used this code:
if (q == 0) {
    out.println(fullName);
    return;
}
if (set.add(name)) q--;
I got WA 2.

Then I replaced it by:
set.add(name);
if (set.size() > q) {
    out.println(fullName);
    return;
}
and got AC.

So, can anybody explain me why?
JavaDoc says:
"Returns:
true if this set did not already contain the specified element",
or, in our problem, if this team is the first team of this university.
Can you give me a test where my first solution gets WA, and the second gets AC?

P.S. I got AC WITHOUT any comparing in lowercase!

Edited by author 07.06.2010 14:12