0%

GzhuOJ Add Problem

GzhuOJ在添加题目时有许多祖传问题,靠着一点点的读代码的能力也算是摸索出了一点使用方法。

GzhuOJ(仅内网登陆)
GzhuOJ源码
GzhuOJ的Judger源码


spj模式

你最基础需要三个文件”1.in”、”1.out”、”spj.cpp”。
“1.in”和”1.out”就是标准输入和标准输出文件。
而”spj.cpp”是你用于判定用户的输入是否正确的文件。
“spj.cpp”需要你输出”WA”、”PE”、”AC”(若不输出则认为是”WA”)对于每一种结果。
例如对于Problem 1345,下面是对这个问题写的”spj.cpp”。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <stdio.h>
int main(int argc, char **argv)
{
FILE * fout = fopen(argv[1], "r"); //对应1.out
FILE * fusr = fopen(argv[2], "r"); //对应用户输出
FILE * fin = fopen(argv[3], "r"); //对应1.in

long long a, b;
double c;
while (fscanf(fin, "%lld %lld", &a, &b) == 2)
{
if (fscanf(fusr, "%lf", &c) != 1) // 用户输出不是一个浮点数
{
puts("WA");
return 0;
}
if (!(c + 1e-8 >= a && c - 1e-8 <= b)) // 用户输出有误
{
puts("WA");
return 0;
}
}
puts("AC");
return 0;
}

说明:不保证上面写的程序没有任何问题,因为题目也不是我出的。

tc模式

tc模式就是用户的代码加上出题人的代码一起去做这个题。出题人的代码就是”tc.cpp”或”tc.hpp”等。上传这个文件即可。
“tc.cpp”是跟在用户的代码的后面。
Problem 1317的”tc.cpp”示例:

1
2
3
4
int main()
{
cout << "Hello,world!" << endl;
}

回到开头