I've got many WA s on this problem, but I can see that the judge's test data is the same as the data in the real contest. But In Both windows and linux mode I can pass all the test case in the real contest using g++ 3.4.2.
I see that SPOJ uses g++ 4.0.0 as the c++ compiler. Is this the problem?
My submission id is 1179170.
Edit: I'm sorry, after I find my silly mistake and have it fixed I've got Accepted.