This page is still under construction! 本页仍在建设中!
0. Index 目录
On this page, you will get to know how to use Lowsars. 在本页上,你将学会如何使用Lowsars。
1. Installing. 安装
deb/rpm packages: deb/rpm包:
- Just use your package manager to install it. 只需使用你的软件包管理器来安装。
源代码 Source .tar.gz:
- After download the package, unpack it and change into the directory: 下载以后,解压并进入该目录:
tar -xvf lowsars-0.2.0.tar.gz && cd lowsars
- Run configure script: 运行configure脚本:
./configure
- If any "Something not found. Please install it." message appeared, you should install that first, and then run the script again. 如果出现了“某某 not found. Please install it.”,你就应该先安装它,然后再次运行该脚本。
- Run make: 运行make:
make
- Run make install with root permission: 在root权限下运行make install:
sudo make install
2. Arranging the files for testing. 整理测试用的文件
- The contest (data, source, config file) should be stored in a directory. From now on, it will be called the Contest Diretrory (ConD). 比赛(测试数据,源代码,配置文件)应该存储在一个目录中。从现在开始,我们将会把它叫做“比赛目录”(ConD)。
- There should be two subdirectories in ConD: data and src . 比赛目录下面应该有两个子目录:data和src。
- All data files should be put in ConD/data. 所有测试数据都应放在ConD/data 下。
- All contestants' source files should be put in ConD/src/contestant_name/, where the contestant_name is the contestant's name. For example, lsz's source files should be in ConD/src/lsz/. 所有选手的源代码都应该放在ConD/src/选手名称/下,比如,lsz的源代码应该放在ConD/src/lsz/下。
- All basenames of source file names should be the same as the problem(task) name. The extension name of it should be .pas, .c, or .cpp, according to the language he/she is using. For example, lsz's Pascal source file for the problem simple should be named simple.pas, and placed in ConD/src/lsz/simple.pas 所有的源代码的主文件名必须和题目名称一致,扩展名必须是.pas,.c或.cpp(根据他/她所用的语言而定)。比如,选手lsz的simple一题的Pascal源代码的文件名应该是simple.pas,并放在ConD/src/lsz/simple.pas。
- All programs must read/write only from/to files. 所有程序都必须从文件输入/输出。
- Lowsars now only support classical problems.(with Special Judge support, but not Submitting Output Files nor Interactive) Lowsars 现在只支持传统题目。(支持 Special Judge,不支持提交文件和交互式题目)
3. Create the contest file 建立比赛文件
- Lowsars reads all the information about the contest from the contest file. It is a text file located in ConD/ . Lowsars 从比赛文件中读入所有有关比赛的信息。比赛文件是在ConD/下的一个文本文件。
- You can name it whatever you like, but something like contest.lsc is recommended. .lsc means LowSars Contest file. 这个文件可以叫做任何名称,但是建议叫做类似contest.lsc的名称。.lsc的意思是LowSars Contest文件。
- You can write it in any text editor you like: vim, emacs, gedit, kate... 你可以使用任何你喜欢的文本编辑器来写比赛文件:vim, emacs, gedit, kate……
- If you already had Cena contest file, you just need to convert it with lowsars-cena, instead of writing again.
- 如果你有Cena比赛文件,你可以使用lowsars-cena把它转换成Lowsars比赛文件,而不用再次手写。
3.1 Simple Example 简单的例子
- Now, let's see a simple example: 现在,让我们从一个简单的例子开始:
problem first input @.in output @.out cases 1 10 input @#.in output @#.out end
- All spaces at the beginning of each line are not necessary, that is, it is equal to the one below:
- 每行开头的所有空格都不是必需的,也就是说,它和下面的例子是一样的:
problem first input @.in output @.out cases 1 10 input @#.in output @#.out end
- Line 1 says that there is a problem named first.
- 第1行表示有一个叫做first的题目。
- Line 2 says the input file (given to the contestants' programs) is named first.in. As you see, @ here means the problem's name, which is first here.
- 第2行表示(选手程序的)输入文件是first.in。没错,这里的@表示题目名称,这里是first。
- Of course, you can also write "input first.in" here, but it will be longer than this, do you want it?
- 当然,这里也可以写"input first.in",但是那个更长,对吧?
- Line 3 is similar to Line 2, except for that it is the output.
- 第3行和第2行差不多,只不过这里是输出文件。
- Line 4 says that there are 10 test cases: from number 1 to 10.
- 第4行表示有10个测试点,从1号到10号。
- Line 5 says the input file (in the data) is named first1.in, first2.in, ..., first10.in. Yes, the # means the case number, which is from 1 to 10. All these files are relative paths from ConD/data/, in other words, they are ConD/data/first1.in and so on.
- 第5行表示(数据里面的)输入文件是 first1.in, first2.in, ……, first10.in。这里的#表示测试点编号,这里是从1到10。所有这些文件都是相对于ConD/data/的路径,也就是说,这些文件实际上是ConD/data/first1.in等等。
- Line 6 is similar to Line 5, but for data output file.
- 第6行与第5行相似,是数据的输出文件。
- Line 7 means the contest file is over. Don't omit this line or Lowsars will do something unexpected.
- 第7行表示比赛文件结束了。不要省略这一行,否则Lowsars会做出一些你不愿看到的事。
- In the 4th part, you will know how to test this contest. But for now, let's see a more complicated contest file:
- 在第4部分,你将知道如何测试这场比赛。但是现在,让我们来看一个更复杂的比赛文件:
3.2 Limits and Multiple Case Groups 限制和多个测试点组
problem second cases 0 4 input @a#.in output @a#.out case 7 input @b#.in output @b#.out timelimit 2 score 15 cases 9 10 input @c#.in output @c#.out memorylimit 4096 end
- This problem, named second, consists 8 test cases: 0,1,2,3,4,7,9,10. 5,6 and 8 are excluded.
- 这道叫做second的题目包括8个测试点:0,1,2,3,4,7,9,10。没有5,6和8号测试点。
- If the programs' input filename is @.in, as in this file, it can be omitted. So it is with the output filename is @.out.
- 如果程序输入文件名是@.in,就像这道题一样,那么它可以省略。输出文件名是@.out的也一样。
- Line 3 means that the data input filenames is @a#.in, which means seconda0.in, seconda1.in, ..., seconda4.in.
- 第3行表示数据输入文件名是@a.in,也就是seconda0.in, seconda1.in, ..., seconda4.in。
- No explanation for line 4. :) 第4行不需要解释。
- Line 5 means there is another test case: case 7. Note it is "case" instead of "cases" since there is only one case here.
- 第5行表示还有另一个测试点:测试点7。注意因为只有一个测试点,这里是“case”而不是“cases”。
- Line 6 means the data input filename for test case 7 is @b#.in, which only means secondb7.in here.
- 第6行表示7号测试点的数据输入文件是@b#.in,在这里只表示secondb7.in。
- No words on line 7. 第7行我也不说了。
- Line 8 defines the timelimit for test case 7. It means if someone's program runs more than the time limit (here 2 seconds), it would be killed and he/she can't get any scores in this test case. If this line is omitted like the above testcases 0-4, the default value as 1 second is used. The word "timelimit" can be shorten as "time" or "tlimit".
- 第8行定义了第7点的时间限制。它表示如果某位选手的程序运行时间超过时间限制(这里是2秒),那么程序将被砍掉,他/她此测试点将不能得到任何分数。如果这一行像上面的0-4测试点一样被省略的话,默认为1秒。“timelimit”可以简写为“time”或者“tlimit”。
- Line 9 defines the score for test case 7. It means you get 15 score each testcase if you have done right on it. If this line is omitted like the above testcases 0-4, the default value is 10.
- 第9行定义了第7点的分数。它表示如果你这个点做对了,将得到15分。如果这一行像上面的0-4测试点一样被省略的话,默认为10分。
- No words on line 10-12.
- 第10-12行我也不说了。
- Line 13 defines the memory limit for test case 7. It means the memory limit is 4096 KB. If this line is omitted like the above testcases 0-4, the default value is 262144 KB. The word "memorylimit" can be written as "memory" or "mlimit" if you are lazy.
- 第13行定义了第7点的内存限制。它表示内存限制是4096KB。如果这一行像上面的0-4测试点一样被省略的话,默认为262144KB。如果你懒,“memorylimit”可以简写为“memory”或者“mlimit”。
3.3 Multiple Problems 多个题目
- Of course, you can have more than one problem in one contest file, just write like below:
- 当然,一个比赛文件中可以含有多个题目,就像下面的例子:
problem third cases 1 10 input @/@#.in output @/@#.out problem fourth cases 1 10 input @/@#.in output @/@#.out end
- This contest file contains two problems: third and fourth.
- 这个比赛文件包括两个题目:third和fourth。
- Lines 1 to 4 describes the problem third, and Lines 5 to 9 describes the problem fourth.
- 第1至4行描述了题目third,第5至9行描述了题目fourth。
- Note: only write one end in one contest file.
- 注意:一个比赛文件中只写一个end。
3.4 Whitespaces and Special Judge 空白字符和Special Judge
problem fifth judge ignore spaces cases 1 5 input @/@#.in output @/@#.out problem sixth judge noscore testsix %a %o cases 0 8 input @/@#.in output @/@#.out problem seventh judge score testseven %a %o cases 1 6 input @/@#.in output @/@#.out end
- Line 2 uses the judge ignore feature in Lowsars. judge ignore space means to ignore extra spaces when comparing the contestants' output file with the standard ones. judge ignore white means to ignore all spaces. judge ignore emptyline means to ignore empty lines. judge ignore case means to be not case-sensitive.
- 第2行使用了Lowsars中的judge ignore功能。judge ignore space表示在比较选手输出和标准输出时忽略额外的空格。judge ignore white表示忽略所有空格 judge ignore emptyline表示忽略所有空行。judge ignore case表示忽略大小写。
- By default, Lowsars will ignore the difference between CR-LF (the line-breaking in DOS/Windows) and LF (the line-breaking in Unix/Linux). If you want pure byte-by-byte comparing, use judge ignore nothing.
- 在默认情况下,Lowsars忽略CR-LF(DOS/Windows换行符)和LF(Unix/Linux换行符)。如果你想要逐字节的比较,请使用judge ignore nothing。
- You can combine them together, like judge igonre space emptyline. It means to ignore both extra spaces and emptylines.
- 你也可以把它们组合在一起,就像judge igonre space emptyline。这表示忽略多余空格和空行。
- Line 7 specifies the no-score special judge program for problem sixth: ConD/testsix %a %o. Here %a means the data output file(answer file), %o means the contestant output file, and %i means the input file. After running the contestants' programs, ConD/testsix %a %o will run. If that exits with code 0 (normal exit), he/she will get full score for that case, otherwise, he/she will get no score for it.
- 第7行指定了题目sixth的非得分Special Judge程序:ConD/testsix %a %o。这里的%a表示数据输出文件(答案文件),%o表示选手输出文件,%i表示输入文件。当选手程序运行完毕后,将会执行ConD/testsix %a %o,如果它退出代码是0(正常退出),则他/她将会得到该测试点的全部分数,否则他/她将得不到该点的分数。
- Line 12 specifies the score special judge program for problem seventh: ConD/testseven %a %o. After running the contestants' programs, ConD/testseven %a %o will run. That program should output a line like SCORE INFO, where SCORE is the score for the testcase, and INFO is the information to display (optimal).
- 第12行指定了题目seventh的含得分Special Judge程序:ConD/testseven %a %o。当选手程序运行完毕后,将会执行ConD/testseven %a %o,它应该输出一行类似SCORE INFO的内容,其中SCORE是该点得分,INFO是用于显示的额外信息(可选)。
3.5 Import contest file from Cena 从Cena导入比赛文件
- Cena is another free scoring and testing program similar to Lowsars, but it runs only on MS Windows. Cena是另一个自由的测评系统,它运行在MS Windows上。
- You can import a Cena contest file to Lowsars contest file by the following command: 你可以用下面的命令把Cena格式的比赛文件转换成Lowsars格式:
lowsars-cena data/dataconf.xml
- Here data/dataconf.xml is the default filename of the Cena contest file. 这里的data/dataconf.xml是Cena的默认比赛文件名。
- The imported Lowsars contest file will be placed in ConD/dataconf.lsc. 导入后的Lowsars比赛文件将会被放在ConD/dataconf.lsc。
4 Run the lowsars command 运行lowsars命令
- When you have finished creating the contest file, you can run lowsars command in ConD/ like below:
- 当你创建完比赛文件以后,就可以像下面一样在比赛目录中运行lowsars命令:
lowsars contest_file.lsc
- where contest_file.lsc is the contest file. 其中contest_file.lsc是比赛文件。
- This command tests every contestant's every problem, and gives the result. 此命令测试了所有选手的所有程序,并给出了结果。
lowsars contest_file.lsc -c lsz yh
- This command tests lsz's and yh's every problem, and gives the result. 此命令测试了选手lsz和yh的所有程序,并给出了结果。
lowsars contest_file.lsc -p proba probb
- This command tests every contestant's programs for the problem proba and probb, and gives the result. 此命令测试了所有选手的proba和probb两道题的程序,并给出了结果。
lowsars contest_file.lsc -a
- The -a means only to test the programs that havn't been tested. It is often used when a new contestant's programs are added.-a表示仅仅测试未测试过的程序。此选项经常用于新添加了一名选手时。
lowsars contest_file.lsc -r -c lsz -p river volunteer
- -r means not to test lsz's programs river and volunteer, but to remove the result of them (so you can use -a option later). -r表示不测试lsz的river和volunteer两个程序,而是去掉它们的评测结果(这样以后就可以使用-a选项了)。
lowsars contest_file.lsc -n
- -n means not to compile the programs, but to use the executables that are already in the src/ directory. -n表示不编译程序,而是使用已经在src/里面的可执行程序。
- There are other options, which are not as useful as the ones listed above: 还有其它的不像上面列出的那么有用的选项:
- --help and --version: Show the brief help and version number. 显示简短的帮助和版本号。
- -q: Be quiet, do not show the result. 安静,不显示结果。
- -v: Be verbose, show some debug information. 输出一些调试信息。
- -V: Be more verbose, show all debug inforamtion. 输出全部的调试信息。
- -C and -P: I won't say about it here. These options are of little use for users, they were designed for the GUI (in the future). But as the plan for 0.3 version is out (and giving up the GUI plan for 0.2 series), these two options are now almost deserted. However, you can still refer to lowsars --help for explanations. 我在这里不做解释。这两个选项对于用户来说基本没有用处。它们本来是为了(未来的)GUI而设计的。但是随着0.3的计划的推出(和0.2版GUI的放弃),这两个选项已经基本废弃了。然而,你还是可以在lowsars --help找到解释。
5 See the result 查看结果
- You can watch the result when lowsars is working. Besides, lowsars generate a lot of result files in the ConD/result/ directory. You can understand them easily.
- 当lowsars工作时,你可以看到结果。另外,lowsars在ConD/result/目录下产生了很多结果文件。它们很容易看懂。