Cena以及Lemon SpecialJudge的姿势
这能算是普及?只是自己留一个存档.
有需要的就来自己脑补吧.
UPD:留一个lemon的对应参数说明:
Special Judge参数传送说明:
argv[1]: 标准输入文件
argv[2]: 选手输出文件
argv[3]: 标准输出文件
argv[4]: 本测试点满分
argv[5]: 分数输出文件(必须创建),仅一行,包含一个非负整数,表示得分。
argv[6]: 额外信息文件(可以不创建)
#include <cstdio> #include <cstring> #include <cstdlib> FILE *fscore, *freport, *fstd, *fin, *fout; inline void getScore(int x) { fprintf(fscore, "%d", x); } char s[2010], output[2010], tmp[1000000], *o = tmp; inline int Judge() { fscanf(fin, "%s", s); int len = strlen(s); fscanf(fout, "%s", output); int len_out = strlen(output); int std_len; fscanf(fstd, "%d", &std_len); if (len_out != std_len) return 1; register int i, j, k, p, q; for(i = 0; i < len_out; ++i) if (output[i] != '$' && output[i] != '*' && !(output[i] >= 'a' && output[i] <= 'z')) return 2; if (output[len_out - 1] != '$') return 2; for(i = 0; i < len_out; ) { if (!(output[i] >= 'a' && output[i] <= 'z')) return 2; for(j = i; output[j] != '$'; ++j); for(k = i; output[k] != '*' && output[k] != '$'; ++k); for(p = k; p <= j; ++p) if (output[p] != '$' && output[p] != '*') return 2; for(p = 1; p <= j - k + 1; ++p) for(q = i; q < k; ++q) *o++ = output[q]; i = j + 1; } int outputlen = o - tmp; if (outputlen != len) return 3; for(i = 0; i < len; ++i) if (tmp[i] != s[i]) return 3; return 0; } int main(int argc, char *argv[]) { fscore = fopen("score.log", "w"); freport = fopen("report.log", "w"); fstd = fopen(argv[2], "r"); //测试点标准输出文件 fin = fopen("compress.in", "r"); fout = fopen("compress.out", "r"); //用户输入、输出文件 if (!fout) { getScore(0); fprintf(freport, "Empty File!"); } else { int res = Judge(); if (res == 0) getScore(10), fprintf(freport, "Right Output!"); else if (res == 1) getScore(0), fprintf(freport, "Wrong Length!"); else if (res == 2) getScore(0), fprintf(freport, "Wrong Format!"); else if (res == 3) getScore(0), fprintf(freport, "Wrong Change!"); } fclose(fscore); fclose(freport); return 0; }
#include<bits/stdc++.h> FILE *fscore,*freport,*fstd,*fin,*fout; inline void GetScore(int d){ fprintf(fscore,"%d",d); } inline void End(){ fclose(fscore),fclose(freport); } int d[1010],x[1000010],y[1000010]; inline void work(int a,int b){ d[b]-=d[a],d[a]*=2; } int main(int argc,char*argv[]){ fscore=fopen(argv[5],"w");//得分文件 freport=fopen(argv[6],"w");//报告文件 fstd=fopen(argv[3],"r");//标准输出 fin=fopen(argv[1],"r");//标准输入 fout=fopen(argv[2],"r");//用户输出 int stdans;fscanf(fstd,"%d",&stdans); int yourans; if(fscanf(fout,"%d",&yourans)==0){ fprintf(freport,"No output."); GetScore(0); End();return 0; } if(stdans==-1){ if(yourans!=-1){ fprintf(freport,"No solution but you output an ans"); GetScore(0); End();return 0; } else{ fprintf(freport,"OK"),GetScore(10); End();return 0; } } else{ if(yourans==-1){ fprintf(freport,"There exists some solutions but you output no ans"); GetScore(0); End();return 0; } else if(yourans<0){ fprintf(freport,"Wrong:T<0"); GetScore(0); End();return 0; } else if(yourans>1000000){ fprintf(freport,"Too many operates"); GetScore(0); End();return 0; } else{ int n;register int i; fscanf(fin,"%d",&n); for(i=1;i<=n;++i)fscanf(fin,"%d",&d[i]); for(i=1;i<=yourans;++i){ if(fscanf(fout,"%d%d",&x[i],&y[i])!=2){ fprintf(freport,"output Not enough"); GetScore(0); End();return 0; } } int cash; if(fscanf(fout,"%d",&cash)==1){ fprintf(freport,"Too many output"); GetScore(0); End();return 0; } for(i=1;i<=yourans;++i){ if(x[i]==y[i]){ fprintf(freport,"Wrong at Line%d:x=y",i+1); GetScore(0); End();return 0; } else if(d[x[i]]>d[y[i]]){ fprintf(freport,"Wrong at Line%d:a[x]>a[y]",i+1); GetScore(0); End();return 0; } else work(x[i],y[i]); } int last=0; for(i=1;i<=n;++i)if(d[i]>0)++last; if(last==2){ fprintf(freport,"OK"),GetScore(10); End();return 0; } else{ fprintf(freport,"yourlast=%d,and it's larger then 2",last),GetScore(0); End();return 0; } } } return 0; }