多解需要SPJ
入门:
题目:输出 Hello, World!,大小写不限。
比赛目录如下:
![](https://img-blog.csdnimg.cn/img_convert/056647a63518e2224ee160bd85333a2c.png)
![](https://img-blog.csdnimg.cn/img_convert/94b14da6dc840e682fedcedbb7a58df6.png)
![](https://img-blog.csdnimg.cn/img_convert/b468079fd822e87d05cf2b3a46fad941.png)
标准输入输出数据如下:
string1.in(空文件,里面没有任何内容)
string1.ans
Hello, World!
用户程序(string.cpp)如下:
#include <bits/stdc++.h>
using namespace std;
int main(){
freopen("string.in","r",stdin);
freopen("string.out","w",stdout);
printf("HellO, World!");
return 0;
}
SPJ代码(chk.cpp)如下:
#include <bits/stdc++.h>
using namespace std;
int main(int argc,char *argv[]){
FILE * f_in=fopen(argv[1],"r");//标准输入
FILE * f_out=fopen(argv[2],"r");//用户输入
FILE * f_std=fopen(argv[3],"r");//标准输出
int score=atoi(argv[4]);//单个测试点分值
FILE * f_score=fopen(argv[5],"w");//得分文件
FILE * f_report=fopen(argv[6],"w");//报告文件
char s1[100],s2[100];
fscanf(f_out,"%s",s1);
fscanf(f_std,"%s",s2);
bool ok = true;
if (strlen(s1) != strlen(s2)) {
fprintf(f_report,"Output length differs.");
ok = false;
} else {
for (int i = 0; i < strlen(s1); i++) {
if (tolower(s1[i]) != tolower(s2[i])) {
fprintf(f_report,"%s%d%s%c%s%c%s","The ",i + 1,"-th character differs. Expected '",s2[i],"'; got '",s1[i],"'.");
ok = false;
}
}
}
if (ok) {
fprintf(f_report,"OK!");
}
fprintf(f_score,"%d",(ok ? score : 0));
fclose(f_in);
fclose(f_out);
fclose(f_std);
fclose(f_score);
fclose(f_report);
return 0;
}
未加SPJ,测评如下:
![](https://img-blog.csdnimg.cn/img_convert/389a6504533ffbb4833c28379a45e710.png)
![](https://img-blog.csdnimg.cn/img_convert/ec8a0f0e3a7726c8f6d80d49fdbd800c.png)
加SPJ(将chk.cpp编译后的chk.exe文件放于spj3\data\string\目录中,详见本文开始部分的比赛目录),测评如下:
![](https://img-blog.csdnimg.cn/img_convert/820381fc18991e612f9b45557222b4f8.png)
![](https://img-blog.csdnimg.cn/img_convert/7da2bd3beac3e4cbae6fc68161e32a2b.png)
Lemon LemonLime 中 SPJ Special Judge 使用的本质是什么?那么,我们就抛开Lemon LemonLime测评软件,进行研究。
![](https://img-blog.csdnimg.cn/img_convert/7d8a10e1d920d27da4ed9a6821e9ff8b.png)
编译string.cpp,生成string.exe,运行string.exe,生成string.out
![](https://img-blog.csdnimg.cn/img_convert/73678a39ecbb998e83838f65399b1f34.png)
编译chk.cpp,生成chk.exe,运行chk.exe
![](https://img-blog.csdnimg.cn/img_convert/af43dd5130e8319ec38d0ea9aee674b2.png)
![](https://img-blog.csdnimg.cn/img_convert/bdfaad0d0f20e7ba640e89721edf443f.png)
解释如下:
argv[1] 对应 string1.in
argv[2] 对应 string.out
argv[3] 对应 string1.ans
argv[4] 对应 100
argv[5] 对应 score.b
argv[6] 对应 report.b
![](https://img-blog.csdnimg.cn/img_convert/4ee478a9fc8be5a34997a1f8f85887a9.png)