Test data could be found here.
I put my data into ${year}/data/ folder. My following examples are based on this assumption.
The test.py file is the my simple test script for checking the correctness of each question. Use python3 test.py -h to figure out the detailed usage.
-
Requirement: -- Python 3.6+ is required. -- Linux works fine. Not tested for MacOS/Windows.
-
Basic Usage: Pass
src,dataandlangarguments in. E.g.python3 test.py --src 2020/src/s4.cpp --data 2020/data/s4/ --lang cpp
Supported languages are
cppandpyfor now.srcis your program file.
datais your test case folder.
langis your programming language. -
Other arguments: -- Timeout option: use
--timeoutto specify the time limit to run each test case in seconds. Since the time limit is variant from CPU to CPU, please refer to the How to set timeout section for details. The default time limit is 2 seconds. -- For some numerical solution taking an answer as corrent when the difference between solution and answer is less than a threshold, use--tol(stands for tolerance) argument. E.g. for 2020 s1, runpython3 test.py --src 2020/src/s1.cpp --data 2020/data/s1/ --lang cpp --tol 1e-6
-- For some questions do not have unique answer, I wrote a simple test harness script for each of them, at
year/test/problem.py. Use--harnessargument to specify the test file. E.g. for 2019 s3, runpython3 test.py --src 2019/src/s3.cpp --data 2019/data/s3 --lang cpp --harness 2019/test/s3.py
--
--early-stopto stop running the current test set when one case is failed. Default option is false.
As the instructions in example.cpp to obtain the time limit you should set on your own computer. This is an estimation provided by CEMC officially.
TL; DR;
-
create a file called
in.txtand write the following line into it.1 11 0
-
Run following to compile
g++ example.cpp
-
Stopwatch the running time multiple times and use the
usertime for referencetime ./a.out < in.txt
-
create a file called
in.txtand write the following line into it.1 9 0
-
Stopwatch the running time multiple times to estimate the time limit. Use the
usertime for referencetime python3 example.py < in.txt
Note: From my personal observation using the c++ version to obtain the time limit is more accurate.