/* eslint-disable no-await-in-loop */ import { ProblemModel, RecordModel, sleep, STATUS, yaml, } from 'hydrooj'; // These tests are from https://loj.ac/d/425 const head = '#include\nusing namespace std;\n'; const TESTS = { ' 1 ': ` int main(){ int a=1000000000,b=1; while(a)b<<=1,a--; printf("%d\\n",b);`, ' 2 ': ` const int MX=50000000; int p[MX],m[MX],pc; int main(){ for(int i=2;iG[j][i]+G[i][k])G[j][k]=G[j][i]+G[i][k]; int ans=0; for(int i=0;i #include const int MX=1000000; int sed=0; inline int rand(){return sed=(sed*sed*73+sed*233+19260817);} int main(){ setS; for(int i=0;i::iterator it=S.begin();it!=S.end();it++)ans^=*it; printf("%d\\n",ans);`, // skipping test 5 by default as it contains a lot of ram ' 5 ': ` const int MX=20000000; int *it[MX]; int main(){ for(int i=0;i { if (key === ' 5 ' && !args.enable5) return; const id = await RecordModel.add('system', docId, 1, 'cc.cc14o2', `// TEST ${key}\n${head}${TESTS[key]}\nreturn 0;}`, true); while ([ STATUS.STATUS_WAITING, STATUS.STATUS_JUDGING, STATUS.STATUS_FETCHED, STATUS.STATUS_COMPILING, ].includes((await RecordModel.get('system', id))?.status)) { await sleep(500); } const result = await RecordModel.get('system', id); if (result.status !== STATUS.STATUS_ACCEPTED && result.status !== STATUS.STATUS_WRONG_ANSWER) { report({ message: `Test ${key} failed (${id}) ${result.status}` }); } else { results[key] = result.testCases.map((i) => i.time); } })); const formatL = (t: number, width = 4) => Math.floor(t).toString().padEnd(width); const formatR = (t: number, width = 4) => Math.floor(t).toString().padStart(width); for (const key of Object.keys(TESTS)) { const timeArr = results[key]; if (!timeArr) continue; const avgTime = Math.sum(...timeArr) / 20; await report({ message: [ `-------Test ${key}-------`, ` Avg: ${formatL(avgTime)} D: ${formatR(Math.sum(...timeArr.map((i) => (i - avgTime) ** 2)) / 20, 5)} `, ` Max: ${formatL(Math.max(...timeArr))} Min: ${formatR(Math.min(...timeArr))} `, ].join('\n'), }); } return true; }