-
Notifications
You must be signed in to change notification settings - Fork 0
/
time.js
54 lines (40 loc) · 1.47 KB
/
time.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const fs = require('fs');
const contests = require('./contests.json');
const users = require('./users.json');
function processUsers(contests, users) {
const results = [];
users.forEach(user => {
let noOfSkipped = 0;
const userResult = {
userID: user.userID,
noOfSkipped: 0,
contests: []
};
user.skippedContests.forEach(skippedContest => {
const contest = contests.find(c => c.contestId === skippedContest.contestId);
if (contest) {
const contestEndTime = contest.startTime + contest.duration;
let cheated = true;
console.log("submissionTime","contestStartTime","contestEndTime")
for (const submission of skippedContest.submissions) {
console.log(submission.time, contest.startTime, contestEndTime)
if ((submission.verdict === "OK" || submission.verdict === "PARTIAL") && (submission.time <= contestEndTime)) {
cheated = false;
break;
}
}
if (!cheated) noOfSkipped++;
userResult.contests.push({ contestId: skippedContest.contestId, cheated });
}
});
userResult.noOfNonCheated = noOfSkipped;
userResult.noOfCheated = user.skippedContests.length - noOfSkipped;
results.push(userResult);
});
return results;
}
const results = processUsers(contests, users);
fs.writeFile('results.json', JSON.stringify(results, null, 2), (err) => {
if (err) throw err;
console.log('Results saved to results.json');
});