The possibility to edit master judge appeared comparatively recently. Now its possible to adjust problem more flexible, but in most cases, standard default Master Judge (1000. Generic masterjudge) will do. You can find code for this default master judge below:
1000. Generic masterjudge
#include <spoj.h>
#include <cstdio>
int main()
{
spoj_init();
int test, sig, mem, memMax=0, tc=0;
double score, scoreAll=0, time, timeAll=0;
char status[4];
while (fscanf(spoj_p_in, "%d %3s %lf %d %lf %d\n", &test, status, &score, &sig, &time, &mem)==6)
{
fprintf(spoj_p_info, "test %d - %s (score=%lf, sig=%d, time=%lf, mem=%d)\n", test, status, score, sig, time, mem);
memMax >?= mem;
scoreAll += score;
timeAll += time;
if (status[0]!='A')
{
fprintf(spoj_score, "%s 0 %d %lf %d\n", status, sig, timeAll, memMax);
return 0;
}
tc++;
}
fprintf(spoj_score, "AC %lf 0 %lf %d\n", scoreAll/tc, timeAll, memMax);
}
The default judge works as follows:
- if at leats one test didn't give AC (it was WA, TLE, ..), the whole solution is ranked this way
- otherwise, the result is AC with score being the average score for all datasets, memory usage is the maximum of memory usages and the time is a sum of all times
Note that if a problem has only one dataset, it's fine - the result is just copied by this masterjudge.
It's nesessary to modify this judge if you want to make the scoring more complicated in some way. Some ideas:
- don't fail a solution which didn't pass some of the tests, but only adjust the score accordingly; AC for one dataset = one point for the final score
- include running times in the final score
- output some details about results for each dataset for the user (for example, he could be able to click on his "5 points" and see he had WA for test 3 and TLE for tests 6-10, when there are 10 tests total)