Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CMS support for PR #351 #360

Merged
merged 6 commits into from
Dec 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions templates/problem/data.html
Original file line number Diff line number Diff line change
Expand Up @@ -427,24 +427,27 @@
console.log("Filling testcase...");
var inFiles = [], outFiles = [];

// regex index 0 = Themis, 1 = Polygon, 2 = DMOJ
var format = ["Themis", "CMS", "Polygon", "DMOJ"];

var in_re = [
new RegExp(/^(.+\.inp|.+\.in|inp|in)$/),
new RegExp(/^input.(.+\d+)$/),
new RegExp(/^(.+\d+)$/),
new RegExp(/^(?=.*?\.in|in).*?(?:(?:^|\W)(?<batch>\d+)[^\d\s]+)?(?<case>\d+)[^\d\s]*$/),
];

var out_re = [
new RegExp(/^(.+\.out|.+\.ok|.+\.ans|out|ok|ans)$/),
new RegExp(/^output.(.+\d+)$/),
new RegExp(/^(.+\d+\.a)$/),
new RegExp(/^(?=.*?\.out|out).*?(?:(?:^|\W)(?<batch>\d+)[^\d\s]+)?(?<case>\d+)[^\d\s]*$/),
];

var test_type = -1;

for (var i = 0; i < window.valid_files.length; i++) {
var tested_filename = window.valid_files[i].toLowerCase().replace('/', '.');
var lastSlashIdx = window.valid_files[i].lastIndexOf('/');
var tested_filename = window.valid_files[i].slice(lastSlashIdx + 1).toLowerCase();

for (var type = 0; type < 3; type++) {
if (in_re[type].test(tested_filename)) {
Expand All @@ -455,6 +458,8 @@

test_type = type;
inFiles.push(window.valid_files[i]);
console.log(`Found input file: ${window.valid_files[i]}`);
console.log(`type: ${format[type]}`);
break;
}

Expand All @@ -466,6 +471,8 @@

test_type = type;
outFiles.push(window.valid_files[i]);
console.log(`Found output file: ${window.valid_files[i]}`);
console.log(`type: ${format[type]}`);
break;
}
}
Expand Down
Loading