fix: match scenario 2601 monthly seed progression

This commit is contained in:
2026-08-03 18:56:23 +00:00
parent 2f17584075
commit 58b9a230a7
92 changed files with 3696 additions and 587 deletions
+10 -4
View File
@@ -27,16 +27,20 @@ export const getCityDistance = (map: MapDefinition, startCityId: number, endCity
return Infinity;
};
export const searchDistance = (map: MapDefinition, startCityId: number, range: number): Record<number, number> => {
const result: Record<number, number> = {};
export const searchDistanceEntries = (
map: MapDefinition,
startCityId: number,
range: number
): Array<[cityId: number, distance: number]> => {
const result: Array<[number, number]> = [];
const visited = new Set<number>();
const queue: [number, number][] = [[startCityId, 0]];
visited.add(startCityId);
result[startCityId] = 0;
while (queue.length > 0) {
const [currentId, dist] = queue.shift()!;
result.push([currentId, dist]);
if (dist >= range) continue;
@@ -47,7 +51,6 @@ export const searchDistance = (map: MapDefinition, startCityId: number, range: n
if (!visited.has(neighborId)) {
visited.add(neighborId);
const newDist = dist + 1;
result[neighborId] = newDist;
queue.push([neighborId, newDist]);
}
}
@@ -55,3 +58,6 @@ export const searchDistance = (map: MapDefinition, startCityId: number, range: n
return result;
};
export const searchDistance = (map: MapDefinition, startCityId: number, range: number): Record<number, number> =>
Object.fromEntries(searchDistanceEntries(map, startCityId, range));