古詩詞大全網 - 成語用法 - cena評測系統的自定義校驗器(Special Judge)

cena評測系統的自定義校驗器(Special Judge)

Cena評測軟件提供了使用自定義校驗器進行評分的功能。可以使用C++或者Pascal進行編寫,其中Pascal需要載入軟件所提供的運行庫。

C++自定義校驗器(SPJ)參考代碼: #include<iostream>#include<cstdio>#defineDatanameName//評測題目的文件名(不含後綴)usingnamespacestd;FILE*fscore,*freport,*fstd,*fin,*fout;intJudge(){intre=0;//用於返回得分//在此補充評測代碼,下面為NOI2011Day1T2智能車比賽的SPJ代碼doublex,y,dif;fscanf(fstd,%lf,&x);fscanf(fout,%lf,&y);dif=(x>y)?(x-y):(y-x);re=dif<=0.000001;re*=10;fprintf(freport,Std:%.10lf\nYourAns:%.10lf\nDiffer:%.10lf\n,x,y,dif);//返回評測後對話框顯示內容,可無內容returnre;}intmain(intargc,char*argv[]){fscore=fopen(score.log,w);//打開得分文件freport=fopen(report.log,w);//打開報告文件fstd=fopen(argv[2],r);//打開測試點標準輸出文件intscore=atoi(argv[1]);//取得測試點的分數fin=fopen(DataName.in,r);//原始數據fout=fopen(Dataname.out,r);//用戶輸出fprintf(fscore,%d,Judge());//返回分數fclose(fscore);//關閉得分文件fclose(freport);//關閉報告文件return0;}