Interactive Problems and the way to deal with them!

A related article on codeforces Interactive Problems: Guide for Participants - Codeforces

7 Likes

There is no need to use fflush(stdout) in c++ if you use cout<<endl; instead of cout<<"\n"; because endl automatically flushes.

22 Likes

I have AC in all tasks of INTXOR but getting WA(-1.0000) in only one task of the 3rd Sub-Task and I have no clue why I m getting this and I m using python 3.6, any idea ???

2 Likes

please anyone provide some more understandable example of interactive problem

3 Likes

@carnage17, endl might not always work. It’s possible that you don’t require to go to the new line. You can use cout.flush() or fflush(stdout)

4 Likes

how to close the output stream after program completes in c++?

6 Likes

for c++ , I do
cout << endl;
whenever I want judge to read my answers.

3 Likes

“Every contest has an end… and a blog from @taran_1407.” - Anonymous

10 Likes

Yes, I wasn’t aware of that article when I wrote this. Thanks for sharing

1 Like

Yes… I told the same…

No…

The running time -1.000 is wrong but the verdict WA is correct. Ignore running time here.

I thought binary search problem was easy enough. Please share the problem which shall be easy, though should not belong to any running contest.

@taran_1407, how did you get 6* if you can not tell what does every verdict mean? After 20 random hit & trial submissions, I found out it’s a TLE, not WA. In C++, my same solution got accepted. I’m new to python perhaps I m not aware of optimized read and write functions of python. This is really disappointing, I wasted my 2 days just bcoz of that fucking incorrect verdict.

@taran_1407, Btw thanks, at least you replied.

I would prefer to say more about it only after the end of the contest.

Won’t that also output a newline? What’s the difference between them?

endl makes sure that the printed text is not in buffer and \n doesn’t.
Generally code does optimization by not printing data unless there is good amount of data to print. That makes it faster. It will strore it in temp buffer( say storage like queue) before printing.

3 Likes

It is showing WA, not running time -1.00, Is my solution correct?

Nope