Skip to content

Commit cf16c09

Browse files
committed
fix solutions
1 parent c05e0dc commit cf16c09

3 files changed

Lines changed: 29 additions & 4 deletions

File tree

tests/501-1000/834. sum-of-distances-in-tree/manifest.yaml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,35 @@ limits:
3030
memory_mb: 512
3131
oracle:
3232
python3:
33-
call: "Checker().check({result})"
33+
call: "Checker().check(n, edges, {result})"
3434
checker: |
35+
from collections import deque
36+
3537
class Checker:
36-
def check(self, result):
37-
return isinstance(result, list) and all(isinstance(value, int) for value in result)
38+
def check(self, n, edges, result):
39+
if not isinstance(result, list) or len(result) != n:
40+
return False
41+
if any(type(value) is not int for value in result):
42+
return False
43+
44+
graph = [[] for _ in range(n)]
45+
for left, right in edges:
46+
graph[left].append(right)
47+
graph[right].append(left)
48+
49+
expected = []
50+
for start in range(n):
51+
distance = [-1] * n
52+
distance[start] = 0
53+
queue = deque([start])
54+
while queue:
55+
node = queue.popleft()
56+
for neighbor in graph[node]:
57+
if distance[neighbor] == -1:
58+
distance[neighbor] = distance[node] + 1
59+
queue.append(neighbor)
60+
expected.append(sum(distance))
61+
return result == expected
3862
seed: 834
3963
tests:
4064
- name: n1

tests/501-1000/834. sum-of-distances-in-tree/sol.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
class Solution {
2+
@SuppressWarnings("unchecked")
23
public int[] sumOfDistancesInTree(int n, int[][] edges) {
34
List<Integer>[] adj = new ArrayList[n];
45
for (int i = 0; i < n; i++) adj[i] = new ArrayList<>();

tests/501-1000/870. advantage-shuffle/manifest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ entry:
2626
judge:
2727
type: exact
2828
limits:
29-
time_ms: 200
29+
time_ms: 1500
3030
memory_mb: 300
3131
oracle:
3232
python3:

0 commit comments

Comments
 (0)