Hello peoples of codeforces, I just want to ask a question. Recently, I found debugging interactive problems' code manually kinda frustrating. Take this problem as an example. Having to answer the code's queries on my own is really time-consuming and one mistake means typing all over again. But if we could have another code that can simply read the original code's queries and answering them automatically then it would be really useful and convenient, especially when participating in a contest. If the problem was non-interactive, I would simply use files for input and output, but interactive problems require simultaneous interaction between two codes, which makes the solution of using files failed. So I am curious to know how to implement that. I would be so appreciative if someone can provide me a template in C++. Thanks for reading and have a nice day.
Auto comment: topic has been updated by ldn694 (previous revision, new revision, compare).
I put all query functions in lambdas. I can easily modify it to return the value from some given data. For example
Its very easy to switch between local testing and submissions. You can also use
#ifdef
s, if you have to change a lot. It's perhaps not the best way to test, but I think it is simple enough.I am looking for a code that can check the original code (the code I would submit). Then I could write a code to generate random tests and check the original one. For example the problem I mentioned in the blog. I want to have a code to simply generate random sequences, run the original code and interact with it, and check whether the sequence that the first code provides are the correct ones. If that is possible, I could automatically check the original one with a lot of random tests and fix the bugs if it gives an incorrect answer. I am sorry if the blog is easily to be misunderstood.
For this problem, you can write some code like this to check your code