Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to link interactive problems (w.r.t. CodeJam)?

I'm not sure if it's allowed to seek for help(if not, I don't mind not getting an answer until the competition period is over).

I was solving the Interactive Problem (Dat Bae) on CodeJam. On my local files, I can run the judge (testing_tool.py) and my program (<name>.py) separately and copy paste the I/O manually. However, I assume I need to find a way to make it automatically.

Edit: To make it clear, I want every output of x file to be input in y file and vice versa.

Some details:

  1. I've used sys.stdout.write / sys.stdin.readline instead of print / input throughout my program

  2. I tried running interactive_runner.py, but I don't seem to figure out how to use it.

  3. I tried running it on their server, my program in first tab, the judge file in second. It's always throwing TLE error.

I don't seem to find any tutorial to do the same either, any help will be appreciated! :/

like image 784
Deep Mehta Avatar asked Apr 06 '19 17:04

Deep Mehta


People also ask

What are interactive problems?

Interactive Problems are those problems in which our solution or code interacts with the judge in real time. When we develop a solution for an Interactive Problem then the input data given to our solution may not be predetermined but is built for that problem specifically.

What is an interactive problem Codeforces?

Sometimes you can meet interactive problems on programming contests (including Codeforces). In problems of this type, the input data given to your program may be not predetermined but is built specifically for your solution.

How many interactive problems are there?

There are three types of interactive problems: Problems that directly tell you the target complexity of your solution (e.g. IOI 2014 Rail). Problems that only tell you the maximum number of queries you may use (e.g. IOI 2013 Cave). Problems that have a hidden limit on the number of queries (e.g. IOI 2015 Scales).


1 Answers

The usage is documented in comments inside the scripts:

interactive_runner.py

# Run this as:
# python interactive_runner.py <cmd_line_judge> -- <cmd_line_solution>
#
# For example:
# python interactive_runner.py python judge.py 0 -- ./my_binary
#
# This will run the first test set of a python judge called "judge.py" that
# receives the test set number (starting from 0) via command line parameter
# with a solution compiled into a binary called "my_binary".

testing_tool.py

# Usage: `testing_tool.py test_number`, where the argument test_number
# is 0 for Test Set 1 or 1 for Test Set 2.

So use them like this:

python interactive_runner.py python testing_tool.py 0 -- ./dat_bae.py
like image 185
Eugene Yarmash Avatar answered Oct 13 '22 14:10

Eugene Yarmash