Hi temper_3243. I checked the outputs from your code inputs 1 to 30000 against my AC code, which I got AC a few minutes ago.
Your code fails for the following test case:
Input:
1
1
Correct Output:
Case 1: 0 1
Your Program Output:
Case 1: 1 0
I have also removed the space in the scanf when I compiled your code.
In fact, your code gives the following output for input 1 to 30000
Case 1: 1 0
Case 2: 1 0
Cases 3 to 30000 also give 1 0.
The environment I ran your code with is g++ 2.95 in Unix, which is similar to UVA online judge environment.
I have tried to debug your code and found one line that could be a problem.
What I can tell you is that I inserted printfs in the compute method and myg method in your code and I got something very interesting.
At the beginning of the myg method
Code: Select all
printf("myg %d %d\n",r,m.count(r));
and at the beginning of the compute method
Code: Select all
printf("compute %d %d\n",n,m.count(n));
For each n, m.count(n) = 0 is correct. But for each r, m.count(r) = 1. This should not be so.
This is a problem with the judge's compiler.
When I compiled your code with g++ 3.3.1 under Dev C++ 4.9.9.1 in Windows wthout the printfs I added and ran it with the same set of inputs and I got your program's output to be the same as from my AC program's output.