https://github.com/sayuan/CodeforcesRunner
This is a simple tool which can run sample tests
easier.
Currenty, it support only 4 languages: c++
, c
, java
, python
. However, it coule be expand very easily and the source code is really short. I haven't added other languages just because I don't have the enviroment for verify.
This tool is only verified on Linux
now, but I think it could be run on other platforms too, although it maybe need a little modify.
Again. Please feel free to fork and any suggesions are welcome. :)
08/13 update
Now this tool can download the sample tests automatically:
$ cf.py -c 198 -p A
You can also download the whole contest:
$ cf.py -c 198
Please see the project page for more detail. Thanks.
Very nice! I, too, use something similar, though Make-based. It's also nice to see that compiler flags are the same as on CF. You could add
-m32
to C and C++ to force 32-bit compilation on 64-bit platforms (the CF system is 32-bit).One concern might be that
input
andoutput
are too slow to type repeatedly. Even if you prepare an empty file with these markers, it takes time to position the cursor for insertion. There's also a possibility that a test case will containinput
oroutput
. I'm not sure what would be a better alternative for separation (I just use empty lines, which are easy to type).Thank you for your recommandatiom. I will add the option
-m32
later.The
input
andoutput
texts are part of sample tests in the problem, you can copy & paste it directly from the problem page, see here: http://codeforces.net/problemset/problem/198/ASometimes, I will add test cases which generate by myself. In this case, I always copy & paste the existing test and modify it.
Test cases contain
input
oroutput
is a big trouble to this program. Hope this will not happen forever! Maybe we need another tool to download and parse the problem page? :pHaha, indeed, you can copy the whole tests section at once, and
input
/output
will be in place! It didn't occur to me because I use the Russian interface.I will fixed it later. Thank you!
Already pushed. Please tell me if it doesn't work. Thanks.
In the HTML source of the problem description page sample inputs and outputs are inside divs of classes
<div class="input">
and<div class="output">
. So possibly you could just parse this page and get the correct samples without trouble even if they contain wordsinput
andoutput
.I am not sure the anonymous has the permission to read the problem during the contest. However, I will check it during the next contest. If so, I will try to implement it. Thank you.
update on Aug 7 Ok, now I am sure anonymous has the permssion to read the problem during the contest.
As It's tool for CodeForces where checkers are friendly, I think it should allow additional whitespaces (e.g to print array as
). I've add pull request.
Already merged. Thank you for your contribution.
I think it is always better to have the same behavior with Codeforces judge. However, after searhing all articles abort
rules
, I still can't find the detail of how the judge doing.By the way, I currently plan to add preferences file to this tool. All compile and run options will move to that file, which is generated by this tool if it doesn't exist. I think the
strict
option should move to preferences file too. How to you think?About how it works: A programm called
checker
runs and gets correct answer, participiants output and input. It returns PE or WA or AC. There are some std checkers for sequence of integer, seq of tokens, yes/no, doubles. You may see std checkers in testlib code.I think, it should be possible to change this setting from problm to problem. Btw, It's OK to add default setting, but I don't think it's useful.
Thank you. I will take a look to
testlib
.Maybe this tool should always print all testcases because some problems may support different outputs. In this case you may see
WA
on test 1 and be not able to see results of other testsThis tool is already print all testcases. However, when the answer incorrect, this message will print: "press enter to continue or to leave." and this process continue when you press enter.
Wouldn't it make more sense to put the output information for each test case after the "== Case #X:" heading? For example:
=== Case #1: AC (85 ms) ===
output: 2
=== Case #2: WA (83 ms) ===
output: 2
answer: 3
=== Case #3: RE (95 ms) ===
output: Exception in thread "main" java.lang.Exception at A.(A.java:12) at A.main(A.java:18)
answer: 0
Just a suggestion :)
Display the result at the top has a major disadvantage, you can't see the output immediately. This may increase the debug difficulty, since you only see the output after the process exit.
However, add another marker before each case is ok. Any idea?
I think if you can create a plugin for the IDE (ex: codeblock, eclipse, ...), it will be more convenient, faster and easier to use ;-)
It is so hard to create plugins for each IDE. However, most of the modern editor has
customized hotkeys
, so you can just press a key to execute this script.For instance, I use VIM as my editor and added this line in my
$VIMRC
:nmap <F8> :!cf.py "%:t"<CR>
.Which version of python do you use? (2.7 or 3.3)
Currently, I am using
Python 2.7
, and I hava no idea what going to happen if you run this tool underPython 3.x
.I will try to use syntaxes and libraries which both valid in Python 2.6 ~ 3.x, but I can't guarantee it. If I have to decide to only support some versions of Python,
Python 2.7
is preferred.Your logo:
(For the new version): The link can be more simple (Such as 198A instead of http://codeforces.net/problemset/problem/198/A) :-)
Thank you. Actually, I forgot to update the usage of the newest version in this post. Now you can just specifiy the
contest_id
(andproblem_id
) to download the sample tests. Please see the post on the top.I downloaded the newest version and try to check my solution. I got this error
http://ideone.com/bRPIB
Help me, please!
Since the gcc(& g++) has the option
-m32
, you need some 32-bits libraries.Using apt to install
g++-multilib
might solve your problem. (also installgcc-multilib
for gcc).Another solution is remove the option
-m32
if you don't need 32-bits compilation. Please modifycompile_cmd
in the[.cpp]
section in thecf.conf
file.Thank you !
Nice plugin. Please update the link (distinct github username): https://github.com/sayuan/CodeforcesRunner
I forgot to update this link after I change the user name. Now it is fixed. Thank you for your remind.