mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: better testdata match experience (#620)
Co-authored-by: undefined <i@undefined.moe>
This commit is contained in:
1 parent
f45a509c05
commit
da9676119b
1 file changed
+23
-12
@@ -235,21 +235,21 @@ interface MatchRule {
|
||||
output: ((a: RegExpExecArray) => string)[];
|
||||
id: (a: RegExpExecArray) => number;
|
||||
subtask: (a: RegExpExecArray) => number;
|
||||
preferredScorerType: 'min' | 'max' | 'sum';
|
||||
preferredScorerType: (a: RegExpExecArray) => 'min' | 'max' | 'sum';
|
||||
}
|
||||
|
||||
const SubtaskMatcher: MatchRule[] = [
|
||||
{
|
||||
regex: /^([^\d]*(?:\d+[a-zA-Z]+)*)(\d+)\.(in|txt)$/,
|
||||
regex: /^(([A-Za-z0-9]*?)(?:(\d*)[-_])?(\d+))\.in$/,
|
||||
output: [
|
||||
(a) => `${a[1] + a[2]}.out`,
|
||||
(a) => `${a[1] + a[2]}.ans`,
|
||||
(a) => `${a[1] + a[2]}.out`.replace(/input/g, 'output'),
|
||||
(a) => (a[1].includes('input') ? `${a[1] + a[2]}.txt`.replace(/input/g, 'output') : null),
|
||||
(a) => `${a[1]}.out`,
|
||||
(a) => `${a[1]}.ans`,
|
||||
(a) => `${a[1]}.out`.replace(/input/g, 'output'),
|
||||
(a) => (a[1].includes('input') ? `${a[1]}.txt`.replace(/input/g, 'output') : null),
|
||||
],
|
||||
id: (a) => +a[2],
|
||||
subtask: () => 1,
|
||||
preferredScorerType: 'sum',
|
||||
id: (a) => +a[4],
|
||||
subtask: (a) => +(a[3] || 1),
|
||||
preferredScorerType: (a) => (a[3] ? 'min' : 'sum'),
|
||||
},
|
||||
{
|
||||
regex: /^([^\d]*)\.in(\d+)$/,
|
||||
@@ -259,7 +259,7 @@ const SubtaskMatcher: MatchRule[] = [
|
||||
],
|
||||
id: (a) => +a[2],
|
||||
subtask: () => 1,
|
||||
preferredScorerType: 'sum',
|
||||
preferredScorerType: () => 'sum',
|
||||
},
|
||||
{
|
||||
regex: /^([^\d]*)([0-9]+)([-_])([0-9]+)\.in$/,
|
||||
@@ -269,7 +269,17 @@ const SubtaskMatcher: MatchRule[] = [
|
||||
],
|
||||
id: (a) => +a[4],
|
||||
subtask: (a) => +a[2],
|
||||
preferredScorerType: 'min',
|
||||
preferredScorerType: () => 'min',
|
||||
},
|
||||
{
|
||||
regex: /^(([0-9]+)[-_](?:.*))\.in$/,
|
||||
output: [
|
||||
(a) => `${a[1]}.out`,
|
||||
(a) => `${a[1]}.ans`,
|
||||
],
|
||||
id: (a) => +a[2],
|
||||
subtask: () => 1,
|
||||
preferredScorerType: () => 'sum',
|
||||
},
|
||||
];
|
||||
|
||||
@@ -309,6 +319,7 @@ export function readSubtasksFromFiles(files: string[], config) {
|
||||
if (!data) continue;
|
||||
const sid = rule.subtask(data);
|
||||
const c = { input: file, output: '', id: rule.id(data) };
|
||||
const type = rule.preferredScorerType(data);
|
||||
for (const func of rule.output) {
|
||||
if (config.noOutputFile) c.output = '/dev/null';
|
||||
else c.output = func(data);
|
||||
@@ -317,7 +328,7 @@ export function readSubtasksFromFiles(files: string[], config) {
|
||||
subtask[sid] = {
|
||||
time: config.time,
|
||||
memory: config.memory,
|
||||
type: rule.preferredScorerType,
|
||||
type,
|
||||
cases: [c],
|
||||
};
|
||||
} else if (!subtask[sid].cases) subtask[sid].cases = [c];
|
||||
|
||||
Reference in new issue
Block a user