pc^2的special judge需要自己寫程式碼去檢查兩份檔案,並且輸出judge結果
以下以C/C++為範例講解
因為他是用參數輸入,所以需要int main(int argc, char *args[])
然後他輸入的參數依序有四個
{:infile}: 題目測資的輸入檔案
{:outfile}:參賽者的輸出檔案
{:ansfile}:題目測資的輸出檔案
{:resfile} :驗證程式的輸出檔案
special judge要如何寫就不細講了,基本上就是比較參賽者的output以及judge answer,IO要很小心,如果參賽者亂輸出你的驗證程式沒吃好的話會當掉
關於輸出檔的部分,要輸出
<?xml version="1.0"?>
<result outcome="{:result}" security="{:resfile}"/>
{:result}是judge結果,他的文字要跟Judgements裡面的一樣(例如 "Yes","No - Wrong Answer"),否則pc^2會說他未定義
然後{:resfile}就是輸出檔案的名稱
以下範例code
int main(int argc, char *args[]){
if(argc != 5){
puts("INPUT ERROR");
return -1;
}
char *inFile = args[1];
char *outFile = args[2];
char *ansFile = args[3];
char *resFile = args[4];
FILE *in = fopen(inFile, "r");
FILE *out = fopen(outFile, "r");
FILE *ans = fopen(ansFile, "r");
FILE *res = fopen(resFile, "w");
if(!in || !out || !ans){
puts("INPUT ERROR");
return -1;
}
/////////////////////////////////////////////
中間是驗證答案的程式碼
//////////////////////////////////////////////
fprintf(res, "<?xml version=\"1.0\"?>\n");
fprintf(res, "<result outcome=\"%s\" security=\"%s\"/>\n", (答案是對的)? "Yes": "No - Wrong Answer", args[4]);
fclose(in);
fclose(out);
fclose(ans);
fclose(res);
}