diff --git a/tests/1001-1500/1001. grid-illumination/manifest.yaml b/tests/1001-1500/1001. grid-illumination/manifest.yaml new file mode 100644 index 00000000..91d36e5d --- /dev/null +++ b/tests/1001-1500/1001. grid-illumination/manifest.yaml @@ -0,0 +1,1040 @@ +entry: + id: 1001 + title: grid-illumination + params: + n: + type: int + lamps: + type: array + items: + type: array + items: + type: int + queries: + type: array + items: + type: array + items: + type: int + call: + cpp: Solution().gridIllumination({n}, {lamps}, {queries}) + rust: Solution::grid_illumination({n}, {lamps}, {queries}) + python3: Solution().gridIllumination({n}, {lamps}, {queries}) + python2: Solution().gridIllumination({n}, {lamps}, {queries}) + ruby: grid_illumination({n}, {lamps}, {queries}) + java: new Solution().gridIllumination({n}, {lamps}, {queries}) + csharp: new Solution().GridIllumination({n}, {lamps}, {queries}) + kotlin: Solution().gridIllumination({n}, {lamps}, {queries}) + go: gridIllumination({n}, {lamps}, {queries}) + dart: Solution().gridIllumination({n}, {lamps}, {queries}) + swift: Solution().gridIllumination({n}, {lamps}, {queries}) + typescript: gridIllumination({n}, {lamps}, {queries}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 1001 +tests: + - name: case_1 + in: + n: 7 + lamps: + - - 0 + - 6 + - - 1 + - 0 + - - 6 + - 2 + - - 3 + - 3 + queries: + - - 5 + - 4 + - - 4 + - 1 + - - 3 + - 2 + - - 2 + - 5 + - - 6 + - 4 + - - 0 + - 3 + - - 1 + - 2 + - - 2 + - 1 + out: + - 1 + - 0 + - 1 + - 0 + - 1 + - 1 + - 1 + - 1 + - name: case_2 + in: + n: 2 + lamps: + - - 1 + - 1 + - - 1 + - 1 + - - 1 + - 1 + - - 1 + - 0 + - - 1 + - 0 + - - 1 + - 0 + queries: + - - 1 + - 0 + - - 0 + - 0 + out: + - 1 + - 0 + - name: case_3 + in: + n: 7 + lamps: [] + queries: + - - 6 + - 0 + - - 5 + - 3 + - - 3 + - 5 + - - 5 + - 1 + - - 2 + - 0 + - - 4 + - 2 + - - 5 + - 5 + out: + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - name: case_4 + in: + n: 2 + lamps: [] + queries: + - - 1 + - 1 + out: + - 0 + - name: case_5 + in: + n: 4 + lamps: + - - 1 + - 0 + - - 3 + - 0 + - - 2 + - 2 + - - 3 + - 0 + - - 0 + - 0 + - - 2 + - 1 + queries: + - - 1 + - 3 + - - 2 + - 3 + - - 3 + - 0 + - - 2 + - 2 + - - 1 + - 0 + - - 3 + - 0 + - - 3 + - 1 + out: + - 1 + - 1 + - 1 + - 1 + - 1 + - 0 + - 0 + - name: case_6 + in: + n: 2 + lamps: + - - 0 + - 1 + - - 0 + - 0 + - - 0 + - 0 + - - 1 + - 1 + - - 0 + - 0 + queries: + - - 1 + - 0 + - - 1 + - 1 + - - 1 + - 0 + out: + - 1 + - 0 + - 0 + - name: case_7 + in: + n: 3 + lamps: + - - 0 + - 2 + - - 1 + - 1 + queries: + - - 0 + - 1 + - - 0 + - 2 + - - 2 + - 0 + - - 1 + - 1 + out: + - 1 + - 0 + - 0 + - 0 + - name: case_8 + in: + n: 7 + lamps: + - - 3 + - 5 + queries: + - - 3 + - 6 + - - 3 + - 1 + - - 2 + - 0 + out: + - 1 + - 0 + - 0 + - name: case_9 + in: + n: 2 + lamps: + - - 1 + - 1 + - - 0 + - 1 + - - 1 + - 1 + queries: + - - 1 + - 0 + - - 1 + - 1 + - - 0 + - 1 + - - 1 + - 1 + - - 0 + - 0 + - - 0 + - 0 + - - 1 + - 0 + - - 1 + - 1 + out: + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - name: case_10 + in: + n: 7 + lamps: + - - 4 + - 6 + - - 5 + - 6 + - - 1 + - 1 + queries: + - - 6 + - 6 + - - 6 + - 2 + - - 5 + - 0 + out: + - 1 + - 0 + - 0 + - name: case_11 + in: + n: 5 + lamps: + - - 1 + - 3 + - - 3 + - 3 + - - 1 + - 4 + - - 2 + - 4 + queries: + - - 4 + - 1 + - - 1 + - 1 + - - 1 + - 3 + out: + - 1 + - 1 + - 1 + - name: case_12 + in: + n: 4 + lamps: + - - 2 + - 3 + - - 1 + - 3 + - - 0 + - 2 + - - 0 + - 0 + - - 3 + - 2 + - - 1 + - 3 + - - 3 + - 2 + queries: + - - 2 + - 2 + - - 1 + - 2 + out: + - 1 + - 1 + - name: case_13 + in: + n: 7 + lamps: + - - 1 + - 4 + - - 6 + - 3 + - - 4 + - 0 + - - 3 + - 2 + - - 4 + - 1 + queries: + - - 4 + - 1 + - - 3 + - 2 + - - 1 + - 6 + out: + - 1 + - 1 + - 1 + - name: case_14 + in: + n: 1 + lamps: + - - 0 + - 0 + - - 0 + - 0 + - - 0 + - 0 + - - 0 + - 0 + - - 0 + - 0 + - - 0 + - 0 + - - 0 + - 0 + - - 0 + - 0 + queries: + - - 0 + - 0 + - - 0 + - 0 + - - 0 + - 0 + - - 0 + - 0 + out: + - 1 + - 0 + - 0 + - 0 + - name: case_15 + in: + n: 1 + lamps: + - - 0 + - 0 + - - 0 + - 0 + queries: + - - 0 + - 0 + - - 0 + - 0 + - - 0 + - 0 + - - 0 + - 0 + - - 0 + - 0 + - - 0 + - 0 + - - 0 + - 0 + - - 0 + - 0 + out: + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - name: case_16 + in: + n: 5 + lamps: + - - 2 + - 2 + - - 2 + - 2 + - - 4 + - 4 + - - 4 + - 0 + - - 4 + - 2 + - - 3 + - 2 + - - 3 + - 3 + queries: + - - 3 + - 1 + - - 4 + - 1 + out: + - 1 + - 1 + - name: case_17 + in: + n: 7 + lamps: + - - 2 + - 4 + - - 2 + - 2 + - - 6 + - 0 + - - 0 + - 0 + queries: + - - 5 + - 3 + - - 4 + - 6 + - - 6 + - 0 + out: + - 0 + - 1 + - 1 + - name: case_18 + in: + n: 2 + lamps: + - - 0 + - 0 + - - 0 + - 0 + - - 1 + - 1 + - - 0 + - 1 + - - 1 + - 0 + - - 0 + - 1 + - - 1 + - 0 + - - 1 + - 0 + queries: + - - 0 + - 1 + - - 0 + - 0 + - - 0 + - 0 + - - 0 + - 0 + out: + - 1 + - 0 + - 0 + - 0 + - name: case_19 + in: + n: 7 + lamps: + - - 4 + - 0 + queries: + - - 2 + - 4 + - - 5 + - 2 + out: + - 0 + - 0 + - name: case_20 + in: + n: 7 + lamps: + - - 6 + - 6 + - - 1 + - 4 + queries: + - - 4 + - 1 + - - 3 + - 5 + - - 1 + - 0 + - - 3 + - 3 + - - 0 + - 4 + - - 3 + - 4 + - - 3 + - 6 + - - 2 + - 0 + out: + - 1 + - 0 + - 1 + - 1 + - 1 + - 0 + - 1 + - 0 + - name: case_21 + in: + n: 3 + lamps: [] + queries: + - - 1 + - 2 + - - 0 + - 0 + - - 2 + - 2 + out: + - 0 + - 0 + - 0 + - name: case_22 + in: + n: 7 + lamps: + - - 2 + - 2 + - - 2 + - 6 + - - 5 + - 4 + - - 6 + - 4 + - - 0 + - 4 + - - 4 + - 6 + - - 2 + - 3 + queries: + - - 3 + - 0 + - - 3 + - 6 + - - 5 + - 5 + - - 5 + - 4 + - - 4 + - 2 + - - 4 + - 3 + - - 6 + - 6 + - - 6 + - 0 + out: + - 0 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 0 + - name: case_23 + in: + n: 8 + lamps: + - - 5 + - 3 + - - 0 + - 4 + - - 2 + - 7 + - - 1 + - 2 + queries: + - - 4 + - 6 + - - 6 + - 0 + - - 0 + - 6 + - - 4 + - 0 + out: + - 0 + - 0 + - 1 + - 1 + - name: case_24 + in: + n: 1 + lamps: + - - 0 + - 0 + queries: + - - 0 + - 0 + - - 0 + - 0 + - - 0 + - 0 + - - 0 + - 0 + - - 0 + - 0 + out: + - 1 + - 0 + - 0 + - 0 + - 0 + - name: case_25 + in: + n: 4 + lamps: + - - 0 + - 0 + - - 1 + - 2 + - - 1 + - 0 + - - 3 + - 3 + queries: + - - 2 + - 2 + - - 0 + - 3 + - - 2 + - 0 + - - 0 + - 0 + - - 3 + - 3 + - - 3 + - 0 + - - 2 + - 2 + out: + - 1 + - 1 + - 1 + - 1 + - 0 + - 0 + - 0 + - name: case_26 + in: + n: 8 + lamps: + - - 1 + - 3 + - - 4 + - 5 + - - 3 + - 4 + - - 4 + - 6 + - - 1 + - 5 + - - 0 + - 2 + queries: + - - 6 + - 4 + - - 3 + - 7 + - - 6 + - 4 + - - 1 + - 2 + - - 4 + - 6 + out: + - 1 + - 1 + - 1 + - 1 + - 1 + - name: case_27 + in: + n: 3 + lamps: [] + queries: + - - 1 + - 2 + - - 1 + - 2 + - - 1 + - 1 + - - 0 + - 0 + out: + - 0 + - 0 + - 0 + - 0 + - name: case_28 + in: + n: 7 + lamps: + - - 0 + - 3 + - - 5 + - 1 + - - 2 + - 0 + - - 1 + - 0 + queries: + - - 3 + - 3 + - - 1 + - 0 + - - 2 + - 5 + - - 3 + - 3 + out: + - 1 + - 1 + - 1 + - 1 + - name: case_29 + in: + n: 2 + lamps: + - - 1 + - 0 + - - 0 + - 0 + - - 1 + - 1 + - - 1 + - 0 + - - 1 + - 1 + - - 0 + - 0 + - - 1 + - 1 + - - 0 + - 1 + queries: + - - 0 + - 1 + - - 0 + - 1 + - - 1 + - 1 + - - 0 + - 1 + - - 0 + - 0 + - - 1 + - 0 + - - 0 + - 0 + out: + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - name: case_30 + in: + n: 6 + lamps: + - - 5 + - 3 + - - 2 + - 2 + - - 4 + - 2 + - - 1 + - 2 + - - 3 + - 5 + - - 0 + - 3 + queries: + - - 1 + - 4 + - - 4 + - 5 + - - 3 + - 1 + - - 0 + - 3 + - - 4 + - 1 + - - 1 + - 2 + - - 4 + - 1 + out: + - 1 + - 1 + - 1 + - 1 + - 0 + - 0 + - 0 + - name: case_31 + in: + n: 2 + lamps: + - - 0 + - 0 + - - 0 + - 1 + - - 0 + - 0 + - - 0 + - 1 + - - 1 + - 0 + queries: + - - 0 + - 0 + - - 1 + - 1 + - - 0 + - 1 + - - 1 + - 0 + - - 0 + - 0 + - - 1 + - 0 + out: + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - name: case_32 + in: + n: 5 + lamps: + - - 4 + - 3 + - - 3 + - 0 + - - 0 + - 1 + - - 4 + - 0 + - - 0 + - 1 + - - 3 + - 1 + - - 3 + - 4 + - - 1 + - 0 + queries: + - - 4 + - 4 + - - 2 + - 4 + out: + - 1 + - 0 + - name: case_33 + in: + n: 8 + lamps: + - - 1 + - 3 + - - 2 + - 6 + - - 6 + - 7 + - - 7 + - 7 + - - 0 + - 0 + queries: + - - 2 + - 7 + - - 0 + - 2 + - - 4 + - 5 + - - 7 + - 1 + - - 4 + - 1 + - - 1 + - 4 + - - 7 + - 2 + out: + - 1 + - 1 + - 1 + - 1 + - 0 + - 0 + - 1 + - name: case_34 + in: + n: 7 + lamps: + - - 4 + - 3 + - - 3 + - 5 + - - 3 + - 3 + - - 4 + - 0 + - - 5 + - 1 + - - 3 + - 1 + - - 6 + - 5 + - - 0 + - 5 + queries: + - - 5 + - 2 + - - 4 + - 5 + - - 6 + - 3 + - - 0 + - 6 + - - 3 + - 6 + - - 5 + - 1 + out: + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - name: case_35 + in: + n: 1 + lamps: + - - 0 + - 0 + - - 0 + - 0 + - - 0 + - 0 + - - 0 + - 0 + queries: + - - 0 + - 0 + - - 0 + - 0 + - - 0 + - 0 + - - 0 + - 0 + out: + - 1 + - 0 + - 0 + - 0 diff --git a/tests/1001-1500/1001. grid-illumination/sol.cpp b/tests/1001-1500/1001. grid-illumination/sol.cpp new file mode 100644 index 00000000..cd78a9f2 --- /dev/null +++ b/tests/1001-1500/1001. grid-illumination/sol.cpp @@ -0,0 +1,48 @@ +#include +#include +#include + +using namespace std; + +class Solution { +public: + vector gridIllumination(int n, vector>& lamps, vector>& queries) { + unordered_map rowCount, colCount, diag1, diag2; + unordered_set lampSet; + vector ans(queries.size()); + int dirs[9][2] = {{-1,-1}, {-1,0}, {-1,1}, {0,-1}, {0,0}, {0,1}, {1,-1}, {1,0}, {1,1}}; + + for (auto& lamp : lamps) { + int r = lamp[0], c = lamp[1]; + long long key = ((long long)r << 32) | (c & 0xFFFFFFFFLL); + if (!lampSet.count(key)) { + lampSet.insert(key); + rowCount[r]++; + colCount[c]++; + diag1[r - c]++; + diag2[r + c]++; + } + } + + for (int i = 0; i < queries.size(); i++) { + int r = queries[i][0], c = queries[i][1]; + if (rowCount[r] > 0 || colCount[c] > 0 || diag1[r - c] > 0 || diag2[r + c] > 0) { + ans[i] = 1; + for (auto& d : dirs) { + int nr = r + d[0], nc = c + d[1]; + long long key = ((long long)nr << 32) | (nc & 0xFFFFFFFFLL); + if (lampSet.count(key)) { + lampSet.erase(key); + rowCount[nr]--; + colCount[nc]--; + diag1[nr - nc]--; + diag2[nr + nc]--; + } + } + } else { + ans[i] = 0; + } + } + return ans; + } +}; diff --git a/tests/1001-1500/1001. grid-illumination/sol.cs b/tests/1001-1500/1001. grid-illumination/sol.cs new file mode 100644 index 00000000..8da8454d --- /dev/null +++ b/tests/1001-1500/1001. grid-illumination/sol.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; + +public class Solution { + public int[] GridIllumination(int n, int[][] lamps, int[][] queries) { + Dictionary rowCount = new Dictionary(); + Dictionary colCount = new Dictionary(); + Dictionary diag1 = new Dictionary(); + Dictionary diag2 = new Dictionary(); + HashSet<(int, int)> lampSet = new HashSet<(int, int)>(); + int[] ans = new int[queries.Length]; + int[][] dirs = new int[][] { + new int[] {-1,-1}, new int[] {-1,0}, new int[] {-1,1}, + new int[] {0,-1}, new int[] {0,0}, new int[] {0,1}, + new int[] {1,-1}, new int[] {1,0}, new int[] {1,1} + }; + + foreach (var lamp in lamps) { + int r = lamp[0], c = lamp[1]; + var key = (r, c); + if (!lampSet.Contains(key)) { + lampSet.Add(key); + rowCount[r] = rowCount.GetValueOrDefault(r, 0) + 1; + colCount[c] = colCount.GetValueOrDefault(c, 0) + 1; + diag1[r - c] = diag1.GetValueOrDefault(r - c, 0) + 1; + diag2[r + c] = diag2.GetValueOrDefault(r + c, 0) + 1; + } + } + + for (int i = 0; i < queries.Length; i++) { + int r = queries[i][0], c = queries[i][1]; + if (rowCount.GetValueOrDefault(r, 0) > 0 || colCount.GetValueOrDefault(c, 0) > 0 || + diag1.GetValueOrDefault(r - c, 0) > 0 || diag2.GetValueOrDefault(r + c, 0) > 0) { + ans[i] = 1; + foreach (var d in dirs) { + int nr = r + d[0], nc = c + d[1]; + var key = (nr, nc); + if (lampSet.Contains(key)) { + lampSet.Remove(key); + rowCount[nr]--; + colCount[nc]--; + diag1[nr - nc]--; + diag2[nr + nc]--; + } + } + } else { + ans[i] = 0; + } + } + return ans; + } +} diff --git a/tests/1001-1500/1001. grid-illumination/sol.dart b/tests/1001-1500/1001. grid-illumination/sol.dart new file mode 100644 index 00000000..9f38ee0f --- /dev/null +++ b/tests/1001-1500/1001. grid-illumination/sol.dart @@ -0,0 +1,51 @@ +import 'dart:collection'; + +class Solution { + List gridIllumination(int n, List> lamps, List> queries) { + Map rowCount = HashMap(); + Map colCount = HashMap(); + Map diag1 = HashMap(); + Map diag2 = HashMap(); + Set lampSet = HashSet(); + List ans = List.filled(queries.length, 0); + List> dirs = [ + [-1,-1], [-1,0], [-1,1], + [0,-1], [0,0], [0,1], + [1,-1], [1,0], [1,1] + ]; + + for (var lamp in lamps) { + int r = lamp[0], c = lamp[1]; + var key = '$r,$c'; + if (!lampSet.contains(key)) { + lampSet.add(key); + rowCount[r] = (rowCount[r] ?? 0) + 1; + colCount[c] = (colCount[c] ?? 0) + 1; + diag1[r - c] = (diag1[r - c] ?? 0) + 1; + diag2[r + c] = (diag2[r + c] ?? 0) + 1; + } + } + + for (int i = 0; i < queries.length; i++) { + int r = queries[i][0], c = queries[i][1]; + if ((rowCount[r] ?? 0) > 0 || (colCount[c] ?? 0) > 0 || + (diag1[r - c] ?? 0) > 0 || (diag2[r + c] ?? 0) > 0) { + ans[i] = 1; + for (var d in dirs) { + int nr = r + d[0], nc = c + d[1]; + var key = '$nr,$nc'; + if (lampSet.contains(key)) { + lampSet.remove(key); + rowCount[nr] = rowCount[nr]! - 1; + colCount[nc] = colCount[nc]! - 1; + diag1[nr - nc] = diag1[nr - nc]! - 1; + diag2[nr + nc] = diag2[nr + nc]! - 1; + } + } + } else { + ans[i] = 0; + } + } + return ans; + } +} diff --git a/tests/1001-1500/1001. grid-illumination/sol.go b/tests/1001-1500/1001. grid-illumination/sol.go new file mode 100644 index 00000000..d89efb6b --- /dev/null +++ b/tests/1001-1500/1001. grid-illumination/sol.go @@ -0,0 +1,42 @@ +func gridIllumination(n int, lamps [][]int, queries [][]int) []int { + rowCount := make(map[int]int) + colCount := make(map[int]int) + diag1 := make(map[int]int) + diag2 := make(map[int]int) + lampSet := make(map[[2]int]bool) + ans := make([]int, len(queries)) + dirs := [][2]int{{-1,-1}, {-1,0}, {-1,1}, {0,-1}, {0,0}, {0,1}, {1,-1}, {1,0}, {1,1}} + + for _, lamp := range lamps { + r, c := lamp[0], lamp[1] + key := [2]int{r, c} + if !lampSet[key] { + lampSet[key] = true + rowCount[r]++ + colCount[c]++ + diag1[r - c]++ + diag2[r + c]++ + } + } + + for i, q := range queries { + r, c := q[0], q[1] + if rowCount[r] > 0 || colCount[c] > 0 || diag1[r - c] > 0 || diag2[r + c] > 0 { + ans[i] = 1 + for _, d := range dirs { + nr, nc := r + d[0], c + d[1] + key := [2]int{nr, nc} + if lampSet[key] { + delete(lampSet, key) + rowCount[nr]-- + colCount[nc]-- + diag1[nr - nc]-- + diag2[nr + nc]-- + } + } + } else { + ans[i] = 0 + } + } + return ans +} diff --git a/tests/1001-1500/1001. grid-illumination/sol.java b/tests/1001-1500/1001. grid-illumination/sol.java new file mode 100644 index 00000000..523f6d83 --- /dev/null +++ b/tests/1001-1500/1001. grid-illumination/sol.java @@ -0,0 +1,49 @@ +import java.util.*; + +class Solution { + public int[] gridIllumination(int n, int[][] lamps, int[][] queries) { + Map rowCount = new HashMap<>(); + Map colCount = new HashMap<>(); + Map diag1 = new HashMap<>(); + Map diag2 = new HashMap<>(); + Set lampSet = new HashSet<>(); + int[] ans = new int[queries.length]; + int[][] dirs = {{-1,-1}, {-1,0}, {-1,1}, {0,-1}, {0,0}, {0,1}, {1,-1}, {1,0}, {1,1}}; + + for (int[] lamp : lamps) { + int r = lamp[0], c = lamp[1]; + long key = (long)r << 32 | (c & 0xFFFFFFFFL); + if (!lampSet.contains(key)) { + lampSet.add(key); + rowCount.merge(r, 1, Integer::sum); + colCount.merge(c, 1, Integer::sum); + diag1.merge(r - c, 1, Integer::sum); + diag2.merge(r + c, 1, Integer::sum); + } + } + + for (int i = 0; i < queries.length; i++) { + int r = queries[i][0], c = queries[i][1]; + if (rowCount.getOrDefault(r, 0) > 0 || + colCount.getOrDefault(c, 0) > 0 || + diag1.getOrDefault(r - c, 0) > 0 || + diag2.getOrDefault(r + c, 0) > 0) { + ans[i] = 1; + for (int[] d : dirs) { + int nr = r + d[0], nc = c + d[1]; + long key = (long)nr << 32 | (nc & 0xFFFFFFFFL); + if (lampSet.contains(key)) { + lampSet.remove(key); + rowCount.merge(nr, -1, Integer::sum); + colCount.merge(nc, -1, Integer::sum); + diag1.merge(nr - nc, -1, Integer::sum); + diag2.merge(nr + nc, -1, Integer::sum); + } + } + } else { + ans[i] = 0; + } + } + return ans; + } +} diff --git a/tests/1001-1500/1001. grid-illumination/sol.kt b/tests/1001-1500/1001. grid-illumination/sol.kt new file mode 100644 index 00000000..75f53c92 --- /dev/null +++ b/tests/1001-1500/1001. grid-illumination/sol.kt @@ -0,0 +1,50 @@ +import kotlin.collections.HashMap +import kotlin.collections.HashSet + +class Solution { + fun gridIllumination(n: Int, lamps: Array, queries: Array): IntArray { + val rowCount = HashMap() + val colCount = HashMap() + val diag1 = HashMap() + val diag2 = HashMap() + val lampSet = HashSet() + val ans = IntArray(queries.size) + val dirs = arrayOf(intArrayOf(-1,-1), intArrayOf(-1,0), intArrayOf(-1,1), + intArrayOf(0,-1), intArrayOf(0,0), intArrayOf(0,1), + intArrayOf(1,-1), intArrayOf(1,0), intArrayOf(1,1)) + + for (lamp in lamps) { + val r = lamp[0]; val c = lamp[1] + val key = (r.toLong() shl 32) or (c.toLong() and 0xFFFFFFFFL) + if (!lampSet.contains(key)) { + lampSet.add(key) + rowCount[r] = rowCount.getOrDefault(r, 0) + 1 + colCount[c] = colCount.getOrDefault(c, 0) + 1 + diag1[r - c] = diag1.getOrDefault(r - c, 0) + 1 + diag2[r + c] = diag2.getOrDefault(r + c, 0) + 1 + } + } + + for (i in queries.indices) { + val r = queries[i][0]; val c = queries[i][1] + if ((rowCount[r] ?: 0) > 0 || (colCount[c] ?: 0) > 0 || + (diag1[r - c] ?: 0) > 0 || (diag2[r + c] ?: 0) > 0) { + ans[i] = 1 + for (d in dirs) { + val nr = r + d[0]; val nc = c + d[1] + val key = (nr.toLong() shl 32) or (nc.toLong() and 0xFFFFFFFFL) + if (lampSet.contains(key)) { + lampSet.remove(key) + rowCount[nr] = rowCount[nr]!! - 1 + colCount[nc] = colCount[nc]!! - 1 + diag1[nr - nc] = diag1[nr - nc]!! - 1 + diag2[nr + nc] = diag2[nr + nc]!! - 1 + } + } + } else { + ans[i] = 0 + } + } + return ans + } +} diff --git a/tests/1001-1500/1001. grid-illumination/sol.py b/tests/1001-1500/1001. grid-illumination/sol.py new file mode 100644 index 00000000..140795f9 --- /dev/null +++ b/tests/1001-1500/1001. grid-illumination/sol.py @@ -0,0 +1,62 @@ +from collections import defaultdict +from typing import List + + +class Solution(object): + def gridIllumination(self, n, lamps, queries): + # Hash maps to track the number of active lamps illuminating each line + row_count = defaultdict(int) + col_count = defaultdict(int) + diagonal1 = defaultdict(int) # Major diagonals (row - col) + diagonal2 = defaultdict(int) # Minor diagonals (row + col) + + # Hash set to quickly verify the exact coordinate presence of an active lamp + lamp_set = set() + ans = [] + + # Relative coordinates defining a 3x3 window centered around a query cell + directions = { + (-1, -1), + (-1, 0), + (-1, 1), + (0, -1), + (0, 0), + (0, 1), + (1, -1), + (1, 0), + (1, 1), + } + + # Phase 1: Record all lamp placements and light up corresponding paths + for row, col in lamps: + if (row, col) not in lamp_set: + lamp_set.add((row, col)) + row_count[row] += 1 + col_count[col] += 1 + diagonal1[row - col] += 1 + diagonal2[row + col] += 1 + + # Phase 2: Process illumination queries sequentially + for row, col in queries: + # Check if any active line counter covers this position + if ( + row_count[row] + or col_count[col] + or diagonal1[row - col] + or diagonal2[row + col] + ): + ans.append(1) + + # Turn off lamps located in the surrounding 3x3 area + for c_row, c_col in directions: + n_row, n_col = row + c_row, col + c_col + if (n_row, n_col) in lamp_set: + lamp_set.remove((n_row, n_col)) + row_count[n_row] -= 1 + col_count[n_col] -= 1 + diagonal1[n_row - n_col] -= 1 + diagonal2[n_row + n_col] -= 1 + else: + ans.append(0) + + return ans diff --git a/tests/1001-1500/1001. grid-illumination/sol.py2 b/tests/1001-1500/1001. grid-illumination/sol.py2 new file mode 100644 index 00000000..89f67788 --- /dev/null +++ b/tests/1001-1500/1001. grid-illumination/sol.py2 @@ -0,0 +1,39 @@ +class Solution(object): + def gridIllumination(self, n, lamps, queries): + """ + :type n: int + :type lamps: List[List[int]] + :type queries: List[List[int]] + :rtype: List[int] + """ + from collections import defaultdict + row_count = defaultdict(int) + col_count = defaultdict(int) + diagonal1 = defaultdict(int) + diagonal2 = defaultdict(int) + lamp_set = set() + ans = [] + directions = [(-1,-1), (-1,0), (-1,1), + (0,-1), (0,0), (0,1), + (1,-1), (1,0), (1,1)] + for row, col in lamps: + if (row, col) not in lamp_set: + lamp_set.add((row, col)) + row_count[row] += 1 + col_count[col] += 1 + diagonal1[row - col] += 1 + diagonal2[row + col] += 1 + for row, col in queries: + if row_count[row] or col_count[col] or diagonal1[row - col] or diagonal2[row + col]: + ans.append(1) + for dr, dc in directions: + nr, nc = row + dr, col + dc + if (nr, nc) in lamp_set: + lamp_set.remove((nr, nc)) + row_count[nr] -= 1 + col_count[nc] -= 1 + diagonal1[nr - nc] -= 1 + diagonal2[nr + nc] -= 1 + else: + ans.append(0) + return ans diff --git a/tests/1001-1500/1001. grid-illumination/sol.rb b/tests/1001-1500/1001. grid-illumination/sol.rb new file mode 100644 index 00000000..e8f95e7b --- /dev/null +++ b/tests/1001-1500/1001. grid-illumination/sol.rb @@ -0,0 +1,42 @@ +# @param {Integer} n +# @param {Integer[][]} lamps +# @param {Integer[][]} queries +# @return {Integer[]} +def grid_illumination(n, lamps, queries) + row_count = Hash.new(0) + col_count = Hash.new(0) + diagonal1 = Hash.new(0) + diagonal2 = Hash.new(0) + lamp_set = Set.new + ans = [] + directions = [[-1,-1], [-1,0], [-1,1], + [0,-1], [0,0], [0,1], + [1,-1], [1,0], [1,1]] + lamps.each do |row, col| + unless lamp_set.include?([row, col]) + lamp_set.add([row, col]) + row_count[row] += 1 + col_count[col] += 1 + diagonal1[row - col] += 1 + diagonal2[row + col] += 1 + end + end + queries.each do |row, col| + if row_count[row] > 0 || col_count[col] > 0 || diagonal1[row - col] > 0 || diagonal2[row + col] > 0 + ans << 1 + directions.each do |dr, dc| + nr, nc = row + dr, col + dc + if lamp_set.include?([nr, nc]) + lamp_set.delete([nr, nc]) + row_count[nr] -= 1 + col_count[nc] -= 1 + diagonal1[nr - nc] -= 1 + diagonal2[nr + nc] -= 1 + end + end + else + ans << 0 + end + end + ans +end diff --git a/tests/1001-1500/1001. grid-illumination/sol.rs b/tests/1001-1500/1001. grid-illumination/sol.rs new file mode 100644 index 00000000..b0e4fed2 --- /dev/null +++ b/tests/1001-1500/1001. grid-illumination/sol.rs @@ -0,0 +1,52 @@ +use std::collections::{HashMap, HashSet}; + +impl Solution { + pub fn grid_illumination(n: i32, lamps: Vec>, queries: Vec>) -> Vec { + let mut row_count: HashMap = HashMap::new(); + let mut col_count: HashMap = HashMap::new(); + let mut diag1: HashMap = HashMap::new(); + let mut diag2: HashMap = HashMap::new(); + let mut lamp_set: HashSet<(i32, i32)> = HashSet::new(); + let mut ans = vec![0; queries.len()]; + let dirs: [(i32, i32); 9] = [ + (-1,-1), (-1,0), (-1,1), + (0,-1), (0,0), (0,1), + (1,-1), (1,0), (1,1) + ]; + + for lamp in &lamps { + let r = lamp[0]; + let c = lamp[1]; + if !lamp_set.contains(&(r, c)) { + lamp_set.insert((r, c)); + *row_count.entry(r).or_insert(0) += 1; + *col_count.entry(c).or_insert(0) += 1; + *diag1.entry(r - c).or_insert(0) += 1; + *diag2.entry(r + c).or_insert(0) += 1; + } + } + + for i in 0..queries.len() { + let r = queries[i][0]; + let c = queries[i][1]; + if *row_count.get(&r).unwrap_or(&0) > 0 || + *col_count.get(&c).unwrap_or(&0) > 0 || + *diag1.get(&(r - c)).unwrap_or(&0) > 0 || + *diag2.get(&(r + c)).unwrap_or(&0) > 0 { + ans[i] = 1; + for &(dr, dc) in &dirs { + let nr = r + dr; + let nc = c + dc; + if lamp_set.contains(&(nr, nc)) { + lamp_set.remove(&(nr, nc)); + *row_count.get_mut(&nr).unwrap() -= 1; + *col_count.get_mut(&nc).unwrap() -= 1; + *diag1.get_mut(&(nr - nc)).unwrap() -= 1; + *diag2.get_mut(&(nr + nc)).unwrap() -= 1; + } + } + } + } + ans + } +} diff --git a/tests/1001-1500/1001. grid-illumination/sol.swift b/tests/1001-1500/1001. grid-illumination/sol.swift new file mode 100644 index 00000000..a874ec2a --- /dev/null +++ b/tests/1001-1500/1001. grid-illumination/sol.swift @@ -0,0 +1,45 @@ +class Solution { + func gridIllumination(_ n: Int, _ lamps: [[Int]], _ queries: [[Int]]) -> [Int] { + var rowCount: [Int: Int] = [:] + var colCount: [Int: Int] = [:] + var diag1: [Int: Int] = [:] + var diag2: [Int: Int] = [:] + var lampSet = Set<[Int]>() + var ans = [Int](repeating: 0, count: queries.count) + let dirs = [[-1,-1], [-1,0], [-1,1], [0,-1], [0,0], [0,1], [1,-1], [1,0], [1,1]] + + for lamp in lamps { + let r = lamp[0], c = lamp[1] + let key = [r, c] + if !lampSet.contains(key) { + lampSet.insert(key) + rowCount[r, default: 0] += 1 + colCount[c, default: 0] += 1 + diag1[r - c, default: 0] += 1 + diag2[r + c, default: 0] += 1 + } + } + + for i in 0.. 0 || (colCount[c] ?? 0) > 0 || + (diag1[r - c] ?? 0) > 0 || (diag2[r + c] ?? 0) > 0 { + ans[i] = 1 + for d in dirs { + let nr = r + d[0], nc = c + d[1] + let key = [nr, nc] + if lampSet.contains(key) { + lampSet.remove(key) + rowCount[nr]! -= 1 + colCount[nc]! -= 1 + diag1[nr - nc]! -= 1 + diag2[nr + nc]! -= 1 + } + } + } else { + ans[i] = 0 + } + } + return ans + } +} diff --git a/tests/1001-1500/1001. grid-illumination/sol.ts b/tests/1001-1500/1001. grid-illumination/sol.ts new file mode 100644 index 00000000..b0ef000c --- /dev/null +++ b/tests/1001-1500/1001. grid-illumination/sol.ts @@ -0,0 +1,61 @@ +function gridIllumination( + n: number, + lamps: number[][], + queries: number[][], +): number[] { + const rowCount: Map = new Map(); + const colCount: Map = new Map(); + const diag1: Map = new Map(); + const diag2: Map = new Map(); + const lampSet: Set = new Set(); + const ans: number[] = new Array(queries.length); + const dirs: [number, number][] = [ + [-1, -1], + [-1, 0], + [-1, 1], + [0, -1], + [0, 0], + [0, 1], + [1, -1], + [1, 0], + [1, 1], + ]; + + for (const [r, c] of lamps) { + const key = `${r},${c}`; + if (!lampSet.has(key)) { + lampSet.add(key); + rowCount.set(r, (rowCount.get(r) || 0) + 1); + colCount.set(c, (colCount.get(c) || 0) + 1); + diag1.set(r - c, (diag1.get(r - c) || 0) + 1); + diag2.set(r + c, (diag2.get(r + c) || 0) + 1); + } + } + + for (let i = 0; i < queries.length; i++) { + const [r, c] = queries[i]; + if ( + (rowCount.get(r) || 0) > 0 || + (colCount.get(c) || 0) > 0 || + (diag1.get(r - c) || 0) > 0 || + (diag2.get(r + c) || 0) > 0 + ) { + ans[i] = 1; + for (const [dr, dc] of dirs) { + const nr = r + dr, + nc = c + dc; + const key = `${nr},${nc}`; + if (lampSet.has(key)) { + lampSet.delete(key); + rowCount.set(nr, rowCount.get(nr)! - 1); + colCount.set(nc, colCount.get(nc)! - 1); + diag1.set(nr - nc, diag1.get(nr - nc)! - 1); + diag2.set(nr + nc, diag2.get(nr + nc)! - 1); + } + } + } else { + ans[i] = 0; + } + } + return ans; +} diff --git a/tests/1001-1500/1002. find-common-characters/manifest.yaml b/tests/1001-1500/1002. find-common-characters/manifest.yaml new file mode 100644 index 00000000..0ab34eb3 --- /dev/null +++ b/tests/1001-1500/1002. find-common-characters/manifest.yaml @@ -0,0 +1,327 @@ +entry: + id: 1002 + title: find-common-characters + params: + words: + type: array + items: + type: string + call: + cpp: Solution().commonChars({words}) + rust: Solution::common_chars({words}) + python3: Solution().commonChars({words}) + python2: Solution().commonChars({words}) + ruby: common_chars({words}) + java: new Solution().commonChars({words}) + csharp: new Solution().CommonChars({words}) + kotlin: Solution().commonChars({words}) + go: commonChars({words}) + dart: Solution().commonChars({words}) + swift: Solution().commonChars({words}) + typescript: commonChars({words}) +judge: + type: ignore_order +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 1002 +tests: + - name: case_1 + in: + words: + - baa + - bdcd + - edcaa + - ecb + - ddbbaa + out: [] + - name: case_2 + in: + words: + - eb + - dd + - e + - bccdd + out: [] + - name: case_3 + in: + words: + - dec + - acb + - ebd + - ec + - d + - cbe + out: [] + - name: case_4 + in: + words: + - bdcd + - bd + - eadb + out: + - b + - d + - name: case_5 + in: + words: + - baac + - dd + - ddabe + - cd + - cae + - b + out: [] + - name: case_6 + in: + words: + - ccab + out: + - c + - c + - a + - b + - name: case_7 + in: + words: + - d + out: + - d + - name: case_8 + in: + words: + - deba + - e + - aacc + - aed + - d + - b + out: [] + - name: case_9 + in: + words: + - decdb + - aadd + - ecccb + - cdd + - ceda + - dac + out: [] + - name: case_10 + in: + words: + - ba + - bdaa + - a + out: + - a + - name: case_11 + in: + words: + - bacca + - caac + - acbbaa + - edbad + - dedd + - bc + out: [] + - name: case_12 + in: + words: + - cea + - bcad + out: + - c + - a + - name: case_13 + in: + words: + - dcc + out: + - d + - c + - c + - name: case_14 + in: + words: + - dc + - cc + - ba + out: [] + - name: case_15 + in: + words: + - dc + - caecae + - eecee + - abcdb + - dbcbc + out: + - c + - name: case_16 + in: + words: + - ddabc + - cab + - d + - dddac + out: [] + - name: case_17 + in: + words: + - d + - eaaddc + - b + out: [] + - name: case_18 + in: + words: + - ddeb + - bcaa + out: + - b + - name: case_19 + in: + words: + - dde + - badb + out: + - d + - name: case_20 + in: + words: + - ecaea + - b + - bac + - eea + out: [] + - name: case_21 + in: + words: + - ddeadb + - edb + - cabb + - cbe + - c + - beae + out: [] + - name: case_22 + in: + words: + - a + - dcaab + out: + - a + - name: case_23 + in: + words: + - acedde + - ece + out: + - c + - e + - e + - name: case_24 + in: + words: + - bb + out: + - b + - b + - name: case_25 + in: + words: + - debdba + out: + - d + - d + - e + - b + - b + - a + - name: case_26 + in: + words: + - ceb + - ce + out: + - c + - e + - name: case_27 + in: + words: + - acba + - cdda + - cabeca + - cd + - beeb + out: [] + - name: case_28 + in: + words: + - e + - cbcce + - cc + out: [] + - name: case_29 + in: + words: + - dc + - bed + - dc + - ecc + out: [] + - name: case_30 + in: + words: + - d + - b + - dadc + - dde + out: [] + - name: case_31 + in: + words: + - cbecb + - e + out: + - e + - name: case_32 + in: + words: + - cceae + - dbe + - cbae + out: + - e + - name: case_33 + in: + words: + - cea + - eed + out: + - e + - name: case_34 + in: + words: + - cccd + - bc + - b + - eb + - ebe + out: [] + - name: case_35 + in: + words: + - cdbba + - becdad + - ba + - ebab + - adebdc + - aea + out: + - a diff --git a/tests/1001-1500/1002. find-common-characters/sol.cpp b/tests/1001-1500/1002. find-common-characters/sol.cpp new file mode 100644 index 00000000..f154eed3 --- /dev/null +++ b/tests/1001-1500/1002. find-common-characters/sol.cpp @@ -0,0 +1,29 @@ +class Solution { +public: + vector commonChars(vector& words) { + unordered_map freq; + for (char c : words[0]) { + freq[c]++; + } + for (int i = 1; i < words.size(); i++) { + unordered_map f; + for (char c : words[i]) { + f[c]++; + } + for (auto& [c, count] : freq) { + if (f.count(c)) { + freq[c] = min(f[c], count); + } else { + freq[c] = 0; + } + } + } + vector res; + for (auto& [c, count] : freq) { + for (int j = 0; j < count; j++) { + res.push_back(string(1, c)); + } + } + return res; + } +}; diff --git a/tests/1001-1500/1002. find-common-characters/sol.cs b/tests/1001-1500/1002. find-common-characters/sol.cs new file mode 100644 index 00000000..8b771542 --- /dev/null +++ b/tests/1001-1500/1002. find-common-characters/sol.cs @@ -0,0 +1,36 @@ +public class Solution { + public IList CommonChars(string[] words) { + Dictionary freq = new Dictionary(); + foreach (char c in words[0]) { + if (freq.ContainsKey(c)) { + freq[c]++; + } else { + freq[c] = 1; + } + } + for (int i = 1; i < words.Length; i++) { + Dictionary f = new Dictionary(); + foreach (char c in words[i]) { + if (f.ContainsKey(c)) { + f[c]++; + } else { + f[c] = 1; + } + } + foreach (char c in new List(freq.Keys)) { + if (f.ContainsKey(c)) { + freq[c] = Math.Min(f[c], freq[c]); + } else { + freq[c] = 0; + } + } + } + IList res = new List(); + foreach (var kvp in freq) { + for (int j = 0; j < kvp.Value; j++) { + res.Add(kvp.Key.ToString()); + } + } + return res; + } +} diff --git a/tests/1001-1500/1002. find-common-characters/sol.dart b/tests/1001-1500/1002. find-common-characters/sol.dart new file mode 100644 index 00000000..084cd363 --- /dev/null +++ b/tests/1001-1500/1002. find-common-characters/sol.dart @@ -0,0 +1,28 @@ +class Solution { + List commonChars(List words) { + Map freq = {}; + for (var c in words[0].split('')) { + freq[c] = (freq[c] ?? 0) + 1; + } + for (int i = 1; i < words.length; i++) { + Map f = {}; + for (var c in words[i].split('')) { + f[c] = (f[c] ?? 0) + 1; + } + for (var c in freq.keys.toList()) { + if (f.containsKey(c)) { + freq[c] = f[c]! < freq[c]! ? f[c]! : freq[c]!; + } else { + freq[c] = 0; + } + } + } + List res = []; + freq.forEach((c, count) { + for (int j = 0; j < count; j++) { + res.add(c); + } + }); + return res; + } +} diff --git a/tests/1001-1500/1002. find-common-characters/sol.go b/tests/1001-1500/1002. find-common-characters/sol.go new file mode 100644 index 00000000..26ccbe76 --- /dev/null +++ b/tests/1001-1500/1002. find-common-characters/sol.go @@ -0,0 +1,32 @@ +func commonChars(words []string) []string { + freq := make(map[rune]int) + for _, c := range words[0] { + freq[c]++ + } + for i := 1; i < len(words); i++ { + f := make(map[rune]int) + for _, c := range words[i] { + f[c]++ + } + for c := range freq { + if count, ok := f[c]; ok { + if count < freq[c] { + freq[c] = count + } + } else { + freq[c] = 0 + } + } + } + res := make([]string, 0) + for c := 'a'; c <= 'z'; c++ { + count, ok := freq[c] + if !ok || count == 0 { + continue + } + for j := 0; j < count; j++ { + res = append(res, string(c)) + } + } + return res +} diff --git a/tests/1001-1500/1002. find-common-characters/sol.java b/tests/1001-1500/1002. find-common-characters/sol.java new file mode 100644 index 00000000..92a32a67 --- /dev/null +++ b/tests/1001-1500/1002. find-common-characters/sol.java @@ -0,0 +1,30 @@ +class Solution { + public List commonChars(String[] words) { + Map freq = new HashMap<>(); + for (char c : words[0].toCharArray()) { + freq.put(c, freq.getOrDefault(c, 0) + 1); + } + for (int i = 1; i < words.length; i++) { + Map f = new HashMap<>(); + for (char c : words[i].toCharArray()) { + f.put(c, f.getOrDefault(c, 0) + 1); + } + for (char c : new HashSet<>(freq.keySet())) { + if (f.containsKey(c)) { + freq.put(c, Math.min(f.get(c), freq.get(c))); + } else { + freq.put(c, 0); + } + } + } + List res = new ArrayList<>(); + for (Map.Entry entry : freq.entrySet()) { + char c = entry.getKey(); + int count = entry.getValue(); + for (int j = 0; j < count; j++) { + res.add(String.valueOf(c)); + } + } + return res; + } +} diff --git a/tests/1001-1500/1002. find-common-characters/sol.kt b/tests/1001-1500/1002. find-common-characters/sol.kt new file mode 100644 index 00000000..c35fadb6 --- /dev/null +++ b/tests/1001-1500/1002. find-common-characters/sol.kt @@ -0,0 +1,26 @@ +class Solution { + fun commonChars(words: Array): List { + val freq = mutableMapOf() + for (c in words[0]) { + freq[c] = freq.getOrDefault(c, 0) + 1 + } + for (i in 1 until words.size) { + val f = mutableMapOf() + for (c in words[i]) { + f[c] = f.getOrDefault(c, 0) + 1 + } + for (c in freq.keys.toList()) { + if (f.containsKey(c)) { + freq[c] = minOf(f[c]!!, freq[c]!!) + } else { + freq[c] = 0 + } + } + } + val res = mutableListOf() + for ((c, count) in freq) { + repeat(count) { res.add(c.toString()) } + } + return res + } +} diff --git a/tests/1001-1500/1002. find-common-characters/sol.py b/tests/1001-1500/1002. find-common-characters/sol.py new file mode 100644 index 00000000..869eeb4e --- /dev/null +++ b/tests/1001-1500/1002. find-common-characters/sol.py @@ -0,0 +1,20 @@ +from collections import Counter +from typing import List + + +class Solution: + def commonChars(self, words: List[str]) -> List[str]: + chars = list(words[0]) + freq = Counter(chars) + for word in words: + f = Counter(word) + for c in freq: + if c in f: + freq[c] = min(f[c], freq[c]) + else: + freq[c] = 0 + res = "" + for x in freq: + if freq[x] != 0: + res = res + x * freq[x] + return list(res) diff --git a/tests/1001-1500/1002. find-common-characters/sol.py2 b/tests/1001-1500/1002. find-common-characters/sol.py2 new file mode 100644 index 00000000..4ab86569 --- /dev/null +++ b/tests/1001-1500/1002. find-common-characters/sol.py2 @@ -0,0 +1,19 @@ +from collections import Counter + + +class Solution(object): + def commonChars(self, words): + chars = list(words[0]) + freq = Counter(chars) + for word in words[1:]: + f = Counter(word) + for c in list(freq.keys()): + if c in f: + freq[c] = min(f[c], freq[c]) + else: + freq[c] = 0 + res = [] + for x in freq: + if freq[x] != 0: + res.extend([x] * freq[x]) + return res diff --git a/tests/1001-1500/1002. find-common-characters/sol.rb b/tests/1001-1500/1002. find-common-characters/sol.rb new file mode 100644 index 00000000..19a925c6 --- /dev/null +++ b/tests/1001-1500/1002. find-common-characters/sol.rb @@ -0,0 +1,24 @@ +# @param {String[]} words +# @return {String[]} +def common_chars(words) + freq = Hash.new(0) + words[0].each_char { |c| freq[c] += 1 } + + words[1..].each do |word| + f = Hash.new(0) + word.each_char { |c| f[c] += 1 } + freq.each_key do |c| + if f.key?(c) + freq[c] = [f[c], freq[c]].min + else + freq[c] = 0 + end + end + end + + res = [] + freq.each do |c, count| + count.times { res << c } if count > 0 + end + res +end diff --git a/tests/1001-1500/1002. find-common-characters/sol.rs b/tests/1001-1500/1002. find-common-characters/sol.rs new file mode 100644 index 00000000..c2acb024 --- /dev/null +++ b/tests/1001-1500/1002. find-common-characters/sol.rs @@ -0,0 +1,28 @@ +impl Solution { + pub fn common_chars(words: Vec) -> Vec { + let mut freq: std::collections::HashMap = std::collections::HashMap::new(); + for c in words[0].chars() { + *freq.entry(c).or_insert(0) += 1; + } + for i in 1..words.len() { + let mut f: std::collections::HashMap = std::collections::HashMap::new(); + for c in words[i].chars() { + *f.entry(c).or_insert(0) += 1; + } + for c in freq.clone().keys() { + if let Some(count) = f.get(c) { + freq.insert(*c, (*count).min(freq[c])); + } else { + freq.insert(*c, 0); + } + } + } + let mut res: Vec = Vec::new(); + for (c, count) in freq { + for _ in 0..count { + res.push(c.to_string()); + } + } + res + } +} diff --git a/tests/1001-1500/1002. find-common-characters/sol.swift b/tests/1001-1500/1002. find-common-characters/sol.swift new file mode 100644 index 00000000..8edb9605 --- /dev/null +++ b/tests/1001-1500/1002. find-common-characters/sol.swift @@ -0,0 +1,28 @@ +class Solution { + func commonChars(_ words: [String]) -> [String] { + var freq: [Character: Int] = [:] + for c in words[0] { + freq[c, default: 0] += 1 + } + for i in 1.. = {}; + for (const c of words[0]) { + freq[c] = (freq[c] || 0) + 1; + } + for (let i = 1; i < words.length; i++) { + const f: Record = {}; + for (const c of words[i]) { + f[c] = (f[c] || 0) + 1; + } + for (const c in freq) { + if (c in f) { + freq[c] = Math.min(f[c], freq[c]); + } else { + freq[c] = 0; + } + } + } + const res: string[] = []; + for (const c in freq) { + for (let j = 0; j < freq[c]; j++) { + res.push(c); + } + } + return res; +} diff --git a/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/manifest.yaml b/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/manifest.yaml new file mode 100644 index 00000000..5f9fd775 --- /dev/null +++ b/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/manifest.yaml @@ -0,0 +1,170 @@ +entry: + id: 1003 + title: check-if-word-is-valid-after-substitutions + params: + s: + type: string + call: + cpp: Solution().isValid({s}) + rust: Solution::is_valid({s}) + python3: Solution().isValid({s}) + python2: Solution().isValid({s}) + ruby: is_valid({s}) + java: new Solution().isValid({s}) + csharp: new Solution().IsValid({s}) + kotlin: Solution().isValid({s}) + go: isValid({s}) + dart: Solution().isValid({s}) + swift: Solution().isValid({s}) + typescript: isValid({s}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 1003 +tests: + - name: case_1 + in: + s: abc + out: true + - name: case_2 + in: + s: aabcbc + out: true + - name: case_3 + in: + s: abcabcababcc + out: true + - name: case_4 + in: + s: abccba + out: false + - name: case_5 + in: + s: cababc + out: false + - name: case_6 + in: + s: ababc + out: false + - name: case_7 + in: + s: aaacbbcbcab + out: false + - name: case_8 + in: + s: aabb + out: false + - name: case_9 + in: + s: accabaacc + out: false + - name: case_10 + in: + s: cacccab + out: false + - name: case_11 + in: + s: b + out: false + - name: case_12 + in: + s: cb + out: false + - name: case_13 + in: + s: cbcababb + out: false + - name: case_14 + in: + s: baa + out: false + - name: case_15 + in: + s: c + out: false + - name: case_16 + in: + s: bbabb + out: false + - name: case_17 + in: + s: abacbcbcb + out: false + - name: case_18 + in: + s: c + out: false + - name: case_19 + in: + s: abbaa + out: false + - name: case_20 + in: + s: aabaaaaccbb + out: false + - name: case_21 + in: + s: acbcbbbccbcb + out: false + - name: case_22 + in: + s: aa + out: false + - name: case_23 + in: + s: bcbaa + out: false + - name: case_24 + in: + s: ca + out: false + - name: case_25 + in: + s: bbacc + out: false + - name: case_26 + in: + s: aa + out: false + - name: case_27 + in: + s: bbcbbc + out: false + - name: case_28 + in: + s: ac + out: false + - name: case_29 + in: + s: bbbbaccbaab + out: false + - name: case_30 + in: + s: abcaba + out: false + - name: case_31 + in: + s: bbaabbcbbab + out: false + - name: case_32 + in: + s: cbcccccaa + out: false + - name: case_33 + in: + s: a + out: false + - name: case_34 + in: + s: cbbabaaacbac + out: false + - name: case_35 + in: + s: babca + out: false diff --git a/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.cpp b/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.cpp new file mode 100644 index 00000000..1d1a22f3 --- /dev/null +++ b/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.cpp @@ -0,0 +1,32 @@ +class Solution { +public: + bool isValid(string s) { + if (s == "abc") { + return true; + } + if (s[0] != 'a' || s[s.length() - 1] != 'c') { + return false; + } + vector l(s.begin(), s.end()); + for (int j = 0; j < l.size(); j++) { + for (int i = 0; i <= (int)l.size() - 3; i++) { + if (l.size() == 3 && l[0] == 'a' && l[1] == 'b' && l[2] == 'c') { + return true; + } + if (i + 2 <= l.size() - 1) { + if (l[i] == 'a' && l[i+1] == 'b' && l[i+2] == 'c') { + l.erase(l.begin() + i); + l.erase(l.begin() + i); + l.erase(l.begin() + i); + i = -1; + continue; + } + } + } + } + if (l.size() == 0) { + return true; + } + return false; + } +}; diff --git a/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.cs b/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.cs new file mode 100644 index 00000000..db5d8242 --- /dev/null +++ b/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.cs @@ -0,0 +1,31 @@ +public class Solution { + public bool IsValid(string s) { + if (s == "abc") { + return true; + } + if (s[0] != 'a' || s[s.Length - 1] != 'c') { + return false; + } + List l = new List(s); + for (int j = 0; j < l.Count; j++) { + for (int i = 0; i <= l.Count - 3; i++) { + if (l.Count == 3 && l[0] == 'a' && l[1] == 'b' && l[2] == 'c') { + return true; + } + if (i + 2 <= l.Count - 1) { + if (l[i] == 'a' && l[i+1] == 'b' && l[i+2] == 'c') { + l.RemoveAt(i); + l.RemoveAt(i); + l.RemoveAt(i); + i = -1; + continue; + } + } + } + } + if (l.Count == 0) { + return true; + } + return false; + } +} diff --git a/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.dart b/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.dart new file mode 100644 index 00000000..d352b2be --- /dev/null +++ b/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.dart @@ -0,0 +1,32 @@ +class Solution { + bool isValid(String s) { + if (s == "abc") { + return true; + } + if (s[0] != "a" || s[s.length - 1] != "c") { + return false; + } + List l = s.split(""); + for (int j = 0; j < l.length; j++) { + int i = 0; + while (i <= l.length - 3) { + if (l.length == 3 && l[0] == "a" && l[1] == "b" && l[2] == "c") { + return true; + } + if (i + 2 <= l.length - 1) { + if (l[i] == "a" && l[i+1] == "b" && l[i+2] == "c") { + l.removeAt(i); + l.removeAt(i); + l.removeAt(i); + i = -1; + } + } + i++; + } + } + if (l.length == 0) { + return true; + } + return false; + } +} diff --git a/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.go b/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.go new file mode 100644 index 00000000..ae37813c --- /dev/null +++ b/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.go @@ -0,0 +1,27 @@ +func isValid(s string) bool { + if s == "abc" { + return true + } + if s[0] != 'a' || s[len(s)-1] != 'c' { + return false + } + l := []rune(s) + for j := 0; j < len(l); j++ { + for i := 0; i <= len(l)-3; i++ { + if len(l) == 3 && l[0] == 'a' && l[1] == 'b' && l[2] == 'c' { + return true + } + if i+2 <= len(l)-1 { + if l[i] == 'a' && l[i+1] == 'b' && l[i+2] == 'c' { + l = append(l[:i], l[i+3:]...) + i = -1 + continue + } + } + } + } + if len(l) == 0 { + return true + } + return false +} diff --git a/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.java b/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.java new file mode 100644 index 00000000..39275627 --- /dev/null +++ b/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.java @@ -0,0 +1,34 @@ +class Solution { + public boolean isValid(String s) { + if (s.equals("abc")) { + return true; + } + if (s.charAt(0) != 'a' || s.charAt(s.length() - 1) != 'c') { + return false; + } + java.util.List l = new java.util.ArrayList<>(); + for (char c : s.toCharArray()) { + l.add(c); + } + for (int j = 0; j < l.size(); j++) { + for (int i = 0; i <= l.size() - 3; i++) { + if (l.equals(java.util.Arrays.asList('a', 'b', 'c'))) { + return true; + } + if (i + 2 <= l.size() - 1) { + if (l.get(i) == 'a' && l.get(i+1) == 'b' && l.get(i+2) == 'c') { + for (int x = 0; x < 3; x++) { + l.remove(i); + } + i = -1; + continue; + } + } + } + } + if (l.size() == 0) { + return true; + } + return false; + } +} diff --git a/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.kt b/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.kt new file mode 100644 index 00000000..ea8d02a0 --- /dev/null +++ b/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.kt @@ -0,0 +1,33 @@ +class Solution { + fun isValid(s: String): Boolean { + if (s == "abc") { + return true + } + if (s[0] != 'a' || s[s.length - 1] != 'c') { + return false + } + val l = s.toMutableList() + for (j in l.indices) { + var i = 0 + while (i <= l.size - 3) { + if (l == mutableListOf('a', 'b', 'c')) { + return true + } + if (i + 2 <= l.size - 1) { + if (l[i] == 'a' && l[i+1] == 'b' && l[i+2] == 'c') { + repeat(3) { l.removeAt(i) } + i = 0 + } else { + i++ + } + } else { + i++ + } + } + } + if (l.size == 0) { + return true + } + return false + } +} diff --git a/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.py b/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.py new file mode 100644 index 00000000..556ce3f7 --- /dev/null +++ b/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.py @@ -0,0 +1,18 @@ +class Solution: + def isValid(self, s: str) -> bool: + if s == "abc": + return True + if s[0] != "a" or s[-1] != "c": + return False + l = list(s) + for j in range(len(l)): + for i in range(0, len(l) - 2): + if l == ["a", "b", "c"]: + return True + if i + 2 <= len(l) - 1: + if l[i] + l[i + 1] + l[i + 2] == "abc": + for x in range(3): + l.pop(i) + if len(l) == 0: + return True + return False diff --git a/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.py2 b/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.py2 new file mode 100644 index 00000000..9bc3f772 --- /dev/null +++ b/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.py2 @@ -0,0 +1,22 @@ +class Solution(object): + def isValid(self, s): + """ + :type s: str + :rtype: bool + """ + if s == "abc": + return True + if s[0] != "a" or s[-1] != "c": + return False + l = list(s) + for j in range(len(l)): + for i in range(0, len(l)-2): + if l == ["a","b","c"]: + return True + if i + 2 <= len(l) - 1: + if l[i] + l[i+1] + l[i+2] == "abc": + for x in range(3): + l.pop(i) + if len(l) == 0: + return True + return False diff --git a/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.rb b/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.rb new file mode 100644 index 00000000..825ed5e1 --- /dev/null +++ b/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.rb @@ -0,0 +1,27 @@ +# @param {String} s +# @return {Boolean} +def is_valid(s) + return true if s == "abc" + return false if s[0] != "a" || s[-1] != "c" + l = s.chars + for j in 0...l.length + i = 0 + while i <= l.length - 3 + if l == ["a", "b", "c"] + return true + end + if i + 2 <= l.length - 1 + if l[i] + l[i+1] + l[i+2] == "abc" + 3.times { l.delete_at(i) } + i = 0 + else + i += 1 + end + else + i += 1 + end + end + end + return true if l.length == 0 + return false +end diff --git a/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.rs b/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.rs new file mode 100644 index 00000000..9ff4ad59 --- /dev/null +++ b/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.rs @@ -0,0 +1,34 @@ +impl Solution { + pub fn is_valid(s: String) -> bool { + if s == "abc" { + return true; + } + let chars: Vec = s.chars().collect(); + if chars[0] != 'a' || chars[chars.len() - 1] != 'c' { + return false; + } + let mut l = s.chars().collect::>(); + for _j in 0..l.len() { + let mut i = 0; + while i as i32 <= l.len() as i32 - 3 { + if l == vec!['a', 'b', 'c'] { + return true; + } + if i + 2 <= l.len() - 1 { + if l[i] == 'a' && l[i+1] == 'b' && l[i+2] == 'c' { + l.remove(i); + l.remove(i); + l.remove(i); + i = 0; + continue; + } + } + i += 1; + } + } + if l.len() == 0 { + return true; + } + false + } +} diff --git a/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.swift b/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.swift new file mode 100644 index 00000000..26e106a9 --- /dev/null +++ b/tests/1001-1500/1003. check-if-word-is-valid-after-substitutions/sol.swift @@ -0,0 +1,32 @@ +class Solution { + func isValid(_ s: String) -> Bool { + if s == "abc" { + return true + } + if s.first != "a" || s.last != "c" { + return false + } + var l = Array(s) + for _ in 0..& nums, int k) { + int left = 0, maxLength = 0, zeroCount = 0; + for (int right = 0; right < nums.size(); right++) { + if (nums[right] == 0) { + zeroCount++; + } + while (zeroCount > k) { + if (nums[left] == 0) { + zeroCount--; + } + left++; + } + maxLength = max(maxLength, right - left + 1); + } + return maxLength; + } +}; diff --git a/tests/1001-1500/1004. max-consecutive-ones-iii/sol.cs b/tests/1001-1500/1004. max-consecutive-ones-iii/sol.cs new file mode 100644 index 00000000..c2c8de90 --- /dev/null +++ b/tests/1001-1500/1004. max-consecutive-ones-iii/sol.cs @@ -0,0 +1,18 @@ +public class Solution { + public int LongestOnes(int[] nums, int k) { + int left = 0, maxLength = 0, zeroCount = 0; + for (int right = 0; right < nums.Length; right++) { + if (nums[right] == 0) { + zeroCount++; + } + while (zeroCount > k) { + if (nums[left] == 0) { + zeroCount--; + } + left++; + } + maxLength = Math.Max(maxLength, right - left + 1); + } + return maxLength; + } +} diff --git a/tests/1001-1500/1004. max-consecutive-ones-iii/sol.dart b/tests/1001-1500/1004. max-consecutive-ones-iii/sol.dart new file mode 100644 index 00000000..153f5f3f --- /dev/null +++ b/tests/1001-1500/1004. max-consecutive-ones-iii/sol.dart @@ -0,0 +1,20 @@ +class Solution { + int longestOnes(List nums, int k) { + int left = 0, maxLength = 0, zeroCount = 0; + for (int right = 0; right < nums.length; right++) { + if (nums[right] == 0) { + zeroCount++; + } + while (zeroCount > k) { + if (nums[left] == 0) { + zeroCount--; + } + left++; + } + if (right - left + 1 > maxLength) { + maxLength = right - left + 1; + } + } + return maxLength; + } +} diff --git a/tests/1001-1500/1004. max-consecutive-ones-iii/sol.go b/tests/1001-1500/1004. max-consecutive-ones-iii/sol.go new file mode 100644 index 00000000..3a6a5c42 --- /dev/null +++ b/tests/1001-1500/1004. max-consecutive-ones-iii/sol.go @@ -0,0 +1,18 @@ +func longestOnes(nums []int, k int) int { + left, maxLength, zeroCount := 0, 0, 0 + for right := 0; right < len(nums); right++ { + if nums[right] == 0 { + zeroCount++ + } + for zeroCount > k { + if nums[left] == 0 { + zeroCount-- + } + left++ + } + if right-left+1 > maxLength { + maxLength = right - left + 1 + } + } + return maxLength +} diff --git a/tests/1001-1500/1004. max-consecutive-ones-iii/sol.java b/tests/1001-1500/1004. max-consecutive-ones-iii/sol.java new file mode 100644 index 00000000..26897d11 --- /dev/null +++ b/tests/1001-1500/1004. max-consecutive-ones-iii/sol.java @@ -0,0 +1,18 @@ +class Solution { + public int longestOnes(int[] nums, int k) { + int left = 0, maxLength = 0, zeroCount = 0; + for (int right = 0; right < nums.length; right++) { + if (nums[right] == 0) { + zeroCount++; + } + while (zeroCount > k) { + if (nums[left] == 0) { + zeroCount--; + } + left++; + } + maxLength = Math.max(maxLength, right - left + 1); + } + return maxLength; + } +} diff --git a/tests/1001-1500/1004. max-consecutive-ones-iii/sol.kt b/tests/1001-1500/1004. max-consecutive-ones-iii/sol.kt new file mode 100644 index 00000000..40b6882e --- /dev/null +++ b/tests/1001-1500/1004. max-consecutive-ones-iii/sol.kt @@ -0,0 +1,20 @@ +class Solution { + fun longestOnes(nums: IntArray, k: Int): Int { + var left = 0 + var maxLength = 0 + var zeroCount = 0 + for (right in nums.indices) { + if (nums[right] == 0) { + zeroCount++ + } + while (zeroCount > k) { + if (nums[left] == 0) { + zeroCount-- + } + left++ + } + maxLength = maxOf(maxLength, right - left + 1) + } + return maxLength + } +} diff --git a/tests/1001-1500/1004. max-consecutive-ones-iii/sol.py b/tests/1001-1500/1004. max-consecutive-ones-iii/sol.py new file mode 100644 index 00000000..c50521f9 --- /dev/null +++ b/tests/1001-1500/1004. max-consecutive-ones-iii/sol.py @@ -0,0 +1,15 @@ +from typing import List + + +class Solution: + def longestOnes(self, nums, k): + left, maxLength, zeroCount = 0, 0, 0 + for right in range(len(nums)): + if nums[right] == 0: + zeroCount += 1 + while zeroCount > k: + if nums[left] == 0: + zeroCount -= 1 + left += 1 + maxLength = max(maxLength, right - left + 1) + return maxLength diff --git a/tests/1001-1500/1004. max-consecutive-ones-iii/sol.py2 b/tests/1001-1500/1004. max-consecutive-ones-iii/sol.py2 new file mode 100644 index 00000000..87a2c2e6 --- /dev/null +++ b/tests/1001-1500/1004. max-consecutive-ones-iii/sol.py2 @@ -0,0 +1,17 @@ +class Solution(object): + def longestOnes(self, nums, k): + """ + :type nums: List[int] + :type k: int + :rtype: int + """ + left, maxLength, zeroCount = 0, 0, 0 + for right in range(len(nums)): + if nums[right] == 0: + zeroCount += 1 + while zeroCount > k: + if nums[left] == 0: + zeroCount -= 1 + left += 1 + maxLength = max(maxLength, right - left + 1) + return maxLength diff --git a/tests/1001-1500/1004. max-consecutive-ones-iii/sol.rb b/tests/1001-1500/1004. max-consecutive-ones-iii/sol.rb new file mode 100644 index 00000000..d0a69f31 --- /dev/null +++ b/tests/1001-1500/1004. max-consecutive-ones-iii/sol.rb @@ -0,0 +1,15 @@ +# @param {Integer[]} nums +# @param {Integer} k +# @return {Integer} +def longest_ones(nums, k) + left, max_length, zero_count = 0, 0, 0 + nums.each_with_index do |num, right| + zero_count += 1 if num == 0 + while zero_count > k + zero_count -= 1 if nums[left] == 0 + left += 1 + end + max_length = [max_length, right - left + 1].max + end + max_length +end diff --git a/tests/1001-1500/1004. max-consecutive-ones-iii/sol.rs b/tests/1001-1500/1004. max-consecutive-ones-iii/sol.rs new file mode 100644 index 00000000..e65c19e9 --- /dev/null +++ b/tests/1001-1500/1004. max-consecutive-ones-iii/sol.rs @@ -0,0 +1,20 @@ +impl Solution { + pub fn longest_ones(nums: Vec, k: i32) -> i32 { + let mut left = 0; + let mut max_length = 0; + let mut zero_count = 0; + for right in 0..nums.len() { + if nums[right] == 0 { + zero_count += 1; + } + while zero_count > k { + if nums[left] == 0 { + zero_count -= 1; + } + left += 1; + } + max_length = max_length.max((right - left + 1) as i32); + } + max_length + } +} diff --git a/tests/1001-1500/1004. max-consecutive-ones-iii/sol.swift b/tests/1001-1500/1004. max-consecutive-ones-iii/sol.swift new file mode 100644 index 00000000..5e0e7d3f --- /dev/null +++ b/tests/1001-1500/1004. max-consecutive-ones-iii/sol.swift @@ -0,0 +1,18 @@ +class Solution { + func longestOnes(_ nums: [Int], _ k: Int) -> Int { + var left = 0, maxLength = 0, zeroCount = 0 + for right in 0.. k { + if nums[left] == 0 { + zeroCount -= 1 + } + left += 1 + } + maxLength = max(maxLength, right - left + 1) + } + return maxLength + } +} diff --git a/tests/1001-1500/1004. max-consecutive-ones-iii/sol.ts b/tests/1001-1500/1004. max-consecutive-ones-iii/sol.ts new file mode 100644 index 00000000..cc2fb777 --- /dev/null +++ b/tests/1001-1500/1004. max-consecutive-ones-iii/sol.ts @@ -0,0 +1,18 @@ +function longestOnes(nums: number[], k: number): number { + let left = 0, + maxLength = 0, + zeroCount = 0; + for (let right = 0; right < nums.length; right++) { + if (nums[right] === 0) { + zeroCount++; + } + while (zeroCount > k) { + if (nums[left] === 0) { + zeroCount--; + } + left++; + } + maxLength = Math.max(maxLength, right - left + 1); + } + return maxLength; +} diff --git a/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/manifest.yaml b/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/manifest.yaml new file mode 100644 index 00000000..7fd22776 --- /dev/null +++ b/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/manifest.yaml @@ -0,0 +1,417 @@ +entry: + id: 1005 + title: maximize-sum-of-array-after-k-negations + params: + nums: + type: array + items: + type: int + k: + type: int + call: + cpp: Solution().largestSumAfterKNegations({nums}, {k}) + rust: Solution::largest_sum_after_k_negations({nums}, {k}) + python3: Solution().largestSumAfterKNegations({nums}, {k}) + python2: Solution().largestSumAfterKNegations({nums}, {k}) + ruby: largest_sum_after_k_negations({nums}, {k}) + java: new Solution().largestSumAfterKNegations({nums}, {k}) + csharp: new Solution().LargestSumAfterKNegations({nums}, {k}) + kotlin: Solution().largestSumAfterKNegations({nums}, {k}) + go: largestSumAfterKNegations({nums}, {k}) + dart: Solution().largestSumAfterKNegations({nums}, {k}) + swift: Solution().largestSumAfterKNegations({nums}, {k}) + typescript: largestSumAfterKNegations({nums}, {k}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 1005 +tests: + - name: case_1 + in: + nums: + - -3 + - -7 + k: 4 + out: 10 + - name: case_2 + in: + nums: + - -4 + - -1 + - -3 + - 9 + - 0 + - 3 + - 1 + - 7 + - 3 + k: 10 + out: 31 + - name: case_3 + in: + nums: + - 8 + - 3 + - 1 + - 9 + k: 5 + out: 19 + - name: case_4 + in: + nums: + - 10 + - -10 + - 7 + - 6 + - -6 + - 8 + - 10 + - 1 + - -4 + - 1 + k: 2 + out: 55 + - name: case_5 + in: + nums: + - -4 + - -1 + k: 10 + out: 5 + - name: case_6 + in: + nums: + - 0 + - 8 + - -9 + - 8 + - 3 + - 10 + - -1 + k: 9 + out: 39 + - name: case_7 + in: + nums: + - -1 + - -2 + - -3 + - -2 + - -8 + - -4 + - 6 + - -6 + - 2 + k: 2 + out: 10 + - name: case_8 + in: + nums: + - 6 + - -4 + k: 10 + out: 2 + - name: case_9 + in: + nums: + - -7 + - 0 + - 6 + - 8 + - 5 + - -2 + - -9 + - -6 + - -1 + - -8 + k: 1 + out: 4 + - name: case_10 + in: + nums: + - -3 + - -10 + - 9 + - -3 + - 3 + k: 9 + out: 28 + - name: case_11 + in: + nums: + - -7 + - 0 + - -10 + k: 8 + out: 17 + - name: case_12 + in: + nums: + - 5 + - -1 + - 4 + - 6 + - 4 + - 7 + k: 9 + out: 27 + - name: case_13 + in: + nums: + - -1 + - -10 + - 1 + - 2 + - 6 + k: 9 + out: 18 + - name: case_14 + in: + nums: + - -9 + - 7 + - -7 + - -4 + k: 2 + out: 19 + - name: case_15 + in: + nums: + - -1 + - -5 + - 10 + - 7 + - 6 + k: 6 + out: 29 + - name: case_16 + in: + nums: + - 5 + - 1 + - 1 + - 10 + - -5 + - 5 + - 9 + k: 9 + out: 36 + - name: case_17 + in: + nums: + - 8 + - -2 + - 3 + - -4 + - -2 + - 1 + - -10 + - 3 + - 7 + k: 4 + out: 40 + - name: case_18 + in: + nums: + - -8 + - -10 + - -4 + - -4 + - -6 + - -1 + - -2 + k: 7 + out: 35 + - name: case_19 + in: + nums: + - 6 + k: 2 + out: 6 + - name: case_20 + in: + nums: + - -1 + - 9 + - -7 + - 3 + k: 5 + out: 18 + - name: case_21 + in: + nums: + - 9 + - 4 + - -6 + - -10 + - -9 + - -5 + - 3 + - -5 + - 6 + - 1 + k: 2 + out: 26 + - name: case_22 + in: + nums: + - 10 + - -2 + - -3 + - -7 + - -9 + - 5 + - 6 + - -6 + - 8 + - -3 + k: 10 + out: 59 + - name: case_23 + in: + nums: + - 4 + - 1 + - -3 + k: 3 + out: 8 + - name: case_24 + in: + nums: + - 5 + - -6 + - 7 + k: 8 + out: 8 + - name: case_25 + in: + nums: + - 7 + - 4 + - 9 + - -4 + k: 5 + out: 24 + - name: case_26 + in: + nums: + - -5 + - -2 + - 1 + - 8 + k: 5 + out: 14 + - name: case_27 + in: + nums: + - -4 + - 5 + - 10 + - -4 + - -1 + - 0 + - 9 + - -7 + - -6 + k: 9 + out: 46 + - name: case_28 + in: + nums: + - 6 + - 5 + - -6 + - -6 + - 7 + - -5 + - 7 + - -1 + - -7 + - -3 + k: 0 + out: -3 + - name: case_29 + in: + nums: + - 4 + k: 3 + out: -4 + - name: case_30 + in: + nums: + - -5 + - -8 + - 0 + - 8 + - -5 + - 6 + - 2 + - 2 + k: 4 + out: 36 + - name: case_31 + in: + nums: + - -5 + - 9 + - 6 + - -8 + - 5 + - 9 + - 7 + - -8 + - 2 + - 4 + k: 8 + out: 59 + - name: case_32 + in: + nums: + - -1 + - 2 + - 0 + - -7 + - 9 + - -1 + - -9 + - 3 + - 8 + - -4 + k: 10 + out: 44 + - name: case_33 + in: + nums: + - 9 + - -5 + - -10 + - -9 + - 3 + k: 9 + out: 36 + - name: case_34 + in: + nums: + - 5 + - 8 + - -2 + - -10 + - -5 + - -4 + - -6 + - -3 + - 8 + k: 6 + out: 51 + - name: case_35 + in: + nums: + - 5 + k: 4 + out: 5 diff --git a/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.cpp b/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.cpp new file mode 100644 index 00000000..e192380f --- /dev/null +++ b/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.cpp @@ -0,0 +1,21 @@ +class Solution { +public: + int largestSumAfterKNegations(vector& nums, int k) { + sort(nums.begin(), nums.end()); + for (int i = 0; i < nums.size(); i++) { + if (nums[i] < 0 && k > 0) { + nums[i] = -nums[i]; + k--; + } + } + sort(nums.begin(), nums.end()); + if (k > 0 && k % 2 != 0) { + nums[0] = -nums[0]; + } + int sum = 0; + for (int num : nums) { + sum += num; + } + return sum; + } +}; diff --git a/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.cs b/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.cs new file mode 100644 index 00000000..b33e42a7 --- /dev/null +++ b/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.cs @@ -0,0 +1,20 @@ +public class Solution { + public int LargestSumAfterKNegations(int[] nums, int k) { + Array.Sort(nums); + for (int i = 0; i < nums.Length; i++) { + if (nums[i] < 0 && k > 0) { + nums[i] = -nums[i]; + k--; + } + } + Array.Sort(nums); + if (k > 0 && k % 2 != 0) { + nums[0] = -nums[0]; + } + int sum = 0; + foreach (int num in nums) { + sum += num; + } + return sum; + } +} diff --git a/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.dart b/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.dart new file mode 100644 index 00000000..b2f5d56a --- /dev/null +++ b/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.dart @@ -0,0 +1,16 @@ +class Solution { + int largestSumAfterKNegations(List nums, int k) { + nums.sort(); + for (int i = 0; i < nums.length; i++) { + if (nums[i] < 0 && k > 0) { + nums[i] = -nums[i]; + k--; + } + } + nums.sort(); + if (k > 0 && k % 2 != 0) { + nums[0] = -nums[0]; + } + return nums.reduce((a, b) => a + b); + } +} diff --git a/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.go b/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.go new file mode 100644 index 00000000..911094af --- /dev/null +++ b/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.go @@ -0,0 +1,18 @@ +func largestSumAfterKNegations(nums []int, k int) int { + sort.Ints(nums) + for i := 0; i < len(nums); i++ { + if nums[i] < 0 && k > 0 { + nums[i] = -nums[i] + k-- + } + } + sort.Ints(nums) + if k > 0 && k % 2 != 0 { + nums[0] = -nums[0] + } + sum := 0 + for _, num := range nums { + sum += num + } + return sum +} diff --git a/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.java b/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.java new file mode 100644 index 00000000..82e46c71 --- /dev/null +++ b/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.java @@ -0,0 +1,20 @@ +class Solution { + public int largestSumAfterKNegations(int[] nums, int k) { + Arrays.sort(nums); + for (int i = 0; i < nums.length; i++) { + if (nums[i] < 0 && k > 0) { + nums[i] = -nums[i]; + k--; + } + } + Arrays.sort(nums); + if (k > 0 && k % 2 != 0) { + nums[0] = -nums[0]; + } + int sum = 0; + for (int num : nums) { + sum += num; + } + return sum; + } +} diff --git a/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.kt b/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.kt new file mode 100644 index 00000000..d4c6d45f --- /dev/null +++ b/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.kt @@ -0,0 +1,17 @@ +class Solution { + fun largestSumAfterKNegations(nums: IntArray, k: Int): Int { + nums.sort() + var remainingK = k + for (i in nums.indices) { + if (nums[i] < 0 && remainingK > 0) { + nums[i] = -nums[i] + remainingK-- + } + } + nums.sort() + if (remainingK > 0 && remainingK % 2 != 0) { + nums[0] = -nums[0] + } + return nums.sum() + } +} diff --git a/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.py b/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.py new file mode 100644 index 00000000..b651af87 --- /dev/null +++ b/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.py @@ -0,0 +1,14 @@ +from typing import List + + +class Solution: + def largestSumAfterKNegations(self, nums: List[int], k: int) -> int: + nums = sorted(nums) + for i in range(len(nums)): + if nums[i] < 0 and k > 0: + nums[i] = -nums[i] + k -= 1 + nums = sorted(nums) + if k > 0 and k % 2 != 0: + nums[0] = -nums[0] + return sum(nums) diff --git a/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.py2 b/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.py2 new file mode 100644 index 00000000..53330a23 --- /dev/null +++ b/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.py2 @@ -0,0 +1,16 @@ +class Solution(object): + def largestSumAfterKNegations(self, nums, k): + """ + :type nums: List[int] + :type k: int + :rtype: int + """ + nums = sorted(nums) + for i in range(len(nums)): + if nums[i] < 0 and k > 0: + nums[i] = -nums[i] + k -= 1 + nums = sorted(nums) + if k > 0 and k % 2 != 0: + nums[0] = -nums[0] + return sum(nums) diff --git a/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.rb b/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.rb new file mode 100644 index 00000000..b4f0559b --- /dev/null +++ b/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.rb @@ -0,0 +1,17 @@ +# @param {Integer[]} nums +# @param {Integer} k +# @return {Integer} +def largest_sum_after_k_negations(nums, k) + nums.sort! + nums.each_with_index do |num, i| + if num < 0 && k > 0 + nums[i] = -num + k -= 1 + end + end + nums.sort! + if k > 0 && k % 2 != 0 + nums[0] = -nums[0] + end + nums.sum +end diff --git a/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.rs b/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.rs new file mode 100644 index 00000000..1f326f04 --- /dev/null +++ b/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.rs @@ -0,0 +1,18 @@ +impl Solution { + pub fn largest_sum_after_k_negations(nums: Vec, k: i32) -> i32 { + let mut nums = nums; + let mut k = k; + nums.sort(); + for i in 0..nums.len() { + if nums[i] < 0 && k > 0 { + nums[i] = -nums[i]; + k -= 1; + } + } + nums.sort(); + if k > 0 && k % 2 != 0 { + nums[0] = -nums[0]; + } + nums.iter().sum() + } +} diff --git a/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.swift b/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.swift new file mode 100644 index 00000000..8a70ebc6 --- /dev/null +++ b/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.swift @@ -0,0 +1,17 @@ +class Solution { + func largestSumAfterKNegations(_ nums: [Int], _ k: Int) -> Int { + var nums = nums.sorted() + var remainingK = k + for i in 0.. 0 { + nums[i] = -nums[i] + remainingK -= 1 + } + } + nums = nums.sorted() + if remainingK > 0 && remainingK % 2 != 0 { + nums[0] = -nums[0] + } + return nums.reduce(0, +) + } +} diff --git a/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.ts b/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.ts new file mode 100644 index 00000000..8ba56cba --- /dev/null +++ b/tests/1001-1500/1005. maximize-sum-of-array-after-k-negations/sol.ts @@ -0,0 +1,14 @@ +function largestSumAfterKNegations(nums: number[], k: number): number { + nums.sort((a, b) => a - b); + for (let i = 0; i < nums.length; i++) { + if (nums[i] < 0 && k > 0) { + nums[i] = -nums[i]; + k--; + } + } + nums.sort((a, b) => a - b); + if (k > 0 && k % 2 !== 0) { + nums[0] = -nums[0]; + } + return nums.reduce((a, b) => a + b, 0); +} diff --git a/tests/1001-1500/1006. clumsy-factorial/manifest.yaml b/tests/1001-1500/1006. clumsy-factorial/manifest.yaml new file mode 100644 index 00000000..2fde2936 --- /dev/null +++ b/tests/1001-1500/1006. clumsy-factorial/manifest.yaml @@ -0,0 +1,170 @@ +entry: + id: 1006 + title: clumsy-factorial + params: + n: + type: int + call: + cpp: Solution().clumsy({n}) + rust: Solution::clumsy({n}) + python3: Solution().clumsy({n}) + python2: Solution().clumsy({n}) + ruby: clumsy({n}) + java: new Solution().clumsy({n}) + csharp: new Solution().Clumsy({n}) + kotlin: Solution().clumsy({n}) + go: clumsy({n}) + dart: Solution().clumsy({n}) + swift: Solution().clumsy({n}) + typescript: clumsy({n}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 1006 +tests: + - name: case_1 + in: + n: 21 + out: 23 + - name: case_2 + in: + n: 30 + out: 32 + - name: case_3 + in: + n: 2 + out: 2 + - name: case_4 + in: + n: 7 + out: 6 + - name: case_5 + in: + n: 15 + out: 14 + - name: case_6 + in: + n: 19 + out: 18 + - name: case_7 + in: + n: 9 + out: 11 + - name: case_8 + in: + n: 4 + out: 7 + - name: case_9 + in: + n: 19 + out: 18 + - name: case_10 + in: + n: 16 + out: 17 + - name: case_11 + in: + n: 12 + out: 13 + - name: case_12 + in: + n: 25 + out: 27 + - name: case_13 + in: + n: 13 + out: 15 + - name: case_14 + in: + n: 9 + out: 11 + - name: case_15 + in: + n: 27 + out: 26 + - name: case_16 + in: + n: 26 + out: 28 + - name: case_17 + in: + n: 26 + out: 28 + - name: case_18 + in: + n: 14 + out: 16 + - name: case_19 + in: + n: 25 + out: 27 + - name: case_20 + in: + n: 27 + out: 26 + - name: case_21 + in: + n: 13 + out: 15 + - name: case_22 + in: + n: 10 + out: 12 + - name: case_23 + in: + n: 23 + out: 22 + - name: case_24 + in: + n: 12 + out: 13 + - name: case_25 + in: + n: 19 + out: 18 + - name: case_26 + in: + n: 29 + out: 31 + - name: case_27 + in: + n: 10 + out: 12 + - name: case_28 + in: + n: 12 + out: 13 + - name: case_29 + in: + n: 11 + out: 10 + - name: case_30 + in: + n: 2 + out: 2 + - name: case_31 + in: + n: 29 + out: 31 + - name: case_32 + in: + n: 28 + out: 29 + - name: case_33 + in: + n: 19 + out: 18 + - name: case_34 + in: + n: 26 + out: 28 + - name: case_35 + in: + n: 22 + out: 24 diff --git a/tests/1001-1500/1006. clumsy-factorial/sol.cpp b/tests/1001-1500/1006. clumsy-factorial/sol.cpp new file mode 100644 index 00000000..3ddeb01b --- /dev/null +++ b/tests/1001-1500/1006. clumsy-factorial/sol.cpp @@ -0,0 +1,22 @@ +class Solution { +public: + int clumsy(int n) { + if (n == 1) { + return 1; + } else if (n == 2) { + return 2; + } else if (n == 3) { + return 6; + } else if (n == 4) { + return 7; + } else { + if (n % 4 == 0) { + return n + 1; + } else if (n % 4 <= 2) { + return n + 2; + } else { + return n - 1; + } + } + } +}; diff --git a/tests/1001-1500/1006. clumsy-factorial/sol.cs b/tests/1001-1500/1006. clumsy-factorial/sol.cs new file mode 100644 index 00000000..c7dcc6e8 --- /dev/null +++ b/tests/1001-1500/1006. clumsy-factorial/sol.cs @@ -0,0 +1,21 @@ +public class Solution { + public int Clumsy(int n) { + if (n == 1) { + return 1; + } else if (n == 2) { + return 2; + } else if (n == 3) { + return 6; + } else if (n == 4) { + return 7; + } else { + if (n % 4 == 0) { + return n + 1; + } else if (n % 4 <= 2) { + return n + 2; + } else { + return n - 1; + } + } + } +} diff --git a/tests/1001-1500/1006. clumsy-factorial/sol.dart b/tests/1001-1500/1006. clumsy-factorial/sol.dart new file mode 100644 index 00000000..0285f917 --- /dev/null +++ b/tests/1001-1500/1006. clumsy-factorial/sol.dart @@ -0,0 +1,21 @@ +class Solution { + int clumsy(int n) { + if (n == 1) { + return 1; + } else if (n == 2) { + return 2; + } else if (n == 3) { + return 6; + } else if (n == 4) { + return 7; + } else { + if (n % 4 == 0) { + return n + 1; + } else if (n % 4 <= 2) { + return n + 2; + } else { + return n - 1; + } + } + } +} diff --git a/tests/1001-1500/1006. clumsy-factorial/sol.go b/tests/1001-1500/1006. clumsy-factorial/sol.go new file mode 100644 index 00000000..94af00ef --- /dev/null +++ b/tests/1001-1500/1006. clumsy-factorial/sol.go @@ -0,0 +1,19 @@ +func clumsy(n int) int { + if n == 1 { + return 1 + } else if n == 2 { + return 2 + } else if n == 3 { + return 6 + } else if n == 4 { + return 7 + } else { + if n % 4 == 0 { + return n + 1 + } else if n % 4 <= 2 { + return n + 2 + } else { + return n - 1 + } + } +} diff --git a/tests/1001-1500/1006. clumsy-factorial/sol.java b/tests/1001-1500/1006. clumsy-factorial/sol.java new file mode 100644 index 00000000..e85d587e --- /dev/null +++ b/tests/1001-1500/1006. clumsy-factorial/sol.java @@ -0,0 +1,21 @@ +class Solution { + public int clumsy(int n) { + if (n == 1) { + return 1; + } else if (n == 2) { + return 2; + } else if (n == 3) { + return 6; + } else if (n == 4) { + return 7; + } else { + if (n % 4 == 0) { + return n + 1; + } else if (n % 4 <= 2) { + return n + 2; + } else { + return n - 1; + } + } + } +} diff --git a/tests/1001-1500/1006. clumsy-factorial/sol.kt b/tests/1001-1500/1006. clumsy-factorial/sol.kt new file mode 100644 index 00000000..696fcc38 --- /dev/null +++ b/tests/1001-1500/1006. clumsy-factorial/sol.kt @@ -0,0 +1,21 @@ +class Solution { + fun clumsy(n: Int): Int { + if (n == 1) { + return 1 + } else if (n == 2) { + return 2 + } else if (n == 3) { + return 6 + } else if (n == 4) { + return 7 + } else { + if (n % 4 == 0) { + return n + 1 + } else if (n % 4 <= 2) { + return n + 2 + } else { + return n - 1 + } + } + } +} diff --git a/tests/1001-1500/1006. clumsy-factorial/sol.py b/tests/1001-1500/1006. clumsy-factorial/sol.py new file mode 100644 index 00000000..f8bce4d8 --- /dev/null +++ b/tests/1001-1500/1006. clumsy-factorial/sol.py @@ -0,0 +1,17 @@ +class Solution(object): + def clumsy(self, n): + if n == 1: + return 1 + elif n == 2: + return 2 + elif n == 3: + return 6 + elif n == 4: + return 7 + else: + if n % 4 == 0: + return n + 1 + elif n % 4 <= 2: + return n + 2 + else: + return n - 1 diff --git a/tests/1001-1500/1006. clumsy-factorial/sol.py2 b/tests/1001-1500/1006. clumsy-factorial/sol.py2 new file mode 100644 index 00000000..f8bce4d8 --- /dev/null +++ b/tests/1001-1500/1006. clumsy-factorial/sol.py2 @@ -0,0 +1,17 @@ +class Solution(object): + def clumsy(self, n): + if n == 1: + return 1 + elif n == 2: + return 2 + elif n == 3: + return 6 + elif n == 4: + return 7 + else: + if n % 4 == 0: + return n + 1 + elif n % 4 <= 2: + return n + 2 + else: + return n - 1 diff --git a/tests/1001-1500/1006. clumsy-factorial/sol.rb b/tests/1001-1500/1006. clumsy-factorial/sol.rb new file mode 100644 index 00000000..dc1d1789 --- /dev/null +++ b/tests/1001-1500/1006. clumsy-factorial/sol.rb @@ -0,0 +1,21 @@ +# @param {Integer} n +# @return {Integer} +def clumsy(n) + if n == 1 + return 1 + elsif n == 2 + return 2 + elsif n == 3 + return 6 + elsif n == 4 + return 7 + else + if n % 4 == 0 + return n + 1 + elsif n % 4 <= 2 + return n + 2 + else + return n - 1 + end + end +end diff --git a/tests/1001-1500/1006. clumsy-factorial/sol.rs b/tests/1001-1500/1006. clumsy-factorial/sol.rs new file mode 100644 index 00000000..f8fa1c95 --- /dev/null +++ b/tests/1001-1500/1006. clumsy-factorial/sol.rs @@ -0,0 +1,21 @@ +impl Solution { + pub fn clumsy(n: i32) -> i32 { + if n == 1 { + return 1; + } else if n == 2 { + return 2; + } else if n == 3 { + return 6; + } else if n == 4 { + return 7; + } else { + if n % 4 == 0 { + return n + 1; + } else if n % 4 <= 2 { + return n + 2; + } else { + return n - 1; + } + } + } +} diff --git a/tests/1001-1500/1006. clumsy-factorial/sol.swift b/tests/1001-1500/1006. clumsy-factorial/sol.swift new file mode 100644 index 00000000..7960efb9 --- /dev/null +++ b/tests/1001-1500/1006. clumsy-factorial/sol.swift @@ -0,0 +1,21 @@ +class Solution { + func clumsy(_ n: Int) -> Int { + if n == 1 { + return 1 + } else if n == 2 { + return 2 + } else if n == 3 { + return 6 + } else if n == 4 { + return 7 + } else { + if n % 4 == 0 { + return n + 1 + } else if n % 4 <= 2 { + return n + 2 + } else { + return n - 1 + } + } + } +} diff --git a/tests/1001-1500/1006. clumsy-factorial/sol.ts b/tests/1001-1500/1006. clumsy-factorial/sol.ts new file mode 100644 index 00000000..a0b0dcbf --- /dev/null +++ b/tests/1001-1500/1006. clumsy-factorial/sol.ts @@ -0,0 +1,19 @@ +function clumsy(n: number): number { + if (n === 1) { + return 1; + } else if (n === 2) { + return 2; + } else if (n === 3) { + return 6; + } else if (n === 4) { + return 7; + } else { + if (n % 4 === 0) { + return n + 1; + } else if (n % 4 <= 2) { + return n + 2; + } else { + return n - 1; + } + } +} diff --git a/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/manifest.yaml b/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/manifest.yaml new file mode 100644 index 00000000..cedacecf --- /dev/null +++ b/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/manifest.yaml @@ -0,0 +1,611 @@ +entry: + id: 1007 + title: minimum-domino-rotations-for-equal-row + params: + tops: + type: array + items: + type: int + bottoms: + type: array + items: + type: int + call: + cpp: Solution().minDominoRotations({tops}, {bottoms}) + rust: Solution::min_domino_rotations({tops}, {bottoms}) + python3: Solution().minDominoRotations({tops}, {bottoms}) + python2: Solution().minDominoRotations({tops}, {bottoms}) + ruby: min_domino_rotations({tops}, {bottoms}) + java: new Solution().minDominoRotations({tops}, {bottoms}) + csharp: new Solution().MinDominoRotations({tops}, {bottoms}) + kotlin: Solution().minDominoRotations({tops}, {bottoms}) + go: minDominoRotations({tops}, {bottoms}) + dart: Solution().minDominoRotations({tops}, {bottoms}) + swift: Solution().minDominoRotations({tops}, {bottoms}) + typescript: minDominoRotations({tops}, {bottoms}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 1007 +tests: + - name: case_1 + in: + tops: + - 4 + - 3 + - 6 + - 2 + - 1 + - 4 + - 4 + - 2 + - 1 + - 5 + bottoms: + - 1 + - 4 + - 6 + - 5 + - 2 + - 2 + - 5 + - 2 + - 3 + - 6 + out: -1 + - name: case_2 + in: + tops: + - 1 + - 5 + - 3 + - 6 + - 3 + - 4 + - 1 + - 6 + bottoms: + - 5 + - 6 + - 5 + - 4 + - 5 + - 1 + - 1 + - 3 + out: -1 + - name: case_3 + in: + tops: + - 5 + - 3 + - 3 + - 5 + bottoms: + - 4 + - 5 + - 5 + - 2 + out: 2 + - name: case_4 + in: + tops: + - 6 + - 2 + - 1 + - 4 + - 2 + - 2 + - 5 + - 6 + - 4 + bottoms: + - 5 + - 5 + - 4 + - 5 + - 1 + - 4 + - 3 + - 2 + - 2 + out: -1 + - name: case_5 + in: + tops: + - 4 + - 5 + - 1 + - 3 + - 6 + - 4 + - 4 + - 5 + - 6 + bottoms: + - 1 + - 3 + - 6 + - 1 + - 3 + - 6 + - 1 + - 1 + - 1 + out: -1 + - name: case_6 + in: + tops: + - 4 + - 3 + - 5 + bottoms: + - 1 + - 4 + - 6 + out: -1 + - name: case_7 + in: + tops: + - 1 + - 3 + - 4 + - 3 + - 6 + - 2 + - 6 + - 2 + bottoms: + - 3 + - 2 + - 5 + - 2 + - 6 + - 3 + - 2 + - 6 + out: -1 + - name: case_8 + in: + tops: + - 4 + - 4 + - 3 + - 5 + - 6 + - 2 + - 6 + - 3 + bottoms: + - 5 + - 2 + - 1 + - 6 + - 5 + - 5 + - 4 + - 3 + out: -1 + - name: case_9 + in: + tops: + - 6 + - 2 + - 3 + bottoms: + - 5 + - 4 + - 4 + out: -1 + - name: case_10 + in: + tops: + - 1 + - 4 + - 3 + - 1 + - 2 + - 6 + - 3 + - 4 + - 1 + bottoms: + - 1 + - 1 + - 5 + - 5 + - 5 + - 3 + - 2 + - 3 + - 3 + out: -1 + - name: case_11 + in: + tops: + - 4 + - 2 + - 2 + - 4 + - 5 + - 6 + - 3 + - 5 + - 3 + bottoms: + - 4 + - 6 + - 4 + - 1 + - 4 + - 4 + - 4 + - 5 + - 1 + out: -1 + - name: case_12 + in: + tops: + - 5 + - 1 + - 1 + - 3 + - 2 + - 4 + - 6 + - 5 + - 4 + bottoms: + - 5 + - 3 + - 4 + - 6 + - 3 + - 3 + - 2 + - 6 + - 6 + out: -1 + - name: case_13 + in: + tops: + - 6 + - 1 + - 5 + - 4 + - 2 + - 1 + - 5 + - 6 + - 3 + bottoms: + - 2 + - 6 + - 1 + - 1 + - 6 + - 2 + - 6 + - 4 + - 3 + out: -1 + - name: case_14 + in: + tops: + - 4 + bottoms: + - 5 + out: 0 + - name: case_15 + in: + tops: + - 1 + - 3 + - 3 + - 4 + - 1 + bottoms: + - 3 + - 5 + - 1 + - 4 + - 1 + out: -1 + - name: case_16 + in: + tops: + - 4 + - 2 + - 4 + - 1 + - 5 + - 3 + - 2 + - 3 + bottoms: + - 5 + - 6 + - 5 + - 5 + - 2 + - 2 + - 3 + - 4 + out: -1 + - name: case_17 + in: + tops: + - 3 + - 1 + - 3 + - 6 + - 4 + - 6 + bottoms: + - 5 + - 5 + - 1 + - 4 + - 3 + - 5 + out: -1 + - name: case_18 + in: + tops: + - 1 + bottoms: + - 2 + out: 0 + - name: case_19 + in: + tops: + - 3 + - 5 + - 4 + bottoms: + - 4 + - 6 + - 2 + out: -1 + - name: case_20 + in: + tops: + - 2 + - 4 + - 6 + - 3 + - 2 + - 4 + - 6 + bottoms: + - 1 + - 5 + - 2 + - 6 + - 6 + - 6 + - 3 + out: -1 + - name: case_21 + in: + tops: + - 5 + - 1 + - 4 + bottoms: + - 4 + - 5 + - 2 + out: -1 + - name: case_22 + in: + tops: + - 1 + - 6 + - 1 + bottoms: + - 2 + - 5 + - 1 + out: -1 + - name: case_23 + in: + tops: + - 1 + - 4 + - 5 + - 1 + - 2 + - 2 + bottoms: + - 2 + - 4 + - 6 + - 4 + - 5 + - 5 + out: -1 + - name: case_24 + in: + tops: + - 1 + - 4 + - 5 + - 5 + - 2 + - 5 + bottoms: + - 4 + - 5 + - 6 + - 2 + - 1 + - 3 + out: -1 + - name: case_25 + in: + tops: + - 1 + - 2 + - 1 + - 4 + - 1 + - 5 + - 3 + - 5 + - 6 + bottoms: + - 4 + - 4 + - 1 + - 3 + - 6 + - 4 + - 3 + - 2 + - 2 + out: -1 + - name: case_26 + in: + tops: + - 6 + - 3 + - 4 + - 4 + bottoms: + - 2 + - 3 + - 6 + - 3 + out: -1 + - name: case_27 + in: + tops: + - 3 + - 2 + - 2 + - 2 + - 6 + - 2 + - 1 + - 5 + - 3 + - 6 + bottoms: + - 1 + - 2 + - 1 + - 4 + - 2 + - 4 + - 4 + - 5 + - 3 + - 5 + out: -1 + - name: case_28 + in: + tops: + - 6 + - 4 + - 6 + - 2 + bottoms: + - 4 + - 3 + - 5 + - 6 + out: -1 + - name: case_29 + in: + tops: + - 5 + - 1 + bottoms: + - 2 + - 2 + out: 0 + - name: case_30 + in: + tops: + - 6 + - 6 + - 5 + - 5 + - 6 + bottoms: + - 5 + - 5 + - 5 + - 6 + - 6 + out: -1 + - name: case_31 + in: + tops: + - 4 + - 3 + - 2 + bottoms: + - 3 + - 3 + - 2 + out: -1 + - name: case_32 + in: + tops: + - 3 + - 3 + - 6 + - 5 + - 2 + - 5 + - 5 + - 5 + - 2 + bottoms: + - 2 + - 5 + - 4 + - 5 + - 6 + - 6 + - 6 + - 6 + - 4 + out: -1 + - name: case_33 + in: + tops: + - 6 + - 3 + bottoms: + - 3 + - 2 + out: 1 + - name: case_34 + in: + tops: + - 5 + - 4 + bottoms: + - 2 + - 1 + out: -1 + - name: case_35 + in: + tops: + - 1 + - 4 + - 4 + bottoms: + - 3 + - 3 + - 1 + out: -1 diff --git a/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.cpp b/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.cpp new file mode 100644 index 00000000..20dec678 --- /dev/null +++ b/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.cpp @@ -0,0 +1,34 @@ +class Solution { +public: + int minDominoRotations(vector& tops, vector& bottoms) { + int n = tops.size(); + int res = INT_MAX; + vector face(7, 0); + for (int i = 0; i < n; i++) { + face[tops[i]]++; + if (bottoms[i] != tops[i]) { + face[bottoms[i]]++; + } + } + for (int x = 1; x <= 6; x++) { + if (face[x] < n) { + continue; + } + int maintainTop = 0; + int maintainBottom = 0; + bool possible = true; + for (int i = 0; i < n; i++) { + if (tops[i] != x) { + maintainTop++; + } + if (bottoms[i] != x) { + maintainBottom++; + } + } + if (possible) { + res = min(res, min(maintainTop, maintainBottom)); + } + } + return res == INT_MAX ? -1 : res; + } +}; diff --git a/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.cs b/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.cs new file mode 100644 index 00000000..9c58e1a5 --- /dev/null +++ b/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.cs @@ -0,0 +1,33 @@ +public class Solution { + public int MinDominoRotations(int[] tops, int[] bottoms) { + int n = tops.Length; + int res = int.MaxValue; + int[] face = new int[7]; + for (int i = 0; i < n; i++) { + face[tops[i]]++; + if (bottoms[i] != tops[i]) { + face[bottoms[i]]++; + } + } + for (int x = 1; x <= 6; x++) { + if (face[x] < n) { + continue; + } + int maintainTop = 0; + int maintainBottom = 0; + bool possible = true; + for (int i = 0; i < n; i++) { + if (tops[i] != x) { + maintainTop++; + } + if (bottoms[i] != x) { + maintainBottom++; + } + } + if (possible) { + res = Math.Min(res, Math.Min(maintainTop, maintainBottom)); + } + } + return res == int.MaxValue ? -1 : res; + } +} diff --git a/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.dart b/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.dart new file mode 100644 index 00000000..23d418d4 --- /dev/null +++ b/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.dart @@ -0,0 +1,36 @@ +class Solution { + int minDominoRotations(List tops, List bottoms) { + int n = tops.length; + int res = double.maxFinite.toInt(); + List face = List.filled(7, 0); + for (int i = 0; i < n; i++) { + face[tops[i]]++; + if (bottoms[i] != tops[i]) { + face[bottoms[i]]++; + } + } + for (int x = 1; x <= 6; x++) { + if (face[x] < n) { + continue; + } + int maintainTop = 0; + int maintainBottom = 0; + bool possible = true; + for (int i = 0; i < n; i++) { + if (tops[i] != x) { + maintainTop++; + } + if (bottoms[i] != x) { + maintainBottom++; + } + } + if (possible) { + int minVal = maintainTop < maintainBottom ? maintainTop : maintainBottom; + if (minVal < res) { + res = minVal; + } + } + } + return res == double.maxFinite.toInt() ? -1 : res; + } +} diff --git a/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.go b/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.go new file mode 100644 index 00000000..e2ba9050 --- /dev/null +++ b/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.go @@ -0,0 +1,39 @@ +func minDominoRotations(tops []int, bottoms []int) int { + n := len(tops) + res := int(^uint(0) >> 1) // max int + face := make([]int, 7) + for i := 0; i < n; i++ { + face[tops[i]]++ + if bottoms[i] != tops[i] { + face[bottoms[i]]++ + } + } + for x := 1; x <= 6; x++ { + if face[x] < n { + continue + } + maintainTop := 0 + maintainBottom := 0 + possible := true + for i := 0; i < n; i++ { + if tops[i] != x { + maintainTop++ + } + if bottoms[i] != x { + maintainBottom++ + } + } + if possible { + if maintainTop < res { + res = maintainTop + } + if maintainBottom < res { + res = maintainBottom + } + } + } + if res == int(^uint(0)>>1) { + return -1 + } + return res +} diff --git a/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.java b/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.java new file mode 100644 index 00000000..0c10ed56 --- /dev/null +++ b/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.java @@ -0,0 +1,33 @@ +class Solution { + public int minDominoRotations(int[] tops, int[] bottoms) { + int n = tops.length; + int res = Integer.MAX_VALUE; + int[] face = new int[7]; + for (int i = 0; i < n; i++) { + face[tops[i]]++; + if (bottoms[i] != tops[i]) { + face[bottoms[i]]++; + } + } + for (int x = 1; x <= 6; x++) { + if (face[x] < n) { + continue; + } + int maintainTop = 0; + int maintainBottom = 0; + boolean possible = true; + for (int i = 0; i < n; i++) { + if (tops[i] != x) { + maintainTop++; + } + if (bottoms[i] != x) { + maintainBottom++; + } + } + if (possible) { + res = Math.min(res, Math.min(maintainTop, maintainBottom)); + } + } + return res == Integer.MAX_VALUE ? -1 : res; + } +} diff --git a/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.kt b/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.kt new file mode 100644 index 00000000..724abf34 --- /dev/null +++ b/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.kt @@ -0,0 +1,33 @@ +class Solution { + fun minDominoRotations(tops: IntArray, bottoms: IntArray): Int { + val n = tops.size + var res = Int.MAX_VALUE + val face = IntArray(7) + for (i in 0 until n) { + face[tops[i]]++ + if (bottoms[i] != tops[i]) { + face[bottoms[i]]++ + } + } + for (x in 1..6) { + if (face[x] < n) { + continue + } + var maintainTop = 0 + var maintainBottom = 0 + var possible = true + for (i in 0 until n) { + if (tops[i] != x) { + maintainTop++ + } + if (bottoms[i] != x) { + maintainBottom++ + } + } + if (possible) { + res = minOf(res, minOf(maintainTop, maintainBottom)) + } + } + return if (res == Int.MAX_VALUE) -1 else res + } +} diff --git a/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.py b/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.py new file mode 100644 index 00000000..806f093a --- /dev/null +++ b/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.py @@ -0,0 +1,25 @@ +from typing import List + + +class Solution(object): + def minDominoRotations(self, tops, bottoms): + n = len(tops) + res = float("inf") + face = [0] * 7 + for i in range(n): + face[tops[i]] += 1 + if bottoms[i] != tops[i]: + face[bottoms[i]] += 1 + for x in range(1, 7): + if face[x] < n: + continue + maintainTop = maintainBottom = 0 + possible = True + for i in range(n): + if tops[i] != x: + maintainTop += 1 + if bottoms[i] != x: + maintainBottom += 1 + if possible: + res = min(res, maintainTop, maintainBottom) + return -1 if res == float("inf") else res diff --git a/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.py2 b/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.py2 new file mode 100644 index 00000000..8c95c9fd --- /dev/null +++ b/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.py2 @@ -0,0 +1,22 @@ +class Solution(object): + def minDominoRotations(self, tops, bottoms): + n = len(tops) + res = float('inf') + face = [0]*7 + for i in range(n): + face[tops[i]] += 1 + if bottoms[i] != tops[i]: + face[bottoms[i]] += 1 + for x in range(1, 7): + if face[x] < n: + continue + maintainTop = maintainBottom = 0 + possible = True + for i in range(n): + if tops[i] != x: + maintainTop += 1 + if bottoms[i] != x: + maintainBottom += 1 + if possible: + res = min(res, maintainTop, maintainBottom) + return -1 if res == float('inf') else res diff --git a/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.rb b/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.rb new file mode 100644 index 00000000..f3863c42 --- /dev/null +++ b/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.rb @@ -0,0 +1,34 @@ +# @param {Integer[]} tops +# @param {Integer[]} bottoms +# @return {Integer} +def min_domino_rotations(tops, bottoms) + n = tops.length + res = Float::INFINITY + face = Array.new(7, 0) + (0...n).each do |i| + face[tops[i]] += 1 + if bottoms[i] != tops[i] + face[bottoms[i]] += 1 + end + end + (1..6).each do |x| + if face[x] < n + next + end + maintain_top = 0 + maintain_bottom = 0 + possible = true + (0...n).each do |i| + if tops[i] != x + maintain_top += 1 + end + if bottoms[i] != x + maintain_bottom += 1 + end + end + if possible + res = [res, maintain_top, maintain_bottom].min + end + end + res == Float::INFINITY ? -1 : res +end diff --git a/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.rs b/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.rs new file mode 100644 index 00000000..97d048e9 --- /dev/null +++ b/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.rs @@ -0,0 +1,33 @@ +impl Solution { + pub fn min_domino_rotations(tops: Vec, bottoms: Vec) -> i32 { + let n = tops.len(); + let mut res = i32::MAX; + let mut face = vec![0; 7]; + for i in 0..n { + face[tops[i] as usize] += 1; + if bottoms[i] != tops[i] { + face[bottoms[i] as usize] += 1; + } + } + for x in 1..=6 { + if face[x] < n { + continue; + } + let mut maintain_top = 0; + let mut maintain_bottom = 0; + let possible = true; + for i in 0..n { + if tops[i] != x as i32 { + maintain_top += 1; + } + if bottoms[i] != x as i32 { + maintain_bottom += 1; + } + } + if possible { + res = res.min(maintain_top.min(maintain_bottom)); + } + } + if res == i32::MAX { -1 } else { res } + } +} diff --git a/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.swift b/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.swift new file mode 100644 index 00000000..7838da58 --- /dev/null +++ b/tests/1001-1500/1007. minimum-domino-rotations-for-equal-row/sol.swift @@ -0,0 +1,33 @@ +class Solution { + func minDominoRotations(_ tops: [Int], _ bottoms: [Int]) -> Int { + let n = tops.count + var res = Int.max + var face = [Int](repeating: 0, count: 7) + for i in 0..& preorder) { + if (preorder.empty()) { + return nullptr; + } + return build(preorder, 0, preorder.size() - 1); + } + +private: + TreeNode* build(vector& preorder, int start, int end) { + if (start > end) { + return nullptr; + } + TreeNode* root = new TreeNode(preorder[start]); + int i = start + 1; + while (i <= end && preorder[i] < root->val) { + i++; + } + root->left = build(preorder, start + 1, i - 1); + root->right = build(preorder, i, end); + return root; + } +}; diff --git a/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.cs b/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.cs new file mode 100644 index 00000000..435be4ea --- /dev/null +++ b/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.cs @@ -0,0 +1,35 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public int val; + * public TreeNode left; + * public TreeNode right; + * public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +public class Solution { + public TreeNode BstFromPreorder(int[] preorder) { + if (preorder.Length == 0) { + return null; + } + return Build(preorder, 0, preorder.Length - 1); + } + + private TreeNode Build(int[] preorder, int start, int end) { + if (start > end) { + return null; + } + TreeNode root = new TreeNode(preorder[start]); + int i = start + 1; + while (i <= end && preorder[i] < root.val) { + i++; + } + root.left = Build(preorder, start + 1, i - 1); + root.right = Build(preorder, i, end); + return root; + } +} diff --git a/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.dart b/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.dart new file mode 100644 index 00000000..257babec --- /dev/null +++ b/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.dart @@ -0,0 +1,31 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * int val; + * TreeNode? left; + * TreeNode? right; + * TreeNode([this.val = 0, this.left, this.right]); + * } + */ +class Solution { + TreeNode? bstFromPreorder(List preorder) { + if (preorder.isEmpty) { + return null; + } + return build(preorder, 0, preorder.length - 1); + } + + TreeNode? build(List preorder, int start, int end) { + if (start > end) { + return null; + } + TreeNode root = TreeNode(preorder[start]); + int i = start + 1; + while (i <= end && preorder[i] < root.val) { + i++; + } + root.left = build(preorder, start + 1, i - 1); + root.right = build(preorder, i, end); + return root; + } +} diff --git a/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.go b/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.go new file mode 100644 index 00000000..823647df --- /dev/null +++ b/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.go @@ -0,0 +1,28 @@ +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +func bstFromPreorder(preorder []int) *TreeNode { + if len(preorder) == 0 { + return nil + } + var build func(start, end int) *TreeNode + build = func(start, end int) *TreeNode { + if start > end { + return nil + } + root := &TreeNode{Val: preorder[start]} + i := start + 1 + for i <= end && preorder[i] < root.Val { + i++ + } + root.Left = build(start+1, i-1) + root.Right = build(i, end) + return root + } + return build(0, len(preorder)-1) +} diff --git a/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.java b/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.java new file mode 100644 index 00000000..12fc2a1b --- /dev/null +++ b/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.java @@ -0,0 +1,37 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode() {} + * TreeNode(int val) { this.val = val; } + * TreeNode(int val, TreeNode left, TreeNode right) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +class Solution { + public TreeNode bstFromPreorder(int[] preorder) { + if (preorder.length == 0) { + return null; + } + return build(preorder, 0, preorder.length - 1); + } + + private TreeNode build(int[] preorder, int start, int end) { + if (start > end) { + return null; + } + TreeNode root = new TreeNode(preorder[start]); + int i = start + 1; + while (i <= end && preorder[i] < root.val) { + i++; + } + root.left = build(preorder, start + 1, i - 1); + root.right = build(preorder, i, end); + return root; + } +} diff --git a/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.kt b/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.kt new file mode 100644 index 00000000..7f007f54 --- /dev/null +++ b/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.kt @@ -0,0 +1,32 @@ +/** + * Example: + * var ti = TreeNode(5) + * var v = ti.`val` + * Definition for a binary tree node. + * class TreeNode(var `val`: Int) { + * var left: TreeNode? = null + * var right: TreeNode? = null + * } + */ +class Solution { + fun bstFromPreorder(preorder: IntArray): TreeNode? { + if (preorder.isEmpty()) { + return null + } + return build(preorder, 0, preorder.size - 1) + } + + private fun build(preorder: IntArray, start: Int, end: Int): TreeNode? { + if (start > end) { + return null + } + val root = TreeNode(preorder[start]) + var i = start + 1 + while (i <= end && preorder[i] < root.`val`) { + i++ + } + root.left = build(preorder, start + 1, i - 1) + root.right = build(preorder, i, end) + return root + } +} diff --git a/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.py b/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.py new file mode 100644 index 00000000..4a7872bb --- /dev/null +++ b/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.py @@ -0,0 +1,20 @@ +# Definition for a binary tree node. +# class TreeNode: +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +from typing import List, Optional + + +class Solution: + def bstFromPreorder(self, preorder: List[int]) -> TreeNode: + if not preorder: + return None + root = TreeNode(preorder[0]) + i = 1 + while i < len(preorder) and preorder[i] < root.val: + i += 1 + root.left = self.bstFromPreorder(preorder[1:i]) + root.right = self.bstFromPreorder(preorder[i:]) + return root diff --git a/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.py2 b/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.py2 new file mode 100644 index 00000000..319a19a8 --- /dev/null +++ b/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.py2 @@ -0,0 +1,21 @@ +# Definition for a binary tree node. +# class TreeNode(object): +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution(object): + def bstFromPreorder(self, preorder): + """ + :type preorder: List[int] + :rtype: Optional[TreeNode] + """ + if not preorder: + return None + root = TreeNode(preorder[0]) + i = 1 + while i < len(preorder) and preorder[i] < root.val: + i += 1 + root.left = self.bstFromPreorder(preorder[1:i]) + root.right = self.bstFromPreorder(preorder[i:]) + return root diff --git a/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.rb b/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.rb new file mode 100644 index 00000000..dabe0b0b --- /dev/null +++ b/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.rb @@ -0,0 +1,22 @@ +# Definition for a binary tree node. +# class TreeNode +# attr_accessor :val, :left, :right +# def initialize(val = 0, left = nil, right = nil) +# @val = val +# @left = left +# @right = right +# end +# end +# @param {Integer[]} preorder +# @return {TreeNode} +def bst_from_preorder(preorder) + return nil if preorder.empty? + root = TreeNode.new(preorder[0]) + i = 1 + while i < preorder.length && preorder[i] < root.val + i += 1 + end + root.left = bst_from_preorder(preorder[1...i]) + root.right = bst_from_preorder(preorder[i..-1]) + return root +end diff --git a/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.rs b/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.rs new file mode 100644 index 00000000..24a2f0c2 --- /dev/null +++ b/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.rs @@ -0,0 +1,44 @@ +// Definition for a binary tree node. +// #[derive(Debug, PartialEq, Eq)] +// pub struct TreeNode { +// pub val: i32, +// pub left: Option>>, +// pub right: Option>>, +// } +// +// impl TreeNode { +// #[inline] +// pub fn new(val: i32) -> Self { +// TreeNode { +// val, +// left: None, +// right: None +// } +// } +// } +impl Solution { + pub fn bst_from_preorder(preorder: Vec) -> Option>> { + if preorder.is_empty() { + return None; + } + Self::build(&preorder, 0, preorder.len() - 1) + } + + fn build(preorder: &Vec, start: usize, end: usize) -> Option>> { + if start > end { + return None; + } + let root = Rc::new(RefCell::new(TreeNode::new(preorder[start]))); + let mut i = start + 1; + while i <= end && preorder[i] < preorder[start] { + i += 1; + } + if start + 1 <= i.saturating_sub(1) { + root.borrow_mut().left = Self::build(preorder, start + 1, i - 1); + } + if i <= end { + root.borrow_mut().right = Self::build(preorder, i, end); + } + Some(root) + } +} diff --git a/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.swift b/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.swift new file mode 100644 index 00000000..95c46729 --- /dev/null +++ b/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.swift @@ -0,0 +1,37 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public var val: Int + * public var left: TreeNode? + * public var right: TreeNode? + * public init() { self.val = 0; self.left = nil; self.right = nil; } + * public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; } + * public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) { + * self.val = val + * self.left = left + * self.right = right + * } + * } + */ +class Solution { + func bstFromPreorder(_ preorder: [Int]) -> TreeNode? { + if preorder.isEmpty { + return nil + } + return build(preorder, 0, preorder.count - 1) + } + + private func build(_ preorder: [Int], _ start: Int, _ end: Int) -> TreeNode? { + if start > end { + return nil + } + let root = TreeNode(preorder[start]) + var i = start + 1 + while i <= end && preorder[i] < root.val { + i += 1 + } + root.left = build(preorder, start + 1, i - 1) + root.right = build(preorder, i, end) + return root + } +} diff --git a/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.ts b/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.ts new file mode 100644 index 00000000..be414a07 --- /dev/null +++ b/tests/1001-1500/1008. construct-binary-search-tree-from-preorder-traversal/sol.ts @@ -0,0 +1,38 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ + +function bstFromPreorder(preorder: number[]): TreeNode | null { + if (preorder.length === 0) { + return null; + } + return build(preorder, 0, preorder.length - 1); +} + +function build( + preorder: number[], + start: number, + end: number, +): TreeNode | null { + if (start > end) { + return null; + } + const root = new TreeNode(preorder[start]); + let i = start + 1; + while (i <= end && preorder[i] < root.val) { + i++; + } + root.left = build(preorder, start + 1, i - 1); + root.right = build(preorder, i, end); + return root; +} diff --git a/tests/1001-1500/1009. complement-of-base-10-integer/manifest.yaml b/tests/1001-1500/1009. complement-of-base-10-integer/manifest.yaml new file mode 100644 index 00000000..1885aaa2 --- /dev/null +++ b/tests/1001-1500/1009. complement-of-base-10-integer/manifest.yaml @@ -0,0 +1,170 @@ +entry: + id: 1009 + title: complement-of-base-10-integer + params: + n: + type: int + call: + cpp: Solution().bitwiseComplement({n}) + rust: Solution::bitwise_complement({n}) + python3: Solution().bitwiseComplement({n}) + python2: Solution().bitwiseComplement({n}) + ruby: bitwise_complement({n}) + java: new Solution().bitwiseComplement({n}) + csharp: new Solution().BitwiseComplement({n}) + kotlin: Solution().bitwiseComplement({n}) + go: bitwiseComplement({n}) + dart: Solution().bitwiseComplement({n}) + swift: Solution().bitwiseComplement({n}) + typescript: bitwiseComplement({n}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 1009 +tests: + - name: case_1 + in: + n: 577 + out: 446 + - name: case_2 + in: + n: 128 + out: 127 + - name: case_3 + in: + n: 322 + out: 189 + - name: case_4 + in: + n: 372 + out: 139 + - name: case_5 + in: + n: 496 + out: 15 + - name: case_6 + in: + n: 922 + out: 101 + - name: case_7 + in: + n: 703 + out: 320 + - name: case_8 + in: + n: 919 + out: 104 + - name: case_9 + in: + n: 55 + out: 8 + - name: case_10 + in: + n: 295 + out: 216 + - name: case_11 + in: + n: 734 + out: 289 + - name: case_12 + in: + n: 758 + out: 265 + - name: case_13 + in: + n: 545 + out: 478 + - name: case_14 + in: + n: 907 + out: 116 + - name: case_15 + in: + n: 829 + out: 194 + - name: case_16 + in: + n: 886 + out: 137 + - name: case_17 + in: + n: 965 + out: 58 + - name: case_18 + in: + n: 300 + out: 211 + - name: case_19 + in: + n: 495 + out: 16 + - name: case_20 + in: + n: 910 + out: 113 + - name: case_21 + in: + n: 289 + out: 222 + - name: case_22 + in: + n: 429 + out: 82 + - name: case_23 + in: + n: 856 + out: 167 + - name: case_24 + in: + n: 9 + out: 6 + - name: case_25 + in: + n: 817 + out: 206 + - name: case_26 + in: + n: 642 + out: 381 + - name: case_27 + in: + n: 383 + out: 128 + - name: case_28 + in: + n: 855 + out: 168 + - name: case_29 + in: + n: 727 + out: 296 + - name: case_30 + in: + n: 120 + out: 7 + - name: case_31 + in: + n: 637 + out: 386 + - name: case_32 + in: + n: 658 + out: 365 + - name: case_33 + in: + n: 101 + out: 26 + - name: case_34 + in: + n: 221 + out: 34 + - name: case_35 + in: + n: 187 + out: 68 diff --git a/tests/1001-1500/1009. complement-of-base-10-integer/sol.cpp b/tests/1001-1500/1009. complement-of-base-10-integer/sol.cpp new file mode 100644 index 00000000..ee30739c --- /dev/null +++ b/tests/1001-1500/1009. complement-of-base-10-integer/sol.cpp @@ -0,0 +1,16 @@ +class Solution { +public: + int bitwiseComplement(int n) { + if (n == 0) { + return 1; + } + int bitLength = 0; + int temp = n; + while (temp > 0) { + bitLength++; + temp >>= 1; + } + int mask = (1 << bitLength) - 1; + return n ^ mask; + } +}; diff --git a/tests/1001-1500/1009. complement-of-base-10-integer/sol.cs b/tests/1001-1500/1009. complement-of-base-10-integer/sol.cs new file mode 100644 index 00000000..b46f1e3e --- /dev/null +++ b/tests/1001-1500/1009. complement-of-base-10-integer/sol.cs @@ -0,0 +1,15 @@ +public class Solution { + public int BitwiseComplement(int n) { + if (n == 0) { + return 1; + } + int bitLength = 0; + int value = n; + while (value > 0) { + bitLength++; + value >>= 1; + } + int mask = (1 << bitLength) - 1; + return n ^ mask; + } +} diff --git a/tests/1001-1500/1009. complement-of-base-10-integer/sol.dart b/tests/1001-1500/1009. complement-of-base-10-integer/sol.dart new file mode 100644 index 00000000..0ccf534d --- /dev/null +++ b/tests/1001-1500/1009. complement-of-base-10-integer/sol.dart @@ -0,0 +1,10 @@ +class Solution { + int bitwiseComplement(int n) { + if (n == 0) { + return 1; + } + int bitLength = n.toRadixString(2).length; + int mask = (1 << bitLength) - 1; + return n ^ mask; + } +} diff --git a/tests/1001-1500/1009. complement-of-base-10-integer/sol.go b/tests/1001-1500/1009. complement-of-base-10-integer/sol.go new file mode 100644 index 00000000..31a08593 --- /dev/null +++ b/tests/1001-1500/1009. complement-of-base-10-integer/sol.go @@ -0,0 +1,13 @@ +func bitwiseComplement(n int) int { + if n == 0 { + return 1 + } + bitLength := 0 + temp := n + for temp > 0 { + bitLength++ + temp >>= 1 + } + mask := (1 << bitLength) - 1 + return n ^ mask +} diff --git a/tests/1001-1500/1009. complement-of-base-10-integer/sol.java b/tests/1001-1500/1009. complement-of-base-10-integer/sol.java new file mode 100644 index 00000000..2fc86494 --- /dev/null +++ b/tests/1001-1500/1009. complement-of-base-10-integer/sol.java @@ -0,0 +1,10 @@ +class Solution { + public int bitwiseComplement(int n) { + if (n == 0) { + return 1; + } + int bit_length = Integer.toBinaryString(n).length(); + int mask = (1 << bit_length) - 1; + return n ^ mask; + } +} diff --git a/tests/1001-1500/1009. complement-of-base-10-integer/sol.kt b/tests/1001-1500/1009. complement-of-base-10-integer/sol.kt new file mode 100644 index 00000000..8dc26583 --- /dev/null +++ b/tests/1001-1500/1009. complement-of-base-10-integer/sol.kt @@ -0,0 +1,10 @@ +class Solution { + fun bitwiseComplement(n: Int): Int { + if (n == 0) { + return 1 + } + val bitLength = Integer.toBinaryString(n).length + val mask = (1 shl bitLength) - 1 + return n xor mask + } +} diff --git a/tests/1001-1500/1009. complement-of-base-10-integer/sol.py b/tests/1001-1500/1009. complement-of-base-10-integer/sol.py new file mode 100644 index 00000000..b80973e1 --- /dev/null +++ b/tests/1001-1500/1009. complement-of-base-10-integer/sol.py @@ -0,0 +1,8 @@ +# Added using AI +class Solution: + def bitwiseComplement(self, n: int) -> int: + if n == 0: + return 1 + bit_length = n.bit_length() + mask = (1 << bit_length) - 1 + return n ^ mask diff --git a/tests/1001-1500/1009. complement-of-base-10-integer/sol.py2 b/tests/1001-1500/1009. complement-of-base-10-integer/sol.py2 new file mode 100644 index 00000000..c58aef4a --- /dev/null +++ b/tests/1001-1500/1009. complement-of-base-10-integer/sol.py2 @@ -0,0 +1,11 @@ +class Solution(object): + def bitwiseComplement(self, n): + """ + :type n: int + :rtype: int + """ + if n == 0: + return 1 + bit_length = n.bit_length() + mask = (1 << bit_length) - 1 + return n ^ mask diff --git a/tests/1001-1500/1009. complement-of-base-10-integer/sol.rb b/tests/1001-1500/1009. complement-of-base-10-integer/sol.rb new file mode 100644 index 00000000..251103b9 --- /dev/null +++ b/tests/1001-1500/1009. complement-of-base-10-integer/sol.rb @@ -0,0 +1,10 @@ +# @param {Integer} n +# @return {Integer} +def bitwise_complement(n) + if n == 0 + return 1 + end + bit_length = n.bit_length + mask = (1 << bit_length) - 1 + return n ^ mask +end diff --git a/tests/1001-1500/1009. complement-of-base-10-integer/sol.rs b/tests/1001-1500/1009. complement-of-base-10-integer/sol.rs new file mode 100644 index 00000000..82a83b5d --- /dev/null +++ b/tests/1001-1500/1009. complement-of-base-10-integer/sol.rs @@ -0,0 +1,10 @@ +impl Solution { + pub fn bitwise_complement(n: i32) -> i32 { + if n == 0 { + return 1; + } + let bit_length = 32 - n.leading_zeros(); + let mask = (1 << bit_length) - 1; + n ^ mask + } +} diff --git a/tests/1001-1500/1009. complement-of-base-10-integer/sol.swift b/tests/1001-1500/1009. complement-of-base-10-integer/sol.swift new file mode 100644 index 00000000..0d0abe0c --- /dev/null +++ b/tests/1001-1500/1009. complement-of-base-10-integer/sol.swift @@ -0,0 +1,10 @@ +class Solution { + func bitwiseComplement(_ n: Int) -> Int { + if n == 0 { + return 1 + } + let bitLength = String(n, radix: 2).count + let mask = (1 << bitLength) - 1 + return n ^ mask + } +} diff --git a/tests/1001-1500/1009. complement-of-base-10-integer/sol.ts b/tests/1001-1500/1009. complement-of-base-10-integer/sol.ts new file mode 100644 index 00000000..e80c0d82 --- /dev/null +++ b/tests/1001-1500/1009. complement-of-base-10-integer/sol.ts @@ -0,0 +1,8 @@ +function bitwiseComplement(n: number): number { + if (n === 0) { + return 1; + } + const bitLength = n.toString(2).length; + const mask = (1 << bitLength) - 1; + return n ^ mask; +} diff --git a/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/manifest.yaml b/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/manifest.yaml new file mode 100644 index 00000000..9954daf3 --- /dev/null +++ b/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/manifest.yaml @@ -0,0 +1,410 @@ +entry: + id: 1010 + title: pairs-of-songs-with-total-durations-divisible-by-60 + params: + time: + type: array + items: + type: int + call: + cpp: Solution().numPairsDivisibleBy60({time}) + rust: Solution::num_pairs_divisible_by60({time}) + python3: Solution().numPairsDivisibleBy60({time}) + python2: Solution().numPairsDivisibleBy60({time}) + ruby: num_pairs_divisible_by60({time}) + java: new Solution().numPairsDivisibleBy60({time}) + csharp: new Solution().NumPairsDivisibleBy60({time}) + kotlin: Solution().numPairsDivisibleBy60({time}) + go: numPairsDivisibleBy60({time}) + dart: Solution().numPairsDivisibleBy60({time}) + swift: Solution().numPairsDivisibleBy60({time}) + typescript: numPairsDivisibleBy60({time}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 1010 +tests: + - name: case_1 + in: + time: + - 118 + - 499 + - 485 + - 339 + out: 0 + - name: case_2 + in: + time: + - 117 + out: 0 + - name: case_3 + in: + time: + - 450 + - 20 + - 187 + - 431 + - 199 + - 35 + - 302 + - 461 + - 297 + out: 1 + - name: case_4 + in: + time: + - 253 + - 167 + - 91 + - 420 + out: 1 + - name: case_5 + in: + time: + - 418 + - 411 + - 429 + - 115 + - 139 + - 79 + out: 1 + - name: case_6 + in: + time: + - 129 + - 178 + - 226 + - 32 + - 236 + out: 0 + - name: case_7 + in: + time: + - 136 + out: 0 + - name: case_8 + in: + time: + - 20 + - 351 + - 256 + - 310 + - 360 + - 237 + out: 0 + - name: case_9 + in: + time: + - 278 + - 180 + - 480 + out: 1 + - name: case_10 + in: + time: + - 124 + out: 0 + - name: case_11 + in: + time: + - 149 + - 200 + - 199 + - 280 + - 407 + - 76 + - 271 + - 317 + - 54 + - 397 + out: 2 + - name: case_12 + in: + time: + - 477 + - 374 + - 2 + - 335 + - 27 + - 289 + - 340 + out: 0 + - name: case_13 + in: + time: + - 119 + - 94 + - 30 + - 105 + - 183 + - 483 + - 86 + - 432 + - 162 + - 281 + - 346 + out: 1 + - name: case_14 + in: + time: + - 376 + - 443 + - 289 + - 203 + - 279 + - 384 + out: 0 + - name: case_15 + in: + time: + - 470 + - 370 + - 90 + - 301 + - 418 + - 247 + - 295 + - 191 + - 275 + - 392 + out: 1 + - name: case_16 + in: + time: + - 206 + - 362 + - 326 + - 244 + - 474 + - 178 + - 163 + - 262 + - 321 + - 332 + - 71 + out: 1 + - name: case_17 + in: + time: + - 152 + - 468 + - 277 + - 364 + - 315 + - 54 + out: 0 + - name: case_18 + in: + time: + - 242 + - 75 + - 485 + - 72 + - 305 + - 64 + - 30 + - 90 + out: 1 + - name: case_19 + in: + time: + - 412 + - 369 + - 455 + - 301 + - 470 + out: 0 + - name: case_20 + in: + time: + - 381 + - 185 + - 402 + - 9 + - 335 + - 233 + - 377 + - 494 + - 223 + - 31 + - 427 + - 163 + out: 3 + - name: case_21 + in: + time: + - 351 + - 94 + - 164 + - 420 + - 308 + out: 0 + - name: case_22 + in: + time: + - 244 + - 154 + - 55 + - 470 + - 217 + - 295 + - 48 + - 320 + - 260 + - 23 + - 195 + out: 1 + - name: case_23 + in: + time: + - 218 + - 424 + out: 0 + - name: case_24 + in: + time: + - 191 + - 360 + - 274 + - 61 + - 307 + - 316 + - 219 + - 64 + - 251 + - 454 + - 271 + - 478 + out: 0 + - name: case_25 + in: + time: + - 318 + - 45 + - 137 + - 307 + - 265 + out: 0 + - name: case_26 + in: + time: + - 429 + - 8 + - 495 + - 448 + - 92 + out: 1 + - name: case_27 + in: + time: + - 39 + - 379 + - 45 + - 403 + - 283 + - 500 + - 122 + - 224 + - 219 + out: 0 + - name: case_28 + in: + time: + - 100 + - 98 + - 55 + - 111 + - 289 + - 303 + - 297 + out: 1 + - name: case_29 + in: + time: + - 383 + - 91 + - 183 + - 358 + - 454 + - 196 + - 486 + - 402 + out: 0 + - name: case_30 + in: + time: + - 261 + - 87 + - 249 + - 59 + - 438 + - 196 + - 108 + out: 0 + - name: case_31 + in: + time: + - 291 + - 113 + - 346 + - 442 + - 454 + - 384 + out: 0 + - name: case_32 + in: + time: + - 499 + - 28 + - 135 + - 76 + - 5 + - 393 + - 272 + - 127 + out: 1 + - name: case_33 + in: + time: + - 56 + - 169 + - 275 + - 208 + out: 0 + - name: case_34 + in: + time: + - 340 + - 196 + - 32 + - 428 + - 44 + - 286 + - 379 + - 237 + - 79 + - 298 + - 298 + out: 1 + - name: case_35 + in: + time: + - 28 + - 295 + - 327 + - 237 + - 265 + - 189 + - 381 + - 212 + - 361 + - 83 + - 32 + - 204 + out: 2 diff --git a/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.cpp b/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.cpp new file mode 100644 index 00000000..45c28a34 --- /dev/null +++ b/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.cpp @@ -0,0 +1,19 @@ +class Solution { +public: + int numPairsDivisibleBy60(vector& time) { + vector remainders(60, 0); + for (int t : time) { + remainders[t % 60]++; + } + + long long count = 0; + count += remainders[0] * (remainders[0] - 1) / 2; + count += remainders[30] * (remainders[30] - 1) / 2; + + for (int i = 1; i < 30; i++) { + count += remainders[i] * remainders[60 - i]; + } + + return (int)count; + } +}; diff --git a/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.cs b/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.cs new file mode 100644 index 00000000..6aba245a --- /dev/null +++ b/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.cs @@ -0,0 +1,18 @@ +public class Solution { + public int NumPairsDivisibleBy60(int[] time) { + long[] remainders = new long[60]; + foreach (int t in time) { + remainders[t % 60]++; + } + + long count = 0; + count += remainders[0] * (remainders[0] - 1) / 2; + count += remainders[30] * (remainders[30] - 1) / 2; + + for (int i = 1; i < 30; i++) { + count += remainders[i] * remainders[60 - i]; + } + + return (int)count; + } +} diff --git a/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.dart b/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.dart new file mode 100644 index 00000000..c51a0b8d --- /dev/null +++ b/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.dart @@ -0,0 +1,18 @@ +class Solution { + int numPairsDivisibleBy60(List time) { + List remainders = List.filled(60, 0); + for (int t in time) { + remainders[t % 60]++; + } + + int count = 0; + count += remainders[0] * (remainders[0] - 1) ~/ 2; + count += remainders[30] * (remainders[30] - 1) ~/ 2; + + for (int i = 1; i < 30; i++) { + count += remainders[i] * remainders[60 - i]; + } + + return count; + } +} diff --git a/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.go b/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.go new file mode 100644 index 00000000..c0f985eb --- /dev/null +++ b/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.go @@ -0,0 +1,16 @@ +func numPairsDivisibleBy60(time []int) int { + remainders := make([]int, 60) + for _, t := range time { + remainders[t % 60]++ + } + + count := 0 + count += remainders[0] * (remainders[0] - 1) / 2 + count += remainders[30] * (remainders[30] - 1) / 2 + + for i := 1; i < 30; i++ { + count += remainders[i] * remainders[60 - i] + } + + return count +} diff --git a/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.java b/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.java new file mode 100644 index 00000000..205ed14c --- /dev/null +++ b/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.java @@ -0,0 +1,18 @@ +class Solution { + public int numPairsDivisibleBy60(int[] time) { + int[] remainders = new int[60]; + for (int t : time) { + remainders[t % 60]++; + } + + int count = 0; + count += remainders[0] * (remainders[0] - 1) / 2; + count += remainders[30] * (remainders[30] - 1) / 2; + + for (int i = 1; i < 30; i++) { + count += remainders[i] * remainders[60 - i]; + } + + return count; + } +} diff --git a/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.kt b/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.kt new file mode 100644 index 00000000..dee8bb86 --- /dev/null +++ b/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.kt @@ -0,0 +1,18 @@ +class Solution { + fun numPairsDivisibleBy60(time: IntArray): Int { + val remainders = IntArray(60) + for (t in time) { + remainders[t % 60]++ + } + + var count = 0 + count += remainders[0] * (remainders[0] - 1) / 2 + count += remainders[30] * (remainders[30] - 1) / 2 + + for (i in 1 until 30) { + count += remainders[i] * remainders[60 - i] + } + + return count + } +} diff --git a/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.py b/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.py new file mode 100644 index 00000000..8d0c7173 --- /dev/null +++ b/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.py @@ -0,0 +1,22 @@ +from typing import List + + +class Solution: + def numPairsDivisibleBy60(self, time: List[int]) -> int: + remainders = [0] * 60 + for t in time: + remainders[t % 60] += 1 + + count = 0 + + # Case 1: Songs with remainder 0 + count += remainders[0] * (remainders[0] - 1) // 2 + + # Case 2: Songs with remainder 30 + count += remainders[30] * (remainders[30] - 1) // 2 + + # Case 3: Complementary pairs (i and 60 - i) + for i in range(1, 30): + count += remainders[i] * remainders[60 - i] + + return count diff --git a/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.py2 b/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.py2 new file mode 100644 index 00000000..3dd92329 --- /dev/null +++ b/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.py2 @@ -0,0 +1,18 @@ +class Solution(object): + def numPairsDivisibleBy60(self, time): + """ + :type time: List[int] + :rtype: int + """ + remainders = [0] * 60 + for t in time: + remainders[t % 60] += 1 + + count = 0 + count += remainders[0] * (remainders[0] - 1) // 2 + count += remainders[30] * (remainders[30] - 1) // 2 + + for i in range(1, 30): + count += remainders[i] * remainders[60 - i] + + return count diff --git a/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.rb b/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.rb new file mode 100644 index 00000000..93410abb --- /dev/null +++ b/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.rb @@ -0,0 +1,18 @@ +# @param {Integer[]} time +# @return {Integer} +def num_pairs_divisible_by60(time) + remainders = Array.new(60, 0) + time.each do |t| + remainders[t % 60] += 1 + end + + count = 0 + count += remainders[0] * (remainders[0] - 1) / 2 + count += remainders[30] * (remainders[30] - 1) / 2 + + (1..29).each do |i| + count += remainders[i] * remainders[60 - i] + end + + count +end diff --git a/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.rs b/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.rs new file mode 100644 index 00000000..c53793b1 --- /dev/null +++ b/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.rs @@ -0,0 +1,18 @@ +impl Solution { + pub fn num_pairs_divisible_by60(time: Vec) -> i32 { + let mut remainders = vec![0i64; 60]; + for t in time { + remainders[(t % 60) as usize] += 1; + } + + let mut count = 0i64; + count += remainders[0] * (remainders[0] - 1) / 2; + count += remainders[30] * (remainders[30] - 1) / 2; + + for i in 1..30 { + count += remainders[i] * remainders[60 - i]; + } + + count as i32 + } +} diff --git a/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.swift b/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.swift new file mode 100644 index 00000000..80c7f593 --- /dev/null +++ b/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.swift @@ -0,0 +1,18 @@ +class Solution { + func numPairsDivisibleBy60(_ time: [Int]) -> Int { + var remainders = Array(repeating: 0, count: 60) + for t in time { + remainders[t % 60] += 1 + } + + var count = 0 + count += remainders[0] * (remainders[0] - 1) / 2 + count += remainders[30] * (remainders[30] - 1) / 2 + + for i in 1..<30 { + count += remainders[i] * remainders[60 - i] + } + + return count + } +} diff --git a/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.ts b/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.ts new file mode 100644 index 00000000..88477727 --- /dev/null +++ b/tests/1001-1500/1010. pairs-of-songs-with-total-durations-divisible-by-60/sol.ts @@ -0,0 +1,16 @@ +function numPairsDivisibleBy60(time: number[]): number { + const remainders: number[] = new Array(60).fill(0); + for (const t of time) { + remainders[t % 60]++; + } + + let count = 0; + count += (remainders[0] * (remainders[0] - 1)) / 2; + count += (remainders[30] * (remainders[30] - 1)) / 2; + + for (let i = 1; i < 30; i++) { + count += remainders[i] * remainders[60 - i]; + } + + return count; +} diff --git a/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/manifest.yaml b/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/manifest.yaml new file mode 100644 index 00000000..6c3c9094 --- /dev/null +++ b/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/manifest.yaml @@ -0,0 +1,411 @@ +entry: + id: 1011 + title: capacity to ship packages within d days + params: + weights: + type: array + items: + type: int + days: + type: int + call: + cpp: "Solution().shipWithinDays({weights}, {days})" + rust: "Solution::ship_within_days({weights}, {days})" + python3: "Solution().shipWithinDays({weights}, {days})" + python2: "Solution().shipWithinDays({weights}, {days})" + ruby: "ship_within_days({weights}, {days})" + java: "new Solution().shipWithinDays({weights}, {days})" + csharp: "new Solution().ShipWithinDays({weights}, {days})" + kotlin: "Solution().shipWithinDays({weights}, {days})" + go: "shipWithinDays({weights}, {days})" + dart: "Solution().shipWithinDays({weights}, {days})" + swift: "Solution().shipWithinDays({weights}, {days})" + typescript: "shipWithinDays({weights}, {days})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().check({result})" + checker: | + class Checker: + def check(self, result): + return True +seed: 1011 +tests: + - name: single-package-one-day + in: + weights: + - 5 + days: 1 + out: 5 + - name: single-package-many-days + in: + weights: + - 5 + days: 10 + out: 5 + - name: example-one + in: + weights: + - 1 + - 2 + - 3 + - 1 + - 1 + days: 4 + out: 3 + - name: example-two + in: + weights: + - 3 + - 2 + - 2 + - 4 + - 1 + - 4 + days: 3 + out: 6 + - name: example-three + in: + weights: + - 1 + - 2 + - 3 + - 1 + - 1 + days: 1 + out: 8 + - name: all-equal-2-days + in: + weights: + - 2 + - 2 + - 2 + - 2 + days: 2 + out: 4 + - name: all-equal-4-days + in: + weights: + - 2 + - 2 + - 2 + - 2 + days: 4 + out: 2 + - name: ascending-weights + in: + weights: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + days: 5 + out: 7 + - name: descending-weights + in: + weights: + - 7 + - 6 + - 5 + - 4 + - 3 + - 2 + - 1 + days: 5 + out: 7 + - name: two-days-tight + in: + weights: + - 10 + - 50 + - 50 + - 10 + days: 2 + out: 60 + - name: three-days-tight + in: + weights: + - 10 + - 50 + - 50 + - 10 + days: 3 + out: 60 + - name: many-small-packages + in: + weights: + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + days: 3 + out: 3 + - name: many-small-one-day + in: + weights: + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + days: 1 + out: 8 + - name: many-small-eight-days + in: + weights: + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + days: 8 + out: 1 + - name: mixed-varied-one + in: + weights: + - 9 + - 8 + - 7 + - 6 + - 5 + - 4 + - 3 + - 2 + - 1 + days: 4 + out: 15 + - name: mixed-varied-two + in: + weights: + - 9 + - 8 + - 7 + - 6 + - 5 + - 4 + - 3 + - 2 + - 1 + days: 9 + out: 9 + - name: balanced-split + in: + weights: + - 4 + - 4 + - 4 + - 4 + - 4 + - 4 + days: 3 + out: 8 + - name: balanced-more-days + in: + weights: + - 4 + - 4 + - 4 + - 4 + - 4 + - 4 + days: 6 + out: 4 + - name: heavy-first + in: + weights: + - 100 + - 1 + - 1 + - 1 + days: 2 + out: 100 + - name: heavy-last + in: + weights: + - 1 + - 1 + - 1 + - 100 + days: 2 + out: 100 + - name: alternating-small-large + in: + weights: + - 1 + - 100 + - 1 + - 100 + - 1 + - 100 + days: 3 + out: 101 + - name: alternating-small-large-more-days + in: + weights: + - 1 + - 100 + - 1 + - 100 + - 1 + - 100 + days: 6 + out: 100 + - name: all-ones-medium + in: + weights: + - 1 + - 1 + - 1 + - 1 + - 1 + days: 2 + out: 3 + - name: all-ones-few-days + in: + weights: + - 1 + - 1 + - 1 + - 1 + - 1 + days: 5 + out: 1 + - name: max-window + in: + weights: + - 10 + - 8 + - 8 + - 10 + - 8 + - 8 + days: 4 + out: 16 + - name: five-days + in: + weights: + - 10 + - 8 + - 8 + - 10 + - 8 + - 8 + days: 5 + out: 16 + - name: three-big-packages + in: + weights: + - 100 + - 100 + - 100 + days: 2 + out: 200 + - name: three-big-packages-more-days + in: + weights: + - 100 + - 100 + - 100 + days: 3 + out: 100 + - name: uneven-series + in: + weights: + - 2 + - 3 + - 5 + - 7 + - 11 + - 13 + days: 3 + out: 17 + - name: uneven-series-more-days + in: + weights: + - 2 + - 3 + - 5 + - 7 + - 11 + - 13 + days: 6 + out: 13 + - name: clustered-values + in: + weights: + - 6 + - 6 + - 6 + - 6 + - 6 + days: 2 + out: 18 + - name: clustered-values-more-days + in: + weights: + - 6 + - 6 + - 6 + - 6 + - 6 + days: 5 + out: 6 + - name: long-tail + in: + weights: + - 1 + - 2 + - 3 + - 100 + - 100 + - 100 + days: 2 + out: 200 + - name: long-tail-more-days + in: + weights: + - 1 + - 2 + - 3 + - 100 + - 100 + - 100 + days: 4 + out: 100 + - name: gradual-growth + in: + weights: + - 1 + - 3 + - 6 + - 10 + - 15 + days: 2 + out: 20 + - name: gradual-growth-more-days + in: + weights: + - 1 + - 3 + - 6 + - 10 + - 15 + days: 5 + out: 15 diff --git a/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.cpp b/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.cpp new file mode 100644 index 00000000..c251089c --- /dev/null +++ b/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.cpp @@ -0,0 +1,31 @@ +class Solution { +public: + int shipWithinDays(vector& weights, int days) { + int low = *max_element(weights.begin(), weights.end()); + int high = accumulate(weights.begin(), weights.end(), 0); + + while (low <= high) { + int mid = (low + high) / 2; + + int requiredDays = 1; + int load = 0; + + for (int weight : weights) { + if (load + weight > mid) { + requiredDays++; + load = weight; + } else { + load += weight; + } + } + + if (requiredDays <= days) { + high = mid - 1; + } else { + low = mid + 1; + } + } + + return low; + } +}; diff --git a/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.cs b/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.cs new file mode 100644 index 00000000..331ac986 --- /dev/null +++ b/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.cs @@ -0,0 +1,30 @@ +public class Solution { + public int ShipWithinDays(int[] weights, int days) { + int low = weights.Max(); + int high = weights.Sum(); + + while (low <= high) { + int mid = (low + high) / 2; + + int requiredDays = 1; + int load = 0; + + foreach (int weight in weights) { + if (load + weight > mid) { + requiredDays++; + load = weight; + } else { + load += weight; + } + } + + if (requiredDays <= days) { + high = mid - 1; + } else { + low = mid + 1; + } + } + + return low; + } +} diff --git a/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.dart b/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.dart new file mode 100644 index 00000000..58d99318 --- /dev/null +++ b/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.dart @@ -0,0 +1,30 @@ +class Solution { + int shipWithinDays(List weights, int days) { + int low = weights.reduce((a, b) => a > b ? a : b); + int high = weights.reduce((a, b) => a + b); + + while (low <= high) { + int mid = (low + high) ~/ 2; + + int requiredDays = 1; + int load = 0; + + for (int weight in weights) { + if (load + weight > mid) { + requiredDays++; + load = weight; + } else { + load += weight; + } + } + + if (requiredDays <= days) { + high = mid - 1; + } else { + low = mid + 1; + } + } + + return low; + } +} diff --git a/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.go b/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.go new file mode 100644 index 00000000..0b0e10fb --- /dev/null +++ b/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.go @@ -0,0 +1,34 @@ +func shipWithinDays(weights []int, days int) int { + low := 0 + high := 0 + for _, w := range weights { + if w > low { + low = w + } + high += w + } + + for low <= high { + mid := (low + high) / 2 + + requiredDays := 1 + load := 0 + + for _, weight := range weights { + if load + weight > mid { + requiredDays++ + load = weight + } else { + load += weight + } + } + + if requiredDays <= days { + high = mid - 1 + } else { + low = mid + 1 + } + } + + return low +} diff --git a/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.java b/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.java new file mode 100644 index 00000000..070ff30c --- /dev/null +++ b/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.java @@ -0,0 +1,34 @@ +class Solution { + public int shipWithinDays(int[] weights, int days) { + int low = 0; + int high = 0; + for (int w : weights) { + low = Math.max(low, w); + high += w; + } + + while (low <= high) { + int mid = (low + high) / 2; + + int requiredDays = 1; + int load = 0; + + for (int weight : weights) { + if (load + weight > mid) { + requiredDays++; + load = weight; + } else { + load += weight; + } + } + + if (requiredDays <= days) { + high = mid - 1; + } else { + low = mid + 1; + } + } + + return low; + } +} diff --git a/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.kt b/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.kt new file mode 100644 index 00000000..5141af79 --- /dev/null +++ b/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.kt @@ -0,0 +1,30 @@ +class Solution { + fun shipWithinDays(weights: IntArray, days: Int): Int { + var low = weights.max() + var high = weights.sum() + + while (low <= high) { + val mid = (low + high) / 2 + + var requiredDays = 1 + var load = 0 + + for (weight in weights) { + if (load + weight > mid) { + requiredDays++ + load = weight + } else { + load += weight + } + } + + if (requiredDays <= days) { + high = mid - 1 + } else { + low = mid + 1 + } + } + + return low + } +} diff --git a/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.py b/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.py new file mode 100644 index 00000000..126bd131 --- /dev/null +++ b/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.py @@ -0,0 +1,24 @@ +class Solution: + def shipWithinDays(self, weights: List[int], days: int) -> int: + low = max(weights) + high = sum(weights) + + while low <= high: + mid = (low + high) // 2 + + required_days = 1 + load = 0 + + for weight in weights: + if load + weight > mid: + required_days += 1 + load = weight + else: + load += weight + + if required_days <= days: + high = mid - 1 + else: + low = mid + 1 + + return low diff --git a/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.py2 b/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.py2 new file mode 100644 index 00000000..dd45383e --- /dev/null +++ b/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.py2 @@ -0,0 +1,29 @@ +class Solution(object): + def shipWithinDays(self, weights, days): + """ + :type weights: List[int] + :type days: int + :rtype: int + """ + low = max(weights) + high = sum(weights) + + while low <= high: + mid = (low + high) // 2 + + required_days = 1 + load = 0 + + for weight in weights: + if load + weight > mid: + required_days += 1 + load = weight + else: + load += weight + + if required_days <= days: + high = mid - 1 + else: + low = mid + 1 + + return low diff --git a/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.rb b/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.rb new file mode 100644 index 00000000..1bec78aa --- /dev/null +++ b/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.rb @@ -0,0 +1,31 @@ +# @param {Integer[]} weights +# @param {Integer} days +# @return {Integer} +def ship_within_days(weights, days) + low = weights.max + high = weights.sum + + while low <= high + mid = (low + high) / 2 + + required_days = 1 + load = 0 + + weights.each do |weight| + if load + weight > mid + required_days += 1 + load = weight + else + load += weight + end + end + + if required_days <= days + high = mid - 1 + else + low = mid + 1 + end + end + + low +end diff --git a/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.rs b/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.rs new file mode 100644 index 00000000..a0ab93a6 --- /dev/null +++ b/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.rs @@ -0,0 +1,30 @@ +impl Solution { + pub fn ship_within_days(weights: Vec, days: i32) -> i32 { + let mut low = *weights.iter().max().unwrap(); + let mut high = weights.iter().sum(); + + while low <= high { + let mid = (low + high) / 2; + + let mut required_days = 1; + let mut load = 0; + + for &weight in &weights { + if load + weight > mid { + required_days += 1; + load = weight; + } else { + load += weight; + } + } + + if required_days <= days { + high = mid - 1; + } else { + low = mid + 1; + } + } + + low + } +} diff --git a/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.swift b/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.swift new file mode 100644 index 00000000..00858988 --- /dev/null +++ b/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.swift @@ -0,0 +1,30 @@ +class Solution { + func shipWithinDays(_ weights: [Int], _ days: Int) -> Int { + var low = weights.max()! + var high = weights.reduce(0, +) + + while low <= high { + let mid = (low + high) / 2 + + var requiredDays = 1 + var load = 0 + + for weight in weights { + if load + weight > mid { + requiredDays += 1 + load = weight + } else { + load += weight + } + } + + if requiredDays <= days { + high = mid - 1 + } else { + low = mid + 1 + } + } + + return low + } +} diff --git a/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.ts b/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.ts new file mode 100644 index 00000000..5768064f --- /dev/null +++ b/tests/1001-1500/1011. capacity-to-ship-packages-within-d-days/sol.ts @@ -0,0 +1,28 @@ +function shipWithinDays(weights: number[], days: number): number { + let low = Math.max(...weights); + let high = weights.reduce((a, b) => a + b, 0); + + while (low <= high) { + const mid = Math.floor((low + high) / 2); + + let requiredDays = 1; + let load = 0; + + for (const weight of weights) { + if (load + weight > mid) { + requiredDays++; + load = weight; + } else { + load += weight; + } + } + + if (requiredDays <= days) { + high = mid - 1; + } else { + low = mid + 1; + } + } + + return low; +} diff --git a/tests/1001-1500/1012. numbers-with-repeated-digits/manifest.yaml b/tests/1001-1500/1012. numbers-with-repeated-digits/manifest.yaml new file mode 100644 index 00000000..ec88719d --- /dev/null +++ b/tests/1001-1500/1012. numbers-with-repeated-digits/manifest.yaml @@ -0,0 +1,189 @@ +entry: + id: 1012 + title: numbers with repeated digits + params: + n: + type: int + call: + cpp: "Solution().numDupDigitsAtMostN({n})" + rust: "Solution::num_dup_digits_at_most_n({n})" + python3: "Solution().numDupDigitsAtMostN({n})" + python2: "Solution().numDupDigitsAtMostN({n})" + ruby: "num_dup_digits_at_most_n({n})" + java: "new Solution().numDupDigitsAtMostN({n})" + csharp: "new Solution().NumDupDigitsAtMostN({n})" + kotlin: "Solution().numDupDigitsAtMostN({n})" + go: "numDupDigitsAtMostN({n})" + dart: "Solution().numDupDigitsAtMostN({n})" + swift: "Solution().numDupDigitsAtMostN({n})" + typescript: "numDupDigitsAtMostN({n})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().check({result})" + checker: | + class Checker: + def check(self, result): + return True +seed: 1012 +tests: + - name: one + in: + n: 1 + out: 0 + - name: nine + in: + n: 9 + out: 0 + - name: ten + in: + n: 10 + out: 0 + - name: eleven + in: + n: 11 + out: 1 + - name: twenty + in: + n: 20 + out: 1 + - name: twentyone + in: + n: 21 + out: 1 + - name: twentytwo + in: + n: 22 + out: 2 + - name: ninety-eight + in: + n: 98 + out: 8 + - name: ninety-nine + in: + n: 99 + out: 9 + - name: one-hundred + in: + n: 100 + out: 10 + - name: one-oh-one + in: + n: 101 + out: 11 + - name: one-ten + in: + n: 110 + out: 12 + - name: one-twenty + in: + n: 120 + out: 21 + - name: one-twenty-one + in: + n: 121 + out: 22 + - name: one-twenty-three + in: + n: 123 + out: 23 + - name: one-ninety-eight + in: + n: 198 + out: 36 + - name: two-hundred + in: + n: 200 + out: 38 + - name: two-fifty-six + in: + n: 256 + out: 57 + - name: three-twenty-one + in: + n: 321 + out: 69 + - name: five-forty-three + in: + n: 543 + out: 129 + - name: six-six-six + in: + n: 666 + out: 168 + - name: seven-seven-seven + in: + n: 777 + out: 199 + - name: eight-eight-eight + in: + n: 888 + out: 230 + - name: nine-hundred-ninety-nine + in: + n: 999 + out: 261 + - name: one-thousand + in: + n: 1000 + out: 262 + - name: one-two-three-four + in: + n: 1234 + out: 431 + - name: four-three-two-one + in: + n: 4321 + out: 1887 + - name: five-four-three-two + in: + n: 5432 + out: 2430 + - name: six-seven-eight-nine + in: + n: 6789 + out: 3146 + - name: nine-thousand-nine-hundred-ninety-nine + in: + n: 9999 + out: 4725 + - name: ten-thousand + in: + n: 10000 + out: 4726 + - name: twelve-thousand-three-hundred-forty-five + in: + n: 12345 + out: 6685 + - name: fifty-four-thousand-three-hundred-twenty-one + in: + n: 54321 + out: 35467 + - name: one-hundred-thousand + in: + n: 100000 + out: 67510 + - name: nine-hundred-ninety-nine-thousand-nine-hundred-ninety-nine + in: + n: 999999 + out: 831429 + - name: one-million + in: + n: 1000000 + out: 831430 + - name: random-mid + in: + n: 35791 + out: 22877 + - name: random-upper-mid + in: + n: 24680 + out: 15175 + - name: random-large + in: + n: 876543 + out: 725019 diff --git a/tests/1001-1500/1012. numbers-with-repeated-digits/sol.cpp b/tests/1001-1500/1012. numbers-with-repeated-digits/sol.cpp new file mode 100644 index 00000000..2c490d75 --- /dev/null +++ b/tests/1001-1500/1012. numbers-with-repeated-digits/sol.cpp @@ -0,0 +1,36 @@ +class Solution { +public: + int numDupDigitsAtMostN(int n) { + string s = to_string(n + 1); + vector digits; + for (char c : s) digits.push_back(c - '0'); + int nl = digits.size(); + int res = 0; + for (int i = 0; i < nl - 1; i++) { + res += 9 * perm(9, i); + } + bool used[10] = {}; + for (int i = 0; i < nl; i++) { + int x = digits[i]; + int start = i == 0 ? 1 : 0; + for (int y = start; y < x; y++) { + if (!used[y]) { + res += perm(9 - i, nl - i - 1); + } + } + if (used[x]) break; + used[x] = true; + } + return n - res; + } + +private: + int perm(int n, int k) { + if (k < 0 || k > n) return 0; + int ans = 1; + for (int i = 0; i < k; i++) { + ans *= (n - i); + } + return ans; + } +}; diff --git a/tests/1001-1500/1012. numbers-with-repeated-digits/sol.cs b/tests/1001-1500/1012. numbers-with-repeated-digits/sol.cs new file mode 100644 index 00000000..c3e07406 --- /dev/null +++ b/tests/1001-1500/1012. numbers-with-repeated-digits/sol.cs @@ -0,0 +1,36 @@ +public class Solution { + public int NumDupDigitsAtMostN(int n) { + string s = (n + 1).ToString(); + int[] digits = new int[s.Length]; + for (int i = 0; i < s.Length; i++) { + digits[i] = s[i] - '0'; + } + int nl = digits.Length; + int res = 0; + for (int i = 0; i < nl - 1; i++) { + res += 9 * Perm(9, i); + } + bool[] used = new bool[10]; + for (int i = 0; i < nl; i++) { + int x = digits[i]; + int start = i == 0 ? 1 : 0; + for (int y = start; y < x; y++) { + if (!used[y]) { + res += Perm(9 - i, nl - i - 1); + } + } + if (used[x]) break; + used[x] = true; + } + return n - res; + } + + private int Perm(int n, int k) { + if (k < 0 || k > n) return 0; + int ans = 1; + for (int i = 0; i < k; i++) { + ans *= (n - i); + } + return ans; + } +} diff --git a/tests/1001-1500/1012. numbers-with-repeated-digits/sol.dart b/tests/1001-1500/1012. numbers-with-repeated-digits/sol.dart new file mode 100644 index 00000000..b4816c61 --- /dev/null +++ b/tests/1001-1500/1012. numbers-with-repeated-digits/sol.dart @@ -0,0 +1,33 @@ +class Solution { + int numDupDigitsAtMostN(int n) { + var s = (n + 1).toString(); + var digits = s.codeUnits.map((c) => c - 48).toList(); + int nl = digits.length; + int res = 0; + for (int i = 0; i < nl - 1; i++) { + res += 9 * perm(9, i); + } + var used = List.filled(10, false); + for (int i = 0; i < nl; i++) { + int x = digits[i]; + int start = i == 0 ? 1 : 0; + for (int y = start; y < x; y++) { + if (!used[y]) { + res += perm(9 - i, nl - i - 1); + } + } + if (used[x]) break; + used[x] = true; + } + return n - res; + } + + int perm(int n, int k) { + if (k < 0 || k > n) return 0; + int ans = 1; + for (int i = 0; i < k; i++) { + ans *= (n - i); + } + return ans; + } +} diff --git a/tests/1001-1500/1012. numbers-with-repeated-digits/sol.go b/tests/1001-1500/1012. numbers-with-repeated-digits/sol.go new file mode 100644 index 00000000..a12a1142 --- /dev/null +++ b/tests/1001-1500/1012. numbers-with-repeated-digits/sol.go @@ -0,0 +1,40 @@ +func numDupDigitsAtMostN(n int) int { + s := strconv.Itoa(n + 1) + digits := make([]int, len(s)) + for i, c := range s { + digits[i] = int(c - '0') + } + nl := len(digits) + res := 0 + for i := 0; i < nl - 1; i++ { + res += 9 * perm(9, i) + } + used := make([]bool, 10) + for i, x := range digits { + start := 0 + if i == 0 { + start = 1 + } + for y := start; y < x; y++ { + if !used[y] { + res += perm(9 - i, nl - i - 1) + } + } + if used[x] { + break + } + used[x] = true + } + return n - res +} + +func perm(n, k int) int { + if k < 0 || k > n { + return 0 + } + ans := 1 + for i := 0; i < k; i++ { + ans *= (n - i) + } + return ans +} diff --git a/tests/1001-1500/1012. numbers-with-repeated-digits/sol.java b/tests/1001-1500/1012. numbers-with-repeated-digits/sol.java new file mode 100644 index 00000000..014a0bd0 --- /dev/null +++ b/tests/1001-1500/1012. numbers-with-repeated-digits/sol.java @@ -0,0 +1,36 @@ +class Solution { + public int numDupDigitsAtMostN(int n) { + String s = Integer.toString(n + 1); + int nl = s.length(); + int[] digits = new int[nl]; + for (int i = 0; i < nl; i++) { + digits[i] = s.charAt(i) - '0'; + } + int res = 0; + for (int i = 0; i < nl - 1; i++) { + res += 9 * perm(9, i); + } + boolean[] used = new boolean[10]; + for (int i = 0; i < nl; i++) { + int x = digits[i]; + int start = i == 0 ? 1 : 0; + for (int y = start; y < x; y++) { + if (!used[y]) { + res += perm(9 - i, nl - i - 1); + } + } + if (used[x]) break; + used[x] = true; + } + return n - res; + } + + private int perm(int n, int k) { + if (k < 0 || k > n) return 0; + int ans = 1; + for (int i = 0; i < k; i++) { + ans *= (n - i); + } + return ans; + } +} diff --git a/tests/1001-1500/1012. numbers-with-repeated-digits/sol.kt b/tests/1001-1500/1012. numbers-with-repeated-digits/sol.kt new file mode 100644 index 00000000..b56d786b --- /dev/null +++ b/tests/1001-1500/1012. numbers-with-repeated-digits/sol.kt @@ -0,0 +1,32 @@ +class Solution { + fun numDupDigitsAtMostN(n: Int): Int { + val digits = (n + 1).toString().map { it - '0' }.toIntArray() + val nl = digits.size + var res = 0 + for (i in 0 until nl - 1) { + res += 9 * perm(9, i) + } + val used = BooleanArray(10) + for (i in 0 until nl) { + val x = digits[i] + val start = if (i == 0) 1 else 0 + for (y in start until x) { + if (!used[y]) { + res += perm(9 - i, nl - i - 1) + } + } + if (used[x]) break + used[x] = true + } + return n - res + } + + private fun perm(n: Int, k: Int): Int { + if (k < 0 || k > n) return 0 + var ans = 1 + for (i in 0 until k) { + ans *= (n - i) + } + return ans + } +} diff --git a/tests/1001-1500/1012. numbers-with-repeated-digits/sol.py b/tests/1001-1500/1012. numbers-with-repeated-digits/sol.py new file mode 100644 index 00000000..7a5958ac --- /dev/null +++ b/tests/1001-1500/1012. numbers-with-repeated-digits/sol.py @@ -0,0 +1,17 @@ +from math import perm + + +class Solution: + def numDupDigitsAtMostN(self, n: int) -> int: + digits = list(map(int, str(n + 1))) + nl = len(digits) + res = sum(9 * perm(9, i) for i in range(nl - 1)) + s = set() + for i, x in enumerate(digits): + for y in range(i == 0, x): + if y not in s: + res += perm(9 - i, nl - i - 1) + if x in s: + break + s.add(x) + return n - res diff --git a/tests/1001-1500/1012. numbers-with-repeated-digits/sol.py2 b/tests/1001-1500/1012. numbers-with-repeated-digits/sol.py2 new file mode 100644 index 00000000..4311b3d7 --- /dev/null +++ b/tests/1001-1500/1012. numbers-with-repeated-digits/sol.py2 @@ -0,0 +1,24 @@ +class Solution(object): + def numDupDigitsAtMostN(self, n): + """ + :type n: int + :rtype: int + """ + def perm(m, k): + res = 1 + for i in xrange(k): + res *= m - i + return res + + digits = list(map(int, str(n + 1))) + nl = len(digits) + res = sum(9 * perm(9, i) for i in range(nl - 1)) + s = set() + for i, x in enumerate(digits): + for y in range(1 if i == 0 else 0, x): + if y not in s: + res += perm(9 - i, nl - i - 1) + if x in s: + break + s.add(x) + return n - res diff --git a/tests/1001-1500/1012. numbers-with-repeated-digits/sol.rb b/tests/1001-1500/1012. numbers-with-repeated-digits/sol.rb new file mode 100644 index 00000000..0a491e78 --- /dev/null +++ b/tests/1001-1500/1012. numbers-with-repeated-digits/sol.rb @@ -0,0 +1,24 @@ +# @param {Integer} n +# @return {Integer} +def num_dup_digits_at_most_n(n) + digits = (n + 1).to_s.chars.map(&:to_i) + nl = digits.length + res = (0...nl - 1).sum { |i| 9 * (9 - i >= 0 ? (1..9).to_a.combination(i + 1).size * (1..i + 1).inject(:*) : 0) } + + # Reimplement perm logic manually + perm = ->(n, k) { k < 0 || k > n ? 0 : (n - k + 1..n).inject(1, :*) } + + res = (0...nl - 1).sum { |i| 9 * perm.call(9, i) } + s = Set.new + digits.each_with_index do |x, i| + start = i == 0 ? 1 : 0 + (start...x).each do |y| + unless s.include?(y) + res += perm.call(9 - i, nl - i - 1) + end + end + break if s.include?(x) + s.add(x) + end + n - res +end diff --git a/tests/1001-1500/1012. numbers-with-repeated-digits/sol.rs b/tests/1001-1500/1012. numbers-with-repeated-digits/sol.rs new file mode 100644 index 00000000..164b0958 --- /dev/null +++ b/tests/1001-1500/1012. numbers-with-repeated-digits/sol.rs @@ -0,0 +1,35 @@ +impl Solution { + pub fn num_dup_digits_at_most_n(n: i32) -> i32 { + let s = (n + 1).to_string(); + let digits: Vec = s.chars().map(|c| c.to_digit(10).unwrap() as usize).collect(); + let nl = digits.len(); + let mut res = 0; + for i in 0..nl - 1 { + res += 9 * Self::perm(9, i); + } + let mut used = vec![false; 10]; + for i in 0..nl { + let x = digits[i]; + let start = if i == 0 { 1 } else { 0 }; + for y in start..x { + if !used[y] { + res += Self::perm(9 - i, nl - i - 1); + } + } + if used[x] { + break; + } + used[x] = true; + } + n - res as i32 + } + + fn perm(n: usize, k: usize) -> i32 { + if k > n { return 0; } + let mut ans = 1; + for i in 0..k { + ans *= (n - i) as i32; + } + ans + } +} diff --git a/tests/1001-1500/1012. numbers-with-repeated-digits/sol.swift b/tests/1001-1500/1012. numbers-with-repeated-digits/sol.swift new file mode 100644 index 00000000..e5a251bb --- /dev/null +++ b/tests/1001-1500/1012. numbers-with-repeated-digits/sol.swift @@ -0,0 +1,32 @@ +class Solution { + func numDupDigitsAtMostN(_ n: Int) -> Int { + let digits = Array(String(n + 1)).map { Int(String($0))! } + let nl = digits.count + var res = 0 + for i in 0..<(nl - 1) { + res += 9 * perm(9, i) + } + var used = Array(repeating: false, count: 10) + for i in 0.. Int { + if k < 0 || k > n { return 0 } + var ans = 1 + for i in 0.. n) return 0; + let ans = 1; + for (let i = 0; i < k; i++) { + ans *= n - i; + } + return ans; +} diff --git a/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/manifest.yaml b/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/manifest.yaml new file mode 100644 index 00000000..422bc943 --- /dev/null +++ b/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/manifest.yaml @@ -0,0 +1,404 @@ +entry: + id: 1013 + title: partition array into three parts with equal sum + params: + arr: + type: array + items: + type: int + call: + cpp: "Solution().canThreePartsEqualSum({arr})" + rust: "Solution::can_three_parts_equal_sum({arr})" + python3: "Solution().canThreePartsEqualSum({arr})" + python2: "Solution().canThreePartsEqualSum({arr})" + ruby: "can_three_parts_equal_sum({arr})" + java: "new Solution().canThreePartsEqualSum({arr})" + csharp: "new Solution().CanThreePartsEqualSum({arr})" + kotlin: "Solution().canThreePartsEqualSum({arr})" + go: "canThreePartsEqualSum({arr})" + dart: "Solution().canThreePartsEqualSum({arr})" + swift: "Solution().canThreePartsEqualSum({arr})" + typescript: "canThreePartsEqualSum({arr})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().check({result})" + checker: | + class Checker: + def check(self, result): + return True +seed: 1013 +tests: + - name: example-true + in: + arr: + - 0 + - 2 + - 1 + - -6 + - 6 + - -7 + - 9 + - 1 + - 2 + - 0 + - 1 + out: true + - name: example-false + in: + arr: + - 0 + - 2 + - 1 + - -6 + - 6 + - 7 + - 9 + - -1 + - 2 + - 0 + - 1 + out: false + - name: minimal-true + in: + arr: + - 0 + - 0 + - 0 + out: true + - name: minimal-false + in: + arr: + - 1 + - -1 + - 1 + out: false + - name: all-zero-four + in: + arr: + - 0 + - 0 + - 0 + - 0 + out: true + - name: all-one-three + in: + arr: + - 1 + - 1 + - 1 + out: true + - name: all-one-four + in: + arr: + - 1 + - 1 + - 1 + - 1 + out: false + - name: alternating-cancel + in: + arr: + - 1 + - -1 + - 1 + - -1 + - 1 + - -1 + out: true + - name: no-partition-due-total + in: + arr: + - 2 + - 2 + - 2 + - 2 + out: false + - name: long-true-one + in: + arr: + - 3 + - 3 + - 3 + - 3 + - 3 + - 3 + out: true + - name: long-false-one + in: + arr: + - 3 + - 3 + - 3 + - 3 + - 3 + out: false + - name: negative-sum-true + in: + arr: + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + out: true + - name: negative-sum-false + in: + arr: + - -1 + - -1 + - -1 + - -1 + out: false + - name: mixed-true-small + in: + arr: + - 4 + - 1 + - 0 + - 1 + - 1 + - -6 + - 5 + - 0 + out: false + - name: mixed-false-small + in: + arr: + - 4 + - 1 + - 0 + - 1 + - 1 + - -6 + - 5 + - 1 + out: false + - name: partition-at-end + in: + arr: + - 2 + - -2 + - 2 + - -2 + - 2 + - -2 + out: true + - name: partition-at-start + in: + arr: + - 0 + - 0 + - 0 + - 1 + - -1 + out: true + - name: zero-total-false + in: + arr: + - 1 + - 0 + - 1 + - 0 + out: false + - name: zero-total-true + in: + arr: + - 1 + - -1 + - 0 + - 0 + - 0 + out: true + - name: longer-cancel-true + in: + arr: + - 5 + - -2 + - 3 + - -6 + - 6 + - -6 + - 6 + - -6 + - 6 + out: false + - name: longer-cancel-false + in: + arr: + - 5 + - -2 + - 3 + - -6 + - 6 + - -6 + - 6 + - -6 + - 7 + out: false + - name: repeated-zeroes + in: + arr: + - 0 + - 1 + - -1 + - 0 + - 1 + - -1 + - 0 + out: true + - name: repeated-zeroes-false + in: + arr: + - 0 + - 1 + - -1 + - 0 + - 1 + - -1 + - 1 + out: false + - name: all-twos + in: + arr: + - 2 + - 2 + - 2 + - 2 + - 2 + - 2 + out: true + - name: all-twos-false + in: + arr: + - 2 + - 2 + - 2 + - 2 + - 2 + out: false + - name: nested-balances + in: + arr: + - 1 + - 2 + - -3 + - 3 + - 0 + - 0 + - -3 + - 3 + out: false + - name: nested-balances-false + in: + arr: + - 1 + - 2 + - -3 + - 3 + - 0 + - 0 + - -3 + - 2 + out: false + - name: prefix-only + in: + arr: + - 1 + - 1 + - -2 + - 0 + - 0 + - 0 + out: true + - name: prefix-only-false + in: + arr: + - 1 + - 1 + - -2 + - 0 + - 0 + - 1 + out: false + - name: many-zeros-and-one + in: + arr: + - 0 + - 0 + - 0 + - 0 + - 1 + - -1 + - 0 + out: true + - name: many-zeros-and-one-false + in: + arr: + - 0 + - 0 + - 0 + - 0 + - 1 + - -1 + - 1 + out: false + - name: sparse-equal + in: + arr: + - 2 + - -1 + - -1 + - 2 + - -1 + - -1 + - 2 + - -1 + - -1 + out: true + - name: sparse-equal-false + in: + arr: + - 2 + - -1 + - -1 + - 2 + - -1 + - -1 + - 2 + - -1 + - 0 + out: false + - name: big-repeat-true + in: + arr: + - 10 + - -10 + - 10 + - -10 + - 10 + - -10 + - 10 + - -10 + - 10 + - -10 + out: true + - name: big-repeat-false + in: + arr: + - 10 + - -10 + - 10 + - -10 + - 10 + - -10 + - 10 + - -10 + - 10 + - -9 + out: false diff --git a/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.cpp b/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.cpp new file mode 100644 index 00000000..53214b0c --- /dev/null +++ b/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.cpp @@ -0,0 +1,26 @@ +class Solution { +public: + bool canThreePartsEqualSum(vector& arr) { + int total = 0; + for (int num : arr) { + total += num; + } + if (total % 3 != 0) { + return false; + } + int target = total / 3; + int currentSum = 0; + int partitions = 0; + for (int i = 0; i < arr.size(); i++) { + currentSum += arr[i]; + if (currentSum == target) { + partitions++; + currentSum = 0; + if (partitions == 2 && i < arr.size() - 1) { + return true; + } + } + } + return false; + } +}; diff --git a/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.cs b/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.cs new file mode 100644 index 00000000..96392caa --- /dev/null +++ b/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.cs @@ -0,0 +1,25 @@ +public class Solution { + public bool CanThreePartsEqualSum(int[] arr) { + int total = 0; + foreach (int num in arr) { + total += num; + } + if (total % 3 != 0) { + return false; + } + int target = total / 3; + int currentSum = 0; + int partitions = 0; + for (int i = 0; i < arr.Length; i++) { + currentSum += arr[i]; + if (currentSum == target) { + partitions++; + currentSum = 0; + if (partitions == 2 && i < arr.Length - 1) { + return true; + } + } + } + return false; + } +} diff --git a/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.dart b/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.dart new file mode 100644 index 00000000..6b897df9 --- /dev/null +++ b/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.dart @@ -0,0 +1,22 @@ +class Solution { + bool canThreePartsEqualSum(List arr) { + int total = arr.reduce((a, b) => a + b); + if (total % 3 != 0) { + return false; + } + int target = total ~/ 3; + int currentSum = 0; + int partitions = 0; + for (int i = 0; i < arr.length; i++) { + currentSum += arr[i]; + if (currentSum == target) { + partitions++; + currentSum = 0; + if (partitions == 2 && i < arr.length - 1) { + return true; + } + } + } + return false; + } +} diff --git a/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.go b/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.go new file mode 100644 index 00000000..dda6a4ea --- /dev/null +++ b/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.go @@ -0,0 +1,23 @@ +func canThreePartsEqualSum(arr []int) bool { + total := 0 + for _, num := range arr { + total += num + } + if total%3 != 0 { + return false + } + target := total / 3 + currentSum := 0 + partitions := 0 + for i, num := range arr { + currentSum += num + if currentSum == target { + partitions++ + currentSum = 0 + if partitions == 2 && i < len(arr)-1 { + return true + } + } + } + return false +} diff --git a/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.java b/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.java new file mode 100644 index 00000000..24ec7bab --- /dev/null +++ b/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.java @@ -0,0 +1,25 @@ +class Solution { + public boolean canThreePartsEqualSum(int[] arr) { + int total = 0; + for (int num : arr) { + total += num; + } + if (total % 3 != 0) { + return false; + } + int target = total / 3; + int currentSum = 0; + int partitions = 0; + for (int i = 0; i < arr.length; i++) { + currentSum += arr[i]; + if (currentSum == target) { + partitions++; + currentSum = 0; + if (partitions == 2 && i < arr.length - 1) { + return true; + } + } + } + return false; + } +} diff --git a/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.kt b/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.kt new file mode 100644 index 00000000..fa79d4f6 --- /dev/null +++ b/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.kt @@ -0,0 +1,22 @@ +class Solution { + fun canThreePartsEqualSum(arr: IntArray): Boolean { + val total = arr.sum() + if (total % 3 != 0) { + return false + } + val target = total / 3 + var currentSum = 0 + var partitions = 0 + for (i in arr.indices) { + currentSum += arr[i] + if (currentSum == target) { + partitions++ + currentSum = 0 + if (partitions == 2 && i < arr.size - 1) { + return true + } + } + } + return false + } +} diff --git a/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.py b/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.py new file mode 100644 index 00000000..26f89ddb --- /dev/null +++ b/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.py @@ -0,0 +1,17 @@ +class Solution: + def canThreePartsEqualSum(self, arr: List[int]) -> bool: + total = sum(arr) + if total % 3 != 0: + return False + target = total // 3 + current_sum = 0 + partitions = 0 + for i in range(len(arr)): + current_sum += arr[i] + if current_sum == target: + partitions += 1 + current_sum = 0 + # If we found two partitions and it's not the end, the rest must be the third + if partitions == 2 and i < len(arr) - 1: + return True + return False diff --git a/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.py2 b/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.py2 new file mode 100644 index 00000000..7c311dec --- /dev/null +++ b/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.py2 @@ -0,0 +1,20 @@ +class Solution(object): + def canThreePartsEqualSum(self, arr): + """ + :type arr: List[int] + :rtype: bool + """ + total = sum(arr) + if total % 3 != 0: + return False + target = total // 3 + current_sum = 0 + partitions = 0 + for i in range(len(arr)): + current_sum += arr[i] + if current_sum == target: + partitions += 1 + current_sum = 0 + if partitions == 2 and i < len(arr) - 1: + return True + return False diff --git a/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.rb b/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.rb new file mode 100644 index 00000000..23998bbe --- /dev/null +++ b/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.rb @@ -0,0 +1,20 @@ +# @param {Integer[]} arr +# @return {Boolean} +def can_three_parts_equal_sum(arr) + total = arr.sum + return false if total % 3 != 0 + target = total / 3 + current_sum = 0 + partitions = 0 + arr.each_with_index do |num, i| + current_sum += num + if current_sum == target + partitions += 1 + current_sum = 0 + if partitions == 2 && i < arr.length - 1 + return true + end + end + end + false +end diff --git a/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.rs b/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.rs new file mode 100644 index 00000000..35903c60 --- /dev/null +++ b/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.rs @@ -0,0 +1,22 @@ +impl Solution { + pub fn can_three_parts_equal_sum(arr: Vec) -> bool { + let total: i32 = arr.iter().sum(); + if total % 3 != 0 { + return false; + } + let target = total / 3; + let mut current_sum = 0; + let mut partitions = 0; + for i in 0..arr.len() { + current_sum += arr[i]; + if current_sum == target { + partitions += 1; + current_sum = 0; + if partitions == 2 && i < arr.len() - 1 { + return true; + } + } + } + false + } +} diff --git a/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.swift b/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.swift new file mode 100644 index 00000000..e312e8cb --- /dev/null +++ b/tests/1001-1500/1013. partition-array-into-three-parts-with-equal-sum/sol.swift @@ -0,0 +1,22 @@ +class Solution { + func canThreePartsEqualSum(_ arr: [Int]) -> Bool { + let total = arr.reduce(0, +) + if total % 3 != 0 { + return false + } + let target = total / 3 + var currentSum = 0 + var partitions = 0 + for i in 0.. a + b, 0); + if (total % 3 !== 0) { + return false; + } + const target = total / 3; + let currentSum = 0; + let partitions = 0; + for (let i = 0; i < arr.length; i++) { + currentSum += arr[i]; + if (currentSum === target) { + partitions++; + currentSum = 0; + if (partitions === 2 && i < arr.length - 1) { + return true; + } + } + } + return false; +} diff --git a/tests/1001-1500/1014. best-sightseeing-pair/manifest.yaml b/tests/1001-1500/1014. best-sightseeing-pair/manifest.yaml new file mode 100644 index 00000000..7ebfdbcf --- /dev/null +++ b/tests/1001-1500/1014. best-sightseeing-pair/manifest.yaml @@ -0,0 +1,332 @@ +entry: + id: 1014 + title: best sightseeing pair + params: + values: + type: array + items: + type: int + call: + cpp: "Solution().maxScoreSightseeingPair({values})" + rust: "Solution::max_score_sightseeing_pair({values})" + python3: "Solution().maxScoreSightseeingPair({values})" + python2: "Solution().maxScoreSightseeingPair({values})" + ruby: "max_score_sightseeing_pair({values})" + java: "new Solution().maxScoreSightseeingPair({values})" + csharp: "new Solution().MaxScoreSightseeingPair({values})" + kotlin: "Solution().maxScoreSightseeingPair({values})" + go: "maxScoreSightseeingPair({values})" + dart: "Solution().maxScoreSightseeingPair({values})" + swift: "Solution().maxScoreSightseeingPair({values})" + typescript: "maxScoreSightseeingPair({values})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().check({result})" + checker: | + class Checker: + def check(self, result): + return True +seed: 1014 +tests: + - name: example-one + in: + values: + - 8 + - 1 + - 5 + - 2 + - 6 + out: 11 + - name: example-two + in: + values: + - 1 + - 2 + out: 2 + - name: two-equal + in: + values: + - 5 + - 5 + out: 9 + - name: three-increasing + in: + values: + - 1 + - 2 + - 3 + out: 4 + - name: three-decreasing + in: + values: + - 3 + - 2 + - 1 + out: 4 + - name: all-one-four + in: + values: + - 1 + - 1 + - 1 + - 1 + out: 1 + - name: all-tens + in: + values: + - 10 + - 10 + - 10 + - 10 + out: 19 + - name: peak-middle + in: + values: + - 1 + - 10 + - 1 + out: 10 + - name: valley-middle + in: + values: + - 10 + - 1 + - 10 + out: 18 + - name: long-increasing + in: + values: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + out: 10 + - name: long-decreasing + in: + values: + - 6 + - 5 + - 4 + - 3 + - 2 + - 1 + out: 10 + - name: alternating-high-low + in: + values: + - 9 + - 1 + - 9 + - 1 + - 9 + out: 16 + - name: alternating-low-high + in: + values: + - 1 + - 9 + - 1 + - 9 + - 1 + out: 16 + - name: spaced-peaks + in: + values: + - 5 + - 1 + - 5 + - 1 + - 5 + - 1 + out: 8 + - name: plateau + in: + values: + - 7 + - 7 + - 7 + - 7 + out: 13 + - name: plateau-long + in: + values: + - 7 + - 7 + - 7 + - 7 + - 7 + out: 13 + - name: mixed-small + in: + values: + - 2 + - 7 + - 1 + - 7 + - 2 + out: 12 + - name: mixed-small-two + in: + values: + - 2 + - 7 + - 1 + - 7 + - 2 + - 7 + out: 12 + - name: end-heavy + in: + values: + - 1 + - 1 + - 1 + - 100 + out: 100 + - name: start-heavy + in: + values: + - 100 + - 1 + - 1 + - 1 + out: 100 + - name: two-peaks + in: + values: + - 4 + - 8 + - 2 + - 8 + - 4 + out: 14 + - name: two-peaks-long + in: + values: + - 4 + - 8 + - 2 + - 8 + - 4 + - 8 + out: 14 + - name: low-variance + in: + values: + - 3 + - 4 + - 5 + - 4 + - 3 + out: 8 + - name: low-variance-long + in: + values: + - 3 + - 4 + - 5 + - 4 + - 3 + - 4 + out: 8 + - name: symmetric + in: + values: + - 6 + - 1 + - 1 + - 6 + out: 9 + - name: symmetric-long + in: + values: + - 6 + - 1 + - 1 + - 6 + - 1 + out: 9 + - name: big-gap + in: + values: + - 1 + - 100 + - 1 + out: 100 + - name: big-gap-long + in: + values: + - 1 + - 100 + - 1 + - 1 + out: 100 + - name: pair-at-ends + in: + values: + - 9 + - 1 + - 1 + - 9 + out: 15 + - name: pair-at-ends-long + in: + values: + - 9 + - 1 + - 1 + - 9 + - 1 + out: 15 + - name: gradual-rise + in: + values: + - 1 + - 3 + - 5 + - 7 + - 9 + out: 15 + - name: gradual-rise-long + in: + values: + - 1 + - 3 + - 5 + - 7 + - 9 + - 11 + out: 19 + - name: flat-and-spike + in: + values: + - 5 + - 5 + - 100 + - 5 + - 5 + out: 104 + - name: flat-and-spike-long + in: + values: + - 5 + - 5 + - 100 + - 5 + - 5 + - 5 + out: 104 + - name: descending-short + in: + values: + - 10 + - 9 + - 8 + out: 18 diff --git a/tests/1001-1500/1014. best-sightseeing-pair/sol.cpp b/tests/1001-1500/1014. best-sightseeing-pair/sol.cpp new file mode 100644 index 00000000..c002603a --- /dev/null +++ b/tests/1001-1500/1014. best-sightseeing-pair/sol.cpp @@ -0,0 +1,19 @@ +class Solution { +public: + int maxScoreSightseeingPair(vector& values) { + int n = values.size(); + vector suffixMax(n); + suffixMax[n - 1] = values[n - 1] - (n - 1); + + for (int i = n - 2; i >= 0; i--) { + suffixMax[i] = max(suffixMax[i + 1], values[i] - i); + } + + int maxScore = INT_MIN; + for (int i = 0; i < n - 1; i++) { + maxScore = max(maxScore, values[i] + i + suffixMax[i + 1]); + } + + return maxScore; + } +}; diff --git a/tests/1001-1500/1014. best-sightseeing-pair/sol.cs b/tests/1001-1500/1014. best-sightseeing-pair/sol.cs new file mode 100644 index 00000000..6200afde --- /dev/null +++ b/tests/1001-1500/1014. best-sightseeing-pair/sol.cs @@ -0,0 +1,18 @@ +public class Solution { + public int MaxScoreSightseeingPair(int[] values) { + int n = values.Length; + int[] suffixMax = new int[n]; + suffixMax[n - 1] = values[n - 1] - (n - 1); + + for (int i = n - 2; i >= 0; i--) { + suffixMax[i] = Math.Max(suffixMax[i + 1], values[i] - i); + } + + int maxScore = int.MinValue; + for (int i = 0; i < n - 1; i++) { + maxScore = Math.Max(maxScore, values[i] + i + suffixMax[i + 1]); + } + + return maxScore; + } +} diff --git a/tests/1001-1500/1014. best-sightseeing-pair/sol.dart b/tests/1001-1500/1014. best-sightseeing-pair/sol.dart new file mode 100644 index 00000000..e4664e59 --- /dev/null +++ b/tests/1001-1500/1014. best-sightseeing-pair/sol.dart @@ -0,0 +1,23 @@ +class Solution { + int maxScoreSightseeingPair(List values) { + int n = values.length; + List suffixMax = List.filled(n, 0); + suffixMax[n - 1] = values[n - 1] - (n - 1); + + for (int i = n - 2; i >= 0; i--) { + suffixMax[i] = suffixMax[i + 1] > values[i] - i + ? suffixMax[i + 1] + : values[i] - i; + } + + int maxScore = -1 << 63; + for (int i = 0; i < n - 1; i++) { + int score = values[i] + i + suffixMax[i + 1]; + if (score > maxScore) { + maxScore = score; + } + } + + return maxScore; + } +} diff --git a/tests/1001-1500/1014. best-sightseeing-pair/sol.go b/tests/1001-1500/1014. best-sightseeing-pair/sol.go new file mode 100644 index 00000000..cb5994c3 --- /dev/null +++ b/tests/1001-1500/1014. best-sightseeing-pair/sol.go @@ -0,0 +1,23 @@ +func maxScoreSightseeingPair(values []int) int { + n := len(values) + suffixMax := make([]int, n) + suffixMax[n-1] = values[n-1] - (n - 1) + + for i := n - 2; i >= 0; i-- { + if suffixMax[i+1] > values[i]-i { + suffixMax[i] = suffixMax[i+1] + } else { + suffixMax[i] = values[i] - i + } + } + + maxScore := -1 << 31 + for i := 0; i < n-1; i++ { + score := values[i] + i + suffixMax[i+1] + if score > maxScore { + maxScore = score + } + } + + return maxScore +} diff --git a/tests/1001-1500/1014. best-sightseeing-pair/sol.java b/tests/1001-1500/1014. best-sightseeing-pair/sol.java new file mode 100644 index 00000000..07546d6a --- /dev/null +++ b/tests/1001-1500/1014. best-sightseeing-pair/sol.java @@ -0,0 +1,18 @@ +class Solution { + public int maxScoreSightseeingPair(int[] values) { + int n = values.length; + int[] suffixMax = new int[n]; + suffixMax[n - 1] = values[n - 1] - (n - 1); + + for (int i = n - 2; i >= 0; i--) { + suffixMax[i] = Math.max(suffixMax[i + 1], values[i] - i); + } + + int maxScore = Integer.MIN_VALUE; + for (int i = 0; i < n - 1; i++) { + maxScore = Math.max(maxScore, values[i] + i + suffixMax[i + 1]); + } + + return maxScore; + } +} diff --git a/tests/1001-1500/1014. best-sightseeing-pair/sol.kt b/tests/1001-1500/1014. best-sightseeing-pair/sol.kt new file mode 100644 index 00000000..1da78e4f --- /dev/null +++ b/tests/1001-1500/1014. best-sightseeing-pair/sol.kt @@ -0,0 +1,18 @@ +class Solution { + fun maxScoreSightseeingPair(values: IntArray): Int { + val n = values.size + val suffixMax = IntArray(n) + suffixMax[n - 1] = values[n - 1] - (n - 1) + + for (i in n - 2 downTo 0) { + suffixMax[i] = maxOf(suffixMax[i + 1], values[i] - i) + } + + var maxScore = Int.MIN_VALUE + for (i in 0 until n - 1) { + maxScore = maxOf(maxScore, values[i] + i + suffixMax[i + 1]) + } + + return maxScore + } +} diff --git a/tests/1001-1500/1014. best-sightseeing-pair/sol.py b/tests/1001-1500/1014. best-sightseeing-pair/sol.py new file mode 100644 index 00000000..0a1a5824 --- /dev/null +++ b/tests/1001-1500/1014. best-sightseeing-pair/sol.py @@ -0,0 +1,15 @@ +class Solution: + def maxScoreSightseeingPair(self, values: List[int]) -> int: + n = len(values) + suffixMax = [0] * n + suffixMax[n - 1] = values[n - 1] - (n - 1) + + for i in range(n - 2, -1, -1): + suffixMax[i] = max(suffixMax[i + 1], values[i] - i) + + maxScore = float("-inf") + + for i in range(n - 1): + maxScore = max(maxScore, values[i] + i + suffixMax[i + 1]) + + return maxScore diff --git a/tests/1001-1500/1014. best-sightseeing-pair/sol.py2 b/tests/1001-1500/1014. best-sightseeing-pair/sol.py2 new file mode 100644 index 00000000..6d5b0feb --- /dev/null +++ b/tests/1001-1500/1014. best-sightseeing-pair/sol.py2 @@ -0,0 +1,18 @@ +class Solution(object): + def maxScoreSightseeingPair(self, values): + """ + :type values: List[int] + :rtype: int + """ + n = len(values) + suffixMax = [0] * n + suffixMax[n - 1] = values[n - 1] - (n - 1) + + for i in range(n - 2, -1, -1): + suffixMax[i] = max(suffixMax[i + 1], values[i] - i) + + maxScore = float('-inf') + for i in range(n - 1): + maxScore = max(maxScore, values[i] + i + suffixMax[i + 1]) + + return maxScore diff --git a/tests/1001-1500/1014. best-sightseeing-pair/sol.rb b/tests/1001-1500/1014. best-sightseeing-pair/sol.rb new file mode 100644 index 00000000..5f7f8b34 --- /dev/null +++ b/tests/1001-1500/1014. best-sightseeing-pair/sol.rb @@ -0,0 +1,18 @@ +# @param {Integer[]} values +# @return {Integer} +def max_score_sightseeing_pair(values) + n = values.length + suffix_max = [0] * n + suffix_max[n - 1] = values[n - 1] - (n - 1) + + (n - 2).downto(0) do |i| + suffix_max[i] = [suffix_max[i + 1], values[i] - i].max + end + + max_score = -Float::INFINITY + (0...n - 1).each do |i| + max_score = [max_score, values[i] + i + suffix_max[i + 1]].max + end + + max_score +end diff --git a/tests/1001-1500/1014. best-sightseeing-pair/sol.rs b/tests/1001-1500/1014. best-sightseeing-pair/sol.rs new file mode 100644 index 00000000..61e89705 --- /dev/null +++ b/tests/1001-1500/1014. best-sightseeing-pair/sol.rs @@ -0,0 +1,18 @@ +impl Solution { + pub fn max_score_sightseeing_pair(values: Vec) -> i32 { + let n = values.len(); + let mut suffix_max = vec![0; n]; + suffix_max[n - 1] = values[n - 1] - (n as i32 - 1); + + for i in (0..n - 1).rev() { + suffix_max[i] = std::cmp::max(suffix_max[i + 1], values[i] - i as i32); + } + + let mut max_score = i32::MIN; + for i in 0..n - 1 { + max_score = std::cmp::max(max_score, values[i] + i as i32 + suffix_max[i + 1]); + } + + max_score + } +} diff --git a/tests/1001-1500/1014. best-sightseeing-pair/sol.swift b/tests/1001-1500/1014. best-sightseeing-pair/sol.swift new file mode 100644 index 00000000..c0151638 --- /dev/null +++ b/tests/1001-1500/1014. best-sightseeing-pair/sol.swift @@ -0,0 +1,18 @@ +class Solution { + func maxScoreSightseeingPair(_ values: [Int]) -> Int { + let n = values.count + var suffixMax = [Int](repeating: 0, count: n) + suffixMax[n - 1] = values[n - 1] - (n - 1) + + for i in stride(from: n - 2, through: 0, by: -1) { + suffixMax[i] = max(suffixMax[i + 1], values[i] - i) + } + + var maxScore = Int.min + for i in 0..<(n - 1) { + maxScore = max(maxScore, values[i] + i + suffixMax[i + 1]) + } + + return maxScore + } +} diff --git a/tests/1001-1500/1014. best-sightseeing-pair/sol.ts b/tests/1001-1500/1014. best-sightseeing-pair/sol.ts new file mode 100644 index 00000000..69da207b --- /dev/null +++ b/tests/1001-1500/1014. best-sightseeing-pair/sol.ts @@ -0,0 +1,16 @@ +function maxScoreSightseeingPair(values: number[]): number { + const n = values.length; + const suffixMax: number[] = new Array(n); + suffixMax[n - 1] = values[n - 1] - (n - 1); + + for (let i = n - 2; i >= 0; i--) { + suffixMax[i] = Math.max(suffixMax[i + 1], values[i] - i); + } + + let maxScore = -Infinity; + for (let i = 0; i < n - 1; i++) { + maxScore = Math.max(maxScore, values[i] + i + suffixMax[i + 1]); + } + + return maxScore; +} diff --git a/tests/1001-1500/1015. smallest-integer-divisible-by-k/manifest.yaml b/tests/1001-1500/1015. smallest-integer-divisible-by-k/manifest.yaml new file mode 100644 index 00000000..066d84cc --- /dev/null +++ b/tests/1001-1500/1015. smallest-integer-divisible-by-k/manifest.yaml @@ -0,0 +1,177 @@ +entry: + id: 1015 + title: "smallest-integer-divisible-by-k" + params: + k: + type: int + call: + cpp: "Solution().smallestRepunitDivByK({k})" + rust: "Solution::smallest_repunit_div_by_k({k})" + python3: "Solution().smallestRepunitDivByK({k})" + python2: "Solution().smallestRepunitDivByK({k})" + ruby: "smallest_repunit_div_by_k({k})" + java: "new Solution().smallestRepunitDivByK({k})" + csharp: "new Solution().SmallestRepunitDivByK({k})" + kotlin: "Solution().smallestRepunitDivByK({k})" + go: "smallestRepunitDivByK({k})" + dart: "Solution().smallestRepunitDivByK({k})" + swift: "Solution().smallestRepunitDivByK({k})" + typescript: "smallestRepunitDivByK({k})" +judge: + type: "exact" +limits: + time_ms: 200 + memory_mb: 256 +oracle: + python3: + call: "Checker().check({result})" + checker: | + class Checker: + def check(self, result): + return True +seed: 1015 +tests: + - name: "k_1" + in: + k: 1 + out: 1 + - name: "k_2_even" + in: + k: 2 + out: -1 + - name: "k_3" + in: + k: 3 + out: 3 + - name: "k_4_even" + in: + k: 4 + out: -1 + - name: "k_5_multiple_of_5" + in: + k: 5 + out: -1 + - name: "k_6_even" + in: + k: 6 + out: -1 + - name: "k_7" + in: + k: 7 + out: 6 + - name: "k_8_even" + in: + k: 8 + out: -1 + - name: "k_9" + in: + k: 9 + out: 9 + - name: "k_10_even" + in: + k: 10 + out: -1 + - name: "k_11" + in: + k: 11 + out: 2 + - name: "k_12_even" + in: + k: 12 + out: -1 + - name: "k_13" + in: + k: 13 + out: 6 + - name: "k_14_even" + in: + k: 14 + out: -1 + - name: "k_15_multiple_of_5" + in: + k: 15 + out: -1 + - name: "k_17" + in: + k: 17 + out: 16 + - name: "k_19" + in: + k: 19 + out: 18 + - name: "k_21" + in: + k: 21 + out: 6 + - name: "k_23" + in: + k: 23 + out: 22 + - name: "k_24_even" + in: + k: 24 + out: -1 + - name: "k_25_multiple_of_5" + in: + k: 25 + out: -1 + - name: "k_27" + in: + k: 27 + out: 27 + - name: "k_29" + in: + k: 29 + out: 28 + - name: "k_31" + in: + k: 31 + out: 15 + - name: "k_33" + in: + k: 33 + out: 6 + - name: "k_37" + in: + k: 37 + out: 3 + - name: "k_39" + in: + k: 39 + out: 6 + - name: "k_41" + in: + k: 41 + out: 5 + - name: "k_43" + in: + k: 43 + out: 21 + - name: "k_45_multiple_of_5" + in: + k: 45 + out: -1 + - name: "k_49" + in: + k: 49 + out: 42 + - name: "k_53" + in: + k: 53 + out: 13 + - name: "k_59" + in: + k: 59 + out: 58 + - name: "k_61" + in: + k: 61 + out: 60 + - name: "k_67" + in: + k: 67 + out: 33 + - name: "k_71" + in: + k: 71 + out: 35 diff --git a/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.cpp b/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.cpp new file mode 100644 index 00000000..9e999fbd --- /dev/null +++ b/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.cpp @@ -0,0 +1,22 @@ +class Solution { +public: + int smallestRepunitDivByK(int k) { + if (k == 1) { + return 1; + } + + if (k % 2 == 0 || k % 5 == 0) { + return -1; + } + + int rem = 0; + for (int i = 1; i <= k; i++) { + rem = (rem * 10 + 1) % k; + if (rem == 0) { + return i; + } + } + + return -1; + } +}; diff --git a/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.cs b/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.cs new file mode 100644 index 00000000..40858d48 --- /dev/null +++ b/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.cs @@ -0,0 +1,21 @@ +public class Solution { + public int SmallestRepunitDivByK(int k) { + if (k == 1) { + return 1; + } + + if (k % 2 == 0 || k % 5 == 0) { + return -1; + } + + int rem = 0; + for (int i = 1; i <= k; i++) { + rem = (rem * 10 + 1) % k; + if (rem == 0) { + return i; + } + } + + return -1; + } +} diff --git a/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.dart b/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.dart new file mode 100644 index 00000000..340f4213 --- /dev/null +++ b/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.dart @@ -0,0 +1,21 @@ +class Solution { + int smallestRepunitDivByK(int k) { + if (k == 1) { + return 1; + } + + if (k % 2 == 0 || k % 5 == 0) { + return -1; + } + + int rem = 0; + for (int i = 1; i <= k; i++) { + rem = (rem * 10 + 1) % k; + if (rem == 0) { + return i; + } + } + + return -1; + } +} diff --git a/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.go b/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.go new file mode 100644 index 00000000..b2d32c2c --- /dev/null +++ b/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.go @@ -0,0 +1,19 @@ +func smallestRepunitDivByK(k int) int { + if k == 1 { + return 1 + } + + if k % 2 == 0 || k % 5 == 0 { + return -1 + } + + rem := 0 + for i := 1; i <= k; i++ { + rem = (rem * 10 + 1) % k + if rem == 0 { + return i + } + } + + return -1 +} diff --git a/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.java b/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.java new file mode 100644 index 00000000..c7166a37 --- /dev/null +++ b/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.java @@ -0,0 +1,21 @@ +class Solution { + public int smallestRepunitDivByK(int k) { + if (k == 1) { + return 1; + } + + if (k % 2 == 0 || k % 5 == 0) { + return -1; + } + + int rem = 0; + for (int i = 1; i <= k; i++) { + rem = (rem * 10 + 1) % k; + if (rem == 0) { + return i; + } + } + + return -1; + } +} diff --git a/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.kt b/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.kt new file mode 100644 index 00000000..0f9fee05 --- /dev/null +++ b/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.kt @@ -0,0 +1,21 @@ +class Solution { + fun smallestRepunitDivByK(k: Int): Int { + if (k == 1) { + return 1 + } + + if (k % 2 == 0 || k % 5 == 0) { + return -1 + } + + var rem = 0 + for (i in 1..k) { + rem = (rem * 10 + 1) % k + if (rem == 0) { + return i + } + } + + return -1 + } +} diff --git a/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.py b/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.py new file mode 100644 index 00000000..29b1f583 --- /dev/null +++ b/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.py @@ -0,0 +1,16 @@ +class Solution: + def smallestRepunitDivByK(self, k: int) -> int: + if k == 1: + return 1 + + # Numbers made of only 1s can never be divisible by 2 or 5 + if k % 2 == 0 or k % 5 == 0: + return -1 + + rem = 0 + for i in range(1, k + 1): + rem = (rem * 10 + 1) % k + if rem == 0: + return i + + return -1 diff --git a/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.py2 b/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.py2 new file mode 100644 index 00000000..12554a0e --- /dev/null +++ b/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.py2 @@ -0,0 +1,19 @@ +class Solution(object): + def smallestRepunitDivByK(self, k): + """ + :type k: int + :rtype: int + """ + if k == 1: + return 1 + + if k % 2 == 0 or k % 5 == 0: + return -1 + + rem = 0 + for i in range(1, k + 1): + rem = (rem * 10 + 1) % k + if rem == 0: + return i + + return -1 diff --git a/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.rb b/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.rb new file mode 100644 index 00000000..47fdbe24 --- /dev/null +++ b/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.rb @@ -0,0 +1,21 @@ +# @param {Integer} k +# @return {Integer} +def smallest_repunit_div_by_k(k) + if k == 1 + return 1 + end + + if k % 2 == 0 || k % 5 == 0 + return -1 + end + + rem = 0 + (1..k).each do |i| + rem = (rem * 10 + 1) % k + if rem == 0 + return i + end + end + + return -1 +end diff --git a/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.rs b/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.rs new file mode 100644 index 00000000..54dfc1c4 --- /dev/null +++ b/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.rs @@ -0,0 +1,21 @@ +impl Solution { + pub fn smallest_repunit_div_by_k(k: i32) -> i32 { + if k == 1 { + return 1; + } + + if k % 2 == 0 || k % 5 == 0 { + return -1; + } + + let mut rem = 0; + for i in 1..=k { + rem = (rem * 10 + 1) % k; + if rem == 0 { + return i; + } + } + + -1 + } +} diff --git a/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.swift b/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.swift new file mode 100644 index 00000000..365fdf52 --- /dev/null +++ b/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.swift @@ -0,0 +1,21 @@ +class Solution { + func smallestRepunitDivByK(_ k: Int) -> Int { + if k == 1 { + return 1 + } + + if k % 2 == 0 || k % 5 == 0 { + return -1 + } + + var rem = 0 + for i in 1...k { + rem = (rem * 10 + 1) % k + if rem == 0 { + return i + } + } + + return -1 + } +} diff --git a/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.ts b/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.ts new file mode 100644 index 00000000..471aef6e --- /dev/null +++ b/tests/1001-1500/1015. smallest-integer-divisible-by-k/sol.ts @@ -0,0 +1,19 @@ +function smallestRepunitDivByK(k: number): number { + if (k === 1) { + return 1; + } + + if (k % 2 === 0 || k % 5 === 0) { + return -1; + } + + let rem = 0; + for (let i = 1; i <= k; i++) { + rem = (rem * 10 + 1) % k; + if (rem === 0) { + return i; + } + } + + return -1; +} diff --git a/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/manifest.yaml b/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/manifest.yaml new file mode 100644 index 00000000..66bf48ee --- /dev/null +++ b/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/manifest.yaml @@ -0,0 +1,230 @@ +entry: + id: 1016 + title: binary-string-with-substrings-representing-1-to-n + params: + s: + type: string + n: + type: int + call: + cpp: Solution().queryString({s}, {n}) + rust: Solution::query_string({s}, {n}) + python3: Solution().queryString({s}, {n}) + python2: Solution().queryString({s}, {n}) + ruby: query_string({s}, {n}) + java: new Solution().queryString({s}, {n}) + csharp: new Solution().QueryString({s}, {n}) + kotlin: Solution().queryString({s}, {n}) + go: queryString({s}, {n}) + dart: Solution().queryString({s}, {n}) + swift: Solution().queryString({s}, {n}) + typescript: queryString({s}, {n}) +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 256 +oracle: + python3: + call: Checker().check(s, n, {result}) + checker: + "class Checker:\n def check(self, s, n, result):\n for num\ + \ in range(1, n + 1):\n if bin(num)[2:] not in s:\n \ + \ return False\n return result is True\n" +seed: 1016 +tests: + - name: example_true + in: + s: "0110" + n: 3 + out: true + - name: example_false + in: + s: "0110" + n: 4 + out: false + - name: single_zero + in: + s: "0" + n: 1 + out: false + - name: single_one + in: + s: "1" + n: 1 + out: true + - name: small_false_missing_two + in: + s: "10" + n: 2 + out: true + - name: small_true_three + in: + s: "1101011" + n: 5 + out: false + - name: false_missing_four + in: + s: "1110010" + n: 4 + out: true + - name: true_seven + in: + s: "111100101011" + n: 7 + out: true + - name: false_eight + in: + s: "111100101011" + n: 8 + out: false + - name: true_nine + in: + s: "1110001010110110" + n: 9 + out: false + - name: false_ten + in: + s: "1110001010110110" + n: 10 + out: false + - name: all_bits_1_to_3 + in: + s: "110111001011101" + n: 3 + out: true + - name: false_gap_for_five + in: + s: "101001101" + n: 5 + out: true + - name: true_five + in: + s: "110111001011" + n: 5 + out: true + - name: false_six + in: + s: "110111001011" + n: 6 + out: true + - name: true_three_longer + in: + s: "100111001011" + n: 3 + out: true + - name: false_four_longer + in: + s: "100111001011" + n: 4 + out: true + - name: true_two_repeated + in: + s: "101010101" + n: 2 + out: true + - name: false_three_repeated + in: + s: "101010101" + n: 3 + out: false + - name: true_one_after_zeros + in: + s: "0001000" + n: 1 + out: true + - name: false_two_after_zeros + in: + s: "0001000" + n: 2 + out: true + - name: true_four_with_padding + in: + s: "0011011100101" + n: 4 + out: true + - name: false_five_with_padding + in: + s: "0011011100101" + n: 5 + out: true + - name: true_six_with_padding + in: + s: "001101110010111" + n: 6 + out: true + - name: false_seven_with_padding + in: + s: "001101110010111" + n: 7 + out: true + - name: true_eight_dense + in: + s: "1110100110101110" + n: 8 + out: false + - name: false_nine_dense + in: + s: "1110100110101110" + n: 9 + out: false + - name: true_fifteen + in: + s: "111101101011001011110" + n: 15 + out: false + - name: false_sixteen + in: + s: "111101101011001011110" + n: 16 + out: false + - name: true_twenty + in: + s: "110111101011011001011101" + n: 20 + out: false + - name: false_twenty_one + in: + s: "110111101011011001011101" + n: 21 + out: false + - name: true_small_exact + in: + s: "1011" + n: 2 + out: true + - name: false_small_exact + in: + s: "1011" + n: 3 + out: true + - name: true_n11 + in: + s: "110101110011011" + n: 11 + out: false + - name: false_n12 + in: + s: "110101110011011" + n: 12 + out: false + - name: true_n13 + in: + s: "1110110101100111101" + n: 13 + out: false + - name: false_n14 + in: + s: "1110110101100111101" + n: 14 + out: false + - name: true_n31 + in: + s: "111101101011001011101111010110" + n: 31 + out: false + - name: false_n32 + in: + s: "111101101011001011101111010110" + n: 32 + out: false diff --git a/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.cpp b/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.cpp new file mode 100644 index 00000000..cb30ae6e --- /dev/null +++ b/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.cpp @@ -0,0 +1,29 @@ +class Solution { +public: + bool queryString(string s, int n) { + for (int num = n; num >= 1; num--) { + string target; + int temp = num; + while (temp > 0) { + target = (char)('0' + temp % 2) + target; + temp /= 2; + } + int length = target.length(); + int left = 0; + bool valid = false; + for (int right = 0; right < s.length(); right++) { + while (right - left + 1 > length) { + left++; + } + if (s.substr(left, right - left + 1) == target) { + valid = true; + break; + } + } + if (!valid) { + return false; + } + } + return true; + } +}; diff --git a/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.cs b/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.cs new file mode 100644 index 00000000..3409d3fa --- /dev/null +++ b/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.cs @@ -0,0 +1,23 @@ +public class Solution { + public bool QueryString(string s, int n) { + for (int num = n; num >= 1; num--) { + string target = Convert.ToString(num, 2); + int length = target.Length; + int left = 0; + bool valid = false; + for (int right = 0; right < s.Length; right++) { + while (right - left + 1 > length) { + left++; + } + if (s.Substring(left, right - left + 1) == target) { + valid = true; + break; + } + } + if (!valid) { + return false; + } + } + return true; + } +} diff --git a/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.dart b/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.dart new file mode 100644 index 00000000..db711928 --- /dev/null +++ b/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.dart @@ -0,0 +1,23 @@ +class Solution { + bool queryString(String s, int n) { + for (int num = n; num >= 1; num--) { + String target = num.toRadixString(2); + int length = target.length; + int left = 0; + bool valid = false; + for (int right = 0; right < s.length; right++) { + while (right - left + 1 > length) { + left++; + } + if (s.substring(left, right + 1) == target) { + valid = true; + break; + } + } + if (!valid) { + return false; + } + } + return true; + } +} diff --git a/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.go b/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.go new file mode 100644 index 00000000..48b26fba --- /dev/null +++ b/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.go @@ -0,0 +1,21 @@ +func queryString(s string, n int) bool { + for num := n; num >= 1; num-- { + target := fmt.Sprintf("%b", num) + length := len(target) + left := 0 + valid := false + for right := 0; right < len(s); right++ { + for right - left + 1 > length { + left++ + } + if s[left:right+1] == target { + valid = true + break + } + } + if !valid { + return false + } + } + return true +} diff --git a/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.java b/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.java new file mode 100644 index 00000000..7f2dc299 --- /dev/null +++ b/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.java @@ -0,0 +1,23 @@ +class Solution { + public boolean queryString(String s, int n) { + for (int num = n; num >= 1; num--) { + String target = Integer.toBinaryString(num); + int length = target.length(); + int left = 0; + boolean valid = false; + for (int right = 0; right < s.length(); right++) { + while (right - left + 1 > length) { + left++; + } + if (s.substring(left, right + 1).equals(target)) { + valid = true; + break; + } + } + if (!valid) { + return false; + } + } + return true; + } +} diff --git a/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.kt b/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.kt new file mode 100644 index 00000000..3e8fa053 --- /dev/null +++ b/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.kt @@ -0,0 +1,23 @@ +class Solution { + fun queryString(s: String, n: Int): Boolean { + for (num in n downTo 1) { + val target = Integer.toBinaryString(num) + val length = target.length + var left = 0 + var valid = false + for (right in s.indices) { + while (right - left + 1 > length) { + left++ + } + if (s.substring(left, right + 1) == target) { + valid = true + break + } + } + if (!valid) { + return false + } + } + return true + } +} diff --git a/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.py b/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.py new file mode 100644 index 00000000..137cdbb2 --- /dev/null +++ b/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.py @@ -0,0 +1,18 @@ +class Solution: + def queryString(self, s: str, n: int) -> bool: + for num in range(n, 0, -1): + target = bin(num)[2:] + length = len(target) + left = 0 + valid = False + for right in range(len(s)): + while right - left + 1 > length: + left += 1 + + if s[left : right + 1] == target: + valid = True + break + + if not valid: + return False + return True diff --git a/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.py2 b/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.py2 new file mode 100644 index 00000000..b4adbcfb --- /dev/null +++ b/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.py2 @@ -0,0 +1,21 @@ +class Solution(object): + def queryString(self, s, n): + """ + :type s: str + :type n: int + :rtype: bool + """ + for num in range(n, 0, -1): + target = bin(num)[2:] + length = len(target) + left = 0 + valid = False + for right in range(len(s)): + while right - left + 1 > length: + left += 1 + if s[left:right+1] == target: + valid = True + break + if not valid: + return False + return True diff --git a/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.rb b/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.rb new file mode 100644 index 00000000..bbf98061 --- /dev/null +++ b/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.rb @@ -0,0 +1,22 @@ +# @param {String} s +# @param {Integer} n +# @return {Boolean} +def query_string(s, n) + n.downto(1) do |num| + target = num.to_s(2) + length = target.length + left = 0 + valid = false + (0...s.length).each do |right| + while right - left + 1 > length + left += 1 + end + if s[left..right] == target + valid = true + break + end + end + return false unless valid + end + true +end diff --git a/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.rs b/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.rs new file mode 100644 index 00000000..dafe42b7 --- /dev/null +++ b/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.rs @@ -0,0 +1,25 @@ +impl Solution { + pub fn query_string(s: String, n: i32) -> bool { + let s_chars: Vec = s.chars().collect(); + for num in (1..=n).rev() { + let target = format!("{:b}", num); + let length = target.len(); + let mut left = 0; + let mut valid = false; + for right in 0..s_chars.len() { + while right - left + 1 > length { + left += 1; + } + let substring: String = s_chars[left..=right].iter().collect(); + if substring == target { + valid = true; + break; + } + } + if !valid { + return false; + } + } + true + } +} diff --git a/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.swift b/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.swift new file mode 100644 index 00000000..ad14b4a8 --- /dev/null +++ b/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.swift @@ -0,0 +1,24 @@ +class Solution { + func queryString(_ s: String, _ n: Int) -> Bool { + let chars = Array(s) + for num in stride(from: n, through: 1, by: -1) { + let target = String(num, radix: 2) + let length = target.count + var left = 0 + var valid = false + for right in 0.. length { + left += 1 + } + if String(chars[left...right]) == target { + valid = true + break + } + } + if !valid { + return false + } + } + return true + } +} diff --git a/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.ts b/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.ts new file mode 100644 index 00000000..f8d01b46 --- /dev/null +++ b/tests/1001-1500/1016. binary-string-with-substrings-representing-1-to-n/sol.ts @@ -0,0 +1,21 @@ +function queryString(s: string, n: number): boolean { + for (let num = n; num >= 1; num--) { + const target = num.toString(2); + const length = target.length; + let left = 0; + let valid = false; + for (let right = 0; right < s.length; right++) { + while (right - left + 1 > length) { + left++; + } + if (s.substring(left, right + 1) === target) { + valid = true; + break; + } + } + if (!valid) { + return false; + } + } + return true; +} diff --git a/tests/1001-1500/1017. convert-to-base-2/manifest.yaml b/tests/1001-1500/1017. convert-to-base-2/manifest.yaml new file mode 100644 index 00000000..e82ff463 --- /dev/null +++ b/tests/1001-1500/1017. convert-to-base-2/manifest.yaml @@ -0,0 +1,150 @@ +entry: + id: 1017 + title: "convert-to-base-2" + params: + n: + type: int + call: + cpp: "Solution().baseNeg2({n})" + rust: "Solution::base_neg2({n})" + python3: "Solution().baseNeg2({n})" + python2: "Solution().baseNeg2({n})" + ruby: "base_neg2({n})" + java: "new Solution().baseNeg2({n})" + csharp: "new Solution().BaseNeg2({n})" + kotlin: "Solution().baseNeg2({n})" + go: "baseNeg2({n})" + dart: "Solution().baseNeg2({n})" + swift: "Solution().baseNeg2({n})" + typescript: "baseNeg2({n})" +judge: + type: "exact" +limits: + time_ms: 200 + memory_mb: 256 +oracle: + python3: + call: "Checker().check(n, {result})" + checker: | + class Checker: + def check(self, n, result): + if n == 0: + return result == "0" + digits = [] + while n: + n, r = divmod(n, -2) + if r < 0: + n += 1 + r += 2 + digits.append(str(r)) + return ''.join(reversed(digits)) == result +seed: 1017 +tests: + - name: "zero" + in: + n: 0 + - name: "one" + in: + n: 1 + - name: "two" + in: + n: 2 + - name: "three" + in: + n: 3 + - name: "four" + in: + n: 4 + - name: "five" + in: + n: 5 + - name: "six" + in: + n: 6 + - name: "seven" + in: + n: 7 + - name: "eight" + in: + n: 8 + - name: "nine" + in: + n: 9 + - name: "ten" + in: + n: 10 + - name: "eleven" + in: + n: 11 + - name: "twelve" + in: + n: 12 + - name: "thirteen" + in: + n: 13 + - name: "fourteen" + in: + n: 14 + - name: "fifteen" + in: + n: 15 + - name: "sixteen" + in: + n: 16 + - name: "seventeen" + in: + n: 17 + - name: "eighteen" + in: + n: 18 + - name: "nineteen" + in: + n: 19 + - name: "twenty" + in: + n: 20 + - name: "twenty_one" + in: + n: 21 + - name: "twenty_two" + in: + n: 22 + - name: "twenty_three" + in: + n: 23 + - name: "twenty_four" + in: + n: 24 + - name: "twenty_five" + in: + n: 25 + - name: "thirty_one" + in: + n: 31 + - name: "thirty_two" + in: + n: 32 + - name: "thirty_three" + in: + n: 33 + - name: "forty_two" + in: + n: 42 + - name: "fifty_one" + in: + n: 51 + - name: "sixty_three" + in: + n: 63 + - name: "sixty_four" + in: + n: 64 + - name: "ninety_seven" + in: + n: 97 + - name: "one_hundred" + in: + n: 100 + - name: "one_hundred_twenty_three" + in: + n: 123 diff --git a/tests/1001-1500/1017. convert-to-base-2/sol.cpp b/tests/1001-1500/1017. convert-to-base-2/sol.cpp new file mode 100644 index 00000000..1362d88c --- /dev/null +++ b/tests/1001-1500/1017. convert-to-base-2/sol.cpp @@ -0,0 +1,14 @@ +class Solution { +public: + string baseNeg2(int n) { + if (n == 0) return "0"; + string res; + while (n != 0) { + int digit = n & 1; + res.push_back(char('0' + digit)); + n = (n - digit) / -2; + } + reverse(res.begin(), res.end()); + return res; + } +}; diff --git a/tests/1001-1500/1017. convert-to-base-2/sol.cs b/tests/1001-1500/1017. convert-to-base-2/sol.cs new file mode 100644 index 00000000..0aeb001b --- /dev/null +++ b/tests/1001-1500/1017. convert-to-base-2/sol.cs @@ -0,0 +1,16 @@ +public class Solution { + public string BaseNeg2(int n) { + if (n == 0) { + return "0"; + } + StringBuilder res = new StringBuilder(); + while (n != 0) { + int digit = n & 1; + res.Append((char)('0' + digit)); + n = (n - digit) / -2; + } + char[] chars = res.ToString().ToCharArray(); + Array.Reverse(chars); + return new string(chars); + } +} diff --git a/tests/1001-1500/1017. convert-to-base-2/sol.dart b/tests/1001-1500/1017. convert-to-base-2/sol.dart new file mode 100644 index 00000000..254c8173 --- /dev/null +++ b/tests/1001-1500/1017. convert-to-base-2/sol.dart @@ -0,0 +1,14 @@ +class Solution { + String baseNeg2(int n) { + if (n == 0) { + return '0'; + } + final res = []; + while (n != 0) { + final digit = n & 1; + res.add('$digit'); + n = (n - digit) ~/ -2; + } + return res.reversed.join(); + } +} diff --git a/tests/1001-1500/1017. convert-to-base-2/sol.go b/tests/1001-1500/1017. convert-to-base-2/sol.go new file mode 100644 index 00000000..9fa53cb0 --- /dev/null +++ b/tests/1001-1500/1017. convert-to-base-2/sol.go @@ -0,0 +1,15 @@ +func baseNeg2(n int) string { + if n == 0 { + return "0" + } + res := []byte{} + for n != 0 { + digit := n & 1 + res = append(res, byte('0'+digit)) + n = (n - digit) / -2 + } + for i, j := 0, len(res)-1; i < j; i, j = i+1, j-1 { + res[i], res[j] = res[j], res[i] + } + return string(res) +} diff --git a/tests/1001-1500/1017. convert-to-base-2/sol.java b/tests/1001-1500/1017. convert-to-base-2/sol.java new file mode 100644 index 00000000..63d79779 --- /dev/null +++ b/tests/1001-1500/1017. convert-to-base-2/sol.java @@ -0,0 +1,14 @@ +class Solution { + public String baseNeg2(int n) { + if (n == 0) { + return "0"; + } + StringBuilder res = new StringBuilder(); + while (n != 0) { + int digit = n & 1; + res.append((char)('0' + digit)); + n = (n - digit) / -2; + } + return res.reverse().toString(); + } +} diff --git a/tests/1001-1500/1017. convert-to-base-2/sol.kt b/tests/1001-1500/1017. convert-to-base-2/sol.kt new file mode 100644 index 00000000..25645b27 --- /dev/null +++ b/tests/1001-1500/1017. convert-to-base-2/sol.kt @@ -0,0 +1,15 @@ +class Solution { + fun baseNeg2(n: Int): String { + if (n == 0) { + return "0" + } + var num = n + val res = StringBuilder() + while (num != 0) { + val digit = num and 1 + res.append(('0'.code + digit).toChar()) + num = (num - digit) / -2 + } + return res.reverse().toString() + } +} diff --git a/tests/1001-1500/1017. convert-to-base-2/sol.py b/tests/1001-1500/1017. convert-to-base-2/sol.py new file mode 100644 index 00000000..6615cb58 --- /dev/null +++ b/tests/1001-1500/1017. convert-to-base-2/sol.py @@ -0,0 +1,10 @@ +class Solution: + def baseNeg2(self, n: int) -> str: + if n == 0: + return "0" + res = [] + while n != 0: + digit = n & 1 + res.append(str(digit)) + n = (n - digit) // -2 + return "".join(reversed(res)) diff --git a/tests/1001-1500/1017. convert-to-base-2/sol.py2 b/tests/1001-1500/1017. convert-to-base-2/sol.py2 new file mode 100644 index 00000000..0d231a2c --- /dev/null +++ b/tests/1001-1500/1017. convert-to-base-2/sol.py2 @@ -0,0 +1,10 @@ +class Solution(object): + def baseNeg2(self, n): + if n == 0: + return "0" + res = [] + while n != 0: + digit = n & 1 + res.append(str(digit)) + n = (n - digit) // -2 + return ''.join(reversed(res)) diff --git a/tests/1001-1500/1017. convert-to-base-2/sol.rb b/tests/1001-1500/1017. convert-to-base-2/sol.rb new file mode 100644 index 00000000..8b3f9d92 --- /dev/null +++ b/tests/1001-1500/1017. convert-to-base-2/sol.rb @@ -0,0 +1,12 @@ +# @param {Integer} n +# @return {String} +def base_neg2(n) + return '0' if n == 0 + res = [] + while n != 0 + digit = n & 1 + res << digit.to_s + n = (n - digit) / -2 + end + res.reverse.join +end diff --git a/tests/1001-1500/1017. convert-to-base-2/sol.rs b/tests/1001-1500/1017. convert-to-base-2/sol.rs new file mode 100644 index 00000000..748ec39c --- /dev/null +++ b/tests/1001-1500/1017. convert-to-base-2/sol.rs @@ -0,0 +1,15 @@ +impl Solution { + pub fn base_neg2(n: i32) -> String { + if n == 0 { + return "0".to_string(); + } + let mut num = n; + let mut res = String::new(); + while num != 0 { + let digit = num & 1; + res.push((b'0' + digit as u8) as char); + num = (num - digit) / -2; + } + res.chars().rev().collect() + } +} diff --git a/tests/1001-1500/1017. convert-to-base-2/sol.swift b/tests/1001-1500/1017. convert-to-base-2/sol.swift new file mode 100644 index 00000000..baf63f46 --- /dev/null +++ b/tests/1001-1500/1017. convert-to-base-2/sol.swift @@ -0,0 +1,15 @@ +class Solution { + func baseNeg2(_ n: Int) -> String { + if n == 0 { + return "0" + } + var num = n + var res = [Character]() + while num != 0 { + let digit = num & 1 + res.append(Character(String(digit))) + num = (num - digit) / -2 + } + return String(res.reversed()) + } +} diff --git a/tests/1001-1500/1017. convert-to-base-2/sol.ts b/tests/1001-1500/1017. convert-to-base-2/sol.ts new file mode 100644 index 00000000..4a1357f3 --- /dev/null +++ b/tests/1001-1500/1017. convert-to-base-2/sol.ts @@ -0,0 +1,12 @@ +function baseNeg2(n: number): string { + if (n === 0) { + return "0"; + } + const res: string[] = []; + while (n !== 0) { + const digit = n & 1; + res.push(String(digit)); + n = Math.trunc((n - digit) / -2); + } + return res.reverse().join(""); +} diff --git a/tests/1001-1500/1018. binary-prefix-divisible-by-5/manifest.yaml b/tests/1001-1500/1018. binary-prefix-divisible-by-5/manifest.yaml new file mode 100644 index 00000000..6822c75a --- /dev/null +++ b/tests/1001-1500/1018. binary-prefix-divisible-by-5/manifest.yaml @@ -0,0 +1,151 @@ +entry: + id: 1018 + title: "binary-prefix-divisible-by-5" + params: + nums: + type: array + items: + type: int + call: + cpp: "Solution().prefixesDivBy5({nums})" + rust: "Solution::prefixes_div_by5({nums})" + python3: "Solution().prefixesDivBy5({nums})" + python2: "Solution().prefixesDivBy5({nums})" + ruby: "prefixes_div_by5({nums})" + java: "new Solution().prefixesDivBy5({nums})" + csharp: "new Solution().PrefixesDivBy5({nums})" + kotlin: "Solution().prefixesDivBy5({nums})" + go: "prefixesDivBy5({nums})" + dart: "Solution().prefixesDivBy5({nums})" + swift: "Solution().prefixesDivBy5({nums})" + typescript: "prefixesDivBy5({nums})" +judge: + type: "exact" +limits: + time_ms: 200 + memory_mb: 256 +oracle: + python3: + call: "Checker().check(nums, {result})" + checker: | + class Checker: + def check(self, nums, result): + expected = [] + val = 0 + for bit in nums: + val = (val * 2 + bit) % 5 + expected.append(val == 0) + return result == expected +seed: 1018 +tests: + - name: "single_zero" + in: + nums: [0] + - name: "single_one" + in: + nums: [1] + - name: "two_zero_zero" + in: + nums: [0, 0] + - name: "two_one_zero" + in: + nums: [1, 0] + - name: "two_one_one" + in: + nums: [1, 1] + - name: "example_prefixes" + in: + nums: [0, 1, 1] + - name: "example_two" + in: + nums: [1, 1, 1] + - name: "alternating_start_zero" + in: + nums: [0, 1, 0, 1] + - name: "alternating_start_one" + in: + nums: [1, 0, 1, 0] + - name: "five_bits_all_zero" + in: + nums: [0, 0, 0, 0, 0] + - name: "five_bits_all_one" + in: + nums: [1, 1, 1, 1, 1] + - name: "prefix_divisible_then_not" + in: + nums: [1, 0, 0, 1] + - name: "longer_sample_one" + in: + nums: [1, 0, 1, 1, 0, 1] + - name: "longer_sample_two" + in: + nums: [0, 1, 1, 0, 1, 0] + - name: "ends_with_divisible" + in: + nums: [1, 0, 0, 0, 1] + - name: "binary_101010" + in: + nums: [1, 0, 1, 0, 1, 0] + - name: "binary_110011" + in: + nums: [1, 1, 0, 0, 1, 1] + - name: "binary_100000" + in: + nums: [1, 0, 0, 0, 0, 0] + - name: "binary_111000" + in: + nums: [1, 1, 1, 0, 0, 0] + - name: "binary_101001" + in: + nums: [1, 0, 1, 0, 0, 1] + - name: "binary_001011" + in: + nums: [0, 0, 1, 0, 1, 1] + - name: "binary_1101001" + in: + nums: [1, 1, 0, 1, 0, 0, 1] + - name: "binary_1011110" + in: + nums: [1, 0, 1, 1, 1, 1, 0] + - name: "binary_1001101" + in: + nums: [1, 0, 0, 1, 1, 0, 1] + - name: "binary_0110101" + in: + nums: [0, 1, 1, 0, 1, 0, 1] + - name: "binary_1111111" + in: + nums: [1, 1, 1, 1, 1, 1, 1] + - name: "binary_0000000" + in: + nums: [0, 0, 0, 0, 0, 0, 0] + - name: "binary_10101010" + in: + nums: [1, 0, 1, 0, 1, 0, 1, 0] + - name: "binary_10010010" + in: + nums: [1, 0, 0, 1, 0, 0, 1, 0] + - name: "binary_11011011" + in: + nums: [1, 1, 0, 1, 1, 0, 1, 1] + - name: "binary_11100011" + in: + nums: [1, 1, 1, 0, 0, 0, 1, 1] + - name: "binary_01010101" + in: + nums: [0, 1, 0, 1, 0, 1, 0, 1] + - name: "binary_10110011" + in: + nums: [1, 0, 1, 1, 0, 0, 1, 1] + - name: "binary_00110011" + in: + nums: [0, 0, 1, 1, 0, 0, 1, 1] + - name: "binary_11101011" + in: + nums: [1, 1, 1, 0, 1, 0, 1, 1] + - name: "binary_10000111" + in: + nums: [1, 0, 0, 0, 0, 1, 1, 1] + - name: "binary_01111110" + in: + nums: [0, 1, 1, 1, 1, 1, 1, 0] diff --git a/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.cpp b/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.cpp new file mode 100644 index 00000000..ed48182f --- /dev/null +++ b/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.cpp @@ -0,0 +1,12 @@ +class Solution { +public: + vector prefixesDivBy5(vector& nums) { + vector ans; + int val = 0; + for (int bit : nums) { + val = (val * 2 + bit) % 5; + ans.push_back(val == 0); + } + return ans; + } +}; diff --git a/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.cs b/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.cs new file mode 100644 index 00000000..6d36b18b --- /dev/null +++ b/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.cs @@ -0,0 +1,11 @@ +public class Solution { + public IList PrefixesDivBy5(int[] nums) { + IList ans = new List(); + int val = 0; + foreach (int bit in nums) { + val = (val * 2 + bit) % 5; + ans.Add(val == 0); + } + return ans; + } +} diff --git a/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.dart b/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.dart new file mode 100644 index 00000000..31a0b23d --- /dev/null +++ b/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.dart @@ -0,0 +1,11 @@ +class Solution { + List prefixesDivBy5(List nums) { + List ans = []; + int val = 0; + for (int bit in nums) { + val = (val * 2 + bit) % 5; + ans.add(val == 0); + } + return ans; + } +} diff --git a/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.go b/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.go new file mode 100644 index 00000000..99ea258c --- /dev/null +++ b/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.go @@ -0,0 +1,9 @@ +func prefixesDivBy5(nums []int) []bool { + ans := make([]bool, 0, len(nums)) + val := 0 + for _, bit := range nums { + val = (val*2 + bit) % 5 + ans = append(ans, val == 0) + } + return ans +} diff --git a/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.java b/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.java new file mode 100644 index 00000000..6f85feee --- /dev/null +++ b/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.java @@ -0,0 +1,11 @@ +class Solution { + public List prefixesDivBy5(int[] nums) { + List ans = new ArrayList<>(); + int val = 0; + for (int bit : nums) { + val = (val * 2 + bit) % 5; + ans.add(val == 0); + } + return ans; + } +} diff --git a/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.kt b/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.kt new file mode 100644 index 00000000..1198ac3e --- /dev/null +++ b/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.kt @@ -0,0 +1,11 @@ +class Solution { + fun prefixesDivBy5(nums: IntArray): List { + val ans = mutableListOf() + var v = 0 + for (bit in nums) { + v = (v * 2 + bit) % 5 + ans.add(v == 0) + } + return ans + } +} diff --git a/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.py b/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.py new file mode 100644 index 00000000..d27cd284 --- /dev/null +++ b/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.py @@ -0,0 +1,8 @@ +class Solution: + def prefixesDivBy5(self, nums): + ans = [] + val = 0 + for bit in nums: + val = (val * 2 + bit) % 5 + ans.append(val == 0) + return ans diff --git a/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.py2 b/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.py2 new file mode 100644 index 00000000..5482867a --- /dev/null +++ b/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.py2 @@ -0,0 +1,12 @@ +class Solution(object): + def prefixesDivBy5(self, nums): + """ + :type nums: List[int] + :rtype: List[bool] + """ + ans = [] + val = 0 + for bit in nums: + val = (val * 2 + bit) % 5 + ans.append(val == 0) + return ans diff --git a/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.rb b/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.rb new file mode 100644 index 00000000..a8743f75 --- /dev/null +++ b/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.rb @@ -0,0 +1,11 @@ +# @param {Integer[]} nums +# @return {Boolean[]} +def prefixes_div_by5(nums) + ans = [] + val = 0 + nums.each do |bit| + val = (val * 2 + bit) % 5 + ans << (val == 0) + end + ans +end diff --git a/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.rs b/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.rs new file mode 100644 index 00000000..3713da31 --- /dev/null +++ b/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.rs @@ -0,0 +1,11 @@ +impl Solution { + pub fn prefixes_div_by5(nums: Vec) -> Vec { + let mut ans = Vec::with_capacity(nums.len()); + let mut val = 0; + for bit in nums { + val = (val * 2 + bit) % 5; + ans.push(val == 0); + } + ans + } +} diff --git a/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.swift b/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.swift new file mode 100644 index 00000000..057508ca --- /dev/null +++ b/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.swift @@ -0,0 +1,11 @@ +class Solution { + func prefixesDivBy5(_ nums: [Int]) -> [Bool] { + var ans = [Bool]() + var val = 0 + for bit in nums { + val = (val * 2 + bit) % 5 + ans.append(val == 0) + } + return ans + } +} diff --git a/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.ts b/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.ts new file mode 100644 index 00000000..7bc156d9 --- /dev/null +++ b/tests/1001-1500/1018. binary-prefix-divisible-by-5/sol.ts @@ -0,0 +1,9 @@ +function prefixesDivBy5(nums: number[]): boolean[] { + const ans: boolean[] = []; + let val = 0; + for (const bit of nums) { + val = (val * 2 + bit) % 5; + ans.push(val === 0); + } + return ans; +} diff --git a/tests/1001-1500/1019. next-greater-node-in-linked-list/manifest.yaml b/tests/1001-1500/1019. next-greater-node-in-linked-list/manifest.yaml new file mode 100644 index 00000000..2b04c02e --- /dev/null +++ b/tests/1001-1500/1019. next-greater-node-in-linked-list/manifest.yaml @@ -0,0 +1,243 @@ +entry: + id: 1019 + title: "next-greater-node-in-linked-list" + params: + head: + type: list_node + call: + cpp: "Solution().nextLargerNodes({head})" + rust: "Solution::next_larger_nodes({head})" + python3: "Solution().nextLargerNodes({head})" + python2: "Solution().nextLargerNodes({head})" + ruby: "next_larger_nodes({head})" + java: "new Solution().nextLargerNodes({head})" + csharp: "new Solution().NextLargerNodes({head})" + kotlin: "Solution().nextLargerNodes({head})" + go: "nextLargerNodes({head})" + dart: "Solution().nextLargerNodes({head})" + swift: "Solution().nextLargerNodes({head})" + typescript: "nextLargerNodes({head})" +judge: + type: "exact" +limits: + time_ms: 200 + memory_mb: 256 +oracle: + python3: + call: "Checker().check({result})" + checker: | + class Checker: + def check(self, result): + return True +seed: 1019 +tests: + - name: "example_one" + in: + head: + elemType: "int" + value: [2, 1, 5] + out: [5, 5, 0] + - name: "example_two" + in: + head: + elemType: "int" + value: [2, 7, 4, 3, 5] + out: [7, 0, 5, 5, 0] + - name: "single_node" + in: + head: + elemType: "int" + value: [1] + out: [0] + - name: "two_increasing" + in: + head: + elemType: "int" + value: [1, 2] + out: [2, 0] + - name: "two_decreasing" + in: + head: + elemType: "int" + value: [2, 1] + out: [0, 0] + - name: "all_equal_three" + in: + head: + elemType: "int" + value: [3, 3, 3] + out: [0, 0, 0] + - name: "strictly_increasing_five" + in: + head: + elemType: "int" + value: [1, 2, 3, 4, 5] + out: [2, 3, 4, 5, 0] + - name: "strictly_decreasing_five" + in: + head: + elemType: "int" + value: [5, 4, 3, 2, 1] + out: [0, 0, 0, 0, 0] + - name: "plateau_then_drop" + in: + head: + elemType: "int" + value: [2, 2, 1] + out: [0, 0, 0] + - name: "plateau_then_rise" + in: + head: + elemType: "int" + value: [2, 2, 3] + out: [3, 3, 0] + - name: "mixed_small" + in: + head: + elemType: "int" + value: [1, 7, 5, 1, 9, 2, 5, 1] + out: [7, 9, 9, 9, 0, 5, 0, 0] + - name: "mixed_medium" + in: + head: + elemType: "int" + value: [4, 1, 2, 3, 1] + out: [0, 2, 3, 0, 0] + - name: "spike_middle" + in: + head: + elemType: "int" + value: [1, 3, 2, 4] + out: [3, 4, 4, 0] + - name: "repeated_blocks" + in: + head: + elemType: "int" + value: [1, 1, 2, 2, 3, 3] + out: [2, 2, 3, 3, 0, 0] + - name: "drop_then_rise" + in: + head: + elemType: "int" + value: [9, 1, 9] + out: [0, 9, 0] + - name: "alternating_small" + in: + head: + elemType: "int" + value: [1, 5, 2, 6, 3, 7] + out: [5, 6, 6, 7, 7, 0] + - name: "alternating_reverse" + in: + head: + elemType: "int" + value: [8, 1, 7, 2, 6, 3] + out: [0, 7, 0, 6, 0, 0] + - name: "zeros_and_peaks" + in: + head: + elemType: "int" + value: [0, 0, 1, 0, 2] + out: [1, 1, 2, 2, 0] + - name: "long_peak_right" + in: + head: + elemType: "int" + value: [1, 4, 3, 2, 5] + out: [4, 5, 5, 5, 0] + - name: "long_peak_left" + in: + head: + elemType: "int" + value: [5, 4, 3, 2, 6] + out: [6, 6, 6, 6, 0] + - name: "many_duplicates_end" + in: + head: + elemType: "int" + value: [2, 7, 7, 7, 1] + out: [7, 0, 0, 0, 0] + - name: "many_duplicates_start" + in: + head: + elemType: "int" + value: [7, 7, 7, 8] + out: [8, 8, 8, 0] + - name: "valley_shape" + in: + head: + elemType: "int" + value: [4, 2, 1, 3] + out: [0, 3, 3, 0] + - name: "hill_shape" + in: + head: + elemType: "int" + value: [1, 3, 5, 4, 2] + out: [3, 5, 0, 0, 0] + - name: "zigzag_one" + in: + head: + elemType: "int" + value: [2, 1, 2, 1, 2] + out: [0, 2, 0, 2, 0] + - name: "zigzag_two" + in: + head: + elemType: "int" + value: [1, 6, 1, 6, 1] + out: [6, 0, 6, 0, 0] + - name: "wide_range" + in: + head: + elemType: "int" + value: [10, 1, 9, 2, 8, 3, 7] + out: [0, 9, 0, 8, 0, 7, 0] + - name: "peak_at_end" + in: + head: + elemType: "int" + value: [1, 2, 3, 4, 10] + out: [2, 3, 4, 10, 0] + - name: "peak_at_start" + in: + head: + elemType: "int" + value: [10, 1, 2, 3, 4] + out: [0, 2, 3, 4, 0] + - name: "flat_then_peak" + in: + head: + elemType: "int" + value: [2, 2, 2, 5] + out: [5, 5, 5, 0] + - name: "peak_then_flat" + in: + head: + elemType: "int" + value: [5, 2, 2, 2] + out: [0, 0, 0, 0] + - name: "long_mixed_one" + in: + head: + elemType: "int" + value: [3, 1, 4, 1, 5, 9, 2, 6] + out: [4, 4, 5, 5, 9, 0, 6, 0] + - name: "long_mixed_two" + in: + head: + elemType: "int" + value: [8, 6, 7, 5, 3, 0, 9] + out: [9, 7, 9, 9, 9, 9, 0] + - name: "strictly_increasing_seven" + in: + head: + elemType: "int" + value: [1, 2, 3, 4, 5, 6, 7] + out: [2, 3, 4, 5, 6, 7, 0] + - name: "strictly_decreasing_seven" + in: + head: + elemType: "int" + value: [7, 6, 5, 4, 3, 2, 1] + out: [0, 0, 0, 0, 0, 0, 0] diff --git a/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.cpp b/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.cpp new file mode 100644 index 00000000..97a6777d --- /dev/null +++ b/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.cpp @@ -0,0 +1,21 @@ +class Solution { +public: + vector nextLargerNodes(ListNode* head) { + vector arr; + while (head) { + arr.push_back(head->val); + head = head->next; + } + int n = arr.size(); + vector ans(n, 0); + vector stack; + for (int i = 0; i < n; i++) { + while (!stack.empty() && arr[i] > arr[stack.back()]) { + ans[stack.back()] = arr[i]; + stack.pop_back(); + } + stack.push_back(i); + } + return ans; + } +}; diff --git a/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.cs b/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.cs new file mode 100644 index 00000000..1bbed9e6 --- /dev/null +++ b/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.cs @@ -0,0 +1,20 @@ +public class Solution { + public int[] NextLargerNodes(ListNode head) { + List arr = new List(); + while (head != null) { + arr.Add(head.val); + head = head.next; + } + int n = arr.Count; + int[] ans = new int[n]; + List stack = new List(); + for (int i = 0; i < n; i++) { + while (stack.Count > 0 && arr[i] > arr[stack[stack.Count - 1]]) { + ans[stack[stack.Count - 1]] = arr[i]; + stack.RemoveAt(stack.Count - 1); + } + stack.Add(i); + } + return ans; + } +} diff --git a/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.dart b/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.dart new file mode 100644 index 00000000..4329018f --- /dev/null +++ b/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.dart @@ -0,0 +1,19 @@ +class Solution { + List nextLargerNodes(ListNode? head) { + List arr = []; + while (head != null) { + arr.add(head.val); + head = head.next; + } + int n = arr.length; + List ans = List.filled(n, 0); + List stack = []; + for (int i = 0; i < n; i++) { + while (stack.isNotEmpty && arr[i] > arr[stack.last]) { + ans[stack.removeLast()] = arr[i]; + } + stack.add(i); + } + return ans; + } +} diff --git a/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.go b/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.go new file mode 100644 index 00000000..20c21d04 --- /dev/null +++ b/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.go @@ -0,0 +1,18 @@ +func nextLargerNodes(head *ListNode) []int { + arr := []int{} + for head != nil { + arr = append(arr, head.Val) + head = head.Next + } + n := len(arr) + ans := make([]int, n) + stack := []int{} + for i := 0; i < n; i++ { + for len(stack) > 0 && arr[i] > arr[stack[len(stack)-1]] { + ans[stack[len(stack)-1]] = arr[i] + stack = stack[:len(stack)-1] + } + stack = append(stack, i) + } + return ans +} diff --git a/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.java b/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.java new file mode 100644 index 00000000..8e38a529 --- /dev/null +++ b/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.java @@ -0,0 +1,20 @@ +class Solution { + public int[] nextLargerNodes(ListNode head) { + java.util.ArrayList arrList = new java.util.ArrayList<>(); + while (head != null) { + arrList.add(head.val); + head = head.next; + } + int n = arrList.size(); + int[] ans = new int[n]; + int[] stack = new int[n]; + int top = -1; + for (int i = 0; i < n; i++) { + while (top >= 0 && arrList.get(i) > arrList.get(stack[top])) { + ans[stack[top--]] = arrList.get(i); + } + stack[++top] = i; + } + return ans; + } +} diff --git a/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.kt b/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.kt new file mode 100644 index 00000000..a42b7320 --- /dev/null +++ b/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.kt @@ -0,0 +1,20 @@ +class Solution { + fun nextLargerNodes(head: ListNode?): IntArray { + val arr = mutableListOf() + var curr = head + while (curr != null) { + arr.add(curr.`val`) + curr = curr.next + } + val n = arr.size + val ans = IntArray(n) + val stack = mutableListOf() + for (i in 0 until n) { + while (stack.isNotEmpty() && arr[i] > arr[stack.last()]) { + ans[stack.removeAt(stack.size - 1)] = arr[i] + } + stack.add(i) + } + return ans + } +} diff --git a/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.py b/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.py new file mode 100644 index 00000000..d6e9003c --- /dev/null +++ b/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.py @@ -0,0 +1,14 @@ +class Solution: + def nextLargerNodes(self, head): + arr = [] + while head: + arr.append(head.val) + head = head.next + n = len(arr) + ans = [0] * n + stack = [] + for i in range(n): + while stack and arr[i] > arr[stack[-1]]: + ans[stack.pop()] = arr[i] + stack.append(i) + return ans diff --git a/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.py2 b/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.py2 new file mode 100644 index 00000000..044628de --- /dev/null +++ b/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.py2 @@ -0,0 +1,14 @@ +class Solution(object): + def nextLargerNodes(self, head): + arr = [] + while head: + arr.append(head.val) + head = head.next + n = len(arr) + ans = [0] * n + stack = [] + for i in range(n): + while stack and arr[i] > arr[stack[-1]]: + ans[stack.pop()] = arr[i] + stack.append(i) + return ans diff --git a/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.rb b/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.rb new file mode 100644 index 00000000..b2392611 --- /dev/null +++ b/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.rb @@ -0,0 +1,17 @@ +def next_larger_nodes(head) + arr = [] + while head + arr << head.val + head = head.next + end + n = arr.length + ans = Array.new(n, 0) + stack = [] + (0...n).each do |i| + while !stack.empty? && arr[i] > arr[stack.last] + ans[stack.pop] = arr[i] + end + stack << i + end + ans +end diff --git a/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.rs b/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.rs new file mode 100644 index 00000000..a3636d18 --- /dev/null +++ b/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.rs @@ -0,0 +1,24 @@ +impl Solution { + pub fn next_larger_nodes(head: Option>) -> Vec { + let mut arr = Vec::new(); + let mut curr = &head; + while let Some(node) = curr { + arr.push(node.val); + curr = &node.next; + } + let n = arr.len(); + let mut ans = vec![0; n]; + let mut stack: Vec = Vec::new(); + for i in 0..n { + while let Some(&top) = stack.last() { + if arr[i] > arr[top] { + ans[stack.pop().unwrap()] = arr[i]; + } else { + break; + } + } + stack.push(i); + } + ans + } +} diff --git a/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.swift b/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.swift new file mode 100644 index 00000000..b9f070d4 --- /dev/null +++ b/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.swift @@ -0,0 +1,20 @@ +class Solution { + func nextLargerNodes(_ head: ListNode?) -> [Int] { + var arr = [Int]() + var curr = head + while let node = curr { + arr.append(node.val) + curr = node.next + } + let n = arr.count + var ans = [Int](repeating: 0, count: n) + var stack = [Int]() + for i in 0.. arr[stack.last!] { + ans[stack.removeLast()] = arr[i] + } + stack.append(i) + } + return ans + } +} diff --git a/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.ts b/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.ts new file mode 100644 index 00000000..2ec6d223 --- /dev/null +++ b/tests/1001-1500/1019. next-greater-node-in-linked-list/sol.ts @@ -0,0 +1,17 @@ +function nextLargerNodes(head: ListNode | null): number[] { + const arr: number[] = []; + while (head !== null) { + arr.push(head.val); + head = head.next; + } + const n = arr.length; + const ans: number[] = new Array(n).fill(0); + const stack: number[] = []; + for (let i = 0; i < n; i++) { + while (stack.length && arr[i] > arr[stack[stack.length - 1]]) { + ans[stack.pop()!] = arr[i]; + } + stack.push(i); + } + return ans; +} diff --git a/tests/1001-1500/1020. number-of-enclaves/manifest.yaml b/tests/1001-1500/1020. number-of-enclaves/manifest.yaml new file mode 100644 index 00000000..61fc8914 --- /dev/null +++ b/tests/1001-1500/1020. number-of-enclaves/manifest.yaml @@ -0,0 +1,831 @@ +entry: + id: 1020 + title: number-of-enclaves + params: + grid: + type: array + items: + type: array + items: + type: int + call: + cpp: Solution().numEnclaves({grid}) + rust: Solution::num_enclaves({grid}) + python3: Solution().numEnclaves({grid}) + python2: Solution().numEnclaves({grid}) + ruby: num_enclaves({grid}) + java: new Solution().numEnclaves({grid}) + csharp: new Solution().NumEnclaves({grid}) + kotlin: Solution().numEnclaves({grid}) + go: numEnclaves({grid}) + dart: Solution().numEnclaves({grid}) + swift: Solution().numEnclaves({grid}) + typescript: numEnclaves({grid}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +seed: 1020 +tests: + - name: ex1 + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - - 1 + - 0 + - 1 + - 0 + - - 0 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + out: 3 + - name: ex2 + in: + grid: + elemType: int + value: + - - 0 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 1 + - 0 + - - 0 + - 0 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + out: 0 + - name: all_zero_1 + in: + grid: + elemType: int + value: + - - 0 + - - 0 + out: 0 + - name: all_zero_2 + in: + grid: + elemType: int + value: + - - 0 + - 0 + - - 0 + - 0 + out: 0 + - name: single_row_land + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 1 + - 1 + out: 0 + - name: single_col_land + in: + grid: + elemType: int + value: + - - 1 + - - 1 + - - 1 + out: 0 + - name: border_only + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 1 + - - 1 + - 0 + - 1 + - - 1 + - 1 + - 1 + out: 0 + - name: one_enclave + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 0 + - - 0 + - 1 + - 0 + - - 0 + - 0 + - 0 + out: 1 + - name: two_enclave + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 1 + - 0 + - - 0 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + out: 4 + - name: l_shape + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 1 + - 0 + - - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + out: 3 + - name: snake_1 + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 1 + - 0 + - - 0 + - 1 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + out: 7 + - name: snake_2 + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 0 + - 1 + - 0 + - - 0 + - 1 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + out: 6 + - name: border_touch_1 + in: + grid: + elemType: int + value: + - - 1 + - 0 + - 0 + - - 0 + - 1 + - 0 + - - 0 + - 0 + - 0 + out: 1 + - name: border_touch_2 + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 1 + - - 0 + - 1 + - 0 + - - 0 + - 0 + - 0 + out: 1 + - name: border_touch_3 + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 0 + - - 1 + - 1 + - 1 + - - 0 + - 0 + - 0 + out: 0 + - name: corner_cluster + in: + grid: + elemType: int + value: + - - 0 + - 1 + - 1 + - 0 + - - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + out: 0 + - name: isolated_center + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + out: 1 + - name: no_enclave_path + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 1 + - 1 + - 0 + - - 0 + - 1 + - 0 + - 1 + - 0 + - - 0 + - 1 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + out: 8 + - name: all_land_3x3 + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + out: 0 + - name: all_land_4x4 + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + out: 0 + - name: checkerboard_1 + in: + grid: + elemType: int + value: + - - 1 + - 0 + - 1 + - 0 + - - 0 + - 1 + - 0 + - 1 + - - 1 + - 0 + - 1 + - 0 + - - 0 + - 1 + - 0 + - 1 + out: 2 + - name: checkerboard_2 + in: + grid: + elemType: int + value: + - - 0 + - 1 + - 0 + - 1 + - - 1 + - 0 + - 1 + - 0 + - - 0 + - 1 + - 0 + - 1 + - - 1 + - 0 + - 1 + - 0 + out: 2 + - name: ring_1 + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 1 + - 1 + - 0 + - - 0 + - 1 + - 0 + - 1 + - 0 + - - 0 + - 1 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + out: 8 + - name: ring_2 + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 0 + - 1 + - 0 + - - 0 + - 1 + - 1 + - 1 + - 0 + - - 0 + - 1 + - 0 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + out: 7 + - name: small_mixed_1 + in: + grid: + elemType: int + value: + - - 0 + - 1 + - 0 + - - 1 + - 1 + - 1 + - - 0 + - 1 + - 0 + out: 0 + - name: small_mixed_2 + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 1 + - 0 + - - 0 + - 1 + - 1 + - 0 + - - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + out: 0 + - name: small_mixed_3 + in: + grid: + elemType: int + value: + - - 1 + - 0 + - 1 + - 0 + - - 0 + - 1 + - 1 + - 0 + - - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + out: 0 + - name: small_mixed_4 + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 0 + - 1 + - - 0 + - 1 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 0 + out: 0 + - name: small_mixed_5 + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 1 + - 0 + - - 1 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + out: 0 + - name: small_mixed_6 + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - - 1 + - 1 + - 1 + - 0 + - - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + out: 0 + - name: small_mixed_7 + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - - 1 + - 1 + - 1 + out: 0 + - name: small_mixed_8 + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 0 + - - 1 + - 1 + - 1 + - - 0 + - 0 + - 0 + out: 0 + - name: small_mixed_9 + in: + grid: + elemType: int + value: + - - 0 + - 1 + - 1 + - - 0 + - 1 + - 0 + - - 0 + - 0 + - 0 + out: 0 + - name: small_mixed_10 + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 0 + - - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + out: 0 + - name: small_mixed_11 + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 0 + - - 0 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + out: 3 + - name: small_mixed_12 + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 0 + - 0 + - - 0 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + out: 3 + - name: small_mixed_13 + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - - 1 + - 1 + - 0 + - 0 + - - 0 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + out: 0 + - name: small_mixed_14 + in: + grid: + elemType: int + value: + - - 0 + - 1 + - 0 + - 0 + - - 0 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + out: 0 + - name: small_mixed_15 + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 1 + - 1 + - - 0 + - 1 + - 0 + - 1 + - - 0 + - 0 + - 0 + - 0 + out: 0 + - name: small_mixed_16 + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 0 + out: 0 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" diff --git a/tests/1001-1500/1020. number-of-enclaves/sol.cpp b/tests/1001-1500/1020. number-of-enclaves/sol.cpp new file mode 100644 index 00000000..2dd8bbdb --- /dev/null +++ b/tests/1001-1500/1020. number-of-enclaves/sol.cpp @@ -0,0 +1,65 @@ +#include +#include +#include +#include +#include + +class Solution { +public: + int numEnclaves(vector>& grid) { + int total = 0; + for (const auto& row : grid) { + for (int val : row) { + total += val; + } + } + + int m = grid.size(); + int n = grid[0].size(); + if (m == 1 || n == 1) return 0; + + std::queue> q; + std::set> seen; + + for (int i = 0; i < n; i++) { + if (grid[0][i] == 1) { + q.push({0, i}); + seen.insert({0, i}); + } + if (grid[m-1][i] == 1) { + q.push({m-1, i}); + seen.insert({m-1, i}); + } + } + for (int i = 1; i < m-1; i++) { + if (grid[i][0] == 1) { + q.push({i, 0}); + seen.insert({i, 0}); + } + if (grid[i][n-1] == 1) { + q.push({i, n-1}); + seen.insert({i, n-1}); + } + } + + int directions[4][2] = {{0,1},{1,0},{0,-1},{-1,0}}; + int next_total = 0; + + while (!q.empty()) { + auto [x, y] = q.front(); + q.pop(); + next_total++; + + for (auto& dir : directions) { + int nx = x + dir[0]; + int ny = y + dir[1]; + if (nx >= 0 && nx < m && ny >= 0 && ny < n && grid[nx][ny] == 1 && seen.find({nx, ny}) == seen.end()) { + q.push({nx, ny}); + seen.insert({nx, ny}); + } + } + } + + return total - next_total; + } +}; diff --git a/tests/1001-1500/1020. number-of-enclaves/sol.cs b/tests/1001-1500/1020. number-of-enclaves/sol.cs new file mode 100644 index 00000000..464fce98 --- /dev/null +++ b/tests/1001-1500/1020. number-of-enclaves/sol.cs @@ -0,0 +1,59 @@ +using System.Collections.Generic; + +public class Solution { + public int NumEnclaves(int[][] grid) { + int total = 0; + foreach (var row in grid) { + foreach (int val in row) { + total += val; + } + } + + int m = grid.Length; + int n = grid[0].Length; + if (m == 1 || n == 1) return 0; + + Queue<(int, int)> q = new Queue<(int, int)>(); + HashSet<(int, int)> seen = new HashSet<(int, int)>(); + + for (int i = 0; i < n; i++) { + if (grid[0][i] == 1) { + q.Enqueue((0, i)); + seen.Add((0, i)); + } + if (grid[m-1][i] == 1) { + q.Enqueue((m-1, i)); + seen.Add((m-1, i)); + } + } + for (int i = 1; i < m-1; i++) { + if (grid[i][0] == 1) { + q.Enqueue((i, 0)); + seen.Add((i, 0)); + } + if (grid[i][n-1] == 1) { + q.Enqueue((i, n-1)); + seen.Add((i, n-1)); + } + } + + int[][] directions = new int[][] { new int[] {0,1}, new int[] {1,0}, new int[] {0,-1}, new int[] {-1,0} }; + int nextTotal = 0; + + while (q.Count > 0) { + var (x, y) = q.Dequeue(); + nextTotal++; + + foreach (var dir in directions) { + int nx = x + dir[0]; + int ny = y + dir[1]; + if (nx >= 0 && nx < m && ny >= 0 && ny < n && grid[nx][ny] == 1 && !seen.Contains((nx, ny))) { + q.Enqueue((nx, ny)); + seen.Add((nx, ny)); + } + } + } + + return total - nextTotal; + } +} diff --git a/tests/1001-1500/1020. number-of-enclaves/sol.dart b/tests/1001-1500/1020. number-of-enclaves/sol.dart new file mode 100644 index 00000000..674c7231 --- /dev/null +++ b/tests/1001-1500/1020. number-of-enclaves/sol.dart @@ -0,0 +1,68 @@ +import 'dart:collection'; + +class Solution { + int numEnclaves(List> grid) { + int total = 0; + for (var row in grid) { + for (var val in row) { + total += val; + } + } + + int m = grid.length; + int n = grid[0].length; + if (m == 1 || n == 1) return 0; + + Queue> q = Queue(); + Set seen = {}; + + for (int i = 0; i < n; i++) { + if (grid[0][i] == 1) { + q.add(Pair(0, i)); + seen.add("0,$i"); + } + if (grid[m-1][i] == 1) { + q.add(Pair(m-1, i)); + seen.add("${m-1},$i"); + } + } + for (int i = 1; i < m - 1; i++) { + if (grid[i][0] == 1) { + q.add(Pair(i, 0)); + seen.add("$i,0"); + } + if (grid[i][n-1] == 1) { + q.add(Pair(i, n-1)); + seen.add("$i,${n-1}"); + } + } + + List> directions = [[0,1],[1,0],[0,-1],[-1,0]]; + int nextTotal = 0; + + while (q.isNotEmpty) { + var curr = q.removeFirst(); + int x = curr.first; + int y = curr.second; + nextTotal++; + + for (var dir in directions) { + int nx = x + dir[0]; + int ny = y + dir[1]; + String key = "$nx,$ny"; + if (nx >= 0 && nx < m && ny >= 0 && ny < n && grid[nx][ny] == 1 && !seen.contains(key)) { + q.add(Pair(nx, ny)); + seen.add(key); + } + } + } + + return total - nextTotal; + } +} + +class Pair { + final F first; + final S second; + Pair(this.first, this.second); +} diff --git a/tests/1001-1500/1020. number-of-enclaves/sol.go b/tests/1001-1500/1020. number-of-enclaves/sol.go new file mode 100644 index 00000000..5a00a240 --- /dev/null +++ b/tests/1001-1500/1020. number-of-enclaves/sol.go @@ -0,0 +1,63 @@ +func numEnclaves(grid [][]int) int { + total := 0 + for _, row := range grid { + for _, val := range row { + total += val + } + } + + m, n := len(grid), len(grid[0]) + if m == 1 || n == 1 { + return 0 + } + + type pair struct{ x, y int } + q := []pair{} + seen := make(map[pair]bool) + + for i := 0; i < n; i++ { + if grid[0][i] == 1 { + p := pair{0, i} + q = append(q, p) + seen[p] = true + } + if grid[m-1][i] == 1 { + p := pair{m-1, i} + q = append(q, p) + seen[p] = true + } + } + for i := 1; i < m-1; i++ { + if grid[i][0] == 1 { + p := pair{i, 0} + q = append(q, p) + seen[p] = true + } + if grid[i][n-1] == 1 { + p := pair{i, n-1} + q = append(q, p) + seen[p] = true + } + } + + directions := [][2]int{{0,1},{1,0},{0,-1},{-1,0}} + nextTotal := 0 + + for len(q) > 0 { + curr := q[0] + q = q[1:] + nextTotal++ + x, y := curr.x, curr.y + + for _, d := range directions { + nx, ny := x + d[0], y + d[1] + p := pair{nx, ny} + if nx >= 0 && nx < m && ny >= 0 && ny < n && grid[nx][ny] == 1 && !seen[p] { + q = append(q, p) + seen[p] = true + } + } + } + + return total - nextTotal +} diff --git a/tests/1001-1500/1020. number-of-enclaves/sol.java b/tests/1001-1500/1020. number-of-enclaves/sol.java new file mode 100644 index 00000000..da58b3af --- /dev/null +++ b/tests/1001-1500/1020. number-of-enclaves/sol.java @@ -0,0 +1,61 @@ +import java.util.*; + +class Solution { + public int numEnclaves(int[][] grid) { + int total = 0; + for (int[] row : grid) { + for (int val : row) { + total += val; + } + } + + int m = grid.length; + int n = grid[0].length; + if (m == 1 || n == 1) return 0; + + Queue q = new LinkedList<>(); + Set seen = new HashSet<>(); + + for (int i = 0; i < n; i++) { + if (grid[0][i] == 1) { + q.offer(new int[]{0, i}); + seen.add("0," + i); + } + if (grid[m-1][i] == 1) { + q.offer(new int[]{m-1, i}); + seen.add((m-1) + "," + i); + } + } + for (int i = 1; i < m - 1; i++) { + if (grid[i][0] == 1) { + q.offer(new int[]{i, 0}); + seen.add(i + ",0"); + } + if (grid[i][n-1] == 1) { + q.offer(new int[]{i, n-1}); + seen.add(i + "," + (n-1)); + } + } + + int[][] directions = {{0,1},{1,0},{0,-1},{-1,0}}; + int nextTotal = 0; + + while (!q.isEmpty()) { + int[] curr = q.poll(); + int x = curr[0], y = curr[1]; + nextTotal++; + + for (int[] dir : directions) { + int nx = x + dir[0]; + int ny = y + dir[1]; + String key = nx + "," + ny; + if (nx >= 0 && nx < m && ny >= 0 && ny < n && grid[nx][ny] == 1 && !seen.contains(key)) { + q.offer(new int[]{nx, ny}); + seen.add(key); + } + } + } + + return total - nextTotal; + } +} diff --git a/tests/1001-1500/1020. number-of-enclaves/sol.kt b/tests/1001-1500/1020. number-of-enclaves/sol.kt new file mode 100644 index 00000000..8a9d190e --- /dev/null +++ b/tests/1001-1500/1020. number-of-enclaves/sol.kt @@ -0,0 +1,60 @@ +import java.util.* + +class Solution { + fun numEnclaves(grid: Array): Int { + var total = 0 + for (row in grid) { + for (v in row) { + total += v + } + } + + val m = grid.size + val n = grid[0].size + if (m == 1 || n == 1) return 0 + + val q: Queue> = LinkedList() + val seen = HashSet>() + + for (i in 0 until n) { + if (grid[0][i] == 1) { + q.offer(Pair(0, i)) + seen.add(Pair(0, i)) + } + if (grid[m-1][i] == 1) { + q.offer(Pair(m-1, i)) + seen.add(Pair(m-1, i)) + } + } + for (i in 1 until m-1) { + if (grid[i][0] == 1) { + q.offer(Pair(i, 0)) + seen.add(Pair(i, 0)) + } + if (grid[i][n-1] == 1) { + q.offer(Pair(i, n-1)) + seen.add(Pair(i, n-1)) + } + } + + val directions = arrayOf(intArrayOf(0,1), intArrayOf(1,0), intArrayOf(0,-1), intArrayOf(-1,0)) + var nextTotal = 0 + + while (q.isNotEmpty()) { + val (x, y) = q.poll() + nextTotal++ + + for (dir in directions) { + val nx = x + dir[0] + val ny = y + dir[1] + val pair = Pair(nx, ny) + if (nx in 0 until m && ny in 0 until n && grid[nx][ny] == 1 && pair !in seen) { + q.offer(pair) + seen.add(pair) + } + } + } + + return total - nextTotal + } +} diff --git a/tests/1001-1500/1020. number-of-enclaves/sol.py b/tests/1001-1500/1020. number-of-enclaves/sol.py new file mode 100644 index 00000000..7be25b23 --- /dev/null +++ b/tests/1001-1500/1020. number-of-enclaves/sol.py @@ -0,0 +1,42 @@ +class Solution: + def numEnclaves(self, grid: List[List[int]]) -> int: + total = sum(sum(i) for i in grid) + print(total) + q = deque([]) + m, n = len(grid), len(grid[0]) + if m == 1 or n == 1: + return 0 + seen = set() + for i in range(n): + if grid[0][i] == 1: + q.append((0, i)) + seen.add((0, i)) + if grid[m - 1][i] == 1: + q.append((m - 1, i)) + seen.add((m - 1, i)) + for i in range(1, m - 1): + if grid[i][0] == 1: + q.append((i, 0)) + seen.add((i, 0)) + if grid[i][n - 1] == 1: + q.append((i, n - 1)) + seen.add((i, n - 1)) + + directions = [[0, 1], [1, 0], [0, -1], [-1, 0]] + next_total = 0 + while q: + x, y = q.popleft() + + next_total += 1 + for i, j in directions: + nx, ny = x - i, y - j + if ( + 0 <= nx < m + and 0 <= ny < n + and grid[nx][ny] == 1 + and (nx, ny) not in seen + ): + q.append((nx, ny)) + seen.add((nx, ny)) + print(next_total) + return total - next_total diff --git a/tests/1001-1500/1020. number-of-enclaves/sol.py2 b/tests/1001-1500/1020. number-of-enclaves/sol.py2 new file mode 100644 index 00000000..a36a3d3a --- /dev/null +++ b/tests/1001-1500/1020. number-of-enclaves/sol.py2 @@ -0,0 +1,39 @@ +class Solution(object): + def numEnclaves(self, grid): + """ + :type grid: List[List[int]] + :rtype: int + """ + from collections import deque + total = sum(sum(i) for i in grid) + q = deque([]) + m, n = len(grid), len(grid[0]) + if m == 1 or n == 1: + return 0 + seen = set() + for i in range(n): + if grid[0][i] == 1: + q.append((0, i)) + seen.add((0, i)) + if grid[m-1][i] == 1: + q.append((m-1, i)) + seen.add((m-1, i)) + for i in range(1, m - 1): + if grid[i][0] == 1: + q.append((i, 0)) + seen.add((i, 0)) + if grid[i][n-1] == 1: + q.append((i, n-1)) + seen.add((i, n-1)) + + directions = [[0,1],[1,0],[0,-1],[-1,0]] + next_total = 0 + while q: + x, y = q.popleft() + next_total += 1 + for i, j in directions: + nx, ny = x + i, y + j + if 0 <= nx < m and 0 <= ny < n and grid[nx][ny] == 1 and (nx, ny) not in seen: + q.append((nx, ny)) + seen.add((nx, ny)) + return total - next_total diff --git a/tests/1001-1500/1020. number-of-enclaves/sol.rb b/tests/1001-1500/1020. number-of-enclaves/sol.rb new file mode 100644 index 00000000..aacb083e --- /dev/null +++ b/tests/1001-1500/1020. number-of-enclaves/sol.rb @@ -0,0 +1,51 @@ +# @param {Integer[][]} grid +# @return {Integer} +def num_enclaves(grid) + total = grid.sum { |row| row.sum } + m = grid.length + n = grid[0].length + return 0 if m == 1 || n == 1 + + seen = Set.new + q = [] + + (0...n).each do |i| + if grid[0][i] == 1 + q << [0, i] + seen.add([0, i]) + end + if grid[m-1][i] == 1 + q << [m-1, i] + seen.add([m-1, i]) + end + end + + (1...m-1).each do |i| + if grid[i][0] == 1 + q << [i, 0] + seen.add([i, 0]) + end + if grid[i][n-1] == 1 + q << [i, n-1] + seen.add([i, n-1]) + end + end + + directions = [[0,1],[1,0],[0,-1],[-1,0]] + next_total = 0 + + while !q.empty? + x, y = q.shift + next_total += 1 + directions.each do |dx, dy| + nx = x + dx + ny = y + dy + if nx >= 0 && nx < m && ny >= 0 && ny < n && grid[nx][ny] == 1 && !seen.include?([nx, ny]) + q << [nx, ny] + seen.add([nx, ny]) + end + end + end + + total - next_total +end diff --git a/tests/1001-1500/1020. number-of-enclaves/sol.rs b/tests/1001-1500/1020. number-of-enclaves/sol.rs new file mode 100644 index 00000000..d47c8510 --- /dev/null +++ b/tests/1001-1500/1020. number-of-enclaves/sol.rs @@ -0,0 +1,58 @@ +use std::collections::{VecDeque, HashSet}; + +impl Solution { + pub fn num_enclaves(grid: Vec>) -> i32 { + let total: i32 = grid.iter().map(|row| row.iter().sum::()).sum(); + let m = grid.len(); + let n = grid[0].len(); + if m == 1 || n == 1 { + return 0; + } + + let mut q: VecDeque<(usize, usize)> = VecDeque::new(); + let mut seen: HashSet<(usize, usize)> = HashSet::new(); + + for i in 0..n { + if grid[0][i] == 1 { + q.push_back((0, i)); + seen.insert((0, i)); + } + if grid[m-1][i] == 1 { + q.push_back((m-1, i)); + seen.insert((m-1, i)); + } + } + for i in 1..m-1 { + if grid[i][0] == 1 { + q.push_back((i, 0)); + seen.insert((i, 0)); + } + if grid[i][n-1] == 1 { + q.push_back((i, n-1)); + seen.insert((i, n-1)); + } + } + + let directions = [(0,1), (1,0), (0,-1), (-1,0)]; + let mut next_total = 0; + + while let Some((x, y)) = q.pop_front() { + next_total += 1; + + for &(dx, dy) in &directions { + let nx = x as isize + dx; + let ny = y as isize + dy; + if nx >= 0 && nx < m as isize && ny >= 0 && ny < n as isize { + let nx = nx as usize; + let ny = ny as usize; + if grid[nx][ny] == 1 && !seen.contains(&(nx, ny)) { + q.push_back((nx, ny)); + seen.insert((nx, ny)); + } + } + } + } + + total - next_total + } +} diff --git a/tests/1001-1500/1020. number-of-enclaves/sol.swift b/tests/1001-1500/1020. number-of-enclaves/sol.swift new file mode 100644 index 00000000..65b1ab02 --- /dev/null +++ b/tests/1001-1500/1020. number-of-enclaves/sol.swift @@ -0,0 +1,58 @@ +class Solution { + func numEnclaves(_ grid: [[Int]]) -> Int { + var total = 0 + for row in grid { + for val in row { + total += val + } + } + + let m = grid.count + let n = grid[0].count + if m == 1 || n == 1 { return 0 } + + var q: [(Int, Int)] = [] + var seen: Set<[Int]> = [] + + for i in 0..= 0 && nx < m && ny >= 0 && ny < n && grid[nx][ny] == 1 && !seen.contains(key) { + q.append((nx, ny)) + seen.insert(key) + } + } + } + + return total - nextTotal + } +} diff --git a/tests/1001-1500/1020. number-of-enclaves/sol.ts b/tests/1001-1500/1020. number-of-enclaves/sol.ts new file mode 100644 index 00000000..2bedfa1e --- /dev/null +++ b/tests/1001-1500/1020. number-of-enclaves/sol.ts @@ -0,0 +1,68 @@ +function numEnclaves(grid: number[][]): number { + let total = 0; + for (const row of grid) { + for (const val of row) { + total += val; + } + } + + const m = grid.length; + const n = grid[0].length; + if (m === 1 || n === 1) return 0; + + const q: [number, number][] = []; + const seen = new Set(); + + for (let i = 0; i < n; i++) { + if (grid[0][i] === 1) { + q.push([0, i]); + seen.add(`0,${i}`); + } + if (grid[m - 1][i] === 1) { + q.push([m - 1, i]); + seen.add(`${m - 1},${i}`); + } + } + for (let i = 1; i < m - 1; i++) { + if (grid[i][0] === 1) { + q.push([i, 0]); + seen.add(`${i},0`); + } + if (grid[i][n - 1] === 1) { + q.push([i, n - 1]); + seen.add(`${i},${n - 1}`); + } + } + + const directions = [ + [0, 1], + [1, 0], + [0, -1], + [-1, 0], + ]; + let nextTotal = 0; + + while (q.length > 0) { + const [x, y] = q.shift()!; + nextTotal++; + + for (const dir of directions) { + const nx = x + dir[0]; + const ny = y + dir[1]; + const key = `${nx},${ny}`; + if ( + nx >= 0 && + nx < m && + ny >= 0 && + ny < n && + grid[nx][ny] === 1 && + !seen.has(key) + ) { + q.push([nx, ny]); + seen.add(key); + } + } + } + + return total - nextTotal; +} diff --git a/tests/1001-1500/1021. remove-outermost-parentheses/manifest.yaml b/tests/1001-1500/1021. remove-outermost-parentheses/manifest.yaml new file mode 100644 index 00000000..9f4bb8c4 --- /dev/null +++ b/tests/1001-1500/1021. remove-outermost-parentheses/manifest.yaml @@ -0,0 +1,190 @@ +entry: + id: 1021 + title: remove-outermost-parentheses + params: + s: + type: string + call: + cpp: Solution().removeOuterParentheses({s}) + rust: Solution::remove_outer_parentheses({s}) + python3: Solution().removeOuterParentheses({s}) + python2: Solution().removeOuterParentheses({s}) + ruby: remove_outer_parentheses({s}) + java: new Solution().removeOuterParentheses({s}) + csharp: new Solution().RemoveOuterParentheses({s}) + kotlin: Solution().removeOuterParentheses({s}) + go: removeOuterParentheses({s}) + dart: Solution().removeOuterParentheses({s}) + swift: Solution().removeOuterParentheses({s}) + typescript: removeOuterParentheses({s}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +seed: 1021 +tests: + - name: ex1 + in: + s: (()())(()) + out: ()()() + - name: ex2 + in: + s: (()())(())(()(())) + out: ()()()()(()) + - name: ex3 + in: + s: ()() + out: "" + - name: single_primitive + in: + s: () + out: "" + - name: nested_2 + in: + s: (()) + out: () + - name: nested_3 + in: + s: ((())) + out: (()) + - name: two_primitives + in: + s: ()()(()) + out: () + - name: mixed_1 + in: + s: (()(())) + out: ()(()) + - name: mixed_2 + in: + s: ((()())) + out: (()()) + - name: mixed_3 + in: + s: (()())() + out: ()() + - name: mixed_4 + in: + s: ()((())) + out: (()) + - name: mixed_5 + in: + s: ((())()) + out: (())() + - name: mixed_6 + in: + s: (()(()())) + out: ()(()()) + - name: mixed_7 + in: + s: ((()()))() + out: (()()) + - name: mixed_8 + in: + s: ()((())()) + out: (())() + - name: mixed_9 + in: + s: (()())(()()) + out: ()()()() + - name: mixed_10 + in: + s: (((()))) + out: ((())) + - name: mixed_11 + in: + s: ()(()) + out: () + - name: mixed_12 + in: + s: ((()))() + out: (()) + - name: mixed_13 + in: + s: ()(()()) + out: ()() + - name: mixed_14 + in: + s: (()())(())() + out: ()()() + - name: mixed_15 + in: + s: ((()()))(()) + out: (()())() + - name: mixed_16 + in: + s: (()(()))() + out: ()(()) + - name: mixed_17 + in: + s: ()((()())) + out: (()()) + - name: mixed_18 + in: + s: ((())())() + out: (())() + - name: mixed_19 + in: + s: (()())((())) + out: ()()(()) + - name: mixed_20 + in: + s: (((()()))()) + out: ((()()))() + - name: mixed_21 + in: + s: ()(()(())) + out: ()(()) + - name: mixed_22 + in: + s: ((()())()) + out: (()())() + - name: mixed_23 + in: + s: (()()()) + out: ()()() + - name: mixed_24 + in: + s: (()(()))(()()) + out: ()(())()() + - name: mixed_25 + in: + s: ((()()))((())) + out: (()())(()) + - name: mixed_26 + in: + s: ()()()() + out: "" + - name: mixed_27 + in: + s: (((())))()() + out: ((())) + - name: mixed_28 + in: + s: ()((())())() + out: (())() + - name: mixed_29 + in: + s: (()())(()(())) + out: ()()()(()) + - name: mixed_30 + in: + s: ((())())((())) + out: (())()(()) + - name: mixed_31 + in: + s: (()(()()))(()()) + out: ()(()())()() + - name: mixed_32 + in: + s: ((()()))(()(())) + out: (()())()(()) + - name: mixed_33 + in: + s: (()())((()())) + out: ()()(()()) +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" diff --git a/tests/1001-1500/1021. remove-outermost-parentheses/sol.cpp b/tests/1001-1500/1021. remove-outermost-parentheses/sol.cpp new file mode 100644 index 00000000..b7ffe491 --- /dev/null +++ b/tests/1001-1500/1021. remove-outermost-parentheses/sol.cpp @@ -0,0 +1,20 @@ +class Solution { +public: + string removeOuterParentheses(string s) { + string res; + int balance = 0; + int start = 0; + for (int i = 0; i < s.size(); i++) { + if (s[i] == '(') { + balance++; + } else { + balance--; + } + if (balance == 0) { + res += s.substr(start + 1, i - start - 1); + start = i + 1; + } + } + return res; + } +}; diff --git a/tests/1001-1500/1021. remove-outermost-parentheses/sol.cs b/tests/1001-1500/1021. remove-outermost-parentheses/sol.cs new file mode 100644 index 00000000..2faa1739 --- /dev/null +++ b/tests/1001-1500/1021. remove-outermost-parentheses/sol.cs @@ -0,0 +1,19 @@ +public class Solution { + public string RemoveOuterParentheses(string s) { + var res = new System.Text.StringBuilder(); + int balance = 0; + int start = 0; + for (int i = 0; i < s.Length; i++) { + if (s[i] == '(') { + balance++; + } else { + balance--; + } + if (balance == 0) { + res.Append(s, start + 1, i - start - 1); + start = i + 1; + } + } + return res.ToString(); + } +} diff --git a/tests/1001-1500/1021. remove-outermost-parentheses/sol.dart b/tests/1001-1500/1021. remove-outermost-parentheses/sol.dart new file mode 100644 index 00000000..c3908c99 --- /dev/null +++ b/tests/1001-1500/1021. remove-outermost-parentheses/sol.dart @@ -0,0 +1,19 @@ +class Solution { + String removeOuterParentheses(String s) { + final res = StringBuffer(); + int balance = 0; + int start = 0; + for (int i = 0; i < s.length; i++) { + if (s[i] == '(') { + balance++; + } else { + balance--; + } + if (balance == 0) { + res.write(s.substring(start + 1, i)); + start = i + 1; + } + } + return res.toString(); + } +} diff --git a/tests/1001-1500/1021. remove-outermost-parentheses/sol.go b/tests/1001-1500/1021. remove-outermost-parentheses/sol.go new file mode 100644 index 00000000..a2ad4c7a --- /dev/null +++ b/tests/1001-1500/1021. remove-outermost-parentheses/sol.go @@ -0,0 +1,17 @@ +func removeOuterParentheses(s string) string { + var res []byte + balance := 0 + start := 0 + for i, ch := range s { + if ch == '(' { + balance++ + } else { + balance-- + } + if balance == 0 { + res = append(res, s[start+1:i]...) + start = i + 1 + } + } + return string(res) +} diff --git a/tests/1001-1500/1021. remove-outermost-parentheses/sol.java b/tests/1001-1500/1021. remove-outermost-parentheses/sol.java new file mode 100644 index 00000000..b1448144 --- /dev/null +++ b/tests/1001-1500/1021. remove-outermost-parentheses/sol.java @@ -0,0 +1,19 @@ +class Solution { + public String removeOuterParentheses(String s) { + StringBuilder res = new StringBuilder(); + int balance = 0; + int start = 0; + for (int i = 0; i < s.length(); i++) { + if (s.charAt(i) == '(') { + balance++; + } else { + balance--; + } + if (balance == 0) { + res.append(s, start + 1, i); + start = i + 1; + } + } + return res.toString(); + } +} diff --git a/tests/1001-1500/1021. remove-outermost-parentheses/sol.kt b/tests/1001-1500/1021. remove-outermost-parentheses/sol.kt new file mode 100644 index 00000000..9987fe1a --- /dev/null +++ b/tests/1001-1500/1021. remove-outermost-parentheses/sol.kt @@ -0,0 +1,19 @@ +class Solution { + fun removeOuterParentheses(s: String): String { + val res = StringBuilder() + var balance = 0 + var start = 0 + for (i in s.indices) { + if (s[i] == '(') { + balance++ + } else { + balance-- + } + if (balance == 0) { + res.append(s, start + 1, i) + start = i + 1 + } + } + return res.toString() + } +} diff --git a/tests/1001-1500/1021. remove-outermost-parentheses/sol.py b/tests/1001-1500/1021. remove-outermost-parentheses/sol.py new file mode 100644 index 00000000..3d3469cd --- /dev/null +++ b/tests/1001-1500/1021. remove-outermost-parentheses/sol.py @@ -0,0 +1,15 @@ +class Solution: + def removeOuterParentheses(self, s: str) -> str: + res = [] + balance = 0 + start = 0 + + for i, ch in enumerate(s): + if ch == "(": + balance += 1 + else: + balance -= 1 + if balance == 0: + res.append(s[start + 1 : i]) + start = i + 1 + return "".join(res) diff --git a/tests/1001-1500/1021. remove-outermost-parentheses/sol.py2 b/tests/1001-1500/1021. remove-outermost-parentheses/sol.py2 new file mode 100644 index 00000000..66c05186 --- /dev/null +++ b/tests/1001-1500/1021. remove-outermost-parentheses/sol.py2 @@ -0,0 +1,18 @@ +class Solution(object): + def removeOuterParentheses(self, s): + """ + :type s: str + :rtype: str + """ + res = [] + balance = 0 + start = 0 + for i, ch in enumerate(s): + if ch == '(': + balance += 1 + else: + balance -= 1 + if balance == 0: + res.append(s[start + 1:i]) + start = i + 1 + return ''.join(res) diff --git a/tests/1001-1500/1021. remove-outermost-parentheses/sol.rb b/tests/1001-1500/1021. remove-outermost-parentheses/sol.rb new file mode 100644 index 00000000..6fcf5804 --- /dev/null +++ b/tests/1001-1500/1021. remove-outermost-parentheses/sol.rb @@ -0,0 +1,19 @@ +# @param {String} s +# @return {String} +def remove_outer_parentheses(s) + res = [] + balance = 0 + start = 0 + s.each_char.with_index do |ch, i| + if ch == '(' + balance += 1 + else + balance -= 1 + end + if balance == 0 + res << s[start + 1...i] + start = i + 1 + end + end + res.join('') +end diff --git a/tests/1001-1500/1021. remove-outermost-parentheses/sol.rs b/tests/1001-1500/1021. remove-outermost-parentheses/sol.rs new file mode 100644 index 00000000..27580763 --- /dev/null +++ b/tests/1001-1500/1021. remove-outermost-parentheses/sol.rs @@ -0,0 +1,19 @@ +impl Solution { + pub fn remove_outer_parentheses(s: String) -> String { + let mut res = String::new(); + let mut balance = 0; + let mut start = 0; + for (i, ch) in s.char_indices() { + if ch == '(' { + balance += 1; + } else { + balance -= 1; + } + if balance == 0 { + res.push_str(&s[start + 1..i]); + start = i + 1; + } + } + res + } +} diff --git a/tests/1001-1500/1021. remove-outermost-parentheses/sol.swift b/tests/1001-1500/1021. remove-outermost-parentheses/sol.swift new file mode 100644 index 00000000..eaa93936 --- /dev/null +++ b/tests/1001-1500/1021. remove-outermost-parentheses/sol.swift @@ -0,0 +1,21 @@ +class Solution { + func removeOuterParentheses(_ s: String) -> String { + var res = "" + var balance = 0 + var start = s.startIndex + for (i, ch) in s.enumerated() { + if ch == "(" { + balance += 1 + } else { + balance -= 1 + } + if balance == 0 { + let startIdx = s.index(start, offsetBy: 1) + let endIdx = s.index(s.startIndex, offsetBy: i) + res += s[startIdx..val; + + if (node->left == nullptr && node->right == nullptr) { + return current; + } + + return dfs(node->left, current) + dfs(node->right, current); + } +}; diff --git a/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.cs b/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.cs new file mode 100644 index 00000000..0ddb3636 --- /dev/null +++ b/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.cs @@ -0,0 +1,32 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public int val; + * public TreeNode left; + * public TreeNode right; + * public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +public class Solution { + public int SumRootToLeaf(TreeNode root) { + return Dfs(root, 0); + } + + private int Dfs(TreeNode node, int current) { + if (node == null) { + return 0; + } + + current = current * 2 + node.val; + + if (node.left == null && node.right == null) { + return current; + } + + return Dfs(node.left, current) + Dfs(node.right, current); + } +} diff --git a/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.dart b/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.dart new file mode 100644 index 00000000..2a0feefc --- /dev/null +++ b/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.dart @@ -0,0 +1,28 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * int val; + * TreeNode? left; + * TreeNode? right; + * TreeNode([this.val = 0, this.left, this.right]); + * } + */ +class Solution { + int sumRootToLeaf(TreeNode? root) { + int dfs(TreeNode? node, int current) { + if (node == null) { + return 0; + } + + current = current * 2 + node.val; + + if (node.left == null && node.right == null) { + return current; + } + + return dfs(node.left, current) + dfs(node.right, current); + } + + return dfs(root, 0); + } +} diff --git a/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.go b/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.go new file mode 100644 index 00000000..febc1b4b --- /dev/null +++ b/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.go @@ -0,0 +1,26 @@ +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +func sumRootToLeaf(root *TreeNode) int { + var dfs func(*TreeNode, int) int + dfs = func(node *TreeNode, current int) int { + if node == nil { + return 0 + } + + current = current * 2 + node.Val + + if node.Left == nil && node.Right == nil { + return current + } + + return dfs(node.Left, current) + dfs(node.Right, current) + } + + return dfs(root, 0) +} diff --git a/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.java b/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.java new file mode 100644 index 00000000..1c629225 --- /dev/null +++ b/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.java @@ -0,0 +1,34 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode() {} + * TreeNode(int val) { this.val = val; } + * TreeNode(int val, TreeNode left, TreeNode right) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +class Solution { + public int sumRootToLeaf(TreeNode root) { + return dfs(root, 0); + } + + private int dfs(TreeNode node, int current) { + if (node == null) { + return 0; + } + + current = current * 2 + node.val; + + if (node.left == null && node.right == null) { + return current; + } + + return dfs(node.left, current) + dfs(node.right, current); + } +} diff --git a/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.kt b/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.kt new file mode 100644 index 00000000..f82018fa --- /dev/null +++ b/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.kt @@ -0,0 +1,29 @@ +/** + * Example: + * var ti = TreeNode(5) + * var v = ti.`val` + * Definition for a binary tree node. + * class TreeNode(var `val`: Int) { + * var left: TreeNode? = null + * var right: TreeNode? = null + * } + */ +class Solution { + fun sumRootToLeaf(root: TreeNode?): Int { + fun dfs(node: TreeNode?, current: Int): Int { + if (node == null) { + return 0 + } + + val newCurrent = current * 2 + node.`val` + + if (node.left == null && node.right == null) { + return newCurrent + } + + return dfs(node.left, newCurrent) + dfs(node.right, newCurrent) + } + + return dfs(root, 0) + } +} diff --git a/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.py b/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.py new file mode 100644 index 00000000..e2cb4800 --- /dev/null +++ b/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.py @@ -0,0 +1,18 @@ +class Solution: + def sumRootToLeaf(self, root): + + def dfs(node, current): + if not node: + return 0 + + # Build binary number + current = current * 2 + node.val + + # If leaf node + if not node.left and not node.right: + return current + + # Return sum of left and right subtree + return dfs(node.left, current) + dfs(node.right, current) + + return dfs(root, 0) diff --git a/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.py2 b/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.py2 new file mode 100644 index 00000000..2b6d5fd4 --- /dev/null +++ b/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.py2 @@ -0,0 +1,24 @@ +# Definition for a binary tree node. +# class TreeNode(object): +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution(object): + def sumRootToLeaf(self, root): + """ + :type root: Optional[TreeNode] + :rtype: int + """ + def dfs(node, current): + if not node: + return 0 + + current = current * 2 + node.val + + if not node.left and not node.right: + return current + + return dfs(node.left, current) + dfs(node.right, current) + + return dfs(root, 0) diff --git a/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.rb b/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.rb new file mode 100644 index 00000000..142b4a22 --- /dev/null +++ b/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.rb @@ -0,0 +1,26 @@ +# Definition for a binary tree node. +# class TreeNode +# attr_accessor :val, :left, :right +# def initialize(val = 0, left = nil, right = nil) +# @val = val +# @left = left +# @right = right +# end +# end +# @param {TreeNode} root +# @return {Integer} +def sum_root_to_leaf(root) + dfs = lambda do |node, current| + return 0 if node.nil? + + current = current * 2 + node.val + + if node.left.nil? && node.right.nil? + return current + end + + return dfs.call(node.left, current) + dfs.call(node.right, current) + end + + dfs.call(root, 0) +end diff --git a/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.rs b/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.rs new file mode 100644 index 00000000..80ac3d31 --- /dev/null +++ b/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.rs @@ -0,0 +1,39 @@ +// Definition for a binary tree node. +// #[derive(Debug, PartialEq, Eq)] +// pub struct TreeNode { +// pub val: i32, +// pub left: Option>>, +// pub right: Option>>, +// } +// +// impl TreeNode { +// #[inline] +// pub fn new(val: i32) -> Self { +// TreeNode { +// val, +// left: None, +// right: None +// } +// } +// } +impl Solution { + pub fn sum_root_to_leaf(root: Option>>) -> i32 { + fn dfs(node: &Option>>, current: i32) -> i32 { + match node { + None => return 0, + Some(n) => { + let n = n.borrow(); + let current = current * 2 + n.val; + + if n.left.is_none() && n.right.is_none() { + return current; + } + + return dfs(&n.left, current) + dfs(&n.right, current); + } + } + } + + dfs(&root, 0) + } +} diff --git a/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.swift b/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.swift new file mode 100644 index 00000000..1a95f09b --- /dev/null +++ b/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.swift @@ -0,0 +1,34 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public var val: Int + * public var left: TreeNode? + * public var right: TreeNode? + * public init() { self.val = 0; self.left = nil; self.right = nil; } + * public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; } + * public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) { + * self.val = val + * self.left = left + * self.right = right + * } + * } + */ +class Solution { + func sumRootToLeaf(_ root: TreeNode?) -> Int { + func dfs(_ node: TreeNode?, _ current: Int) -> Int { + guard let node = node else { + return 0 + } + + let newCurrent = current * 2 + node.val + + if node.left == nil && node.right == nil { + return newCurrent + } + + return dfs(node.left, newCurrent) + dfs(node.right, newCurrent) + } + + return dfs(root, 0) + } +} diff --git a/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.ts b/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.ts new file mode 100644 index 00000000..573d6ce9 --- /dev/null +++ b/tests/1001-1500/1022. sum-of-root-to-leaf-binary-numbers/sol.ts @@ -0,0 +1,31 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ + +function sumRootToLeaf(root: TreeNode | null): number { + const dfs = (node: TreeNode | null, current: number): number => { + if (node === null) { + return 0; + } + + current = current * 2 + node.val; + + if (node.left === null && node.right === null) { + return current; + } + + return dfs(node.left, current) + dfs(node.right, current); + }; + + return dfs(root, 0); +} diff --git a/tests/1001-1500/1023. camelcase-matching/manifest.yaml b/tests/1001-1500/1023. camelcase-matching/manifest.yaml new file mode 100644 index 00000000..4e842f40 --- /dev/null +++ b/tests/1001-1500/1023. camelcase-matching/manifest.yaml @@ -0,0 +1,550 @@ +entry: + id: 1023 + title: camelcase-matching + params: + queries: + type: array + items: + type: string + pattern: + type: string + call: + cpp: Solution().camelMatch({queries}, {pattern}) + rust: Solution::camel_match({queries}, {pattern}) + python3: Solution().camelMatch({queries}, {pattern}) + python2: Solution().camelMatch({queries}, {pattern}) + ruby: camel_match({queries}, {pattern}) + java: new Solution().camelMatch({queries}, {pattern}) + csharp: new Solution().CamelMatch({queries}, {pattern}) + kotlin: Solution().camelMatch({queries}, {pattern}) + go: camelMatch({queries}, {pattern}) + dart: Solution().camelMatch({queries}, {pattern}) + swift: Solution().camelMatch({queries}, {pattern}) + typescript: camelMatch({queries}, {pattern}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +seed: 1023 +tests: + - name: ex1 + in: + queries: + - FooBar + - FooBarTest + - FootBall + - FrameBuffer + - ForceFeedBack + pattern: FB + out: + - true + - false + - true + - true + - false + - name: ex2 + in: + queries: + - FooBar + - FooBarTest + - FootBall + - FrameBuffer + - ForceFeedBack + pattern: FoBa + out: + - true + - false + - true + - false + - false + - name: ex3 + in: + queries: + - FooBar + - FooBarTest + - FootBall + - FrameBuffer + - ForceFeedBack + pattern: FoBaT + out: + - false + - true + - false + - false + - false + - name: lower_only_1 + in: + queries: + - foo + - foobar + - football + pattern: fo + out: + - true + - true + - true + - name: lower_only_2 + in: + queries: + - foo + - bar + - baz + pattern: f + out: + - true + - false + - false + - name: empty_upper_match + in: + queries: + - a + - b + - c + pattern: a + out: + - true + - false + - false + - name: single_upper_ok + in: + queries: + - A + - AA + - aA + pattern: A + out: + - true + - false + - true + - name: single_upper_fail + in: + queries: + - B + - AB + - aB + pattern: A + out: + - false + - false + - false + - name: mixed_1 + in: + queries: + - CamelCase + - Camel + - Case + - camelCase + pattern: CC + out: + - true + - false + - false + - false + - name: mixed_2 + in: + queries: + - HiThere + - Hi + - Hithere + - HiT + pattern: HT + out: + - true + - false + - false + - true + - name: mixed_3 + in: + queries: + - ABC + - A + - AB + - AbC + pattern: ABC + out: + - true + - false + - false + - false + - name: mixed_4 + in: + queries: + - aBc + - abC + - Abc + - aBC + pattern: BC + out: + - false + - false + - false + - true + - name: mixed_5 + in: + queries: + - HelloWorld + - HiWorld + - HWorld + - Helloworld + pattern: HW + out: + - true + - true + - true + - false + - name: mixed_6 + in: + queries: + - FooBar + - FBar + - Far + - F + pattern: F + out: + - false + - false + - true + - true + - name: mixed_7 + in: + queries: + - FoBa + - FoB + - FoaBa + - FoBaX + pattern: FoBa + out: + - true + - false + - true + - false + - name: mixed_8 + in: + queries: + - FrameBuffer + - Frame + - Buffer + - FrmBfr + pattern: FB + out: + - true + - false + - false + - true + - name: mixed_9 + in: + queries: + - TestCase + - Test + - Case + - testCase + pattern: TC + out: + - true + - false + - false + - false + - name: mixed_10 + in: + queries: + - AlphaBetaGamma + - AlphaBeta + - ABeGa + - ABG + pattern: ABG + out: + - true + - false + - true + - true + - name: mixed_11 + in: + queries: + - ABCDEF + - AB + - ABC + - ABcDEf + pattern: ACE + out: + - false + - false + - false + - false + - name: mixed_12 + in: + queries: + - Z + - ZZ + - zZ + - Zz + pattern: Z + out: + - true + - false + - true + - true + - name: mixed_13 + in: + queries: + - QuickBrownFox + - QuickFox + - QBF + - Quickbrownfox + pattern: QBF + out: + - true + - false + - true + - false + - name: mixed_14 + in: + queries: + - CamelCaseMatching + - CamelCase + - Matching + - camelcasematching + pattern: CCM + out: + - true + - false + - false + - false + - name: mixed_15 + in: + queries: + - AaaaBbbb + - Aaaa + - Bbbb + - AaBb + pattern: AB + out: + - true + - false + - false + - true + - name: mixed_16 + in: + queries: + - Hello + - HeLlo + - Helo + - HELL + pattern: HL + out: + - false + - true + - false + - false + - name: mixed_17 + in: + queries: + - XyZ + - XZ + - xYz + - Xyz + pattern: XZ + out: + - true + - true + - false + - false + - name: mixed_18 + in: + queries: + - DataBase + - Data + - Base + - Db + pattern: DB + out: + - true + - false + - false + - false + - name: mixed_19 + in: + queries: + - MySql + - My + - Sql + - MSql + pattern: MS + out: + - true + - false + - false + - true + - name: mixed_20 + in: + queries: + - OneTwoThree + - OneTwo + - OTT + - Onetwothree + pattern: OTT + out: + - true + - false + - true + - false + - name: mixed_21 + in: + queries: + - ABcD + - ABD + - AB + - AbCd + pattern: ABD + out: + - true + - true + - false + - false + - name: mixed_22 + in: + queries: + - HelloWorld + - HW + - HWorld + - HelloWorLd + pattern: HW + out: + - true + - true + - true + - false + - name: mixed_23 + in: + queries: + - CodeReview + - Code + - Review + - CoRe + pattern: CR + out: + - true + - false + - false + - true + - name: mixed_24 + in: + queries: + - OpenAI + - Open + - AI + - OAI + pattern: OAI + out: + - true + - false + - false + - true + - name: mixed_25 + in: + queries: + - GitHub + - Git + - Hub + - GH + pattern: GH + out: + - true + - false + - false + - true + - name: mixed_26 + in: + queries: + - StackOverflow + - Stack + - Overflow + - SO + pattern: SO + out: + - true + - false + - false + - true + - name: mixed_27 + in: + queries: + - RedBlueGreen + - RedBlue + - RBG + - Redgreen + pattern: RBG + out: + - true + - false + - true + - false + - name: mixed_28 + in: + queries: + - FooBarBaz + - FooBaz + - FBB + - FooBar + pattern: FBB + out: + - true + - false + - true + - false + - name: mixed_29 + in: + queries: + - ABCXYZ + - AXZ + - ABX + - ABC + pattern: AXZ + out: + - false + - true + - false + - false + - name: mixed_30 + in: + queries: + - Alpha + - Beta + - Gamma + - Delta + pattern: AB + out: + - false + - false + - false + - false + - name: mixed_31 + in: + queries: + - AaAaAa + - AAA + - AaA + - aAaA + pattern: AAA + out: + - true + - true + - false + - false + - name: mixed_32 + in: + queries: + - ZZTop + - ZTop + - Z + - Top + pattern: ZT + out: + - false + - true + - false + - false +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" diff --git a/tests/1001-1500/1023. camelcase-matching/sol.cpp b/tests/1001-1500/1023. camelcase-matching/sol.cpp new file mode 100644 index 00000000..2fc10206 --- /dev/null +++ b/tests/1001-1500/1023. camelcase-matching/sol.cpp @@ -0,0 +1,25 @@ +class Solution { +public: + vector camelMatch(vector& queries, string pattern) { + vector ans; + for (const string& query : queries) { + int j = 0; + int i = 0; + while (i < query.size()) { + if (isupper(query[i]) && ((j < pattern.size() && query[i] != pattern[j]) || j > pattern.size() - 1)) { + break; + } + if (j < pattern.size() && query[i] == pattern[j]) { + j++; + } + i++; + } + if (i == query.size() && j == pattern.size()) { + ans.push_back(true); + } else { + ans.push_back(false); + } + } + return ans; + } +}; diff --git a/tests/1001-1500/1023. camelcase-matching/sol.cs b/tests/1001-1500/1023. camelcase-matching/sol.cs new file mode 100644 index 00000000..97553b89 --- /dev/null +++ b/tests/1001-1500/1023. camelcase-matching/sol.cs @@ -0,0 +1,24 @@ +public class Solution { + public IList CamelMatch(string[] queries, string pattern) { + IList ans = new List(); + foreach (string query in queries) { + int j = 0; + int i = 0; + while (i < query.Length) { + if (char.IsUpper(query[i]) && ((j < pattern.Length && query[i] != pattern[j]) || j > pattern.Length - 1)) { + break; + } + if (j < pattern.Length && query[i] == pattern[j]) { + j++; + } + i++; + } + if (i == query.Length && j == pattern.Length) { + ans.Add(true); + } else { + ans.Add(false); + } + } + return ans; + } +} diff --git a/tests/1001-1500/1023. camelcase-matching/sol.dart b/tests/1001-1500/1023. camelcase-matching/sol.dart new file mode 100644 index 00000000..cdb165a6 --- /dev/null +++ b/tests/1001-1500/1023. camelcase-matching/sol.dart @@ -0,0 +1,24 @@ +class Solution { + List camelMatch(List queries, String pattern) { + List ans = []; + for (String query in queries) { + int j = 0; + int i = 0; + while (i < query.length) { + if (query[i].toUpperCase() == query[i] && query[i] != query[i].toLowerCase() && ((j < pattern.length && query[i] != pattern[j]) || j > pattern.length - 1)) { + break; + } + if (j < pattern.length && query[i] == pattern[j]) { + j++; + } + i++; + } + if (i == query.length && j == pattern.length) { + ans.add(true); + } else { + ans.add(false); + } + } + return ans; + } +} diff --git a/tests/1001-1500/1023. camelcase-matching/sol.go b/tests/1001-1500/1023. camelcase-matching/sol.go new file mode 100644 index 00000000..a697768f --- /dev/null +++ b/tests/1001-1500/1023. camelcase-matching/sol.go @@ -0,0 +1,22 @@ +func camelMatch(queries []string, pattern string) []bool { + ans := make([]bool, 0, len(queries)) + for _, query := range queries { + j := 0 + i := 0 + for i < len(query) { + if query[i] >= 'A' && query[i] <= 'Z' && ((j < len(pattern) && query[i] != pattern[j]) || j > len(pattern)-1) { + break + } + if j < len(pattern) && query[i] == pattern[j] { + j++ + } + i++ + } + if i == len(query) && j == len(pattern) { + ans = append(ans, true) + } else { + ans = append(ans, false) + } + } + return ans +} diff --git a/tests/1001-1500/1023. camelcase-matching/sol.java b/tests/1001-1500/1023. camelcase-matching/sol.java new file mode 100644 index 00000000..981dba84 --- /dev/null +++ b/tests/1001-1500/1023. camelcase-matching/sol.java @@ -0,0 +1,24 @@ +class Solution { + public List camelMatch(String[] queries, String pattern) { + List ans = new ArrayList<>(); + for (String query : queries) { + int j = 0; + int i = 0; + while (i < query.length()) { + if (Character.isUpperCase(query.charAt(i)) && ((j < pattern.length() && query.charAt(i) != pattern.charAt(j)) || j > pattern.length() - 1)) { + break; + } + if (j < pattern.length() && query.charAt(i) == pattern.charAt(j)) { + j++; + } + i++; + } + if (i == query.length() && j == pattern.length()) { + ans.add(true); + } else { + ans.add(false); + } + } + return ans; + } +} diff --git a/tests/1001-1500/1023. camelcase-matching/sol.kt b/tests/1001-1500/1023. camelcase-matching/sol.kt new file mode 100644 index 00000000..e0f7d7a7 --- /dev/null +++ b/tests/1001-1500/1023. camelcase-matching/sol.kt @@ -0,0 +1,24 @@ +class Solution { + fun camelMatch(queries: Array, pattern: String): List { + val ans = mutableListOf() + for (query in queries) { + var j = 0 + var i = 0 + while (i < query.length) { + if (query[i].isUpperCase() && ((j < pattern.length && query[i] != pattern[j]) || j > pattern.length - 1)) { + break + } + if (j < pattern.length && query[i] == pattern[j]) { + j++ + } + i++ + } + if (i == query.length && j == pattern.length) { + ans.add(true) + } else { + ans.add(false) + } + } + return ans + } +} diff --git a/tests/1001-1500/1023. camelcase-matching/sol.py b/tests/1001-1500/1023. camelcase-matching/sol.py new file mode 100644 index 00000000..89b90b47 --- /dev/null +++ b/tests/1001-1500/1023. camelcase-matching/sol.py @@ -0,0 +1,25 @@ +class Solution: + def camelMatch(self, queries: List[str], pattern: str) -> List[bool]: + ans = [] + + for query in queries: + j = 0 + i = 0 + while i < len(query): + if query[i].isupper() and ( + (j < len(pattern) and query[i] != pattern[j]) + or j > len(pattern) - 1 + ): + break + + if j < len(pattern) and query[i] == pattern[j]: + j += 1 + + i += 1 + + if i == len(query) and j == len(pattern): + ans.append(True) + else: + ans.append(False) + + return ans diff --git a/tests/1001-1500/1023. camelcase-matching/sol.py2 b/tests/1001-1500/1023. camelcase-matching/sol.py2 new file mode 100644 index 00000000..d219e6b4 --- /dev/null +++ b/tests/1001-1500/1023. camelcase-matching/sol.py2 @@ -0,0 +1,22 @@ +class Solution(object): + def camelMatch(self, queries, pattern): + """ + :type queries: List[str] + :type pattern: str + :rtype: List[bool] + """ + ans = [] + for query in queries: + j = 0 + i = 0 + while i < len(query): + if query[i].isupper() and ((j < len(pattern) and query[i] != pattern[j]) or j > len(pattern)-1): + break + if j < len(pattern) and query[i] == pattern[j]: + j += 1 + i += 1 + if i == len(query) and j == len(pattern): + ans.append(True) + else: + ans.append(False) + return ans diff --git a/tests/1001-1500/1023. camelcase-matching/sol.rb b/tests/1001-1500/1023. camelcase-matching/sol.rb new file mode 100644 index 00000000..20bdd19c --- /dev/null +++ b/tests/1001-1500/1023. camelcase-matching/sol.rb @@ -0,0 +1,25 @@ +# @param {String[]} queries +# @param {String} pattern +# @return {Boolean[]} +def camel_match(queries, pattern) + ans = [] + queries.each do |query| + j = 0 + i = 0 + while i < query.length + if query[i] == query[i].upcase && ((j < pattern.length && query[i] != pattern[j]) || j > pattern.length - 1) + break + end + if j < pattern.length && query[i] == pattern[j] + j += 1 + end + i += 1 + end + if i == query.length && j == pattern.length + ans << true + else + ans << false + end + end + ans +end diff --git a/tests/1001-1500/1023. camelcase-matching/sol.rs b/tests/1001-1500/1023. camelcase-matching/sol.rs new file mode 100644 index 00000000..793355a8 --- /dev/null +++ b/tests/1001-1500/1023. camelcase-matching/sol.rs @@ -0,0 +1,26 @@ +impl Solution { + pub fn camel_match(queries: Vec, pattern: String) -> Vec { + let mut ans = Vec::new(); + for query in queries { + let mut j = 0; + let mut i = 0; + let query_chars: Vec = query.chars().collect(); + let pattern_chars: Vec = pattern.chars().collect(); + while i < query_chars.len() { + if query_chars[i].is_uppercase() && ((j < pattern_chars.len() && query_chars[i] != pattern_chars[j]) || j > pattern_chars.len() - 1) { + break; + } + if j < pattern_chars.len() && query_chars[i] == pattern_chars[j] { + j += 1; + } + i += 1; + } + if i == query_chars.len() && j == pattern_chars.len() { + ans.push(true); + } else { + ans.push(false); + } + } + ans + } +} diff --git a/tests/1001-1500/1023. camelcase-matching/sol.swift b/tests/1001-1500/1023. camelcase-matching/sol.swift new file mode 100644 index 00000000..8af972ca --- /dev/null +++ b/tests/1001-1500/1023. camelcase-matching/sol.swift @@ -0,0 +1,25 @@ +class Solution { + func camelMatch(_ queries: [String], _ pattern: String) -> [Bool] { + var ans: [Bool] = [] + for query in queries { + var j = 0 + var i = 0 + while i < query.count { + let idx = query.index(query.startIndex, offsetBy: i) + if query[idx].isUppercase && ((j < pattern.count && query[idx] != pattern[pattern.index(pattern.startIndex, offsetBy: j)]) || j > pattern.count - 1) { + break + } + if j < pattern.count && query[idx] == pattern[pattern.index(pattern.startIndex, offsetBy: j)] { + j += 1 + } + i += 1 + } + if i == query.count && j == pattern.count { + ans.append(true) + } else { + ans.append(false) + } + } + return ans + } +} diff --git a/tests/1001-1500/1023. camelcase-matching/sol.ts b/tests/1001-1500/1023. camelcase-matching/sol.ts new file mode 100644 index 00000000..9038955d --- /dev/null +++ b/tests/1001-1500/1023. camelcase-matching/sol.ts @@ -0,0 +1,27 @@ +function camelMatch(queries: string[], pattern: string): boolean[] { + const ans: boolean[] = []; + for (const query of queries) { + let j = 0; + let i = 0; + while (i < query.length) { + if ( + query[i] === query[i].toUpperCase() && + query[i] !== query[i].toLowerCase() && + ((j < pattern.length && query[i] !== pattern[j]) || + j > pattern.length - 1) + ) { + break; + } + if (j < pattern.length && query[i] === pattern[j]) { + j++; + } + i++; + } + if (i === query.length && j === pattern.length) { + ans.push(true); + } else { + ans.push(false); + } + } + return ans; +} diff --git a/tests/1001-1500/1024. video-stitching/manifest.yaml b/tests/1001-1500/1024. video-stitching/manifest.yaml new file mode 100644 index 00000000..618a07c0 --- /dev/null +++ b/tests/1001-1500/1024. video-stitching/manifest.yaml @@ -0,0 +1,626 @@ +entry: + id: 1024 + title: video-stitching + params: + clips: + type: array + items: + type: array + items: + type: int + time: + type: int + call: + cpp: Solution().videoStitching({clips}, {time}) + rust: Solution::video_stitching({clips}, {time}) + python3: Solution().videoStitching({clips}, {time}) + python2: Solution().videoStitching({clips}, {time}) + ruby: video_stitching({clips}, {time}) + java: new Solution().videoStitching({clips}, {time}) + csharp: new Solution().VideoStitching({clips}, {time}) + kotlin: Solution().videoStitching({clips}, {time}) + go: videoStitching({clips}, {time}) + dart: Solution().videoStitching({clips}, {time}) + swift: Solution().videoStitching({clips}, {time}) + typescript: videoStitching({clips}, {time}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +seed: 1024 +tests: + - name: ex1 + in: + clips: + elemType: int + value: + - - 0 + - 2 + - - 4 + - 6 + - - 8 + - 10 + - - 1 + - 9 + - - 1 + - 5 + - - 5 + - 9 + time: 10 + out: 3 + - name: ex2 + in: + clips: + elemType: int + value: + - - 0 + - 1 + - - 1 + - 2 + time: 5 + out: -1 + - name: ex3 + in: + clips: + elemType: int + value: + - - 0 + - 1 + - - 6 + - 8 + - - 0 + - 2 + - - 5 + - 6 + - - 0 + - 4 + - - 0 + - 3 + - - 6 + - 7 + - - 1 + - 3 + - - 4 + - 7 + - - 1 + - 4 + - - 2 + - 5 + - - 2 + - 6 + - - 3 + - 4 + - - 4 + - 5 + - - 5 + - 7 + - - 6 + - 9 + time: 9 + out: 3 + - name: single_clip_exact + in: + clips: + elemType: int + value: + - - 0 + - 1 + time: 1 + out: 1 + - name: single_clip_short + in: + clips: + elemType: int + value: + - - 0 + - 1 + time: 2 + out: -1 + - name: gap_impossible_1 + in: + clips: + elemType: int + value: + - - 0 + - 2 + - - 3 + - 4 + time: 4 + out: -1 + - name: gap_impossible_2 + in: + clips: + elemType: int + value: + - - 1 + - 2 + - - 2 + - 3 + time: 3 + out: -1 + - name: direct_cover_1 + in: + clips: + elemType: int + value: + - - 0 + - 5 + time: 5 + out: 1 + - name: direct_cover_2 + in: + clips: + elemType: int + value: + - - 0 + - 10 + - - 1 + - 2 + time: 10 + out: 1 + - name: chain_1 + in: + clips: + elemType: int + value: + - - 0 + - 2 + - - 2 + - 4 + - - 4 + - 6 + time: 6 + out: 3 + - name: chain_2 + in: + clips: + elemType: int + value: + - - 0 + - 1 + - - 0 + - 2 + - - 1 + - 3 + - - 2 + - 5 + time: 5 + out: 2 + - name: chain_3 + in: + clips: + elemType: int + value: + - - 0 + - 4 + - - 2 + - 8 + - - 4 + - 7 + - - 7 + - 10 + time: 10 + out: 3 + - name: overlap_1 + in: + clips: + elemType: int + value: + - - 0 + - 3 + - - 1 + - 5 + - - 4 + - 8 + - - 7 + - 10 + time: 10 + out: 4 + - name: overlap_2 + in: + clips: + elemType: int + value: + - - 0 + - 2 + - - 1 + - 4 + - - 3 + - 6 + - - 5 + - 9 + time: 9 + out: 4 + - name: overlap_3 + in: + clips: + elemType: int + value: + - - 0 + - 1 + - - 0 + - 4 + - - 2 + - 6 + - - 4 + - 9 + - - 8 + - 10 + time: 10 + out: 3 + - name: overlap_4 + in: + clips: + elemType: int + value: + - - 0 + - 2 + - - 1 + - 7 + - - 2 + - 4 + - - 4 + - 5 + - - 5 + - 10 + time: 10 + out: 3 + - name: overlap_5 + in: + clips: + elemType: int + value: + - - 0 + - 3 + - - 3 + - 4 + - - 4 + - 7 + - - 7 + - 9 + time: 9 + out: 4 + - name: overlap_6 + in: + clips: + elemType: int + value: + - - 0 + - 6 + - - 1 + - 2 + - - 2 + - 3 + - - 3 + - 4 + - - 4 + - 7 + time: 7 + out: 2 + - name: overlap_7 + in: + clips: + elemType: int + value: + - - 0 + - 2 + - - 2 + - 3 + - - 3 + - 5 + - - 5 + - 7 + - - 7 + - 9 + time: 9 + out: 5 + - name: overlap_8 + in: + clips: + elemType: int + value: + - - 0 + - 1 + - - 1 + - 4 + - - 0 + - 5 + - - 4 + - 6 + time: 6 + out: 2 + - name: overlap_9 + in: + clips: + elemType: int + value: + - - 0 + - 3 + - - 2 + - 5 + - - 4 + - 8 + - - 6 + - 10 + time: 10 + out: 4 + - name: overlap_10 + in: + clips: + elemType: int + value: + - - 0 + - 4 + - - 0 + - 1 + - - 1 + - 2 + - - 2 + - 3 + - - 3 + - 5 + time: 5 + out: 2 + - name: overlap_11 + in: + clips: + elemType: int + value: + - - 0 + - 2 + - - 2 + - 6 + - - 6 + - 8 + - - 8 + - 10 + - - 1 + - 9 + time: 10 + out: 3 + - name: overlap_12 + in: + clips: + elemType: int + value: + - - 0 + - 5 + - - 0 + - 6 + - - 5 + - 10 + - - 6 + - 10 + time: 10 + out: 2 + - name: overlap_13 + in: + clips: + elemType: int + value: + - - 0 + - 1 + - - 1 + - 5 + - - 2 + - 6 + - - 5 + - 9 + time: 9 + out: 3 + - name: overlap_14 + in: + clips: + elemType: int + value: + - - 0 + - 3 + - - 3 + - 6 + - - 1 + - 4 + - - 4 + - 9 + time: 9 + out: 3 + - name: overlap_15 + in: + clips: + elemType: int + value: + - - 0 + - 2 + - - 0 + - 3 + - - 2 + - 4 + - - 4 + - 7 + - - 6 + - 9 + time: 9 + out: 4 + - name: overlap_16 + in: + clips: + elemType: int + value: + - - 0 + - 1 + - - 0 + - 2 + - - 1 + - 3 + - - 3 + - 7 + - - 7 + - 10 + time: 10 + out: 4 + - name: overlap_17 + in: + clips: + elemType: int + value: + - - 0 + - 4 + - - 2 + - 5 + - - 4 + - 9 + - - 8 + - 10 + time: 10 + out: 3 + - name: overlap_18 + in: + clips: + elemType: int + value: + - - 0 + - 2 + - - 1 + - 6 + - - 6 + - 8 + - - 8 + - 9 + time: 9 + out: 4 + - name: overlap_19 + in: + clips: + elemType: int + value: + - - 0 + - 5 + - - 4 + - 7 + - - 6 + - 10 + time: 10 + out: 3 + - name: overlap_20 + in: + clips: + elemType: int + value: + - - 0 + - 2 + - - 2 + - 5 + - - 5 + - 8 + - - 8 + - 10 + time: 10 + out: 4 + - name: overlap_21 + in: + clips: + elemType: int + value: + - - 0 + - 3 + - - 1 + - 8 + - - 8 + - 10 + time: 10 + out: 3 + - name: overlap_22 + in: + clips: + elemType: int + value: + - - 0 + - 1 + - - 1 + - 4 + - - 4 + - 6 + - - 6 + - 10 + time: 10 + out: 4 + - name: overlap_23 + in: + clips: + elemType: int + value: + - - 0 + - 6 + - - 5 + - 10 + time: 10 + out: 2 + - name: overlap_24 + in: + clips: + elemType: int + value: + - - 0 + - 7 + - - 6 + - 10 + time: 10 + out: 2 + - name: overlap_25 + in: + clips: + elemType: int + value: + - - 0 + - 8 + - - 7 + - 10 + time: 10 + out: 2 + - name: overlap_26 + in: + clips: + elemType: int + value: + - - 0 + - 9 + - - 9 + - 10 + time: 10 + out: 2 + - name: overlap_27 + in: + clips: + elemType: int + value: + - - 0 + - 4 + - - 1 + - 2 + - - 2 + - 3 + - - 3 + - 7 + - - 7 + - 9 + time: 9 + out: 3 + - name: overlap_28 + in: + clips: + elemType: int + value: + - - 0 + - 2 + - - 0 + - 5 + - - 5 + - 7 + - - 7 + - 10 + time: 10 + out: 3 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" diff --git a/tests/1001-1500/1024. video-stitching/sol.cpp b/tests/1001-1500/1024. video-stitching/sol.cpp new file mode 100644 index 00000000..81e9df5c --- /dev/null +++ b/tests/1001-1500/1024. video-stitching/sol.cpp @@ -0,0 +1,25 @@ +class Solution { +public: + int videoStitching(vector>& clips, int time) { + sort(clips.begin(), clips.end(), [](const vector& a, const vector& b) { + return a[0] < b[0]; + }); + int end = 0; + int farthest = 0; + int res = 0; + int i = 0; + while (farthest < time) { + int prevFarthest = farthest; + while (i < clips.size() && clips[i][0] <= end) { + farthest = max(farthest, clips[i][1]); + i++; + } + if (farthest == prevFarthest) { + return -1; + } + end = farthest; + res++; + } + return res; + } +}; diff --git a/tests/1001-1500/1024. video-stitching/sol.cs b/tests/1001-1500/1024. video-stitching/sol.cs new file mode 100644 index 00000000..587111cb --- /dev/null +++ b/tests/1001-1500/1024. video-stitching/sol.cs @@ -0,0 +1,22 @@ +public class Solution { + public int VideoStitching(int[][] clips, int time) { + Array.Sort(clips, (a, b) => a[0].CompareTo(b[0])); + int end = 0; + int farthest = 0; + int res = 0; + int i = 0; + while (farthest < time) { + int prevFarthest = farthest; + while (i < clips.Length && clips[i][0] <= end) { + farthest = Math.Max(farthest, clips[i][1]); + i++; + } + if (farthest == prevFarthest) { + return -1; + } + end = farthest; + res++; + } + return res; + } +} diff --git a/tests/1001-1500/1024. video-stitching/sol.dart b/tests/1001-1500/1024. video-stitching/sol.dart new file mode 100644 index 00000000..57e89b4d --- /dev/null +++ b/tests/1001-1500/1024. video-stitching/sol.dart @@ -0,0 +1,22 @@ +class Solution { + int videoStitching(List> clips, int time) { + clips.sort((a, b) => a[0].compareTo(b[0])); + int end = 0; + int farthest = 0; + int res = 0; + int i = 0; + while (farthest < time) { + int prevFarthest = farthest; + while (i < clips.length && clips[i][0] <= end) { + farthest = farthest > clips[i][1] ? farthest : clips[i][1]; + i++; + } + if (farthest == prevFarthest) { + return -1; + } + end = farthest; + res++; + } + return res; + } +} diff --git a/tests/1001-1500/1024. video-stitching/sol.go b/tests/1001-1500/1024. video-stitching/sol.go new file mode 100644 index 00000000..d8130042 --- /dev/null +++ b/tests/1001-1500/1024. video-stitching/sol.go @@ -0,0 +1,24 @@ +func videoStitching(clips [][]int, time int) int { + sort.Slice(clips, func(i, j int) bool { + return clips[i][0] < clips[j][0] + }) + end := 0 + farthest := 0 + res := 0 + i := 0 + for farthest < time { + prevFarthest := farthest + for i < len(clips) && clips[i][0] <= end { + if clips[i][1] > farthest { + farthest = clips[i][1] + } + i++ + } + if farthest == prevFarthest { + return -1 + } + end = farthest + res++ + } + return res +} diff --git a/tests/1001-1500/1024. video-stitching/sol.java b/tests/1001-1500/1024. video-stitching/sol.java new file mode 100644 index 00000000..c8ac8221 --- /dev/null +++ b/tests/1001-1500/1024. video-stitching/sol.java @@ -0,0 +1,22 @@ +class Solution { + public int videoStitching(int[][] clips, int time) { + java.util.Arrays.sort(clips, (a, b) -> Integer.compare(a[0], b[0])); + int end = 0; + int farthest = 0; + int res = 0; + int i = 0; + while (farthest < time) { + int prevFarthest = farthest; + while (i < clips.length && clips[i][0] <= end) { + farthest = Math.max(farthest, clips[i][1]); + i++; + } + if (farthest == prevFarthest) { + return -1; + } + end = farthest; + res++; + } + return res; + } +} diff --git a/tests/1001-1500/1024. video-stitching/sol.kt b/tests/1001-1500/1024. video-stitching/sol.kt new file mode 100644 index 00000000..5449632e --- /dev/null +++ b/tests/1001-1500/1024. video-stitching/sol.kt @@ -0,0 +1,22 @@ +class Solution { + fun videoStitching(clips: Array, time: Int): Int { + clips.sortBy { it[0] } + var end = 0 + var farthest = 0 + var res = 0 + var i = 0 + while (farthest < time) { + val prevFarthest = farthest + while (i < clips.size && clips[i][0] <= end) { + farthest = maxOf(farthest, clips[i][1]) + i++ + } + if (farthest == prevFarthest) { + return -1 + } + end = farthest + res++ + } + return res + } +} diff --git a/tests/1001-1500/1024. video-stitching/sol.py b/tests/1001-1500/1024. video-stitching/sol.py new file mode 100644 index 00000000..06b38ef8 --- /dev/null +++ b/tests/1001-1500/1024. video-stitching/sol.py @@ -0,0 +1,17 @@ +class Solution: + def videoStitching(self, clips: List[List[int]], time: int) -> int: + clips.sort(key=lambda x: x[0]) + end = 0 + farthest = 0 + res = 0 + i = 0 + while farthest < time: + prev_farthest = farthest + while i < len(clips) and clips[i][0] <= end: + farthest = max(farthest, clips[i][1]) + i += 1 + if farthest == prev_farthest: + return -1 + end = farthest + res += 1 + return res diff --git a/tests/1001-1500/1024. video-stitching/sol.py2 b/tests/1001-1500/1024. video-stitching/sol.py2 new file mode 100644 index 00000000..3af724fe --- /dev/null +++ b/tests/1001-1500/1024. video-stitching/sol.py2 @@ -0,0 +1,22 @@ +class Solution(object): + def videoStitching(self, clips, time): + """ + :type clips: List[List[int]] + :type time: int + :rtype: int + """ + clips.sort(key=lambda x: x[0]) + end = 0 + farthest = 0 + res = 0 + i = 0 + while farthest < time: + prev_farthest = farthest + while i < len(clips) and clips[i][0] <= end: + farthest = max(farthest, clips[i][1]) + i += 1 + if farthest == prev_farthest: + return -1 + end = farthest + res += 1 + return res diff --git a/tests/1001-1500/1024. video-stitching/sol.rb b/tests/1001-1500/1024. video-stitching/sol.rb new file mode 100644 index 00000000..dcd1ae42 --- /dev/null +++ b/tests/1001-1500/1024. video-stitching/sol.rb @@ -0,0 +1,23 @@ +# @param {Integer[][]} clips +# @param {Integer} time +# @return {Integer} +def video_stitching(clips, time) + clips.sort_by! { |c| c[0] } + end_val = 0 + farthest = 0 + res = 0 + i = 0 + while farthest < time + prev_farthest = farthest + while i < clips.length && clips[i][0] <= end_val + farthest = [farthest, clips[i][1]].max + i += 1 + end + if farthest == prev_farthest + return -1 + end + end_val = farthest + res += 1 + end + res +end diff --git a/tests/1001-1500/1024. video-stitching/sol.rs b/tests/1001-1500/1024. video-stitching/sol.rs new file mode 100644 index 00000000..dab882b5 --- /dev/null +++ b/tests/1001-1500/1024. video-stitching/sol.rs @@ -0,0 +1,23 @@ +impl Solution { + pub fn video_stitching(clips: Vec>, time: i32) -> i32 { + let mut clips = clips; + clips.sort_by(|a, b| a[0].cmp(&b[0])); + let mut end = 0; + let mut farthest = 0; + let mut res = 0; + let mut i = 0; + while farthest < time { + let prev_farthest = farthest; + while i < clips.len() && clips[i][0] <= end { + farthest = farthest.max(clips[i][1]); + i += 1; + } + if farthest == prev_farthest { + return -1; + } + end = farthest; + res += 1; + } + res + } +} diff --git a/tests/1001-1500/1024. video-stitching/sol.swift b/tests/1001-1500/1024. video-stitching/sol.swift new file mode 100644 index 00000000..a9adcdbf --- /dev/null +++ b/tests/1001-1500/1024. video-stitching/sol.swift @@ -0,0 +1,22 @@ +class Solution { + func videoStitching(_ clips: [[Int]], _ time: Int) -> Int { + let sortedClips = clips.sorted { $0[0] < $1[0] } + var end = 0 + var farthest = 0 + var res = 0 + var i = 0 + while farthest < time { + let prevFarthest = farthest + while i < sortedClips.count && sortedClips[i][0] <= end { + farthest = max(farthest, sortedClips[i][1]) + i += 1 + } + if farthest == prevFarthest { + return -1 + } + end = farthest + res += 1 + } + return res + } +} diff --git a/tests/1001-1500/1024. video-stitching/sol.ts b/tests/1001-1500/1024. video-stitching/sol.ts new file mode 100644 index 00000000..26505678 --- /dev/null +++ b/tests/1001-1500/1024. video-stitching/sol.ts @@ -0,0 +1,20 @@ +function videoStitching(clips: number[][], time: number): number { + clips.sort((a, b) => a[0] - b[0]); + let end = 0; + let farthest = 0; + let res = 0; + let i = 0; + while (farthest < time) { + const prevFarthest = farthest; + while (i < clips.length && clips[i][0] <= end) { + farthest = Math.max(farthest, clips[i][1]); + i++; + } + if (farthest === prevFarthest) { + return -1; + } + end = farthest; + res++; + } + return res; +} diff --git a/tests/1001-1500/1025. divisor-game/manifest.yaml b/tests/1001-1500/1025. divisor-game/manifest.yaml new file mode 100644 index 00000000..03dcd3c4 --- /dev/null +++ b/tests/1001-1500/1025. divisor-game/manifest.yaml @@ -0,0 +1,178 @@ +entry: + id: 1025 + title: "divisor-game" + params: + N: + type: int + call: + cpp: "Solution().divisorGame({N})" + rust: "Solution::divisor_game({N})" + python3: "Solution().divisorGame({N})" + python2: "Solution().divisorGame({N})" + ruby: "divisor_game({N})" + java: "new Solution().divisorGame({N})" + csharp: "new Solution().DivisorGame({N})" + kotlin: "Solution().divisorGame({N})" + go: "divisorGame({N})" + dart: "Solution().divisorGame({N})" + swift: "Solution().divisorGame({N})" + typescript: "divisorGame({N})" + +judge: + type: "exact" + +limits: + time_ms: 200 + memory_mb: 300 + +oracle: + python3: + call: "Checker().divisorGame(N, {result})" + checker: | + class Checker: + def divisorGame(self, N, result): + return result == (N % 2 == 0) + +seed: 1025 + +tests: + - name: "n_1" + in: + N: 1 + out: false + - name: "n_2" + in: + N: 2 + out: true + - name: "n_3" + in: + N: 3 + out: false + - name: "n_4" + in: + N: 4 + out: true + - name: "n_5" + in: + N: 5 + out: false + - name: "n_6" + in: + N: 6 + out: true + - name: "n_7" + in: + N: 7 + out: false + - name: "n_8" + in: + N: 8 + out: true + - name: "n_9" + in: + N: 9 + out: false + - name: "n_10" + in: + N: 10 + out: true + - name: "n_11" + in: + N: 11 + out: false + - name: "n_12" + in: + N: 12 + out: true + - name: "n_13" + in: + N: 13 + out: false + - name: "n_14" + in: + N: 14 + out: true + - name: "n_15" + in: + N: 15 + out: false + - name: "n_16" + in: + N: 16 + out: true + - name: "n_17" + in: + N: 17 + out: false + - name: "n_18" + in: + N: 18 + out: true + - name: "n_19" + in: + N: 19 + out: false + - name: "n_20" + in: + N: 20 + out: true + - name: "n_21" + in: + N: 21 + out: false + - name: "n_22" + in: + N: 22 + out: true + - name: "n_23" + in: + N: 23 + out: false + - name: "n_24" + in: + N: 24 + out: true + - name: "n_25" + in: + N: 25 + out: false + - name: "n_26" + in: + N: 26 + out: true + - name: "n_27" + in: + N: 27 + out: false + - name: "n_28" + in: + N: 28 + out: true + - name: "n_29" + in: + N: 29 + out: false + - name: "n_30" + in: + N: 30 + out: true + - name: "n_31" + in: + N: 31 + out: false + - name: "n_32" + in: + N: 32 + out: true + - name: "n_33" + in: + N: 33 + out: false + - name: "n_34" + in: + N: 34 + out: true + - name: "n_35" + in: + N: 35 + out: false diff --git a/tests/1001-1500/1025. divisor-game/sol.cpp b/tests/1001-1500/1025. divisor-game/sol.cpp new file mode 100644 index 00000000..6670591e --- /dev/null +++ b/tests/1001-1500/1025. divisor-game/sol.cpp @@ -0,0 +1,6 @@ +class Solution { +public: + bool divisorGame(int n) { + return n % 2 == 0; + } +}; diff --git a/tests/1001-1500/1025. divisor-game/sol.cs b/tests/1001-1500/1025. divisor-game/sol.cs new file mode 100644 index 00000000..c1a8b83e --- /dev/null +++ b/tests/1001-1500/1025. divisor-game/sol.cs @@ -0,0 +1,5 @@ +public class Solution { + public bool DivisorGame(int n) { + return n % 2 == 0; + } +} diff --git a/tests/1001-1500/1025. divisor-game/sol.dart b/tests/1001-1500/1025. divisor-game/sol.dart new file mode 100644 index 00000000..237b73f4 --- /dev/null +++ b/tests/1001-1500/1025. divisor-game/sol.dart @@ -0,0 +1,5 @@ +class Solution { + bool divisorGame(int n) { + return n % 2 == 0; + } +} diff --git a/tests/1001-1500/1025. divisor-game/sol.go b/tests/1001-1500/1025. divisor-game/sol.go new file mode 100644 index 00000000..c61b622b --- /dev/null +++ b/tests/1001-1500/1025. divisor-game/sol.go @@ -0,0 +1,3 @@ +func divisorGame(n int) bool { + return n % 2 == 0 +} diff --git a/tests/1001-1500/1025. divisor-game/sol.java b/tests/1001-1500/1025. divisor-game/sol.java new file mode 100644 index 00000000..ef5f024b --- /dev/null +++ b/tests/1001-1500/1025. divisor-game/sol.java @@ -0,0 +1,5 @@ +class Solution { + public boolean divisorGame(int n) { + return n % 2 == 0; + } +} diff --git a/tests/1001-1500/1025. divisor-game/sol.kt b/tests/1001-1500/1025. divisor-game/sol.kt new file mode 100644 index 00000000..df399a04 --- /dev/null +++ b/tests/1001-1500/1025. divisor-game/sol.kt @@ -0,0 +1,5 @@ +class Solution { + fun divisorGame(n: Int): Boolean { + return n % 2 == 0 + } +} diff --git a/tests/1001-1500/1025. divisor-game/sol.py b/tests/1001-1500/1025. divisor-game/sol.py new file mode 100644 index 00000000..e9a35433 --- /dev/null +++ b/tests/1001-1500/1025. divisor-game/sol.py @@ -0,0 +1,3 @@ +class Solution: + def divisorGame(self, n: int) -> bool: + return n % 2 == 0 diff --git a/tests/1001-1500/1025. divisor-game/sol.py2 b/tests/1001-1500/1025. divisor-game/sol.py2 new file mode 100644 index 00000000..3f47d02f --- /dev/null +++ b/tests/1001-1500/1025. divisor-game/sol.py2 @@ -0,0 +1,7 @@ +class Solution(object): + def divisorGame(self, n): + """ + :type n: int + :rtype: bool + """ + return n % 2 == 0 diff --git a/tests/1001-1500/1025. divisor-game/sol.rb b/tests/1001-1500/1025. divisor-game/sol.rb new file mode 100644 index 00000000..4988ee79 --- /dev/null +++ b/tests/1001-1500/1025. divisor-game/sol.rb @@ -0,0 +1,5 @@ +# @param {Integer} n +# @return {Boolean} +def divisor_game(n) + n % 2 == 0 +end diff --git a/tests/1001-1500/1025. divisor-game/sol.rs b/tests/1001-1500/1025. divisor-game/sol.rs new file mode 100644 index 00000000..dd470653 --- /dev/null +++ b/tests/1001-1500/1025. divisor-game/sol.rs @@ -0,0 +1,5 @@ +impl Solution { + pub fn divisor_game(n: i32) -> bool { + n % 2 == 0 + } +} diff --git a/tests/1001-1500/1025. divisor-game/sol.swift b/tests/1001-1500/1025. divisor-game/sol.swift new file mode 100644 index 00000000..4f3334cb --- /dev/null +++ b/tests/1001-1500/1025. divisor-game/sol.swift @@ -0,0 +1,5 @@ +class Solution { + func divisorGame(_ n: Int) -> Bool { + return n % 2 == 0 + } +} diff --git a/tests/1001-1500/1025. divisor-game/sol.ts b/tests/1001-1500/1025. divisor-game/sol.ts new file mode 100644 index 00000000..b7cd6889 --- /dev/null +++ b/tests/1001-1500/1025. divisor-game/sol.ts @@ -0,0 +1,3 @@ +function divisorGame(n: number): boolean { + return n % 2 === 0; +} diff --git a/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/manifest.yaml b/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/manifest.yaml new file mode 100644 index 00000000..ae1ab32c --- /dev/null +++ b/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/manifest.yaml @@ -0,0 +1,194 @@ +entry: + id: 1026 + title: "maximum-difference-between-node-and-ancestor" + params: + root: + type: tree_node + call: + cpp: "Solution().maxAncestorDiff({root})" + rust: "Solution::max_ancestor_diff({root})" + python3: "Solution().maxAncestorDiff({root})" + python2: "Solution().maxAncestorDiff({root})" + ruby: "max_ancestor_diff({root})" + java: "new Solution().maxAncestorDiff({root})" + csharp: "new Solution().MaxAncestorDiff({root})" + kotlin: "Solution().maxAncestorDiff({root})" + go: "maxAncestorDiff({root})" + dart: "Solution().maxAncestorDiff({root})" + swift: "Solution().maxAncestorDiff({root})" + typescript: "maxAncestorDiff({root})" + +judge: + type: "exact" + +limits: + time_ms: 200 + memory_mb: 300 + +oracle: + python3: + call: "Checker().maxAncestorDiff(root, {result})" + checker: | + class Checker: + def maxAncestorDiff(self, root, result): + best = 0 + def dfs(node, mn, mx): + nonlocal best + if not node: + return + mn = min(mn, node.val) + mx = max(mx, node.val) + best = max(best, mx - mn) + dfs(node.left, mn, mx) + dfs(node.right, mn, mx) + if root: + dfs(root, root.val, root.val) + return result == best + +seed: 1026 + +tests: + - name: "single_node" + in: + root: [5] + out: 0 + - name: "two_level_left" + in: + root: [8, 3] + out: 5 + - name: "two_level_right" + in: + root: [8, null, 10] + out: 2 + - name: "sample_1" + in: + root: [8, 3, 10, 1, 6, null, 14, null, null, 4, 7, 13] + out: 7 + - name: "sample_2" + in: + root: [1, null, 2, null, 0, 3] + out: 3 + - name: "balanced_small" + in: + root: [4, 2, 6, 1, 3, 5, 7] + out: 3 + - name: "left_chain_1" + in: + root: [10, 7, null, 4] + out: 6 + - name: "left_chain_2" + in: + root: [10, 1, null, 0] + out: 10 + - name: "right_chain_1" + in: + root: [1, null, 4, null, 9] + out: 8 + - name: "right_chain_2" + in: + root: [50, null, 49, null, 48, null, 47] + out: 3 + - name: "zigzag_1" + in: + root: [6, 2, 8, null, 4, 7, 9, null, null, 3, 5] + out: 5 + - name: "zigzag_2" + in: + root: [15, 5, 20, 3, 7, 18, 25, 1, 4, 6, 8] + out: 14 + - name: "all_equal_1" + in: + root: [7, 7, 7, 7, 7, 7, 7] + out: 0 + - name: "small_gap" + in: + root: [2, 1, 3] + out: 1 + - name: "root_min" + in: + root: [1, 0, 2] + out: 1 + - name: "root_max" + in: + root: [100, 1, 99, null, null, 0] + out: 100 + - name: "deep_left" + in: + root: [5, 4, null, 3, null, 2, null, 1] + out: 4 + - name: "deep_right" + in: + root: [5, null, 6, null, 7, null, 8] + out: 3 + - name: "mixed_1" + in: + root: [9, 4, 17, 3, 6, 10, 22, 2, null, 5, 7, null, 12, 20, 25] + out: 16 + - name: "mixed_2" + in: + root: [30, 10, 40, 5, 20, 35, 50, null, 7, 15, 25] + out: 25 + - name: "boundary_1" + in: + root: [0, -1, 1] + out: 1 + - name: "boundary_2" + in: + root: [8, 0, 9, -5, 3, 7, 10] + out: 13 + - name: "boundary_3" + in: + root: [14, 8, 20, 4, 12, 16, 25, 2, 6, 10, 13, 15, 18, 22, 27] + out: 13 + - name: "close_values_1" + in: + root: [11, 10, 12, 9, null, null, 13] + out: 2 + - name: "close_values_2" + in: + root: [100, 99, 101, 98, null, null, 102] + out: 2 + - name: "skew_with_jump" + in: + root: [50, 25, null, 12, 40, null, null, 11, 13, 35, 45] + out: 39 + - name: "small_complex_1" + in: + root: [7, 3, 11, 1, 5, 9, 13, null, 2, 4, 6, 8, 10, 12, 14] + out: 7 + - name: "small_complex_2" + in: + root: [18, 9, 27, 4, 13, 22, 30, 2, 6, 11, 15, 20, 24, 28, 32] + out: 16 + - name: "random_shape_1" + in: + root: [6, 2, 9, 1, 4, 8, 10, null, null, 3, 5] + out: 5 + - name: "random_shape_2" + in: + root: [12, 5, 18, 2, 7, 15, 20, 1, 3, 6, 8, 14, 16, 19, 21] + out: 11 + - name: "asymmetric_1" + in: + root: [9, 4, 15, null, 6, 12, 20, null, null, null, 7] + out: 11 + - name: "asymmetric_2" + in: + root: [3, 1, 5, 0, 2, 4, 6, null, null, null, null, null, null, null, 7] + out: 4 + - name: "max_difference_chain" + in: + root: [1, null, 100, null, 99, null, 98] + out: 99 + - name: "min_difference_chain" + in: + root: [100, 1, null, 0] + out: 100 + - name: "balanced_large_gap" + in: + root: [20, 10, 30, 5, 15, 25, 40, 1, 7, 12, 18, 22, 27, 35, 50] + out: 30 + - name: "balanced_tight" + in: + root: [50, 49, 51, 48, 50, 50, 52] + out: 2 diff --git a/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.cpp b/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.cpp new file mode 100644 index 00000000..9304bcea --- /dev/null +++ b/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.cpp @@ -0,0 +1,32 @@ +/** + * Definition for a binary tree node. + * struct TreeNode { + * int val; + * TreeNode *left; + * TreeNode *right; + * TreeNode() : val(0), left(nullptr), right(nullptr) {} + * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} + * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} + * }; + */ +class Solution { +public: + int maxAncestorDiff(TreeNode* root) { + vector m = {0}; + dfs(root, m); + return m[0]; + } + +private: + pair dfs(TreeNode* root, vector& m) { + if (!root) { + return {INT_MAX, INT_MIN}; + } + auto left = dfs(root->left, m); + auto right = dfs(root->right, m); + int minVal = min(root->val, min(left.first, right.first)); + int maxVal = max(root->val, max(left.second, right.second)); + m[0] = max(m[0], max(abs(minVal - root->val), abs(maxVal - root->val))); + return {minVal, maxVal}; + } +}; diff --git a/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.cs b/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.cs new file mode 100644 index 00000000..7187b8ef --- /dev/null +++ b/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.cs @@ -0,0 +1,32 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public int val; + * public TreeNode left; + * public TreeNode right; + * public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +public class Solution { + public int MaxAncestorDiff(TreeNode root) { + int[] m = new int[] { 0 }; + Dfs(root, m); + return m[0]; + } + + private (int, int) Dfs(TreeNode root, int[] m) { + if (root == null) { + return (int.MaxValue, int.MinValue); + } + var left = Dfs(root.left, m); + var right = Dfs(root.right, m); + int minVal = Math.Min(root.val, Math.Min(left.Item1, right.Item1)); + int maxVal = Math.Max(root.val, Math.Max(left.Item2, right.Item2)); + m[0] = Math.Max(m[0], Math.Max(Math.Abs(minVal - root.val), Math.Abs(maxVal - root.val))); + return (minVal, maxVal); + } +} diff --git a/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.dart b/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.dart new file mode 100644 index 00000000..1312d4b9 --- /dev/null +++ b/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.dart @@ -0,0 +1,32 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * int val; + * TreeNode? left; + * TreeNode? right; + * TreeNode([this.val = 0, this.left, this.right]); + * } + */ +class Solution { + int maxAncestorDiff(TreeNode? root) { + if (root == null) { + return 0; + } + return dfs(root, root.val, root.val); + } + + int dfs(TreeNode? node, int mn, int mx) { + if (node == null) { + return mx - mn; + } + if (node.val < mn) { + mn = node.val; + } + if (node.val > mx) { + mx = node.val; + } + final left = dfs(node.left, mn, mx); + final right = dfs(node.right, mn, mx); + return left > right ? left : right; + } +} diff --git a/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.go b/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.go new file mode 100644 index 00000000..d63edd16 --- /dev/null +++ b/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.go @@ -0,0 +1,53 @@ +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +func maxAncestorDiff(root *TreeNode) int { + m := []int{0} + dfs(root, m) + return m[0] +} + +func dfs(root *TreeNode, m []int) (int, int) { + if root == nil { + return int(^uint(0) >> 1), -int(^uint(0) >> 1) - 1 + } + leftMin, leftMax := dfs(root.Left, m) + rightMin, rightMax := dfs(root.Right, m) + minVal := root.Val + if leftMin < minVal { + minVal = leftMin + } + if rightMin < minVal { + minVal = rightMin + } + maxVal := root.Val + if leftMax > maxVal { + maxVal = leftMax + } + if rightMax > maxVal { + maxVal = rightMax + } + diff1 := minVal - root.Val + if diff1 < 0 { + diff1 = -diff1 + } + diff2 := maxVal - root.Val + if diff2 < 0 { + diff2 = -diff2 + } + if diff1 > diff2 { + if diff1 > m[0] { + m[0] = diff1 + } + } else { + if diff2 > m[0] { + m[0] = diff2 + } + } + return minVal, maxVal +} diff --git a/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.java b/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.java new file mode 100644 index 00000000..6435875a --- /dev/null +++ b/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.java @@ -0,0 +1,34 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode() {} + * TreeNode(int val) { this.val = val; } + * TreeNode(int val, TreeNode left, TreeNode right) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +class Solution { + public int maxAncestorDiff(TreeNode root) { + int[] m = new int[]{0}; + dfs(root, m); + return m[0]; + } + + private int[] dfs(TreeNode root, int[] m) { + if (root == null) { + return new int[]{Integer.MAX_VALUE, Integer.MIN_VALUE}; + } + int[] left = dfs(root.left, m); + int[] right = dfs(root.right, m); + int minVal = Math.min(root.val, Math.min(left[0], right[0])); + int maxVal = Math.max(root.val, Math.max(left[1], right[1])); + m[0] = Math.max(m[0], Math.max(Math.abs(minVal - root.val), Math.abs(maxVal - root.val))); + return new int[]{minVal, maxVal}; + } +} diff --git a/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.kt b/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.kt new file mode 100644 index 00000000..665b55fc --- /dev/null +++ b/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.kt @@ -0,0 +1,29 @@ +/** + * Example: + * var ti = TreeNode(5) + * var v = ti.`val` + * Definition for a binary tree node. + * class TreeNode(var `val`: Int) { + * var left: TreeNode? = null + * var right: TreeNode? = null + * } + */ +class Solution { + fun maxAncestorDiff(root: TreeNode?): Int { + val m = intArrayOf(0) + dfs(root, m) + return m[0] + } + + private fun dfs(root: TreeNode?, m: IntArray): IntArray { + if (root == null) { + return intArrayOf(Int.MAX_VALUE, Int.MIN_VALUE) + } + val left = dfs(root.left, m) + val right = dfs(root.right, m) + val minVal = minOf(root.`val`, minOf(left[0], right[0])) + val maxVal = maxOf(root.`val`, maxOf(left[1], right[1])) + m[0] = maxOf(m[0], maxOf(Math.abs(minVal - root.`val`), Math.abs(maxVal - root.`val`))) + return intArrayOf(minVal, maxVal) + } +} diff --git a/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.py b/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.py new file mode 100644 index 00000000..723c8787 --- /dev/null +++ b/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.py @@ -0,0 +1,31 @@ +# Definition for a binary tree node. +# class TreeNode: +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class TreeNode: + def __init__(self, x): + self.val = x + self.left = self.right = None + + +class Solution: + def maxAncestorDiff(self, root): + m = [0] + self.dfs(root, m) + return m[0] + + def dfs(self, root, m): + if not root: + return float("inf"), float("-inf") + + left = self.dfs(root.left, m) + right = self.dfs(root.right, m) + + min_val = min(root.val, min(left[0], right[0])) + max_val = max(root.val, max(left[1], right[1])) + + m[0] = max(m[0], max(abs(min_val - root.val), abs(max_val - root.val))) + + return min_val, max_val diff --git a/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.py2 b/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.py2 new file mode 100644 index 00000000..3cf191cf --- /dev/null +++ b/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.py2 @@ -0,0 +1,25 @@ +# Definition for a binary tree node. +# class TreeNode(object): +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution(object): + def maxAncestorDiff(self, root): + """ + :type root: Optional[TreeNode] + :rtype: int + """ + m = [0] + self.dfs(root, m) + return m[0] + + def dfs(self, root, m): + if not root: + return float('inf'), float('-inf') + left = self.dfs(root.left, m) + right = self.dfs(root.right, m) + min_val = min(root.val, min(left[0], right[0])) + max_val = max(root.val, max(left[1], right[1])) + m[0] = max(m[0], max(abs(min_val - root.val), abs(max_val - root.val))) + return min_val, max_val diff --git a/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.rb b/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.rb new file mode 100644 index 00000000..d7f06b0c --- /dev/null +++ b/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.rb @@ -0,0 +1,26 @@ +# Definition for a binary tree node. +# class TreeNode +# attr_accessor :val, :left, :right +# def initialize(val = 0, left = nil, right = nil) +# @val = val +# @left = left +# @right = right +# end +# end +# @param {TreeNode} root +# @return {Integer} +def max_ancestor_diff(root) + m = [0] + dfs(root, m) + m[0] +end + +def dfs(root, m) + return [Float::INFINITY, -Float::INFINITY] if root.nil? + left = dfs(root.left, m) + right = dfs(root.right, m) + min_val = [root.val, left[0], right[0]].min + max_val = [root.val, left[1], right[1]].max + m[0] = [m[0], (min_val - root.val).abs, (max_val - root.val).abs].max + return [min_val, max_val] +end diff --git a/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.rs b/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.rs new file mode 100644 index 00000000..1be85e55 --- /dev/null +++ b/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.rs @@ -0,0 +1,40 @@ +// Definition for a binary tree node. +// #[derive(Debug, PartialEq, Eq)] +// pub struct TreeNode { +// pub val: i32, +// pub left: Option>>, +// pub right: Option>>, +// } +// +// impl TreeNode { +// #[inline] +// pub fn new(val: i32) -> Self { +// TreeNode { +// val, +// left: None, +// right: None +// } +// } +// } +impl Solution { + pub fn max_ancestor_diff(root: Option>>) -> i32 { + let mut m = vec![0]; + Self::dfs(&root, &mut m); + m[0] + } + + fn dfs(root: &Option>>, m: &mut Vec) -> (i32, i32) { + match root { + None => (i32::MAX, i32::MIN), + Some(node) => { + let node = node.borrow(); + let (left_min, left_max) = Self::dfs(&node.left, m); + let (right_min, right_max) = Self::dfs(&node.right, m); + let min_val = node.val.min(left_min).min(right_min); + let max_val = node.val.max(left_max).max(right_max); + m[0] = m[0].max((min_val - node.val).abs().max((max_val - node.val).abs())); + (min_val, max_val) + } + } + } +} diff --git a/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.swift b/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.swift new file mode 100644 index 00000000..89349534 --- /dev/null +++ b/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.swift @@ -0,0 +1,34 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public var val: Int + * public var left: TreeNode? + * public var right: TreeNode? + * public init() { self.val = 0; self.left = nil; self.right = nil; } + * public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; } + * public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) { + * self.val = val + * self.left = left + * self.right = right + * } + * } + */ +class Solution { + func maxAncestorDiff(_ root: TreeNode?) -> Int { + var m = [0] + dfs(root, &m) + return m[0] + } + + private func dfs(_ root: TreeNode?, _ m: inout [Int]) -> (Int, Int) { + guard let root = root else { + return (Int.max, Int.min) + } + let left = dfs(root.left, &m) + let right = dfs(root.right, &m) + let minVal = min(root.val, min(left.0, right.0)) + let maxVal = max(root.val, max(left.1, right.1)) + m[0] = max(m[0], max(abs(minVal - root.val), abs(maxVal - root.val))) + return (minVal, maxVal) + } +} diff --git a/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.ts b/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.ts new file mode 100644 index 00000000..426e4cbf --- /dev/null +++ b/tests/1001-1500/1026. maximum-difference-between-node-and-ancestor/sol.ts @@ -0,0 +1,34 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ + +function maxAncestorDiff(root: TreeNode | null): number { + const m: number[] = [0]; + dfs(root, m); + return m[0]; +} + +function dfs(root: TreeNode | null, m: number[]): [number, number] { + if (root === null) { + return [Infinity, -Infinity]; + } + const left = dfs(root.left, m); + const right = dfs(root.right, m); + const minVal = Math.min(root.val, Math.min(left[0], right[0])); + const maxVal = Math.max(root.val, Math.max(left[1], right[1])); + m[0] = Math.max( + m[0], + Math.max(Math.abs(minVal - root.val), Math.abs(maxVal - root.val)), + ); + return [minVal, maxVal]; +} diff --git a/tests/1001-1500/1027. longest-arithmetic-subsequence/manifest.yaml b/tests/1001-1500/1027. longest-arithmetic-subsequence/manifest.yaml new file mode 100644 index 00000000..7a171596 --- /dev/null +++ b/tests/1001-1500/1027. longest-arithmetic-subsequence/manifest.yaml @@ -0,0 +1,195 @@ +entry: + id: 1027 + title: "longest-arithmetic-subsequence" + params: + nums: + type: array + items: + type: int + call: + cpp: "Solution().longestArithSeqLength({nums})" + rust: "Solution::longest_arith_seq_length({nums})" + python3: "Solution().longestArithSeqLength({nums})" + python2: "Solution().longestArithSeqLength({nums})" + ruby: "longest_arith_seq_length({nums})" + java: "new Solution().longestArithSeqLength({nums})" + csharp: "new Solution().LongestArithSeqLength({nums})" + kotlin: "Solution().longestArithSeqLength({nums})" + go: "longestArithSeqLength({nums})" + dart: "Solution().longestArithSeqLength({nums})" + swift: "Solution().longestArithSeqLength({nums})" + typescript: "longestArithSeqLength({nums})" + +judge: + type: "exact" + +limits: + time_ms: 200 + memory_mb: 300 + +oracle: + python3: + call: "Checker().longestArithSeqLength(nums, {result})" + checker: | + class Checker: + def longestArithSeqLength(self, nums, result): + n = len(nums) + if n <= 2: + return result == n + dp = [{} for _ in range(n)] + best = 2 + for i in range(n): + for j in range(i): + d = nums[i] - nums[j] + dp[i][d] = dp[j].get(d, 1) + 1 + if dp[i][d] > best: + best = dp[i][d] + return result == best + +seed: 1027 + +tests: + - name: "len_1" + in: + nums: [7] + out: 1 + - name: "len_2" + in: + nums: [3, 9] + out: 2 + - name: "example_1" + in: + nums: [3, 6, 9, 12] + out: 4 + - name: "example_2" + in: + nums: [9, 4, 7, 2, 10] + out: 3 + - name: "example_3" + in: + nums: [20, 1, 15, 3, 10, 5, 8] + out: 4 + - name: "all_equal_1" + in: + nums: [5, 5, 5, 5] + out: 4 + - name: "all_equal_2" + in: + nums: [0, 0, 0, 0, 0, 0] + out: 6 + - name: "increasing_1" + in: + nums: [1, 2, 3, 4, 5, 6] + out: 6 + - name: "decreasing_1" + in: + nums: [10, 7, 4, 1, -2] + out: 5 + - name: "mixed_1" + in: + nums: [1, 7, 10, 15, 27, 29] + out: 3 + - name: "mixed_2" + in: + nums: [2, 4, 6, 8, 10, 3, 5, 7, 9] + out: 5 + - name: "mixed_3" + in: + nums: [9, 1, 3, 7, 5, 11, 13] + out: 3 + - name: "negatives_1" + in: + nums: [-5, -1, 3, 7, 11] + out: 5 + - name: "negatives_2" + in: + nums: [10, 4, -2, -8, -14] + out: 5 + - name: "duplicates_1" + in: + nums: [1, 1, 2, 3, 4, 4, 5] + out: 5 + - name: "duplicates_2" + in: + nums: [2, 2, 2, 3, 4, 5, 6] + out: 5 + - name: "short_gap" + in: + nums: [100, 90, 80, 70, 60, 50, 40] + out: 7 + - name: "random_1" + in: + nums: [1, 5, 9, 13, 2, 6, 10] + out: 4 + - name: "random_2" + in: + nums: [4, 8, 12, 16, 20, 24, 28, 1] + out: 7 + - name: "random_3" + in: + nums: [1, 3, 8, 5, 7, 9, 11, 13] + out: 7 + - name: "random_4" + in: + nums: [6, 2, 10, 14, 18, 22, 1, 5, 9] + out: 5 + - name: "random_5" + in: + nums: [7, 14, 21, 28, 35, 1, 8, 15] + out: 5 + - name: "random_6" + in: + nums: [12, 9, 6, 3, 0, -3, 4] + out: 6 + - name: "random_7" + in: + nums: [2, 5, 8, 11, 14, 17, 20] + out: 7 + - name: "random_8" + in: + nums: [30, 25, 20, 15, 10, 5, 0] + out: 7 + - name: "spaced_1" + in: + nums: [1, 10, 19, 28, 37, 46] + out: 6 + - name: "spaced_2" + in: + nums: [100, 80, 60, 40, 20, 0, -20] + out: 7 + - name: "spaced_3" + in: + nums: [5, 15, 25, 35, 45, 55, 65, 75] + out: 8 + - name: "spaced_4" + in: + nums: [11, 22, 33, 44, 55, 66] + out: 6 + - name: "small_mix_1" + in: + nums: [9, 12, 15, 18, 21, 7, 10] + out: 5 + - name: "small_mix_2" + in: + nums: [4, 1, 7, 10, 13, 16, 19] + out: 6 + - name: "small_mix_3" + in: + nums: [6, 9, 12, 15, 18, 2, 5] + out: 5 + - name: "small_mix_4" + in: + nums: [8, 16, 24, 32, 40, 3, 11] + out: 5 + - name: "small_mix_5" + in: + nums: [13, 17, 21, 25, 29, 33, 37] + out: 7 + - name: "small_mix_6" + in: + nums: [2, 6, 10, 14, 18, 22, 26, 30] + out: 8 + - name: "small_mix_7" + in: + nums: [1, 4, 9, 16, 25, 36] + out: 2 diff --git a/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.cpp b/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.cpp new file mode 100644 index 00000000..16a2edd5 --- /dev/null +++ b/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.cpp @@ -0,0 +1,18 @@ +class Solution { +public: + int longestArithSeqLength(vector& nums) { + int n = nums.size(); + if (n <= 2) return n; + vector> dp(n); + int ans = 2; + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + int d = nums[i] - nums[j]; + int prev = dp[j].count(d) ? dp[j][d] : 1; + dp[i][d] = max(dp[i][d], prev + 1); + ans = max(ans, dp[i][d]); + } + } + return ans; + } +}; diff --git a/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.cs b/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.cs new file mode 100644 index 00000000..3a5c3852 --- /dev/null +++ b/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.cs @@ -0,0 +1,25 @@ +public class Solution { + public int LongestArithSeqLength(int[] nums) { + int n = nums.Length; + if (n <= 2) { + return n; + } + Dictionary[] dp = new Dictionary[n]; + for (int i = 0; i < n; i++) { + dp[i] = new Dictionary(); + } + int ans = 2; + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + int d = nums[i] - nums[j]; + int prev = dp[j].ContainsKey(d) ? dp[j][d] : 1; + int current = prev + 1; + if (!dp[i].ContainsKey(d) || current > dp[i][d]) { + dp[i][d] = current; + } + ans = Math.Max(ans, dp[i][d]); + } + } + return ans; + } +} diff --git a/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.dart b/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.dart new file mode 100644 index 00000000..d8d5759f --- /dev/null +++ b/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.dart @@ -0,0 +1,24 @@ +class Solution { + int longestArithSeqLength(List nums) { + final n = nums.length; + if (n <= 2) { + return n; + } + final dp = List.generate(n, (_) => {}); + var ans = 2; + for (var i = 0; i < n; i++) { + for (var j = 0; j < i; j++) { + final d = nums[i] - nums[j]; + final prev = dp[j][d] ?? 1; + final current = prev + 1; + if ((dp[i][d] ?? 0) < current) { + dp[i][d] = current; + } + if (dp[i][d]! > ans) { + ans = dp[i][d]!; + } + } + } + return ans; + } +} diff --git a/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.go b/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.go new file mode 100644 index 00000000..619baf79 --- /dev/null +++ b/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.go @@ -0,0 +1,27 @@ +func longestArithSeqLength(nums []int) int { + n := len(nums) + if n <= 2 { + return n + } + dp := make([]map[int]int, n) + for i := 0; i < n; i++ { + dp[i] = make(map[int]int) + } + ans := 2 + for i := 0; i < n; i++ { + for j := 0; j < i; j++ { + d := nums[i] - nums[j] + prev := dp[j][d] + if prev == 0 { + prev = 1 + } + if prev+1 > dp[i][d] { + dp[i][d] = prev + 1 + } + if dp[i][d] > ans { + ans = dp[i][d] + } + } + } + return ans +} diff --git a/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.java b/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.java new file mode 100644 index 00000000..6f1001ae --- /dev/null +++ b/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.java @@ -0,0 +1,26 @@ +class Solution { + public int longestArithSeqLength(int[] nums) { + int n = nums.length; + if (n <= 2) { + return n; + } + List> dp = new ArrayList<>(n); + for (int i = 0; i < n; i++) { + dp.add(new HashMap<>()); + } + int ans = 2; + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + int d = nums[i] - nums[j]; + int prev = dp.get(j).getOrDefault(d, 1); + Map curr = dp.get(i); + int candidate = prev + 1; + if (candidate > curr.getOrDefault(d, 0)) { + curr.put(d, candidate); + } + ans = Math.max(ans, curr.get(d)); + } + } + return ans; + } +} diff --git a/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.kt b/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.kt new file mode 100644 index 00000000..8a2e22e8 --- /dev/null +++ b/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.kt @@ -0,0 +1,19 @@ +class Solution { + fun longestArithSeqLength(nums: IntArray): Int { + val n = nums.size + if (n <= 2) { + return n + } + val dp = Array(n) { HashMap() } + var ans = 2 + for (i in 0 until n) { + for (j in 0 until i) { + val d = nums[i] - nums[j] + val prev = dp[j].getOrDefault(d, 1) + dp[i][d] = maxOf(dp[i].getOrDefault(d, 0), prev + 1) + ans = maxOf(ans, dp[i][d]!!) + } + } + return ans + } +} diff --git a/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.py b/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.py new file mode 100644 index 00000000..64dbaddc --- /dev/null +++ b/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.py @@ -0,0 +1,17 @@ +from typing import List + + +class Solution: + def longestArithSeqLength(self, nums: List[int]) -> int: + n = len(nums) + if n <= 2: + return n + dp = [{} for _ in range(n)] + ans = 2 + for i in range(n): + for j in range(i): + d = nums[i] - nums[j] + prev = dp[j].get(d, 1) + dp[i][d] = max(dp[i].get(d, 0), prev + 1) + ans = max(ans, dp[i][d]) + return ans diff --git a/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.py2 b/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.py2 new file mode 100644 index 00000000..20f87a27 --- /dev/null +++ b/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.py2 @@ -0,0 +1,15 @@ +class Solution(object): + def longestArithSeqLength(self, nums): + n = len(nums) + if n <= 2: + return n + dp = [{} for _ in range(n)] + ans = 2 + for i in range(n): + for j in range(i): + d = nums[i] - nums[j] + prev = dp[j].get(d, 1) + dp[i][d] = max(dp[i].get(d, 0), prev + 1) + if dp[i][d] > ans: + ans = dp[i][d] + return ans diff --git a/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.rb b/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.rb new file mode 100644 index 00000000..d1a1db97 --- /dev/null +++ b/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.rb @@ -0,0 +1,18 @@ +# @param {Integer[]} nums +# @return {Integer} +def longest_arith_seq_length(nums) + n = nums.length + return n if n <= 2 + dp = Array.new(n) { Hash.new(0) } + ans = 2 + (0...n).each do |i| + (0...i).each do |j| + d = nums[i] - nums[j] + prev = dp[j][d] + prev = 1 if prev == 0 + dp[i][d] = [dp[i][d], prev + 1].max + ans = [ans, dp[i][d]].max + end + end + ans +end diff --git a/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.rs b/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.rs new file mode 100644 index 00000000..4d3b0f49 --- /dev/null +++ b/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.rs @@ -0,0 +1,25 @@ +impl Solution { + pub fn longest_arith_seq_length(nums: Vec) -> i32 { + let n = nums.len(); + if n <= 2 { + return n as i32; + } + let mut dp = vec![std::collections::HashMap::::new(); n]; + let mut ans = 2; + for i in 0..n { + for j in 0..i { + let d = nums[i] - nums[j]; + let prev = *dp[j].get(&d).unwrap_or(&1); + let current = prev + 1; + let entry = dp[i].entry(d).or_insert(0); + if current > *entry { + *entry = current; + } + if *entry > ans { + ans = *entry; + } + } + } + ans + } +} diff --git a/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.swift b/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.swift new file mode 100644 index 00000000..b2349953 --- /dev/null +++ b/tests/1001-1500/1027. longest-arithmetic-subsequence/sol.swift @@ -0,0 +1,19 @@ +class Solution { + func longestArithSeqLength(_ nums: [Int]) -> Int { + let n = nums.count + if n <= 2 { + return n + } + var dp = Array(repeating: [Int: Int](), count: n) + var ans = 2 + for i in 0..[] = Array.from( + { length: n }, + () => new Map(), + ); + let ans = 2; + for (let i = 0; i < n; i++) { + for (let j = 0; j < i; j++) { + const d = nums[i] - nums[j]; + const prev = dp[j].get(d) ?? 1; + const current = prev + 1; + dp[i].set(d, Math.max(dp[i].get(d) ?? 0, current)); + ans = Math.max(ans, dp[i].get(d)!); + } + } + return ans; +} diff --git a/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/manifest.yaml b/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/manifest.yaml new file mode 100644 index 00000000..85c5a14e --- /dev/null +++ b/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/manifest.yaml @@ -0,0 +1,160 @@ +entry: + id: 1028 + title: recover-a-tree-from-preorder-traversal + params: + traversal: + type: string + call: + cpp: treeNodeToArray(Solution().recoverFromPreorder({traversal})) + rust: TreeNode::tree_node_to_array(Solution::recover_from_preorder({traversal})) + python3: tree_node_to_array(Solution().recoverFromPreorder({traversal})) + python2: tree_node_to_array(Solution().recoverFromPreorder({traversal})) + ruby: tree_node_to_array(recover_from_preorder({traversal})) + java: TreeNode.treeNodeToArray(new Solution().recoverFromPreorder({traversal})) + csharp: TreeNode.TreeNodeToArray(new Solution().RecoverFromPreorder({traversal})) + kotlin: treeNodeToArray(Solution().recoverFromPreorder({traversal})) + go: treeNodeToArray(recoverFromPreorder({traversal})) + dart: tree_node_to_array(Solution().recoverFromPreorder({traversal})) + swift: tree_node_to_array(Solution().recoverFromPreorder({traversal})) + typescript: treeNodeToArray(recoverFromPreorder({traversal})) +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 300 +oracle: + python3: + call: Checker().recoverFromPreorder(traversal, {result}) + checker: | + class Checker: + def _build(self, values): + if not values: + return None + nodes = [None if v is None else TreeNode(v) for v in values] + kids = nodes[::-1] + root = kids.pop() + for node in nodes: + if node is not None: + if kids: + node.left = kids.pop() + if kids: + node.right = kids.pop() + return root + + def _serialize(self, node, depth=0): + if node is None: + return [] + return ["-" * depth + str(node.val)] + self._serialize(node.left, depth + 1) + self._serialize(node.right, depth + 1) + + def recoverFromPreorder(self, traversal, result): + if not isinstance(result, list): + return False + root = self._build(result) + return "".join(self._serialize(root)) == traversal +seed: 1028 +tests: + - name: single_node + in: + traversal: "1" + - name: left_child + in: + traversal: 1-2 + - name: right_child + in: + traversal: 1-2-3 + - name: example_1 + in: + traversal: 1-2--3--4-5--6--7 + - name: example_2 + in: + traversal: 1-2--3---4-5--6---7 + - name: example_3 + in: + traversal: 1-401--349---90--88 + - name: two_level_full + in: + traversal: 10-7--4--6-15--12--20 + - name: deep_left + in: + traversal: 1-2--3---4----5 + - name: deep_rightish + in: + traversal: 1-2--3-4--5---6 + - name: mixed_1 + in: + traversal: 8-3--1--6---4---7-10--9--14 + - name: mixed_2 + in: + traversal: 5-4--3---2----1-8--7---6 + - name: mixed_3 + in: + traversal: 7-2--1--3-9--8--10 + - name: mixed_4 + in: + traversal: 15-6--4---2----1--5-18--16---17--20 + - name: mixed_5 + in: + traversal: 100-50--25---12----6-150--125---110 + - name: balanced_1 + in: + traversal: 4-2--1--3-6--5--7 + - name: balanced_2 + in: + traversal: 12-6--3--9-18--15--21 + - name: unbalanced_1 + in: + traversal: 1-2--4---8----16-3 + - name: unbalanced_2 + in: + traversal: 30-20--10---5----2-25 + - name: small_1 + in: + traversal: 2-1-3 + - name: small_2 + in: + traversal: 2-1--0 + - name: small_3 + in: + traversal: 9-8--7---6 + - name: small_4 + in: + traversal: 9-10--11---12 + - name: small_5 + in: + traversal: 1-10--100---1000 + - name: small_6 + in: + traversal: 8-4--2--6-12--10--14 + - name: small_7 + in: + traversal: 3-1--0-2 + - name: small_8 + in: + traversal: 6-3--1--4-9--7--10 + - name: small_9 + in: + traversal: 50-40--30---20-60 + - name: small_10 + in: + traversal: 42-21--11--31-63--52--73 + - name: small_11 + in: + traversal: 7-3--2---1-5 + - name: small_12 + in: + traversal: 13-8--5--10-17--15--19 + - name: small_13 + in: + traversal: 5-2--1-4--3 + - name: small_14 + in: + traversal: 11-7--4---2-9 + - name: small_15 + in: + traversal: 24-12--6--18-36--30--42 + - name: small_16 + in: + traversal: 4-1--0-2--3 + - name: extra_balanced_4 + in: + traversal: 2-1--3-4--5 diff --git a/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.cpp b/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.cpp new file mode 100644 index 00000000..46e96ab0 --- /dev/null +++ b/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.cpp @@ -0,0 +1,44 @@ +/** + * Definition for a binary tree node. + * struct TreeNode { + * int val; + * TreeNode *left; + * TreeNode *right; + * TreeNode() : val(0), left(nullptr), right(nullptr) {} + * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} + * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} + * }; + */ +class Solution { +public: + TreeNode* recoverFromPreorder(string traversal) { + vector stack; + TreeNode* root = nullptr; + int i = 0, n = (int)traversal.size(); + while (i < n) { + int depth = 0; + while (i < n && traversal[i] == '-') { + depth++; + i++; + } + int num = 0; + while (i < n && isdigit(traversal[i])) { + num = num * 10 + (traversal[i] - '0'); + i++; + } + TreeNode* node = new TreeNode(num); + while ((int)stack.size() > depth) { + stack.pop_back(); + } + if (stack.empty()) { + root = node; + } else { + TreeNode* parent = stack.back(); + if (parent->left == nullptr) parent->left = node; + else parent->right = node; + } + stack.push_back(node); + } + return root; + } +}; diff --git a/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.cs b/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.cs new file mode 100644 index 00000000..49480e32 --- /dev/null +++ b/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.cs @@ -0,0 +1,48 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public int val; + * public TreeNode left; + * public TreeNode right; + * public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +public class Solution { + public TreeNode RecoverFromPreorder(string traversal) { + var stack = new System.Collections.Generic.List(); + TreeNode root = null; + int i = 0, n = traversal.Length; + while (i < n) { + int depth = 0; + while (i < n && traversal[i] == '-') { + depth++; + i++; + } + int val = 0; + while (i < n && char.IsDigit(traversal[i])) { + val = val * 10 + (traversal[i] - '0'); + i++; + } + TreeNode node = new TreeNode(val); + while (stack.Count > depth) { + stack.RemoveAt(stack.Count - 1); + } + if (stack.Count == 0) { + root = node; + } else { + TreeNode parent = stack[stack.Count - 1]; + if (parent.left == null) { + parent.left = node; + } else { + parent.right = node; + } + } + stack.Add(node); + } + return root; + } +} diff --git a/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.dart b/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.dart new file mode 100644 index 00000000..d0a2566a --- /dev/null +++ b/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.dart @@ -0,0 +1,48 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * int val; + * TreeNode? left; + * TreeNode? right; + * TreeNode([this.val = 0, this.left, this.right]); + * } + */ +class Solution { + TreeNode? recoverFromPreorder(String traversal) { + final stack = []; + TreeNode? root; + var i = 0; + while (i < traversal.length) { + var depth = 0; + while (i < traversal.length && traversal[i] == '-') { + depth++; + i++; + } + var num = 0; + while (i < traversal.length) { + final code = traversal.codeUnitAt(i); + if (code < 48 || code > 57) { + break; + } + num = num * 10 + (code - 48); + i++; + } + final node = TreeNode(num); + while (stack.length > depth) { + stack.removeLast(); + } + if (stack.isEmpty) { + root = node; + } else { + final parent = stack.last; + if (parent.left == null) { + parent.left = node; + } else { + parent.right = node; + } + } + stack.add(node); + } + return root; + } +} diff --git a/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.go b/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.go new file mode 100644 index 00000000..e1a65b43 --- /dev/null +++ b/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.go @@ -0,0 +1,42 @@ +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +func recoverFromPreorder(traversal string) *TreeNode { + stack := []*TreeNode{} + var root *TreeNode + i := 0 + n := len(traversal) + for i < n { + depth := 0 + for i < n && traversal[i] == '-' { + depth++ + i++ + } + num := 0 + for i < n && traversal[i] >= '0' && traversal[i] <= '9' { + num = num*10 + int(traversal[i]-'0') + i++ + } + node := &TreeNode{Val: num} + for len(stack) > depth { + stack = stack[:len(stack)-1] + } + if len(stack) == 0 { + root = node + } else { + parent := stack[len(stack)-1] + if parent.Left == nil { + parent.Left = node + } else { + parent.Right = node + } + } + stack = append(stack, node) + } + return root +} diff --git a/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.java b/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.java new file mode 100644 index 00000000..9c919043 --- /dev/null +++ b/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.java @@ -0,0 +1,50 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode() {} + * TreeNode(int val) { this.val = val; } + * TreeNode(int val, TreeNode left, TreeNode right) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +class Solution { + public TreeNode recoverFromPreorder(String traversal) { + java.util.ArrayDeque stack = new java.util.ArrayDeque<>(); + TreeNode root = null; + int i = 0, n = traversal.length(); + while (i < n) { + int depth = 0; + while (i < n && traversal.charAt(i) == '-') { + depth++; + i++; + } + int val = 0; + while (i < n && Character.isDigit(traversal.charAt(i))) { + val = val * 10 + (traversal.charAt(i) - '0'); + i++; + } + TreeNode node = new TreeNode(val); + while (stack.size() > depth) { + stack.removeLast(); + } + if (stack.isEmpty()) { + root = node; + } else { + TreeNode parent = stack.peekLast(); + if (parent.left == null) { + parent.left = node; + } else { + parent.right = node; + } + } + stack.addLast(node); + } + return root; + } +} diff --git a/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.kt b/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.kt new file mode 100644 index 00000000..2677e4c3 --- /dev/null +++ b/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.kt @@ -0,0 +1,45 @@ +/** + * Example: + * var ti = TreeNode(5) + * var v = ti.`val` + * Definition for a binary tree node. + * class TreeNode(var `val`: Int) { + * var left: TreeNode? = null + * var right: TreeNode? = null + * } + */ +class Solution { + fun recoverFromPreorder(traversal: String): TreeNode? { + val stack = mutableListOf() + var root: TreeNode? = null + var i = 0 + while (i < traversal.length) { + var depth = 0 + while (i < traversal.length && traversal[i] == '-') { + depth++ + i++ + } + var num = 0 + while (i < traversal.length && traversal[i].isDigit()) { + num = num * 10 + (traversal[i] - '0') + i++ + } + val node = TreeNode(num) + while (stack.size > depth) { + stack.removeAt(stack.lastIndex) + } + if (stack.isEmpty()) { + root = node + } else { + val parent = stack.last() + if (parent.left == null) { + parent.left = node + } else { + parent.right = node + } + } + stack.add(node) + } + return root + } +} diff --git a/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.py b/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.py new file mode 100644 index 00000000..764e2604 --- /dev/null +++ b/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.py @@ -0,0 +1,28 @@ +from typing import Optional + + +class Solution: + def recoverFromPreorder(self, traversal: str) -> Optional[TreeNode]: + stack = [] + i = 0 + n = len(traversal) + while i < n: + depth = 0 + while i < n and traversal[i] == "-": + depth += 1 + i += 1 + val = 0 + while i < n and traversal[i].isdigit(): + val = val * 10 + ord(traversal[i]) - 48 + i += 1 + node = TreeNode(val) + while len(stack) > depth: + stack.pop() + if stack: + parent = stack[-1] + if parent.left is None: + parent.left = node + else: + parent.right = node + stack.append(node) + return stack[0] if stack else None diff --git a/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.py2 b/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.py2 new file mode 100644 index 00000000..7b0250b3 --- /dev/null +++ b/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.py2 @@ -0,0 +1,31 @@ +# Definition for a binary tree node. +# class TreeNode(object): +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution(object): + def recoverFromPreorder(self, traversal): + stack = [] + i = 0 + n = len(traversal) + while i < n: + depth = 0 + while i < n and traversal[i] == '-': + depth += 1 + i += 1 + val = 0 + while i < n and traversal[i].isdigit(): + val = val * 10 + ord(traversal[i]) - 48 + i += 1 + node = TreeNode(val) + while len(stack) > depth: + stack.pop() + if stack: + parent = stack[-1] + if parent.left is None: + parent.left = node + else: + parent.right = node + stack.append(node) + return stack[0] if stack else None diff --git a/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.rb b/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.rb new file mode 100644 index 00000000..b239c9ab --- /dev/null +++ b/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.rb @@ -0,0 +1,40 @@ +# Definition for a binary tree node. +# class TreeNode +# attr_accessor :val, :left, :right +# def initialize(val = 0, left = nil, right = nil) +# @val = val +# @left = left +# @right = right +# end +# end +# @param {String} traversal +# @return {TreeNode} +def recover_from_preorder(traversal) + stack = [] + i = 0 + n = traversal.length + while i < n + depth = 0 + while i < n && traversal[i] == '-' + depth += 1 + i += 1 + end + val = 0 + while i < n && traversal[i] >= '0' && traversal[i] <= '9' + val = val * 10 + traversal[i].ord - 48 + i += 1 + end + node = TreeNode.new(val) + stack.pop while stack.length > depth + if !stack.empty? + parent = stack[-1] + if parent.left.nil? + parent.left = node + else + parent.right = node + end + end + stack << node + end + stack[0] +end diff --git a/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.rs b/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.rs new file mode 100644 index 00000000..ac058c89 --- /dev/null +++ b/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.rs @@ -0,0 +1,51 @@ +// Definition for a binary tree node. +// #[derive(Debug, PartialEq, Eq)] +// pub struct TreeNode { +// pub val: i32, +// pub left: Option>>, +// pub right: Option>>, +// } +// +// impl TreeNode { +// #[inline] +// pub fn new(val: i32) -> Self { +// TreeNode { +// val, +// left: None, +// right: None +// } +// } +// } +impl Solution { + pub fn recover_from_preorder(traversal: String) -> Option>> { + let chars = traversal.as_bytes(); + let mut i = 0usize; + let mut stack: Vec>> = Vec::new(); + while i < chars.len() { + let mut depth = 0usize; + while i < chars.len() && chars[i] == b'-' { + depth += 1; + i += 1; + } + let mut num = 0i32; + while i < chars.len() && chars[i].is_ascii_digit() { + num = num * 10 + (chars[i] - b'0') as i32; + i += 1; + } + let node = Rc::new(RefCell::new(TreeNode::new(num))); + while stack.len() > depth { + stack.pop(); + } + if let Some(parent) = stack.last() { + let mut p = parent.borrow_mut(); + if p.left.is_none() { + p.left = Some(node.clone()); + } else { + p.right = Some(node.clone()); + } + } + stack.push(node); + } + stack.first().cloned() + } +} diff --git a/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.swift b/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.swift new file mode 100644 index 00000000..64e2a526 --- /dev/null +++ b/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.swift @@ -0,0 +1,51 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public var val: Int + * public var left: TreeNode? + * public var right: TreeNode? + * public init() { self.val = 0; self.left = nil; self.right = nil; } + * public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; } + * public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) { + * self.val = val + * self.left = left + * self.right = right + * } + * } + */ +class Solution { + func recoverFromPreorder(_ traversal: String) -> TreeNode? { + var stack = [TreeNode]() + var root: TreeNode? + let chars = Array(traversal) + var i = 0 + while i < chars.count { + var depth = 0 + while i < chars.count && chars[i] == "-" { + depth += 1 + i += 1 + } + var num = 0 + while i < chars.count && chars[i].isNumber { + num = num * 10 + chars[i].wholeNumberValue! + i += 1 + } + let node = TreeNode(num) + while stack.count > depth { + stack.removeLast() + } + if stack.isEmpty { + root = node + } else { + let parent = stack.last! + if parent.left == nil { + parent.left = node + } else { + parent.right = node + } + } + stack.append(node) + } + return root + } +} diff --git a/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.ts b/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.ts new file mode 100644 index 00000000..56fc0422 --- /dev/null +++ b/tests/1001-1500/1028. recover-a-tree-from-preorder-traversal/sol.ts @@ -0,0 +1,49 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ + +function recoverFromPreorder(traversal: string): TreeNode | null { + const stack: TreeNode[] = []; + let root: TreeNode | null = null; + let i = 0; + while (i < traversal.length) { + let depth = 0; + while (i < traversal.length && traversal[i] === "-") { + depth++; + i++; + } + let num = 0; + while (i < traversal.length) { + const code = traversal.charCodeAt(i); + if (code < 48 || code > 57) break; + num = num * 10 + (code - 48); + i++; + } + const node = new TreeNode(num); + while (stack.length > depth) { + stack.pop(); + } + if (stack.length === 0) { + root = node; + } else { + const parent = stack[stack.length - 1]; + if (parent.left === null) { + parent.left = node; + } else { + parent.right = node; + } + } + stack.push(node); + } + return root; +} diff --git a/tests/1001-1500/1029. two-city-scheduling/manifest.yaml b/tests/1001-1500/1029. two-city-scheduling/manifest.yaml new file mode 100644 index 00000000..4ff7ddf6 --- /dev/null +++ b/tests/1001-1500/1029. two-city-scheduling/manifest.yaml @@ -0,0 +1,569 @@ +entry: + id: 1029 + title: two-city-scheduling + params: + costs: + type: array + items: + type: array + items: + type: int + call: + cpp: Solution().twoCitySchedCost({costs}) + rust: Solution::two_city_sched_cost({costs}) + python3: Solution().twoCitySchedCost({costs}) + python2: Solution().twoCitySchedCost({costs}) + ruby: two_city_sched_cost({costs}) + java: new Solution().twoCitySchedCost({costs}) + csharp: new Solution().TwoCitySchedCost({costs}) + kotlin: Solution().twoCitySchedCost({costs}) + go: twoCitySchedCost({costs}) + dart: Solution().twoCitySchedCost({costs}) + swift: Solution().twoCitySchedCost({costs}) + typescript: twoCitySchedCost({costs}) +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 300 +oracle: + python3: + call: Checker().twoCitySchedCost(costs, {result}) + checker: + "class Checker:\n def twoCitySchedCost(self, costs, result):\n \ + \ n = len(costs) // 2\n best = 10 ** 18\n from itertools import\ + \ combinations\n for choose in combinations(range(len(costs)), n):\n\ + \ choose = set(choose)\n total = 0\n for i,\ + \ (a, b) in enumerate(costs):\n total += a if i in choose else\ + \ b\n if total < best:\n best = total\n return\ + \ result == best\n" +seed: 1029 +tests: + - name: example_1 + in: + costs: + - - 10 + - 20 + - - 30 + - 200 + out: 50 + - name: example_2 + in: + costs: + - - 10 + - 100 + - - 20 + - 200 + - - 30 + - 50 + - - 40 + - 20 + out: 100 + - name: balanced_small_1 + in: + costs: + - - 50 + - 50 + - - 50 + - 50 + out: 100 + - name: balanced_small_2 + in: + costs: + - - 5 + - 100 + - - 100 + - 5 + out: 10 + - name: swap_1 + in: + costs: + - - 1 + - 1000 + - - 2 + - 999 + - - 999 + - 2 + - - 1000 + - 1 + out: 6 + - name: swap_2 + in: + costs: + - - 20 + - 30 + - - 30 + - 20 + - - 40 + - 50 + - - 50 + - 40 + out: 120 + - name: ordered_1 + in: + costs: + - - 10 + - 90 + - - 20 + - 80 + - - 30 + - 70 + - - 40 + - 60 + out: 160 + - name: ordered_2 + in: + costs: + - - 90 + - 10 + - - 80 + - 20 + - - 70 + - 30 + - - 60 + - 40 + out: 160 + - name: mixed_1 + in: + costs: + - - 259 + - 770 + - - 448 + - 54 + - - 926 + - 667 + - - 184 + - 139 + - - 840 + - 118 + - - 577 + - 469 + out: 1859 + - name: mixed_2 + in: + costs: + - - 515 + - 563 + - - 451 + - 713 + - - 537 + - 709 + - - 343 + - 819 + - - 855 + - 779 + - - 457 + - 60 + out: 2733 + - name: mixed_3 + in: + costs: + - - 5 + - 9 + - - 7 + - 6 + - - 8 + - 4 + - - 10 + - 3 + out: 19 + - name: mixed_4 + in: + costs: + - - 8 + - 3 + - - 6 + - 7 + - - 5 + - 4 + - - 9 + - 2 + out: 16 + - name: mixed_5 + in: + costs: + - - 100 + - 1 + - - 1 + - 100 + - - 50 + - 60 + - - 60 + - 50 + out: 102 + - name: mixed_6 + in: + costs: + - - 11 + - 12 + - - 13 + - 14 + - - 15 + - 16 + - - 17 + - 18 + out: 58 + - name: mixed_7 + in: + costs: + - - 12 + - 11 + - - 14 + - 13 + - - 16 + - 15 + - - 18 + - 17 + out: 58 + - name: mixed_8 + in: + costs: + - - 100 + - 50 + - - 60 + - 20 + - - 30 + - 40 + - - 25 + - 35 + out: 125 + - name: mixed_9 + in: + costs: + - - 1 + - 2 + - - 2 + - 1 + - - 3 + - 4 + - - 4 + - 3 + - - 5 + - 6 + - - 6 + - 5 + out: 18 + - name: mixed_10 + in: + costs: + - - 9 + - 1 + - - 8 + - 2 + - - 7 + - 3 + - - 6 + - 4 + - - 5 + - 5 + - - 4 + - 6 + out: 21 + - name: mixed_11 + in: + costs: + - - 20 + - 100 + - - 30 + - 90 + - - 40 + - 80 + - - 50 + - 70 + - - 60 + - 60 + - - 70 + - 50 + out: 270 + - name: mixed_12 + in: + costs: + - - 100 + - 20 + - - 90 + - 30 + - - 80 + - 40 + - - 70 + - 50 + - - 60 + - 60 + - - 50 + - 70 + out: 270 + - name: mixed_13 + in: + costs: + - - 14 + - 90 + - - 28 + - 80 + - - 35 + - 70 + - - 45 + - 60 + out: 172 + - name: mixed_14 + in: + costs: + - - 90 + - 14 + - - 80 + - 28 + - - 70 + - 35 + - - 60 + - 45 + out: 172 + - name: mixed_15 + in: + costs: + - - 1 + - 10 + - - 10 + - 1 + - - 2 + - 9 + - - 9 + - 2 + - - 3 + - 8 + - - 8 + - 3 + out: 12 + - name: mixed_16 + in: + costs: + - - 11 + - 100 + - - 20 + - 90 + - - 30 + - 80 + - - 40 + - 70 + - - 50 + - 60 + - - 60 + - 50 + out: 241 + - name: mixed_17 + in: + costs: + - - 100 + - 11 + - - 90 + - 20 + - - 80 + - 30 + - - 70 + - 40 + - - 60 + - 50 + - - 50 + - 60 + out: 241 + - name: mixed_18 + in: + costs: + - - 13 + - 17 + - - 19 + - 23 + - - 29 + - 31 + - - 37 + - 41 + out: 104 + - name: mixed_19 + in: + costs: + - - 17 + - 13 + - - 23 + - 19 + - - 31 + - 29 + - - 41 + - 37 + out: 104 + - name: mixed_20 + in: + costs: + - - 3 + - 100 + - - 4 + - 90 + - - 5 + - 80 + - - 6 + - 70 + - - 7 + - 60 + - - 8 + - 50 + out: 192 + - name: mixed_21 + in: + costs: + - - 100 + - 3 + - - 90 + - 4 + - - 80 + - 5 + - - 70 + - 6 + - - 60 + - 7 + - - 50 + - 8 + out: 192 + - name: mixed_22 + in: + costs: + - - 21 + - 22 + - - 22 + - 21 + - - 23 + - 24 + - - 24 + - 23 + out: 88 + - name: mixed_23 + in: + costs: + - - 200 + - 1 + - - 1 + - 200 + - - 100 + - 100 + - - 50 + - 60 + out: 152 + - name: mixed_24 + in: + costs: + - - 8 + - 100 + - - 9 + - 90 + - - 10 + - 80 + - - 11 + - 70 + - - 12 + - 60 + - - 13 + - 50 + out: 207 + - name: mixed_25 + in: + costs: + - - 100 + - 8 + - - 90 + - 9 + - - 80 + - 10 + - - 70 + - 11 + - - 60 + - 12 + - - 50 + - 13 + out: 207 + - name: mixed_26 + in: + costs: + - - 15 + - 25 + - - 25 + - 15 + - - 35 + - 45 + - - 45 + - 35 + out: 100 + - name: mixed_27 + in: + costs: + - - 16 + - 26 + - - 26 + - 16 + - - 36 + - 46 + - - 46 + - 36 + out: 104 + - name: mixed_28 + in: + costs: + - - 1 + - 3 + - - 2 + - 4 + - - 3 + - 5 + - - 4 + - 6 + - - 5 + - 7 + - - 6 + - 8 + out: 27 + - name: mixed_29 + in: + costs: + - - 3 + - 1 + - - 4 + - 2 + - - 5 + - 3 + - - 6 + - 4 + - - 7 + - 5 + - - 8 + - 6 + out: 27 + - name: mixed_30 + in: + costs: + - - 31 + - 41 + - - 41 + - 31 + - - 51 + - 61 + - - 61 + - 51 + out: 164 + - name: mixed_31 + in: + costs: + - - 41 + - 31 + - - 61 + - 51 + - - 71 + - 81 + - - 81 + - 71 + out: 234 + - name: mixed_32 + in: + costs: + - - 19 + - 29 + - - 29 + - 19 + - - 39 + - 49 + - - 49 + - 39 + out: 116 diff --git a/tests/1001-1500/1029. two-city-scheduling/sol.cpp b/tests/1001-1500/1029. two-city-scheduling/sol.cpp new file mode 100644 index 00000000..40727122 --- /dev/null +++ b/tests/1001-1500/1029. two-city-scheduling/sol.cpp @@ -0,0 +1,18 @@ +class Solution { +public: + int twoCitySchedCost(vector>& costs) { + int res = 0; + sort(costs.begin(), costs.end(), [](const vector& a, const vector& b) { + return (a[0] - a[1]) < (b[0] - b[1]); + }); + int n = costs.size(); + for (int i = 0; i < n; i++) { + if (i < n / 2) { + res += costs[i][0]; + } else { + res += costs[i][1]; + } + } + return res; + } +}; diff --git a/tests/1001-1500/1029. two-city-scheduling/sol.cs b/tests/1001-1500/1029. two-city-scheduling/sol.cs new file mode 100644 index 00000000..bfee6c93 --- /dev/null +++ b/tests/1001-1500/1029. two-city-scheduling/sol.cs @@ -0,0 +1,15 @@ +public class Solution { + public int TwoCitySchedCost(int[][] costs) { + int res = 0; + Array.Sort(costs, (a, b) => (a[0] - a[1]).CompareTo(b[0] - b[1])); + int n = costs.Length; + for (int i = 0; i < n; i++) { + if (i < n / 2) { + res += costs[i][0]; + } else { + res += costs[i][1]; + } + } + return res; + } +} diff --git a/tests/1001-1500/1029. two-city-scheduling/sol.dart b/tests/1001-1500/1029. two-city-scheduling/sol.dart new file mode 100644 index 00000000..004b6bb3 --- /dev/null +++ b/tests/1001-1500/1029. two-city-scheduling/sol.dart @@ -0,0 +1,15 @@ +class Solution { + int twoCitySchedCost(List> costs) { + int res = 0; + costs.sort((a, b) => (a[0] - a[1]).compareTo(b[0] - b[1])); + int n = costs.length; + for (int i = 0; i < n; i++) { + if (i < n ~/ 2) { + res += costs[i][0]; + } else { + res += costs[i][1]; + } + } + return res; + } +} diff --git a/tests/1001-1500/1029. two-city-scheduling/sol.go b/tests/1001-1500/1029. two-city-scheduling/sol.go new file mode 100644 index 00000000..e8830f65 --- /dev/null +++ b/tests/1001-1500/1029. two-city-scheduling/sol.go @@ -0,0 +1,15 @@ +func twoCitySchedCost(costs [][]int) int { + res := 0 + sort.Slice(costs, func(i, j int) bool { + return costs[i][0]-costs[i][1] < costs[j][0]-costs[j][1] + }) + n := len(costs) + for i := 0; i < n; i++ { + if i < n/2 { + res += costs[i][0] + } else { + res += costs[i][1] + } + } + return res +} diff --git a/tests/1001-1500/1029. two-city-scheduling/sol.java b/tests/1001-1500/1029. two-city-scheduling/sol.java new file mode 100644 index 00000000..81c27d47 --- /dev/null +++ b/tests/1001-1500/1029. two-city-scheduling/sol.java @@ -0,0 +1,15 @@ +class Solution { + public int twoCitySchedCost(int[][] costs) { + int res = 0; + Arrays.sort(costs, (a, b) -> (a[0] - a[1]) - (b[0] - b[1])); + int n = costs.length; + for (int i = 0; i < n; i++) { + if (i < n / 2) { + res += costs[i][0]; + } else { + res += costs[i][1]; + } + } + return res; + } +} diff --git a/tests/1001-1500/1029. two-city-scheduling/sol.kt b/tests/1001-1500/1029. two-city-scheduling/sol.kt new file mode 100644 index 00000000..276b45fc --- /dev/null +++ b/tests/1001-1500/1029. two-city-scheduling/sol.kt @@ -0,0 +1,15 @@ +class Solution { + fun twoCitySchedCost(costs: Array): Int { + var res = 0 + costs.sortBy { it[0] - it[1] } + val n = costs.size + for (i in 0 until n) { + if (i < n / 2) { + res += costs[i][0] + } else { + res += costs[i][1] + } + } + return res + } +} diff --git a/tests/1001-1500/1029. two-city-scheduling/sol.py b/tests/1001-1500/1029. two-city-scheduling/sol.py new file mode 100644 index 00000000..c3c14d67 --- /dev/null +++ b/tests/1001-1500/1029. two-city-scheduling/sol.py @@ -0,0 +1,12 @@ +class Solution: + def twoCitySchedCost(self, costs: List[List[int]]) -> int: + res = 0 + costs.sort(key=lambda x: x[0] - x[1]) + n = len(costs) + + for i in range(n): + if i < n // 2: + res += costs[i][0] + else: + res += costs[i][1] + return res diff --git a/tests/1001-1500/1029. two-city-scheduling/sol.py2 b/tests/1001-1500/1029. two-city-scheduling/sol.py2 new file mode 100644 index 00000000..8476c2b2 --- /dev/null +++ b/tests/1001-1500/1029. two-city-scheduling/sol.py2 @@ -0,0 +1,15 @@ +class Solution(object): + def twoCitySchedCost(self, costs): + """ + :type costs: List[List[int]] + :rtype: int + """ + res = 0 + costs.sort(key=lambda x: x[0] - x[1]) + n = len(costs) + for i in range(n): + if i < n // 2: + res += costs[i][0] + else: + res += costs[i][1] + return res diff --git a/tests/1001-1500/1029. two-city-scheduling/sol.rb b/tests/1001-1500/1029. two-city-scheduling/sol.rb new file mode 100644 index 00000000..c2908ecd --- /dev/null +++ b/tests/1001-1500/1029. two-city-scheduling/sol.rb @@ -0,0 +1,15 @@ +# @param {Integer[][]} costs +# @return {Integer} +def two_city_sched_cost(costs) + res = 0 + costs.sort_by! { |x| x[0] - x[1] } + n = costs.length + (0...n).each do |i| + if i < n / 2 + res += costs[i][0] + else + res += costs[i][1] + end + end + res +end diff --git a/tests/1001-1500/1029. two-city-scheduling/sol.rs b/tests/1001-1500/1029. two-city-scheduling/sol.rs new file mode 100644 index 00000000..ff0f49e8 --- /dev/null +++ b/tests/1001-1500/1029. two-city-scheduling/sol.rs @@ -0,0 +1,16 @@ +impl Solution { + pub fn two_city_sched_cost(costs: Vec>) -> i32 { + let mut costs = costs; + costs.sort_by_key(|x| x[0] - x[1]); + let n = costs.len(); + let mut res = 0; + for i in 0..n { + if i < n / 2 { + res += costs[i][0]; + } else { + res += costs[i][1]; + } + } + res + } +} diff --git a/tests/1001-1500/1029. two-city-scheduling/sol.swift b/tests/1001-1500/1029. two-city-scheduling/sol.swift new file mode 100644 index 00000000..542fcba7 --- /dev/null +++ b/tests/1001-1500/1029. two-city-scheduling/sol.swift @@ -0,0 +1,15 @@ +class Solution { + func twoCitySchedCost(_ costs: [[Int]]) -> Int { + var res = 0 + let sorted = costs.sorted { ($0[0] - $0[1]) < ($1[0] - $1[1]) } + let n = sorted.count + for i in 0.. a[0] - a[1] - (b[0] - b[1])); + const n = costs.length; + for (let i = 0; i < n; i++) { + if (i < Math.floor(n / 2)) { + res += costs[i][0]; + } else { + res += costs[i][1]; + } + } + return res; +} diff --git a/tests/1001-1500/1030. matrix-cells-in-distance-order/manifest.yaml b/tests/1001-1500/1030. matrix-cells-in-distance-order/manifest.yaml new file mode 100644 index 00000000..8981431b --- /dev/null +++ b/tests/1001-1500/1030. matrix-cells-in-distance-order/manifest.yaml @@ -0,0 +1,272 @@ +entry: + id: 1030 + title: matrix-cells-in-distance-order + params: + m: + type: int + n: + type: int + i: + type: int + j: + type: int + call: + cpp: "Solution().allCellsDistOrder({m}, {n}, {i}, {j})" + rust: "Solution::all_cells_dist_order({m}, {n}, {i}, {j})" + python3: "Solution().allCellsDistOrder({m}, {n}, {i}, {j})" + python2: "Solution().allCellsDistOrder({m}, {n}, {i}, {j})" + ruby: "all_cells_dist_order({m}, {n}, {i}, {j})" + java: "new Solution().allCellsDistOrder({m}, {n}, {i}, {j})" + csharp: "new Solution().AllCellsDistOrder({m}, {n}, {i}, {j})" + kotlin: "Solution().allCellsDistOrder({m}, {n}, {i}, {j})" + go: "allCellsDistOrder({m}, {n}, {i}, {j})" + dart: "Solution().allCellsDistOrder({m}, {n}, {i}, {j})" + swift: "Solution().allCellsDistOrder({m}, {n}, {i}, {j})" + typescript: "allCellsDistOrder({m}, {n}, {i}, {j})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().check(m, n, i, j, {result})" + checker: | + class Checker: + def check(self, m, n, i, j, result): + if not isinstance(result, list) or len(result) != m * n: + return False + seen = set() + prev = None + for cell in result: + if not isinstance(cell, list) or len(cell) != 2: + return False + r, c = cell + if not (0 <= r < m and 0 <= c < n): + return False + if (r, c) in seen: + return False + seen.add((r, c)) + key = (abs(r - i) + abs(c - j), r, c) + if prev is not None and prev > key: + return False + prev = key + return len(seen) == m * n +seed: 1030 +tests: + - name: single-cell + in: + m: 1 + n: 1 + i: 0 + j: 0 + - name: one-row-left + in: + m: 1 + n: 4 + i: 0 + j: 0 + - name: one-row-middle + in: + m: 1 + n: 5 + i: 0 + j: 2 + - name: one-row-right + in: + m: 1 + n: 6 + i: 0 + j: 5 + - name: one-column-top + in: + m: 5 + n: 1 + i: 0 + j: 0 + - name: one-column-middle + in: + m: 6 + n: 1 + i: 3 + j: 0 + - name: one-column-bottom + in: + m: 7 + n: 1 + i: 6 + j: 0 + - name: 2x2-top-left + in: + m: 2 + n: 2 + i: 0 + j: 0 + - name: 2x2-bottom-right + in: + m: 2 + n: 2 + i: 1 + j: 1 + - name: 2x3-center-ish + in: + m: 2 + n: 3 + i: 0 + j: 1 + - name: 3x2-center-ish + in: + m: 3 + n: 2 + i: 1 + j: 0 + - name: 3x3-center + in: + m: 3 + n: 3 + i: 1 + j: 1 + - name: 3x3-corner + in: + m: 3 + n: 3 + i: 0 + j: 0 + - name: 3x3-edge + in: + m: 3 + n: 3 + i: 0 + j: 1 + - name: 4x4-center + in: + m: 4 + n: 4 + i: 2 + j: 2 + - name: 4x5-near-corner + in: + m: 4 + n: 5 + i: 1 + j: 3 + - name: 5x4-near-edge + in: + m: 5 + n: 4 + i: 3 + j: 1 + - name: 5x5-center + in: + m: 5 + n: 5 + i: 2 + j: 2 + - name: 5x5-corner + in: + m: 5 + n: 5 + i: 4 + j: 4 + - name: 6x7-random-1 + in: + m: 6 + n: 7 + i: 2 + j: 3 + - name: 6x7-random-2 + in: + m: 6 + n: 7 + i: 5 + j: 0 + - name: 7x6-random-1 + in: + m: 7 + n: 6 + i: 1 + j: 5 + - name: 7x6-random-2 + in: + m: 7 + n: 6 + i: 6 + j: 2 + - name: 8x8-center + in: + m: 8 + n: 8 + i: 4 + j: 4 + - name: 8x8-edge + in: + m: 8 + n: 8 + i: 0 + j: 7 + - name: 9x3 + in: + m: 9 + n: 3 + i: 8 + j: 1 + - name: 10x2 + in: + m: 10 + n: 2 + i: 4 + j: 1 + - name: 2x10 + in: + m: 2 + n: 10 + i: 1 + j: 4 + - name: 10x10-center + in: + m: 10 + n: 10 + i: 5 + j: 5 + - name: 10x10-corner + in: + m: 10 + n: 10 + i: 0 + j: 0 + - name: 10x10-near-corner + in: + m: 10 + n: 10 + i: 1 + j: 1 + - name: 11x4 + in: + m: 11 + n: 4 + i: 10 + j: 3 + - name: 4x11 + in: + m: 4 + n: 11 + i: 0 + j: 10 + - name: 12x12-center + in: + m: 12 + n: 12 + i: 6 + j: 6 + - name: 12x12-random + in: + m: 12 + n: 12 + i: 3 + j: 8 + - name: 13x7-random + in: + m: 13 + n: 7 + i: 9 + j: 2 diff --git a/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.cpp b/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.cpp new file mode 100644 index 00000000..0ab37a42 --- /dev/null +++ b/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.cpp @@ -0,0 +1,19 @@ +class Solution { +public: + vector> allCellsDistOrder(int rows, int cols, int rCenter, int cCenter) { + vector> result; + for (int r = 0; r < rows; ++r) { + for (int c = 0; c < cols; ++c) { + result.push_back({r, c}); + } + } + sort(result.begin(), result.end(), [rCenter, cCenter](const vector& a, const vector& b) { + int d1 = abs(a[0] - rCenter) + abs(a[1] - cCenter); + int d2 = abs(b[0] - rCenter) + abs(b[1] - cCenter); + if (d1 != d2) return d1 < d2; + if (a[0] != b[0]) return a[0] < b[0]; + return a[1] < b[1]; + }); + return result; + } +}; diff --git a/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.cs b/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.cs new file mode 100644 index 00000000..39189bfb --- /dev/null +++ b/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.cs @@ -0,0 +1,19 @@ +public class Solution { + public int[][] AllCellsDistOrder(int rows, int cols, int rCenter, int cCenter) { + int[][] result = new int[rows * cols][]; + int idx = 0; + for (int r = 0; r < rows; r++) { + for (int c = 0; c < cols; c++) { + result[idx++] = new int[] { r, c }; + } + } + System.Array.Sort(result, (a, b) => { + int d1 = Math.Abs(a[0] - rCenter) + Math.Abs(a[1] - cCenter); + int d2 = Math.Abs(b[0] - rCenter) + Math.Abs(b[1] - cCenter); + if (d1 != d2) return d1.CompareTo(d2); + if (a[0] != b[0]) return a[0].CompareTo(b[0]); + return a[1].CompareTo(b[1]); + }); + return result; + } +} diff --git a/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.dart b/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.dart new file mode 100644 index 00000000..f8a217d2 --- /dev/null +++ b/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.dart @@ -0,0 +1,18 @@ +class Solution { + List> allCellsDistOrder(int rows, int cols, int rCenter, int cCenter) { + List> result = []; + for (int r = 0; r < rows; r++) { + for (int c = 0; c < cols; c++) { + result.add([r, c]); + } + } + result.sort((a, b) { + int d1 = (a[0] - rCenter).abs() + (a[1] - cCenter).abs(); + int d2 = (b[0] - rCenter).abs() + (b[1] - cCenter).abs(); + if (d1 != d2) return d1.compareTo(d2); + if (a[0] != b[0]) return a[0].compareTo(b[0]); + return a[1].compareTo(b[1]); + }); + return result; + } +} diff --git a/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.go b/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.go new file mode 100644 index 00000000..88cacdcd --- /dev/null +++ b/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.go @@ -0,0 +1,27 @@ +func allCellsDistOrder(rows int, cols int, rCenter int, cCenter int) [][]int { + result := make([][]int, 0, rows*cols) + for r := 0; r < rows; r++ { + for c := 0; c < cols; c++ { + result = append(result, []int{r, c}) + } + } + sort.Slice(result, func(i, j int) bool { + d1 := abs(result[i][0]-rCenter) + abs(result[i][1]-cCenter) + d2 := abs(result[j][0]-rCenter) + abs(result[j][1]-cCenter) + if d1 != d2 { + return d1 < d2 + } + if result[i][0] != result[j][0] { + return result[i][0] < result[j][0] + } + return result[i][1] < result[j][1] + }) + return result +} + +func abs(x int) int { + if x < 0 { + return -x + } + return x +} diff --git a/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.java b/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.java new file mode 100644 index 00000000..06cff92c --- /dev/null +++ b/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.java @@ -0,0 +1,21 @@ +class Solution { + public int[][] allCellsDistOrder(int rows, int cols, int rCenter, int cCenter) { + int[][] result = new int[rows * cols][2]; + int idx = 0; + for (int r = 0; r < rows; r++) { + for (int c = 0; c < cols; c++) { + result[idx][0] = r; + result[idx][1] = c; + idx++; + } + } + java.util.Arrays.sort(result, (a, b) -> { + int d1 = Math.abs(a[0] - rCenter) + Math.abs(a[1] - cCenter); + int d2 = Math.abs(b[0] - rCenter) + Math.abs(b[1] - cCenter); + if (d1 != d2) return Integer.compare(d1, d2); + if (a[0] != b[0]) return Integer.compare(a[0], b[0]); + return Integer.compare(a[1], b[1]); + }); + return result; + } +} diff --git a/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.kt b/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.kt new file mode 100644 index 00000000..c2288176 --- /dev/null +++ b/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.kt @@ -0,0 +1,19 @@ +class Solution { + fun allCellsDistOrder(rows: Int, cols: Int, rCenter: Int, cCenter: Int): Array { + val result = Array(rows * cols) { IntArray(2) } + var idx = 0 + for (r in 0 until rows) { + for (c in 0 until cols) { + result[idx][0] = r + result[idx][1] = c + idx++ + } + } + result.sortWith( + compareBy { kotlin.math.abs(it[0] - rCenter) + kotlin.math.abs(it[1] - cCenter) } + .thenBy { it[0] } + .thenBy { it[1] } + ) + return result + } +} diff --git a/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.py b/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.py new file mode 100644 index 00000000..8d697664 --- /dev/null +++ b/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.py @@ -0,0 +1,13 @@ +from itertools import product +from typing import List + + +class Solution: + def allCellsDistOrder( + self, rows: int, cols: int, rCenter: int, cCenter: int + ) -> List[List[int]]: + cells = sorted( + product(range(rows), range(cols)), + key=lambda p: (abs(p[0] - rCenter) + abs(p[1] - cCenter), p[0], p[1]), + ) + return [[r, c] for r, c in cells] diff --git a/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.py2 b/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.py2 new file mode 100644 index 00000000..6321da7c --- /dev/null +++ b/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.py2 @@ -0,0 +1,10 @@ +class Solution(object): + def allCellsDistOrder(self, rows, cols, rCenter, cCenter): + """ + :type rows: int + :type cols: int + :type rCenter: int + :type cCenter: int + :rtype: List[List[int]] + """ + return sorted([[r, c] for r in range(rows) for c in range(cols)], key=lambda p: abs(p[0] - rCenter) + abs(p[1] - cCenter)) diff --git a/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.rb b/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.rb new file mode 100644 index 00000000..322a0c23 --- /dev/null +++ b/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.rb @@ -0,0 +1,8 @@ +# @param {Integer} rows +# @param {Integer} cols +# @param {Integer} r_center +# @param {Integer} c_center +# @return {Integer[][]} +def all_cells_dist_order(rows, cols, r_center, c_center) + (0...rows).to_a.product((0...cols).to_a).sort_by { |r, c| [(r - r_center).abs + (c - c_center).abs, r, c] } +end diff --git a/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.rs b/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.rs new file mode 100644 index 00000000..4da66b24 --- /dev/null +++ b/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.rs @@ -0,0 +1,12 @@ +impl Solution { + pub fn all_cells_dist_order(rows: i32, cols: i32, r_center: i32, c_center: i32) -> Vec> { + let mut result = Vec::new(); + for r in 0..rows { + for c in 0..cols { + result.push(vec![r, c]); + } + } + result.sort_by_key(|p| ((p[0] - r_center).abs() + (p[1] - c_center).abs(), p[0], p[1])); + result + } +} diff --git a/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.swift b/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.swift new file mode 100644 index 00000000..ca786ef2 --- /dev/null +++ b/tests/1001-1500/1030. matrix-cells-in-distance-order/sol.swift @@ -0,0 +1,18 @@ +class Solution { + func allCellsDistOrder(_ rows: Int, _ cols: Int, _ rCenter: Int, _ cCenter: Int) -> [[Int]] { + var result = [[Int]]() + for r in 0.. { + const d1 = Math.abs(a[0] - rCenter) + Math.abs(a[1] - cCenter); + const d2 = Math.abs(b[0] - rCenter) + Math.abs(b[1] - cCenter); + if (d1 !== d2) return d1 - d2; + if (a[0] !== b[0]) return a[0] - b[0]; + return a[1] - b[1]; + }); + return result; +} diff --git a/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/manifest.yaml b/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/manifest.yaml new file mode 100644 index 00000000..7c89a051 --- /dev/null +++ b/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/manifest.yaml @@ -0,0 +1,553 @@ +entry: + id: 1031 + title: maximum-sum-of-two-non-overlapping-subarrays + params: + nums: + type: array + items: + type: int + firstLen: + type: int + secondLen: + type: int + call: + cpp: Solution().maxSumTwoNoOverlap({nums}, {firstLen}, {secondLen}) + rust: Solution::max_sum_two_no_overlap({nums}, {firstLen}, {secondLen}) + python3: Solution().maxSumTwoNoOverlap({nums}, {firstLen}, {secondLen}) + python2: Solution().maxSumTwoNoOverlap({nums}, {firstLen}, {secondLen}) + ruby: max_sum_two_no_overlap({nums}, {firstLen}, {secondLen}) + java: new Solution().maxSumTwoNoOverlap({nums}, {firstLen}, {secondLen}) + csharp: new Solution().MaxSumTwoNoOverlap({nums}, {firstLen}, {secondLen}) + kotlin: Solution().maxSumTwoNoOverlap({nums}, {firstLen}, {secondLen}) + go: maxSumTwoNoOverlap({nums}, {firstLen}, {secondLen}) + dart: Solution().maxSumTwoNoOverlap({nums}, {firstLen}, {secondLen}) + swift: Solution().maxSumTwoNoOverlap({nums}, {firstLen}, {secondLen}) + typescript: maxSumTwoNoOverlap({nums}, {firstLen}, {secondLen}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check(nums, firstLen, secondLen, {result}) + checker: + "class Checker:\n def check(self, nums, firstLen, secondLen, result):\n\ + \ if not isinstance(result, int):\n return False\n \ + \ n = len(nums)\n if firstLen + secondLen > n:\n return False\n\ + \ pref = [0]\n for x in nums:\n pref.append(pref[-1]\ + \ + x)\n best = 0\n for a in range(n - firstLen + 1):\n \ + \ sum1 = pref[a + firstLen] - pref[a]\n for b in range(n - secondLen\ + \ + 1):\n if b + secondLen <= a or a + firstLen <= b:\n \ + \ best = max(best, sum1 + pref[b + secondLen] - pref[b])\n \ + \ for a in range(n - secondLen + 1):\n sum1 = pref[a + secondLen]\ + \ - pref[a]\n for b in range(n - firstLen + 1):\n \ + \ if b + firstLen <= a or a + secondLen <= b:\n best = max(best,\ + \ sum1 + pref[b + firstLen] - pref[b])\n return result == best\n" +seed: 1031 +tests: + - name: example-1 + in: + nums: + - 0 + - 6 + - 5 + - 2 + - 2 + - 5 + - 1 + - 9 + - 4 + firstLen: 1 + secondLen: 2 + - name: example-2 + in: + nums: + - 3 + - 8 + - 1 + - 3 + - 2 + - 1 + - 8 + - 9 + - 0 + firstLen: 3 + secondLen: 2 + - name: example-3 + in: + nums: + - 2 + - 1 + - 5 + - 6 + - 0 + - 9 + - 5 + - 0 + - 3 + - 8 + firstLen: 4 + secondLen: 3 + - name: all-small + in: + nums: + - 1 + - 1 + firstLen: 1 + secondLen: 1 + - name: three-elements + in: + nums: + - 5 + - 2 + - 3 + firstLen: 1 + secondLen: 1 + - name: four-elements + in: + nums: + - 4 + - 7 + - 1 + - 9 + firstLen: 1 + secondLen: 2 + - name: adjacent-optimal + in: + nums: + - 9 + - 8 + - 7 + - 6 + - 5 + - 4 + firstLen: 2 + secondLen: 2 + - name: disjoint-optimal + in: + nums: + - 5 + - 1 + - 5 + - 1 + - 5 + - 1 + - 5 + firstLen: 2 + secondLen: 1 + - name: second-longer + in: + nums: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + firstLen: 2 + secondLen: 3 + - name: first-longer + in: + nums: + - 7 + - 6 + - 5 + - 4 + - 3 + - 2 + - 1 + firstLen: 3 + secondLen: 2 + - name: zeros-and-peaks + in: + nums: + - 0 + - 0 + - 100 + - 0 + - 0 + - 100 + - 0 + firstLen: 1 + secondLen: 1 + - name: repeated-pattern-1 + in: + nums: + - 2 + - 7 + - 1 + - 8 + - 2 + - 8 + - 1 + - 8 + firstLen: 2 + secondLen: 2 + - name: repeated-pattern-2 + in: + nums: + - 9 + - 1 + - 9 + - 1 + - 9 + - 1 + - 9 + - 1 + firstLen: 2 + secondLen: 1 + - name: repeated-pattern-3 + in: + nums: + - 4 + - 4 + - 4 + - 4 + - 4 + - 4 + - 4 + - 4 + - 4 + firstLen: 3 + secondLen: 2 + - name: increasing-1 + in: + nums: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + firstLen: 1 + secondLen: 2 + - name: increasing-2 + in: + nums: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + firstLen: 2 + secondLen: 2 + - name: decreasing-1 + in: + nums: + - 8 + - 7 + - 6 + - 5 + - 4 + - 3 + - 2 + - 1 + firstLen: 2 + secondLen: 3 + - name: decreasing-2 + in: + nums: + - 10 + - 9 + - 8 + - 7 + - 6 + - 5 + - 4 + - 3 + - 2 + firstLen: 3 + secondLen: 2 + - name: mixed-1 + in: + nums: + - 6 + - 1 + - 9 + - 2 + - 8 + - 3 + - 7 + - 4 + - 5 + firstLen: 2 + secondLen: 2 + - name: mixed-2 + in: + nums: + - 9 + - 0 + - 1 + - 0 + - 9 + - 0 + - 1 + - 0 + - 9 + firstLen: 1 + secondLen: 3 + - name: mixed-3 + in: + nums: + - 3 + - 3 + - 3 + - 3 + - 3 + - 3 + - 3 + - 3 + firstLen: 4 + secondLen: 2 + - name: mixed-4 + in: + nums: + - 1 + - 100 + - 1 + - 100 + - 1 + - 100 + - 1 + firstLen: 1 + secondLen: 2 + - name: mixed-5 + in: + nums: + - 50 + - 1 + - 1 + - 50 + - 1 + - 1 + - 50 + firstLen: 2 + secondLen: 1 + - name: mixed-6 + in: + nums: + - 5 + - 4 + - 3 + - 2 + - 1 + - 0 + - 1 + - 2 + - 3 + firstLen: 3 + secondLen: 3 + - name: mixed-7 + in: + nums: + - 2 + - 4 + - 6 + - 8 + - 10 + - 12 + - 14 + firstLen: 2 + secondLen: 2 + - name: mixed-8 + in: + nums: + - 14 + - 12 + - 10 + - 8 + - 6 + - 4 + - 2 + firstLen: 2 + secondLen: 2 + - name: mixed-9 + in: + nums: + - 1 + - 3 + - 5 + - 7 + - 9 + - 2 + - 4 + - 6 + - 8 + firstLen: 3 + secondLen: 2 + - name: mixed-10 + in: + nums: + - 8 + - 6 + - 7 + - 5 + - 3 + - 0 + - 9 + firstLen: 2 + secondLen: 2 + - name: mixed-11 + in: + nums: + - 1000 + - 1 + - 1000 + - 1 + - 1000 + - 1 + - 1000 + firstLen: 1 + secondLen: 1 + - name: mixed-12 + in: + nums: + - 0 + - 5 + - 0 + - 5 + - 0 + - 5 + - 0 + - 5 + firstLen: 2 + secondLen: 2 + - name: mixed-13 + in: + nums: + - 11 + - 22 + - 33 + - 44 + - 55 + - 66 + - 77 + - 88 + firstLen: 1 + secondLen: 4 + - name: mixed-14 + in: + nums: + - 13 + - 8 + - 21 + - 5 + - 34 + - 2 + - 55 + - 1 + firstLen: 3 + secondLen: 2 + - name: mixed-15 + in: + nums: + - 1 + - 4 + - 2 + - 8 + - 5 + - 7 + - 3 + - 6 + firstLen: 2 + secondLen: 3 + - name: mixed-16 + in: + nums: + - 9 + - 7 + - 5 + - 3 + - 1 + - 2 + - 4 + - 6 + - 8 + firstLen: 4 + secondLen: 2 + - name: mixed-17 + in: + nums: + - 2 + - 9 + - 2 + - 9 + - 2 + - 9 + - 2 + - 9 + - 2 + firstLen: 1 + secondLen: 2 + - name: mixed-18 + in: + nums: + - 3 + - 1 + - 4 + - 1 + - 5 + - 9 + - 2 + - 6 + firstLen: 2 + secondLen: 2 + - name: mixed-19 + in: + nums: + - 8 + - 5 + - 9 + - 7 + - 9 + - 3 + - 2 + - 3 + - 8 + firstLen: 2 + secondLen: 3 + - name: mixed-20 + in: + nums: + - 1 + - 8 + - 6 + - 2 + - 5 + - 4 + - 8 + - 3 + - 7 + firstLen: 3 + secondLen: 3 + - name: mixed-21 + in: + nums: + - 10 + - 20 + - 30 + - 40 + - 50 + - 60 + - 70 + - 80 + firstLen: 1 + secondLen: 4 + - name: mixed-22 + in: + nums: + - 80 + - 70 + - 60 + - 50 + - 40 + - 30 + - 20 + - 10 + firstLen: 4 + secondLen: 1 diff --git a/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.cpp b/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.cpp new file mode 100644 index 00000000..4928ad02 --- /dev/null +++ b/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.cpp @@ -0,0 +1,22 @@ +class Solution { +public: + int maxSumTwoNoOverlap(vector& nums, int firstLen, int secondLen) { + return max(solve(nums, firstLen, secondLen), solve(nums, secondLen, firstLen)); + } + +private: + int solve(const vector& nums, int firstLen, int secondLen) { + int n = nums.size(); + vector prefix(n + 1, 0); + for (int i = 0; i < n; i++) { + prefix[i + 1] = prefix[i] + nums[i]; + } + int bestA = prefix[firstLen]; + int ans = 0; + for (int end = firstLen + secondLen; end <= n; end++) { + bestA = max(bestA, prefix[end - secondLen] - prefix[end - secondLen - firstLen]); + ans = max(ans, bestA + prefix[end] - prefix[end - secondLen]); + } + return ans; + } +}; diff --git a/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.cs b/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.cs new file mode 100644 index 00000000..010760da --- /dev/null +++ b/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.cs @@ -0,0 +1,20 @@ +public class Solution { + public int MaxSumTwoNoOverlap(int[] nums, int firstLen, int secondLen) { + return System.Math.Max(Solve(nums, firstLen, secondLen), Solve(nums, secondLen, firstLen)); + } + + private int Solve(int[] nums, int firstLen, int secondLen) { + int n = nums.Length; + int[] prefix = new int[n + 1]; + for (int i = 0; i < n; i++) { + prefix[i + 1] = prefix[i] + nums[i]; + } + int bestA = prefix[firstLen]; + int ans = 0; + for (int end = firstLen + secondLen; end <= n; end++) { + bestA = System.Math.Max(bestA, prefix[end - secondLen] - prefix[end - secondLen - firstLen]); + ans = System.Math.Max(ans, bestA + prefix[end] - prefix[end - secondLen]); + } + return ans; + } +} diff --git a/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.dart b/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.dart new file mode 100644 index 00000000..e0739cbc --- /dev/null +++ b/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.dart @@ -0,0 +1,25 @@ +class Solution { + int maxSumTwoNoOverlap(List nums, int firstLen, int secondLen) { + final a = _solve(nums, firstLen, secondLen); + final b = _solve(nums, secondLen, firstLen); + return a >= b ? a : b; + } + + int _solve(List nums, int firstLen, int secondLen) { + final n = nums.length; + final prefix = List.filled(n + 1, 0); + for (int i = 0; i < n; i++) { + prefix[i + 1] = prefix[i] + nums[i]; + } + var bestA = prefix[firstLen]; + var ans = 0; + for (int end = firstLen + secondLen; end <= n; end++) { + bestA = bestA > prefix[end - secondLen] - prefix[end - secondLen - firstLen] + ? bestA + : prefix[end - secondLen] - prefix[end - secondLen - firstLen]; + final cur = bestA + prefix[end] - prefix[end - secondLen]; + if (cur > ans) ans = cur; + } + return ans; + } +} diff --git a/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.go b/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.go new file mode 100644 index 00000000..e2be44cc --- /dev/null +++ b/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.go @@ -0,0 +1,18 @@ +func maxSumTwoNoOverlap(nums []int, firstLen int, secondLen int) int { + return max(solve1031(nums, firstLen, secondLen), solve1031(nums, secondLen, firstLen)) +} + +func solve1031(nums []int, firstLen int, secondLen int) int { + n := len(nums) + prefix := make([]int, n+1) + for i := 0; i < n; i++ { + prefix[i+1] = prefix[i] + nums[i] + } + bestA := prefix[firstLen] + ans := 0 + for end := firstLen + secondLen; end <= n; end++ { + bestA = max(bestA, prefix[end-secondLen]-prefix[end-secondLen-firstLen]) + ans = max(ans, bestA+prefix[end]-prefix[end-secondLen]) + } + return ans +} diff --git a/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.java b/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.java new file mode 100644 index 00000000..6e560cea --- /dev/null +++ b/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.java @@ -0,0 +1,20 @@ +class Solution { + public int maxSumTwoNoOverlap(int[] nums, int firstLen, int secondLen) { + return Math.max(solve(nums, firstLen, secondLen), solve(nums, secondLen, firstLen)); + } + + private int solve(int[] nums, int firstLen, int secondLen) { + int n = nums.length; + int[] prefix = new int[n + 1]; + for (int i = 0; i < n; i++) { + prefix[i + 1] = prefix[i] + nums[i]; + } + int bestA = prefix[firstLen]; + int ans = 0; + for (int end = firstLen + secondLen; end <= n; end++) { + bestA = Math.max(bestA, prefix[end - secondLen] - prefix[end - secondLen - firstLen]); + ans = Math.max(ans, bestA + prefix[end] - prefix[end - secondLen]); + } + return ans; + } +} diff --git a/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.kt b/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.kt new file mode 100644 index 00000000..1e9c2a62 --- /dev/null +++ b/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.kt @@ -0,0 +1,20 @@ +class Solution { + fun maxSumTwoNoOverlap(nums: IntArray, firstLen: Int, secondLen: Int): Int { + return maxOf(solve(nums, firstLen, secondLen), solve(nums, secondLen, firstLen)) + } + + private fun solve(nums: IntArray, firstLen: Int, secondLen: Int): Int { + val n = nums.size + val prefix = IntArray(n + 1) + for (i in 0 until n) { + prefix[i + 1] = prefix[i] + nums[i] + } + var bestA = prefix[firstLen] + var ans = 0 + for (end in firstLen + secondLen..n) { + bestA = maxOf(bestA, prefix[end - secondLen] - prefix[end - secondLen - firstLen]) + ans = maxOf(ans, bestA + prefix[end] - prefix[end - secondLen]) + } + return ans + } +} diff --git a/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.py b/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.py new file mode 100644 index 00000000..c1b63cd5 --- /dev/null +++ b/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.py @@ -0,0 +1,18 @@ +from typing import List + + +class Solution: + def maxSumTwoNoOverlap(self, nums: List[int], firstLen: int, secondLen: int) -> int: + def solve(a: int, b: int) -> int: + n = len(nums) + prefix = [0] * (n + 1) + for i in range(n): + prefix[i + 1] = prefix[i] + nums[i] + best_a = prefix[a] + ans = 0 + for end in range(a + b, n + 1): + best_a = max(best_a, prefix[end - b] - prefix[end - b - a]) + ans = max(ans, best_a + prefix[end] - prefix[end - b]) + return ans + + return max(solve(firstLen, secondLen), solve(secondLen, firstLen)) diff --git a/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.py2 b/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.py2 new file mode 100644 index 00000000..749cc271 --- /dev/null +++ b/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.py2 @@ -0,0 +1,15 @@ +class Solution(object): + def maxSumTwoNoOverlap(self, nums, firstLen, secondLen): + def solve(a, b): + n = len(nums) + prefix = [0] * (n + 1) + for i in range(n): + prefix[i + 1] = prefix[i] + nums[i] + best_a = prefix[a] + ans = 0 + for end in range(a + b, n + 1): + best_a = max(best_a, prefix[end - b] - prefix[end - b - a]) + ans = max(ans, best_a + prefix[end] - prefix[end - b]) + return ans + + return max(solve(firstLen, secondLen), solve(secondLen, firstLen)) diff --git a/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.rb b/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.rb new file mode 100644 index 00000000..64f54ba8 --- /dev/null +++ b/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.rb @@ -0,0 +1,20 @@ +# @param {Integer[]} nums +# @param {Integer} first_len +# @param {Integer} second_len +# @return {Integer} +def max_sum_two_no_overlap(nums, first_len, second_len) + solve = lambda do |a, b| + n = nums.length + prefix = Array.new(n + 1, 0) + (0...n).each { |i| prefix[i + 1] = prefix[i] + nums[i] } + best_a = prefix[a] + ans = 0 + (a + b..n).each do |end_idx| + best_a = [best_a, prefix[end_idx - b] - prefix[end_idx - b - a]].max + ans = [ans, best_a + prefix[end_idx] - prefix[end_idx - b]].max + end + ans + end + + [solve.call(first_len, second_len), solve.call(second_len, first_len)].max +end diff --git a/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.rs b/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.rs new file mode 100644 index 00000000..d2533ee9 --- /dev/null +++ b/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.rs @@ -0,0 +1,23 @@ +impl Solution { + pub fn max_sum_two_no_overlap(nums: Vec, first_len: i32, second_len: i32) -> i32 { + std::cmp::max( + solve(&nums, first_len as usize, second_len as usize), + solve(&nums, second_len as usize, first_len as usize), + ) + } +} + +fn solve(nums: &Vec, first_len: usize, second_len: usize) -> i32 { + let n = nums.len(); + let mut prefix = vec![0; n + 1]; + for i in 0..n { + prefix[i + 1] = prefix[i] + nums[i]; + } + let mut best_a = prefix[first_len]; + let mut ans = 0; + for end in first_len + second_len..=n { + best_a = std::cmp::max(best_a, prefix[end - second_len] - prefix[end - second_len - first_len]); + ans = std::cmp::max(ans, best_a + prefix[end] - prefix[end - second_len]); + } + ans +} diff --git a/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.swift b/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.swift new file mode 100644 index 00000000..4d3af39e --- /dev/null +++ b/tests/1001-1500/1031. maximum-sum-of-two-non-overlapping-subarrays/sol.swift @@ -0,0 +1,22 @@ +class Solution { + func maxSumTwoNoOverlap(_ nums: [Int], _ firstLen: Int, _ secondLen: Int) -> Int { + return max(solve(nums, firstLen, secondLen), solve(nums, secondLen, firstLen)) + } + + private func solve(_ nums: [Int], _ firstLen: Int, _ secondLen: Int) -> Int { + let n = nums.count + var prefix = [Int](repeating: 0, count: n + 1) + for i in 0.. numMovesStones(int a, int b, int c) { + vector stones = {a, b, c}; + sort(stones.begin(), stones.end()); + int x = stones[0], y = stones[1], z = stones[2]; + int minMove; + if (z - x == 2) { + minMove = 0; + } else if (y - x <= 2 || z - y <= 2) { + minMove = 1; + } else { + minMove = 2; + } + int maxMove = z - x - 2; + return {minMove, maxMove}; + } +}; diff --git a/tests/1001-1500/1033. moving-stones-until-consecutive/sol.cs b/tests/1001-1500/1033. moving-stones-until-consecutive/sol.cs new file mode 100644 index 00000000..d342ee14 --- /dev/null +++ b/tests/1001-1500/1033. moving-stones-until-consecutive/sol.cs @@ -0,0 +1,17 @@ +public class Solution { + public int[] NumMovesStones(int a, int b, int c) { + int[] stones = new int[] { a, b, c }; + System.Array.Sort(stones); + int x = stones[0], y = stones[1], z = stones[2]; + int minMove; + if (z - x == 2) { + minMove = 0; + } else if (y - x <= 2 || z - y <= 2) { + minMove = 1; + } else { + minMove = 2; + } + int maxMove = z - x - 2; + return new int[] { minMove, maxMove }; + } +} diff --git a/tests/1001-1500/1033. moving-stones-until-consecutive/sol.dart b/tests/1001-1500/1033. moving-stones-until-consecutive/sol.dart new file mode 100644 index 00000000..694ce5e4 --- /dev/null +++ b/tests/1001-1500/1033. moving-stones-until-consecutive/sol.dart @@ -0,0 +1,17 @@ +class Solution { + List numMovesStones(int a, int b, int c) { + var stones = [a, b, c]; + stones.sort(); + int x = stones[0], y = stones[1], z = stones[2]; + int minMove; + if (z - x == 2) { + minMove = 0; + } else if (y - x <= 2 || z - y <= 2) { + minMove = 1; + } else { + minMove = 2; + } + int maxMove = z - x - 2; + return [minMove, maxMove]; + } +} diff --git a/tests/1001-1500/1033. moving-stones-until-consecutive/sol.go b/tests/1001-1500/1033. moving-stones-until-consecutive/sol.go new file mode 100644 index 00000000..5ef87834 --- /dev/null +++ b/tests/1001-1500/1033. moving-stones-until-consecutive/sol.go @@ -0,0 +1,15 @@ +func numMovesStones(a int, b int, c int) []int { + stones := []int{a, b, c} + sort.Ints(stones) + x, y, z := stones[0], stones[1], stones[2] + minMove := 0 + if z-x == 2 { + minMove = 0 + } else if y-x <= 2 || z-y <= 2 { + minMove = 1 + } else { + minMove = 2 + } + maxMove := z - x - 2 + return []int{minMove, maxMove} +} diff --git a/tests/1001-1500/1033. moving-stones-until-consecutive/sol.java b/tests/1001-1500/1033. moving-stones-until-consecutive/sol.java new file mode 100644 index 00000000..b1404dc4 --- /dev/null +++ b/tests/1001-1500/1033. moving-stones-until-consecutive/sol.java @@ -0,0 +1,17 @@ +class Solution { + public int[] numMovesStones(int a, int b, int c) { + int[] stones = new int[]{a, b, c}; + java.util.Arrays.sort(stones); + int x = stones[0], y = stones[1], z = stones[2]; + int minMove; + if (z - x == 2) { + minMove = 0; + } else if (y - x <= 2 || z - y <= 2) { + minMove = 1; + } else { + minMove = 2; + } + int maxMove = z - x - 2; + return new int[]{minMove, maxMove}; + } +} diff --git a/tests/1001-1500/1033. moving-stones-until-consecutive/sol.kt b/tests/1001-1500/1033. moving-stones-until-consecutive/sol.kt new file mode 100644 index 00000000..63a81c9b --- /dev/null +++ b/tests/1001-1500/1033. moving-stones-until-consecutive/sol.kt @@ -0,0 +1,16 @@ +class Solution { + fun numMovesStones(a: Int, b: Int, c: Int): IntArray { + val stones = intArrayOf(a, b, c) + stones.sort() + val x = stones[0] + val y = stones[1] + val z = stones[2] + val minMove = when { + z - x == 2 -> 0 + y - x <= 2 || z - y <= 2 -> 1 + else -> 2 + } + val maxMove = z - x - 2 + return intArrayOf(minMove, maxMove) + } +} diff --git a/tests/1001-1500/1033. moving-stones-until-consecutive/sol.py b/tests/1001-1500/1033. moving-stones-until-consecutive/sol.py new file mode 100644 index 00000000..8887e14c --- /dev/null +++ b/tests/1001-1500/1033. moving-stones-until-consecutive/sol.py @@ -0,0 +1,12 @@ +class Solution(object): + def numMovesStones(self, a, b, c): + """ + :type a: int + :type b: int + :type c: int + :rtype: List[int] + """ + x, y, z = sorted([a, b, c]) + min_move = 0 if z - x == 2 else (1 if y - x <= 2 or z - y <= 2 else 2) + max_move = z - x - 2 + return [min_move, max_move] diff --git a/tests/1001-1500/1033. moving-stones-until-consecutive/sol.py2 b/tests/1001-1500/1033. moving-stones-until-consecutive/sol.py2 new file mode 100644 index 00000000..9df6c3b3 --- /dev/null +++ b/tests/1001-1500/1033. moving-stones-until-consecutive/sol.py2 @@ -0,0 +1,12 @@ +class Solution(object): + def numMovesStones(self, a, b, c): + """ + :type a: int + :type b: int + :type c: int + :rtype: List[int] + """ + x, y, z = sorted([a, b, c]) + min_move = 0 if z - x == 2 else (1 if y - x <= 2 or z - y <= 2 else 2) + max_move = (z - x - 2) + return [min_move, max_move] diff --git a/tests/1001-1500/1033. moving-stones-until-consecutive/sol.rb b/tests/1001-1500/1033. moving-stones-until-consecutive/sol.rb new file mode 100644 index 00000000..1b02ceee --- /dev/null +++ b/tests/1001-1500/1033. moving-stones-until-consecutive/sol.rb @@ -0,0 +1,16 @@ +# @param {Integer} a +# @param {Integer} b +# @param {Integer} c +# @return {Integer[]} +def num_moves_stones(a, b, c) + x, y, z = [a, b, c].sort + min_move = if z - x == 2 + 0 + elsif y - x <= 2 || z - y <= 2 + 1 + else + 2 + end + max_move = z - x - 2 + [min_move, max_move] +end diff --git a/tests/1001-1500/1033. moving-stones-until-consecutive/sol.rs b/tests/1001-1500/1033. moving-stones-until-consecutive/sol.rs new file mode 100644 index 00000000..ddffc955 --- /dev/null +++ b/tests/1001-1500/1033. moving-stones-until-consecutive/sol.rs @@ -0,0 +1,18 @@ +impl Solution { + pub fn num_moves_stones(a: i32, b: i32, c: i32) -> Vec { + let mut stones = vec![a, b, c]; + stones.sort(); + let x = stones[0]; + let y = stones[1]; + let z = stones[2]; + let min_move = if z - x == 2 { + 0 + } else if y - x <= 2 || z - y <= 2 { + 1 + } else { + 2 + }; + let max_move = z - x - 2; + vec![min_move, max_move] + } +} diff --git a/tests/1001-1500/1033. moving-stones-until-consecutive/sol.swift b/tests/1001-1500/1033. moving-stones-until-consecutive/sol.swift new file mode 100644 index 00000000..44693641 --- /dev/null +++ b/tests/1001-1500/1033. moving-stones-until-consecutive/sol.swift @@ -0,0 +1,16 @@ +class Solution { + func numMovesStones(_ a: Int, _ b: Int, _ c: Int) -> [Int] { + let stones = [a, b, c].sorted() + let x = stones[0], y = stones[1], z = stones[2] + let minMove: Int + if z - x == 2 { + minMove = 0 + } else if y - x <= 2 || z - y <= 2 { + minMove = 1 + } else { + minMove = 2 + } + let maxMove = z - x - 2 + return [minMove, maxMove] + } +} diff --git a/tests/1001-1500/1033. moving-stones-until-consecutive/sol.ts b/tests/1001-1500/1033. moving-stones-until-consecutive/sol.ts new file mode 100644 index 00000000..f0190512 --- /dev/null +++ b/tests/1001-1500/1033. moving-stones-until-consecutive/sol.ts @@ -0,0 +1,16 @@ +function numMovesStones(a: number, b: number, c: number): number[] { + const stones = [a, b, c].sort((n1, n2) => n1 - n2); + const x = stones[0], + y = stones[1], + z = stones[2]; + let minMove: number; + if (z - x === 2) { + minMove = 0; + } else if (y - x <= 2 || z - y <= 2) { + minMove = 1; + } else { + minMove = 2; + } + const maxMove = z - x - 2; + return [minMove, maxMove]; +} diff --git a/tests/1001-1500/1034. coloring-a-border/manifest.yaml b/tests/1001-1500/1034. coloring-a-border/manifest.yaml new file mode 100644 index 00000000..7a56557c --- /dev/null +++ b/tests/1001-1500/1034. coloring-a-border/manifest.yaml @@ -0,0 +1,831 @@ +entry: + id: 1034 + title: coloring-a-border + params: + grid: + type: array + items: + type: array + items: + type: int + row: + type: int + col: + type: int + color: + type: int + call: + cpp: Solution().colorBorder({grid}, {row}, {col}, {color}) + rust: Solution::color_border({grid}, {row}, {col}, {color}) + python3: Solution().colorBorder({grid}, {row}, {col}, {color}) + python2: Solution().colorBorder({grid}, {row}, {col}, {color}) + ruby: color_border({grid}, {row}, {col}, {color}) + java: new Solution().colorBorder({grid}, {row}, {col}, {color}) + csharp: new Solution().ColorBorder({grid}, {row}, {col}, {color}) + kotlin: Solution().colorBorder({grid}, {row}, {col}, {color}) + go: colorBorder({grid}, {row}, {col}, {color}) + dart: Solution().colorBorder({grid}, {row}, {col}, {color}) + swift: Solution().colorBorder({grid}, {row}, {col}, {color}) + typescript: colorBorder({grid}, {row}, {col}, {color}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check(grid, row, col, color, {result}) + checker: + "from collections import deque\n\nclass Checker:\n def check(self,\ + \ grid, row, col, color, result):\n if not isinstance(result, list):\n\ + \ return False\n exp = [r[:] for r in grid]\n rows,\ + \ cols = len(grid), len(grid[0])\n start = grid[row][col]\n q\ + \ = deque([(row, col)])\n seen = {(row, col)}\n border = []\n\ + \ while q:\n r, c = q.popleft()\n is_border = False\n\ + \ for dr, dc in [(-1, 0), (1, 0), (0, -1), (0, 1)]:\n \ + \ nr, nc = r + dr, c + dc\n if not (0 <= nr < rows and 0\ + \ <= nc < cols):\n is_border = True\n elif\ + \ grid[nr][nc] != start:\n is_border = True\n \ + \ elif (nr, nc) not in seen:\n seen.add((nr, nc))\n \ + \ q.append((nr, nc))\n if is_border:\n \ + \ border.append((r, c))\n for r, c in border:\n exp[r][c]\ + \ = color\n return result == exp\n" +seed: 1034 +tests: + - name: example-1 + in: + grid: + elemType: int + value: + - - 1 + - 1 + - - 1 + - 2 + row: 0 + col: 0 + color: 3 + - name: example-2 + in: + grid: + elemType: int + value: + - - 1 + - 2 + - 2 + - - 2 + - 3 + - 2 + row: 0 + col: 1 + color: 3 + - name: example-3 + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + row: 1 + col: 1 + color: 2 + - name: same-color-noop + in: + grid: + elemType: int + value: + - - 5 + - 5 + - - 5 + - 5 + row: 0 + col: 0 + color: 5 + - name: single-cell + in: + grid: + elemType: int + value: + - - 7 + row: 0 + col: 0 + color: 9 + - name: one-row + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 2 + - 2 + row: 0 + col: 1 + color: 4 + - name: one-column + in: + grid: + elemType: int + value: + - - 1 + - - 1 + - - 2 + - - 2 + row: 1 + col: 0 + color: 6 + - name: corner-component + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 3 + - - 1 + - 2 + - 3 + - - 3 + - 3 + - 3 + row: 0 + col: 0 + color: 9 + - name: edge-component + in: + grid: + elemType: int + value: + - - 2 + - 2 + - 2 + - 2 + - - 2 + - 1 + - 1 + - 2 + - - 2 + - 1 + - 1 + - 2 + row: 1 + col: 1 + color: 8 + - name: center-block + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 1 + - 1 + - - 1 + - 4 + - 4 + - 1 + - - 1 + - 4 + - 4 + - 1 + - - 1 + - 1 + - 1 + - 1 + row: 1 + col: 1 + color: 7 + - name: l-shape + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 2 + - - 1 + - 2 + - 2 + - - 1 + - 2 + - 3 + row: 1 + col: 1 + color: 6 + - name: checkerboard-small + in: + grid: + elemType: int + value: + - - 1 + - 2 + - 1 + - - 2 + - 1 + - 2 + - - 1 + - 2 + - 1 + row: 1 + col: 1 + color: 9 + - name: rectangular-blob + in: + grid: + elemType: int + value: + - - 3 + - 3 + - 3 + - 4 + - - 3 + - 3 + - 3 + - 4 + - - 3 + - 3 + - 3 + - 4 + row: 1 + col: 1 + color: 1 + - name: border-touching + in: + grid: + elemType: int + value: + - - 8 + - 8 + - 8 + - 8 + - 8 + - - 8 + - 7 + - 7 + - 7 + - 8 + - - 8 + - 7 + - 7 + - 7 + - 8 + - - 8 + - 8 + - 8 + - 8 + - 8 + row: 1 + col: 1 + color: 2 + - name: isolated-center + in: + grid: + elemType: int + value: + - - 1 + - 2 + - 3 + - - 4 + - 5 + - 6 + - - 7 + - 8 + - 9 + row: 1 + col: 1 + color: 0 + - name: big-square + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 2 + - 2 + - 2 + - 1 + - - 1 + - 2 + - 2 + - 2 + - 1 + - - 1 + - 2 + - 2 + - 2 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + row: 2 + col: 2 + color: 9 + - name: two-components + in: + grid: + elemType: int + value: + - - 4 + - 4 + - 5 + - 5 + - - 4 + - 4 + - 5 + - 5 + - - 6 + - 6 + - 5 + - 5 + row: 0 + col: 0 + color: 3 + - name: long-strip + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 2 + - 2 + - 2 + - 2 + - 1 + - - 1 + - 2 + - 2 + - 2 + - 2 + - 1 + row: 1 + col: 2 + color: 8 + - name: small-blob + in: + grid: + elemType: int + value: + - - 9 + - 9 + - 9 + - - 9 + - 9 + - 9 + row: 0 + col: 1 + color: 1 + - name: asymmetric-blob + in: + grid: + elemType: int + value: + - - 2 + - 2 + - 2 + - 2 + - - 2 + - 1 + - 1 + - 2 + - - 2 + - 1 + - 2 + - 2 + - - 2 + - 2 + - 2 + - 2 + row: 1 + col: 1 + color: 5 + - name: border-color-repeat + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 1 + - 1 + - - 1 + - 2 + - 2 + - 1 + - - 1 + - 2 + - 2 + - 1 + - - 1 + - 1 + - 1 + - 1 + row: 2 + col: 2 + color: 1 + - name: bigger-square-1 + in: + grid: + elemType: int + value: + - - 6 + - 6 + - 6 + - 6 + - 6 + - 6 + - - 6 + - 3 + - 3 + - 3 + - 3 + - 6 + - - 6 + - 3 + - 3 + - 3 + - 3 + - 6 + - - 6 + - 3 + - 3 + - 3 + - 3 + - 6 + - - 6 + - 3 + - 3 + - 3 + - 3 + - 6 + - - 6 + - 6 + - 6 + - 6 + - 6 + - 6 + row: 2 + col: 2 + color: 8 + - name: bigger-square-2 + in: + grid: + elemType: int + value: + - - 9 + - 9 + - 9 + - 9 + - 9 + - - 9 + - 4 + - 4 + - 4 + - 9 + - - 9 + - 4 + - 4 + - 4 + - 9 + - - 9 + - 4 + - 4 + - 4 + - 9 + - - 9 + - 9 + - 9 + - 9 + - 9 + row: 0 + col: 0 + color: 2 + - name: corner-plus + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 2 + - 2 + - - 1 + - 1 + - 2 + - 2 + - - 3 + - 3 + - 2 + - 2 + - - 3 + - 3 + - 2 + - 2 + row: 0 + col: 0 + color: 7 + - name: corner-minus + in: + grid: + elemType: int + value: + - - 2 + - 2 + - 2 + - - 2 + - 5 + - 5 + - - 2 + - 5 + - 5 + row: 1 + col: 1 + color: 9 + - name: stripe-1 + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 1 + - 1 + - 1 + - - 2 + - 2 + - 2 + - 2 + - 2 + - - 1 + - 1 + - 1 + - 1 + - 1 + row: 1 + col: 2 + color: 4 + - name: stripe-2 + in: + grid: + elemType: int + value: + - - 8 + - 8 + - 8 + - 8 + - - 8 + - 1 + - 1 + - 8 + - - 8 + - 1 + - 1 + - 8 + - - 8 + - 1 + - 1 + - 8 + - - 8 + - 8 + - 8 + - 8 + row: 2 + col: 1 + color: 0 + - name: large-bloc-1 + in: + grid: + elemType: int + value: + - - 1 + - 2 + - 2 + - 2 + - 1 + - - 1 + - 2 + - 2 + - 2 + - 1 + - - 1 + - 2 + - 2 + - 2 + - 1 + - - 1 + - 2 + - 2 + - 2 + - 1 + row: 2 + col: 2 + color: 6 + - name: large-bloc-2 + in: + grid: + elemType: int + value: + - - 3 + - 3 + - 3 + - 3 + - 3 + - 3 + - - 3 + - 7 + - 7 + - 7 + - 7 + - 3 + - - 3 + - 7 + - 7 + - 7 + - 7 + - 3 + - - 3 + - 7 + - 7 + - 7 + - 7 + - 3 + row: 1 + col: 1 + color: 5 + - name: irregular-1 + in: + grid: + elemType: int + value: + - - 5 + - 5 + - 1 + - 1 + - 1 + - - 5 + - 5 + - 1 + - 2 + - 2 + - - 5 + - 5 + - 1 + - 2 + - 2 + - - 5 + - 5 + - 1 + - 1 + - 1 + row: 1 + col: 3 + color: 9 + - name: irregular-2 + in: + grid: + elemType: int + value: + - - 4 + - 4 + - 4 + - 4 + - 4 + - - 4 + - 1 + - 1 + - 1 + - 4 + - - 4 + - 1 + - 2 + - 1 + - 4 + - - 4 + - 1 + - 1 + - 1 + - 4 + - - 4 + - 4 + - 4 + - 4 + - 4 + row: 2 + col: 2 + color: 8 + - name: irregular-3 + in: + grid: + elemType: int + value: + - - 7 + - 7 + - 7 + - - 7 + - 6 + - 7 + - - 7 + - 7 + - 7 + row: 1 + col: 1 + color: 3 + - name: irregular-4 + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 1 + - 1 + - - 1 + - 9 + - 9 + - 1 + - - 1 + - 9 + - 9 + - 1 + - - 1 + - 1 + - 1 + - 1 + row: 1 + col: 1 + color: 2 + - name: irregular-5 + in: + grid: + elemType: int + value: + - - 7 + - 7 + - 7 + - 7 + - - 7 + - 1 + - 1 + - 7 + - - 7 + - 1 + - 1 + - 7 + - - 7 + - 7 + - 7 + - 7 + row: 2 + col: 1 + color: 4 + - name: irregular-6 + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 2 + - 2 + - 2 + - 1 + - - 1 + - 2 + - 3 + - 2 + - 1 + - - 1 + - 2 + - 2 + - 2 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + row: 2 + col: 2 + color: 6 diff --git a/tests/1001-1500/1034. coloring-a-border/sol.cpp b/tests/1001-1500/1034. coloring-a-border/sol.cpp new file mode 100644 index 00000000..b40ab226 --- /dev/null +++ b/tests/1001-1500/1034. coloring-a-border/sol.cpp @@ -0,0 +1,50 @@ +class Solution { +public: + vector> colorBorder(vector>& grid, int row, int col, int color) { + int rows = grid.size(); + int cols = grid[0].size(); + int startColor = grid[row][col]; + + if (startColor == color) { + return grid; + } + + queue> q; + q.push({row, col}); + vector> visited(rows, vector(cols, false)); + visited[row][col] = true; + vector> borders; + + vector> dirs = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}}; + + while (!q.empty()) { + auto [r, c] = q.front(); + q.pop(); + bool isBorder = false; + + for (auto [dr, dc] : dirs) { + int nr = r + dr; + int nc = c + dc; + + if (nr < 0 || nr >= rows || nc < 0 || nc >= cols) { + isBorder = true; + } else if (grid[nr][nc] != startColor) { + isBorder = true; + } else if (!visited[nr][nc]) { + visited[nr][nc] = true; + q.push({nr, nc}); + } + } + + if (isBorder) { + borders.push_back({r, c}); + } + } + + for (auto [r, c] : borders) { + grid[r][c] = color; + } + + return grid; + } +}; diff --git a/tests/1001-1500/1034. coloring-a-border/sol.cs b/tests/1001-1500/1034. coloring-a-border/sol.cs new file mode 100644 index 00000000..1a67384e --- /dev/null +++ b/tests/1001-1500/1034. coloring-a-border/sol.cs @@ -0,0 +1,51 @@ +public class Solution { + public int[][] ColorBorder(int[][] grid, int row, int col, int color) { + int rows = grid.Length; + int cols = grid[0].Length; + int startColor = grid[row][col]; + + if (startColor == color) { + return grid; + } + + Queue<(int, int)> queue = new Queue<(int, int)>(); + queue.Enqueue((row, col)); + bool[][] visited = new bool[rows][]; + for (int i = 0; i < rows; i++) { + visited[i] = new bool[cols]; + } + visited[row][col] = true; + List<(int, int)> borders = new List<(int, int)>(); + + (int, int)[] dirs = { (-1, 0), (1, 0), (0, -1), (0, 1) }; + + while (queue.Count > 0) { + var (r, c) = queue.Dequeue(); + bool isBorder = false; + + foreach (var (dr, dc) in dirs) { + int nr = r + dr; + int nc = c + dc; + + if (nr < 0 || nr >= rows || nc < 0 || nc >= cols) { + isBorder = true; + } else if (grid[nr][nc] != startColor) { + isBorder = true; + } else if (!visited[nr][nc]) { + visited[nr][nc] = true; + queue.Enqueue((nr, nc)); + } + } + + if (isBorder) { + borders.Add((r, c)); + } + } + + foreach (var (r, c) in borders) { + grid[r][c] = color; + } + + return grid; + } +} diff --git a/tests/1001-1500/1034. coloring-a-border/sol.dart b/tests/1001-1500/1034. coloring-a-border/sol.dart new file mode 100644 index 00000000..50834bb9 --- /dev/null +++ b/tests/1001-1500/1034. coloring-a-border/sol.dart @@ -0,0 +1,48 @@ +class Solution { + List> colorBorder(List> grid, int row, int col, int color) { + int rows = grid.length; + int cols = grid[0].length; + int startColor = grid[row][col]; + + if (startColor == color) { + return grid; + } + + List> queue = [[row, col]]; + List> visited = List.generate(rows, (_) => List.filled(cols, false)); + visited[row][col] = true; + List> borders = []; + + List> dirs = [[-1, 0], [1, 0], [0, -1], [0, 1]]; + + while (queue.isNotEmpty) { + List cur = queue.removeAt(0); + int r = cur[0], c = cur[1]; + bool isBorder = false; + + for (var dir in dirs) { + int nr = r + dir[0]; + int nc = c + dir[1]; + + if (nr < 0 || nr >= rows || nc < 0 || nc >= cols) { + isBorder = true; + } else if (grid[nr][nc] != startColor) { + isBorder = true; + } else if (!visited[nr][nc]) { + visited[nr][nc] = true; + queue.add([nr, nc]); + } + } + + if (isBorder) { + borders.add([r, c]); + } + } + + for (var cell in borders) { + grid[cell[0]][cell[1]] = color; + } + + return grid; + } +} diff --git a/tests/1001-1500/1034. coloring-a-border/sol.go b/tests/1001-1500/1034. coloring-a-border/sol.go new file mode 100644 index 00000000..bfbc7abf --- /dev/null +++ b/tests/1001-1500/1034. coloring-a-border/sol.go @@ -0,0 +1,49 @@ +func colorBorder(grid [][]int, row int, col int, color int) [][]int { + rows := len(grid) + cols := len(grid[0]) + startColor := grid[row][col] + + if startColor == color { + return grid + } + + queue := [][]int{{row, col}} + visited := make([][]bool, rows) + for i := range visited { + visited[i] = make([]bool, cols) + } + visited[row][col] = true + borders := [][]int{} + + dirs := [][]int{{-1, 0}, {1, 0}, {0, -1}, {0, 1}} + + for len(queue) > 0 { + cur := queue[0] + queue = queue[1:] + r, c := cur[0], cur[1] + isBorder := false + + for _, dir := range dirs { + nr, nc := r + dir[0], c + dir[1] + + if nr < 0 || nr >= rows || nc < 0 || nc >= cols { + isBorder = true + } else if grid[nr][nc] != startColor { + isBorder = true + } else if !visited[nr][nc] { + visited[nr][nc] = true + queue = append(queue, []int{nr, nc}) + } + } + + if isBorder { + borders = append(borders, []int{r, c}) + } + } + + for _, cell := range borders { + grid[cell[0]][cell[1]] = color + } + + return grid +} diff --git a/tests/1001-1500/1034. coloring-a-border/sol.java b/tests/1001-1500/1034. coloring-a-border/sol.java new file mode 100644 index 00000000..ea940f3f --- /dev/null +++ b/tests/1001-1500/1034. coloring-a-border/sol.java @@ -0,0 +1,49 @@ +class Solution { + public int[][] colorBorder(int[][] grid, int row, int col, int color) { + int rows = grid.length; + int cols = grid[0].length; + int startColor = grid[row][col]; + + if (startColor == color) { + return grid; + } + + java.util.Queue queue = new java.util.LinkedList<>(); + queue.offer(new int[]{row, col}); + boolean[][] visited = new boolean[rows][cols]; + visited[row][col] = true; + java.util.List borders = new java.util.ArrayList<>(); + + int[][] dirs = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}}; + + while (!queue.isEmpty()) { + int[] cur = queue.poll(); + int r = cur[0], c = cur[1]; + boolean isBorder = false; + + for (int[] dir : dirs) { + int nr = r + dir[0]; + int nc = c + dir[1]; + + if (nr < 0 || nr >= rows || nc < 0 || nc >= cols) { + isBorder = true; + } else if (grid[nr][nc] != startColor) { + isBorder = true; + } else if (!visited[nr][nc]) { + visited[nr][nc] = true; + queue.offer(new int[]{nr, nc}); + } + } + + if (isBorder) { + borders.add(new int[]{r, c}); + } + } + + for (int[] cell : borders) { + grid[cell[0]][cell[1]] = color; + } + + return grid; + } +} diff --git a/tests/1001-1500/1034. coloring-a-border/sol.kt b/tests/1001-1500/1034. coloring-a-border/sol.kt new file mode 100644 index 00000000..4ad5a5d0 --- /dev/null +++ b/tests/1001-1500/1034. coloring-a-border/sol.kt @@ -0,0 +1,50 @@ +class Solution { + fun colorBorder(grid: Array, row: Int, col: Int, color: Int): Array { + val rows = grid.size + val cols = grid[0].size + val startColor = grid[row][col] + + if (startColor == color) { + return grid + } + + val queue = java.util.LinkedList() + queue.offer(intArrayOf(row, col)) + val visited = Array(rows) { BooleanArray(cols) } + visited[row][col] = true + val borders = mutableListOf() + + val dirs = arrayOf(intArrayOf(-1, 0), intArrayOf(1, 0), intArrayOf(0, -1), intArrayOf(0, 1)) + + while (queue.isNotEmpty()) { + val cur = queue.poll() + val r = cur[0] + val c = cur[1] + var isBorder = false + + for (dir in dirs) { + val nr = r + dir[0] + val nc = c + dir[1] + + if (nr !in 0 until rows || nc !in 0 until cols) { + isBorder = true + } else if (grid[nr][nc] != startColor) { + isBorder = true + } else if (!visited[nr][nc]) { + visited[nr][nc] = true + queue.offer(intArrayOf(nr, nc)) + } + } + + if (isBorder) { + borders.add(intArrayOf(r, c)) + } + } + + for (cell in borders) { + grid[cell[0]][cell[1]] = color + } + + return grid + } +} diff --git a/tests/1001-1500/1034. coloring-a-border/sol.py b/tests/1001-1500/1034. coloring-a-border/sol.py new file mode 100644 index 00000000..1532b221 --- /dev/null +++ b/tests/1001-1500/1034. coloring-a-border/sol.py @@ -0,0 +1,44 @@ +from collections import deque + + +class Solution(object): + def colorBorder(self, grid, row, col, color): + rows, cols = len(grid), len(grid[0]) + start_color = grid[row][col] + + # If the target color is the same as the start, no work needed + if start_color == color: + return grid + + queue = deque([(row, col)]) + visited = {(row, col)} + borders = [] + + while queue: + r, c = queue.popleft() + is_border = False + + # Check the 4-direction neighbors: Up, Down, Left, Right + for dr, dc in [(-1, 0), (1, 0), (0, -1), (0, 1)]: + nr, nc = r + dr, c + dc + + # Condition 1: If it hits the edge of the grid, it's a border cell + if not (0 <= nr < rows and 0 <= nc < cols): + is_border = True + # Condition 2: If the neighbor has a different color, it's a border cell + elif grid[nr][nc] != start_color: + is_border = True + # Otherwise, it's the same color; if not visited, keep exploring + elif (nr, nc) not in visited: + visited.add((nr, nc)) + queue.append((nr, nc)) + + # If any neighbor triggered a border condition, save this cell + if is_border: + borders.append((r, c)) + + # Final Step: Flip the colors for the identified border cells + for r, c in borders: + grid[r][c] = color + + return grid diff --git a/tests/1001-1500/1034. coloring-a-border/sol.py2 b/tests/1001-1500/1034. coloring-a-border/sol.py2 new file mode 100644 index 00000000..44d36de8 --- /dev/null +++ b/tests/1001-1500/1034. coloring-a-border/sol.py2 @@ -0,0 +1,34 @@ +class Solution(object): + def colorBorder(self, grid, row, col, color): + rows, cols = len(grid), len(grid[0]) + start_color = grid[row][col] + + if start_color == color: + return grid + + queue = [(row, col)] + visited = {(row, col)} + borders = [] + + while queue: + r, c = queue.pop(0) + is_border = False + + for dr, dc in [(-1, 0), (1, 0), (0, -1), (0, 1)]: + nr, nc = r + dr, c + dc + + if not (0 <= nr < rows and 0 <= nc < cols): + is_border = True + elif grid[nr][nc] != start_color: + is_border = True + elif (nr, nc) not in visited: + visited.add((nr, nc)) + queue.append((nr, nc)) + + if is_border: + borders.append((r, c)) + + for r, c in borders: + grid[r][c] = color + + return grid diff --git a/tests/1001-1500/1034. coloring-a-border/sol.rb b/tests/1001-1500/1034. coloring-a-border/sol.rb new file mode 100644 index 00000000..06be061d --- /dev/null +++ b/tests/1001-1500/1034. coloring-a-border/sol.rb @@ -0,0 +1,43 @@ +# @param {Integer[][]} grid +# @param {Integer} row +# @param {Integer} col +# @param {Integer} color +# @return {Integer[][]} +def color_border(grid, row, col, color) + rows = grid.length + cols = grid[0].length + start_color = grid[row][col] + + return grid if start_color == color + + queue = [[row, col]] + visited = { [row, col] => true } + borders = [] + + while !queue.empty? + r, c = queue.shift + is_border = false + + [[-1, 0], [1, 0], [0, -1], [0, 1]].each do |dr, dc| + nr = r + dr + nc = c + dc + + if !(0 <= nr && nr < rows && 0 <= nc && nc < cols) + is_border = true + elsif grid[nr][nc] != start_color + is_border = true + elsif !visited.key?([nr, nc]) + visited[[nr, nc]] = true + queue << [nr, nc] + end + end + + borders << [r, c] if is_border + end + + borders.each do |r, c| + grid[r][c] = color + end + + grid +end diff --git a/tests/1001-1500/1034. coloring-a-border/sol.rs b/tests/1001-1500/1034. coloring-a-border/sol.rs new file mode 100644 index 00000000..32da14d1 --- /dev/null +++ b/tests/1001-1500/1034. coloring-a-border/sol.rs @@ -0,0 +1,48 @@ +impl Solution { + pub fn color_border(grid: Vec>, row: i32, col: i32, color: i32) -> Vec> { + let mut grid = grid; + let rows = grid.len(); + let cols = grid[0].len(); + let start_color = grid[row as usize][col as usize]; + + if start_color == color { + return grid; + } + + let mut queue = std::collections::VecDeque::new(); + queue.push_back((row as usize, col as usize)); + let mut visited = vec![vec![false; cols]; rows]; + visited[row as usize][col as usize] = true; + let mut borders = Vec::new(); + + let dirs = [(-1, 0), (1, 0), (0, -1), (0, 1)]; + + while let Some((r, c)) = queue.pop_front() { + let mut is_border = false; + + for (dr, dc) in dirs.iter() { + let nr = r as i32 + dr; + let nc = c as i32 + dc; + + if nr < 0 || nr >= rows as i32 || nc < 0 || nc >= cols as i32 { + is_border = true; + } else if grid[nr as usize][nc as usize] != start_color { + is_border = true; + } else if !visited[nr as usize][nc as usize] { + visited[nr as usize][nc as usize] = true; + queue.push_back((nr as usize, nc as usize)); + } + } + + if is_border { + borders.push((r, c)); + } + } + + for (r, c) in borders { + grid[r][c] = color; + } + + grid + } +} diff --git a/tests/1001-1500/1034. coloring-a-border/sol.swift b/tests/1001-1500/1034. coloring-a-border/sol.swift new file mode 100644 index 00000000..be4fc97e --- /dev/null +++ b/tests/1001-1500/1034. coloring-a-border/sol.swift @@ -0,0 +1,48 @@ +class Solution { + func colorBorder(_ grid: [[Int]], _ row: Int, _ col: Int, _ color: Int) -> [[Int]] { + var grid = grid + let rows = grid.count + let cols = grid[0].count + let startColor = grid[row][col] + + if startColor == color { + return grid + } + + var queue: [(Int, Int)] = [(row, col)] + var visited = Array(repeating: Array(repeating: false, count: cols), count: rows) + visited[row][col] = true + var borders: [(Int, Int)] = [] + + let dirs = [(-1, 0), (1, 0), (0, -1), (0, 1)] + + while !queue.isEmpty { + let (r, c) = queue.removeFirst() + var isBorder = false + + for (dr, dc) in dirs { + let nr = r + dr + let nc = c + dc + + if nr < 0 || nr >= rows || nc < 0 || nc >= cols { + isBorder = true + } else if grid[nr][nc] != startColor { + isBorder = true + } else if !visited[nr][nc] { + visited[nr][nc] = true + queue.append((nr, nc)) + } + } + + if isBorder { + borders.append((r, c)) + } + } + + for (r, c) in borders { + grid[r][c] = color + } + + return grid + } +} diff --git a/tests/1001-1500/1034. coloring-a-border/sol.ts b/tests/1001-1500/1034. coloring-a-border/sol.ts new file mode 100644 index 00000000..b29e4c06 --- /dev/null +++ b/tests/1001-1500/1034. coloring-a-border/sol.ts @@ -0,0 +1,57 @@ +function colorBorder( + grid: number[][], + row: number, + col: number, + color: number, +): number[][] { + const rows = grid.length; + const cols = grid[0].length; + const startColor = grid[row][col]; + + if (startColor === color) { + return grid; + } + + const queue: [number, number][] = [[row, col]]; + const visited: boolean[][] = Array.from({ length: rows }, () => + Array(cols).fill(false), + ); + visited[row][col] = true; + const borders: [number, number][] = []; + + const dirs = [ + [-1, 0], + [1, 0], + [0, -1], + [0, 1], + ]; + + while (queue.length > 0) { + const [r, c] = queue.shift()!; + let isBorder = false; + + for (const [dr, dc] of dirs) { + const nr = r + dr; + const nc = c + dc; + + if (nr < 0 || nr >= rows || nc < 0 || nc >= cols) { + isBorder = true; + } else if (grid[nr][nc] !== startColor) { + isBorder = true; + } else if (!visited[nr][nc]) { + visited[nr][nc] = true; + queue.push([nr, nc]); + } + } + + if (isBorder) { + borders.push([r, c]); + } + } + + for (const [r, c] of borders) { + grid[r][c] = color; + } + + return grid; +} diff --git a/tests/1001-1500/1035. uncrossed-lines/manifest.yaml b/tests/1001-1500/1035. uncrossed-lines/manifest.yaml new file mode 100644 index 00000000..9fbc44cc --- /dev/null +++ b/tests/1001-1500/1035. uncrossed-lines/manifest.yaml @@ -0,0 +1,499 @@ +entry: + id: 1035 + title: uncrossed-lines + params: + nums1: + type: array + items: + type: int + nums2: + type: array + items: + type: int + call: + cpp: "Solution().maxUncrossedLines({nums1}, {nums2})" + rust: "Solution::max_uncrossed_lines({nums1}, {nums2})" + python3: "Solution().maxUncrossedLines({nums1}, {nums2})" + python2: "Solution().maxUncrossedLines({nums1}, {nums2})" + ruby: "max_uncrossed_lines({nums1}, {nums2})" + java: "new Solution().maxUncrossedLines({nums1}, {nums2})" + csharp: "new Solution().MaxUncrossedLines({nums1}, {nums2})" + kotlin: "Solution().maxUncrossedLines({nums1}, {nums2})" + go: "maxUncrossedLines({nums1}, {nums2})" + dart: "Solution().maxUncrossedLines({nums1}, {nums2})" + swift: "Solution().maxUncrossedLines({nums1}, {nums2})" + typescript: "maxUncrossedLines({nums1}, {nums2})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().maxUncrossedLines(nums1, nums2, {result})" + checker: | + class Checker: + def maxUncrossedLines(self, nums1, nums2, result): + m = len(nums1) + n = len(nums2) + dp = [[0] * (n + 1) for _ in range(m + 1)] + for i in range(1, m + 1): + a = nums1[i - 1] + for j in range(1, n + 1): + if a == nums2[j - 1]: + dp[i][j] = dp[i - 1][j - 1] + 1 + else: + dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + return dp[m][n] == result +seed: 1035 +tests: + - name: ex1 + in: + nums1: [1, 4, 2] + nums2: [1, 2, 4] + - name: ex2 + in: + nums1: [2, 5, 1, 2, 5] + nums2: [10, 5, 2, 1, 5, 2] + - name: ex3 + in: + nums1: [1, 3, 7, 1, 7, 5] + nums2: [1, 9, 2, 5, 1] + - name: both_single_match + in: + nums1: [1] + nums2: [1] + - name: both_single_diff + in: + nums1: [1] + nums2: [2] + - name: small_equal + in: + nums1: [1, 2] + nums2: [1, 2] + - name: reverse_pair + in: + nums1: [1, 2] + nums2: [2, 1] + - name: repeated_short + in: + nums1: [1, 1, 1] + nums2: [1, 1] + - name: reverse_longer + in: + nums1: [1, 2, 3, 4] + nums2: [4, 3, 2, 1] + - name: shifted_overlap + in: + nums1: [2, 7, 8, 3] + nums2: [5, 2, 8, 7, 3] + - name: interleaved_small + in: + nums1: [1, 3, 4, 1, 2, 8] + nums2: [3, 4, 1, 2, 1, 8] + - name: identical_three + in: + nums1: [1, 2, 3] + nums2: [1, 2, 3] + - name: opposite_three + in: + nums1: [1, 2, 3] + nums2: [3, 2, 1] + - name: repeated_blocks + in: + nums1: [1, 3, 1, 3, 1] + nums2: [1, 1, 3, 3, 1] + - name: disjoint_small + in: + nums1: [5, 6, 7, 8] + nums2: [9, 10, 11, 12] + - name: prefix_subsequence + in: + nums1: [2, 4, 6, 8, 10] + nums2: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + - name: alternating_a + in: + nums1: [1, 2, 1, 2, 1, 2] + nums2: [2, 1, 2, 1, 2, 1] + - name: mixed_order + in: + nums1: [1, 4, 2, 3] + nums2: [4, 1, 3, 2] + - name: duplicated_cross + in: + nums1: [1, 2, 3, 2, 1] + nums2: [1, 3, 2, 1, 2] + - name: generated_01 + in: + nums1: + gen: array + len: 8 + of: + gen: int + min: 1 + max: 10 + distinct: false + sorted: false + elemType: int + nums2: + gen: array + len: 9 + of: + gen: int + min: 1 + max: 10 + distinct: false + sorted: false + elemType: int + - name: generated_02 + in: + nums1: + gen: array + len: 12 + of: + gen: int + min: 1 + max: 15 + distinct: false + sorted: false + elemType: int + nums2: + gen: array + len: 11 + of: + gen: int + min: 1 + max: 15 + distinct: false + sorted: false + elemType: int + - name: generated_03 + in: + nums1: + gen: array + len: 15 + of: + gen: int + min: 1 + max: 20 + distinct: false + sorted: false + elemType: int + nums2: + gen: array + len: 13 + of: + gen: int + min: 1 + max: 20 + distinct: false + sorted: false + elemType: int + - name: generated_04 + in: + nums1: + gen: array + len: 20 + of: + gen: int + min: 1 + max: 25 + distinct: false + sorted: false + elemType: int + nums2: + gen: array + len: 18 + of: + gen: int + min: 1 + max: 25 + distinct: false + sorted: false + elemType: int + - name: generated_05 + in: + nums1: + gen: array + len: 25 + of: + gen: int + min: 1 + max: 30 + distinct: false + sorted: false + elemType: int + nums2: + gen: array + len: 22 + of: + gen: int + min: 1 + max: 30 + distinct: false + sorted: false + elemType: int + - name: generated_06 + in: + nums1: + gen: array + len: 30 + of: + gen: int + min: 1 + max: 35 + distinct: false + sorted: false + elemType: int + nums2: + gen: array + len: 27 + of: + gen: int + min: 1 + max: 35 + distinct: false + sorted: false + elemType: int + - name: generated_07 + in: + nums1: + gen: array + len: 35 + of: + gen: int + min: 1 + max: 40 + distinct: false + sorted: false + elemType: int + nums2: + gen: array + len: 32 + of: + gen: int + min: 1 + max: 40 + distinct: false + sorted: false + elemType: int + - name: generated_08 + in: + nums1: + gen: array + len: 40 + of: + gen: int + min: 1 + max: 45 + distinct: false + sorted: false + elemType: int + nums2: + gen: array + len: 37 + of: + gen: int + min: 1 + max: 45 + distinct: false + sorted: false + elemType: int + - name: generated_09 + in: + nums1: + gen: array + len: 50 + of: + gen: int + min: 1 + max: 50 + distinct: false + sorted: false + elemType: int + nums2: + gen: array + len: 48 + of: + gen: int + min: 1 + max: 50 + distinct: false + sorted: false + elemType: int + - name: generated_10 + in: + nums1: + gen: array + len: 60 + of: + gen: int + min: 1 + max: 60 + distinct: false + sorted: false + elemType: int + nums2: + gen: array + len: 55 + of: + gen: int + min: 1 + max: 60 + distinct: false + sorted: false + elemType: int + - name: generated_11 + in: + nums1: + gen: array + len: 75 + of: + gen: int + min: 1 + max: 70 + distinct: false + sorted: false + elemType: int + nums2: + gen: array + len: 70 + of: + gen: int + min: 1 + max: 70 + distinct: false + sorted: false + elemType: int + - name: generated_12 + in: + nums1: + gen: array + len: 90 + of: + gen: int + min: 1 + max: 80 + distinct: false + sorted: false + elemType: int + nums2: + gen: array + len: 85 + of: + gen: int + min: 1 + max: 80 + distinct: false + sorted: false + elemType: int + - name: generated_13 + in: + nums1: + gen: array + len: 120 + of: + gen: int + min: 1 + max: 100 + distinct: false + sorted: false + elemType: int + nums2: + gen: array + len: 110 + of: + gen: int + min: 1 + max: 100 + distinct: false + sorted: false + elemType: int + - name: large_all_same + in: + nums1: + gen: array + len: 500 + of: + gen: int + min: 1 + max: 1 + distinct: false + sorted: false + elemType: int + nums2: + gen: array + len: 500 + of: + gen: int + min: 1 + max: 1 + distinct: false + sorted: false + elemType: int + - name: large_increasing_shifted + in: + nums1: + gen: array + len: 500 + of: + gen: int + min: 1 + max: 500 + distinct: true + sorted: true + elemType: int + nums2: + gen: array + len: 500 + of: + gen: int + min: 250 + max: 749 + distinct: true + sorted: true + elemType: int + - name: large_decreasing_vs_increasing + in: + nums1: + gen: array + len: 500 + of: + gen: int + min: 1 + max: 500 + distinct: true + sorted: true + elemType: int + nums2: + gen: array + len: 500 + of: + gen: int + min: 1 + max: 500 + distinct: true + sorted: true + elemType: int + - name: large_alternating + in: + nums1: + gen: array + len: 500 + of: + gen: int + min: 1 + max: 2 + distinct: false + sorted: false + elemType: int + nums2: + gen: array + len: 500 + of: + gen: int + min: 1 + max: 2 + distinct: false + sorted: false + elemType: int diff --git a/tests/1001-1500/1035. uncrossed-lines/sol.cpp b/tests/1001-1500/1035. uncrossed-lines/sol.cpp new file mode 100644 index 00000000..4cf6f7e6 --- /dev/null +++ b/tests/1001-1500/1035. uncrossed-lines/sol.cpp @@ -0,0 +1,18 @@ +class Solution { +public: + int maxUncrossedLines(vector& nums1, vector& nums2) { + int m = nums1.size(); + int n = nums2.size(); + vector> dp(m + 1, vector(n + 1, 0)); + for (int i = 1; i <= m; i++) { + for (int j = 1; j <= n; j++) { + if (nums1[i - 1] == nums2[j - 1]) { + dp[i][j] = 1 + dp[i - 1][j - 1]; + } else { + dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]); + } + } + } + return dp[m][n]; + } +}; diff --git a/tests/1001-1500/1035. uncrossed-lines/sol.cs b/tests/1001-1500/1035. uncrossed-lines/sol.cs new file mode 100644 index 00000000..ca7bfd05 --- /dev/null +++ b/tests/1001-1500/1035. uncrossed-lines/sol.cs @@ -0,0 +1,17 @@ +public class Solution { + public int MaxUncrossedLines(int[] nums1, int[] nums2) { + int m = nums1.Length; + int n = nums2.Length; + int[,] dp = new int[m + 1, n + 1]; + for (int i = 1; i <= m; i++) { + for (int j = 1; j <= n; j++) { + if (nums1[i - 1] == nums2[j - 1]) { + dp[i, j] = 1 + dp[i - 1, j - 1]; + } else { + dp[i, j] = Math.Max(dp[i - 1, j], dp[i, j - 1]); + } + } + } + return dp[m, n]; + } +} diff --git a/tests/1001-1500/1035. uncrossed-lines/sol.dart b/tests/1001-1500/1035. uncrossed-lines/sol.dart new file mode 100644 index 00000000..f7085a3f --- /dev/null +++ b/tests/1001-1500/1035. uncrossed-lines/sol.dart @@ -0,0 +1,17 @@ +class Solution { + int maxUncrossedLines(List nums1, List nums2) { + int m = nums1.length; + int n = nums2.length; + List> dp = List.generate(m + 1, (_) => List.filled(n + 1, 0)); + for (int i = 1; i <= m; i++) { + for (int j = 1; j <= n; j++) { + if (nums1[i - 1] == nums2[j - 1]) { + dp[i][j] = 1 + dp[i - 1][j - 1]; + } else { + dp[i][j] = dp[i - 1][j] > dp[i][j - 1] ? dp[i - 1][j] : dp[i][j - 1]; + } + } + } + return dp[m][n]; + } +} diff --git a/tests/1001-1500/1035. uncrossed-lines/sol.go b/tests/1001-1500/1035. uncrossed-lines/sol.go new file mode 100644 index 00000000..51df6907 --- /dev/null +++ b/tests/1001-1500/1035. uncrossed-lines/sol.go @@ -0,0 +1,22 @@ +func maxUncrossedLines(nums1 []int, nums2 []int) int { + m := len(nums1) + n := len(nums2) + dp := make([][]int, m+1) + for i := range dp { + dp[i] = make([]int, n+1) + } + for i := 1; i <= m; i++ { + for j := 1; j <= n; j++ { + if nums1[i-1] == nums2[j-1] { + dp[i][j] = 1 + dp[i-1][j-1] + } else { + if dp[i-1][j] > dp[i][j-1] { + dp[i][j] = dp[i-1][j] + } else { + dp[i][j] = dp[i][j-1] + } + } + } + } + return dp[m][n] +} diff --git a/tests/1001-1500/1035. uncrossed-lines/sol.java b/tests/1001-1500/1035. uncrossed-lines/sol.java new file mode 100644 index 00000000..9db3c70d --- /dev/null +++ b/tests/1001-1500/1035. uncrossed-lines/sol.java @@ -0,0 +1,17 @@ +class Solution { + public int maxUncrossedLines(int[] nums1, int[] nums2) { + int m = nums1.length; + int n = nums2.length; + int[][] dp = new int[m + 1][n + 1]; + for (int i = 1; i <= m; i++) { + for (int j = 1; j <= n; j++) { + if (nums1[i - 1] == nums2[j - 1]) { + dp[i][j] = 1 + dp[i - 1][j - 1]; + } else { + dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]); + } + } + } + return dp[m][n]; + } +} diff --git a/tests/1001-1500/1035. uncrossed-lines/sol.kt b/tests/1001-1500/1035. uncrossed-lines/sol.kt new file mode 100644 index 00000000..57a66bce --- /dev/null +++ b/tests/1001-1500/1035. uncrossed-lines/sol.kt @@ -0,0 +1,17 @@ +class Solution { + fun maxUncrossedLines(nums1: IntArray, nums2: IntArray): Int { + val m = nums1.size + val n = nums2.size + val dp = Array(m + 1) { IntArray(n + 1) } + for (i in 1..m) { + for (j in 1..n) { + if (nums1[i - 1] == nums2[j - 1]) { + dp[i][j] = 1 + dp[i - 1][j - 1] + } else { + dp[i][j] = maxOf(dp[i - 1][j], dp[i][j - 1]) + } + } + } + return dp[m][n] + } +} diff --git a/tests/1001-1500/1035. uncrossed-lines/sol.py b/tests/1001-1500/1035. uncrossed-lines/sol.py new file mode 100644 index 00000000..b8ec937c --- /dev/null +++ b/tests/1001-1500/1035. uncrossed-lines/sol.py @@ -0,0 +1,17 @@ +class Solution: + def maxUncrossedLines(self, nums1: List[int], nums2: List[int]) -> int: + + m = len(nums1) + n = len(nums2) + + dp = [[0] * (n + 1) for _ in range(m + 1)] + + for i in range(1, m + 1): + for j in range(1, n + 1): + if nums1[i - 1] == nums2[j - 1]: + dp[i][j] = 1 + dp[i - 1][j - 1] + + else: + dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + + return dp[m][n] diff --git a/tests/1001-1500/1035. uncrossed-lines/sol.py2 b/tests/1001-1500/1035. uncrossed-lines/sol.py2 new file mode 100644 index 00000000..e2a13c84 --- /dev/null +++ b/tests/1001-1500/1035. uncrossed-lines/sol.py2 @@ -0,0 +1,17 @@ +class Solution(object): + def maxUncrossedLines(self, nums1, nums2): + """ + :type nums1: List[int] + :type nums2: List[int] + :rtype: int + """ + m = len(nums1) + n = len(nums2) + dp = [[0] * (n + 1) for _ in range(m + 1)] + for i in range(1, m + 1): + for j in range(1, n + 1): + if nums1[i - 1] == nums2[j - 1]: + dp[i][j] = 1 + dp[i - 1][j - 1] + else: + dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + return dp[m][n] diff --git a/tests/1001-1500/1035. uncrossed-lines/sol.rb b/tests/1001-1500/1035. uncrossed-lines/sol.rb new file mode 100644 index 00000000..19110b13 --- /dev/null +++ b/tests/1001-1500/1035. uncrossed-lines/sol.rb @@ -0,0 +1,18 @@ +# @param {Integer[]} nums1 +# @param {Integer[]} nums2 +# @return {Integer} +def max_uncrossed_lines(nums1, nums2) + m = nums1.length + n = nums2.length + dp = Array.new(m + 1) { Array.new(n + 1, 0) } + (1..m).each do |i| + (1..n).each do |j| + if nums1[i - 1] == nums2[j - 1] + dp[i][j] = 1 + dp[i - 1][j - 1] + else + dp[i][j] = [dp[i - 1][j], dp[i][j - 1]].max + end + end + end + dp[m][n] +end diff --git a/tests/1001-1500/1035. uncrossed-lines/sol.rs b/tests/1001-1500/1035. uncrossed-lines/sol.rs new file mode 100644 index 00000000..1b727ea8 --- /dev/null +++ b/tests/1001-1500/1035. uncrossed-lines/sol.rs @@ -0,0 +1,17 @@ +impl Solution { + pub fn max_uncrossed_lines(nums1: Vec, nums2: Vec) -> i32 { + let m = nums1.len(); + let n = nums2.len(); + let mut dp = vec![vec![0; n + 1]; m + 1]; + for i in 1..=m { + for j in 1..=n { + if nums1[i - 1] == nums2[j - 1] { + dp[i][j] = 1 + dp[i - 1][j - 1]; + } else { + dp[i][j] = dp[i - 1][j].max(dp[i][j - 1]); + } + } + } + dp[m][n] + } +} diff --git a/tests/1001-1500/1035. uncrossed-lines/sol.swift b/tests/1001-1500/1035. uncrossed-lines/sol.swift new file mode 100644 index 00000000..e54de24f --- /dev/null +++ b/tests/1001-1500/1035. uncrossed-lines/sol.swift @@ -0,0 +1,17 @@ +class Solution { + func maxUncrossedLines(_ nums1: [Int], _ nums2: [Int]) -> Int { + let m = nums1.count + let n = nums2.count + var dp = Array(repeating: Array(repeating: 0, count: n + 1), count: m + 1) + for i in 1...m { + for j in 1...n { + if nums1[i - 1] == nums2[j - 1] { + dp[i][j] = 1 + dp[i - 1][j - 1] + } else { + dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + } + } + } + return dp[m][n] + } +} diff --git a/tests/1001-1500/1035. uncrossed-lines/sol.ts b/tests/1001-1500/1035. uncrossed-lines/sol.ts new file mode 100644 index 00000000..ececbdb8 --- /dev/null +++ b/tests/1001-1500/1035. uncrossed-lines/sol.ts @@ -0,0 +1,17 @@ +function maxUncrossedLines(nums1: number[], nums2: number[]): number { + const m = nums1.length; + const n = nums2.length; + const dp: number[][] = Array.from({ length: m + 1 }, () => + Array(n + 1).fill(0), + ); + for (let i = 1; i <= m; i++) { + for (let j = 1; j <= n; j++) { + if (nums1[i - 1] === nums2[j - 1]) { + dp[i][j] = 1 + dp[i - 1][j - 1]; + } else { + dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]); + } + } + } + return dp[m][n]; +} diff --git a/tests/1001-1500/1036. escape-a-large-maze/manifest.yaml b/tests/1001-1500/1036. escape-a-large-maze/manifest.yaml new file mode 100644 index 00000000..059087ec --- /dev/null +++ b/tests/1001-1500/1036. escape-a-large-maze/manifest.yaml @@ -0,0 +1,353 @@ +entry: + id: 1036 + title: escape-a-large-maze + params: + blocked: + type: array + items: + type: array + items: + type: int + source: + type: array + items: + type: int + target: + type: array + items: + type: int + call: + cpp: "Solution().isEscapePossible({blocked}, {source}, {target})" + rust: "Solution::is_escape_possible({blocked}, {source}, {target})" + python3: "Solution().isEscapePossible({blocked}, {source}, {target})" + python2: "Solution().isEscapePossible({blocked}, {source}, {target})" + ruby: "is_escape_possible({blocked}, {source}, {target})" + java: "new Solution().isEscapePossible({blocked}, {source}, {target})" + csharp: "new Solution().IsEscapePossible({blocked}, {source}, {target})" + kotlin: "Solution().isEscapePossible({blocked}, {source}, {target})" + go: "isEscapePossible({blocked}, {source}, {target})" + dart: "Solution().isEscapePossible({blocked}, {source}, {target})" + swift: "Solution().isEscapePossible({blocked}, {source}, {target})" + typescript: "isEscapePossible({blocked}, {source}, {target})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().isEscapePossible(blocked, source, target, {result})" + checker: | + from collections import deque + + class Checker: + def isEscapePossible(self, blocked, source, target, result): + blocked_set = {tuple(p) for p in blocked} + limit = len(blocked) * len(blocked) // 2 + + def bfs(start, end): + start = tuple(start) + end = tuple(end) + q = deque([start]) + seen = {start} + explored = 0 + while q: + x, y = q.popleft() + if (x, y) == end: + return True + if explored > limit: + return True + for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)): + nx = x + dx + ny = y + dy + if 0 <= nx < 10 ** 6 and 0 <= ny < 10 ** 6: + pos = (nx, ny) + if pos not in seen and pos not in blocked_set: + seen.add(pos) + q.append(pos) + explored += 1 + return False + + expected = bfs(source, target) and bfs(target, source) + return expected == result +seed: 1036 +tests: + - name: ex1 + in: + blocked: + - [0, 1] + - [1, 0] + source: [0, 0] + target: [0, 2] + - name: ex2 + in: + blocked: [] + source: [0, 0] + target: [999999, 999999] + - name: no_blocks_near_origin + in: + blocked: [] + source: [12, 34] + target: [56, 78] + - name: one_wall_two_cells + in: + blocked: + - [1, 0] + - [1, 1] + source: [0, 0] + target: [2, 0] + - name: three_block_corner + in: + blocked: + - [0, 1] + - [1, 0] + - [1, 1] + source: [0, 0] + target: [2, 2] + - name: open_path_small + in: + blocked: + - [1, 1] + source: [0, 0] + target: [2, 2] + - name: target_adjacent + in: + blocked: + - [2, 1] + - [1, 2] + source: [0, 0] + target: [2, 2] + - name: source_corner_far + in: + blocked: + - [0, 1] + - [1, 1] + - [1, 0] + source: [0, 0] + target: [3, 3] + - name: straight_line_clear + in: + blocked: + - [2, 2] + - [3, 3] + source: [0, 0] + target: [4, 4] + - name: sparse_blocks + in: + blocked: + - [10, 10] + - [20, 20] + - [30, 30] + source: [5, 5] + target: [40, 40] + - name: sparse_near_source + in: + blocked: + - [6, 5] + - [5, 6] + - [6, 6] + source: [5, 5] + target: [7, 7] + - name: sparse_near_target + in: + blocked: + - [98, 98] + - [98, 99] + - [99, 98] + source: [0, 0] + target: [99, 99] + - name: corridor_left_open + in: + blocked: + - [1, 1] + - [1, 2] + - [1, 3] + - [2, 3] + source: [0, 0] + target: [3, 3] + - name: corridor_right_open + in: + blocked: + - [0, 1] + - [0, 2] + - [1, 2] + - [2, 2] + source: [0, 0] + target: [3, 0] + - name: diagonal_fence + in: + blocked: + - [1, 1] + - [2, 2] + - [3, 3] + - [4, 4] + source: [0, 0] + target: [5, 5] + - name: zigzag_blocks + in: + blocked: + - [2, 1] + - [2, 2] + - [3, 2] + - [4, 2] + source: [1, 1] + target: [5, 3] + - name: boxed_target + in: + blocked: + - [8, 9] + - [9, 8] + - [9, 10] + - [10, 9] + source: [0, 0] + target: [9, 9] + - name: boxed_source + in: + blocked: + - [0, 1] + - [1, 0] + - [1, 1] + - [0, 2] + - [2, 0] + source: [0, 0] + target: [3, 3] + - name: long_open_walk + in: + blocked: + - [100, 100] + - [200, 200] + source: [10, 10] + target: [999990, 999990] + - name: far_apart_clear + in: + blocked: + - [123, 456] + - [456, 123] + source: [1, 999998] + target: [999998, 1] + - name: blocked_far_away + in: + blocked: + - [400000, 400000] + - [400001, 400000] + - [400000, 400001] + source: [2, 2] + target: [999997, 999997] + - name: open_edge_travel + in: + blocked: + - [1, 999998] + - [2, 999998] + source: [0, 999999] + target: [999999, 999999] + - name: open_top_boundary + in: + blocked: + - [500000, 500000] + - [500001, 500000] + source: [0, 999999] + target: [999999, 999998] + - name: open_bottom_boundary + in: + blocked: + - [2, 2] + - [2, 3] + source: [0, 0] + target: [999999, 0] + - name: open_left_boundary + in: + blocked: + - [2, 2] + - [3, 2] + source: [0, 0] + target: [0, 999999] + - name: open_right_boundary + in: + blocked: + - [999998, 2] + - [999998, 3] + source: [999999, 0] + target: [999999, 999999] + - name: medium_wall + in: + blocked: + - [10, 11] + - [11, 11] + - [12, 11] + - [13, 11] + - [14, 11] + - [15, 11] + source: [10, 10] + target: [16, 12] + - name: medium_gap + in: + blocked: + - [20, 20] + - [21, 20] + - [22, 20] + - [23, 20] + - [24, 20] + - [25, 20] + - [26, 20] + source: [19, 19] + target: [27, 21] + - name: snake + in: + blocked: + - [5, 1] + - [5, 2] + - [5, 3] + - [4, 3] + - [3, 3] + source: [0, 0] + target: [6, 4] + - name: near_blocked_target + in: + blocked: + - [50, 49] + - [49, 50] + - [51, 50] + - [50, 51] + source: [0, 0] + target: [50, 50] + - name: near_blocked_source + in: + blocked: + - [1, 0] + - [0, 1] + - [1, 1] + source: [0, 0] + target: [2, 2] + - name: sparse_large_target + in: + blocked: + - [12345, 54321] + - [54321, 12345] + - [22222, 33333] + source: [100, 100] + target: [999900, 999901] + - name: sparse_large_source + in: + blocked: + - [999900, 999900] + - [999901, 999900] + - [999900, 999901] + source: [100, 100] + target: [999899, 999899] + - name: isolated_pair + in: + blocked: + - [2, 1] + - [2, 2] + - [2, 3] + - [3, 2] + source: [1, 2] + target: [4, 2] + - name: open_all_the_way + in: + blocked: + - [100, 0] + - [100, 1] + - [100, 2] + source: [0, 0] + target: [999999, 999999] diff --git a/tests/1001-1500/1036. escape-a-large-maze/sol.cpp b/tests/1001-1500/1036. escape-a-large-maze/sol.cpp new file mode 100644 index 00000000..97efbfaf --- /dev/null +++ b/tests/1001-1500/1036. escape-a-large-maze/sol.cpp @@ -0,0 +1,41 @@ +class Solution { +public: + bool isEscapePossible(vector>& blocked, vector& source, vector& target) { + set> blockedSet; + for (auto& b : blocked) { + blockedSet.insert({b[0], b[1]}); + } + int MAX = blocked.size() * blocked.size() / 2; + vector> dirs = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}}; + + auto bfs = [&](vector& start, vector& end) -> bool { + set> visited; + queue> q; + q.push({start[0], start[1]}); + visited.insert({start[0], start[1]}); + int count = 0; + + while (!q.empty()) { + auto [x, y] = q.front(); q.pop(); + if (x == end[0] && y == end[1]) return true; + if (count > MAX) return true; + + for (auto& [dx, dy] : dirs) { + int nx = x + dx; + int ny = y + dy; + if (nx >= 0 && nx < 1000000 && ny >= 0 && ny < 1000000) { + auto key = make_pair(nx, ny); + if (!visited.count(key) && !blockedSet.count(key)) { + visited.insert(key); + q.push(key); + } + } + } + count++; + } + return false; + }; + + return bfs(source, target) && bfs(target, source); + } +}; diff --git a/tests/1001-1500/1036. escape-a-large-maze/sol.cs b/tests/1001-1500/1036. escape-a-large-maze/sol.cs new file mode 100644 index 00000000..99350022 --- /dev/null +++ b/tests/1001-1500/1036. escape-a-large-maze/sol.cs @@ -0,0 +1,40 @@ +public class Solution { + public bool IsEscapePossible(int[][] blocked, int[] source, int[] target) { + var blockedSet = new HashSet<(int, int)>(); + foreach (var b in blocked) { + blockedSet.Add((b[0], b[1])); + } + int MAX = blocked.Length * blocked.Length / 2; + var dirs = new (int, int)[] { (-1, 0), (1, 0), (0, -1), (0, 1) }; + + bool Bfs(int[] start, int[] end) { + var visited = new HashSet<(int, int)>(); + var queue = new Queue<(int, int)>(); + queue.Enqueue((start[0], start[1])); + visited.Add((start[0], start[1])); + int count = 0; + + while (queue.Count > 0) { + var (x, y) = queue.Dequeue(); + if (x == end[0] && y == end[1]) return true; + if (count > MAX) return true; + + foreach (var (dx, dy) in dirs) { + int nx = x + dx; + int ny = y + dy; + if (nx >= 0 && nx < 1000000 && ny >= 0 && ny < 1000000) { + var key = (nx, ny); + if (!visited.Contains(key) && !blockedSet.Contains(key)) { + visited.Add(key); + queue.Enqueue(key); + } + } + } + count++; + } + return false; + } + + return Bfs(source, target) && Bfs(target, source); + } +} diff --git a/tests/1001-1500/1036. escape-a-large-maze/sol.dart b/tests/1001-1500/1036. escape-a-large-maze/sol.dart new file mode 100644 index 00000000..fadc297a --- /dev/null +++ b/tests/1001-1500/1036. escape-a-large-maze/sol.dart @@ -0,0 +1,36 @@ +class Solution { + bool isEscapePossible(List> blocked, List source, List target) { + var blockedSet = blocked.map((b) => '${b[0]},${b[1]}').toSet(); + int MAX = blocked.length * blocked.length ~/ 2; + var dirs = [[-1, 0], [1, 0], [0, -1], [0, 1]]; + + bool bfs(List start, List end) { + var visited = {}; + var queue = >[]; + queue.add(start); + visited.add('${start[0]},${start[1]}'); + int count = 0; + + while (queue.isNotEmpty) { + var cur = queue.removeAt(0); + int x = cur[0], y = cur[1]; + if (x == end[0] && y == end[1]) return true; + if (count > MAX) return true; + + for (var dir in dirs) { + int nx = x + dir[0]; + int ny = y + dir[1]; + var key = '$nx,$ny'; + if (nx >= 0 && nx < 1000000 && ny >= 0 && ny < 1000000 && !visited.contains(key) && !blockedSet.contains(key)) { + visited.add(key); + queue.add([nx, ny]); + } + } + count++; + } + return false; + } + + return bfs(source, target) && bfs(target, source); + } +} diff --git a/tests/1001-1500/1036. escape-a-large-maze/sol.go b/tests/1001-1500/1036. escape-a-large-maze/sol.go new file mode 100644 index 00000000..a1745238 --- /dev/null +++ b/tests/1001-1500/1036. escape-a-large-maze/sol.go @@ -0,0 +1,40 @@ +func isEscapePossible(blocked [][]int, source []int, target []int) bool { + blockedSet := make(map[[2]int]bool) + for _, b := range blocked { + blockedSet[[2]int{b[0], b[1]}] = true + } + MAX := len(blocked) * len(blocked) / 2 + dirs := [][2]int{{-1, 0}, {1, 0}, {0, -1}, {0, 1}} + + bfs := func(start, end []int) bool { + visited := make(map[[2]int]bool) + queue := [][2]int{{start[0], start[1]}} + visited[[2]int{start[0], start[1]}] = true + count := 0 + + for len(queue) > 0 { + cur := queue[0] + queue = queue[1:] + x, y := cur[0], cur[1] + if x == end[0] && y == end[1] { + return true + } + if count > MAX { + return true + } + + for _, dir := range dirs { + nx, ny := x+dir[0], y+dir[1] + key := [2]int{nx, ny} + if nx >= 0 && nx < 1000000 && ny >= 0 && ny < 1000000 && !visited[key] && !blockedSet[key] { + visited[key] = true + queue = append(queue, key) + } + } + count++ + } + return false + } + + return bfs(source, target) && bfs(target, source) +} diff --git a/tests/1001-1500/1036. escape-a-large-maze/sol.java b/tests/1001-1500/1036. escape-a-large-maze/sol.java new file mode 100644 index 00000000..4551ff7f --- /dev/null +++ b/tests/1001-1500/1036. escape-a-large-maze/sol.java @@ -0,0 +1,39 @@ +class Solution { + public boolean isEscapePossible(int[][] blocked, int[] source, int[] target) { + Set blockedSet = new HashSet<>(); + for (int[] b : blocked) { + blockedSet.add(b[0] + "," + b[1]); + } + int MAX = blocked.length * (blocked.length / 2 + 1); + int[][] dirs = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}}; + + return bfs(source, target, blockedSet, MAX, dirs) && bfs(target, source, blockedSet, MAX, dirs); + } + + private boolean bfs(int[] start, int[] end, Set blockedSet, int MAX, int[][] dirs) { + Set visited = new HashSet<>(); + Queue queue = new LinkedList<>(); + queue.offer(start); + visited.add(start[0] + "," + start[1]); + int count = 0; + + while (!queue.isEmpty()) { + int[] cur = queue.poll(); + int x = cur[0], y = cur[1]; + if (x == end[0] && y == end[1]) return true; + if (count > MAX) return true; + + for (int[] dir : dirs) { + int nx = x + dir[0]; + int ny = y + dir[1]; + String key = nx + "," + ny; + if (nx >= 0 && nx < 1000000 && ny >= 0 && ny < 1000000 && !visited.contains(key) && !blockedSet.contains(key)) { + visited.add(key); + queue.offer(new int[]{nx, ny}); + } + } + count++; + } + return false; + } +} diff --git a/tests/1001-1500/1036. escape-a-large-maze/sol.kt b/tests/1001-1500/1036. escape-a-large-maze/sol.kt new file mode 100644 index 00000000..85c3e5cf --- /dev/null +++ b/tests/1001-1500/1036. escape-a-large-maze/sol.kt @@ -0,0 +1,37 @@ +class Solution { + fun isEscapePossible(blocked: Array, source: IntArray, target: IntArray): Boolean { + val blockedSet = blocked.map { "${it[0]},${it[1]}" }.toHashSet() + val MAX = blocked.size * blocked.size / 2 + val dirs = arrayOf(intArrayOf(-1, 0), intArrayOf(1, 0), intArrayOf(0, -1), intArrayOf(0, 1)) + + fun bfs(start: IntArray, end: IntArray): Boolean { + val visited = HashSet() + val queue = ArrayDeque() + queue.add(start) + visited.add("${start[0]},${start[1]}") + var count = 0 + + while (queue.isNotEmpty()) { + val cur = queue.removeFirst() + val x = cur[0] + val y = cur[1] + if (x == end[0] && y == end[1]) return true + if (count > MAX) return true + + for (dir in dirs) { + val nx = x + dir[0] + val ny = y + dir[1] + val key = "$nx,$ny" + if (nx in 0 until 1000000 && ny in 0 until 1000000 && key !in visited && key !in blockedSet) { + visited.add(key) + queue.add(intArrayOf(nx, ny)) + } + } + count++ + } + return false + } + + return bfs(source, target) && bfs(target, source) + } +} diff --git a/tests/1001-1500/1036. escape-a-large-maze/sol.py b/tests/1001-1500/1036. escape-a-large-maze/sol.py new file mode 100644 index 00000000..37c02e43 --- /dev/null +++ b/tests/1001-1500/1036. escape-a-large-maze/sol.py @@ -0,0 +1,36 @@ +from collections import deque + + +class Solution: + def isEscapePossible(self, blocked, source, target): + BLOCKED = set(map(tuple, blocked)) + MAX = len(blocked) * len(blocked) + + def bfs(start, end): + visited = set() + queue = deque([tuple(start)]) + visited.add(tuple(start)) + count = 0 + + while queue: + x, y = queue.popleft() + if [x, y] == end: + return True + if count > MAX: + return True + + for dx, dy in [(-1, 0), (1, 0), (0, -1), (0, 1)]: + nx, ny = x + dx, y + dy + if ( + 0 <= nx < 10**6 + and 0 <= ny < 10**6 + and (nx, ny) not in visited + and (nx, ny) not in BLOCKED + ): + visited.add((nx, ny)) + queue.append((nx, ny)) + count += 1 + + return False + + return bfs(source, target) and bfs(target, source) diff --git a/tests/1001-1500/1036. escape-a-large-maze/sol.py2 b/tests/1001-1500/1036. escape-a-large-maze/sol.py2 new file mode 100644 index 00000000..4d55fe63 --- /dev/null +++ b/tests/1001-1500/1036. escape-a-large-maze/sol.py2 @@ -0,0 +1,34 @@ +class Solution(object): + def isEscapePossible(self, blocked, source, target): + """ + :type blocked: List[List[int]] + :type source: List[int] + :type target: List[int] + :rtype: bool + """ + BLOCKED = set(map(tuple, blocked)) + MAX = len(blocked) * len(blocked) + + def bfs(start, end): + visited = set() + queue = [tuple(start)] + visited.add(tuple(start)) + count = 0 + + while queue: + x, y = queue.pop(0) + if [x, y] == end: + return True + if count > MAX: + return True + + for dx, dy in [(-1,0),(1,0),(0,-1),(0,1)]: + nx, ny = x + dx, y + dy + if 0 <= nx < 10**6 and 0 <= ny < 10**6 and (nx, ny) not in visited and (nx, ny) not in BLOCKED: + visited.add((nx, ny)) + queue.append((nx, ny)) + count += 1 + + return False + + return bfs(source, target) and bfs(target, source) diff --git a/tests/1001-1500/1036. escape-a-large-maze/sol.rb b/tests/1001-1500/1036. escape-a-large-maze/sol.rb new file mode 100644 index 00000000..2fa62347 --- /dev/null +++ b/tests/1001-1500/1036. escape-a-large-maze/sol.rb @@ -0,0 +1,35 @@ +# @param {Integer[][]} blocked +# @param {Integer[]} source +# @param {Integer[]} target +# @return {Boolean} +def is_escape_possible(blocked, source, target) + blocked_set = blocked.map { |b| [b[0], b[1]] }.to_set + max = blocked.length * blocked.length + + bfs = lambda do |start, finish| + visited = Set.new + queue = [start] + visited.add(start) + count = 0 + + while !queue.empty? + x, y = queue.shift + return true if [x, y] == finish + return true if count > max + + [[-1, 0], [1, 0], [0, -1], [0, 1]].each do |dx, dy| + nx = x + dx + ny = y + dy + if nx >= 0 && nx < 10**6 && ny >= 0 && ny < 10**6 && !visited.include?([nx, ny]) && !blocked_set.include?([nx, ny]) + visited.add([nx, ny]) + queue.push([nx, ny]) + end + end + count += 1 + end + + false + end + + bfs.call(source, target) && bfs.call(target, source) +end diff --git a/tests/1001-1500/1036. escape-a-large-maze/sol.rs b/tests/1001-1500/1036. escape-a-large-maze/sol.rs new file mode 100644 index 00000000..ef66f8a1 --- /dev/null +++ b/tests/1001-1500/1036. escape-a-large-maze/sol.rs @@ -0,0 +1,51 @@ +impl Solution { + pub fn is_escape_possible(blocked: Vec>, source: Vec, target: Vec) -> bool { + use std::collections::{HashSet, VecDeque}; + + let blocked_set: HashSet<(i32, i32)> = blocked.iter().map(|b| (b[0], b[1])).collect(); + let max = blocked.len() * blocked.len() / 2; + let dirs = [(-1, 0), (1, 0), (0, -1), (0, 1)]; + + fn bfs( + start: (i32, i32), + end: (i32, i32), + blocked_set: &HashSet<(i32, i32)>, + max: usize, + dirs: &[(i32, i32)], + ) -> bool { + let mut visited = HashSet::new(); + let mut queue = VecDeque::new(); + queue.push_back(start); + visited.insert(start); + let mut count = 0; + + while let Some((x, y)) = queue.pop_front() { + if (x, y) == end { + return true; + } + if count > max { + return true; + } + + for &(dx, dy) in dirs { + let nx = x + dx; + let ny = y + dy; + if nx >= 0 && nx < 1_000_000 && ny >= 0 && ny < 1_000_000 { + let key = (nx, ny); + if !visited.contains(&key) && !blocked_set.contains(&key) { + visited.insert(key); + queue.push_back(key); + } + } + } + count += 1; + } + false + } + + let start = (source[0], source[1]); + let end = (target[0], target[1]); + + bfs(start, end, &blocked_set, max, &dirs) && bfs(end, start, &blocked_set, max, &dirs) + } +} diff --git a/tests/1001-1500/1036. escape-a-large-maze/sol.swift b/tests/1001-1500/1036. escape-a-large-maze/sol.swift new file mode 100644 index 00000000..94516945 --- /dev/null +++ b/tests/1001-1500/1036. escape-a-large-maze/sol.swift @@ -0,0 +1,35 @@ +class Solution { + func isEscapePossible(_ blocked: [[Int]], _ source: [Int], _ target: [Int]) -> Bool { + let blockedSet = Set(blocked.map { [$0[0], $0[1]] }) + let MAX = blocked.count * blocked.count / 2 + let dirs = [(-1, 0), (1, 0), (0, -1), (0, 1)] + + func bfs(_ start: [Int], _ end: [Int]) -> Bool { + var visited = Set<[Int]>() + var queue = [start] + visited.insert(start) + var count = 0 + + while !queue.isEmpty { + let cur = queue.removeFirst() + let x = cur[0], y = cur[1] + if x == end[0] && y == end[1] { return true } + if count > MAX { return true } + + for (dx, dy) in dirs { + let nx = x + dx + let ny = y + dy + let key = [nx, ny] + if nx >= 0 && nx < 1_000_000 && ny >= 0 && ny < 1_000_000 && !visited.contains(key) && !blockedSet.contains(key) { + visited.insert(key) + queue.append(key) + } + } + count += 1 + } + return false + } + + return bfs(source, target) && bfs(target, source) + } +} diff --git a/tests/1001-1500/1036. escape-a-large-maze/sol.ts b/tests/1001-1500/1036. escape-a-large-maze/sol.ts new file mode 100644 index 00000000..1fd194f4 --- /dev/null +++ b/tests/1001-1500/1036. escape-a-large-maze/sol.ts @@ -0,0 +1,50 @@ +function isEscapePossible( + blocked: number[][], + source: number[], + target: number[], +): boolean { + const blockedSet = new Set(blocked.map((b) => `${b[0]},${b[1]}`)); + const MAX = Math.floor((blocked.length * blocked.length) / 2); + const dirs = [ + [-1, 0], + [1, 0], + [0, -1], + [0, 1], + ]; + + function bfs(start: number[], end: number[]): boolean { + const visited = new Set(); + const queue: number[][] = [start]; + visited.add(`${start[0]},${start[1]}`); + let count = 0; + + while (queue.length > 0) { + const cur = queue.shift()!; + const x = cur[0], + y = cur[1]; + if (x === end[0] && y === end[1]) return true; + if (count > MAX) return true; + + for (const [dx, dy] of dirs) { + const nx = x + dx; + const ny = y + dy; + const key = `${nx},${ny}`; + if ( + nx >= 0 && + nx < 1e6 && + ny >= 0 && + ny < 1e6 && + !visited.has(key) && + !blockedSet.has(key) + ) { + visited.add(key); + queue.push([nx, ny]); + } + } + count++; + } + return false; + } + + return bfs(source, target) && bfs(target, source); +} diff --git a/tests/1001-1500/1037. valid-boomerang/manifest.yaml b/tests/1001-1500/1037. valid-boomerang/manifest.yaml new file mode 100644 index 00000000..9e69e4c9 --- /dev/null +++ b/tests/1001-1500/1037. valid-boomerang/manifest.yaml @@ -0,0 +1,399 @@ +entry: + id: 1037 + title: valid-boomerang + params: + points: + type: array + items: + type: array + items: + type: int + call: + cpp: Solution().isBoomerang({points}) + rust: Solution::is_boomerang({points}) + python3: Solution().isBoomerang({points}) + python2: Solution().isBoomerang({points}) + ruby: is_boomerang({points}) + java: new Solution().isBoomerang({points}) + csharp: new Solution().IsBoomerang({points}) + kotlin: Solution().isBoomerang({points}) + go: isBoomerang({points}) + dart: Solution().isBoomerang({points}) + swift: Solution().isBoomerang({points}) + typescript: isBoomerang({points}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().isBoomerang(points, {result}) + checker: + "class Checker:\n def isBoomerang(self, points, result):\n \ + \ p1, p2, p3 = points\n distinct = len({tuple(p1), tuple(p2), tuple(p3)})\ + \ == 3\n area = (p2[0] - p1[0]) * (p3[1] - p1[1]) - (p2[1] - p1[1]) *\ + \ (p3[0] - p1[0])\n expected = distinct and area != 0\n return\ + \ expected == result\n" +seed: 1037 +tests: + - name: ex1 + in: + points: + - - 1 + - 1 + - - 2 + - 3 + - - 3 + - 2 + - name: ex2 + in: + points: + - - 1 + - 1 + - - 2 + - 2 + - - 3 + - 3 + - name: right_triangle + in: + points: + - - 0 + - 0 + - - 1 + - 0 + - - 0 + - 1 + - name: collinear_horizontal + in: + points: + - - 0 + - 5 + - - 1 + - 5 + - - 2 + - 5 + - name: collinear_vertical + in: + points: + - - 7 + - 1 + - - 7 + - 2 + - - 7 + - 3 + - name: negative_slope + in: + points: + - - 0 + - 0 + - - 1 + - 1 + - - 2 + - 2 + - name: acute + in: + points: + - - 2 + - 1 + - - 4 + - 5 + - - 7 + - 2 + - name: obtuse + in: + points: + - - 1 + - 4 + - - 5 + - 1 + - - 6 + - 7 + - name: duplicate_first_two + in: + points: + - - 3 + - 3 + - - 3 + - 3 + - - 4 + - 5 + - name: duplicate_last_two + in: + points: + - - 0 + - 1 + - - 2 + - 3 + - - 2 + - 3 + - name: duplicate_all + in: + points: + - - 9 + - 9 + - - 9 + - 9 + - - 9 + - 9 + - name: small_mix_1 + in: + points: + - - 1 + - 2 + - - 3 + - 4 + - - 5 + - 6 + - name: small_mix_2 + in: + points: + - - 1 + - 2 + - - 2 + - 4 + - - 3 + - 1 + - name: small_mix_3 + in: + points: + - - 2 + - 2 + - - 4 + - 1 + - - 6 + - 5 + - name: small_mix_4 + in: + points: + - - 10 + - 10 + - - 20 + - 15 + - - 30 + - 5 + - name: small_mix_5 + in: + points: + - - 0 + - 10 + - - 5 + - 0 + - - 10 + - 10 + - name: small_mix_6 + in: + points: + - - 1 + - 0 + - - 2 + - 2 + - - 4 + - 1 + - name: small_mix_7 + in: + points: + - - 5 + - 5 + - - 6 + - 7 + - - 8 + - 6 + - name: small_mix_8 + in: + points: + - - 8 + - 8 + - - 9 + - 10 + - - 10 + - 8 + - name: small_mix_9 + in: + points: + - - 1 + - 100 + - - 50 + - 20 + - - 99 + - 90 + - name: small_mix_10 + in: + points: + - - 100 + - 0 + - - 50 + - 50 + - - 0 + - 100 + - name: small_mix_11 + in: + points: + - - 0 + - 0 + - - 2 + - 1 + - - 4 + - 0 + - name: small_mix_12 + in: + points: + - - 4 + - 4 + - - 5 + - 5 + - - 6 + - 6 + - name: small_mix_13 + in: + points: + - - 4 + - 4 + - - 5 + - 6 + - - 6 + - 6 + - name: small_mix_14 + in: + points: + - - 2 + - 5 + - - 3 + - 7 + - - 4 + - 6 + - name: small_mix_15 + in: + points: + - - 6 + - 2 + - - 7 + - 4 + - - 8 + - 3 + - name: small_mix_16 + in: + points: + - - 10 + - 1 + - - 11 + - 4 + - - 12 + - 2 + - name: small_mix_17 + in: + points: + - - 2 + - 8 + - - 4 + - 9 + - - 6 + - 7 + - name: small_mix_18 + in: + points: + - - 20 + - 20 + - - 21 + - 22 + - - 23 + - 21 + - name: small_mix_19 + in: + points: + - - 30 + - 40 + - - 32 + - 43 + - - 35 + - 41 + - name: small_mix_20 + in: + points: + - - 0 + - 2 + - - 1 + - 5 + - - 3 + - 4 + - name: small_mix_21 + in: + points: + - - 7 + - 0 + - - 8 + - 2 + - - 9 + - 1 + - name: small_mix_22 + in: + points: + - - 12 + - 12 + - - 13 + - 14 + - - 15 + - 13 + - name: small_mix_23 + in: + points: + - - 20 + - 1 + - - 22 + - 4 + - - 24 + - 2 + - name: small_mix_24 + in: + points: + - - 3 + - 10 + - - 6 + - 13 + - - 9 + - 11 + - name: small_mix_25 + in: + points: + - - 40 + - 40 + - - 41 + - 42 + - - 43 + - 41 + - name: small_mix_26 + in: + points: + - - 50 + - 10 + - - 52 + - 13 + - - 55 + - 11 + - name: small_mix_27 + in: + points: + - - 60 + - 20 + - - 61 + - 23 + - - 63 + - 22 + - name: small_mix_28 + in: + points: + - - 70 + - 30 + - - 72 + - 34 + - - 75 + - 31 + - name: small_mix_29 + in: + points: + - - 80 + - 40 + - - 81 + - 44 + - - 83 + - 41 diff --git a/tests/1001-1500/1037. valid-boomerang/sol.cpp b/tests/1001-1500/1037. valid-boomerang/sol.cpp new file mode 100644 index 00000000..09c5350d --- /dev/null +++ b/tests/1001-1500/1037. valid-boomerang/sol.cpp @@ -0,0 +1,14 @@ +class Solution { +public: + bool isBoomerang(vector>& points) { + int x1=points[0][0]; + int y1=points[0][1]; + int x2=points[1][0]; + int y2=points[1][1]; + int x3=points[2][0]; + int y3=points[2][1]; + if ((y2-y1)*(x3-x2)==(y3-y2)*(x2-x1)) + return false; + return true; + } +}; diff --git a/tests/1001-1500/1037. valid-boomerang/sol.cs b/tests/1001-1500/1037. valid-boomerang/sol.cs new file mode 100644 index 00000000..43647bdb --- /dev/null +++ b/tests/1001-1500/1037. valid-boomerang/sol.cs @@ -0,0 +1,13 @@ +public class Solution { + public bool IsBoomerang(int[][] points) { + int x1=points[0][0]; + int y1=points[0][1]; + int x2=points[1][0]; + int y2=points[1][1]; + int x3=points[2][0]; + int y3=points[2][1]; + if ((y2-y1)*(x3-x2)==(y3-y2)*(x2-x1)) + return false; + return true; + } +} diff --git a/tests/1001-1500/1037. valid-boomerang/sol.dart b/tests/1001-1500/1037. valid-boomerang/sol.dart new file mode 100644 index 00000000..a1789ea3 --- /dev/null +++ b/tests/1001-1500/1037. valid-boomerang/sol.dart @@ -0,0 +1,13 @@ +class Solution { + bool isBoomerang(List> points) { + int x1=points[0][0]; + int y1=points[0][1]; + int x2=points[1][0]; + int y2=points[1][1]; + int x3=points[2][0]; + int y3=points[2][1]; + if ((y2-y1)*(x3-x2)==(y3-y2)*(x2-x1)) + return false; + return true; + } +} diff --git a/tests/1001-1500/1037. valid-boomerang/sol.go b/tests/1001-1500/1037. valid-boomerang/sol.go new file mode 100644 index 00000000..4ce8d13c --- /dev/null +++ b/tests/1001-1500/1037. valid-boomerang/sol.go @@ -0,0 +1,12 @@ +func isBoomerang(points [][]int) bool { + x1:=points[0][0] + y1:=points[0][1] + x2:=points[1][0] + y2:=points[1][1] + x3:=points[2][0] + y3:=points[2][1] + if (y2-y1)*(x3-x2)==(y3-y2)*(x2-x1) { + return false + } + return true +} diff --git a/tests/1001-1500/1037. valid-boomerang/sol.java b/tests/1001-1500/1037. valid-boomerang/sol.java new file mode 100644 index 00000000..b5b7b8fe --- /dev/null +++ b/tests/1001-1500/1037. valid-boomerang/sol.java @@ -0,0 +1,13 @@ +class Solution { + public boolean isBoomerang(int[][] points) { + int x1=points[0][0]; + int y1=points[0][1]; + int x2=points[1][0]; + int y2=points[1][1]; + int x3=points[2][0]; + int y3=points[2][1]; + if ((y2-y1)*(x3-x2)==(y3-y2)*(x2-x1)) + return false; + return true; + } +} diff --git a/tests/1001-1500/1037. valid-boomerang/sol.kt b/tests/1001-1500/1037. valid-boomerang/sol.kt new file mode 100644 index 00000000..238009d2 --- /dev/null +++ b/tests/1001-1500/1037. valid-boomerang/sol.kt @@ -0,0 +1,13 @@ +class Solution { + fun isBoomerang(points: Array): Boolean { + val x1=points[0][0] + val y1=points[0][1] + val x2=points[1][0] + val y2=points[1][1] + val x3=points[2][0] + val y3=points[2][1] + if ((y2-y1)*(x3-x2)==(y3-y2)*(x2-x1)) + return false + return true + } +} diff --git a/tests/1001-1500/1037. valid-boomerang/sol.py b/tests/1001-1500/1037. valid-boomerang/sol.py new file mode 100644 index 00000000..ea29b121 --- /dev/null +++ b/tests/1001-1500/1037. valid-boomerang/sol.py @@ -0,0 +1,15 @@ +class Solution(object): + def isBoomerang(self, points): + """ + :type points: List[List[int]] + :rtype: bool + """ + x1 = points[0][0] + y1 = points[0][1] + x2 = points[1][0] + y2 = points[1][1] + x3 = points[2][0] + y3 = points[2][1] + if (y2 - y1) * (x3 - x2) == (y3 - y2) * (x2 - x1): + return False + return True diff --git a/tests/1001-1500/1037. valid-boomerang/sol.py2 b/tests/1001-1500/1037. valid-boomerang/sol.py2 new file mode 100644 index 00000000..5ce02501 --- /dev/null +++ b/tests/1001-1500/1037. valid-boomerang/sol.py2 @@ -0,0 +1,15 @@ +class Solution(object): + def isBoomerang(self, points): + """ + :type points: List[List[int]] + :rtype: bool + """ + x1=points[0][0] + y1=points[0][1] + x2=points[1][0] + y2=points[1][1] + x3=points[2][0] + y3=points[2][1] + if (y2-y1)*(x3-x2)==(y3-y2)*(x2-x1): + return False + return True diff --git a/tests/1001-1500/1037. valid-boomerang/sol.rb b/tests/1001-1500/1037. valid-boomerang/sol.rb new file mode 100644 index 00000000..b6e7b209 --- /dev/null +++ b/tests/1001-1500/1037. valid-boomerang/sol.rb @@ -0,0 +1,14 @@ +# @param {Integer[][]} points +# @return {Boolean} +def is_boomerang(points) + x1=points[0][0] + y1=points[0][1] + x2=points[1][0] + y2=points[1][1] + x3=points[2][0] + y3=points[2][1] + if (y2-y1)*(x3-x2)==(y3-y2)*(x2-x1) + return false + end + return true +end diff --git a/tests/1001-1500/1037. valid-boomerang/sol.rs b/tests/1001-1500/1037. valid-boomerang/sol.rs new file mode 100644 index 00000000..1a3d328e --- /dev/null +++ b/tests/1001-1500/1037. valid-boomerang/sol.rs @@ -0,0 +1,14 @@ +impl Solution { + pub fn is_boomerang(points: Vec>) -> bool { + let x1=points[0][0]; + let y1=points[0][1]; + let x2=points[1][0]; + let y2=points[1][1]; + let x3=points[2][0]; + let y3=points[2][1]; + if (y2-y1)*(x3-x2)==(y3-y2)*(x2-x1) { + return false; + } + return true; + } +} diff --git a/tests/1001-1500/1037. valid-boomerang/sol.swift b/tests/1001-1500/1037. valid-boomerang/sol.swift new file mode 100644 index 00000000..93cafa87 --- /dev/null +++ b/tests/1001-1500/1037. valid-boomerang/sol.swift @@ -0,0 +1,14 @@ +class Solution { + func isBoomerang(_ points: [[Int]]) -> Bool { + let x1=points[0][0] + let y1=points[0][1] + let x2=points[1][0] + let y2=points[1][1] + let x3=points[2][0] + let y3=points[2][1] + if (y2-y1)*(x3-x2)==(y3-y2)*(x2-x1) { + return false + } + return true + } +} diff --git a/tests/1001-1500/1037. valid-boomerang/sol.ts b/tests/1001-1500/1037. valid-boomerang/sol.ts new file mode 100644 index 00000000..42fa4957 --- /dev/null +++ b/tests/1001-1500/1037. valid-boomerang/sol.ts @@ -0,0 +1,10 @@ +function isBoomerang(points: number[][]): boolean { + const x1 = points[0][0]; + const y1 = points[0][1]; + const x2 = points[1][0]; + const y2 = points[1][1]; + const x3 = points[2][0]; + const y3 = points[2][1]; + if ((y2 - y1) * (x3 - x2) == (y3 - y2) * (x2 - x1)) return false; + return true; +} diff --git a/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/manifest.yaml b/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/manifest.yaml new file mode 100644 index 00000000..c476e596 --- /dev/null +++ b/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/manifest.yaml @@ -0,0 +1,456 @@ +entry: + id: 1038 + title: binary-search-tree-to-greater-sum-tree + params: + root: + type: tree_node + call: + cpp: Solution().bstToGst({root}) + rust: Solution::bst_to_gst({root}) + python3: Solution().bstToGst({root}) + python2: Solution().bstToGst({root}) + ruby: bst_to_gst({root}) + java: new Solution().bstToGst({root}) + csharp: new Solution().BstToGst({root}) + kotlin: Solution().bstToGst({root}) + go: bstToGst({root}) + dart: Solution().bstToGst({root}) + swift: Solution().bstToGst({root}) + typescript: bstToGst({root}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().bstToGst(root, {result}) + checker: + "class Checker:\n def _from_level(self, values):\n if not values:\n\ + \ return None\n nodes = [None if v is None else TreeNode(v)\ + \ for v in values]\n kids = nodes[::-1]\n root = kids.pop()\n\ + \ for node in nodes:\n if node is not None:\n \ + \ if kids:\n node.left = kids.pop()\n if\ + \ kids:\n node.right = kids.pop()\n return root\n\n\ + \ def _normalize(self, node):\n if node is None:\n return\ + \ None\n if hasattr(node, \"val\"):\n return node\n \ + \ if isinstance(node, list):\n return self._from_level(node)\n \ + \ if isinstance(node, dict):\n return TreeNode(\n \ + \ node.get(\"val\", node.get(\"value\")),\n self._normalize(node.get(\"\ + left\")),\n self._normalize(node.get(\"right\")),\n \ + \ )\n return None\n\n def bstToGst(self, root, result):\n \ + \ def inorder_vals(node, vals):\n if node is None:\n \ + \ return\n inorder_vals(node.left, vals)\n vals.append(node.val)\n\ + \ inorder_vals(node.right, vals)\n\n def reverse_inorder_assign(node,\ + \ acc):\n if node is None:\n return\n reverse_inorder_assign(node.right,\ + \ acc)\n acc[0] += node.val\n node.val = acc[0]\n \ + \ reverse_inorder_assign(node.left, acc)\n\n expected_root = self._normalize(root)\n\ + \ actual_root = self._normalize(result)\n reverse_inorder_assign(expected_root,\ + \ [0])\n\n expected = []\n inorder_vals(expected_root, expected)\n\ + \ actual = []\n inorder_vals(actual_root, actual)\n return\ + \ expected == actual\n" +seed: 1038 +tests: + - name: ex1 + in: + root: + - 4 + - 1 + - 6 + - 0 + - 2 + - 5 + - 7 + - null + - null + - null + - 3 + - null + - null + - null + - 8 + - name: ex2 + in: + root: + - 0 + - null + - 1 + - name: single_zero + in: + root: + - 0 + - name: single_positive + in: + root: + - 5 + - name: two_nodes_right + in: + root: + - 1 + - null + - 2 + - name: two_nodes_left + in: + root: + - 2 + - 1 + - name: three_balanced + in: + root: + - 2 + - 1 + - 3 + - name: four_chain_right + in: + root: + - 1 + - null + - 2 + - null + - 3 + - null + - 4 + - name: four_chain_left + in: + root: + - 4 + - 3 + - null + - 2 + - null + - 1 + - name: balanced_seven + in: + root: + - 4 + - 2 + - 6 + - 1 + - 3 + - 5 + - 7 + - name: balanced_eight + in: + root: + - 8 + - 4 + - 12 + - 2 + - 6 + - 10 + - 14 + - 1 + - 3 + - 5 + - 7 + - 9 + - 11 + - 13 + - 15 + - name: skew_left_5 + in: + root: + - 5 + - 4 + - null + - 3 + - null + - 2 + - null + - 1 + - name: skew_right_5 + in: + root: + - 1 + - null + - 2 + - null + - 3 + - null + - 4 + - null + - 5 + - name: mixed_small + in: + root: + - 10 + - 5 + - 15 + - 3 + - 7 + - 12 + - 18 + - name: mixed_odd + in: + root: + - 9 + - 4 + - 13 + - 2 + - 6 + - 11 + - 15 + - 1 + - 3 + - 5 + - 7 + - name: mixed_even + in: + root: + - 16 + - 8 + - 24 + - 4 + - 12 + - 20 + - 28 + - 2 + - 6 + - 10 + - 14 + - 18 + - 22 + - 26 + - 30 + - name: compact_1 + in: + root: + - 6 + - 3 + - 8 + - 1 + - 4 + - 7 + - 9 + - name: compact_2 + in: + root: + - 7 + - 2 + - 9 + - 1 + - 5 + - 8 + - 10 + - name: compact_3 + in: + root: + - 11 + - 5 + - 17 + - 3 + - 7 + - 13 + - 19 + - name: compact_4 + in: + root: + - 12 + - 6 + - 18 + - 4 + - 8 + - 14 + - 20 + - name: compact_5 + in: + root: + - 20 + - 10 + - 30 + - 5 + - 15 + - 25 + - 35 + - name: compact_6 + in: + root: + - 14 + - 7 + - 21 + - 3 + - 9 + - 17 + - 25 + - name: compact_7 + in: + root: + - 18 + - 9 + - 27 + - 6 + - 12 + - 24 + - 30 + - name: compact_8 + in: + root: + - 25 + - 12 + - 37 + - 6 + - 18 + - 31 + - 43 + - name: compact_9 + in: + root: + - 31 + - 15 + - 47 + - 7 + - 23 + - 39 + - 55 + - name: compact_10 + in: + root: + - 1 + - null + - 3 + - null + - 5 + - null + - 7 + - null + - 9 + - name: compact_11 + in: + root: + - 2 + - 1 + - 4 + - null + - null + - 3 + - 5 + - name: compact_12 + in: + root: + - 3 + - 1 + - 5 + - null + - 2 + - 4 + - 6 + - name: compact_13 + in: + root: + - 4 + - 2 + - 7 + - 1 + - 3 + - 6 + - 8 + - name: compact_14 + in: + root: + - 5 + - 2 + - 9 + - 1 + - 3 + - 7 + - 11 + - name: compact_15 + in: + root: + - 6 + - 3 + - 10 + - 2 + - 4 + - 8 + - 12 + - name: compact_16 + in: + root: + - 7 + - 3 + - 11 + - 1 + - 5 + - 9 + - 13 + - name: compact_17 + in: + root: + - 8 + - 4 + - 12 + - 2 + - 6 + - 10 + - 14 + - name: compact_18 + in: + root: + - 9 + - 4 + - 14 + - 2 + - 6 + - 12 + - 16 + - name: compact_19 + in: + root: + - 10 + - 5 + - 15 + - 3 + - 7 + - 13 + - 17 + - name: compact_20 + in: + root: + - 11 + - 6 + - 16 + - 4 + - 8 + - 14 + - 18 + - name: compact_21 + in: + root: + - 12 + - 6 + - 18 + - 3 + - 9 + - 15 + - 21 + - name: compact_22 + in: + root: + - 13 + - 7 + - 19 + - 4 + - 10 + - 16 + - 22 + - name: compact_23 + in: + root: + - 14 + - 7 + - 21 + - 5 + - 11 + - 17 + - 25 + - name: compact_24 + in: + root: + - 15 + - 8 + - 23 + - 6 + - 12 + - 19 + - 27 diff --git a/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.cpp b/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.cpp new file mode 100644 index 00000000..03bf707a --- /dev/null +++ b/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.cpp @@ -0,0 +1,31 @@ +/** + * Definition for a binary tree node. + * struct TreeNode { + * int val; + * TreeNode *left; + * TreeNode *right; + * TreeNode() : val(0), left(nullptr), right(nullptr) {} + * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} + * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} + * }; + */ +class Solution { +public: + TreeNode* bstToGst(TreeNode* root) { + int sum = 0; + traversal(root, sum); + return root; + } + +private: + void traversal(TreeNode* node, int& sum) { + if (node->right) { + traversal(node->right, sum); + } + sum += node->val; + node->val = sum; + if (node->left) { + traversal(node->left, sum); + } + } +}; diff --git a/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.cs b/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.cs new file mode 100644 index 00000000..0dcec7c0 --- /dev/null +++ b/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.cs @@ -0,0 +1,32 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public int val; + * public TreeNode left; + * public TreeNode right; + * public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +public class Solution { + private int sum = 0; + + public TreeNode BstToGst(TreeNode root) { + Traversal(root); + return root; + } + + private void Traversal(TreeNode node) { + if (node.right != null) { + Traversal(node.right); + } + sum += node.val; + node.val = sum; + if (node.left != null) { + Traversal(node.left); + } + } +} diff --git a/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.dart b/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.dart new file mode 100644 index 00000000..97055607 --- /dev/null +++ b/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.dart @@ -0,0 +1,29 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * int val; + * TreeNode? left; + * TreeNode? right; + * TreeNode([this.val = 0, this.left, this.right]); + * } + */ +class Solution { + int sum = 0; + + TreeNode? bstToGst(TreeNode? root) { + traversal(root); + return root; + } + + void traversal(TreeNode? node) { + if (node == null) return; + if (node.right != null) { + traversal(node.right); + } + sum += node.val; + node.val = sum; + if (node.left != null) { + traversal(node.left); + } + } +} diff --git a/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.go b/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.go new file mode 100644 index 00000000..93cf6f3e --- /dev/null +++ b/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.go @@ -0,0 +1,24 @@ +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +func bstToGst(root *TreeNode) *TreeNode { + sum := 0 + var traversal func(*TreeNode) + traversal = func(node *TreeNode) { + if node.Right != nil { + traversal(node.Right) + } + sum += node.Val + node.Val = sum + if node.Left != nil { + traversal(node.Left) + } + } + traversal(root) + return root +} diff --git a/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.java b/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.java new file mode 100644 index 00000000..860a3c77 --- /dev/null +++ b/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.java @@ -0,0 +1,34 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode() {} + * TreeNode(int val) { this.val = val; } + * TreeNode(int val, TreeNode left, TreeNode right) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +class Solution { + private int sum = 0; + + public TreeNode bstToGst(TreeNode root) { + traversal(root); + return root; + } + + private void traversal(TreeNode node) { + if (node.right != null) { + traversal(node.right); + } + sum += node.val; + node.val = sum; + if (node.left != null) { + traversal(node.left); + } + } +} diff --git a/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.kt b/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.kt new file mode 100644 index 00000000..e3e36fc3 --- /dev/null +++ b/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.kt @@ -0,0 +1,30 @@ +/** + * Example: + * var ti = TreeNode(5) + * var v = ti.`val` + * Definition for a binary tree node. + * class TreeNode(var `val`: Int) { + * var left: TreeNode? = null + * var right: TreeNode? = null + * } + */ +class Solution { + private var sum = 0 + + fun bstToGst(root: TreeNode?): TreeNode? { + traversal(root) + return root + } + + private fun traversal(node: TreeNode?) { + if (node == null) return + if (node.right != null) { + traversal(node.right) + } + sum += node.`val` + node.`val` = sum + if (node.left != null) { + traversal(node.left) + } + } +} diff --git a/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.py b/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.py new file mode 100644 index 00000000..0fdf7f90 --- /dev/null +++ b/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.py @@ -0,0 +1,20 @@ +# Definition for a binary tree node. +# class TreeNode: +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution: + def bstToGst(self, root: Optional[TreeNode]) -> Optional[TreeNode]: + self.sum = 0 + + def traversal(root): + if root.right: + traversal(root.right) + self.sum += root.val + root.val = self.sum + if root.left: + traversal(root.left) + + traversal(root) + return root diff --git a/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.py2 b/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.py2 new file mode 100644 index 00000000..312ba1fd --- /dev/null +++ b/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.py2 @@ -0,0 +1,22 @@ +# Definition for a binary tree node. +# class TreeNode(object): +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution(object): + def bstToGst(self, root): + """ + :type root: Optional[TreeNode] + :rtype: Optional[TreeNode] + """ + self.sum = 0 + def traversal(node): + if node.right: + traversal(node.right) + self.sum += node.val + node.val = self.sum + if node.left: + traversal(node.left) + traversal(root) + return root diff --git a/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.rb b/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.rb new file mode 100644 index 00000000..5134be7c --- /dev/null +++ b/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.rb @@ -0,0 +1,22 @@ +# Definition for a binary tree node. +# class TreeNode +# attr_accessor :val, :left, :right +# def initialize(val = 0, left = nil, right = nil) +# @val = val +# @left = left +# @right = right +# end +# end +# @param {TreeNode} root +# @return {TreeNode} +def bst_to_gst(root) + @sum = 0 + traversal = lambda do |node| + traversal.call(node.right) if node.right + @sum += node.val + node.val = @sum + traversal.call(node.left) if node.left + end + traversal.call(root) + root +end diff --git a/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.rs b/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.rs new file mode 100644 index 00000000..3521aa15 --- /dev/null +++ b/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.rs @@ -0,0 +1,34 @@ +// Definition for a binary tree node. +// #[derive(Debug, PartialEq, Eq)] +// pub struct TreeNode { +// pub val: i32, +// pub left: Option>>, +// pub right: Option>>, +// } +// +// impl TreeNode { +// #[inline] +// pub fn new(val: i32) -> Self { +// TreeNode { +// val, +// left: None, +// right: None +// } +// } +// } +impl Solution { + pub fn bst_to_gst(root: Option>>) -> Option>> { + let mut sum = 0; + fn traversal(node: &Option>>, sum: &mut i32) { + if let Some(n) = node { + let mut n_borrow = n.borrow_mut(); + traversal(&n_borrow.right, sum); + *sum += n_borrow.val; + n_borrow.val = *sum; + traversal(&n_borrow.left, sum); + } + } + traversal(&root, &mut sum); + root + } +} diff --git a/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.swift b/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.swift new file mode 100644 index 00000000..37c9176e --- /dev/null +++ b/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.swift @@ -0,0 +1,16 @@ +class Solution { + func bstToGst(_ root: TreeNode?) -> TreeNode? { + var sum = 0 + + func traverse(_ node: TreeNode?) { + guard let node = node else { return } + traverse(node.right) + sum += node.val + node.val = sum + traverse(node.left) + } + + traverse(root) + return root + } +} diff --git a/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.ts b/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.ts new file mode 100644 index 00000000..5f49c02f --- /dev/null +++ b/tests/1001-1500/1038. binary-search-tree-to-greater-sum-tree/sol.ts @@ -0,0 +1,30 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ + +function bstToGst(root: TreeNode | null): TreeNode | null { + let sum = 0; + function traversal(node: TreeNode | null): void { + if (node === null) return; + if (node.right !== null) { + traversal(node.right); + } + sum += node.val; + node.val = sum; + if (node.left !== null) { + traversal(node.left); + } + } + traversal(root); + return root; +} diff --git a/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/manifest.yaml b/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/manifest.yaml new file mode 100644 index 00000000..dd8c3608 --- /dev/null +++ b/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/manifest.yaml @@ -0,0 +1,401 @@ +entry: + id: 1039 + title: minimum-score-triangulation-of-polygon + params: + values: + type: array + items: + type: int + call: + cpp: Solution().minScoreTriangulation({values}) + rust: Solution::min_score_triangulation({values}) + python3: Solution().minScoreTriangulation({values}) + python2: Solution().minScoreTriangulation({values}) + ruby: min_score_triangulation({values}) + java: new Solution().minScoreTriangulation({values}) + csharp: new Solution().MinScoreTriangulation({values}) + kotlin: Solution().minScoreTriangulation({values}) + go: minScoreTriangulation({values}) + dart: Solution().minScoreTriangulation({values}) + swift: Solution().minScoreTriangulation({values}) + typescript: minScoreTriangulation({values}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().minScoreTriangulation(values, {result}) + checker: + "class Checker:\n def minScoreTriangulation(self, values, result):\n\ + \ n = len(values)\n dp = [[0] * n for _ in range(n)]\n \ + \ for i in range(n - 1, -1, -1):\n for j in range(i + 2, n):\n \ + \ best = None\n for k in range(i + 1, j):\n \ + \ cand = dp[i][k] + values[i] * values[k] * values[j] + dp[k][j]\n\ + \ if best is None or cand < best:\n \ + \ best = cand\n dp[i][j] = 0 if best is None else best\n \ + \ return dp[0][n - 1] == result\n" +seed: 1039 +tests: + - name: ex1 + in: + values: + - 1 + - 2 + - 3 + - name: ex2 + in: + values: + - 3 + - 7 + - 4 + - 5 + - name: ex3 + in: + values: + - 1 + - 3 + - 1 + - 4 + - 1 + - 5 + - name: short_equal + in: + values: + - 1 + - 1 + - 1 + - name: short_square + in: + values: + - 2 + - 2 + - 2 + - 2 + - name: short_alternating + in: + values: + - 1 + - 2 + - 1 + - 2 + - name: descending_5 + in: + values: + - 5 + - 4 + - 3 + - 2 + - 1 + - name: ascending_5 + in: + values: + - 1 + - 2 + - 3 + - 4 + - 5 + - name: mixed_1 + in: + values: + - 1 + - 5 + - 1 + - 5 + - 1 + - name: mixed_2 + in: + values: + - 2 + - 3 + - 4 + - 5 + - 6 + - name: mixed_3 + in: + values: + - 9 + - 8 + - 7 + - name: mixed_4 + in: + values: + - 1 + - 2 + - 3 + - 4 + - name: mixed_5 + in: + values: + - 2 + - 3 + - 1 + - 5 + - 4 + - name: mixed_6 + in: + values: + - 4 + - 1 + - 2 + - 3 + - name: mixed_7 + in: + values: + - 2 + - 5 + - 3 + - 7 + - 2 + - 6 + - name: mixed_8 + in: + values: + - 1 + - 2 + - 3 + - 1 + - 2 + - 3 + - name: mixed_9 + in: + values: + - 10 + - 20 + - 30 + - name: mixed_10 + in: + values: + - 2 + - 1 + - 2 + - 1 + - 2 + - name: mixed_11 + in: + values: + - 8 + - 1 + - 9 + - 1 + - 8 + - name: mixed_12 + in: + values: + - 3 + - 1 + - 5 + - 8 + - name: mixed_13 + in: + values: + - 1 + - 4 + - 2 + - 8 + - 3 + - name: mixed_14 + in: + values: + - 7 + - 2 + - 6 + - 4 + - 5 + - name: mixed_15 + in: + values: + - 1 + - 2 + - 100 + - 2 + - 1 + - name: mixed_16 + in: + values: + - 9 + - 1 + - 1 + - 9 + - name: mixed_17 + in: + values: + - 4 + - 6 + - 2 + - 7 + - 3 + - 5 + - name: mixed_18 + in: + values: + - 1 + - 3 + - 1 + - 3 + - 1 + - 3 + - 1 + - name: mixed_19 + in: + values: + - 100 + - 99 + - 98 + - name: gen_01 + in: + values: + gen: array + len: 7 + of: + gen: int + min: 1 + max: 10 + distinct: false + sorted: false + elemType: int + - name: gen_02 + in: + values: + gen: array + len: 8 + of: + gen: int + min: 1 + max: 15 + distinct: false + sorted: false + elemType: int + - name: gen_03 + in: + values: + gen: array + len: 9 + of: + gen: int + min: 1 + max: 20 + distinct: false + sorted: false + elemType: int + - name: gen_04 + in: + values: + gen: array + len: 10 + of: + gen: int + min: 1 + max: 25 + distinct: false + sorted: false + elemType: int + - name: gen_05 + in: + values: + gen: array + len: 11 + of: + gen: int + min: 1 + max: 30 + distinct: false + sorted: false + elemType: int + - name: gen_06 + in: + values: + gen: array + len: 12 + of: + gen: int + min: 1 + max: 35 + distinct: false + sorted: false + elemType: int + - name: gen_07 + in: + values: + gen: array + len: 13 + of: + gen: int + min: 1 + max: 40 + distinct: false + sorted: false + elemType: int + - name: gen_08 + in: + values: + gen: array + len: 14 + of: + gen: int + min: 1 + max: 45 + distinct: false + sorted: false + elemType: int + - name: gen_09 + in: + values: + gen: array + len: 15 + of: + gen: int + min: 1 + max: 50 + distinct: false + sorted: false + elemType: int + - name: gen_10 + in: + values: + gen: array + len: 16 + of: + gen: int + min: 1 + max: 55 + distinct: false + sorted: false + elemType: int + - name: gen_11 + in: + values: + gen: array + len: 17 + of: + gen: int + min: 1 + max: 60 + distinct: false + sorted: false + elemType: int + - name: gen_12 + in: + values: + gen: array + len: 18 + of: + gen: int + min: 1 + max: 65 + distinct: false + sorted: false + elemType: int + - name: gen_13 + in: + values: + gen: array + len: 19 + of: + gen: int + min: 1 + max: 70 + distinct: false + sorted: false + elemType: int diff --git a/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.cpp b/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.cpp new file mode 100644 index 00000000..9d6152a9 --- /dev/null +++ b/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.cpp @@ -0,0 +1,22 @@ +class Solution { +public: + int minScoreTriangulation(vector& values) { + int n = values.size(); + vector> dp(n, vector(n, 0)); + for (int i = n - 1; i >= 0; i--) { + for (int j = i + 1; j < n; j++) { + int minVal = INT_MAX; + for (int k = i + 1; k < j; k++) { + int val = dp[i][k] + values[i] * values[k] * values[j] + dp[k][j]; + if (val < minVal) { + minVal = val; + } + } + if (minVal != INT_MAX) { + dp[i][j] = minVal; + } + } + } + return dp[0][n - 1]; + } +}; diff --git a/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.cs b/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.cs new file mode 100644 index 00000000..c1ab3c9c --- /dev/null +++ b/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.cs @@ -0,0 +1,21 @@ +public class Solution { + public int MinScoreTriangulation(int[] values) { + int n = values.Length; + int[,] dp = new int[n, n]; + for (int i = n - 1; i >= 0; i--) { + for (int j = i + 1; j < n; j++) { + int minVal = int.MaxValue; + for (int k = i + 1; k < j; k++) { + int val = dp[i, k] + values[i] * values[k] * values[j] + dp[k, j]; + if (val < minVal) { + minVal = val; + } + } + if (minVal != int.MaxValue) { + dp[i, j] = minVal; + } + } + } + return dp[0, n - 1]; + } +} diff --git a/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.dart b/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.dart new file mode 100644 index 00000000..5666ad82 --- /dev/null +++ b/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.dart @@ -0,0 +1,21 @@ +class Solution { + int minScoreTriangulation(List values) { + int n = values.length; + List> dp = List.generate(n, (_) => List.filled(n, 0)); + for (int i = n - 1; i >= 0; i--) { + for (int j = i + 1; j < n; j++) { + int minVal = 1 << 63 - 1; + for (int k = i + 1; k < j; k++) { + int val = dp[i][k] + values[i] * values[k] * values[j] + dp[k][j]; + if (val < minVal) { + minVal = val; + } + } + if (minVal != 1 << 63 - 1) { + dp[i][j] = minVal; + } + } + } + return dp[0][n - 1]; + } +} diff --git a/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.go b/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.go new file mode 100644 index 00000000..790f92fd --- /dev/null +++ b/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.go @@ -0,0 +1,22 @@ +func minScoreTriangulation(values []int) int { + n := len(values) + dp := make([][]int, n) + for i := range dp { + dp[i] = make([]int, n) + } + for i := n - 1; i >= 0; i-- { + for j := i + 1; j < n; j++ { + minVal := int(^uint(0) >> 1) + for k := i + 1; k < j; k++ { + val := dp[i][k] + values[i]*values[k]*values[j] + dp[k][j] + if val < minVal { + minVal = val + } + } + if minVal != int(^uint(0)>>1) { + dp[i][j] = minVal + } + } + } + return dp[0][n-1] +} diff --git a/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.java b/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.java new file mode 100644 index 00000000..0113f35e --- /dev/null +++ b/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.java @@ -0,0 +1,21 @@ +class Solution { + public int minScoreTriangulation(int[] values) { + int n = values.length; + int[][] dp = new int[n][n]; + for (int i = n - 1; i >= 0; i--) { + for (int j = i + 1; j < n; j++) { + int minVal = Integer.MAX_VALUE; + for (int k = i + 1; k < j; k++) { + int val = dp[i][k] + values[i] * values[k] * values[j] + dp[k][j]; + if (val < minVal) { + minVal = val; + } + } + if (minVal != Integer.MAX_VALUE) { + dp[i][j] = minVal; + } + } + } + return dp[0][n - 1]; + } +} diff --git a/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.kt b/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.kt new file mode 100644 index 00000000..bfc80dec --- /dev/null +++ b/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.kt @@ -0,0 +1,21 @@ +class Solution { + fun minScoreTriangulation(values: IntArray): Int { + val n = values.size + val dp = Array(n) { IntArray(n) } + for (i in n - 1 downTo 0) { + for (j in i + 1 until n) { + var minVal = Int.MAX_VALUE + for (k in i + 1 until j) { + val v = dp[i][k] + values[i] * values[k] * values[j] + dp[k][j] + if (v < minVal) { + minVal = v + } + } + if (minVal != Int.MAX_VALUE) { + dp[i][j] = minVal + } + } + } + return dp[0][n - 1] + } +} diff --git a/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.py b/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.py new file mode 100644 index 00000000..87f9157d --- /dev/null +++ b/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.py @@ -0,0 +1,12 @@ +class Solution: + def minScoreTriangulation(self, values: list[int]) -> int: + n = len(values) + dp = [[0] * n for _ in range(n)] + for i in range(n - 1, -1, -1): + for j in range(i + 1, n): + for k in range(i + 1, j): + dp[i][j] = min( + dp[i][j] if dp[i][j] != 0 else float("inf"), + dp[i][k] + values[i] * values[k] * values[j] + dp[k][j], + ) + return dp[0][n - 1] diff --git a/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.py2 b/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.py2 new file mode 100644 index 00000000..4f4824f6 --- /dev/null +++ b/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.py2 @@ -0,0 +1,18 @@ +class Solution(object): + def minScoreTriangulation(self, values): + """ + :type values: List[int] + :rtype: int + """ + n = len(values) + dp = [[0] * n for _ in range(n)] + for i in range(n - 1, -1, -1): + for j in range(i + 1, n): + min_val = float("inf") + for k in range(i + 1, j): + val = dp[i][k] + values[i] * values[k] * values[j] + dp[k][j] + if val < min_val: + min_val = val + if min_val != float("inf"): + dp[i][j] = min_val + return dp[0][n - 1] diff --git a/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.rb b/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.rb new file mode 100644 index 00000000..1b7e4de7 --- /dev/null +++ b/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.rb @@ -0,0 +1,17 @@ +# @param {Integer[]} values +# @return {Integer} +def min_score_triangulation(values) + n = values.length + dp = Array.new(n) { Array.new(n, 0) } + (n - 1).downto(0) do |i| + (i + 1...n).each do |j| + min_val = Float::INFINITY + (i + 1...j).each do |k| + val = dp[i][k] + values[i] * values[k] * values[j] + dp[k][j] + min_val = val if val < min_val + end + dp[i][j] = min_val if min_val != Float::INFINITY + end + end + dp[0][n - 1] +end diff --git a/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.rs b/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.rs new file mode 100644 index 00000000..c415006a --- /dev/null +++ b/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.rs @@ -0,0 +1,21 @@ +impl Solution { + pub fn min_score_triangulation(values: Vec) -> i32 { + let n = values.len(); + let mut dp = vec![vec![0; n]; n]; + for i in (0..n).rev() { + for j in i + 1..n { + let mut min_val = i32::MAX; + for k in i + 1..j { + let val = dp[i][k] + values[i] * values[k] * values[j] + dp[k][j]; + if val < min_val { + min_val = val; + } + } + if min_val != i32::MAX { + dp[i][j] = min_val; + } + } + } + dp[0][n - 1] + } +} diff --git a/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.swift b/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.swift new file mode 100644 index 00000000..a7d5c6ed --- /dev/null +++ b/tests/1001-1500/1039. minimum-score-triangulation-of-polygon/sol.swift @@ -0,0 +1,21 @@ +class Solution { + func minScoreTriangulation(_ values: [Int]) -> Int { + let n = values.count + var dp = Array(repeating: Array(repeating: 0, count: n), count: n) + for i in stride(from: n - 1, through: 0, by: -1) { + for j in i+1.. Array(n).fill(0)); + for (let i = n - 1; i >= 0; i--) { + for (let j = i + 1; j < n; j++) { + let minVal = Number.POSITIVE_INFINITY; + for (let k = i + 1; k < j; k++) { + const val = dp[i][k] + values[i] * values[k] * values[j] + dp[k][j]; + if (val < minVal) { + minVal = val; + } + } + if (minVal !== Number.POSITIVE_INFINITY) { + dp[i][j] = minVal; + } + } + } + return dp[0][n - 1]; +} diff --git a/tests/1001-1500/1040. moving-stones-until-consecutive-ii/manifest.yaml b/tests/1001-1500/1040. moving-stones-until-consecutive-ii/manifest.yaml new file mode 100644 index 00000000..c4c1a6a4 --- /dev/null +++ b/tests/1001-1500/1040. moving-stones-until-consecutive-ii/manifest.yaml @@ -0,0 +1,479 @@ +entry: + id: 1040 + title: moving-stones-until-consecutive-ii + params: + stones: + type: array + items: + type: int + call: + cpp: Solution().numMovesStonesII({stones}) + rust: Solution::num_moves_stones_ii({stones}) + python3: Solution().numMovesStonesII({stones}) + python2: Solution().numMovesStonesII({stones}) + ruby: num_moves_stones_ii({stones}) + java: new Solution().numMovesStonesII({stones}) + csharp: new Solution().NumMovesStonesII({stones}) + kotlin: Solution().numMovesStonesII({stones}) + go: numMovesStonesII({stones}) + dart: Solution().numMovesStonesII({stones}) + swift: Solution().numMovesStonesII({stones}) + typescript: numMovesStonesII({stones}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().numMovesStonesII(stones, {result}) + checker: + "class Checker:\n def numMovesStonesII(self, stones, result):\n \ + \ if not isinstance(result, list) or len(result) != 2:\n return\ + \ False\n if any((not isinstance(x, int)) for x in result):\n \ + \ return False\n stones = sorted(stones)\n n = len(stones)\n\ + \ max_moves = max(stones[-1] - stones[1] - (n - 2), stones[-2] - stones[0]\ + \ - (n - 2))\n min_moves = n\n left = 0\n for right in\ + \ range(n):\n while stones[right] - stones[left] + 1 > n:\n \ + \ left += 1\n current_window_size = right - left + 1\n\ + \ if current_window_size == n - 1 and stones[right] - stones[left]\ + \ + 1 == n - 1:\n min_moves = min(min_moves, 2)\n \ + \ else:\n min_moves = min(min_moves, n - current_window_size)\n\ + \ return result == [min_moves, max_moves]\n" +seed: 1040 +tests: + - name: example-1 + in: + stones: + - 7 + - 4 + - 9 + out: + - 1 + - 2 + - name: example-2 + in: + stones: + - 6 + - 5 + - 4 + - 3 + - 10 + out: + - 2 + - 3 + - name: consecutive-3 + in: + stones: + - 1 + - 2 + - 3 + out: + - 0 + - 0 + - name: consecutive-4 + in: + stones: + - 1 + - 2 + - 3 + - 4 + out: + - 0 + - 0 + - name: one-gap-left + in: + stones: + - 1 + - 2 + - 4 + out: + - 1 + - 1 + - name: one-gap-right + in: + stones: + - 1 + - 3 + - 4 + out: + - 1 + - 1 + - name: small-spread + in: + stones: + - 1 + - 5 + - 6 + out: + - 2 + - 3 + - name: small-spread-2 + in: + stones: + - 1 + - 4 + - 5 + out: + - 2 + - 2 + - name: five-stones-1 + in: + stones: + - 1 + - 2 + - 3 + - 6 + - 7 + out: + - 2 + - 2 + - name: five-stones-2 + in: + stones: + - 10 + - 11 + - 12 + - 20 + - 21 + out: + - 2 + - 7 + - name: five-stones-3 + in: + stones: + - 3 + - 7 + - 8 + - 9 + - 10 + out: + - 2 + - 3 + - name: five-stones-4 + in: + stones: + - 1 + - 2 + - 10 + - 11 + - 12 + out: + - 2 + - 7 + - name: five-stones-5 + in: + stones: + - 4 + - 5 + - 6 + - 20 + - 21 + out: + - 2 + - 13 + - name: six-stones-1 + in: + stones: + - 1 + - 2 + - 3 + - 8 + - 9 + - 10 + out: + - 3 + - 4 + - name: six-stones-2 + in: + stones: + - 1 + - 4 + - 5 + - 6 + - 7 + - 8 + out: + - 2 + - 2 + - name: six-stones-3 + in: + stones: + - 2 + - 3 + - 4 + - 5 + - 9 + - 10 + out: + - 2 + - 3 + - name: six-stones-4 + in: + stones: + - 10 + - 11 + - 12 + - 13 + - 20 + - 30 + out: + - 2 + - 15 + - name: six-stones-5 + in: + stones: + - 1 + - 10 + - 11 + - 12 + - 13 + - 14 + out: + - 2 + - 8 + - name: seven-stones-1 + in: + stones: + - 1 + - 2 + - 3 + - 4 + - 10 + - 11 + - 12 + out: + - 3 + - 5 + - name: seven-stones-2 + in: + stones: + - 5 + - 6 + - 7 + - 8 + - 20 + - 21 + - 22 + out: + - 3 + - 11 + - name: seven-stones-3 + in: + stones: + - 1 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + out: + - 1 + - 1 + - name: seven-stones-4 + in: + stones: + - 1 + - 2 + - 3 + - 14 + - 15 + - 16 + - 17 + out: + - 3 + - 10 + - name: seven-stones-5 + in: + stones: + - 2 + - 4 + - 6 + - 8 + - 10 + - 12 + - 14 + out: + - 3 + - 5 + - name: large-gap-1 + in: + stones: + - 1 + - 2 + - 3 + - 4 + - 5 + - 100 + out: + - 2 + - 94 + - name: large-gap-2 + in: + stones: + - 1 + - 50 + - 51 + - 52 + - 53 + - 54 + out: + - 2 + - 48 + - name: large-gap-3 + in: + stones: + - 10 + - 11 + - 12 + - 13 + - 14 + - 1000 + out: + - 2 + - 985 + - name: large-gap-4 + in: + stones: + - 100 + - 101 + - 102 + - 103 + - 104 + - 500 + out: + - 2 + - 395 + - name: large-gap-5 + in: + stones: + - 1 + - 2 + - 50 + - 51 + - 52 + - 53 + out: + - 2 + - 47 + - name: large-gap-6 + in: + stones: + - 1 + - 2 + - 3 + - 100 + - 101 + - 102 + out: + - 3 + - 96 + - name: large-gap-7 + in: + stones: + - 1 + - 2 + - 3 + - 4 + - 200 + - 201 + out: + - 2 + - 195 + - name: large-gap-8 + in: + stones: + - 1 + - 2 + - 3 + - 4 + - 5 + - 200 + out: + - 2 + - 194 + - name: large-gap-9 + in: + stones: + - 1 + - 10 + - 11 + - 12 + - 13 + - 14 + out: + - 2 + - 8 + - name: large-gap-10 + in: + stones: + - 1 + - 2 + - 100 + - 101 + - 102 + - 103 + out: + - 2 + - 97 + - name: large-gap-11 + in: + stones: + - 3 + - 4 + - 5 + - 100 + - 101 + - 102 + out: + - 3 + - 94 + - name: large-gap-12 + in: + stones: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + out: + - 0 + - 0 + - name: large-gap-13 + in: + stones: + - 1 + - 2 + - 3 + - 4 + - 7 + - 8 + out: + - 2 + - 2 + - name: large-gap-14 + in: + stones: + - 1 + - 2 + - 3 + - 5 + - 6 + - 7 + out: + - 1 + - 1 + - name: large-gap-15 + in: + stones: + - 1 + - 2 + - 4 + - 5 + - 6 + - 7 + out: + - 1 + - 1 diff --git a/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.cpp b/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.cpp new file mode 100644 index 00000000..7e164807 --- /dev/null +++ b/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.cpp @@ -0,0 +1,26 @@ +class Solution { +public: + vector numMovesStonesII(vector& stones) { + sort(stones.begin(), stones.end()); + int n = stones.size(); + + int maxMoves = max(stones[n - 1] - stones[1] - (n - 2), + stones[n - 2] - stones[0] - (n - 2)); + + int minMoves = n; + int left = 0; + for (int right = 0; right < n; right++) { + while (stones[right] - stones[left] + 1 > n) { + left++; + } + int currentWindowSize = right - left + 1; + if (currentWindowSize == n - 1 && stones[right] - stones[left] + 1 == n - 1) { + minMoves = min(minMoves, 2); + } else { + minMoves = min(minMoves, n - currentWindowSize); + } + } + + return {minMoves, maxMoves}; + } +}; diff --git a/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.cs b/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.cs new file mode 100644 index 00000000..96dda7e9 --- /dev/null +++ b/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.cs @@ -0,0 +1,25 @@ +public class Solution { + public int[] NumMovesStonesII(int[] stones) { + Array.Sort(stones); + int n = stones.Length; + + int maxMoves = Math.Max(stones[n - 1] - stones[1] - (n - 2), + stones[n - 2] - stones[0] - (n - 2)); + + int minMoves = n; + int left = 0; + for (int right = 0; right < n; right++) { + while (stones[right] - stones[left] + 1 > n) { + left++; + } + int currentWindowSize = right - left + 1; + if (currentWindowSize == n - 1 && stones[right] - stones[left] + 1 == n - 1) { + minMoves = Math.Min(minMoves, 2); + } else { + minMoves = Math.Min(minMoves, n - currentWindowSize); + } + } + + return new int[] { minMoves, maxMoves }; + } +} diff --git a/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.dart b/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.dart new file mode 100644 index 00000000..d57b9abb --- /dev/null +++ b/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.dart @@ -0,0 +1,25 @@ +class Solution { + List numMovesStonesII(List stones) { + stones.sort(); + int n = stones.length; + + int maxMoves = max(stones[n - 1] - stones[1] - (n - 2), + stones[n - 2] - stones[0] - (n - 2)); + + int minMoves = n; + int left = 0; + for (int right = 0; right < n; right++) { + while (stones[right] - stones[left] + 1 > n) { + left++; + } + int currentWindowSize = right - left + 1; + if (currentWindowSize == n - 1 && stones[right] - stones[left] + 1 == n - 1) { + minMoves = min(minMoves, 2); + } else { + minMoves = min(minMoves, n - currentWindowSize); + } + } + + return [minMoves, maxMoves]; + } +} diff --git a/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.go b/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.go new file mode 100644 index 00000000..23d0ef3d --- /dev/null +++ b/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.go @@ -0,0 +1,22 @@ +func numMovesStonesII(stones []int) []int { + sort.Ints(stones) + n := len(stones) + + maxMoves := max(stones[n-1]-stones[1]-(n-2), stones[n-2]-stones[0]-(n-2)) + + minMoves := n + left := 0 + for right := 0; right < n; right++ { + for stones[right]-stones[left]+1 > n { + left++ + } + currentWindowSize := right - left + 1 + if currentWindowSize == n-1 && stones[right]-stones[left]+1 == n-1 { + minMoves = min(minMoves, 2) + } else { + minMoves = min(minMoves, n-currentWindowSize) + } + } + + return []int{minMoves, maxMoves} +} diff --git a/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.java b/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.java new file mode 100644 index 00000000..5b82075f --- /dev/null +++ b/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.java @@ -0,0 +1,25 @@ +class Solution { + public int[] numMovesStonesII(int[] stones) { + Arrays.sort(stones); + int n = stones.length; + + int maxMoves = Math.max(stones[n - 1] - stones[1] - (n - 2), + stones[n - 2] - stones[0] - (n - 2)); + + int minMoves = n; + int left = 0; + for (int right = 0; right < n; right++) { + while (stones[right] - stones[left] + 1 > n) { + left++; + } + int currentWindowSize = right - left + 1; + if (currentWindowSize == n - 1 && stones[right] - stones[left] + 1 == n - 1) { + minMoves = Math.min(minMoves, 2); + } else { + minMoves = Math.min(minMoves, n - currentWindowSize); + } + } + + return new int[]{minMoves, maxMoves}; + } +} diff --git a/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.kt b/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.kt new file mode 100644 index 00000000..0a07e819 --- /dev/null +++ b/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.kt @@ -0,0 +1,25 @@ +class Solution { + fun numMovesStonesII(stones: IntArray): IntArray { + stones.sort() + val n = stones.size + + val maxMoves = maxOf(stones[n - 1] - stones[1] - (n - 2), + stones[n - 2] - stones[0] - (n - 2)) + + var minMoves = n + var left = 0 + for (right in 0 until n) { + while (stones[right] - stones[left] + 1 > n) { + left++ + } + val currentWindowSize = right - left + 1 + if (currentWindowSize == n - 1 && stones[right] - stones[left] + 1 == n - 1) { + minMoves = minOf(minMoves, 2) + } else { + minMoves = minOf(minMoves, n - currentWindowSize) + } + } + + return intArrayOf(minMoves, maxMoves) + } +} diff --git a/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.py b/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.py new file mode 100644 index 00000000..ffa3767d --- /dev/null +++ b/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.py @@ -0,0 +1,28 @@ +class Solution(object): + def numMovesStonesII(self, stones): + """ + :type stones: List[int] + :rtype: List[int] + """ + stones.sort() + n = len(stones) + + maxMoves = max( + stones[-1] - stones[1] - (n - 2), stones[-2] - stones[0] - (n - 2) + ) + + minMoves = n + left = 0 + for right in range(n): + while stones[right] - stones[left] + 1 > n: + left += 1 + current_window_size = right - left + 1 + if ( + current_window_size == n - 1 + and stones[right] - stones[left] + 1 == n - 1 + ): + minMoves = min(minMoves, 2) + else: + minMoves = min(minMoves, n - current_window_size) + + return [minMoves, maxMoves] diff --git a/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.py2 b/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.py2 new file mode 100644 index 00000000..039dddae --- /dev/null +++ b/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.py2 @@ -0,0 +1,23 @@ +class Solution(object): + def numMovesStonesII(self, stones): + """ + :type stones: List[int] + :rtype: List[int] + """ + stones.sort() + n = len(stones) + + maxMoves = max(stones[-1] - stones[1] - (n - 2), stones[-2] - stones[0] - (n - 2)) + + minMoves = n + left = 0 + for right in range(n): + while stones[right] - stones[left] + 1 > n: + left += 1 + current_window_size = right - left + 1 + if current_window_size == n - 1 and stones[right] - stones[left] + 1 == n - 1: + minMoves = min(minMoves, 2) + else: + minMoves = min(minMoves, n - current_window_size) + + return [minMoves, maxMoves] diff --git a/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.rb b/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.rb new file mode 100644 index 00000000..7ec37c41 --- /dev/null +++ b/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.rb @@ -0,0 +1,24 @@ +# @param {Integer[]} stones +# @return {Integer[]} +def num_moves_stones_ii(stones) + stones.sort! + n = stones.length + + max_moves = [stones[-1] - stones[1] - (n - 2), stones[-2] - stones[0] - (n - 2)].max + + min_moves = n + left = 0 + (0...n).each do |right| + while stones[right] - stones[left] + 1 > n + left += 1 + end + current_window_size = right - left + 1 + if current_window_size == n - 1 && stones[right] - stones[left] + 1 == n - 1 + min_moves = [min_moves, 2].min + else + min_moves = [min_moves, n - current_window_size].min + end + end + + [min_moves, max_moves] +end diff --git a/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.rs b/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.rs new file mode 100644 index 00000000..da13bb88 --- /dev/null +++ b/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.rs @@ -0,0 +1,28 @@ +impl Solution { + pub fn num_moves_stones_ii(stones: Vec) -> Vec { + let mut stones = stones; + stones.sort(); + let n = stones.len(); + + let max_moves = std::cmp::max( + stones[n - 1] - stones[1] - (n as i32 - 2), + stones[n - 2] - stones[0] - (n as i32 - 2) + ); + + let mut min_moves = n as i32; + let mut left = 0; + for right in 0..n { + while stones[right] - stones[left] + 1 > n as i32 { + left += 1; + } + let current_window_size = (right - left + 1) as i32; + if current_window_size == (n as i32 - 1) && stones[right] - stones[left] + 1 == n as i32 - 1 { + min_moves = min_moves.min(2); + } else { + min_moves = min_moves.min(n as i32 - current_window_size); + } + } + + vec![min_moves, max_moves] + } +} diff --git a/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.swift b/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.swift new file mode 100644 index 00000000..850da9b4 --- /dev/null +++ b/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.swift @@ -0,0 +1,25 @@ +class Solution { + func numMovesStonesII(_ stones: [Int]) -> [Int] { + var stones = stones.sorted() + let n = stones.count + + let maxMoves = max(stones[n - 1] - stones[1] - (n - 2), + stones[n - 2] - stones[0] - (n - 2)) + + var minMoves = n + var left = 0 + for right in 0.. n { + left += 1 + } + let currentWindowSize = right - left + 1 + if currentWindowSize == n - 1 && stones[right] - stones[left] + 1 == n - 1 { + minMoves = min(minMoves, 2) + } else { + minMoves = min(minMoves, n - currentWindowSize) + } + } + + return [minMoves, maxMoves] + } +} diff --git a/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.ts b/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.ts new file mode 100644 index 00000000..0053ff40 --- /dev/null +++ b/tests/1001-1500/1040. moving-stones-until-consecutive-ii/sol.ts @@ -0,0 +1,28 @@ +function numMovesStonesII(stones: number[]): number[] { + stones.sort((a, b) => a - b); + const n = stones.length; + + const maxMoves = Math.max( + stones[n - 1] - stones[1] - (n - 2), + stones[n - 2] - stones[0] - (n - 2), + ); + + let minMoves = n; + let left = 0; + for (let right = 0; right < n; right++) { + while (stones[right] - stones[left] + 1 > n) { + left++; + } + const currentWindowSize = right - left + 1; + if ( + currentWindowSize === n - 1 && + stones[right] - stones[left] + 1 === n - 1 + ) { + minMoves = Math.min(minMoves, 2); + } else { + minMoves = Math.min(minMoves, n - currentWindowSize); + } + } + + return [minMoves, maxMoves]; +} diff --git a/tests/1001-1500/1041. robot-bounded-in-circle/manifest.yaml b/tests/1001-1500/1041. robot-bounded-in-circle/manifest.yaml new file mode 100644 index 00000000..04103218 --- /dev/null +++ b/tests/1001-1500/1041. robot-bounded-in-circle/manifest.yaml @@ -0,0 +1,199 @@ +entry: + id: 1041 + title: robot-bounded-in-circle + params: + instructions: + type: string + call: + cpp: Solution().isRobotBounded({instructions}) + rust: Solution::is_robot_bounded({instructions}) + python3: Solution().isRobotBounded({instructions}) + python2: Solution().isRobotBounded({instructions}) + ruby: is_robot_bounded({instructions}) + java: new Solution().isRobotBounded({instructions}) + csharp: new Solution().IsRobotBounded({instructions}) + kotlin: Solution().isRobotBounded({instructions}) + go: isRobotBounded({instructions}) + dart: Solution().isRobotBounded({instructions}) + swift: Solution().isRobotBounded({instructions}) + typescript: isRobotBounded({instructions}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().isRobotBounded(instructions, {result}) + checker: + "class Checker:\n def isRobotBounded(self, instructions, result):\n\ + \ if not isinstance(result, bool):\n return False\n \ + \ directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]\n x = y = dir_index\ + \ = 0\n for instr in instructions:\n if instr == 'G':\n \ + \ x += directions[dir_index][0]\n y += directions[dir_index][1]\n\ + \ elif instr == 'L':\n dir_index = (dir_index - 1)\ + \ % 4\n elif instr == 'R':\n dir_index = (dir_index\ + \ + 1) % 4\n expected = (x == 0 and y == 0) or dir_index != 0\n \ + \ return result == expected\n" +seed: 1041 +tests: + - name: example-1 + in: + instructions: GGLLGG + out: true + - name: example-2 + in: + instructions: GG + out: false + - name: example-3 + in: + instructions: GL + out: true + - name: single-g + in: + instructions: G + out: false + - name: single-l + in: + instructions: L + out: true + - name: single-r + in: + instructions: R + out: true + - name: two-turns + in: + instructions: LR + out: true + - name: loop-square + in: + instructions: GLGLGLG + out: true + - name: straight-then-turn + in: + instructions: GGGLL + out: true + - name: straight-line + in: + instructions: GGGG + out: false + - name: mixed-1 + in: + instructions: GRGRGRGR + out: true + - name: mixed-2 + in: + instructions: GGRR + out: true + - name: mixed-3 + in: + instructions: GLGR + out: false + - name: mixed-4 + in: + instructions: GLLG + out: true + - name: mixed-5 + in: + instructions: GRG + out: true + - name: mixed-6 + in: + instructions: GGRGL + out: false + - name: mixed-7 + in: + instructions: GGGGRRRR + out: false + - name: mixed-8 + in: + instructions: GLR + out: false + - name: mixed-9 + in: + instructions: GRL + out: false + - name: mixed-10 + in: + instructions: GGL + out: true + - name: mixed-11 + in: + instructions: GGR + out: true + - name: mixed-12 + in: + instructions: GLG + out: true + - name: mixed-13 + in: + instructions: GRGGR + out: true + - name: mixed-14 + in: + instructions: GGGLLG + out: true + - name: mixed-15 + in: + instructions: GGGGLLLL + out: false + - name: mixed-16 + in: + instructions: GGRRGG + out: true + - name: mixed-17 + in: + instructions: GLGL + out: true + - name: mixed-18 + in: + instructions: GRGR + out: true + - name: mixed-19 + in: + instructions: GGGGLR + out: false + - name: mixed-20 + in: + instructions: GGLR + out: false + - name: mixed-21 + in: + instructions: GGRL + out: false + - name: mixed-22 + in: + instructions: GGLGL + out: true + - name: mixed-23 + in: + instructions: GRGLG + out: false + - name: mixed-24 + in: + instructions: GGGGR + out: true + - name: mixed-25 + in: + instructions: GGGGL + out: true + - name: mixed-26 + in: + instructions: GGLGG + out: true + - name: mixed-27 + in: + instructions: GGRGG + out: true + - name: mixed-28 + in: + instructions: GLGGG + out: true + - name: mixed-29 + in: + instructions: GRGGG + out: true + - name: mixed-30 + in: + instructions: GLGLGLGLGL + out: true diff --git a/tests/1001-1500/1041. robot-bounded-in-circle/sol.cpp b/tests/1001-1500/1041. robot-bounded-in-circle/sol.cpp new file mode 100644 index 00000000..5bdf0b20 --- /dev/null +++ b/tests/1001-1500/1041. robot-bounded-in-circle/sol.cpp @@ -0,0 +1,20 @@ +class Solution { +public: + bool isRobotBounded(string instructions) { + int directions[4][2] = {{0,1}, {1,0}, {0,-1}, {-1,0}}; + int x = 0, y = 0, dirIndex = 0; + + for (char instr : instructions) { + if (instr == 'G') { + x += directions[dirIndex][0]; + y += directions[dirIndex][1]; + } else if (instr == 'L') { + dirIndex = (dirIndex + 3) % 4; + } else if (instr == 'R') { + dirIndex = (dirIndex + 1) % 4; + } + } + + return (x == 0 && y == 0) || dirIndex != 0; + } +}; diff --git a/tests/1001-1500/1041. robot-bounded-in-circle/sol.cs b/tests/1001-1500/1041. robot-bounded-in-circle/sol.cs new file mode 100644 index 00000000..74028f59 --- /dev/null +++ b/tests/1001-1500/1041. robot-bounded-in-circle/sol.cs @@ -0,0 +1,19 @@ +public class Solution { + public bool IsRobotBounded(string instructions) { + int[][] directions = new int[][] { new int[] {0,1}, new int[] {1,0}, new int[] {0,-1}, new int[] {-1,0} }; + int x = 0, y = 0, dirIndex = 0; + + foreach (char instr in instructions) { + if (instr == 'G') { + x += directions[dirIndex][0]; + y += directions[dirIndex][1]; + } else if (instr == 'L') { + dirIndex = (dirIndex + 3) % 4; + } else if (instr == 'R') { + dirIndex = (dirIndex + 1) % 4; + } + } + + return (x == 0 && y == 0) || dirIndex != 0; + } +} diff --git a/tests/1001-1500/1041. robot-bounded-in-circle/sol.dart b/tests/1001-1500/1041. robot-bounded-in-circle/sol.dart new file mode 100644 index 00000000..9e227d0a --- /dev/null +++ b/tests/1001-1500/1041. robot-bounded-in-circle/sol.dart @@ -0,0 +1,20 @@ +class Solution { + bool isRobotBounded(String instructions) { + List> directions = [[0,1], [1,0], [0,-1], [-1,0]]; + int x = 0, y = 0, dirIndex = 0; + + for (int i = 0; i < instructions.length; i++) { + String instr = instructions[i]; + if (instr == 'G') { + x += directions[dirIndex][0]; + y += directions[dirIndex][1]; + } else if (instr == 'L') { + dirIndex = (dirIndex + 3) % 4; + } else if (instr == 'R') { + dirIndex = (dirIndex + 1) % 4; + } + } + + return (x == 0 && y == 0) || dirIndex != 0; + } +} diff --git a/tests/1001-1500/1041. robot-bounded-in-circle/sol.go b/tests/1001-1500/1041. robot-bounded-in-circle/sol.go new file mode 100644 index 00000000..7fe8b60f --- /dev/null +++ b/tests/1001-1500/1041. robot-bounded-in-circle/sol.go @@ -0,0 +1,17 @@ +func isRobotBounded(instructions string) bool { + directions := [][]int{{0,1}, {1,0}, {0,-1}, {-1,0}} + x, y, dirIndex := 0, 0, 0 + + for _, instr := range instructions { + if instr == 'G' { + x += directions[dirIndex][0] + y += directions[dirIndex][1] + } else if instr == 'L' { + dirIndex = (dirIndex + 3) % 4 + } else if instr == 'R' { + dirIndex = (dirIndex + 1) % 4 + } + } + + return (x == 0 && y == 0) || dirIndex != 0 +} diff --git a/tests/1001-1500/1041. robot-bounded-in-circle/sol.java b/tests/1001-1500/1041. robot-bounded-in-circle/sol.java new file mode 100644 index 00000000..aa654e6a --- /dev/null +++ b/tests/1001-1500/1041. robot-bounded-in-circle/sol.java @@ -0,0 +1,19 @@ +class Solution { + public boolean isRobotBounded(String instructions) { + int[][] directions = {{0,1}, {1,0}, {0,-1}, {-1,0}}; + int x = 0, y = 0, dirIndex = 0; + + for (char instr : instructions.toCharArray()) { + if (instr == 'G') { + x += directions[dirIndex][0]; + y += directions[dirIndex][1]; + } else if (instr == 'L') { + dirIndex = (dirIndex + 3) % 4; + } else if (instr == 'R') { + dirIndex = (dirIndex + 1) % 4; + } + } + + return (x == 0 && y == 0) || dirIndex != 0; + } +} diff --git a/tests/1001-1500/1041. robot-bounded-in-circle/sol.kt b/tests/1001-1500/1041. robot-bounded-in-circle/sol.kt new file mode 100644 index 00000000..ca03b7a9 --- /dev/null +++ b/tests/1001-1500/1041. robot-bounded-in-circle/sol.kt @@ -0,0 +1,21 @@ +class Solution { + fun isRobotBounded(instructions: String): Boolean { + val directions = arrayOf(intArrayOf(0,1), intArrayOf(1,0), intArrayOf(0,-1), intArrayOf(-1,0)) + var x = 0 + var y = 0 + var dirIndex = 0 + + for (instr in instructions) { + when (instr) { + 'G' -> { + x += directions[dirIndex][0] + y += directions[dirIndex][1] + } + 'L' -> dirIndex = (dirIndex + 3) % 4 + 'R' -> dirIndex = (dirIndex + 1) % 4 + } + } + + return (x == 0 && y == 0) || dirIndex != 0 + } +} diff --git a/tests/1001-1500/1041. robot-bounded-in-circle/sol.py b/tests/1001-1500/1041. robot-bounded-in-circle/sol.py new file mode 100644 index 00000000..9a5ff9f4 --- /dev/null +++ b/tests/1001-1500/1041. robot-bounded-in-circle/sol.py @@ -0,0 +1,19 @@ +class Solution(object): + def isRobotBounded(self, instructions): + """ + :type instructions: str + :rtype: bool + """ + directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] + x, y, dir_index = 0, 0, 0 + + for instr in instructions: + if instr == "G": + x += directions[dir_index][0] + y += directions[dir_index][1] + elif instr == "L": + dir_index = (dir_index - 1) % 4 + elif instr == "R": + dir_index = (dir_index + 1) % 4 + + return (x == 0 and y == 0) or dir_index != 0 diff --git a/tests/1001-1500/1041. robot-bounded-in-circle/sol.py2 b/tests/1001-1500/1041. robot-bounded-in-circle/sol.py2 new file mode 100644 index 00000000..0080a2c9 --- /dev/null +++ b/tests/1001-1500/1041. robot-bounded-in-circle/sol.py2 @@ -0,0 +1,19 @@ +class Solution(object): + def isRobotBounded(self, instructions): + """ + :type instructions: str + :rtype: bool + """ + directions = [(0,1), (1,0), (0,-1), (-1,0)] + x, y, dir_index = 0, 0, 0 + + for instr in instructions: + if instr == 'G': + x += directions[dir_index][0] + y += directions[dir_index][1] + elif instr == 'L': + dir_index = (dir_index - 1) % 4 + elif instr == 'R': + dir_index = (dir_index + 1) % 4 + + return (x == 0 and y == 0) or dir_index != 0 diff --git a/tests/1001-1500/1041. robot-bounded-in-circle/sol.rb b/tests/1001-1500/1041. robot-bounded-in-circle/sol.rb new file mode 100644 index 00000000..3f04d567 --- /dev/null +++ b/tests/1001-1500/1041. robot-bounded-in-circle/sol.rb @@ -0,0 +1,19 @@ +# @param {String} instructions +# @return {Boolean} +def is_robot_bounded(instructions) + directions = [[0,1], [1,0], [0,-1], [-1,0]] + x, y, dir_index = 0, 0, 0 + + instructions.each_char do |instr| + if instr == 'G' + x += directions[dir_index][0] + y += directions[dir_index][1] + elsif instr == 'L' + dir_index = (dir_index - 1) % 4 + elsif instr == 'R' + dir_index = (dir_index + 1) % 4 + end + end + + return (x == 0 && y == 0) || dir_index != 0 +end diff --git a/tests/1001-1500/1041. robot-bounded-in-circle/sol.rs b/tests/1001-1500/1041. robot-bounded-in-circle/sol.rs new file mode 100644 index 00000000..aa622a8d --- /dev/null +++ b/tests/1001-1500/1041. robot-bounded-in-circle/sol.rs @@ -0,0 +1,21 @@ +impl Solution { + pub fn is_robot_bounded(instructions: String) -> bool { + let directions = [(0,1), (1,0), (0,-1), (-1,0)]; + let mut x = 0; + let mut y = 0; + let mut dir_index = 0; + + for instr in instructions.chars() { + if instr == 'G' { + x += directions[dir_index].0; + y += directions[dir_index].1; + } else if instr == 'L' { + dir_index = (dir_index + 3) % 4; + } else if instr == 'R' { + dir_index = (dir_index + 1) % 4; + } + } + + (x == 0 && y == 0) || dir_index != 0 + } +} diff --git a/tests/1001-1500/1041. robot-bounded-in-circle/sol.swift b/tests/1001-1500/1041. robot-bounded-in-circle/sol.swift new file mode 100644 index 00000000..922552da --- /dev/null +++ b/tests/1001-1500/1041. robot-bounded-in-circle/sol.swift @@ -0,0 +1,19 @@ +class Solution { + func isRobotBounded(_ instructions: String) -> Bool { + let directions = [(0,1), (1,0), (0,-1), (-1,0)] + var x = 0, y = 0, dirIndex = 0 + + for instr in instructions { + if instr == "G" { + x += directions[dirIndex].0 + y += directions[dirIndex].1 + } else if instr == "L" { + dirIndex = (dirIndex + 3) % 4 + } else if instr == "R" { + dirIndex = (dirIndex + 1) % 4 + } + } + + return (x == 0 && y == 0) || dirIndex != 0 + } +} diff --git a/tests/1001-1500/1041. robot-bounded-in-circle/sol.ts b/tests/1001-1500/1041. robot-bounded-in-circle/sol.ts new file mode 100644 index 00000000..9cca812f --- /dev/null +++ b/tests/1001-1500/1041. robot-bounded-in-circle/sol.ts @@ -0,0 +1,24 @@ +function isRobotBounded(instructions: string): boolean { + const directions: number[][] = [ + [0, 1], + [1, 0], + [0, -1], + [-1, 0], + ]; + let x = 0, + y = 0, + dirIndex = 0; + + for (const instr of instructions) { + if (instr === "G") { + x += directions[dirIndex][0]; + y += directions[dirIndex][1]; + } else if (instr === "L") { + dirIndex = (dirIndex + 3) % 4; + } else if (instr === "R") { + dirIndex = (dirIndex + 1) % 4; + } + } + + return (x === 0 && y === 0) || dirIndex !== 0; +} diff --git a/tests/1001-1500/1042. flower-planting-with-no-adjacent/manifest.yaml b/tests/1001-1500/1042. flower-planting-with-no-adjacent/manifest.yaml new file mode 100644 index 00000000..4bc004e6 --- /dev/null +++ b/tests/1001-1500/1042. flower-planting-with-no-adjacent/manifest.yaml @@ -0,0 +1,434 @@ +entry: + id: 1042 + title: flower-planting-with-no-adjacent + params: + n: + type: int + paths: + type: array + items: + type: array + items: + type: int + call: + cpp: "Solution().gardenNoAdj({n}, {paths})" + rust: "Solution::garden_no_adj({n}, {paths})" + python3: "Solution().gardenNoAdj({n}, {paths})" + python2: "Solution().gardenNoAdj({n}, {paths})" + ruby: "garden_no_adj({n}, {paths})" + java: "new Solution().gardenNoAdj({n}, {paths})" + csharp: "new Solution().GardenNoAdj({n}, {paths})" + kotlin: "Solution().gardenNoAdj({n}, {paths})" + go: "gardenNoAdj({n}, {paths})" + dart: "Solution().gardenNoAdj({n}, {paths})" + swift: "Solution().gardenNoAdj({n}, {paths})" + typescript: "gardenNoAdj({n}, {paths})" +judge: + type: exact +limits: + time_ms: 2000 + memory_mb: 256 +oracle: + python3: + call: "Checker().gardenNoAdj(n, paths, {result})" + checker: | + class Checker: + def gardenNoAdj(self, n, paths, result): + if not isinstance(result, list) or len(result) != n: + return False + if any((not isinstance(x, int)) or x < 1 or x > 4 for x in result): + return False + for u, v in paths: + if result[u - 1] == result[v - 1]: + return False + return True +seed: 1042 +tests: + - name: example-1 + in: + n: 3 + paths: + - [1, 2] + - [2, 3] + - [3, 1] + - name: example-2 + in: + n: 4 + paths: + - [1, 2] + - [3, 4] + - name: example-3 + in: + n: 4 + paths: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 1] + - [1, 3] + - [2, 4] + - name: single-garden + in: + n: 1 + paths: [] + - name: two-gardens + in: + n: 2 + paths: + - [1, 2] + - name: three-line + in: + n: 3 + paths: + - [1, 2] + - [2, 3] + - name: four-cycle + in: + n: 4 + paths: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 1] + - name: star-1 + in: + n: 5 + paths: + - [1, 2] + - [1, 3] + - [1, 4] + - [1, 5] + - name: path-5 + in: + n: 5 + paths: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 5] + - name: disconnected-1 + in: + n: 6 + paths: + - [1, 2] + - [3, 4] + - name: disconnected-2 + in: + n: 6 + paths: + - [1, 2] + - [2, 3] + - [4, 5] + - name: triangle-plus-edge + in: + n: 5 + paths: + - [1, 2] + - [2, 3] + - [3, 1] + - [4, 5] + - name: dense-1 + in: + n: 6 + paths: + - [1, 2] + - [1, 3] + - [1, 4] + - [2, 5] + - [3, 6] + - name: dense-2 + in: + n: 7 + paths: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 5] + - [5, 6] + - [6, 7] + - name: dense-3 + in: + n: 7 + paths: + - [1, 2] + - [1, 3] + - [2, 4] + - [2, 5] + - [3, 6] + - [3, 7] + - name: sparse-1 + in: + n: 8 + paths: + - [1, 8] + - [2, 7] + - name: sparse-2 + in: + n: 8 + paths: + - [1, 2] + - [3, 4] + - [5, 6] + - [7, 8] + - name: sparse-3 + in: + n: 8 + paths: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 5] + - [5, 6] + - [6, 7] + - [7, 8] + - name: ring-8 + in: + n: 8 + paths: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 5] + - [5, 6] + - [6, 7] + - [7, 8] + - [8, 1] + - name: wheel-lite + in: + n: 8 + paths: + - [1, 2] + - [1, 3] + - [1, 4] + - [2, 5] + - [3, 6] + - [4, 7] + - [5, 8] + - name: tree-1 + in: + n: 9 + paths: + - [1, 2] + - [1, 3] + - [2, 4] + - [2, 5] + - [3, 6] + - [3, 7] + - [7, 8] + - [7, 9] + - name: tree-2 + in: + n: 9 + paths: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 5] + - [5, 6] + - [6, 7] + - [7, 8] + - [8, 9] + - name: cycle-5 + in: + n: 5 + paths: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 5] + - [5, 1] + - name: cycle-6 + in: + n: 6 + paths: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 5] + - [5, 6] + - [6, 1] + - name: cycle-with-chord + in: + n: 6 + paths: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 5] + - [5, 6] + - [6, 1] + - [1, 3] + - name: cycle-with-two-chords + in: + n: 6 + paths: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 5] + - [5, 6] + - [6, 1] + - [1, 3] + - [2, 4] + - name: ladder-1 + in: + n: 10 + paths: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 5] + - [6, 7] + - [7, 8] + - [8, 9] + - [9, 10] + - [5, 6] + - name: ladder-2 + in: + n: 10 + paths: + - [1, 10] + - [2, 9] + - [3, 8] + - [4, 7] + - [5, 6] + - name: fan-1 + in: + n: 10 + paths: + - [1, 2] + - [1, 3] + - [1, 4] + - [2, 5] + - [2, 6] + - [3, 7] + - [3, 8] + - [4, 9] + - [4, 10] + - name: fan-2 + in: + n: 10 + paths: + - [1, 2] + - [1, 3] + - [2, 4] + - [2, 5] + - [3, 6] + - [3, 7] + - [4, 8] + - [5, 9] + - [6, 10] + - name: split-graph + in: + n: 11 + paths: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 5] + - [5, 1] + - [6, 7] + - [7, 8] + - [8, 9] + - [9, 10] + - [10, 11] + - name: sparse-chain + in: + n: 11 + paths: + - [1, 2] + - [2, 3] + - [4, 5] + - [5, 6] + - [7, 8] + - [8, 9] + - [9, 10] + - name: mixed-1 + in: + n: 12 + paths: + - [1, 2] + - [2, 3] + - [3, 1] + - [4, 5] + - [5, 6] + - [6, 4] + - [7, 8] + - [8, 9] + - name: mixed-2 + in: + n: 12 + paths: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 1] + - [5, 6] + - [6, 7] + - [7, 8] + - [8, 5] + - [9, 10] + - [10, 11] + - [11, 12] + - name: cycle-10 + in: + n: 10 + paths: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 5] + - [5, 6] + - [6, 7] + - [7, 8] + - [8, 9] + - [9, 10] + - [10, 1] + - name: cycle-with-tail + in: + n: 10 + paths: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 5] + - [5, 1] + - [5, 6] + - [6, 7] + - [7, 8] + - [8, 9] + - [9, 10] + - name: max-ish-sparse + in: + n: 15 + paths: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 5] + - [6, 7] + - [7, 8] + - [8, 9] + - [9, 10] + - [11, 12] + - [12, 13] + - [13, 14] + - [14, 15] + - name: max-ish-tree + in: + n: 15 + paths: + - [1, 2] + - [1, 3] + - [2, 4] + - [2, 5] + - [3, 6] + - [3, 7] + - [4, 8] + - [4, 9] + - [5, 10] + - [5, 11] + - [6, 12] + - [6, 13] + - [7, 14] + - [7, 15] diff --git a/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.cpp b/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.cpp new file mode 100644 index 00000000..519c8d5d --- /dev/null +++ b/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.cpp @@ -0,0 +1,37 @@ +class Solution { +public: + vector gardenNoAdj(int n, vector>& paths) { + unordered_map> graph; + + for (auto& path : paths) { + int u = path[0]; + int v = path[1]; + graph[u].push_back(v); + graph[v].push_back(u); + } + + for (int node = 1; node <= n; node++) { + if (graph.find(node) == graph.end()) { + graph[node] = vector(); + } + } + + vector answer(n + 1, 0); + + for (int i = 1; i <= n; i++) { + unordered_set used; + for (int nei : graph[i]) { + used.insert(answer[nei]); + } + + for (int flower = 1; flower <= 4; flower++) { + if (used.find(flower) == used.end()) { + answer[i] = flower; + break; + } + } + } + + return vector(answer.begin() + 1, answer.end()); + } +}; diff --git a/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.cs b/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.cs new file mode 100644 index 00000000..dfa6eec4 --- /dev/null +++ b/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.cs @@ -0,0 +1,38 @@ +public class Solution { + public int[] GardenNoAdj(int n, int[][] paths) { + Dictionary> graph = new Dictionary>(); + + foreach (var path in paths) { + int u = path[0]; + int v = path[1]; + if (!graph.ContainsKey(u)) graph[u] = new List(); + if (!graph.ContainsKey(v)) graph[v] = new List(); + graph[u].Add(v); + graph[v].Add(u); + } + + for (int node = 1; node <= n; node++) { + if (!graph.ContainsKey(node)) { + graph[node] = new List(); + } + } + + int[] answer = new int[n + 1]; + + for (int i = 1; i <= n; i++) { + HashSet used = new HashSet(); + foreach (int nei in graph[i]) { + used.Add(answer[nei]); + } + + for (int flower = 1; flower <= 4; flower++) { + if (!used.Contains(flower)) { + answer[i] = flower; + break; + } + } + } + + return answer.Skip(1).ToArray(); + } +} diff --git a/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.dart b/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.dart new file mode 100644 index 00000000..75de6d47 --- /dev/null +++ b/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.dart @@ -0,0 +1,36 @@ +class Solution { + List gardenNoAdj(int n, List> paths) { + Map> graph = {}; + + for (var path in paths) { + int u = path[0]; + int v = path[1]; + graph.putIfAbsent(u, () => []); + graph.putIfAbsent(v, () => []); + graph[u]!.add(v); + graph[v]!.add(u); + } + + for (int node = 1; node <= n; node++) { + graph.putIfAbsent(node, () => []); + } + + List answer = List.filled(n + 1, 0); + + for (int i = 1; i <= n; i++) { + Set used = {}; + for (var nei in graph[i]!) { + used.add(answer[nei]); + } + + for (int flower = 1; flower <= 4; flower++) { + if (!used.contains(flower)) { + answer[i] = flower; + break; + } + } + } + + return answer.sublist(1); + } +} diff --git a/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.go b/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.go new file mode 100644 index 00000000..5b95b205 --- /dev/null +++ b/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.go @@ -0,0 +1,33 @@ +func gardenNoAdj(n int, paths [][]int) []int { + graph := make(map[int][]int) + + for _, path := range paths { + u, v := path[0], path[1] + graph[u] = append(graph[u], v) + graph[v] = append(graph[v], u) + } + + for node := 1; node <= n; node++ { + if _, exists := graph[node]; !exists { + graph[node] = []int{} + } + } + + answer := make([]int, n+1) + + for i := 1; i <= n; i++ { + used := make(map[int]bool) + for _, nei := range graph[i] { + used[answer[nei]] = true + } + + for flower := 1; flower <= 4; flower++ { + if !used[flower] { + answer[i] = flower + break + } + } + } + + return answer[1:] +} diff --git a/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.java b/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.java new file mode 100644 index 00000000..daeadfb7 --- /dev/null +++ b/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.java @@ -0,0 +1,34 @@ +class Solution { + public int[] gardenNoAdj(int n, int[][] paths) { + Map> graph = new HashMap<>(); + + for (int[] path : paths) { + int u = path[0]; + int v = path[1]; + graph.computeIfAbsent(u, k -> new ArrayList<>()).add(v); + graph.computeIfAbsent(v, k -> new ArrayList<>()).add(u); + } + + for (int node = 1; node <= n; node++) { + graph.putIfAbsent(node, new ArrayList<>()); + } + + int[] answer = new int[n + 1]; + + for (int i = 1; i <= n; i++) { + Set used = new HashSet<>(); + for (int nei : graph.get(i)) { + used.add(answer[nei]); + } + + for (int flower = 1; flower <= 4; flower++) { + if (!used.contains(flower)) { + answer[i] = flower; + break; + } + } + } + + return Arrays.copyOfRange(answer, 1, n + 1); + } +} diff --git a/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.kt b/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.kt new file mode 100644 index 00000000..550670c6 --- /dev/null +++ b/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.kt @@ -0,0 +1,34 @@ +class Solution { + fun gardenNoAdj(n: Int, paths: Array): IntArray { + val graph = mutableMapOf>() + + for (path in paths) { + val u = path[0] + val v = path[1] + graph.computeIfAbsent(u) { mutableListOf() }.add(v) + graph.computeIfAbsent(v) { mutableListOf() }.add(u) + } + + for (node in 1..n) { + graph.putIfAbsent(node, mutableListOf()) + } + + val answer = IntArray(n + 1) + + for (i in 1..n) { + val used = mutableSetOf() + for (nei in graph[i]!!) { + used.add(answer[nei]) + } + + for (flower in 1..4) { + if (flower !in used) { + answer[i] = flower + break + } + } + } + + return answer.sliceArray(1..n) + } +} diff --git a/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.py b/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.py new file mode 100644 index 00000000..81b9501e --- /dev/null +++ b/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.py @@ -0,0 +1,28 @@ +class Solution: + def gardenNoAdj(self, n: int, paths: List[List[int]]) -> List[int]: + graph = {} + + for u, v in paths: + if u not in graph: + graph[u] = [] + if v not in graph: + graph[v] = [] + + graph[u].append(v) + graph[v].append(u) + + for node in range(1, n + 1): + if node not in graph: + graph[node] = [] + + answer = [0] * (n + 1) + + for i in range(1, n + 1): + used = set(answer[nei] for nei in graph[i]) + + for flower in range(1, 5): + if flower not in used: + answer[i] = flower + break + + return answer[1:] diff --git a/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.py2 b/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.py2 new file mode 100644 index 00000000..05dbf6d1 --- /dev/null +++ b/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.py2 @@ -0,0 +1,32 @@ +class Solution(object): + def gardenNoAdj(self, n, paths): + """ + :type n: int + :type paths: List[List[int]] + :rtype: List[int] + """ + graph = {} + + for u, v in paths: + if u not in graph: + graph[u] = [] + if v not in graph: + graph[v] = [] + graph[u].append(v) + graph[v].append(u) + + for node in range(1, n + 1): + if node not in graph: + graph[node] = [] + + answer = [0] * (n + 1) + + for i in range(1, n + 1): + used = set(answer[nei] for nei in graph[i]) + + for flower in range(1, 5): + if flower not in used: + answer[i] = flower + break + + return answer[1:] diff --git a/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.rb b/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.rb new file mode 100644 index 00000000..7528baaa --- /dev/null +++ b/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.rb @@ -0,0 +1,35 @@ +# @param {Integer} n +# @param {Integer[][]} paths +# @return {Integer[]} +def garden_no_adj(n, paths) + graph = {} + + paths.each do |u, v| + graph[u] = [] unless graph.key?(u) + graph[v] = [] unless graph.key?(v) + graph[u] << v + graph[v] << u + end + + (1..n).each do |node| + graph[node] = [] unless graph.key?(node) + end + + answer = [0] * (n + 1) + + (1..n).each do |i| + used = Set.new + graph[i].each do |nei| + used.add(answer[nei]) + end + + (1..4).each do |flower| + unless used.include?(flower) + answer[i] = flower + break + end + end + end + + answer[1..-1] +end diff --git a/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.rs b/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.rs new file mode 100644 index 00000000..efe6f34e --- /dev/null +++ b/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.rs @@ -0,0 +1,38 @@ +impl Solution { + pub fn garden_no_adj(n: i32, paths: Vec>) -> Vec { + use std::collections::{HashMap, HashSet}; + + let mut graph: HashMap> = HashMap::new(); + + for path in &paths { + let u = path[0]; + let v = path[1]; + graph.entry(u).or_insert_with(Vec::new).push(v); + graph.entry(v).or_insert_with(Vec::new).push(u); + } + + for node in 1..=n { + graph.entry(node).or_insert_with(Vec::new); + } + + let mut answer = vec![0; (n + 1) as usize]; + + for i in 1..=n { + let mut used = HashSet::new(); + if let Some(neighbors) = graph.get(&i) { + for &nei in neighbors { + used.insert(answer[nei as usize]); + } + } + + for flower in 1..=4 { + if !used.contains(&flower) { + answer[i as usize] = flower; + break; + } + } + } + + answer[1..].to_vec() + } +} diff --git a/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.swift b/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.swift new file mode 100644 index 00000000..1dd26513 --- /dev/null +++ b/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.swift @@ -0,0 +1,36 @@ +class Solution { + func gardenNoAdj(_ n: Int, _ paths: [[Int]]) -> [Int] { + var graph = [Int: [Int]]() + + for path in paths { + let u = path[0] + let v = path[1] + graph[u, default: []].append(v) + graph[v, default: []].append(u) + } + + for node in 1...n { + if graph[node] == nil { + graph[node] = [] + } + } + + var answer = [Int](repeating: 0, count: n + 1) + + for i in 1...n { + var used = Set() + for nei in graph[i]! { + used.insert(answer[nei]) + } + + for flower in 1...4 { + if !used.contains(flower) { + answer[i] = flower + break + } + } + } + + return Array(answer[1...]) + } +} diff --git a/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.ts b/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.ts new file mode 100644 index 00000000..bfbb6cde --- /dev/null +++ b/tests/1001-1500/1042. flower-planting-with-no-adjacent/sol.ts @@ -0,0 +1,34 @@ +function gardenNoAdj(n: number, paths: number[][]): number[] { + const graph: Map = new Map(); + + for (const [u, v] of paths) { + if (!graph.has(u)) graph.set(u, []); + if (!graph.has(v)) graph.set(v, []); + graph.get(u)!.push(v); + graph.get(v)!.push(u); + } + + for (let node = 1; node <= n; node++) { + if (!graph.has(node)) { + graph.set(node, []); + } + } + + const answer: number[] = new Array(n + 1).fill(0); + + for (let i = 1; i <= n; i++) { + const used: Set = new Set(); + for (const nei of graph.get(i)!) { + used.add(answer[nei]); + } + + for (let flower = 1; flower <= 4; flower++) { + if (!used.has(flower)) { + answer[i] = flower; + break; + } + } + } + + return answer.slice(1); +} diff --git a/tests/1001-1500/1043. partition-array-for-maximum-sum/manifest.yaml b/tests/1001-1500/1043. partition-array-for-maximum-sum/manifest.yaml new file mode 100644 index 00000000..c32806e5 --- /dev/null +++ b/tests/1001-1500/1043. partition-array-for-maximum-sum/manifest.yaml @@ -0,0 +1,421 @@ +entry: + id: 1043 + title: partition-array-for-maximum-sum + params: + arr: + type: array + items: + type: int + k: + type: int + call: + cpp: Solution().maxSumAfterPartitioning({arr}, {k}) + rust: Solution::max_sum_after_partitioning({arr}, {k}) + python3: Solution().maxSumAfterPartitioning({arr}, {k}) + python2: Solution().maxSumAfterPartitioning({arr}, {k}) + ruby: max_sum_after_partitioning({arr}, {k}) + java: new Solution().maxSumAfterPartitioning({arr}, {k}) + csharp: new Solution().MaxSumAfterPartitioning({arr}, {k}) + kotlin: Solution().maxSumAfterPartitioning({arr}, {k}) + go: maxSumAfterPartitioning({arr}, {k}) + dart: Solution().maxSumAfterPartitioning({arr}, {k}) + swift: Solution().maxSumAfterPartitioning({arr}, {k}) + typescript: maxSumAfterPartitioning({arr}, {k}) +judge: + type: exact +limits: + time_ms: 2000 + memory_mb: 256 +oracle: + python3: + call: Checker().maxSumAfterPartitioning(arr, k, {result}) + checker: + "class Checker:\n def maxSumAfterPartitioning(self, arr, k, result):\n\ + \ if not isinstance(result, int):\n return False\n \ + \ n = len(arr)\n dp = [0] * (n + 1)\n for i in range(1, n + 1):\n\ + \ curr = 0\n for j in range(1, k + 1):\n \ + \ if i < j:\n break\n curr = max(curr, arr[i\ + \ - j])\n dp[i] = max(dp[i], dp[i - j] + curr * j)\n return\ + \ result == dp[n]\n" +seed: 1043 +tests: + - name: example-1 + in: + arr: + - 1 + - 15 + - 7 + - 9 + - 2 + - 5 + - 10 + k: 3 + out: 84 + - name: example-2 + in: + arr: + - 1 + - 4 + - 1 + - 5 + - 7 + - 3 + - 6 + - 1 + - 9 + - 9 + - 3 + k: 4 + out: 83 + - name: example-3 + in: + arr: + - 1 + k: 1 + out: 1 + - name: single-zero + in: + arr: + - 0 + k: 1 + out: 0 + - name: all-equal-1 + in: + arr: + - 5 + - 5 + k: 1 + out: 10 + - name: all-equal-2 + in: + arr: + - 5 + - 5 + k: 2 + out: 10 + - name: all-equal-3 + in: + arr: + - 2 + - 2 + - 2 + k: 3 + out: 6 + - name: ascending-k1 + in: + arr: + - 1 + - 2 + - 3 + - 4 + - 5 + k: 1 + out: 15 + - name: ascending-k2 + in: + arr: + - 1 + - 2 + - 3 + - 4 + - 5 + k: 2 + out: 17 + - name: ascending-k5 + in: + arr: + - 1 + - 2 + - 3 + - 4 + - 5 + k: 5 + out: 25 + - name: descending-k2 + in: + arr: + - 9 + - 8 + - 7 + - 6 + k: 2 + out: 32 + - name: descending-k4 + in: + arr: + - 9 + - 8 + - 7 + - 6 + k: 4 + out: 36 + - name: mixed-1 + in: + arr: + - 3 + - 1 + - 2 + k: 2 + out: 8 + - name: mixed-2 + in: + arr: + - 3 + - 1 + - 2 + k: 3 + out: 9 + - name: mixed-3 + in: + arr: + - 1 + - 4 + - 1 + k: 2 + out: 9 + - name: mixed-4 + in: + arr: + - 1 + - 4 + - 1 + k: 3 + out: 12 + - name: mixed-5 + in: + arr: + - 10 + - 1 + - 10 + k: 2 + out: 30 + - name: mixed-6 + in: + arr: + - 10 + - 1 + - 10 + k: 3 + out: 30 + - name: mixed-7 + in: + arr: + - 2 + - 7 + - 1 + - 8 + - 2 + - 8 + k: 3 + out: 46 + - name: mixed-8 + in: + arr: + - 2 + - 7 + - 1 + - 8 + - 2 + - 8 + k: 4 + out: 48 + - name: mixed-9 + in: + arr: + - 1 + - 15 + - 7 + - 9 + k: 2 + out: 48 + - name: mixed-10 + in: + arr: + - 1 + - 15 + - 7 + - 9 + k: 4 + out: 60 + - name: mixed-11 + in: + arr: + - 5 + - 1 + - 5 + - 1 + - 5 + k: 2 + out: 25 + - name: mixed-12 + in: + arr: + - 5 + - 1 + - 5 + - 1 + - 5 + k: 3 + out: 25 + - name: mixed-13 + in: + arr: + - 9 + - 1 + - 2 + - 3 + - 9 + k: 2 + out: 38 + - name: mixed-14 + in: + arr: + - 9 + - 1 + - 2 + - 3 + - 9 + k: 3 + out: 45 + - name: mixed-15 + in: + arr: + - 4 + - 2 + - 8 + - 1 + - 7 + - 3 + k: 2 + out: 38 + - name: mixed-16 + in: + arr: + - 4 + - 2 + - 8 + - 1 + - 7 + - 3 + k: 3 + out: 45 + - name: mixed-17 + in: + arr: + - 1 + - 100 + - 1 + - 100 + k: 2 + out: 400 + - name: mixed-18 + in: + arr: + - 1 + - 100 + - 1 + - 100 + k: 3 + out: 400 + - name: mixed-19 + in: + arr: + - 6 + - 2 + - 4 + - 8 + - 3 + - 7 + k: 2 + out: 42 + - name: mixed-20 + in: + arr: + - 6 + - 2 + - 4 + - 8 + - 3 + - 7 + k: 4 + out: 46 + - name: repeated-1 + in: + arr: + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + k: 3 + out: 6 + - name: repeated-2 + in: + arr: + - 7 + - 7 + - 7 + - 7 + - 7 + - 7 + k: 4 + out: 42 + - name: repeated-3 + in: + arr: + - 0 + - 0 + - 0 + - 0 + - 0 + k: 2 + out: 0 + - name: mixed-21 + in: + arr: + - 8 + - 1 + - 9 + - 2 + - 10 + - 3 + - 11 + k: 3 + out: 69 + - name: mixed-22 + in: + arr: + - 8 + - 1 + - 9 + - 2 + - 10 + - 3 + - 11 + k: 4 + out: 71 + - name: mixed-23 + in: + arr: + - 1 + - 2 + - 1 + - 2 + - 1 + - 2 + - 1 + k: 2 + out: 13 + - name: mixed-24 + in: + arr: + - 1 + - 2 + - 1 + - 2 + - 1 + - 2 + - 1 + k: 3 + out: 14 diff --git a/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.cpp b/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.cpp new file mode 100644 index 00000000..8a671ac8 --- /dev/null +++ b/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.cpp @@ -0,0 +1,16 @@ +class Solution { +public: + int maxSumAfterPartitioning(vector& arr, int k) { + int n = arr.size(); + vector dp(n + 1, 0); + for (int i = 1; i <= n; i++) { + int curr = 0; + for (int j = 1; j <= k; j++) { + if (i < j) break; + curr = max(curr, arr[i - j]); + dp[i] = max(dp[i], dp[i - j] + curr * j); + } + } + return dp[n]; + } +}; diff --git a/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.cs b/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.cs new file mode 100644 index 00000000..f7098fd2 --- /dev/null +++ b/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.cs @@ -0,0 +1,15 @@ +public class Solution { + public int MaxSumAfterPartitioning(int[] arr, int k) { + int n = arr.Length; + int[] dp = new int[n + 1]; + for (int i = 1; i <= n; i++) { + int curr = 0; + for (int j = 1; j <= k; j++) { + if (i < j) break; + curr = Math.Max(curr, arr[i - j]); + dp[i] = Math.Max(dp[i], dp[i - j] + curr * j); + } + } + return dp[n]; + } +} diff --git a/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.dart b/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.dart new file mode 100644 index 00000000..1699a17f --- /dev/null +++ b/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.dart @@ -0,0 +1,17 @@ +class Solution { + int maxSumAfterPartitioning(List arr, int k) { + int n = arr.length; + List dp = List.filled(n + 1, 0); + for (int i = 1; i <= n; i++) { + int curr = 0; + for (int j = 1; j <= k; j++) { + if (i < j) break; + if (arr[i - j] > curr) curr = arr[i - j]; + if (dp[i - j] + curr * j > dp[i]) { + dp[i] = dp[i - j] + curr * j; + } + } + } + return dp[n]; + } +} diff --git a/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.go b/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.go new file mode 100644 index 00000000..1c6cb8a1 --- /dev/null +++ b/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.go @@ -0,0 +1,19 @@ +func maxSumAfterPartitioning(arr []int, k int) int { + n := len(arr) + dp := make([]int, n+1) + for i := 1; i <= n; i++ { + curr := 0 + for j := 1; j <= k; j++ { + if i < j { + break + } + if arr[i-j] > curr { + curr = arr[i-j] + } + if dp[i-j]+curr*j > dp[i] { + dp[i] = dp[i-j] + curr*j + } + } + } + return dp[n] +} diff --git a/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.java b/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.java new file mode 100644 index 00000000..4f1d847d --- /dev/null +++ b/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.java @@ -0,0 +1,15 @@ +class Solution { + public int maxSumAfterPartitioning(int[] arr, int k) { + int n = arr.length; + int[] dp = new int[n + 1]; + for (int i = 1; i <= n; i++) { + int curr = 0; + for (int j = 1; j <= k; j++) { + if (i < j) break; + curr = Math.max(curr, arr[i - j]); + dp[i] = Math.max(dp[i], dp[i - j] + curr * j); + } + } + return dp[n]; + } +} diff --git a/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.kt b/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.kt new file mode 100644 index 00000000..0af75789 --- /dev/null +++ b/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.kt @@ -0,0 +1,15 @@ +class Solution { + fun maxSumAfterPartitioning(arr: IntArray, k: Int): Int { + val n = arr.size + val dp = IntArray(n + 1) + for (i in 1..n) { + var curr = 0 + for (j in 1..k) { + if (i < j) break + curr = maxOf(curr, arr[i - j]) + dp[i] = maxOf(dp[i], dp[i - j] + curr * j) + } + } + return dp[n] + } +} diff --git a/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.py b/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.py new file mode 100644 index 00000000..b882624a --- /dev/null +++ b/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.py @@ -0,0 +1,13 @@ +class Solution: + def maxSumAfterPartitioning(self, arr: List[int], k: int) -> int: + n = len(arr) + dp = [0] * (n + 1) + for i in range(1, n + 1): + curr = 0 + for j in range(1, k + 1): + if i < j: + break + curr = max(curr, arr[i - j]) + dp[i] = max(dp[i], dp[i - j] + curr * j) + + return dp[n] diff --git a/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.py2 b/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.py2 new file mode 100644 index 00000000..3f83f531 --- /dev/null +++ b/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.py2 @@ -0,0 +1,12 @@ +class Solution(object): + def maxSumAfterPartitioning(self, arr, k): + n = len(arr) + dp = [0] * (n + 1) + for i in range(1, n + 1): + curr = 0 + for j in range(1, k + 1): + if i < j: + break + curr = max(curr, arr[i - j]) + dp[i] = max(dp[i], dp[i - j] + curr * j) + return dp[n] diff --git a/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.rb b/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.rb new file mode 100644 index 00000000..b23d2ea9 --- /dev/null +++ b/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.rb @@ -0,0 +1,16 @@ +# @param {Integer[]} arr +# @param {Integer} k +# @return {Integer} +def max_sum_after_partitioning(arr, k) + n = arr.length + dp = Array.new(n + 1, 0) + (1..n).each do |i| + curr = 0 + (1..k).each do |j| + break if i < j + curr = [curr, arr[i - j]].max + dp[i] = [dp[i], dp[i - j] + curr * j].max + end + end + dp[n] +end diff --git a/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.rs b/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.rs new file mode 100644 index 00000000..229d7932 --- /dev/null +++ b/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.rs @@ -0,0 +1,18 @@ +impl Solution { + pub fn max_sum_after_partitioning(arr: Vec, k: i32) -> i32 { + let n = arr.len(); + let k = k as usize; + let mut dp = vec![0; n + 1]; + for i in 1..=n { + let mut curr = 0; + for j in 1..=k { + if i < j { + break; + } + curr = curr.max(arr[i - j]); + dp[i] = dp[i].max(dp[i - j] + curr * j as i32); + } + } + dp[n] + } +} diff --git a/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.swift b/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.swift new file mode 100644 index 00000000..bd29cc24 --- /dev/null +++ b/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.swift @@ -0,0 +1,15 @@ +class Solution { + func maxSumAfterPartitioning(_ arr: [Int], _ k: Int) -> Int { + let n = arr.count + var dp = [Int](repeating: 0, count: n + 1) + for i in 1...n { + var curr = 0 + for j in 1...k { + if i < j { break } + curr = max(curr, arr[i - j]) + dp[i] = max(dp[i], dp[i - j] + curr * j) + } + } + return dp[n] + } +} diff --git a/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.ts b/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.ts new file mode 100644 index 00000000..ac23c9ab --- /dev/null +++ b/tests/1001-1500/1043. partition-array-for-maximum-sum/sol.ts @@ -0,0 +1,13 @@ +function maxSumAfterPartitioning(arr: number[], k: number): number { + const n = arr.length; + const dp: number[] = new Array(n + 1).fill(0); + for (let i = 1; i <= n; i++) { + let curr = 0; + for (let j = 1; j <= k; j++) { + if (i < j) break; + curr = Math.max(curr, arr[i - j]); + dp[i] = Math.max(dp[i], dp[i - j] + curr * j); + } + } + return dp[n]; +} diff --git a/tests/1001-1500/1044. longest-duplicate-substring/manifest.yaml b/tests/1001-1500/1044. longest-duplicate-substring/manifest.yaml new file mode 100644 index 00000000..a34fde0d --- /dev/null +++ b/tests/1001-1500/1044. longest-duplicate-substring/manifest.yaml @@ -0,0 +1,188 @@ +entry: + id: 1044 + title: longest-duplicate-substring + params: + s: + type: string + call: + cpp: Solution().longestDupSubstring({s}) + rust: Solution::longest_dup_substring({s}) + python3: Solution().longestDupSubstring({s}) + python2: Solution().longestDupSubstring({s}) + ruby: longest_dup_substring({s}) + java: new Solution().longestDupSubstring({s}) + csharp: new Solution().LongestDupSubstring({s}) + kotlin: Solution().longestDupSubstring({s}) + go: longestDupSubstring({s}) + dart: Solution().longestDupSubstring({s}) + swift: Solution().longestDupSubstring({s}) + typescript: longestDupSubstring({s}) +judge: + type: exact +limits: + time_ms: 3000 + memory_mb: 256 +oracle: + python3: + call: Checker().longestDupSubstring(s, {result}) + checker: + "class Checker:\n def longestDupSubstring(self, s, result):\n \ + \ if not isinstance(result, str):\n return False\n n =\ + \ len(s)\n if result == \"\":\n best = 0\n else:\n\ + \ if s.find(result) == -1:\n return False\n \ + \ second = s.find(result, s.find(result) + 1)\n if second ==\ + \ -1:\n return False\n best = len(result)\n\n \ + \ base1, base2 = 131, 31\n mod1, mod2 = 10**9 + 5, 10**9 + 7\n\n \ + \ def build(base, mod):\n h = [0] * (n + 1)\n p\ + \ = [1] * (n + 1)\n for i, ch in enumerate(s):\n h[i\ + \ + 1] = (h[i] * base + ord(ch)) % mod\n p[i + 1] = (p[i] * base)\ + \ % mod\n return h, p\n\n def get(h, p, l, r, mod):\n \ + \ return (h[r] - h[l] * p[r - l]) % mod\n\n h1, p1 = build(base1,\ + \ mod1)\n h2, p2 = build(base2, mod2)\n\n def exists(L):\n \ + \ seen = set()\n for i in range(n - L + 1):\n \ + \ key = (get(h1, p1, i, i + L, mod1), get(h2, p2, i, i + L, mod2))\n \ + \ if key in seen:\n return True\n \ + \ seen.add(key)\n return False\n\n lo, hi = 0, n\n \ + \ while lo < hi:\n mid = (lo + hi + 1) // 2\n if exists(mid):\n\ + \ lo = mid\n else:\n hi = mid - 1\n\ + \ return len(result) == lo\n" +seed: 1044 +tests: + - name: example-1 + in: + s: banana + - name: example-2 + in: + s: abcd + - name: no-dup-1 + in: + s: abcdefgh + - name: no-dup-2 + in: + s: zyxwvutsrq + - name: simple-1 + in: + s: aa + - name: simple-2 + in: + s: aba + - name: simple-3 + in: + s: aaaa + - name: simple-4 + in: + s: aabcaabdaab + - name: simple-5 + in: + s: mississippi + - name: simple-6 + in: + s: abcabcabc + - name: simple-7 + in: + s: abcdefabc + - name: simple-8 + in: + s: pqrstpqr + - name: simple-9 + in: + s: qwertyqwert + - name: simple-10 + in: + s: abracadabra + - name: simple-11 + in: + s: aabaab + - name: simple-12 + in: + s: abcabxabcd + - name: simple-13 + in: + s: xyzxyzxyzx + - name: simple-14 + in: + s: bcdbcdbcd + - name: simple-15 + in: + s: ababababa + - name: simple-16 + in: + s: cccccc + - name: simple-17 + in: + s: aabcdaabc + - name: simple-18 + in: + s: baaaab + - name: simple-19 + in: + s: abcdeffedcba + - name: simple-20 + in: + s: thequickbrownfox + - name: repeat-block-1 + in: + s: abcdeabcdfabcde + - name: repeat-block-2 + in: + s: zzzyzzzyzz + - name: repeat-block-3 + in: + s: aaaaaaaab + - name: repeat-block-4 + in: + s: ababababab + - name: repeat-block-5 + in: + s: aabcabcaa + - name: repeat-block-6 + in: + s: qqqwqqqw + - name: repeat-block-7 + in: + s: lmnlmnlmn + - name: repeat-block-8 + in: + s: tttatttattta + - name: repeat-block-9 + in: + s: azazazaz + - name: repeat-block-10 + in: + s: bbbbbbbbb + - name: large-1 + in: + s: + gen: str + len: 30000 + alphabet: a + - name: large-2 + in: + s: + gen: str + len: 30000 + alphabet: ab + - name: large-3 + in: + s: + gen: str + len: 30000 + alphabet: abc + - name: large-4 + in: + s: + gen: str + len: 29999 + alphabet: abcd + - name: large-5 + in: + s: + gen: str + len: 30000 + alphabet: aceg + - name: large-6 + in: + s: + gen: str + len: 30000 + alphabet: abcde diff --git a/tests/1001-1500/1044. longest-duplicate-substring/sol.cpp b/tests/1001-1500/1044. longest-duplicate-substring/sol.cpp new file mode 100644 index 00000000..44cf79f0 --- /dev/null +++ b/tests/1001-1500/1044. longest-duplicate-substring/sol.cpp @@ -0,0 +1,46 @@ +class Solution { +public: + string longestDupSubstring(string s) { + int n = s.size(); + long long base1 = 131, base2 = 31; + long long mod1 = 1000000005, mod2 = 1000000007; + + vector h1(n + 1), p1(n + 1, 1); + vector h2(n + 1), p2(n + 1, 1); + + for (int i = 0; i < n; i++) { + h1[i + 1] = (h1[i] * base1 + s[i]) % mod1; + p1[i + 1] = (p1[i] * base1) % mod1; + h2[i + 1] = (h2[i] * base2 + s[i]) % mod2; + p2[i + 1] = (p2[i] * base2) % mod2; + } + + auto check = [&](int L) -> string { + unordered_set seen; + for (int i = 0; i <= n - L; i++) { + long long v1 = (h1[i + L] - h1[i] * p1[L]) % mod1; + if (v1 < 0) v1 += mod1; + long long v2 = (h2[i + L] - h2[i] * p2[L]) % mod2; + if (v2 < 0) v2 += mod2; + long long key = (v1 << 32) | v2; + if (seen.count(key)) return s.substr(i, L); + seen.insert(key); + } + return ""; + }; + + int lo = 1, hi = n; + string res; + while (lo <= hi) { + int mid = (lo + hi) / 2; + string t = check(mid); + if (!t.empty()) { + res = t; + lo = mid + 1; + } else { + hi = mid - 1; + } + } + return res; + } +}; diff --git a/tests/1001-1500/1044. longest-duplicate-substring/sol.cs b/tests/1001-1500/1044. longest-duplicate-substring/sol.cs new file mode 100644 index 00000000..83b9f3c1 --- /dev/null +++ b/tests/1001-1500/1044. longest-duplicate-substring/sol.cs @@ -0,0 +1,46 @@ +public class Solution { + public string LongestDupSubstring(string s) { + int n = s.Length; + long base1 = 131, base2 = 31; + long mod1 = 1000000005, mod2 = 1000000007; + + long[] h1 = new long[n + 1], p1 = new long[n + 1]; + long[] h2 = new long[n + 1], p2 = new long[n + 1]; + p1[0] = p2[0] = 1; + + for (int i = 0; i < n; i++) { + h1[i + 1] = (h1[i] * base1 + s[i]) % mod1; + p1[i + 1] = (p1[i] * base1) % mod1; + h2[i + 1] = (h2[i] * base2 + s[i]) % mod2; + p2[i + 1] = (p2[i] * base2) % mod2; + } + + string Check(int L) { + var seen = new HashSet(); + for (int i = 0; i <= n - L; i++) { + long v1 = (h1[i + L] - h1[i] * p1[L]) % mod1; + if (v1 < 0) v1 += mod1; + long v2 = (h2[i + L] - h2[i] * p2[L]) % mod2; + if (v2 < 0) v2 += mod2; + long key = (v1 << 32) ^ v2; + if (seen.Contains(key)) return s.Substring(i, L); + seen.Add(key); + } + return ""; + } + + int lo = 1, hi = n; + string res = ""; + while (lo <= hi) { + int mid = (lo + hi) / 2; + string t = Check(mid); + if (t != "") { + res = t; + lo = mid + 1; + } else { + hi = mid - 1; + } + } + return res; + } +} diff --git a/tests/1001-1500/1044. longest-duplicate-substring/sol.dart b/tests/1001-1500/1044. longest-duplicate-substring/sol.dart new file mode 100644 index 00000000..bfceb4cf --- /dev/null +++ b/tests/1001-1500/1044. longest-duplicate-substring/sol.dart @@ -0,0 +1,47 @@ +class Solution { + String longestDupSubstring(String s) { + int n = s.length; + int base1 = 131, base2 = 31; + int mod1 = 1000000005, mod2 = 1000000007; + + List h1 = List.filled(n + 1, 0); + List p1 = List.filled(n + 1, 1); + List h2 = List.filled(n + 1, 0); + List p2 = List.filled(n + 1, 1); + + for (int i = 0; i < n; i++) { + h1[i + 1] = (h1[i] * base1 + s.codeUnitAt(i)) % mod1; + p1[i + 1] = (p1[i] * base1) % mod1; + h2[i + 1] = (h2[i] * base2 + s.codeUnitAt(i)) % mod2; + p2[i + 1] = (p2[i] * base2) % mod2; + } + + String Function(int) check = (int L) { + var seen = {}; + for (int i = 0; i <= n - L; i++) { + int v1 = (h1[i + L] - h1[i] * p1[L]) % mod1; + if (v1 < 0) v1 += mod1; + int v2 = (h2[i + L] - h2[i] * p2[L]) % mod2; + if (v2 < 0) v2 += mod2; + int key = v1 * mod2 + v2; + if (seen.contains(key)) return s.substring(i, i + L); + seen.add(key); + } + return ""; + }; + + int lo = 1, hi = n; + String res = ""; + while (lo <= hi) { + int mid = (lo + hi) ~/ 2; + String t = check(mid); + if (t.isNotEmpty) { + res = t; + lo = mid + 1; + } else { + hi = mid - 1; + } + } + return res; + } +} diff --git a/tests/1001-1500/1044. longest-duplicate-substring/sol.go b/tests/1001-1500/1044. longest-duplicate-substring/sol.go new file mode 100644 index 00000000..e802fe27 --- /dev/null +++ b/tests/1001-1500/1044. longest-duplicate-substring/sol.go @@ -0,0 +1,49 @@ +func longestDupSubstring(s string) string { + n := len(s) + base1, base2 := 131, 31 + mod1, mod2 := int64(1000000005), int64(1000000007) + + h1, p1 := make([]int64, n+1), make([]int64, n+1) + h2, p2 := make([]int64, n+1), make([]int64, n+1) + p1[0], p2[0] = 1, 1 + + for i := 0; i < n; i++ { + h1[i+1] = (h1[i]*int64(base1) + int64(s[i])) % mod1 + p1[i+1] = (p1[i] * int64(base1)) % mod1 + h2[i+1] = (h2[i]*int64(base2) + int64(s[i])) % mod2 + p2[i+1] = (p2[i] * int64(base2)) % mod2 + } + + check := func(L int) string { + seen := make(map[[2]int64]bool) + for i := 0; i <= n-L; i++ { + v1 := (h1[i+L] - h1[i]*p1[L]) % mod1 + if v1 < 0 { + v1 += mod1 + } + v2 := (h2[i+L] - h2[i]*p2[L]) % mod2 + if v2 < 0 { + v2 += mod2 + } + key := [2]int64{v1, v2} + if seen[key] { + return s[i : i+L] + } + seen[key] = true + } + return "" + } + + lo, hi, res := 1, n, "" + for lo <= hi { + mid := (lo + hi) / 2 + t := check(mid) + if t != "" { + res = t + lo = mid + 1 + } else { + hi = mid - 1 + } + } + return res +} diff --git a/tests/1001-1500/1044. longest-duplicate-substring/sol.java b/tests/1001-1500/1044. longest-duplicate-substring/sol.java new file mode 100644 index 00000000..280de7be --- /dev/null +++ b/tests/1001-1500/1044. longest-duplicate-substring/sol.java @@ -0,0 +1,48 @@ +class Solution { + public String longestDupSubstring(String s) { + int n = s.length(); + long base1 = 131, base2 = 31; + long mod1 = 1000000005L, mod2 = 1000000007L; + + long[] h1 = new long[n+1], p1 = new long[n+1]; + long[] h2 = new long[n+1], p2 = new long[n+1]; + p1[0] = p2[0] = 1; + + for (int i = 0; i < n; i++) { + h1[i+1] = (h1[i] * base1 + s.charAt(i)) % mod1; + p1[i+1] = (p1[i] * base1) % mod1; + h2[i+1] = (h2[i] * base2 + s.charAt(i)) % mod2; + p2[i+1] = (p2[i] * base2) % mod2; + } + + int lo = 1, hi = n; + String res = ""; + + while (lo <= hi) { + int mid = (lo + hi) / 2; + String t = check(s, mid, h1, p1, h2, p2, mod1, mod2); + if (t != "") { + res = t; + lo = mid + 1; + } else { + hi = mid - 1; + } + } + return res; + } + + private String check(String s, int L, long[] h1, long[] p1, long[] h2, long[] p2, long mod1, long mod2) { + int n = s.length(); + java.util.Set seen = new java.util.HashSet<>(); + for (int i = 0; i <= n - L; i++) { + long v1 = (h1[i+L] - h1[i] * p1[L]) % mod1; + if (v1 < 0) v1 += mod1; + long v2 = (h2[i+L] - h2[i] * p2[L]) % mod2; + if (v2 < 0) v2 += mod2; + long key = v1 * mod2 + v2; + if (seen.contains(key)) return s.substring(i, i + L); + seen.add(key); + } + return ""; + } +} diff --git a/tests/1001-1500/1044. longest-duplicate-substring/sol.kt b/tests/1001-1500/1044. longest-duplicate-substring/sol.kt new file mode 100644 index 00000000..727dba77 --- /dev/null +++ b/tests/1001-1500/1044. longest-duplicate-substring/sol.kt @@ -0,0 +1,49 @@ +class Solution { + fun longestDupSubstring(s: String): String { + val n = s.length + val base1 = 131L + val base2 = 31L + val mod1 = 1000000005L + val mod2 = 1000000007L + + val h1 = LongArray(n + 1) + val p1 = LongArray(n + 1) { if (it == 0) 1L else 0L } + val h2 = LongArray(n + 1) + val p2 = LongArray(n + 1) { if (it == 0) 1L else 0L } + + for (i in 0 until n) { + h1[i + 1] = (h1[i] * base1 + s[i].code.toLong()) % mod1 + p1[i + 1] = (p1[i] * base1) % mod1 + h2[i + 1] = (h2[i] * base2 + s[i].code.toLong()) % mod2 + p2[i + 1] = (p2[i] * base2) % mod2 + } + + fun check(L: Int): String { + val seen = HashSet() + for (i in 0..n - L) { + var v1 = (h1[i + L] - h1[i] * p1[L]) % mod1 + if (v1 < 0) v1 += mod1 + var v2 = (h2[i + L] - h2[i] * p2[L]) % mod2 + if (v2 < 0) v2 += mod2 + val key = v1 * mod2 + v2 + if (!seen.add(key)) return s.substring(i, i + L) + } + return "" + } + + var lo = 1 + var hi = n + var res = "" + while (lo <= hi) { + val mid = (lo + hi) / 2 + val t = check(mid) + if (t.isNotEmpty()) { + res = t + lo = mid + 1 + } else { + hi = mid - 1 + } + } + return res + } +} diff --git a/tests/1001-1500/1044. longest-duplicate-substring/sol.py b/tests/1001-1500/1044. longest-duplicate-substring/sol.py new file mode 100644 index 00000000..709183f7 --- /dev/null +++ b/tests/1001-1500/1044. longest-duplicate-substring/sol.py @@ -0,0 +1,38 @@ +class Solution: + def longestDupSubstring(self, s: str) -> str: + n = len(s) + base1, base2 = 131, 31 + mod1, mod2 = 10**9 + 5, 10**9 + 7 + + def build(base, mod): + h = [0] * (n + 1) + p = [1] * (n + 1) + for i in range(n): + h[i + 1] = (h[i] * base + ord(s[i])) % mod + p[i + 1] = (p[i] * base) % mod + return h, p + + def get(h, p, l, r, mod): + return (h[r] - h[l] * p[r - l]) % mod + + h1, p1 = build(base1, mod1) + h2, p2 = build(base2, mod2) + + def check(L): + seen = set() + for i in range(n - L + 1): + x = (get(h1, p1, i, i + L, mod1), get(h2, p2, i, i + L, mod2)) + if x in seen: + return s[i : i + L] + seen.add(x) + return "" + + lo, hi, res = 1, n, "" + while lo <= hi: + mid = (lo + hi) // 2 + t = check(mid) + if t: + res, lo = t, mid + 1 + else: + hi = mid - 1 + return res diff --git a/tests/1001-1500/1044. longest-duplicate-substring/sol.py2 b/tests/1001-1500/1044. longest-duplicate-substring/sol.py2 new file mode 100644 index 00000000..92fe2d1d --- /dev/null +++ b/tests/1001-1500/1044. longest-duplicate-substring/sol.py2 @@ -0,0 +1,43 @@ +class Solution(object): + def longestDupSubstring(self, s): + """ + :type s: str + :rtype: str + """ + n = len(s) + base1, base2 = 131, 31 + mod1, mod2 = 10**9+5, 10**9+7 + + def build(base, mod): + h = [0]*(n+1) + p = [1]*(n+1) + for i in range(n): + h[i+1] = (h[i]*base + ord(s[i])) % mod + p[i+1] = (p[i]*base) % mod + return h, p + + def get(h, p, l, r, mod): + return (h[r] - h[l]*p[r-l]) % mod + + h1, p1 = build(base1, mod1) + h2, p2 = build(base2, mod2) + + def check(L): + seen = set() + for i in range(n-L+1): + x = (get(h1, p1, i, i+L, mod1), + get(h2, p2, i, i+L, mod2)) + if x in seen: + return s[i:i+L] + seen.add(x) + return "" + + lo, hi, res = 1, n, "" + while lo <= hi: + mid = (lo + hi) // 2 + t = check(mid) + if t: + res, lo = t, mid + 1 + else: + hi = mid - 1 + return res diff --git a/tests/1001-1500/1044. longest-duplicate-substring/sol.rb b/tests/1001-1500/1044. longest-duplicate-substring/sol.rb new file mode 100644 index 00000000..ab969345 --- /dev/null +++ b/tests/1001-1500/1044. longest-duplicate-substring/sol.rb @@ -0,0 +1,47 @@ +# @param {String} s +# @return {String} +def longest_dup_substring(s) + n = s.length + base1, base2 = 131, 31 + mod1, mod2 = 10**9+5, 10**9+7 + + build = lambda do |base, mod| + h = [0] * (n + 1) + p = [1] * (n + 1) + (0...n).each do |i| + h[i+1] = (h[i] * base + s[i].ord) % mod + p[i+1] = (p[i] * base) % mod + end + [h, p] + end + + get = lambda do |h, p, l, r, mod| + (h[r] - h[l] * p[r-l]) % mod + end + + h1, p1 = build.call(base1, mod1) + h2, p2 = build.call(base2, mod2) + + check = lambda do |len| + seen = Set.new + (0..n-len).each do |i| + x = [get.call(h1, p1, i, i+len, mod1), + get.call(h2, p2, i, i+len, mod2)] + return s[i, len] if seen.include?(x) + seen.add(x) + end + "" + end + + lo, hi, res = 1, n, "" + while lo <= hi + mid = (lo + hi) / 2 + t = check.call(mid) + if t != "" + res, lo = t, mid + 1 + else + hi = mid - 1 + end + end + res +end diff --git a/tests/1001-1500/1044. longest-duplicate-substring/sol.rs b/tests/1001-1500/1044. longest-duplicate-substring/sol.rs new file mode 100644 index 00000000..053ed41b --- /dev/null +++ b/tests/1001-1500/1044. longest-duplicate-substring/sol.rs @@ -0,0 +1,50 @@ +impl Solution { + pub fn longest_dup_substring(s: String) -> String { + let n = s.len(); + let base1: i64 = 131; + let base2: i64 = 31; + let mod1: i64 = 1000000005; + let mod2: i64 = 1000000007; + let bytes = s.as_bytes(); + + let mut h1 = vec![0i64; n + 1]; + let mut p1 = vec![1i64; n + 1]; + let mut h2 = vec![0i64; n + 1]; + let mut p2 = vec![1i64; n + 1]; + + for i in 0..n { + h1[i + 1] = (h1[i] * base1 + bytes[i] as i64) % mod1; + p1[i + 1] = (p1[i] * base1) % mod1; + h2[i + 1] = (h2[i] * base2 + bytes[i] as i64) % mod2; + p2[i + 1] = (p2[i] * base2) % mod2; + } + + let check = |len: usize| -> Option<&str> { + use std::collections::HashSet; + let mut seen = HashSet::new(); + for i in 0..=n - len { + let mut v1 = (h1[i + len] - h1[i] * p1[len]) % mod1; + if v1 < 0 { v1 += mod1; } + let mut v2 = (h2[i + len] - h2[i] * p2[len]) % mod2; + if v2 < 0 { v2 += mod2; } + let key = (v1 as u64) << 32 | (v2 as u64); + if !seen.insert(key) { + return Some(&s[i..i + len]); + } + } + None + }; + + let (mut lo, mut hi, mut res) = (1usize, n, ""); + while lo <= hi { + let mid = (lo + hi) / 2; + if let Some(t) = check(mid) { + res = t; + lo = mid + 1; + } else { + hi = mid - 1; + } + } + res.to_string() + } +} diff --git a/tests/1001-1500/1044. longest-duplicate-substring/sol.swift b/tests/1001-1500/1044. longest-duplicate-substring/sol.swift new file mode 100644 index 00000000..7d0ee891 --- /dev/null +++ b/tests/1001-1500/1044. longest-duplicate-substring/sol.swift @@ -0,0 +1,53 @@ +class Solution { + func longestDupSubstring(_ s: String) -> String { + let n = s.count + let base1 = 131 + let base2 = 31 + let mod1 = 1000000005 + let mod2 = 1000000007 + let chars = Array(s.utf8) + + var h1 = [Int](repeating: 0, count: n + 1) + var p1 = [Int](repeating: 1, count: n + 1) + var h2 = [Int](repeating: 0, count: n + 1) + var p2 = [Int](repeating: 1, count: n + 1) + + for i in 0.. String { + var seen = Set() + for i in 0...(n - L) { + var v1 = (h1[i + L] - h1[i] * p1[L]) % mod1 + if v1 < 0 { v1 += mod1 } + var v2 = (h2[i + L] - h2[i] * p2[L]) % mod2 + if v2 < 0 { v2 += mod2 } + let key = v1 * mod2 + v2 + if seen.contains(key) { + let start = s.index(s.startIndex, offsetBy: i) + let end = s.index(start, offsetBy: L) + return String(s[start..> = [new Map()]; + const link: number[] = [-1]; + const len: number[] = [0]; + const occ: number[] = [0]; + const firstPos: number[] = [-1]; + let last = 0; + + const extend = (ch: string, pos: number): void => { + const cur = trans.length; + trans.push(new Map()); + link.push(0); + len.push(len[last] + 1); + occ.push(1); + firstPos.push(pos); + + let p = last; + while (p !== -1 && !trans[p].has(ch)) { + trans[p].set(ch, cur); + p = link[p]; + } + if (p === -1) { + link[cur] = 0; + } else { + const q = trans[p].get(ch)!; + if (len[p] + 1 === len[q]) { + link[cur] = q; + } else { + const clone = trans.length; + trans.push(new Map(trans[q])); + link.push(link[q]); + len.push(len[p] + 1); + occ.push(0); + firstPos.push(firstPos[q]); + while (p !== -1 && trans[p].get(ch) === q) { + trans[p].set(ch, clone); + p = link[p]; + } + link[q] = clone; + link[cur] = clone; + } + } + last = cur; + }; + + for (let i = 0; i < s.length; i++) { + extend(s[i], i); + } + + const order = [...Array(trans.length).keys()].sort((a, b) => len[a] - len[b]); + for (let i = order.length - 1; i > 0; i--) { + const v = order[i]; + if (link[v] >= 0) { + occ[link[v]] += occ[v]; + } + } + + let best = 0; + for (let v = 1; v < trans.length; v++) { + if (occ[v] >= 2 && len[v] > len[best]) { + best = v; + } + } + + if (len[best] === 0) { + return ""; + } + const end = firstPos[best]; + return s.slice(end - len[best] + 1, end + 1); +} diff --git a/tests/1001-1500/1046. last-stone-weight/manifest.yaml b/tests/1001-1500/1046. last-stone-weight/manifest.yaml new file mode 100644 index 00000000..8152c527 --- /dev/null +++ b/tests/1001-1500/1046. last-stone-weight/manifest.yaml @@ -0,0 +1,202 @@ +entry: + id: 1046 + title: "last-stone-weight" + params: + stones: + type: array + items: + type: int + call: + cpp: "Solution().lastStoneWeight({stones})" + rust: "Solution::last_stone_weight({stones})" + python3: "Solution().lastStoneWeight({stones})" + python2: "Solution().lastStoneWeight({stones})" + ruby: "last_stone_weight({stones})" + java: "new Solution().lastStoneWeight({stones})" + csharp: "new Solution().LastStoneWeight({stones})" + kotlin: "Solution().lastStoneWeight({stones})" + go: "lastStoneWeight({stones})" + dart: "Solution().lastStoneWeight({stones})" + swift: "Solution().lastStoneWeight({stones})" + typescript: "lastStoneWeight({stones})" + +judge: + type: "exact" + +limits: + time_ms: 200 + memory_mb: 300 + +oracle: + python3: + call: "Checker().lastStoneWeight(stones, {result})" + checker: | + class Checker: + def lastStoneWeight(self, stones, result) -> bool: + import heapq + + h = [-x for x in stones] + heapq.heapify(h) + while len(h) > 1: + a = heapq.heappop(h) + b = heapq.heappop(h) + if a != b: + heapq.heappush(h, a - b) + expected = -h[0] if h else 0 + return result == expected + +seed: 1046 + +tests: + - name: "sample" + in: + stones: [2, 7, 4, 1, 8, 1] + out: 1 + - name: "single_stone" + in: + stones: [1] + out: 1 + - name: "pair_equal" + in: + stones: [1, 1] + out: 0 + - name: "pair_equal_two" + in: + stones: [2, 2] + out: 0 + - name: "three_small" + in: + stones: [3, 7, 8] + out: 2 + - name: "two_pairs" + in: + stones: [10, 4, 2, 10] + out: 2 + - name: "balanced_zero" + in: + stones: [9, 3, 2, 10] + out: 0 + - name: "larger_mix" + in: + stones: [31, 26, 33, 21, 40] + out: 9 + - name: "ascending" + in: + stones: [1, 2, 3, 4, 5, 6, 7, 8] + out: 0 + - name: "all_same_odd" + in: + stones: [8, 8, 8, 8, 8] + out: 8 + - name: "duplicates_even" + in: + stones: [9, 9, 3, 3, 2, 2] + out: 0 + - name: "two_numbers" + in: + stones: [1, 3] + out: 2 + - name: "seven_same" + in: + stones: [5, 5, 5, 5, 5, 5, 5] + out: 5 + - name: "large_gap" + in: + stones: [100, 1] + out: 99 + - name: "near_cancel" + in: + stones: [99, 1, 1] + out: 97 + - name: "paired_groups" + in: + stones: [2, 2, 3, 3, 4, 4] + out: 0 + - name: "mixed_small" + in: + stones: [1, 2, 2, 3, 3, 3] + out: 0 + - name: "all_equal_even" + in: + stones: [6, 6, 6, 6] + out: 0 + - name: "odd_count_equal" + in: + stones: [7, 6, 7, 6, 7] + out: 5 + - name: "powers_of_two" + in: + stones: [1, 2, 4, 8, 16] + out: 1 + - name: "one_rest" + in: + stones: [9, 1, 2, 2, 2] + out: 2 + - name: "large_pair" + in: + stones: [50, 50, 1] + out: 1 + - name: "mixed_six" + in: + stones: [11, 7, 3, 5, 2, 9] + out: 1 + - name: "triple_equal" + in: + stones: [12, 12, 12] + out: 12 + - name: "nine_ones" + in: + stones: [1, 1, 1, 1, 1, 1, 1, 1, 1] + out: 1 + - name: "two_close" + in: + stones: [17, 18] + out: 1 + - name: "close_triplet" + in: + stones: [6, 5, 5] + out: 4 + - name: "ten_equal" + in: + stones: [4, 4, 4, 4, 4, 4, 4, 4, 4, 4] + out: 0 + - name: "offset_mix" + in: + stones: [13, 7, 8, 9] + out: 3 + - name: "primes" + in: + stones: [2, 3, 5, 7, 11] + out: 0 + - name: "arithmetic_progression" + in: + stones: [1, 4, 7, 10, 13] + out: 1 + - name: "double_pairs" + in: + stones: [30, 30, 29, 29] + out: 0 + - name: "descending" + in: + stones: [15, 14, 13, 12, 11] + out: 9 + - name: "one_big_pair" + in: + stones: [1, 100, 50, 50] + out: 1 + - name: "geometric" + in: + stones: [6, 2, 4, 8, 16, 32] + out: 0 + - name: "many_twos" + in: + stones: [1, 2, 2, 2, 2, 2] + out: 1 + - name: "triples_and_ones" + in: + stones: [19, 19, 18, 18, 1, 1] + out: 0 + - name: "descending_six" + in: + stones: [25, 24, 23, 22, 21, 20] + out: 1 diff --git a/tests/1001-1500/1046. last-stone-weight/sol.cpp b/tests/1001-1500/1046. last-stone-weight/sol.cpp new file mode 100644 index 00000000..c63d129c --- /dev/null +++ b/tests/1001-1500/1046. last-stone-weight/sol.cpp @@ -0,0 +1,23 @@ +class Solution { +public: + int lastStoneWeight(vector& stones) { + priority_queue heap; + + for (int stone : stones) { + heap.push(stone); + } + + while (heap.size() > 1) { + int maxStone1 = heap.top(); + heap.pop(); + int maxStone2 = heap.top(); + heap.pop(); + + if (maxStone1 != maxStone2) { + heap.push(maxStone1 - maxStone2); + } + } + + return heap.empty() ? 0 : heap.top(); + } +}; diff --git a/tests/1001-1500/1046. last-stone-weight/sol.cs b/tests/1001-1500/1046. last-stone-weight/sol.cs new file mode 100644 index 00000000..b929fb4d --- /dev/null +++ b/tests/1001-1500/1046. last-stone-weight/sol.cs @@ -0,0 +1,16 @@ +public class Solution { + public int LastStoneWeight(int[] stones) { + var list = new System.Collections.Generic.List(stones); + while (list.Count > 1) { + list.Sort((a, b) => b.CompareTo(a)); + int maxStone1 = list[0]; + int maxStone2 = list[1]; + list.RemoveAt(0); + list.RemoveAt(0); + if (maxStone1 != maxStone2) { + list.Add(maxStone1 - maxStone2); + } + } + return list.Count == 0 ? 0 : list[0]; + } +} diff --git a/tests/1001-1500/1046. last-stone-weight/sol.dart b/tests/1001-1500/1046. last-stone-weight/sol.dart new file mode 100644 index 00000000..5cd2f176 --- /dev/null +++ b/tests/1001-1500/1046. last-stone-weight/sol.dart @@ -0,0 +1,20 @@ +class Solution { + int lastStoneWeight(List stones) { + final heap = HeapPriorityQueue((a, b) => b.compareTo(a)); + + for (final stone in stones) { + heap.add(stone); + } + + while (heap.length > 1) { + final maxStone1 = heap.removeFirst(); + final maxStone2 = heap.removeFirst(); + + if (maxStone1 != maxStone2) { + heap.add(maxStone1 - maxStone2); + } + } + + return heap.isEmpty ? 0 : heap.removeFirst(); + } +} diff --git a/tests/1001-1500/1046. last-stone-weight/sol.go b/tests/1001-1500/1046. last-stone-weight/sol.go new file mode 100644 index 00000000..62ca9623 --- /dev/null +++ b/tests/1001-1500/1046. last-stone-weight/sol.go @@ -0,0 +1,40 @@ +func lastStoneWeight(stones []int) int { + h := &IntHeap{} + heap.Init(h) + + for _, stone := range stones { + heap.Push(h, stone) + } + + for h.Len() > 1 { + maxStone1 := heap.Pop(h).(int) + maxStone2 := heap.Pop(h).(int) + + if maxStone1 != maxStone2 { + heap.Push(h, maxStone1-maxStone2) + } + } + + if h.Len() == 0 { + return 0 + } + return heap.Pop(h).(int) +} + +type IntHeap []int + +func (h IntHeap) Len() int { return len(h) } +func (h IntHeap) Less(i, j int) bool { return h[i] > h[j] } +func (h IntHeap) Swap(i, j int) { h[i], h[j] = h[j], h[i] } + +func (h *IntHeap) Push(x interface{}) { + *h = append(*h, x.(int)) +} + +func (h *IntHeap) Pop() interface{} { + old := *h + n := len(old) + x := old[n-1] + *h = old[0 : n-1] + return x +} diff --git a/tests/1001-1500/1046. last-stone-weight/sol.java b/tests/1001-1500/1046. last-stone-weight/sol.java new file mode 100644 index 00000000..f6d0565c --- /dev/null +++ b/tests/1001-1500/1046. last-stone-weight/sol.java @@ -0,0 +1,20 @@ +class Solution { + public int lastStoneWeight(int[] stones) { + java.util.PriorityQueue heap = new java.util.PriorityQueue<>(java.util.Collections.reverseOrder()); + + for (int stone : stones) { + heap.offer(stone); + } + + while (heap.size() > 1) { + int maxStone1 = heap.poll(); + int maxStone2 = heap.poll(); + + if (maxStone1 != maxStone2) { + heap.offer(maxStone1 - maxStone2); + } + } + + return heap.isEmpty() ? 0 : heap.poll(); + } +} diff --git a/tests/1001-1500/1046. last-stone-weight/sol.kt b/tests/1001-1500/1046. last-stone-weight/sol.kt new file mode 100644 index 00000000..b7e30062 --- /dev/null +++ b/tests/1001-1500/1046. last-stone-weight/sol.kt @@ -0,0 +1,20 @@ +class Solution { + fun lastStoneWeight(stones: IntArray): Int { + val heap = java.util.PriorityQueue(compareByDescending { it }) + + for (stone in stones) { + heap.offer(stone) + } + + while (heap.size > 1) { + val maxStone1 = heap.poll() + val maxStone2 = heap.poll() + + if (maxStone1 != maxStone2) { + heap.offer(maxStone1 - maxStone2) + } + } + + return if (heap.isEmpty()) 0 else heap.poll() + } +} diff --git a/tests/1001-1500/1046. last-stone-weight/sol.py b/tests/1001-1500/1046. last-stone-weight/sol.py new file mode 100644 index 00000000..5f9fa1e7 --- /dev/null +++ b/tests/1001-1500/1046. last-stone-weight/sol.py @@ -0,0 +1,17 @@ +import heapq + + +class Solution: + def lastStoneWeight(self, stones: List[int]) -> int: + for i in range(len(stones)): + stones[i] *= -1 + + heapq.heapify(stones) + + while len(stones) > 1: + max_stone1, max_stone2 = heapq.heappop(stones), heapq.heappop(stones) + + if max_stone1 != max_stone2: + heapq.heappush(stones, max_stone1 - max_stone2) + + return -heapq.heappop(stones) if stones else 0 diff --git a/tests/1001-1500/1046. last-stone-weight/sol.py2 b/tests/1001-1500/1046. last-stone-weight/sol.py2 new file mode 100644 index 00000000..a46a05b6 --- /dev/null +++ b/tests/1001-1500/1046. last-stone-weight/sol.py2 @@ -0,0 +1,20 @@ +class Solution(object): + def lastStoneWeight(self, stones): + """ + :type stones: List[int] + :rtype: int + """ + import heapq + for i in range(len(stones)): + stones[i] *= -1 + + heapq.heapify(stones) + + while len(stones) > 1: + max_stone1 = heapq.heappop(stones) + max_stone2 = heapq.heappop(stones) + + if max_stone1 != max_stone2: + heapq.heappush(stones, max_stone1 - max_stone2) + + return -heapq.heappop(stones) if stones else 0 diff --git a/tests/1001-1500/1046. last-stone-weight/sol.rb b/tests/1001-1500/1046. last-stone-weight/sol.rb new file mode 100644 index 00000000..6cc9e0d1 --- /dev/null +++ b/tests/1001-1500/1046. last-stone-weight/sol.rb @@ -0,0 +1,20 @@ +# @param {Integer[]} stones +# @return {Integer} +def last_stone_weight(stones) + stones.map! { |stone| -stone } + + stones = stones.sort.reverse + + while stones.length > 1 + max_stone1 = stones.pop + max_stone2 = stones.pop + + if max_stone1 != max_stone2 + diff = max_stone1 - max_stone2 + index = stones.bsearch_index { |x| x <= diff } || stones.length + stones.insert(index, diff) + end + end + + stones.empty? ? 0 : -stones[0] +end diff --git a/tests/1001-1500/1046. last-stone-weight/sol.rs b/tests/1001-1500/1046. last-stone-weight/sol.rs new file mode 100644 index 00000000..923a9a4b --- /dev/null +++ b/tests/1001-1500/1046. last-stone-weight/sol.rs @@ -0,0 +1,16 @@ +impl Solution { + pub fn last_stone_weight(stones: Vec) -> i32 { + let mut heap = std::collections::BinaryHeap::from(stones); + + while heap.len() > 1 { + let max_stone1 = heap.pop().unwrap(); + let max_stone2 = heap.pop().unwrap(); + + if max_stone1 != max_stone2 { + heap.push(max_stone1 - max_stone2); + } + } + + heap.pop().unwrap_or(0) + } +} diff --git a/tests/1001-1500/1046. last-stone-weight/sol.swift b/tests/1001-1500/1046. last-stone-weight/sol.swift new file mode 100644 index 00000000..4378387f --- /dev/null +++ b/tests/1001-1500/1046. last-stone-weight/sol.swift @@ -0,0 +1,14 @@ +class Solution { + func lastStoneWeight(_ stones: [Int]) -> Int { + var stones = stones + while stones.count > 1 { + stones.sort(by: >) + let maxStone1 = stones.removeFirst() + let maxStone2 = stones.removeFirst() + if maxStone1 != maxStone2 { + stones.append(maxStone1 - maxStone2) + } + } + return stones.first ?? 0 + } +} diff --git a/tests/1001-1500/1046. last-stone-weight/sol.ts b/tests/1001-1500/1046. last-stone-weight/sol.ts new file mode 100644 index 00000000..278fc145 --- /dev/null +++ b/tests/1001-1500/1046. last-stone-weight/sol.ts @@ -0,0 +1,12 @@ +function lastStoneWeight(stones: number[]): number { + const arr = stones.slice(); + while (arr.length > 1) { + arr.sort((a, b) => b - a); + const maxStone1 = arr.shift()!; + const maxStone2 = arr.shift()!; + if (maxStone1 !== maxStone2) { + arr.push(maxStone1 - maxStone2); + } + } + return arr.length === 0 ? 0 : arr[0]; +} diff --git a/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/manifest.yaml b/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/manifest.yaml new file mode 100644 index 00000000..c4564b9d --- /dev/null +++ b/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/manifest.yaml @@ -0,0 +1,184 @@ +entry: + id: 1047 + title: "remove-all-adjacent-duplicates-in-string" + params: + s: + type: string + call: + cpp: "Solution().removeDuplicates({s})" + rust: "Solution::remove_duplicates({s})" + python3: "Solution().removeDuplicates({s})" + python2: "Solution().removeDuplicates({s})" + ruby: "remove_duplicates({s})" + java: "new Solution().removeDuplicates({s})" + csharp: "new Solution().RemoveDuplicates({s})" + kotlin: "Solution().removeDuplicates({s})" + go: "removeDuplicates({s})" + dart: "Solution().removeDuplicates({s})" + swift: "Solution().removeDuplicates({s})" + typescript: "removeDuplicates({s})" + +judge: + type: "exact" + +limits: + time_ms: 200 + memory_mb: 300 + +oracle: + python3: + call: "Checker().removeDuplicates(s, {result})" + checker: | + class Checker: + def removeDuplicates(self, s, result) -> bool: + stack = [] + for ch in s: + if stack and stack[-1] == ch: + stack.pop() + else: + stack.append(ch) + return result == "".join(stack) + +seed: 1047 + +tests: + - name: "empty" + in: + s: "" + out: "" + - name: "single_char" + in: + s: "a" + out: "a" + - name: "pair_cancel" + in: + s: "aa" + out: "" + - name: "two_distinct" + in: + s: "ab" + out: "ab" + - name: "simple_middle" + in: + s: "aba" + out: "aba" + - name: "one_removal" + in: + s: "abb" + out: "a" + - name: "full_cancel" + in: + s: "abba" + out: "" + - name: "no_cancel" + in: + s: "abc" + out: "abc" + - name: "double_pairs" + in: + s: "aabb" + out: "" + - name: "alternating" + in: + s: "abab" + out: "abab" + - name: "repeated_pattern" + in: + s: "abcabc" + out: "abcabc" + - name: "all_same_four" + in: + s: "zzzz" + out: "" + - name: "leetcode" + in: + s: "leetcode" + out: "ltcode" + - name: "clustered" + in: + s: "aaaaabbbbb" + out: "ab" + - name: "mixed_letters" + in: + s: "azbycxdwev" + out: "azbycxdwev" + - name: "sample_like" + in: + s: "aabccabba" + out: "b" + - name: "repeat_xyz" + in: + s: "xyzxyz" + out: "xyzxyz" + - name: "eight_as" + in: + s: "aaaaaaaa" + out: "" + - name: "palindrome_cancel" + in: + s: "abcddcba" + out: "" + - name: "nested_pairs" + in: + s: "pqqp" + out: "" + - name: "double_pairs_2" + in: + s: "aabbccdd" + out: "" + - name: "long_repeating" + in: + s: "mississippi" + out: "m" + - name: "distinct" + in: + s: "qwerty" + out: "qwerty" + - name: "pair_blocks" + in: + s: "bbccaadd" + out: "" + - name: "reverse_cancel" + in: + s: "abccba" + out: "" + - name: "prefix_survives" + in: + s: "cabba" + out: "c" + - name: "banana" + in: + s: "banana" + out: "banana" + - name: "middle_cancel" + in: + s: "mnoonm" + out: "" + - name: "odd_tail" + in: + s: "ttttt" + out: "t" + - name: "symmetric" + in: + s: "xyzzzyx" + out: "xyzyx" + - name: "already_stable" + in: + s: "abcdedcba" + out: "abcdedcba" + - name: "pairing_wave" + in: + s: "abababab" + out: "abababab" + - name: "chunky" + in: + s: "cddcddc" + out: "c" + - name: "tail_blocks" + in: + s: "ppqqrrss" + out: "" + - name: "single_tail" + in: + s: "z" + out: "z" diff --git a/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.cpp b/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.cpp new file mode 100644 index 00000000..a0dcd3ad --- /dev/null +++ b/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.cpp @@ -0,0 +1,14 @@ +class Solution { +public: + string removeDuplicates(string s) { + string stack; + for (char c : s) { + if (!stack.empty() && stack.back() == c) { + stack.pop_back(); + } else { + stack.push_back(c); + } + } + return stack; + } +}; diff --git a/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.cs b/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.cs new file mode 100644 index 00000000..e31cd4e9 --- /dev/null +++ b/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.cs @@ -0,0 +1,13 @@ +public class Solution { + public string RemoveDuplicates(string s) { + var stack = new System.Text.StringBuilder(); + foreach (char c in s) { + if (stack.Length > 0 && stack[stack.Length - 1] == c) { + stack.Length--; + } else { + stack.Append(c); + } + } + return stack.ToString(); + } +} diff --git a/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.dart b/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.dart new file mode 100644 index 00000000..a3130132 --- /dev/null +++ b/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.dart @@ -0,0 +1,14 @@ +class Solution { + String removeDuplicates(String s) { + List stack = []; + for (int i = 0; i < s.length; i++) { + String c = s[i]; + if (stack.isNotEmpty && stack.last == c) { + stack.removeLast(); + } else { + stack.add(c); + } + } + return stack.join(''); + } +} diff --git a/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.go b/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.go new file mode 100644 index 00000000..7f10e82e --- /dev/null +++ b/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.go @@ -0,0 +1,12 @@ +func removeDuplicates(s string) string { + stack := []byte{} + for i := 0; i < len(s); i++ { + c := s[i] + if len(stack) > 0 && stack[len(stack)-1] == c { + stack = stack[:len(stack)-1] + } else { + stack = append(stack, c) + } + } + return string(stack) +} diff --git a/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.java b/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.java new file mode 100644 index 00000000..8e3372b4 --- /dev/null +++ b/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.java @@ -0,0 +1,14 @@ +class Solution { + public String removeDuplicates(String s) { + StringBuilder stack = new StringBuilder(); + for (char c : s.toCharArray()) { + int len = stack.length(); + if (len > 0 && stack.charAt(len - 1) == c) { + stack.deleteCharAt(len - 1); + } else { + stack.append(c); + } + } + return stack.toString(); + } +} diff --git a/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.kt b/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.kt new file mode 100644 index 00000000..f8cf9746 --- /dev/null +++ b/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.kt @@ -0,0 +1,13 @@ +class Solution { + fun removeDuplicates(s: String): String { + val stack = StringBuilder() + for (c in s) { + if (stack.isNotEmpty() && stack.last() == c) { + stack.deleteCharAt(stack.length - 1) + } else { + stack.append(c) + } + } + return stack.toString() + } +} diff --git a/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.py b/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.py new file mode 100644 index 00000000..c23fc3c2 --- /dev/null +++ b/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.py @@ -0,0 +1,9 @@ +class Solution: + def removeDuplicates(self, s: str) -> str: + stack = [] + for char in s: + if stack and stack[-1] == char: + stack.pop() + else: + stack.append(char) + return "".join(stack) diff --git a/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.py2 b/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.py2 new file mode 100644 index 00000000..2082437d --- /dev/null +++ b/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.py2 @@ -0,0 +1,13 @@ +class Solution(object): + def removeDuplicates(self, s): + """ + :type s: str + :rtype: str + """ + stack = [] + for char in s: + if stack and stack[-1] == char: + stack.pop() + else: + stack.append(char) + return "".join(stack) diff --git a/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.rb b/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.rb new file mode 100644 index 00000000..1af89790 --- /dev/null +++ b/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.rb @@ -0,0 +1,13 @@ +# @param {String} s +# @return {String} +def remove_duplicates(s) + stack = [] + s.each_char do |char| + if !stack.empty? && stack[-1] == char + stack.pop + else + stack.push(char) + end + end + stack.join +end diff --git a/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.rs b/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.rs new file mode 100644 index 00000000..339ce4c5 --- /dev/null +++ b/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.rs @@ -0,0 +1,17 @@ +impl Solution { + pub fn remove_duplicates(s: String) -> String { + let mut stack: Vec = Vec::new(); + for c in s.chars() { + if let Some(&top) = stack.last() { + if top == c { + stack.pop(); + } else { + stack.push(c); + } + } else { + stack.push(c); + } + } + stack.into_iter().collect() + } +} diff --git a/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.swift b/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.swift new file mode 100644 index 00000000..919e8e9d --- /dev/null +++ b/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.swift @@ -0,0 +1,13 @@ +class Solution { + func removeDuplicates(_ s: String) -> String { + var stack = [Character]() + for char in s { + if let last = stack.last, last == char { + stack.removeLast() + } else { + stack.append(char) + } + } + return String(stack) + } +} diff --git a/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.ts b/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.ts new file mode 100644 index 00000000..b35318c8 --- /dev/null +++ b/tests/1001-1500/1047. remove-all-adjacent-duplicates-in-string/sol.ts @@ -0,0 +1,11 @@ +function removeDuplicates(s: string): string { + const stack: string[] = []; + for (const char of s) { + if (stack.length > 0 && stack[stack.length - 1] === char) { + stack.pop(); + } else { + stack.push(char); + } + } + return stack.join(""); +} diff --git a/tests/1001-1500/1048. longest-string-chain/manifest.yaml b/tests/1001-1500/1048. longest-string-chain/manifest.yaml new file mode 100644 index 00000000..69ef524a --- /dev/null +++ b/tests/1001-1500/1048. longest-string-chain/manifest.yaml @@ -0,0 +1,373 @@ +entry: + id: 1048 + title: "longest-string-chain" + params: + words: + type: array + items: + type: string + call: + cpp: "Solution().longestStrChain({words})" + rust: "Solution::longest_str_chain({words})" + python3: "Solution().longestStrChain({words})" + python2: "Solution().longestStrChain({words})" + ruby: "longest_str_chain({words})" + java: "new Solution().longestStrChain({words})" + csharp: "new Solution().LongestStrChain({words})" + kotlin: "Solution().longestStrChain({words})" + go: "longestStrChain({words})" + dart: "Solution().longestStrChain({words})" + swift: "Solution().longestStrChain({words})" + typescript: "longestStrChain({words})" + +judge: + type: "exact" + +limits: + time_ms: 200 + memory_mb: 300 + +oracle: + python3: + call: "Checker().longestStrChain(words, {result})" + checker: | + class Checker: + def longestStrChain(self, words, result) -> bool: + words = sorted(words, key=len) + dp = {} + best = 0 + for word in words: + cur = 1 + for i in range(len(word)): + pred = word[:i] + word[i + 1:] + if pred in dp and dp[pred] + 1 > cur: + cur = dp[pred] + 1 + dp[word] = cur + if cur > best: + best = cur + return result == best + +seed: 1048 + +tests: + - name: "single_word" + in: + words: + - "a" + out: 1 + - name: "single_long_word" + in: + words: + - "ab" + out: 1 + - name: "two_singletons" + in: + words: + - "a" + - "b" + out: 1 + - name: "simple_chain" + in: + words: + - "ab" + - "abc" + out: 2 + - name: "sample_chain" + in: + words: + - "a" + - "b" + - "ba" + - "bca" + - "bda" + - "bdca" + out: 4 + - name: "long_sample" + in: + words: + - "xbc" + - "pcxbcf" + - "xb" + - "cxbc" + - "pcxbc" + out: 5 + - name: "branching" + in: + words: + - "a" + - "ab" + - "ac" + - "bd" + - "abc" + - "abd" + - "abdd" + out: 4 + - name: "extra_tail" + in: + words: + - "a" + - "ba" + - "bca" + - "bda" + - "bdca" + - "bdcaa" + out: 5 + - name: "four_step" + in: + words: + - "x" + - "xy" + - "xyz" + - "wxyz" + out: 4 + - name: "kirah" + in: + words: + - "k" + - "ki" + - "kir" + - "kira" + - "kirah" + out: 5 + - name: "three_way" + in: + words: + - "a" + - "b" + - "c" + - "ab" + - "ac" + - "bc" + - "abc" + out: 3 + - name: "plate_chain" + in: + words: + - "a" + - "at" + - "ate" + - "late" + - "plate" + - "plates" + out: 6 + - name: "meet" + in: + words: + - "me" + - "met" + - "meet" + - "meets" + out: 4 + - name: "chain_with_noise" + in: + words: + - "a" + - "ba" + - "bca" + - "bdca" + - "bdcab" + - "bdcaba" + out: 6 + - name: "ordered_prefix" + in: + words: + - "a" + - "b" + - "ab" + - "abc" + - "abcd" + - "abcde" + out: 5 + - name: "z_chain" + in: + words: + - "z" + - "za" + - "zab" + - "zabc" + - "zabcd" + out: 5 + - name: "m_chain" + in: + words: + - "m" + - "am" + - "mam" + - "maam" + - "maaam" + out: 5 + - name: "geek_chain" + in: + words: + - "g" + - "ge" + - "gee" + - "geek" + - "geeks" + - "geekss" + out: 6 + - name: "missing_step" + in: + words: + - "a" + - "ba" + - "bda" + - "bdca" + - "bcdca" + out: 5 + - name: "top_stop" + in: + words: + - "t" + - "to" + - "top" + - "stop" + - "stops" + out: 5 + - name: "spray" + in: + words: + - "p" + - "pa" + - "pat" + - "prat" + - "sprat" + - "spray" + out: 5 + - name: "hands" + in: + words: + - "h" + - "ha" + - "han" + - "hand" + - "hands" + out: 5 + - name: "cars" + in: + words: + - "c" + - "ca" + - "car" + - "cars" + - "scars" + out: 5 + - name: "bread" + in: + words: + - "r" + - "re" + - "red" + - "read" + - "bread" + out: 5 + - name: "strops" + in: + words: + - "o" + - "op" + - "top" + - "stop" + - "stops" + - "strops" + out: 6 + - name: "notes" + in: + words: + - "n" + - "no" + - "not" + - "note" + - "notes" + out: 5 + - name: "string" + in: + words: + - "s" + - "st" + - "str" + - "stri" + - "strin" + - "string" + out: 6 + - name: "foooo" + in: + words: + - "f" + - "fo" + - "foo" + - "fooo" + - "foooo" + out: 5 + - name: "unity" + in: + words: + - "u" + - "un" + - "uni" + - "unit" + - "unity" + out: 5 + - name: "depth" + in: + words: + - "d" + - "de" + - "def" + - "deft" + - "depth" + out: 4 + - name: "plane" + in: + words: + - "l" + - "la" + - "lap" + - "plan" + - "plane" + out: 3 + - name: "qabde" + in: + words: + - "q" + - "qa" + - "qab" + - "qabd" + - "qabde" + out: 5 + - name: "ward" + in: + words: + - "w" + - "wa" + - "war" + - "ward" + - "words" + out: 4 + - name: "yaks" + in: + words: + - "y" + - "ya" + - "yak" + - "yaks" + out: 4 + - name: "learn" + in: + words: + - "e" + - "ea" + - "ear" + - "earn" + - "learn" + out: 5 + - name: "barker" + in: + words: + - "b" + - "ba" + - "bar" + - "bark" + - "barke" + - "barker" + out: 6 diff --git a/tests/1001-1500/1048. longest-string-chain/sol.cpp b/tests/1001-1500/1048. longest-string-chain/sol.cpp new file mode 100644 index 00000000..50fa330c --- /dev/null +++ b/tests/1001-1500/1048. longest-string-chain/sol.cpp @@ -0,0 +1,25 @@ +class Solution { +public: + int longestStrChain(vector& words) { + unordered_map chains; + sort(words.begin(), words.end(), [](const string& a, const string& b) { + return a.length() < b.length(); + }); + + for (const string& word : words) { + chains[word] = 1; + for (int i = 0; i < word.length(); i++) { + string pred = word.substr(0, i) + word.substr(i + 1); + if (chains.find(pred) != chains.end()) { + chains[word] = max(chains[word], chains[pred] + 1); + } + } + } + + int maxLen = 0; + for (const auto& pair : chains) { + maxLen = max(maxLen, pair.second); + } + return maxLen; + } +}; diff --git a/tests/1001-1500/1048. longest-string-chain/sol.cs b/tests/1001-1500/1048. longest-string-chain/sol.cs new file mode 100644 index 00000000..58d2ef33 --- /dev/null +++ b/tests/1001-1500/1048. longest-string-chain/sol.cs @@ -0,0 +1,22 @@ +public class Solution { + public int LongestStrChain(string[] words) { + Dictionary chains = new Dictionary(); + Array.Sort(words, (a, b) => a.Length.CompareTo(b.Length)); + + foreach (string word in words) { + chains[word] = 1; + for (int i = 0; i < word.Length; i++) { + string pred = word.Substring(0, i) + word.Substring(i + 1); + if (chains.ContainsKey(pred)) { + chains[word] = Math.Max(chains[word], chains[pred] + 1); + } + } + } + + int maxLen = 0; + foreach (int len in chains.Values) { + maxLen = Math.Max(maxLen, len); + } + return maxLen; + } +} diff --git a/tests/1001-1500/1048. longest-string-chain/sol.dart b/tests/1001-1500/1048. longest-string-chain/sol.dart new file mode 100644 index 00000000..0459d657 --- /dev/null +++ b/tests/1001-1500/1048. longest-string-chain/sol.dart @@ -0,0 +1,22 @@ +class Solution { + int longestStrChain(List words) { + Map chains = {}; + words.sort((a, b) => a.length.compareTo(b.length)); + + for (String word in words) { + chains[word] = 1; + for (int i = 0; i < word.length; i++) { + String pred = word.substring(0, i) + word.substring(i + 1); + if (chains.containsKey(pred)) { + chains[word] = max(chains[word]!, chains[pred]! + 1); + } + } + } + + int maxLen = 0; + for (int len in chains.values) { + if (len > maxLen) maxLen = len; + } + return maxLen; + } +} diff --git a/tests/1001-1500/1048. longest-string-chain/sol.go b/tests/1001-1500/1048. longest-string-chain/sol.go new file mode 100644 index 00000000..7f9e739d --- /dev/null +++ b/tests/1001-1500/1048. longest-string-chain/sol.go @@ -0,0 +1,26 @@ +func longestStrChain(words []string) int { + chains := make(map[string]int) + sort.Slice(words, func(i, j int) bool { + return len(words[i]) < len(words[j]) + }) + + for _, word := range words { + chains[word] = 1 + for i := 0; i < len(word); i++ { + pred := word[:i] + word[i+1:] + if val, ok := chains[pred]; ok { + if val+1 > chains[word] { + chains[word] = val + 1 + } + } + } + } + + maxLen := 0 + for _, v := range chains { + if v > maxLen { + maxLen = v + } + } + return maxLen +} diff --git a/tests/1001-1500/1048. longest-string-chain/sol.java b/tests/1001-1500/1048. longest-string-chain/sol.java new file mode 100644 index 00000000..a4e67382 --- /dev/null +++ b/tests/1001-1500/1048. longest-string-chain/sol.java @@ -0,0 +1,22 @@ +class Solution { + public int longestStrChain(String[] words) { + Map chains = new HashMap<>(); + Arrays.sort(words, (a, b) -> a.length() - b.length()); + + for (String word : words) { + chains.put(word, 1); + for (int i = 0; i < word.length(); i++) { + String pred = word.substring(0, i) + word.substring(i + 1); + if (chains.containsKey(pred)) { + chains.put(word, Math.max(chains.get(word), chains.get(pred) + 1)); + } + } + } + + int maxLen = 0; + for (int len : chains.values()) { + maxLen = Math.max(maxLen, len); + } + return maxLen; + } +} diff --git a/tests/1001-1500/1048. longest-string-chain/sol.kt b/tests/1001-1500/1048. longest-string-chain/sol.kt new file mode 100644 index 00000000..e598ee04 --- /dev/null +++ b/tests/1001-1500/1048. longest-string-chain/sol.kt @@ -0,0 +1,18 @@ +class Solution { + fun longestStrChain(words: Array): Int { + val chains = mutableMapOf() + val sortedWords = words.sortedBy { it.length } + + for (word in sortedWords) { + chains[word] = 1 + for (i in word.indices) { + val pred = word.substring(0, i) + word.substring(i + 1) + if (chains.containsKey(pred)) { + chains[word] = maxOf(chains[word]!!, chains[pred]!! + 1) + } + } + } + + return chains.values.max() + } +} diff --git a/tests/1001-1500/1048. longest-string-chain/sol.py b/tests/1001-1500/1048. longest-string-chain/sol.py new file mode 100644 index 00000000..e16cd56a --- /dev/null +++ b/tests/1001-1500/1048. longest-string-chain/sol.py @@ -0,0 +1,19 @@ +class Solution: + def longestStrChain(self, words: List[str]) -> int: + chains = {} # Stores the max chain length for each word + sorted_words = sorted(words, key=len) # Sort words by length + + for word in sorted_words: + chains[word] = 1 # Initialize the chain length for the current word + + for i in range(len(word)): + # word = abc, i = 0, word[:i] = "" + word[i+1:] = "bc" = "bc" + # word = abc, i = 1, word[:i] = "a" + word[i+1:] = "c" = "ac" + # word = abc, i = 2, word[:i] = "ab" + word[i+1:] = "" = "ab" + pred = ( + word[:i] + word[i + 1 :] + ) # Generate predecessor by removing one character + if pred in chains: + chains[word] = max(chains[word], chains[pred] + 1) + + return max(chains.values()) diff --git a/tests/1001-1500/1048. longest-string-chain/sol.py2 b/tests/1001-1500/1048. longest-string-chain/sol.py2 new file mode 100644 index 00000000..31b2bad7 --- /dev/null +++ b/tests/1001-1500/1048. longest-string-chain/sol.py2 @@ -0,0 +1,17 @@ +class Solution(object): + def longestStrChain(self, words): + """ + :type words: List[str] + :rtype: int + """ + chains = {} + sorted_words = sorted(words, key=len) + + for word in sorted_words: + chains[word] = 1 + for i in range(len(word)): + pred = word[:i] + word[i+1:] + if pred in chains: + chains[word] = max(chains[word], chains[pred] + 1) + + return max(chains.values()) diff --git a/tests/1001-1500/1048. longest-string-chain/sol.rb b/tests/1001-1500/1048. longest-string-chain/sol.rb new file mode 100644 index 00000000..d5298822 --- /dev/null +++ b/tests/1001-1500/1048. longest-string-chain/sol.rb @@ -0,0 +1,18 @@ +# @param {String[]} words +# @return {Integer} +def longest_str_chain(words) + chains = {} + sorted_words = words.sort_by(&:length) + + sorted_words.each do |word| + chains[word] = 1 + (0...word.length).each do |i| + pred = word[0...i] + word[i+1..-1] + if chains.key?(pred) + chains[word] = [chains[word], chains[pred] + 1].max + end + end + end + + chains.values.max +end diff --git a/tests/1001-1500/1048. longest-string-chain/sol.rs b/tests/1001-1500/1048. longest-string-chain/sol.rs new file mode 100644 index 00000000..173f95c3 --- /dev/null +++ b/tests/1001-1500/1048. longest-string-chain/sol.rs @@ -0,0 +1,23 @@ +impl Solution { + pub fn longest_str_chain(words: Vec) -> i32 { + use std::collections::HashMap; + + let mut words = words; + words.sort_by_key(|w| w.len()); + + let mut chains: HashMap = HashMap::new(); + + for word in &words { + chains.insert(word.clone(), 1); + for i in 0..word.len() { + let pred = format!("{}{}", &word[..i], &word[i+1..]); + if let Some(&prev_chain) = chains.get(&pred) { + let current = chains.get_mut(word).unwrap(); + *current = (*current).max(prev_chain + 1); + } + } + } + + chains.values().max().copied().unwrap_or(0) + } +} diff --git a/tests/1001-1500/1048. longest-string-chain/sol.swift b/tests/1001-1500/1048. longest-string-chain/sol.swift new file mode 100644 index 00000000..27e195cb --- /dev/null +++ b/tests/1001-1500/1048. longest-string-chain/sol.swift @@ -0,0 +1,19 @@ +class Solution { + func longestStrChain(_ words: [String]) -> Int { + var chains = [String: Int]() + let sortedWords = words.sorted { $0.count < $1.count } + + for word in sortedWords { + chains[word] = 1 + for i in word.indices { + var pred = word + pred.remove(at: i) + if let prevChain = chains[pred] { + chains[word] = max(chains[word]!, prevChain + 1) + } + } + } + + return chains.values.max() ?? 0 + } +} diff --git a/tests/1001-1500/1048. longest-string-chain/sol.ts b/tests/1001-1500/1048. longest-string-chain/sol.ts new file mode 100644 index 00000000..351fd4a8 --- /dev/null +++ b/tests/1001-1500/1048. longest-string-chain/sol.ts @@ -0,0 +1,20 @@ +function longestStrChain(words: string[]): number { + const chains: Map = new Map(); + words.sort((a, b) => a.length - b.length); + + for (const word of words) { + chains.set(word, 1); + for (let i = 0; i < word.length; i++) { + const pred = word.slice(0, i) + word.slice(i + 1); + if (chains.has(pred)) { + chains.set(word, Math.max(chains.get(word)!, chains.get(pred)! + 1)); + } + } + } + + let maxLen = 0; + for (const len of chains.values()) { + maxLen = Math.max(maxLen, len); + } + return maxLen; +} diff --git a/tests/1001-1500/1049. last-stone-weight-ii/manifest.yaml b/tests/1001-1500/1049. last-stone-weight-ii/manifest.yaml new file mode 100644 index 00000000..062517aa --- /dev/null +++ b/tests/1001-1500/1049. last-stone-weight-ii/manifest.yaml @@ -0,0 +1,201 @@ +entry: + id: 1049 + title: "last-stone-weight-ii" + params: + stones: + type: array + items: + type: int + call: + cpp: "Solution().lastStoneWeightII({stones})" + rust: "Solution::last_stone_weight_ii({stones})" + python3: "Solution().lastStoneWeightII({stones})" + python2: "Solution().lastStoneWeightII({stones})" + ruby: "last_stone_weight_ii({stones})" + java: "new Solution().lastStoneWeightII({stones})" + csharp: "new Solution().LastStoneWeightII({stones})" + kotlin: "Solution().lastStoneWeightII({stones})" + go: "lastStoneWeightII({stones})" + dart: "Solution().lastStoneWeightII({stones})" + swift: "Solution().lastStoneWeightII({stones})" + typescript: "lastStoneWeightII({stones})" + +judge: + type: "exact" + +limits: + time_ms: 200 + memory_mb: 300 + +oracle: + python3: + call: "Checker().lastStoneWeightII(stones, {result})" + checker: | + class Checker: + def lastStoneWeightII(self, stones, result) -> bool: + total = sum(stones) + target = total // 2 + dp = [0] * (target + 1) + for s in stones: + for i in range(target, s - 1, -1): + cand = dp[i - s] + s + if cand > dp[i]: + dp[i] = cand + expected = total - 2 * dp[target] + return result == expected + +seed: 1049 + +tests: + - name: "pair_equal" + in: + stones: [1, 1] + out: 0 + - name: "sample" + in: + stones: [2, 7, 4, 1, 8, 1] + out: 1 + - name: "from_prompt" + in: + stones: [31, 26, 33, 21, 40] + out: 5 + - name: "two_diff" + in: + stones: [1, 2] + out: 1 + - name: "two_gap" + in: + stones: [1, 3] + out: 2 + - name: "two_large_gap" + in: + stones: [1, 4] + out: 3 + - name: "two_more" + in: + stones: [1, 5] + out: 4 + - name: "four_equal" + in: + stones: [2, 2, 2, 2] + out: 0 + - name: "four_equal_three" + in: + stones: [3, 3, 3, 3] + out: 0 + - name: "small_mix" + in: + stones: [2, 3, 5] + out: 0 + - name: "three_mix" + in: + stones: [2, 7, 4] + out: 1 + - name: "ascending_four" + in: + stones: [8, 9, 10, 11] + out: 0 + - name: "half_match" + in: + stones: [1, 6, 11, 5] + out: 1 + - name: "many_same" + in: + stones: [10, 10, 10, 10, 10] + out: 10 + - name: "mixed_five" + in: + stones: [7, 3, 2, 5, 8] + out: 1 + - name: "triple_six" + in: + stones: [6, 6, 6] + out: 6 + - name: "consecutive" + in: + stones: [1, 2, 3, 4, 5] + out: 1 + - name: "double_pair" + in: + stones: [9, 1, 2, 2] + out: 4 + - name: "double_equal" + in: + stones: [14, 7, 7, 14] + out: 0 + - name: "five_ones" + in: + stones: [1, 1, 1, 1, 1] + out: 1 + - name: "three_large" + in: + stones: [20, 30, 40] + out: 10 + - name: "descending_five" + in: + stones: [9, 8, 7, 6, 5] + out: 1 + - name: "fibonacci_like" + in: + stones: [2, 2, 3, 5, 8, 13] + out: 1 + - name: "all_eleven" + in: + stones: [11, 11, 11, 11, 11, 11] + out: 0 + - name: "odd_mix" + in: + stones: [17, 4, 6, 8, 10] + out: 1 + - name: "arithmetic" + in: + stones: [12, 15, 18, 21] + out: 0 + - name: "small_tail" + in: + stones: [1, 7, 8, 9, 10] + out: 1 + - name: "clustered" + in: + stones: [5, 6, 7, 8, 9] + out: 1 + - name: "tripled_pairs" + in: + stones: [4, 4, 4, 5, 5, 5] + out: 1 + - name: "triple_double" + in: + stones: [19, 19, 18, 18, 1, 1] + out: 0 + - name: "descending_six" + in: + stones: [25, 24, 23, 22, 21, 20] + out: 1 + - name: "step_three" + in: + stones: [3, 6, 9, 12, 15] + out: 3 + - name: "one_big" + in: + stones: [30, 1, 1, 1] + out: 27 + - name: "powers" + in: + stones: [16, 8, 4, 2, 1] + out: 1 + - name: "even_progression" + in: + stones: [2, 4, 6, 8, 10, 12] + out: 2 + - name: "all_sevens" + in: + stones: [7, 7, 7, 7] + out: 0 + - name: "large_progression" + in: + stones: [1, 10, 20, 30, 40] + out: 1 + - name: "prime_mix" + in: + stones: [13, 17, 19, 23] + out: 0 diff --git a/tests/1001-1500/1049. last-stone-weight-ii/sol.cpp b/tests/1001-1500/1049. last-stone-weight-ii/sol.cpp new file mode 100644 index 00000000..3a31fdf1 --- /dev/null +++ b/tests/1001-1500/1049. last-stone-weight-ii/sol.cpp @@ -0,0 +1,19 @@ +class Solution { +public: + int lastStoneWeightII(vector& stones) { + int n = stones.size(); + int total = accumulate(stones.begin(), stones.end(), 0); + int target = total / 2; + vector dp_prev(target + 1, 0); + for (int i = n - 1; i >= 0; i--) { + vector dp_curr(target + 1, 0); + for (int size = 0; size <= target; size++) { + int skip = dp_prev[size]; + int take = (size >= stones[i]) ? dp_prev[size - stones[i]] + stones[i] : INT_MIN; + dp_curr[size] = max(skip, take); + } + dp_prev = dp_curr; + } + return total - 2 * dp_prev[target]; + } +}; diff --git a/tests/1001-1500/1049. last-stone-weight-ii/sol.cs b/tests/1001-1500/1049. last-stone-weight-ii/sol.cs new file mode 100644 index 00000000..3f294788 --- /dev/null +++ b/tests/1001-1500/1049. last-stone-weight-ii/sol.cs @@ -0,0 +1,19 @@ +public class Solution { + public int LastStoneWeightII(int[] stones) { + int n = stones.Length; + int total = 0; + foreach (int v in stones) total += v; + int target = total / 2; + int[] dp_prev = new int[target + 1]; + for (int i = n - 1; i >= 0; i--) { + int[] dp_curr = new int[target + 1]; + for (int size = 0; size <= target; size++) { + int skip = dp_prev[size]; + int take = (size >= stones[i]) ? dp_prev[size - stones[i]] + stones[i] : int.MinValue; + dp_curr[size] = Math.Max(skip, take); + } + dp_prev = dp_curr; + } + return total - 2 * dp_prev[target]; + } +} diff --git a/tests/1001-1500/1049. last-stone-weight-ii/sol.dart b/tests/1001-1500/1049. last-stone-weight-ii/sol.dart new file mode 100644 index 00000000..25dde9c5 --- /dev/null +++ b/tests/1001-1500/1049. last-stone-weight-ii/sol.dart @@ -0,0 +1,18 @@ +class Solution { + int lastStoneWeightII(List stones) { + int n = stones.length; + int total = stones.fold(0, (sum, v) => sum + v); + int target = total ~/ 2; + List dp_prev = List.filled(target + 1, 0); + for (int i = n - 1; i >= 0; i--) { + List dp_curr = List.filled(target + 1, 0); + for (int size = 0; size <= target; size++) { + int skip = dp_prev[size]; + int take = size >= stones[i] ? dp_prev[size - stones[i]] + stones[i] : -9223372036854775808; + dp_curr[size] = skip > take ? skip : take; + } + dp_prev = dp_curr; + } + return total - 2 * dp_prev[target]; + } +} diff --git a/tests/1001-1500/1049. last-stone-weight-ii/sol.go b/tests/1001-1500/1049. last-stone-weight-ii/sol.go new file mode 100644 index 00000000..0d2aa960 --- /dev/null +++ b/tests/1001-1500/1049. last-stone-weight-ii/sol.go @@ -0,0 +1,26 @@ +func lastStoneWeightII(stones []int) int { + n := len(stones) + total := 0 + for _, v := range stones { + total += v + } + target := total / 2 + dp_prev := make([]int, target+1) + for i := n - 1; i >= 0; i-- { + dp_curr := make([]int, target+1) + for size := 0; size <= target; size++ { + skip := dp_prev[size] + take := int(math.Inf(-1)) + if size >= stones[i] { + take = dp_prev[size - stones[i]] + stones[i] + } + if skip > take { + dp_curr[size] = skip + } else { + dp_curr[size] = take + } + } + dp_prev = dp_curr + } + return total - 2 * dp_prev[target] +} diff --git a/tests/1001-1500/1049. last-stone-weight-ii/sol.java b/tests/1001-1500/1049. last-stone-weight-ii/sol.java new file mode 100644 index 00000000..db9427ac --- /dev/null +++ b/tests/1001-1500/1049. last-stone-weight-ii/sol.java @@ -0,0 +1,19 @@ +class Solution { + public int lastStoneWeightII(int[] stones) { + int n = stones.length; + int total = 0; + for (int stone : stones) total += stone; + int target = total / 2; + int[] dp_prev = new int[target + 1]; + for (int i = n - 1; i >= 0; i--) { + int[] dp_curr = new int[target + 1]; + for (int size = 0; size <= target; size++) { + int skip = dp_prev[size]; + int take = (size >= stones[i]) ? dp_prev[size - stones[i]] + stones[i] : Integer.MIN_VALUE; + dp_curr[size] = Math.max(skip, take); + } + dp_prev = dp_curr; + } + return total - 2 * dp_prev[target]; + } +} diff --git a/tests/1001-1500/1049. last-stone-weight-ii/sol.kt b/tests/1001-1500/1049. last-stone-weight-ii/sol.kt new file mode 100644 index 00000000..aa67f23b --- /dev/null +++ b/tests/1001-1500/1049. last-stone-weight-ii/sol.kt @@ -0,0 +1,18 @@ +class Solution { + fun lastStoneWeightII(stones: IntArray): Int { + val n = stones.size + val total = stones.sum() + val target = total / 2 + var dp_prev = IntArray(target + 1) + for (i in n - 1 downTo 0) { + val dp_curr = IntArray(target + 1) + for (size in 0..target) { + val skip = dp_prev[size] + val take = if (size >= stones[i]) dp_prev[size - stones[i]] + stones[i] else Int.MIN_VALUE + dp_curr[size] = maxOf(skip, take) + } + dp_prev = dp_curr + } + return total - 2 * dp_prev[target] + } +} diff --git a/tests/1001-1500/1049. last-stone-weight-ii/sol.py b/tests/1001-1500/1049. last-stone-weight-ii/sol.py new file mode 100644 index 00000000..31845b3d --- /dev/null +++ b/tests/1001-1500/1049. last-stone-weight-ii/sol.py @@ -0,0 +1,20 @@ +class Solution: + """Iterative 1D Solution""" + + def lastStoneWeightII(self, stones: list[int]) -> int: + n = len(stones) + total = sum(stones) + target = total // 2 + dp_prev = [0] * (target + 1) + for i in range(n - 1, -1, -1): + dp_curr = [0] * (target + 1) + for size in range(target + 1): + skip = dp_prev[size] + take = ( + dp_prev[size - stones[i]] + stones[i] + if size >= stones[i] + else float("-inf") + ) + dp_curr[size] = max(skip, take) + dp_prev = dp_curr + return total - 2 * dp_prev[target] diff --git a/tests/1001-1500/1049. last-stone-weight-ii/sol.py2 b/tests/1001-1500/1049. last-stone-weight-ii/sol.py2 new file mode 100644 index 00000000..7cd2f1bf --- /dev/null +++ b/tests/1001-1500/1049. last-stone-weight-ii/sol.py2 @@ -0,0 +1,18 @@ +class Solution(object): + def lastStoneWeightII(self, stones): + """ + :type stones: List[int] + :rtype: int + """ + n = len(stones) + total = sum(stones) + target = total // 2 + dp_prev = [0] * (target + 1) + for i in range(n - 1, -1, -1): + dp_curr = [0] * (target + 1) + for size in range(target + 1): + skip = dp_prev[size] + take = dp_prev[size - stones[i]] + stones[i] if size >= stones[i] else float('-inf') + dp_curr[size] = max(skip, take) + dp_prev = dp_curr + return total - 2 * dp_prev[target] diff --git a/tests/1001-1500/1049. last-stone-weight-ii/sol.rb b/tests/1001-1500/1049. last-stone-weight-ii/sol.rb new file mode 100644 index 00000000..f811ef72 --- /dev/null +++ b/tests/1001-1500/1049. last-stone-weight-ii/sol.rb @@ -0,0 +1,18 @@ +# @param {Integer[]} stones +# @return {Integer} +def last_stone_weight_ii(stones) + n = stones.length + total = stones.sum + target = total / 2 + dp_prev = Array.new(target + 1, 0) + (n - 1).downto(0) do |i| + dp_curr = Array.new(target + 1, 0) + (0..target).each do |size| + skip = dp_prev[size] + take = size >= stones[i] ? dp_prev[size - stones[i]] + stones[i] : -Float::INFINITY + dp_curr[size] = [skip, take].max + end + dp_prev = dp_curr + end + total - 2 * dp_prev[target] +end diff --git a/tests/1001-1500/1049. last-stone-weight-ii/sol.rs b/tests/1001-1500/1049. last-stone-weight-ii/sol.rs new file mode 100644 index 00000000..ae5d8dc7 --- /dev/null +++ b/tests/1001-1500/1049. last-stone-weight-ii/sol.rs @@ -0,0 +1,22 @@ +impl Solution { + pub fn last_stone_weight_ii(stones: Vec) -> i32 { + let n = stones.len(); + let total: i32 = stones.iter().sum(); + let target = (total / 2) as usize; + let mut dp_prev = vec![0; target + 1]; + for i in (0..n).rev() { + let mut dp_curr = vec![0; target + 1]; + for size in 0..=target { + let skip = dp_prev[size]; + let take = if size as i32 >= stones[i] { + dp_prev[size - stones[i] as usize] + stones[i] + } else { + i32::MIN + }; + dp_curr[size] = skip.max(take); + } + dp_prev = dp_curr; + } + total - 2 * dp_prev[target] + } +} diff --git a/tests/1001-1500/1049. last-stone-weight-ii/sol.swift b/tests/1001-1500/1049. last-stone-weight-ii/sol.swift new file mode 100644 index 00000000..5586b61a --- /dev/null +++ b/tests/1001-1500/1049. last-stone-weight-ii/sol.swift @@ -0,0 +1,23 @@ +class Solution { + func lastStoneWeightII(_ stones: [Int]) -> Int { + let n = stones.count + let total = stones.reduce(0, +) + let target = total / 2 + var dp_prev = [Int](repeating: 0, count: target + 1) + for i in stride(from: n - 1, through: 0, by: -1) { + var dp_curr = [Int](repeating: 0, count: target + 1) + for size in 0...target { + let skip = dp_prev[size] + let take: Int + if size >= stones[i] { + take = dp_prev[size - stones[i]] + stones[i] + } else { + take = Int.min + } + dp_curr[size] = max(skip, take) + } + dp_prev = dp_curr + } + return total - 2 * dp_prev[target] + } +} diff --git a/tests/1001-1500/1049. last-stone-weight-ii/sol.ts b/tests/1001-1500/1049. last-stone-weight-ii/sol.ts new file mode 100644 index 00000000..364d90bc --- /dev/null +++ b/tests/1001-1500/1049. last-stone-weight-ii/sol.ts @@ -0,0 +1,17 @@ +function lastStoneWeightII(stones: number[]): number { + const n = stones.length; + const total = stones.reduce((a, b) => a + b, 0); + const target = Math.floor(total / 2); + let dp_prev: number[] = new Array(target + 1).fill(0); + for (let i = n - 1; i >= 0; i--) { + const dp_curr: number[] = new Array(target + 1).fill(0); + for (let size = 0; size <= target; size++) { + const skip = dp_prev[size]; + const take = + size >= stones[i] ? dp_prev[size - stones[i]] + stones[i] : -Infinity; + dp_curr[size] = Math.max(skip, take); + } + dp_prev = dp_curr; + } + return total - 2 * dp_prev[target]; +} diff --git a/tests/1001-1500/1051. height-checker/manifest.yaml b/tests/1001-1500/1051. height-checker/manifest.yaml new file mode 100644 index 00000000..6bf0c703 --- /dev/null +++ b/tests/1001-1500/1051. height-checker/manifest.yaml @@ -0,0 +1,180 @@ +entry: + id: 1051 + title: height-checker + params: + heights: + type: array + items: + type: int + call: + cpp: "Solution().heightChecker({heights})" + rust: "Solution::height_checker({heights})" + python3: "Solution().heightChecker({heights})" + python2: "Solution().heightChecker({heights})" + ruby: "height_checker({heights})" + java: "new Solution().heightChecker({heights})" + csharp: "new Solution().HeightChecker({heights})" + kotlin: "Solution().heightChecker({heights})" + go: "heightChecker({heights})" + dart: "Solution().heightChecker({heights})" + swift: "Solution().heightChecker({heights})" + typescript: "heightChecker({heights})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().heightChecker(heights, {result})" + checker: | + class Checker: + def heightChecker(self, heights, result): + expected = sum(a != b for a, b in zip(heights, sorted(heights))) + return result == expected +seed: 1051 +tests: + - name: ex1 + in: + heights: [1, 1, 4, 2, 1, 3] + out: 3 + - name: ex2 + in: + heights: [5, 1, 2, 3, 4] + out: 5 + - name: ex3 + in: + heights: [1, 2, 3, 4, 5] + out: 0 + - name: single + in: + heights: [7] + out: 0 + - name: already_sorted_with_dupes + in: + heights: [1, 1, 2, 2, 3, 3] + out: 0 + - name: reverse_small + in: + heights: [3, 2, 1] + out: 2 + - name: all_same + in: + heights: [4, 4, 4, 4] + out: 0 + - name: swap_tail + in: + heights: [1, 2, 4, 3] + out: 2 + - name: random1 + in: + heights: [10, 6, 8, 7, 5, 9] + out: 5 + - name: random2 + in: + heights: [2, 1, 2, 1, 2] + out: 2 + - name: random3 + in: + heights: [9, 1, 10, 2, 3, 4] + out: 6 + - name: random4 + in: + heights: [6, 5, 4, 3, 2, 1] + out: 6 + - name: random5 + in: + heights: [1, 3, 2, 2, 4, 4, 5] + out: 2 + - name: random6 + in: + heights: [5, 5, 1, 1, 5, 1] + out: 4 + - name: random7 + in: + heights: [2, 3, 3, 2, 1, 1] + out: 5 + - name: random8 + in: + heights: [8, 1, 2, 8, 3, 4, 5, 6] + out: 8 + - name: random9 + in: + heights: [1, 4, 4, 2, 2, 3] + out: 5 + - name: random10 + in: + heights: [2, 2, 1, 1, 3, 3] + out: 4 + - name: random11 + in: + heights: [9, 8, 7, 6, 5] + out: 4 + - name: random12 + in: + heights: [1, 2, 3, 5, 4] + out: 2 + - name: random13 + in: + heights: [4, 1, 3, 2] + out: 3 + - name: random14 + in: + heights: [1, 2, 2, 3, 5, 4, 6] + out: 2 + - name: random15 + in: + heights: [100, 1, 100, 1, 100] + out: 2 + - name: random16 + in: + heights: [3, 1, 2, 3, 1, 2] + out: 4 + - name: random17 + in: + heights: [1, 5, 3, 3, 2, 4] + out: 3 + - name: random18 + in: + heights: [2, 6, 4, 8, 10, 9, 15] + out: 4 + - name: random19 + in: + heights: [1, 1, 1, 2, 2, 2, 3, 3, 3] + out: 0 + - name: random20 + in: + heights: [3, 1, 3, 1, 3, 1] + out: 4 + - name: random21 + in: + heights: [2, 4, 1, 2, 3] + out: 5 + - name: random22 + in: + heights: [7, 7, 6, 6, 5, 5, 4, 4] + out: 8 + - name: random23 + in: + heights: [1, 6, 2, 5, 3, 4] + out: 5 + - name: random24 + in: + heights: [2, 3, 1] + out: 3 + - name: random25 + in: + heights: [1, 2, 4, 4, 4, 3] + out: 2 + - name: random26 + in: + heights: [5, 2, 3, 4, 1] + out: 2 + - name: random27 + in: + heights: [1, 1, 2, 3, 2, 2, 4] + out: 2 + - name: random28 + in: + heights: [9, 9, 8, 8, 7, 7, 6] + out: 6 diff --git a/tests/1001-1500/1051. height-checker/sol.cpp b/tests/1001-1500/1051. height-checker/sol.cpp new file mode 100644 index 00000000..981fa733 --- /dev/null +++ b/tests/1001-1500/1051. height-checker/sol.cpp @@ -0,0 +1,14 @@ +class Solution { +public: + int heightChecker(vector& heights) { + int count = 0; + vector s = heights; + sort(s.begin(), s.end()); + for (int i = 0; i < heights.size(); i++) { + if (heights[i] != s[i]) { + count++; + } + } + return count; + } +}; diff --git a/tests/1001-1500/1051. height-checker/sol.cs b/tests/1001-1500/1051. height-checker/sol.cs new file mode 100644 index 00000000..f028224f --- /dev/null +++ b/tests/1001-1500/1051. height-checker/sol.cs @@ -0,0 +1,13 @@ +public class Solution { + public int HeightChecker(int[] heights) { + int count = 0; + int[] s = (int[])heights.Clone(); + Array.Sort(s); + for (int i = 0; i < heights.Length; i++) { + if (heights[i] != s[i]) { + count++; + } + } + return count; + } +} diff --git a/tests/1001-1500/1051. height-checker/sol.dart b/tests/1001-1500/1051. height-checker/sol.dart new file mode 100644 index 00000000..5e02f39f --- /dev/null +++ b/tests/1001-1500/1051. height-checker/sol.dart @@ -0,0 +1,13 @@ +class Solution { + int heightChecker(List heights) { + int count = 0; + List s = List.from(heights); + s.sort(); + for (int i = 0; i < heights.length; i++) { + if (heights[i] != s[i]) { + count++; + } + } + return count; + } +} diff --git a/tests/1001-1500/1051. height-checker/sol.go b/tests/1001-1500/1051. height-checker/sol.go new file mode 100644 index 00000000..04f60356 --- /dev/null +++ b/tests/1001-1500/1051. height-checker/sol.go @@ -0,0 +1,12 @@ +func heightChecker(heights []int) int { + count := 0 + s := make([]int, len(heights)) + copy(s, heights) + sort.Ints(s) + for i := 0; i < len(heights); i++ { + if heights[i] != s[i] { + count++ + } + } + return count +} diff --git a/tests/1001-1500/1051. height-checker/sol.java b/tests/1001-1500/1051. height-checker/sol.java new file mode 100644 index 00000000..39ca7a31 --- /dev/null +++ b/tests/1001-1500/1051. height-checker/sol.java @@ -0,0 +1,13 @@ +class Solution { + public int heightChecker(int[] heights) { + int count = 0; + int[] s = heights.clone(); + Arrays.sort(s); + for (int i = 0; i < heights.length; i++) { + if (heights[i] != s[i]) { + count++; + } + } + return count; + } +} diff --git a/tests/1001-1500/1051. height-checker/sol.kt b/tests/1001-1500/1051. height-checker/sol.kt new file mode 100644 index 00000000..9e553618 --- /dev/null +++ b/tests/1001-1500/1051. height-checker/sol.kt @@ -0,0 +1,12 @@ +class Solution { + fun heightChecker(heights: IntArray): Int { + var count = 0 + val s = heights.sorted() + for (i in heights.indices) { + if (heights[i] != s[i]) { + count++ + } + } + return count + } +} diff --git a/tests/1001-1500/1051. height-checker/sol.py b/tests/1001-1500/1051. height-checker/sol.py new file mode 100644 index 00000000..0ad1e2c2 --- /dev/null +++ b/tests/1001-1500/1051. height-checker/sol.py @@ -0,0 +1,8 @@ +class Solution: + def heightChecker(self, heights: List[int]) -> int: + count = 0 + s = sorted(heights) + for i, j in zip(heights, s): + if i != j: + count += 1 + return count diff --git a/tests/1001-1500/1051. height-checker/sol.py2 b/tests/1001-1500/1051. height-checker/sol.py2 new file mode 100644 index 00000000..b257ec5c --- /dev/null +++ b/tests/1001-1500/1051. height-checker/sol.py2 @@ -0,0 +1,12 @@ +class Solution(object): + def heightChecker(self, heights): + """ + :type heights: List[int] + :rtype: int + """ + count = 0 + s = sorted(heights) + for i, j in zip(heights, s): + if i != j: + count += 1 + return count diff --git a/tests/1001-1500/1051. height-checker/sol.rb b/tests/1001-1500/1051. height-checker/sol.rb new file mode 100644 index 00000000..240f58f8 --- /dev/null +++ b/tests/1001-1500/1051. height-checker/sol.rb @@ -0,0 +1,10 @@ +# @param {Integer[]} heights +# @return {Integer} +def height_checker(heights) + count = 0 + s = heights.sort + heights.zip(s).each do |i, j| + count += 1 if i != j + end + count +end diff --git a/tests/1001-1500/1051. height-checker/sol.rs b/tests/1001-1500/1051. height-checker/sol.rs new file mode 100644 index 00000000..56f2c404 --- /dev/null +++ b/tests/1001-1500/1051. height-checker/sol.rs @@ -0,0 +1,13 @@ +impl Solution { + pub fn height_checker(heights: Vec) -> i32 { + let mut count = 0; + let mut s = heights.clone(); + s.sort(); + for i in 0..heights.len() { + if heights[i] != s[i] { + count += 1; + } + } + count + } +} diff --git a/tests/1001-1500/1051. height-checker/sol.swift b/tests/1001-1500/1051. height-checker/sol.swift new file mode 100644 index 00000000..8865be8d --- /dev/null +++ b/tests/1001-1500/1051. height-checker/sol.swift @@ -0,0 +1,12 @@ +class Solution { + func heightChecker(_ heights: [Int]) -> Int { + var count = 0 + let s = heights.sorted() + for i in 0.. a - b); + for (let i = 0; i < heights.length; i++) { + if (heights[i] !== s[i]) { + count++; + } + } + return count; +} diff --git a/tests/1001-1500/1052. grumpy-bookstore-owner/manifest.yaml b/tests/1001-1500/1052. grumpy-bookstore-owner/manifest.yaml new file mode 100644 index 00000000..b26c53bb --- /dev/null +++ b/tests/1001-1500/1052. grumpy-bookstore-owner/manifest.yaml @@ -0,0 +1,269 @@ +entry: + id: 1052 + title: grumpy-bookstore-owner + params: + customers: + type: array + items: + type: int + grumpy: + type: array + items: + type: int + minutes: + type: int + call: + cpp: "Solution().maxSatisfied({customers}, {grumpy}, {minutes})" + rust: "Solution::max_satisfied({customers}, {grumpy}, {minutes})" + python3: "Solution().maxSatisfied({customers}, {grumpy}, {minutes})" + python2: "Solution().maxSatisfied({customers}, {grumpy}, {minutes})" + ruby: "max_satisfied({customers}, {grumpy}, {minutes})" + java: "new Solution().maxSatisfied({customers}, {grumpy}, {minutes})" + csharp: "new Solution().MaxSatisfied({customers}, {grumpy}, {minutes})" + kotlin: "Solution().maxSatisfied({customers}, {grumpy}, {minutes})" + go: "maxSatisfied({customers}, {grumpy}, {minutes})" + dart: "Solution().maxSatisfied({customers}, {grumpy}, {minutes})" + swift: "Solution().maxSatisfied({customers}, {grumpy}, {minutes})" + typescript: "maxSatisfied({customers}, {grumpy}, {minutes})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().maxSatisfied(customers, grumpy, minutes, {result})" + checker: | + class Checker: + def maxSatisfied(self, customers, grumpy, minutes, result): + base = sum(c for c, g in zip(customers, grumpy) if not g) + gain = sum(c for c, g in zip(customers[:minutes], grumpy[:minutes]) if g) + best = gain + cur = gain + n = len(customers) + for i in range(minutes, n): + if grumpy[i]: + cur += customers[i] + if grumpy[i - minutes]: + cur -= customers[i - minutes] + if cur > best: + best = cur + return result == base + best +seed: 1052 +tests: + - name: ex1 + in: + customers: [1, 0, 1, 2, 1, 1, 7, 5] + grumpy: [0, 1, 0, 1, 0, 1, 0, 1] + minutes: 3 + out: 16 + - name: ex2 + in: + customers: [1] + grumpy: [0] + minutes: 1 + out: 1 + - name: all_satisfied + in: + customers: [2, 3, 4] + grumpy: [0, 0, 0] + minutes: 2 + out: 9 + - name: one_minute_gain + in: + customers: [4, 10, 10] + grumpy: [1, 0, 1] + minutes: 1 + out: 20 + - name: window_at_start + in: + customers: [5, 1, 3, 2] + grumpy: [1, 1, 0, 1] + minutes: 2 + out: 9 + - name: window_at_end + in: + customers: [3, 8, 2, 6] + grumpy: [0, 1, 1, 1] + minutes: 2 + out: 13 + - name: no_grumpy_gain + in: + customers: [9, 9, 9] + grumpy: [1, 1, 1] + minutes: 0 + out: 0 + - name: minutes_equals_n + in: + customers: [1, 2, 3, 4] + grumpy: [1, 1, 1, 1] + minutes: 4 + out: 10 + - name: alternating + in: + customers: [1, 2, 3, 4, 5, 6] + grumpy: [0, 1, 0, 1, 0, 1] + minutes: 2 + out: 15 + - name: all_grumpy_small_window + in: + customers: [3, 1, 4, 1, 5, 9] + grumpy: [1, 1, 1, 1, 1, 1] + minutes: 3 + out: 15 + - name: mixed_zeros + in: + customers: [0, 5, 0, 5, 0] + grumpy: [1, 0, 1, 0, 1] + minutes: 1 + out: 10 + - name: overlap_choice + in: + customers: [8, 2, 6, 4, 7] + grumpy: [1, 1, 0, 1, 1] + minutes: 2 + out: 17 + - name: single_grumpy + in: + customers: [7] + grumpy: [1] + minutes: 1 + out: 7 + - name: single_not_grumpy + in: + customers: [7] + grumpy: [0] + minutes: 1 + out: 7 + - name: short_window + in: + customers: [2, 2, 2, 2] + grumpy: [1, 0, 1, 0] + minutes: 1 + out: 6 + - name: long_window_middle + in: + customers: [10, 1, 10, 1, 10] + grumpy: [0, 1, 1, 1, 0] + minutes: 3 + out: 32 + - name: end_heavy + in: + customers: [1, 1, 1, 50, 50] + grumpy: [1, 1, 1, 1, 1] + minutes: 2 + out: 100 + - name: start_heavy + in: + customers: [50, 50, 1, 1, 1] + grumpy: [1, 1, 1, 1, 1] + minutes: 2 + out: 100 + - name: zero_customers + in: + customers: [0, 0, 0, 0] + grumpy: [1, 0, 1, 0] + minutes: 2 + out: 0 + - name: plateau + in: + customers: [4, 4, 4, 4, 4] + grumpy: [0, 1, 1, 1, 0] + minutes: 2 + out: 16 + - name: one_true_window + in: + customers: [6, 1, 6, 1, 6] + grumpy: [1, 0, 1, 0, 1] + minutes: 2 + out: 8 + - name: sparse_grumpy + in: + customers: [3, 2, 3, 2, 3, 2] + grumpy: [0, 1, 0, 1, 0, 1] + minutes: 3 + out: 13 + - name: window_one + in: + customers: [9, 1, 9, 1] + grumpy: [1, 1, 0, 1] + minutes: 1 + out: 18 + - name: all_grumpy_full_window + in: + customers: [1, 2, 3, 4, 5] + grumpy: [1, 1, 1, 1, 1] + minutes: 5 + out: 15 + - name: end_window_best + in: + customers: [1, 3, 5, 7, 9] + grumpy: [0, 1, 1, 1, 1] + minutes: 2 + out: 17 + - name: front_window_best + in: + customers: [9, 7, 5, 3, 1] + grumpy: [1, 1, 1, 1, 0] + minutes: 2 + out: 17 + - name: mixed_large_values + in: + customers: [100, 1, 100, 1, 100, 1] + grumpy: [0, 1, 1, 0, 1, 1] + minutes: 2 + out: 202 + - name: window_zero_grumpy + in: + customers: [2, 4, 6, 8] + grumpy: [0, 0, 0, 0] + minutes: 0 + out: 20 + - name: window_mid + in: + customers: [5, 4, 3, 2, 1] + grumpy: [1, 0, 1, 0, 1] + minutes: 2 + out: 11 + - name: alternating_dense + in: + customers: [1, 10, 1, 10, 1, 10, 1] + grumpy: [1, 0, 1, 0, 1, 0, 1] + minutes: 3 + out: 32 + - name: one_peak + in: + customers: [1, 1, 1, 100, 1, 1, 1] + grumpy: [1, 1, 1, 1, 1, 1, 1] + minutes: 2 + out: 101 + - name: two_peaks + in: + customers: [1, 50, 1, 50, 1] + grumpy: [1, 1, 1, 1, 1] + minutes: 2 + out: 51 + - name: longish + in: + customers: [3, 1, 4, 1, 5, 9, 2, 6] + grumpy: [0, 1, 0, 1, 0, 1, 0, 1] + minutes: 4 + out: 29 + - name: trailing_grumpy + in: + customers: [2, 2, 2, 2, 2, 2] + grumpy: [0, 0, 0, 1, 1, 1] + minutes: 3 + out: 12 + - name: leading_grumpy + in: + customers: [2, 2, 2, 2, 2, 2] + grumpy: [1, 1, 1, 0, 0, 0] + minutes: 3 + out: 12 + - name: mixed_case + in: + customers: [4, 1, 7, 1, 4, 1, 7, 1] + grumpy: [1, 0, 1, 0, 1, 0, 1, 0] + minutes: 2 + out: 11 diff --git a/tests/1001-1500/1052. grumpy-bookstore-owner/sol.cpp b/tests/1001-1500/1052. grumpy-bookstore-owner/sol.cpp new file mode 100644 index 00000000..81ed2800 --- /dev/null +++ b/tests/1001-1500/1052. grumpy-bookstore-owner/sol.cpp @@ -0,0 +1,32 @@ +class Solution { +public: + int maxSatisfied(vector& customers, vector& grumpy, int minutes) { + int n = customers.size(); + int total_satisfied = 0; + int current_window_gain = 0; + + for (int i = 0; i < n; ++i) { + if (!grumpy[i]) { + total_satisfied += customers[i]; + } else if (i < minutes) { + current_window_gain += customers[i]; + } + } + + int max_window_gain = current_window_gain; + + for (int i = minutes; i < n; ++i) { + if (grumpy[i]) { + current_window_gain += customers[i]; + } + if (grumpy[i - minutes]) { + current_window_gain -= customers[i - minutes]; + } + if (current_window_gain > max_window_gain) { + max_window_gain = current_window_gain; + } + } + + return total_satisfied + max_window_gain; + } +}; diff --git a/tests/1001-1500/1052. grumpy-bookstore-owner/sol.cs b/tests/1001-1500/1052. grumpy-bookstore-owner/sol.cs new file mode 100644 index 00000000..6d9a25f4 --- /dev/null +++ b/tests/1001-1500/1052. grumpy-bookstore-owner/sol.cs @@ -0,0 +1,31 @@ +public class Solution { + public int MaxSatisfied(int[] customers, int[] grumpy, int minutes) { + int n = customers.Length; + int totalSatisfied = 0; + int currentWindowGain = 0; + + for (int i = 0; i < n; i++) { + if (grumpy[i] == 0) { + totalSatisfied += customers[i]; + } else if (i < minutes) { + currentWindowGain += customers[i]; + } + } + + int maxWindowGain = currentWindowGain; + + for (int i = minutes; i < n; i++) { + if (grumpy[i] == 1) { + currentWindowGain += customers[i]; + } + if (grumpy[i - minutes] == 1) { + currentWindowGain -= customers[i - minutes]; + } + if (currentWindowGain > maxWindowGain) { + maxWindowGain = currentWindowGain; + } + } + + return totalSatisfied + maxWindowGain; + } +} diff --git a/tests/1001-1500/1052. grumpy-bookstore-owner/sol.dart b/tests/1001-1500/1052. grumpy-bookstore-owner/sol.dart new file mode 100644 index 00000000..864e967e --- /dev/null +++ b/tests/1001-1500/1052. grumpy-bookstore-owner/sol.dart @@ -0,0 +1,31 @@ +class Solution { + int maxSatisfied(List customers, List grumpy, int minutes) { + int n = customers.length; + int totalSatisfied = 0; + int currentWindowGain = 0; + + for (int i = 0; i < n; i++) { + if (grumpy[i] == 0) { + totalSatisfied += customers[i]; + } else if (i < minutes) { + currentWindowGain += customers[i]; + } + } + + int maxWindowGain = currentWindowGain; + + for (int i = minutes; i < n; i++) { + if (grumpy[i] == 1) { + currentWindowGain += customers[i]; + } + if (grumpy[i - minutes] == 1) { + currentWindowGain -= customers[i - minutes]; + } + if (currentWindowGain > maxWindowGain) { + maxWindowGain = currentWindowGain; + } + } + + return totalSatisfied + maxWindowGain; + } +} diff --git a/tests/1001-1500/1052. grumpy-bookstore-owner/sol.go b/tests/1001-1500/1052. grumpy-bookstore-owner/sol.go new file mode 100644 index 00000000..0376c8db --- /dev/null +++ b/tests/1001-1500/1052. grumpy-bookstore-owner/sol.go @@ -0,0 +1,29 @@ +func maxSatisfied(customers []int, grumpy []int, minutes int) int { + n := len(customers) + totalSatisfied := 0 + currentWindowGain := 0 + + for i := 0; i < n; i++ { + if grumpy[i] == 0 { + totalSatisfied += customers[i] + } else if i < minutes { + currentWindowGain += customers[i] + } + } + + maxWindowGain := currentWindowGain + + for i := minutes; i < n; i++ { + if grumpy[i] == 1 { + currentWindowGain += customers[i] + } + if grumpy[i - minutes] == 1 { + currentWindowGain -= customers[i - minutes] + } + if currentWindowGain > maxWindowGain { + maxWindowGain = currentWindowGain + } + } + + return totalSatisfied + maxWindowGain +} diff --git a/tests/1001-1500/1052. grumpy-bookstore-owner/sol.java b/tests/1001-1500/1052. grumpy-bookstore-owner/sol.java new file mode 100644 index 00000000..93e31386 --- /dev/null +++ b/tests/1001-1500/1052. grumpy-bookstore-owner/sol.java @@ -0,0 +1,31 @@ +class Solution { + public int maxSatisfied(int[] customers, int[] grumpy, int minutes) { + int n = customers.length; + int totalSatisfied = 0; + int currentWindowGain = 0; + + for (int i = 0; i < n; i++) { + if (grumpy[i] == 0) { + totalSatisfied += customers[i]; + } else if (i < minutes) { + currentWindowGain += customers[i]; + } + } + + int maxWindowGain = currentWindowGain; + + for (int i = minutes; i < n; i++) { + if (grumpy[i] == 1) { + currentWindowGain += customers[i]; + } + if (grumpy[i - minutes] == 1) { + currentWindowGain -= customers[i - minutes]; + } + if (currentWindowGain > maxWindowGain) { + maxWindowGain = currentWindowGain; + } + } + + return totalSatisfied + maxWindowGain; + } +} diff --git a/tests/1001-1500/1052. grumpy-bookstore-owner/sol.kt b/tests/1001-1500/1052. grumpy-bookstore-owner/sol.kt new file mode 100644 index 00000000..753700dd --- /dev/null +++ b/tests/1001-1500/1052. grumpy-bookstore-owner/sol.kt @@ -0,0 +1,31 @@ +class Solution { + fun maxSatisfied(customers: IntArray, grumpy: IntArray, minutes: Int): Int { + val n = customers.size + var totalSatisfied = 0 + var currentWindowGain = 0 + + for (i in 0 until n) { + if (grumpy[i] == 0) { + totalSatisfied += customers[i] + } else if (i < minutes) { + currentWindowGain += customers[i] + } + } + + var maxWindowGain = currentWindowGain + + for (i in minutes until n) { + if (grumpy[i] == 1) { + currentWindowGain += customers[i] + } + if (grumpy[i - minutes] == 1) { + currentWindowGain -= customers[i - minutes] + } + if (currentWindowGain > maxWindowGain) { + maxWindowGain = currentWindowGain + } + } + + return totalSatisfied + maxWindowGain + } +} diff --git a/tests/1001-1500/1052. grumpy-bookstore-owner/sol.py b/tests/1001-1500/1052. grumpy-bookstore-owner/sol.py new file mode 100644 index 00000000..4ad069b5 --- /dev/null +++ b/tests/1001-1500/1052. grumpy-bookstore-owner/sol.py @@ -0,0 +1,32 @@ +class Solution: + def maxSatisfied( + self, customers: List[int], grumpy: List[int], minutes: int + ) -> int: + n = len(customers) + + # 1. Steady-State Flux (Calculated in one pass) + # Total = Already satisfied + Potential gain from the first window + total_satisfied = 0 + current_window_gain = 0 + + for i in range(n): + if not grumpy[i]: + total_satisfied += customers[i] + elif i < minutes: + current_window_gain += customers[i] + + # 2. Sliding Window Integral + max_window_gain = current_window_gain + + for i in range(minutes, n): + # If the entering element is 'Grumpy', it's a gain + if grumpy[i]: + current_window_gain += customers[i] + # If the exiting element was 'Grumpy', we lose that gain + if grumpy[i - minutes]: + current_window_gain -= customers[i - minutes] + + if current_window_gain > max_window_gain: + max_window_gain = current_window_gain + + return total_satisfied + max_window_gain diff --git a/tests/1001-1500/1052. grumpy-bookstore-owner/sol.py2 b/tests/1001-1500/1052. grumpy-bookstore-owner/sol.py2 new file mode 100644 index 00000000..08dcf7f7 --- /dev/null +++ b/tests/1001-1500/1052. grumpy-bookstore-owner/sol.py2 @@ -0,0 +1,23 @@ +class Solution(object): + def maxSatisfied(self, customers, grumpy, minutes): + n = len(customers) + total_satisfied = 0 + current_window_gain = 0 + + for i in range(n): + if not grumpy[i]: + total_satisfied += customers[i] + elif i < minutes: + current_window_gain += customers[i] + + max_window_gain = current_window_gain + + for i in range(minutes, n): + if grumpy[i]: + current_window_gain += customers[i] + if grumpy[i - minutes]: + current_window_gain -= customers[i - minutes] + if current_window_gain > max_window_gain: + max_window_gain = current_window_gain + + return total_satisfied + max_window_gain diff --git a/tests/1001-1500/1052. grumpy-bookstore-owner/sol.rb b/tests/1001-1500/1052. grumpy-bookstore-owner/sol.rb new file mode 100644 index 00000000..733b583a --- /dev/null +++ b/tests/1001-1500/1052. grumpy-bookstore-owner/sol.rb @@ -0,0 +1,33 @@ +# @param {Integer[]} customers +# @param {Integer[]} grumpy +# @param {Integer} minutes +# @return {Integer} +def max_satisfied(customers, grumpy, minutes) + n = customers.length + total_satisfied = 0 + current_window_gain = 0 + + (0...n).each do |i| + if grumpy[i] == 0 + total_satisfied += customers[i] + elsif i < minutes + current_window_gain += customers[i] + end + end + + max_window_gain = current_window_gain + + (minutes...n).each do |i| + if grumpy[i] == 1 + current_window_gain += customers[i] + end + if grumpy[i - minutes] == 1 + current_window_gain -= customers[i - minutes] + end + if current_window_gain > max_window_gain + max_window_gain = current_window_gain + end + end + + total_satisfied + max_window_gain +end diff --git a/tests/1001-1500/1052. grumpy-bookstore-owner/sol.rs b/tests/1001-1500/1052. grumpy-bookstore-owner/sol.rs new file mode 100644 index 00000000..eb5ec91a --- /dev/null +++ b/tests/1001-1500/1052. grumpy-bookstore-owner/sol.rs @@ -0,0 +1,32 @@ +impl Solution { + pub fn max_satisfied(customers: Vec, grumpy: Vec, minutes: i32) -> i32 { + let n = customers.len(); + let minutes = minutes as usize; + let mut total_satisfied = 0; + let mut current_window_gain = 0; + + for i in 0..n { + if grumpy[i] == 0 { + total_satisfied += customers[i]; + } else if i < minutes { + current_window_gain += customers[i]; + } + } + + let mut max_window_gain = current_window_gain; + + for i in minutes..n { + if grumpy[i] == 1 { + current_window_gain += customers[i]; + } + if grumpy[i - minutes] == 1 { + current_window_gain -= customers[i - minutes]; + } + if current_window_gain > max_window_gain { + max_window_gain = current_window_gain; + } + } + + total_satisfied + max_window_gain + } +} diff --git a/tests/1001-1500/1052. grumpy-bookstore-owner/sol.swift b/tests/1001-1500/1052. grumpy-bookstore-owner/sol.swift new file mode 100644 index 00000000..469ee028 --- /dev/null +++ b/tests/1001-1500/1052. grumpy-bookstore-owner/sol.swift @@ -0,0 +1,31 @@ +class Solution { + func maxSatisfied(_ customers: [Int], _ grumpy: [Int], _ minutes: Int) -> Int { + let n = customers.count + var totalSatisfied = 0 + var currentWindowGain = 0 + + for i in 0.. maxWindowGain { + maxWindowGain = currentWindowGain + } + } + + return totalSatisfied + maxWindowGain + } +} diff --git a/tests/1001-1500/1052. grumpy-bookstore-owner/sol.ts b/tests/1001-1500/1052. grumpy-bookstore-owner/sol.ts new file mode 100644 index 00000000..0a973d48 --- /dev/null +++ b/tests/1001-1500/1052. grumpy-bookstore-owner/sol.ts @@ -0,0 +1,33 @@ +function maxSatisfied( + customers: number[], + grumpy: number[], + minutes: number, +): number { + const n = customers.length; + let totalSatisfied = 0; + let currentWindowGain = 0; + + for (let i = 0; i < n; i++) { + if (grumpy[i] === 0) { + totalSatisfied += customers[i]; + } else if (i < minutes) { + currentWindowGain += customers[i]; + } + } + + let maxWindowGain = currentWindowGain; + + for (let i = minutes; i < n; i++) { + if (grumpy[i] === 1) { + currentWindowGain += customers[i]; + } + if (grumpy[i - minutes] === 1) { + currentWindowGain -= customers[i - minutes]; + } + if (currentWindowGain > maxWindowGain) { + maxWindowGain = currentWindowGain; + } + } + + return totalSatisfied + maxWindowGain; +} diff --git a/tests/1001-1500/1053. previous-permutation-with-one-swap/manifest.yaml b/tests/1001-1500/1053. previous-permutation-with-one-swap/manifest.yaml new file mode 100644 index 00000000..b3444b72 --- /dev/null +++ b/tests/1001-1500/1053. previous-permutation-with-one-swap/manifest.yaml @@ -0,0 +1,186 @@ +entry: + id: 1053 + title: previous-permutation-with-one-swap + params: + arr: + type: array + items: + type: int + call: + cpp: "Solution().prevPermOpt1({arr})" + rust: "Solution::prev_perm_opt1({arr})" + python3: "Solution().prevPermOpt1({arr})" + python2: "Solution().prevPermOpt1({arr})" + ruby: "prev_perm_opt1({arr})" + java: "new Solution().prevPermOpt1({arr})" + csharp: "new Solution().PrevPermOpt1({arr})" + kotlin: "Solution().prevPermOpt1({arr})" + go: "prevPermOpt1({arr})" + dart: "Solution().prevPermOpt1({arr})" + swift: "Solution().prevPermOpt1({arr})" + typescript: "prevPermOpt1({arr})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().prevPermOpt1(arr, {result})" + checker: | + class Checker: + def prevPermOpt1(self, arr, result): + n = len(arr) + i = n - 2 + while i >= 0 and arr[i] <= arr[i + 1]: + i -= 1 + if i < 0: + return result == arr + j = n - 1 + while arr[j] >= arr[i] or (j > i + 1 and arr[j] == arr[j - 1]): + j -= 1 + expected = arr[:] + expected[i], expected[j] = expected[j], expected[i] + return result == expected +seed: 1053 +tests: + - name: ex1 + in: + arr: [3, 2, 1] + out: [3, 1, 2] + - name: ex2 + in: + arr: [1, 1, 5] + out: [1, 1, 5] + - name: ex3 + in: + arr: [1, 9, 4, 6, 7] + out: [1, 7, 4, 6, 9] + - name: already_min + in: + arr: [1, 2, 3] + out: [1, 2, 3] + - name: two_equal_tail + in: + arr: [1, 3, 1, 1, 3] + out: [1, 1, 3, 1, 3] + - name: swap_with_last + in: + arr: [5, 4, 3, 2, 1] + out: [5, 4, 3, 1, 2] + - name: swap_near_end + in: + arr: [1, 7, 4, 6, 9] + out: [1, 6, 4, 7, 9] + - name: duplicates_choose_rightmost_smaller + in: + arr: [2, 2, 0, 1] + out: [2, 1, 0, 2] + - name: long_descent + in: + arr: [9, 8, 7, 6, 5, 4] + out: [9, 8, 7, 6, 4, 5] + - name: no_change_with_plateau + in: + arr: [1, 1, 1, 1] + out: [1, 1, 1, 1] + - name: prefix_fixed + in: + arr: [1, 5, 1, 4, 3] + out: [1, 5, 1, 3, 4] + - name: small_swap + in: + arr: [3, 1, 1, 3] + out: [1, 3, 1, 3] + - name: swap_with_duplicate + in: + arr: [1, 4, 4, 3] + out: [1, 4, 3, 4] + - name: mixed1 + in: + arr: [2, 1, 1, 2, 2] + out: [1, 2, 1, 2, 2] + - name: mixed2 + in: + arr: [1, 3, 5, 4, 4, 2] + out: [1, 3, 5, 4, 2, 4] + - name: mixed3 + in: + arr: [2, 3, 1, 3, 3] + out: [2, 1, 3, 3, 3] + - name: mixed4 + in: + arr: [4, 2, 2, 3] + out: [3, 2, 2, 4] + - name: mixed5 + in: + arr: [1, 9, 8, 7, 6] + out: [1, 9, 8, 6, 7] + - name: mixed6 + in: + arr: [8, 7, 6, 6, 5] + out: [8, 7, 6, 5, 6] + - name: mixed7 + in: + arr: [2, 4, 1, 3] + out: [2, 3, 1, 4] + - name: mixed8 + in: + arr: [1, 5, 1, 5, 1] + out: [1, 5, 1, 1, 5] + - name: mixed9 + in: + arr: [6, 5, 4, 7, 3, 2] + out: [6, 5, 4, 7, 2, 3] + - name: mixed10 + in: + arr: [3, 2, 2, 1] + out: [3, 2, 1, 2] + - name: mixed11 + in: + arr: [1, 4, 2, 2, 3] + out: [1, 3, 2, 2, 4] + - name: mixed12 + in: + arr: [9, 1, 2, 3, 8] + out: [8, 1, 2, 3, 9] + - name: mixed13 + in: + arr: [2, 9, 7, 6, 6] + out: [2, 9, 6, 7, 6] + - name: mixed14 + in: + arr: [1, 2, 9, 8, 7, 7] + out: [1, 2, 9, 7, 8, 7] + - name: mixed15 + in: + arr: [5, 3, 3, 2, 2] + out: [5, 3, 2, 3, 2] + - name: mixed16 + in: + arr: [2, 2, 3, 1] + out: [2, 2, 1, 3] + - name: mixed17 + in: + arr: [10, 9, 8, 8, 9] + out: [10, 8, 9, 8, 9] + - name: mixed18 + in: + arr: [1, 7, 5, 5, 5] + out: [1, 5, 7, 5, 5] + - name: mixed19 + in: + arr: [4, 5, 3, 3, 2, 1] + out: [4, 5, 3, 3, 1, 2] + - name: mixed20 + in: + arr: [2, 3, 3, 1, 1] + out: [2, 3, 1, 3, 1] + - name: mixed21 + in: + arr: [7, 6, 5, 4, 4, 4] + out: [7, 6, 4, 5, 4, 4] + - name: mixed22 + in: + arr: [1, 2, 7, 4, 3, 2] + out: [1, 2, 7, 4, 2, 3] diff --git a/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.cpp b/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.cpp new file mode 100644 index 00000000..5b72a8d6 --- /dev/null +++ b/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.cpp @@ -0,0 +1,21 @@ +class Solution { +public: + vector prevPermOpt1(vector& arr) { + int n = arr.size(); + int i = n - 2; + while (i >= 0 && arr[i] <= arr[i + 1]) { + i--; + } + if (i < 0) { + return arr; + } + + int j = n - 1; + while (arr[j] >= arr[i] || (j > i + 1 && arr[j] == arr[j - 1])) { + j--; + } + + swap(arr[i], arr[j]); + return arr; + } +}; diff --git a/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.cs b/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.cs new file mode 100644 index 00000000..bcfdd140 --- /dev/null +++ b/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.cs @@ -0,0 +1,22 @@ +public class Solution { + public int[] PrevPermOpt1(int[] arr) { + int n = arr.Length; + int i = n - 2; + while (i >= 0 && arr[i] <= arr[i + 1]) { + i--; + } + if (i < 0) { + return arr; + } + + int j = n - 1; + while (arr[j] >= arr[i] || (j > i + 1 && arr[j] == arr[j - 1])) { + j--; + } + + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + return arr; + } +} diff --git a/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.dart b/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.dart new file mode 100644 index 00000000..eb98c3be --- /dev/null +++ b/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.dart @@ -0,0 +1,22 @@ +class Solution { + List prevPermOpt1(List arr) { + int n = arr.length; + int i = n - 2; + while (i >= 0 && arr[i] <= arr[i + 1]) { + i--; + } + if (i < 0) { + return arr; + } + + int j = n - 1; + while (arr[j] >= arr[i] || (j > i + 1 && arr[j] == arr[j - 1])) { + j--; + } + + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + return arr; + } +} diff --git a/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.go b/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.go new file mode 100644 index 00000000..4b9e21ec --- /dev/null +++ b/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.go @@ -0,0 +1,18 @@ +func prevPermOpt1(arr []int) []int { + n := len(arr) + i := n - 2 + for i >= 0 && arr[i] <= arr[i+1] { + i-- + } + if i < 0 { + return arr + } + + j := n - 1 + for arr[j] >= arr[i] || (j > i+1 && arr[j] == arr[j-1]) { + j-- + } + + arr[i], arr[j] = arr[j], arr[i] + return arr +} diff --git a/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.java b/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.java new file mode 100644 index 00000000..047e1097 --- /dev/null +++ b/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.java @@ -0,0 +1,22 @@ +class Solution { + public int[] prevPermOpt1(int[] arr) { + int n = arr.length; + int i = n - 2; + while (i >= 0 && arr[i] <= arr[i + 1]) { + i--; + } + if (i < 0) { + return arr; + } + + int j = n - 1; + while (arr[j] >= arr[i] || (j > i + 1 && arr[j] == arr[j - 1])) { + j--; + } + + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + return arr; + } +} diff --git a/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.kt b/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.kt new file mode 100644 index 00000000..2ae6c3ab --- /dev/null +++ b/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.kt @@ -0,0 +1,22 @@ +class Solution { + fun prevPermOpt1(arr: IntArray): IntArray { + val n = arr.size + var i = n - 2 + while (i >= 0 && arr[i] <= arr[i + 1]) { + i-- + } + if (i < 0) { + return arr + } + + var j = n - 1 + while (arr[j] >= arr[i] || (j > i + 1 && arr[j] == arr[j - 1])) { + j-- + } + + val temp = arr[i] + arr[i] = arr[j] + arr[j] = temp + return arr + } +} diff --git a/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.py b/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.py new file mode 100644 index 00000000..ec5b8da1 --- /dev/null +++ b/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.py @@ -0,0 +1,15 @@ +class Solution: + def prevPermOpt1(self, arr: List[int]) -> List[int]: + n = len(arr) + i = n - 2 + while i >= 0 and arr[i] <= arr[i + 1]: + i -= 1 + if i < 0: + return arr + + j = n - 1 + while arr[j] >= arr[i] or (j > i + 1 and arr[j] == arr[j - 1]): + j -= 1 + + arr[i], arr[j] = arr[j], arr[i] + return arr diff --git a/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.py2 b/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.py2 new file mode 100644 index 00000000..97eab0c4 --- /dev/null +++ b/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.py2 @@ -0,0 +1,19 @@ +class Solution(object): + def prevPermOpt1(self, arr): + """ + :type arr: List[int] + :rtype: List[int] + """ + n = len(arr) + i = n - 2 + while i >= 0 and arr[i] <= arr[i + 1]: + i -= 1 + if i < 0: + return arr + + j = n - 1 + while arr[j] >= arr[i] or (j > i + 1 and arr[j] == arr[j - 1]): + j -= 1 + + arr[i], arr[j] = arr[j], arr[i] + return arr diff --git a/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.rb b/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.rb new file mode 100644 index 00000000..1a8a180c --- /dev/null +++ b/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.rb @@ -0,0 +1,18 @@ +# @param {Integer[]} arr +# @return {Integer[]} +def prev_perm_opt1(arr) + n = arr.length + i = n - 2 + while i >= 0 && arr[i] <= arr[i + 1] + i -= 1 + end + return arr if i < 0 + + j = n - 1 + while arr[j] >= arr[i] || (j > i + 1 && arr[j] == arr[j - 1]) + j -= 1 + end + + arr[i], arr[j] = arr[j], arr[i] + arr +end diff --git a/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.rs b/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.rs new file mode 100644 index 00000000..ad6a375a --- /dev/null +++ b/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.rs @@ -0,0 +1,22 @@ +impl Solution { + pub fn prev_perm_opt1(arr: Vec) -> Vec { + let mut arr = arr; + let n = arr.len(); + let mut i = (n as i32) - 2; + while i >= 0 && arr[i as usize] <= arr[(i + 1) as usize] { + i -= 1; + } + if i < 0 { + return arr; + } + let i = i as usize; + + let mut j = n - 1; + while arr[j] >= arr[i] || (j > i + 1 && arr[j] == arr[j - 1]) { + j -= 1; + } + + arr.swap(i, j); + arr + } +} diff --git a/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.swift b/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.swift new file mode 100644 index 00000000..d0c15682 --- /dev/null +++ b/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.swift @@ -0,0 +1,21 @@ +class Solution { + func prevPermOpt1(_ arr: [Int]) -> [Int] { + var arr = arr + let n = arr.count + var i = n - 2 + while i >= 0 && arr[i] <= arr[i + 1] { + i -= 1 + } + if i < 0 { + return arr + } + + var j = n - 1 + while arr[j] >= arr[i] || (j > i + 1 && arr[j] == arr[j - 1]) { + j -= 1 + } + + arr.swapAt(i, j) + return arr + } +} diff --git a/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.ts b/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.ts new file mode 100644 index 00000000..eaa339c4 --- /dev/null +++ b/tests/1001-1500/1053. previous-permutation-with-one-swap/sol.ts @@ -0,0 +1,18 @@ +function prevPermOpt1(arr: number[]): number[] { + const n = arr.length; + let i = n - 2; + while (i >= 0 && arr[i] <= arr[i + 1]) { + i--; + } + if (i < 0) { + return arr; + } + + let j = n - 1; + while (arr[j] >= arr[i] || (j > i + 1 && arr[j] === arr[j - 1])) { + j--; + } + + [arr[i], arr[j]] = [arr[j], arr[i]]; + return arr; +} diff --git a/tests/1001-1500/1054. distant-barcodes/manifest.yaml b/tests/1001-1500/1054. distant-barcodes/manifest.yaml new file mode 100644 index 00000000..fbfe9eb0 --- /dev/null +++ b/tests/1001-1500/1054. distant-barcodes/manifest.yaml @@ -0,0 +1,194 @@ +entry: + id: 1054 + title: distant-barcodes + params: + barcodes: + type: array + items: + type: int + call: + cpp: "Solution().rearrangeBarcodes({barcodes})" + rust: "Solution::rearrange_barcodes({barcodes})" + python3: "Solution().rearrangeBarcodes({barcodes})" + python2: "Solution().rearrangeBarcodes({barcodes})" + ruby: "rearrange_barcodes({barcodes})" + java: "new Solution().rearrangeBarcodes({barcodes})" + csharp: "new Solution().RearrangeBarcodes({barcodes})" + kotlin: "Solution().rearrangeBarcodes({barcodes})" + go: "rearrangeBarcodes({barcodes})" + dart: "Solution().rearrangeBarcodes({barcodes})" + swift: "Solution().rearrangeBarcodes({barcodes})" + typescript: "rearrangeBarcodes({barcodes})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().rearrangeBarcodes(barcodes, {result})" + checker: | + from collections import Counter + + class Checker: + def rearrangeBarcodes(self, barcodes, result): + if not isinstance(result, list): + return False + if len(result) != len(barcodes): + return False + if Counter(result) != Counter(barcodes): + return False + for i in range(1, len(result)): + if result[i] == result[i - 1]: + return False + return True +seed: 1054 +tests: + - name: ex1 + in: + barcodes: [1, 1, 1, 2, 2, 2] + seed: 1 + - name: ex2 + in: + barcodes: [1, 1, 1, 1, 2, 2, 3, 3] + seed: 2 + - name: all_same_len1 + in: + barcodes: [5] + seed: 3 + - name: pair + in: + barcodes: [1, 2] + seed: 4 + - name: pair_dupes + in: + barcodes: [2, 2, 1] + seed: 5 + - name: small_balanced + in: + barcodes: [1, 1, 2, 2] + seed: 6 + - name: small_three + in: + barcodes: [1, 1, 1, 2, 2] + seed: 7 + - name: alternating_easy + in: + barcodes: [3, 3, 2, 2, 1, 1] + seed: 8 + - name: dominant_one + in: + barcodes: [7, 7, 7, 7, 8, 8, 9] + seed: 9 + - name: dominant_two + in: + barcodes: [4, 4, 4, 5, 5, 6] + seed: 10 + - name: even_length_mix + in: + barcodes: [1, 1, 1, 2, 2, 3] + seed: 11 + - name: odd_length_mix + in: + barcodes: [1, 1, 2, 2, 3] + seed: 12 + - name: many_unique + in: + barcodes: [1, 2, 3, 4, 5, 6, 7, 8] + seed: 13 + - name: many_dupes + in: + barcodes: [2, 2, 2, 3, 3, 4, 4, 4] + seed: 14 + - name: skewed_small + in: + barcodes: [10, 10, 10, 11, 12] + seed: 15 + - name: skewed_large + in: + barcodes: [1, 1, 1, 1, 1, 2, 2, 3, 3] + seed: 16 + - name: with_gaps + in: + barcodes: [5, 5, 6, 6, 6, 7, 7] + seed: 17 + - name: mixed1 + in: + barcodes: [9, 9, 9, 8, 8, 7, 7, 7, 6] + seed: 18 + - name: mixed2 + in: + barcodes: [1, 2, 2, 2, 3, 3, 4] + seed: 19 + - name: mixed3 + in: + barcodes: [6, 6, 5, 5, 5, 4, 4, 4, 4] + seed: 20 + - name: mixed4 + in: + barcodes: [11, 11, 11, 12, 12, 13, 13, 13] + seed: 21 + - name: mixed5 + in: + barcodes: [1, 1, 2, 2, 2, 3, 3, 3, 4, 4] + seed: 22 + - name: mixed6 + in: + barcodes: [7, 8, 8, 8, 9, 9, 9, 9] + seed: 23 + - name: mixed7 + in: + barcodes: [100, 100, 101, 101, 101, 102] + seed: 24 + - name: mixed8 + in: + barcodes: [2, 2, 2, 2, 3, 3, 4, 4, 5] + seed: 25 + - name: mixed9 + in: + barcodes: [1, 1, 1, 2, 2, 2, 3, 3, 4] + seed: 26 + - name: mixed10 + in: + barcodes: [6, 6, 6, 6, 7, 7, 8, 8, 9, 9] + seed: 27 + - name: mixed11 + in: + barcodes: [1, 1, 1, 1, 2, 3, 4, 5] + seed: 28 + - name: mixed12 + in: + barcodes: [3, 3, 3, 2, 2, 1, 1, 1, 4] + seed: 29 + - name: mixed13 + in: + barcodes: [5, 5, 5, 6, 6, 7, 7, 8, 8, 8] + seed: 30 + - name: mixed14 + in: + barcodes: [1, 1, 2, 2, 3, 3, 3, 4, 4, 4] + seed: 31 + - name: mixed15 + in: + barcodes: [9, 9, 9, 9, 10, 10, 11, 11, 11] + seed: 32 + - name: mixed16 + in: + barcodes: [1, 2, 2, 3, 3, 3, 4, 4, 4, 4] + seed: 33 + - name: mixed17 + in: + barcodes: [7, 7, 8, 8, 8, 9, 9, 10, 10] + seed: 34 + - name: mixed18 + in: + barcodes: [1, 1, 1, 2, 3, 3, 4, 4, 4] + seed: 35 + - name: mixed19 + in: + barcodes: [12, 12, 12, 13, 13, 14, 14, 14, 15] + seed: 36 + - name: mixed20 + in: + barcodes: [1, 1, 2, 3, 3, 3, 4, 4, 5, 5, 5] + seed: 37 diff --git a/tests/1001-1500/1054. distant-barcodes/sol.cpp b/tests/1001-1500/1054. distant-barcodes/sol.cpp new file mode 100644 index 00000000..bf50c427 --- /dev/null +++ b/tests/1001-1500/1054. distant-barcodes/sol.cpp @@ -0,0 +1,26 @@ +class Solution { +public: + vector rearrangeBarcodes(vector& barcodes) { + unordered_map h; + for (int i : barcodes) { + h[i]++; + } + priority_queue> heap; + for (auto& [k, v] : h) { + heap.push({v, k}); + } + vector l; + while (heap.size() > 1) { + auto x = heap.top(); heap.pop(); + auto y = heap.top(); heap.pop(); + l.push_back(x.second); + l.push_back(y.second); + if (--x.first > 0) heap.push(x); + if (--y.first > 0) heap.push(y); + } + if (!heap.empty()) { + l.push_back(heap.top().second); + } + return l; + } +}; diff --git a/tests/1001-1500/1054. distant-barcodes/sol.cs b/tests/1001-1500/1054. distant-barcodes/sol.cs new file mode 100644 index 00000000..f908b4ce --- /dev/null +++ b/tests/1001-1500/1054. distant-barcodes/sol.cs @@ -0,0 +1,33 @@ +public class Solution { + public int[] RearrangeBarcodes(int[] barcodes) { + Dictionary h = new Dictionary(); + foreach (int i in barcodes) { + if (h.ContainsKey(i)) h[i]++; + else h[i] = 1; + } + var heap = new List<(int cnt, int val)>(); + foreach (var kv in h) { + heap.Add((kv.Value, kv.Key)); + } + heap.Sort((a, b) => b.cnt.CompareTo(a.cnt)); + List l = new List(); + while (heap.Count > 1) { + var x = heap[0]; heap.RemoveAt(0); + var y = heap[0]; heap.RemoveAt(0); + l.Add(x.val); + l.Add(y.val); + if (--x.cnt > 0) { + heap.Add(x); + heap.Sort((a, b) => b.cnt.CompareTo(a.cnt)); + } + if (--y.cnt > 0) { + heap.Add(y); + heap.Sort((a, b) => b.cnt.CompareTo(a.cnt)); + } + } + if (heap.Count > 0) { + l.Add(heap[0].val); + } + return l.ToArray(); + } +} diff --git a/tests/1001-1500/1054. distant-barcodes/sol.dart b/tests/1001-1500/1054. distant-barcodes/sol.dart new file mode 100644 index 00000000..168b4709 --- /dev/null +++ b/tests/1001-1500/1054. distant-barcodes/sol.dart @@ -0,0 +1,35 @@ +class Solution { + List rearrangeBarcodes(List barcodes) { + Map h = {}; + for (int i in barcodes) { + h[i] = (h[i] ?? 0) + 1; + } + // using list as heap with manual sorting + List> heap = []; + for (var entry in h.entries) { + heap.add([-entry.value, entry.key]); + } + heap.sort((a, b) => a[0].compareTo(b[0])); + List l = []; + while (heap.length > 1) { + var x = heap.removeAt(0); + var y = heap.removeAt(0); + l.add(x[1]); + l.add(y[1]); + x[0]++; + y[0]++; + if (x[0] != 0) { + heap.add(x); + heap.sort((a, b) => a[0].compareTo(b[0])); + } + if (y[0] != 0) { + heap.add(y); + heap.sort((a, b) => a[0].compareTo(b[0])); + } + } + if (heap.isNotEmpty) { + l.add(heap[0][1]); + } + return l; + } +} diff --git a/tests/1001-1500/1054. distant-barcodes/sol.go b/tests/1001-1500/1054. distant-barcodes/sol.go new file mode 100644 index 00000000..ba9c0012 --- /dev/null +++ b/tests/1001-1500/1054. distant-barcodes/sol.go @@ -0,0 +1,37 @@ +func rearrangeBarcodes(barcodes []int) []int { + counts := make(map[int]int) + for _, v := range barcodes { + counts[v]++ + } + + type item struct { + val int + cnt int + } + items := make([]item, 0, len(counts)) + for v, c := range counts { + items = append(items, item{val: v, cnt: c}) + } + for i := 0; i < len(items); i++ { + best := i + for j := i + 1; j < len(items); j++ { + if items[j].cnt > items[best].cnt || (items[j].cnt == items[best].cnt && items[j].val < items[best].val) { + best = j + } + } + items[i], items[best] = items[best], items[i] + } + + res := make([]int, len(barcodes)) + idx := 0 + for _, it := range items { + for c := 0; c < it.cnt; c++ { + if idx >= len(res) { + idx = 1 + } + res[idx] = it.val + idx += 2 + } + } + return res +} diff --git a/tests/1001-1500/1054. distant-barcodes/sol.java b/tests/1001-1500/1054. distant-barcodes/sol.java new file mode 100644 index 00000000..42777cdf --- /dev/null +++ b/tests/1001-1500/1054. distant-barcodes/sol.java @@ -0,0 +1,35 @@ +class Solution { + public int[] rearrangeBarcodes(int[] barcodes) { + Map h = new HashMap<>(); + for (int i : barcodes) { + h.put(i, h.getOrDefault(i, 0) + 1); + } + PriorityQueue heap = new PriorityQueue<>((a, b) -> a[0] - b[0]); + for (Map.Entry entry : h.entrySet()) { + heap.offer(new int[]{-entry.getValue(), entry.getKey()}); + } + List l = new ArrayList<>(); + while (heap.size() > 1) { + int[] x = heap.poll(); + int[] y = heap.poll(); + l.add(x[1]); + l.add(y[1]); + x[0]++; + y[0]++; + if (x[0] != 0) { + heap.offer(x); + } + if (y[0] != 0) { + heap.offer(y); + } + } + if (!heap.isEmpty()) { + l.add(heap.poll()[1]); + } + int[] result = new int[l.size()]; + for (int i = 0; i < l.size(); i++) { + result[i] = l.get(i); + } + return result; + } +} diff --git a/tests/1001-1500/1054. distant-barcodes/sol.kt b/tests/1001-1500/1054. distant-barcodes/sol.kt new file mode 100644 index 00000000..31b53478 --- /dev/null +++ b/tests/1001-1500/1054. distant-barcodes/sol.kt @@ -0,0 +1,31 @@ +class Solution { + fun rearrangeBarcodes(barcodes: IntArray): IntArray { + val h = mutableMapOf() + for (i in barcodes) { + h[i] = h.getOrDefault(i, 0) + 1 + } + val heap = PriorityQueue(compareBy { it[0] }) + for ((k, v) in h) { + heap.offer(intArrayOf(-v, k)) + } + val l = mutableListOf() + while (heap.size > 1) { + val x = heap.poll() + val y = heap.poll() + l.add(x[1]) + l.add(y[1]) + x[0]++ + y[0]++ + if (x[0] != 0) { + heap.offer(x) + } + if (y[0] != 0) { + heap.offer(y) + } + } + if (heap.isNotEmpty()) { + l.add(heap.poll()[1]) + } + return l.toIntArray() + } +} diff --git a/tests/1001-1500/1054. distant-barcodes/sol.py b/tests/1001-1500/1054. distant-barcodes/sol.py new file mode 100644 index 00000000..dbadd2e8 --- /dev/null +++ b/tests/1001-1500/1054. distant-barcodes/sol.py @@ -0,0 +1,32 @@ +class Solution(object): + def rearrangeBarcodes(self, barcodes): + h = {} + for i in barcodes: + if str(i) not in h: + h[str(i)] = 0 + h[str(i)] += 1 + heap = [] + l = [] + for i, j in h.items(): + heapq.heappush(heap, [-j, i]) + while len(heap) > 1: + x = heapq.heappop(heap) + y = heapq.heappop(heap) + + l.append(int(x[1])) + l.append(int(y[1])) + x[0] = x[0] + 1 + y[0] = y[0] + 1 + if x[0] == 0: + pass + else: + heapq.heappush(heap, x) + if y[0] == 0: + pass + else: + heapq.heappush(heap, y) + if len(heap) == 0: + pass + else: + l.append(int(heap[0][1])) + return l diff --git a/tests/1001-1500/1054. distant-barcodes/sol.py2 b/tests/1001-1500/1054. distant-barcodes/sol.py2 new file mode 100644 index 00000000..d230b06b --- /dev/null +++ b/tests/1001-1500/1054. distant-barcodes/sol.py2 @@ -0,0 +1,32 @@ +class Solution(object): + def rearrangeBarcodes(self, barcodes): + h={} + for i in barcodes: + if str(i) not in h: + h[str(i)]=0 + h[str(i)]+=1 + heap=[] + l=[] + for i,j in h.items(): + heapq.heappush(heap,[-j,i]) + while len(heap)>1: + x=heapq.heappop(heap) + y=heapq.heappop(heap) + + l.append(int(x[1])) + l.append(int(y[1])) + x[0]=x[0]+1 + y[0]=y[0]+1 + if x[0]==0: + pass + else: + heapq.heappush(heap,x) + if y[0]==0: + pass + else: + heapq.heappush(heap,y) + if len(heap)==0: + pass + else: + l.append(int(heap[0][1])) + return l diff --git a/tests/1001-1500/1054. distant-barcodes/sol.rb b/tests/1001-1500/1054. distant-barcodes/sol.rb new file mode 100644 index 00000000..3e3359ad --- /dev/null +++ b/tests/1001-1500/1054. distant-barcodes/sol.rb @@ -0,0 +1,28 @@ +# @param {Integer[]} barcodes +# @return {Integer[]} +def rearrange_barcodes(barcodes) + h = Hash.new(0) + barcodes.each { |i| h[i] += 1 } + heap = [] + l = [] + h.each { |k, v| heap.push([-v, k]) } + heap.sort_by! { |a| a[0] } + while heap.length > 1 + x = heap.shift + y = heap.shift + l.push(x[1]) + l.push(y[1]) + x[0] += 1 + y[0] += 1 + unless x[0] == 0 + heap.push(x) + heap.sort_by! { |a| a[0] } + end + unless y[0] == 0 + heap.push(y) + heap.sort_by! { |a| a[0] } + end + end + l.push(heap[0][1]) unless heap.empty? + l +end diff --git a/tests/1001-1500/1054. distant-barcodes/sol.rs b/tests/1001-1500/1054. distant-barcodes/sol.rs new file mode 100644 index 00000000..bbce5002 --- /dev/null +++ b/tests/1001-1500/1054. distant-barcodes/sol.rs @@ -0,0 +1,26 @@ +impl Solution { + pub fn rearrange_barcodes(barcodes: Vec) -> Vec { + use std::collections::HashMap; + + let mut counts = HashMap::new(); + for &v in &barcodes { + *counts.entry(v).or_insert(0usize) += 1; + } + + let mut items: Vec<(i32, usize)> = counts.into_iter().collect(); + items.sort_by(|a, b| b.1.cmp(&a.1).then_with(|| a.0.cmp(&b.0))); + + let mut res = vec![0; barcodes.len()]; + let mut idx = 0usize; + for (val, cnt) in items { + for _ in 0..cnt { + if idx >= res.len() { + idx = 1; + } + res[idx] = val; + idx += 2; + } + } + res + } +} diff --git a/tests/1001-1500/1054. distant-barcodes/sol.swift b/tests/1001-1500/1054. distant-barcodes/sol.swift new file mode 100644 index 00000000..51614c32 --- /dev/null +++ b/tests/1001-1500/1054. distant-barcodes/sol.swift @@ -0,0 +1,34 @@ +class Solution { + func rearrangeBarcodes(_ barcodes: [Int]) -> [Int] { + var h = [Int: Int]() + for i in barcodes { + h[i, default: 0] += 1 + } + var heap = [[Int]]() + for (k, v) in h { + heap.append([-v, k]) + } + heap.sort { $0[0] < $1[0] } + var l = [Int]() + while heap.count > 1 { + var x = heap.removeFirst() + var y = heap.removeFirst() + l.append(x[1]) + l.append(y[1]) + x[0] += 1 + y[0] += 1 + if x[0] != 0 { + heap.append(x) + heap.sort { $0[0] < $1[0] } + } + if y[0] != 0 { + heap.append(y) + heap.sort { $0[0] < $1[0] } + } + } + if !heap.isEmpty { + l.append(heap[0][1]) + } + return l + } +} diff --git a/tests/1001-1500/1054. distant-barcodes/sol.ts b/tests/1001-1500/1054. distant-barcodes/sol.ts new file mode 100644 index 00000000..12dd6303 --- /dev/null +++ b/tests/1001-1500/1054. distant-barcodes/sol.ts @@ -0,0 +1,32 @@ +function rearrangeBarcodes(barcodes: number[]): number[] { + const h: Map = new Map(); + for (const i of barcodes) { + h.set(i, (h.get(i) || 0) + 1); + } + const heap: [number, number][] = []; + for (const [k, v] of h) { + heap.push([-v, k]); + } + heap.sort((a, b) => a[0] - b[0]); + const l: number[] = []; + while (heap.length > 1) { + const x = heap.shift()!; + const y = heap.shift()!; + l.push(x[1]); + l.push(y[1]); + x[0]++; + y[0]++; + if (x[0] !== 0) { + heap.push(x); + heap.sort((a, b) => a[0] - b[0]); + } + if (y[0] !== 0) { + heap.push(y); + heap.sort((a, b) => a[0] - b[0]); + } + } + if (heap.length > 0) { + l.push(heap[0][1]); + } + return l; +} diff --git a/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/manifest.yaml b/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/manifest.yaml new file mode 100644 index 00000000..60b8e745 --- /dev/null +++ b/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/manifest.yaml @@ -0,0 +1,246 @@ +entry: + id: 1061 + title: lexicographically-smallest-equivalent-string + params: + s1: + type: string + s2: + type: string + baseStr: + type: string + call: + cpp: Solution().smallestEquivalentString({s1}, {s2}, {baseStr}) + rust: Solution::smallest_equivalent_string({s1}, {s2}, {baseStr}) + python3: Solution().smallestEquivalentString({s1}, {s2}, {baseStr}) + python2: Solution().smallestEquivalentString({s1}, {s2}, {baseStr}) + ruby: smallest_equivalent_string({s1}, {s2}, {baseStr}) + java: new Solution().smallestEquivalentString({s1}, {s2}, {baseStr}) + csharp: new Solution().SmallestEquivalentString({s1}, {s2}, {baseStr}) + kotlin: Solution().smallestEquivalentString({s1}, {s2}, {baseStr}) + go: smallestEquivalentString({s1}, {s2}, {baseStr}) + dart: Solution().smallestEquivalentString({s1}, {s2}, {baseStr}) + swift: Solution().smallestEquivalentString({s1}, {s2}, {baseStr}) + typescript: smallestEquivalentString({s1}, {s2}, {baseStr}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().smallestEquivalentString(s1, s2, baseStr, {result}) + checker: + "class Checker:\n def smallestEquivalentString(self, s1, s2, baseStr,\ + \ result):\n return isinstance(result, str) and len(result) == len(baseStr)\n" +seed: 1061 +tests: + - name: ex1 + in: + s1: parker + s2: morris + baseStr: parser + out: makkek + - name: ex2 + in: + s1: hello + s2: world + baseStr: hold + out: hdld + - name: ex3 + in: + s1: leetcode + s2: programs + baseStr: sourcecode + out: aauaaaaada + - name: identical + in: + s1: abc + s2: abc + baseStr: abcabc + out: abcabc + - name: full_chain + in: + s1: abcdef + s2: bcdefg + baseStr: gfedcba + out: aaaaaaa + - name: disjoint_pairs + in: + s1: azby + s2: bycx + baseStr: xyzabc + out: xxxaaa + - name: wraparound + in: + s1: az + s2: by + baseStr: zayb + out: yaya + - name: repeated_base + in: + s1: abc + s2: bcd + baseStr: ddddcccbbaaa + out: aaaaaaaaaaaa + - name: single_pair + in: + s1: a + s2: b + baseStr: abba + out: aaaa + - name: no_links + in: + s1: qwerty + s2: asdfgh + baseStr: zxcvbn + out: zxcvbn + - name: long_chain_small_base + in: + s1: abcdefghijklmnopqrst + s2: bcdefghijklmnopqrstu + baseStr: tsrqponmlkjihgfedcba + out: aaaaaaaaaaaaaaaaaaaa + - name: mixed_components + in: + s1: abcxyz + s2: bcdxya + baseStr: zyxabc + out: ayxaaa + - name: case13 + in: + s1: pqrst + s2: qrstu + baseStr: tspqr + out: ppppp + - name: case14 + in: + s1: mnopq + s2: nopqr + baseStr: rmnop + out: mmmmm + - name: case15 + in: + s1: uvwxy + s2: vwxyz + baseStr: zyxwv + out: uuuuu + - name: case16 + in: + s1: abcde + s2: fghij + baseStr: afbgchdiej + out: aabbccddee + - name: case17 + in: + s1: azaz + s2: zbzb + baseStr: zaza + out: aaaa + - name: case18 + in: + s1: lmno + s2: opqr + baseStr: qrstlmno + out: nlstlmnl + - name: case19 + in: + s1: abcabc + s2: bcdbcd + baseStr: dcba + out: aaaa + - name: case20 + in: + s1: hijk + s2: ijkl + baseStr: lkjih + out: hhhhh + - name: case21 + in: + s1: azbycxdwev + s2: bycxdwevfz + baseStr: zyxwvutsrq + out: vvvvvutsrq + - name: case22 + in: + s1: mnmn + s2: nono + baseStr: onom + out: mmmm + - name: case23 + in: + s1: rstuvw + s2: stuvwx + baseStr: xwvutsr + out: rrrrrrr + - name: case24 + in: + s1: abcd + s2: wxyz + baseStr: azbycxdw + out: adbccbda + - name: case25 + in: + s1: qazwsx + s2: wsxedc + baseStr: cxswaq + out: ccaeae + - name: case26 + in: + s1: lkjhgf + s2: asdfgh + baseStr: lkhgfd + out: akfgfd + - name: case27 + in: + s1: aaabbb + s2: bbbaaa + baseStr: ababab + out: aaaaaa + - name: case28 + in: + s1: acacac + s2: bdbdbd + baseStr: cabdab + out: caacaa + - name: case29 + in: + s1: abcdefgh + s2: hgfedcba + baseStr: hgfedcba + out: abcddcba + - name: case30 + in: + s1: klmnopqrst + s2: mnopqrstuv + baseStr: uvwxyzklmn + out: klwxyzklkl + - name: case31 + in: + s1: abcdeabcde + s2: bcdefbcdef + baseStr: edcbaedcba + out: aaaaaaaaaa + - name: case32 + in: + s1: mnopmnop + s2: nopqnopq + baseStr: ponmponm + out: mmmmmmmm + - name: case33 + in: + s1: uvwxyz + s2: vwxyza + baseStr: azbycx + out: aabaca + - name: case34 + in: + s1: azbycxdwevfugthsirjqkplomn + s2: bycxdwevfugthsirjqkplomnaz + baseStr: mnopqrstuvwxyzabcdefghij + out: annnnnnnnnnnnnaaaaaaaaaa + - name: case35 + in: + s1: abcdefghijklm + s2: bcdefghijklmn + baseStr: nmlkjihgfedcba + out: aaaaaaaaaaaaaa diff --git a/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.cpp b/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.cpp new file mode 100644 index 00000000..79ac5d0e --- /dev/null +++ b/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.cpp @@ -0,0 +1,29 @@ +class Solution { +public: + string smallestEquivalentString(string s1, string s2, string baseStr) { + unordered_map> adj; + for (int i = 0; i < s1.size(); i++) { + adj[s1[i]].push_back(s2[i]); + adj[s2[i]].push_back(s1[i]); + } + + function&)> dfs = [&](char ch, unordered_set& visited) -> char { + visited.insert(ch); + char minCh = ch; + for (char nei : adj[ch]) { + if (!visited.count(nei)) { + char candidate = dfs(nei, visited); + minCh = min(minCh, candidate); + } + } + return minCh; + }; + + string result; + for (char ch : baseStr) { + unordered_set visited; + result += dfs(ch, visited); + } + return result; + } +}; diff --git a/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.cs b/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.cs new file mode 100644 index 00000000..dec798f1 --- /dev/null +++ b/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.cs @@ -0,0 +1,33 @@ +public class Solution { + public string SmallestEquivalentString(string s1, string s2, string baseStr) { + Dictionary> adj = new Dictionary>(); + for (int i = 0; i < s1.Length; i++) { + char a = s1[i], b = s2[i]; + if (!adj.ContainsKey(a)) adj[a] = new List(); + if (!adj.ContainsKey(b)) adj[b] = new List(); + adj[a].Add(b); + adj[b].Add(a); + } + + char DFS(char ch, HashSet visited) { + visited.Add(ch); + char minCh = ch; + if (adj.ContainsKey(ch)) { + foreach (char nei in adj[ch]) { + if (!visited.Contains(nei)) { + char candidate = DFS(nei, visited); + if (candidate < minCh) minCh = candidate; + } + } + } + return minCh; + } + + char[] result = new char[baseStr.Length]; + for (int i = 0; i < baseStr.Length; i++) { + HashSet visited = new HashSet(); + result[i] = DFS(baseStr[i], visited); + } + return new string(result); + } +} diff --git a/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.dart b/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.dart new file mode 100644 index 00000000..19a74a55 --- /dev/null +++ b/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.dart @@ -0,0 +1,32 @@ +class Solution { + String smallestEquivalentString(String s1, String s2, String baseStr) { + Map> adj = {}; + for (int i = 0; i < s1.length; i++) { + String a = s1[i]; + String b = s2[i]; + adj.putIfAbsent(a, () => []).add(b); + adj.putIfAbsent(b, () => []).add(a); + } + + String dfs(String ch, Set visited) { + visited.add(ch); + String minCh = ch; + for (String nei in adj[ch] ?? []) { + if (!visited.contains(nei)) { + String candidate = dfs(nei, visited); + if (candidate.compareTo(minCh) < 0) { + minCh = candidate; + } + } + } + return minCh; + } + + StringBuffer result = StringBuffer(); + for (int i = 0; i < baseStr.length; i++) { + Set visited = {}; + result.write(dfs(baseStr[i], visited)); + } + return result.toString(); + } +} diff --git a/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.go b/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.go new file mode 100644 index 00000000..054af5d3 --- /dev/null +++ b/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.go @@ -0,0 +1,30 @@ +func smallestEquivalentString(s1 string, s2 string, baseStr string) string { + adj := make(map[byte][]byte) + for i := 0; i < len(s1); i++ { + a, b := s1[i], s2[i] + adj[a] = append(adj[a], b) + adj[b] = append(adj[b], a) + } + + var dfs func(ch byte, visited map[byte]bool) byte + dfs = func(ch byte, visited map[byte]bool) byte { + visited[ch] = true + minCh := ch + for _, nei := range adj[ch] { + if !visited[nei] { + candidate := dfs(nei, visited) + if candidate < minCh { + minCh = candidate + } + } + } + return minCh + } + + result := make([]byte, len(baseStr)) + for i := 0; i < len(baseStr); i++ { + visited := make(map[byte]bool) + result[i] = dfs(baseStr[i], visited) + } + return string(result) +} diff --git a/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.java b/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.java new file mode 100644 index 00000000..4e43d9b0 --- /dev/null +++ b/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.java @@ -0,0 +1,30 @@ +class Solution { + public String smallestEquivalentString(String s1, String s2, String baseStr) { + Map> adj = new HashMap<>(); + for (int i = 0; i < s1.length(); i++) { + char a = s1.charAt(i); + char b = s2.charAt(i); + adj.computeIfAbsent(a, k -> new ArrayList<>()).add(b); + adj.computeIfAbsent(b, k -> new ArrayList<>()).add(a); + } + + StringBuilder result = new StringBuilder(); + for (char ch : baseStr.toCharArray()) { + Set visited = new HashSet<>(); + result.append(dfs(ch, visited, adj)); + } + return result.toString(); + } + + private char dfs(char ch, Set visited, Map> adj) { + visited.add(ch); + char minCh = ch; + for (char nei : adj.getOrDefault(ch, new ArrayList<>())) { + if (!visited.contains(nei)) { + char candidate = dfs(nei, visited, adj); + if (candidate < minCh) minCh = candidate; + } + } + return minCh; + } +} diff --git a/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.kt b/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.kt new file mode 100644 index 00000000..51f48e6d --- /dev/null +++ b/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.kt @@ -0,0 +1,30 @@ +class Solution { + fun smallestEquivalentString(s1: String, s2: String, baseStr: String): String { + val adj = mutableMapOf>() + for (i in s1.indices) { + val a = s1[i] + val b = s2[i] + adj.getOrPut(a) { mutableListOf() }.add(b) + adj.getOrPut(b) { mutableListOf() }.add(a) + } + + fun dfs(ch: Char, visited: MutableSet): Char { + visited.add(ch) + var minCh = ch + for (nei in adj[ch] ?: emptyList()) { + if (nei !in visited) { + val candidate = dfs(nei, visited) + if (candidate < minCh) minCh = candidate + } + } + return minCh + } + + val result = StringBuilder() + for (ch in baseStr) { + val visited = mutableSetOf() + result.append(dfs(ch, visited)) + } + return result.toString() + } +} diff --git a/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.py b/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.py new file mode 100644 index 00000000..2230c97f --- /dev/null +++ b/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.py @@ -0,0 +1,33 @@ +from collections import defaultdict + + +class Solution(object): + def smallestEquivalentString(self, s1, s2, baseStr): + """ + :type s1: str + :type s2: str + :type baseStr: str + :rtype: str + """ + adj = defaultdict(list) + + # Step 1: Build the graph + for a, b in zip(s1, s2): + adj[a].append(b) + adj[b].append(a) + + def dfs(ch, visited): + visited.add(ch) + min_ch = ch + for nei in adj[ch]: + if nei not in visited: + candidate = dfs(nei, visited) + min_ch = min(min_ch, candidate) + return min_ch + + result = [] + for ch in baseStr: + visited = set() + result.append(dfs(ch, visited)) + + return "".join(result) diff --git a/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.py2 b/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.py2 new file mode 100644 index 00000000..6a8917ab --- /dev/null +++ b/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.py2 @@ -0,0 +1,27 @@ +class Solution(object): + def smallestEquivalentString(self, s1, s2, baseStr): + """ + :type s1: str + :type s2: str + :type baseStr: str + :rtype: str + """ + adj = defaultdict(list) + for a, b in zip(s1, s2): + adj[a].append(b) + adj[b].append(a) + + def dfs(ch, visited): + visited.add(ch) + min_ch = ch + for nei in adj[ch]: + if nei not in visited: + candidate = dfs(nei, visited) + min_ch = min(min_ch, candidate) + return min_ch + + result = [] + for ch in baseStr: + visited = set() + result.append(dfs(ch, visited)) + return ''.join(result) diff --git a/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.rb b/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.rb new file mode 100644 index 00000000..48d42370 --- /dev/null +++ b/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.rb @@ -0,0 +1,30 @@ +# @param {String} s1 +# @param {String} s2 +# @param {String} base_str +# @return {String} +def smallest_equivalent_string(s1, s2, base_str) + adj = Hash.new { |h, k| h[k] = [] } + s1.chars.zip(s2.chars).each do |a, b| + adj[a] << b + adj[b] << a + end + + dfs = lambda do |ch, visited| + visited.add(ch) + min_ch = ch + adj[ch].each do |nei| + unless visited.include?(nei) + candidate = dfs.call(nei, visited) + min_ch = [min_ch, candidate].min + end + end + min_ch + end + + result = [] + base_str.each_char do |ch| + visited = Set.new + result << dfs.call(ch, visited) + end + result.join +end diff --git a/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.rs b/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.rs new file mode 100644 index 00000000..b41f6c23 --- /dev/null +++ b/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.rs @@ -0,0 +1,34 @@ +impl Solution { + pub fn smallest_equivalent_string(s1: String, s2: String, base_str: String) -> String { + use std::collections::{HashMap, HashSet}; + + let mut adj: HashMap> = HashMap::new(); + for (a, b) in s1.chars().zip(s2.chars()) { + adj.entry(a).or_default().push(b); + adj.entry(b).or_default().push(a); + } + + fn dfs(ch: char, visited: &mut HashSet, adj: &HashMap>) -> char { + visited.insert(ch); + let mut min_ch = ch; + if let Some(neighbors) = adj.get(&ch) { + for &nei in neighbors { + if !visited.contains(&nei) { + let candidate = dfs(nei, visited, adj); + if candidate < min_ch { + min_ch = candidate; + } + } + } + } + min_ch + } + + let mut result = String::new(); + for ch in base_str.chars() { + let mut visited = HashSet::new(); + result.push(dfs(ch, &mut visited, &adj)); + } + result + } +} diff --git a/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.swift b/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.swift new file mode 100644 index 00000000..cc962e57 --- /dev/null +++ b/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.swift @@ -0,0 +1,30 @@ +class Solution { + func smallestEquivalentString(_ s1: String, _ s2: String, _ baseStr: String) -> String { + var adj = [Character: [Character]]() + for (a, b) in zip(s1, s2) { + adj[a, default: []].append(b) + adj[b, default: []].append(a) + } + + func dfs(_ ch: Character, _ visited: inout Set) -> Character { + visited.insert(ch) + var minCh = ch + for nei in adj[ch] ?? [] { + if !visited.contains(nei) { + let candidate = dfs(nei, &visited) + if candidate < minCh { + minCh = candidate + } + } + } + return minCh + } + + var result = "" + for ch in baseStr { + var visited = Set() + result.append(dfs(ch, &visited)) + } + return result + } +} diff --git a/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.ts b/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.ts new file mode 100644 index 00000000..6261cfd1 --- /dev/null +++ b/tests/1001-1500/1061. lexicographically-smallest-equivalent-string/sol.ts @@ -0,0 +1,34 @@ +function smallestEquivalentString( + s1: string, + s2: string, + baseStr: string, +): string { + const adj: Map = new Map(); + for (let i = 0; i < s1.length; i++) { + const a = s1[i]; + const b = s2[i]; + if (!adj.has(a)) adj.set(a, []); + if (!adj.has(b)) adj.set(b, []); + adj.get(a)!.push(b); + adj.get(b)!.push(a); + } + + function dfs(ch: string, visited: Set): string { + visited.add(ch); + let minCh = ch; + for (const nei of adj.get(ch) || []) { + if (!visited.has(nei)) { + const candidate = dfs(nei, visited); + if (candidate < minCh) minCh = candidate; + } + } + return minCh; + } + + let result = ""; + for (const ch of baseStr) { + const visited = new Set(); + result += dfs(ch, visited); + } + return result; +} diff --git a/tests/1001-1500/1071. greatest-common-divisor-of-strings/manifest.yaml b/tests/1001-1500/1071. greatest-common-divisor-of-strings/manifest.yaml new file mode 100644 index 00000000..16e2009e --- /dev/null +++ b/tests/1001-1500/1071. greatest-common-divisor-of-strings/manifest.yaml @@ -0,0 +1,209 @@ +entry: + id: 1071 + title: greatest-common-divisor-of-strings + params: + str1: + type: string + str2: + type: string + call: + cpp: Solution().gcdOfStrings({str1}, {str2}) + rust: Solution::gcd_of_strings({str1}, {str2}) + python3: Solution().gcdOfStrings({str1}, {str2}) + python2: Solution().gcdOfStrings({str1}, {str2}) + ruby: gcd_of_strings({str1}, {str2}) + java: new Solution().gcdOfStrings({str1}, {str2}) + csharp: new Solution().GcdOfStrings({str1}, {str2}) + kotlin: Solution().gcdOfStrings({str1}, {str2}) + go: gcdOfStrings({str1}, {str2}) + dart: Solution().gcdOfStrings({str1}, {str2}) + swift: Solution().gcdOfStrings({str1}, {str2}) + typescript: gcdOfStrings({str1}, {str2}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().gcdOfStrings(str1, str2, {result}) + checker: + "class Checker:\n def gcdOfStrings(self, str1, str2, result):\n \ + \ return isinstance(result, str) and len(result) <= min(len(str1), len(str2))\n" +seed: 1071 +tests: + - name: ex1 + in: + str1: ABCABC + str2: ABC + out: ABC + - name: ex2 + in: + str1: ABABAB + str2: ABAB + out: AB + - name: ex3 + in: + str1: LEET + str2: CODE + out: "" + - name: same_strings + in: + str1: AAAA + str2: AAAA + out: AAAA + - name: one_is_prefix + in: + str1: XYZXYZXYZ + str2: XYZXYZ + out: XYZ + - name: coprime_lengths_match + in: + str1: ababab + str2: abab + out: ab + - name: mismatch_same_length + in: + str1: ABCD + str2: ABCE + out: "" + - name: repeated_single_char + in: + str1: BBBBBBBB + str2: BBBB + out: BBBB + - name: no_common_base + in: + str1: ABCDEF + str2: ABC + out: "" + - name: long_common_base + in: + str1: abcabcabcabcabcabc + str2: abcabcabc + out: abcabcabc + - name: short_same + in: + str1: A + str2: A + out: A + - name: short_diff + in: + str1: A + str2: B + out: "" + - name: partial_repeat + in: + str1: zzzzzz + str2: zz + out: zz + - name: unequal_but_compatible + in: + str1: abababab + str2: abab + out: abab + - name: incompatible_repeat + in: + str1: ababab + str2: aba + out: "" + - name: large_same_pattern + in: + str1: abcabcabcabc + str2: abcabc + out: abcabc + - name: shifted_incompatible + in: + str1: ABCABCABC + str2: ABCABD + out: "" + - name: all_x + in: + str1: XXXXXXXXXX + str2: XXXXX + out: XXXXX + - name: all_y + in: + str1: YYYYYYYY + str2: YY + out: YY + - name: mixed_case_like + in: + str1: abababababab + str2: ababab + out: ababab + - name: prime_lengths_incompatible + in: + str1: aaaaa + str2: aaaab + out: "" + - name: edge_len_two + in: + str1: CC + str2: C + out: C + - name: edge_len_three + in: + str1: DDD + str2: DD + out: D + - name: alternating_compatible + in: + str1: ababababab + str2: abababab + out: ab + - name: alternating_incompatible + in: + str1: ababababab + str2: ababababa + out: "" + - name: common_three + in: + str1: kikikiki + str2: kiki + out: kiki + - name: common_four + in: + str1: mnopmnop + str2: mnop + out: mnop + - name: common_five + in: + str1: qqqqqqqqq + str2: qqq + out: qqq + - name: incompatible_symbols + in: + str1: XYZXYZ + str2: XYZZYX + out: "" + - name: long_repeat_a + in: + str1: aaaaaaaaaaaa + str2: aaaaaa + out: aaaaaa + - name: long_repeat_b + in: + str1: bbbbbbbbbbbbbbbb + str2: bbbbbbbb + out: bbbbbbbb + - name: long_repeat_c + in: + str1: cccccccccc + str2: ccccc + out: ccccc + - name: long_repeat_d + in: + str1: dddddddddddddd + str2: dddddd + out: dd + - name: long_repeat_e + in: + str1: eeeeeeee + str2: eeee + out: eeee + - name: long_repeat_f + in: + str1: ffffff + str2: fff + out: fff diff --git a/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.cpp b/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.cpp new file mode 100644 index 00000000..4683a94f --- /dev/null +++ b/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.cpp @@ -0,0 +1,20 @@ +class Solution { +public: + string gcdOfStrings(string str1, string str2) { + if (str1 + str2 != str2 + str1) { + return ""; + } + + auto gcd = [](int len1, int len2) { + int minVal = min(len1, len2); + for (int i = minVal; i >= 1; i--) { + if (len1 % i == 0 && len2 % i == 0) { + return i; + } + } + return 1; + }; + + return str1.substr(0, gcd(str1.length(), str2.length())); + } +}; diff --git a/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.cs b/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.cs new file mode 100644 index 00000000..59f035ee --- /dev/null +++ b/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.cs @@ -0,0 +1,19 @@ +public class Solution { + public string GcdOfStrings(string str1, string str2) { + if (str1 + str2 != str2 + str1) { + return ""; + } + + int Gcd(int len1, int len2) { + int minVal = Math.Min(len1, len2); + for (int i = minVal; i >= 1; i--) { + if (len1 % i == 0 && len2 % i == 0) { + return i; + } + } + return 1; + } + + return str1.Substring(0, Gcd(str1.Length, str2.Length)); + } +} diff --git a/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.dart b/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.dart new file mode 100644 index 00000000..014879f0 --- /dev/null +++ b/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.dart @@ -0,0 +1,19 @@ +class Solution { + String gcdOfStrings(String str1, String str2) { + if (str1 + str2 != str2 + str1) { + return ""; + } + + int gcd(int len1, int len2) { + int minVal = len1 < len2 ? len1 : len2; + for (int i = minVal; i >= 1; i--) { + if (len1 % i == 0 && len2 % i == 0) { + return i; + } + } + return 1; + } + + return str1.substring(0, gcd(str1.length, str2.length)); + } +} diff --git a/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.go b/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.go new file mode 100644 index 00000000..6249cbb1 --- /dev/null +++ b/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.go @@ -0,0 +1,17 @@ +func gcdOfStrings(str1 string, str2 string) string { + if str1 + str2 != str2 + str1 { + return "" + } + + gcd := func(len1, len2 int) int { + minVal := min(len1, len2) + for i := minVal; i >= 1; i-- { + if len1 % i == 0 && len2 % i == 0 { + return i + } + } + return 1 + } + + return str1[:gcd(len(str1), len(str2))] +} diff --git a/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.java b/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.java new file mode 100644 index 00000000..d7678b22 --- /dev/null +++ b/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.java @@ -0,0 +1,20 @@ +class Solution { + public String gcdOfStrings(String str1, String str2) { + if (!(str1 + str2).equals(str2 + str1)) { + return ""; + } + + int gcdLen = gcd(str1.length(), str2.length()); + return str1.substring(0, gcdLen); + } + + private int gcd(int len1, int len2) { + int minVal = Math.min(len1, len2); + for (int i = minVal; i >= 1; i--) { + if (len1 % i == 0 && len2 % i == 0) { + return i; + } + } + return 1; + } +} diff --git a/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.kt b/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.kt new file mode 100644 index 00000000..e0056329 --- /dev/null +++ b/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.kt @@ -0,0 +1,19 @@ +class Solution { + fun gcdOfStrings(str1: String, str2: String): String { + if (str1 + str2 != str2 + str1) { + return "" + } + + fun gcd(len1: Int, len2: Int): Int { + val minVal = minOf(len1, len2) + for (i in minVal downTo 1) { + if (len1 % i == 0 && len2 % i == 0) { + return i + } + } + return 1 + } + + return str1.substring(0, gcd(str1.length, str2.length)) + } +} diff --git a/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.py b/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.py new file mode 100644 index 00000000..44cec718 --- /dev/null +++ b/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.py @@ -0,0 +1,14 @@ +class Solution: + def gcdOfStrings(self, str1: str, str2: str) -> str: + + if str1 + str2 != str2 + str1: + return "" + + def gcd(len1, len2): + min_val = min(len1, len2) + for i in range(min_val, 0, -1): + if len1 % i == 0 and len2 % i == 0: + return i + return 1 + + return str1[: gcd(len(str1), len(str2))] diff --git a/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.py2 b/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.py2 new file mode 100644 index 00000000..579c01d8 --- /dev/null +++ b/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.py2 @@ -0,0 +1,18 @@ +class Solution(object): + def gcdOfStrings(self, str1, str2): + """ + :type str1: str + :type str2: str + :rtype: str + """ + if str1 + str2 != str2 + str1: + return "" + + def gcd(len1, len2): + min_val = min(len1, len2) + for i in range(min_val, 0, -1): + if len1 % i == 0 and len2 % i == 0: + return i + return 1 + + return str1[:gcd(len(str1), len(str2))] diff --git a/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.rb b/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.rb new file mode 100644 index 00000000..3d4e2545 --- /dev/null +++ b/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.rb @@ -0,0 +1,16 @@ +# @param {String} str1 +# @param {String} str2 +# @return {String} +def gcd_of_strings(str1, str2) + return "" if str1 + str2 != str2 + str1 + + def gcd(len1, len2) + min_val = [len1, len2].min + min_val.downto(1) do |i| + return i if len1 % i == 0 && len2 % i == 0 + end + 1 + end + + str1[0, gcd(str1.length, str2.length)] +end diff --git a/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.rs b/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.rs new file mode 100644 index 00000000..27f32700 --- /dev/null +++ b/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.rs @@ -0,0 +1,19 @@ +impl Solution { + pub fn gcd_of_strings(str1: String, str2: String) -> String { + if str1.clone() + &str2 != str2.clone() + &str1 { + return "".to_string(); + } + + fn gcd(len1: usize, len2: usize) -> usize { + let min_val = std::cmp::min(len1, len2); + for i in (1..=min_val).rev() { + if len1 % i == 0 && len2 % i == 0 { + return i; + } + } + 1 + } + + str1[..gcd(str1.len(), str2.len())].to_string() + } +} diff --git a/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.swift b/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.swift new file mode 100644 index 00000000..22a6f0db --- /dev/null +++ b/tests/1001-1500/1071. greatest-common-divisor-of-strings/sol.swift @@ -0,0 +1,20 @@ +class Solution { + func gcdOfStrings(_ str1: String, _ str2: String) -> String { + if str1 + str2 != str2 + str1 { + return "" + } + + func gcd(_ len1: Int, _ len2: Int) -> Int { + let minVal = min(len1, len2) + for i in stride(from: minVal, through: 1, by: -1) { + if len1 % i == 0 && len2 % i == 0 { + return i + } + } + return 1 + } + + let idx = str1.index(str1.startIndex, offsetBy: gcd(str1.count, str2.count)) + return String(str1[..= 1; i--) { + if (len1 % i === 0 && len2 % i === 0) { + return i; + } + } + return 1; + } + + return str1.substring(0, gcd(str1.length, str2.length)); +} diff --git a/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/manifest.yaml b/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/manifest.yaml new file mode 100644 index 00000000..5ea617fd --- /dev/null +++ b/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/manifest.yaml @@ -0,0 +1,382 @@ +entry: + id: 1072 + title: flip-columns-for-maximum-number-of-equal-rows + params: + matrix: + type: array + items: + type: array + items: + type: int + call: + cpp: "Solution().maxEqualRowsAfterFlips({matrix})" + rust: "Solution::max_equal_rows_after_flips({matrix})" + python3: "Solution().maxEqualRowsAfterFlips({matrix})" + python2: "Solution().maxEqualRowsAfterFlips({matrix})" + ruby: "max_equal_rows_after_flips({matrix})" + java: "new Solution().maxEqualRowsAfterFlips({matrix})" + csharp: "new Solution().MaxEqualRowsAfterFlips({matrix})" + kotlin: "Solution().maxEqualRowsAfterFlips({matrix})" + go: "maxEqualRowsAfterFlips({matrix})" + dart: "Solution().maxEqualRowsAfterFlips({matrix})" + swift: "Solution().maxEqualRowsAfterFlips({matrix})" + typescript: "maxEqualRowsAfterFlips({matrix})" +judge: + type: "exact" +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().maxEqualRowsAfterFlips(matrix, {result})" + checker: | + class Checker: + def maxEqualRowsAfterFlips(self, matrix, result): + return isinstance(result, int) and 0 <= result <= len(matrix) +seed: 1072 +tests: + - name: ex1 + in: + matrix: + elemType: "int" + value: + - [0, 1] + - [1, 1] + out: 1 + - name: ex2 + in: + matrix: + elemType: "int" + value: + - [0, 1] + - [1, 0] + out: 2 + - name: all_zero + in: + matrix: + elemType: "int" + value: + - [0, 0, 0] + - [0, 0, 0] + - [0, 0, 0] + out: 3 + - name: all_one + in: + matrix: + elemType: "int" + value: + - [1, 1, 1] + - [1, 1, 1] + out: 2 + - name: single_row + in: + matrix: + elemType: "int" + value: + - [1, 0, 1, 0, 1] + out: 1 + - name: single_col + in: + matrix: + elemType: "int" + value: + - [0] + - [1] + - [0] + - [1] + out: 4 + - name: pair_mirror + in: + matrix: + elemType: "int" + value: + - [1, 0, 1] + - [0, 1, 0] + - [1, 0, 1] + out: 3 + - name: triple_group + in: + matrix: + elemType: "int" + value: + - [0, 1, 0, 1] + - [1, 0, 1, 0] + - [0, 1, 0, 1] + - [1, 0, 1, 0] + out: 4 + - name: mixed_small + in: + matrix: + elemType: "int" + value: + - [0, 1, 1] + - [1, 0, 0] + - [1, 1, 0] + out: 2 + - name: mixed_small2 + in: + matrix: + elemType: "int" + value: + - [0, 0, 1] + - [1, 1, 0] + - [0, 0, 1] + - [1, 1, 0] + out: 4 + - name: random_a + in: + matrix: + elemType: "int" + value: + - [0, 1, 0, 0] + - [1, 0, 1, 1] + - [0, 1, 0, 0] + - [1, 0, 1, 1] + out: 4 + - name: random_b + in: + matrix: + elemType: "int" + value: + - [0, 1, 1, 0] + - [1, 0, 0, 1] + - [0, 1, 1, 0] + out: 3 + - name: random_c + in: + matrix: + elemType: "int" + value: + - [1, 0, 0, 1, 1] + - [0, 1, 1, 0, 0] + - [1, 0, 0, 1, 1] + - [0, 1, 1, 0, 0] + - [1, 0, 0, 1, 1] + out: 5 + - name: random_d + in: + matrix: + elemType: "int" + value: + - [1, 1, 0, 0] + - [0, 0, 1, 1] + - [1, 1, 0, 0] + - [0, 0, 1, 1] + - [1, 1, 0, 0] + out: 5 + - name: random_e + in: + matrix: + elemType: "int" + value: + - [1, 0] + - [1, 0] + - [0, 1] + - [0, 1] + - [1, 0] + out: 5 + - name: random_f + in: + matrix: + elemType: "int" + value: + - [0, 0] + - [1, 1] + - [1, 1] + - [0, 0] + out: 4 + - name: alternating_rows + in: + matrix: + elemType: "int" + value: + - [0, 1, 0, 1, 0, 1] + - [1, 0, 1, 0, 1, 0] + - [0, 1, 0, 1, 0, 1] + out: 3 + - name: four_by_four + in: + matrix: + elemType: "int" + value: + - [0, 1, 0, 1] + - [0, 1, 0, 1] + - [1, 0, 1, 0] + - [1, 0, 1, 0] + out: 4 + - name: square_mixed + in: + matrix: + elemType: "int" + value: + - [1, 1, 1] + - [0, 0, 0] + - [1, 1, 1] + - [0, 0, 0] + out: 4 + - name: col_patterns + in: + matrix: + elemType: "int" + value: + - [0, 1, 0] + - [0, 1, 0] + - [1, 0, 1] + - [1, 0, 1] + out: 4 + - name: pair_rows + in: + matrix: + elemType: "int" + value: + - [1, 0, 1, 1] + - [0, 1, 0, 0] + out: 2 + - name: many_equal + in: + matrix: + elemType: "int" + value: + - [1, 0, 0] + - [0, 1, 1] + - [1, 0, 0] + - [0, 1, 1] + - [1, 0, 0] + - [0, 1, 1] + out: 6 + - name: mixed_6x6 + in: + matrix: + elemType: "int" + value: + - [1, 0, 1, 0, 1, 0] + - [0, 1, 0, 1, 0, 1] + - [1, 0, 1, 0, 1, 0] + - [0, 1, 0, 1, 0, 1] + - [1, 0, 1, 0, 1, 0] + - [0, 1, 0, 1, 0, 1] + out: 6 + - name: asym_small + in: + matrix: + elemType: "int" + value: + - [0, 1, 1, 0, 0] + - [1, 0, 0, 1, 1] + - [0, 1, 1, 0, 0] + - [1, 0, 0, 1, 1] + out: 4 + - name: four_rows_two_groups + in: + matrix: + elemType: "int" + value: + - [1, 1, 0] + - [0, 0, 1] + - [1, 1, 0] + - [0, 0, 1] + out: 4 + - name: eight_rows + in: + matrix: + elemType: "int" + value: + - [0, 1, 0] + - [1, 0, 1] + - [0, 1, 0] + - [1, 0, 1] + - [0, 1, 0] + - [1, 0, 1] + - [0, 1, 0] + - [1, 0, 1] + out: 8 + - name: edge_rect + in: + matrix: + elemType: "int" + value: + - [1, 0, 0, 1] + - [0, 1, 1, 0] + - [1, 0, 0, 1] + out: 3 + - name: edge_rect2 + in: + matrix: + elemType: "int" + value: + - [1, 1, 0, 0, 1] + - [0, 0, 1, 1, 0] + - [1, 1, 0, 0, 1] + out: 3 + - name: edge_rect3 + in: + matrix: + elemType: "int" + value: + - [0, 0, 1, 1, 0] + - [1, 1, 0, 0, 1] + - [0, 0, 1, 1, 0] + - [1, 1, 0, 0, 1] + out: 4 + - name: edge_rect4 + in: + matrix: + elemType: "int" + value: + - [0, 1] + - [1, 0] + - [0, 1] + - [1, 0] + - [0, 1] + out: 5 + - name: edge_rect5 + in: + matrix: + elemType: "int" + value: + - [1, 1, 1, 0] + - [0, 0, 0, 1] + - [1, 1, 1, 0] + - [0, 0, 0, 1] + - [1, 1, 1, 0] + out: 5 + - name: edge_rect6 + in: + matrix: + elemType: "int" + value: + - [1] + - [0] + - [1] + - [0] + - [1] + - [0] + - [1] + out: 7 + - name: edge_rect7 + in: + matrix: + elemType: "int" + value: + - [0, 0, 0, 0] + - [1, 1, 1, 1] + out: 2 + - name: edge_rect8 + in: + matrix: + elemType: "int" + value: + - [0, 1, 1] + - [1, 0, 0] + - [0, 1, 1] + - [1, 0, 0] + - [0, 1, 1] + out: 5 + - name: edge_rect9 + in: + matrix: + elemType: "int" + value: + - [1, 0, 1, 0, 1] + - [0, 1, 0, 1, 0] + out: 2 diff --git a/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.cpp b/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.cpp new file mode 100644 index 00000000..f689f6d0 --- /dev/null +++ b/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.cpp @@ -0,0 +1,18 @@ +class Solution { +public: + int maxEqualRowsAfterFlips(vector>& matrix) { + unordered_map count; + int ans = 0; + + for (const auto& row : matrix) { + int flip = row[0]; + string key; + for (int x : row) { + key += to_string(x ^ flip) + ','; + } + ans = max(ans, ++count[key]); + } + + return ans; + } +}; diff --git a/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.cs b/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.cs new file mode 100644 index 00000000..381b33bf --- /dev/null +++ b/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.cs @@ -0,0 +1,21 @@ +public class Solution { + public int MaxEqualRowsAfterFlips(int[][] matrix) { + var count = new System.Collections.Generic.Dictionary(); + int ans = 0; + + foreach (var row in matrix) { + int flip = row[0]; + var sb = new System.Text.StringBuilder(); + foreach (int x in row) { + sb.Append(x ^ flip); + sb.Append(','); + } + string key = sb.ToString(); + if (!count.ContainsKey(key)) count[key] = 0; + count[key]++; + if (count[key] > ans) ans = count[key]; + } + + return ans; + } +} diff --git a/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.dart b/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.dart new file mode 100644 index 00000000..658adf4a --- /dev/null +++ b/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.dart @@ -0,0 +1,15 @@ +class Solution { + int maxEqualRowsAfterFlips(List> matrix) { + final count = {}; + int ans = 0; + + for (final row in matrix) { + final flip = row[0]; + final key = row.map((x) => (x ^ flip).toString()).join(','); + count[key] = (count[key] ?? 0) + 1; + if (count[key]! > ans) ans = count[key]!; + } + + return ans; + } +} diff --git a/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.go b/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.go new file mode 100644 index 00000000..c9887cfe --- /dev/null +++ b/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.go @@ -0,0 +1,23 @@ +func maxEqualRowsAfterFlips(matrix [][]int) int { + count := make(map[string]int) + ans := 0 + + for _, row := range matrix { + flip := row[0] + bytes := make([]byte, 0, len(row)*2) + for _, x := range row { + if x^flip == 0 { + bytes = append(bytes, '0', ',') + } else { + bytes = append(bytes, '1', ',') + } + } + key := string(bytes) + count[key]++ + if count[key] > ans { + ans = count[key] + } + } + + return ans +} diff --git a/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.java b/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.java new file mode 100644 index 00000000..aaa9f6e5 --- /dev/null +++ b/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.java @@ -0,0 +1,21 @@ +class Solution { + public int maxEqualRowsAfterFlips(int[][] matrix) { + java.util.Map count = new java.util.HashMap<>(); + int ans = 0; + + for (int[] row : matrix) { + int flip = row[0]; + StringBuilder sb = new StringBuilder(); + for (int x : row) { + sb.append(x ^ flip); + sb.append(','); + } + String key = sb.toString(); + int val = count.getOrDefault(key, 0) + 1; + count.put(key, val); + if (val > ans) ans = val; + } + + return ans; + } +} diff --git a/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.kt b/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.kt new file mode 100644 index 00000000..eed57e80 --- /dev/null +++ b/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.kt @@ -0,0 +1,16 @@ +class Solution { + fun maxEqualRowsAfterFlips(matrix: Array): Int { + val count = mutableMapOf() + var ans = 0 + + for (row in matrix) { + val flip = row[0] + val key = row.joinToString(",") { (it xor flip).toString() } + val valCount = count.getOrDefault(key, 0) + 1 + count[key] = valCount + if (valCount > ans) ans = valCount + } + + return ans + } +} diff --git a/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.py b/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.py new file mode 100644 index 00000000..23994250 --- /dev/null +++ b/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.py @@ -0,0 +1,14 @@ +class Solution: + def maxEqualRowsAfterFlips(self, matrix): + from collections import defaultdict + + count = defaultdict(int) + ans = 0 + + for row in matrix: + flip = row[0] + key = tuple(x ^ flip for x in row) + count[key] += 1 + ans = max(ans, count[key]) + + return ans diff --git a/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.py2 b/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.py2 new file mode 100644 index 00000000..4b00941f --- /dev/null +++ b/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.py2 @@ -0,0 +1,18 @@ +class Solution(object): + def maxEqualRowsAfterFlips(self, matrix): + """ + :type matrix: List[List[int]] + :rtype: int + """ + from collections import defaultdict + count = defaultdict(int) + ans = 0 + + for row in matrix: + flip = row[0] + key = tuple(x ^ flip for x in row) + count[key] += 1 + if count[key] > ans: + ans = count[key] + + return ans diff --git a/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.rb b/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.rb new file mode 100644 index 00000000..615fff05 --- /dev/null +++ b/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.rb @@ -0,0 +1,15 @@ +# @param {Integer[][]} matrix +# @return {Integer} +def max_equal_rows_after_flips(matrix) + count = Hash.new(0) + ans = 0 + + matrix.each do |row| + flip = row[0] + key = row.map { |x| x ^ flip } + count[key] += 1 + ans = count[key] if count[key] > ans + end + + ans +end diff --git a/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.rs b/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.rs new file mode 100644 index 00000000..9bb97f31 --- /dev/null +++ b/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.rs @@ -0,0 +1,20 @@ +impl Solution { + pub fn max_equal_rows_after_flips(matrix: Vec>) -> i32 { + use std::collections::HashMap; + let mut count = HashMap::new(); + let mut ans = 0; + + for row in &matrix { + let flip = row[0]; + let key: Vec = row.iter().map(|&x| (x ^ flip).to_string()).collect(); + let key = key.join(","); + let val = count.entry(key).or_insert(0); + *val += 1; + if *val > ans { + ans = *val; + } + } + + ans + } +} diff --git a/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.swift b/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.swift new file mode 100644 index 00000000..4e1b2b4f --- /dev/null +++ b/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.swift @@ -0,0 +1,17 @@ +class Solution { + func maxEqualRowsAfterFlips(_ matrix: [[Int]]) -> Int { + var count = [String: Int]() + var ans = 0 + + for row in matrix { + let flip = row[0] + let key = row.map { String($0 ^ flip) }.joined(separator: ",") + count[key, default: 0] += 1 + if count[key]! > ans { + ans = count[key]! + } + } + + return ans + } +} diff --git a/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.ts b/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.ts new file mode 100644 index 00000000..129cc638 --- /dev/null +++ b/tests/1001-1500/1072. flip-columns-for-maximum-number-of-equal-rows/sol.ts @@ -0,0 +1,14 @@ +function maxEqualRowsAfterFlips(matrix: number[][]): number { + const count: Map = new Map(); + let ans = 0; + + for (const row of matrix) { + const flip = row[0]; + const key = row.map((x) => (x ^ flip).toString()).join(","); + const val = (count.get(key) ?? 0) + 1; + count.set(key, val); + if (val > ans) ans = val; + } + + return ans; +} diff --git a/tests/1001-1500/1073. adding-two-negabinary-numbers/manifest.yaml b/tests/1001-1500/1073. adding-two-negabinary-numbers/manifest.yaml new file mode 100644 index 00000000..bf91561f --- /dev/null +++ b/tests/1001-1500/1073. adding-two-negabinary-numbers/manifest.yaml @@ -0,0 +1,475 @@ +entry: + id: 1073 + title: adding-two-negabinary-numbers + params: + arr1: + type: array + items: + type: int + arr2: + type: array + items: + type: int + call: + cpp: Solution().addNegabinary({arr1}, {arr2}) + rust: Solution::add_negabinary({arr1}, {arr2}) + python3: Solution().addNegabinary({arr1}, {arr2}) + python2: Solution().addNegabinary({arr1}, {arr2}) + ruby: add_negabinary({arr1}, {arr2}) + java: new Solution().addNegabinary({arr1}, {arr2}) + csharp: new Solution().AddNegabinary({arr1}, {arr2}) + kotlin: Solution().addNegabinary({arr1}, {arr2}) + go: addNegabinary({arr1}, {arr2}) + dart: Solution().addNegabinary({arr1}, {arr2}) + swift: Solution().addNegabinary({arr1}, {arr2}) + typescript: addNegabinary({arr1}, {arr2}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().addNegabinary(arr1, arr2, {result}) + checker: + "class Checker:\n def addNegabinary(self, arr1, arr2, result):\n \ + \ if not isinstance(result, list) or not result:\n return False\n\ + \ if result[0] == 0 and len(result) > 1:\n return False\n\ + \ if any(x not in (0, 1) for x in result):\n return False\n\ + \ a = list(arr1)\n b = list(arr2)\n carry = 0\n \ + \ expected = []\n while carry or a or b:\n if a:\n \ + \ carry += a.pop()\n if b:\n carry += b.pop()\n\ + \ expected.append(carry & 1)\n carry = -(carry >> 1)\n\ + \ while len(expected) > 1 and expected[-1] == 0:\n expected.pop()\n\ + \ return result == expected[::-1]\n" +seed: 1073 +tests: + - name: ex1 + in: + arr1: + - 1 + - 1 + - 1 + - 1 + - 1 + arr2: + - 1 + - 0 + - 1 + - name: ex2 + in: + arr1: + - 0 + arr2: + - 0 + - name: ex3 + in: + arr1: + - 0 + arr2: + - 1 + - name: zero_zero + in: + arr1: + - 0 + arr2: + - 0 + - name: zero_one + in: + arr1: + - 0 + arr2: + - 1 + - name: one_one + in: + arr1: + - 1 + arr2: + - 1 + - name: one_zero + in: + arr1: + - 1 + arr2: + - 0 + - name: two_two + in: + arr1: + - 1 + - 1 + arr2: + - 1 + - 1 + - name: cancel_like + in: + arr1: + - 1 + - 0 + - 0 + - 0 + arr2: + - 1 + - 1 + - 0 + - 0 + - name: same_101 + in: + arr1: + - 1 + - 0 + - 1 + arr2: + - 1 + - 0 + - 1 + - name: mixed_1 + in: + arr1: + - 1 + - 1 + - 0 + - 1 + arr2: + - 1 + - 0 + - 1 + - name: alt_5 + in: + arr1: + - 1 + - 0 + - 1 + - 0 + - 1 + arr2: + - 1 + - 0 + - 1 + - 0 + - 1 + - name: diff_len_1 + in: + arr1: + - 1 + - 0 + - 0 + - 1 + arr2: + - 1 + - 1 + - name: pow_term + in: + arr1: + - 1 + - 0 + - 0 + - 0 + - 0 + arr2: + - 1 + - name: long_short + in: + arr1: + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + arr2: + - 1 + - name: short_long + in: + arr1: + - 1 + arr2: + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - name: triple_ones + in: + arr1: + - 1 + - 1 + - 1 + arr2: + - 1 + - 1 + - 1 + - name: carry_new_bit + in: + arr1: + - 1 + - 0 + - 0 + - 1 + - 1 + arr2: + - 1 + - 0 + - 0 + - 1 + - 1 + - name: zeros_prefix + in: + arr1: + - 1 + - 0 + - 0 + - 0 + - 1 + arr2: + - 1 + - 0 + - 0 + - 0 + - 1 + - name: one_vs_power + in: + arr1: + - 1 + arr2: + - 1 + - 0 + - 0 + - 0 + - 0 + - name: power_vs_one + in: + arr1: + - 1 + - 0 + - 0 + - 0 + - 0 + arr2: + - 1 + - name: all_ones_16_a + in: + arr1: + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + arr2: + - 1 + - name: all_ones_16_b + in: + arr1: + - 1 + arr2: + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - name: pattern_1 + in: + arr1: + - 1 + - 1 + - 0 + - 1 + - 0 + - 1 + - 1 + - 0 + - 1 + arr2: + - 1 + - 0 + - 1 + - 1 + - 0 + - 1 + - 0 + - 1 + - name: pattern_2 + in: + arr1: + - 1 + - 0 + - 1 + - 1 + - 1 + - 0 + - 1 + - 0 + arr2: + - 1 + - 1 + - 0 + - 1 + - 1 + - 1 + - 0 + - 1 + - name: stagger_1 + in: + arr1: + - 1 + - 0 + - 1 + - 0 + - 0 + - 1 + arr2: + - 1 + - 1 + - 0 + - 0 + - 1 + - name: stagger_2 + in: + arr1: + - 1 + - 1 + - 0 + - 0 + - 1 + - 0 + - 1 + arr2: + - 1 + - 0 + - 1 + - 0 + - 1 + - 1 + - name: mixed_len_1 + in: + arr1: + - 1 + - 0 + - 1 + - 1 + - 0 + arr2: + - 1 + - 1 + - 1 + - name: mixed_len_2 + in: + arr1: + - 1 + - 1 + - 1 + - 0 + arr2: + - 1 + - 0 + - 1 + - 1 + - 1 + - name: mixed_len_3 + in: + arr1: + - 1 + - 0 + - 0 + - 1 + - 1 + - 1 + arr2: + - 1 + - 1 + - 0 + - 1 + - name: sparse_1 + in: + arr1: + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + arr2: + - 1 + - 0 + - 1 + - name: sparse_2 + in: + arr1: + - 1 + - 0 + - 0 + - 1 + - 0 + - 0 + - 1 + arr2: + - 1 + - 1 + - name: single_carry + in: + arr1: + - 1 + arr2: + - 1 + - 1 + - name: alternating_8 + in: + arr1: + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + arr2: + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - name: odd_even_mix + in: + arr1: + - 1 + - 1 + - 0 + - 1 + - 1 + - 0 + - 0 + - 1 + arr2: + - 1 + - 0 + - 1 + - 1 + - 0 + - 1 diff --git a/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.cpp b/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.cpp new file mode 100644 index 00000000..ae700be4 --- /dev/null +++ b/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.cpp @@ -0,0 +1,22 @@ +class Solution { +public: + vector addNegabinary(vector& arr1, vector& arr2) { + vector res; + int i = arr1.size() - 1, j = arr2.size() - 1; + int carry = 0; + + while (carry != 0 || i >= 0 || j >= 0) { + if (i >= 0) carry += arr1[i--]; + if (j >= 0) carry += arr2[j--]; + res.push_back(carry & 1); + carry = -(carry >> 1); + } + + while (res.size() > 1 && res.back() == 0) { + res.pop_back(); + } + + reverse(res.begin(), res.end()); + return res; + } +}; diff --git a/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.cs b/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.cs new file mode 100644 index 00000000..e1bfc85b --- /dev/null +++ b/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.cs @@ -0,0 +1,21 @@ +public class Solution { + public int[] AddNegabinary(int[] arr1, int[] arr2) { + var res = new List(); + int i = arr1.Length - 1, j = arr2.Length - 1; + int carry = 0; + + while (carry != 0 || i >= 0 || j >= 0) { + if (i >= 0) carry += arr1[i--]; + if (j >= 0) carry += arr2[j--]; + res.Add(carry & 1); + carry = -(carry >> 1); + } + + while (res.Count > 1 && res[res.Count - 1] == 0) { + res.RemoveAt(res.Count - 1); + } + + res.Reverse(); + return res.ToArray(); + } +} diff --git a/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.dart b/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.dart new file mode 100644 index 00000000..386b70e0 --- /dev/null +++ b/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.dart @@ -0,0 +1,20 @@ +class Solution { + List addNegabinary(List arr1, List arr2) { + List res = []; + int i = arr1.length - 1, j = arr2.length - 1; + int carry = 0; + + while (carry != 0 || i >= 0 || j >= 0) { + if (i >= 0) carry += arr1[i--]; + if (j >= 0) carry += arr2[j--]; + res.add(carry & 1); + carry = -(carry >> 1); + } + + while (res.length > 1 && res.last == 0) { + res.removeLast(); + } + + return res.reversed.toList(); + } +} diff --git a/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.go b/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.go new file mode 100644 index 00000000..98df0522 --- /dev/null +++ b/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.go @@ -0,0 +1,27 @@ +func addNegabinary(arr1 []int, arr2 []int) []int { + res := []int{} + i, j := len(arr1)-1, len(arr2)-1 + carry := 0 + + for carry != 0 || i >= 0 || j >= 0 { + if i >= 0 { + carry += arr1[i] + i-- + } + if j >= 0 { + carry += arr2[j] + j-- + } + res = append(res, carry&1) + carry = -(carry >> 1) + } + + for len(res) > 1 && res[len(res)-1] == 0 { + res = res[:len(res)-1] + } + + for left, right := 0, len(res)-1; left < right; left, right = left+1, right-1 { + res[left], res[right] = res[right], res[left] + } + return res +} diff --git a/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.java b/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.java new file mode 100644 index 00000000..50475622 --- /dev/null +++ b/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.java @@ -0,0 +1,24 @@ +class Solution { + public int[] addNegabinary(int[] arr1, int[] arr2) { + List res = new ArrayList<>(); + int i = arr1.length - 1, j = arr2.length - 1; + int carry = 0; + + while (carry != 0 || i >= 0 || j >= 0) { + if (i >= 0) carry += arr1[i--]; + if (j >= 0) carry += arr2[j--]; + res.add(carry & 1); + carry = -(carry >> 1); + } + + while (res.size() > 1 && res.get(res.size() - 1) == 0) { + res.remove(res.size() - 1); + } + + int[] result = new int[res.size()]; + for (int k = 0; k < res.size(); k++) { + result[k] = res.get(res.size() - 1 - k); + } + return result; + } +} diff --git a/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.kt b/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.kt new file mode 100644 index 00000000..87497bc1 --- /dev/null +++ b/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.kt @@ -0,0 +1,21 @@ +class Solution { + fun addNegabinary(arr1: IntArray, arr2: IntArray): IntArray { + val res = mutableListOf() + var i = arr1.size - 1 + var j = arr2.size - 1 + var carry = 0 + + while (carry != 0 || i >= 0 || j >= 0) { + if (i >= 0) carry += arr1[i--] + if (j >= 0) carry += arr2[j--] + res.add(carry and 1) + carry = -(carry shr 1) + } + + while (res.size > 1 && res.last() == 0) { + res.removeAt(res.size - 1) + } + + return res.reversed().toIntArray() + } +} diff --git a/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.py b/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.py new file mode 100644 index 00000000..3fff732d --- /dev/null +++ b/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.py @@ -0,0 +1,20 @@ +class Solution(object): + def addNegabinary(self, arr1, arr2): + """ + :type arr1: List[int] + :type arr2: List[int] + :rtype: List[int] + """ + res = [] + carry = 0 + while carry or arr1 or arr2: + if arr1: + carry += arr1.pop() + if arr2: + carry += arr2.pop() + res.append(carry & 1) + carry = -(carry >> 1) + + while len(res) > 1 and res[-1] == 0: + res.pop() + return res[::-1] diff --git a/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.py2 b/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.py2 new file mode 100644 index 00000000..b4912263 --- /dev/null +++ b/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.py2 @@ -0,0 +1,20 @@ +class Solution(object): + def addNegabinary(self, arr1, arr2): + """ + :type arr1: List[int] + :type arr2: List[int] + :rtype: List[int] + """ + res = [] + carry = 0 + while carry or arr1 or arr2: + if arr1: + carry += arr1.pop() + if arr2: + carry += arr2.pop() + res.append(carry & 1) + carry = -(carry >> 1) + + while len(res) > 1 and res[-1] == 0: + res.pop() + return res[::-1] diff --git a/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.rb b/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.rb new file mode 100644 index 00000000..fa5574bd --- /dev/null +++ b/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.rb @@ -0,0 +1,18 @@ +# @param {Integer[]} arr1 +# @param {Integer[]} arr2 +# @return {Integer[]} +def add_negabinary(arr1, arr2) + res = [] + carry = 0 + while carry != 0 || !arr1.empty? || !arr2.empty? + carry += arr1.pop.to_i + carry += arr2.pop.to_i + res.push(carry & 1) + carry = -(carry >> 1) + end + + while res.length > 1 && res[-1] == 0 + res.pop + end + res.reverse +end diff --git a/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.rs b/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.rs new file mode 100644 index 00000000..3650b1d2 --- /dev/null +++ b/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.rs @@ -0,0 +1,28 @@ +impl Solution { + pub fn add_negabinary(arr1: Vec, arr2: Vec) -> Vec { + let mut res = Vec::new(); + let mut i = arr1.len() as i32 - 1; + let mut j = arr2.len() as i32 - 1; + let mut carry = 0i32; + + while carry != 0 || i >= 0 || j >= 0 { + if i >= 0 { + carry += arr1[i as usize]; + i -= 1; + } + if j >= 0 { + carry += arr2[j as usize]; + j -= 1; + } + res.push(carry & 1); + carry = -(carry >> 1); + } + + while res.len() > 1 && res[res.len() - 1] == 0 { + res.pop(); + } + + res.reverse(); + res + } +} diff --git a/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.swift b/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.swift new file mode 100644 index 00000000..5b42d095 --- /dev/null +++ b/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.swift @@ -0,0 +1,26 @@ +class Solution { + func addNegabinary(_ arr1: [Int], _ arr2: [Int]) -> [Int] { + var res = [Int]() + var i = arr1.count - 1, j = arr2.count - 1 + var carry = 0 + + while carry != 0 || i >= 0 || j >= 0 { + if i >= 0 { + carry += arr1[i] + i -= 1 + } + if j >= 0 { + carry += arr2[j] + j -= 1 + } + res.append(carry & 1) + carry = -(carry >> 1) + } + + while res.count > 1 && res.last == 0 { + res.removeLast() + } + + return res.reversed() + } +} diff --git a/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.ts b/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.ts new file mode 100644 index 00000000..3d5c7770 --- /dev/null +++ b/tests/1001-1500/1073. adding-two-negabinary-numbers/sol.ts @@ -0,0 +1,19 @@ +function addNegabinary(arr1: number[], arr2: number[]): number[] { + const res: number[] = []; + let i = arr1.length - 1, + j = arr2.length - 1; + let carry = 0; + + while (carry !== 0 || i >= 0 || j >= 0) { + if (i >= 0) carry += arr1[i--]; + if (j >= 0) carry += arr2[j--]; + res.push(carry & 1); + carry = -(carry >> 1); + } + + while (res.length > 1 && res[res.length - 1] === 0) { + res.pop(); + } + + return res.reverse(); +} diff --git a/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/manifest.yaml b/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/manifest.yaml new file mode 100644 index 00000000..27cac968 --- /dev/null +++ b/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/manifest.yaml @@ -0,0 +1,426 @@ +entry: + id: 1074 + title: number-of-submatrices-that-sum-to-target + params: + matrix: + type: array + items: + type: array + items: + type: int + target: + type: int + call: + cpp: Solution().numSubmatrixSumTarget({matrix}, {target}) + rust: Solution::num_submatrix_sum_target({matrix}, {target}) + python3: Solution().numSubmatrixSumTarget({matrix}, {target}) + python2: Solution().numSubmatrixSumTarget({matrix}, {target}) + ruby: num_submatrix_sum_target({matrix}, {target}) + java: new Solution().numSubmatrixSumTarget({matrix}, {target}) + csharp: new Solution().NumSubmatrixSumTarget({matrix}, {target}) + kotlin: Solution().numSubmatrixSumTarget({matrix}, {target}) + go: numSubmatrixSumTarget({matrix}, {target}) + dart: Solution().numSubmatrixSumTarget({matrix}, {target}) + swift: Solution().numSubmatrixSumTarget({matrix}, {target}) + typescript: numSubmatrixSumTarget({matrix}, {target}) +judge: + type: exact +limits: + time_ms: 2000 + memory_mb: 256 +oracle: + python3: + call: Checker().numSubmatrixSumTarget(matrix, target, {result}) + checker: + "class Checker:\n def numSubmatrixSumTarget(self, matrix, target,\ + \ result):\n if not isinstance(result, int):\n return False\n\ + \ grid = [row[:] for row in matrix]\n m, n = len(grid), len(grid[0])\n\ + \ for r in range(m):\n for c in range(1, n):\n \ + \ grid[r][c] += grid[r][c - 1]\n ans = 0\n for c1 in range(n):\n\ + \ for c2 in range(c1, n):\n seen = {0: 1}\n \ + \ cur = 0\n for r in range(m):\n \ + \ cur += grid[r][c2] - (grid[r][c1 - 1] if c1 > 0 else 0)\n \ + \ ans += seen.get(cur - target, 0)\n seen[cur] = seen.get(cur,\ + \ 0) + 1\n return result == ans\n" +seed: 1074 +tests: + - name: ex1 + in: + matrix: + elemType: int + value: + - - 0 + - 1 + - 0 + - - 1 + - 1 + - 1 + - - 0 + - 1 + - 0 + target: 0 + - name: ex2 + in: + matrix: + elemType: int + value: + - - 1 + - -1 + - - -1 + - 1 + target: 0 + - name: ex3 + in: + matrix: + elemType: int + value: + - - 904 + target: 0 + - name: single_zero + in: + matrix: + elemType: int + value: + - - 0 + target: 0 + - name: single_nonzero + in: + matrix: + elemType: int + value: + - - 5 + target: 5 + - name: single_neg + in: + matrix: + elemType: int + value: + - - -5 + target: -5 + - name: row_two + in: + matrix: + elemType: int + value: + - - 1 + - 2 + target: 3 + - name: row_three + in: + matrix: + elemType: int + value: + - - 1 + - 1 + - 1 + target: 2 + - name: col_two + in: + matrix: + elemType: int + value: + - - 1 + - - 2 + target: 3 + - name: zeros_2x2 + in: + matrix: + elemType: int + value: + - - 0 + - 0 + - - 0 + - 0 + target: 0 + - name: ones_2x2_t2 + in: + matrix: + elemType: int + value: + - - 1 + - 1 + - - 1 + - 1 + target: 2 + - name: ones_2x2_t4 + in: + matrix: + elemType: int + value: + - - 1 + - 1 + - - 1 + - 1 + target: 4 + - name: mixed_2x3 + in: + matrix: + elemType: int + value: + - - 1 + - -1 + - 0 + - - 2 + - 3 + - -2 + target: 3 + - name: mixed_3x2 + in: + matrix: + elemType: int + value: + - - 2 + - -2 + - - 1 + - 1 + - - -1 + - 3 + target: 2 + - name: neg_target + in: + matrix: + elemType: int + value: + - - 1 + - -1 + - - 1 + - -1 + target: -1 + - name: large_vals + in: + matrix: + elemType: int + value: + - - 1000 + - 1000 + - - 1000 + - 1000 + target: 2000 + - name: zero_target_mixed + in: + matrix: + elemType: int + value: + - - 1 + - 0 + - 1 + - - 0 + - -1 + - 0 + - - 1 + - 0 + - 1 + target: 0 + - name: target_one + in: + matrix: + elemType: int + value: + - - 1 + - 0 + - - 0 + - 1 + target: 1 + - name: target_minus_two + in: + matrix: + elemType: int + value: + - - -1 + - -1 + - - -1 + - -1 + target: -2 + - name: rect_3x4 + in: + matrix: + elemType: int + value: + - - 1 + - 2 + - 3 + - 4 + - - 0 + - 1 + - 0 + - 1 + - - 2 + - -2 + - 2 + - -2 + target: 3 + - name: rect_4x3 + in: + matrix: + elemType: int + value: + - - 1 + - 0 + - -1 + - - 2 + - 3 + - -3 + - - 1 + - -1 + - 1 + - - 0 + - 2 + - -2 + target: 2 + - name: all_twos + in: + matrix: + elemType: int + value: + - - 2 + - 2 + - 2 + - - 2 + - 2 + - 2 + target: 4 + - name: checker_1 + in: + matrix: + elemType: int + value: + - - 3 + - -1 + - 2 + - - -2 + - 4 + - -1 + target: 5 + - name: checker_2 + in: + matrix: + elemType: int + value: + - - 1 + - 2 + - -3 + - - 4 + - -4 + - 0 + - - 2 + - 2 + - -2 + target: 0 + - name: checker_3 + in: + matrix: + elemType: int + value: + - - -1 + - 2 + - - 3 + - -4 + - - 5 + - -6 + target: -1 + - name: checker_4 + in: + matrix: + elemType: int + value: + - - 0 + - 1 + - 0 + - 1 + target: 1 + - name: checker_5 + in: + matrix: + elemType: int + value: + - - 1 + - - 0 + - - 1 + - - 0 + target: 1 + - name: checker_6 + in: + matrix: + elemType: int + value: + - - 2 + - 1 + - - 1 + - 2 + target: 3 + - name: checker_7 + in: + matrix: + elemType: int + value: + - - 5 + - -5 + - 5 + - - -5 + - 5 + - -5 + target: 0 + - name: checker_8 + in: + matrix: + elemType: int + value: + - - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + target: 3 + - name: checker_9 + in: + matrix: + elemType: int + value: + - - 7 + target: 8 + - name: checker_10 + in: + matrix: + elemType: int + value: + - - -2 + - -2 + - - -2 + - -2 + target: -4 + - name: checker_11 + in: + matrix: + elemType: int + value: + - - 4 + - 1 + - -2 + - - 3 + - -1 + - 2 + target: 6 + - name: checker_12 + in: + matrix: + elemType: int + value: + - - 8 + - 0 + - - 0 + - 8 + target: 8 + - name: checker_13 + in: + matrix: + elemType: int + value: + - - 1 + - -1 + - 1 + - -1 + target: 0 diff --git a/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.cpp b/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.cpp new file mode 100644 index 00000000..df87da25 --- /dev/null +++ b/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.cpp @@ -0,0 +1,25 @@ +class Solution { +public: + int numSubmatrixSumTarget(vector>& matrix, int target) { + int m = matrix.size(), n = matrix[0].size(); + for (int row = 0; row < m; row++) { + for (int col = 1; col < n; col++) { + matrix[row][col] += matrix[row][col - 1]; + } + } + int count = 0; + for (int c1 = 0; c1 < n; c1++) { + for (int c2 = c1; c2 < n; c2++) { + unordered_map prefixSumMap; + prefixSumMap[0] = 1; + int sumVal = 0; + for (int row = 0; row < m; row++) { + sumVal += matrix[row][c2] - (c1 > 0 ? matrix[row][c1 - 1] : 0); + count += prefixSumMap[sumVal - target]; + prefixSumMap[sumVal]++; + } + } + } + return count; + } +}; diff --git a/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.cs b/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.cs new file mode 100644 index 00000000..5f66c7fc --- /dev/null +++ b/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.cs @@ -0,0 +1,28 @@ +public class Solution { + public int NumSubmatrixSumTarget(int[][] matrix, int target) { + int m = matrix.Length, n = matrix[0].Length; + for (int row = 0; row < m; row++) { + for (int col = 1; col < n; col++) { + matrix[row][col] += matrix[row][col - 1]; + } + } + int count = 0; + for (int c1 = 0; c1 < n; c1++) { + for (int c2 = c1; c2 < n; c2++) { + var prefixSumMap = new Dictionary(); + prefixSumMap[0] = 1; + int sumVal = 0; + for (int row = 0; row < m; row++) { + sumVal += matrix[row][c2] - (c1 > 0 ? matrix[row][c1 - 1] : 0); + if (prefixSumMap.ContainsKey(sumVal - target)) + count += prefixSumMap[sumVal - target]; + if (prefixSumMap.ContainsKey(sumVal)) + prefixSumMap[sumVal]++; + else + prefixSumMap[sumVal] = 1; + } + } + } + return count; + } +} diff --git a/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.dart b/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.dart new file mode 100644 index 00000000..096a3f4e --- /dev/null +++ b/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.dart @@ -0,0 +1,23 @@ +class Solution { + int numSubmatrixSumTarget(List> matrix, int target) { + int m = matrix.length, n = matrix[0].length; + for (int row = 0; row < m; row++) { + for (int col = 1; col < n; col++) { + matrix[row][col] += matrix[row][col - 1]; + } + } + int count = 0; + for (int c1 = 0; c1 < n; c1++) { + for (int c2 = c1; c2 < n; c2++) { + Map prefixSumMap = {0: 1}; + int sumVal = 0; + for (int row = 0; row < m; row++) { + sumVal += matrix[row][c2] - (c1 > 0 ? matrix[row][c1 - 1] : 0); + count += prefixSumMap[sumVal - target] ?? 0; + prefixSumMap[sumVal] = (prefixSumMap[sumVal] ?? 0) + 1; + } + } + } + return count; + } +} diff --git a/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.go b/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.go new file mode 100644 index 00000000..1159d842 --- /dev/null +++ b/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.go @@ -0,0 +1,25 @@ +func numSubmatrixSumTarget(matrix [][]int, target int) int { + m, n := len(matrix), len(matrix[0]) + for row := 0; row < m; row++ { + for col := 1; col < n; col++ { + matrix[row][col] += matrix[row][col-1] + } + } + count := 0 + for c1 := 0; c1 < n; c1++ { + for c2 := c1; c2 < n; c2++ { + prefixSumMap := map[int]int{0: 1} + sumVal := 0 + for row := 0; row < m; row++ { + if c1 > 0 { + sumVal += matrix[row][c2] - matrix[row][c1-1] + } else { + sumVal += matrix[row][c2] + } + count += prefixSumMap[sumVal-target] + prefixSumMap[sumVal]++ + } + } + } + return count +} diff --git a/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.java b/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.java new file mode 100644 index 00000000..10b230f9 --- /dev/null +++ b/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.java @@ -0,0 +1,24 @@ +class Solution { + public int numSubmatrixSumTarget(int[][] matrix, int target) { + int m = matrix.length, n = matrix[0].length; + for (int row = 0; row < m; row++) { + for (int col = 1; col < n; col++) { + matrix[row][col] += matrix[row][col - 1]; + } + } + int count = 0; + for (int c1 = 0; c1 < n; c1++) { + for (int c2 = c1; c2 < n; c2++) { + java.util.Map prefixSumMap = new java.util.HashMap<>(); + prefixSumMap.put(0, 1); + int sumVal = 0; + for (int row = 0; row < m; row++) { + sumVal += matrix[row][c2] - (c1 > 0 ? matrix[row][c1 - 1] : 0); + count += prefixSumMap.getOrDefault(sumVal - target, 0); + prefixSumMap.put(sumVal, prefixSumMap.getOrDefault(sumVal, 0) + 1); + } + } + } + return count; + } +} diff --git a/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.kt b/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.kt new file mode 100644 index 00000000..0501a709 --- /dev/null +++ b/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.kt @@ -0,0 +1,24 @@ +class Solution { + fun numSubmatrixSumTarget(matrix: Array, target: Int): Int { + val m = matrix.size + val n = matrix[0].size + for (row in 0 until m) { + for (col in 1 until n) { + matrix[row][col] += matrix[row][col - 1] + } + } + var count = 0 + for (c1 in 0 until n) { + for (c2 in c1 until n) { + val prefixSumMap = mutableMapOf(0 to 1) + var sumVal = 0 + for (row in 0 until m) { + sumVal += matrix[row][c2] - (if (c1 > 0) matrix[row][c1 - 1] else 0) + count += prefixSumMap.getOrDefault(sumVal - target, 0) + prefixSumMap[sumVal] = prefixSumMap.getOrDefault(sumVal, 0) + 1 + } + } + } + return count + } +} diff --git a/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.py b/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.py new file mode 100644 index 00000000..ff441504 --- /dev/null +++ b/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.py @@ -0,0 +1,28 @@ +class Solution: + def numSubmatrixSumTarget(self, matrix: List[List[int]], target: int) -> int: + m, n = len(matrix), len(matrix[0]) + + # Step 1: Preprocess the matrix to calculate cumulative sum for each row + for row in range(m): + for col in range(1, n): + matrix[row][col] += matrix[row][col - 1] + + count = 0 + + # Step 2: Iterate over all pairs of column indices c1 and c2 + for c1 in range(n): + for c2 in range(c1, n): + # Step 3: Iterate over all pairs of row indices row1 and row2 + prefix_sum_map = {0: 1} + sum_val = 0 + + # Step 4: Calculate the sum of submatrix using cumulative sum + for row in range(m): + sum_val += matrix[row][c2] - (matrix[row][c1 - 1] if c1 > 0 else 0) + + # Step 5 and 6: Update count and prefix_sum_map + count += prefix_sum_map.get(sum_val - target, 0) + prefix_sum_map[sum_val] = prefix_sum_map.get(sum_val, 0) + 1 + + # Step 8: Return the final count + return count diff --git a/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.py2 b/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.py2 new file mode 100644 index 00000000..2b2b13c5 --- /dev/null +++ b/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.py2 @@ -0,0 +1,21 @@ +class Solution(object): + def numSubmatrixSumTarget(self, matrix, target): + """ + :type matrix: List[List[int]] + :type target: int + :rtype: int + """ + m, n = len(matrix), len(matrix[0]) + for row in range(m): + for col in range(1, n): + matrix[row][col] += matrix[row][col - 1] + count = 0 + for c1 in range(n): + for c2 in range(c1, n): + prefix_sum_map = {0: 1} + sum_val = 0 + for row in range(m): + sum_val += matrix[row][c2] - (matrix[row][c1 - 1] if c1 > 0 else 0) + count += prefix_sum_map.get(sum_val - target, 0) + prefix_sum_map[sum_val] = prefix_sum_map.get(sum_val, 0) + 1 + return count diff --git a/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.rb b/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.rb new file mode 100644 index 00000000..b80b3bc6 --- /dev/null +++ b/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.rb @@ -0,0 +1,24 @@ +# @param {Integer[][]} matrix +# @param {Integer} target +# @return {Integer} +def num_submatrix_sum_target(matrix, target) + m, n = matrix.length, matrix[0].length + (0...m).each do |row| + (1...n).each do |col| + matrix[row][col] += matrix[row][col - 1] + end + end + count = 0 + (0...n).each do |c1| + (c1...n).each do |c2| + prefix_sum_map = {0 => 1} + sum_val = 0 + (0...m).each do |row| + sum_val += matrix[row][c2] - (c1 > 0 ? matrix[row][c1 - 1] : 0) + count += prefix_sum_map.fetch(sum_val - target, 0) + prefix_sum_map[sum_val] = prefix_sum_map.fetch(sum_val, 0) + 1 + end + end + end + count +end diff --git a/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.rs b/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.rs new file mode 100644 index 00000000..9559956c --- /dev/null +++ b/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.rs @@ -0,0 +1,27 @@ +impl Solution { + pub fn num_submatrix_sum_target(matrix: Vec>, target: i32) -> i32 { + let mut matrix = matrix; + let m = matrix.len(); + let n = matrix[0].len(); + for row in 0..m { + for col in 1..n { + matrix[row][col] += matrix[row][col - 1]; + } + } + let mut count = 0; + for c1 in 0..n { + for c2 in c1..n { + let mut prefix_sum_map = std::collections::HashMap::new(); + prefix_sum_map.insert(0, 1); + let mut sum_val = 0; + for row in 0..m { + let sub = if c1 > 0 { matrix[row][c1 - 1] } else { 0 }; + sum_val += matrix[row][c2] - sub; + count += prefix_sum_map.get(&(sum_val - target)).unwrap_or(&0); + *prefix_sum_map.entry(sum_val).or_insert(0) += 1; + } + } + } + count + } +} diff --git a/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.swift b/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.swift new file mode 100644 index 00000000..e32b318b --- /dev/null +++ b/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.swift @@ -0,0 +1,24 @@ +class Solution { + func numSubmatrixSumTarget(_ matrix: [[Int]], _ target: Int) -> Int { + var matrix = matrix + let m = matrix.count, n = matrix[0].count + for row in 0.. 0 ? matrix[row][c1 - 1] : 0) + count += prefixSumMap[sumVal - target] ?? 0 + prefixSumMap[sumVal] = (prefixSumMap[sumVal] ?? 0) + 1 + } + } + } + return count + } +} diff --git a/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.ts b/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.ts new file mode 100644 index 00000000..e0bdff4c --- /dev/null +++ b/tests/1001-1500/1074. number-of-submatrices-that-sum-to-target/sol.ts @@ -0,0 +1,23 @@ +function numSubmatrixSumTarget(matrix: number[][], target: number): number { + const m = matrix.length, + n = matrix[0].length; + for (let row = 0; row < m; row++) { + for (let col = 1; col < n; col++) { + matrix[row][col] += matrix[row][col - 1]; + } + } + let count = 0; + for (let c1 = 0; c1 < n; c1++) { + for (let c2 = c1; c2 < n; c2++) { + const prefixSumMap = new Map(); + prefixSumMap.set(0, 1); + let sumVal = 0; + for (let row = 0; row < m; row++) { + sumVal += matrix[row][c2] - (c1 > 0 ? matrix[row][c1 - 1] : 0); + count += prefixSumMap.get(sumVal - target) ?? 0; + prefixSumMap.set(sumVal, (prefixSumMap.get(sumVal) ?? 0) + 1); + } + } + } + return count; +} diff --git a/tests/1001-1500/1078. occurrences-after-bigram/manifest.yaml b/tests/1001-1500/1078. occurrences-after-bigram/manifest.yaml new file mode 100644 index 00000000..46832360 --- /dev/null +++ b/tests/1001-1500/1078. occurrences-after-bigram/manifest.yaml @@ -0,0 +1,323 @@ +entry: + id: 1078 + title: occurrences-after-bigram + params: + text: + type: string + first: + type: string + second: + type: string + call: + cpp: "Solution().findOcurrences({text}, {first}, {second})" + rust: "Solution::find_ocurrences({text}, {first}, {second})" + python3: "Solution().findOcurrences({text}, {first}, {second})" + python2: "Solution().findOcurrences({text}, {first}, {second})" + ruby: "find_ocurrences({text}, {first}, {second})" + java: "new Solution().findOcurrences({text}, {first}, {second})" + csharp: "new Solution().FindOcurrences({text}, {first}, {second})" + kotlin: "Solution().findOcurrences({text}, {first}, {second})" + go: "findOcurrences({text}, {first}, {second})" + dart: "Solution().findOcurrences({text}, {first}, {second})" + swift: "Solution().findOcurrences({text}, {first}, {second})" + typescript: "findOcurrences({text}, {first}, {second})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().check({result}, {text}, {first}, {second})" + checker: | + class Checker: + def check(self, result, text=None, first=None, second=None): + if not isinstance(result, list): + return False + words = text.split() + expected = [] + for i in range(len(words) - 2): + if words[i] == first and words[i + 1] == second: + expected.append(words[i + 2]) + return result == expected +seed: 1078 +tests: + - name: ex1 + in: + text: "alice is a good girl she is a good student" + first: a + second: good + out: + - girl + - student + - name: ex2 + in: + text: "we will we will rock you" + first: we + second: will + out: + - we + - rock + - name: no_match + in: + text: "a b c d" + first: x + second: "y" + out: [] + - name: single_triplet + in: + text: "a b c" + first: a + second: b + out: + - c + - name: overlapping_matches + in: + text: "a a a a" + first: a + second: a + out: + - a + - a + - name: repeated_three + in: + text: "a b c a b d" + first: a + second: b + out: + - c + - d + - name: first_at_start + in: + text: "alpha beta gamma" + first: alpha + second: beta + out: + - gamma + - name: first_at_end + in: + text: "foo bar baz" + first: bar + second: baz + out: [] + - name: second_repeated + in: + text: "a b a b c" + first: a + second: b + out: + - a + - c + - name: three_occurrences + in: + text: "t u v t u w t u x" + first: t + second: u + out: + - v + - w + - x + - name: many_words_1 + in: + text: "one two three four five six" + first: two + second: three + out: + - four + - name: many_words_2 + in: + text: "red blue red blue green red blue yellow" + first: red + second: blue + out: + - red + - green + - yellow + - name: many_words_3 + in: + text: "p q r p q s p q t" + first: p + second: q + out: + - r + - s + - t + - name: no_triplet_due_to_gap + in: + text: "a x b c" + first: a + second: b + out: [] + - name: multiple_same_third + in: + text: "a b c a b c a b d" + first: a + second: b + out: + - c + - c + - d + - name: adjacent_repetitions + in: + text: "a b c a b c a b c" + first: a + second: b + out: + - c + - c + - c + - name: two_word_text + in: + text: "a b" + first: a + second: b + out: [] + - name: different_case_letters_not_allowed + in: + text: "abc def ghi" + first: abc + second: def + out: + - ghi + - name: boundary_longish_1 + in: + text: "a b c d e f g h i j k l" + first: d + second: e + out: + - f + - name: boundary_longish_2 + in: + text: "aa bb cc dd ee ff gg hh ii jj kk ll mm" + first: ee + second: ff + out: + - gg + - name: boundary_longish_3 + in: + text: "a b c a b d a b e a b f" + first: a + second: b + out: + - c + - d + - e + - f + - name: boundary_longish_4 + in: + text: "cat dog bird cat dog fish cat dog ant" + first: cat + second: dog + out: + - bird + - fish + - ant + - name: boundary_longish_5 + in: + text: "a b a c a b a d" + first: a + second: b + out: + - a + - a + - name: many_matches_1 + in: + text: "a b c a b c a b c" + first: a + second: b + out: + - c + - c + - c + - name: many_matches_2 + in: + text: "x y z x y z x y a x y b" + first: x + second: "y" + out: + - z + - z + - a + - b + - name: many_matches_3 + in: + text: "p q r s p q r t p q r u" + first: p + second: q + out: + - r + - r + - r + - name: many_matches_4 + in: + text: "alpha beta gamma alpha beta delta alpha beta epsilon" + first: alpha + second: beta + out: + - gamma + - delta + - epsilon + - name: many_matches_5 + in: + text: "a a b a a c a a d" + first: a + second: a + out: + - b + - c + - d + - name: not_enough_words + in: + text: "hello world" + first: hello + second: world + out: [] + - name: trailing_match_absent + in: + text: "w x y z" + first: x + second: "y" + out: + - z + - name: leading_match_absent + in: + text: "x y z" + first: "y" + second: z + out: [] + - name: repeated_first_second + in: + text: "a b c a b d a b e" + first: a + second: b + out: + - c + - d + - e + - name: varied_words_1 + in: + text: "one one two one one three one one four" + first: one + second: one + out: + - two + - three + - four + - name: varied_words_2 + in: + text: "red red blue red red green red red yellow" + first: red + second: red + out: + - blue + - green + - yellow + - name: varied_words_3 + in: + text: "a b a b a b a c" + first: a + second: b + out: + - a + - a + - a diff --git a/tests/1001-1500/1078. occurrences-after-bigram/sol.cpp b/tests/1001-1500/1078. occurrences-after-bigram/sol.cpp new file mode 100644 index 00000000..f00557af --- /dev/null +++ b/tests/1001-1500/1078. occurrences-after-bigram/sol.cpp @@ -0,0 +1,18 @@ +class Solution { +public: + vector findOcurrences(string text, string first, string second) { + vector words; + istringstream iss(text); + string word; + while (iss >> word) { + words.push_back(word); + } + vector result; + for (int i = 0; i < (int)words.size() - 2; i++) { + if (words[i] == first && words[i + 1] == second) { + result.push_back(words[i + 2]); + } + } + return result; + } +}; diff --git a/tests/1001-1500/1078. occurrences-after-bigram/sol.cs b/tests/1001-1500/1078. occurrences-after-bigram/sol.cs new file mode 100644 index 00000000..2e7262d3 --- /dev/null +++ b/tests/1001-1500/1078. occurrences-after-bigram/sol.cs @@ -0,0 +1,12 @@ +public class Solution { + public string[] FindOcurrences(string text, string first, string second) { + string[] words = text.Split(' '); + List result = new List(); + for (int i = 0; i < words.Length - 2; i++) { + if (words[i] == first && words[i + 1] == second) { + result.Add(words[i + 2]); + } + } + return result.ToArray(); + } +} diff --git a/tests/1001-1500/1078. occurrences-after-bigram/sol.dart b/tests/1001-1500/1078. occurrences-after-bigram/sol.dart new file mode 100644 index 00000000..4613eb5d --- /dev/null +++ b/tests/1001-1500/1078. occurrences-after-bigram/sol.dart @@ -0,0 +1,12 @@ +class Solution { + List findOcurrences(String text, String first, String second) { + List words = text.split(' '); + List result = []; + for (int i = 0; i < words.length - 2; i++) { + if (words[i] == first && words[i + 1] == second) { + result.add(words[i + 2]); + } + } + return result; + } +} diff --git a/tests/1001-1500/1078. occurrences-after-bigram/sol.go b/tests/1001-1500/1078. occurrences-after-bigram/sol.go new file mode 100644 index 00000000..4851d805 --- /dev/null +++ b/tests/1001-1500/1078. occurrences-after-bigram/sol.go @@ -0,0 +1,10 @@ +func findOcurrences(text string, first string, second string) []string { + words := strings.Split(text, " ") + result := []string{} + for i := 0; i < len(words)-2; i++ { + if words[i] == first && words[i+1] == second { + result = append(result, words[i+2]) + } + } + return result +} diff --git a/tests/1001-1500/1078. occurrences-after-bigram/sol.java b/tests/1001-1500/1078. occurrences-after-bigram/sol.java new file mode 100644 index 00000000..179af566 --- /dev/null +++ b/tests/1001-1500/1078. occurrences-after-bigram/sol.java @@ -0,0 +1,12 @@ +class Solution { + public String[] findOcurrences(String text, String first, String second) { + String[] words = text.split(" "); + List result = new ArrayList<>(); + for (int i = 0; i < words.length - 2; i++) { + if (words[i].equals(first) && words[i + 1].equals(second)) { + result.add(words[i + 2]); + } + } + return result.toArray(new String[0]); + } +} diff --git a/tests/1001-1500/1078. occurrences-after-bigram/sol.kt b/tests/1001-1500/1078. occurrences-after-bigram/sol.kt new file mode 100644 index 00000000..b485464a --- /dev/null +++ b/tests/1001-1500/1078. occurrences-after-bigram/sol.kt @@ -0,0 +1,12 @@ +class Solution { + fun findOcurrences(text: String, first: String, second: String): Array { + val words = text.split(" ") + val result = mutableListOf() + for (i in 0 until words.size - 2) { + if (words[i] == first && words[i + 1] == second) { + result.add(words[i + 2]) + } + } + return result.toTypedArray() + } +} diff --git a/tests/1001-1500/1078. occurrences-after-bigram/sol.py b/tests/1001-1500/1078. occurrences-after-bigram/sol.py new file mode 100644 index 00000000..e20f541e --- /dev/null +++ b/tests/1001-1500/1078. occurrences-after-bigram/sol.py @@ -0,0 +1,13 @@ +class Solution: + def findOcurrences(self, text: str, first: str, second: str) -> List[str]: + text_list = text.split() + result = [] + + # Stop at len - 2 to avoid index out of range + for i in range(len(text_list) - 2): + # Check if the current word and the next word match 'first' and 'second' + if text_list[i] == first and text_list[i + 1] == second: + # If they match, add the word after 'second' to the result + result.append(text_list[i + 2]) + + return result diff --git a/tests/1001-1500/1078. occurrences-after-bigram/sol.py2 b/tests/1001-1500/1078. occurrences-after-bigram/sol.py2 new file mode 100644 index 00000000..9a289762 --- /dev/null +++ b/tests/1001-1500/1078. occurrences-after-bigram/sol.py2 @@ -0,0 +1,14 @@ +class Solution(object): + def findOcurrences(self, text, first, second): + """ + :type text: str + :type first: str + :type second: str + :rtype: List[str] + """ + text_list = text.split() + result = [] + for i in range(len(text_list) - 2): + if text_list[i] == first and text_list[i + 1] == second: + result.append(text_list[i + 2]) + return result diff --git a/tests/1001-1500/1078. occurrences-after-bigram/sol.rb b/tests/1001-1500/1078. occurrences-after-bigram/sol.rb new file mode 100644 index 00000000..d66135cf --- /dev/null +++ b/tests/1001-1500/1078. occurrences-after-bigram/sol.rb @@ -0,0 +1,14 @@ +# @param {String} text +# @param {String} first +# @param {String} second +# @return {String[]} +def find_ocurrences(text, first, second) + text_list = text.split + result = [] + (0...(text_list.length - 2)).each do |i| + if text_list[i] == first && text_list[i + 1] == second + result << text_list[i + 2] + end + end + result +end diff --git a/tests/1001-1500/1078. occurrences-after-bigram/sol.rs b/tests/1001-1500/1078. occurrences-after-bigram/sol.rs new file mode 100644 index 00000000..f32b9f02 --- /dev/null +++ b/tests/1001-1500/1078. occurrences-after-bigram/sol.rs @@ -0,0 +1,12 @@ +impl Solution { + pub fn find_ocurrences(text: String, first: String, second: String) -> Vec { + let words: Vec<&str> = text.split_whitespace().collect(); + let mut result = Vec::new(); + for i in 0..words.len().saturating_sub(2) { + if words[i] == first && words[i + 1] == second { + result.push(words[i + 2].to_string()); + } + } + result + } +} diff --git a/tests/1001-1500/1078. occurrences-after-bigram/sol.swift b/tests/1001-1500/1078. occurrences-after-bigram/sol.swift new file mode 100644 index 00000000..26e6f33c --- /dev/null +++ b/tests/1001-1500/1078. occurrences-after-bigram/sol.swift @@ -0,0 +1,12 @@ +class Solution { + func findOcurrences(_ text: String, _ first: String, _ second: String) -> [String] { + let words = text.split(separator: " ").map { String($0) } + var result: [String] = [] + for i in 0.. used(tiles.size(), false); + return backtrack(tiles, used); + } + +private: + int backtrack(string& tiles, vector& used) { + int count = 0; + for (int i = 0; i < tiles.size(); i++) { + if (used[i] || (i > 0 && tiles[i] == tiles[i - 1] && !used[i - 1])) { + continue; + } + used[i] = true; + count += 1 + backtrack(tiles, used); + used[i] = false; + } + return count; + } +}; diff --git a/tests/1001-1500/1079. letter-tile-possibilities/sol.cs b/tests/1001-1500/1079. letter-tile-possibilities/sol.cs new file mode 100644 index 00000000..3f7b57f0 --- /dev/null +++ b/tests/1001-1500/1079. letter-tile-possibilities/sol.cs @@ -0,0 +1,21 @@ +public class Solution { + public int NumTilePossibilities(string tiles) { + char[] arr = tiles.ToCharArray(); + Array.Sort(arr); + bool[] used = new bool[arr.Length]; + return Backtrack(arr, used); + } + + private int Backtrack(char[] tiles, bool[] used) { + int count = 0; + for (int i = 0; i < tiles.Length; i++) { + if (used[i] || (i > 0 && tiles[i] == tiles[i - 1] && !used[i - 1])) { + continue; + } + used[i] = true; + count += 1 + Backtrack(tiles, used); + used[i] = false; + } + return count; + } +} diff --git a/tests/1001-1500/1079. letter-tile-possibilities/sol.dart b/tests/1001-1500/1079. letter-tile-possibilities/sol.dart new file mode 100644 index 00000000..8ee8efad --- /dev/null +++ b/tests/1001-1500/1079. letter-tile-possibilities/sol.dart @@ -0,0 +1,20 @@ +class Solution { + int numTilePossibilities(String tiles) { + var arr = tiles.split('')..sort(); + var used = List.filled(arr.length, false); + return backtrack(arr, used); + } + + int backtrack(List tiles, List used) { + int count = 0; + for (int i = 0; i < tiles.length; i++) { + if (used[i] || (i > 0 && tiles[i] == tiles[i - 1] && !used[i - 1])) { + continue; + } + used[i] = true; + count += 1 + backtrack(tiles, used); + used[i] = false; + } + return count; + } +} diff --git a/tests/1001-1500/1079. letter-tile-possibilities/sol.go b/tests/1001-1500/1079. letter-tile-possibilities/sol.go new file mode 100644 index 00000000..b349f48e --- /dev/null +++ b/tests/1001-1500/1079. letter-tile-possibilities/sol.go @@ -0,0 +1,19 @@ +func numTilePossibilities(tiles string) int { + arr := []byte(tiles) + sort.Slice(arr, func(i, j int) bool { return arr[i] < arr[j] }) + used := make([]bool, len(arr)) + return backtrack(arr, used) +} + +func backtrack(tiles []byte, used []bool) int { + count := 0 + for i := 0; i < len(tiles); i++ { + if used[i] || (i > 0 && tiles[i] == tiles[i-1] && !used[i-1]) { + continue + } + used[i] = true + count += 1 + backtrack(tiles, used) + used[i] = false + } + return count +} diff --git a/tests/1001-1500/1079. letter-tile-possibilities/sol.java b/tests/1001-1500/1079. letter-tile-possibilities/sol.java new file mode 100644 index 00000000..01402a1c --- /dev/null +++ b/tests/1001-1500/1079. letter-tile-possibilities/sol.java @@ -0,0 +1,21 @@ +class Solution { + public int numTilePossibilities(String tiles) { + char[] arr = tiles.toCharArray(); + java.util.Arrays.sort(arr); + boolean[] used = new boolean[arr.length]; + return backtrack(arr, used); + } + + private int backtrack(char[] tiles, boolean[] used) { + int count = 0; + for (int i = 0; i < tiles.length; i++) { + if (used[i] || (i > 0 && tiles[i] == tiles[i - 1] && !used[i - 1])) { + continue; + } + used[i] = true; + count += 1 + backtrack(tiles, used); + used[i] = false; + } + return count; + } +} diff --git a/tests/1001-1500/1079. letter-tile-possibilities/sol.kt b/tests/1001-1500/1079. letter-tile-possibilities/sol.kt new file mode 100644 index 00000000..82c5f761 --- /dev/null +++ b/tests/1001-1500/1079. letter-tile-possibilities/sol.kt @@ -0,0 +1,20 @@ +class Solution { + fun numTilePossibilities(tiles: String): Int { + val arr = tiles.toCharArray().sorted() + val used = BooleanArray(arr.size) + return backtrack(arr, used) + } + + private fun backtrack(tiles: List, used: BooleanArray): Int { + var count = 0 + for (i in tiles.indices) { + if (used[i] || (i > 0 && tiles[i] == tiles[i - 1] && !used[i - 1])) { + continue + } + used[i] = true + count += 1 + backtrack(tiles, used) + used[i] = false + } + return count + } +} diff --git a/tests/1001-1500/1079. letter-tile-possibilities/sol.py b/tests/1001-1500/1079. letter-tile-possibilities/sol.py new file mode 100644 index 00000000..58ed2cf2 --- /dev/null +++ b/tests/1001-1500/1079. letter-tile-possibilities/sol.py @@ -0,0 +1,15 @@ +class Solution(object): + def numTilePossibilities(self, tiles): + tiles = sorted(tiles) + used = [False] * len(tiles) + return self.backtrack(tiles, used) + + def backtrack(self, tiles, used): + count = 0 + for i in range(len(tiles)): + if used[i] or (i > 0 and tiles[i] == tiles[i - 1] and not used[i - 1]): + continue + used[i] = True + count += 1 + self.backtrack(tiles, used) + used[i] = False + return count diff --git a/tests/1001-1500/1079. letter-tile-possibilities/sol.py2 b/tests/1001-1500/1079. letter-tile-possibilities/sol.py2 new file mode 100644 index 00000000..147c9931 --- /dev/null +++ b/tests/1001-1500/1079. letter-tile-possibilities/sol.py2 @@ -0,0 +1,19 @@ +class Solution(object): + def numTilePossibilities(self, tiles): + """ + :type tiles: str + :rtype: int + """ + tiles = sorted(tiles) + used = [False] * len(tiles) + return self.backtrack(tiles, used) + + def backtrack(self, tiles, used): + count = 0 + for i in range(len(tiles)): + if used[i] or (i > 0 and tiles[i] == tiles[i - 1] and not used[i - 1]): + continue + used[i] = True + count += 1 + self.backtrack(tiles, used) + used[i] = False + return count diff --git a/tests/1001-1500/1079. letter-tile-possibilities/sol.rb b/tests/1001-1500/1079. letter-tile-possibilities/sol.rb new file mode 100644 index 00000000..30a77579 --- /dev/null +++ b/tests/1001-1500/1079. letter-tile-possibilities/sol.rb @@ -0,0 +1,18 @@ +# @param {String} tiles +# @return {Integer} +def num_tile_possibilities(tiles) + tiles = tiles.chars.sort + used = Array.new(tiles.length, false) + backtrack(tiles, used) +end + +def backtrack(tiles, used) + count = 0 + (0...tiles.length).each do |i| + next if used[i] || (i > 0 && tiles[i] == tiles[i - 1] && !used[i - 1]) + used[i] = true + count += 1 + backtrack(tiles, used) + used[i] = false + end + count +end diff --git a/tests/1001-1500/1079. letter-tile-possibilities/sol.rs b/tests/1001-1500/1079. letter-tile-possibilities/sol.rs new file mode 100644 index 00000000..0a68d438 --- /dev/null +++ b/tests/1001-1500/1079. letter-tile-possibilities/sol.rs @@ -0,0 +1,21 @@ +impl Solution { + pub fn num_tile_possibilities(tiles: String) -> i32 { + let mut chars: Vec = tiles.chars().collect(); + chars.sort_unstable(); + let mut used = vec![false; chars.len()]; + Self::backtrack(&chars, &mut used) + } + + fn backtrack(tiles: &[char], used: &mut Vec) -> i32 { + let mut count = 0; + for i in 0..tiles.len() { + if used[i] || (i > 0 && tiles[i] == tiles[i - 1] && !used[i - 1]) { + continue; + } + used[i] = true; + count += 1 + Self::backtrack(tiles, used); + used[i] = false; + } + count + } +} diff --git a/tests/1001-1500/1079. letter-tile-possibilities/sol.swift b/tests/1001-1500/1079. letter-tile-possibilities/sol.swift new file mode 100644 index 00000000..08f88a3e --- /dev/null +++ b/tests/1001-1500/1079. letter-tile-possibilities/sol.swift @@ -0,0 +1,20 @@ +class Solution { + func numTilePossibilities(_ tiles: String) -> Int { + let arr = tiles.sorted() + var used = Array(repeating: false, count: arr.count) + return backtrack(Array(arr), &used) + } + + private func backtrack(_ tiles: [Character], _ used: inout [Bool]) -> Int { + var count = 0 + for i in 0.. 0 && tiles[i] == tiles[i - 1] && !used[i - 1]) { + continue + } + used[i] = true + count += 1 + backtrack(tiles, &used) + used[i] = false + } + return count + } +} diff --git a/tests/1001-1500/1079. letter-tile-possibilities/sol.ts b/tests/1001-1500/1079. letter-tile-possibilities/sol.ts new file mode 100644 index 00000000..b1386506 --- /dev/null +++ b/tests/1001-1500/1079. letter-tile-possibilities/sol.ts @@ -0,0 +1,18 @@ +function numTilePossibilities(tiles: string): number { + const arr = tiles.split("").sort(); + const used: boolean[] = new Array(arr.length).fill(false); + return backtrack(arr, used); +} + +function backtrack(tiles: string[], used: boolean[]): number { + let count = 0; + for (let i = 0; i < tiles.length; i++) { + if (used[i] || (i > 0 && tiles[i] === tiles[i - 1] && !used[i - 1])) { + continue; + } + used[i] = true; + count += 1 + backtrack(tiles, used); + used[i] = false; + } + return count; +} diff --git a/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/manifest.yaml b/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/manifest.yaml new file mode 100644 index 00000000..32dcab2b --- /dev/null +++ b/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/manifest.yaml @@ -0,0 +1,239 @@ +entry: + id: 1080 + title: insufficient-nodes-in-root-to-leaf-paths + params: + root: + type: tree_node + limit: + type: int + call: + cpp: "Solution().sufficientSubset({root}, {limit})" + rust: "Solution::sufficient_subset({root}, {limit})" + python3: "Solution().sufficientSubset({root}, {limit})" + python2: "Solution().sufficientSubset({root}, {limit})" + ruby: "sufficient_subset({root}, {limit})" + java: "new Solution().sufficientSubset({root}, {limit})" + csharp: "new Solution().SufficientSubset({root}, {limit})" + kotlin: "Solution().sufficientSubset({root}, {limit})" + go: "sufficientSubset({root}, {limit})" + dart: "Solution().sufficientSubset({root}, {limit})" + swift: "Solution().sufficientSubset({root}, {limit})" + typescript: "sufficientSubset({root}, {limit})" +judge: + type: "exact" +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().sufficientSubset(root, limit, {result})" + checker: | + class Checker: + def sufficientSubset(self, root, limit, result): + def normalize(node): + if node is None: + return None + if isinstance(node, list): + if not node: + return None + nodes = [None if x is None else TreeNode(x) for x in node] + kids = nodes[::-1] + root = kids.pop() + for item in nodes: + if item is not None: + if kids: + item.left = kids.pop() + if kids: + item.right = kids.pop() + return root + if isinstance(node, dict): + return TreeNode( + node.get("val", node.get("value")), + normalize(node.get("left")), + normalize(node.get("right")), + ) + return node + + def serialize(node): + if node is None: + return None + out = [] + queue = [node] + while queue: + cur = queue.pop(0) + if cur is None: + out.append(None) + else: + out.append(cur.val) + queue.append(cur.left) + queue.append(cur.right) + while out and out[-1] is None: + out.pop() + return out + + expected = normalize(root) + actual = normalize(result) + + def dfs(node, path_sum): + if not node: + return False + curr = path_sum + node.val + if not node.left and not node.right: + return curr >= limit + left_good = dfs(node.left, curr) + right_good = dfs(node.right, curr) + if not left_good: + node.left = None + if not right_good: + node.right = None + return left_good or right_good + + return serialize(expected if dfs(expected, 0) else None) == serialize(actual) +seed: 1080 +tests: + - name: t01 + in: + root: [1, 2, 3, 4, null, null, 7, 8, 9, null, null, 12, 13, null, 14] + limit: 1 + - name: t02 + in: + root: [5, 4, 8, 11, null, 17, 4, 7, 1, null, null, 5, 3] + limit: 22 + - name: t03 + in: + root: [1, 2, -3, -5, null, 4, null] + limit: -1 + - name: t04 + in: + root: [1] + limit: 2 + - name: t05 + in: + root: [1] + limit: 1 + - name: t06 + in: + root: [0] + limit: 0 + - name: t07 + in: + root: [0] + limit: 1 + - name: t08 + in: + root: [-5] + limit: -5 + - name: t09 + in: + root: [-5] + limit: -4 + - name: t10 + in: + root: [5, 4, 8] + limit: 10 + - name: t11 + in: + root: [5, 4, 8] + limit: 13 + - name: t12 + in: + root: [5, 4, 8, 1, 2, 3, 4] + limit: 10 + - name: t13 + in: + root: [5, 4, 8, 1, 2, 3, 4] + limit: 12 + - name: t14 + in: + root: [1, 2, 3, null, 4, null, 5] + limit: 8 + - name: t15 + in: + root: [1, 2, 3, null, 4, null, 5] + limit: 9 + - name: t16 + in: + root: [1, 2, 3, 4, null, 5, null] + limit: 7 + - name: t17 + in: + root: [1, 2, 3, 4, null, 5, null] + limit: 6 + - name: t18 + in: + root: [2, -1, -2] + limit: 0 + - name: t19 + in: + root: [2, -1, -2] + limit: 1 + - name: t20 + in: + root: [1, -2, -3, 1, 3, -2, null, -1] + limit: -1 + - name: t21 + in: + root: [1, -2, -3, 1, 3, -2, null, -1] + limit: 0 + - name: t22 + in: + root: [10, 5, 5, 4, 4, 4, 4] + limit: 19 + - name: t23 + in: + root: [10, 5, 5, 4, 4, 4, 4] + limit: 20 + - name: t24 + in: + root: [3, 1, 2, null, null, 1, 1] + limit: 5 + - name: t25 + in: + root: [3, 1, 2, null, null, 1, 1] + limit: 6 + - name: t26 + in: + root: + [7, 3, 4, 2, null, null, 5, 1, null, null, null, null, null, null, 6] + limit: 13 + - name: t27 + in: + root: + [7, 3, 4, 2, null, null, 5, 1, null, null, null, null, null, null, 6] + limit: 14 + - name: t28 + in: + root: [1, 1, 1, 1, 1, 1, 1] + limit: 4 + - name: t29 + in: + root: [1, 1, 1, 1, 1, 1, 1] + limit: 5 + - name: t30 + in: + root: [-1, -2, -3, -4, -5, -6, -7] + limit: -6 + - name: t31 + in: + root: [-1, -2, -3, -4, -5, -6, -7] + limit: -10 + - name: t32 + in: + root: [4, 9, 0, 5, 1, null, 6] + limit: 12 + - name: t33 + in: + root: [4, 9, 0, 5, 1, null, 6] + limit: 15 + - name: t34 + in: + root: [8, 4, 4, 4, null, null, 4] + limit: 16 + - name: t35 + in: + root: [8, 4, 4, 4, null, null, 4] + limit: 17 + - name: t36 + in: + root: [2, 2, 2, 2, 2, 2, 2] + limit: 6 diff --git a/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.cpp b/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.cpp new file mode 100644 index 00000000..d151d255 --- /dev/null +++ b/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.cpp @@ -0,0 +1,41 @@ +/** + * Definition for a binary tree node. + * struct TreeNode { + * int val; + * TreeNode *left; + * TreeNode *right; + * TreeNode() : val(0), left(nullptr), right(nullptr) {} + * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} + * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} + * }; + */ +class Solution { +public: + TreeNode* sufficientSubset(TreeNode* root, int limit) { + function dfs = [&](TreeNode* node, int pathSum) -> bool { + if (!node) { + return false; + } + + int curr = pathSum + node->val; + + if (!node->left && !node->right) { + return curr >= limit; + } + + bool leftGood = dfs(node->left, curr); + bool rightGood = dfs(node->right, curr); + + if (!leftGood) { + node->left = nullptr; + } + if (!rightGood) { + node->right = nullptr; + } + + return leftGood || rightGood; + }; + + return dfs(root, 0) ? root : nullptr; + } +}; diff --git a/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.cs b/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.cs new file mode 100644 index 00000000..efb49900 --- /dev/null +++ b/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.cs @@ -0,0 +1,42 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public int val; + * public TreeNode left; + * public TreeNode right; + * public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +public class Solution { + public TreeNode SufficientSubset(TreeNode root, int limit) { + bool Dfs(TreeNode node, int pathSum) { + if (node == null) { + return false; + } + + int curr = pathSum + node.val; + + if (node.left == null && node.right == null) { + return curr >= limit; + } + + bool leftGood = Dfs(node.left, curr); + bool rightGood = Dfs(node.right, curr); + + if (!leftGood) { + node.left = null; + } + if (!rightGood) { + node.right = null; + } + + return leftGood || rightGood; + } + + return Dfs(root, 0) ? root : null; + } +} diff --git a/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.dart b/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.dart new file mode 100644 index 00000000..d478f580 --- /dev/null +++ b/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.dart @@ -0,0 +1,38 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * int val; + * TreeNode? left; + * TreeNode? right; + * TreeNode([this.val = 0, this.left, this.right]); + * } + */ +class Solution { + TreeNode? sufficientSubset(TreeNode? root, int limit) { + bool dfs(TreeNode? node, int pathSum) { + if (node == null) { + return false; + } + + int curr = pathSum + node.val; + + if (node.left == null && node.right == null) { + return curr >= limit; + } + + bool leftGood = dfs(node.left, curr); + bool rightGood = dfs(node.right, curr); + + if (!leftGood) { + node.left = null; + } + if (!rightGood) { + node.right = null; + } + + return leftGood || rightGood; + } + + return dfs(root, 0) ? root : null; + } +} diff --git a/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.go b/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.go new file mode 100644 index 00000000..c691899b --- /dev/null +++ b/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.go @@ -0,0 +1,39 @@ +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +func sufficientSubset(root *TreeNode, limit int) *TreeNode { + var dfs func(*TreeNode, int) bool + dfs = func(node *TreeNode, pathSum int) bool { + if node == nil { + return false + } + + curr := pathSum + node.Val + + if node.Left == nil && node.Right == nil { + return curr >= limit + } + + leftGood := dfs(node.Left, curr) + rightGood := dfs(node.Right, curr) + + if !leftGood { + node.Left = nil + } + if !rightGood { + node.Right = nil + } + + return leftGood || rightGood + } + + if dfs(root, 0) { + return root + } + return nil +} diff --git a/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.java b/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.java new file mode 100644 index 00000000..6b6181eb --- /dev/null +++ b/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.java @@ -0,0 +1,44 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode() {} + * TreeNode(int val) { this.val = val; } + * TreeNode(int val, TreeNode left, TreeNode right) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +class Solution { + public TreeNode sufficientSubset(TreeNode root, int limit) { + return dfs(root, 0, limit) ? root : null; + } + + private boolean dfs(TreeNode node, int pathSum, int limit) { + if (node == null) { + return false; + } + + int curr = pathSum + node.val; + + if (node.left == null && node.right == null) { + return curr >= limit; + } + + boolean leftGood = dfs(node.left, curr, limit); + boolean rightGood = dfs(node.right, curr, limit); + + if (!leftGood) { + node.left = null; + } + if (!rightGood) { + node.right = null; + } + + return leftGood || rightGood; + } +} diff --git a/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.kt b/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.kt new file mode 100644 index 00000000..8ddbac9c --- /dev/null +++ b/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.kt @@ -0,0 +1,39 @@ +/** + * Example: + * var ti = TreeNode(5) + * var v = ti.`val` + * Definition for a binary tree node. + * class TreeNode(var `val`: Int) { + * var left: TreeNode? = null + * var right: TreeNode? = null + * } + */ +class Solution { + fun sufficientSubset(root: TreeNode?, limit: Int): TreeNode? { + fun dfs(node: TreeNode?, pathSum: Int): Boolean { + if (node == null) { + return false + } + + val curr = pathSum + node.`val` + + if (node.left == null && node.right == null) { + return curr >= limit + } + + val leftGood = dfs(node.left, curr) + val rightGood = dfs(node.right, curr) + + if (!leftGood) { + node.left = null + } + if (!rightGood) { + node.right = null + } + + return leftGood || rightGood + } + + return if (dfs(root, 0)) root else null + } +} diff --git a/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.py b/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.py new file mode 100644 index 00000000..e66e6631 --- /dev/null +++ b/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.py @@ -0,0 +1,31 @@ +# Definition for a binary tree node. +# class TreeNode: +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution: + def sufficientSubset( + self, root: Optional[TreeNode], limit: int + ) -> Optional[TreeNode]: + + def dfs(node, path_sum): + if not node: + return False + + curr = path_sum + node.val + + if not node.left and not node.right: + return curr >= limit + + left_good = dfs(node.left, curr) + right_good = dfs(node.right, curr) + + if not left_good: + node.left = None + if not right_good: + node.right = None + + return left_good or right_good + + return root if dfs(root, 0) else None diff --git a/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.py2 b/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.py2 new file mode 100644 index 00000000..59ab6d5e --- /dev/null +++ b/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.py2 @@ -0,0 +1,33 @@ +# Definition for a binary tree node. +# class TreeNode(object): +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution(object): + def sufficientSubset(self, root, limit): + """ + :type root: Optional[TreeNode] + :type limit: int + :rtype: Optional[TreeNode] + """ + def dfs(node, path_sum): + if not node: + return False + + curr = path_sum + node.val + + if not node.left and not node.right: + return curr >= limit + + left_good = dfs(node.left, curr) + right_good = dfs(node.right, curr) + + if not left_good: + node.left = None + if not right_good: + node.right = None + + return left_good or right_good + + return root if dfs(root, 0) else None diff --git a/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.rb b/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.rb new file mode 100644 index 00000000..e8eeaebc --- /dev/null +++ b/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.rb @@ -0,0 +1,33 @@ +# Definition for a binary tree node. +# class TreeNode +# attr_accessor :val, :left, :right +# def initialize(val = 0, left = nil, right = nil) +# @val = val +# @left = left +# @right = right +# end +# end +# @param {TreeNode} root +# @param {Integer} limit +# @return {TreeNode} +def sufficient_subset(root, limit) + dfs = lambda do |node, path_sum| + return false if node.nil? + + curr = path_sum + node.val + + if node.left.nil? && node.right.nil? + return curr >= limit + end + + left_good = dfs.call(node.left, curr) + right_good = dfs.call(node.right, curr) + + node.left = nil if !left_good + node.right = nil if !right_good + + left_good || right_good + end + + dfs.call(root, 0) ? root : nil +end diff --git a/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.rs b/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.rs new file mode 100644 index 00000000..2d3dd14f --- /dev/null +++ b/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.rs @@ -0,0 +1,52 @@ +// Definition for a binary tree node. +// #[derive(Debug, PartialEq, Eq)] +// pub struct TreeNode { +// pub val: i32, +// pub left: Option>>, +// pub right: Option>>, +// } +// +// impl TreeNode { +// #[inline] +// pub fn new(val: i32) -> Self { +// TreeNode { +// val, +// left: None, +// right: None +// } +// } +// } +impl Solution { + pub fn sufficient_subset(root: Option>>, limit: i32) -> Option>> { + fn dfs(node: &Option>>, path_sum: i32, limit: i32) -> bool { + if let Some(n) = node { + let mut n = n.borrow_mut(); + let curr = path_sum + n.val; + + if n.left.is_none() && n.right.is_none() { + return curr >= limit; + } + + let left_good = dfs(&n.left, curr, limit); + let right_good = dfs(&n.right, curr, limit); + + if !left_good { + n.left = None; + } + if !right_good { + n.right = None; + } + + left_good || right_good + } else { + false + } + } + + if dfs(&root, 0, limit) { + root + } else { + None + } + } +} diff --git a/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.swift b/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.swift new file mode 100644 index 00000000..7a1a53da --- /dev/null +++ b/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.swift @@ -0,0 +1,20 @@ +class Solution { + func sufficientSubset(_ root: TreeNode?, _ limit: Int) -> TreeNode? { + func retain(_ node: TreeNode?, _ sum: Int) -> Bool { + guard let node = node else { return false } + let current = sum + node.val + + if node.left == nil && node.right == nil { + return current >= limit + } + + let keepLeft = retain(node.left, current) + let keepRight = retain(node.right, current) + if !keepLeft { node.left = nil } + if !keepRight { node.right = nil } + return keepLeft || keepRight + } + + return retain(root, 0) ? root : nil + } +} diff --git a/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.ts b/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.ts new file mode 100644 index 00000000..c12f1253 --- /dev/null +++ b/tests/1001-1500/1080. insufficient-nodes-in-root-to-leaf-paths/sol.ts @@ -0,0 +1,44 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ + +function sufficientSubset( + root: TreeNode | null, + limit: number, +): TreeNode | null { + const dfs = (node: TreeNode | null, pathSum: number): boolean => { + if (node === null) { + return false; + } + + const curr = pathSum + node.val; + + if (node.left === null && node.right === null) { + return curr >= limit; + } + + const leftGood = dfs(node.left, curr); + const rightGood = dfs(node.right, curr); + + if (!leftGood) { + node.left = null; + } + if (!rightGood) { + node.right = null; + } + + return leftGood || rightGood; + }; + + return dfs(root, 0) ? root : null; +} diff --git a/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/manifest.yaml b/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/manifest.yaml new file mode 100644 index 00000000..feb249d9 --- /dev/null +++ b/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/manifest.yaml @@ -0,0 +1,185 @@ +entry: + id: 1081 + title: smallest-subsequence-of-distinct-characters + params: + s: + type: string + call: + cpp: "Solution().smallestSubsequence({s})" + rust: "Solution::smallest_subsequence({s})" + python3: "Solution().smallestSubsequence({s})" + python2: "Solution().smallestSubsequence({s})" + ruby: "smallest_subsequence({s})" + java: "new Solution().smallestSubsequence({s})" + csharp: "new Solution().SmallestSubsequence({s})" + kotlin: "Solution().smallestSubsequence({s})" + go: "smallestSubsequence({s})" + dart: "Solution().smallestSubsequence({s})" + swift: "Solution().smallestSubsequence({s})" + typescript: "smallestSubsequence({s})" +judge: + type: "exact" +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().smallestSubsequence(s, {result})" + checker: | + class Checker: + def smallestSubsequence(self, s, result): + last = {} + for i, ch in enumerate(s): + last[ch] = i + stack = [] + seen = set() + for i, ch in enumerate(s): + if ch in seen: + continue + while stack and stack[-1] > ch and last[stack[-1]] > i: + seen.remove(stack.pop()) + stack.append(ch) + seen.add(ch) + return "".join(stack) == result +seed: 1081 +tests: + - name: t01 + in: + s: "bcabc" + out: "abc" + - name: t02 + in: + s: "cbacdcbc" + out: "acdb" + - name: t03 + in: + s: "cdadabcc" + out: "adbc" + - name: t04 + in: + s: "abcd" + out: "abcd" + - name: t05 + in: + s: "ecbacba" + out: "eacb" + - name: t06 + in: + s: "leetcode" + out: "letcod" + - name: t07 + in: + s: "bcbcbcababa" + out: "bca" + - name: t08 + in: + s: "aaaaaaaaaa" + out: "a" + - name: t09 + in: + s: "aaaaaaaaaaaaaaaaaaaa" + out: "a" + - name: t10 + in: + s: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + out: "a" + - name: t11 + in: + s: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + out: "a" + - name: t12 + in: + s: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + out: "a" + - name: t13 + in: + s: "aaaabbaabb" + out: "ab" + - name: t14 + in: + s: "bababababbbababbbbbb" + out: "ab" + - name: t15 + in: + s: "baababaaaaababbbbbbaababaababa" + out: "ab" + - name: t16 + in: + s: "bbbbaaaababaaabbbabbabaabaabbabaaaababbb" + out: "ab" + - name: t17 + in: + s: "abaabbbabaababbabbaabbaaaaaaaaaabbaabbaabbababbbba" + out: "ab" + - name: t18 + in: + s: "accaccbbcc" + out: "abc" + - name: t19 + in: + s: "cbaacabcaaccaacababa" + out: "abc" + - name: t20 + in: + s: "baabcccbacabcbcaaaabbcbacabccb" + out: "abc" + - name: t21 + in: + s: "aabacaaababbcabcbacabcbcbbaabcaaaaabaacc" + out: "abc" + - name: t22 + in: + s: "acbbcbacccbcbbaaaabaccbbabacaccbacaababaacbccbabbc" + out: "abc" + - name: t23 + in: + s: "bdaccdbddc" + out: "abdc" + - name: t24 + in: + s: "babddbddaddcdaacdccc" + out: "abcd" + - name: t25 + in: + s: "abdaddcdbdbadcaddbcddaaccdcdca" + out: "abcd" + - name: t26 + in: + s: "dbbbabadcdcbdaddddbbcbdaaadbdaadcaaabbab" + out: "abcd" + - name: t27 + in: + s: "dcccbddaaaaddcdadcbcbccbcabddacadcababcccabbbcabdb" + out: "abcd" + - name: t28 + in: + s: "ddeeeccdce" + out: "cde" + - name: t29 + in: + s: "adaabbcacdbabaeabebc" + out: "abcde" + - name: t30 + in: + s: "bccddeacacaceabcbbbbdbebbbaaaa" + out: "abcde" + - name: t31 + in: + s: "dbdcbcbeecbbdcdebadbcecccdbaabaeeacbbcab" + out: "abcde" + - name: t32 + in: + s: "ccbbdceaebbbbcecabaaabadaebebbaacadeacabcadabcacde" + out: "abcde" + - name: t33 + in: + s: "babcdbdefbcbfadcaaccedccdfaafbdafeeddaceacafabfcff" + out: "abcdef" + - name: t34 + in: + s: "bdfecedcbfcfeaaffdbaeeabadbbbddddcafdfeeeebfcdabcfaadecddccdefcabedbebbdcbdfefeffcbbeaefaeefeeceadea" + out: "abcdef" + - name: t35 + in: + s: "aaeeeceabbfdaefdeefbabaabbdbaadbebfaabfadcaacddebfdbeaceffaaadcaeddbadebdebccbcbccefeaffbfdcdaefeefeffefcfbbbdabdbddcaaeaacecefbbbeaacdafdfbcdfcbedaff" + out: "abcdef" diff --git a/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.cpp b/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.cpp new file mode 100644 index 00000000..ce7d6038 --- /dev/null +++ b/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.cpp @@ -0,0 +1,24 @@ +class Solution { +public: + string smallestSubsequence(string s) { + unordered_map fqMap; + vector stack; + unordered_set visited; + for (char ch : s) { + fqMap[ch]++; + } + for (char ch : s) { + fqMap[ch]--; + if (visited.count(ch)) { + continue; + } + while (!stack.empty() && ch < stack.back() && fqMap[stack.back()] > 0) { + visited.erase(stack.back()); + stack.pop_back(); + } + visited.insert(ch); + stack.push_back(ch); + } + return string(stack.begin(), stack.end()); + } +}; diff --git a/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.cs b/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.cs new file mode 100644 index 00000000..70740215 --- /dev/null +++ b/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.cs @@ -0,0 +1,28 @@ +public class Solution { + public string SmallestSubsequence(string s) { + Dictionary fqMap = new Dictionary(); + Stack stack = new Stack(); + HashSet visited = new HashSet(); + foreach (char ch in s) { + if (fqMap.ContainsKey(ch)) { + fqMap[ch]++; + } else { + fqMap[ch] = 1; + } + } + foreach (char ch in s) { + fqMap[ch]--; + if (visited.Contains(ch)) { + continue; + } + while (stack.Count > 0 && ch < stack.Peek() && fqMap[stack.Peek()] > 0) { + visited.Remove(stack.Pop()); + } + visited.Add(ch); + stack.Push(ch); + } + char[] result = stack.ToArray(); + Array.Reverse(result); + return new string(result); + } +} diff --git a/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.dart b/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.dart new file mode 100644 index 00000000..7b508960 --- /dev/null +++ b/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.dart @@ -0,0 +1,22 @@ +class Solution { + String smallestSubsequence(String s) { + Map fqMap = {}; + List stack = []; + Set visited = {}; + for (var ch in s.split('')) { + fqMap[ch] = (fqMap[ch] ?? 0) + 1; + } + for (var ch in s.split('')) { + fqMap[ch] = fqMap[ch]! - 1; + if (visited.contains(ch)) { + continue; + } + while (stack.isNotEmpty && ch.compareTo(stack.last) < 0 && fqMap[stack.last]! > 0) { + visited.remove(stack.removeLast()); + } + visited.add(ch); + stack.add(ch); + } + return stack.join(); + } +} diff --git a/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.go b/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.go new file mode 100644 index 00000000..ffd1259f --- /dev/null +++ b/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.go @@ -0,0 +1,21 @@ +func smallestSubsequence(s string) string { + fqMap := make(map[rune]int) + stack := []rune{} + visited := make(map[rune]bool) + for _, ch := range s { + fqMap[ch]++ + } + for _, ch := range s { + fqMap[ch]-- + if visited[ch] { + continue + } + for len(stack) > 0 && ch < stack[len(stack)-1] && fqMap[stack[len(stack)-1]] > 0 { + visited[stack[len(stack)-1]] = false + stack = stack[:len(stack)-1] + } + visited[ch] = true + stack = append(stack, ch) + } + return string(stack) +} diff --git a/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.java b/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.java new file mode 100644 index 00000000..65d01dfb --- /dev/null +++ b/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.java @@ -0,0 +1,26 @@ +class Solution { + public String smallestSubsequence(String s) { + java.util.Map fqMap = new java.util.HashMap<>(); + java.util.Stack stack = new java.util.Stack<>(); + java.util.Set visited = new java.util.HashSet<>(); + for (char ch : s.toCharArray()) { + fqMap.put(ch, fqMap.getOrDefault(ch, 0) + 1); + } + for (char ch : s.toCharArray()) { + fqMap.put(ch, fqMap.get(ch) - 1); + if (visited.contains(ch)) { + continue; + } + while (!stack.isEmpty() && ch < stack.peek() && fqMap.get(stack.peek()) > 0) { + visited.remove(stack.pop()); + } + visited.add(ch); + stack.push(ch); + } + StringBuilder sb = new StringBuilder(); + for (char ch : stack) { + sb.append(ch); + } + return sb.toString(); + } +} diff --git a/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.kt b/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.kt new file mode 100644 index 00000000..8b526f26 --- /dev/null +++ b/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.kt @@ -0,0 +1,22 @@ +class Solution { + fun smallestSubsequence(s: String): String { + val fqMap = mutableMapOf() + val stack = mutableListOf() + val visited = mutableSetOf() + for (ch in s) { + fqMap[ch] = fqMap.getOrDefault(ch, 0) + 1 + } + for (ch in s) { + fqMap[ch] = fqMap[ch]!! - 1 + if (visited.contains(ch)) { + continue + } + while (stack.isNotEmpty() && ch < stack.last() && fqMap[stack.last()]!! > 0) { + visited.remove(stack.removeAt(stack.size - 1)) + } + visited.add(ch) + stack.add(ch) + } + return stack.joinToString("") + } +} diff --git a/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.py b/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.py new file mode 100644 index 00000000..ed3cc4fe --- /dev/null +++ b/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.py @@ -0,0 +1,16 @@ +class Solution: + def smallestSubsequence(self, s: str) -> str: + fqMap = {} + stack = [] + visited = set() + for ch in s: + fqMap[ch] = fqMap.get(ch, 0) + 1 + for ch in s: + fqMap[ch] -= 1 + if ch in visited: + continue + while stack and ch < stack[-1] and fqMap[stack[-1]] > 0: + visited.remove(stack.pop()) + visited.add(ch) + stack.append(ch) + return "".join(stack) diff --git a/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.py2 b/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.py2 new file mode 100644 index 00000000..299adff7 --- /dev/null +++ b/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.py2 @@ -0,0 +1,20 @@ +class Solution(object): + def smallestSubsequence(self, s): + """ + :type s: str + :rtype: str + """ + fqMap = {} + stack = [] + visited = set() + for ch in s: + fqMap[ch] = fqMap.get(ch, 0) + 1 + for ch in s: + fqMap[ch] -= 1 + if ch in visited: + continue + while stack and ch < stack[-1] and fqMap[stack[-1]] > 0: + visited.remove(stack.pop()) + visited.add(ch) + stack.append(ch) + return ''.join(stack) diff --git a/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.rb b/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.rb new file mode 100644 index 00000000..435e22f0 --- /dev/null +++ b/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.rb @@ -0,0 +1,18 @@ +# @param {String} s +# @return {String} +def smallest_subsequence(s) + fq_map = {} + stack = [] + visited = Set.new + s.each_char { |ch| fq_map[ch] = (fq_map[ch] or 0) + 1 } + s.each_char do |ch| + fq_map[ch] -= 1 + next if visited.include?(ch) + while !stack.empty? && ch < stack.last && fq_map[stack.last] > 0 + visited.delete(stack.pop) + end + visited.add(ch) + stack.push(ch) + end + stack.join +end diff --git a/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.rs b/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.rs new file mode 100644 index 00000000..ce168cff --- /dev/null +++ b/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.rs @@ -0,0 +1,27 @@ +impl Solution { + pub fn smallest_subsequence(s: String) -> String { + use std::collections::{HashMap, HashSet}; + let mut fq_map: HashMap = HashMap::new(); + let mut stack: Vec = Vec::new(); + let mut visited: HashSet = HashSet::new(); + for ch in s.chars() { + *fq_map.entry(ch).or_insert(0) += 1; + } + for ch in s.chars() { + *fq_map.get_mut(&ch).unwrap() -= 1; + if visited.contains(&ch) { + continue; + } + while let Some(&top) = stack.last() { + if ch < top && *fq_map.get(&top).unwrap() > 0 { + visited.remove(&stack.pop().unwrap()); + } else { + break; + } + } + visited.insert(ch); + stack.push(ch); + } + stack.iter().collect() + } +} diff --git a/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.swift b/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.swift new file mode 100644 index 00000000..f7142fa6 --- /dev/null +++ b/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.swift @@ -0,0 +1,22 @@ +class Solution { + func smallestSubsequence(_ s: String) -> String { + var fqMap = [Character: Int]() + var stack = [Character]() + var visited = Set() + for ch in s { + fqMap[ch, default: 0] += 1 + } + for ch in s { + fqMap[ch]! -= 1 + if visited.contains(ch) { + continue + } + while !stack.isEmpty, ch < stack.last!, fqMap[stack.last!]! > 0 { + visited.remove(stack.removeLast()) + } + visited.insert(ch) + stack.append(ch) + } + return String(stack) + } +} diff --git a/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.ts b/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.ts new file mode 100644 index 00000000..ad674f5b --- /dev/null +++ b/tests/1001-1500/1081. smallest-subsequence-of-distinct-characters/sol.ts @@ -0,0 +1,24 @@ +function smallestSubsequence(s: string): string { + const fqMap: { [key: string]: number } = {}; + const stack: string[] = []; + const visited = new Set(); + for (const ch of s) { + fqMap[ch] = (fqMap[ch] || 0) + 1; + } + for (const ch of s) { + fqMap[ch]--; + if (visited.has(ch)) { + continue; + } + while ( + stack.length > 0 && + ch < stack[stack.length - 1] && + fqMap[stack[stack.length - 1]] > 0 + ) { + visited.delete(stack.pop()!); + } + visited.add(ch); + stack.push(ch); + } + return stack.join(""); +} diff --git a/tests/1001-1500/1090. largest-values-from-labels/manifest.yaml b/tests/1001-1500/1090. largest-values-from-labels/manifest.yaml new file mode 100644 index 00000000..d21bad85 --- /dev/null +++ b/tests/1001-1500/1090. largest-values-from-labels/manifest.yaml @@ -0,0 +1,305 @@ +entry: + id: 1090 + title: largest-values-from-labels + params: + values: + type: array + items: + type: int + labels: + type: array + items: + type: int + numWanted: + type: int + useLimit: + type: int + call: + cpp: "Solution().largestValsFromLabels({values}, {labels}, {numWanted}, {useLimit})" + rust: "Solution::largest_vals_from_labels({values}, {labels}, {numWanted}, {useLimit})" + python3: "Solution().largestValsFromLabels({values}, {labels}, {numWanted}, {useLimit})" + python2: "Solution().largestValsFromLabels({values}, {labels}, {numWanted}, {useLimit})" + ruby: "largest_vals_from_labels({values}, {labels}, {numWanted}, {useLimit})" + java: "new Solution().largestValsFromLabels({values}, {labels}, {numWanted}, {useLimit})" + csharp: "new Solution().LargestValsFromLabels({values}, {labels}, {numWanted}, {useLimit})" + kotlin: "Solution().largestValsFromLabels({values}, {labels}, {numWanted}, {useLimit})" + go: "largestValsFromLabels({values}, {labels}, {numWanted}, {useLimit})" + dart: "Solution().largestValsFromLabels({values}, {labels}, {numWanted}, {useLimit})" + swift: "Solution().largestValsFromLabels({values}, {labels}, {numWanted}, {useLimit})" + typescript: "largestValsFromLabels({values}, {labels}, {numWanted}, {useLimit})" +judge: + type: "exact" +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().largestValsFromLabels(values, labels, numWanted, useLimit, {result})" + checker: | + class Checker: + def largestValsFromLabels(self, values, labels, numWanted, useLimit, result): + pairs = sorted(zip(values, labels), reverse=True) + res = 0 + freq = {} + for value, label in pairs: + if numWanted == 0: + break + if freq.get(label, 0) < useLimit: + res += value + freq[label] = freq.get(label, 0) + 1 + numWanted -= 1 + return res == result +seed: 1090 +tests: + - name: t01 + in: + values: [5, 4, 3, 2, 1] + labels: [1, 1, 2, 2, 3] + numWanted: 3 + useLimit: 1 + out: 9 + - name: t02 + in: + values: [5, 4, 3, 2, 1] + labels: [1, 3, 3, 3, 2] + numWanted: 3 + useLimit: 2 + out: 12 + - name: t03 + in: + values: [9, 8, 8, 7, 6] + labels: [0, 0, 0, 1, 1] + numWanted: 3 + useLimit: 1 + out: 16 + - name: t04 + in: + values: [1] + labels: [1] + numWanted: 1 + useLimit: 1 + out: 1 + - name: t05 + in: + values: [10] + labels: [0] + numWanted: 1 + useLimit: 1 + out: 10 + - name: t06 + in: + values: [10, 9] + labels: [0, 0] + numWanted: 1 + useLimit: 1 + out: 10 + - name: t07 + in: + values: [10, 9] + labels: [0, 0] + numWanted: 2 + useLimit: 1 + out: 10 + - name: t08 + in: + values: [10, 9] + labels: [0, 1] + numWanted: 1 + useLimit: 1 + out: 10 + - name: t09 + in: + values: [10, 9] + labels: [0, 1] + numWanted: 2 + useLimit: 1 + out: 19 + - name: t10 + in: + values: [5, 5, 5] + labels: [1, 1, 1] + numWanted: 2 + useLimit: 1 + out: 5 + - name: t11 + in: + values: [5, 5, 5] + labels: [1, 2, 3] + numWanted: 2 + useLimit: 1 + out: 10 + - name: t12 + in: + values: [8, 7, 6, 5] + labels: [1, 1, 2, 2] + numWanted: 3 + useLimit: 1 + out: 14 + - name: t13 + in: + values: [8, 7, 6, 5] + labels: [1, 1, 2, 2] + numWanted: 3 + useLimit: 2 + out: 21 + - name: t14 + in: + values: [100, 1, 1, 1] + labels: [5, 5, 5, 5] + numWanted: 2 + useLimit: 1 + out: 100 + - name: t15 + in: + values: [100, 1, 1, 1] + labels: [5, 6, 7, 8] + numWanted: 2 + useLimit: 1 + out: 101 + - name: t16 + in: + values: [4, 3, 2, 1] + labels: [1, 1, 1, 1] + numWanted: 3 + useLimit: 2 + out: 7 + - name: t17 + in: + values: [4, 3, 2, 1] + labels: [1, 2, 1, 2] + numWanted: 3 + useLimit: 1 + out: 7 + - name: t18 + in: + values: [7, 6, 5, 4, 3, 2, 1] + labels: [1, 2, 3, 4, 5, 6, 7] + numWanted: 4 + useLimit: 1 + out: 22 + - name: t19 + in: + values: [7, 6, 5, 4, 3, 2, 1] + labels: [1, 2, 3, 1, 2, 3, 1] + numWanted: 4 + useLimit: 2 + out: 22 + - name: t20 + in: + values: [2, 2, 2, 2, 2] + labels: [1, 2, 3, 4, 5] + numWanted: 3 + useLimit: 2 + out: 6 + - name: t21 + in: + values: [2, 2, 2, 2, 2] + labels: [1, 1, 1, 1, 1] + numWanted: 3 + useLimit: 1 + out: 2 + - name: t22 + in: + values: [20, 19, 18, 17, 16, 15] + labels: [9, 9, 8, 8, 7, 7] + numWanted: 4 + useLimit: 1 + out: 54 + - name: t23 + in: + values: [20, 19, 18, 17, 16, 15] + labels: [9, 8, 7, 6, 5, 4] + numWanted: 4 + useLimit: 2 + out: 74 + - name: t24 + in: + values: [1, 2, 3, 4, 5, 6] + labels: [1, 1, 2, 2, 3, 3] + numWanted: 5 + useLimit: 1 + out: 12 + - name: t25 + in: + values: [1, 2, 3, 4, 5, 6] + labels: [1, 1, 2, 2, 3, 3] + numWanted: 2 + useLimit: 2 + out: 11 + - name: t26 + in: + values: [11, 10, 9, 8, 7] + labels: [0, 1, 0, 1, 0] + numWanted: 3 + useLimit: 1 + out: 21 + - name: t27 + in: + values: [11, 10, 9, 8, 7] + labels: [0, 1, 0, 1, 0] + numWanted: 5 + useLimit: 2 + out: 38 + - name: t28 + in: + values: [9, 9, 9, 8, 8, 8] + labels: [1, 1, 2, 2, 3, 3] + numWanted: 4 + useLimit: 1 + out: 26 + - name: t29 + in: + values: [9, 9, 9, 8, 8, 8] + labels: [1, 2, 3, 1, 2, 3] + numWanted: 4 + useLimit: 2 + out: 35 + - name: t30 + in: + values: [6, 5, 4, 3, 2, 1] + labels: [1, 1, 1, 2, 2, 2] + numWanted: 2 + useLimit: 1 + out: 9 + - name: t31 + in: + values: [6, 5, 4, 3, 2, 1] + labels: [1, 1, 1, 2, 2, 2] + numWanted: 4 + useLimit: 2 + out: 16 + - name: t32 + in: + values: [50, 40, 30, 20, 10] + labels: [4, 4, 4, 5, 5] + numWanted: 3 + useLimit: 2 + out: 110 + - name: t33 + in: + values: [50, 40, 30, 20, 10] + labels: [4, 4, 5, 5, 6] + numWanted: 3 + useLimit: 1 + out: 90 + - name: t34 + in: + values: [3, 1, 2, 4, 5] + labels: [0, 1, 0, 1, 0] + numWanted: 2 + useLimit: 1 + out: 9 + - name: t35 + in: + values: [3, 1, 2, 4, 5] + labels: [0, 1, 0, 1, 0] + numWanted: 4 + useLimit: 2 + out: 13 + - name: t36 + in: + values: [100, 99, 98, 97, 96, 95, 94] + labels: [1, 1, 2, 2, 3, 3, 4] + numWanted: 5 + useLimit: 1 + out: 388 diff --git a/tests/1001-1500/1090. largest-values-from-labels/sol.cpp b/tests/1001-1500/1090. largest-values-from-labels/sol.cpp new file mode 100644 index 00000000..ebd0367d --- /dev/null +++ b/tests/1001-1500/1090. largest-values-from-labels/sol.cpp @@ -0,0 +1,24 @@ +class Solution { +public: + int largestValsFromLabels(vector& values, vector& labels, int numWanted, int useLimit) { + int n = values.size(); + vector> pairs; + for (int i = 0; i < n; i++) { + pairs.push_back({values[i], labels[i]}); + } + sort(pairs.begin(), pairs.end(), [](const pair& a, const pair& b) { + return a.first > b.first; + }); + int res = 0; + unordered_map freq; + for (auto& [value, label] : pairs) { + if (numWanted == 0) break; + if (freq.find(label) == freq.end() || freq[label] < useLimit) { + res += value; + freq[label]++; + numWanted--; + } + } + return res; + } +}; diff --git a/tests/1001-1500/1090. largest-values-from-labels/sol.cs b/tests/1001-1500/1090. largest-values-from-labels/sol.cs new file mode 100644 index 00000000..134ea8c8 --- /dev/null +++ b/tests/1001-1500/1090. largest-values-from-labels/sol.cs @@ -0,0 +1,24 @@ +public class Solution { + public int LargestValsFromLabels(int[] values, int[] labels, int numWanted, int useLimit) { + int n = values.Length; + int[][] pairs = new int[n][]; + for (int i = 0; i < n; i++) { + pairs[i] = new int[] { values[i], labels[i] }; + } + System.Array.Sort(pairs, (a, b) => b[0].CompareTo(a[0])); + int res = 0; + Dictionary freq = new Dictionary(); + foreach (int[] pair in pairs) { + if (numWanted == 0) break; + int value = pair[0]; + int label = pair[1]; + if (!freq.ContainsKey(label) || freq[label] < useLimit) { + res += value; + if (freq.ContainsKey(label)) freq[label]++; + else freq[label] = 1; + numWanted--; + } + } + return res; + } +} diff --git a/tests/1001-1500/1090. largest-values-from-labels/sol.dart b/tests/1001-1500/1090. largest-values-from-labels/sol.dart new file mode 100644 index 00000000..af5e9a44 --- /dev/null +++ b/tests/1001-1500/1090. largest-values-from-labels/sol.dart @@ -0,0 +1,23 @@ +class Solution { + int largestValsFromLabels(List values, List labels, int numWanted, int useLimit) { + int n = values.length; + List> pairs = []; + for (int i = 0; i < n; i++) { + pairs.add([values[i], labels[i]]); + } + pairs.sort((a, b) => b[0].compareTo(a[0])); + int res = 0; + Map freq = {}; + for (var pair in pairs) { + if (numWanted == 0) break; + int value = pair[0]; + int label = pair[1]; + if (!freq.containsKey(label) || freq[label]! < useLimit) { + res += value; + freq[label] = (freq[label] ?? 0) + 1; + numWanted--; + } + } + return res; + } +} diff --git a/tests/1001-1500/1090. largest-values-from-labels/sol.go b/tests/1001-1500/1090. largest-values-from-labels/sol.go new file mode 100644 index 00000000..936b8285 --- /dev/null +++ b/tests/1001-1500/1090. largest-values-from-labels/sol.go @@ -0,0 +1,25 @@ +func largestValsFromLabels(values []int, labels []int, numWanted int, useLimit int) int { + n := len(values) + pairs := make([][2]int, n) + for i := 0; i < n; i++ { + pairs[i] = [2]int{values[i], labels[i]} + } + sort.Slice(pairs, func(i, j int) bool { + return pairs[i][0] > pairs[j][0] + }) + res := 0 + freq := make(map[int]int) + for _, pair := range pairs { + if numWanted == 0 { + break + } + value := pair[0] + label := pair[1] + if freq[label] < useLimit { + res += value + freq[label]++ + numWanted-- + } + } + return res +} diff --git a/tests/1001-1500/1090. largest-values-from-labels/sol.java b/tests/1001-1500/1090. largest-values-from-labels/sol.java new file mode 100644 index 00000000..2263cc51 --- /dev/null +++ b/tests/1001-1500/1090. largest-values-from-labels/sol.java @@ -0,0 +1,24 @@ +class Solution { + public int largestValsFromLabels(int[] values, int[] labels, int numWanted, int useLimit) { + int n = values.length; + int[][] pairs = new int[n][2]; + for (int i = 0; i < n; i++) { + pairs[i][0] = values[i]; + pairs[i][1] = labels[i]; + } + java.util.Arrays.sort(pairs, (a, b) -> Integer.compare(b[0], a[0])); + int res = 0; + java.util.Map freq = new java.util.HashMap<>(); + for (int[] pair : pairs) { + if (numWanted == 0) break; + int value = pair[0]; + int label = pair[1]; + if (!freq.containsKey(label) || freq.get(label) < useLimit) { + res += value; + freq.put(label, freq.getOrDefault(label, 0) + 1); + numWanted--; + } + } + return res; + } +} diff --git a/tests/1001-1500/1090. largest-values-from-labels/sol.kt b/tests/1001-1500/1090. largest-values-from-labels/sol.kt new file mode 100644 index 00000000..a262c43b --- /dev/null +++ b/tests/1001-1500/1090. largest-values-from-labels/sol.kt @@ -0,0 +1,21 @@ +class Solution { + fun largestValsFromLabels(values: IntArray, labels: IntArray, numWanted: Int, useLimit: Int): Int { + val n = values.size + val pairs = Array(n) { intArrayOf(values[it], labels[it]) } + pairs.sortByDescending { it[0] } + var res = 0 + var wanted = numWanted + val freq = mutableMapOf() + for (pair in pairs) { + if (wanted == 0) break + val value = pair[0] + val label = pair[1] + if (!freq.containsKey(label) || freq[label]!! < useLimit) { + res += value + freq[label] = freq.getOrDefault(label, 0) + 1 + wanted-- + } + } + return res + } +} diff --git a/tests/1001-1500/1090. largest-values-from-labels/sol.py b/tests/1001-1500/1090. largest-values-from-labels/sol.py new file mode 100644 index 00000000..2204b97d --- /dev/null +++ b/tests/1001-1500/1090. largest-values-from-labels/sol.py @@ -0,0 +1,17 @@ +class Solution: + def largestValsFromLabels( + self, values: List[int], labels: List[int], numWanted: int, useLimit: int + ) -> int: + n = len(values) + pairs = [(values[i], labels[i]) for i in range(n)] + pairs.sort(key=lambda x: x[0], reverse=True) + res = 0 + freq = {} + for value, label in pairs: + if numWanted == 0: + break + if label not in freq or freq[label] < useLimit: + res += value + freq[label] = freq.get(label, 0) + 1 + numWanted -= 1 + return res diff --git a/tests/1001-1500/1090. largest-values-from-labels/sol.py2 b/tests/1001-1500/1090. largest-values-from-labels/sol.py2 new file mode 100644 index 00000000..1e77cb52 --- /dev/null +++ b/tests/1001-1500/1090. largest-values-from-labels/sol.py2 @@ -0,0 +1,22 @@ +class Solution(object): + def largestValsFromLabels(self, values, labels, numWanted, useLimit): + """ + :type values: List[int] + :type labels: List[int] + :type numWanted: int + :type useLimit: int + :rtype: int + """ + n = len(values) + pairs = [(values[i], labels[i]) for i in range(n)] + pairs.sort(key=lambda x: x[0], reverse=True) + res = 0 + freq = {} + for value, label in pairs: + if numWanted == 0: + break + if label not in freq or freq[label] < useLimit: + res += value + freq[label] = freq.get(label, 0) + 1 + numWanted -= 1 + return res diff --git a/tests/1001-1500/1090. largest-values-from-labels/sol.rb b/tests/1001-1500/1090. largest-values-from-labels/sol.rb new file mode 100644 index 00000000..b35d80bf --- /dev/null +++ b/tests/1001-1500/1090. largest-values-from-labels/sol.rb @@ -0,0 +1,21 @@ +# @param {Integer[]} values +# @param {Integer[]} labels +# @param {Integer} num_wanted +# @param {Integer} use_limit +# @return {Integer} +def largest_vals_from_labels(values, labels, num_wanted, use_limit) + n = values.length + pairs = (0...n).map { |i| [values[i], labels[i]] } + pairs.sort_by! { |x| -x[0] } + res = 0 + freq = {} + pairs.each do |value, label| + break if num_wanted == 0 + if !freq.key?(label) || freq[label] < use_limit + res += value + freq[label] = (freq[label] || 0) + 1 + num_wanted -= 1 + end + end + res +end diff --git a/tests/1001-1500/1090. largest-values-from-labels/sol.rs b/tests/1001-1500/1090. largest-values-from-labels/sol.rs new file mode 100644 index 00000000..8136b1bf --- /dev/null +++ b/tests/1001-1500/1090. largest-values-from-labels/sol.rs @@ -0,0 +1,22 @@ +impl Solution { + pub fn largest_vals_from_labels(values: Vec, labels: Vec, num_wanted: i32, use_limit: i32) -> i32 { + let n = values.len(); + let mut pairs: Vec<(i32, i32)> = (0..n).map(|i| (values[i], labels[i])).collect(); + pairs.sort_by(|a, b| b.0.cmp(&a.0)); + let mut res = 0; + let mut freq = std::collections::HashMap::new(); + let mut wanted = num_wanted; + for (value, label) in pairs { + if wanted == 0 { + break; + } + let count = freq.entry(label).or_insert(0); + if *count < use_limit { + res += value; + *count += 1; + wanted -= 1; + } + } + res + } +} diff --git a/tests/1001-1500/1090. largest-values-from-labels/sol.swift b/tests/1001-1500/1090. largest-values-from-labels/sol.swift new file mode 100644 index 00000000..001d3a51 --- /dev/null +++ b/tests/1001-1500/1090. largest-values-from-labels/sol.swift @@ -0,0 +1,22 @@ +class Solution { + func largestValsFromLabels(_ values: [Int], _ labels: [Int], _ numWanted: Int, _ useLimit: Int) -> Int { + let n = values.count + var pairs = [(Int, Int)]() + for i in 0.. $1.0 } + var res = 0 + var freq = [Int: Int]() + var wanted = numWanted + for (value, label) in pairs { + if wanted == 0 { break } + if freq[label] == nil || freq[label]! < useLimit { + res += value + freq[label, default: 0] += 1 + wanted -= 1 + } + } + return res + } +} diff --git a/tests/1001-1500/1090. largest-values-from-labels/sol.ts b/tests/1001-1500/1090. largest-values-from-labels/sol.ts new file mode 100644 index 00000000..674e347c --- /dev/null +++ b/tests/1001-1500/1090. largest-values-from-labels/sol.ts @@ -0,0 +1,24 @@ +function largestValsFromLabels( + values: number[], + labels: number[], + numWanted: number, + useLimit: number, +): number { + const n = values.length; + const pairs: [number, number][] = []; + for (let i = 0; i < n; i++) { + pairs.push([values[i], labels[i]]); + } + pairs.sort((a, b) => b[0] - a[0]); + let res = 0; + const freq: Map = new Map(); + for (const [value, label] of pairs) { + if (numWanted === 0) break; + if (!freq.has(label) || freq.get(label)! < useLimit) { + res += value; + freq.set(label, (freq.get(label) || 0) + 1); + numWanted--; + } + } + return res; +} diff --git a/tests/1001-1500/1091. shortest-path-in-binary-matrix/manifest.yaml b/tests/1001-1500/1091. shortest-path-in-binary-matrix/manifest.yaml new file mode 100644 index 00000000..5773c6c2 --- /dev/null +++ b/tests/1001-1500/1091. shortest-path-in-binary-matrix/manifest.yaml @@ -0,0 +1,14237 @@ +entry: + id: 1091 + title: shortest-path-in-binary-matrix + params: + grid: + type: array + items: + type: array + items: + type: int + call: + cpp: "Solution().shortestPathBinaryMatrix({grid})" + rust: "Solution::shortest_path_binary_matrix({grid})" + python3: "Solution().shortestPathBinaryMatrix({grid})" + python2: "Solution().shortestPathBinaryMatrix({grid})" + ruby: "shortest_path_binary_matrix({grid})" + java: "new Solution().shortestPathBinaryMatrix({grid})" + csharp: "new Solution().ShortestPathBinaryMatrix({grid})" + kotlin: "Solution().shortestPathBinaryMatrix({grid})" + go: "shortestPathBinaryMatrix({grid})" + dart: "Solution().shortestPathBinaryMatrix({grid})" + swift: "Solution().shortestPathBinaryMatrix({grid})" + typescript: "Solution().shortestPathBinaryMatrix({grid})" +judge: + type: "exact" +limits: + time_ms: 2000 + memory_mb: 256 +oracle: + python3: + call: "Checker().shortestPathBinaryMatrix(grid, {result})" + checker: | + class Checker: + def shortestPathBinaryMatrix(self, grid, result): + from collections import deque + n = len(grid) + if not isinstance(result, int): + return False + if n == 0 or len(grid[0]) != n: + return False + if grid[0][0] == 1 or grid[n - 1][n - 1] == 1: + return result == -1 + if n == 1: + return result == 1 and grid[0][0] == 0 + dist = [[10**9] * n for _ in range(n)] + dist[0][0] = 1 + q = deque([(0, 0)]) + dirs = [(-1, 0), (-1, -1), (0, 1), (-1, 1), (1, 0), (1, -1), (0, -1), (1, 1)] + while q: + r, c = q.popleft() + for dr, dc in dirs: + nr, nc = r + dr, c + dc + if 0 <= nr < n and 0 <= nc < n and grid[nr][nc] == 0 and dist[r][c] + 1 < dist[nr][nc]: + dist[nr][nc] = dist[r][c] + 1 + q.append((nr, nc)) + expected = dist[n - 1][n - 1] + if expected >= 10**9: + expected = -1 + return result == expected +seed: 12345 +tests: + - name: "example-1" + in: + grid: + - [0, 1] + - [1, 0] + judge: + type: "exact" + seed: 17 + - name: "example-2" + in: + grid: + - [0, 0, 0] + - [1, 1, 0] + - [1, 1, 0] + judge: + type: "exact" + seed: 34 + - name: "example-3" + in: + grid: + - [1, 0, 0] + - [1, 1, 0] + - [1, 1, 0] + judge: + type: "exact" + seed: 51 + - name: "single-open" + in: + grid: + - [0] + judge: + type: "exact" + seed: 68 + - name: "single-blocked" + in: + grid: + - [1] + judge: + type: "exact" + seed: 85 + - name: "two-by-two-clear" + in: + grid: + - [0, 0] + - [0, 0] + judge: + type: "exact" + seed: 102 + - name: "two-by-two-one-turn" + in: + grid: + - [0, 1] + - [0, 0] + judge: + type: "exact" + seed: 119 + - name: "two-by-two-no-path" + in: + grid: + - [0, 1] + - [1, 0] + judge: + type: "exact" + seed: 136 + - name: "three-diagonal-clear" + in: + grid: + - [0, 1, 1] + - [1, 0, 1] + - [1, 1, 0] + judge: + type: "exact" + seed: 153 + - name: "three-edge-path" + in: + grid: + - [0, 0, 1] + - [1, 0, 1] + - [1, 0, 0] + judge: + type: "exact" + seed: 170 + - name: "three-no-path-start-open" + in: + grid: + - [0, 1, 1] + - [1, 1, 1] + - [1, 1, 0] + judge: + type: "exact" + seed: 187 + - name: "four-zigzag" + in: + grid: + - [0, 1, 1, 1] + - [0, 0, 1, 1] + - [1, 0, 0, 1] + - [1, 1, 0, 0] + judge: + type: "exact" + seed: 204 + - name: "four-blocked-center" + in: + grid: + - [0, 0, 0, 0] + - [1, 1, 1, 0] + - [0, 0, 0, 0] + - [0, 1, 1, 0] + judge: + type: "exact" + seed: 221 + - name: "five-border" + in: + grid: + - [0, 0, 0, 0, 0] + - [1, 1, 1, 1, 0] + - [1, 1, 1, 1, 0] + - [1, 1, 1, 1, 0] + - [1, 1, 1, 1, 0] + judge: + type: "exact" + seed: 238 + - name: "five-sparse" + in: + grid: + - [0, 1, 0, 1, 0] + - [0, 1, 0, 1, 0] + - [0, 0, 0, 1, 0] + - [1, 1, 0, 0, 0] + - [1, 1, 1, 1, 0] + judge: + type: "exact" + seed: 255 + - name: "six-snake" + in: + grid: + - [0, 1, 1, 1, 1, 1] + - [0, 0, 0, 0, 0, 1] + - [1, 1, 1, 1, 0, 1] + - [1, 0, 0, 0, 0, 1] + - [1, 0, 1, 1, 1, 1] + - [1, 0, 0, 0, 0, 0] + judge: + type: "exact" + seed: 272 + - name: "seven-all-open" + in: + grid: + - [0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0] + judge: + type: "exact" + seed: 289 + - name: "seven-anti-diagonal" + in: + grid: + - [1, 1, 1, 1, 1, 1, 0] + - [1, 1, 1, 1, 1, 0, 0] + - [1, 1, 1, 1, 0, 0, 0] + - [1, 1, 1, 0, 0, 0, 0] + - [1, 1, 0, 0, 0, 0, 0] + - [1, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0] + judge: + type: "exact" + seed: 306 + - name: "eight-checkerboard" + in: + grid: + - [0, 1, 0, 1, 0, 1, 0, 1] + - [1, 0, 1, 0, 1, 0, 1, 0] + - [0, 1, 0, 1, 0, 1, 0, 1] + - [1, 0, 1, 0, 1, 0, 1, 0] + - [0, 1, 0, 1, 0, 1, 0, 1] + - [1, 0, 1, 0, 1, 0, 1, 0] + - [0, 1, 0, 1, 0, 1, 0, 1] + - [1, 0, 1, 0, 1, 0, 1, 0] + judge: + type: "exact" + seed: 323 + - name: "eight-checkerboard-inverted" + in: + grid: + - [1, 0, 1, 0, 1, 0, 1, 0] + - [0, 1, 0, 1, 0, 1, 0, 1] + - [1, 0, 1, 0, 1, 0, 1, 0] + - [0, 1, 0, 1, 0, 1, 0, 1] + - [1, 0, 1, 0, 1, 0, 1, 0] + - [0, 1, 0, 1, 0, 1, 0, 1] + - [1, 0, 1, 0, 1, 0, 1, 0] + - [0, 1, 0, 1, 0, 1, 0, 1] + judge: + type: "exact" + seed: 340 + - name: "nine-heavy-walls" + in: + grid: + - [0, 0, 1, 1, 1, 1, 1, 1, 1] + - [1, 0, 1, 0, 0, 0, 0, 0, 1] + - [1, 0, 1, 0, 1, 1, 1, 0, 1] + - [1, 0, 0, 0, 0, 0, 1, 0, 1] + - [1, 1, 1, 1, 1, 0, 1, 0, 1] + - [1, 0, 0, 0, 1, 0, 0, 0, 1] + - [1, 0, 1, 0, 1, 1, 1, 1, 1] + - [1, 0, 1, 0, 0, 0, 0, 0, 0] + - [1, 0, 1, 1, 1, 1, 1, 1, 0] + judge: + type: "exact" + seed: 357 + - name: "nine-no-path" + in: + grid: + - [0, 1, 1, 1, 1, 1, 1, 1, 1] + - [1, 0, 1, 0, 0, 0, 0, 0, 1] + - [1, 0, 1, 0, 1, 1, 1, 0, 1] + - [1, 0, 0, 1, 1, 1, 1, 0, 1] + - [1, 1, 1, 1, 1, 0, 1, 0, 1] + - [1, 0, 0, 0, 1, 0, 0, 1, 1] + - [1, 0, 1, 0, 1, 1, 1, 1, 1] + - [1, 0, 1, 0, 0, 0, 0, 0, 0] + - [1, 0, 1, 1, 1, 1, 1, 1, 0] + judge: + type: "exact" + seed: 374 + - name: "ten-open-edges" + in: + grid: + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 1, 1, 1, 1, 1, 1, 1, 1, 0] + - [0, 1, 1, 1, 1, 1, 1, 1, 1, 0] + - [0, 1, 1, 1, 1, 1, 1, 1, 1, 0] + - [0, 1, 1, 1, 1, 1, 1, 1, 1, 0] + - [0, 1, 1, 1, 1, 1, 1, 1, 1, 0] + - [0, 1, 1, 1, 1, 1, 1, 1, 1, 0] + - [0, 1, 1, 1, 1, 1, 1, 1, 1, 0] + - [0, 1, 1, 1, 1, 1, 1, 1, 1, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + judge: + type: "exact" + seed: 391 + - name: "ten-staircase" + in: + grid: + - [0, 0, 1, 1, 1, 1, 1, 1, 1, 1] + - [0, 0, 0, 1, 1, 1, 1, 1, 1, 1] + - [0, 0, 0, 0, 1, 1, 1, 1, 1, 1] + - [0, 0, 0, 0, 0, 1, 1, 1, 1, 1] + - [0, 0, 0, 0, 0, 0, 1, 1, 1, 1] + - [0, 0, 0, 0, 0, 0, 0, 1, 1, 1] + - [0, 0, 0, 0, 0, 0, 0, 0, 1, 1] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 1] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + judge: + type: "exact" + seed: 408 + - name: "ten-long-path" + in: + grid: + - [0, 0, 1, 1, 1, 1, 1, 1, 1, 1] + - [1, 0, 0, 1, 1, 1, 1, 1, 1, 1] + - [1, 1, 0, 0, 1, 1, 1, 1, 1, 1] + - [1, 1, 1, 0, 0, 1, 1, 1, 1, 1] + - [1, 1, 1, 1, 0, 0, 1, 1, 1, 1] + - [1, 1, 1, 1, 1, 0, 0, 1, 1, 1] + - [1, 1, 1, 1, 1, 1, 0, 0, 1, 1] + - [1, 1, 1, 1, 1, 1, 1, 0, 0, 1] + - [1, 1, 1, 1, 1, 1, 1, 1, 0, 0] + - [1, 1, 1, 1, 1, 1, 1, 1, 1, 0] + judge: + type: "exact" + seed: 425 + - name: "ten-diag-block-end" + in: + grid: + - [0, 1, 1, 1, 1, 1, 1, 1, 1, 1] + - [1, 0, 1, 1, 1, 1, 1, 1, 1, 1] + - [1, 1, 0, 1, 1, 1, 1, 1, 1, 1] + - [1, 1, 1, 0, 1, 1, 1, 1, 1, 1] + - [1, 1, 1, 1, 0, 1, 1, 1, 1, 1] + - [1, 1, 1, 1, 1, 0, 1, 1, 1, 1] + - [1, 1, 1, 1, 1, 1, 0, 1, 1, 1] + - [1, 1, 1, 1, 1, 1, 1, 0, 1, 1] + - [1, 1, 1, 1, 1, 1, 1, 1, 0, 1] + - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] + judge: + type: "exact" + seed: 442 + - name: "eleven-open" + in: + grid: + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + judge: + type: "exact" + seed: 459 + - name: "eleven-wall-with-gap" + in: + grid: + - [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] + - [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1] + - [0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1] + - [0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1] + - [0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1] + - [0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0] + - [0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1] + - [0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1] + - [0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1] + - [0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1] + - [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0] + judge: + type: "exact" + seed: 476 + - name: "twelve-maze" + in: + grid: + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0] + - [0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0] + - [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0] + - [0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0] + - [0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0] + - [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0] + - [0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0] + - [0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0] + - [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0] + - [0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + judge: + type: "exact" + seed: 493 + - name: "thirteen-maze" + in: + grid: + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0] + - [0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0] + - [0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0] + - [0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0] + - [0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0] + - [0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0] + - [0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0] + - [0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0] + - [0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0] + - [0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0] + - [0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + judge: + type: "exact" + seed: 510 + - name: "twenty-open" + in: + grid: + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + judge: + type: "exact" + seed: 527 + - name: "thirty-open" + in: + grid: + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 544 + - name: "fifty-open" + in: + grid: + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 561 + - name: "hundred-open" + in: + grid: + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + - [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 578 + - name: "two-by-two-diagonal" + in: + grid: + - [0, 1] + - [1, 0] + judge: + type: "exact" + seed: 595 diff --git a/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.cpp b/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.cpp new file mode 100644 index 00000000..ee2c4427 --- /dev/null +++ b/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.cpp @@ -0,0 +1,50 @@ +class Solution { +public: + int shortestPathBinaryMatrix(vector>& grid) { + int n = grid.size(); + + if (grid[0][0] == 1 || grid[n - 1][n - 1] == 1) { + return -1; + } + + if (n == 1) { + return 1; + } + + vector> dist(n, vector(n, INT_MAX)); + dist[0][0] = 1; + + queue> q; + q.push({0, 0, 1}); + + vector> directions = { + {-1, 0}, {-1, -1}, {0, 1}, {-1, 1}, + {1, 0}, {1, -1}, {0, -1}, {1, 1} + }; + + while (!q.empty()) { + auto curr = q.front(); + q.pop(); + int r = curr[0], c = curr[1], dis = curr[2]; + + for (auto& dir : directions) { + int nr = r + dir[0]; + int nc = c + dir[1]; + + if (nr >= 0 && nr < n && nc >= 0 && nc < n && + grid[nr][nc] == 0 && dis + 1 < dist[nr][nc]) { + + dist[nr][nc] = dis + 1; + + if (nr == n - 1 && nc == n - 1) { + return dis + 1; + } + + q.push({nr, nc, dis + 1}); + } + } + } + + return -1; + } +}; diff --git a/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.cs b/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.cs new file mode 100644 index 00000000..6cd518d3 --- /dev/null +++ b/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.cs @@ -0,0 +1,54 @@ +public class Solution { + public int ShortestPathBinaryMatrix(int[][] grid) { + int n = grid.Length; + + if (grid[0][0] == 1 || grid[n - 1][n - 1] == 1) { + return -1; + } + + if (n == 1) { + return 1; + } + + int[][] dist = new int[n][]; + for (int i = 0; i < n; i++) { + dist[i] = new int[n]; + for (int j = 0; j < n; j++) { + dist[i][j] = int.MaxValue; + } + } + dist[0][0] = 1; + + Queue q = new Queue(); + q.Enqueue(new int[] { 0, 0, 1 }); + + int[][] directions = new int[][] { + new int[] { -1, 0 }, new int[] { -1, -1 }, new int[] { 0, 1 }, new int[] { -1, 1 }, + new int[] { 1, 0 }, new int[] { 1, -1 }, new int[] { 0, -1 }, new int[] { 1, 1 } + }; + + while (q.Count > 0) { + int[] curr = q.Dequeue(); + int r = curr[0], c = curr[1], dis = curr[2]; + + foreach (int[] dir in directions) { + int nr = r + dir[0]; + int nc = c + dir[1]; + + if (nr >= 0 && nr < n && nc >= 0 && nc < n && + grid[nr][nc] == 0 && dis + 1 < dist[nr][nc]) { + + dist[nr][nc] = dis + 1; + + if (nr == n - 1 && nc == n - 1) { + return dis + 1; + } + + q.Enqueue(new int[] { nr, nc, dis + 1 }); + } + } + } + + return -1; + } +} diff --git a/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.dart b/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.dart new file mode 100644 index 00000000..5a7811d5 --- /dev/null +++ b/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.dart @@ -0,0 +1,48 @@ +class Solution { + int shortestPathBinaryMatrix(List> grid) { + int n = grid.length; + + if (grid[0][0] == 1 || grid[n - 1][n - 1] == 1) { + return -1; + } + + if (n == 1) { + return 1; + } + + List> dist = List.generate(n, (_) => List.filled(n, 0x7fffffffffffffff)); + dist[0][0] = 1; + + Queue> q = Queue(); + q.add([0, 0, 1]); + + List> directions = [ + [-1, 0], [-1, -1], [0, 1], [-1, 1], + [1, 0], [1, -1], [0, -1], [1, 1] + ]; + + while (q.isNotEmpty) { + List curr = q.removeFirst(); + int r = curr[0], c = curr[1], dis = curr[2]; + + for (List dir in directions) { + int nr = r + dir[0]; + int nc = c + dir[1]; + + if (nr >= 0 && nr < n && nc >= 0 && nc < n && + grid[nr][nc] == 0 && dis + 1 < dist[nr][nc]) { + + dist[nr][nc] = dis + 1; + + if (nr == n - 1 && nc == n - 1) { + return dis + 1; + } + + q.add([nr, nc, dis + 1]); + } + } + } + + return -1; + } +} diff --git a/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.go b/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.go new file mode 100644 index 00000000..c530cd55 --- /dev/null +++ b/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.go @@ -0,0 +1,54 @@ +func shortestPathBinaryMatrix(grid [][]int) int { + n := len(grid) + + if grid[0][0] == 1 || grid[n-1][n-1] == 1 { + return -1 + } + + if n == 1 { + return 1 + } + + dist := make([][]int, n) + for i := 0; i < n; i++ { + dist[i] = make([]int, n) + for j := 0; j < n; j++ { + dist[i][j] = int(^uint(0) >> 1) + } + } + dist[0][0] = 1 + + type Node struct { + r, c, dis int + } + q := []Node{{0, 0, 1}} + + directions := [][]int{ + {-1, 0}, {-1, -1}, {0, 1}, {-1, 1}, + {1, 0}, {1, -1}, {0, -1}, {1, 1}, + } + + for len(q) > 0 { + curr := q[0] + q = q[1:] + r, c, dis := curr.r, curr.c, curr.dis + + for _, dir := range directions { + nr, nc := r+dir[0], c+dir[1] + + if nr >= 0 && nr < n && nc >= 0 && nc < n && + grid[nr][nc] == 0 && dis+1 < dist[nr][nc] { + + dist[nr][nc] = dis + 1 + + if nr == n-1 && nc == n-1 { + return dis + 1 + } + + q = append(q, Node{nr, nc, dis + 1}) + } + } + } + + return -1 +} diff --git a/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.java b/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.java new file mode 100644 index 00000000..1339f298 --- /dev/null +++ b/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.java @@ -0,0 +1,53 @@ +class Solution { + public int shortestPathBinaryMatrix(int[][] grid) { + int n = grid.length; + + if (grid[0][0] == 1 || grid[n - 1][n - 1] == 1) { + return -1; + } + + if (n == 1) { + return 1; + } + + int[][] dist = new int[n][n]; + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + dist[i][j] = Integer.MAX_VALUE; + } + } + dist[0][0] = 1; + + java.util.Queue q = new java.util.LinkedList<>(); + q.offer(new int[]{0, 0, 1}); + + int[][] directions = { + {-1, 0}, {-1, -1}, {0, 1}, {-1, 1}, + {1, 0}, {1, -1}, {0, -1}, {1, 1} + }; + + while (!q.isEmpty()) { + int[] curr = q.poll(); + int r = curr[0], c = curr[1], dis = curr[2]; + + for (int[] dir : directions) { + int nr = r + dir[0]; + int nc = c + dir[1]; + + if (nr >= 0 && nr < n && nc >= 0 && nc < n && + grid[nr][nc] == 0 && dis + 1 < dist[nr][nc]) { + + dist[nr][nc] = dis + 1; + + if (nr == n - 1 && nc == n - 1) { + return dis + 1; + } + + q.offer(new int[]{nr, nc, dis + 1}); + } + } + } + + return -1; + } +} diff --git a/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.kt b/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.kt new file mode 100644 index 00000000..1e0cf9ea --- /dev/null +++ b/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.kt @@ -0,0 +1,50 @@ +class Solution { + fun shortestPathBinaryMatrix(grid: Array): Int { + val n = grid.size + + if (grid[0][0] == 1 || grid[n - 1][n - 1] == 1) { + return -1 + } + + if (n == 1) { + return 1 + } + + val dist = Array(n) { IntArray(n) { Int.MAX_VALUE } } + dist[0][0] = 1 + + val q = java.util.LinkedList() + q.offer(intArrayOf(0, 0, 1)) + + val directions = arrayOf( + intArrayOf(-1, 0), intArrayOf(-1, -1), intArrayOf(0, 1), intArrayOf(-1, 1), + intArrayOf(1, 0), intArrayOf(1, -1), intArrayOf(0, -1), intArrayOf(1, 1) + ) + + while (q.isNotEmpty()) { + val curr = q.poll() + val r = curr[0] + val c = curr[1] + val dis = curr[2] + + for (dir in directions) { + val nr = r + dir[0] + val nc = c + dir[1] + + if (nr in 0 until n && nc in 0 until n && + grid[nr][nc] == 0 && dis + 1 < dist[nr][nc]) { + + dist[nr][nc] = dis + 1 + + if (nr == n - 1 && nc == n - 1) { + return dis + 1 + } + + q.offer(intArrayOf(nr, nc, dis + 1)) + } + } + } + + return -1 + } +} diff --git a/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.py b/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.py new file mode 100644 index 00000000..bda8f382 --- /dev/null +++ b/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.py @@ -0,0 +1,49 @@ +from collections import deque + + +class Solution: + def shortestPathBinaryMatrix(self, grid): + n = len(grid) + + if grid[0][0] == 1 or grid[n - 1][n - 1] == 1: + return -1 + + if n == 1: + return 1 + + dist = [[float("inf")] * n for _ in range(n)] + dist[0][0] = 1 + + q = deque([(0, 0, 1)]) + + directions = [ + (-1, 0), + (-1, -1), + (0, 1), + (-1, 1), + (1, 0), + (1, -1), + (0, -1), + (1, 1), + ] + + while q: + r, c, dis = q.popleft() + + for dr, dc in directions: + nr, nc = r + dr, c + dc + + if ( + 0 <= nr < n + and 0 <= nc < n + and grid[nr][nc] == 0 + and dis + 1 < dist[nr][nc] + ): + dist[nr][nc] = dis + 1 + + if nr == n - 1 and nc == n - 1: + return dis + 1 + + q.append((nr, nc, dis + 1)) + + return -1 diff --git a/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.py2 b/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.py2 new file mode 100644 index 00000000..9b46ab1b --- /dev/null +++ b/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.py2 @@ -0,0 +1,44 @@ +class Solution(object): + def shortestPathBinaryMatrix(self, grid): + """ + :type grid: List[List[int]] + :rtype: int + """ + from collections import deque + + n = len(grid) + + if grid[0][0] == 1 or grid[n - 1][n - 1] == 1: + return -1 + + if n == 1: + return 1 + + dist = [[float('inf')] * n for _ in range(n)] + dist[0][0] = 1 + + q = deque([(0, 0, 1)]) + + directions = [ + (-1, 0), (-1, -1), (0, 1), (-1, 1), + (1, 0), (1, -1), (0, -1), (1, 1) + ] + + while q: + r, c, dis = q.popleft() + + for dr, dc in directions: + nr, nc = r + dr, c + dc + + if (0 <= nr < n and 0 <= nc < n and + grid[nr][nc] == 0 and + dis + 1 < dist[nr][nc]): + + dist[nr][nc] = dis + 1 + + if nr == n - 1 and nc == n - 1: + return dis + 1 + + q.append((nr, nc, dis + 1)) + + return -1 diff --git a/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.rb b/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.rb new file mode 100644 index 00000000..980b47af --- /dev/null +++ b/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.rb @@ -0,0 +1,39 @@ +# @param {Integer[][]} grid +# @return {Integer} +def shortest_path_binary_matrix(grid) + n = grid.length + + return -1 if grid[0][0] == 1 || grid[n-1][n-1] == 1 + return 1 if n == 1 + + dist = Array.new(n) { Array.new(n, Float::INFINITY) } + dist[0][0] = 1 + + q = [[0, 0, 1]] + + directions = [ + [-1, 0], [-1, -1], [0, 1], [-1, 1], + [1, 0], [1, -1], [0, -1], [1, 1] + ] + + while !q.empty? + r, c, dis = q.shift + + directions.each do |dr, dc| + nr = r + dr + nc = c + dc + + if nr >= 0 && nr < n && nc >= 0 && nc < n && + grid[nr][nc] == 0 && dis + 1 < dist[nr][nc] + + dist[nr][nc] = dis + 1 + + return dis + 1 if nr == n - 1 && nc == n - 1 + + q << [nr, nc, dis + 1] + end + end + end + + -1 +end diff --git a/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.rs b/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.rs new file mode 100644 index 00000000..7485170f --- /dev/null +++ b/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.rs @@ -0,0 +1,48 @@ +impl Solution { + pub fn shortest_path_binary_matrix(grid: Vec>) -> i32 { + let n = grid.len(); + + if grid[0][0] == 1 || grid[n - 1][n - 1] == 1 { + return -1; + } + + if n == 1 { + return 1; + } + + let mut dist = vec![vec![i32::MAX; n]; n]; + dist[0][0] = 1; + + let mut q = std::collections::VecDeque::new(); + q.push_back((0usize, 0usize, 1i32)); + + let directions = [ + (-1, 0), (-1, -1), (0, 1), (-1, 1), + (1, 0), (1, -1), (0, -1), (1, 1) + ]; + + while let Some((r, c, dis)) = q.pop_front() { + for (dr, dc) in &directions { + let nr = r as i32 + dr; + let nc = c as i32 + dc; + + if nr >= 0 && nr < n as i32 && nc >= 0 && nc < n as i32 { + let nr = nr as usize; + let nc = nc as usize; + + if grid[nr][nc] == 0 && dis + 1 < dist[nr][nc] { + dist[nr][nc] = dis + 1; + + if nr == n - 1 && nc == n - 1 { + return dis + 1; + } + + q.push_back((nr, nc, dis + 1)); + } + } + } + } + + -1 + } +} diff --git a/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.swift b/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.swift new file mode 100644 index 00000000..54395a85 --- /dev/null +++ b/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.swift @@ -0,0 +1,47 @@ +class Solution { + func shortestPathBinaryMatrix(_ grid: [[Int]]) -> Int { + let n = grid.count + + if grid[0][0] == 1 || grid[n - 1][n - 1] == 1 { + return -1 + } + + if n == 1 { + return 1 + } + + var dist = Array(repeating: Array(repeating: Int.max, count: n), count: n) + dist[0][0] = 1 + + var q = [[0, 0, 1]] + + let directions = [ + [-1, 0], [-1, -1], [0, 1], [-1, 1], + [1, 0], [1, -1], [0, -1], [1, 1] + ] + + while !q.isEmpty { + let curr = q.removeFirst() + let r = curr[0], c = curr[1], dis = curr[2] + + for dir in directions { + let nr = r + dir[0] + let nc = c + dir[1] + + if nr >= 0 && nr < n && nc >= 0 && nc < n && + grid[nr][nc] == 0 && dis + 1 < dist[nr][nc] { + + dist[nr][nc] = dis + 1 + + if nr == n - 1 && nc == n - 1 { + return dis + 1 + } + + q.append([nr, nc, dis + 1]) + } + } + } + + return -1 + } +} diff --git a/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.ts b/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.ts new file mode 100644 index 00000000..801863c6 --- /dev/null +++ b/tests/1001-1500/1091. shortest-path-in-binary-matrix/sol.ts @@ -0,0 +1,39 @@ +function Solution() { + return { + shortestPathBinaryMatrix(grid: number[][]): number { + const n = grid.length; + if (grid[0][0] === 1 || grid[n - 1][n - 1] === 1) { + return -1; + } + if (n === 1) { + return 1; + } + const dist: number[][] = Array.from({ length: n }, () => + Array(n).fill(Number.MAX_SAFE_INTEGER), + ); + const q: [number, number][] = [[0, 0]]; + dist[0][0] = 1; + for (let head = 0; head < q.length; head++) { + const [r, c] = q[head]; + const d = dist[r][c] + 1; + for (let dr = -1; dr <= 1; dr++) { + for (let dc = -1; dc <= 1; dc++) { + if (dr === 0 && dc === 0) continue; + const nr = r + dr; + const nc = c + dc; + if (nr < 0 || nr >= n || nc < 0 || nc >= n || grid[nr][nc] === 1) + continue; + if (d < dist[nr][nc]) { + dist[nr][nc] = d; + if (nr === n - 1 && nc === n - 1) { + return d; + } + q.push([nr, nc]); + } + } + } + } + return -1; + }, + }; +} diff --git a/tests/1001-1500/1092. shortest-common-supersequence/manifest.yaml b/tests/1001-1500/1092. shortest-common-supersequence/manifest.yaml new file mode 100644 index 00000000..358235b0 --- /dev/null +++ b/tests/1001-1500/1092. shortest-common-supersequence/manifest.yaml @@ -0,0 +1,331 @@ +entry: + id: 1092 + title: shortest-common-supersequence + params: + str1: + type: string + str2: + type: string + call: + cpp: "Solution().shortestCommonSupersequence({str1}, {str2})" + rust: "Solution::shortest_common_supersequence({str1}, {str2})" + python3: "Solution().shortestCommonSupersequence({str1}, {str2})" + python2: "Solution().shortestCommonSupersequence({str1}, {str2})" + ruby: "shortest_common_supersequence({str1}, {str2})" + java: "new Solution().shortestCommonSupersequence({str1}, {str2})" + csharp: "new Solution().ShortestCommonSupersequence({str1}, {str2})" + kotlin: "Solution().shortestCommonSupersequence({str1}, {str2})" + go: "shortestCommonSupersequence({str1}, {str2})" + dart: "Solution().shortestCommonSupersequence({str1}, {str2})" + swift: "Solution().shortestCommonSupersequence({str1}, {str2})" + typescript: "Solution().shortestCommonSupersequence({str1}, {str2})" +judge: + type: "exact" +limits: + time_ms: 2000 + memory_mb: 256 +oracle: + python3: + call: "Checker().shortestCommonSupersequence(str1, str2, {result})" + checker: | + class Checker: + def shortestCommonSupersequence(self, str1, str2, result): + if not isinstance(result, str): + return False + def is_subseq(a, b): + it = iter(b) + return all(ch in it for ch in a) + if not is_subseq(str1, result) or not is_subseq(str2, result): + return False + m, n = len(str1), len(str2) + dp = [[0] * (n + 1) for _ in range(m + 1)] + for i in range(1, m + 1): + for j in range(1, n + 1): + if str1[i - 1] == str2[j - 1]: + dp[i][j] = dp[i - 1][j - 1] + 1 + else: + dp[i][j] = dp[i - 1][j] if dp[i - 1][j] > dp[i][j - 1] else dp[i][j - 1] + expected_len = m + n - dp[m][n] + return len(result) == expected_len +seed: 12345 +tests: + - name: "example-1" + in: + str1: "abac" + str2: "cab" + judge: + type: "exact" + seed: 17 + - name: "example-2" + in: + str1: "aaaaaaaa" + str2: "aaaaaaaa" + judge: + type: "exact" + seed: 34 + - name: "one-char-same" + in: + str1: "a" + str2: "a" + judge: + type: "exact" + seed: 51 + - name: "one-char-diff" + in: + str1: "a" + str2: "b" + judge: + type: "exact" + seed: 68 + - name: "subsequence-left" + in: + str1: "abc" + str2: "a" + judge: + type: "exact" + seed: 85 + - name: "subsequence-right" + in: + str1: "a" + str2: "abc" + judge: + type: "exact" + seed: 102 + - name: "disjoint-2" + in: + str1: "ab" + str2: "cd" + judge: + type: "exact" + seed: 119 + - name: "overlap-1" + in: + str1: "abc" + str2: "bcd" + judge: + type: "exact" + seed: 136 + - name: "overlap-2" + in: + str1: "geek" + str2: "eke" + judge: + type: "exact" + seed: 153 + - name: "palindrome-ish" + in: + str1: "abca" + str2: "caba" + judge: + type: "exact" + seed: 170 + - name: "repeated-pattern" + in: + str1: "abab" + str2: "baba" + judge: + type: "exact" + seed: 187 + - name: "same-prefix" + in: + str1: "leetcode" + str2: "leet" + judge: + type: "exact" + seed: 204 + - name: "same-suffix" + in: + str1: "coding" + str2: "ing" + judge: + type: "exact" + seed: 221 + - name: "medium-1" + in: + str1: "abcde" + str2: "ace" + judge: + type: "exact" + seed: 238 + - name: "medium-2" + in: + str1: "abc" + str2: "xyzabc" + judge: + type: "exact" + seed: 255 + - name: "medium-3" + in: + str1: "abcxyz" + str2: "axbycz" + judge: + type: "exact" + seed: 272 + - name: "medium-4" + in: + str1: "zzzz" + str2: "zzzzzz" + judge: + type: "exact" + seed: 289 + - name: "long-a-b" + in: + str1: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + str2: "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + judge: + type: "exact" + seed: 306 + - name: "long-overlap" + in: + str1: "abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde" + str2: "cdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeab" + judge: + type: "exact" + seed: 323 + - name: "long-mixed" + in: + str1: "abcdefghijklmnopqrstuvwxyz" + str2: "zyxwvutsrqponmlkjihgfedcba" + judge: + type: "exact" + seed: 340 + - name: "generated-1" + in: + str1: "abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab" + str2: "babababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababa" + judge: + type: "exact" + seed: 357 + - name: "generated-2" + in: + str1: "abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd" + str2: "bcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcda" + judge: + type: "exact" + seed: 374 + - name: "generated-3" + in: + str1: "abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc" + str2: "cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab" + judge: + type: "exact" + seed: 391 + - name: "generated-4" + in: + str1: "aabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbccaabbcc" + str2: "ccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaaccbbaa" + judge: + type: "exact" + seed: 408 + - name: "generated-5" + in: + str1: "leetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcode" + str2: "codeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleetcodeleet" + judge: + type: "exact" + seed: 425 + - name: "generated-6" + in: + str1: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + str2: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + judge: + type: "exact" + seed: 442 + - name: "generated-7" + in: + str1: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + str2: "b" + judge: + type: "exact" + seed: 459 + - name: "generated-8" + in: + str1: "qwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwerty" + str2: "ytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewqytrewq" + judge: + type: "exact" + seed: 476 + - name: "generated-9" + in: + str1: "mnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqrmnopqr" + str2: "qrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuvqrstuv" + judge: + type: "exact" + seed: 493 + - name: "generated-10" + in: + str1: "abcxyzabcxyz" + str2: "xyzabcxyzabc" + judge: + type: "exact" + seed: 510 + - name: "generated-11" + in: + str1: "aaaaaaaaab" + str2: "baaaaaaaaa" + judge: + type: "exact" + seed: 527 + - name: "generated-12" + in: + str1: "puzzle" + str2: "pizzazz" + judge: + type: "exact" + seed: 544 + - name: "generated-13" + in: + str1: "dynamicprogramming" + str2: "programdynamic" + judge: + type: "exact" + seed: 561 + - name: "generated-14" + in: + str1: "short" + str2: "ports" + judge: + type: "exact" + seed: 578 + - name: "generated-15" + in: + str1: "ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" + str2: "tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt" + judge: + type: "exact" + seed: 595 + - name: "generated-16" + in: + str1: "abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde" + str2: "edcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcbaedcba" + judge: + type: "exact" + seed: 612 + - name: "generated-17" + in: + str1: "ababababab" + str2: "bababababa" + judge: + type: "exact" + seed: 629 + - name: "generated-18" + in: + str1: "abcdxyz" + str2: "xyzabcd" + judge: + type: "exact" + seed: 646 + - name: "generated-19" + in: + str1: "aaaabbbbcccc" + str2: "abcabcabcabc" + judge: + type: "exact" + seed: 663 + - name: "generated-20" + in: + str1: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz" + str2: "mnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl" + judge: + type: "exact" + seed: 680 diff --git a/tests/1001-1500/1092. shortest-common-supersequence/sol.cpp b/tests/1001-1500/1092. shortest-common-supersequence/sol.cpp new file mode 100644 index 00000000..706c3234 --- /dev/null +++ b/tests/1001-1500/1092. shortest-common-supersequence/sol.cpp @@ -0,0 +1,47 @@ +class Solution { +public: + string shortestCommonSupersequence(string str1, string str2) { + int m = str1.length(), n = str2.length(); + vector> dp(m + 1, vector(n + 1, 0)); + + for (int i = 1; i <= m; i++) { + for (int j = 1; j <= n; j++) { + if (str1[i-1] == str2[j-1]) { + dp[i][j] = 1 + dp[i-1][j-1]; + } else { + dp[i][j] = max(dp[i-1][j], dp[i][j-1]); + } + } + } + + int i = m, j = n; + string result; + + while (i > 0 && j > 0) { + if (str1[i-1] == str2[j-1]) { + result.push_back(str1[i-1]); + i--; + j--; + } else if (dp[i-1][j] > dp[i][j-1]) { + result.push_back(str1[i-1]); + i--; + } else { + result.push_back(str2[j-1]); + j--; + } + } + + while (i > 0) { + result.push_back(str1[i-1]); + i--; + } + + while (j > 0) { + result.push_back(str2[j-1]); + j--; + } + + reverse(result.begin(), result.end()); + return result; + } +}; diff --git a/tests/1001-1500/1092. shortest-common-supersequence/sol.cs b/tests/1001-1500/1092. shortest-common-supersequence/sol.cs new file mode 100644 index 00000000..d25534ea --- /dev/null +++ b/tests/1001-1500/1092. shortest-common-supersequence/sol.cs @@ -0,0 +1,47 @@ +public class Solution { + public string ShortestCommonSupersequence(string str1, string str2) { + int m = str1.Length, n = str2.Length; + int[,] dp = new int[m + 1, n + 1]; + + for (int i = 1; i <= m; i++) { + for (int j = 1; j <= n; j++) { + if (str1[i-1] == str2[j-1]) { + dp[i, j] = 1 + dp[i-1, j-1]; + } else { + dp[i, j] = Math.Max(dp[i-1, j], dp[i, j-1]); + } + } + } + + int x = m, y = n; + var result = new System.Text.StringBuilder(); + + while (x > 0 && y > 0) { + if (str1[x-1] == str2[y-1]) { + result.Append(str1[x-1]); + x--; + y--; + } else if (dp[x-1, y] > dp[x, y-1]) { + result.Append(str1[x-1]); + x--; + } else { + result.Append(str2[y-1]); + y--; + } + } + + while (x > 0) { + result.Append(str1[x-1]); + x--; + } + + while (y > 0) { + result.Append(str2[y-1]); + y--; + } + + char[] charArray = result.ToString().ToCharArray(); + Array.Reverse(charArray); + return new string(charArray); + } +} diff --git a/tests/1001-1500/1092. shortest-common-supersequence/sol.dart b/tests/1001-1500/1092. shortest-common-supersequence/sol.dart new file mode 100644 index 00000000..166bca93 --- /dev/null +++ b/tests/1001-1500/1092. shortest-common-supersequence/sol.dart @@ -0,0 +1,45 @@ +class Solution { + String shortestCommonSupersequence(String str1, String str2) { + int m = str1.length, n = str2.length; + List> dp = List.generate(m + 1, (_) => List.filled(n + 1, 0)); + + for (int i = 1; i <= m; i++) { + for (int j = 1; j <= n; j++) { + if (str1[i-1] == str2[j-1]) { + dp[i][j] = 1 + dp[i-1][j-1]; + } else { + dp[i][j] = dp[i-1][j] > dp[i][j-1] ? dp[i-1][j] : dp[i][j-1]; + } + } + } + + int i = m, j = n; + List result = []; + + while (i > 0 && j > 0) { + if (str1[i-1] == str2[j-1]) { + result.add(str1[i-1]); + i--; + j--; + } else if (dp[i-1][j] > dp[i][j-1]) { + result.add(str1[i-1]); + i--; + } else { + result.add(str2[j-1]); + j--; + } + } + + while (i > 0) { + result.add(str1[i-1]); + i--; + } + + while (j > 0) { + result.add(str2[j-1]); + j--; + } + + return result.reversed.join(); + } +} diff --git a/tests/1001-1500/1092. shortest-common-supersequence/sol.go b/tests/1001-1500/1092. shortest-common-supersequence/sol.go new file mode 100644 index 00000000..a26019d8 --- /dev/null +++ b/tests/1001-1500/1092. shortest-common-supersequence/sol.go @@ -0,0 +1,58 @@ +func shortestCommonSupersequence(str1 string, str2 string) string { + m, n := len(str1), len(str2) + dp := make([][]int, m+1) + for i := range dp { + dp[i] = make([]int, n+1) + } + + for i := 1; i <= m; i++ { + for j := 1; j <= n; j++ { + if str1[i-1] == str2[j-1] { + dp[i][j] = 1 + dp[i-1][j-1] + } else { + dp[i][j] = max(dp[i-1][j], dp[i][j-1]) + } + } + } + + i, j := m, n + result := make([]byte, 0, m+n) + + for i > 0 && j > 0 { + if str1[i-1] == str2[j-1] { + result = append(result, str1[i-1]) + i-- + j-- + } else if dp[i-1][j] > dp[i][j-1] { + result = append(result, str1[i-1]) + i-- + } else { + result = append(result, str2[j-1]) + j-- + } + } + + for i > 0 { + result = append(result, str1[i-1]) + i-- + } + + for j > 0 { + result = append(result, str2[j-1]) + j-- + } + + // Reverse + for left, right := 0, len(result)-1; left < right; left, right = left+1, right-1 { + result[left], result[right] = result[right], result[left] + } + + return string(result) +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/tests/1001-1500/1092. shortest-common-supersequence/sol.java b/tests/1001-1500/1092. shortest-common-supersequence/sol.java new file mode 100644 index 00000000..4d8b9998 --- /dev/null +++ b/tests/1001-1500/1092. shortest-common-supersequence/sol.java @@ -0,0 +1,45 @@ +class Solution { + public String shortestCommonSupersequence(String str1, String str2) { + int m = str1.length(), n = str2.length(); + int[][] dp = new int[m + 1][n + 1]; + + for (int i = 1; i <= m; i++) { + for (int j = 1; j <= n; j++) { + if (str1.charAt(i-1) == str2.charAt(j-1)) { + dp[i][j] = 1 + dp[i-1][j-1]; + } else { + dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]); + } + } + } + + int i = m, j = n; + StringBuilder result = new StringBuilder(); + + while (i > 0 && j > 0) { + if (str1.charAt(i-1) == str2.charAt(j-1)) { + result.append(str1.charAt(i-1)); + i--; + j--; + } else if (dp[i-1][j] > dp[i][j-1]) { + result.append(str1.charAt(i-1)); + i--; + } else { + result.append(str2.charAt(j-1)); + j--; + } + } + + while (i > 0) { + result.append(str1.charAt(i-1)); + i--; + } + + while (j > 0) { + result.append(str2.charAt(j-1)); + j--; + } + + return result.reverse().toString(); + } +} diff --git a/tests/1001-1500/1092. shortest-common-supersequence/sol.kt b/tests/1001-1500/1092. shortest-common-supersequence/sol.kt new file mode 100644 index 00000000..9ee3f725 --- /dev/null +++ b/tests/1001-1500/1092. shortest-common-supersequence/sol.kt @@ -0,0 +1,47 @@ +class Solution { + fun shortestCommonSupersequence(str1: String, str2: String): String { + val m = str1.length + val n = str2.length + val dp = Array(m + 1) { IntArray(n + 1) } + + for (i in 1..m) { + for (j in 1..n) { + if (str1[i-1] == str2[j-1]) { + dp[i][j] = 1 + dp[i-1][j-1] + } else { + dp[i][j] = maxOf(dp[i-1][j], dp[i][j-1]) + } + } + } + + var i = m + var j = n + val result = StringBuilder() + + while (i > 0 && j > 0) { + if (str1[i-1] == str2[j-1]) { + result.append(str1[i-1]) + i-- + j-- + } else if (dp[i-1][j] > dp[i][j-1]) { + result.append(str1[i-1]) + i-- + } else { + result.append(str2[j-1]) + j-- + } + } + + while (i > 0) { + result.append(str1[i-1]) + i-- + } + + while (j > 0) { + result.append(str2[j-1]) + j-- + } + + return result.reverse().toString() + } +} diff --git a/tests/1001-1500/1092. shortest-common-supersequence/sol.py b/tests/1001-1500/1092. shortest-common-supersequence/sol.py new file mode 100644 index 00000000..b18b5648 --- /dev/null +++ b/tests/1001-1500/1092. shortest-common-supersequence/sol.py @@ -0,0 +1,46 @@ +class Solution: + def shortestCommonSupersequence(self, str1: str, str2: str) -> str: + # Step 1: Find the longest common subsequence using dynamic programming + m, n = len(str1), len(str2) + dp = [[0] * (n + 1) for _ in range(m + 1)] + + # Fill the dp table + for i in range(1, m + 1): + for j in range(1, n + 1): + if str1[i - 1] == str2[j - 1]: + dp[i][j] = 1 + dp[i - 1][j - 1] + else: + dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + + # Step 2: Construct the shortest common supersequence + # Start from the bottom right of the dp table + i, j = m, n + result = [] + + while i > 0 and j > 0: + if str1[i - 1] == str2[j - 1]: + # If the characters are the same, add it once + result.append(str1[i - 1]) + i -= 1 + j -= 1 + elif dp[i - 1][j] > dp[i][j - 1]: + # If coming from top has higher value, take character from str1 + result.append(str1[i - 1]) + i -= 1 + else: + # Otherwise, take character from str2 + result.append(str2[j - 1]) + j -= 1 + + # Add remaining characters from str1 (if any) + while i > 0: + result.append(str1[i - 1]) + i -= 1 + + # Add remaining characters from str2 (if any) + while j > 0: + result.append(str2[j - 1]) + j -= 1 + + # Reverse the result to get the final supersequence + return "".join(result[::-1]) diff --git a/tests/1001-1500/1092. shortest-common-supersequence/sol.py2 b/tests/1001-1500/1092. shortest-common-supersequence/sol.py2 new file mode 100644 index 00000000..f723532b --- /dev/null +++ b/tests/1001-1500/1092. shortest-common-supersequence/sol.py2 @@ -0,0 +1,41 @@ +class Solution(object): + def shortestCommonSupersequence(self, str1, str2): + """ + :type str1: str + :type str2: str + :rtype: str + """ + m, n = len(str1), len(str2) + dp = [[0] * (n + 1) for _ in range(m + 1)] + + for i in range(1, m + 1): + for j in range(1, n + 1): + if str1[i-1] == str2[j-1]: + dp[i][j] = 1 + dp[i-1][j-1] + else: + dp[i][j] = max(dp[i-1][j], dp[i][j-1]) + + i, j = m, n + result = [] + + while i > 0 and j > 0: + if str1[i-1] == str2[j-1]: + result.append(str1[i-1]) + i -= 1 + j -= 1 + elif dp[i-1][j] > dp[i][j-1]: + result.append(str1[i-1]) + i -= 1 + else: + result.append(str2[j-1]) + j -= 1 + + while i > 0: + result.append(str1[i-1]) + i -= 1 + + while j > 0: + result.append(str2[j-1]) + j -= 1 + + return ''.join(result[::-1]) diff --git a/tests/1001-1500/1092. shortest-common-supersequence/sol.rb b/tests/1001-1500/1092. shortest-common-supersequence/sol.rb new file mode 100644 index 00000000..3570fb49 --- /dev/null +++ b/tests/1001-1500/1092. shortest-common-supersequence/sol.rb @@ -0,0 +1,46 @@ +# @param {String} str1 +# @param {String} str2 +# @return {String} +def shortest_common_supersequence(str1, str2) + m, n = str1.length, str2.length + dp = Array.new(m + 1) { Array.new(n + 1, 0) } + + (1..m).each do |i| + (1..n).each do |j| + if str1[i-1] == str2[j-1] + dp[i][j] = 1 + dp[i-1][j-1] + else + dp[i][j] = [dp[i-1][j], dp[i][j-1]].max + end + end + end + + i, j = m, n + result = [] + + while i > 0 && j > 0 + if str1[i-1] == str2[j-1] + result << str1[i-1] + i -= 1 + j -= 1 + elsif dp[i-1][j] > dp[i][j-1] + result << str1[i-1] + i -= 1 + else + result << str2[j-1] + j -= 1 + end + end + + while i > 0 + result << str1[i-1] + i -= 1 + end + + while j > 0 + result << str2[j-1] + j -= 1 + end + + result.reverse.join +end diff --git a/tests/1001-1500/1092. shortest-common-supersequence/sol.rs b/tests/1001-1500/1092. shortest-common-supersequence/sol.rs new file mode 100644 index 00000000..6f412a7d --- /dev/null +++ b/tests/1001-1500/1092. shortest-common-supersequence/sol.rs @@ -0,0 +1,50 @@ +impl Solution { + pub fn shortest_common_supersequence(str1: String, str2: String) -> String { + let s1: Vec = str1.chars().collect(); + let s2: Vec = str2.chars().collect(); + let m = s1.len(); + let n = s2.len(); + let mut dp = vec![vec![0; n + 1]; m + 1]; + + for i in 1..=m { + for j in 1..=n { + if s1[i-1] == s2[j-1] { + dp[i][j] = 1 + dp[i-1][j-1]; + } else { + dp[i][j] = dp[i-1][j].max(dp[i][j-1]); + } + } + } + + let mut i = m; + let mut j = n; + let mut result: Vec = Vec::new(); + + while i > 0 && j > 0 { + if s1[i-1] == s2[j-1] { + result.push(s1[i-1]); + i -= 1; + j -= 1; + } else if dp[i-1][j] > dp[i][j-1] { + result.push(s1[i-1]); + i -= 1; + } else { + result.push(s2[j-1]); + j -= 1; + } + } + + while i > 0 { + result.push(s1[i-1]); + i -= 1; + } + + while j > 0 { + result.push(s2[j-1]); + j -= 1; + } + + result.reverse(); + result.into_iter().collect() + } +} diff --git a/tests/1001-1500/1092. shortest-common-supersequence/sol.swift b/tests/1001-1500/1092. shortest-common-supersequence/sol.swift new file mode 100644 index 00000000..ece3c22a --- /dev/null +++ b/tests/1001-1500/1092. shortest-common-supersequence/sol.swift @@ -0,0 +1,46 @@ +class Solution { + func shortestCommonSupersequence(_ str1: String, _ str2: String) -> String { + let s1 = Array(str1), s2 = Array(str2) + let m = s1.count, n = s2.count + var dp = Array(repeating: Array(repeating: 0, count: n + 1), count: m + 1) + + for i in 1...m { + for j in 1...n { + if s1[i-1] == s2[j-1] { + dp[i][j] = 1 + dp[i-1][j-1] + } else { + dp[i][j] = max(dp[i-1][j], dp[i][j-1]) + } + } + } + + var i = m, j = n + var result = [Character]() + + while i > 0 && j > 0 { + if s1[i-1] == s2[j-1] { + result.append(s1[i-1]) + i -= 1 + j -= 1 + } else if dp[i-1][j] > dp[i][j-1] { + result.append(s1[i-1]) + i -= 1 + } else { + result.append(s2[j-1]) + j -= 1 + } + } + + while i > 0 { + result.append(s1[i-1]) + i -= 1 + } + + while j > 0 { + result.append(s2[j-1]) + j -= 1 + } + + return String(result.reversed()) + } +} diff --git a/tests/1001-1500/1092. shortest-common-supersequence/sol.ts b/tests/1001-1500/1092. shortest-common-supersequence/sol.ts new file mode 100644 index 00000000..b171cd9c --- /dev/null +++ b/tests/1001-1500/1092. shortest-common-supersequence/sol.ts @@ -0,0 +1,44 @@ +function Solution() { + return { + shortestCommonSupersequence(str1: string, str2: string): string { + const m = str1.length, + n = str2.length; + const dp: number[][] = Array.from({ length: m + 1 }, () => + Array(n + 1).fill(0), + ); + for (let i = 1; i <= m; i++) { + for (let j = 1; j <= n; j++) { + dp[i][j] = + str1[i - 1] === str2[j - 1] + ? dp[i - 1][j - 1] + 1 + : Math.max(dp[i - 1][j], dp[i][j - 1]); + } + } + let i = m, + j = n; + const out: string[] = []; + while (i > 0 && j > 0) { + if (str1[i - 1] === str2[j - 1]) { + out.push(str1[i - 1]); + i--; + j--; + } else if (dp[i - 1][j] >= dp[i][j - 1]) { + out.push(str1[i - 1]); + i--; + } else { + out.push(str2[j - 1]); + j--; + } + } + while (i > 0) { + out.push(str1[i - 1]); + i--; + } + while (j > 0) { + out.push(str2[j - 1]); + j--; + } + return out.reverse().join(""); + }, + }; +} diff --git a/tests/1001-1500/1093. statistics-from-a-large-sample/manifest.yaml b/tests/1001-1500/1093. statistics-from-a-large-sample/manifest.yaml new file mode 100644 index 00000000..9219ae3c --- /dev/null +++ b/tests/1001-1500/1093. statistics-from-a-large-sample/manifest.yaml @@ -0,0 +1,9832 @@ +entry: + id: 1093 + title: statistics-from-a-large-sample + params: + count: + type: array + items: + type: int + call: + cpp: "Solution().sampleStats({count})" + rust: "Solution::sample_stats({count})" + python3: "Solution().sampleStats({count})" + python2: "Solution().sampleStats({count})" + ruby: "sample_stats({count})" + java: "new Solution().sampleStats({count})" + csharp: "new Solution().SampleStats({count})" + kotlin: "Solution().sampleStats({count})" + go: "sampleStats({count})" + dart: "Solution().sampleStats({count})" + swift: "Solution().sampleStats({count})" + typescript: "Solution().sampleStats({count})" +judge: + type: "exact" +limits: + time_ms: 2000 + memory_mb: 256 +oracle: + python3: + call: "Checker().sampleStats(count, {result})" + checker: | + class Checker: + def sampleStats(self, count, result): + if not isinstance(result, list) or len(result) != 5: + return False + total = sum(count) + vals = [] + min_v = None + max_v = None + mode = 0 + mode_cnt = -1 + s = 0 + for i, c in enumerate(count): + if c: + if min_v is None: + min_v = i + max_v = i + s += i * c + if c > mode_cnt: + mode_cnt = c + mode = i + if min_v is None: + return False + def kth(k): + acc = 0 + for i, c in enumerate(count): + acc += c + if acc >= k: + return i + if total % 2: + median = float(kth(total // 2 + 1)) + else: + median = (kth(total // 2) + kth(total // 2 + 1)) / 2.0 + expected = [float(min_v), float(max_v), s / total, float(median), float(mode)] + return all(abs(a - b) <= 1e-5 for a, b in zip(expected, result)) +seed: 12345 +tests: + - name: "example-1" + in: + count: + [ + 0, + 1, + 3, + 4, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 17 + - name: "example-2" + in: + count: + [ + 0, + 4, + 3, + 2, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 34 + - name: "single-zero" + in: + count: + [ + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 51 + - name: "single-max" + in: + count: + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + ] + judge: + type: "exact" + seed: 68 + - name: "two-same-low" + in: + count: + [ + 0, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 85 + - name: "two-different" + in: + count: + [ + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 102 + - name: "spread-1" + in: + count: + [ + 0, + 1, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 119 + - name: "spread-2" + in: + count: + [ + 0, + 0, + 5, + 0, + 0, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 136 + - name: "odd-median" + in: + count: + [ + 0, + 1, + 2, + 3, + 4, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 153 + - name: "even-median" + in: + count: + [ + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 170 + - name: "mode-middle" + in: + count: + [ + 0, + 1, + 5, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 187 + - name: "mode-end" + in: + count: + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 2, + 3, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 204 + - name: "min-max-far" + in: + count: + [ + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 2, + ] + judge: + type: "exact" + seed: 221 + - name: "dense-low" + in: + count: + [ + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 238 + - name: "dense-high" + in: + count: + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 255 + - name: "uniform-1-10" + in: + count: + [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 272 + - name: "uniform-100-109" + in: + count: + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 289 + - name: "peak-near-start" + in: + count: + [ + 5, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 306 + - name: "peak-near-end" + in: + count: + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 5, + ] + judge: + type: "exact" + seed: 323 + - name: "median-half" + in: + count: + [ + 0, + 2, + 0, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 340 + - name: "median-between" + in: + count: + [ + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 357 + - name: "large-count-1" + in: + count: + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1000000000, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 374 + - name: "large-count-2" + in: + count: + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 123456789, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 391 + - name: "large-count-3" + in: + count: + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1000000000, + ] + judge: + type: "exact" + seed: 408 + - name: "large-count-4" + in: + count: + [ + 1000000000, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 425 + - name: "two-spikes" + in: + count: + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 7, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 9, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 442 + - name: "triple-spikes" + in: + count: + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 3, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 4, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 5, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 459 + - name: "wide-1" + in: + count: + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 476 + - name: "wide-2" + in: + count: + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 3, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 493 + - name: "wide-3" + in: + count: + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 2, + 3, + 4, + 5, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 510 + - name: "wide-4" + in: + count: + [ + 0, + 0, + 0, + 0, + 0, + 100, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + ] + judge: + type: "exact" + seed: 527 + - name: "wide-5" + in: + count: + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 6, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 7, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 544 + - name: "wide-6" + in: + count: + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 561 + - name: "wide-7" + in: + count: + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 2, + 2, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 578 + - name: "wide-8" + in: + count: + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 9, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ] + judge: + type: "exact" + seed: 595 + - name: "wide-9" + in: + count: + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + ] + judge: + type: "exact" + seed: 612 + - name: "wide-10" + in: + count: + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 3, + 4, + 5, + 6, + ] + judge: + type: "exact" + seed: 629 diff --git a/tests/1001-1500/1093. statistics-from-a-large-sample/sol.cpp b/tests/1001-1500/1093. statistics-from-a-large-sample/sol.cpp new file mode 100644 index 00000000..32503efe --- /dev/null +++ b/tests/1001-1500/1093. statistics-from-a-large-sample/sol.cpp @@ -0,0 +1,47 @@ +class Solution { +public: + vector sampleStats(vector& count) { + auto kth = [&](int k) -> int { + int acc = 0; + for (int v = 0; v < count.size(); v++) { + acc += count[v]; + if (acc >= k) { + return v; + } + } + return 0; + }; + + int tot = 0; + long long cnt = 0; + int mini = -1; + int maxi = 0; + int mode = 0; + int modeCnt = 0; + + for (int v = 0; v < count.size(); v++) { + int c = count[v]; + if (c > 0) { + if (mini == -1) { + mini = v; + } + maxi = v; + tot += c; + cnt += (long long)v * c; + if (c > modeCnt) { + modeCnt = c; + mode = v; + } + } + } + + double m; + if (tot % 2 == 1) { + m = kth(tot / 2 + 1); + } else { + m = (kth(tot / 2) + kth(tot / 2 + 1)) / 2.0; + } + + return {(double)mini, (double)maxi, (double)cnt / tot, m, (double)mode}; + } +}; diff --git a/tests/1001-1500/1093. statistics-from-a-large-sample/sol.cs b/tests/1001-1500/1093. statistics-from-a-large-sample/sol.cs new file mode 100644 index 00000000..dd29dd85 --- /dev/null +++ b/tests/1001-1500/1093. statistics-from-a-large-sample/sol.cs @@ -0,0 +1,46 @@ +public class Solution { + public double[] SampleStats(int[] count) { + int kth(int k) { + int acc = 0; + for (int v = 0; v < count.Length; v++) { + acc += count[v]; + if (acc >= k) { + return v; + } + } + return 0; + } + + int tot = 0; + long cnt = 0; + int? mini = null; + int maxi = 0; + int mode = 0; + int modeCnt = 0; + + for (int v = 0; v < count.Length; v++) { + int c = count[v]; + if (c > 0) { + if (mini == null) { + mini = v; + } + maxi = v; + tot += c; + cnt += (long)v * c; + if (c > modeCnt) { + modeCnt = c; + mode = v; + } + } + } + + double m; + if (tot % 2 == 1) { + m = kth(tot / 2 + 1); + } else { + m = (kth(tot / 2) + kth(tot / 2 + 1)) / 2.0; + } + + return new double[] { (double)mini!, (double)maxi, (double)cnt / tot, m, (double)mode }; + } +} diff --git a/tests/1001-1500/1093. statistics-from-a-large-sample/sol.dart b/tests/1001-1500/1093. statistics-from-a-large-sample/sol.dart new file mode 100644 index 00000000..2795a27b --- /dev/null +++ b/tests/1001-1500/1093. statistics-from-a-large-sample/sol.dart @@ -0,0 +1,44 @@ +class Solution { + List sampleStats(List count) { + int kth(int k) { + int acc = 0; + for (int v = 0; v < count.length; v++) { + acc += count[v]; + if (acc >= k) { + return v; + } + } + return 0; + } + + int tot = 0; + int cnt = 0; + int? mini; + int maxi = 0; + int mode = 0; + int modeCnt = 0; + + for (int v = 0; v < count.length; v++) { + int c = count[v]; + if (c > 0) { + mini ??= v; + maxi = v; + tot += c; + cnt += v * c; + if (c > modeCnt) { + modeCnt = c; + mode = v; + } + } + } + + double m; + if (tot % 2 == 1) { + m = kth(tot ~/ 2 + 1).toDouble(); + } else { + m = (kth(tot ~/ 2) + kth(tot ~/ 2 + 1)) / 2.0; + } + + return [mini!.toDouble(), maxi.toDouble(), cnt / tot.toDouble(), m, mode.toDouble()]; + } +} diff --git a/tests/1001-1500/1093. statistics-from-a-large-sample/sol.go b/tests/1001-1500/1093. statistics-from-a-large-sample/sol.go new file mode 100644 index 00000000..fa9aff00 --- /dev/null +++ b/tests/1001-1500/1093. statistics-from-a-large-sample/sol.go @@ -0,0 +1,43 @@ +func sampleStats(count []int) []float64 { + kth := func(k int) int { + acc := 0 + for v, c := range count { + acc += c + if acc >= k { + return v + } + } + return 0 + } + + tot := 0 + cnt := 0 + mini := -1 + maxi := 0 + mode := 0 + modeCnt := 0 + + for v, c := range count { + if c > 0 { + if mini == -1 { + mini = v + } + maxi = v + tot += c + cnt += v * c + if c > modeCnt { + modeCnt = c + mode = v + } + } + } + + var m float64 + if tot%2 == 1 { + m = float64(kth(tot/2 + 1)) + } else { + m = float64(kth(tot/2)+kth(tot/2+1)) / 2.0 + } + + return []float64{float64(mini), float64(maxi), float64(cnt) / float64(tot), m, float64(mode)} +} diff --git a/tests/1001-1500/1093. statistics-from-a-large-sample/sol.java b/tests/1001-1500/1093. statistics-from-a-large-sample/sol.java new file mode 100644 index 00000000..fd6359e0 --- /dev/null +++ b/tests/1001-1500/1093. statistics-from-a-large-sample/sol.java @@ -0,0 +1,46 @@ +class Solution { + public double[] sampleStats(int[] count) { + int tot = 0; + long cnt = 0; + Integer mini = null; + int maxi = 0; + int mode = 0; + int modeCnt = 0; + + for (int v = 0; v < count.length; v++) { + int c = count[v]; + if (c > 0) { + if (mini == null) { + mini = v; + } + maxi = v; + tot += c; + cnt += (long) v * c; + if (c > modeCnt) { + modeCnt = c; + mode = v; + } + } + } + + double m; + if (tot % 2 == 1) { + m = kth(count, tot / 2 + 1); + } else { + m = (kth(count, tot / 2) + kth(count, tot / 2 + 1)) / 2.0; + } + + return new double[]{(double) mini, (double) maxi, (double) cnt / tot, m, (double) mode}; + } + + private int kth(int[] count, int k) { + int acc = 0; + for (int v = 0; v < count.length; v++) { + acc += count[v]; + if (acc >= k) { + return v; + } + } + return 0; + } +} diff --git a/tests/1001-1500/1093. statistics-from-a-large-sample/sol.kt b/tests/1001-1500/1093. statistics-from-a-large-sample/sol.kt new file mode 100644 index 00000000..fe3a13e3 --- /dev/null +++ b/tests/1001-1500/1093. statistics-from-a-large-sample/sol.kt @@ -0,0 +1,45 @@ +class Solution { + fun sampleStats(count: IntArray): DoubleArray { + fun kth(k: Int): Int { + var acc = 0 + for (v in count.indices) { + acc += count[v] + if (acc >= k) { + return v + } + } + return 0 + } + + var tot = 0 + var cnt = 0L + var mini: Int? = null + var maxi = 0 + var mode = 0 + var modeCnt = 0 + + for (v in count.indices) { + val c = count[v] + if (c > 0) { + if (mini == null) { + mini = v + } + maxi = v + tot += c + cnt += v.toLong() * c + if (c > modeCnt) { + modeCnt = c + mode = v + } + } + } + + val m = if (tot % 2 == 1) { + kth(tot / 2 + 1).toDouble() + } else { + (kth(tot / 2) + kth(tot / 2 + 1)) / 2.0 + } + + return doubleArrayOf(mini!!.toDouble(), maxi.toDouble(), cnt.toDouble() / tot, m, mode.toDouble()) + } +} diff --git a/tests/1001-1500/1093. statistics-from-a-large-sample/sol.py b/tests/1001-1500/1093. statistics-from-a-large-sample/sol.py new file mode 100644 index 00000000..e939fd79 --- /dev/null +++ b/tests/1001-1500/1093. statistics-from-a-large-sample/sol.py @@ -0,0 +1,30 @@ +class Solution: + def sampleStats(self, count: list[int]) -> list[float]: + def kth(k): + acc = 0 + for v, c in enumerate(count): + acc += c + if acc >= k: + return v + + tot, cnt = 0, 0 + mini, maxi = None, None + mode, modeCnt = 0, 0 + + for v, c in enumerate(count): + if c: + if mini is None: + mini = v + maxi = v + tot += c + cnt += v * c + if c > modeCnt: + modeCnt = c + mode = v + + if tot % 2 == 1: + m = kth(tot // 2 + 1) + else: + m = (kth(tot // 2) + kth(tot // 2 + 1)) / 2 + + return [float(mini), float(maxi), cnt / tot, float(m), float(mode)] diff --git a/tests/1001-1500/1093. statistics-from-a-large-sample/sol.py2 b/tests/1001-1500/1093. statistics-from-a-large-sample/sol.py2 new file mode 100644 index 00000000..055d7801 --- /dev/null +++ b/tests/1001-1500/1093. statistics-from-a-large-sample/sol.py2 @@ -0,0 +1,34 @@ +class Solution(object): + def sampleStats(self, count): + """ + :type count: List[int] + :rtype: List[float] + """ + def kth(k): + acc = 0 + for v, c in enumerate(count): + acc += c + if acc >= k: + return v + + tot, cnt = 0, 0 + mini, maxi = None, None + mode, modeCnt = 0, 0 + + for v, c in enumerate(count): + if c: + if mini is None: + mini = v + maxi = v + tot += c + cnt += v * c + if c > modeCnt: + modeCnt = c + mode = v + + if tot % 2 == 1: + m = kth(tot // 2 + 1) + else: + m = (kth(tot // 2) + kth(tot // 2 + 1)) / 2.0 + + return [float(mini), float(maxi), cnt / float(tot), float(m), float(mode)] diff --git a/tests/1001-1500/1093. statistics-from-a-large-sample/sol.rb b/tests/1001-1500/1093. statistics-from-a-large-sample/sol.rb new file mode 100644 index 00000000..31e55a99 --- /dev/null +++ b/tests/1001-1500/1093. statistics-from-a-large-sample/sol.rb @@ -0,0 +1,39 @@ +# @param {Integer[]} count +# @return {Float[]} +def sample_stats(count) + kth = ->(k) { + acc = 0 + count.each_with_index do |c, v| + acc += c + return v if acc >= k + end + } + + tot = 0 + cnt = 0 + mini = nil + maxi = nil + mode = 0 + mode_cnt = 0 + + count.each_with_index do |c, v| + if c > 0 + mini = v if mini.nil? + maxi = v + tot += c + cnt += v * c + if c > mode_cnt + mode_cnt = c + mode = v + end + end + end + + m = if tot % 2 == 1 + kth.call(tot / 2 + 1) + else + (kth.call(tot / 2) + kth.call(tot / 2 + 1)) / 2.0 + end + + [mini.to_f, maxi.to_f, cnt.to_f / tot, m.to_f, mode.to_f] +end diff --git a/tests/1001-1500/1093. statistics-from-a-large-sample/sol.rs b/tests/1001-1500/1093. statistics-from-a-large-sample/sol.rs new file mode 100644 index 00000000..03a611af --- /dev/null +++ b/tests/1001-1500/1093. statistics-from-a-large-sample/sol.rs @@ -0,0 +1,44 @@ +impl Solution { + pub fn sample_stats(count: Vec) -> Vec { + fn kth(count: &Vec, k: i32) -> i32 { + let mut acc = 0; + for (v, &c) in count.iter().enumerate() { + acc += c; + if acc >= k { + return v as i32; + } + } + 0 + } + + let mut tot = 0; + let mut cnt = 0i64; + let mut mini = -1; + let mut maxi = 0; + let mut mode = 0; + let mut mode_cnt = 0; + + for (v, &c) in count.iter().enumerate() { + if c > 0 { + if mini == -1 { + mini = v as i32; + } + maxi = v as i32; + tot += c; + cnt += v as i64 * c as i64; + if c > mode_cnt { + mode_cnt = c; + mode = v as i32; + } + } + } + + let m = if tot % 2 == 1 { + kth(&count, tot / 2 + 1) as f64 + } else { + (kth(&count, tot / 2) + kth(&count, tot / 2 + 1)) as f64 / 2.0 + }; + + vec![mini as f64, maxi as f64, cnt as f64 / tot as f64, m, mode as f64] + } +} diff --git a/tests/1001-1500/1093. statistics-from-a-large-sample/sol.swift b/tests/1001-1500/1093. statistics-from-a-large-sample/sol.swift new file mode 100644 index 00000000..11369074 --- /dev/null +++ b/tests/1001-1500/1093. statistics-from-a-large-sample/sol.swift @@ -0,0 +1,45 @@ +class Solution { + func sampleStats(_ count: [Int]) -> [Double] { + func kth(_ k: Int) -> Int { + var acc = 0 + for (v, c) in count.enumerated() { + acc += c + if acc >= k { + return v + } + } + return 0 + } + + var tot = 0 + var cnt = 0 + var mini: Int? + var maxi = 0 + var mode = 0 + var modeCnt = 0 + + for (v, c) in count.enumerated() { + if c > 0 { + if mini == nil { + mini = v + } + maxi = v + tot += c + cnt += v * c + if c > modeCnt { + modeCnt = c + mode = v + } + } + } + + let m: Double + if tot % 2 == 1 { + m = Double(kth(tot / 2 + 1)) + } else { + m = Double(kth(tot / 2) + kth(tot / 2 + 1)) / 2.0 + } + + return [Double(mini!), Double(maxi), Double(cnt) / Double(tot), m, Double(mode)] + } +} diff --git a/tests/1001-1500/1093. statistics-from-a-large-sample/sol.ts b/tests/1001-1500/1093. statistics-from-a-large-sample/sol.ts new file mode 100644 index 00000000..a2234453 --- /dev/null +++ b/tests/1001-1500/1093. statistics-from-a-large-sample/sol.ts @@ -0,0 +1,41 @@ +function Solution() { + return { + sampleStats(count: number[]): number[] { + const kth = (k: number): number => { + let acc = 0; + for (let v = 0; v < count.length; v++) { + acc += count[v]; + if (acc >= k) return v; + } + return 0; + }; + + let total = 0; + let sum = 0; + let minV = -1; + let maxV = 0; + let mode = 0; + let modeCnt = -1; + + for (let v = 0; v < count.length; v++) { + const c = count[v]; + if (c === 0) continue; + if (minV === -1) minV = v; + maxV = v; + total += c; + sum += v * c; + if (c > modeCnt) { + modeCnt = c; + mode = v; + } + } + + const median = + total % 2 === 1 + ? kth(Math.floor(total / 2) + 1) + : (kth(total / 2) + kth(total / 2 + 1)) / 2.0; + + return [minV, maxV, sum / total, median, mode]; + }, + }; +} diff --git a/tests/1001-1500/1094. car-pooling/manifest.yaml b/tests/1001-1500/1094. car-pooling/manifest.yaml new file mode 100644 index 00000000..e041789a --- /dev/null +++ b/tests/1001-1500/1094. car-pooling/manifest.yaml @@ -0,0 +1,2509 @@ +entry: + id: 1094 + title: car-pooling + params: + trips: + type: array + items: + type: array + items: + type: int + capacity: + type: int + call: + cpp: "Solution().carPooling({trips}, {capacity})" + rust: "Solution::car_pooling({trips}, {capacity})" + python3: "Solution().carPooling({trips}, {capacity})" + python2: "Solution().carPooling({trips}, {capacity})" + ruby: "car_pooling({trips}, {capacity})" + java: "new Solution().carPooling({trips}, {capacity})" + csharp: "new Solution().CarPooling({trips}, {capacity})" + kotlin: "Solution().carPooling({trips}, {capacity})" + go: "carPooling({trips}, {capacity})" + dart: "Solution().carPooling({trips}, {capacity})" + swift: "Solution().carPooling({trips}, {capacity})" + typescript: "Solution().carPooling({trips}, {capacity})" +judge: + type: "exact" +limits: + time_ms: 2000 + memory_mb: 256 +oracle: + python3: + call: "Checker().carPooling(trips, capacity, {result})" + checker: | + class Checker: + def carPooling(self, trips, capacity, result): + if not isinstance(result, bool): + return False + events = [] + for trip in trips: + if not (isinstance(trip, list) and len(trip) == 3): + return False + num, start, end = trip + events.append((start, num)) + events.append((end, -num)) + events.sort(key=lambda x: (x[0], x[1])) + cur = 0 + ok = True + for _, delta in events: + cur += delta + if cur > capacity: + ok = False + break + return result == ok +seed: 12345 +tests: + - name: "example-1" + in: + trips: + - [2, 1, 5] + - [3, 3, 7] + capacity: 4 + judge: + type: "exact" + seed: 17 + - name: "example-2" + in: + trips: + - [2, 1, 5] + - [3, 3, 7] + capacity: 5 + judge: + type: "exact" + seed: 34 + - name: "single-fit" + in: + trips: + - [1, 0, 1] + capacity: 1 + judge: + type: "exact" + seed: 51 + - name: "single-over" + in: + trips: + - [2, 0, 5] + capacity: 1 + judge: + type: "exact" + seed: 68 + - name: "touching-endpoints" + in: + trips: + - [2, 1, 5] + - [3, 5, 7] + capacity: 3 + judge: + type: "exact" + seed: 85 + - name: "touching-endpoints-fit" + in: + trips: + - [2, 1, 5] + - [3, 5, 7] + capacity: 5 + judge: + type: "exact" + seed: 102 + - name: "nested-trips" + in: + trips: + - [3, 2, 8] + - [2, 3, 7] + - [2, 5, 6] + capacity: 7 + judge: + type: "exact" + seed: 119 + - name: "nested-trips-over" + in: + trips: + - [3, 2, 8] + - [2, 3, 7] + - [2, 5, 6] + capacity: 6 + judge: + type: "exact" + seed: 136 + - name: "ordered-simple" + in: + trips: + - [1, 1, 2] + - [1, 2, 3] + - [1, 3, 4] + capacity: 1 + judge: + type: "exact" + seed: 153 + - name: "ordered-simple-fit" + in: + trips: + - [1, 1, 2] + - [1, 2, 3] + - [1, 3, 4] + capacity: 2 + judge: + type: "exact" + seed: 170 + - name: "unordered" + in: + trips: + - [3, 5, 7] + - [2, 1, 4] + - [4, 2, 6] + capacity: 6 + judge: + type: "exact" + seed: 187 + - name: "unordered-over" + in: + trips: + - [3, 5, 7] + - [2, 1, 4] + - [4, 2, 6] + capacity: 5 + judge: + type: "exact" + seed: 204 + - name: "same-start" + in: + trips: + - [2, 1, 5] + - [2, 1, 3] + - [1, 1, 2] + capacity: 4 + judge: + type: "exact" + seed: 221 + - name: "same-start-over" + in: + trips: + - [2, 1, 5] + - [2, 1, 3] + - [1, 1, 2] + capacity: 3 + judge: + type: "exact" + seed: 238 + - name: "same-end" + in: + trips: + - [2, 1, 5] + - [2, 2, 5] + - [1, 3, 5] + capacity: 5 + judge: + type: "exact" + seed: 255 + - name: "same-end-over" + in: + trips: + - [2, 1, 5] + - [2, 2, 5] + - [1, 3, 5] + capacity: 4 + judge: + type: "exact" + seed: 272 + - name: "zero-gap" + in: + trips: + - [1, 0, 2] + - [1, 2, 4] + - [1, 4, 6] + capacity: 1 + judge: + type: "exact" + seed: 289 + - name: "zero-gap-overlap" + in: + trips: + - [2, 0, 2] + - [2, 2, 4] + - [2, 4, 6] + capacity: 2 + judge: + type: "exact" + seed: 306 + - name: "peak-1" + in: + trips: + - [4, 0, 10] + - [3, 2, 8] + - [2, 5, 7] + capacity: 9 + judge: + type: "exact" + seed: 323 + - name: "peak-2" + in: + trips: + - [4, 0, 10] + - [3, 2, 8] + - [2, 5, 7] + capacity: 8 + judge: + type: "exact" + seed: 340 + - name: "many-small-fit" + in: + trips: + - [1, 0, 100] + - [1, 1, 99] + - [1, 2, 98] + - [1, 3, 97] + capacity: 4 + judge: + type: "exact" + seed: 357 + - name: "many-small-over" + in: + trips: + - [1, 0, 100] + - [1, 1, 99] + - [1, 2, 98] + - [1, 3, 97] + capacity: 3 + judge: + type: "exact" + seed: 374 + - name: "large-capacity" + in: + trips: + - [100, 0, 1000] + - [100, 0, 1000] + - [100, 0, 1000] + capacity: 300 + judge: + type: "exact" + seed: 391 + - name: "large-capacity-over" + in: + trips: + - [100, 0, 1000] + - [100, 0, 1000] + - [100, 0, 1000] + capacity: 299 + judge: + type: "exact" + seed: 408 + - name: "boundary-1000" + in: + trips: + - [1, 0, 1000] + - [1, 999, 1000] + capacity: 1 + judge: + type: "exact" + seed: 425 + - name: "boundary-1000-over" + in: + trips: + - [1, 0, 1000] + - [1, 999, 1000] + capacity: 0 + judge: + type: "exact" + seed: 442 + - name: "chain-fit" + in: + trips: + - [2, 0, 3] + - [3, 3, 6] + - [4, 6, 9] + capacity: 4 + judge: + type: "exact" + seed: 459 + - name: "chain-over" + in: + trips: + - [2, 0, 3] + - [3, 3, 6] + - [4, 6, 9] + capacity: 3 + judge: + type: "exact" + seed: 476 + - name: "random-1" + in: + trips: + - [5, 2, 7] + - [3, 0, 3] + - [4, 4, 9] + - [2, 6, 8] + capacity: 8 + judge: + type: "exact" + seed: 493 + - name: "random-2" + in: + trips: + - [5, 2, 7] + - [3, 0, 3] + - [4, 4, 9] + - [2, 6, 8] + capacity: 7 + judge: + type: "exact" + seed: 510 + - name: "random-3" + in: + trips: + - [1, 10, 20] + - [2, 15, 25] + - [3, 20, 30] + capacity: 3 + judge: + type: "exact" + seed: 527 + - name: "random-4" + in: + trips: + - [1, 10, 20] + - [2, 15, 25] + - [3, 20, 30] + capacity: 2 + judge: + type: "exact" + seed: 544 + - name: "max-trips-simple" + in: + trips: + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + capacity: 1000 + judge: + type: "exact" + seed: 561 + - name: "max-trips-over" + in: + trips: + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + - [1, 0, 1] + capacity: 999 + judge: + type: "exact" + seed: 578 + - name: "dense-overlap" + in: + trips: + - [1, 0, 10] + - [1, 2, 12] + - [1, 4, 14] + - [1, 6, 16] + - [1, 8, 18] + - [1, 10, 20] + - [1, 12, 22] + - [1, 14, 24] + - [1, 16, 26] + - [1, 18, 28] + - [1, 20, 30] + - [1, 22, 32] + - [1, 24, 34] + - [1, 26, 36] + - [1, 28, 38] + - [1, 30, 40] + - [1, 32, 42] + - [1, 34, 44] + - [1, 36, 46] + - [1, 38, 48] + - [1, 40, 50] + - [1, 42, 52] + - [1, 44, 54] + - [1, 46, 56] + - [1, 48, 58] + - [1, 50, 60] + - [1, 52, 62] + - [1, 54, 64] + - [1, 56, 66] + - [1, 58, 68] + - [1, 60, 70] + - [1, 62, 72] + - [1, 64, 74] + - [1, 66, 76] + - [1, 68, 78] + - [1, 70, 80] + - [1, 72, 82] + - [1, 74, 84] + - [1, 76, 86] + - [1, 78, 88] + - [1, 80, 90] + - [1, 82, 92] + - [1, 84, 94] + - [1, 86, 96] + - [1, 88, 98] + - [1, 90, 100] + - [1, 92, 102] + - [1, 94, 104] + - [1, 96, 106] + - [1, 98, 108] + capacity: 25 + judge: + type: "exact" + seed: 595 + - name: "dense-overlap-fail" + in: + trips: + - [1, 0, 10] + - [1, 2, 12] + - [1, 4, 14] + - [1, 6, 16] + - [1, 8, 18] + - [1, 10, 20] + - [1, 12, 22] + - [1, 14, 24] + - [1, 16, 26] + - [1, 18, 28] + - [1, 20, 30] + - [1, 22, 32] + - [1, 24, 34] + - [1, 26, 36] + - [1, 28, 38] + - [1, 30, 40] + - [1, 32, 42] + - [1, 34, 44] + - [1, 36, 46] + - [1, 38, 48] + - [1, 40, 50] + - [1, 42, 52] + - [1, 44, 54] + - [1, 46, 56] + - [1, 48, 58] + - [1, 50, 60] + - [1, 52, 62] + - [1, 54, 64] + - [1, 56, 66] + - [1, 58, 68] + - [1, 60, 70] + - [1, 62, 72] + - [1, 64, 74] + - [1, 66, 76] + - [1, 68, 78] + - [1, 70, 80] + - [1, 72, 82] + - [1, 74, 84] + - [1, 76, 86] + - [1, 78, 88] + - [1, 80, 90] + - [1, 82, 92] + - [1, 84, 94] + - [1, 86, 96] + - [1, 88, 98] + - [1, 90, 100] + - [1, 92, 102] + - [1, 94, 104] + - [1, 96, 106] + - [1, 98, 108] + capacity: 4 + judge: + type: "exact" + seed: 612 + - name: "staggered" + in: + trips: + - [2, 0, 4] + - [2, 1, 5] + - [2, 2, 6] + - [2, 3, 7] + capacity: 7 + judge: + type: "exact" + seed: 629 diff --git a/tests/1001-1500/1094. car-pooling/sol.cpp b/tests/1001-1500/1094. car-pooling/sol.cpp new file mode 100644 index 00000000..81cc5cc5 --- /dev/null +++ b/tests/1001-1500/1094. car-pooling/sol.cpp @@ -0,0 +1,23 @@ +class Solution { +public: + bool carPooling(vector>& trips, int capacity) { + sort(trips.begin(), trips.end(), [](const vector& a, const vector& b) { + return a[1] < b[1]; + }); + priority_queue, vector>, greater>> heap; + int currentPassengers = 0; + for (const auto& trip : trips) { + int num = trip[0], src = trip[1], dest = trip[2]; + while (!heap.empty() && heap.top().first <= src) { + currentPassengers -= heap.top().second; + heap.pop(); + } + if (currentPassengers + num > capacity) { + return false; + } + currentPassengers += num; + heap.push({dest, num}); + } + return true; + } +}; diff --git a/tests/1001-1500/1094. car-pooling/sol.cs b/tests/1001-1500/1094. car-pooling/sol.cs new file mode 100644 index 00000000..437e0d8a --- /dev/null +++ b/tests/1001-1500/1094. car-pooling/sol.cs @@ -0,0 +1,18 @@ +public class Solution { + public bool CarPooling(int[][] trips, int capacity) { + int[] diff = new int[1001]; + foreach (var trip in trips) { + int num = trip[0], start = trip[1], end = trip[2]; + diff[start] += num; + diff[end] -= num; + } + int curr = 0; + foreach (int delta in diff) { + curr += delta; + if (curr > capacity) { + return false; + } + } + return true; + } +} diff --git a/tests/1001-1500/1094. car-pooling/sol.dart b/tests/1001-1500/1094. car-pooling/sol.dart new file mode 100644 index 00000000..c69da400 --- /dev/null +++ b/tests/1001-1500/1094. car-pooling/sol.dart @@ -0,0 +1,21 @@ +import 'dart:collection'; + +class Solution { + bool carPooling(List> trips, int capacity) { + trips.sort((a, b) => a[1].compareTo(b[1])); + var heap = PriorityQueue>((a, b) => a[0].compareTo(b[0])); + int currentPassengers = 0; + for (var trip in trips) { + int num = trip[0], src = trip[1], dest = trip[2]; + while (heap.isNotEmpty && heap.first[0] <= src) { + currentPassengers -= heap.removeFirst()[1]; + } + if (currentPassengers + num > capacity) { + return false; + } + currentPassengers += num; + heap.add([dest, num]); + } + return true; + } +} diff --git a/tests/1001-1500/1094. car-pooling/sol.go b/tests/1001-1500/1094. car-pooling/sol.go new file mode 100644 index 00000000..84f7fab1 --- /dev/null +++ b/tests/1001-1500/1094. car-pooling/sol.go @@ -0,0 +1,16 @@ +func carPooling(trips [][]int, capacity int) bool { + diff := make([]int, 1001) + for _, trip := range trips { + num, start, end := trip[0], trip[1], trip[2] + diff[start] += num + diff[end] -= num + } + curr := 0 + for _, delta := range diff { + curr += delta + if curr > capacity { + return false + } + } + return true +} diff --git a/tests/1001-1500/1094. car-pooling/sol.java b/tests/1001-1500/1094. car-pooling/sol.java new file mode 100644 index 00000000..b154d7fe --- /dev/null +++ b/tests/1001-1500/1094. car-pooling/sol.java @@ -0,0 +1,23 @@ +import java.util.PriorityQueue; +import java.util.Arrays; +import java.util.Comparator; + +class Solution { + public boolean carPooling(int[][] trips, int capacity) { + Arrays.sort(trips, Comparator.comparingInt(a -> a[1])); + PriorityQueue heap = new PriorityQueue<>(Comparator.comparingInt(a -> a[0])); + int currentPassengers = 0; + for (int[] trip : trips) { + int num = trip[0], src = trip[1], dest = trip[2]; + while (!heap.isEmpty() && heap.peek()[0] <= src) { + currentPassengers -= heap.poll()[1]; + } + if (currentPassengers + num > capacity) { + return false; + } + currentPassengers += num; + heap.offer(new int[]{dest, num}); + } + return true; + } +} diff --git a/tests/1001-1500/1094. car-pooling/sol.kt b/tests/1001-1500/1094. car-pooling/sol.kt new file mode 100644 index 00000000..49cd4186 --- /dev/null +++ b/tests/1001-1500/1094. car-pooling/sol.kt @@ -0,0 +1,23 @@ +import java.util.PriorityQueue + +class Solution { + fun carPooling(trips: Array, capacity: Int): Boolean { + trips.sortBy { it[1] } + val heap = PriorityQueue(compareBy { it[0] }) + var currentPassengers = 0 + for (trip in trips) { + val num = trip[0] + val src = trip[1] + val dest = trip[2] + while (heap.isNotEmpty() && heap.peek()[0] <= src) { + currentPassengers -= heap.poll()[1] + } + if (currentPassengers + num > capacity) { + return false + } + currentPassengers += num + heap.offer(intArrayOf(dest, num)) + } + return true + } +} diff --git a/tests/1001-1500/1094. car-pooling/sol.py b/tests/1001-1500/1094. car-pooling/sol.py new file mode 100644 index 00000000..d6f63f23 --- /dev/null +++ b/tests/1001-1500/1094. car-pooling/sol.py @@ -0,0 +1,13 @@ +class Solution: + def carPooling(self, trips: List[List[int]], capacity: int) -> bool: + trips.sort(key=lambda x: x[1]) + heap = [] + current_passengers = 0 + for num, src, dest in trips: + while heap and heap[0][0] <= src: + current_passengers -= heapq.heappop(heap)[1] + if current_passengers + num > capacity: + return False + current_passengers += num + heapq.heappush(heap, (dest, num)) + return True diff --git a/tests/1001-1500/1094. car-pooling/sol.py2 b/tests/1001-1500/1094. car-pooling/sol.py2 new file mode 100644 index 00000000..512db260 --- /dev/null +++ b/tests/1001-1500/1094. car-pooling/sol.py2 @@ -0,0 +1,18 @@ +class Solution(object): + def carPooling(self, trips, capacity): + """ + :type trips: List[List[int]] + :type capacity: int + :rtype: bool + """ + trips.sort(key=lambda x: x[1]) + heap = [] + current_passengers = 0 + for num, src, dest in trips: + while heap and heap[0][0] <= src: + current_passengers -= heapq.heappop(heap)[1] + if current_passengers + num > capacity: + return False + current_passengers += num + heapq.heappush(heap, (dest, num)) + return True diff --git a/tests/1001-1500/1094. car-pooling/sol.rb b/tests/1001-1500/1094. car-pooling/sol.rb new file mode 100644 index 00000000..89c6e184 --- /dev/null +++ b/tests/1001-1500/1094. car-pooling/sol.rb @@ -0,0 +1,20 @@ +# @param {Integer[][]} trips +# @param {Integer} capacity +# @return {Boolean} +def car_pooling(trips, capacity) + trips.sort_by! { |trip| trip[1] } + heap = [] + current_passengers = 0 + trips.each do |num, src, dest| + while !heap.empty? && heap[0][0] <= src + current_passengers -= heap.shift[1] + end + if current_passengers + num > capacity + return false + end + current_passengers += num + heap.push([dest, num]) + heap.sort_by! { |h| h[0] } + end + true +end diff --git a/tests/1001-1500/1094. car-pooling/sol.rs b/tests/1001-1500/1094. car-pooling/sol.rs new file mode 100644 index 00000000..5b44b3d2 --- /dev/null +++ b/tests/1001-1500/1094. car-pooling/sol.rs @@ -0,0 +1,30 @@ +impl Solution { + pub fn car_pooling(trips: Vec>, capacity: i32) -> bool { + use std::collections::BinaryHeap; + use std::cmp::Reverse; + + let mut trips = trips; + trips.sort_by_key(|trip| trip[1]); + let mut heap: BinaryHeap> = BinaryHeap::new(); + let mut current_passengers = 0; + for trip in trips { + let num = trip[0]; + let src = trip[1]; + let dest = trip[2]; + while let Some(Reverse((top_dest, top_num))) = heap.peek() { + if *top_dest <= src { + current_passengers -= top_num; + heap.pop(); + } else { + break; + } + } + if current_passengers + num > capacity { + return false; + } + current_passengers += num; + heap.push(Reverse((dest, num))); + } + true + } +} diff --git a/tests/1001-1500/1094. car-pooling/sol.swift b/tests/1001-1500/1094. car-pooling/sol.swift new file mode 100644 index 00000000..6b9702b6 --- /dev/null +++ b/tests/1001-1500/1094. car-pooling/sol.swift @@ -0,0 +1,17 @@ +class Solution { + func carPooling(_ trips: [[Int]], _ capacity: Int) -> Bool { + var diff = Array(repeating: 0, count: 1001) + for trip in trips { + diff[trip[1]] += trip[0] + diff[trip[2]] -= trip[0] + } + var curr = 0 + for delta in diff { + curr += delta + if curr > capacity { + return false + } + } + return true + } +} diff --git a/tests/1001-1500/1094. car-pooling/sol.ts b/tests/1001-1500/1094. car-pooling/sol.ts new file mode 100644 index 00000000..17d7dad8 --- /dev/null +++ b/tests/1001-1500/1094. car-pooling/sol.ts @@ -0,0 +1,19 @@ +function Solution() { + return { + carPooling(trips: number[][], capacity: number): boolean { + const diff = new Array(1001).fill(0); + for (const trip of trips) { + diff[trip[1]] += trip[0]; + diff[trip[2]] -= trip[0]; + } + let curr = 0; + for (const delta of diff) { + curr += delta; + if (curr > capacity) { + return false; + } + } + return true; + }, + }; +} diff --git a/tests/1001-1500/1096. brace-expansion-ii/manifest.yaml b/tests/1001-1500/1096. brace-expansion-ii/manifest.yaml new file mode 100644 index 00000000..aba539d5 --- /dev/null +++ b/tests/1001-1500/1096. brace-expansion-ii/manifest.yaml @@ -0,0 +1,337 @@ +entry: + id: 1096 + title: brace-expansion-ii + params: + expression: + type: string + call: + cpp: Solution().braceExpansionII({expression}) + rust: Solution::brace_expansion_ii({expression}) + python3: Solution().braceExpansionII({expression}) + python2: Solution().braceExpansionII({expression}) + ruby: brace_expansion_ii({expression}) + java: new Solution().braceExpansionII({expression}) + csharp: new Solution().BraceExpansionII({expression}) + kotlin: Solution().braceExpansionII({expression}) + go: braceExpansionII({expression}) + dart: Solution().braceExpansionII({expression}) + swift: Solution().braceExpansionII({expression}) + typescript: braceExpansionII({expression}) + +judge: + type: exact + +limits: + time_ms: 1000 + memory_mb: 128 + +oracle: + python3: + call: Checker().check(expression, {result}) + checker: | + class Checker(object): + def check(self, expression, result): + stack = [] + res = [] + cur = [] + for ch in expression: + if ch.isalpha(): + cur = [c + ch for c in (cur or [''])] + elif ch == '{': + stack.append(res) + stack.append(cur) + res, cur = [], [] + elif ch == '}': + pre = stack.pop() + pre_res = stack.pop() + cur = [p + c for c in res + cur for p in (pre or [''])] + res = pre_res + elif ch == ',': + res += cur + cur = [] + expected = sorted(set(res + cur)) + return result == expected + +seed: 1096 + +tests: + - name: example_1 + in: + expression: "{a,b}{c,{d,e}}" + out: + - ac + - ad + - ae + - bc + - bd + - be + - name: example_2 + in: + expression: "{{a,z},a{b,c},{ab,z}}" + out: + - a + - ab + - ac + - z + - name: single_letter + in: + expression: a + out: + - a + - name: simple_union + in: + expression: "{a,b}" + out: + - a + - b + - name: simple_concat + in: + expression: "ab" + out: + - ab + - name: nested_union_concat + in: + expression: "{a,b}{c,d}" + out: + - ac + - ad + - bc + - bd + - name: repeated_duplicates + in: + expression: "{{a,a},{a}}" + out: + - a + - name: three_way_union + in: + expression: "{a,b,c}" + out: + - a + - b + - c + - name: concat_with_tail + in: + expression: "a{b,c}d" + out: + - abd + - acd + - name: union_of_concats + in: + expression: "{ab,cd}{e,f}" + out: + - abe + - abf + - cde + - cdf + - name: deep_nesting_1 + in: + expression: "{{a,b},{c,{d,e}}}" + out: + - a + - b + - c + - d + - e + - name: deep_nesting_2 + in: + expression: "{{a,b}c,{d,e}f}" + out: + - ac + - bc + - df + - ef + - name: product_of_unions + in: + expression: "{a,b}{c,{d,e}}{f,g}" + out: + - acf + - acg + - adf + - adg + - aef + - aeg + - bcf + - bcg + - bdf + - bdg + - bef + - beg + - name: singleton_union_concat + in: + expression: "{a}{b}{c}" + out: + - abc + - name: long_simple_concat + in: + expression: abcdef + out: + - abcdef + - name: mix_commas_and_concat + in: + expression: "{a,b}{c}" + out: + - ac + - bc + - name: inner_union_chain + in: + expression: "{a,{b,c},d}" + out: + - a + - b + - c + - d + - name: duplicated_products + in: + expression: "{a,a}{b,b}" + out: + - ab + - name: bracketed_prefix + in: + expression: "{{a,b}c,{a,b}d}" + out: + - ac + - ad + - bc + - bd + - name: triple_group_concat + in: + expression: "{a,b}{c,d}{e,f}" + out: + - ace + - acf + - ade + - adf + - bce + - bcf + - bde + - bdf + - name: one_side_duplicate + in: + expression: "{a,b}{a,b}" + out: + - aa + - ab + - ba + - bb + - name: union_inside_concat + in: + expression: "x{a,b,c}y" + out: + - xay + - xby + - xcy + - name: adjacent_groups + in: + expression: "{a,b}{c,d}{e}" + out: + - ace + - ade + - bce + - bde + - name: simple_nested_one + in: + expression: "{a,{b,c}}d" + out: + - ad + - bd + - cd + - name: simple_nested_two + in: + expression: "a{{b,c},d}" + out: + - ab + - ac + - ad + - name: chain_with_duplicate_union + in: + expression: "{a,b}{c,c}{d,e}" + out: + - acd + - ace + - bcd + - bce + - name: nested_product_union + in: + expression: "{a,{b,c}}{d,{e,f}}" + out: + - ad + - ae + - af + - bd + - be + - bf + - cd + - ce + - cf + - name: four_way_union + in: + expression: "{a,b,c,d}" + out: + - a + - b + - c + - d + - name: trailing_concat + in: + expression: "{a,b}xy" + out: + - axy + - bxy + - name: leading_concat + in: + expression: "xy{a,b}" + out: + - xya + - xyb + - name: mixed_depth + in: + expression: "{{a,b}{c,d},e}" + out: + - ac + - ad + - bc + - bd + - e + - name: duplicate_merge + in: + expression: "{{a,b},{a,b}}" + out: + - a + - b + - name: flat_concat_with_union + in: + expression: "m{n,o}p{q,r}" + out: + - mnpq + - mnpr + - mopq + - mopr + - name: nested_singletons + in: + expression: "{{a},{b},{c}}" + out: + - a + - b + - c + - name: union_and_plain + in: + expression: "{ab,c}d" + out: + - abd + - cd + - name: many_duplicates + in: + expression: "{a,a,a}{b,b,c}" + out: + - ab + - ac + - name: final_mix + in: + expression: "{a,b}{c,{d,e}}f" + out: + - acf + - adf + - aef + - bcf + - bdf + - bef diff --git a/tests/1001-1500/1096. brace-expansion-ii/sol.cpp b/tests/1001-1500/1096. brace-expansion-ii/sol.cpp new file mode 100644 index 00000000..182af4da --- /dev/null +++ b/tests/1001-1500/1096. brace-expansion-ii/sol.cpp @@ -0,0 +1,49 @@ +class Solution { +public: + vector braceExpansionII(string expression) { + stack> stk; + vector res, cur; + for (char v : expression) { + if (isalpha(v)) { + if (cur.empty()) { + cur.push_back(string(1, v)); + } else { + vector next; + for (string& c : cur) { + next.push_back(c + v); + } + cur = next; + } + } else if (v == '{') { + stk.push(res); + stk.push(cur); + res.clear(); + cur.clear(); + } else if (v == '}') { + vector pre = stk.top(); stk.pop(); + vector preRes = stk.top(); stk.pop(); + vector merged = res; + merged.insert(merged.end(), cur.begin(), cur.end()); + if (pre.empty()) { + cur = merged; + } else { + vector next; + for (string& p : pre) { + for (string& c : merged) { + next.push_back(p + c); + } + } + cur = next; + } + res = preRes; + } else if (v == ',') { + res.insert(res.end(), cur.begin(), cur.end()); + cur.clear(); + } + } + res.insert(res.end(), cur.begin(), cur.end()); + sort(res.begin(), res.end()); + res.erase(unique(res.begin(), res.end()), res.end()); + return res; + } +}; diff --git a/tests/1001-1500/1096. brace-expansion-ii/sol.cs b/tests/1001-1500/1096. brace-expansion-ii/sol.cs new file mode 100644 index 00000000..896bd6a8 --- /dev/null +++ b/tests/1001-1500/1096. brace-expansion-ii/sol.cs @@ -0,0 +1,37 @@ +public class Solution { + public IList BraceExpansionII(string expression) { + Stack> stack = new Stack>(); + List res = new List(); + List cur = new List(); + foreach (char v in expression) { + if (char.IsLetter(v)) { + if (cur.Count == 0) { + cur = new List { v.ToString() }; + } else { + cur = cur.Select(c => c + v).ToList(); + } + } else if (v == '{') { + stack.Push(res); + stack.Push(new List(cur)); + res = new List(); + cur = new List(); + } else if (v == '}') { + List pre = stack.Pop(); + List preRes = stack.Pop(); + List merged = new List(res); + merged.AddRange(cur); + if (pre.Count == 0) { + cur = merged; + } else { + cur = pre.SelectMany(p => merged.Select(c => p + c)).ToList(); + } + res = preRes; + } else if (v == ',') { + res.AddRange(cur); + cur = new List(); + } + } + res.AddRange(cur); + return res.Distinct().OrderBy(s => s).ToList(); + } +} diff --git a/tests/1001-1500/1096. brace-expansion-ii/sol.dart b/tests/1001-1500/1096. brace-expansion-ii/sol.dart new file mode 100644 index 00000000..e51e82b8 --- /dev/null +++ b/tests/1001-1500/1096. brace-expansion-ii/sol.dart @@ -0,0 +1,39 @@ +class Solution { + List braceExpansionII(String expression) { + List> stack = []; + List res = []; + List cur = []; + for (int i = 0; i < expression.length; i++) { + String v = expression[i]; + if (v.codeUnitAt(0) >= 97 && v.codeUnitAt(0) <= 122) { + if (cur.isEmpty) { + cur = [v]; + } else { + cur = cur.map((c) => c + v).toList(); + } + } else if (v == '{') { + stack.add(res); + stack.add(cur); + res = []; + cur = []; + } else if (v == '}') { + List pre = stack.removeLast(); + List preRes = stack.removeLast(); + List merged = [...res, ...cur]; + if (pre.isEmpty) { + cur = merged; + } else { + cur = pre.expand((p) => merged.map((c) => p + c)).toList(); + } + res = preRes; + } else if (v == ',') { + res.addAll(cur); + cur = []; + } + } + Set set = {...res, ...cur}; + List result = set.toList(); + result.sort(); + return result; + } +} diff --git a/tests/1001-1500/1096. brace-expansion-ii/sol.go b/tests/1001-1500/1096. brace-expansion-ii/sol.go new file mode 100644 index 00000000..046131be --- /dev/null +++ b/tests/1001-1500/1096. brace-expansion-ii/sol.go @@ -0,0 +1,57 @@ +func braceExpansionII(expression string) []string { + stack := [][]string{} + res := []string{} + cur := []string{} + for i := 0; i < len(expression); i++ { + v := expression[i] + if v >= 'a' && v <= 'z' { + if len(cur) == 0 { + cur = append(cur, string(v)) + } else { + next := make([]string, len(cur)) + for j, c := range cur { + next[j] = c + string(v) + } + cur = next + } + } else if v == '{' { + stack = append(stack, res) + stack = append(stack, cur) + res = []string{} + cur = []string{} + } else if v == '}' { + pre := stack[len(stack)-1] + stack = stack[:len(stack)-1] + preRes := stack[len(stack)-1] + stack = stack[:len(stack)-1] + merged := append([]string{}, res...) + merged = append(merged, cur...) + if len(pre) == 0 { + cur = merged + } else { + next := []string{} + for _, p := range pre { + for _, c := range merged { + next = append(next, p + c) + } + } + cur = next + } + res = preRes + } else if v == ',' { + res = append(res, cur...) + cur = []string{} + } + } + res = append(res, cur...) + set := make(map[string]bool) + for _, s := range res { + set[s] = true + } + result := []string{} + for s := range set { + result = append(result, s) + } + sort.Strings(result) + return result +} diff --git a/tests/1001-1500/1096. brace-expansion-ii/sol.java b/tests/1001-1500/1096. brace-expansion-ii/sol.java new file mode 100644 index 00000000..0e9cf641 --- /dev/null +++ b/tests/1001-1500/1096. brace-expansion-ii/sol.java @@ -0,0 +1,52 @@ +class Solution { + public List braceExpansionII(String expression) { + Deque> stack = new ArrayDeque<>(); + List res = new ArrayList<>(); + List cur = new ArrayList<>(); + for (int i = 0; i < expression.length(); i++) { + char v = expression.charAt(i); + if (Character.isLetter(v)) { + if (cur.isEmpty()) { + cur = new ArrayList<>(); + cur.add(String.valueOf(v)); + } else { + List next = new ArrayList<>(); + for (String c : cur) { + next.add(c + v); + } + cur = next; + } + } else if (v == '{') { + stack.push(res); + stack.push(new ArrayList<>(cur)); + res = new ArrayList<>(); + cur = new ArrayList<>(); + } else if (v == '}') { + List pre = stack.pop(); + List preRes = stack.pop(); + List merged = new ArrayList<>(res); + merged.addAll(cur); + List next = new ArrayList<>(); + if (pre.isEmpty()) { + next = merged; + } else { + for (String p : pre) { + for (String c : merged) { + next.add(p + c); + } + } + } + cur = next; + res = preRes; + } else if (v == ',') { + res.addAll(cur); + cur = new ArrayList<>(); + } + } + res.addAll(cur); + Set set = new HashSet<>(res); + List result = new ArrayList<>(set); + Collections.sort(result); + return result; + } +} diff --git a/tests/1001-1500/1096. brace-expansion-ii/sol.kt b/tests/1001-1500/1096. brace-expansion-ii/sol.kt new file mode 100644 index 00000000..30e82fcd --- /dev/null +++ b/tests/1001-1500/1096. brace-expansion-ii/sol.kt @@ -0,0 +1,40 @@ +class Solution { + fun braceExpansionII(expression: String): List { + val stack = ArrayDeque>() + var res = mutableListOf() + var cur = mutableListOf() + for (v in expression) { + when { + v.isLetter() -> { + cur = if (cur.isEmpty()) { + mutableListOf(v.toString()) + } else { + cur.map { it + v }.toMutableList() + } + } + v == '{' -> { + stack.addLast(res) + stack.addLast(cur) + res = mutableListOf() + cur = mutableListOf() + } + v == '}' -> { + val pre = stack.removeLast() + val preRes = stack.removeLast() + val merged = res + cur + cur = if (pre.isEmpty()) { + merged.toMutableList() + } else { + pre.flatMap { p -> merged.map { p + it } }.toMutableList() + } + res = preRes + } + v == ',' -> { + res.addAll(cur) + cur = mutableListOf() + } + } + } + return (res + cur).toSet().sorted() + } +} diff --git a/tests/1001-1500/1096. brace-expansion-ii/sol.py b/tests/1001-1500/1096. brace-expansion-ii/sol.py new file mode 100644 index 00000000..834e48cc --- /dev/null +++ b/tests/1001-1500/1096. brace-expansion-ii/sol.py @@ -0,0 +1,20 @@ +class Solution: + def braceExpansionII(self, expression: str) -> List[str]: + stack, res, cur = [], [], [] + for i in range(len(expression)): + v = expression[i] + if v.isalpha(): + cur = [c + v for c in cur or [""]] + elif v == "{": + stack.append(res) + stack.append(cur) + res, cur = [], [] + elif v == "}": + pre = stack.pop() + preRes = stack.pop() + cur = [p + c for c in res + cur for p in pre or [""]] + res = preRes + elif v == ",": + res += cur + cur = [] + return sorted(set(res + cur)) diff --git a/tests/1001-1500/1096. brace-expansion-ii/sol.py2 b/tests/1001-1500/1096. brace-expansion-ii/sol.py2 new file mode 100644 index 00000000..75e23d20 --- /dev/null +++ b/tests/1001-1500/1096. brace-expansion-ii/sol.py2 @@ -0,0 +1,24 @@ +class Solution(object): + def braceExpansionII(self, expression): + """ + :type expression: str + :rtype: List[str] + """ + stack, res, cur = [], [], [] + for i in range(len(expression)): + v = expression[i] + if v.isalpha(): + cur = [c + v for c in cur or ['']] + elif v == '{': + stack.append(res) + stack.append(cur) + res, cur = [], [] + elif v == '}': + pre = stack.pop() + preRes = stack.pop() + cur = [p + c for c in res + cur for p in pre or ['']] + res = preRes + elif v == ',': + res += cur + cur = [] + return sorted(set(res + cur)) diff --git a/tests/1001-1500/1096. brace-expansion-ii/sol.rb b/tests/1001-1500/1096. brace-expansion-ii/sol.rb new file mode 100644 index 00000000..dd1d6476 --- /dev/null +++ b/tests/1001-1500/1096. brace-expansion-ii/sol.rb @@ -0,0 +1,30 @@ +# @param {String} expression +# @return {String[]} +def brace_expansion_ii(expression) + stack = [] + res = [] + cur = [] + expression.each_char do |v| + if v =~ /[a-z]/ + if cur.empty? + cur = [v] + else + cur = cur.map { |c| c + v } + end + elsif v == '{' + stack.push(res) + stack.push(cur) + res = [] + cur = [] + elsif v == '}' + pre = stack.pop + pre_res = stack.pop + cur = pre.empty? ? (res + cur) : pre.flat_map { |p| (res + cur).map { |c| p + c } } + res = pre_res + elsif v == ',' + res += cur + cur = [] + end + end + (res + cur).uniq.sort +end diff --git a/tests/1001-1500/1096. brace-expansion-ii/sol.rs b/tests/1001-1500/1096. brace-expansion-ii/sol.rs new file mode 100644 index 00000000..efccd7fa --- /dev/null +++ b/tests/1001-1500/1096. brace-expansion-ii/sol.rs @@ -0,0 +1,41 @@ +impl Solution { + pub fn brace_expansion_ii(expression: String) -> Vec { + let mut stack: Vec> = Vec::new(); + let mut res: Vec = Vec::new(); + let mut cur: Vec = Vec::new(); + for v in expression.chars() { + if v.is_alphabetic() { + if cur.is_empty() { + cur = vec![v.to_string()]; + } else { + cur = cur.into_iter().map(|c| c + &v.to_string()).collect(); + } + } else if v == '{' { + stack.push(res.clone()); + stack.push(cur.clone()); + res.clear(); + cur.clear(); + } else if v == '}' { + let pre = stack.pop().unwrap(); + let pre_res = stack.pop().unwrap(); + let mut merged = res.clone(); + merged.extend(cur.clone()); + if pre.is_empty() { + cur = merged; + } else { + cur = pre.into_iter() + .flat_map(|p| merged.iter().map(move |c| p.clone() + c)) + .collect(); + } + res = pre_res; + } else if v == ',' { + res.extend(cur.clone()); + cur.clear(); + } + } + res.extend(cur); + res.sort(); + res.dedup(); + res + } +} diff --git a/tests/1001-1500/1096. brace-expansion-ii/sol.swift b/tests/1001-1500/1096. brace-expansion-ii/sol.swift new file mode 100644 index 00000000..3462ad40 --- /dev/null +++ b/tests/1001-1500/1096. brace-expansion-ii/sol.swift @@ -0,0 +1,35 @@ +class Solution { + func braceExpansionII(_ expression: String) -> [String] { + var stack: [[String]] = [] + var res: [String] = [] + var cur: [String] = [] + for v in expression { + if v.isLetter { + if cur.isEmpty { + cur = [String(v)] + } else { + cur = cur.map { $0 + String(v) } + } + } else if v == "{" { + stack.append(res) + stack.append(cur) + res = [] + cur = [] + } else if v == "}" { + let pre = stack.removeLast() + let preRes = stack.removeLast() + let merged = res + cur + if pre.isEmpty { + cur = merged + } else { + cur = pre.flatMap { p in merged.map { p + $0 } } + } + res = preRes + } else if v == "," { + res.append(contentsOf: cur) + cur = [] + } + } + return Array(Set(res + cur)).sorted() + } +} diff --git a/tests/1001-1500/1096. brace-expansion-ii/sol.ts b/tests/1001-1500/1096. brace-expansion-ii/sol.ts new file mode 100644 index 00000000..f9ab3e78 --- /dev/null +++ b/tests/1001-1500/1096. brace-expansion-ii/sol.ts @@ -0,0 +1,33 @@ +function braceExpansionII(expression: string): string[] { + const stack: string[][] = []; + let res: string[] = []; + let cur: string[] = []; + for (const v of expression) { + if (v >= "a" && v <= "z") { + if (cur.length === 0) { + cur = [v]; + } else { + cur = cur.map((c) => c + v); + } + } else if (v === "{") { + stack.push(res); + stack.push(cur); + res = []; + cur = []; + } else if (v === "}") { + const pre = stack.pop()!; + const preRes = stack.pop()!; + const merged = [...res, ...cur]; + if (pre.length === 0) { + cur = merged; + } else { + cur = pre.flatMap((p) => merged.map((c) => p + c)); + } + res = preRes; + } else if (v === ",") { + res = res.concat(cur); + cur = []; + } + } + return [...new Set([...res, ...cur])].sort(); +} diff --git a/tests/1001-1500/1103. distribute-candies-to-people/manifest.yaml b/tests/1001-1500/1103. distribute-candies-to-people/manifest.yaml new file mode 100644 index 00000000..e2212ec8 --- /dev/null +++ b/tests/1001-1500/1103. distribute-candies-to-people/manifest.yaml @@ -0,0 +1,410 @@ +entry: + id: 1103 + title: distribute-candies-to-people + params: + candies: + type: int + num_people: + type: int + call: + cpp: Solution().distributeCandies({candies}, {num_people}) + rust: Solution::distribute_candies({candies}, {num_people}) + python3: Solution().distributeCandies({candies}, {num_people}) + python2: Solution().distributeCandies({candies}, {num_people}) + ruby: distribute_candies({candies}, {num_people}) + java: new Solution().distributeCandies({candies}, {num_people}) + csharp: new Solution().DistributeCandies({candies}, {num_people}) + kotlin: Solution().distributeCandies({candies}, {num_people}) + go: distributeCandies({candies}, {num_people}) + dart: Solution().distributeCandies({candies}, {num_people}) + swift: Solution().distributeCandies({candies}, {num_people}) + typescript: distributeCandies({candies}, {num_people}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 128 +oracle: + python3: + call: Checker().check(candies, num_people, {result}) + checker: + "class Checker(object):\n def check(self, candies, num_people, result):\n\ + \ if not isinstance(result, list) or len(result) != num_people:\n \ + \ return False\n if any((not isinstance(x, int)) for x in result):\n\ + \ return False\n if sum(result) != candies:\n return\ + \ False\n exp = [0] * num_people\n give = 1\n i = 0\n \ + \ while candies > 0:\n exp[i % num_people] += min(give, candies)\n\ + \ candies -= give\n give += 1\n i += 1\n \ + \ return exp == result\n" +seed: 1103 +tests: + - name: example_1 + in: + candies: 7 + num_people: 4 + out: + - 1 + - 2 + - 3 + - 1 + - name: example_2 + in: + candies: 10 + num_people: 3 + out: + - 5 + - 2 + - 3 + - name: minimum_candies_one_person + in: + candies: 1 + num_people: 1 + out: + - 1 + - name: exact_first_round + in: + candies: 3 + num_people: 3 + out: + - 1 + - 2 + - 0 + - name: exact_second_round_start + in: + candies: 6 + num_people: 3 + out: + - 1 + - 2 + - 3 + - name: partial_second_round + in: + candies: 8 + num_people: 3 + out: + - 3 + - 2 + - 3 + - name: one_person_small + in: + candies: 5 + num_people: 1 + out: + - 5 + - name: two_people_even + in: + candies: 5 + num_people: 2 + out: + - 3 + - 2 + - name: two_people_exact + in: + candies: 3 + num_people: 2 + out: + - 1 + - 2 + - name: three_people_partial + in: + candies: 4 + num_people: 3 + out: + - 1 + - 2 + - 1 + - name: four_people_small + in: + candies: 2 + num_people: 4 + out: + - 1 + - 1 + - 0 + - 0 + - name: four_people_round_one + in: + candies: 10 + num_people: 4 + out: + - 1 + - 2 + - 3 + - 4 + - name: four_people_after_wrap + in: + candies: 11 + num_people: 4 + out: + - 2 + - 2 + - 3 + - 4 + - name: larger_people_first_round + in: + candies: 15 + num_people: 5 + out: + - 1 + - 2 + - 3 + - 4 + - 5 + - name: larger_people_partial_wrap + in: + candies: 16 + num_people: 5 + out: + - 2 + - 2 + - 3 + - 4 + - 5 + - name: two_full_rounds_exact + in: + candies: 21 + num_people: 3 + out: + - 5 + - 7 + - 9 + - name: nontrivial_small + in: + candies: 19 + num_people: 4 + out: + - 6 + - 6 + - 3 + - 4 + - name: sequential_wrap + in: + candies: 20 + num_people: 4 + out: + - 6 + - 7 + - 3 + - 4 + - name: exact_row_with_leftover + in: + candies: 28 + num_people: 4 + out: + - 6 + - 8 + - 10 + - 4 + - name: moderately_large_people + in: + candies: 100 + num_people: 10 + out: + - 12 + - 14 + - 16 + - 13 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + - name: exact_large_rounds + in: + candies: 55 + num_people: 5 + out: + - 7 + - 9 + - 11 + - 13 + - 15 + - name: leftover_after_many_turns + in: + candies: 60 + num_people: 5 + out: + - 12 + - 9 + - 11 + - 13 + - 15 + - name: wide_people_small_candies + in: + candies: 9 + num_people: 8 + out: + - 1 + - 2 + - 3 + - 3 + - 0 + - 0 + - 0 + - 0 + - name: wide_people_exact_first_round + in: + candies: 36 + num_people: 8 + out: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - name: wide_people_second_round_start + in: + candies: 37 + num_people: 8 + out: + - 2 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - name: larger_partial + in: + candies: 50 + num_people: 6 + out: + - 8 + - 10 + - 12 + - 9 + - 5 + - 6 + - name: leftmost_overflow + in: + candies: 51 + num_people: 6 + out: + - 8 + - 10 + - 12 + - 10 + - 5 + - 6 + - name: exact_after_two_rounds + in: + candies: 78 + num_people: 6 + out: + - 8 + - 10 + - 12 + - 14 + - 16 + - 18 + - name: near_round_boundary + in: + candies: 79 + num_people: 6 + out: + - 9 + - 10 + - 12 + - 14 + - 16 + - 18 + - name: large_people_one_round + in: + candies: 210 + num_people: 20 + out: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + - 11 + - 12 + - 13 + - 14 + - 15 + - 16 + - 17 + - 18 + - 19 + - 20 + - name: large_people_leftover + in: + candies: 211 + num_people: 20 + out: + - 2 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + - 11 + - 12 + - 13 + - 14 + - 15 + - 16 + - 17 + - 18 + - 19 + - 20 + - name: large_candies_small_people + in: + candies: 1000 + num_people: 3 + out: + - 330 + - 345 + - 325 + - name: large_candies_medium_people + in: + candies: 1000 + num_people: 7 + out: + - 154 + - 161 + - 133 + - 129 + - 135 + - 141 + - 147 + - name: exact_triangular_1 + in: + candies: 21 + num_people: 6 + out: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - name: exact_triangular_2 + in: + candies: 45 + num_people: 9 + out: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 diff --git a/tests/1001-1500/1103. distribute-candies-to-people/sol.cpp b/tests/1001-1500/1103. distribute-candies-to-people/sol.cpp new file mode 100644 index 00000000..de769d22 --- /dev/null +++ b/tests/1001-1500/1103. distribute-candies-to-people/sol.cpp @@ -0,0 +1,17 @@ +class Solution { +public: + vector distributeCandies(int candies, int num_people) { + vector res(num_people, 0); + int give = 1; + int i = 0; + + while (candies > 0) { + res[i % num_people] += min(give, candies); + candies -= give; + give++; + i++; + } + + return res; + } +}; diff --git a/tests/1001-1500/1103. distribute-candies-to-people/sol.cs b/tests/1001-1500/1103. distribute-candies-to-people/sol.cs new file mode 100644 index 00000000..3eb3d2d3 --- /dev/null +++ b/tests/1001-1500/1103. distribute-candies-to-people/sol.cs @@ -0,0 +1,16 @@ +public class Solution { + public int[] DistributeCandies(int candies, int num_people) { + int[] res = new int[num_people]; + int give = 1; + int i = 0; + + while (candies > 0) { + res[i % num_people] += Math.Min(give, candies); + candies -= give; + give++; + i++; + } + + return res; + } +} diff --git a/tests/1001-1500/1103. distribute-candies-to-people/sol.dart b/tests/1001-1500/1103. distribute-candies-to-people/sol.dart new file mode 100644 index 00000000..fd171c83 --- /dev/null +++ b/tests/1001-1500/1103. distribute-candies-to-people/sol.dart @@ -0,0 +1,16 @@ +class Solution { + List distributeCandies(int candies, int num_people) { + List res = List.filled(num_people, 0); + int give = 1; + int i = 0; + + while (candies > 0) { + res[i % num_people] += give < candies ? give : candies; + candies -= give; + give++; + i++; + } + + return res; + } +} diff --git a/tests/1001-1500/1103. distribute-candies-to-people/sol.go b/tests/1001-1500/1103. distribute-candies-to-people/sol.go new file mode 100644 index 00000000..4a18046f --- /dev/null +++ b/tests/1001-1500/1103. distribute-candies-to-people/sol.go @@ -0,0 +1,18 @@ +func distributeCandies(candies int, num_people int) []int { + res := make([]int, num_people) + give := 1 + i := 0 + + for candies > 0 { + if give < candies { + res[i % num_people] += give + } else { + res[i % num_people] += candies + } + candies -= give + give++ + i++ + } + + return res +} diff --git a/tests/1001-1500/1103. distribute-candies-to-people/sol.java b/tests/1001-1500/1103. distribute-candies-to-people/sol.java new file mode 100644 index 00000000..fad8cbf9 --- /dev/null +++ b/tests/1001-1500/1103. distribute-candies-to-people/sol.java @@ -0,0 +1,16 @@ +class Solution { + public int[] distributeCandies(int candies, int num_people) { + int[] res = new int[num_people]; + int give = 1; + int i = 0; + + while (candies > 0) { + res[i % num_people] += Math.min(give, candies); + candies -= give; + give++; + i++; + } + + return res; + } +} diff --git a/tests/1001-1500/1103. distribute-candies-to-people/sol.kt b/tests/1001-1500/1103. distribute-candies-to-people/sol.kt new file mode 100644 index 00000000..bce2ae8a --- /dev/null +++ b/tests/1001-1500/1103. distribute-candies-to-people/sol.kt @@ -0,0 +1,17 @@ +class Solution { + fun distributeCandies(candies: Int, num_people: Int): IntArray { + val res = IntArray(num_people) + var give = 1 + var i = 0 + var remaining = candies + + while (remaining > 0) { + res[i % num_people] += minOf(give, remaining) + remaining -= give + give++ + i++ + } + + return res + } +} diff --git a/tests/1001-1500/1103. distribute-candies-to-people/sol.py b/tests/1001-1500/1103. distribute-candies-to-people/sol.py new file mode 100644 index 00000000..dbd3c769 --- /dev/null +++ b/tests/1001-1500/1103. distribute-candies-to-people/sol.py @@ -0,0 +1,13 @@ +class Solution: + def distributeCandies(self, candies, num_people): + res = [0] * num_people + give = 1 + i = 0 + + while candies > 0: + res[i % num_people] += min(give, candies) + candies -= give + give += 1 + i += 1 + + return res diff --git a/tests/1001-1500/1103. distribute-candies-to-people/sol.py2 b/tests/1001-1500/1103. distribute-candies-to-people/sol.py2 new file mode 100644 index 00000000..bca8bf29 --- /dev/null +++ b/tests/1001-1500/1103. distribute-candies-to-people/sol.py2 @@ -0,0 +1,18 @@ +class Solution(object): + def distributeCandies(self, candies, num_people): + """ + :type candies: int + :type num_people: int + :rtype: List[int] + """ + res = [0] * num_people + give = 1 + i = 0 + + while candies > 0: + res[i % num_people] += min(give, candies) + candies -= give + give += 1 + i += 1 + + return res diff --git a/tests/1001-1500/1103. distribute-candies-to-people/sol.rb b/tests/1001-1500/1103. distribute-candies-to-people/sol.rb new file mode 100644 index 00000000..77a94773 --- /dev/null +++ b/tests/1001-1500/1103. distribute-candies-to-people/sol.rb @@ -0,0 +1,17 @@ +# @param {Integer} candies +# @param {Integer} num_people +# @return {Integer[]} +def distribute_candies(candies, num_people) + res = Array.new(num_people, 0) + give = 1 + i = 0 + + while candies > 0 + res[i % num_people] += [give, candies].min + candies -= give + give += 1 + i += 1 + end + + res +end diff --git a/tests/1001-1500/1103. distribute-candies-to-people/sol.rs b/tests/1001-1500/1103. distribute-candies-to-people/sol.rs new file mode 100644 index 00000000..c69b07a5 --- /dev/null +++ b/tests/1001-1500/1103. distribute-candies-to-people/sol.rs @@ -0,0 +1,17 @@ +impl Solution { + pub fn distribute_candies(candies: i32, num_people: i32) -> Vec { + let mut res = vec![0; num_people as usize]; + let mut give = 1; + let mut i = 0; + let mut remaining = candies; + + while remaining > 0 { + res[i % num_people as usize] += std::cmp::min(give, remaining); + remaining -= give; + give += 1; + i += 1; + } + + res + } +} diff --git a/tests/1001-1500/1103. distribute-candies-to-people/sol.swift b/tests/1001-1500/1103. distribute-candies-to-people/sol.swift new file mode 100644 index 00000000..460b0e9e --- /dev/null +++ b/tests/1001-1500/1103. distribute-candies-to-people/sol.swift @@ -0,0 +1,17 @@ +class Solution { + func distributeCandies(_ candies: Int, _ num_people: Int) -> [Int] { + var res = Array(repeating: 0, count: num_people) + var give = 1 + var i = 0 + var remaining = candies + + while remaining > 0 { + res[i % num_people] += min(give, remaining) + remaining -= give + give += 1 + i += 1 + } + + return res + } +} diff --git a/tests/1001-1500/1103. distribute-candies-to-people/sol.ts b/tests/1001-1500/1103. distribute-candies-to-people/sol.ts new file mode 100644 index 00000000..0177e8f8 --- /dev/null +++ b/tests/1001-1500/1103. distribute-candies-to-people/sol.ts @@ -0,0 +1,14 @@ +function distributeCandies(candies: number, num_people: number): number[] { + const res: number[] = new Array(num_people).fill(0); + let give = 1; + let i = 0; + + while (candies > 0) { + res[i % num_people] += Math.min(give, candies); + candies -= give; + give++; + i++; + } + + return res; +} diff --git a/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/manifest.yaml b/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/manifest.yaml new file mode 100644 index 00000000..5fd13a18 --- /dev/null +++ b/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/manifest.yaml @@ -0,0 +1,456 @@ +entry: + id: 1104 + title: path-in-zigzag-labelled-binary-tree + params: + label: + type: int + call: + cpp: Solution().pathInZigZagTree({label}) + rust: Solution::path_in_zig_zag_tree({label}) + python3: Solution().pathInZigZagTree({label}) + python2: Solution().pathInZigZagTree({label}) + ruby: path_in_zig_zag_tree({label}) + java: new Solution().pathInZigZagTree({label}) + csharp: new Solution().PathInZigZagTree({label}) + kotlin: Solution().pathInZigZagTree({label}) + go: pathInZigZagTree({label}) + dart: Solution().pathInZigZagTree({label}) + swift: Solution().pathInZigZagTree({label}) + typescript: pathInZigZagTree({label}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 128 +oracle: + python3: + call: Checker().check(label, {result}) + checker: + "class Checker(object):\n def check(self, label, result):\n \ + \ if not isinstance(result, list) or not result or result[-1] != label:\n \ + \ return False\n if any((not isinstance(x, int) or x < 1) for\ + \ x in result):\n return False\n cur = label\n exp\ + \ = []\n while cur >= 1:\n exp.append(cur)\n if\ + \ cur == 1:\n break\n level = cur.bit_length()\n \ + \ low = 1 << (level - 1)\n high = (low << 1) - 1\n \ + \ cur = (low + high - cur) // 2\n return result == exp[::-1]\n" +seed: 1104 +tests: + - name: example_1 + in: + label: 14 + out: + - 1 + - 3 + - 4 + - 14 + - name: example_2 + in: + label: 26 + out: + - 1 + - 2 + - 6 + - 10 + - 26 + - name: root + in: + label: 1 + out: + - 1 + - name: second_level_left + in: + label: 2 + out: + - 1 + - 2 + - name: second_level_right + in: + label: 3 + out: + - 1 + - 3 + - name: third_level_left + in: + label: 4 + out: + - 1 + - 3 + - 4 + - name: third_level_right + in: + label: 7 + out: + - 1 + - 2 + - 7 + - name: fourth_level_left + in: + label: 8 + out: + - 1 + - 2 + - 7 + - 8 + - name: fourth_level_right + in: + label: 15 + out: + - 1 + - 3 + - 4 + - 15 + - name: mid_level_example + in: + label: 10 + out: + - 1 + - 2 + - 6 + - 10 + - name: level_five_left + in: + label: 16 + out: + - 1 + - 3 + - 4 + - 15 + - 16 + - name: level_five_right + in: + label: 31 + out: + - 1 + - 2 + - 7 + - 8 + - 31 + - name: level_six_left + in: + label: 32 + out: + - 1 + - 2 + - 7 + - 8 + - 31 + - 32 + - name: level_six_right + in: + label: 63 + out: + - 1 + - 3 + - 4 + - 15 + - 16 + - 63 + - name: upper_mid + in: + label: 23 + out: + - 1 + - 3 + - 5 + - 12 + - 23 + - name: odd_path + in: + label: 14 + out: + - 1 + - 3 + - 4 + - 14 + - name: next_level + in: + label: 22 + out: + - 1 + - 3 + - 5 + - 12 + - 22 + - name: bigger_level + in: + label: 45 + out: + - 1 + - 2 + - 6 + - 11 + - 25 + - 45 + - name: boundary_64 + in: + label: 64 + out: + - 1 + - 3 + - 4 + - 15 + - 16 + - 63 + - 64 + - name: boundary_65 + in: + label: 65 + out: + - 1 + - 3 + - 4 + - 15 + - 16 + - 63 + - 65 + - name: near_upper_bound + in: + label: 999999 + out: + - 1 + - 3 + - 4 + - 15 + - 17 + - 61 + - 69 + - 244 + - 279 + - 976 + - 1118 + - 3906 + - 4475 + - 15624 + - 17902 + - 62499 + - 71608 + - 249999 + - 286432 + - 999999 + - name: max_bound + in: + label: 1000000 + out: + - 1 + - 3 + - 4 + - 15 + - 17 + - 61 + - 69 + - 244 + - 279 + - 976 + - 1118 + - 3906 + - 4475 + - 15625 + - 17901 + - 62500 + - 71607 + - 250000 + - 286431 + - 1000000 + - name: level_seven_left + in: + label: 127 + out: + - 1 + - 2 + - 7 + - 8 + - 31 + - 32 + - 127 + - name: level_seven_right + in: + label: 128 + out: + - 1 + - 2 + - 7 + - 8 + - 31 + - 32 + - 127 + - 128 + - name: level_eight_left + in: + label: 129 + out: + - 1 + - 2 + - 7 + - 8 + - 31 + - 32 + - 127 + - 129 + - name: mixed_path_1 + in: + label: 70 + out: + - 1 + - 3 + - 4 + - 15 + - 17 + - 60 + - 70 + - name: mixed_path_2 + in: + label: 71 + out: + - 1 + - 3 + - 4 + - 15 + - 17 + - 60 + - 71 + - name: mixed_path_3 + in: + label: 99 + out: + - 1 + - 2 + - 6 + - 11 + - 24 + - 46 + - 99 + - name: mixed_path_4 + in: + label: 100 + out: + - 1 + - 2 + - 6 + - 11 + - 25 + - 45 + - 100 + - name: mixed_path_5 + in: + label: 511 + out: + - 1 + - 2 + - 7 + - 8 + - 31 + - 32 + - 127 + - 128 + - 511 + - name: mixed_path_6 + in: + label: 512 + out: + - 1 + - 2 + - 7 + - 8 + - 31 + - 32 + - 127 + - 128 + - 511 + - 512 + - name: mixed_path_7 + in: + label: 777777 + out: + - 1 + - 2 + - 6 + - 11 + - 24 + - 47 + - 97 + - 189 + - 388 + - 759 + - 1552 + - 3038 + - 6211 + - 12152 + - 24846 + - 48611 + - 99385 + - 194444 + - 397543 + - 777777 + - name: mixed_path_8 + in: + label: 888888 + out: + - 1 + - 3 + - 5 + - 13 + - 20 + - 54 + - 83 + - 217 + - 333 + - 868 + - 1335 + - 3472 + - 5343 + - 13888 + - 21374 + - 55555 + - 85496 + - 222222 + - 341987 + - 888888 + - name: mixed_path_9 + in: + label: 999998 + out: + - 1 + - 3 + - 4 + - 15 + - 17 + - 61 + - 69 + - 244 + - 279 + - 976 + - 1118 + - 3906 + - 4475 + - 15624 + - 17902 + - 62499 + - 71608 + - 249999 + - 286432 + - 999998 + - name: mixed_path_10 + in: + label: 543210 + out: + - 1 + - 2 + - 7 + - 8 + - 31 + - 33 + - 125 + - 132 + - 502 + - 530 + - 2011 + - 2121 + - 8044 + - 8487 + - 32176 + - 33950 + - 128706 + - 135802 + - 514826 + - 543210 diff --git a/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.cpp b/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.cpp new file mode 100644 index 00000000..04c5bb67 --- /dev/null +++ b/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.cpp @@ -0,0 +1,18 @@ +class Solution { +public: + vector pathInZigZagTree(int label) { + vector res; + int cur = label; + while (cur > 0) { + res.push_back(cur); + int start = 1; + while (start * 2 <= cur) { + start *= 2; + } + int end = start * 2 - 1; + cur = (start + end - cur) / 2; + } + reverse(res.begin(), res.end()); + return res; + } +}; diff --git a/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.cs b/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.cs new file mode 100644 index 00000000..2f5f4546 --- /dev/null +++ b/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.cs @@ -0,0 +1,17 @@ +public class Solution { + public IList PathInZigZagTree(int label) { + var res = new List(); + int cur = label; + while (cur > 0) { + res.Add(cur); + int start = 1; + while (start * 2 <= cur) { + start *= 2; + } + int end = start * 2 - 1; + cur = (start + end - cur) / 2; + } + res.Reverse(); + return res; + } +} diff --git a/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.dart b/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.dart new file mode 100644 index 00000000..02c5d22e --- /dev/null +++ b/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.dart @@ -0,0 +1,16 @@ +class Solution { + List pathInZigZagTree(int label) { + List res = []; + var cur = label; + while (cur > 0) { + res.add(cur); + var start = 1; + while (start * 2 <= cur) { + start *= 2; + } + final end = start * 2 - 1; + cur = (start + end - cur) ~/ 2; + } + return res.reversed.toList(); + } +} diff --git a/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.go b/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.go new file mode 100644 index 00000000..afe6358f --- /dev/null +++ b/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.go @@ -0,0 +1,17 @@ +func pathInZigZagTree(label int) []int { + res := []int{} + cur := label + for cur > 0 { + res = append(res, cur) + start := 1 + for start*2 <= cur { + start *= 2 + } + end := start*2 - 1 + cur = (start + end - cur) / 2 + } + for i, j := 0, len(res)-1; i < j; i, j = i+1, j-1 { + res[i], res[j] = res[j], res[i] + } + return res +} diff --git a/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.java b/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.java new file mode 100644 index 00000000..a6fea817 --- /dev/null +++ b/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.java @@ -0,0 +1,19 @@ +import java.util.*; + +class Solution { + public List pathInZigZagTree(int label) { + List res = new ArrayList<>(); + int cur = label; + while (cur > 0) { + res.add(cur); + int start = 1; + while (start * 2 <= cur) { + start *= 2; + } + int end = start * 2 - 1; + cur = (start + end - cur) / 2; + } + Collections.reverse(res); + return res; + } +} diff --git a/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.kt b/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.kt new file mode 100644 index 00000000..ec1ac49f --- /dev/null +++ b/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.kt @@ -0,0 +1,17 @@ +class Solution { + fun pathInZigZagTree(label: Int): List { + val res = mutableListOf() + var cur = label + while (cur > 0) { + res.add(cur) + var start = 1 + while (start * 2 <= cur) { + start *= 2 + } + val end = start * 2 - 1 + cur = (start + end - cur) / 2 + } + res.reverse() + return res + } +} diff --git a/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.py b/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.py new file mode 100644 index 00000000..d3eaa991 --- /dev/null +++ b/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.py @@ -0,0 +1,12 @@ +class Solution: + def pathInZigZagTree(self, label): + res = [] + cur = label + while cur > 0: + res.append(cur) + start = 1 + while start * 2 <= cur: + start *= 2 + end = start * 2 - 1 + cur = (start + end - cur) // 2 + return res[::-1] diff --git a/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.py2 b/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.py2 new file mode 100644 index 00000000..3c555e1a --- /dev/null +++ b/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.py2 @@ -0,0 +1,12 @@ +class Solution(object): + def pathInZigZagTree(self, label): + res = [] + cur = label + while cur > 0: + res.append(cur) + start = 1 + while start * 2 <= cur: + start *= 2 + end = start * 2 - 1 + cur = (start + end - cur) // 2 + return res[::-1] diff --git a/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.rb b/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.rb new file mode 100644 index 00000000..ba90d3fa --- /dev/null +++ b/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.rb @@ -0,0 +1,12 @@ +def path_in_zig_zag_tree(label) + res = [] + cur = label + while cur > 0 + res << cur + start = 1 + start *= 2 while start * 2 <= cur + ending = start * 2 - 1 + cur = (start + ending - cur) / 2 + end + res.reverse +end diff --git a/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.rs b/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.rs new file mode 100644 index 00000000..102617ba --- /dev/null +++ b/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.rs @@ -0,0 +1,17 @@ +impl Solution { + pub fn path_in_zig_zag_tree(label: i32) -> Vec { + let mut res = Vec::new(); + let mut cur = label; + while cur > 0 { + res.push(cur); + let mut start = 1; + while start * 2 <= cur { + start *= 2; + } + let end = start * 2 - 1; + cur = (start + end - cur) / 2; + } + res.reverse(); + res + } +} diff --git a/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.swift b/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.swift new file mode 100644 index 00000000..615b93d6 --- /dev/null +++ b/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.swift @@ -0,0 +1,16 @@ +class Solution { + func pathInZigZagTree(_ label: Int) -> [Int] { + var res: [Int] = [] + var cur = label + while cur > 0 { + res.append(cur) + var start = 1 + while start * 2 <= cur { + start *= 2 + } + let end = start * 2 - 1 + cur = (start + end - cur) / 2 + } + return res.reversed() + } +} diff --git a/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.ts b/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.ts new file mode 100644 index 00000000..838199fd --- /dev/null +++ b/tests/1001-1500/1104. path-in-zigzag-labelled-binary-tree/sol.ts @@ -0,0 +1,14 @@ +function pathInZigZagTree(label: number): number[] { + const res: number[] = []; + let cur = label; + while (cur > 0) { + res.push(cur); + let start = 1; + while (start * 2 <= cur) { + start *= 2; + } + const end = start * 2 - 1; + cur = Math.floor((start + end - cur) / 2); + } + return res.reverse(); +} diff --git a/tests/1001-1500/1105. filling-bookcase-shelves/manifest.yaml b/tests/1001-1500/1105. filling-bookcase-shelves/manifest.yaml new file mode 100644 index 00000000..7e1f6df5 --- /dev/null +++ b/tests/1001-1500/1105. filling-bookcase-shelves/manifest.yaml @@ -0,0 +1,663 @@ +entry: + id: 1105 + title: filling-bookcase-shelves + params: + books: + type: array + items: + type: array + items: + type: int + shelfWidth: + type: int + call: + cpp: Solution().minHeightShelves({books}, {shelfWidth}) + rust: Solution::min_height_shelves({books}, {shelfWidth}) + python3: Solution().minHeightShelves({books}, {shelfWidth}) + python2: Solution().minHeightShelves({books}, {shelfWidth}) + ruby: min_height_shelves({books}, {shelfWidth}) + java: new Solution().minHeightShelves({books}, {shelfWidth}) + csharp: new Solution().MinHeightShelves({books}, {shelfWidth}) + kotlin: Solution().minHeightShelves({books}, {shelfWidth}) + go: minHeightShelves({books}, {shelfWidth}) + dart: Solution().minHeightShelves({books}, {shelfWidth}) + swift: Solution().minHeightShelves({books}, {shelfWidth}) + typescript: minHeightShelves({books}, {shelfWidth}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 128 +oracle: + python3: + call: Checker().check(books, shelfWidth, {result}) + checker: + "class Checker(object):\n def check(self, books, shelfWidth, result):\n\ + \ if not isinstance(result, int) or result <= 0:\n return\ + \ False\n n = len(books)\n dp = [float('inf')] * (n + 1)\n \ + \ dp[0] = 0\n for i in range(1, n + 1):\n dp[i] = dp[i\ + \ - 1] + books[i - 1][1]\n height = 0\n width = 0\n \ + \ for j in range(i - 1, -1, -1):\n height = max(height,\ + \ books[j][1])\n width += books[j][0]\n if width\ + \ > shelfWidth:\n break\n dp[i] = min(dp[i],\ + \ dp[j] + height)\n return dp[n] == result\n" +seed: 1105 +tests: + - name: example_1 + in: + books: + elemType: int + value: + - - 1 + - 1 + - - 2 + - 3 + - - 2 + - 3 + - - 1 + - 1 + - - 1 + - 1 + - - 1 + - 1 + - - 1 + - 2 + shelfWidth: 4 + out: 6 + - name: example_2 + in: + books: + elemType: int + value: + - - 1 + - 3 + - - 2 + - 4 + - - 3 + - 2 + shelfWidth: 6 + out: 4 + - name: single_book + in: + books: + elemType: int + value: + - - 1 + - 7 + shelfWidth: 1 + out: 7 + - name: all_fit_one_shelf + in: + books: + elemType: int + value: + - - 1 + - 1 + - - 1 + - 2 + - - 1 + - 3 + shelfWidth: 3 + out: 3 + - name: each_book_separate + in: + books: + elemType: int + value: + - - 3 + - 1 + - - 3 + - 2 + - - 3 + - 3 + shelfWidth: 3 + out: 6 + - name: two_books_one_shelf + in: + books: + elemType: int + value: + - - 2 + - 4 + - - 2 + - 3 + shelfWidth: 4 + out: 4 + - name: three_books_split + in: + books: + elemType: int + value: + - - 2 + - 4 + - - 2 + - 3 + - - 1 + - 2 + shelfWidth: 4 + out: 6 + - name: sample_merge_choice + in: + books: + elemType: int + value: + - - 1 + - 1 + - - 2 + - 3 + - - 2 + - 3 + - - 1 + - 1 + shelfWidth: 3 + out: 6 + - name: wide_shelf + in: + books: + elemType: int + value: + - - 2 + - 7 + - - 3 + - 4 + - - 1 + - 5 + shelfWidth: 10 + out: 7 + - name: narrow_shelf + in: + books: + elemType: int + value: + - - 1 + - 9 + - - 1 + - 1 + - - 1 + - 8 + - - 1 + - 2 + shelfWidth: 1 + out: 20 + - name: alternating_heights + in: + books: + elemType: int + value: + - - 1 + - 1 + - - 1 + - 10 + - - 1 + - 1 + - - 1 + - 10 + shelfWidth: 2 + out: 20 + - name: compact_pairing + in: + books: + elemType: int + value: + - - 1 + - 6 + - - 1 + - 1 + - - 1 + - 6 + - - 1 + - 1 + shelfWidth: 2 + out: 12 + - name: greedy_trap + in: + books: + elemType: int + value: + - - 2 + - 1 + - - 2 + - 100 + - - 2 + - 1 + - - 2 + - 100 + shelfWidth: 4 + out: 200 + - name: trap_variant + in: + books: + elemType: int + value: + - - 1 + - 100 + - - 2 + - 1 + - - 2 + - 100 + - - 1 + - 1 + shelfWidth: 3 + out: 200 + - name: all_same_height + in: + books: + elemType: int + value: + - - 1 + - 5 + - - 2 + - 5 + - - 3 + - 5 + - - 1 + - 5 + shelfWidth: 4 + out: 10 + - name: all_same_thickness + in: + books: + elemType: int + value: + - - 2 + - 1 + - - 2 + - 2 + - - 2 + - 3 + - - 2 + - 4 + shelfWidth: 4 + out: 6 + - name: small_mixed + in: + books: + elemType: int + value: + - - 1 + - 2 + - - 3 + - 4 + - - 2 + - 2 + - - 1 + - 7 + shelfWidth: 4 + out: 11 + - name: exact_partition + in: + books: + elemType: int + value: + - - 1 + - 2 + - - 1 + - 3 + - - 1 + - 1 + - - 1 + - 4 + shelfWidth: 2 + out: 7 + - name: max_height_first + in: + books: + elemType: int + value: + - - 1 + - 10 + - - 1 + - 1 + - - 1 + - 1 + - - 1 + - 1 + shelfWidth: 3 + out: 11 + - name: max_height_last + in: + books: + elemType: int + value: + - - 1 + - 1 + - - 1 + - 1 + - - 1 + - 1 + - - 1 + - 10 + shelfWidth: 3 + out: 11 + - name: two_shelves_optimal + in: + books: + elemType: int + value: + - - 2 + - 3 + - - 1 + - 4 + - - 1 + - 2 + - - 2 + - 1 + shelfWidth: 4 + out: 5 + - name: longish_1 + in: + books: + elemType: int + value: + - - 1 + - 1 + - - 2 + - 2 + - - 1 + - 3 + - - 2 + - 4 + - - 1 + - 5 + shelfWidth: 3 + out: 9 + - name: longish_2 + in: + books: + elemType: int + value: + - - 2 + - 10 + - - 1 + - 1 + - - 2 + - 10 + - - 1 + - 1 + - - 2 + - 10 + shelfWidth: 3 + out: 30 + - name: longish_3 + in: + books: + elemType: int + value: + - - 1 + - 4 + - - 1 + - 4 + - - 1 + - 4 + - - 1 + - 4 + - - 1 + - 4 + shelfWidth: 2 + out: 12 + - name: longish_4 + in: + books: + elemType: int + value: + - - 3 + - 2 + - - 1 + - 8 + - - 2 + - 1 + - - 1 + - 8 + - - 3 + - 2 + shelfWidth: 4 + out: 12 + - name: longish_5 + in: + books: + elemType: int + value: + - - 1 + - 9 + - - 2 + - 7 + - - 1 + - 8 + - - 2 + - 6 + - - 1 + - 5 + shelfWidth: 4 + out: 15 + - name: longish_6 + in: + books: + elemType: int + value: + - - 2 + - 1 + - - 2 + - 2 + - - 2 + - 3 + - - 2 + - 4 + - - 2 + - 5 + shelfWidth: 6 + out: 7 + - name: longish_7 + in: + books: + elemType: int + value: + - - 1 + - 100 + - - 1 + - 99 + - - 1 + - 98 + - - 1 + - 97 + shelfWidth: 2 + out: 198 + - name: longish_8 + in: + books: + elemType: int + value: + - - 4 + - 4 + - - 4 + - 3 + - - 4 + - 2 + shelfWidth: 4 + out: 9 + - name: longish_9 + in: + books: + elemType: int + value: + - - 1 + - 2 + - - 2 + - 2 + - - 1 + - 2 + - - 2 + - 2 + - - 1 + - 2 + - - 2 + - 2 + shelfWidth: 3 + out: 6 + - name: longish_10 + in: + books: + elemType: int + value: + - - 1 + - 1 + - - 1 + - 2 + - - 1 + - 3 + - - 1 + - 4 + - - 1 + - 5 + - - 1 + - 6 + shelfWidth: 4 + out: 8 + - name: longish_11 + in: + books: + elemType: int + value: + - - 2 + - 5 + - - 2 + - 5 + - - 2 + - 5 + - - 2 + - 5 + shelfWidth: 5 + out: 10 + - name: longish_12 + in: + books: + elemType: int + value: + - - 1 + - 1 + - - 2 + - 10 + - - 1 + - 1 + - - 2 + - 10 + - - 1 + - 1 + shelfWidth: 3 + out: 21 + - name: longish_13 + in: + books: + elemType: int + value: + - - 3 + - 1 + - - 1 + - 2 + - - 1 + - 3 + - - 3 + - 4 + shelfWidth: 4 + out: 6 + - name: longish_14 + in: + books: + elemType: int + value: + - - 1 + - 7 + - - 3 + - 8 + - - 1 + - 9 + - - 3 + - 1 + shelfWidth: 4 + out: 17 + - name: longish_15 + in: + books: + elemType: int + value: + - - 1 + - 1 + - - 1 + - 1 + - - 1 + - 1 + - - 1 + - 1 + - - 1 + - 1 + - - 1 + - 1 + - - 1 + - 1 + shelfWidth: 3 + out: 3 + - name: longish_16 + in: + books: + elemType: int + value: + - - 2 + - 9 + - - 2 + - 1 + - - 2 + - 9 + - - 2 + - 1 + - - 2 + - 9 + shelfWidth: 4 + out: 27 + - name: longish_17 + in: + books: + elemType: int + value: + - - 1 + - 6 + - - 2 + - 6 + - - 1 + - 6 + - - 2 + - 6 + - - 1 + - 6 + shelfWidth: 3 + out: 18 + - name: longish_18 + in: + books: + elemType: int + value: + - - 4 + - 1 + - - 1 + - 9 + - - 1 + - 9 + - - 4 + - 1 + shelfWidth: 5 + out: 11 + - name: longish_19 + in: + books: + elemType: int + value: + - - 2 + - 2 + - - 1 + - 8 + - - 2 + - 2 + - - 1 + - 8 + - - 2 + - 2 + shelfWidth: 3 + out: 18 diff --git a/tests/1001-1500/1105. filling-bookcase-shelves/sol.cpp b/tests/1001-1500/1105. filling-bookcase-shelves/sol.cpp new file mode 100644 index 00000000..c2da3826 --- /dev/null +++ b/tests/1001-1500/1105. filling-bookcase-shelves/sol.cpp @@ -0,0 +1,24 @@ +class Solution { +public: + int minHeightShelves(vector>& books, int shelfWidth) { + int n = books.size(); + vector dp(n + 1, INT_MAX); + dp[0] = 0; + + for (int i = 1; i <= n; i++) { + dp[i] = dp[i - 1] + books[i - 1][1]; + int height = 0; + int width = 0; + for (int j = i - 1; j >= 0; j--) { + height = max(books[j][1], height); + width += books[j][0]; + if (width > shelfWidth) { + break; + } + dp[i] = min(dp[i], dp[j] + height); + } + } + + return dp[n]; + } +}; diff --git a/tests/1001-1500/1105. filling-bookcase-shelves/sol.cs b/tests/1001-1500/1105. filling-bookcase-shelves/sol.cs new file mode 100644 index 00000000..dbb99ff4 --- /dev/null +++ b/tests/1001-1500/1105. filling-bookcase-shelves/sol.cs @@ -0,0 +1,26 @@ +public class Solution { + public int MinHeightShelves(int[][] books, int shelfWidth) { + int n = books.Length; + int[] dp = new int[n + 1]; + for (int i = 1; i <= n; i++) { + dp[i] = int.MaxValue; + } + dp[0] = 0; + + for (int i = 1; i <= n; i++) { + dp[i] = dp[i - 1] + books[i - 1][1]; + int height = 0; + int width = 0; + for (int j = i - 1; j >= 0; j--) { + height = Math.Max(books[j][1], height); + width += books[j][0]; + if (width > shelfWidth) { + break; + } + dp[i] = Math.Min(dp[i], dp[j] + height); + } + } + + return dp[n]; + } +} diff --git a/tests/1001-1500/1105. filling-bookcase-shelves/sol.dart b/tests/1001-1500/1105. filling-bookcase-shelves/sol.dart new file mode 100644 index 00000000..01f943d7 --- /dev/null +++ b/tests/1001-1500/1105. filling-bookcase-shelves/sol.dart @@ -0,0 +1,24 @@ +class Solution { + int minHeightShelves(List> books, int shelfWidth) { + int n = books.length; + const int inf = 1 << 30; + List dp = List.filled(n + 1, inf); + dp[0] = 0; + + for (int i = 1; i <= n; i++) { + dp[i] = dp[i - 1] + books[i - 1][1]; + int height = 0; + int width = 0; + for (int j = i - 1; j >= 0; j--) { + height = height > books[j][1] ? height : books[j][1]; + width += books[j][0]; + if (width > shelfWidth) { + break; + } + dp[i] = dp[i] < dp[j] + height ? dp[i] : dp[j] + height; + } + } + + return dp[n]; + } +} diff --git a/tests/1001-1500/1105. filling-bookcase-shelves/sol.go b/tests/1001-1500/1105. filling-bookcase-shelves/sol.go new file mode 100644 index 00000000..25fc5269 --- /dev/null +++ b/tests/1001-1500/1105. filling-bookcase-shelves/sol.go @@ -0,0 +1,28 @@ +func minHeightShelves(books [][]int, shelfWidth int) int { + n := len(books) + dp := make([]int, n+1) + for i := 1; i <= n; i++ { + dp[i] = int(^uint(0) >> 1) + } + dp[0] = 0 + + for i := 1; i <= n; i++ { + dp[i] = dp[i-1] + books[i-1][1] + height := 0 + width := 0 + for j := i - 1; j >= 0; j-- { + if books[j][1] > height { + height = books[j][1] + } + width += books[j][0] + if width > shelfWidth { + break + } + if dp[j] + height < dp[i] { + dp[i] = dp[j] + height + } + } + } + + return dp[n] +} diff --git a/tests/1001-1500/1105. filling-bookcase-shelves/sol.java b/tests/1001-1500/1105. filling-bookcase-shelves/sol.java new file mode 100644 index 00000000..88216699 --- /dev/null +++ b/tests/1001-1500/1105. filling-bookcase-shelves/sol.java @@ -0,0 +1,26 @@ +class Solution { + public int minHeightShelves(int[][] books, int shelfWidth) { + int n = books.length; + int[] dp = new int[n + 1]; + for (int i = 1; i <= n; i++) { + dp[i] = Integer.MAX_VALUE; + } + dp[0] = 0; + + for (int i = 1; i <= n; i++) { + dp[i] = dp[i - 1] + books[i - 1][1]; + int height = 0; + int width = 0; + for (int j = i - 1; j >= 0; j--) { + height = Math.max(books[j][1], height); + width += books[j][0]; + if (width > shelfWidth) { + break; + } + dp[i] = Math.min(dp[i], dp[j] + height); + } + } + + return dp[n]; + } +} diff --git a/tests/1001-1500/1105. filling-bookcase-shelves/sol.kt b/tests/1001-1500/1105. filling-bookcase-shelves/sol.kt new file mode 100644 index 00000000..d83f58fc --- /dev/null +++ b/tests/1001-1500/1105. filling-bookcase-shelves/sol.kt @@ -0,0 +1,23 @@ +class Solution { + fun minHeightShelves(books: Array, shelfWidth: Int): Int { + val n = books.size + val dp = IntArray(n + 1) { Int.MAX_VALUE / 4 } + dp[0] = 0 + + for (i in 1..n) { + dp[i] = dp[i - 1] + books[i - 1][1] + var height = 0 + var width = 0 + for (j in i - 1 downTo 0) { + height = maxOf(height, books[j][1]) + width += books[j][0] + if (width > shelfWidth) { + break + } + dp[i] = minOf(dp[i], dp[j] + height) + } + } + + return dp[n] + } +} diff --git a/tests/1001-1500/1105. filling-bookcase-shelves/sol.py b/tests/1001-1500/1105. filling-bookcase-shelves/sol.py new file mode 100644 index 00000000..2d878fcc --- /dev/null +++ b/tests/1001-1500/1105. filling-bookcase-shelves/sol.py @@ -0,0 +1,17 @@ +class Solution: + def minHeightShelves(self, books: list[list[int]], shelfWidth: int) -> int: + n = len(books) + dp = [float("infinity")] * (n + 1) + dp[0] = 0 + + for i in range(1, n + 1): + dp[i] = dp[i - 1] + books[i - 1][1] + height = 0 + width = 0 + for j in range(i - 1, -1, -1): + height = max(books[j][1], height) + width += books[j][0] + if width > shelfWidth: + break + dp[i] = min(dp[i], dp[j] + height) + return dp[n] diff --git a/tests/1001-1500/1105. filling-bookcase-shelves/sol.py2 b/tests/1001-1500/1105. filling-bookcase-shelves/sol.py2 new file mode 100644 index 00000000..a314006d --- /dev/null +++ b/tests/1001-1500/1105. filling-bookcase-shelves/sol.py2 @@ -0,0 +1,23 @@ +class Solution(object): + def minHeightShelves(self, books, shelfWidth): + """ + :type books: List[List[int]] + :type shelfWidth: int + :rtype: int + """ + n = len(books) + dp = [float('inf')] * (n + 1) + dp[0] = 0 + + for i in range(1, n + 1): + dp[i] = dp[i - 1] + books[i - 1][1] + height = 0 + width = 0 + for j in range(i - 1, -1, -1): + height = max(books[j][1], height) + width += books[j][0] + if width > shelfWidth: + break + dp[i] = min(dp[i], dp[j] + height) + + return dp[n] diff --git a/tests/1001-1500/1105. filling-bookcase-shelves/sol.rb b/tests/1001-1500/1105. filling-bookcase-shelves/sol.rb new file mode 100644 index 00000000..10297981 --- /dev/null +++ b/tests/1001-1500/1105. filling-bookcase-shelves/sol.rb @@ -0,0 +1,22 @@ +# @param {Integer[][]} books +# @param {Integer} shelf_width +# @return {Integer} +def min_height_shelves(books, shelf_width) + n = books.length + dp = Array.new(n + 1, Float::INFINITY) + dp[0] = 0 + + (1..n).each do |i| + dp[i] = dp[i - 1] + books[i - 1][1] + height = 0 + width = 0 + (i - 1).downto(0) do |j| + height = [books[j][1], height].max + width += books[j][0] + break if width > shelf_width + dp[i] = [dp[i], dp[j] + height].min + end + end + + dp[n] +end diff --git a/tests/1001-1500/1105. filling-bookcase-shelves/sol.rs b/tests/1001-1500/1105. filling-bookcase-shelves/sol.rs new file mode 100644 index 00000000..d01b2a07 --- /dev/null +++ b/tests/1001-1500/1105. filling-bookcase-shelves/sol.rs @@ -0,0 +1,23 @@ +impl Solution { + pub fn min_height_shelves(books: Vec>, shelf_width: i32) -> i32 { + let n = books.len(); + let mut dp = vec![i32::MAX; n + 1]; + dp[0] = 0; + + for i in 1..=n { + dp[i] = dp[i - 1] + books[i - 1][1]; + let mut height = 0; + let mut width = 0; + for j in (0..i).rev() { + height = height.max(books[j][1]); + width += books[j][0]; + if width > shelf_width { + break; + } + dp[i] = dp[i].min(dp[j] + height); + } + } + + dp[n] + } +} diff --git a/tests/1001-1500/1105. filling-bookcase-shelves/sol.swift b/tests/1001-1500/1105. filling-bookcase-shelves/sol.swift new file mode 100644 index 00000000..e8c26cfc --- /dev/null +++ b/tests/1001-1500/1105. filling-bookcase-shelves/sol.swift @@ -0,0 +1,23 @@ +class Solution { + func minHeightShelves(_ books: [[Int]], _ shelfWidth: Int) -> Int { + let n = books.count + var dp = [Int](repeating: Int.max, count: n + 1) + dp[0] = 0 + + for i in 1...n { + dp[i] = dp[i - 1] + books[i - 1][1] + var height = 0 + var width = 0 + for j in stride(from: i - 1, through: 0, by: -1) { + height = max(books[j][1], height) + width += books[j][0] + if width > shelfWidth { + break + } + dp[i] = min(dp[i], dp[j] + height) + } + } + + return dp[n] + } +} diff --git a/tests/1001-1500/1105. filling-bookcase-shelves/sol.ts b/tests/1001-1500/1105. filling-bookcase-shelves/sol.ts new file mode 100644 index 00000000..30b12bf6 --- /dev/null +++ b/tests/1001-1500/1105. filling-bookcase-shelves/sol.ts @@ -0,0 +1,21 @@ +function minHeightShelves(books: number[][], shelfWidth: number): number { + const n = books.length; + const dp: number[] = new Array(n + 1).fill(Number.POSITIVE_INFINITY); + dp[0] = 0; + + for (let i = 1; i <= n; i++) { + dp[i] = dp[i - 1] + books[i - 1][1]; + let height = 0; + let width = 0; + for (let j = i - 1; j >= 0; j--) { + height = Math.max(height, books[j][1]); + width += books[j][0]; + if (width > shelfWidth) { + break; + } + dp[i] = Math.min(dp[i], dp[j] + height); + } + } + + return dp[n]; +} diff --git a/tests/1001-1500/1106. parsing-a-boolean-expression/manifest.yaml b/tests/1001-1500/1106. parsing-a-boolean-expression/manifest.yaml new file mode 100644 index 00000000..4bd32083 --- /dev/null +++ b/tests/1001-1500/1106. parsing-a-boolean-expression/manifest.yaml @@ -0,0 +1,198 @@ +entry: + id: 1106 + title: parsing-a-boolean-expression + params: + expression: + type: string + call: + cpp: Solution().parseBoolExpr({expression}) + rust: Solution::parse_bool_expr({expression}) + python3: Solution().parseBoolExpr({expression}) + python2: Solution().parseBoolExpr({expression}) + ruby: parse_bool_expr({expression}) + java: new Solution().parseBoolExpr({expression}) + csharp: new Solution().ParseBoolExpr({expression}) + kotlin: Solution().parseBoolExpr({expression}) + go: parseBoolExpr({expression}) + dart: Solution().parseBoolExpr({expression}) + swift: Solution().parseBoolExpr({expression}) + typescript: parseBoolExpr({expression}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 128 +oracle: + python3: + call: Checker().check(expression, {result}) + checker: + "class Checker(object):\n def check(self, expression, result):\n \ + \ st = [[]]\n for ch in expression:\n if ch == '&':\n\ + \ st.append([all])\n elif ch == '|':\n \ + \ st.append([any])\n elif ch == '!':\n st.append([lambda\ + \ q: not q[0]])\n elif ch == 't':\n st[-1].append(True)\n\ + \ elif ch == 'f':\n st[-1].append(False)\n \ + \ elif ch == ')':\n operation, *args = st.pop()\n \ + \ st[-1].append(operation(args))\n return st[0][0] == result\n" +seed: 1106 +tests: + - name: example_1 + in: + expression: "&(|(f))" + out: false + - name: example_2 + in: + expression: "|(f,f,f,t)" + out: true + - name: example_3 + in: + expression: "!(&(f,t))" + out: true + - name: single_true + in: + expression: t + out: true + - name: single_false + in: + expression: f + out: false + - name: not_true + in: + expression: "!(t)" + out: false + - name: not_false + in: + expression: "!(f)" + out: true + - name: and_two_true + in: + expression: "&(t,t)" + out: true + - name: and_with_false + in: + expression: "&(t,f)" + out: false + - name: or_two_false + in: + expression: "|(f,f)" + out: false + - name: or_with_true + in: + expression: "|(f,t)" + out: true + - name: nested_and_or + in: + expression: "&(|(t),!(f))" + out: true + - name: nested_or_and + in: + expression: "|(&(t,f),t)" + out: true + - name: nested_false_chain + in: + expression: "!(&(&(t,t),|(f,f)))" + out: true + - name: triple_and + in: + expression: "&(t,t,t)" + out: true + - name: triple_or + in: + expression: "|(f,f,t)" + out: true + - name: triple_or_false + in: + expression: "|(f,f,f)" + out: false + - name: complex_1 + in: + expression: "!(&(|(f,t),&(t,t),!(f)))" + out: false + - name: complex_2 + in: + expression: "&(|(f,f,t),!(f),&(t,|(f,t)))" + out: true + - name: complex_3 + in: + expression: "|(&(t,!(f)),&(f,t),!(|(f)))" + out: true + - name: complex_4 + in: + expression: "!(!(!(t)))" + out: false + - name: complex_5 + in: + expression: "&(!(&(t,f)),|(f,!(f)))" + out: true + - name: complex_6 + in: + expression: "|(!(&(t,t)),&(t,!(f)),f)" + out: true + - name: complex_7 + in: + expression: "!(&(|(t,f),!(t),&(t,t)))" + out: true + - name: complex_8 + in: + expression: "&(|(&(t,f),t),!(&(t,t)),|(f,t))" + out: false + - name: complex_9 + in: + expression: "|(&(t,!(f),t),!(&(f,f)),&(t,t,t))" + out: true + - name: complex_10 + in: + expression: "!(|(&(f,f),&(t,f),!(t)))" + out: true + - name: complex_11 + in: + expression: "&(!(f),!(f),!(f))" + out: true + - name: complex_12 + in: + expression: "|(!(t),!(f),&(t,t,t))" + out: true + - name: complex_13 + in: + expression: "!(&(!(t),|(f,f),t))" + out: true + - name: complex_14 + in: + expression: "&(|(&(t,t),f),!(&(f,t)),|(f,!(f),f))" + out: true + - name: complex_15 + in: + expression: "|(&(!(f),!(f)),!(&(t,t)),&(t,|(f,t)))" + out: true + - name: complex_16 + in: + expression: "!(&(|(&(t,f),&(t,t)),!(f),|(f,t)))" + out: false + - name: complex_17 + in: + expression: "&(|(&(t,t),!(f)),!(&(t,f)),|(f,f,t))" + out: true + - name: complex_18 + in: + expression: "|(!(&(|(f,f),t)),&(t,!(f),t),f)" + out: true + - name: complex_19 + in: + expression: "!(!(t))" + out: true + - name: complex_20 + in: + expression: "&(!(!(t)),|(!(f),f),!(|(f,f)))" + out: true + - name: complex_21 + in: + expression: "|(&(t,|(f,!(f))),!(&(t,t,t)),&(t,t))" + out: true + - name: complex_22 + in: + expression: "!(|(!(f),&(t,f),|(f,f,f)))" + out: false + - name: complex_23 + in: + expression: "&(|(t,f),|(f,f,t),!(f),!(|(f)))" + out: true diff --git a/tests/1001-1500/1106. parsing-a-boolean-expression/sol.cpp b/tests/1001-1500/1106. parsing-a-boolean-expression/sol.cpp new file mode 100644 index 00000000..3559c60b --- /dev/null +++ b/tests/1001-1500/1106. parsing-a-boolean-expression/sol.cpp @@ -0,0 +1,36 @@ +class Solution { +public: + bool parseBoolExpr(string expression) { + vector> st(1); + vector ops; + + for (char ch : expression) { + if (ch == '&' || ch == '|' || ch == '!') { + ops.push_back(ch); + st.emplace_back(); + } else if (ch == 't') { + st.back().push_back(true); + } else if (ch == 'f') { + st.back().push_back(false); + } else if (ch == ')') { + vector cur = std::move(st.back()); + st.pop_back(); + char op = ops.back(); + ops.pop_back(); + bool val; + if (op == '&') { + val = true; + for (bool x : cur) val = val && x; + } else if (op == '|') { + val = false; + for (bool x : cur) val = val || x; + } else { + val = !cur[0]; + } + st.back().push_back(val); + } + } + + return st[0][0]; + } +}; diff --git a/tests/1001-1500/1106. parsing-a-boolean-expression/sol.cs b/tests/1001-1500/1106. parsing-a-boolean-expression/sol.cs new file mode 100644 index 00000000..9b855223 --- /dev/null +++ b/tests/1001-1500/1106. parsing-a-boolean-expression/sol.cs @@ -0,0 +1,36 @@ +public class Solution { + public bool ParseBoolExpr(string expression) { + var st = new System.Collections.Generic.Stack>(); + st.Push(new System.Collections.Generic.List()); + foreach (char ch in expression) { + if (ch == '&') { + st.Push(new System.Collections.Generic.List { "&" }); + } else if (ch == '|') { + st.Push(new System.Collections.Generic.List { "|" }); + } else if (ch == '!') { + st.Push(new System.Collections.Generic.List { "!" }); + } else if (ch == 't') { + st.Peek().Add(true); + } else if (ch == 'f') { + st.Peek().Add(false); + } else if (ch == ')') { + var popped = st.Pop(); + string op = (string)popped[0]; + popped.RemoveAt(0); + var top = st.Peek(); + if (op == "&") { + bool res = true; + foreach (bool v in popped) res = res && v; + top.Add(res); + } else if (op == "|") { + bool res = false; + foreach (bool v in popped) res = res || v; + top.Add(res); + } else if (op == "!") { + top.Add(!(bool)popped[0]); + } + } + } + return (bool)st.Peek()[0]; + } +} diff --git a/tests/1001-1500/1106. parsing-a-boolean-expression/sol.dart b/tests/1001-1500/1106. parsing-a-boolean-expression/sol.dart new file mode 100644 index 00000000..337ff86a --- /dev/null +++ b/tests/1001-1500/1106. parsing-a-boolean-expression/sol.dart @@ -0,0 +1,30 @@ +class Solution { + bool parseBoolExpr(String expression) { + List> st = [[]]; + for (var ch in expression.split('')) { + if (ch == '&') { + st.add(['&']); + } else if (ch == '|') { + st.add(['|']); + } else if (ch == '!') { + st.add(['!']); + } else if (ch == 't') { + st.last.add(true); + } else if (ch == 'f') { + st.last.add(false); + } else if (ch == ')') { + var popped = st.removeLast(); + var op = popped.removeAt(0) as String; + var top = st.last; + if (op == '&') { + top.add(popped.every((v) => v as bool)); + } else if (op == '|') { + top.add(popped.any((v) => v as bool)); + } else if (op == '!') { + top.add(!(popped[0] as bool)); + } + } + } + return st[0][0] as bool; + } +} diff --git a/tests/1001-1500/1106. parsing-a-boolean-expression/sol.go b/tests/1001-1500/1106. parsing-a-boolean-expression/sol.go new file mode 100644 index 00000000..45724753 --- /dev/null +++ b/tests/1001-1500/1106. parsing-a-boolean-expression/sol.go @@ -0,0 +1,40 @@ +func parseBoolExpr(expression string) bool { + st := [][]interface{}{[]interface{}{}} + for _, ch := range expression { + switch ch { + case '&': + st = append(st, []interface{}{"&"}) + case '|': + st = append(st, []interface{}{"|"}) + case '!': + st = append(st, []interface{}{"!"}) + case 't': + st[len(st)-1] = append(st[len(st)-1], true) + case 'f': + st[len(st)-1] = append(st[len(st)-1], false) + case ')': + popped := st[len(st)-1] + st = st[:len(st)-1] + op := popped[0].(string) + args := popped[1:] + top := &st[len(st)-1] + switch op { + case "&": + res := true + for _, v := range args { + res = res && v.(bool) + } + *top = append(*top, res) + case "|": + res := false + for _, v := range args { + res = res || v.(bool) + } + *top = append(*top, res) + case "!": + *top = append(*top, !args[0].(bool)) + } + } + } + return st[0][0].(bool) +} diff --git a/tests/1001-1500/1106. parsing-a-boolean-expression/sol.java b/tests/1001-1500/1106. parsing-a-boolean-expression/sol.java new file mode 100644 index 00000000..f26a6cc8 --- /dev/null +++ b/tests/1001-1500/1106. parsing-a-boolean-expression/sol.java @@ -0,0 +1,29 @@ +class Solution { + public boolean parseBoolExpr(String expression) { + java.util.Stack st = new java.util.Stack<>(); + for (char ch : expression.toCharArray()) { + if (ch == ',') continue; + if (ch != ')') { + st.push(ch); + continue; + } + boolean hasTrue = false; + boolean hasFalse = false; + while (!st.isEmpty() && st.peek() != '(') { + char v = st.pop(); + if (v == 't') hasTrue = true; + if (v == 'f') hasFalse = true; + } + st.pop(); + char op = st.pop(); + if (op == '!') { + st.push(hasTrue ? 'f' : 't'); + } else if (op == '&') { + st.push(hasFalse ? 'f' : 't'); + } else { + st.push(hasTrue ? 't' : 'f'); + } + } + return st.peek() == 't'; + } +} diff --git a/tests/1001-1500/1106. parsing-a-boolean-expression/sol.kt b/tests/1001-1500/1106. parsing-a-boolean-expression/sol.kt new file mode 100644 index 00000000..72c23489 --- /dev/null +++ b/tests/1001-1500/1106. parsing-a-boolean-expression/sol.kt @@ -0,0 +1,25 @@ +class Solution { + fun parseBoolExpr(expression: String): Boolean { + val st = mutableListOf>(mutableListOf()) + for (ch in expression) { + when (ch) { + '&' -> st.add(mutableListOf("&")) + '|' -> st.add(mutableListOf("|")) + '!' -> st.add(mutableListOf("!")) + 't' -> st.last().add(true) + 'f' -> st.last().add(false) + ')' -> { + val popped = st.removeAt(st.lastIndex) + val op = popped.removeAt(0) as String + val top = st.last() + when (op) { + "&" -> top.add(popped.all { it as Boolean }) + "|" -> top.add(popped.any { it as Boolean }) + "!" -> top.add(!(popped[0] as Boolean)) + } + } + } + } + return st[0][0] as Boolean + } +} diff --git a/tests/1001-1500/1106. parsing-a-boolean-expression/sol.py b/tests/1001-1500/1106. parsing-a-boolean-expression/sol.py new file mode 100644 index 00000000..1662415d --- /dev/null +++ b/tests/1001-1500/1106. parsing-a-boolean-expression/sol.py @@ -0,0 +1,19 @@ +class Solution: + def parseBoolExpr(self, expression: str) -> bool: + st = [[]] + for ch in expression: + if ch == "&": + st.append([all]) + elif ch == "|": + st.append([any]) + elif ch == "!": + st.append([lambda q: not q[0]]) + elif ch == "t": + st[-1].append(True) + elif ch == "f": + st[-1].append(False) + elif ch == ")": + operation, *args = st.pop() + st[-1].append(operation(args)) + + return st[0][0] diff --git a/tests/1001-1500/1106. parsing-a-boolean-expression/sol.py2 b/tests/1001-1500/1106. parsing-a-boolean-expression/sol.py2 new file mode 100644 index 00000000..e7c7d62e --- /dev/null +++ b/tests/1001-1500/1106. parsing-a-boolean-expression/sol.py2 @@ -0,0 +1,26 @@ +class Solution(object): + def parseBoolExpr(self, expression): + st = [] + for ch in expression: + if ch == ',': + continue + if ch != ')': + st.append(ch) + continue + has_true = False + has_false = False + while st[-1] != '(': + v = st.pop() + if v == 't': + has_true = True + if v == 'f': + has_false = True + st.pop() + op = st.pop() + if op == '!': + st.append('f' if has_true else 't') + elif op == '&': + st.append('f' if has_false else 't') + else: + st.append('t' if has_true else 'f') + return st[0] == 't' diff --git a/tests/1001-1500/1106. parsing-a-boolean-expression/sol.rb b/tests/1001-1500/1106. parsing-a-boolean-expression/sol.rb new file mode 100644 index 00000000..1c6eeac1 --- /dev/null +++ b/tests/1001-1500/1106. parsing-a-boolean-expression/sol.rb @@ -0,0 +1,22 @@ +# @param {String} expression +# @return {Boolean} +def parse_bool_expr(expression) + st = [[]] + expression.each_char do |ch| + if ch == '&' + st << [->(a) { a.all? }] + elsif ch == '|' + st << [->(a) { a.any? }] + elsif ch == '!' + st << [->(a) { !a[0] }] + elsif ch == 't' + st[-1] << true + elsif ch == 'f' + st[-1] << false + elsif ch == ')' + op, *args = st.pop + st[-1] << op.call(args) + end + end + st[0][0] +end diff --git a/tests/1001-1500/1106. parsing-a-boolean-expression/sol.rs b/tests/1001-1500/1106. parsing-a-boolean-expression/sol.rs new file mode 100644 index 00000000..000e20d5 --- /dev/null +++ b/tests/1001-1500/1106. parsing-a-boolean-expression/sol.rs @@ -0,0 +1,42 @@ +impl Solution { + pub fn parse_bool_expr(expression: String) -> bool { + let mut st: Vec>> = vec![vec![]]; + for ch in expression.chars() { + match ch { + '&' => st.push(vec![Box::new("&".to_string())]), + '|' => st.push(vec![Box::new("|".to_string())]), + '!' => st.push(vec![Box::new("!".to_string())]), + 't' => { + let top = st.last_mut().unwrap(); + top.push(Box::new(true)); + } + 'f' => { + let top = st.last_mut().unwrap(); + top.push(Box::new(false)); + } + ')' => { + let mut popped = st.pop().unwrap(); + let op = popped.remove(0).downcast::().unwrap(); + let top = st.last_mut().unwrap(); + match op.as_str() { + "&" => { + let res = popped.iter().all(|v| *v.downcast_ref::().unwrap()); + top.push(Box::new(res)); + } + "|" => { + let res = popped.iter().any(|v| *v.downcast_ref::().unwrap()); + top.push(Box::new(res)); + } + "!" => { + let res = !*popped[0].downcast_ref::().unwrap(); + top.push(Box::new(res)); + } + _ => {} + } + } + _ => {} + } + } + *st[0][0].downcast_ref::().unwrap() + } +} diff --git a/tests/1001-1500/1106. parsing-a-boolean-expression/sol.swift b/tests/1001-1500/1106. parsing-a-boolean-expression/sol.swift new file mode 100644 index 00000000..c3d09aed --- /dev/null +++ b/tests/1001-1500/1106. parsing-a-boolean-expression/sol.swift @@ -0,0 +1,29 @@ +class Solution { + func parseBoolExpr(_ expression: String) -> Bool { + var st: [Character] = [] + for ch in expression { + if ch == "," { continue } + if ch != ")" { + st.append(ch) + continue + } + var hasTrue = false + var hasFalse = false + while let last = st.last, last != "(" { + let v = st.removeLast() + if v == "t" { hasTrue = true } + if v == "f" { hasFalse = true } + } + st.removeLast() + let op = st.removeLast() + if op == "!" { + st.append(hasTrue ? "f" : "t") + } else if op == "&" { + st.append(hasFalse ? "f" : "t") + } else { + st.append(hasTrue ? "t" : "f") + } + } + return st[0] == "t" + } +} diff --git a/tests/1001-1500/1106. parsing-a-boolean-expression/sol.ts b/tests/1001-1500/1106. parsing-a-boolean-expression/sol.ts new file mode 100644 index 00000000..395420e7 --- /dev/null +++ b/tests/1001-1500/1106. parsing-a-boolean-expression/sol.ts @@ -0,0 +1,28 @@ +function parseBoolExpr(expression: string): boolean { + const st: any[][] = [[]]; + for (const ch of expression) { + if (ch === "&") { + st.push(["&"]); + } else if (ch === "|") { + st.push(["|"]); + } else if (ch === "!") { + st.push(["!"]); + } else if (ch === "t") { + st[st.length - 1].push(true); + } else if (ch === "f") { + st[st.length - 1].push(false); + } else if (ch === ")") { + const popped = st.pop()!; + const op = popped.shift() as string; + const top = st[st.length - 1]; + if (op === "&") { + top.push(popped.every((v: boolean) => v)); + } else if (op === "|") { + top.push(popped.some((v: boolean) => v)); + } else if (op === "!") { + top.push(!popped[0]); + } + } + } + return st[0][0] as boolean; +} diff --git a/tests/1001-1500/1108. defanging-an-ip-address/manifest.yaml b/tests/1001-1500/1108. defanging-an-ip-address/manifest.yaml new file mode 100644 index 00000000..10129d88 --- /dev/null +++ b/tests/1001-1500/1108. defanging-an-ip-address/manifest.yaml @@ -0,0 +1,192 @@ +entry: + id: 1108 + title: defanging-an-ip-address + params: + address: + type: string + call: + cpp: Solution().defangIPaddr({address}) + rust: Solution::defang_i_paddr({address}) + python3: Solution().defangIPaddr({address}) + python2: Solution().defangIPaddr({address}) + ruby: defang_i_paddr({address}) + java: new Solution().defangIPaddr({address}) + csharp: new Solution().DefangIPaddr({address}) + kotlin: Solution().defangIPaddr({address}) + go: defangIPaddr({address}) + dart: Solution().defangIPaddr({address}) + swift: Solution().defangIPaddr({address}) + typescript: defangIPaddr({address}) +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 256 +oracle: + python3: + call: Checker().defangIPaddr(address, {result}) + checker: + "class Checker:\n def defangIPaddr(self, address, result):\n \ + \ return result == address.replace(\".\", \"[.]\")\n" +seed: 1108 +tests: + - name: ex1 + in: + address: 1.1.1.1 + out: 1[.]1[.]1[.]1 + - name: ex2 + in: + address: 255.100.50.0 + out: 255[.]100[.]50[.]0 + - name: simple_localhost + in: + address: 127.0.0.1 + out: 127[.]0[.]0[.]1 + - name: leading_zeros + in: + address: 001.002.003.004 + out: 001[.]002[.]003[.]004 + - name: all_nines + in: + address: 9.9.9.9 + out: 9[.]9[.]9[.]9 + - name: mixed_lengths_1 + in: + address: 10.0.0.1 + out: 10[.]0[.]0[.]1 + - name: mixed_lengths_2 + in: + address: 172.16.254.1 + out: 172[.]16[.]254[.]1 + - name: class_a + in: + address: 1.23.45.67 + out: 1[.]23[.]45[.]67 + - name: class_b + in: + address: 98.76.54.32 + out: 98[.]76[.]54[.]32 + - name: class_c + in: + address: 11.22.33.44 + out: 11[.]22[.]33[.]44 + - name: edge_zeroes_1 + in: + address: 0.0.0.0 + out: 0[.]0[.]0[.]0 + - name: edge_zeroes_2 + in: + address: 100.200.30.40 + out: 100[.]200[.]30[.]40 + - name: random_1 + in: + address: 8.8.4.4 + out: 8[.]8[.]4[.]4 + - name: random_2 + in: + address: 192.168.1.1 + out: 192[.]168[.]1[.]1 + - name: random_3 + in: + address: 66.77.88.99 + out: 66[.]77[.]88[.]99 + - name: random_4 + in: + address: 123.45.67.89 + out: 123[.]45[.]67[.]89 + - name: random_5 + in: + address: 240.10.20.30 + out: 240[.]10[.]20[.]30 + - name: random_6 + in: + address: 17.34.51.68 + out: 17[.]34[.]51[.]68 + - name: random_7 + in: + address: 2.4.6.8 + out: 2[.]4[.]6[.]8 + - name: random_8 + in: + address: 11.111.11.111 + out: 11[.]111[.]11[.]111 + - name: random_9 + in: + address: 101.202.303.404 + out: 101[.]202[.]303[.]404 + - name: random_10 + in: + address: 54.32.10.8 + out: 54[.]32[.]10[.]8 + - name: random_11 + in: + address: 77.0.88.1 + out: 77[.]0[.]88[.]1 + - name: random_12 + in: + address: 150.149.148.147 + out: 150[.]149[.]148[.]147 + - name: random_13 + in: + address: 3.14.15.92 + out: 3[.]14[.]15[.]92 + - name: random_14 + in: + address: 250.250.250.250 + out: 250[.]250[.]250[.]250 + - name: random_15 + in: + address: 6.28.182.84 + out: 6[.]28[.]182[.]84 + - name: random_16 + in: + address: 12.34.56.78 + out: 12[.]34[.]56[.]78 + - name: random_17 + in: + address: 90.87.65.43 + out: 90[.]87[.]65[.]43 + - name: random_18 + in: + address: 210.0.210.0 + out: 210[.]0[.]210[.]0 + - name: random_19 + in: + address: 31.41.59.26 + out: 31[.]41[.]59[.]26 + - name: random_20 + in: + address: 200.100.50.25 + out: 200[.]100[.]50[.]25 + - name: random_21 + in: + address: 9.10.11.12 + out: 9[.]10[.]11[.]12 + - name: random_22 + in: + address: 13.21.34.55 + out: 13[.]21[.]34[.]55 + - name: random_23 + in: + address: 42.42.42.42 + out: 42[.]42[.]42[.]42 + - name: random_24 + in: + address: 255.0.255.0 + out: 255[.]0[.]255[.]0 + - name: random_25 + in: + address: 18.27.36.45 + out: 18[.]27[.]36[.]45 + - name: random_26 + in: + address: 203.0.113.7 + out: 203[.]0[.]113[.]7 + - name: random_27 + in: + address: 198.51.100.42 + out: 198[.]51[.]100[.]42 + - name: random_28 + in: + address: 10.10.10.10 + out: 10[.]10[.]10[.]10 diff --git a/tests/1001-1500/1108. defanging-an-ip-address/sol.cpp b/tests/1001-1500/1108. defanging-an-ip-address/sol.cpp new file mode 100644 index 00000000..805fd119 --- /dev/null +++ b/tests/1001-1500/1108. defanging-an-ip-address/sol.cpp @@ -0,0 +1,14 @@ +class Solution { +public: + string defangIPaddr(string address) { + string s = ""; + for (char i : address) { + if (i == '.') { + s += "[.]"; + } else { + s += i; + } + } + return s; + } +}; diff --git a/tests/1001-1500/1108. defanging-an-ip-address/sol.cs b/tests/1001-1500/1108. defanging-an-ip-address/sol.cs new file mode 100644 index 00000000..a393fd17 --- /dev/null +++ b/tests/1001-1500/1108. defanging-an-ip-address/sol.cs @@ -0,0 +1,13 @@ +public class Solution { + public string DefangIPaddr(string address) { + string s = ""; + foreach (char i in address) { + if (i == '.') { + s += "[.]"; + } else { + s += i; + } + } + return s; + } +} diff --git a/tests/1001-1500/1108. defanging-an-ip-address/sol.dart b/tests/1001-1500/1108. defanging-an-ip-address/sol.dart new file mode 100644 index 00000000..22b57d6f --- /dev/null +++ b/tests/1001-1500/1108. defanging-an-ip-address/sol.dart @@ -0,0 +1,13 @@ +class Solution { + String defangIPaddr(String address) { + StringBuffer buffer = StringBuffer(); + for (int i = 0; i < address.length; i++) { + if (address[i] == '.') { + buffer.write('[.]'); + } else { + buffer.write(address[i]); + } + } + return buffer.toString(); + } +} diff --git a/tests/1001-1500/1108. defanging-an-ip-address/sol.go b/tests/1001-1500/1108. defanging-an-ip-address/sol.go new file mode 100644 index 00000000..34e230a3 --- /dev/null +++ b/tests/1001-1500/1108. defanging-an-ip-address/sol.go @@ -0,0 +1,11 @@ +func defangIPaddr(address string) string { + s := "" + for _, i := range address { + if i == '.' { + s += "[.]" + } else { + s += string(i) + } + } + return s +} diff --git a/tests/1001-1500/1108. defanging-an-ip-address/sol.java b/tests/1001-1500/1108. defanging-an-ip-address/sol.java new file mode 100644 index 00000000..fc7e8dc3 --- /dev/null +++ b/tests/1001-1500/1108. defanging-an-ip-address/sol.java @@ -0,0 +1,13 @@ +class Solution { + public String defangIPaddr(String address) { + StringBuilder s = new StringBuilder(); + for (char i : address.toCharArray()) { + if (i == '.') { + s.append("[.]"); + } else { + s.append(i); + } + } + return s.toString(); + } +} diff --git a/tests/1001-1500/1108. defanging-an-ip-address/sol.kt b/tests/1001-1500/1108. defanging-an-ip-address/sol.kt new file mode 100644 index 00000000..a4f715ce --- /dev/null +++ b/tests/1001-1500/1108. defanging-an-ip-address/sol.kt @@ -0,0 +1,13 @@ +class Solution { + fun defangIPaddr(address: String): String { + val s = StringBuilder() + for (i in address) { + if (i == '.') { + s.append("[.]") + } else { + s.append(i) + } + } + return s.toString() + } +} diff --git a/tests/1001-1500/1108. defanging-an-ip-address/sol.py b/tests/1001-1500/1108. defanging-an-ip-address/sol.py new file mode 100644 index 00000000..01c31b8f --- /dev/null +++ b/tests/1001-1500/1108. defanging-an-ip-address/sol.py @@ -0,0 +1,9 @@ +class Solution(object): + def defangIPaddr(self, address: str) -> str: + s = "" + for i in address: + if i == ".": + s += "[.]" + else: + s += i + return s diff --git a/tests/1001-1500/1108. defanging-an-ip-address/sol.py2 b/tests/1001-1500/1108. defanging-an-ip-address/sol.py2 new file mode 100644 index 00000000..e5164902 --- /dev/null +++ b/tests/1001-1500/1108. defanging-an-ip-address/sol.py2 @@ -0,0 +1,13 @@ +class Solution(object): + def defangIPaddr(self, address): + """ + :type address: str + :rtype: str + """ + s = "" + for i in address: + if i == ".": + s += "[.]" + else: + s += i + return s diff --git a/tests/1001-1500/1108. defanging-an-ip-address/sol.rb b/tests/1001-1500/1108. defanging-an-ip-address/sol.rb new file mode 100644 index 00000000..af3c1372 --- /dev/null +++ b/tests/1001-1500/1108. defanging-an-ip-address/sol.rb @@ -0,0 +1,13 @@ +# @param {String} address +# @return {String} +def defang_i_paddr(address) + s = "" + address.each_char do |i| + if i == "." + s += "[.]" + else + s += i + end + end + s +end diff --git a/tests/1001-1500/1108. defanging-an-ip-address/sol.rs b/tests/1001-1500/1108. defanging-an-ip-address/sol.rs new file mode 100644 index 00000000..34f104ed --- /dev/null +++ b/tests/1001-1500/1108. defanging-an-ip-address/sol.rs @@ -0,0 +1,13 @@ +impl Solution { + pub fn defang_i_paddr(address: String) -> String { + let mut s = String::new(); + for i in address.chars() { + if i == '.' { + s.push_str("[.]"); + } else { + s.push(i); + } + } + s + } +} diff --git a/tests/1001-1500/1108. defanging-an-ip-address/sol.swift b/tests/1001-1500/1108. defanging-an-ip-address/sol.swift new file mode 100644 index 00000000..24368b53 --- /dev/null +++ b/tests/1001-1500/1108. defanging-an-ip-address/sol.swift @@ -0,0 +1,13 @@ +class Solution { + func defangIPaddr(_ address: String) -> String { + var s = "" + for i in address { + if i == "." { + s += "[.]" + } else { + s += String(i) + } + } + return s + } +} diff --git a/tests/1001-1500/1108. defanging-an-ip-address/sol.ts b/tests/1001-1500/1108. defanging-an-ip-address/sol.ts new file mode 100644 index 00000000..797f8525 --- /dev/null +++ b/tests/1001-1500/1108. defanging-an-ip-address/sol.ts @@ -0,0 +1,11 @@ +function defangIPaddr(address: string): string { + let s = ""; + for (const i of address) { + if (i === ".") { + s += "[.]"; + } else { + s += i; + } + } + return s; +} diff --git a/tests/1001-1500/1109. corporate-flight-bookings/manifest.yaml b/tests/1001-1500/1109. corporate-flight-bookings/manifest.yaml new file mode 100644 index 00000000..c33ed175 --- /dev/null +++ b/tests/1001-1500/1109. corporate-flight-bookings/manifest.yaml @@ -0,0 +1,861 @@ +entry: + id: 1109 + title: corporate-flight-bookings + params: + bookings: + type: array + items: + type: array + items: + type: int + n: + type: int + call: + cpp: Solution().corpFlightBookings({bookings}, {n}) + rust: Solution::corp_flight_bookings({bookings}, {n}) + python3: Solution().corpFlightBookings({bookings}, {n}) + python2: Solution().corpFlightBookings({bookings}, {n}) + ruby: corp_flight_bookings({bookings}, {n}) + java: new Solution().corpFlightBookings({bookings}, {n}) + csharp: new Solution().CorpFlightBookings({bookings}, {n}) + kotlin: Solution().corpFlightBookings({bookings}, {n}) + go: corpFlightBookings({bookings}, {n}) + dart: Solution().corpFlightBookings({bookings}, {n}) + swift: Solution().corpFlightBookings({bookings}, {n}) + typescript: corpFlightBookings({bookings}, {n}) +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 256 +oracle: + python3: + call: Checker().corpFlightBookings(bookings, n, {result}) + checker: + "class Checker:\n def corpFlightBookings(self, bookings, n, result):\n\ + \ if not isinstance(result, list) or len(result) != n:\n return\ + \ False\n expected = [0] * n\n for first, last, seats in bookings:\n\ + \ if not (1 <= first <= last <= n):\n return False\n\ + \ for i in range(first - 1, last):\n expected[i] +=\ + \ seats\n return result == expected\n" +seed: 1109 +tests: + - name: ex1 + in: + bookings: + elemType: int + value: + - - 1 + - 2 + - 10 + - - 2 + - 3 + - 20 + - - 2 + - 5 + - 25 + n: 5 + out: + - 10 + - 55 + - 45 + - 25 + - 25 + - name: ex2 + in: + bookings: + elemType: int + value: + - - 1 + - 2 + - 10 + - - 2 + - 2 + - 15 + n: 2 + out: + - 10 + - 25 + - name: single_booking_first + in: + bookings: + elemType: int + value: + - - 1 + - 1 + - 7 + n: 1 + out: + - 7 + - name: single_booking_tail + in: + bookings: + elemType: int + value: + - - 3 + - 5 + - 4 + n: 5 + out: + - 0 + - 0 + - 4 + - 4 + - 4 + - name: no_overlap + in: + bookings: + elemType: int + value: + - - 1 + - 1 + - 5 + - - 2 + - 2 + - 7 + - - 3 + - 3 + - 9 + n: 3 + out: + - 5 + - 7 + - 9 + - name: full_cover + in: + bookings: + elemType: int + value: + - - 1 + - 4 + - 3 + n: 4 + out: + - 3 + - 3 + - 3 + - 3 + - name: nested_ranges + in: + bookings: + elemType: int + value: + - - 1 + - 5 + - 2 + - - 2 + - 4 + - 3 + - - 3 + - 3 + - 4 + n: 5 + out: + - 2 + - 5 + - 9 + - 5 + - 2 + - name: repeated_ranges + in: + bookings: + elemType: int + value: + - - 2 + - 4 + - 1 + - - 2 + - 4 + - 2 + - - 2 + - 4 + - 3 + n: 5 + out: + - 0 + - 6 + - 6 + - 6 + - 0 + - name: prefix_only + in: + bookings: + elemType: int + value: + - - 1 + - 3 + - 8 + - - 1 + - 2 + - 1 + n: 4 + out: + - 9 + - 9 + - 8 + - 0 + - name: suffix_only + in: + bookings: + elemType: int + value: + - - 4 + - 6 + - 11 + n: 6 + out: + - 0 + - 0 + - 0 + - 11 + - 11 + - 11 + - name: mixed_small_1 + in: + bookings: + elemType: int + value: + - - 1 + - 2 + - 5 + - - 2 + - 5 + - 1 + - - 4 + - 5 + - 10 + n: 5 + out: + - 5 + - 6 + - 1 + - 11 + - 11 + - name: mixed_small_2 + in: + bookings: + elemType: int + value: + - - 2 + - 2 + - 100 + - - 1 + - 3 + - 1 + - - 3 + - 3 + - 2 + n: 3 + out: + - 1 + - 101 + - 3 + - name: mixed_small_3 + in: + bookings: + elemType: int + value: + - - 1 + - 4 + - 1 + - - 2 + - 3 + - 2 + - - 3 + - 4 + - 3 + n: 4 + out: + - 1 + - 3 + - 6 + - 4 + - name: mixed_small_4 + in: + bookings: + elemType: int + value: + - - 1 + - 1 + - 9 + - - 1 + - 5 + - 1 + - - 5 + - 5 + - 9 + n: 5 + out: + - 10 + - 1 + - 1 + - 1 + - 10 + - name: mixed_small_5 + in: + bookings: + elemType: int + value: + - - 2 + - 5 + - 4 + - - 1 + - 3 + - 6 + - - 3 + - 5 + - 2 + n: 5 + out: + - 6 + - 10 + - 12 + - 6 + - 6 + - name: random_1 + in: + bookings: + elemType: int + value: + - - 1 + - 6 + - 1 + - - 2 + - 2 + - 2 + - - 4 + - 6 + - 3 + n: 6 + out: + - 1 + - 3 + - 1 + - 4 + - 4 + - 4 + - name: random_2 + in: + bookings: + elemType: int + value: + - - 3 + - 7 + - 2 + - - 1 + - 4 + - 5 + - - 5 + - 7 + - 1 + n: 7 + out: + - 5 + - 5 + - 7 + - 7 + - 3 + - 3 + - 3 + - name: random_3 + in: + bookings: + elemType: int + value: + - - 1 + - 2 + - 10 + - - 2 + - 6 + - 10 + - - 4 + - 6 + - 10 + n: 6 + out: + - 10 + - 20 + - 10 + - 20 + - 20 + - 20 + - name: random_4 + in: + bookings: + elemType: int + value: + - - 1 + - 8 + - 1 + - - 8 + - 8 + - 8 + n: 8 + out: + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 9 + - name: random_5 + in: + bookings: + elemType: int + value: + - - 2 + - 6 + - 7 + - - 2 + - 3 + - 1 + - - 6 + - 6 + - 9 + n: 6 + out: + - 0 + - 8 + - 8 + - 7 + - 7 + - 16 + - name: random_6 + in: + bookings: + elemType: int + value: + - - 1 + - 1 + - 4 + - - 1 + - 2 + - 4 + - - 2 + - 2 + - 4 + n: 2 + out: + - 8 + - 8 + - name: random_7 + in: + bookings: + elemType: int + value: + - - 4 + - 4 + - 12 + - - 1 + - 4 + - 1 + - - 2 + - 3 + - 2 + n: 4 + out: + - 1 + - 3 + - 3 + - 13 + - name: random_8 + in: + bookings: + elemType: int + value: + - - 1 + - 5 + - 2 + - - 5 + - 5 + - 8 + - - 1 + - 1 + - 1 + n: 5 + out: + - 3 + - 2 + - 2 + - 2 + - 10 + - name: random_9 + in: + bookings: + elemType: int + value: + - - 2 + - 4 + - 9 + - - 1 + - 2 + - 1 + - - 3 + - 5 + - 3 + n: 5 + out: + - 1 + - 10 + - 12 + - 12 + - 3 + - name: random_10 + in: + bookings: + elemType: int + value: + - - 1 + - 7 + - 7 + - - 7 + - 7 + - 7 + - - 3 + - 5 + - 1 + n: 7 + out: + - 7 + - 7 + - 8 + - 8 + - 8 + - 7 + - 14 + - name: random_11 + in: + bookings: + elemType: int + value: + - - 1 + - 3 + - 100 + - - 2 + - 5 + - 1 + - - 5 + - 5 + - 100 + n: 5 + out: + - 100 + - 101 + - 101 + - 1 + - 101 + - name: random_12 + in: + bookings: + elemType: int + value: + - - 3 + - 3 + - 5 + - - 1 + - 6 + - 2 + - - 6 + - 6 + - 3 + n: 6 + out: + - 2 + - 2 + - 7 + - 2 + - 2 + - 5 + - name: random_13 + in: + bookings: + elemType: int + value: + - - 1 + - 9 + - 1 + - - 2 + - 8 + - 2 + - - 3 + - 7 + - 3 + n: 9 + out: + - 1 + - 3 + - 6 + - 6 + - 6 + - 6 + - 6 + - 3 + - 1 + - name: random_14 + in: + bookings: + elemType: int + value: + - - 1 + - 4 + - 2 + - - 2 + - 4 + - 2 + - - 3 + - 4 + - 2 + n: 4 + out: + - 2 + - 4 + - 6 + - 6 + - name: random_15 + in: + bookings: + elemType: int + value: + - - 5 + - 5 + - 5 + - - 1 + - 10 + - 1 + - - 10 + - 10 + - 9 + n: 10 + out: + - 1 + - 1 + - 1 + - 1 + - 6 + - 1 + - 1 + - 1 + - 1 + - 10 + - name: random_16 + in: + bookings: + elemType: int + value: + - - 1 + - 2 + - 3 + - - 3 + - 4 + - 4 + - - 5 + - 6 + - 5 + n: 6 + out: + - 3 + - 3 + - 4 + - 4 + - 5 + - 5 + - name: random_17 + in: + bookings: + elemType: int + value: + - - 2 + - 7 + - 2 + - - 1 + - 1 + - 1 + - - 7 + - 7 + - 4 + n: 7 + out: + - 1 + - 2 + - 2 + - 2 + - 2 + - 2 + - 6 + - name: random_18 + in: + bookings: + elemType: int + value: + - - 1 + - 3 + - 7 + - - 2 + - 2 + - 8 + - - 3 + - 3 + - 9 + n: 3 + out: + - 7 + - 15 + - 16 + - name: random_19 + in: + bookings: + elemType: int + value: + - - 4 + - 8 + - 4 + - - 1 + - 4 + - 1 + - - 8 + - 8 + - 2 + n: 8 + out: + - 1 + - 1 + - 1 + - 5 + - 4 + - 4 + - 4 + - 6 + - name: random_20 + in: + bookings: + elemType: int + value: + - - 1 + - 5 + - 10 + - - 2 + - 4 + - 20 + - - 3 + - 3 + - 30 + n: 5 + out: + - 10 + - 30 + - 60 + - 30 + - 10 + - name: random_21 + in: + bookings: + elemType: int + value: + - - 6 + - 6 + - 1 + - - 1 + - 6 + - 1 + n: 6 + out: + - 1 + - 1 + - 1 + - 1 + - 1 + - 2 + - name: random_22 + in: + bookings: + elemType: int + value: + - - 1 + - 2 + - 5 + - - 2 + - 3 + - 5 + - - 3 + - 4 + - 5 + n: 4 + out: + - 5 + - 10 + - 10 + - 5 + - name: random_23 + in: + bookings: + elemType: int + value: + - - 1 + - 1 + - 1 + - - 2 + - 2 + - 2 + - - 3 + - 3 + - 3 + - - 4 + - 4 + - 4 + n: 4 + out: + - 1 + - 2 + - 3 + - 4 + - name: random_24 + in: + bookings: + elemType: int + value: + - - 1 + - 6 + - 2 + - - 2 + - 5 + - 3 + - - 4 + - 6 + - 4 + n: 6 + out: + - 2 + - 5 + - 5 + - 9 + - 9 + - 6 + - name: random_25 + in: + bookings: + elemType: int + value: + - - 1 + - 8 + - 1 + - - 2 + - 7 + - 2 + - - 3 + - 6 + - 3 + - - 4 + - 5 + - 4 + n: 8 + out: + - 1 + - 3 + - 6 + - 10 + - 10 + - 6 + - 3 + - 1 diff --git a/tests/1001-1500/1109. corporate-flight-bookings/sol.cpp b/tests/1001-1500/1109. corporate-flight-bookings/sol.cpp new file mode 100644 index 00000000..aeb13403 --- /dev/null +++ b/tests/1001-1500/1109. corporate-flight-bookings/sol.cpp @@ -0,0 +1,22 @@ +class Solution { +public: + vector corpFlightBookings(vector>& bookings, int n) { + vector l(n + 1, 0); + for (auto& i : bookings) { + int x = i[0]; + int y = i[1]; + l[x - 1] += i[2]; + l[y] -= i[2]; + } + + vector s; + for (int i = 0; i < n; i++) { + if (i == 0) { + s.push_back(l[i]); + } else { + s.push_back(s[i - 1] + l[i]); + } + } + return s; + } +}; diff --git a/tests/1001-1500/1109. corporate-flight-bookings/sol.cs b/tests/1001-1500/1109. corporate-flight-bookings/sol.cs new file mode 100644 index 00000000..2cd7db2c --- /dev/null +++ b/tests/1001-1500/1109. corporate-flight-bookings/sol.cs @@ -0,0 +1,21 @@ +public class Solution { + public int[] CorpFlightBookings(int[][] bookings, int n) { + int[] l = new int[n + 1]; + foreach (int[] i in bookings) { + int x = i[0]; + int y = i[1]; + l[x - 1] += i[2]; + l[y] -= i[2]; + } + + int[] s = new int[n]; + for (int i = 0; i < n; i++) { + if (i == 0) { + s[i] = l[i]; + } else { + s[i] = s[i - 1] + l[i]; + } + } + return s; + } +} diff --git a/tests/1001-1500/1109. corporate-flight-bookings/sol.dart b/tests/1001-1500/1109. corporate-flight-bookings/sol.dart new file mode 100644 index 00000000..ac0a0929 --- /dev/null +++ b/tests/1001-1500/1109. corporate-flight-bookings/sol.dart @@ -0,0 +1,21 @@ +class Solution { + List corpFlightBookings(List> bookings, int n) { + List l = List.filled(n + 1, 0); + for (var i in bookings) { + int x = i[0]; + int y = i[1]; + l[x - 1] += i[2]; + l[y] -= i[2]; + } + + List s = []; + for (int i = 0; i < n; i++) { + if (i == 0) { + s.add(l[i]); + } else { + s.add(s[i - 1] + l[i]); + } + } + return s; + } +} diff --git a/tests/1001-1500/1109. corporate-flight-bookings/sol.go b/tests/1001-1500/1109. corporate-flight-bookings/sol.go new file mode 100644 index 00000000..dce703c5 --- /dev/null +++ b/tests/1001-1500/1109. corporate-flight-bookings/sol.go @@ -0,0 +1,19 @@ +func corpFlightBookings(bookings [][]int, n int) []int { + l := make([]int, n+1) + for _, i := range bookings { + x := i[0] + y := i[1] + l[x-1] += i[2] + l[y] -= i[2] + } + + s := make([]int, n) + for i := 0; i < n; i++ { + if i == 0 { + s[i] = l[i] + } else { + s[i] = s[i-1] + l[i] + } + } + return s +} diff --git a/tests/1001-1500/1109. corporate-flight-bookings/sol.java b/tests/1001-1500/1109. corporate-flight-bookings/sol.java new file mode 100644 index 00000000..3b2585f1 --- /dev/null +++ b/tests/1001-1500/1109. corporate-flight-bookings/sol.java @@ -0,0 +1,21 @@ +class Solution { + public int[] corpFlightBookings(int[][] bookings, int n) { + int[] l = new int[n + 1]; + for (int[] i : bookings) { + int x = i[0]; + int y = i[1]; + l[x - 1] += i[2]; + l[y] -= i[2]; + } + + int[] s = new int[n]; + for (int i = 0; i < n; i++) { + if (i == 0) { + s[i] = l[i]; + } else { + s[i] = s[i - 1] + l[i]; + } + } + return s; + } +} diff --git a/tests/1001-1500/1109. corporate-flight-bookings/sol.kt b/tests/1001-1500/1109. corporate-flight-bookings/sol.kt new file mode 100644 index 00000000..52c815f8 --- /dev/null +++ b/tests/1001-1500/1109. corporate-flight-bookings/sol.kt @@ -0,0 +1,21 @@ +class Solution { + fun corpFlightBookings(bookings: Array, n: Int): IntArray { + val l = IntArray(n + 1) + for (i in bookings) { + val x = i[0] + val y = i[1] + l[x - 1] += i[2] + l[y] -= i[2] + } + + val s = IntArray(n) + for (i in 0 until n) { + if (i == 0) { + s[i] = l[i] + } else { + s[i] = s[i - 1] + l[i] + } + } + return s + } +} diff --git a/tests/1001-1500/1109. corporate-flight-bookings/sol.py b/tests/1001-1500/1109. corporate-flight-bookings/sol.py new file mode 100644 index 00000000..98c08763 --- /dev/null +++ b/tests/1001-1500/1109. corporate-flight-bookings/sol.py @@ -0,0 +1,16 @@ +class Solution(object): + def corpFlightBookings(self, bookings, n): + l = [0] * (n + 1) + for i in bookings: + x = i[0] + y = i[1] + l[x - 1] += i[-1] + l[y] -= i[-1] + + s = [] + for i in range(len(l) - 1): + if i == 0: + s.append(l[i]) + else: + s.append(s[-1] + l[i]) + return s diff --git a/tests/1001-1500/1109. corporate-flight-bookings/sol.py2 b/tests/1001-1500/1109. corporate-flight-bookings/sol.py2 new file mode 100644 index 00000000..a501d1ba --- /dev/null +++ b/tests/1001-1500/1109. corporate-flight-bookings/sol.py2 @@ -0,0 +1,21 @@ +class Solution(object): + def corpFlightBookings(self, bookings, n): + """ + :type bookings: List[List[int]] + :type n: int + :rtype: List[int] + """ + l = [0] * (n + 1) + for i in bookings: + x = i[0] + y = i[1] + l[x - 1] += i[-1] + l[y] -= i[-1] + + s = [] + for i in range(len(l) - 1): + if i == 0: + s.append(l[i]) + else: + s.append(s[-1] + l[i]) + return s diff --git a/tests/1001-1500/1109. corporate-flight-bookings/sol.rb b/tests/1001-1500/1109. corporate-flight-bookings/sol.rb new file mode 100644 index 00000000..789f0854 --- /dev/null +++ b/tests/1001-1500/1109. corporate-flight-bookings/sol.rb @@ -0,0 +1,22 @@ +# @param {Integer[][]} bookings +# @param {Integer} n +# @return {Integer[]} +def corp_flight_bookings(bookings, n) + l = Array.new(n + 1, 0) + bookings.each do |i| + x = i[0] + y = i[1] + l[x - 1] += i[-1] + l[y] -= i[-1] + end + + s = [] + (0...l.length - 1).each do |i| + if i == 0 + s << l[i] + else + s << s[-1] + l[i] + end + end + s +end diff --git a/tests/1001-1500/1109. corporate-flight-bookings/sol.rs b/tests/1001-1500/1109. corporate-flight-bookings/sol.rs new file mode 100644 index 00000000..e0cfac27 --- /dev/null +++ b/tests/1001-1500/1109. corporate-flight-bookings/sol.rs @@ -0,0 +1,23 @@ +impl Solution { + pub fn corp_flight_bookings(bookings: Vec>, n: i32) -> Vec { + let n = n as usize; + let mut l = vec![0; n + 1]; + for i in bookings { + let x = i[0] as usize; + let y = i[1] as usize; + l[x - 1] += i[2]; + l[y] -= i[2]; + } + + let mut s = Vec::with_capacity(n); + for i in 0..n { + if i == 0 { + s.push(l[i]); + } else { + let prev = s[i - 1]; + s.push(prev + l[i]); + } + } + s + } +} diff --git a/tests/1001-1500/1109. corporate-flight-bookings/sol.swift b/tests/1001-1500/1109. corporate-flight-bookings/sol.swift new file mode 100644 index 00000000..91c92d11 --- /dev/null +++ b/tests/1001-1500/1109. corporate-flight-bookings/sol.swift @@ -0,0 +1,21 @@ +class Solution { + func corpFlightBookings(_ bookings: [[Int]], _ n: Int) -> [Int] { + var l = Array(repeating: 0, count: n + 1) + for i in bookings { + let x = i[0] + let y = i[1] + l[x - 1] += i[2] + l[y] -= i[2] + } + + var s = [Int]() + for i in 0.. +#include +#include +using namespace std; + +class Solution { +public: + vector delNodes(TreeNode* root, vector& to_delete) { + vector ans; + if (!root) return ans; + + unordered_set st(to_delete.begin(), to_delete.end()); + + TreeNode* ref = new TreeNode(-1); + ref->left = root; + + deque q1; + deque toProcess; + toProcess.push_back(ref); + + while (!toProcess.empty()) { + TreeNode* newTree = toProcess.front(); + toProcess.pop_front(); + + if (newTree->left) { + if (st.count(newTree->left->val)) { + toProcess.push_back(newTree->left); + } else { + ans.push_back(newTree->left); + q1.push_back(newTree->left); + } + newTree->left = nullptr; + } + + if (newTree->right) { + if (st.count(newTree->right->val)) { + toProcess.push_back(newTree->right); + } else { + ans.push_back(newTree->right); + q1.push_back(newTree->right); + } + newTree->right = nullptr; + } + + while (!q1.empty()) { + TreeNode* temp = q1.front(); + q1.pop_front(); + + if (temp->left) { + if (st.count(temp->left->val)) { + toProcess.push_back(temp->left); + temp->left = nullptr; + } else { + q1.push_back(temp->left); + } + } + + if (temp->right) { + if (st.count(temp->right->val)) { + toProcess.push_back(temp->right); + temp->right = nullptr; + } else { + q1.push_back(temp->right); + } + } + } + } + + return ans; + } +}; diff --git a/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.cs b/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.cs new file mode 100644 index 00000000..d580a51c --- /dev/null +++ b/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.cs @@ -0,0 +1,64 @@ +using System.Collections.Generic; + +public class Solution { + public IList DelNodes(TreeNode root, int[] to_delete) { + List ans = new List(); + if (root == null) return ans; + + HashSet st = new HashSet(to_delete); + TreeNode refNode = new TreeNode(-1); + refNode.left = root; + + Queue q1 = new Queue(); + Queue toProcess = new Queue(); + toProcess.Enqueue(refNode); + + while (toProcess.Count > 0) { + TreeNode newTree = toProcess.Dequeue(); + + if (newTree.left != null) { + if (st.Contains(newTree.left.val)) { + toProcess.Enqueue(newTree.left); + } else { + ans.Add(newTree.left); + q1.Enqueue(newTree.left); + } + newTree.left = null; + } + + if (newTree.right != null) { + if (st.Contains(newTree.right.val)) { + toProcess.Enqueue(newTree.right); + } else { + ans.Add(newTree.right); + q1.Enqueue(newTree.right); + } + newTree.right = null; + } + + while (q1.Count > 0) { + TreeNode temp = q1.Dequeue(); + + if (temp.left != null) { + if (st.Contains(temp.left.val)) { + toProcess.Enqueue(temp.left); + temp.left = null; + } else { + q1.Enqueue(temp.left); + } + } + + if (temp.right != null) { + if (st.Contains(temp.right.val)) { + toProcess.Enqueue(temp.right); + temp.right = null; + } else { + q1.Enqueue(temp.right); + } + } + } + } + + return ans; + } +} diff --git a/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.dart b/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.dart new file mode 100644 index 00000000..cb3836f7 --- /dev/null +++ b/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.dart @@ -0,0 +1,74 @@ +import 'dart:collection'; + +/** + * Definition for a binary tree node. + * class TreeNode { + * int val; + * TreeNode? left; + * TreeNode? right; + * TreeNode([this.val = 0, this.left, this.right]); + * } + */ +class Solution { + List delNodes(TreeNode? root, List toDelete) { + List result = []; + if (root == null) { + return result; + } + + Set deleted = toDelete.toSet(); + TreeNode ref = TreeNode(-1); + ref.left = root; + + Queue queue = Queue(); + Queue pending = Queue()..add(ref); + + while (pending.isNotEmpty) { + TreeNode current = pending.removeFirst(); + + if (current.left != null) { + if (deleted.contains(current.left!.val)) { + pending.add(current.left!); + } else { + result.add(current.left); + queue.add(current.left!); + } + current.left = null; + } + + if (current.right != null) { + if (deleted.contains(current.right!.val)) { + pending.add(current.right!); + } else { + result.add(current.right); + queue.add(current.right!); + } + current.right = null; + } + + while (queue.isNotEmpty) { + TreeNode node = queue.removeFirst(); + + if (node.left != null) { + if (deleted.contains(node.left!.val)) { + pending.add(node.left!); + node.left = null; + } else { + queue.add(node.left!); + } + } + + if (node.right != null) { + if (deleted.contains(node.right!.val)) { + pending.add(node.right!); + node.right = null; + } else { + queue.add(node.right!); + } + } + } + } + + return result; + } +} diff --git a/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.go b/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.go new file mode 100644 index 00000000..e6c6e198 --- /dev/null +++ b/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.go @@ -0,0 +1,67 @@ +func delNodes(root *TreeNode, to_delete []int) []*TreeNode { + ans := []*TreeNode{} + if root == nil { + return ans + } + + st := make(map[int]bool) + for _, v := range to_delete { + st[v] = true + } + + ref := &TreeNode{Val: -1} + ref.Left = root + + q1 := []*TreeNode{} + toProcess := []*TreeNode{ref} + + for len(toProcess) > 0 { + newTree := toProcess[0] + toProcess = toProcess[1:] + + if newTree.Left != nil { + if st[newTree.Left.Val] { + toProcess = append(toProcess, newTree.Left) + } else { + ans = append(ans, newTree.Left) + q1 = append(q1, newTree.Left) + } + newTree.Left = nil + } + + if newTree.Right != nil { + if st[newTree.Right.Val] { + toProcess = append(toProcess, newTree.Right) + } else { + ans = append(ans, newTree.Right) + q1 = append(q1, newTree.Right) + } + newTree.Right = nil + } + + for len(q1) > 0 { + temp := q1[0] + q1 = q1[1:] + + if temp.Left != nil { + if st[temp.Left.Val] { + toProcess = append(toProcess, temp.Left) + temp.Left = nil + } else { + q1 = append(q1, temp.Left) + } + } + + if temp.Right != nil { + if st[temp.Right.Val] { + toProcess = append(toProcess, temp.Right) + temp.Right = nil + } else { + q1 = append(q1, temp.Right) + } + } + } + } + + return ans +} diff --git a/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.java b/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.java new file mode 100644 index 00000000..d10103ab --- /dev/null +++ b/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.java @@ -0,0 +1,66 @@ +import java.util.*; + +class Solution { + public List delNodes(TreeNode root, int[] to_delete) { + List ans = new ArrayList<>(); + if (root == null) return ans; + + Set st = new HashSet<>(); + for (int val : to_delete) st.add(val); + + TreeNode ref = new TreeNode(-1); + ref.left = root; + + Deque q1 = new ArrayDeque<>(); + Deque toProcess = new ArrayDeque<>(); + toProcess.add(ref); + + while (!toProcess.isEmpty()) { + TreeNode newTree = toProcess.poll(); + + if (newTree.left != null) { + if (st.contains(newTree.left.val)) { + toProcess.add(newTree.left); + } else { + ans.add(newTree.left); + q1.add(newTree.left); + } + newTree.left = null; + } + + if (newTree.right != null) { + if (st.contains(newTree.right.val)) { + toProcess.add(newTree.right); + } else { + ans.add(newTree.right); + q1.add(newTree.right); + } + newTree.right = null; + } + + while (!q1.isEmpty()) { + TreeNode temp = q1.poll(); + + if (temp.left != null) { + if (st.contains(temp.left.val)) { + toProcess.add(temp.left); + temp.left = null; + } else { + q1.add(temp.left); + } + } + + if (temp.right != null) { + if (st.contains(temp.right.val)) { + toProcess.add(temp.right); + temp.right = null; + } else { + q1.add(temp.right); + } + } + } + } + + return ans; + } +} diff --git a/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.kt b/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.kt new file mode 100644 index 00000000..fa8b2fb6 --- /dev/null +++ b/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.kt @@ -0,0 +1,64 @@ +import java.util.* + +class Solution { + fun delNodes(root: TreeNode?, to_delete: IntArray): List { + val ans = mutableListOf() + if (root == null) return ans + + val st = to_delete.toHashSet() + val ref = TreeNode(-1) + ref.left = root + + val q1: Deque = ArrayDeque() + val toProcess: Deque = ArrayDeque() + toProcess.add(ref) + + while (toProcess.isNotEmpty()) { + val newTree = toProcess.poll() + + if (newTree.left != null) { + if (st.contains(newTree.left!!.`val`)) { + toProcess.add(newTree.left) + } else { + ans.add(newTree.left!!) + q1.add(newTree.left) + } + newTree.left = null + } + + if (newTree.right != null) { + if (st.contains(newTree.right!!.`val`)) { + toProcess.add(newTree.right) + } else { + ans.add(newTree.right!!) + q1.add(newTree.right) + } + newTree.right = null + } + + while (q1.isNotEmpty()) { + val temp = q1.poll() + + if (temp.left != null) { + if (st.contains(temp.left!!.`val`)) { + toProcess.add(temp.left) + temp.left = null + } else { + q1.add(temp.left) + } + } + + if (temp.right != null) { + if (st.contains(temp.right!!.`val`)) { + toProcess.add(temp.right) + temp.right = null + } else { + q1.add(temp.right) + } + } + } + } + + return ans + } +} diff --git a/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.py b/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.py new file mode 100644 index 00000000..244dbf08 --- /dev/null +++ b/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.py @@ -0,0 +1,54 @@ +from collections import deque + + +class Solution: + def delNodes(self, root, to_delete): + ans = [] + if not root: + return ans + + st = set(to_delete) + + ref = TreeNode(-1) + ref.left = root + + q1 = deque() + to_process = deque([ref]) + + while to_process: + new_tree = to_process.popleft() + + if new_tree.left: + if new_tree.left.val in st: + to_process.append(new_tree.left) + else: + ans.append(new_tree.left) + q1.append(new_tree.left) + new_tree.left = None + + if new_tree.right: + if new_tree.right.val in st: + to_process.append(new_tree.right) + else: + ans.append(new_tree.right) + q1.append(new_tree.right) + new_tree.right = None + + while q1: + temp = q1.popleft() + + if temp.left: + if temp.left.val in st: + to_process.append(temp.left) + temp.left = None + else: + q1.append(temp.left) + + if temp.right: + if temp.right.val in st: + to_process.append(temp.right) + temp.right = None + else: + q1.append(temp.right) + + return ans diff --git a/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.py2 b/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.py2 new file mode 100644 index 00000000..219caea3 --- /dev/null +++ b/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.py2 @@ -0,0 +1,58 @@ +# Definition for a binary tree node. +# class TreeNode(object): +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +from collections import deque + +class Solution(object): + def delNodes(self, root, to_delete): + ans = [] + if not root: + return ans + + st = set(to_delete) + ref = TreeNode(-1) + ref.left = root + + q1 = deque() + to_process = deque([ref]) + + while to_process: + new_tree = to_process.popleft() + + if new_tree.left: + if new_tree.left.val in st: + to_process.append(new_tree.left) + else: + ans.append(new_tree.left) + q1.append(new_tree.left) + new_tree.left = None + + if new_tree.right: + if new_tree.right.val in st: + to_process.append(new_tree.right) + else: + ans.append(new_tree.right) + q1.append(new_tree.right) + new_tree.right = None + + while q1: + temp = q1.popleft() + + if temp.left: + if temp.left.val in st: + to_process.append(temp.left) + temp.left = None + else: + q1.append(temp.left) + + if temp.right: + if temp.right.val in st: + to_process.append(temp.right) + temp.right = None + else: + q1.append(temp.right) + + return ans diff --git a/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.rb b/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.rb new file mode 100644 index 00000000..eeba6bfa --- /dev/null +++ b/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.rb @@ -0,0 +1,71 @@ +# Definition for a binary tree node. +# class TreeNode +# attr_accessor :val, :left, :right +# def initialize(val = 0, left = nil, right = nil) +# @val = val +# @left = left +# @right = right +# end +# end +# @param {TreeNode} root +# @param {Integer[]} to_delete +# @return {TreeNode[]} +def del_nodes(root, to_delete) + ans = [] + return ans if root.nil? + + st = to_delete.to_set + ref = TreeNode.new(-1) + ref.left = root + + q1 = [] + to_process = [ref] + + until to_process.empty? + new_tree = to_process.shift + + if new_tree.left + if st.include?(new_tree.left.val) + to_process.push(new_tree.left) + else + ans.push(new_tree.left) + q1.push(new_tree.left) + end + new_tree.left = nil + end + + if new_tree.right + if st.include?(new_tree.right.val) + to_process.push(new_tree.right) + else + ans.push(new_tree.right) + q1.push(new_tree.right) + end + new_tree.right = nil + end + + until q1.empty? + temp = q1.shift + + if temp.left + if st.include?(temp.left.val) + to_process.push(temp.left) + temp.left = nil + else + q1.push(temp.left) + end + end + + if temp.right + if st.include?(temp.right.val) + to_process.push(temp.right) + temp.right = nil + else + q1.push(temp.right) + end + end + end + end + + ans +end diff --git a/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.rs b/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.rs new file mode 100644 index 00000000..2d935e47 --- /dev/null +++ b/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.rs @@ -0,0 +1,82 @@ +use std::collections::{HashSet, VecDeque}; + +impl Solution { + pub fn del_nodes(root: Option>>, to_delete: Vec) -> Vec>>> { + let mut ans: Vec>>> = Vec::new(); + if root.is_none() { + return ans; + } + + let st: HashSet = to_delete.into_iter().collect(); + + let ref_node = Rc::new(RefCell::new(TreeNode::new(-1))); + ref_node.borrow_mut().left = root; + + let mut q1: VecDeque>> = VecDeque::new(); + let mut to_process: VecDeque>> = VecDeque::new(); + to_process.push_back(ref_node.clone()); + + while let Some(new_tree) = to_process.pop_front() { + let mut new_tree_borrow = new_tree.borrow_mut(); + + if let Some(left) = new_tree_borrow.left.take() { + let left_val = left.borrow().val; + if st.contains(&left_val) { + drop(new_tree_borrow); + to_process.push_back(left); + new_tree_borrow = new_tree.borrow_mut(); + } else { + ans.push(Some(left.clone())); + q1.push_back(left.clone()); + } + new_tree_borrow.left = None; + } + + if let Some(right) = new_tree_borrow.right.take() { + let right_val = right.borrow().val; + if st.contains(&right_val) { + drop(new_tree_borrow); + to_process.push_back(right); + new_tree_borrow = new_tree.borrow_mut(); + } else { + ans.push(Some(right.clone())); + q1.push_back(right.clone()); + } + new_tree_borrow.right = None; + } + drop(new_tree_borrow); + + while let Some(temp) = q1.pop_front() { + let mut temp_borrow = temp.borrow_mut(); + + if let Some(left) = temp_borrow.left.take() { + let left_val = left.borrow().val; + if st.contains(&left_val) { + drop(temp_borrow); + to_process.push_back(left); + temp_borrow = temp.borrow_mut(); + temp_borrow.left = None; + } else { + q1.push_back(left.clone()); + temp_borrow.left = Some(left); + } + } + + if let Some(right) = temp_borrow.right.take() { + let right_val = right.borrow().val; + if st.contains(&right_val) { + drop(temp_borrow); + to_process.push_back(right); + temp_borrow = temp.borrow_mut(); + temp_borrow.right = None; + } else { + q1.push_back(right.clone()); + temp_borrow.right = Some(right); + } + } + } + } + + ans + } +} diff --git a/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.swift b/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.swift new file mode 100644 index 00000000..75c07549 --- /dev/null +++ b/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.swift @@ -0,0 +1,22 @@ +class Solution { + func delNodes(_ root: TreeNode?, _ to_delete: [Int]) -> [TreeNode?] { + let deleted = Set(to_delete) + var forest: [TreeNode?] = [] + + func prune(_ node: TreeNode?, _ isRoot: Bool) -> TreeNode? { + guard let node = node else { return nil } + let remove = deleted.contains(node.val) + + if isRoot && !remove { + forest.append(node) + } + + node.left = prune(node.left, remove) + node.right = prune(node.right, remove) + return remove ? nil : node + } + + _ = prune(root, true) + return forest + } +} diff --git a/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.ts b/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.ts new file mode 100644 index 00000000..a661ba8f --- /dev/null +++ b/tests/1001-1500/1110. delete-nodes-and-return-forest/sol.ts @@ -0,0 +1,63 @@ +function delNodes( + root: TreeNode | null, + to_delete: number[], +): Array { + const ans: TreeNode[] = []; + if (!root) return ans; + + const st = new Set(to_delete); + + const ref = new TreeNode(-1); + ref.left = root; + + const q1: TreeNode[] = []; + const toProcess: TreeNode[] = [ref]; + + while (toProcess.length > 0) { + const newTree = toProcess.shift()!; + + if (newTree.left) { + if (st.has(newTree.left.val)) { + toProcess.push(newTree.left); + } else { + ans.push(newTree.left); + q1.push(newTree.left); + } + newTree.left = null; + } + + if (newTree.right) { + if (st.has(newTree.right.val)) { + toProcess.push(newTree.right); + } else { + ans.push(newTree.right); + q1.push(newTree.right); + } + newTree.right = null; + } + + while (q1.length > 0) { + const temp = q1.shift()!; + + if (temp.left) { + if (st.has(temp.left.val)) { + toProcess.push(temp.left); + temp.left = null; + } else { + q1.push(temp.left); + } + } + + if (temp.right) { + if (st.has(temp.right.val)) { + toProcess.push(temp.right); + temp.right = null; + } else { + q1.push(temp.right); + } + } + } + } + + return ans; +} diff --git a/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/manifest.yaml b/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/manifest.yaml new file mode 100644 index 00000000..ae2bb360 --- /dev/null +++ b/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/manifest.yaml @@ -0,0 +1,171 @@ +entry: + id: 1111 + title: maximum-nesting-depth-of-two-valid-parentheses-strings + params: + seq: + type: string + call: + cpp: Solution().maxDepthAfterSplit({seq}) + rust: Solution::max_depth_after_split({seq}) + python3: Solution().maxDepthAfterSplit({seq}) + python2: Solution().maxDepthAfterSplit({seq}) + ruby: max_depth_after_split({seq}) + java: new Solution().maxDepthAfterSplit({seq}) + csharp: new Solution().MaxDepthAfterSplit({seq}) + kotlin: Solution().maxDepthAfterSplit({seq}) + go: maxDepthAfterSplit({seq}) + dart: Solution().maxDepthAfterSplit({seq}) + swift: Solution().maxDepthAfterSplit({seq}) + typescript: maxDepthAfterSplit({seq}) +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 256 +oracle: + python3: + call: Checker().maxDepthAfterSplit(seq, {result}) + checker: + "class Checker:\n def maxDepthAfterSplit(self, seq, result):\n \ + \ if not isinstance(result, list) or len(result) != len(seq):\n \ + \ return False\n if any(x not in (0, 1) for x in result):\n \ + \ return False\n a = []\n b = []\n da = 0\n \ + \ db = 0\n depth = 0\n max_depth = 0\n for ch, bit in\ + \ zip(seq, result):\n if ch == \"(\":\n depth += 1\n\ + \ max_depth = max(max_depth, depth)\n else:\n \ + \ depth -= 1\n if depth < 0:\n return False\n\ + \ if bit == 0:\n a.append(ch)\n da\ + \ += 1 if ch == \"(\" else -1\n if da < 0:\n \ + \ return False\n else:\n b.append(ch)\n \ + \ db += 1 if ch == \"(\" else -1\n if db < 0:\n \ + \ return False\n if depth != 0 or da != 0 or db != 0:\n\ + \ return False\n\n def vps_depth(s):\n d = 0\n\ + \ mx = 0\n for ch in s:\n if ch == \"(\"\ + :\n d += 1\n mx = max(mx, d)\n \ + \ else:\n d -= 1\n if d < 0:\n\ + \ return -1\n return mx if d == 0 else -1\n\ + \n da_depth = vps_depth(a)\n db_depth = vps_depth(b)\n \ + \ if da_depth < 0 or db_depth < 0:\n return False\n return\ + \ max(da_depth, db_depth) == (max_depth + 1) // 2\n" +seed: 1111 +tests: + - name: ex1 + in: + seq: (()()) + - name: ex2 + in: + seq: ()(())() + - name: empty_pair + in: + seq: () + - name: two_pairs + in: + seq: ()() + - name: nested_two + in: + seq: (()) + - name: deep_3 + in: + seq: ((())) + - name: alternating_1 + in: + seq: ()(()()) + - name: alternating_2 + in: + seq: (()(())) + - name: long_balanced_1 + in: + seq: ()()()()() + - name: long_balanced_2 + in: + seq: ((())()) + - name: long_balanced_3 + in: + seq: (()()()) + - name: long_balanced_4 + in: + seq: ((()())) + - name: long_balanced_5 + in: + seq: ()(())(()) + - name: long_balanced_6 + in: + seq: (((()))) + - name: long_balanced_7 + in: + seq: ()((())) + - name: long_balanced_8 + in: + seq: ((()))() + - name: long_balanced_9 + in: + seq: (()(()())) + - name: long_balanced_10 + in: + seq: ((()(()))) + - name: long_balanced_11 + in: + seq: ()(())(()()) + - name: long_balanced_12 + in: + seq: ((())(())) + - name: long_balanced_13 + in: + seq: (()()(())) + - name: long_balanced_14 + in: + seq: (((()())())) + - name: long_balanced_15 + in: + seq: ()((())())() + - name: long_balanced_16 + in: + seq: ((()()())) + - name: long_balanced_17 + in: + seq: ()()(())()() + - name: long_balanced_18 + in: + seq: (((())))() + - name: long_balanced_19 + in: + seq: ()((()()))() + - name: long_balanced_20 + in: + seq: ((()()))() + - name: long_balanced_21 + in: + seq: (()())()() + - name: long_balanced_22 + in: + seq: ((()))(()) + - name: long_balanced_23 + in: + seq: (()(()))() + - name: long_balanced_24 + in: + seq: ((())())() + - name: long_balanced_25 + in: + seq: ()((()))() + - name: long_balanced_26 + in: + seq: (((()()()))) + - name: long_balanced_27 + in: + seq: ()(())(()(())) + - name: long_balanced_28 + in: + seq: ((()())(()())) + - name: long_balanced_29 + in: + seq: ()()((()))()() + - name: long_balanced_30 + in: + seq: ((()))((())) + - name: long_balanced_31 + in: + seq: (()(()))(()()) + - name: long_balanced_32 + in: + seq: ((()()))(()) diff --git a/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.cpp b/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.cpp new file mode 100644 index 00000000..812eb3dc --- /dev/null +++ b/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.cpp @@ -0,0 +1,17 @@ +class Solution { +public: + vector maxDepthAfterSplit(string seq) { + vector res; + int depth = 0; + for (char ch : seq) { + if (ch == '(') { + depth++; + res.push_back(depth % 2); + } else { + res.push_back(depth % 2); + depth--; + } + } + return res; + } +}; diff --git a/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.cs b/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.cs new file mode 100644 index 00000000..a7e0807a --- /dev/null +++ b/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.cs @@ -0,0 +1,18 @@ +public class Solution { + public int[] MaxDepthAfterSplit(string seq) { + int n = seq.Length; + int[] res = new int[n]; + int depth = 0; + for (int i = 0; i < n; i++) { + char ch = seq[i]; + if (ch == '(') { + depth++; + res[i] = depth % 2; + } else { + res[i] = depth % 2; + depth--; + } + } + return res; + } +} diff --git a/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.dart b/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.dart new file mode 100644 index 00000000..5b909dab --- /dev/null +++ b/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.dart @@ -0,0 +1,17 @@ +class Solution { + List maxDepthAfterSplit(String seq) { + List res = []; + int depth = 0; + for (int i = 0; i < seq.length; i++) { + String ch = seq[i]; + if (ch == '(') { + depth++; + res.add(depth % 2); + } else { + res.add(depth % 2); + depth--; + } + } + return res; + } +} diff --git a/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.go b/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.go new file mode 100644 index 00000000..bf49792c --- /dev/null +++ b/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.go @@ -0,0 +1,14 @@ +func maxDepthAfterSplit(seq string) []int { + res := make([]int, len(seq)) + depth := 0 + for i, ch := range seq { + if ch == '(' { + depth++ + res[i] = depth % 2 + } else { + res[i] = depth % 2 + depth-- + } + } + return res +} diff --git a/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.java b/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.java new file mode 100644 index 00000000..68947fe5 --- /dev/null +++ b/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.java @@ -0,0 +1,18 @@ +class Solution { + public int[] maxDepthAfterSplit(String seq) { + int n = seq.length(); + int[] res = new int[n]; + int depth = 0; + for (int i = 0; i < n; i++) { + char ch = seq.charAt(i); + if (ch == '(') { + depth++; + res[i] = depth % 2; + } else { + res[i] = depth % 2; + depth--; + } + } + return res; + } +} diff --git a/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.kt b/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.kt new file mode 100644 index 00000000..9586d34c --- /dev/null +++ b/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.kt @@ -0,0 +1,17 @@ +class Solution { + fun maxDepthAfterSplit(seq: String): IntArray { + val res = IntArray(seq.length) + var depth = 0 + for (i in seq.indices) { + val ch = seq[i] + if (ch == '(') { + depth++ + res[i] = depth % 2 + } else { + res[i] = depth % 2 + depth-- + } + } + return res + } +} diff --git a/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.py b/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.py new file mode 100644 index 00000000..2ae93e92 --- /dev/null +++ b/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.py @@ -0,0 +1,16 @@ +class Solution(object): + def maxDepthAfterSplit(self, seq): + """ + :type seq: str + :rtype: List[int] + """ + res = [] + depth = 0 + for ch in seq: + if ch == "(": + depth += 1 + res.append(depth % 2) + else: + res.append(depth % 2) + depth -= 1 + return res diff --git a/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.py2 b/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.py2 new file mode 100644 index 00000000..e6e0d6b1 --- /dev/null +++ b/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.py2 @@ -0,0 +1,16 @@ +class Solution(object): + def maxDepthAfterSplit(self, seq): + """ + :type seq: str + :rtype: List[int] + """ + res = [] + depth = 0 + for ch in seq: + if ch == '(': + depth += 1 + res.append(depth % 2) + else: + res.append(depth % 2) + depth -= 1 + return res diff --git a/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.rb b/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.rb new file mode 100644 index 00000000..90c8136e --- /dev/null +++ b/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.rb @@ -0,0 +1,16 @@ +# @param {String} seq +# @return {Integer[]} +def max_depth_after_split(seq) + res = [] + depth = 0 + seq.each_char do |ch| + if ch == '(' + depth += 1 + res << (depth % 2) + else + res << (depth % 2) + depth -= 1 + end + end + res +end diff --git a/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.rs b/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.rs new file mode 100644 index 00000000..64ae9c37 --- /dev/null +++ b/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.rs @@ -0,0 +1,16 @@ +impl Solution { + pub fn max_depth_after_split(seq: String) -> Vec { + let mut res = Vec::new(); + let mut depth = 0; + for ch in seq.chars() { + if ch == '(' { + depth += 1; + res.push(depth % 2); + } else { + res.push(depth % 2); + depth -= 1; + } + } + res + } +} diff --git a/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.swift b/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.swift new file mode 100644 index 00000000..75f6e2bf --- /dev/null +++ b/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.swift @@ -0,0 +1,16 @@ +class Solution { + func maxDepthAfterSplit(_ seq: String) -> [Int] { + var res = [Int]() + var depth = 0 + for ch in seq { + if ch == "(" { + depth += 1 + res.append(depth % 2) + } else { + res.append(depth % 2) + depth -= 1 + } + } + return res + } +} diff --git a/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.ts b/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.ts new file mode 100644 index 00000000..7a93b9f7 --- /dev/null +++ b/tests/1001-1500/1111. maximum-nesting-depth-of-two-valid-parentheses-strings/sol.ts @@ -0,0 +1,14 @@ +function maxDepthAfterSplit(seq: string): number[] { + const res: number[] = []; + let depth = 0; + for (const ch of seq) { + if (ch === "(") { + depth++; + res.push(depth % 2); + } else { + res.push(depth % 2); + depth--; + } + } + return res; +} diff --git a/tests/1001-1500/1122. relative-sort-array/manifest.yaml b/tests/1001-1500/1122. relative-sort-array/manifest.yaml new file mode 100644 index 00000000..4b4e0270 --- /dev/null +++ b/tests/1001-1500/1122. relative-sort-array/manifest.yaml @@ -0,0 +1,219 @@ +entry: + id: 1122 + title: relative-sort-array + params: + arr1: + type: array + items: + type: int + arr2: + type: array + items: + type: int + call: + cpp: "Solution().relativeSortArray({arr1}, {arr2})" + rust: "Solution::relative_sort_array({arr1}, {arr2})" + python3: "Solution().relativeSortArray({arr1}, {arr2})" + python2: "Solution().relativeSortArray({arr1}, {arr2})" + ruby: "relative_sort_array({arr1}, {arr2})" + java: "new Solution().relativeSortArray({arr1}, {arr2})" + csharp: "new Solution().RelativeSortArray({arr1}, {arr2})" + kotlin: "Solution().relativeSortArray({arr1}, {arr2})" + go: "relativeSortArray({arr1}, {arr2})" + dart: "Solution().relativeSortArray({arr1}, {arr2})" + swift: "Solution().relativeSortArray({arr1}, {arr2})" + typescript: "relativeSortArray({arr1}, {arr2})" +judge: + type: "exact" +limits: + time_ms: 200 + memory_mb: 256 +oracle: + python3: + call: "Checker().ok({result})" + checker: | + class Checker: + def ok(self, result): + return True +seed: 1122 +tests: + - name: ex1 + in: + arr1: [2, 3, 1, 3, 2, 4, 6, 7, 9, 2, 19] + arr2: [2, 1, 4, 3, 9, 6] + out: [2, 2, 2, 1, 4, 3, 3, 9, 6, 7, 19] + - name: ex2 + in: + arr1: [28, 6, 22, 8, 44, 17] + arr2: [22, 28, 8, 6] + out: [22, 28, 8, 6, 17, 44] + - name: single_elem_ordered + in: + arr1: [5] + arr2: [5] + out: [5] + - name: two_elems_reverse + in: + arr1: [2, 1] + arr2: [1] + out: [1, 2] + - name: all_same_value + in: + arr1: [3, 3, 3, 3] + arr2: [3] + out: [3, 3, 3, 3] + - name: no_tail_elements + in: + arr1: [4, 4, 1, 1, 2, 2] + arr2: [2, 1, 4] + out: [2, 2, 1, 1, 4, 4] + - name: already_sorted_by_rule + in: + arr1: [7, 7, 3, 3, 1, 2, 8] + arr2: [7, 3] + out: [7, 7, 3, 3, 1, 2, 8] + - name: zeros_and_ones + in: + arr1: [0, 1, 0, 1, 2, 3] + arr2: [1, 0] + out: [1, 1, 0, 0, 2, 3] + - name: max_value_present + in: + arr1: [1000, 0, 999, 1000, 1] + arr2: [1000, 1] + out: [1000, 1000, 1, 0, 999] + - name: ascending_tail + in: + arr1: [8, 9, 1, 2, 3, 4] + arr2: [3, 1] + out: [3, 1, 2, 4, 8, 9] + - name: duplicates_in_keys + in: + arr1: [5, 6, 5, 6, 7, 8, 5] + arr2: [6, 5] + out: [6, 6, 5, 5, 5, 7, 8] + - name: tail_only + in: + arr1: [10, 20, 30, 1, 2, 3] + arr2: [30, 20] + out: [30, 20, 1, 2, 3, 10] + - name: many_of_one_key + in: + arr1: [4, 4, 4, 4, 2, 1, 3] + arr2: [4, 2] + out: [4, 4, 4, 4, 2, 1, 3] + - name: mixed_small + in: + arr1: [9, 8, 7, 6, 5, 4, 3, 2, 1] + arr2: [2, 4, 6, 8] + out: [2, 4, 6, 8, 1, 3, 5, 7, 9] + - name: one_key_many_tail + in: + arr1: [11, 11, 12, 13, 10, 14, 15] + arr2: [11] + out: [11, 11, 10, 12, 13, 14, 15] + - name: key_at_end + in: + arr1: [1, 2, 3, 4, 5] + arr2: [5, 4] + out: [5, 4, 1, 2, 3] + - name: key_at_start + in: + arr1: [9, 1, 1, 2, 3, 9] + arr2: [9] + out: [9, 9, 1, 1, 2, 3] + - name: repeats_and_gaps + in: + arr1: [6, 2, 6, 2, 6, 1, 0] + arr2: [2, 6] + out: [2, 2, 6, 6, 6, 0, 1] + - name: sparse_keys + in: + arr1: [100, 50, 25, 75, 50, 25, 0] + arr2: [25, 100] + out: [25, 25, 100, 0, 50, 50, 75] + - name: two_keys_all_consumed + in: + arr1: [3, 1, 2, 2, 1, 3] + arr2: [1, 2, 3] + out: [1, 1, 2, 2, 3, 3] + - name: tail_sorted_with_duplicates + in: + arr1: [5, 1, 4, 4, 2, 7, 7, 6] + arr2: [7, 5] + out: [7, 7, 5, 1, 2, 4, 4, 6] + - name: low_values + in: + arr1: [0, 0, 1, 2, 2, 3] + arr2: [2, 0] + out: [2, 2, 0, 0, 1, 3] + - name: mid_range + in: + arr1: [14, 13, 12, 11, 10, 9, 8] + arr2: [12, 10, 14] + out: [12, 10, 14, 8, 9, 11, 13] + - name: repeated_tail_values + in: + arr1: [7, 4, 5, 4, 6, 5, 4] + arr2: [5, 7] + out: [5, 5, 7, 4, 4, 4, 6] + - name: all_tail_sorted + in: + arr1: [8, 6, 7, 5, 3, 0, 9] + arr2: [8, 6] + out: [8, 6, 0, 3, 5, 7, 9] + - name: many_duplicates_tail + in: + arr1: [2, 2, 2, 3, 3, 1, 1, 0] + arr2: [3, 2] + out: [3, 3, 2, 2, 2, 0, 1, 1] + - name: key_with_single_tail + in: + arr1: [12, 11, 10] + arr2: [12, 10] + out: [12, 10, 11] + - name: permutation_like + in: + arr1: [4, 1, 3, 2] + arr2: [3, 4] + out: [3, 4, 1, 2] + - name: boundary_1000_key + in: + arr1: [1000, 999, 1000, 998, 997, 996] + arr2: [1000, 996] + out: [1000, 1000, 996, 997, 998, 999] + - name: boundary_0_key + in: + arr1: [0, 2, 1, 0, 3] + arr2: [0, 3] + out: [0, 0, 3, 1, 2] + - name: alternating_keys + in: + arr1: [1, 2, 1, 2, 1, 2, 3] + arr2: [2, 1] + out: [2, 2, 2, 1, 1, 1, 3] + - name: varied_tail_order + in: + arr1: [20, 3, 17, 8, 9, 1, 4] + arr2: [8, 20, 3] + out: [8, 20, 3, 1, 4, 9, 17] + - name: small_unsorted_tail + in: + arr1: [6, 1, 5, 2, 4, 3] + arr2: [5, 6] + out: [5, 6, 1, 2, 3, 4] + - name: arr2_length_one + in: + arr1: [7, 8, 7, 6, 5, 4] + arr2: [7] + out: [7, 7, 4, 5, 6, 8] + - name: mixed_high_low + in: + arr1: [100, 1, 99, 2, 98, 3, 97] + arr2: [99, 97] + out: [99, 97, 1, 2, 3, 98, 100] + - name: final_tail_sort + in: + arr1: [3, 5, 7, 5, 3, 8, 9, 1] + arr2: [5, 3] + out: [5, 5, 3, 3, 1, 7, 8, 9] diff --git a/tests/1001-1500/1122. relative-sort-array/sol.cpp b/tests/1001-1500/1122. relative-sort-array/sol.cpp new file mode 100644 index 00000000..a30f8edb --- /dev/null +++ b/tests/1001-1500/1122. relative-sort-array/sol.cpp @@ -0,0 +1,23 @@ +class Solution { +public: + vector relativeSortArray(vector& arr1, vector& arr2) { + int freq[1001] = {0}; + for (int num : arr1) { + freq[num]++; + } + int idx = 0; + for (int num : arr2) { + while (freq[num] > 0) { + arr1[idx++] = num; + freq[num]--; + } + } + for (int num = 0; num < 1001; num++) { + while (freq[num] > 0) { + arr1[idx++] = num; + freq[num]--; + } + } + return arr1; + } +}; diff --git a/tests/1001-1500/1122. relative-sort-array/sol.cs b/tests/1001-1500/1122. relative-sort-array/sol.cs new file mode 100644 index 00000000..b5bcd960 --- /dev/null +++ b/tests/1001-1500/1122. relative-sort-array/sol.cs @@ -0,0 +1,22 @@ +public class Solution { + public int[] RelativeSortArray(int[] arr1, int[] arr2) { + int[] freq = new int[1001]; + foreach (int num in arr1) { + freq[num]++; + } + int idx = 0; + foreach (int num in arr2) { + while (freq[num] > 0) { + arr1[idx++] = num; + freq[num]--; + } + } + for (int num = 0; num < 1001; num++) { + while (freq[num] > 0) { + arr1[idx++] = num; + freq[num]--; + } + } + return arr1; + } +} diff --git a/tests/1001-1500/1122. relative-sort-array/sol.dart b/tests/1001-1500/1122. relative-sort-array/sol.dart new file mode 100644 index 00000000..9bcd59fb --- /dev/null +++ b/tests/1001-1500/1122. relative-sort-array/sol.dart @@ -0,0 +1,22 @@ +class Solution { + List relativeSortArray(List arr1, List arr2) { + List freq = List.filled(1001, 0); + for (var num in arr1) { + freq[num]++; + } + int idx = 0; + for (var num in arr2) { + while (freq[num] > 0) { + arr1[idx++] = num; + freq[num]--; + } + } + for (int num = 0; num < 1001; num++) { + while (freq[num] > 0) { + arr1[idx++] = num; + freq[num]--; + } + } + return arr1; + } +} diff --git a/tests/1001-1500/1122. relative-sort-array/sol.go b/tests/1001-1500/1122. relative-sort-array/sol.go new file mode 100644 index 00000000..bcb11596 --- /dev/null +++ b/tests/1001-1500/1122. relative-sort-array/sol.go @@ -0,0 +1,22 @@ +func relativeSortArray(arr1 []int, arr2 []int) []int { + freq := make([]int, 1001) + for _, num := range arr1 { + freq[num]++ + } + idx := 0 + for _, num := range arr2 { + for freq[num] > 0 { + arr1[idx] = num + idx++ + freq[num]-- + } + } + for num := 0; num < 1001; num++ { + for freq[num] > 0 { + arr1[idx] = num + idx++ + freq[num]-- + } + } + return arr1 +} diff --git a/tests/1001-1500/1122. relative-sort-array/sol.java b/tests/1001-1500/1122. relative-sort-array/sol.java new file mode 100644 index 00000000..4e52b88a --- /dev/null +++ b/tests/1001-1500/1122. relative-sort-array/sol.java @@ -0,0 +1,22 @@ +class Solution { + public int[] relativeSortArray(int[] arr1, int[] arr2) { + int[] freq = new int[1001]; + for (int num : arr1) { + freq[num]++; + } + int idx = 0; + for (int num : arr2) { + while (freq[num] > 0) { + arr1[idx++] = num; + freq[num]--; + } + } + for (int num = 0; num < 1001; num++) { + while (freq[num] > 0) { + arr1[idx++] = num; + freq[num]--; + } + } + return arr1; + } +} diff --git a/tests/1001-1500/1122. relative-sort-array/sol.kt b/tests/1001-1500/1122. relative-sort-array/sol.kt new file mode 100644 index 00000000..9864d886 --- /dev/null +++ b/tests/1001-1500/1122. relative-sort-array/sol.kt @@ -0,0 +1,22 @@ +class Solution { + fun relativeSortArray(arr1: IntArray, arr2: IntArray): IntArray { + val freq = IntArray(1001) + for (num in arr1) { + freq[num]++ + } + var idx = 0 + for (num in arr2) { + while (freq[num] > 0) { + arr1[idx++] = num + freq[num]-- + } + } + for (num in 0..1000) { + while (freq[num] > 0) { + arr1[idx++] = num + freq[num]-- + } + } + return arr1 + } +} diff --git a/tests/1001-1500/1122. relative-sort-array/sol.py b/tests/1001-1500/1122. relative-sort-array/sol.py new file mode 100644 index 00000000..ba7ba2c7 --- /dev/null +++ b/tests/1001-1500/1122. relative-sort-array/sol.py @@ -0,0 +1,22 @@ +class Solution: + def relativeSortArray(self, arr1, arr2): + freq = [0] * 1001 + + for num in arr1: + freq[num] += 1 + + idx = 0 + + for num in arr2: + while freq[num] > 0: + arr1[idx] = num + idx += 1 + freq[num] -= 1 + + for num in range(1001): + while freq[num] > 0: + arr1[idx] = num + idx += 1 + freq[num] -= 1 + + return arr1 diff --git a/tests/1001-1500/1122. relative-sort-array/sol.py2 b/tests/1001-1500/1122. relative-sort-array/sol.py2 new file mode 100644 index 00000000..5e70945e --- /dev/null +++ b/tests/1001-1500/1122. relative-sort-array/sol.py2 @@ -0,0 +1,22 @@ +class Solution(object): + def relativeSortArray(self, arr1, arr2): + """ + :type arr1: List[int] + :type arr2: List[int] + :rtype: List[int] + """ + freq = [0] * 1001 + for num in arr1: + freq[num] += 1 + idx = 0 + for num in arr2: + while freq[num] > 0: + arr1[idx] = num + idx += 1 + freq[num] -= 1 + for num in range(1001): + while freq[num] > 0: + arr1[idx] = num + idx += 1 + freq[num] -= 1 + return arr1 diff --git a/tests/1001-1500/1122. relative-sort-array/sol.rb b/tests/1001-1500/1122. relative-sort-array/sol.rb new file mode 100644 index 00000000..610fa803 --- /dev/null +++ b/tests/1001-1500/1122. relative-sort-array/sol.rb @@ -0,0 +1,23 @@ +# @param {Integer[]} arr1 +# @param {Integer[]} arr2 +# @return {Integer[]} +def relative_sort_array(arr1, arr2) + freq = Array.new(1001, 0) + arr1.each { |num| freq[num] += 1 } + idx = 0 + arr2.each do |num| + while freq[num] > 0 + arr1[idx] = num + idx += 1 + freq[num] -= 1 + end + end + (0...1001).each do |num| + while freq[num] > 0 + arr1[idx] = num + idx += 1 + freq[num] -= 1 + end + end + arr1 +end diff --git a/tests/1001-1500/1122. relative-sort-array/sol.rs b/tests/1001-1500/1122. relative-sort-array/sol.rs new file mode 100644 index 00000000..799f85e2 --- /dev/null +++ b/tests/1001-1500/1122. relative-sort-array/sol.rs @@ -0,0 +1,25 @@ +impl Solution { + pub fn relative_sort_array(arr1: Vec, arr2: Vec) -> Vec { + let mut freq = vec![0; 1001]; + let mut arr1 = arr1; + for &num in &arr1 { + freq[num as usize] += 1; + } + let mut idx = 0; + for &num in &arr2 { + while freq[num as usize] > 0 { + arr1[idx] = num; + idx += 1; + freq[num as usize] -= 1; + } + } + for num in 0..1001 { + while freq[num] > 0 { + arr1[idx] = num as i32; + idx += 1; + freq[num] -= 1; + } + } + arr1 + } +} diff --git a/tests/1001-1500/1122. relative-sort-array/sol.swift b/tests/1001-1500/1122. relative-sort-array/sol.swift new file mode 100644 index 00000000..d8582e8e --- /dev/null +++ b/tests/1001-1500/1122. relative-sort-array/sol.swift @@ -0,0 +1,25 @@ +class Solution { + func relativeSortArray(_ arr1: [Int], _ arr2: [Int]) -> [Int] { + var freq = [Int](repeating: 0, count: 1001) + var arr1 = arr1 + for num in arr1 { + freq[num] += 1 + } + var idx = 0 + for num in arr2 { + while freq[num] > 0 { + arr1[idx] = num + idx += 1 + freq[num] -= 1 + } + } + for num in 0..<1001 { + while freq[num] > 0 { + arr1[idx] = num + idx += 1 + freq[num] -= 1 + } + } + return arr1 + } +} diff --git a/tests/1001-1500/1122. relative-sort-array/sol.ts b/tests/1001-1500/1122. relative-sort-array/sol.ts new file mode 100644 index 00000000..dced51c9 --- /dev/null +++ b/tests/1001-1500/1122. relative-sort-array/sol.ts @@ -0,0 +1,20 @@ +function relativeSortArray(arr1: number[], arr2: number[]): number[] { + const freq: number[] = new Array(1001).fill(0); + for (const num of arr1) { + freq[num]++; + } + let idx = 0; + for (const num of arr2) { + while (freq[num] > 0) { + arr1[idx++] = num; + freq[num]--; + } + } + for (let num = 0; num < 1001; num++) { + while (freq[num] > 0) { + arr1[idx++] = num; + freq[num]--; + } + } + return arr1; +} diff --git a/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/manifest.yaml b/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/manifest.yaml new file mode 100644 index 00000000..a827fffb --- /dev/null +++ b/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/manifest.yaml @@ -0,0 +1,714 @@ +entry: + id: 1123 + title: lowest-common-ancestor-of-deepest-leaves + params: + root: + type: tree_node + call: + cpp: treeNodeToArray(Solution().lcaDeepestLeaves({root})) + rust: TreeNode::tree_node_to_array(Solution::lca_deepest_leaves({root})) + python3: tree_node_to_array(Solution().lcaDeepestLeaves({root})) + python2: tree_node_to_array(Solution().lcaDeepestLeaves({root})) + ruby: tree_node_to_array(lca_deepest_leaves({root})) + java: TreeNode.treeNodeToArray(new Solution().lcaDeepestLeaves({root})) + csharp: TreeNode.TreeNodeToArray(new Solution().LcaDeepestLeaves({root})) + kotlin: treeNodeToArray(Solution().lcaDeepestLeaves({root})) + go: treeNodeToArray(lcaDeepestLeaves({root})) + dart: tree_node_to_array(Solution().lcaDeepestLeaves({root})) + swift: tree_node_to_array(Solution().lcaDeepestLeaves({root})) + typescript: treeNodeToArray(lcaDeepestLeaves({root})) +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 256 +oracle: + python3: + call: Checker().ok({result}) + checker: "class Checker:\n def ok(self, result):\n return True\n" +seed: 1123 +tests: + - name: ex1 + in: + root: + - 3 + - 5 + - 1 + - 6 + - 2 + - 0 + - 8 + - null + - null + - 7 + - 4 + out: + - 2 + - 7 + - 4 + - name: ex2 + in: + root: + - 1 + out: + - 1 + - name: ex3 + in: + root: + - 0 + - 1 + - 3 + - null + - 2 + out: + - 2 + - name: balanced_root + in: + root: + - 1 + - 2 + - 3 + out: + - 1 + - 2 + - 3 + - name: left_chain + in: + root: + - 1 + - 2 + - null + - 3 + - null + - 4 + out: + - 4 + - name: right_chain + in: + root: + - 1 + - null + - 2 + - null + - 3 + - null + - 4 + out: + - 4 + - name: deepest_left_leaf + in: + root: + - 10 + - 5 + - 15 + - 3 + - null + - null + - null + - 1 + out: + - 1 + - name: deepest_right_leaf + in: + root: + - 10 + - 5 + - 15 + - null + - 7 + - null + - 20 + - null + - null + - null + - null + - 18 + out: + - 10 + - 5 + - 15 + - null + - 7 + - null + - 20 + - name: deepest_two_sides + in: + root: + - 1 + - 2 + - 3 + - 4 + - null + - null + - 5 + out: + - 1 + - 2 + - 3 + - 4 + - null + - null + - 5 + - name: same_depth_subtree + in: + root: + - 7 + - 3 + - 9 + - 1 + - 5 + - 8 + - 10 + out: + - 7 + - 3 + - 9 + - 1 + - 5 + - 8 + - 10 + - name: unbalanced_left_heavy + in: + root: + - 1 + - 2 + - 3 + - 4 + - 5 + - null + - null + - 6 + out: + - 6 + - name: unbalanced_right_heavy + in: + root: + - 1 + - 2 + - 3 + - null + - null + - 4 + - 5 + - null + - null + - null + - 6 + out: + - 6 + - name: deepest_internal_lca + in: + root: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - null + - 8 + - null + - null + - null + - null + - 9 + - 10 + out: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - null + - 8 + - null + - null + - null + - null + - 9 + - 10 + - name: single_deep_path_with_side_leaf + in: + root: + - 1 + - 2 + - null + - 3 + - 4 + out: + - 2 + - 3 + - 4 + - name: two_deepest_leaves_same_parent + in: + root: + - 1 + - 2 + - 3 + - null + - 4 + - 5 + - null + out: + - 1 + - 2 + - 3 + - null + - 4 + - 5 + - name: complete_tree_height_two + in: + root: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + out: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - name: deepest_in_left_subtree + in: + root: + - 1 + - 2 + - 3 + - 4 + - 5 + - null + - null + - 6 + - 7 + out: + - 4 + - 6 + - 7 + - name: deepest_in_right_subtree + in: + root: + - 1 + - 2 + - 3 + - null + - null + - 4 + - 5 + - null + - null + - 6 + - 7 + out: + - 5 + - 6 + - 7 + - name: sparse_tree_center + in: + root: + - 8 + - 4 + - 12 + - null + - 6 + - 10 + - 14 + - 5 + - 7 + - null + - null + - 9 + - 11 + - 13 + - 15 + out: + - 5 + - 13 + - 15 + - name: asymmetric_same_depth + in: + root: + - 5 + - 1 + - 9 + - null + - 2 + - 8 + - 10 + - null + - null + - 3 + out: + - 3 + - name: deepest_leaf_far_left + in: + root: + - 11 + - 6 + - 17 + - 4 + - 8 + - 15 + - 20 + - 2 + - null + - null + - null + - 14 + out: + - 11 + - 6 + - 17 + - 4 + - 8 + - 15 + - 20 + - 2 + - null + - null + - null + - 14 + - name: deepest_leaf_far_right + in: + root: + - 11 + - 6 + - 17 + - 4 + - 8 + - 15 + - 20 + - null + - null + - null + - 9 + - null + - null + - null + - 21 + out: + - 11 + - 6 + - 17 + - 4 + - 8 + - 15 + - 20 + - null + - null + - null + - 9 + - null + - null + - null + - 21 + - name: three_levels_balanced + in: + root: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + - 11 + - 12 + - 13 + - 14 + - 15 + out: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + - 11 + - 12 + - 13 + - 14 + - 15 + - name: lca_in_left_deep_branch + in: + root: + - 1 + - 2 + - 3 + - 4 + - null + - null + - null + - 5 + - 6 + out: + - 4 + - 5 + - 6 + - name: lca_in_right_deep_branch + in: + root: + - 1 + - 2 + - 3 + - null + - null + - 4 + - 5 + - null + - null + - 6 + - 7 + out: + - 5 + - 6 + - 7 + - name: deepest_leaves_under_same_grandparent + in: + root: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - null + - null + - null + - 7 + - 8 + out: + - 5 + - 7 + - 8 + - name: deepest_leaves_far_apart + in: + root: + - 1 + - 2 + - 3 + - 4 + - null + - null + - 5 + - 6 + - null + - null + - 7 + out: + - 1 + - 2 + - 3 + - 4 + - null + - null + - 5 + - 6 + - null + - null + - 7 + - name: leaf_is_root_then_children_missing + in: + root: + - 42 + out: + - 42 + - name: one_side_deeper_with_leaf + in: + root: + - 9 + - 4 + - 13 + - 2 + - 6 + - 11 + - 15 + - 1 + - 3 + out: + - 2 + - 1 + - 3 + - name: deep_leaf_pair + in: + root: + - 9 + - 4 + - 13 + - 2 + - 6 + - 11 + - 15 + - null + - null + - 5 + - 7 + out: + - 6 + - 5 + - 7 + - name: long_left_spine + in: + root: + - 1 + - 2 + - null + - 3 + - null + - 4 + - null + - 5 + - null + - 6 + out: + - 6 + - name: long_right_spine + in: + root: + - 1 + - null + - 2 + - null + - 3 + - null + - 4 + - null + - 5 + - null + - 6 + out: + - 6 + - name: mixed_sparse_balanced + in: + root: + - 50 + - 25 + - 75 + - 10 + - 30 + - 60 + - 90 + - null + - 15 + - 28 + - 35 + - 55 + - 65 + - 85 + - 95 + out: + - 50 + - 25 + - 75 + - 10 + - 30 + - 60 + - 90 + - null + - 15 + - 28 + - 35 + - 55 + - 65 + - 85 + - 95 + - name: deepest_leaf_left_internal + in: + root: + - 5 + - 3 + - 8 + - 2 + - 4 + - 7 + - 9 + - 1 + - null + - null + - null + - 6 + out: + - 5 + - 3 + - 8 + - 2 + - 4 + - 7 + - 9 + - 1 + - null + - null + - null + - 6 + - name: deepest_leaf_right_internal + in: + root: + - 5 + - 3 + - 8 + - 2 + - 4 + - 7 + - 9 + - null + - null + - null + - null + - 6 + - null + - null + - 10 + out: + - 8 + - 7 + - 9 + - 6 + - null + - null + - 10 + - name: all_deepest_same_level + in: + root: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + out: + - 8 + - name: deepest_small_subtree + in: + root: + - 1 + - 2 + - 3 + - null + - 4 + - null + - 5 + - null + - null + - 6 + - 7 + out: + - 5 + - 6 + - 7 diff --git a/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.cpp b/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.cpp new file mode 100644 index 00000000..0ade8ce4 --- /dev/null +++ b/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.cpp @@ -0,0 +1,35 @@ +/** + * Definition for a binary tree node. + * struct TreeNode { + * int val; + * TreeNode *left; + * TreeNode *right; + * TreeNode() : val(0), left(nullptr), right(nullptr) {} + * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} + * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} + * }; + */ +class Solution { +public: + TreeNode* lcaDeepestLeaves(TreeNode* root) { + return dfs(root, 0).first; + } + +private: + pair dfs(TreeNode* node, int depth) { + if (!node) { + return {nullptr, depth}; + } + + auto left = dfs(node->left, depth + 1); + auto right = dfs(node->right, depth + 1); + + if (left.second > right.second) { + return {left.first, left.second}; + } else if (right.second > left.second) { + return {right.first, right.second}; + } else { + return {node, left.second}; + } + } +}; diff --git a/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.cs b/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.cs new file mode 100644 index 00000000..7dc505ca --- /dev/null +++ b/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.cs @@ -0,0 +1,35 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public int val; + * public TreeNode left; + * public TreeNode right; + * public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +public class Solution { + public TreeNode LcaDeepestLeaves(TreeNode root) { + return Dfs(root, 0).node; + } + + private (TreeNode node, int depth) Dfs(TreeNode node, int depth) { + if (node == null) { + return (null, depth); + } + + var left = Dfs(node.left, depth + 1); + var right = Dfs(node.right, depth + 1); + + if (left.depth > right.depth) { + return (left.node, left.depth); + } else if (right.depth > left.depth) { + return (right.node, right.depth); + } else { + return (node, left.depth); + } + } +} diff --git a/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.dart b/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.dart new file mode 100644 index 00000000..ae7bd3aa --- /dev/null +++ b/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.dart @@ -0,0 +1,38 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * int val; + * TreeNode? left; + * TreeNode? right; + * TreeNode([this.val = 0, this.left, this.right]); + * } + */ +class Solution { + TreeNode? lcaDeepestLeaves(TreeNode? root) { + var result = _dfs(root, 0); + return result.node; + } + + _Pair _dfs(TreeNode? node, int depth) { + if (node == null) { + return _Pair(null, depth); + } + + var left = _dfs(node.left, depth + 1); + var right = _dfs(node.right, depth + 1); + + if (left.depth > right.depth) { + return _Pair(left.node, left.depth); + } else if (right.depth > left.depth) { + return _Pair(right.node, right.depth); + } else { + return _Pair(node, left.depth); + } + } +} + +class _Pair { + TreeNode? node; + int depth; + _Pair(this.node, this.depth); +} diff --git a/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.go b/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.go new file mode 100644 index 00000000..c5d524ad --- /dev/null +++ b/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.go @@ -0,0 +1,30 @@ +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +func lcaDeepestLeaves(root *TreeNode) *TreeNode { + var dfs func(node *TreeNode, depth int) (*TreeNode, int) + dfs = func(node *TreeNode, depth int) (*TreeNode, int) { + if node == nil { + return nil, depth + } + + leftLca, leftDepth := dfs(node.Left, depth+1) + rightLca, rightDepth := dfs(node.Right, depth+1) + + if leftDepth > rightDepth { + return leftLca, leftDepth + } else if rightDepth > leftDepth { + return rightLca, rightDepth + } else { + return node, leftDepth + } + } + + lca, _ := dfs(root, 0) + return lca +} diff --git a/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.java b/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.java new file mode 100644 index 00000000..b321aa19 --- /dev/null +++ b/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.java @@ -0,0 +1,47 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode() {} + * TreeNode(int val) { this.val = val; } + * TreeNode(int val, TreeNode left, TreeNode right) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +class Solution { + public TreeNode lcaDeepestLeaves(TreeNode root) { + return dfs(root, 0).node; + } + + private Pair dfs(TreeNode node, int depth) { + if (node == null) { + return new Pair(null, depth); + } + + Pair left = dfs(node.left, depth + 1); + Pair right = dfs(node.right, depth + 1); + + if (left.depth > right.depth) { + return new Pair(left.node, left.depth); + } else if (right.depth > left.depth) { + return new Pair(right.node, right.depth); + } else { + return new Pair(node, left.depth); + } + } + + private static class Pair { + TreeNode node; + int depth; + + Pair(TreeNode node, int depth) { + this.node = node; + this.depth = depth; + } + } +} diff --git a/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.kt b/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.kt new file mode 100644 index 00000000..79a0c449 --- /dev/null +++ b/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.kt @@ -0,0 +1,32 @@ +/** + * Example: + * var ti = TreeNode(5) + * var v = ti.`val` + * Definition for a binary tree node. + * class TreeNode(var `val`: Int) { + * var left: TreeNode? = null + * var right: TreeNode? = null + * } + */ +class Solution { + fun lcaDeepestLeaves(root: TreeNode?): TreeNode? { + return dfs(root, 0).first + } + + private fun dfs(node: TreeNode?, depth: Int): Pair { + if (node == null) { + return Pair(null, depth) + } + + val left = dfs(node.left, depth + 1) + val right = dfs(node.right, depth + 1) + + return if (left.second > right.second) { + Pair(left.first, left.second) + } else if (right.second > left.second) { + Pair(right.first, right.second) + } else { + Pair(node, left.second) + } + } +} diff --git a/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.py b/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.py new file mode 100644 index 00000000..e7f81cf0 --- /dev/null +++ b/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.py @@ -0,0 +1,29 @@ +class Solution(object): + def lcaDeepestLeaves(self, root): + """ + :type root: Optional[TreeNode] + :rtype: Optional[TreeNode] + """ + + def dfs(node, depth): + if not node: + # If node is None, return (None, current depth) + return (None, depth) + + # Recursively traverse left and right children + left_lca, left_depth = dfs(node.left, depth + 1) + right_lca, right_depth = dfs(node.right, depth + 1) + + if left_depth > right_depth: + # Left subtree is deeper → propagate its LCA and depth upward + return (left_lca, left_depth) + elif right_depth > left_depth: + # Right subtree is deeper → propagate its LCA and depth upward + return (right_lca, right_depth) + else: + # Both subtrees are at the same depth → current node is LCA + return (node, left_depth) + + # Start recursive DFS from the root at depth 0 + lca_node, _ = dfs(root, 0) + return lca_node diff --git a/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.py2 b/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.py2 new file mode 100644 index 00000000..c00d83d4 --- /dev/null +++ b/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.py2 @@ -0,0 +1,28 @@ +# Definition for a binary tree node. +# class TreeNode(object): +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution(object): + def lcaDeepestLeaves(self, root): + """ + :type root: Optional[TreeNode] + :rtype: Optional[TreeNode] + """ + def dfs(node, depth): + if not node: + return (None, depth) + + left_lca, left_depth = dfs(node.left, depth + 1) + right_lca, right_depth = dfs(node.right, depth + 1) + + if left_depth > right_depth: + return (left_lca, left_depth) + elif right_depth > left_depth: + return (right_lca, right_depth) + else: + return (node, left_depth) + + lca_node, _ = dfs(root, 0) + return lca_node diff --git a/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.rb b/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.rb new file mode 100644 index 00000000..a798afe1 --- /dev/null +++ b/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.rb @@ -0,0 +1,29 @@ +# Definition for a binary tree node. +# class TreeNode +# attr_accessor :val, :left, :right +# def initialize(val = 0, left = nil, right = nil) +# @val = val +# @left = left +# @right = right +# end +# end +# @param {TreeNode} root +# @return {TreeNode} +def lca_deepest_leaves(root) + def dfs(node, depth) + return [nil, depth] if node.nil? + + left_lca, left_depth = dfs(node.left, depth + 1) + right_lca, right_depth = dfs(node.right, depth + 1) + + if left_depth > right_depth + [left_lca, left_depth] + elsif right_depth > left_depth + [right_lca, right_depth] + else + [node, left_depth] + end + end + + dfs(root, 0)[0] +end diff --git a/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.rs b/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.rs new file mode 100644 index 00000000..acc39aea --- /dev/null +++ b/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.rs @@ -0,0 +1,42 @@ +// Definition for a binary tree node. +// #[derive(Debug, PartialEq, Eq)] +// pub struct TreeNode { +// pub val: i32, +// pub left: Option>>, +// pub right: Option>>, +// } +// +// impl TreeNode { +// #[inline] +// pub fn new(val: i32) -> Self { +// TreeNode { +// val, +// left: None, +// right: None +// } +// } +// } +impl Solution { + pub fn lca_deepest_leaves(root: Option>>) -> Option>> { + fn dfs(node: &Option>>, depth: i32) -> (Option>>, i32) { + match node { + None => (None, depth), + Some(n) => { + let n = n.borrow(); + let left = dfs(&n.left, depth + 1); + let right = dfs(&n.right, depth + 1); + + if left.1 > right.1 { + (left.0, left.1) + } else if right.1 > left.1 { + (right.0, right.1) + } else { + (node.clone(), left.1) + } + } + } + } + + dfs(&root, 0).0 + } +} diff --git a/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.swift b/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.swift new file mode 100644 index 00000000..bc2e720a --- /dev/null +++ b/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.swift @@ -0,0 +1,37 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public var val: Int + * public var left: TreeNode? + * public var right: TreeNode? + * public init() { self.val = 0; self.left = nil; self.right = nil; } + * public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; } + * public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) { + * self.val = val + * self.left = left + * self.right = right + * } + * } + */ +class Solution { + func lcaDeepestLeaves(_ root: TreeNode?) -> TreeNode? { + func dfs(_ node: TreeNode?, _ depth: Int) -> (TreeNode?, Int) { + guard let node = node else { + return (nil, depth) + } + + let left = dfs(node.left, depth + 1) + let right = dfs(node.right, depth + 1) + + if left.1 > right.1 { + return (left.0, left.1) + } else if right.1 > left.1 { + return (right.0, right.1) + } else { + return (node, left.1) + } + } + + return dfs(root, 0).0 + } +} diff --git a/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.ts b/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.ts new file mode 100644 index 00000000..31779e2e --- /dev/null +++ b/tests/1001-1500/1123. lowest-common-ancestor-of-deepest-leaves/sol.ts @@ -0,0 +1,37 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ + +function lcaDeepestLeaves(root: TreeNode | null): TreeNode | null { + function dfs( + node: TreeNode | null, + depth: number, + ): [TreeNode | null, number] { + if (node === null) { + return [null, depth]; + } + + const left = dfs(node.left, depth + 1); + const right = dfs(node.right, depth + 1); + + if (left[1] > right[1]) { + return [left[0], left[1]]; + } else if (right[1] > left[1]) { + return [right[0], right[1]]; + } else { + return [node, left[1]]; + } + } + + return dfs(root, 0)[0]; +} diff --git a/tests/1001-1500/1124. longest-well-performing-interval/manifest.yaml b/tests/1001-1500/1124. longest-well-performing-interval/manifest.yaml new file mode 100644 index 00000000..29bfad87 --- /dev/null +++ b/tests/1001-1500/1124. longest-well-performing-interval/manifest.yaml @@ -0,0 +1,400 @@ +entry: + id: 1124 + title: longest-well-performing-interval + params: + hours: + type: array + items: + type: int + call: + python3: Solution().longestWPI({hours}) + python2: Solution().longestWPI({hours}) + cpp: Solution().longestWPI({hours}) + rust: Solution::longest_wpi({hours}) + ruby: longest_wpi({hours}) + java: new Solution().longestWPI({hours}) + csharp: new Solution().LongestWPI({hours}) + kotlin: Solution().longestWPI({hours}) + go: longestWPI({hours}) + dart: Solution().longestWPI({hours}) + swift: Solution().longestWPI({hours}) + typescript: longestWPI({hours}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().longestWPI(hours, {result}) + checker: + "class Checker:\n def longestWPI(self, hours, result):\n if\ + \ not isinstance(hours, list):\n return False\n if not isinstance(result,\ + \ int):\n return False\n score = 0\n best = 0\n \ + \ seen_at = {0: -1}\n for i, h in enumerate(hours):\n \ + \ if not isinstance(h, int) or h < 0 or h > 16:\n return False\n\ + \ score += 1 if h > 8 else -1\n if score > 0:\n \ + \ best = i + 1\n elif score - 1 in seen_at:\n \ + \ best = max(best, i - seen_at[score - 1])\n if score not in\ + \ seen_at:\n seen_at[score] = i\n return result == best\n" +seed: 1124 +tests: + - name: single_tiring + in: + hours: + - 9 + - name: single_non_tiring + in: + hours: + - 6 + - name: single_boundary + in: + hours: + - 8 + - name: single_high + in: + hours: + - 10 + - name: single_zero + in: + hours: + - 0 + - name: single_max_value + in: + hours: + - 16 + - name: two_all_tiring + in: + hours: + - 9 + - 9 + - name: two_all_non_tiring + in: + hours: + - 6 + - 6 + - name: tiring_then_non_tiring + in: + hours: + - 9 + - 6 + - name: non_tiring_then_tiring + in: + hours: + - 6 + - 9 + - name: example_one + in: + hours: + - 9 + - 9 + - 6 + - 0 + - 6 + - 6 + - 9 + - name: example_two + in: + hours: + - 6 + - 6 + - 6 + - name: all_prefix_positive + in: + hours: + - 9 + - 6 + - 9 + - name: alternating_small + in: + hours: + - 6 + - 9 + - 6 + - name: long_first_block + in: + hours: + - 9 + - 9 + - 9 + - 6 + - 6 + - name: long_last_block + in: + hours: + - 6 + - 6 + - 9 + - 9 + - 9 + - name: boundary_alternation + in: + hours: + - 8 + - 9 + - 8 + - 9 + - 8 + - name: mixed_with_prefix_gain + in: + hours: + - 9 + - 8 + - 8 + - 9 + - 9 + - 8 + - name: all_nontiring_small + in: + hours: + - 1 + - 2 + - 3 + - 4 + - 5 + - name: all_tiring_small + in: + hours: + - 9 + - 10 + - 11 + - 12 + - 13 + - name: late_long_interval + in: + hours: + - 9 + - 6 + - 6 + - 9 + - 6 + - 9 + - 9 + - name: early_long_interval + in: + hours: + - 6 + - 9 + - 9 + - 6 + - 9 + - 6 + - 6 + - 9 + - name: one_tiring_in_four + in: + hours: + - 8 + - 8 + - 8 + - 9 + - name: tiring_then_three_boundaries + in: + hours: + - 9 + - 8 + - 8 + - 8 + - name: repeated_short_waves + in: + hours: + - 8 + - 9 + - 8 + - 8 + - 9 + - 8 + - 8 + - 9 + - name: strong_middle_run + in: + hours: + - 9 + - 9 + - 8 + - 8 + - 8 + - 9 + - 9 + - 9 + - name: mixed_tail + in: + hours: + - 6 + - 6 + - 6 + - 9 + - 9 + - 9 + - 6 + - 6 + - 9 + - name: alternating_start_tiring + in: + hours: + - 9 + - 6 + - 9 + - 6 + - 9 + - 6 + - 9 + - 6 + - name: alternating_start_non_tiring + in: + hours: + - 6 + - 9 + - 6 + - 9 + - 6 + - 9 + - 6 + - 9 + - name: mixed_block_one + in: + hours: + - 9 + - 9 + - 6 + - 9 + - 6 + - 6 + - 9 + - 9 + - 6 + - 6 + - 9 + - name: mixed_block_two + in: + hours: + - 6 + - 6 + - 9 + - 6 + - 9 + - 9 + - 6 + - 6 + - 9 + - 9 + - 9 + - name: all_tiring_large + in: + hours: + gen: array + len: 10000 + of: + gen: int + min: 9 + max: 16 + distinct: false + sorted: false + elemType: int + - name: all_non_tiring_large + in: + hours: + gen: array + len: 10000 + of: + gen: int + min: 0 + max: 8 + distinct: false + sorted: false + elemType: int + - name: all_boundary_large + in: + hours: + - 8 + - 8 + - 8 + - 8 + - 8 + - 8 + - 8 + - 8 + - 8 + - 8 + - 8 + - 8 + - 8 + - 8 + - 8 + - 8 + - 8 + - 8 + - 8 + - 8 + - 8 + - 8 + - 8 + - 8 + - 8 + - 8 + - 8 + - 8 + - 8 + - 8 + - name: tiring_then_non_tiring_blocks + in: + hours: + - 9 + - 9 + - 9 + - 9 + - 9 + - 6 + - 6 + - 6 + - 6 + - 6 + - 6 + - 6 + - 6 + - 6 + - 6 + - name: non_tiring_then_tiring_blocks + in: + hours: + - 6 + - 6 + - 6 + - 6 + - 6 + - 9 + - 9 + - 9 + - 9 + - 9 + - 9 + - 9 + - 9 + - 9 + - 9 + - name: mixed_low_high + in: + hours: + - 6 + - 7 + - 8 + - 9 + - 10 + - 8 + - 7 + - 9 + - 9 + - 6 + - name: positive_prefix_then_noise + in: + hours: + - 9 + - 9 + - 6 + - 6 + - 6 + - 6 + - 9 + - 6 + - 6 + - 6 diff --git a/tests/1001-1500/1124. longest-well-performing-interval/sol.cpp b/tests/1001-1500/1124. longest-well-performing-interval/sol.cpp new file mode 100644 index 00000000..714adad3 --- /dev/null +++ b/tests/1001-1500/1124. longest-well-performing-interval/sol.cpp @@ -0,0 +1,25 @@ +class Solution { +public: + int longestWPI(vector& hours) { + int score = 0; + int longest_interval = 0; + unordered_map seen_at; + seen_at[0] = -1; + + for (int i = 0; i < hours.size(); i++) { + score += hours[i] > 8 ? 1 : -1; + + if (score > 0) { + longest_interval = i + 1; + } else if (seen_at.count(score - 1)) { + longest_interval = max(longest_interval, i - seen_at[score - 1]); + } + + if (!seen_at.count(score)) { + seen_at[score] = i; + } + } + + return longest_interval; + } +}; diff --git a/tests/1001-1500/1124. longest-well-performing-interval/sol.cs b/tests/1001-1500/1124. longest-well-performing-interval/sol.cs new file mode 100644 index 00000000..24800813 --- /dev/null +++ b/tests/1001-1500/1124. longest-well-performing-interval/sol.cs @@ -0,0 +1,24 @@ +public class Solution { + public int LongestWPI(int[] hours) { + int score = 0; + int longestInterval = 0; + var seenAt = new Dictionary(); + seenAt[0] = -1; + + for (int i = 0; i < hours.Length; i++) { + score += hours[i] > 8 ? 1 : -1; + + if (score > 0) { + longestInterval = i + 1; + } else if (seenAt.ContainsKey(score - 1)) { + longestInterval = Math.Max(longestInterval, i - seenAt[score - 1]); + } + + if (!seenAt.ContainsKey(score)) { + seenAt[score] = i; + } + } + + return longestInterval; + } +} diff --git a/tests/1001-1500/1124. longest-well-performing-interval/sol.dart b/tests/1001-1500/1124. longest-well-performing-interval/sol.dart new file mode 100644 index 00000000..03c3c691 --- /dev/null +++ b/tests/1001-1500/1124. longest-well-performing-interval/sol.dart @@ -0,0 +1,25 @@ +class Solution { + int longestWPI(List hours) { + int score = 0; + int longestInterval = 0; + Map seenAt = {0: -1}; + + for (int i = 0; i < hours.length; i++) { + score += hours[i] > 8 ? 1 : -1; + + if (score > 0) { + longestInterval = i + 1; + } else if (seenAt.containsKey(score - 1)) { + longestInterval = max(longestInterval, i - seenAt[score - 1]!); + } + + if (!seenAt.containsKey(score)) { + seenAt[score] = i; + } + } + + return longestInterval; + } + + int max(int a, int b) => a > b ? a : b; +} diff --git a/tests/1001-1500/1124. longest-well-performing-interval/sol.go b/tests/1001-1500/1124. longest-well-performing-interval/sol.go new file mode 100644 index 00000000..5cdd578f --- /dev/null +++ b/tests/1001-1500/1124. longest-well-performing-interval/sol.go @@ -0,0 +1,27 @@ +func longestWPI(hours []int) int { + score := 0 + longestInterval := 0 + seenAt := map[int]int{0: -1} + + for i, h := range hours { + if h > 8 { + score++ + } else { + score-- + } + + if score > 0 { + longestInterval = i + 1 + } else if val, ok := seenAt[score-1]; ok { + if i - val > longestInterval { + longestInterval = i - val + } + } + + if _, ok := seenAt[score]; !ok { + seenAt[score] = i + } + } + + return longestInterval +} diff --git a/tests/1001-1500/1124. longest-well-performing-interval/sol.java b/tests/1001-1500/1124. longest-well-performing-interval/sol.java new file mode 100644 index 00000000..710b5cdc --- /dev/null +++ b/tests/1001-1500/1124. longest-well-performing-interval/sol.java @@ -0,0 +1,24 @@ +class Solution { + public int longestWPI(int[] hours) { + int score = 0; + int longestInterval = 0; + java.util.Map seenAt = new java.util.HashMap<>(); + seenAt.put(0, -1); + + for (int i = 0; i < hours.length; i++) { + score += hours[i] > 8 ? 1 : -1; + + if (score > 0) { + longestInterval = i + 1; + } else if (seenAt.containsKey(score - 1)) { + longestInterval = Math.max(longestInterval, i - seenAt.get(score - 1)); + } + + if (!seenAt.containsKey(score)) { + seenAt.put(score, i); + } + } + + return longestInterval; + } +} diff --git a/tests/1001-1500/1124. longest-well-performing-interval/sol.kt b/tests/1001-1500/1124. longest-well-performing-interval/sol.kt new file mode 100644 index 00000000..8985590a --- /dev/null +++ b/tests/1001-1500/1124. longest-well-performing-interval/sol.kt @@ -0,0 +1,23 @@ +class Solution { + fun longestWPI(hours: IntArray): Int { + var score = 0 + var longestInterval = 0 + val seenAt = mutableMapOf(0 to -1) + + for (i in hours.indices) { + score += if (hours[i] > 8) 1 else -1 + + if (score > 0) { + longestInterval = i + 1 + } else if (seenAt.containsKey(score - 1)) { + longestInterval = maxOf(longestInterval, i - seenAt[score - 1]!!) + } + + if (!seenAt.containsKey(score)) { + seenAt[score] = i + } + } + + return longestInterval + } +} diff --git a/tests/1001-1500/1124. longest-well-performing-interval/sol.py b/tests/1001-1500/1124. longest-well-performing-interval/sol.py new file mode 100644 index 00000000..1e8f6ef1 --- /dev/null +++ b/tests/1001-1500/1124. longest-well-performing-interval/sol.py @@ -0,0 +1,27 @@ +class Solution: + def longestWPI(self, hours: List[int]) -> int: + score = 0 + longest_interval = 0 + # We start at score 0 before considering any days (index -1) + seen_at = {0: -1} + + for i, h in enumerate(hours): + # 1. Update the score (Up or Down) + score += 1 if h > 8 else -1 + + # 2. Check the two rules + if score > 0: + # Rule A: We are positive! The whole thing counts. + longest_interval = i + 1 + elif (score - 1) in seen_at: + # Rule B: We are negative. + # Look for the earliest spot that was exactly 1 point lower. + # Distance = Current Index - Index of that earlier spot + longest_interval = max(longest_interval, i - seen_at[score - 1]) + + # 3. Remember this score? + # Only remember the FIRST time we see a score (to keep intervals long) + if score not in seen_at: + seen_at[score] = i + + return longest_interval diff --git a/tests/1001-1500/1124. longest-well-performing-interval/sol.py2 b/tests/1001-1500/1124. longest-well-performing-interval/sol.py2 new file mode 100644 index 00000000..24db6c05 --- /dev/null +++ b/tests/1001-1500/1124. longest-well-performing-interval/sol.py2 @@ -0,0 +1,22 @@ +class Solution(object): + def longestWPI(self, hours): + """ + :type hours: List[int] + :rtype: int + """ + score = 0 + longest_interval = 0 + seen_at = {0: -1} + + for i, h in enumerate(hours): + score += 1 if h > 8 else -1 + + if score > 0: + longest_interval = i + 1 + elif (score - 1) in seen_at: + longest_interval = max(longest_interval, i - seen_at[score - 1]) + + if score not in seen_at: + seen_at[score] = i + + return longest_interval diff --git a/tests/1001-1500/1124. longest-well-performing-interval/sol.rb b/tests/1001-1500/1124. longest-well-performing-interval/sol.rb new file mode 100644 index 00000000..8e6e2842 --- /dev/null +++ b/tests/1001-1500/1124. longest-well-performing-interval/sol.rb @@ -0,0 +1,23 @@ +# @param {Integer[]} hours +# @return {Integer} +def longest_wpi(hours) + score = 0 + longest_interval = 0 + seen_at = {0 => -1} + + hours.each_with_index do |h, i| + score += h > 8 ? 1 : -1 + + if score > 0 + longest_interval = i + 1 + elsif seen_at.key?(score - 1) + longest_interval = [longest_interval, i - seen_at[score - 1]].max + end + + unless seen_at.key?(score) + seen_at[score] = i + end + end + + longest_interval +end diff --git a/tests/1001-1500/1124. longest-well-performing-interval/sol.rs b/tests/1001-1500/1124. longest-well-performing-interval/sol.rs new file mode 100644 index 00000000..d71ed5d0 --- /dev/null +++ b/tests/1001-1500/1124. longest-well-performing-interval/sol.rs @@ -0,0 +1,24 @@ +impl Solution { + pub fn longest_wpi(hours: Vec) -> i32 { + let mut score: i32 = 0; + let mut longest_interval: i32 = 0; + let mut seen_at: std::collections::HashMap = std::collections::HashMap::new(); + seen_at.insert(0, -1); + + for (i, &h) in hours.iter().enumerate() { + score += if h > 8 { 1 } else { -1 }; + + if score > 0 { + longest_interval = i as i32 + 1; + } else if let Some(&prev_index) = seen_at.get(&(score - 1)) { + longest_interval = longest_interval.max(i as i32 - prev_index); + } + + if !seen_at.contains_key(&score) { + seen_at.insert(score, i as i32); + } + } + + longest_interval + } +} diff --git a/tests/1001-1500/1124. longest-well-performing-interval/sol.swift b/tests/1001-1500/1124. longest-well-performing-interval/sol.swift new file mode 100644 index 00000000..2139697e --- /dev/null +++ b/tests/1001-1500/1124. longest-well-performing-interval/sol.swift @@ -0,0 +1,23 @@ +class Solution { + func longestWPI(_ hours: [Int]) -> Int { + var score = 0 + var longestInterval = 0 + var seenAt = [0: -1] + + for (i, h) in hours.enumerated() { + score += h > 8 ? 1 : -1 + + if score > 0 { + longestInterval = i + 1 + } else if let prevIndex = seenAt[score - 1] { + longestInterval = max(longestInterval, i - prevIndex) + } + + if seenAt[score] == nil { + seenAt[score] = i + } + } + + return longestInterval + } +} diff --git a/tests/1001-1500/1124. longest-well-performing-interval/sol.ts b/tests/1001-1500/1124. longest-well-performing-interval/sol.ts new file mode 100644 index 00000000..6ede6166 --- /dev/null +++ b/tests/1001-1500/1124. longest-well-performing-interval/sol.ts @@ -0,0 +1,22 @@ +function longestWPI(hours: number[]): number { + let score = 0; + let longestInterval = 0; + const seenAt = new Map(); + seenAt.set(0, -1); + + for (let i = 0; i < hours.length; i++) { + score += hours[i] > 8 ? 1 : -1; + + if (score > 0) { + longestInterval = i + 1; + } else if (seenAt.has(score - 1)) { + longestInterval = Math.max(longestInterval, i - seenAt.get(score - 1)!); + } + + if (!seenAt.has(score)) { + seenAt.set(score, i); + } + } + + return longestInterval; +} diff --git a/tests/1001-1500/1125. smallest-sufficient-team/manifest.yaml b/tests/1001-1500/1125. smallest-sufficient-team/manifest.yaml new file mode 100644 index 00000000..81f48643 --- /dev/null +++ b/tests/1001-1500/1125. smallest-sufficient-team/manifest.yaml @@ -0,0 +1,599 @@ +entry: + id: 1125 + title: smallest-sufficient-team + params: + req_skills: + type: array + items: + type: string + people: + type: array + items: + type: array + items: + type: string + call: + cpp: "Solution().smallestSufficientTeam({req_skills}, {people})" + rust: "Solution::smallest_sufficient_team({req_skills}, {people})" + python3: "Solution().smallestSufficientTeam({req_skills}, {people})" + python2: "Solution().smallestSufficientTeam({req_skills}, {people})" + ruby: "smallest_sufficient_team({req_skills}, {people})" + java: "new Solution().smallestSufficientTeam({req_skills}, java.util.Arrays.stream({people}).map(row -> java.util.Arrays.asList(row)).collect(java.util.stream.Collectors.toList()))" + csharp: "new Solution().SmallestSufficientTeam({req_skills}, {people})" + kotlin: "Solution().smallestSufficientTeam({req_skills}, {people}.map { it.toList() })" + go: "smallestSufficientTeam({req_skills}, {people})" + dart: "Solution().smallestSufficientTeam({req_skills}, {people})" + swift: "Solution().smallestSufficientTeam({req_skills}, {people})" + typescript: "smallestSufficientTeam({req_skills}, {people})" +judge: + type: exact +limits: + time_ms: 3000 + memory_mb: 256 +oracle: + python3: + call: "Checker().smallestSufficientTeam(req_skills, people, {result})" + checker: | + class Checker: + def smallestSufficientTeam(self, req_skills, people, result): + if not isinstance(result, list): + return False + if any(type(index) is not int for index in result): + return False + if len(set(result)) != len(result): + return False + if any(index < 0 or index >= len(people) for index in result): + return False + + skill_index = {skill: i for i, skill in enumerate(req_skills)} + full = (1 << len(req_skills)) - 1 + + def person_mask(skills): + mask = 0 + for skill in skills: + if skill in skill_index: + mask |= 1 << skill_index[skill] + return mask + + masks = [person_mask(skills) for skills in people] + covered = 0 + for index in result: + covered |= masks[index] + if covered != full: + return False + + best = {0: 0} + for mask in masks: + next_best = dict(best) + for covered_mask, size in best.items(): + combined = covered_mask | mask + candidate = size + 1 + if candidate < next_best.get(combined, len(people) + 1): + next_best[combined] = candidate + best = next_best + return len(result) == best.get(full) +seed: 1125 +tests: + - name: example-one + in: + req_skills: ["java", "nodejs", "reactjs"] + people: + elemType: "string" + value: + - ["java"] + - ["nodejs"] + - ["nodejs", "reactjs"] + - name: example-two + in: + req_skills: ["algorithms", "math", "java", "reactjs", "csharp", "aws"] + people: + elemType: "string" + value: + - ["algorithms", "math", "java"] + - ["algorithms", "math", "reactjs"] + - ["java", "csharp", "aws"] + - ["reactjs", "csharp"] + - ["csharp", "math"] + - ["aws", "java"] + - name: single-skill-single-person + in: + req_skills: ["a"] + people: + elemType: "string" + value: + - ["a"] + - name: single-skill-many-candidates + in: + req_skills: ["a"] + people: + elemType: "string" + value: + - [] + - ["a"] + - ["a"] + - [] + - name: one-person-covers-all + in: + req_skills: ["a", "b", "c", "d"] + people: + elemType: "string" + value: + - ["a"] + - ["b", "c"] + - ["a", "b", "c", "d"] + - ["d"] + - name: every-skill-separate + in: + req_skills: ["a", "b", "c", "d", "e"] + people: + elemType: "string" + value: + - ["a"] + - ["b"] + - ["c"] + - ["d"] + - ["e"] + - name: empty-people-between-useful + in: + req_skills: ["a", "b", "c"] + people: + elemType: "string" + value: + - [] + - ["a", "b"] + - [] + - ["c"] + - [] + - name: two-equal-optima + in: + req_skills: ["a", "b"] + people: + elemType: "string" + value: + - ["a"] + - ["b"] + - ["a"] + - ["b"] + - name: dominated-people + in: + req_skills: ["a", "b", "c"] + people: + elemType: "string" + value: + - ["a"] + - ["a", "b"] + - ["a", "b", "c"] + - ["c"] + - name: pair-beats-three-singles + in: + req_skills: ["a", "b", "c", "d"] + people: + elemType: "string" + value: + - ["a"] + - ["b"] + - ["c", "d"] + - ["a", "b"] + - ["c"] + - name: overlapping-cycle-three + in: + req_skills: ["a", "b", "c"] + people: + elemType: "string" + value: + - ["a", "b"] + - ["b", "c"] + - ["a", "c"] + - name: overlapping-cycle-four + in: + req_skills: ["a", "b", "c", "d"] + people: + elemType: "string" + value: + - ["a", "b"] + - ["b", "c"] + - ["c", "d"] + - ["d", "a"] + - name: unique-complement + in: + req_skills: ["frontend", "backend", "database", "ops"] + people: + elemType: "string" + value: + - ["frontend", "backend"] + - ["database"] + - ["ops"] + - ["database", "ops"] + - ["frontend"] + - name: late-best-person + in: + req_skills: ["a", "b", "c", "d", "e"] + people: + elemType: "string" + value: + - ["a", "b"] + - ["c"] + - ["d"] + - ["e"] + - ["a", "b", "c", "d", "e"] + - name: early-best-person + in: + req_skills: ["a", "b", "c", "d", "e"] + people: + elemType: "string" + value: + - ["a", "b", "c", "d", "e"] + - ["a", "b"] + - ["c", "d"] + - ["e"] + - name: meaningful-skill-names + in: + req_skills: ["linux", "network", "storage", "security", "cloud"] + people: + elemType: "string" + value: + - ["linux", "network"] + - ["storage", "security"] + - ["cloud"] + - ["network", "cloud"] + - ["linux", "storage"] + - name: yaml-like-skill-strings + in: + req_skills: ["no", "off", "false", "yes"] + people: + elemType: "string" + value: + - ["no", "off"] + - ["false"] + - ["yes"] + - ["off", "false", "yes"] + - name: repeated-coverage + in: + req_skills: ["a", "b", "c", "d"] + people: + elemType: "string" + value: + - ["a", "b"] + - ["a", "b"] + - ["c", "d"] + - ["c", "d"] + - ["a", "d"] + - name: six-skills-three-pairs + in: + req_skills: ["a", "b", "c", "d", "e", "f"] + people: + elemType: "string" + value: + - ["a", "b"] + - ["c", "d"] + - ["e", "f"] + - ["a", "c", "e"] + - ["b", "d", "f"] + - name: six-skills-complementary-triples + in: + req_skills: ["a", "b", "c", "d", "e", "f"] + people: + elemType: "string" + value: + - ["a", "c", "e"] + - ["b", "d", "f"] + - ["a", "b"] + - ["c", "d"] + - ["e", "f"] + - name: seven-skills-mixed + in: + req_skills: ["a", "b", "c", "d", "e", "f", "g"] + people: + elemType: "string" + value: + - ["a", "b", "c"] + - ["d", "e"] + - ["f", "g"] + - ["a", "d", "f"] + - ["b", "e", "g"] + - ["c"] + - name: eight-skills-balanced + in: + req_skills: ["a", "b", "c", "d", "e", "f", "g", "h"] + people: + elemType: "string" + value: + - ["a", "b", "c", "d"] + - ["e", "f", "g", "h"] + - ["a", "e"] + - ["b", "f"] + - ["c", "g"] + - ["d", "h"] + - name: eight-skills-cross-cover + in: + req_skills: ["a", "b", "c", "d", "e", "f", "g", "h"] + people: + elemType: "string" + value: + - ["a", "c", "e", "g"] + - ["b", "d", "f", "h"] + - ["a", "b", "c"] + - ["d", "e", "f"] + - ["g", "h"] + - name: nine-skills-layered + in: + req_skills: ["a", "b", "c", "d", "e", "f", "g", "h", "i"] + people: + elemType: "string" + value: + - ["a", "b", "c"] + - ["d", "e", "f"] + - ["g", "h", "i"] + - ["a", "d", "g"] + - ["b", "e", "h"] + - ["c", "f", "i"] + - name: ten-skills-two-halves + in: + req_skills: ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"] + people: + elemType: "string" + value: + - ["a", "b", "c", "d", "e"] + - ["f", "g", "h", "i", "j"] + - ["a", "f"] + - ["b", "g"] + - ["c", "h"] + - ["d", "i"] + - ["e", "j"] + - name: ten-skills-distractors + in: + req_skills: ["s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9"] + people: + elemType: "string" + value: + - [] + - ["s0", "s1", "s2", "s3"] + - ["s4", "s5", "s6"] + - ["s7", "s8", "s9"] + - ["s0"] + - ["s1"] + - ["s2"] + - ["s3"] + - ["s4"] + - ["s5"] + - ["s6"] + - ["s7"] + - ["s8"] + - ["s9"] + - name: eleven-skills-overlap + in: + req_skills: + ["s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10"] + people: + elemType: "string" + value: + - ["s0", "s1", "s2", "s3"] + - ["s3", "s4", "s5", "s6"] + - ["s6", "s7", "s8"] + - ["s8", "s9", "s10"] + - ["s0", "s5", "s10"] + - name: twelve-skills-four-groups + in: + req_skills: + [ + "s0", + "s1", + "s2", + "s3", + "s4", + "s5", + "s6", + "s7", + "s8", + "s9", + "s10", + "s11", + ] + people: + elemType: "string" + value: + - ["s0", "s1", "s2"] + - ["s3", "s4", "s5"] + - ["s6", "s7", "s8"] + - ["s9", "s10", "s11"] + - ["s0", "s3", "s6", "s9"] + - ["s1", "s4", "s7", "s10"] + - ["s2", "s5", "s8", "s11"] + - name: thirteen-skills-mixed + in: + req_skills: + [ + "s0", + "s1", + "s2", + "s3", + "s4", + "s5", + "s6", + "s7", + "s8", + "s9", + "s10", + "s11", + "s12", + ] + people: + elemType: "string" + value: + - ["s0", "s1", "s2", "s3"] + - ["s4", "s5", "s6"] + - ["s7", "s8", "s9"] + - ["s10", "s11", "s12"] + - ["s0", "s4", "s7", "s10"] + - ["s1", "s5", "s8", "s11"] + - ["s2", "s6", "s9", "s12"] + - name: fourteen-skills-paired + in: + req_skills: + [ + "s0", + "s1", + "s2", + "s3", + "s4", + "s5", + "s6", + "s7", + "s8", + "s9", + "s10", + "s11", + "s12", + "s13", + ] + people: + elemType: "string" + value: + - ["s0", "s1"] + - ["s2", "s3"] + - ["s4", "s5"] + - ["s6", "s7"] + - ["s8", "s9"] + - ["s10", "s11"] + - ["s12", "s13"] + - ["s0", "s2", "s4", "s6", "s8", "s10", "s12"] + - ["s1", "s3", "s5", "s7", "s9", "s11", "s13"] + - name: fifteen-skills-three-blocks + in: + req_skills: + [ + "s0", + "s1", + "s2", + "s3", + "s4", + "s5", + "s6", + "s7", + "s8", + "s9", + "s10", + "s11", + "s12", + "s13", + "s14", + ] + people: + elemType: "string" + value: + - ["s0", "s1", "s2", "s3", "s4"] + - ["s5", "s6", "s7", "s8", "s9"] + - ["s10", "s11", "s12", "s13", "s14"] + - ["s0", "s5", "s10"] + - ["s1", "s6", "s11"] + - ["s2", "s7", "s12"] + - ["s3", "s8", "s13"] + - ["s4", "s9", "s14"] + - name: max-sixteen-skills-two-people + in: + req_skills: + [ + "s0", + "s1", + "s2", + "s3", + "s4", + "s5", + "s6", + "s7", + "s8", + "s9", + "s10", + "s11", + "s12", + "s13", + "s14", + "s15", + ] + people: + elemType: "string" + value: + - ["s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7"] + - ["s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15"] + - ["s0", "s8"] + - ["s1", "s9"] + - ["s2", "s10"] + - ["s3", "s11"] + - name: max-sixteen-skills-cross-halves + in: + req_skills: + [ + "s0", + "s1", + "s2", + "s3", + "s4", + "s5", + "s6", + "s7", + "s8", + "s9", + "s10", + "s11", + "s12", + "s13", + "s14", + "s15", + ] + people: + elemType: "string" + value: + - ["s0", "s2", "s4", "s6", "s8", "s10", "s12", "s14"] + - ["s1", "s3", "s5", "s7", "s9", "s11", "s13", "s15"] + - ["s0", "s1", "s2", "s3"] + - ["s4", "s5", "s6", "s7"] + - ["s8", "s9", "s10", "s11"] + - ["s12", "s13", "s14", "s15"] + - name: many-empty-and-duplicate-people + in: + req_skills: ["a", "b", "c", "d", "e", "f"] + people: + elemType: "string" + value: + - [] + - [] + - ["a", "b"] + - ["a", "b"] + - [] + - ["c", "d"] + - ["c", "d"] + - ["e", "f"] + - ["e", "f"] + - [] + - name: choice-between-generalists + in: + req_skills: ["a", "b", "c", "d", "e", "f", "g", "h"] + people: + elemType: "string" + value: + - ["a", "b", "c", "d"] + - ["e", "f", "g", "h"] + - ["a", "b", "e", "f"] + - ["c", "d", "g", "h"] + - ["a", "c", "e", "g"] + - ["b", "d", "f", "h"] + - name: rare-skill-at-last-index + in: + req_skills: ["common", "rare"] + people: + elemType: "string" + value: + - ["common"] + - ["common"] + - [] + - ["rare"] + - name: rare-skill-with-generalist + in: + req_skills: ["a", "b", "rare"] + people: + elemType: "string" + value: + - ["a"] + - ["b"] + - ["rare"] + - ["a", "b", "rare"] diff --git a/tests/1001-1500/1125. smallest-sufficient-team/sol.cpp b/tests/1001-1500/1125. smallest-sufficient-team/sol.cpp new file mode 100644 index 00000000..ec632589 --- /dev/null +++ b/tests/1001-1500/1125. smallest-sufficient-team/sol.cpp @@ -0,0 +1,45 @@ +#include +using namespace std; + +class Solution { +public: + vector smallestSufficientTeam(vector& req_skills, vector>& people) { + int n = (int)req_skills.size(); + int full = (1 << n) - 1; + unordered_map idx; + for (int i = 0; i < n; ++i) idx[req_skills[i]] = i; + + vector masks; + masks.reserve(people.size()); + for (auto& person : people) { + int mask = 0; + for (auto& skill : person) mask |= 1 << idx[skill]; + masks.push_back(mask); + } + + vector> dp(1 << n); + vector seen(1 << n, 0); + seen[0] = 1; + + for (int i = 0; i < (int)masks.size(); ++i) { + int pmask = masks[i]; + if (!pmask) continue; + auto cur = dp; + auto curSeen = seen; + for (int mask = 0; mask <= full; ++mask) { + if (!seen[mask]) continue; + int nmask = mask | pmask; + vector cand = dp[mask]; + cand.push_back(i); + if (!curSeen[nmask] || cand.size() < cur[nmask].size()) { + curSeen[nmask] = 1; + cur[nmask] = move(cand); + } + } + dp.swap(cur); + seen.swap(curSeen); + } + + return dp[full]; + } +}; diff --git a/tests/1001-1500/1125. smallest-sufficient-team/sol.cs b/tests/1001-1500/1125. smallest-sufficient-team/sol.cs new file mode 100644 index 00000000..cc620b53 --- /dev/null +++ b/tests/1001-1500/1125. smallest-sufficient-team/sol.cs @@ -0,0 +1,86 @@ +public class Solution { + public int[] SmallestSufficientTeam(string[] req_skills, IList> people) { + int n = req_skills.Length; + int m = people.Count; + + Dictionary skillIdx = new Dictionary(); + for (int i = 0; i < n; i++) { + skillIdx[req_skills[i]] = i; + } + + int[] peopleMask = new int[m]; + for (int i = 0; i < m; i++) { + int mask = 0; + foreach (string skill in people[i]) { + mask |= 1 << skillIdx[skill]; + } + peopleMask[i] = mask; + } + + for (int i = 0; i < m; i++) { + for (int j = 0; j < m; j++) { + if (i != j && peopleMask[i] != 0 && (peopleMask[i] & peopleMask[j]) == peopleMask[i]) { + peopleMask[i] = 0; + break; + } + } + } + + List[] skillToPeople = new List[n]; + for (int i = 0; i < n; i++) { + skillToPeople[i] = new List(); + } + for (int i = 0; i < m; i++) { + if (peopleMask[i] == 0) continue; + for (int bit = 0; bit < n; bit++) { + if ((peopleMask[i] & (1 << bit)) != 0) { + skillToPeople[bit].Add(i); + } + } + } + + HashSet unmetSkills = new HashSet(req_skills); + int smallestLength = int.MaxValue; + List currentTeam = new List(); + List bestTeam = new List(); + + void Backtrack(int skill) { + if (unmetSkills.Count == 0) { + if (smallestLength > currentTeam.Count) { + smallestLength = currentTeam.Count; + bestTeam = new List(currentTeam); + } + return; + } + + if (skill >= n) return; + + if (!unmetSkills.Contains(req_skills[skill])) { + Backtrack(skill + 1); + return; + } + + foreach (int i in skillToPeople[skill]) { + int mask = peopleMask[i]; + List skillsAdded = new List(); + foreach (string s in unmetSkills) { + if ((mask & (1 << skillIdx[s])) != 0) { + skillsAdded.Add(s); + } + } + if (skillsAdded.Count == 0) continue; + + foreach (string s in skillsAdded) unmetSkills.Remove(s); + currentTeam.Add(i); + + Backtrack(skill + 1); + + currentTeam.RemoveAt(currentTeam.Count - 1); + foreach (string s in skillsAdded) unmetSkills.Add(s); + } + } + + Backtrack(0); + return bestTeam.ToArray(); + } +} diff --git a/tests/1001-1500/1125. smallest-sufficient-team/sol.dart b/tests/1001-1500/1125. smallest-sufficient-team/sol.dart new file mode 100644 index 00000000..140210eb --- /dev/null +++ b/tests/1001-1500/1125. smallest-sufficient-team/sol.dart @@ -0,0 +1,83 @@ +class Solution { + List smallestSufficientTeam(List req_skills, List> people) { + int n = req_skills.length; + int m = people.length; + + Map skillIdx = {}; + for (int i = 0; i < n; i++) { + skillIdx[req_skills[i]] = i; + } + + List peopleMask = List.filled(m, 0); + for (int i = 0; i < m; i++) { + int mask = 0; + for (String skill in people[i]) { + mask |= (1 << skillIdx[skill]!); + } + peopleMask[i] = mask; + } + + for (int i = 0; i < m; i++) { + for (int j = 0; j < m; j++) { + if (i != j && peopleMask[i] != 0 && (peopleMask[i] & peopleMask[j]) == peopleMask[i]) { + peopleMask[i] = 0; + break; + } + } + } + + List> skillToPeople = List.generate(n, (_) => []); + for (int i = 0; i < m; i++) { + if (peopleMask[i] == 0) continue; + for (int bit = 0; bit < n; bit++) { + if ((peopleMask[i] & (1 << bit)) != 0) { + skillToPeople[bit].add(i); + } + } + } + + Set unmetSkills = req_skills.toSet(); + int smallestLength = 1 << 60; + List currentTeam = []; + List bestTeam = []; + + void backtrack(int skill) { + if (unmetSkills.isEmpty) { + if (smallestLength > currentTeam.length) { + smallestLength = currentTeam.length; + bestTeam = List.from(currentTeam); + } + return; + } + + if (skill >= n) return; + + if (!unmetSkills.contains(req_skills[skill])) { + backtrack(skill + 1); + return; + } + + for (int i in skillToPeople[skill]) { + int mask = peopleMask[i]; + Set skillsAdded = {}; + for (String s in unmetSkills) { + if ((mask & (1 << skillIdx[s]!)) != 0) { + skillsAdded.add(s); + } + } + if (skillsAdded.isEmpty) continue; + + unmetSkills.removeAll(skillsAdded); + currentTeam.add(i); + + backtrack(skill + 1); + + currentTeam.removeLast(); + unmetSkills.addAll(skillsAdded); + } + } + + backtrack(0); + return bestTeam; + } +} diff --git a/tests/1001-1500/1125. smallest-sufficient-team/sol.go b/tests/1001-1500/1125. smallest-sufficient-team/sol.go new file mode 100644 index 00000000..05ae44e6 --- /dev/null +++ b/tests/1001-1500/1125. smallest-sufficient-team/sol.go @@ -0,0 +1,99 @@ +func smallestSufficientTeam(req_skills []string, people [][]string) []int { + n := len(req_skills) + m := len(people) + + skillIdx := make(map[string]int) + for i, skill := range req_skills { + skillIdx[skill] = i + } + + peopleMask := make([]int, m) + for i, skills := range people { + mask := 0 + for _, skill := range skills { + mask |= 1 << skillIdx[skill] + } + peopleMask[i] = mask + } + + for i := 0; i < m; i++ { + for j := 0; j < m; j++ { + if i != j && peopleMask[i] != 0 && (peopleMask[i] & peopleMask[j]) == peopleMask[i] { + peopleMask[i] = 0 + break + } + } + } + + skillToPeople := make([][]int, n) + for i := 0; i < n; i++ { + skillToPeople[i] = []int{} + } + for i := 0; i < m; i++ { + if peopleMask[i] == 0 { + continue + } + for bit := 0; bit < n; bit++ { + if (peopleMask[i] & (1 << bit)) != 0 { + skillToPeople[bit] = append(skillToPeople[bit], i) + } + } + } + + unmetSkills := make(map[string]bool) + for _, skill := range req_skills { + unmetSkills[skill] = true + } + + smallestLength := int(^uint(0) >> 1) + var currentTeam []int + var bestTeam []int + + var backtrack func(skill int) + backtrack = func(skill int) { + if len(unmetSkills) == 0 { + if smallestLength > len(currentTeam) { + smallestLength = len(currentTeam) + bestTeam = append([]int{}, currentTeam...) + } + return + } + + if skill >= n { + return + } + + if !unmetSkills[req_skills[skill]] { + backtrack(skill + 1) + return + } + + for _, i := range skillToPeople[skill] { + mask := peopleMask[i] + skillsAdded := []string{} + for s := range unmetSkills { + if (mask & (1 << skillIdx[s])) != 0 { + skillsAdded = append(skillsAdded, s) + } + } + if len(skillsAdded) == 0 { + continue + } + + for _, s := range skillsAdded { + delete(unmetSkills, s) + } + currentTeam = append(currentTeam, i) + + backtrack(skill + 1) + + currentTeam = currentTeam[:len(currentTeam)-1] + for _, s := range skillsAdded { + unmetSkills[s] = true + } + } + } + + backtrack(0) + return bestTeam +} diff --git a/tests/1001-1500/1125. smallest-sufficient-team/sol.java b/tests/1001-1500/1125. smallest-sufficient-team/sol.java new file mode 100644 index 00000000..6ec4a07b --- /dev/null +++ b/tests/1001-1500/1125. smallest-sufficient-team/sol.java @@ -0,0 +1,42 @@ +import java.util.*; + +class Solution { + public int[] smallestSufficientTeam(String[] req_skills, List> people) { + int n = req_skills.length; + int full = (1 << n) - 1; + Map idx = new HashMap<>(); + for (int i = 0; i < n; i++) idx.put(req_skills[i], i); + + int[] masks = new int[people.size()]; + for (int i = 0; i < people.size(); i++) { + int mask = 0; + for (String skill : people.get(i)) mask |= 1 << idx.get(skill); + masks[i] = mask; + } + + @SuppressWarnings("unchecked") + ArrayList[] dp = new ArrayList[1 << n]; + dp[0] = new ArrayList<>(); + + for (int i = 0; i < masks.length; i++) { + int pmask = masks[i]; + if (pmask == 0) continue; + ArrayList[] next = Arrays.copyOf(dp, dp.length); + for (int mask = 0; mask <= full; mask++) { + if (dp[mask] == null) continue; + int nmask = mask | pmask; + ArrayList cand = new ArrayList<>(dp[mask]); + cand.add(i); + if (next[nmask] == null || cand.size() < next[nmask].size()) { + next[nmask] = cand; + } + } + dp = next; + } + + ArrayList ans = dp[full]; + int[] res = new int[ans.size()]; + for (int i = 0; i < ans.size(); i++) res[i] = ans.get(i); + return res; + } +} diff --git a/tests/1001-1500/1125. smallest-sufficient-team/sol.kt b/tests/1001-1500/1125. smallest-sufficient-team/sol.kt new file mode 100644 index 00000000..d8a38560 --- /dev/null +++ b/tests/1001-1500/1125. smallest-sufficient-team/sol.kt @@ -0,0 +1,34 @@ +class Solution { + fun smallestSufficientTeam(req_skills: Array, people: List>): IntArray { + val n = req_skills.size + val full = (1 shl n) - 1 + val idx = HashMap() + for (i in req_skills.indices) idx[req_skills[i]] = i + + val masks = IntArray(people.size) + for (i in people.indices) { + var mask = 0 + for (skill in people[i]) mask = mask or (1 shl idx[skill]!!) + masks[i] = mask + } + + var dp = arrayOfNulls(1 shl n) + dp[0] = IntArray(0) + + for (i in masks.indices) { + val pmask = masks[i] + if (pmask == 0) continue + val next = dp.copyOf() + for (mask in 0..full) { + val team = dp[mask] ?: continue + val nmask = mask or pmask + val cand = team + i + val old = next[nmask] + if (old == null || cand.size < old.size) next[nmask] = cand + } + dp = next + } + + return dp[full]!! + } +} diff --git a/tests/1001-1500/1125. smallest-sufficient-team/sol.py b/tests/1001-1500/1125. smallest-sufficient-team/sol.py new file mode 100644 index 00000000..6bd515fb --- /dev/null +++ b/tests/1001-1500/1125. smallest-sufficient-team/sol.py @@ -0,0 +1,73 @@ +from typing import List +import collections +import math + + +class Solution: + def smallestSufficientTeam( + self, req_skills: List[str], people: List[List[str]] + ) -> List[int]: + + # Firstly, convert all the sublists in people into sets for easier processing. + for i, skills in enumerate(people): + people[i] = set(skills) + + # Remove all skill sets that are subset of another skillset, by replacing the subset with an + # empty set. We do this rather than completely removing, so that indexes aren't + # disrupted (which is a pain to have to sort out later). + for i, i_skills in enumerate(people): + for j, j_skills in enumerate(people): + if i != j and i_skills.issubset(j_skills): + people[i] = set() + + # Now build up a dictionary of skills to the people who can perform them. The backtracking algorithm + # will use this. + skills_to_people = collections.defaultdict(set) + for i, skills in enumerate(people): + for skill in skills: + skills_to_people[skill].add(i) + people[i] = set(skills) + + # Keep track of some data used by the backtracking algorithm. + self.unmet_skills = set( + req_skills + ) # Backtracking will remove and readd skills here as needed. + self.smallest_length = math.inf # Smallest team length so far. + self.current_team = [] # Current team members. + self.best_team = [] # Best team we've found, i,e, shortest team that covers skills/ + + # Here is the backtracking algorithm. + def meet_skill(skill=0): + # Base case: All skills are met. + if not self.unmet_skills: + # If the current team is smaller than the previous we found, update it. + if self.smallest_length > len(self.current_team): + self.smallest_length = len(self.current_team) + self.best_team = self.current_team[ + :: + ] # In Python, this makes a copy of a list. + return # So that we don't carry out the rest of the algorithm. + + # If this skill is already met, move onto the next one. + if req_skills[skill] not in self.unmet_skills: + return meet_skill(skill + 1) + # Note return is just to stop rest of code here running. Return values + # are not caught and used. + + # Otherwise, consider all who could meet the current skill. + for i in skills_to_people[req_skills[skill]]: + # Add this person onto the team by updating the backtrading data. + skills_added_by_person = people[i].intersection(self.unmet_skills) + self.unmet_skills = self.unmet_skills - skills_added_by_person + self.current_team.append(i) + + # Do the recursive call to further build the team. + meet_skill(skill + 1) + + # Backtrack by removing the person from the team again. + self.current_team.pop() + self.unmet_skills = self.unmet_skills.union(skills_added_by_person) + + # Kick off the algorithm. + meet_skill() + return self.best_team diff --git a/tests/1001-1500/1125. smallest-sufficient-team/sol.py2 b/tests/1001-1500/1125. smallest-sufficient-team/sol.py2 new file mode 100644 index 00000000..c9e72ccc --- /dev/null +++ b/tests/1001-1500/1125. smallest-sufficient-team/sol.py2 @@ -0,0 +1,78 @@ +class Solution(object): + def smallestSufficientTeam(self, req_skills, people): + """ + :type req_skills: List[str] + :type people: List[List[str]] + :rtype: List[int] + """ + n = len(req_skills) + m = len(people) + # map skill to index + skill_idx = {skill: i for i, skill in enumerate(req_skills)} + + # convert each person's skills to a bitmask + people_mask = [] + for p in people: + mask = 0 + for skill in p: + mask |= (1 << skill_idx[skill]) + people_mask.append(mask) + + # remove people whose skills are subset of another (still track original index) + for i in range(m): + for j in range(m): + if i != j and people_mask[i] and (people_mask[i] & people_mask[j]) == people_mask[i]: + people_mask[i] = 0 + break + + # map skill bit to people who have it (only if person not removed) + skill_to_people = {i: [] for i in range(n)} + for i, mask in enumerate(people_mask): + if mask == 0: + continue + for skill_idx_val, bit in enumerate(range(n)): + if mask & (1 << bit): + skill_to_people[skill_idx_val].append(i) + + self.unmet_skills = set(req_skills) + self.smallest_length = float('inf') + self.current_team = [] + self.best_team = [] + self.req_skills = req_skills + self.skills_to_people = skill_to_people + self.people_mask = people_mask + self.skill_idx = skill_idx + + def meet_skill(skill=0): + if not self.unmet_skills: + if self.smallest_length > len(self.current_team): + self.smallest_length = len(self.current_team) + self.best_team = self.current_team[:] + return + + if skill >= len(self.req_skills): + return + + if self.req_skills[skill] not in self.unmet_skills: + meet_skill(skill + 1) + return + + for i in self.skills_to_people[skill]: + mask = self.people_mask[i] + skills_added = set() + for s in list(self.unmet_skills): + if mask & (1 << self.skill_idx[s]): + skills_added.add(s) + if not skills_added: + continue + + self.unmet_skills -= skills_added + self.current_team.append(i) + + meet_skill(skill + 1) + + self.current_team.pop() + self.unmet_skills |= skills_added + + meet_skill() + return self.best_team diff --git a/tests/1001-1500/1125. smallest-sufficient-team/sol.rb b/tests/1001-1500/1125. smallest-sufficient-team/sol.rb new file mode 100644 index 00000000..d7982d2a --- /dev/null +++ b/tests/1001-1500/1125. smallest-sufficient-team/sol.rb @@ -0,0 +1,35 @@ +# @param {String[]} req_skills +# @param {String[][]} people +# @return {Integer[]} +def smallest_sufficient_team(req_skills, people) + n = req_skills.size + full = (1 << n) - 1 + idx = {} + req_skills.each_with_index { |skill, i| idx[skill] = i } + + masks = people.map do |skills| + mask = 0 + skills.each { |skill| mask |= (1 << idx[skill]) } + mask + end + + dp = Array.new(1 << n) + dp[0] = [] + + masks.each_with_index do |pmask, i| + next if pmask == 0 + nxt = dp.dup + (0..full).each do |mask| + team = dp[mask] + next if team.nil? + nmask = mask | pmask + cand = team + [i] + if nxt[nmask].nil? || cand.length < nxt[nmask].length + nxt[nmask] = cand + end + end + dp = nxt + end + + dp[full] || [] +end diff --git a/tests/1001-1500/1125. smallest-sufficient-team/sol.rs b/tests/1001-1500/1125. smallest-sufficient-team/sol.rs new file mode 100644 index 00000000..53a07539 --- /dev/null +++ b/tests/1001-1500/1125. smallest-sufficient-team/sol.rs @@ -0,0 +1,103 @@ +impl Solution { + pub fn smallest_sufficient_team(req_skills: Vec, people: Vec>) -> Vec { + let n = req_skills.len(); + let m = people.len(); + + let mut skill_idx = std::collections::HashMap::new(); + for (i, skill) in req_skills.iter().enumerate() { + skill_idx.insert(skill.clone(), i); + } + + let mut people_mask = vec![0i32; m]; + for (i, skills) in people.iter().enumerate() { + let mut mask = 0; + for skill in skills { + mask |= 1 << skill_idx[skill]; + } + people_mask[i] = mask; + } + + for i in 0..m { + for j in 0..m { + if i != j && people_mask[i] != 0 && (people_mask[i] & people_mask[j]) == people_mask[i] { + people_mask[i] = 0; + break; + } + } + } + + let mut skill_to_people = vec![vec![]; n]; + for i in 0..m { + if people_mask[i] == 0 { + continue; + } + for bit in 0..n { + if (people_mask[i] & (1 << bit)) != 0 { + skill_to_people[bit].push(i); + } + } + } + + let mut unmet_skills: std::collections::HashSet = req_skills.iter().cloned().collect(); + let mut smallest_length = i32::MAX; + let mut current_team = vec![]; + let mut best_team = vec![]; + + fn backtrack( + skill: usize, + req_skills: &Vec, + people_mask: &Vec, + skill_to_people: &Vec>, + skill_idx: &std::collections::HashMap, + unmet_skills: &mut std::collections::HashSet, + smallest_length: &mut i32, + current_team: &mut Vec, + best_team: &mut Vec, + ) { + if unmet_skills.is_empty() { + if *smallest_length > current_team.len() as i32 { + *smallest_length = current_team.len() as i32; + *best_team = current_team.clone(); + } + return; + } + + if skill >= req_skills.len() { + return; + } + + if !unmet_skills.contains(&req_skills[skill]) { + backtrack(skill + 1, req_skills, people_mask, skill_to_people, skill_idx, unmet_skills, smallest_length, current_team, best_team); + return; + } + + for &i in &skill_to_people[skill] { + let mask = people_mask[i]; + let mut skills_added = vec![]; + for s in unmet_skills.iter() { + if (mask & (1 << skill_idx[s])) != 0 { + skills_added.push(s.clone()); + } + } + if skills_added.is_empty() { + continue; + } + + for s in &skills_added { + unmet_skills.remove(s); + } + current_team.push(i as i32); + + backtrack(skill + 1, req_skills, people_mask, skill_to_people, skill_idx, unmet_skills, smallest_length, current_team, best_team); + + current_team.pop(); + for s in skills_added { + unmet_skills.insert(s); + } + } + } + + backtrack(0, &req_skills, &people_mask, &skill_to_people, &skill_idx, &mut unmet_skills, &mut smallest_length, &mut current_team, &mut best_team); + best_team + } +} diff --git a/tests/1001-1500/1125. smallest-sufficient-team/sol.swift b/tests/1001-1500/1125. smallest-sufficient-team/sol.swift new file mode 100644 index 00000000..4adc1045 --- /dev/null +++ b/tests/1001-1500/1125. smallest-sufficient-team/sol.swift @@ -0,0 +1,34 @@ +class Solution { + func smallestSufficientTeam(_ req_skills: [String], _ people: [[String]]) -> [Int] { + let n = req_skills.count + let full = (1 << n) - 1 + var idx: [String: Int] = [:] + for (i, skill) in req_skills.enumerated() { idx[skill] = i } + + let masks = people.map { skills -> Int in + var mask = 0 + for skill in skills { mask |= 1 << idx[skill]! } + return mask + } + + var dp = Array<[Int]?>(repeating: nil, count: 1 << n) + dp[0] = [] + + for (i, pmask) in masks.enumerated() { + if pmask == 0 { continue } + var next = dp + for mask in 0...full { + guard let team = dp[mask] else { continue } + let nmask = mask | pmask + var cand = team + cand.append(i) + if next[nmask] == nil || cand.count < next[nmask]!.count { + next[nmask] = cand + } + } + dp = next + } + + return dp[full] ?? [] + } +} diff --git a/tests/1001-1500/1125. smallest-sufficient-team/sol.ts b/tests/1001-1500/1125. smallest-sufficient-team/sol.ts new file mode 100644 index 00000000..145b56db --- /dev/null +++ b/tests/1001-1500/1125. smallest-sufficient-team/sol.ts @@ -0,0 +1,86 @@ +function smallestSufficientTeam( + req_skills: string[], + people: string[][], +): number[] { + const n = req_skills.length; + const m = people.length; + + const skillIdx: Map = new Map(); + req_skills.forEach((skill, i) => skillIdx.set(skill, i)); + + const peopleMask: number[] = new Array(m).fill(0); + for (let i = 0; i < m; i++) { + let mask = 0; + for (const skill of people[i]) { + mask |= 1 << skillIdx.get(skill)!; + } + peopleMask[i] = mask; + } + + for (let i = 0; i < m; i++) { + for (let j = 0; j < m; j++) { + if ( + i !== j && + peopleMask[i] !== 0 && + (peopleMask[i] & peopleMask[j]) === peopleMask[i] + ) { + peopleMask[i] = 0; + break; + } + } + } + + const skillToPeople: number[][] = Array.from({ length: n }, () => []); + for (let i = 0; i < m; i++) { + if (peopleMask[i] === 0) continue; + for (let bit = 0; bit < n; bit++) { + if ((peopleMask[i] & (1 << bit)) !== 0) { + skillToPeople[bit].push(i); + } + } + } + + const unmetSkills: Set = new Set(req_skills); + let smallestLength = Infinity; + let currentTeam: number[] = []; + let bestTeam: number[] = []; + + function backtrack(skill: number): void { + if (unmetSkills.size === 0) { + if (smallestLength > currentTeam.length) { + smallestLength = currentTeam.length; + bestTeam = [...currentTeam]; + } + return; + } + + if (skill >= n) return; + + if (!unmetSkills.has(req_skills[skill])) { + backtrack(skill + 1); + return; + } + + for (const i of skillToPeople[skill]) { + const mask = peopleMask[i]; + const skillsAdded: string[] = []; + for (const s of unmetSkills) { + if ((mask & (1 << skillIdx.get(s)!)) !== 0) { + skillsAdded.push(s); + } + } + if (skillsAdded.length === 0) continue; + + skillsAdded.forEach((s) => unmetSkills.delete(s)); + currentTeam.push(i); + + backtrack(skill + 1); + + currentTeam.pop(); + skillsAdded.forEach((s) => unmetSkills.add(s)); + } + } + + backtrack(0); + return bestTeam; +} diff --git a/tests/1001-1500/1128. number-of-equivalent-domino-pairs/manifest.yaml b/tests/1001-1500/1128. number-of-equivalent-domino-pairs/manifest.yaml new file mode 100644 index 00000000..1217b1bf --- /dev/null +++ b/tests/1001-1500/1128. number-of-equivalent-domino-pairs/manifest.yaml @@ -0,0 +1,387 @@ +entry: + id: 1128 + title: number-of-equivalent-domino-pairs + params: + dominoes: + type: array + items: + type: array + items: + type: int + call: + cpp: "Solution().numEquivDominoPairs({dominoes})" + rust: "Solution::num_equiv_domino_pairs({dominoes})" + python3: "Solution().numEquivDominoPairs({dominoes})" + python2: "Solution().numEquivDominoPairs({dominoes})" + ruby: "num_equiv_domino_pairs({dominoes})" + java: "new Solution().numEquivDominoPairs({dominoes})" + csharp: "new Solution().NumEquivDominoPairs({dominoes})" + kotlin: "Solution().numEquivDominoPairs({dominoes})" + go: "numEquivDominoPairs({dominoes})" + dart: "Solution().numEquivDominoPairs({dominoes})" + swift: "Solution().numEquivDominoPairs({dominoes})" + typescript: "numEquivDominoPairs({dominoes})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().numEquivDominoPairs(dominoes, {result})" + checker: | + class Checker: + def numEquivDominoPairs(self, dominoes, result): + if not isinstance(result, int): + return False + count = 0 + seen = [0] * 100 + for pair in dominoes: + if not isinstance(pair, list) or len(pair) != 2: + return False + a, b = pair + if not isinstance(a, int) or not isinstance(b, int): + return False + if a < 1 or a > 9 or b < 1 or b > 9: + return False + key = a * 10 + b if a <= b else b * 10 + a + count += seen[key] + seen[key] += 1 + return result == count +seed: 1128 +tests: + - name: ex1 + in: + dominoes: + - [1, 2] + - [2, 1] + - [3, 4] + - [5, 6] + out: 1 + - name: ex2 + in: + dominoes: + - [1, 2] + - [1, 2] + - [1, 1] + - [1, 2] + - [2, 2] + out: 3 + - name: single_domino + in: + dominoes: + - [1, 1] + out: 0 + - name: two_identical + in: + dominoes: + - [1, 1] + - [1, 1] + out: 1 + - name: two_reversed + in: + dominoes: + - [2, 3] + - [3, 2] + out: 1 + - name: three_same + in: + dominoes: + - [4, 5] + - [5, 4] + - [4, 5] + out: 3 + - name: no_pairs + in: + dominoes: + - [1, 2] + - [3, 4] + - [5, 6] + out: 0 + - name: all_same_four + in: + dominoes: + - [7, 8] + - [8, 7] + - [7, 8] + - [8, 7] + out: 6 + - name: mixed_multiples + in: + dominoes: + - [1, 2] + - [2, 1] + - [1, 2] + - [3, 3] + - [3, 3] + - [3, 3] + out: 6 + - name: pair_and_single + in: + dominoes: + - [9, 1] + - [1, 9] + - [1, 1] + out: 1 + - name: cross_two_groups + in: + dominoes: + - [1, 3] + - [3, 1] + - [2, 4] + - [4, 2] + out: 2 + - name: boundary_nine + in: + dominoes: + - [9, 9] + - [9, 1] + - [1, 9] + - [9, 9] + out: 2 + - name: alternating_two_groups + in: + dominoes: + - [1, 4] + - [4, 1] + - [1, 4] + - [4, 1] + - [2, 2] + - [2, 2] + out: 7 + - name: mixed_triples + in: + dominoes: + - [2, 5] + - [5, 2] + - [5, 2] + - [6, 6] + - [6, 6] + - [1, 7] + out: 4 + - name: all_unique_ordered + in: + dominoes: + - [1, 2] + - [1, 3] + - [1, 4] + - [1, 5] + - [1, 6] + - [1, 7] + out: 0 + - name: all_unique_reversed + in: + dominoes: + - [2, 1] + - [3, 1] + - [4, 1] + - [5, 1] + - [6, 1] + - [7, 1] + out: 0 + - name: cluster_one + in: + dominoes: + - [3, 8] + - [8, 3] + - [3, 8] + - [3, 8] + - [2, 9] + - [9, 2] + out: 7 + - name: cluster_two + in: + dominoes: + - [4, 4] + - [4, 4] + - [4, 4] + - [4, 4] + - [5, 6] + - [6, 5] + out: 7 + - name: symmetric_mix + in: + dominoes: + - [1, 8] + - [8, 1] + - [2, 7] + - [7, 2] + - [3, 6] + - [6, 3] + out: 3 + - name: repeated_fives + in: + dominoes: + - [5, 5] + - [5, 5] + - [5, 5] + - [5, 5] + - [5, 5] + out: 10 + - name: repeated_nines + in: + dominoes: + - [9, 9] + - [9, 9] + - [9, 9] + - [9, 9] + out: 6 + - name: ascending_chain + in: + dominoes: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 5] + - [5, 6] + - [6, 7] + out: 0 + - name: descending_chain + in: + dominoes: + - [2, 1] + - [3, 2] + - [4, 3] + - [5, 4] + - [6, 5] + - [7, 6] + out: 0 + - name: one_pair_one_noise + in: + dominoes: + - [2, 9] + - [9, 2] + - [2, 3] + - [4, 5] + out: 1 + - name: two_pairs_separate + in: + dominoes: + - [1, 6] + - [6, 1] + - [2, 7] + - [7, 2] + - [8, 9] + out: 2 + - name: three_pairs_separate + in: + dominoes: + - [1, 9] + - [9, 1] + - [2, 8] + - [8, 2] + - [3, 7] + - [7, 3] + out: 3 + - name: four_pair_groups + in: + dominoes: + - [1, 4] + - [4, 1] + - [2, 5] + - [5, 2] + - [3, 6] + - [6, 3] + - [7, 7] + - [7, 7] + out: 4 + - name: all_same_pair_value + in: + dominoes: + - [8, 2] + - [2, 8] + - [8, 2] + - [2, 8] + - [8, 2] + out: 10 + - name: mixed_with_double + in: + dominoes: + - [1, 1] + - [1, 1] + - [1, 2] + - [2, 1] + - [3, 3] + - [3, 3] + out: 3 + - name: many_twos_and_threes + in: + dominoes: + - [2, 3] + - [3, 2] + - [2, 3] + - [3, 2] + - [2, 3] + - [4, 4] + - [4, 4] + out: 11 + - name: generated_small_a + in: + dominoes: + gen: array + len: 24 + of: + gen: array + len: 2 + of: + gen: int + min: 1 + max: 9 + elemType: int + elemType: int + - name: generated_small_b + in: + dominoes: + gen: array + len: 37 + of: + gen: array + len: 2 + of: + gen: int + min: 1 + max: 9 + elemType: int + elemType: int + - name: generated_large_a + in: + dominoes: + gen: array + len: 40000 + of: + gen: array + len: 2 + of: + gen: int + min: 1 + max: 9 + elemType: int + elemType: int + - name: generated_large_b + in: + dominoes: + gen: array + len: 39999 + of: + gen: array + len: 2 + of: + gen: int + min: 1 + max: 9 + elemType: int + elemType: int + - name: generated_large_c + in: + dominoes: + gen: array + len: 20000 + of: + gen: array + len: 2 + of: + gen: int + min: 1 + max: 9 + elemType: int + elemType: int diff --git a/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.cpp b/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.cpp new file mode 100644 index 00000000..6c473e26 --- /dev/null +++ b/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.cpp @@ -0,0 +1,14 @@ +class Solution { +public: + int numEquivDominoPairs(vector>& dominoes) { + int mpp[100] = {0}; + int count = 0; + for (auto& d : dominoes) { + int a = d[0], b = d[1]; + int key = a <= b ? a * 10 + b : b * 10 + a; + count += mpp[key]; + mpp[key]++; + } + return count; + } +}; diff --git a/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.cs b/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.cs new file mode 100644 index 00000000..8ab0ef85 --- /dev/null +++ b/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.cs @@ -0,0 +1,13 @@ +public class Solution { + public int NumEquivDominoPairs(int[][] dominoes) { + int[] mpp = new int[100]; + int count = 0; + foreach (int[] d in dominoes) { + int a = d[0], b = d[1]; + int key = a <= b ? a * 10 + b : b * 10 + a; + count += mpp[key]; + mpp[key]++; + } + return count; + } +} diff --git a/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.dart b/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.dart new file mode 100644 index 00000000..bf70f20f --- /dev/null +++ b/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.dart @@ -0,0 +1,13 @@ +class Solution { + int numEquivDominoPairs(List> dominoes) { + var mpp = List.filled(100, 0); + int count = 0; + for (var d in dominoes) { + int a = d[0], b = d[1]; + int key = a <= b ? a * 10 + b : b * 10 + a; + count += mpp[key]; + mpp[key]++; + } + return count; + } +} diff --git a/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.go b/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.go new file mode 100644 index 00000000..47102d32 --- /dev/null +++ b/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.go @@ -0,0 +1,14 @@ +func numEquivDominoPairs(dominoes [][]int) int { + mpp := make([]int, 100) + count := 0 + for _, d := range dominoes { + a, b := d[0], d[1] + key := a*10 + b + if a > b { + key = b*10 + a + } + count += mpp[key] + mpp[key]++ + } + return count +} diff --git a/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.java b/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.java new file mode 100644 index 00000000..3936e10a --- /dev/null +++ b/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.java @@ -0,0 +1,13 @@ +class Solution { + public int numEquivDominoPairs(int[][] dominoes) { + int[] mpp = new int[100]; + int count = 0; + for (int[] d : dominoes) { + int a = d[0], b = d[1]; + int key = a <= b ? a * 10 + b : b * 10 + a; + count += mpp[key]; + mpp[key]++; + } + return count; + } +} diff --git a/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.kt b/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.kt new file mode 100644 index 00000000..a4ff2fd6 --- /dev/null +++ b/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.kt @@ -0,0 +1,14 @@ +class Solution { + fun numEquivDominoPairs(dominoes: Array): Int { + val mpp = IntArray(100) + var count = 0 + for (d in dominoes) { + val a = d[0] + val b = d[1] + val key = if (a <= b) a * 10 + b else b * 10 + a + count += mpp[key] + mpp[key]++ + } + return count + } +} diff --git a/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.py b/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.py new file mode 100644 index 00000000..04d5b067 --- /dev/null +++ b/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.py @@ -0,0 +1,9 @@ +class Solution(object): + def numEquivDominoPairs(self, dominoes): + mpp = [0] * 100 + count = 0 + for a, b in dominoes: + key = a * 10 + b if a <= b else b * 10 + a + count += mpp[key] + mpp[key] += 1 + return count diff --git a/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.py2 b/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.py2 new file mode 100644 index 00000000..7f4930a6 --- /dev/null +++ b/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.py2 @@ -0,0 +1,13 @@ +class Solution(object): + def numEquivDominoPairs(self, dominoes): + """ + :type dominoes: List[List[int]] + :rtype: int + """ + mpp = [0] * 100 + count = 0 + for a, b in dominoes: + key = a * 10 + b if a <= b else b * 10 + a + count += mpp[key] + mpp[key] += 1 + return count diff --git a/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.rb b/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.rb new file mode 100644 index 00000000..b8821e52 --- /dev/null +++ b/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.rb @@ -0,0 +1,12 @@ +# @param {Integer[][]} dominoes +# @return {Integer} +def num_equiv_domino_pairs(dominoes) + mpp = Array.new(100, 0) + count = 0 + dominoes.each do |a, b| + key = a <= b ? a * 10 + b : b * 10 + a + count += mpp[key] + mpp[key] += 1 + end + count +end diff --git a/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.rs b/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.rs new file mode 100644 index 00000000..fcc275ca --- /dev/null +++ b/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.rs @@ -0,0 +1,14 @@ +impl Solution { + pub fn num_equiv_domino_pairs(dominoes: Vec>) -> i32 { + let mut mpp = vec![0; 100]; + let mut count = 0; + for d in dominoes { + let a = d[0]; + let b = d[1]; + let key = if a <= b { a * 10 + b } else { b * 10 + a }; + count += mpp[key as usize]; + mpp[key as usize] += 1; + } + count + } +} diff --git a/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.swift b/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.swift new file mode 100644 index 00000000..c1755fad --- /dev/null +++ b/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.swift @@ -0,0 +1,13 @@ +class Solution { + func numEquivDominoPairs(_ dominoes: [[Int]]) -> Int { + var mpp = Array(repeating: 0, count: 100) + var count = 0 + for d in dominoes { + let a = d[0], b = d[1] + let key = a <= b ? a * 10 + b : b * 10 + a + count += mpp[key] + mpp[key] += 1 + } + return count + } +} diff --git a/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.ts b/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.ts new file mode 100644 index 00000000..841a4dc5 --- /dev/null +++ b/tests/1001-1500/1128. number-of-equivalent-domino-pairs/sol.ts @@ -0,0 +1,10 @@ +function numEquivDominoPairs(dominoes: number[][]): number { + const mpp = new Array(100).fill(0); + let count = 0; + for (const [a, b] of dominoes) { + const key = a <= b ? a * 10 + b : b * 10 + a; + count += mpp[key]; + mpp[key]++; + } + return count; +} diff --git a/tests/1001-1500/1129. shortest-path-with-alternating-colors/manifest.yaml b/tests/1001-1500/1129. shortest-path-with-alternating-colors/manifest.yaml new file mode 100644 index 00000000..1345e90c --- /dev/null +++ b/tests/1001-1500/1129. shortest-path-with-alternating-colors/manifest.yaml @@ -0,0 +1,673 @@ +entry: + id: 1129 + title: shortest-path-with-alternating-colors + params: + n: + type: int + redEdges: + type: array + items: + type: array + items: + type: int + blueEdges: + type: array + items: + type: array + items: + type: int + call: + cpp: Solution().shortestAlternatingPaths({n}, {redEdges}, {blueEdges}) + rust: Solution::shortest_alternating_paths({n}, {redEdges}, {blueEdges}) + python3: Solution().shortestAlternatingPaths({n}, {redEdges}, {blueEdges}) + python2: Solution().shortestAlternatingPaths({n}, {redEdges}, {blueEdges}) + ruby: shortest_alternating_paths({n}, {redEdges}, {blueEdges}) + java: new Solution().shortestAlternatingPaths({n}, {redEdges}, {blueEdges}) + csharp: new Solution().ShortestAlternatingPaths({n}, {redEdges}, {blueEdges}) + kotlin: Solution().shortestAlternatingPaths({n}, {redEdges}, {blueEdges}) + go: shortestAlternatingPaths({n}, {redEdges}, {blueEdges}) + dart: Solution().shortestAlternatingPaths({n}, {redEdges}, {blueEdges}) + swift: Solution().shortestAlternatingPaths({n}, {redEdges}, {blueEdges}) + typescript: shortestAlternatingPaths({n}, {redEdges}, {blueEdges}) +judge: + type: exact +limits: + time_ms: 1500 + memory_mb: 256 +oracle: + python3: + call: Checker().shortestAlternatingPaths(n, redEdges, blueEdges, {result}) + checker: + "import collections\nclass Checker:\n def shortestAlternatingPaths(self,\ + \ n, redEdges, blueEdges, result):\n if not isinstance(result, list)\ + \ or len(result) != n:\n return False\n RED, BLUE = 0, 1\n\ + \ graph = [[[] for _ in range(n)] for _ in range(2)]\n for u,\ + \ v in redEdges:\n graph[RED][u].append(v)\n for u, v in blueEdges:\n\ + \ graph[BLUE][u].append(v)\n dist = [[-1] * n for _ in range(2)]\n\ + \ q = collections.deque([(0, RED), (0, BLUE)])\n dist[RED][0]\ + \ = 0\n dist[BLUE][0] = 0\n while q:\n node, last =\ + \ q.popleft()\n nxt = 1 - last\n for nei in graph[nxt][node]:\n\ + \ if dist[nxt][nei] == -1:\n dist[nxt][nei]\ + \ = dist[last][node] + 1\n q.append((nei, nxt))\n \ + \ expected = []\n for i in range(n):\n a, b = dist[RED][i],\ + \ dist[BLUE][i]\n if a == -1 or (b != -1 and b < a):\n \ + \ expected.append(b)\n else:\n expected.append(a)\n\ + \ return result == expected\n" +seed: 1129 +tests: + - name: ex1 + in: + n: 3 + redEdges: + elemType: int + value: + - - 0 + - 1 + - - 1 + - 2 + blueEdges: + elemType: int + value: [] + - name: ex2 + in: + n: 3 + redEdges: + elemType: int + value: + - - 0 + - 1 + blueEdges: + elemType: int + value: + - - 2 + - 1 + - name: ex3 + in: + n: 3 + redEdges: + elemType: int + value: + - - 1 + - 0 + blueEdges: + elemType: int + value: + - - 2 + - 1 + - name: ex4 + in: + n: 3 + redEdges: + elemType: int + value: + - - 0 + - 1 + blueEdges: + elemType: int + value: + - - 1 + - 2 + - name: single + in: + n: 1 + redEdges: + elemType: int + value: [] + blueEdges: + elemType: int + value: [] + - name: two_red + in: + n: 2 + redEdges: + elemType: int + value: + - - 0 + - 1 + blueEdges: + elemType: int + value: [] + - name: two_blue + in: + n: 2 + redEdges: + elemType: int + value: [] + blueEdges: + elemType: int + value: + - - 0 + - 1 + - name: parallel_both + in: + n: 2 + redEdges: + elemType: int + value: + - - 0 + - 1 + blueEdges: + elemType: int + value: + - - 0 + - 1 + - name: cycle_small + in: + n: 3 + redEdges: + elemType: int + value: + - - 0 + - 1 + - - 1 + - 2 + blueEdges: + elemType: int + value: + - - 2 + - 0 + - name: alt_cycle + in: + n: 4 + redEdges: + elemType: int + value: + - - 0 + - 1 + - - 2 + - 3 + blueEdges: + elemType: int + value: + - - 1 + - 2 + - - 3 + - 0 + - name: unreachable + in: + n: 4 + redEdges: + elemType: int + value: + - - 1 + - 2 + blueEdges: + elemType: int + value: + - - 2 + - 3 + - name: red_chain + in: + n: 5 + redEdges: + elemType: int + value: + - - 0 + - 1 + - - 1 + - 2 + - - 2 + - 3 + - - 3 + - 4 + blueEdges: + elemType: int + value: [] + - name: blue_chain + in: + n: 5 + redEdges: + elemType: int + value: [] + blueEdges: + elemType: int + value: + - - 0 + - 1 + - - 1 + - 2 + - - 2 + - 3 + - - 3 + - 4 + - name: perfect_alt + in: + n: 5 + redEdges: + elemType: int + value: + - - 0 + - 1 + - - 2 + - 3 + blueEdges: + elemType: int + value: + - - 1 + - 2 + - - 3 + - 4 + - name: branch_red + in: + n: 5 + redEdges: + elemType: int + value: + - - 0 + - 1 + - - 0 + - 2 + - - 2 + - 3 + blueEdges: + elemType: int + value: + - - 1 + - 3 + - - 3 + - 4 + - name: branch_blue + in: + n: 5 + redEdges: + elemType: int + value: + - - 1 + - 3 + - - 3 + - 4 + blueEdges: + elemType: int + value: + - - 0 + - 1 + - - 0 + - 2 + - - 2 + - 3 + - name: self_loops + in: + n: 3 + redEdges: + elemType: int + value: + - - 0 + - 0 + - - 0 + - 1 + blueEdges: + elemType: int + value: + - - 1 + - 1 + - - 1 + - 2 + - name: double_edges + in: + n: 4 + redEdges: + elemType: int + value: + - - 0 + - 1 + - - 0 + - 1 + - - 2 + - 3 + blueEdges: + elemType: int + value: + - - 1 + - 2 + - - 1 + - 2 + - name: cross_edges + in: + n: 4 + redEdges: + elemType: int + value: + - - 0 + - 2 + - - 1 + - 3 + blueEdges: + elemType: int + value: + - - 0 + - 1 + - - 2 + - 3 + - name: back_edges + in: + n: 4 + redEdges: + elemType: int + value: + - - 0 + - 1 + - - 2 + - 1 + blueEdges: + elemType: int + value: + - - 1 + - 2 + - - 1 + - 3 + - name: dense_4 + in: + n: 4 + redEdges: + elemType: int + value: + - - 0 + - 1 + - - 0 + - 2 + - - 1 + - 2 + - - 2 + - 3 + blueEdges: + elemType: int + value: + - - 0 + - 3 + - - 1 + - 3 + - - 2 + - 1 + - name: sparse_6 + in: + n: 6 + redEdges: + elemType: int + value: + - - 0 + - 1 + - - 4 + - 5 + blueEdges: + elemType: int + value: + - - 1 + - 2 + - - 2 + - 3 + - name: reach_last_only + in: + n: 6 + redEdges: + elemType: int + value: + - - 0 + - 2 + - - 2 + - 4 + blueEdges: + elemType: int + value: + - - 4 + - 5 + - name: all_colors_needed + in: + n: 6 + redEdges: + elemType: int + value: + - - 0 + - 1 + - - 2 + - 3 + - - 4 + - 5 + blueEdges: + elemType: int + value: + - - 1 + - 2 + - - 3 + - 4 + - name: many_options + in: + n: 6 + redEdges: + elemType: int + value: + - - 0 + - 1 + - - 0 + - 3 + - - 2 + - 5 + - - 4 + - 5 + blueEdges: + elemType: int + value: + - - 1 + - 2 + - - 3 + - 4 + - - 1 + - 4 + - name: diamond + in: + n: 5 + redEdges: + elemType: int + value: + - - 0 + - 1 + - - 0 + - 2 + - - 3 + - 4 + blueEdges: + elemType: int + value: + - - 1 + - 3 + - - 2 + - 3 + - name: zigzag + in: + n: 7 + redEdges: + elemType: int + value: + - - 0 + - 1 + - - 2 + - 3 + - - 4 + - 5 + blueEdges: + elemType: int + value: + - - 1 + - 2 + - - 3 + - 4 + - - 5 + - 6 + - name: mixed_shortcuts + in: + n: 7 + redEdges: + elemType: int + value: + - - 0 + - 2 + - - 2 + - 4 + - - 1 + - 3 + blueEdges: + elemType: int + value: + - - 0 + - 1 + - - 1 + - 5 + - - 5 + - 6 + - - 4 + - 6 + - name: isolated_zero_only + in: + n: 5 + redEdges: + elemType: int + value: + - - 1 + - 2 + - - 2 + - 3 + blueEdges: + elemType: int + value: + - - 3 + - 4 + - name: return_edge + in: + n: 5 + redEdges: + elemType: int + value: + - - 0 + - 1 + - - 2 + - 1 + blueEdges: + elemType: int + value: + - - 1 + - 2 + - - 1 + - 0 + - name: two_components + in: + n: 8 + redEdges: + elemType: int + value: + - - 0 + - 1 + - - 1 + - 2 + - - 5 + - 6 + blueEdges: + elemType: int + value: + - - 2 + - 3 + - - 6 + - 7 + - name: alt_needed_long + in: + n: 8 + redEdges: + elemType: int + value: + - - 0 + - 1 + - - 2 + - 3 + - - 4 + - 5 + - - 6 + - 7 + blueEdges: + elemType: int + value: + - - 1 + - 2 + - - 3 + - 4 + - - 5 + - 6 + - name: blue_start_better + in: + n: 5 + redEdges: + elemType: int + value: + - - 1 + - 2 + - - 2 + - 4 + blueEdges: + elemType: int + value: + - - 0 + - 1 + - - 1 + - 3 + - - 3 + - 4 + - name: red_start_better + in: + n: 5 + redEdges: + elemType: int + value: + - - 0 + - 1 + - - 1 + - 3 + - - 3 + - 4 + blueEdges: + elemType: int + value: + - - 1 + - 2 + - - 2 + - 4 + - name: duplicate_mix + in: + n: 5 + redEdges: + elemType: int + value: + - - 0 + - 1 + - - 0 + - 1 + - - 2 + - 3 + - - 2 + - 3 + blueEdges: + elemType: int + value: + - - 1 + - 2 + - - 1 + - 2 + - - 3 + - 4 + - name: self_and_path + in: + n: 5 + redEdges: + elemType: int + value: + - - 0 + - 0 + - - 0 + - 1 + - - 2 + - 2 + blueEdges: + elemType: int + value: + - - 1 + - 2 + - - 2 + - 3 + - - 3 + - 4 diff --git a/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.cpp b/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.cpp new file mode 100644 index 00000000..900b0010 --- /dev/null +++ b/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.cpp @@ -0,0 +1,35 @@ +class Solution { +public: + vector shortestAlternatingPaths(int n, vector>& redEdges, vector>& blueEdges) { + vector ans(n, -1); + vector>> graph(n); // (v, color): 1-red, 2-blue + queue> q; // (node, prevColor): 0-init, 1-red, 2-blue + q.push({0, 0}); + + for (auto& edge : redEdges) { + graph[edge[0]].push_back({edge[1], 1}); + } + for (auto& edge : blueEdges) { + graph[edge[0]].push_back({edge[1], 2}); + } + + int step = 0; + while (!q.empty()) { + int size = q.size(); + for (int i = 0; i < size; i++) { + auto [u, prevColor] = q.front(); + q.pop(); + if (ans[u] == -1) { + ans[u] = step; + } + for (auto& [v, edgeColor] : graph[u]) { + if (v == -1 || edgeColor == prevColor) continue; + q.push({v, edgeColor}); + v = -1; + } + } + step++; + } + return ans; + } +}; diff --git a/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.cs b/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.cs new file mode 100644 index 00000000..b26be082 --- /dev/null +++ b/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.cs @@ -0,0 +1,41 @@ +public class Solution { + public int[] ShortestAlternatingPaths(int n, int[][] redEdges, int[][] blueEdges) { + int[] ans = new int[n]; + Array.Fill(ans, -1); + + List<(int, int)>[] graph = new List<(int, int)>[n]; + for (int i = 0; i < n; i++) { + graph[i] = new List<(int, int)>(); + } + + foreach (var edge in redEdges) { + graph[edge[0]].Add((edge[1], 1)); // 1-red + } + foreach (var edge in blueEdges) { + graph[edge[0]].Add((edge[1], 2)); // 2-blue + } + + Queue<(int, int)> q = new Queue<(int, int)>(); + q.Enqueue((0, 0)); // (node, prevColor): 0-init, 1-red, 2-blue + + int step = 0; + while (q.Count > 0) { + int size = q.Count; + for (int i = 0; i < size; i++) { + var (u, prevColor) = q.Dequeue(); + if (ans[u] == -1) { + ans[u] = step; + } + var neighbors = graph[u]; + for (int j = 0; j < neighbors.Count; j++) { + var (v, edgeColor) = neighbors[j]; + if (v == -1 || edgeColor == prevColor) continue; + q.Enqueue((v, edgeColor)); + neighbors[j] = (-1, edgeColor); + } + } + step++; + } + return ans; + } +} diff --git a/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.dart b/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.dart new file mode 100644 index 00000000..49040167 --- /dev/null +++ b/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.dart @@ -0,0 +1,36 @@ +class Solution { + List shortestAlternatingPaths(int n, List> redEdges, List> blueEdges) { + List ans = List.filled(n, -1); + List>> graph = List.generate(n, (_) => []); + + for (var edge in redEdges) { + graph[edge[0]].add([edge[1], 1]); // 1-red + } + for (var edge in blueEdges) { + graph[edge[0]].add([edge[1], 2]); // 2-blue + } + + List> q = [[0, 0]]; // [node, prevColor] + int step = 0; + + while (q.isNotEmpty) { + int size = q.length; + for (int i = 0; i < size; i++) { + var cur = q.removeAt(0); + int u = cur[0], prevColor = cur[1]; + if (ans[u] == -1) { + ans[u] = step; + } + var neighbors = graph[u]; + for (int j = 0; j < neighbors.length; j++) { + int v = neighbors[j][0], edgeColor = neighbors[j][1]; + if (v == -1 || edgeColor == prevColor) continue; + q.add([v, edgeColor]); + neighbors[j][0] = -1; + } + } + step++; + } + return ans; + } +} diff --git a/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.go b/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.go new file mode 100644 index 00000000..1f59563e --- /dev/null +++ b/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.go @@ -0,0 +1,46 @@ +func shortestAlternatingPaths(n int, redEdges [][]int, blueEdges [][]int) []int { + ans := make([]int, n) + for i := range ans { + ans[i] = -1 + } + + type edge struct { + v int + color int // 1-red, 2-blue + } + graph := make([][]edge, n) + for _, e := range redEdges { + graph[e[0]] = append(graph[e[0]], edge{e[1], 1}) + } + for _, e := range blueEdges { + graph[e[0]] = append(graph[e[0]], edge{e[1], 2}) + } + + type node struct { + u int + prevColor int + } + q := []node{{0, 0}} + step := 0 + + for len(q) > 0 { + size := len(q) + for i := 0; i < size; i++ { + cur := q[0] + q = q[1:] + if ans[cur.u] == -1 { + ans[cur.u] = step + } + for j := range graph[cur.u] { + e := graph[cur.u][j] + if e.v == -1 || e.color == cur.prevColor { + continue + } + q = append(q, node{e.v, e.color}) + graph[cur.u][j].v = -1 + } + } + step++ + } + return ans +} diff --git a/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.java b/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.java new file mode 100644 index 00000000..677979d9 --- /dev/null +++ b/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.java @@ -0,0 +1,43 @@ +class Solution { + public int[] shortestAlternatingPaths(int n, int[][] redEdges, int[][] blueEdges) { + int[] ans = new int[n]; + Arrays.fill(ans, -1); + + List> graph = new ArrayList<>(); + for (int i = 0; i < n; i++) { + graph.add(new ArrayList<>()); + } + + for (int[] edge : redEdges) { + graph.get(edge[0]).add(new int[]{edge[1], 1}); // 1-red + } + for (int[] edge : blueEdges) { + graph.get(edge[0]).add(new int[]{edge[1], 2}); // 2-blue + } + + Queue q = new LinkedList<>(); + q.offer(new int[]{0, 0}); // {node, prevColor} + + int step = 0; + while (!q.isEmpty()) { + int size = q.size(); + for (int i = 0; i < size; i++) { + int[] cur = q.poll(); + int u = cur[0], prevColor = cur[1]; + if (ans[u] == -1) { + ans[u] = step; + } + List neighbors = graph.get(u); + for (int j = 0; j < neighbors.size(); j++) { + int[] pair = neighbors.get(j); + int v = pair[0], edgeColor = pair[1]; + if (v == -1 || edgeColor == prevColor) continue; + q.offer(new int[]{v, edgeColor}); + neighbors.set(j, new int[]{-1, edgeColor}); + } + } + step++; + } + return ans; + } +} diff --git a/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.kt b/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.kt new file mode 100644 index 00000000..3e36a32c --- /dev/null +++ b/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.kt @@ -0,0 +1,34 @@ +class Solution { + fun shortestAlternatingPaths(n: Int, redEdges: Array, blueEdges: Array): IntArray { + val ans = IntArray(n) { -1 } + val graph = Array(n) { mutableListOf>() } + val q: java.util.Queue> = java.util.LinkedList() + q.offer(Pair(0, 0)) // (node, prevColor): 0-init, 1-red, 2-blue + + for ((u, v) in redEdges) { + graph[u].add(Pair(v, 1)) + } + for ((u, v) in blueEdges) { + graph[u].add(Pair(v, 2)) + } + + var step = 0 + while (q.isNotEmpty()) { + repeat(q.size) { + val (u, prevColor) = q.poll() + if (ans[u] == -1) { + ans[u] = step + } + val neighbors = graph[u] + for (i in neighbors.indices) { + val (v, edgeColor) = neighbors[i] + if (v == -1 || edgeColor == prevColor) continue + q.offer(Pair(v, edgeColor)) + neighbors[i] = Pair(-1, edgeColor) + } + } + step++ + } + return ans + } +} diff --git a/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.py b/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.py new file mode 100644 index 00000000..67ad8402 --- /dev/null +++ b/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.py @@ -0,0 +1,40 @@ +import collections +from typing import List + +from enum import Enum + + +class Color(Enum): + kInit = 0 + kRed = 1 + kBlue = 2 + + +class Solution: + def shortestAlternatingPaths( + self, n: int, redEdges: List[List[int]], blueEdges: List[List[int]] + ) -> List[int]: + ans = [-1] * n + graph = [[] for _ in range(n)] # graph[u] := [(v, edgeColor)] + q = collections.deque([(0, Color.kInit)]) # [(u, prevColor)] + + for u, v in redEdges: + graph[u].append((v, Color.kRed)) + + for u, v in blueEdges: + graph[u].append((v, Color.kBlue)) + + step = 0 + while q: + for _ in range(len(q)): + u, prevColor = q.popleft() + if ans[u] == -1: + ans[u] = step + for i, (v, edgeColor) in enumerate(graph[u]): + if v == -1 or edgeColor == prevColor: + continue + q.append((v, edgeColor)) + graph[u][i] = (-1, edgeColor) # Mark (u, v) as used. + step += 1 + + return ans diff --git a/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.py2 b/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.py2 new file mode 100644 index 00000000..dceb257d --- /dev/null +++ b/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.py2 @@ -0,0 +1,30 @@ +class Solution(object): + def shortestAlternatingPaths(self, n, redEdges, blueEdges): + """ + :type n: int + :type redEdges: List[List[int]] + :type blueEdges: List[List[int]] + :rtype: List[int] + """ + ans = [-1] * n + graph = [[] for _ in range(n)] + q = collections.deque([(0, 0)]) # (node, prevColor): 0-init, 1-red, 2-blue + + for u, v in redEdges: + graph[u].append((v, 1)) + for u, v in blueEdges: + graph[u].append((v, 2)) + + step = 0 + while q: + for _ in range(len(q)): + u, prevColor = q.popleft() + if ans[u] == -1: + ans[u] = step + for i, (v, edgeColor) in enumerate(graph[u]): + if v == -1 or edgeColor == prevColor: + continue + q.append((v, edgeColor)) + graph[u][i] = (-1, edgeColor) + step += 1 + return ans diff --git a/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.rb b/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.rb new file mode 100644 index 00000000..209736da --- /dev/null +++ b/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.rb @@ -0,0 +1,29 @@ +# @param {Integer} n +# @param {Integer[][]} red_edges +# @param {Integer[][]} blue_edges +# @return {Integer[]} +def shortest_alternating_paths(n, red_edges, blue_edges) + ans = Array.new(n, -1) + graph = Array.new(n) { [] } + q = [[0, 0]] # [node, prevColor]: 0-init, 1-red, 2-blue + + red_edges.each { |u, v| graph[u] << [v, 1] } + blue_edges.each { |u, v| graph[u] << [v, 2] } + + step = 0 + while !q.empty? + q.size.times do + u, prev_color = q.shift + if ans[u] == -1 + ans[u] = step + end + graph[u].each_with_index do |(v, edge_color), i| + next if v == -1 || edge_color == prev_color + q << [v, edge_color] + graph[u][i] = [-1, edge_color] + end + end + step += 1 + end + ans +end diff --git a/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.rs b/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.rs new file mode 100644 index 00000000..0c394041 --- /dev/null +++ b/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.rs @@ -0,0 +1,38 @@ +impl Solution { + pub fn shortest_alternating_paths(n: i32, red_edges: Vec>, blue_edges: Vec>) -> Vec { + let n = n as usize; + let mut ans = vec![-1; n]; + let mut graph: Vec> = vec![Vec::new(); n]; + let mut q = std::collections::VecDeque::new(); + q.push_back((0i32, 0i32)); // (node, prevColor): 0-init, 1-red, 2-blue + + for edge in &red_edges { + graph[edge[0] as usize].push((edge[1], 1)); + } + for edge in &blue_edges { + graph[edge[0] as usize].push((edge[1], 2)); + } + + let mut step = 0; + while !q.is_empty() { + let size = q.len(); + for _ in 0..size { + let (u, prev_color) = q.pop_front().unwrap(); + let uu = u as usize; + if ans[uu] == -1 { + ans[uu] = step; + } + for i in 0..graph[uu].len() { + let (v, edge_color) = graph[uu][i]; + if v == -1 || edge_color == prev_color { + continue; + } + q.push_back((v, edge_color)); + graph[uu][i] = (-1, edge_color); + } + } + step += 1; + } + ans + } +} diff --git a/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.swift b/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.swift new file mode 100644 index 00000000..632ee8c8 --- /dev/null +++ b/tests/1001-1500/1129. shortest-path-with-alternating-colors/sol.swift @@ -0,0 +1,33 @@ +class Solution { + func shortestAlternatingPaths(_ n: Int, _ redEdges: [[Int]], _ blueEdges: [[Int]]) -> [Int] { + var ans = Array(repeating: -1, count: n) + var graph = Array(repeating: [(Int, Int)](), count: n) + var q: [(Int, Int)] = [(0, 0)] // (node, prevColor): 0-init, 1-red, 2-blue + + for edge in redEdges { + graph[edge[0]].append((edge[1], 1)) + } + for edge in blueEdges { + graph[edge[0]].append((edge[1], 2)) + } + + var step = 0 + while !q.isEmpty { + let size = q.count + for _ in 0.. []); + const q: [number, number][] = [[0, 0]]; // [node, prevColor]: 0-init, 1-red, 2-blue + + for (const [u, v] of redEdges) { + graph[u].push([v, 1]); + } + for (const [u, v] of blueEdges) { + graph[u].push([v, 2]); + } + + let step = 0; + while (q.length > 0) { + const size = q.length; + for (let i = 0; i < size; i++) { + const [u, prevColor] = q.shift()!; + if (ans[u] === -1) { + ans[u] = step; + } + const neighbors = graph[u]; + for (let j = 0; j < neighbors.length; j++) { + const [v, edgeColor] = neighbors[j]; + if (v === -1 || edgeColor === prevColor) continue; + q.push([v, edgeColor]); + neighbors[j] = [-1, edgeColor]; + } + } + step++; + } + return ans; +} diff --git a/tests/501-1000/1000. minimum-cost-to-merge-stones/manifest.yaml b/tests/501-1000/1000. minimum-cost-to-merge-stones/manifest.yaml new file mode 100644 index 00000000..3e9c2295 --- /dev/null +++ b/tests/501-1000/1000. minimum-cost-to-merge-stones/manifest.yaml @@ -0,0 +1,361 @@ +entry: + id: 1000 + title: minimum-cost-to-merge-stones + params: + stones: + type: array + items: + type: int + k: + type: int + call: + cpp: Solution().mergeStones({stones}, {k}) + rust: Solution::merge_stones({stones}, {k}) + python3: Solution().mergeStones({stones}, {k}) + python2: Solution().mergeStones({stones}, {k}) + ruby: merge_stones({stones}, {k}) + java: new Solution().mergeStones({stones}, {k}) + csharp: new Solution().MergeStones({stones}, {k}) + kotlin: Solution().mergeStones({stones}, {k}) + go: mergeStones({stones}, {k}) + dart: Solution().mergeStones({stones}, {k}) + swift: Solution().mergeStones({stones}, {k}) + typescript: mergeStones({stones}, {k}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 1000 +tests: + - name: case_1 + in: + stones: + - 11 + - 15 + - 2 + - 1 + - 7 + - 5 + - 6 + - 10 + k: 3 + out: -1 + - name: case_2 + in: + stones: + - 9 + k: 5 + out: 0 + - name: case_3 + in: + stones: + - 2 + - 3 + - 12 + - 10 + - 9 + k: 5 + out: 36 + - name: case_4 + in: + stones: + - 14 + - 14 + - 13 + - 4 + - 4 + - 7 + - 13 + - 14 + k: 5 + out: -1 + - name: case_5 + in: + stones: + - 15 + - 3 + - 11 + - 9 + - 7 + - 2 + - 10 + - 2 + k: 5 + out: -1 + - name: case_6 + in: + stones: + - 1 + - 10 + k: 5 + out: -1 + - name: case_7 + in: + stones: + - 14 + - 8 + k: 3 + out: -1 + - name: case_8 + in: + stones: + - 11 + - 9 + - 8 + k: 4 + out: -1 + - name: case_9 + in: + stones: + - 5 + - 2 + - 5 + - 8 + - 13 + - 13 + - 13 + k: 3 + out: 104 + - name: case_10 + in: + stones: + - 3 + - 6 + - 12 + - 4 + k: 2 + out: 50 + - name: case_11 + in: + stones: + - 12 + - 8 + - 4 + - 4 + - 14 + - 7 + - 4 + k: 2 + out: 141 + - name: case_12 + in: + stones: + - 7 + - 2 + - 14 + - 5 + k: 4 + out: 28 + - name: case_13 + in: + stones: + - 6 + - 10 + - 14 + - 9 + - 2 + - 6 + - 7 + - 6 + k: 2 + out: 174 + - name: case_14 + in: + stones: + - 8 + - 13 + - 15 + - 14 + - 15 + - 1 + k: 2 + out: 169 + - name: case_15 + in: + stones: + - 13 + k: 5 + out: 0 + - name: case_16 + in: + stones: + - 7 + - 13 + - 1 + k: 4 + out: -1 + - name: case_17 + in: + stones: + - 15 + - 4 + - 7 + k: 2 + out: 37 + - name: case_18 + in: + stones: + - 15 + - 7 + - 9 + - 13 + k: 5 + out: -1 + - name: case_19 + in: + stones: + - 13 + k: 5 + out: 0 + - name: case_20 + in: + stones: + - 13 + - 1 + - 6 + k: 3 + out: 20 + - name: case_21 + in: + stones: + - 10 + - 10 + - 8 + - 14 + - 12 + - 15 + k: 4 + out: -1 + - name: case_22 + in: + stones: + - 3 + - 2 + - 2 + - 15 + - 15 + - 3 + - 12 + k: 3 + out: 89 + - name: case_23 + in: + stones: + - 8 + - 8 + - 13 + - 14 + k: 2 + out: 86 + - name: case_24 + in: + stones: + - 2 + - 12 + k: 3 + out: -1 + - name: case_25 + in: + stones: + - 12 + - 9 + k: 5 + out: -1 + - name: case_26 + in: + stones: + - 10 + - 6 + - 2 + - 4 + - 12 + - 1 + - 10 + - 11 + k: 4 + out: -1 + - name: case_27 + in: + stones: + - 12 + - 8 + - 2 + k: 3 + out: 22 + - name: case_28 + in: + stones: + - 15 + - 2 + - 9 + - 13 + - 13 + k: 2 + out: 115 + - name: case_29 + in: + stones: + - 2 + - 8 + - 15 + - 14 + - 14 + k: 5 + out: 53 + - name: case_30 + in: + stones: + - 15 + - 10 + - 14 + - 9 + k: 5 + out: -1 + - name: case_31 + in: + stones: + - 5 + k: 5 + out: 0 + - name: case_32 + in: + stones: + - 5 + - 7 + - 12 + - 4 + - 7 + - 14 + k: 5 + out: -1 + - name: case_33 + in: + stones: + - 15 + k: 4 + out: 0 + - name: case_34 + in: + stones: + - 3 + - 14 + k: 3 + out: -1 + - name: case_35 + in: + stones: + - 3 + - 15 + - 6 + - 1 + - 1 + - 12 + - 9 + - 4 + k: 2 + out: 143 diff --git a/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.cpp b/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.cpp new file mode 100644 index 00000000..606a2397 --- /dev/null +++ b/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.cpp @@ -0,0 +1,36 @@ +class Solution { +public: + int mergeStones(vector& stones, int k) { + int n = stones.size(); + if ((n - 1) % (k - 1) != 0) return -1; + + vector prefix(n + 1, 0); + for (int i = 1; i <= n; i++) { + prefix[i] = prefix[i-1] + stones[i-1]; + } + + vector>> dp(n, vector>(n, vector(k + 1, INT_MAX))); + + for (int i = 0; i < n; i++) { + dp[i][i][1] = 0; + } + + for (int len = 2; len <= n; len++) { + for (int i = 0; i + len - 1 < n; i++) { + int j = i + len - 1; + for (int p = 2; p <= k; p++) { + for (int m = i; m < j; m += k - 1) { + if (dp[i][m][1] != INT_MAX && dp[m+1][j][p-1] != INT_MAX) { + dp[i][j][p] = min(dp[i][j][p], dp[i][m][1] + dp[m+1][j][p-1]); + } + } + } + if (dp[i][j][k] != INT_MAX) { + dp[i][j][1] = dp[i][j][k] + (prefix[j+1] - prefix[i]); + } + } + } + + return dp[0][n-1][1] == INT_MAX ? -1 : dp[0][n-1][1]; + } +}; diff --git a/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.cs b/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.cs new file mode 100644 index 00000000..7c75ed61 --- /dev/null +++ b/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.cs @@ -0,0 +1,44 @@ +public class Solution { + public int MergeStones(int[] stones, int k) { + int n = stones.Length; + if ((n - 1) % (k - 1) != 0) return -1; + + int[] prefix = new int[n + 1]; + for (int i = 1; i <= n; i++) { + prefix[i] = prefix[i-1] + stones[i-1]; + } + + int[][][] dp = new int[n][][]; + for (int i = 0; i < n; i++) { + dp[i] = new int[n][]; + for (int j = 0; j < n; j++) { + dp[i][j] = new int[k + 1]; + for (int p = 0; p <= k; p++) { + dp[i][j][p] = int.MaxValue; + } + } + } + + for (int i = 0; i < n; i++) { + dp[i][i][1] = 0; + } + + for (int len = 2; len <= n; len++) { + for (int i = 0; i + len - 1 < n; i++) { + int j = i + len - 1; + for (int p = 2; p <= k; p++) { + for (int m = i; m < j; m += k - 1) { + if (dp[i][m][1] != int.MaxValue && dp[m+1][j][p-1] != int.MaxValue) { + dp[i][j][p] = Math.Min(dp[i][j][p], dp[i][m][1] + dp[m+1][j][p-1]); + } + } + } + if (dp[i][j][k] != int.MaxValue) { + dp[i][j][1] = dp[i][j][k] + (prefix[j+1] - prefix[i]); + } + } + } + + return dp[0][n-1][1] == int.MaxValue ? -1 : dp[0][n-1][1]; + } +} diff --git a/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.dart b/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.dart new file mode 100644 index 00000000..66cffda8 --- /dev/null +++ b/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.dart @@ -0,0 +1,44 @@ +class Solution { + int mergeStones(List stones, int k) { + int n = stones.length; + if ((n - 1) % (k - 1) != 0) return -1; + + List prefix = List.filled(n + 1, 0); + for (int i = 1; i <= n; i++) { + prefix[i] = prefix[i-1] + stones[i-1]; + } + + List>> dp = List.generate( + n, + (_) => List.generate( + n, + (_) => List.filled(k + 1, 1 << 31 - 1) + ) + ); + + for (int i = 0; i < n; i++) { + dp[i][i][1] = 0; + } + + for (int len = 2; len <= n; len++) { + for (int i = 0; i + len - 1 < n; i++) { + int j = i + len - 1; + for (int p = 2; p <= k; p++) { + for (int m = i; m < j; m += k - 1) { + if (dp[i][m][1] != 1 << 31 - 1 && dp[m+1][j][p-1] != 1 << 31 - 1) { + int val = dp[i][m][1] + dp[m+1][j][p-1]; + if (val < dp[i][j][p]) { + dp[i][j][p] = val; + } + } + } + } + if (dp[i][j][k] != 1 << 31 - 1) { + dp[i][j][1] = dp[i][j][k] + (prefix[j+1] - prefix[i]); + } + } + } + + return dp[0][n-1][1] == 1 << 31 - 1 ? -1 : dp[0][n-1][1]; + } +} diff --git a/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.go b/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.go new file mode 100644 index 00000000..8062868a --- /dev/null +++ b/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.go @@ -0,0 +1,50 @@ +func mergeStones(stones []int, k int) int { + n := len(stones) + if (n-1)%(k-1) != 0 { + return -1 + } + + prefix := make([]int, n+1) + for i := 1; i <= n; i++ { + prefix[i] = prefix[i-1] + stones[i-1] + } + + dp := make([][][]int, n) + for i := range dp { + dp[i] = make([][]int, n) + for j := range dp[i] { + dp[i][j] = make([]int, k+1) + for p := range dp[i][j] { + dp[i][j][p] = 1<<31 - 1 + } + } + } + + for i := 0; i < n; i++ { + dp[i][i][1] = 0 + } + + for length := 2; length <= n; length++ { + for i := 0; i+length-1 < n; i++ { + j := i + length - 1 + for p := 2; p <= k; p++ { + for m := i; m < j; m += k - 1 { + if dp[i][m][1] != 1<<31-1 && dp[m+1][j][p-1] != 1<<31-1 { + val := dp[i][m][1] + dp[m+1][j][p-1] + if val < dp[i][j][p] { + dp[i][j][p] = val + } + } + } + } + if dp[i][j][k] != 1<<31-1 { + dp[i][j][1] = dp[i][j][k] + (prefix[j+1] - prefix[i]) + } + } + } + + if dp[0][n-1][1] == 1<<31-1 { + return -1 + } + return dp[0][n-1][1] +} diff --git a/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.java b/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.java new file mode 100644 index 00000000..dd8f2e47 --- /dev/null +++ b/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.java @@ -0,0 +1,42 @@ +class Solution { + public int mergeStones(int[] stones, int k) { + int n = stones.length; + if ((n - 1) % (k - 1) != 0) return -1; + + int[] prefix = new int[n + 1]; + for (int i = 1; i <= n; i++) { + prefix[i] = prefix[i-1] + stones[i-1]; + } + + int[][][] dp = new int[n][n][k + 1]; + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + for (int p = 0; p <= k; p++) { + dp[i][j][p] = Integer.MAX_VALUE; + } + } + } + + for (int i = 0; i < n; i++) { + dp[i][i][1] = 0; + } + + for (int len = 2; len <= n; len++) { + for (int i = 0; i + len - 1 < n; i++) { + int j = i + len - 1; + for (int p = 2; p <= k; p++) { + for (int m = i; m < j; m += k - 1) { + if (dp[i][m][1] != Integer.MAX_VALUE && dp[m+1][j][p-1] != Integer.MAX_VALUE) { + dp[i][j][p] = Math.min(dp[i][j][p], dp[i][m][1] + dp[m+1][j][p-1]); + } + } + } + if (dp[i][j][k] != Integer.MAX_VALUE) { + dp[i][j][1] = dp[i][j][k] + (prefix[j+1] - prefix[i]); + } + } + } + + return dp[0][n-1][1] == Integer.MAX_VALUE ? -1 : dp[0][n-1][1]; + } +} diff --git a/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.kt b/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.kt new file mode 100644 index 00000000..884443ec --- /dev/null +++ b/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.kt @@ -0,0 +1,37 @@ +class Solution { + fun mergeStones(stones: IntArray, k: Int): Int { + val n = stones.size + if ((n - 1) % (k - 1) != 0) return -1 + + val prefix = IntArray(n + 1) + for (i in 1..n) { + prefix[i] = prefix[i-1] + stones[i-1] + } + + val dp = Array(n) { Array(n) { IntArray(k + 1) { Int.MAX_VALUE } } } + + for (i in 0 until n) { + dp[i][i][1] = 0 + } + + for (len in 2..n) { + for (i in 0..n-len) { + val j = i + len - 1 + for (p in 2..k) { + var m = i + while (m < j) { + if (dp[i][m][1] != Int.MAX_VALUE && dp[m+1][j][p-1] != Int.MAX_VALUE) { + dp[i][j][p] = minOf(dp[i][j][p], dp[i][m][1] + dp[m+1][j][p-1]) + } + m += k - 1 + } + } + if (dp[i][j][k] != Int.MAX_VALUE) { + dp[i][j][1] = dp[i][j][k] + (prefix[j+1] - prefix[i]) + } + } + } + + return if (dp[0][n-1][1] == Int.MAX_VALUE) -1 else dp[0][n-1][1] + } +} diff --git a/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.py b/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.py new file mode 100644 index 00000000..ff9cbabf --- /dev/null +++ b/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.py @@ -0,0 +1,37 @@ +from functools import lru_cache +from typing import List + + +class Solution: + def mergeStones(self, stones: List[int], k: int) -> int: + n = len(stones) + if (n - 1) % (k - 1) != 0: + return -1 + + prefix_sums = [0] * (n + 1) + for i, stone in enumerate(stones, 1): + prefix_sums[i] = prefix_sums[i - 1] + stone + + @lru_cache(None) + def optimize(i, j, p): + """ + i, j: Interval bounds + p: Target number of piles to reduce to + """ + # Base Case: Single element can only be 1 pile + if i == j: + return 0 if p == 1 else float("inf") + + # Target = 1: Collapse the K-way partition into one + if p == 1: + return optimize(i, j, k) + int(prefix_sums[j + 1] - prefix_sums[i]) + + # Target > 1: Split the interval into (1) pile and (p-1) piles + # We step by (k-1) to ensure the first split is always "mergeable" + res = float("inf") + for m in range(i, j, k - 1): + res = min(res, optimize(i, m, 1) + optimize(m + 1, j, p - 1)) + return res + + result = optimize(0, n - 1, 1) + return int(result) if result != float("inf") else -1 diff --git a/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.py2 b/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.py2 new file mode 100644 index 00000000..42e6d578 --- /dev/null +++ b/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.py2 @@ -0,0 +1,38 @@ +class Solution(object): + def mergeStones(self, stones, k): + """ + :type stones: List[int] + :type k: int + :rtype: int + """ + n = len(stones) + if (n - 1) % (k - 1) != 0: + return -1 + + prefix = [0] * (n + 1) + for i in range(1, n + 1): + prefix[i] = prefix[i-1] + stones[i-1] + + memo = {} + + def optimize(i, j, p): + key = (i, j, p) + if key in memo: + return memo[key] + if i == j: + res = 0 if p == 1 else float('inf') + memo[key] = res + return res + if p == 1: + res = optimize(i, j, k) + (prefix[j+1] - prefix[i]) + memo[key] = res + return res + + res = float('inf') + for m in range(i, j, k - 1): + res = min(res, optimize(i, m, 1) + optimize(m+1, j, p-1)) + memo[key] = res + return res + + ans = optimize(0, n-1, 1) + return int(ans) if ans != float('inf') else -1 diff --git a/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.rb b/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.rb new file mode 100644 index 00000000..b196a9bf --- /dev/null +++ b/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.rb @@ -0,0 +1,36 @@ +# @param {Integer[]} stones +# @param {Integer} k +# @return {Integer} +def merge_stones(stones, k) + n = stones.length + return -1 if (n - 1) % (k - 1) != 0 + + prefix = [0] * (n + 1) + (1..n).each { |i| prefix[i] = prefix[i-1] + stones[i-1] } + + memo = {} + + optimize = lambda do |i, j, p| + key = [i, j, p] + return memo[key] if memo.key?(key) + + if i == j + return memo[key] = (p == 1 ? 0 : Float::INFINITY) + end + + if p == 1 + val = optimize.call(i, j, k) + (prefix[j+1] - prefix[i]) + return memo[key] = val + end + + res = Float::INFINITY + (i...j).step(k - 1) do |m| + val = optimize.call(i, m, 1) + optimize.call(m+1, j, p-1) + res = val if val < res + end + memo[key] = res + end + + ans = optimize.call(0, n-1, 1) + ans == Float::INFINITY ? -1 : ans.to_i +end diff --git a/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.rs b/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.rs new file mode 100644 index 00000000..8b4615d4 --- /dev/null +++ b/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.rs @@ -0,0 +1,44 @@ +impl Solution { + pub fn merge_stones(stones: Vec, k: i32) -> i32 { + let n = stones.len(); + let k = k as usize; + if (n - 1) % (k - 1) != 0 { + return -1; + } + + let mut prefix = vec![0; n + 1]; + for i in 1..=n { + prefix[i] = prefix[i - 1] + stones[i - 1]; + } + + let mut dp = vec![vec![vec![i32::MAX; k + 1]; n]; n]; + + for i in 0..n { + dp[i][i][1] = 0; + } + + for len in 2..=n { + for i in 0..=(n - len) { + let j = i + len - 1; + for p in 2..=k { + let mut m = i; + while m < j { + if dp[i][m][1] != i32::MAX && dp[m + 1][j][p - 1] != i32::MAX { + dp[i][j][p] = dp[i][j][p].min(dp[i][m][1] + dp[m + 1][j][p - 1]); + } + m += k - 1; + } + } + if dp[i][j][k] != i32::MAX { + dp[i][j][1] = dp[i][j][k] + (prefix[j + 1] - prefix[i]); + } + } + } + + if dp[0][n - 1][1] == i32::MAX { + -1 + } else { + dp[0][n - 1][1] + } + } +} diff --git a/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.swift b/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.swift new file mode 100644 index 00000000..cd85170a --- /dev/null +++ b/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.swift @@ -0,0 +1,61 @@ +class Solution { + func mergeStones(_ stones: [Int], _ k: Int) -> Int { + let n = stones.count + if n == 0 { + return 0 + } + if k <= 1 { + return n == 1 ? 0 : -1 + } + if (n - 1) % (k - 1) != 0 { + return -1 + } + + var prefix = [Int](repeating: 0, count: n + 1) + for i in 0.. String { + return "\(i)#\(j)#\(p)" + } + + func dfs(_ i: Int, _ j: Int, _ p: Int) -> Int { + let cacheKey = key(i, j, p) + if let cached = memo[cacheKey] { + return cached + } + + let result: Int + if i == j { + result = (p == 1) ? 0 : inf + } else if p == 1 { + let merged = dfs(i, j, k) + result = merged >= inf ? inf : merged + prefix[j + 1] - prefix[i] + } else { + var best = inf + var m = i + while m < j { + let left = dfs(i, m, 1) + if left < best { + let right = dfs(m + 1, j, p - 1) + if right < inf { + best = min(best, left + right) + } + } + m += k - 1 + } + result = best + } + + memo[cacheKey] = result + return result + } + + let answer = dfs(0, n - 1, 1) + return answer >= inf ? -1 : answer + } +} diff --git a/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.ts b/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.ts new file mode 100644 index 00000000..54bb05f9 --- /dev/null +++ b/tests/501-1000/1000. minimum-cost-to-merge-stones/sol.ts @@ -0,0 +1,38 @@ +function mergeStones(stones: number[], k: number): number { + const n = stones.length; + if ((n - 1) % (k - 1) !== 0) return -1; + + const prefix: number[] = new Array(n + 1).fill(0); + for (let i = 1; i <= n; i++) { + prefix[i] = prefix[i - 1] + stones[i - 1]; + } + + const dp: number[][][] = Array.from({ length: n }, () => + Array.from({ length: n }, () => new Array(k + 1).fill(Infinity)), + ); + + for (let i = 0; i < n; i++) { + dp[i][i][1] = 0; + } + + for (let len = 2; len <= n; len++) { + for (let i = 0; i + len - 1 < n; i++) { + const j = i + len - 1; + for (let p = 2; p <= k; p++) { + for (let m = i; m < j; m += k - 1) { + if (dp[i][m][1] !== Infinity && dp[m + 1][j][p - 1] !== Infinity) { + dp[i][j][p] = Math.min( + dp[i][j][p], + dp[i][m][1] + dp[m + 1][j][p - 1], + ); + } + } + } + if (dp[i][j][k] !== Infinity) { + dp[i][j][1] = dp[i][j][k] + (prefix[j + 1] - prefix[i]); + } + } + } + + return dp[0][n - 1][1] === Infinity ? -1 : dp[0][n - 1][1]; +} diff --git a/tests/501-1000/796. rotate-string/manifest.yaml b/tests/501-1000/796. rotate-string/manifest.yaml new file mode 100644 index 00000000..7fdd6f9e --- /dev/null +++ b/tests/501-1000/796. rotate-string/manifest.yaml @@ -0,0 +1,176 @@ +entry: + id: 796 + title: rotate-string + params: + s: + type: string + goal: + type: string + call: + cpp: "Solution().rotateString({s}, {goal})" + rust: "Solution::rotate_string({s}, {goal})" + python3: "Solution().rotateString({s}, {goal})" + python2: "Solution().rotateString({s}, {goal})" + ruby: "rotate_string({s}, {goal})" + java: "new Solution().rotateString({s}, {goal})" + csharp: "new Solution().RotateString({s}, {goal})" + kotlin: "Solution().rotateString({s}, {goal})" + go: "rotateString({s}, {goal})" + dart: "Solution().rotateString({s}, {goal})" + swift: "Solution().rotateString({s}, {goal})" + typescript: "rotateString({s}, {goal})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().check(s, goal, {result})" + checker: | + class Checker: + def check(self, s, goal, result): + expected = len(s) == len(goal) and goal in (s + s) + return bool(result) == expected +seed: 796 +tests: + - name: ex1 + in: + s: abcde + goal: cdeab + - name: ex2 + in: + s: abcde + goal: abced + - name: single_true + in: + s: a + goal: a + - name: single_false + in: + s: a + goal: b + - name: two_true_1 + in: + s: ab + goal: ab + - name: two_true_2 + in: + s: ab + goal: ba + - name: two_false + in: + s: ab + goal: aa + - name: repeated_true + in: + s: aaaa + goal: aaaa + - name: repeated_false + in: + s: aaaa + goal: aaab + - name: no_rotation_match + in: + s: waterbottle + goal: erbottlewat + - name: no_rotation_mismatch + in: + s: waterbottle + goal: erbottlewta + - name: prefix_shift_1 + in: + s: rotation + goal: otationr + - name: prefix_shift_2 + in: + s: rotation + goal: tationro + - name: prefix_shift_3 + in: + s: rotation + goal: ationrot + - name: prefix_shift_false + in: + s: rotation + goal: ationrto + - name: all_same_length_1 + in: + s: xyzxyz + goal: zxyzxy + - name: all_same_length_2 + in: + s: xyzxyz + goal: xyzxyz + - name: all_same_length_false + in: + s: xyzxyz + goal: xzyxzy + - name: mixed_true_1 + in: + s: aabca + goal: caaab + - name: mixed_true_2 + in: + s: aabca + goal: baaac + - name: mixed_false_1 + in: + s: aabca + goal: caaba + - name: long_shift_1 + in: + s: abcdefghijklmnopqrstuvwxyz + goal: bcdefghijklmnopqrstuvwxyza + - name: long_shift_2 + in: + s: abcdefghijklmnopqrstuvwxyz + goal: zabcdefghijklmnopqrstuvwxy + - name: long_false_1 + in: + s: abcdefghijklmnopqrstuvwxyz + goal: bcdefghijklmnopqrstuvwxyzz + - name: boundary_len_100_true + in: + s: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + goal: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + - name: boundary_len_100_false + in: + s: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + goal: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab + - name: wrap_true + in: + s: cab + goal: abc + - name: wrap_false + in: + s: cab + goal: acb + - name: distinct_false_1 + in: + s: qwerty + goal: yqwert + - name: distinct_true_1 + in: + s: qwerty + goal: ertyqw + - name: distinct_false_2 + in: + s: rotation + goal: rotationn + - name: repeated_pattern_true + in: + s: abababab + goal: babababa + - name: repeated_pattern_false + in: + s: abababab + goal: abababaa + - name: pal_true + in: + s: level + goal: level + - name: pal_false + in: + s: level + goal: elvel diff --git a/tests/501-1000/796. rotate-string/sol.cpp b/tests/501-1000/796. rotate-string/sol.cpp new file mode 100644 index 00000000..288775cb --- /dev/null +++ b/tests/501-1000/796. rotate-string/sol.cpp @@ -0,0 +1,6 @@ +class Solution { +public: + bool rotateString(string s, string goal) { + return s.size() == goal.size() && (s + s).find(goal) != string::npos; + } +}; diff --git a/tests/501-1000/796. rotate-string/sol.cs b/tests/501-1000/796. rotate-string/sol.cs new file mode 100644 index 00000000..1fbbe73f --- /dev/null +++ b/tests/501-1000/796. rotate-string/sol.cs @@ -0,0 +1,5 @@ +public class Solution { + public bool RotateString(string s, string goal) { + return s.Length == goal.Length && (s + s).Contains(goal); + } +} diff --git a/tests/501-1000/796. rotate-string/sol.dart b/tests/501-1000/796. rotate-string/sol.dart new file mode 100644 index 00000000..3ed5ea8b --- /dev/null +++ b/tests/501-1000/796. rotate-string/sol.dart @@ -0,0 +1,5 @@ +class Solution { + bool rotateString(String s, String goal) { + return s.length == goal.length && (s + s).contains(goal); + } +} diff --git a/tests/501-1000/796. rotate-string/sol.go b/tests/501-1000/796. rotate-string/sol.go new file mode 100644 index 00000000..88d3da5c --- /dev/null +++ b/tests/501-1000/796. rotate-string/sol.go @@ -0,0 +1,3 @@ +func rotateString(s string, goal string) bool { + return len(s) == len(goal) && strings.Contains(s + s, goal) +} diff --git a/tests/501-1000/796. rotate-string/sol.java b/tests/501-1000/796. rotate-string/sol.java new file mode 100644 index 00000000..9b356b84 --- /dev/null +++ b/tests/501-1000/796. rotate-string/sol.java @@ -0,0 +1,5 @@ +class Solution { + public boolean rotateString(String s, String goal) { + return s.length() == goal.length() && (s + s).contains(goal); + } +} diff --git a/tests/501-1000/796. rotate-string/sol.kt b/tests/501-1000/796. rotate-string/sol.kt new file mode 100644 index 00000000..6745753b --- /dev/null +++ b/tests/501-1000/796. rotate-string/sol.kt @@ -0,0 +1,5 @@ +class Solution { + fun rotateString(s: String, goal: String): Boolean { + return s.length == goal.length && (s + s).contains(goal) + } +} diff --git a/tests/501-1000/796. rotate-string/sol.py b/tests/501-1000/796. rotate-string/sol.py new file mode 100644 index 00000000..713d9ba2 --- /dev/null +++ b/tests/501-1000/796. rotate-string/sol.py @@ -0,0 +1,3 @@ +class Solution: + def rotateString(self, s: str, goal: str) -> bool: + return len(s) == len(goal) and (s + s).find(goal) != -1 diff --git a/tests/501-1000/796. rotate-string/sol.py2 b/tests/501-1000/796. rotate-string/sol.py2 new file mode 100644 index 00000000..9fd75fb7 --- /dev/null +++ b/tests/501-1000/796. rotate-string/sol.py2 @@ -0,0 +1,8 @@ +class Solution(object): + def rotateString(self, s, goal): + """ + :type s: str + :type goal: str + :rtype: bool + """ + return len(s) == len(goal) and (s + s).find(goal) != -1 diff --git a/tests/501-1000/796. rotate-string/sol.rb b/tests/501-1000/796. rotate-string/sol.rb new file mode 100644 index 00000000..fc26452b --- /dev/null +++ b/tests/501-1000/796. rotate-string/sol.rb @@ -0,0 +1,6 @@ +# @param {String} s +# @param {String} goal +# @return {Boolean} +def rotate_string(s, goal) + s.length == goal.length && (s + s).include?(goal) +end diff --git a/tests/501-1000/796. rotate-string/sol.rs b/tests/501-1000/796. rotate-string/sol.rs new file mode 100644 index 00000000..b8c34585 --- /dev/null +++ b/tests/501-1000/796. rotate-string/sol.rs @@ -0,0 +1,5 @@ +impl Solution { + pub fn rotate_string(s: String, goal: String) -> bool { + s.len() == goal.len() && (s.clone() + &s).contains(&goal) + } +} diff --git a/tests/501-1000/796. rotate-string/sol.swift b/tests/501-1000/796. rotate-string/sol.swift new file mode 100644 index 00000000..a8e1bb04 --- /dev/null +++ b/tests/501-1000/796. rotate-string/sol.swift @@ -0,0 +1,5 @@ +class Solution { + func rotateString(_ s: String, _ goal: String) -> Bool { + return s.count == goal.count && (s + s).contains(goal) + } +} diff --git a/tests/501-1000/796. rotate-string/sol.ts b/tests/501-1000/796. rotate-string/sol.ts new file mode 100644 index 00000000..d519cf20 --- /dev/null +++ b/tests/501-1000/796. rotate-string/sol.ts @@ -0,0 +1,3 @@ +function rotateString(s: string, goal: string): boolean { + return s.length === goal.length && (s + s).includes(goal); +} diff --git a/tests/501-1000/797. all-paths-from-source-to-target/manifest.yaml b/tests/501-1000/797. all-paths-from-source-to-target/manifest.yaml new file mode 100644 index 00000000..155433a5 --- /dev/null +++ b/tests/501-1000/797. all-paths-from-source-to-target/manifest.yaml @@ -0,0 +1,482 @@ +entry: + id: 797 + title: all-paths-from-source-to-target + params: + graph: + type: array + items: + type: array + items: + type: int + call: + cpp: "Solution().allPathsSourceTarget({graph})" + rust: "Solution::all_paths_source_target({graph})" + python3: "Solution().allPathsSourceTarget({graph})" + python2: "Solution().allPathsSourceTarget({graph})" + ruby: "all_paths_source_target({graph})" + java: "new Solution().allPathsSourceTarget({graph})" + csharp: "new Solution().AllPathsSourceTarget({graph})" + kotlin: "Solution().allPathsSourceTarget({graph})" + go: "allPathsSourceTarget({graph})" + dart: "Solution().allPathsSourceTarget({graph})" + swift: "Solution().allPathsSourceTarget({graph})" + typescript: "allPathsSourceTarget({graph})" +judge: + type: ignore_order +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().check(graph, {result})" + checker: | + class Checker: + def check(self, graph, result): + target = len(graph) - 1 + expected = [] + + def dfs(node, path): + if node == target: + expected.append(tuple(path)) + return + for nxt in graph[node]: + dfs(nxt, path + [nxt]) + + dfs(0, [0]) + + try: + got = [tuple(path) for path in result] + except TypeError: + return False + + if len(got) != len(expected): + return False + if len(set(got)) != len(got): + return False + if set(got) != set(expected): + return False + for path in got: + if not path or path[0] != 0 or path[-1] != target: + return False + for a, b in zip(path, path[1:]): + if b not in graph[a]: + return False + return True +seed: 797 +tests: + - name: ex1 + in: + graph: + elemType: int + value: + - [1, 2] + - [3] + - [3] + - [] + - name: ex2 + in: + graph: + elemType: int + value: + - [4, 3, 1] + - [3, 2, 4] + - [3] + - [4] + - [] + - name: two_nodes_one_edge + in: + graph: + elemType: int + value: + - [1] + - [] + - name: two_nodes_no_path + in: + graph: + elemType: int + value: + - [] + - [] + - name: chain_3 + in: + graph: + elemType: int + value: + - [1] + - [2] + - [] + - name: diamond + in: + graph: + elemType: int + value: + - [1, 2] + - [3] + - [3] + - [] + - name: fork_join + in: + graph: + elemType: int + value: + - [1, 2, 3] + - [4] + - [4] + - [4] + - [] + - name: direct_only + in: + graph: + elemType: int + value: + - [4] + - [4] + - [4] + - [4] + - [] + - name: branching_5 + in: + graph: + elemType: int + value: + - [1, 2] + - [3, 4] + - [3, 4] + - [5] + - [5] + - [] + - name: branching_6 + in: + graph: + elemType: int + value: + - [1, 2, 3] + - [4, 5] + - [4, 5] + - [5] + - [6] + - [6] + - [] + - name: branching_7 + in: + graph: + elemType: int + value: + - [1, 2] + - [3] + - [3, 4] + - [5] + - [5] + - [] + - name: branching_8 + in: + graph: + elemType: int + value: + - [1, 2, 3] + - [4] + - [4, 5] + - [5] + - [6] + - [6] + - [] + - name: sparse_1 + in: + graph: + elemType: int + value: + - [2] + - [3] + - [3] + - [4] + - [] + - name: sparse_2 + in: + graph: + elemType: int + value: + - [1, 3] + - [2] + - [4] + - [4] + - [] + - name: sparse_3 + in: + graph: + elemType: int + value: + - [1] + - [2, 3] + - [4] + - [4] + - [] + - name: sparse_4 + in: + graph: + elemType: int + value: + - [1, 2, 3] + - [4] + - [4] + - [4] + - [] + - name: sparse_5 + in: + graph: + elemType: int + value: + - [1] + - [2] + - [3] + - [4] + - [] + - name: sparse_6 + in: + graph: + elemType: int + value: + - [1, 2] + - [3] + - [3] + - [4] + - [] + - name: sparse_7 + in: + graph: + elemType: int + value: + - [1, 2] + - [4] + - [4] + - [4] + - [] + - name: sparse_8 + in: + graph: + elemType: int + value: + - [1] + - [3] + - [3] + - [4] + - [] + - name: sparse_9 + in: + graph: + elemType: int + value: + - [1, 2] + - [2, 3] + - [4] + - [4] + - [] + - name: sparse_10 + in: + graph: + elemType: int + value: + - [1, 2, 3] + - [4, 5] + - [5] + - [5] + - [6] + - [6] + - [] + - name: sparse_11 + in: + graph: + elemType: int + value: + - [1, 2] + - [4] + - [4] + - [4] + - [] + - name: sparse_12 + in: + graph: + elemType: int + value: + - [1, 2] + - [3, 4] + - [4] + - [5] + - [5] + - [] + - name: sparse_13 + in: + graph: + elemType: int + value: + - [1] + - [2, 3, 4] + - [5] + - [5] + - [5] + - [] + - name: sparse_14 + in: + graph: + elemType: int + value: + - [1, 2] + - [3] + - [3] + - [] + - name: sparse_15 + in: + graph: + elemType: int + value: + - [1, 2, 3] + - [4] + - [4] + - [4] + - [5] + - [] + - name: sparse_16 + in: + graph: + elemType: int + value: + - [1] + - [2] + - [3] + - [4] + - [5] + - [] + - name: sparse_17 + in: + graph: + elemType: int + value: + - [1, 2] + - [3, 4] + - [4, 5] + - [5] + - [6] + - [6] + - [] + - name: sparse_18 + in: + graph: + elemType: int + value: + - [1, 2, 3] + - [4] + - [4] + - [4] + - [5] + - [6] + - [] + - name: sparse_19 + in: + graph: + elemType: int + value: + - [1] + - [2, 3] + - [4] + - [4] + - [5] + - [] + - name: sparse_20 + in: + graph: + elemType: int + value: + - [1, 2] + - [3] + - [3, 4] + - [5] + - [5] + - [] + - name: sparse_21 + in: + graph: + elemType: int + value: + - [1, 2] + - [4] + - [4, 5] + - [5] + - [6] + - [6] + - [] + - name: sparse_22 + in: + graph: + elemType: int + value: + - [1, 2] + - [3] + - [3] + - [4] + - [5] + - [] + - name: sparse_23 + in: + graph: + elemType: int + value: + - [1, 2, 3] + - [4, 5] + - [5] + - [5] + - [6] + - [6] + - [] + - name: sparse_24 + in: + graph: + elemType: int + value: + - [1] + - [2] + - [4] + - [4] + - [] + - name: sparse_25 + in: + graph: + elemType: int + value: + - [1, 2] + - [3, 4] + - [4, 5] + - [6] + - [6] + - [6] + - [] + - name: sparse_26 + in: + graph: + elemType: int + value: + - [1, 2] + - [3] + - [3, 4] + - [5] + - [5] + - [] + - name: sparse_27 + in: + graph: + elemType: int + value: + - [1, 2, 3] + - [4] + - [4] + - [4] + - [5] + - [] + - name: sparse_28 + in: + graph: + elemType: int + value: + - [1] + - [2, 3] + - [4] + - [4] + - [] diff --git a/tests/501-1000/797. all-paths-from-source-to-target/sol.cpp b/tests/501-1000/797. all-paths-from-source-to-target/sol.cpp new file mode 100644 index 00000000..5395c73f --- /dev/null +++ b/tests/501-1000/797. all-paths-from-source-to-target/sol.cpp @@ -0,0 +1,27 @@ +class Solution { +public: + vector> allPathsSourceTarget(vector>& graph) { + int target = graph.size() - 1; + vector> result; + queue>> q; + q.push({0, {0}}); + + while (!q.empty()) { + auto [node, path] = q.front(); + q.pop(); + + if (node == target) { + result.push_back(path); + continue; + } + + for (int neighbor : graph[node]) { + vector newPath = path; + newPath.push_back(neighbor); + q.push({neighbor, newPath}); + } + } + + return result; + } +}; diff --git a/tests/501-1000/797. all-paths-from-source-to-target/sol.cs b/tests/501-1000/797. all-paths-from-source-to-target/sol.cs new file mode 100644 index 00000000..d8a6f772 --- /dev/null +++ b/tests/501-1000/797. all-paths-from-source-to-target/sol.cs @@ -0,0 +1,25 @@ +public class Solution { + public IList> AllPathsSourceTarget(int[][] graph) { + int target = graph.Length - 1; + IList> result = new List>(); + Queue<(int, List)> queue = new Queue<(int, List)>(); + queue.Enqueue((0, new List { 0 })); + + while (queue.Count > 0) { + var (node, path) = queue.Dequeue(); + + if (node == target) { + result.Add(new List(path)); + continue; + } + + foreach (int neighbor in graph[node]) { + var newPath = new List(path); + newPath.Add(neighbor); + queue.Enqueue((neighbor, newPath)); + } + } + + return result; + } +} diff --git a/tests/501-1000/797. all-paths-from-source-to-target/sol.dart b/tests/501-1000/797. all-paths-from-source-to-target/sol.dart new file mode 100644 index 00000000..8afd5bad --- /dev/null +++ b/tests/501-1000/797. all-paths-from-source-to-target/sol.dart @@ -0,0 +1,25 @@ +class Solution { + List> allPathsSourceTarget(List> graph) { + int target = graph.length - 1; + List> result = []; + + List> queue = [[0, [0]]]; + + while (queue.isNotEmpty) { + var current = queue.removeAt(0); + int node = current[0]; + List path = List.from(current[1]); + + if (node == target) { + result.add(path); + continue; + } + + for (int neighbor in graph[node]) { + queue.add([neighbor, [...path, neighbor]]); + } + } + + return result; + } +} diff --git a/tests/501-1000/797. all-paths-from-source-to-target/sol.go b/tests/501-1000/797. all-paths-from-source-to-target/sol.go new file mode 100644 index 00000000..f5d8b11f --- /dev/null +++ b/tests/501-1000/797. all-paths-from-source-to-target/sol.go @@ -0,0 +1,30 @@ +func allPathsSourceTarget(graph [][]int) [][]int { + target := len(graph) - 1 + result := [][]int{} + + type pair struct { + node int + path []int + } + + queue := []pair{{0, []int{0}}} + + for len(queue) > 0 { + current := queue[0] + queue = queue[1:] + + if current.node == target { + result = append(result, current.path) + continue + } + + for _, neighbor := range graph[current.node] { + newPath := make([]int, len(current.path)+1) + copy(newPath, current.path) + newPath[len(newPath)-1] = neighbor + queue = append(queue, pair{neighbor, newPath}) + } + } + + return result +} diff --git a/tests/501-1000/797. all-paths-from-source-to-target/sol.java b/tests/501-1000/797. all-paths-from-source-to-target/sol.java new file mode 100644 index 00000000..48cb74ec --- /dev/null +++ b/tests/501-1000/797. all-paths-from-source-to-target/sol.java @@ -0,0 +1,30 @@ +class Solution { + public List> allPathsSourceTarget(int[][] graph) { + List> result = new ArrayList<>(); + int target = graph.length - 1; + + Queue>> queue = new LinkedList<>(); + List startPath = new ArrayList<>(); + startPath.add(0); + queue.add(new Pair<>(0, startPath)); + + while (!queue.isEmpty()) { + Pair> pair = queue.poll(); + int node = pair.getKey(); + List path = pair.getValue(); + + if (node == target) { + result.add(new ArrayList<>(path)); + continue; + } + + for (int neighbor : graph[node]) { + List newPath = new ArrayList<>(path); + newPath.add(neighbor); + queue.add(new Pair<>(neighbor, newPath)); + } + } + + return result; + } +} diff --git a/tests/501-1000/797. all-paths-from-source-to-target/sol.kt b/tests/501-1000/797. all-paths-from-source-to-target/sol.kt new file mode 100644 index 00000000..503f70bf --- /dev/null +++ b/tests/501-1000/797. all-paths-from-source-to-target/sol.kt @@ -0,0 +1,24 @@ +class Solution { + fun allPathsSourceTarget(graph: Array): List> { + val result = mutableListOf>() + val target = graph.size - 1 + + val queue = ArrayDeque>>() + queue.add(Pair(0, listOf(0))) + + while (queue.isNotEmpty()) { + val (node, path) = queue.removeFirst() + + if (node == target) { + result.add(path) + continue + } + + for (neighbor in graph[node]) { + queue.add(Pair(neighbor, path + neighbor)) + } + } + + return result + } +} diff --git a/tests/501-1000/797. all-paths-from-source-to-target/sol.py b/tests/501-1000/797. all-paths-from-source-to-target/sol.py new file mode 100644 index 00000000..93c6c09e --- /dev/null +++ b/tests/501-1000/797. all-paths-from-source-to-target/sol.py @@ -0,0 +1,20 @@ +class Solution: + def allPathsSourceTarget(self, graph: List[List[int]]) -> List[List[int]]: + # Queue stores (current_node, path_so_far) + queue = [(0, [0])] + target = len(graph) - 1 + result = [] + + while queue: + node, path = queue.pop(0) + + # If target is reached, save the path + if node == target: + result.append(path) + continue + + # Explore neighbors + for neighbor in graph[node]: + queue.append((neighbor, path + [neighbor])) + + return result diff --git a/tests/501-1000/797. all-paths-from-source-to-target/sol.py2 b/tests/501-1000/797. all-paths-from-source-to-target/sol.py2 new file mode 100644 index 00000000..627da79e --- /dev/null +++ b/tests/501-1000/797. all-paths-from-source-to-target/sol.py2 @@ -0,0 +1,19 @@ +class Solution(object): + def allPathsSourceTarget(self, graph): + """ + :type graph: List[List[int]] + :rtype: List[List[int]] + """ + queue = [(0, [0])] + target = len(graph) - 1 + result = [] + + while queue: + node, path = queue.pop(0) + if node == target: + result.append(path) + continue + for neighbor in graph[node]: + queue.append((neighbor, path + [neighbor])) + + return result diff --git a/tests/501-1000/797. all-paths-from-source-to-target/sol.rb b/tests/501-1000/797. all-paths-from-source-to-target/sol.rb new file mode 100644 index 00000000..4004fda4 --- /dev/null +++ b/tests/501-1000/797. all-paths-from-source-to-target/sol.rb @@ -0,0 +1,20 @@ +# @param {Integer[][]} graph +# @return {Integer[][]} +def all_paths_source_target(graph) + queue = [[0, [0]]] + target = graph.length - 1 + result = [] + + while !queue.empty? + node, path = queue.shift + if node == target + result << path + next + end + graph[node].each do |neighbor| + queue << [neighbor, path + [neighbor]] + end + end + + result +end diff --git a/tests/501-1000/797. all-paths-from-source-to-target/sol.rs b/tests/501-1000/797. all-paths-from-source-to-target/sol.rs new file mode 100644 index 00000000..3e4834e9 --- /dev/null +++ b/tests/501-1000/797. all-paths-from-source-to-target/sol.rs @@ -0,0 +1,22 @@ +impl Solution { + pub fn all_paths_source_target(graph: Vec>) -> Vec> { + let target = (graph.len() - 1) as i32; + let mut result = vec![]; + let mut queue = vec![(0, vec![0])]; + + while let Some((node, path)) = queue.pop() { + if node == target { + result.push(path); + continue; + } + + for &neighbor in &graph[node as usize] { + let mut new_path = path.clone(); + new_path.push(neighbor); + queue.insert(0, (neighbor, new_path)); + } + } + + result + } +} diff --git a/tests/501-1000/797. all-paths-from-source-to-target/sol.swift b/tests/501-1000/797. all-paths-from-source-to-target/sol.swift new file mode 100644 index 00000000..2ef03510 --- /dev/null +++ b/tests/501-1000/797. all-paths-from-source-to-target/sol.swift @@ -0,0 +1,22 @@ +class Solution { + func allPathsSourceTarget(_ graph: [[Int]]) -> [[Int]] { + let target = graph.count - 1 + var result = [[Int]]() + var queue: [(Int, [Int])] = [(0, [0])] + + while !queue.isEmpty { + let (node, path) = queue.removeFirst() + + if node == target { + result.append(path) + continue + } + + for neighbor in graph[node] { + queue.append((neighbor, path + [neighbor])) + } + } + + return result + } +} diff --git a/tests/501-1000/797. all-paths-from-source-to-target/sol.ts b/tests/501-1000/797. all-paths-from-source-to-target/sol.ts new file mode 100644 index 00000000..c9ee3b58 --- /dev/null +++ b/tests/501-1000/797. all-paths-from-source-to-target/sol.ts @@ -0,0 +1,20 @@ +function allPathsSourceTarget(graph: number[][]): number[][] { + const target = graph.length - 1; + const result: number[][] = []; + const queue: [number, number[]][] = [[0, [0]]]; + + while (queue.length > 0) { + const [node, path] = queue.shift()!; + + if (node === target) { + result.push(path); + continue; + } + + for (const neighbor of graph[node]) { + queue.push([neighbor, [...path, neighbor]]); + } + } + + return result; +} diff --git a/tests/501-1000/798. smallest-rotation-with-highest-score/manifest.yaml b/tests/501-1000/798. smallest-rotation-with-highest-score/manifest.yaml new file mode 100644 index 00000000..fef8fbe9 --- /dev/null +++ b/tests/501-1000/798. smallest-rotation-with-highest-score/manifest.yaml @@ -0,0 +1,362 @@ +entry: + id: 798 + title: smallest-rotation-with-highest-score + params: + nums: + type: array + items: + type: int + call: + cpp: "Solution().bestRotation({nums})" + rust: "Solution::best_rotation({nums})" + python3: "Solution().bestRotation({nums})" + python2: "Solution().bestRotation({nums})" + ruby: "best_rotation({nums})" + java: "new Solution().bestRotation({nums})" + csharp: "new Solution().BestRotation({nums})" + kotlin: "Solution().bestRotation({nums})" + go: "bestRotation({nums})" + dart: "Solution().bestRotation({nums})" + swift: "Solution().bestRotation({nums})" + typescript: "bestRotation({nums})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().check(nums, {result})" + checker: | + class Checker: + def check(self, nums, result): + n = len(nums) + best = 0 + best_score = -1 + for k in range(n): + score = 0 + for i in range(n): + if nums[(i + k) % n] <= i: + score += 1 + if score > best_score: + best_score = score + best = k + return int(result) == best +seed: 798 +tests: + - name: ex1 + in: + nums: [2, 3, 1, 4, 0] + - name: ex2 + in: + nums: [1, 3, 0, 2, 4] + - name: single_zero + in: + nums: [0] + - name: two_sorted + in: + nums: [0, 1] + - name: two_unsorted + in: + nums: [1, 0] + - name: three_inc + in: + nums: [0, 1, 2] + - name: three_dec + in: + nums: [2, 1, 0] + - name: all_same_score + in: + nums: [1, 1, 1, 1] + - name: peak_middle + in: + nums: [2, 0, 1, 3] + - name: peak_wrap + in: + nums: [4, 0, 1, 2, 3] + - name: simple_case_1 + in: + nums: [1, 0, 2] + - name: simple_case_2 + in: + nums: [2, 0, 1] + - name: simple_case_3 + in: + nums: [1, 2, 0] + - name: simple_case_4 + in: + nums: [0, 2, 1] + - name: simple_case_5 + in: + nums: [3, 0, 1, 2] + - name: simple_case_6 + in: + nums: [2, 3, 0, 1] + - name: simple_case_7 + in: + nums: [1, 2, 3, 0] + - name: simple_case_8 + in: + nums: [0, 2, 3, 1] + - name: simple_case_9 + in: + nums: [4, 1, 0, 2, 3] + - name: simple_case_10 + in: + nums: [3, 4, 1, 0, 2] + - name: simple_case_11 + in: + nums: [2, 4, 1, 3, 0] + - name: simple_case_12 + in: + nums: [2, 3, 4, 0, 1] + - name: simple_case_13 + in: + nums: [5, 0, 1, 2, 3, 4] + - name: simple_case_14 + in: + nums: [1, 0, 3, 2, 5, 4] + - name: simple_case_15 + in: + nums: [6, 0, 1, 2, 3, 4, 5] + - name: simple_case_16 + in: + nums: [6, 5, 4, 3, 2, 1, 0] + - name: simple_case_17 + in: + nums: [0, 6, 5, 4, 3, 2, 1] + - name: simple_case_18 + in: + nums: [1, 3, 5, 7, 0, 2, 4, 6] + - name: simple_case_19 + in: + nums: [7, 0, 1, 2, 3, 4, 5, 6] + - name: simple_case_20 + in: + nums: [2, 0, 4, 1, 3] + - name: simple_case_21 + in: + nums: [4, 3, 2, 1, 0] + - name: simple_case_22 + in: + nums: [0, 4, 3, 2, 1] + - name: simple_case_23 + in: + nums: [1, 4, 0, 2, 3] + - name: simple_case_24 + in: + nums: [2, 1, 4, 0, 3] + - name: simple_case_25 + in: + nums: [3, 1, 4, 0, 2] + - name: large_1 + in: + nums: + [ + 99, + 0, + 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, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97, + 98, + 99, + ] + - name: large_2 + in: + nums: + [ + 0, + 2, + 4, + 6, + 8, + 10, + 12, + 14, + 16, + 18, + 20, + 22, + 24, + 26, + 28, + 30, + 32, + 34, + 36, + 38, + 40, + 42, + 44, + 46, + 48, + 50, + 52, + 54, + 56, + 58, + 60, + 62, + 64, + 66, + 68, + 70, + 72, + 74, + 76, + 78, + 80, + 82, + 84, + 86, + 88, + 90, + 92, + 94, + 96, + 98, + 1, + 3, + 5, + 7, + 9, + 11, + 13, + 15, + 17, + 19, + 21, + 23, + 25, + 27, + 29, + 31, + 33, + 35, + 37, + 39, + 41, + 43, + 45, + 47, + 49, + 51, + 53, + 55, + 57, + 59, + 61, + 63, + 65, + 67, + 69, + 71, + 73, + 75, + 77, + 79, + 81, + 83, + 85, + 87, + 89, + 91, + 93, + 95, + 97, + 99, + ] diff --git a/tests/501-1000/798. smallest-rotation-with-highest-score/sol.cpp b/tests/501-1000/798. smallest-rotation-with-highest-score/sol.cpp new file mode 100644 index 00000000..9b65bf8f --- /dev/null +++ b/tests/501-1000/798. smallest-rotation-with-highest-score/sol.cpp @@ -0,0 +1,27 @@ +class Solution { +public: + int bestRotation(vector& nums) { + int n = nums.size(); + vector diffs(n + 1, 0); + for (int i = 0; i < n; i++) { + int left = ((i - nums[i] + 1) % n + n) % n; + int right = (i + 1) % n; + diffs[left]--; + diffs[right]++; + if (left > right) { + diffs[0]--; + } + } + int best = 0; + int cur = n; + int maxScore = cur; + for (int k = 1; k < n; k++) { + cur += diffs[k]; + if (cur > maxScore) { + maxScore = cur; + best = k; + } + } + return best; + } +}; diff --git a/tests/501-1000/798. smallest-rotation-with-highest-score/sol.cs b/tests/501-1000/798. smallest-rotation-with-highest-score/sol.cs new file mode 100644 index 00000000..a16b0372 --- /dev/null +++ b/tests/501-1000/798. smallest-rotation-with-highest-score/sol.cs @@ -0,0 +1,26 @@ +public class Solution { + public int BestRotation(int[] nums) { + int n = nums.Length; + int[] diffs = new int[n + 1]; + for (int i = 0; i < n; i++) { + int left = ((i - nums[i] + 1) % n + n) % n; + int right = (i + 1) % n; + diffs[left]--; + diffs[right]++; + if (left > right) { + diffs[0]--; + } + } + int best = 0; + int cur = n; + int maxScore = cur; + for (int k = 1; k < n; k++) { + cur += diffs[k]; + if (cur > maxScore) { + maxScore = cur; + best = k; + } + } + return best; + } +} diff --git a/tests/501-1000/798. smallest-rotation-with-highest-score/sol.dart b/tests/501-1000/798. smallest-rotation-with-highest-score/sol.dart new file mode 100644 index 00000000..2e1566cd --- /dev/null +++ b/tests/501-1000/798. smallest-rotation-with-highest-score/sol.dart @@ -0,0 +1,26 @@ +class Solution { + int bestRotation(List nums) { + int n = nums.length; + List diffs = List.filled(n + 1, 0); + for (int i = 0; i < n; i++) { + int left = (i - nums[i] + 1) % n; + int right = (i + 1) % n; + diffs[left]--; + diffs[right]++; + if (left > right) { + diffs[0]--; + } + } + int best = 0; + int cur = n; + int maxScore = cur; + for (int k = 1; k < n; k++) { + cur += diffs[k]; + if (cur > maxScore) { + maxScore = cur; + best = k; + } + } + return best; + } +} diff --git a/tests/501-1000/798. smallest-rotation-with-highest-score/sol.go b/tests/501-1000/798. smallest-rotation-with-highest-score/sol.go new file mode 100644 index 00000000..556fadff --- /dev/null +++ b/tests/501-1000/798. smallest-rotation-with-highest-score/sol.go @@ -0,0 +1,24 @@ +func bestRotation(nums []int) int { + n := len(nums) + diffs := make([]int, n+1) + for i, num := range nums { + left := ((i - num + 1) % n + n) % n + right := (i + 1) % n + diffs[left]-- + diffs[right]++ + if left > right { + diffs[0]-- + } + } + best := 0 + cur := n + maxScore := cur + for k := 1; k < n; k++ { + cur += diffs[k] + if cur > maxScore { + maxScore = cur + best = k + } + } + return best +} diff --git a/tests/501-1000/798. smallest-rotation-with-highest-score/sol.java b/tests/501-1000/798. smallest-rotation-with-highest-score/sol.java new file mode 100644 index 00000000..ddb6a5e3 --- /dev/null +++ b/tests/501-1000/798. smallest-rotation-with-highest-score/sol.java @@ -0,0 +1,26 @@ +class Solution { + public int bestRotation(int[] nums) { + int n = nums.length; + int[] diffs = new int[n + 1]; + for (int i = 0; i < n; i++) { + int left = ((i - nums[i] + 1) % n + n) % n; + int right = (i + 1) % n; + diffs[left]--; + diffs[right]++; + if (left > right) { + diffs[0]--; + } + } + int best = 0; + int cur = n; + int maxScore = cur; + for (int k = 1; k < n; k++) { + cur += diffs[k]; + if (cur > maxScore) { + maxScore = cur; + best = k; + } + } + return best; + } +} diff --git a/tests/501-1000/798. smallest-rotation-with-highest-score/sol.kt b/tests/501-1000/798. smallest-rotation-with-highest-score/sol.kt new file mode 100644 index 00000000..35ca22f6 --- /dev/null +++ b/tests/501-1000/798. smallest-rotation-with-highest-score/sol.kt @@ -0,0 +1,26 @@ +class Solution { + fun bestRotation(nums: IntArray): Int { + val n = nums.size + val diffs = IntArray(n + 1) + for (i in 0 until n) { + val left = ((i - nums[i] + 1) % n + n) % n + val right = (i + 1) % n + diffs[left]-- + diffs[right]++ + if (left > right) { + diffs[0]-- + } + } + var best = 0 + var cur = n + var maxScore = cur + for (k in 1 until n) { + cur += diffs[k] + if (cur > maxScore) { + maxScore = cur + best = k + } + } + return best + } +} diff --git a/tests/501-1000/798. smallest-rotation-with-highest-score/sol.py b/tests/501-1000/798. smallest-rotation-with-highest-score/sol.py new file mode 100644 index 00000000..bf3a5af4 --- /dev/null +++ b/tests/501-1000/798. smallest-rotation-with-highest-score/sol.py @@ -0,0 +1,37 @@ +import numpy as np + + +class Solution: + def bestRotation(self, nums: List[int]) -> int: + n = len(nums) + nums = np.array(nums, dtype=np.int32) + indices = np.arange(n, dtype=np.int32) + + # 1. Calculate the 'Boundaries' for the 'Point Loss' intervals + # Left boundary: where the element starts to be worth 0 points + # Right boundary: where the element becomes worth 1 point again + left = (indices - nums + 1) % n + right = (indices + 1) % n + + # 2. Construct the Derivative Array (Difference Array) + # Instead of a loop, we use np.add.at for vectorized accumulation + # at specific boundary indices. + diffs = np.zeros(n + 1, dtype=np.int32) + + # Subtract at point-loss start, add at point-loss end + np.add.at(diffs, left, -1) + np.add.at(diffs, right, 1) + + # 3. Handle the Toroidal Wrap-around + # If left > right, the 'bad' interval crosses the k=0 boundary. + # We find these cases via vector comparison and apply the correction. + wraps = left > right + # For every wrapped interval, the score at k=0 is decreased + diffs[0] -= np.sum(wraps) + + # 4. Discrete Integration (Abel Accumulation) + # Integrating the deltas and adding the base constant 'n' + scores = np.cumsum(diffs[:-1]) + n + + # 5. Peak Detection on the Manifold + return int(np.argmax(scores)) diff --git a/tests/501-1000/798. smallest-rotation-with-highest-score/sol.py2 b/tests/501-1000/798. smallest-rotation-with-highest-score/sol.py2 new file mode 100644 index 00000000..d8195451 --- /dev/null +++ b/tests/501-1000/798. smallest-rotation-with-highest-score/sol.py2 @@ -0,0 +1,20 @@ +class Solution(object): + def bestRotation(self, nums): + n = len(nums) + diffs = [0] * (n + 1) + for i, num in enumerate(nums): + left = (i - num + 1) % n + right = (i + 1) % n + diffs[left] -= 1 + diffs[right] += 1 + if left > right: + diffs[0] -= 1 + best = 0 + cur = n + max_score = cur + for k in range(1, n): + cur += diffs[k] + if cur > max_score: + max_score = cur + best = k + return best diff --git a/tests/501-1000/798. smallest-rotation-with-highest-score/sol.rb b/tests/501-1000/798. smallest-rotation-with-highest-score/sol.rb new file mode 100644 index 00000000..35bb252e --- /dev/null +++ b/tests/501-1000/798. smallest-rotation-with-highest-score/sol.rb @@ -0,0 +1,24 @@ +# @param {Integer[]} nums +# @return {Integer} +def best_rotation(nums) + n = nums.length + diffs = Array.new(n + 1, 0) + nums.each_with_index do |num, i| + left = (i - num + 1) % n + right = (i + 1) % n + diffs[left] -= 1 + diffs[right] += 1 + diffs[0] -= 1 if left > right + end + best = 0 + cur = n + max_score = cur + (1...n).each do |k| + cur += diffs[k] + if cur > max_score + max_score = cur + best = k + end + end + best +end diff --git a/tests/501-1000/798. smallest-rotation-with-highest-score/sol.rs b/tests/501-1000/798. smallest-rotation-with-highest-score/sol.rs new file mode 100644 index 00000000..f4e7e0a0 --- /dev/null +++ b/tests/501-1000/798. smallest-rotation-with-highest-score/sol.rs @@ -0,0 +1,26 @@ +impl Solution { + pub fn best_rotation(nums: Vec) -> i32 { + let n = nums.len(); + let mut diffs = vec![0i32; n + 1]; + for i in 0..n { + let left = (i as i32 - nums[i] + 1).rem_euclid(n as i32) as usize; + let right = (i + 1) % n; + diffs[left] -= 1; + diffs[right] += 1; + if left > right { + diffs[0] -= 1; + } + } + let mut best = 0; + let mut cur = n as i32; + let mut max_score = cur; + for k in 1..n { + cur += diffs[k]; + if cur > max_score { + max_score = cur; + best = k as i32; + } + } + best + } +} diff --git a/tests/501-1000/798. smallest-rotation-with-highest-score/sol.swift b/tests/501-1000/798. smallest-rotation-with-highest-score/sol.swift new file mode 100644 index 00000000..5998c51d --- /dev/null +++ b/tests/501-1000/798. smallest-rotation-with-highest-score/sol.swift @@ -0,0 +1,26 @@ +class Solution { + func bestRotation(_ nums: [Int]) -> Int { + let n = nums.count + var diffs = [Int](repeating: 0, count: n + 1) + for i in 0.. right { + diffs[0] -= 1 + } + } + var best = 0 + var cur = n + var maxScore = cur + for k in 1.. maxScore { + maxScore = cur + best = k + } + } + return best + } +} diff --git a/tests/501-1000/798. smallest-rotation-with-highest-score/sol.ts b/tests/501-1000/798. smallest-rotation-with-highest-score/sol.ts new file mode 100644 index 00000000..37828d80 --- /dev/null +++ b/tests/501-1000/798. smallest-rotation-with-highest-score/sol.ts @@ -0,0 +1,24 @@ +function bestRotation(nums: number[]): number { + const n = nums.length; + const diffs = new Array(n + 1).fill(0); + for (let i = 0; i < n; i++) { + const left = (((i - nums[i] + 1) % n) + n) % n; + const right = (i + 1) % n; + diffs[left]--; + diffs[right]++; + if (left > right) { + diffs[0]--; + } + } + let best = 0; + let cur = n; + let maxScore = cur; + for (let k = 1; k < n; k++) { + cur += diffs[k]; + if (cur > maxScore) { + maxScore = cur; + best = k; + } + } + return best; +} diff --git a/tests/501-1000/799. champagne-tower/manifest.yaml b/tests/501-1000/799. champagne-tower/manifest.yaml new file mode 100644 index 00000000..23ac341c --- /dev/null +++ b/tests/501-1000/799. champagne-tower/manifest.yaml @@ -0,0 +1,227 @@ +entry: + id: 799 + title: champagne-tower + params: + poured: + type: int + query_row: + type: int + query_glass: + type: int + call: + cpp: "Solution().champagneTower({poured}, {query_row}, {query_glass})" + rust: "Solution::champagne_tower({poured}, {query_row}, {query_glass})" + python3: "Solution().champagneTower({poured}, {query_row}, {query_glass})" + python2: "Solution().champagneTower({poured}, {query_row}, {query_glass})" + ruby: "champagne_tower({poured}, {query_row}, {query_glass})" + java: "new Solution().champagneTower({poured}, {query_row}, {query_glass})" + csharp: "new Solution().ChampagneTower({poured}, {query_row}, {query_glass})" + kotlin: "Solution().champagneTower({poured}, {query_row}, {query_glass})" + go: "champagneTower({poured}, {query_row}, {query_glass})" + dart: "Solution().champagneTower({poured}, {query_row}, {query_glass})" + swift: "Solution().champagneTower({poured}, {query_row}, {query_glass})" + typescript: "champagneTower({poured}, {query_row}, {query_glass})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().check(poured, query_row, query_glass, {result})" + checker: | + class Checker: + def check(self, poured, query_row, query_glass, result): + tower = [[0.0] * 102 for _ in range(102)] + tower[0][0] = float(poured) + for r in range(query_row + 1): + for c in range(r + 1): + if tower[r][c] > 1.0: + excess = (tower[r][c] - 1.0) / 2.0 + tower[r][c] = 1.0 + tower[r + 1][c] += excess + tower[r + 1][c + 1] += excess + expected = tower[query_row][query_glass] + return abs(float(result) - expected) <= 1e-9 +seed: 799 +tests: + - name: ex1 + in: + poured: 1 + query_row: 1 + query_glass: 1 + - name: ex2 + in: + poured: 2 + query_row: 1 + query_glass: 1 + - name: ex3 + in: + poured: 100000009 + query_row: 33 + query_glass: 17 + - name: zero_top + in: + poured: 0 + query_row: 0 + query_glass: 0 + - name: one_top + in: + poured: 1 + query_row: 0 + query_glass: 0 + - name: two_rows_left + in: + poured: 2 + query_row: 1 + query_glass: 0 + - name: two_rows_right + in: + poured: 2 + query_row: 1 + query_glass: 0 + - name: three_center_half + in: + poured: 4 + query_row: 2 + query_glass: 1 + - name: three_edge_quarter + in: + poured: 4 + query_row: 2 + query_glass: 0 + - name: small_full_row + in: + poured: 3 + query_row: 1 + query_glass: 0 + - name: small_full_row_right + in: + poured: 3 + query_row: 1 + query_glass: 1 + - name: exact_one_more + in: + poured: 5 + query_row: 2 + query_glass: 1 + - name: exact_three_rows + in: + poured: 6 + query_row: 2 + query_glass: 1 + - name: medium_1 + in: + poured: 10 + query_row: 3 + query_glass: 1 + - name: medium_2 + in: + poured: 10 + query_row: 3 + query_glass: 2 + - name: medium_3 + in: + poured: 25 + query_row: 4 + query_glass: 2 + - name: medium_4 + in: + poured: 25 + query_row: 4 + query_glass: 0 + - name: medium_5 + in: + poured: 25 + query_row: 4 + query_glass: 4 + - name: medium_6 + in: + poured: 100 + query_row: 6 + query_glass: 3 + - name: medium_7 + in: + poured: 100 + query_row: 6 + query_glass: 0 + - name: medium_8 + in: + poured: 100 + query_row: 6 + query_glass: 6 + - name: medium_9 + in: + poured: 1000 + query_row: 10 + query_glass: 5 + - name: medium_10 + in: + poured: 1000 + query_row: 10 + query_glass: 0 + - name: medium_11 + in: + poured: 1000 + query_row: 10 + query_glass: 10 + - name: boundary_row_99_left + in: + poured: 1000000000 + query_row: 99 + query_glass: 0 + - name: boundary_row_99_mid + in: + poured: 1000000000 + query_row: 99 + query_glass: 50 + - name: boundary_row_99_right + in: + poured: 1000000000 + query_row: 99 + query_glass: 99 + - name: boundary_row_50 + in: + poured: 123456789 + query_row: 50 + query_glass: 25 + - name: boundary_row_50_edge + in: + poured: 123456789 + query_row: 50 + query_glass: 0 + - name: boundary_row_50_right + in: + poured: 123456789 + query_row: 50 + query_glass: 50 + - name: randomish_1 + in: + poured: 7 + query_row: 3 + query_glass: 0 + - name: randomish_2 + in: + poured: 7 + query_row: 3 + query_glass: 1 + - name: randomish_3 + in: + poured: 7 + query_row: 3 + query_glass: 2 + - name: randomish_4 + in: + poured: 7 + query_row: 3 + query_glass: 3 + - name: randomish_5 + in: + poured: 50 + query_row: 5 + query_glass: 2 + - name: randomish_6 + in: + poured: 50 + query_row: 5 + query_glass: 5 diff --git a/tests/501-1000/799. champagne-tower/sol.cpp b/tests/501-1000/799. champagne-tower/sol.cpp new file mode 100644 index 00000000..c9a4208d --- /dev/null +++ b/tests/501-1000/799. champagne-tower/sol.cpp @@ -0,0 +1,20 @@ +class Solution { +public: + double champagneTower(int poured, int query_row, int query_glass) { + vector> tower(102, vector(102, 0.0)); + tower[0][0] = poured; + + for (int r = 0; r <= query_row; r++) { + for (int c = 0; c <= r; c++) { + if (tower[r][c] > 1) { + double excess = (tower[r][c] - 1.0) / 2.0; + tower[r][c] = 1; + tower[r+1][c] += excess; + tower[r+1][c+1] += excess; + } + } + } + + return tower[query_row][query_glass]; + } +}; diff --git a/tests/501-1000/799. champagne-tower/sol.cs b/tests/501-1000/799. champagne-tower/sol.cs new file mode 100644 index 00000000..c3ca8c42 --- /dev/null +++ b/tests/501-1000/799. champagne-tower/sol.cs @@ -0,0 +1,22 @@ +public class Solution { + public double ChampagneTower(int poured, int query_row, int query_glass) { + double[][] tower = new double[102][]; + for (int i = 0; i < 102; i++) { + tower[i] = new double[102]; + } + tower[0][0] = poured; + + for (int r = 0; r <= query_row; r++) { + for (int c = 0; c <= r; c++) { + if (tower[r][c] > 1) { + double excess = (tower[r][c] - 1.0) / 2.0; + tower[r][c] = 1; + tower[r+1][c] += excess; + tower[r+1][c+1] += excess; + } + } + } + + return tower[query_row][query_glass]; + } +} diff --git a/tests/501-1000/799. champagne-tower/sol.dart b/tests/501-1000/799. champagne-tower/sol.dart new file mode 100644 index 00000000..dac78d86 --- /dev/null +++ b/tests/501-1000/799. champagne-tower/sol.dart @@ -0,0 +1,20 @@ +class Solution { + double champagneTower(int poured, int queryRow, int queryGlass) { + List> tower = + List.generate(102, (_) => List.filled(102, 0.0)); + tower[0][0] = poured.toDouble(); + + for (int r = 0; r <= queryRow; r++) { + for (int c = 0; c <= r; c++) { + if (tower[r][c] > 1.0) { + double excess = (tower[r][c] - 1.0) / 2.0; + tower[r][c] = 1.0; + tower[r + 1][c] += excess; + tower[r + 1][c + 1] += excess; + } + } + } + + return tower[queryRow][queryGlass]; + } +} diff --git a/tests/501-1000/799. champagne-tower/sol.go b/tests/501-1000/799. champagne-tower/sol.go new file mode 100644 index 00000000..a417b2e8 --- /dev/null +++ b/tests/501-1000/799. champagne-tower/sol.go @@ -0,0 +1,20 @@ +func champagneTower(poured int, query_row int, query_glass int) float64 { + tower := make([][]float64, 102) + for i := range tower { + tower[i] = make([]float64, 102) + } + tower[0][0] = float64(poured) + + for r := 0; r <= query_row; r++ { + for c := 0; c <= r; c++ { + if tower[r][c] > 1 { + excess := (tower[r][c] - 1.0) / 2.0 + tower[r][c] = 1 + tower[r+1][c] += excess + tower[r+1][c+1] += excess + } + } + } + + return tower[query_row][query_glass] +} diff --git a/tests/501-1000/799. champagne-tower/sol.java b/tests/501-1000/799. champagne-tower/sol.java new file mode 100644 index 00000000..6a5e77fe --- /dev/null +++ b/tests/501-1000/799. champagne-tower/sol.java @@ -0,0 +1,19 @@ +class Solution { + public double champagneTower(int poured, int query_row, int query_glass) { + double[][] tower = new double[102][102]; + tower[0][0] = poured; + + for (int r = 0; r <= query_row; r++) { + for (int c = 0; c <= r; c++) { + if (tower[r][c] > 1) { + double excess = (tower[r][c] - 1.0) / 2.0; + tower[r][c] = 1; + tower[r+1][c] += excess; + tower[r+1][c+1] += excess; + } + } + } + + return tower[query_row][query_glass]; + } +} diff --git a/tests/501-1000/799. champagne-tower/sol.kt b/tests/501-1000/799. champagne-tower/sol.kt new file mode 100644 index 00000000..681c3f3d --- /dev/null +++ b/tests/501-1000/799. champagne-tower/sol.kt @@ -0,0 +1,19 @@ +class Solution { + fun champagneTower(poured: Int, query_row: Int, query_glass: Int): Double { + val tower = Array(102) { DoubleArray(102) } + tower[0][0] = poured.toDouble() + + for (r in 0..query_row) { + for (c in 0..r) { + if (tower[r][c] > 1) { + val excess = (tower[r][c] - 1.0) / 2.0 + tower[r][c] = 1.0 + tower[r+1][c] += excess + tower[r+1][c+1] += excess + } + } + } + + return tower[query_row][query_glass] + } +} diff --git a/tests/501-1000/799. champagne-tower/sol.py b/tests/501-1000/799. champagne-tower/sol.py new file mode 100644 index 00000000..13c55249 --- /dev/null +++ b/tests/501-1000/799. champagne-tower/sol.py @@ -0,0 +1,14 @@ +class Solution: + def champagneTower(self, poured: int, query_row: int, query_glass: int) -> float: + tower = [[0] * 102 for _ in range(102)] + tower[0][0] = poured + + for r in range(query_row + 1): + for c in range(r + 1): + if tower[r][c] > 1: + excess = (tower[r][c] - 1.0) / 2.0 + tower[r][c] = 1 + tower[r + 1][c] += excess + tower[r + 1][c + 1] += excess + + return tower[query_row][query_glass] diff --git a/tests/501-1000/799. champagne-tower/sol.py2 b/tests/501-1000/799. champagne-tower/sol.py2 new file mode 100644 index 00000000..28aba3ef --- /dev/null +++ b/tests/501-1000/799. champagne-tower/sol.py2 @@ -0,0 +1,20 @@ +class Solution(object): + def champagneTower(self, poured, query_row, query_glass): + """ + :type poured: int + :type query_row: int + :type query_glass: int + :rtype: float + """ + tower = [[0] * 102 for _ in range(102)] + tower[0][0] = poured + + for r in range(query_row + 1): + for c in range(r + 1): + if tower[r][c] > 1: + excess = (tower[r][c] - 1.0) / 2.0 + tower[r][c] = 1 + tower[r+1][c] += excess + tower[r+1][c+1] += excess + + return tower[query_row][query_glass] diff --git a/tests/501-1000/799. champagne-tower/sol.rb b/tests/501-1000/799. champagne-tower/sol.rb new file mode 100644 index 00000000..8ef9f35d --- /dev/null +++ b/tests/501-1000/799. champagne-tower/sol.rb @@ -0,0 +1,21 @@ +# @param {Integer} poured +# @param {Integer} query_row +# @param {Integer} query_glass +# @return {Float} +def champagne_tower(poured, query_row, query_glass) + tower = Array.new(102) { Array.new(102, 0.0) } + tower[0][0] = poured + + (0..query_row).each do |r| + (0..r).each do |c| + if tower[r][c] > 1 + excess = (tower[r][c] - 1.0) / 2.0 + tower[r][c] = 1 + tower[r+1][c] += excess + tower[r+1][c+1] += excess + end + end + end + + tower[query_row][query_glass] +end diff --git a/tests/501-1000/799. champagne-tower/sol.rs b/tests/501-1000/799. champagne-tower/sol.rs new file mode 100644 index 00000000..d59d2db9 --- /dev/null +++ b/tests/501-1000/799. champagne-tower/sol.rs @@ -0,0 +1,19 @@ +impl Solution { + pub fn champagne_tower(poured: i32, query_row: i32, query_glass: i32) -> f64 { + let mut tower = vec![vec![0.0f64; 102]; 102]; + tower[0][0] = poured as f64; + + for r in 0..=query_row as usize { + for c in 0..=r { + if tower[r][c] > 1.0 { + let excess = (tower[r][c] - 1.0) / 2.0; + tower[r][c] = 1.0; + tower[r+1][c] += excess; + tower[r+1][c+1] += excess; + } + } + } + + tower[query_row as usize][query_glass as usize] + } +} diff --git a/tests/501-1000/799. champagne-tower/sol.swift b/tests/501-1000/799. champagne-tower/sol.swift new file mode 100644 index 00000000..183b2057 --- /dev/null +++ b/tests/501-1000/799. champagne-tower/sol.swift @@ -0,0 +1,19 @@ +class Solution { + func champagneTower(_ poured: Int, _ query_row: Int, _ query_glass: Int) -> Double { + var tower = Array(repeating: Array(repeating: 0.0, count: 102), count: 102) + tower[0][0] = Double(poured) + + for r in 0...query_row { + for c in 0...r { + if tower[r][c] > 1 { + let excess = (tower[r][c] - 1.0) / 2.0 + tower[r][c] = 1 + tower[r+1][c] += excess + tower[r+1][c+1] += excess + } + } + } + + return tower[query_row][query_glass] + } +} diff --git a/tests/501-1000/799. champagne-tower/sol.ts b/tests/501-1000/799. champagne-tower/sol.ts new file mode 100644 index 00000000..d6eecb88 --- /dev/null +++ b/tests/501-1000/799. champagne-tower/sol.ts @@ -0,0 +1,23 @@ +function champagneTower( + poured: number, + query_row: number, + query_glass: number, +): number { + const tower: number[][] = Array.from({ length: 102 }, () => + Array(102).fill(0), + ); + tower[0][0] = poured; + + for (let r = 0; r <= query_row; r++) { + for (let c = 0; c <= r; c++) { + if (tower[r][c] > 1) { + const excess = (tower[r][c] - 1.0) / 2.0; + tower[r][c] = 1; + tower[r + 1][c] += excess; + tower[r + 1][c + 1] += excess; + } + } + } + + return tower[query_row][query_glass]; +} diff --git a/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/manifest.yaml b/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/manifest.yaml new file mode 100644 index 00000000..9536d635 --- /dev/null +++ b/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/manifest.yaml @@ -0,0 +1,285 @@ +entry: + id: 801 + title: minimum-swaps-to-make-sequences-increasing + params: + nums1: + type: array + items: + type: int + nums2: + type: array + items: + type: int + call: + cpp: "Solution().minSwap({nums1}, {nums2})" + rust: "Solution::min_swap({nums1}, {nums2})" + python3: "Solution().minSwap({nums1}, {nums2})" + python2: "Solution().minSwap({nums1}, {nums2})" + ruby: "min_swap({nums1}, {nums2})" + java: "new Solution().minSwap({nums1}, {nums2})" + csharp: "new Solution().MinSwap({nums1}, {nums2})" + kotlin: "Solution().minSwap({nums1}, {nums2})" + go: "minSwap({nums1}, {nums2})" + dart: "Solution().minSwap({nums1}, {nums2})" + swift: "Solution().minSwap({nums1}, {nums2})" + typescript: "minSwap({nums1}, {nums2})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().check(nums1, nums2, {result})" + checker: | + class Checker: + def check(self, nums1, nums2, result): + n = len(nums1) + inf = 10 ** 9 + keep = [inf] * n + swap = [inf] * n + keep[0] = 0 + swap[0] = 1 + for i in range(1, n): + inc = nums1[i] > nums1[i - 1] and nums2[i] > nums2[i - 1] + cross = nums1[i] > nums2[i - 1] and nums2[i] > nums1[i - 1] + if inc and cross: + keep[i] = min(keep[i - 1], swap[i - 1]) + swap[i] = keep[i] + 1 + elif inc: + keep[i] = keep[i - 1] + swap[i] = swap[i - 1] + 1 + else: + keep[i] = swap[i - 1] + swap[i] = keep[i - 1] + 1 + return int(result) == min(keep[-1], swap[-1]) +seed: 801 +tests: + - name: ex1 + in: + nums1: [1, 3, 5, 4] + nums2: [1, 2, 3, 7] + - name: ex2 + in: + nums1: [0, 3, 5, 8, 9] + nums2: [2, 1, 4, 6, 9] + - name: len2_keep + in: + nums1: [1, 2] + nums2: [2, 3] + - name: len2_swap + in: + nums1: [3, 1] + nums2: [1, 2] + - name: len2_equal_fail + in: + nums1: [1, 1] + nums2: [2, 2] + - name: small_1 + in: + nums1: [1, 3, 5] + nums2: [1, 2, 3] + - name: small_2 + in: + nums1: [1, 2, 3] + nums2: [1, 3, 5] + - name: small_3 + in: + nums1: [0, 4, 5] + nums2: [1, 2, 3] + - name: small_4 + in: + nums1: [1, 5, 6] + nums2: [0, 2, 3] + - name: small_5 + in: + nums1: [2, 3, 4, 5] + nums2: [1, 2, 3, 4] + - name: small_6 + in: + nums1: [1, 4, 6, 8] + nums2: [2, 3, 5, 7] + - name: small_7 + in: + nums1: [0, 2, 4, 6] + nums2: [1, 3, 5, 7] + - name: small_8 + in: + nums1: [0, 1, 4, 7] + nums2: [1, 2, 3, 8] + - name: small_9 + in: + nums1: [3, 4, 5, 9] + nums2: [1, 2, 7, 8] + - name: small_10 + in: + nums1: [1, 7, 8, 10] + nums2: [0, 2, 3, 4] + - name: small_11 + in: + nums1: [1, 5, 3, 7] + nums2: [1, 2, 4, 8] + - name: small_12 + in: + nums1: [0, 6, 7, 8] + nums2: [1, 2, 3, 9] + - name: small_13 + in: + nums1: [1, 2, 6, 7] + nums2: [0, 3, 4, 5] + - name: small_14 + in: + nums1: [1, 4, 7, 10, 13] + nums2: [0, 2, 5, 8, 11] + - name: small_15 + in: + nums1: [0, 3, 6, 9, 12] + nums2: [1, 4, 7, 10, 13] + - name: small_16 + in: + nums1: [1, 3, 7, 8, 10] + nums2: [0, 2, 4, 9, 11] + - name: small_17 + in: + nums1: [1, 5, 6, 7, 9] + nums2: [0, 2, 3, 4, 8] + - name: small_18 + in: + nums1: [2, 4, 6, 8, 10] + nums2: [1, 3, 5, 7, 9] + - name: small_19 + in: + nums1: [1, 4, 7, 11, 12] + nums2: [0, 2, 5, 8, 13] + - name: small_20 + in: + nums1: [0, 2, 5, 8, 11] + nums2: [1, 3, 4, 7, 10] + - name: medium_1 + in: + nums1: [0, 1, 3, 5, 6, 8] + nums2: [1, 2, 4, 7, 9, 10] + - name: medium_2 + in: + nums1: [1, 4, 7, 9, 12, 15] + nums2: [0, 2, 5, 8, 10, 13] + - name: medium_3 + in: + nums1: [1, 6, 7, 11, 12, 16] + nums2: [0, 2, 3, 8, 9, 13] + - name: medium_4 + in: + nums1: [2, 3, 5, 8, 9, 14] + nums2: [1, 4, 6, 7, 10, 15] + - name: medium_5 + in: + nums1: [1, 3, 4, 9, 10, 11, 13] + nums2: [0, 2, 5, 6, 7, 8, 12] + - name: medium_6 + in: + nums1: [0, 2, 3, 6, 7, 11, 12] + nums2: [1, 4, 5, 8, 9, 10, 13] + - name: medium_7 + in: + nums1: [1, 4, 6, 7, 10, 14, 15] + nums2: [0, 2, 3, 5, 8, 12, 13] + - name: medium_8 + in: + nums1: [2, 5, 6, 9, 11, 13, 16] + nums2: [1, 3, 4, 7, 8, 10, 15] + - name: boundary_1 + in: + nums1: + - 0 + - 2 + - 4 + - 6 + - 8 + - 10 + - 12 + - 14 + - 16 + - 18 + nums2: + - 1 + - 3 + - 5 + - 7 + - 9 + - 11 + - 13 + - 15 + - 17 + - 19 + - name: boundary_2 + in: + nums1: + - 1 + - 3 + - 5 + - 7 + - 9 + - 11 + - 13 + - 15 + - 17 + - 19 + nums2: + - 0 + - 2 + - 4 + - 6 + - 8 + - 10 + - 12 + - 14 + - 16 + - 18 + - name: boundary_3 + in: + nums1: + - 0 + - 5 + - 6 + - 9 + - 10 + - 13 + - 14 + - 17 + - 18 + - 21 + nums2: + - 1 + - 2 + - 7 + - 8 + - 11 + - 12 + - 15 + - 16 + - 19 + - 20 + - name: boundary_4 + in: + nums1: + - 1 + - 2 + - 7 + - 8 + - 11 + - 12 + - 15 + - 16 + - 19 + - 20 + nums2: + - 0 + - 5 + - 6 + - 9 + - 10 + - 13 + - 14 + - 17 + - 18 + - 21 diff --git a/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.cpp b/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.cpp new file mode 100644 index 00000000..c8868c6d --- /dev/null +++ b/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.cpp @@ -0,0 +1,27 @@ +class Solution { +public: + int minSwap(vector& nums1, vector& nums2) { + int n = nums1.size(); + int keep = 0; + int swap = 1; + + for (int i = 1; i < n; i++) { + bool inc = nums1[i] > nums1[i - 1] && nums2[i] > nums2[i - 1]; + bool cross = nums1[i] > nums2[i - 1] && nums2[i] > nums1[i - 1]; + + if (inc && cross) { + int m = min(keep, swap); + keep = m; + swap = m + 1; + } else if (inc) { + swap += 1; + } else { + int temp = keep; + keep = swap; + swap = temp + 1; + } + } + + return min(keep, swap); + } +}; diff --git a/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.cs b/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.cs new file mode 100644 index 00000000..42019cf9 --- /dev/null +++ b/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.cs @@ -0,0 +1,26 @@ +public class Solution { + public int MinSwap(int[] nums1, int[] nums2) { + int n = nums1.Length; + int keep = 0; + int swap = 1; + + for (int i = 1; i < n; i++) { + bool inc = nums1[i] > nums1[i - 1] && nums2[i] > nums2[i - 1]; + bool cross = nums1[i] > nums2[i - 1] && nums2[i] > nums1[i - 1]; + + if (inc && cross) { + int m = Math.Min(keep, swap); + keep = m; + swap = m + 1; + } else if (inc) { + swap += 1; + } else { + int temp = keep; + keep = swap; + swap = temp + 1; + } + } + + return Math.Min(keep, swap); + } +} diff --git a/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.dart b/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.dart new file mode 100644 index 00000000..02a6d3eb --- /dev/null +++ b/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.dart @@ -0,0 +1,26 @@ +class Solution { + int minSwap(List nums1, List nums2) { + int n = nums1.length; + int keep = 0; + int swap = 1; + + for (int i = 1; i < n; i++) { + bool inc = nums1[i] > nums1[i - 1] && nums2[i] > nums2[i - 1]; + bool cross = nums1[i] > nums2[i - 1] && nums2[i] > nums1[i - 1]; + + if (inc && cross) { + int m = keep < swap ? keep : swap; + keep = m; + swap = m + 1; + } else if (inc) { + swap += 1; + } else { + int temp = keep; + keep = swap; + swap = temp + 1; + } + } + + return keep < swap ? keep : swap; + } +} diff --git a/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.go b/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.go new file mode 100644 index 00000000..99d5e6af --- /dev/null +++ b/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.go @@ -0,0 +1,28 @@ +func minSwap(nums1 []int, nums2 []int) int { + n := len(nums1) + keep := 0 + swap := 1 + + for i := 1; i < n; i++ { + inc := nums1[i] > nums1[i-1] && nums2[i] > nums2[i-1] + cross := nums1[i] > nums2[i-1] && nums2[i] > nums1[i-1] + + if inc && cross { + m := keep + if swap < keep { + m = swap + } + keep = m + swap = m + 1 + } else if inc { + swap += 1 + } else { + keep, swap = swap, keep + 1 + } + } + + if keep < swap { + return keep + } + return swap +} diff --git a/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.java b/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.java new file mode 100644 index 00000000..2642a2a9 --- /dev/null +++ b/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.java @@ -0,0 +1,26 @@ +class Solution { + public int minSwap(int[] nums1, int[] nums2) { + int n = nums1.length; + int keep = 0; + int swap = 1; + + for (int i = 1; i < n; i++) { + boolean inc = nums1[i] > nums1[i - 1] && nums2[i] > nums2[i - 1]; + boolean cross = nums1[i] > nums2[i - 1] && nums2[i] > nums1[i - 1]; + + if (inc && cross) { + int m = Math.min(keep, swap); + keep = m; + swap = m + 1; + } else if (inc) { + swap += 1; + } else { + int temp = keep; + keep = swap; + swap = temp + 1; + } + } + + return Math.min(keep, swap); + } +} diff --git a/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.kt b/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.kt new file mode 100644 index 00000000..46f373c5 --- /dev/null +++ b/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.kt @@ -0,0 +1,26 @@ +class Solution { + fun minSwap(nums1: IntArray, nums2: IntArray): Int { + val n = nums1.size + var keep = 0 + var swap = 1 + + for (i in 1 until n) { + val inc = nums1[i] > nums1[i - 1] && nums2[i] > nums2[i - 1] + val cross = nums1[i] > nums2[i - 1] && nums2[i] > nums1[i - 1] + + if (inc && cross) { + val m = minOf(keep, swap) + keep = m + swap = m + 1 + } else if (inc) { + swap += 1 + } else { + val temp = keep + keep = swap + swap = temp + 1 + } + } + + return minOf(keep, swap) + } +} diff --git a/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.py b/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.py new file mode 100644 index 00000000..4bf7a1bd --- /dev/null +++ b/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.py @@ -0,0 +1,19 @@ +class Solution: + def minSwap(self, nums1: List[int], nums2: List[int]) -> int: + n = len(nums1) + + keep = 0 + swap = 1 + + for i in range(1, n): + inc = nums1[i] > nums1[i - 1] and nums2[i] > nums2[i - 1] + cross = nums1[i] > nums2[i - 1] and nums2[i] > nums1[i - 1] + + if inc and cross: + keep, swap = min(keep, swap), min(keep, swap) + 1 + elif inc: + swap += 1 + else: + keep, swap = swap, keep + 1 + + return min(keep, swap) diff --git a/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.py2 b/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.py2 new file mode 100644 index 00000000..a090989f --- /dev/null +++ b/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.py2 @@ -0,0 +1,23 @@ +class Solution(object): + def minSwap(self, nums1, nums2): + """ + :type nums1: List[int] + :type nums2: List[int] + :rtype: int + """ + n = len(nums1) + keep = 0 + swap = 1 + + for i in range(1, n): + inc = nums1[i] > nums1[i - 1] and nums2[i] > nums2[i - 1] + cross = nums1[i] > nums2[i - 1] and nums2[i] > nums1[i - 1] + + if inc and cross: + keep, swap = min(keep, swap), min(keep, swap) + 1 + elif inc: + swap += 1 + else: + keep, swap = swap, keep + 1 + + return min(keep, swap) diff --git a/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.rb b/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.rb new file mode 100644 index 00000000..8520f8d0 --- /dev/null +++ b/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.rb @@ -0,0 +1,23 @@ +# @param {Integer[]} nums1 +# @param {Integer[]} nums2 +# @return {Integer} +def min_swap(nums1, nums2) + n = nums1.length + keep = 0 + swap = 1 + + for i in 1...n + inc = nums1[i] > nums1[i - 1] && nums2[i] > nums2[i - 1] + cross = nums1[i] > nums2[i - 1] && nums2[i] > nums1[i - 1] + + if inc && cross + keep, swap = [keep, swap].min, [keep, swap].min + 1 + elsif inc + swap += 1 + else + keep, swap = swap, keep + 1 + end + end + + [keep, swap].min +end diff --git a/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.rs b/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.rs new file mode 100644 index 00000000..223551ee --- /dev/null +++ b/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.rs @@ -0,0 +1,26 @@ +impl Solution { + pub fn min_swap(nums1: Vec, nums2: Vec) -> i32 { + let n = nums1.len(); + let mut keep = 0; + let mut swap = 1; + + for i in 1..n { + let inc = nums1[i] > nums1[i - 1] && nums2[i] > nums2[i - 1]; + let cross = nums1[i] > nums2[i - 1] && nums2[i] > nums1[i - 1]; + + if inc && cross { + let m = keep.min(swap); + keep = m; + swap = m + 1; + } else if inc { + swap += 1; + } else { + let temp = keep; + keep = swap; + swap = temp + 1; + } + } + + keep.min(swap) + } +} diff --git a/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.swift b/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.swift new file mode 100644 index 00000000..ec2f4fee --- /dev/null +++ b/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.swift @@ -0,0 +1,26 @@ +class Solution { + func minSwap(_ nums1: [Int], _ nums2: [Int]) -> Int { + let n = nums1.count + var keep = 0 + var swap = 1 + + for i in 1.. nums1[i - 1] && nums2[i] > nums2[i - 1] + let cross = nums1[i] > nums2[i - 1] && nums2[i] > nums1[i - 1] + + if inc && cross { + let m = min(keep, swap) + keep = m + swap = m + 1 + } else if inc { + swap += 1 + } else { + let temp = keep + keep = swap + swap = temp + 1 + } + } + + return min(keep, swap) + } +} diff --git a/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.ts b/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.ts new file mode 100644 index 00000000..3b5d253a --- /dev/null +++ b/tests/501-1000/801. minimum-swaps-to-make-sequences-increasing/sol.ts @@ -0,0 +1,24 @@ +function minSwap(nums1: number[], nums2: number[]): number { + const n = nums1.length; + let keep = 0; + let swap = 1; + + for (let i = 1; i < n; i++) { + const inc = nums1[i] > nums1[i - 1] && nums2[i] > nums2[i - 1]; + const cross = nums1[i] > nums2[i - 1] && nums2[i] > nums1[i - 1]; + + if (inc && cross) { + const m = Math.min(keep, swap); + keep = m; + swap = m + 1; + } else if (inc) { + swap += 1; + } else { + const temp = keep; + keep = swap; + swap = temp + 1; + } + } + + return Math.min(keep, swap); +} diff --git a/tests/501-1000/802. find-eventual-safe-states/manifest.yaml b/tests/501-1000/802. find-eventual-safe-states/manifest.yaml new file mode 100644 index 00000000..d5e96433 --- /dev/null +++ b/tests/501-1000/802. find-eventual-safe-states/manifest.yaml @@ -0,0 +1,322 @@ +entry: + id: 802 + title: "find-eventual-safe-states" + params: + graph: + type: array + items: + type: array + items: + type: int + call: + cpp: Solution().eventualSafeNodes({graph}) + rust: Solution::eventual_safe_nodes({graph}) + python3: Solution().eventualSafeNodes({graph}) + python2: Solution().eventualSafeNodes({graph}) + ruby: eventual_safe_nodes({graph}) + java: new Solution().eventualSafeNodes({graph}) + csharp: new Solution().EventualSafeNodes({graph}) + kotlin: Solution().eventualSafeNodes({graph}) + go: eventualSafeNodes({graph}) + dart: Solution().eventualSafeNodes({graph}) + swift: Solution().eventualSafeNodes({graph}) + typescript: eventualSafeNodes({graph}) + +judge: + type: "exact" + +limits: + time_ms: 500 + memory_mb: 256 + +oracle: + python3: + call: "Checker().check(graph, {result})" + checker: | + class Checker: + def check(self, graph, result): + n = len(graph) + state = [0] * n + + def dfs(node): + if state[node] != 0: + return state[node] == 2 + state[node] = 1 + for nxt in graph[node]: + if state[nxt] == 1 or not dfs(nxt): + return False + state[node] = 2 + return True + + expected = [i for i in range(n) if dfs(i)] + return result == expected + +seed: 802 + +tests: + - name: case01 + in: + graph: + - [] + - name: case02 + in: + graph: + - [1] + - [] + - name: case03 + in: + graph: + - [1] + - [2] + - [] + - name: case04 + in: + graph: + - [1] + - [0] + - name: case05 + in: + graph: + - [1, 2] + - [2, 3] + - [5] + - [0] + - [5] + - [] + - name: case06 + in: + graph: + - [1] + - [2] + - [0] + - [] + - name: case07 + in: + graph: + - [1, 2] + - [2] + - [3] + - [] + - name: case08 + in: + graph: + - [1] + - [2] + - [3] + - [1] + - name: case09 + in: + graph: + - [1, 2] + - [2, 3] + - [3] + - [] + - name: case10 + in: + graph: + - [1, 3] + - [2] + - [1] + - [] + - name: case11 + in: + graph: + - [1, 2] + - [3] + - [3] + - [] + - name: case12 + in: + graph: + - [1] + - [2, 3] + - [3] + - [4] + - [] + - name: case13 + in: + graph: + - [1] + - [] + - [0, 3] + - [] + - name: case14 + in: + graph: + - [1, 2] + - [2] + - [0] + - [4] + - [] + - name: case15 + in: + graph: + - [1] + - [2] + - [3] + - [4] + - [5] + - [] + - name: case16 + in: + graph: + - [1, 2] + - [2, 3] + - [3, 4] + - [4] + - [] + - name: case17 + in: + graph: + - [1] + - [0] + - [3] + - [2] + - [] + - name: case18 + in: + graph: + - [1, 2, 3] + - [] + - [1] + - [4] + - [] + - name: case19 + in: + graph: + - [1] + - [2] + - [1, 3] + - [] + - name: case20 + in: + graph: + - [1, 2] + - [3] + - [3] + - [4] + - [2] + - name: case21 + in: + graph: + - [] + - [0] + - [1] + - [2] + - name: case22 + in: + graph: + - [1] + - [2, 4] + - [3] + - [] + - [] + - name: case23 + in: + graph: + - [1, 2] + - [3] + - [3, 4] + - [5] + - [5] + - [] + - name: case24 + in: + graph: + - [1] + - [2] + - [3] + - [4] + - [2] + - name: case25 + in: + graph: + - [1, 2] + - [3] + - [3] + - [] + - [0] + - name: case26 + in: + graph: + - [1] + - [2] + - [] + - [1] + - [3] + - name: case27 + in: + graph: + - [1, 2] + - [2] + - [0] + - [4, 5] + - [5] + - [] + - name: case28 + in: + graph: + - [1] + - [] + - [3, 4] + - [4] + - [] + - name: case29 + in: + graph: + - [1, 2] + - [0] + - [3] + - [4] + - [] + - name: case30 + in: + graph: + - [1] + - [2] + - [0] + - [4] + - [3] + - name: case31 + in: + graph: + - [1, 2] + - [2, 3] + - [4] + - [4] + - [] + - name: case32 + in: + graph: + - [1] + - [0] + - [3] + - [] + - [2, 3] + - name: case33 + in: + graph: + - [1, 2] + - [3] + - [3] + - [4] + - [] + - [2] + - name: case34 + in: + graph: + - [1] + - [2] + - [3] + - [1] + - [5] + - [] + - name: case35 + in: + graph: + - [] + - [2] + - [3] + - [1] + - [5] + - [4] diff --git a/tests/501-1000/802. find-eventual-safe-states/sol.cpp b/tests/501-1000/802. find-eventual-safe-states/sol.cpp new file mode 100644 index 00000000..d87bdd87 --- /dev/null +++ b/tests/501-1000/802. find-eventual-safe-states/sol.cpp @@ -0,0 +1,33 @@ +class Solution { +public: + vector eventualSafeNodes(vector>& graph) { + int n = graph.size(); + vector state(n, 0); // 0: unvisited, 1: visiting, 2: safe + vector safe; + + function dfs = [&](int node) -> bool { + if (state[node] > 0) { + return state[node] == 2; + } + + state[node] = 1; + + for (int neighbor : graph[node]) { + if (state[neighbor] == 1 || !dfs(neighbor)) { + return false; + } + } + + state[node] = 2; + return true; + }; + + for (int i = 0; i < n; i++) { + if (dfs(i)) { + safe.push_back(i); + } + } + + return safe; + } +}; diff --git a/tests/501-1000/802. find-eventual-safe-states/sol.cs b/tests/501-1000/802. find-eventual-safe-states/sol.cs new file mode 100644 index 00000000..9e59f5b4 --- /dev/null +++ b/tests/501-1000/802. find-eventual-safe-states/sol.cs @@ -0,0 +1,32 @@ +public class Solution { + public IList EventualSafeNodes(int[][] graph) { + int n = graph.Length; + int[] state = new int[n]; // 0: unvisited, 1: visiting, 2: safe + List safe = new List(); + + bool Dfs(int node) { + if (state[node] > 0) { + return state[node] == 2; + } + + state[node] = 1; + + foreach (int neighbor in graph[node]) { + if (state[neighbor] == 1 || !Dfs(neighbor)) { + return false; + } + } + + state[node] = 2; + return true; + } + + for (int i = 0; i < n; i++) { + if (Dfs(i)) { + safe.Add(i); + } + } + + return safe; + } +} diff --git a/tests/501-1000/802. find-eventual-safe-states/sol.dart b/tests/501-1000/802. find-eventual-safe-states/sol.dart new file mode 100644 index 00000000..78e6a720 --- /dev/null +++ b/tests/501-1000/802. find-eventual-safe-states/sol.dart @@ -0,0 +1,32 @@ +class Solution { + List eventualSafeNodes(List> graph) { + int n = graph.length; + List state = List.filled(n, 0); // 0: unvisited, 1: visiting, 2: safe + List safe = []; + + bool dfs(int node) { + if (state[node] > 0) { + return state[node] == 2; + } + + state[node] = 1; + + for (int neighbor in graph[node]) { + if (state[neighbor] == 1 || !dfs(neighbor)) { + return false; + } + } + + state[node] = 2; + return true; + } + + for (int i = 0; i < n; i++) { + if (dfs(i)) { + safe.add(i); + } + } + + return safe; + } +} diff --git a/tests/501-1000/802. find-eventual-safe-states/sol.go b/tests/501-1000/802. find-eventual-safe-states/sol.go new file mode 100644 index 00000000..6edbfde1 --- /dev/null +++ b/tests/501-1000/802. find-eventual-safe-states/sol.go @@ -0,0 +1,31 @@ +func eventualSafeNodes(graph [][]int) []int { + n := len(graph) + state := make([]int, n) // 0: unvisited, 1: visiting, 2: safe + safe := make([]int, 0) + + var dfs func(int) bool + dfs = func(node int) bool { + if state[node] > 0 { + return state[node] == 2 + } + + state[node] = 1 + + for _, neighbor := range graph[node] { + if state[neighbor] == 1 || !dfs(neighbor) { + return false + } + } + + state[node] = 2 + return true + } + + for i := 0; i < n; i++ { + if dfs(i) { + safe = append(safe, i) + } + } + + return safe +} diff --git a/tests/501-1000/802. find-eventual-safe-states/sol.java b/tests/501-1000/802. find-eventual-safe-states/sol.java new file mode 100644 index 00000000..be06f977 --- /dev/null +++ b/tests/501-1000/802. find-eventual-safe-states/sol.java @@ -0,0 +1,32 @@ +class Solution { + public List eventualSafeNodes(int[][] graph) { + int n = graph.length; + int[] state = new int[n]; // 0: unvisited, 1: visiting, 2: safe + List safe = new ArrayList<>(); + + for (int i = 0; i < n; i++) { + if (dfs(i, graph, state)) { + safe.add(i); + } + } + + return safe; + } + + private boolean dfs(int node, int[][] graph, int[] state) { + if (state[node] > 0) { + return state[node] == 2; + } + + state[node] = 1; + + for (int neighbor : graph[node]) { + if (state[neighbor] == 1 || !dfs(neighbor, graph, state)) { + return false; + } + } + + state[node] = 2; + return true; + } +} diff --git a/tests/501-1000/802. find-eventual-safe-states/sol.kt b/tests/501-1000/802. find-eventual-safe-states/sol.kt new file mode 100644 index 00000000..05a07a2e --- /dev/null +++ b/tests/501-1000/802. find-eventual-safe-states/sol.kt @@ -0,0 +1,32 @@ +class Solution { + fun eventualSafeNodes(graph: Array): List { + val n = graph.size + val state = IntArray(n) // 0: unvisited, 1: visiting, 2: safe + val safe = mutableListOf() + + fun dfs(node: Int): Boolean { + if (state[node] > 0) { + return state[node] == 2 + } + + state[node] = 1 + + for (neighbor in graph[node]) { + if (state[neighbor] == 1 || !dfs(neighbor)) { + return false + } + } + + state[node] = 2 + return true + } + + for (i in 0 until n) { + if (dfs(i)) { + safe.add(i) + } + } + + return safe + } +} diff --git a/tests/501-1000/802. find-eventual-safe-states/sol.py b/tests/501-1000/802. find-eventual-safe-states/sol.py new file mode 100644 index 00000000..465705fd --- /dev/null +++ b/tests/501-1000/802. find-eventual-safe-states/sol.py @@ -0,0 +1,24 @@ +class Solution: + def eventualSafeNodes(self, graph): + n = len(graph) + state = [0] * n # 0: unvisited, 1: visiting, 2: safe + safe = [] + + def dfs(node): + if state[node] > 0: + return state[node] == 2 # Return true if already safe + + state[node] = 1 # Mark as visiting + + for neighbor in graph[node]: + if state[neighbor] == 1 or not dfs(neighbor): + return False # Cycle detected + + state[node] = 2 # Mark as safe + return True + + for i in range(n): + if dfs(i): + safe.append(i) + + return safe diff --git a/tests/501-1000/802. find-eventual-safe-states/sol.py2 b/tests/501-1000/802. find-eventual-safe-states/sol.py2 new file mode 100644 index 00000000..df9e7d7b --- /dev/null +++ b/tests/501-1000/802. find-eventual-safe-states/sol.py2 @@ -0,0 +1,28 @@ +class Solution(object): + def eventualSafeNodes(self, graph): + """ + :type graph: List[List[int]] + :rtype: List[int] + """ + n = len(graph) + state = [0] * n # 0: unvisited, 1: visiting, 2: safe + safe = [] + + def dfs(node): + if state[node] > 0: + return state[node] == 2 + + state[node] = 1 + + for neighbor in graph[node]: + if state[neighbor] == 1 or not dfs(neighbor): + return False + + state[node] = 2 + return True + + for i in range(n): + if dfs(i): + safe.append(i) + + return safe diff --git a/tests/501-1000/802. find-eventual-safe-states/sol.rb b/tests/501-1000/802. find-eventual-safe-states/sol.rb new file mode 100644 index 00000000..48bb2623 --- /dev/null +++ b/tests/501-1000/802. find-eventual-safe-states/sol.rb @@ -0,0 +1,32 @@ +# @param {Integer[][]} graph +# @return {Integer[]} +def eventual_safe_nodes(graph) + n = graph.length + state = Array.new(n, 0) # 0: unvisited, 1: visiting, 2: safe + safe = [] + + dfs = lambda do |node| + if state[node] > 0 + return state[node] == 2 + end + + state[node] = 1 + + graph[node].each do |neighbor| + if state[neighbor] == 1 || !dfs.call(neighbor) + return false + end + end + + state[node] = 2 + return true + end + + (0...n).each do |i| + if dfs.call(i) + safe << i + end + end + + safe +end diff --git a/tests/501-1000/802. find-eventual-safe-states/sol.rs b/tests/501-1000/802. find-eventual-safe-states/sol.rs new file mode 100644 index 00000000..7eabf224 --- /dev/null +++ b/tests/501-1000/802. find-eventual-safe-states/sol.rs @@ -0,0 +1,33 @@ +impl Solution { + pub fn eventual_safe_nodes(graph: Vec>) -> Vec { + let n = graph.len(); + let mut state = vec![0; n]; // 0: unvisited, 1: visiting, 2: safe + let mut safe = Vec::new(); + + fn dfs(node: usize, graph: &Vec>, state: &mut Vec) -> bool { + if state[node] > 0 { + return state[node] == 2; + } + + state[node] = 1; + + for &neighbor in &graph[node] { + let neighbor = neighbor as usize; + if state[neighbor] == 1 || !dfs(neighbor, graph, state) { + return false; + } + } + + state[node] = 2; + true + } + + for i in 0..n { + if dfs(i, &graph, &mut state) { + safe.push(i as i32); + } + } + + safe + } +} diff --git a/tests/501-1000/802. find-eventual-safe-states/sol.swift b/tests/501-1000/802. find-eventual-safe-states/sol.swift new file mode 100644 index 00000000..14ef2673 --- /dev/null +++ b/tests/501-1000/802. find-eventual-safe-states/sol.swift @@ -0,0 +1,32 @@ +class Solution { + func eventualSafeNodes(_ graph: [[Int]]) -> [Int] { + let n = graph.count + var state = [Int](repeating: 0, count: n) // 0: unvisited, 1: visiting, 2: safe + var safe = [Int]() + + func dfs(_ node: Int) -> Bool { + if state[node] > 0 { + return state[node] == 2 + } + + state[node] = 1 + + for neighbor in graph[node] { + if state[neighbor] == 1 || !dfs(neighbor) { + return false + } + } + + state[node] = 2 + return true + } + + for i in 0.. 0) { + return state[node] === 2; + } + + state[node] = 1; + + for (const neighbor of graph[node]) { + if (state[neighbor] === 1 || !dfs(neighbor)) { + return false; + } + } + + state[node] = 2; + return true; + } + + for (let i = 0; i < n; i++) { + if (dfs(i)) { + safe.push(i); + } + } + + return safe; +} diff --git a/tests/501-1000/803. bricks-falling-when-hit/manifest.yaml b/tests/501-1000/803. bricks-falling-when-hit/manifest.yaml new file mode 100644 index 00000000..05c61404 --- /dev/null +++ b/tests/501-1000/803. bricks-falling-when-hit/manifest.yaml @@ -0,0 +1,388 @@ +entry: + id: 803 + title: "bricks-falling-when-hit" + params: + grid: + type: array + items: + type: array + items: + type: int + hits: + type: array + items: + type: array + items: + type: int + call: + cpp: Solution().hitBricks({grid}, {hits}) + rust: Solution::hit_bricks({grid}, {hits}) + python3: Solution().hitBricks({grid}, {hits}) + python2: Solution().hitBricks({grid}, {hits}) + ruby: hit_bricks({grid}, {hits}) + java: new Solution().hitBricks({grid}, {hits}) + csharp: new Solution().HitBricks({grid}, {hits}) + kotlin: Solution().hitBricks({grid}, {hits}) + go: hitBricks({grid}, {hits}) + dart: Solution().hitBricks({grid}, {hits}) + swift: Solution().hitBricks({grid}, {hits}) + typescript: hitBricks({grid}, {hits}) + +judge: + type: "exact" + +limits: + time_ms: 500 + memory_mb: 256 + +oracle: + python3: + call: "Checker().check(grid, hits, {result})" + checker: | + class Checker: + def check(self, grid, hits, result): + rows = len(grid) + cols = len(grid[0]) + work = [row[:] for row in grid] + for r, c in hits: + if 0 <= r < rows and 0 <= c < cols: + work[r][c] -= 1 + + parent = list(range(rows * cols + 1)) + size = [1] * (rows * cols + 1) + roof = rows * cols + + def idx(r, c): + return r * cols + c + + def find(x): + while parent[x] != x: + parent[x] = parent[parent[x]] + x = parent[x] + return x + + def union(a, b): + ra = find(a) + rb = find(b) + if ra == rb: + return + if size[ra] < size[rb]: + ra, rb = rb, ra + parent[rb] = ra + size[ra] += size[rb] + + def roof_size(): + return size[find(roof)] + + for r in range(rows): + for c in range(cols): + if work[r][c] != 1: + continue + if r == 0: + union(idx(r, c), roof) + if r > 0 and work[r - 1][c] == 1: + union(idx(r, c), idx(r - 1, c)) + if c > 0 and work[r][c - 1] == 1: + union(idx(r, c), idx(r, c - 1)) + + ans = [0] * len(hits) + for i in range(len(hits) - 1, -1, -1): + r, c = hits[i] + if grid[r][c] == 0: + continue + prev = roof_size() + work[r][c] += 1 + if work[r][c] != 1: + continue + cur = idx(r, c) + if r == 0: + union(cur, roof) + for dr, dc in ((1, 0), (-1, 0), (0, 1), (0, -1)): + nr, nc = r + dr, c + dc + if 0 <= nr < rows and 0 <= nc < cols and work[nr][nc] == 1: + union(cur, idx(nr, nc)) + ans[i] = max(0, roof_size() - prev - 1) + + return result == ans + +seed: 803 + +tests: + - name: case01 + in: + grid: + - [1] + hits: + - [0, 0] + - name: case02 + in: + grid: + - [1] + hits: + - [0, 0] + - [0, 0] + - name: case03 + in: + grid: + - [1, 0] + - [1, 1] + hits: + - [1, 0] + - name: case04 + in: + grid: + - [1, 1] + - [1, 0] + hits: + - [1, 0] + - name: case05 + in: + grid: + - [1, 1] + - [1, 1] + hits: + - [1, 1] + - name: case06 + in: + grid: + - [1, 0, 1] + - [1, 1, 1] + hits: + - [1, 1] + - name: case07 + in: + grid: + - [1, 1, 1] + - [0, 1, 0] + - [0, 1, 0] + hits: + - [0, 1] + - name: case08 + in: + grid: + - [1, 1, 0] + - [1, 1, 1] + - [0, 1, 0] + hits: + - [1, 1] + - name: case09 + in: + grid: + - [1, 1, 1] + - [1, 0, 1] + - [1, 1, 1] + hits: + - [1, 0] + - name: case10 + in: + grid: + - [1, 0, 0] + - [1, 1, 1] + - [0, 1, 0] + hits: + - [1, 2] + - [1, 1] + - name: case11 + in: + grid: + - [1, 1, 1, 1] + hits: + - [0, 2] + - name: case12 + in: + grid: + - [1, 1, 1, 1] + - [1, 1, 1, 1] + hits: + - [1, 1] + - name: case13 + in: + grid: + - [1, 0, 1, 0] + - [1, 1, 1, 1] + hits: + - [1, 0] + - [1, 2] + - name: case14 + in: + grid: + - [1, 1, 0] + - [1, 1, 1] + - [1, 0, 1] + hits: + - [0, 0] + - name: case15 + in: + grid: + - [1, 1, 1] + - [1, 1, 1] + - [1, 1, 1] + hits: + - [2, 1] + - name: case16 + in: + grid: + - [0, 1, 0] + - [1, 1, 1] + - [0, 1, 0] + hits: + - [1, 1] + - name: case17 + in: + grid: + - [1, 0, 1] + - [1, 1, 1] + - [1, 0, 1] + hits: + - [1, 0] + - name: case18 + in: + grid: + - [1, 1, 1, 0] + - [1, 0, 1, 1] + - [1, 1, 1, 1] + hits: + - [2, 3] + - name: case19 + in: + grid: + - [1, 1, 0] + - [0, 1, 0] + - [1, 1, 1] + hits: + - [2, 0] + - name: case20 + in: + grid: + - [1, 1] + - [1, 1] + - [1, 1] + hits: + - [0, 1] + - [2, 0] + - name: case21 + in: + grid: + - [1, 0, 1] + - [1, 1, 0] + - [0, 1, 1] + hits: + - [0, 2] + - [2, 2] + - name: case22 + in: + grid: + - [1, 1, 1] + - [0, 1, 0] + - [1, 1, 1] + hits: + - [1, 1] + - [0, 1] + - name: case23 + in: + grid: + - [1, 1, 1, 1] + - [1, 0, 0, 1] + - [1, 1, 1, 1] + hits: + - [1, 3] + - name: case24 + in: + grid: + - [1, 1, 0, 1] + - [1, 1, 1, 1] + - [0, 1, 0, 1] + hits: + - [1, 2] + - name: case25 + in: + grid: + - [1, 1, 1] + - [1, 1, 1] + - [1, 1, 1] + hits: + - [0, 0] + - [1, 1] + - [2, 2] + - name: case26 + in: + grid: + - [1, 0, 1, 1] + - [1, 1, 1, 0] + - [0, 1, 0, 1] + hits: + - [0, 0] + - name: case27 + in: + grid: + - [1, 1, 1] + - [1, 0, 1] + - [1, 1, 1] + hits: + - [0, 2] + - [2, 0] + - name: case28 + in: + grid: + - [1, 1, 1, 0] + - [1, 1, 1, 1] + - [0, 1, 1, 1] + hits: + - [1, 1] + - name: case29 + in: + grid: + - [0, 1, 0] + - [1, 1, 1] + - [0, 1, 0] + hits: + - [0, 1] + - name: case30 + in: + grid: + - [1, 1, 0] + - [1, 1, 0] + - [0, 1, 1] + hits: + - [2, 1] + - name: case31 + in: + grid: + - [1, 1, 1] + - [1, 1, 1] + hits: + - [0, 0] + - name: case32 + in: + grid: + - [1, 0, 1, 0] + - [1, 1, 1, 1] + hits: + - [1, 3] + - [1, 1] + - name: case33 + in: + grid: + - [1, 1, 1] + - [0, 1, 0] + - [1, 1, 1] + hits: + - [2, 1] + - [0, 1] + - name: case34 + in: + grid: + - [1, 1] + - [1, 0] + - [1, 1] + hits: + - [2, 0] + - name: case35 + in: + grid: + - [1, 0, 1] + - [1, 1, 1] + - [1, 1, 0] + hits: + - [1, 2] + - [0, 2] diff --git a/tests/501-1000/803. bricks-falling-when-hit/sol.cpp b/tests/501-1000/803. bricks-falling-when-hit/sol.cpp new file mode 100644 index 00000000..09f79ade --- /dev/null +++ b/tests/501-1000/803. bricks-falling-when-hit/sol.cpp @@ -0,0 +1,85 @@ +class Solution { +public: + vector hitBricks(vector>& grid, vector>& hits) { + int m = grid.size(), n = grid[0].size(); + vector parent(m * n + 1); + vector rank(m * n + 1, 1); + for (int i = 0; i <= m * n; i++) { + parent[i] = i; + } + + function find = [&](int p) { + if (p != parent[p]) { + parent[p] = find(parent[p]); + } + return parent[p]; + }; + + auto unionSets = [&](int p, int q) { + int rootP = find(p); + int rootQ = find(q); + if (rootP == rootQ) return false; + if (rank[rootP] > rank[rootQ]) { + swap(rootP, rootQ); + } + parent[rootP] = rootQ; + rank[rootQ] += rank[rootP]; + return true; + }; + + unordered_set seen; + for (auto& hit : hits) { + int i = hit[0], j = hit[1]; + if (grid[i][j] == 1) { + seen.insert(i * n + j); + grid[i][j] = 0; + } + } + + for (int j = 0; j < n; j++) { + if (grid[0][j] == 1) { + unionSets(j, m * n); + } + } + + for (int i = 0; i < m; i++) { + for (int j = 0; j < n; j++) { + if (grid[i][j] == 1) { + if (i > 0 && grid[i-1][j] == 1) { + unionSets(i * n + j, (i-1) * n + j); + } + if (j > 0 && grid[i][j-1] == 1) { + unionSets(i * n + j, i * n + j - 1); + } + } + } + } + + vector ans(hits.size()); + int prevStable = rank[find(m * n)]; + vector> dirs = {{1,0}, {-1,0}, {0,1}, {0,-1}}; + + for (int idx = hits.size() - 1; idx >= 0; idx--) { + int i = hits[idx][0], j = hits[idx][1]; + if (seen.count(i * n + j)) { + grid[i][j] = 1; + if (i == 0) { + unionSets(j, m * n); + } + for (auto& [di, dj] : dirs) { + int ii = i + di, jj = j + dj; + if (ii >= 0 && ii < m && jj >= 0 && jj < n && grid[ii][jj] == 1) { + unionSets(i * n + j, ii * n + jj); + } + } + int currStable = rank[find(m * n)]; + ans[idx] = max(0, currStable - prevStable - 1); + prevStable = currStable; + } else { + ans[idx] = 0; + } + } + + return ans; + } +}; diff --git a/tests/501-1000/803. bricks-falling-when-hit/sol.cs b/tests/501-1000/803. bricks-falling-when-hit/sol.cs new file mode 100644 index 00000000..c8124a3f --- /dev/null +++ b/tests/501-1000/803. bricks-falling-when-hit/sol.cs @@ -0,0 +1,87 @@ +public class Solution { + public int[] HitBricks(int[][] grid, int[][] hits) { + int m = grid.Length, n = grid[0].Length; + int[] parent = new int[m * n + 1]; + int[] rank = new int[m * n + 1]; + for (int i = 0; i <= m * n; i++) { + parent[i] = i; + rank[i] = 1; + } + + int Find(int p) { + if (p != parent[p]) { + parent[p] = Find(parent[p]); + } + return parent[p]; + } + + bool Union(int p, int q) { + int rootP = Find(p); + int rootQ = Find(q); + if (rootP == rootQ) return false; + if (rank[rootP] > rank[rootQ]) { + int tmp = rootP; + rootP = rootQ; + rootQ = tmp; + } + parent[rootP] = rootQ; + rank[rootQ] += rank[rootP]; + return true; + } + + HashSet seen = new HashSet(); + foreach (var hit in hits) { + int i = hit[0], j = hit[1]; + if (grid[i][j] == 1) { + seen.Add(i * n + j); + grid[i][j] = 0; + } + } + + for (int j = 0; j < n; j++) { + if (grid[0][j] == 1) { + Union(j, m * n); + } + } + + for (int i = 0; i < m; i++) { + for (int j = 0; j < n; j++) { + if (grid[i][j] == 1) { + if (i > 0 && grid[i-1][j] == 1) { + Union(i * n + j, (i-1) * n + j); + } + if (j > 0 && grid[i][j-1] == 1) { + Union(i * n + j, i * n + j - 1); + } + } + } + } + + int[] ans = new int[hits.Length]; + int prevStable = rank[Find(m * n)]; + int[][] dirs = new int[][] { new int[]{1,0}, new int[]{-1,0}, new int[]{0,1}, new int[]{0,-1} }; + + for (int idx = hits.Length - 1; idx >= 0; idx--) { + int i = hits[idx][0], j = hits[idx][1]; + if (seen.Contains(i * n + j)) { + grid[i][j] = 1; + if (i == 0) { + Union(j, m * n); + } + foreach (var dir in dirs) { + int ii = i + dir[0], jj = j + dir[1]; + if (ii >= 0 && ii < m && jj >= 0 && jj < n && grid[ii][jj] == 1) { + Union(i * n + j, ii * n + jj); + } + } + int currStable = rank[Find(m * n)]; + ans[idx] = Math.Max(0, currStable - prevStable - 1); + prevStable = currStable; + } else { + ans[idx] = 0; + } + } + + return ans; + } +} diff --git a/tests/501-1000/803. bricks-falling-when-hit/sol.dart b/tests/501-1000/803. bricks-falling-when-hit/sol.dart new file mode 100644 index 00000000..b7ebe69e --- /dev/null +++ b/tests/501-1000/803. bricks-falling-when-hit/sol.dart @@ -0,0 +1,83 @@ +class Solution { + List hitBricks(List> grid, List> hits) { + int m = grid.length, n = grid[0].length; + List parent = List.generate(m * n + 1, (i) => i); + List rank = List.filled(m * n + 1, 1); + + int find(int p) { + if (p != parent[p]) { + parent[p] = find(parent[p]); + } + return parent[p]; + } + + bool union(int p, int q) { + int rootP = find(p); + int rootQ = find(q); + if (rootP == rootQ) return false; + if (rank[rootP] > rank[rootQ]) { + int tmp = rootP; + rootP = rootQ; + rootQ = tmp; + } + parent[rootP] = rootQ; + rank[rootQ] += rank[rootP]; + return true; + } + + Set seen = {}; + for (var hit in hits) { + int i = hit[0], j = hit[1]; + if (grid[i][j] == 1) { + seen.add(i * n + j); + grid[i][j] = 0; + } + } + + for (int j = 0; j < n; j++) { + if (grid[0][j] == 1) { + union(j, m * n); + } + } + + for (int i = 0; i < m; i++) { + for (int j = 0; j < n; j++) { + if (grid[i][j] == 1) { + if (i > 0 && grid[i-1][j] == 1) { + union(i * n + j, (i-1) * n + j); + } + if (j > 0 && grid[i][j-1] == 1) { + union(i * n + j, i * n + j - 1); + } + } + } + } + + List ans = List.filled(hits.length, 0); + int prevStable = rank[find(m * n)]; + List> dirs = [[1,0], [-1,0], [0,1], [0,-1]]; + + for (int idx = hits.length - 1; idx >= 0; idx--) { + int i = hits[idx][0], j = hits[idx][1]; + if (seen.contains(i * n + j)) { + grid[i][j] = 1; + if (i == 0) { + union(j, m * n); + } + for (var dir in dirs) { + int ii = i + dir[0], jj = j + dir[1]; + if (ii >= 0 && ii < m && jj >= 0 && jj < n && grid[ii][jj] == 1) { + union(i * n + j, ii * n + jj); + } + } + int currStable = rank[find(m * n)]; + ans[idx] = (currStable - prevStable - 1).clamp(0, 999999); + prevStable = currStable; + } else { + ans[idx] = 0; + } + } + + return ans; + } +} diff --git a/tests/501-1000/803. bricks-falling-when-hit/sol.go b/tests/501-1000/803. bricks-falling-when-hit/sol.go new file mode 100644 index 00000000..b5aa525a --- /dev/null +++ b/tests/501-1000/803. bricks-falling-when-hit/sol.go @@ -0,0 +1,89 @@ +func hitBricks(grid [][]int, hits [][]int) []int { + m, n := len(grid), len(grid[0]) + parent := make([]int, m*n+1) + rank := make([]int, m*n+1) + for i := range parent { + parent[i] = i + rank[i] = 1 + } + + var find func(int) int + find = func(p int) int { + if p != parent[p] { + parent[p] = find(parent[p]) + } + return parent[p] + } + + union := func(p, q int) bool { + rootP, rootQ := find(p), find(q) + if rootP == rootQ { + return false + } + if rank[rootP] > rank[rootQ] { + rootP, rootQ = rootQ, rootP + } + parent[rootP] = rootQ + rank[rootQ] += rank[rootP] + return true + } + + seen := make(map[int]bool) + for _, hit := range hits { + i, j := hit[0], hit[1] + if grid[i][j] == 1 { + seen[i*n+j] = true + grid[i][j] = 0 + } + } + + for j := 0; j < n; j++ { + if grid[0][j] == 1 { + union(j, m*n) + } + } + + for i := 0; i < m; i++ { + for j := 0; j < n; j++ { + if grid[i][j] == 1 { + if i > 0 && grid[i-1][j] == 1 { + union(i*n+j, (i-1)*n+j) + } + if j > 0 && grid[i][j-1] == 1 { + union(i*n+j, i*n+j-1) + } + } + } + } + + ans := make([]int, len(hits)) + prevStable := rank[find(m*n)] + dirs := [][]int{{1,0}, {-1,0}, {0,1}, {0,-1}} + + for idx := len(hits) - 1; idx >= 0; idx-- { + i, j := hits[idx][0], hits[idx][1] + if seen[i*n+j] { + grid[i][j] = 1 + if i == 0 { + union(j, m*n) + } + for _, dir := range dirs { + ii, jj := i+dir[0], j+dir[1] + if ii >= 0 && ii < m && jj >= 0 && jj < n && grid[ii][jj] == 1 { + union(i*n+j, ii*n+jj) + } + } + currStable := rank[find(m*n)] + if currStable-prevStable-1 > 0 { + ans[idx] = currStable - prevStable - 1 + } else { + ans[idx] = 0 + } + prevStable = currStable + } else { + ans[idx] = 0 + } + } + + return ans +} diff --git a/tests/501-1000/803. bricks-falling-when-hit/sol.java b/tests/501-1000/803. bricks-falling-when-hit/sol.java new file mode 100644 index 00000000..723c63de --- /dev/null +++ b/tests/501-1000/803. bricks-falling-when-hit/sol.java @@ -0,0 +1,87 @@ +class Solution { + public int[] hitBricks(int[][] grid, int[][] hits) { + int m = grid.length, n = grid[0].length; + int[] parent = new int[m * n + 1]; + int[] rank = new int[m * n + 1]; + for (int i = 0; i < parent.length; i++) { + parent[i] = i; + rank[i] = 1; + } + + java.util.Set seen = new java.util.HashSet<>(); + for (int[] hit : hits) { + int i = hit[0], j = hit[1]; + if (grid[i][j] == 1) { + seen.add(i * n + j); + grid[i][j] = 0; + } + } + + for (int j = 0; j < n; j++) { + if (grid[0][j] == 1) { + union(parent, rank, j, m * n); + } + } + + for (int i = 0; i < m; i++) { + for (int j = 0; j < n; j++) { + if (grid[i][j] == 1) { + if (i > 0 && grid[i-1][j] == 1) { + union(parent, rank, i * n + j, (i-1) * n + j); + } + if (j > 0 && grid[i][j-1] == 1) { + union(parent, rank, i * n + j, i * n + j - 1); + } + } + } + } + + int[] ans = new int[hits.length]; + int prevStable = rank[find(parent, m * n)]; + + for (int idx = hits.length - 1; idx >= 0; idx--) { + int i = hits[idx][0], j = hits[idx][1]; + if (seen.contains(i * n + j)) { + grid[i][j] = 1; + if (i == 0) { + union(parent, rank, j, m * n); + } + int[][] dirs = {{1,0}, {-1,0}, {0,1}, {0,-1}}; + for (int[] dir : dirs) { + int ii = i + dir[0], jj = j + dir[1]; + if (ii >= 0 && ii < m && jj >= 0 && jj < n && grid[ii][jj] == 1) { + union(parent, rank, i * n + j, ii * n + jj); + } + } + int currStable = rank[find(parent, m * n)]; + ans[idx] = Math.max(0, currStable - prevStable - 1); + prevStable = currStable; + } else { + ans[idx] = 0; + } + } + + return ans; + } + + private int find(int[] parent, int p) { + if (p != parent[p]) { + parent[p] = find(parent, parent[p]); + } + return parent[p]; + } + + private boolean union(int[] parent, int[] rank, int p, int q) { + int rootP = find(parent, p); + int rootQ = find(parent, q); + if (rootP == rootQ) return false; + if (rank[rootP] > rank[rootQ]) { + int tmp = rootP; + rootP = rootQ; + rootQ = tmp; + } + parent[rootP] = rootQ; + rank[rootQ] += rank[rootP]; + return true; + } +} diff --git a/tests/501-1000/803. bricks-falling-when-hit/sol.kt b/tests/501-1000/803. bricks-falling-when-hit/sol.kt new file mode 100644 index 00000000..45bc913d --- /dev/null +++ b/tests/501-1000/803. bricks-falling-when-hit/sol.kt @@ -0,0 +1,87 @@ +class Solution { + fun hitBricks(grid: Array, hits: Array): IntArray { + val m = grid.size + val n = grid[0].size + val parent = IntArray(m * n + 1) { it } + val rank = IntArray(m * n + 1) { 1 } + + val seen = mutableSetOf() + for (hit in hits) { + val i = hit[0] + val j = hit[1] + if (grid[i][j] == 1) { + seen.add(i * n + j) + grid[i][j] = 0 + } + } + + fun find(p: Int): Int { + if (p != parent[p]) { + parent[p] = find(parent[p]) + } + return parent[p] + } + + fun union(p: Int, q: Int): Boolean { + var rootP = find(p) + var rootQ = find(q) + if (rootP == rootQ) return false + if (rank[rootP] > rank[rootQ]) { + val tmp = rootP + rootP = rootQ + rootQ = tmp + } + parent[rootP] = rootQ + rank[rootQ] += rank[rootP] + return true + } + + for (j in 0 until n) { + if (grid[0][j] == 1) { + union(j, m * n) + } + } + + for (i in 0 until m) { + for (j in 0 until n) { + if (grid[i][j] == 1) { + if (i > 0 && grid[i-1][j] == 1) { + union(i * n + j, (i-1) * n + j) + } + if (j > 0 && grid[i][j-1] == 1) { + union(i * n + j, i * n + j - 1) + } + } + } + } + + val ans = IntArray(hits.size) + var prevStable = rank[find(m * n)] + val dirs = arrayOf(intArrayOf(1,0), intArrayOf(-1,0), intArrayOf(0,1), intArrayOf(0,-1)) + + for (idx in hits.indices.reversed()) { + val i = hits[idx][0] + val j = hits[idx][1] + if (seen.contains(i * n + j)) { + grid[i][j] = 1 + if (i == 0) { + union(j, m * n) + } + for (dir in dirs) { + val ii = i + dir[0] + val jj = j + dir[1] + if (ii in 0 until m && jj in 0 until n && grid[ii][jj] == 1) { + union(i * n + j, ii * n + jj) + } + } + val currStable = rank[find(m * n)] + ans[idx] = maxOf(0, currStable - prevStable - 1) + prevStable = currStable + } else { + ans[idx] = 0 + } + } + + return ans + } +} diff --git a/tests/501-1000/803. bricks-falling-when-hit/sol.py b/tests/501-1000/803. bricks-falling-when-hit/sol.py new file mode 100644 index 00000000..4daa29a8 --- /dev/null +++ b/tests/501-1000/803. bricks-falling-when-hit/sol.py @@ -0,0 +1,63 @@ +class UnionFind: + def __init__(self, n): + self.parent = list(range(n)) # Initialize parent array + self.rank = [1] * n # Initialize rank array + + def find(self, p): + if p != self.parent[p]: + self.parent[p] = self.find(self.parent[p]) # Path compression + return self.parent[p] + + def union(self, p, q): + root_p, root_q = self.find(p), self.find(q) + if root_p == root_q: + return False # Already in the same set + if self.rank[root_p] > self.rank[root_q]: + root_p, root_q = root_q, root_p # Union by rank + self.parent[root_p] = root_q + self.rank[root_q] += self.rank[root_p] + return True + + +class Solution: + def hitBricks(self, grid: List[List[int]], hits: List[List[int]]) -> List[int]: + m, n = len(grid), len(grid[0]) + + seen = set() + for i, j in hits: + if grid[i][j]: + seen.add((i, j)) # Record hit locations + grid[i][j] = 0 # Simulate initial hits + + uf = UnionFind(m * n + 1) # Create Union-Find with virtual top row + for j in range(n): + if grid[0][j]: + uf.union(j, m * n) # Connect top row to virtual top row + + for i in range(m): + for j in range(n): + if grid[i][j]: + for ii, jj in (i - 1, j), (i, j - 1): + if 0 <= ii < m and 0 <= jj < n and grid[ii][jj]: + uf.union(i * n + j, ii * n + jj) # Connect adjacent bricks + + ans = [] + prev_stable = uf.rank[uf.find(m * n)] # Initial stable bricks + + for i, j in reversed(hits): + if (i, j) in seen: + grid[i][j] = 1 # Revert the hit + if i == 0: + uf.union(j, m * n) # Reconnect to top if on top row + for ii, jj in (i - 1, j), (i, j - 1), (i, j + 1), (i + 1, j): + if 0 <= ii < m and 0 <= jj < n and grid[ii][jj]: + uf.union(i * n + j, ii * n + jj) # Reconnect to neighbors + curr_stable = uf.rank[uf.find(m * n)] # Count stable bricks + ans.append( + max(0, curr_stable - prev_stable - 1) + ) # Calculate fallen bricks + prev_stable = curr_stable + else: + ans.append(0) # No bricks fall if initially empty + + return ans[::-1] diff --git a/tests/501-1000/803. bricks-falling-when-hit/sol.py2 b/tests/501-1000/803. bricks-falling-when-hit/sol.py2 new file mode 100644 index 00000000..3e98780d --- /dev/null +++ b/tests/501-1000/803. bricks-falling-when-hit/sol.py2 @@ -0,0 +1,64 @@ +class Solution(object): + def hitBricks(self, grid, hits): + """ + :type grid: List[List[int]] + :type hits: List[List[int]] + :rtype: List[int] + """ + m, n = len(grid), len(grid[0]) + + seen = set() + for i, j in hits: + if grid[i][j]: + seen.add((i, j)) + grid[i][j] = 0 + + parent = list(range(m * n + 1)) + rank = [1] * (m * n + 1) + + def find(p): + if p != parent[p]: + parent[p] = find(parent[p]) + return parent[p] + + def union(p, q): + root_p, root_q = find(p), find(q) + if root_p == root_q: + return False + if rank[root_p] > rank[root_q]: + root_p, root_q = root_q, root_p + parent[root_p] = root_q + rank[root_q] += rank[root_p] + return True + + for j in range(n): + if grid[0][j]: + union(j, m * n) + + for i in range(m): + for j in range(n): + if grid[i][j]: + if i - 1 >= 0 and grid[i-1][j]: + union(i * n + j, (i-1) * n + j) + if j - 1 >= 0 and grid[i][j-1]: + union(i * n + j, i * n + j - 1) + + ans = [] + prev_stable = rank[find(m * n)] + + for i, j in reversed(hits): + if (i, j) in seen: + grid[i][j] = 1 + if i == 0: + union(j, m * n) + for di, dj in [(1, 0), (-1, 0), (0, 1), (0, -1)]: + ii, jj = i + di, j + dj + if 0 <= ii < m and 0 <= jj < n and grid[ii][jj]: + union(i * n + j, ii * n + jj) + curr_stable = rank[find(m * n)] + ans.append(max(0, curr_stable - prev_stable - 1)) + prev_stable = curr_stable + else: + ans.append(0) + + return ans[::-1] diff --git a/tests/501-1000/803. bricks-falling-when-hit/sol.rb b/tests/501-1000/803. bricks-falling-when-hit/sol.rb new file mode 100644 index 00000000..eafa33e0 --- /dev/null +++ b/tests/501-1000/803. bricks-falling-when-hit/sol.rb @@ -0,0 +1,78 @@ +# @param {Integer[][]} grid +# @param {Integer[][]} hits +# @return {Integer[]} +def hit_bricks(grid, hits) + m, n = grid.length, grid[0].length + + seen = {} + hits.each do |i, j| + if grid[i][j] == 1 + seen[[i, j]] = true + grid[i][j] = 0 + end + end + + parent = (0...m*n+1).to_a + rank = Array.new(m*n+1, 1) + + find = lambda do |p| + if p != parent[p] + parent[p] = find.call(parent[p]) + end + parent[p] + end + + union = lambda do |p, q| + root_p = find.call(p) + root_q = find.call(q) + return false if root_p == root_q + if rank[root_p] > rank[root_q] + root_p, root_q = root_q, root_p + end + parent[root_p] = root_q + rank[root_q] += rank[root_p] + true + end + + (0...n).each do |j| + union.call(j, m*n) if grid[0][j] == 1 + end + + (0...m).each do |i| + (0...n).each do |j| + if grid[i][j] == 1 + if i > 0 && grid[i-1][j] == 1 + union.call(i*n+j, (i-1)*n+j) + end + if j > 0 && grid[i][j-1] == 1 + union.call(i*n+j, i*n+j-1) + end + end + end + end + + ans = [] + prev_stable = rank[find.call(m*n)] + + hits.reverse.each do |i, j| + if seen[[i, j]] + grid[i][j] = 1 + if i == 0 + union.call(j, m*n) + end + [[1,0], [-1,0], [0,1], [0,-1]].each do |di, dj| + ii, jj = i + di, j + dj + if ii >= 0 && ii < m && jj >= 0 && jj < n && grid[ii][jj] == 1 + union.call(i*n+j, ii*n+jj) + end + end + curr_stable = rank[find.call(m*n)] + ans << [0, curr_stable - prev_stable - 1].max + prev_stable = curr_stable + else + ans << 0 + end + end + + ans.reverse +end diff --git a/tests/501-1000/803. bricks-falling-when-hit/sol.rs b/tests/501-1000/803. bricks-falling-when-hit/sol.rs new file mode 100644 index 00000000..899fcddf --- /dev/null +++ b/tests/501-1000/803. bricks-falling-when-hit/sol.rs @@ -0,0 +1,92 @@ +impl Solution { + pub fn hit_bricks(grid: Vec>, hits: Vec>) -> Vec { + let mut grid = grid; + let m = grid.len(); + let n = grid[0].len(); + let mut parent: Vec = (0..m*n+1).collect(); + let mut rank = vec![1usize; m*n+1]; + + fn find(parent: &mut Vec, p: usize) -> usize { + if p != parent[p] { + parent[p] = find(parent, parent[p]); + } + parent[p] + } + + fn union(parent: &mut Vec, rank: &mut Vec, p: usize, q: usize) -> bool { + let mut root_p = find(parent, p); + let mut root_q = find(parent, q); + if root_p == root_q { + return false; + } + if rank[root_p] > rank[root_q] { + std::mem::swap(&mut root_p, &mut root_q); + } + parent[root_p] = root_q; + rank[root_q] += rank[root_p]; + true + } + + let mut seen = std::collections::HashSet::new(); + for hit in &hits { + let i = hit[0] as usize; + let j = hit[1] as usize; + if grid[i][j] == 1 { + seen.insert(i * n + j); + grid[i][j] = 0; + } + } + + for j in 0..n { + if grid[0][j] == 1 { + union(&mut parent, &mut rank, j, m * n); + } + } + + for i in 0..m { + for j in 0..n { + if grid[i][j] == 1 { + if i > 0 && grid[i-1][j] == 1 { + union(&mut parent, &mut rank, i * n + j, (i-1) * n + j); + } + if j > 0 && grid[i][j-1] == 1 { + union(&mut parent, &mut rank, i * n + j, i * n + j - 1); + } + } + } + } + + let mut ans = vec![0i32; hits.len()]; + let mut prev_stable = rank[find(&mut parent, m * n)]; + let dirs = [(1i32, 0i32), (-1, 0), (0, 1), (0, -1)]; + + for idx in (0..hits.len()).rev() { + let i = hits[idx][0] as usize; + let j = hits[idx][1] as usize; + if seen.contains(&(i * n + j)) { + grid[i][j] = 1; + if i == 0 { + union(&mut parent, &mut rank, j, m * n); + } + for (di, dj) in &dirs { + let ii = i as i32 + di; + let jj = j as i32 + dj; + if ii >= 0 && ii < m as i32 && jj >= 0 && jj < n as i32 { + let ii = ii as usize; + let jj = jj as usize; + if grid[ii][jj] == 1 { + union(&mut parent, &mut rank, i * n + j, ii * n + jj); + } + } + } + let curr_stable = rank[find(&mut parent, m * n)]; + ans[idx] = std::cmp::max(0, curr_stable as i32 - prev_stable as i32 - 1); + prev_stable = curr_stable; + } else { + ans[idx] = 0; + } + } + + ans + } +} diff --git a/tests/501-1000/803. bricks-falling-when-hit/sol.swift b/tests/501-1000/803. bricks-falling-when-hit/sol.swift new file mode 100644 index 00000000..755a6cea --- /dev/null +++ b/tests/501-1000/803. bricks-falling-when-hit/sol.swift @@ -0,0 +1,83 @@ +class Solution { + func hitBricks(_ grid: [[Int]], _ hits: [[Int]]) -> [Int] { + var grid = grid + let m = grid.count + let n = grid[0].count + var parent = Array(0.. Int { + if p != parent[p] { + parent[p] = find(parent[p]) + } + return parent[p] + } + + func union(_ p: Int, _ q: Int) -> Bool { + var rootP = find(p) + var rootQ = find(q) + if rootP == rootQ { return false } + if rank[rootP] > rank[rootQ] { + swap(&rootP, &rootQ) + } + parent[rootP] = rootQ + rank[rootQ] += rank[rootP] + return true + } + + var seen = Set() + for hit in hits { + let i = hit[0], j = hit[1] + if grid[i][j] == 1 { + seen.insert(i * n + j) + grid[i][j] = 0 + } + } + + for j in 0.. 0 && grid[i-1][j] == 1 { + _ = union(i * n + j, (i-1) * n + j) + } + if j > 0 && grid[i][j-1] == 1 { + _ = union(i * n + j, i * n + j - 1) + } + } + } + } + + var ans = [Int]() + var prevStable = rank[find(m * n)] + let dirs = [(1,0), (-1,0), (0,1), (0,-1)] + + for hit in hits.reversed() { + let i = hit[0], j = hit[1] + if seen.contains(i * n + j) { + grid[i][j] = 1 + if i == 0 { + _ = union(j, m * n) + } + for (di, dj) in dirs { + let ii = i + di, jj = j + dj + if ii >= 0 && ii < m && jj >= 0 && jj < n && grid[ii][jj] == 1 { + _ = union(i * n + j, ii * n + jj) + } + } + let currStable = rank[find(m * n)] + ans.append(max(0, currStable - prevStable - 1)) + prevStable = currStable + } else { + ans.append(0) + } + } + + return ans.reversed() + } +} diff --git a/tests/501-1000/803. bricks-falling-when-hit/sol.ts b/tests/501-1000/803. bricks-falling-when-hit/sol.ts new file mode 100644 index 00000000..bef391d3 --- /dev/null +++ b/tests/501-1000/803. bricks-falling-when-hit/sol.ts @@ -0,0 +1,85 @@ +function hitBricks(grid: number[][], hits: number[][]): number[] { + const m = grid.length, + n = grid[0].length; + const parent: number[] = Array.from({ length: m * n + 1 }, (_, i) => i); + const rank: number[] = Array(m * n + 1).fill(1); + + const find = (p: number): number => { + if (p !== parent[p]) { + parent[p] = find(parent[p]); + } + return parent[p]; + }; + + const union = (p: number, q: number): boolean => { + let rootP = find(p); + let rootQ = find(q); + if (rootP === rootQ) return false; + if (rank[rootP] > rank[rootQ]) { + [rootP, rootQ] = [rootQ, rootP]; + } + parent[rootP] = rootQ; + rank[rootQ] += rank[rootP]; + return true; + }; + + const seen = new Set(); + for (const [i, j] of hits) { + if (grid[i][j] === 1) { + seen.add(i * n + j); + grid[i][j] = 0; + } + } + + for (let j = 0; j < n; j++) { + if (grid[0][j] === 1) { + union(j, m * n); + } + } + + for (let i = 0; i < m; i++) { + for (let j = 0; j < n; j++) { + if (grid[i][j] === 1) { + if (i > 0 && grid[i - 1][j] === 1) { + union(i * n + j, (i - 1) * n + j); + } + if (j > 0 && grid[i][j - 1] === 1) { + union(i * n + j, i * n + j - 1); + } + } + } + } + + const ans: number[] = []; + let prevStable = rank[find(m * n)]; + const dirs = [ + [1, 0], + [-1, 0], + [0, 1], + [0, -1], + ]; + + for (let idx = hits.length - 1; idx >= 0; idx--) { + const [i, j] = hits[idx]; + if (seen.has(i * n + j)) { + grid[i][j] = 1; + if (i === 0) { + union(j, m * n); + } + for (const [di, dj] of dirs) { + const ii = i + di, + jj = j + dj; + if (ii >= 0 && ii < m && jj >= 0 && jj < n && grid[ii][jj] === 1) { + union(i * n + j, ii * n + jj); + } + } + const currStable = rank[find(m * n)]; + ans.push(Math.max(0, currStable - prevStable - 1)); + prevStable = currStable; + } else { + ans.push(0); + } + } + + return ans.reverse(); +} diff --git a/tests/501-1000/804. unique-morse-code-words/manifest.yaml b/tests/501-1000/804. unique-morse-code-words/manifest.yaml new file mode 100644 index 00000000..42c2b57b --- /dev/null +++ b/tests/501-1000/804. unique-morse-code-words/manifest.yaml @@ -0,0 +1,421 @@ +entry: + id: 804 + title: "unique-morse-code-words" + params: + words: + type: array + items: + type: string + call: + cpp: Solution().uniqueMorseRepresentations({words}) + rust: Solution::unique_morse_representations({words}) + python3: Solution().uniqueMorseRepresentations({words}) + python2: Solution().uniqueMorseRepresentations({words}) + ruby: unique_morse_representations({words}) + java: new Solution().uniqueMorseRepresentations({words}) + csharp: new Solution().UniqueMorseRepresentations({words}) + kotlin: Solution().uniqueMorseRepresentations({words}) + go: uniqueMorseRepresentations({words}) + dart: Solution().uniqueMorseRepresentations({words}) + swift: Solution().uniqueMorseRepresentations({words}) + typescript: uniqueMorseRepresentations({words}) + +judge: + type: "exact" + +limits: + time_ms: 200 + memory_mb: 128 + +oracle: + python3: + call: "Checker().check({words}, {result})" + checker: | + class Checker: + def check(self, *args): + return True + +seed: 804 + +tests: + - name: case01 + in: + words: + elemType: "string" + value: + - "a" + out: 1 + - name: case02 + in: + words: + elemType: "string" + value: + - "a" + - "a" + out: 1 + - name: case03 + in: + words: + elemType: "string" + value: + - "a" + - "b" + - "c" + out: 3 + - name: case04 + in: + words: + elemType: "string" + value: + - "g" + - "z" + - "g" + - "m" + out: 3 + - name: case05 + in: + words: + elemType: "string" + value: + - "n" + - "o" + - "n" + out: 2 + - name: case06 + in: + words: + elemType: "string" + value: + - "a" + - "e" + - "i" + - "o" + - "u" + out: 5 + - name: case07 + in: + words: + elemType: "string" + value: + - "b" + - "d" + - "f" + - "h" + - "j" + out: 5 + - name: case08 + in: + words: + elemType: "string" + value: + - "q" + - "w" + - "e" + - "r" + - "t" + - "y" + out: 6 + - name: case09 + in: + words: + elemType: "string" + value: + - "m" + - "n" + - "m" + - "n" + out: 2 + - name: case10 + in: + words: + elemType: "string" + value: + - "c" + - "c" + - "d" + - "d" + - "e" + out: 3 + - name: case11 + in: + words: + elemType: "string" + value: + - "p" + - "q" + - "p" + - "r" + - "s" + out: 4 + - name: case12 + in: + words: + elemType: "string" + value: + - "t" + - "u" + - "v" + - "w" + - "x" + - "y" + - "z" + out: 7 + - name: case13 + in: + words: + elemType: "string" + value: + - "a" + - "b" + - "a" + - "b" + - "a" + out: 2 + - name: case14 + in: + words: + elemType: "string" + value: + - "f" + - "g" + - "h" + - "i" + - "j" + - "k" + out: 6 + - name: case15 + in: + words: + elemType: "string" + value: + - "l" + - "l" + - "m" + - "n" + - "n" + out: 3 + - name: case16 + in: + words: + elemType: "string" + value: + - "e" + - "f" + - "e" + - "g" + - "h" + out: 4 + - name: case17 + in: + words: + elemType: "string" + value: + - "i" + - "j" + - "k" + - "i" + - "k" + out: 3 + - name: case18 + in: + words: + elemType: "string" + value: + - "o" + - "p" + - "q" + - "r" + - "s" + out: 5 + - name: case19 + in: + words: + elemType: "string" + value: + - "t" + - "t" + - "t" + - "u" + out: 2 + - name: case20 + in: + words: + elemType: "string" + value: + - "v" + - "w" + - "x" + - "y" + - "z" + - "z" + out: 5 + - name: case21 + in: + words: + elemType: "string" + value: + - "a" + - "b" + - "c" + - "d" + out: 4 + - name: case22 + in: + words: + elemType: "string" + value: + - "e" + - "f" + - "g" + - "h" + out: 4 + - name: case23 + in: + words: + elemType: "string" + value: + - "i" + - "j" + - "k" + - "l" + out: 4 + - name: case24 + in: + words: + elemType: "string" + value: + - "m" + - "n" + - "o" + - "p" + out: 4 + - name: case25 + in: + words: + elemType: "string" + value: + - "q" + - "r" + - "s" + - "t" + out: 4 + - name: case26 + in: + words: + elemType: "string" + value: + - "u" + - "v" + - "w" + - "x" + out: 4 + - name: case27 + in: + words: + elemType: "string" + value: + - "y" + - "z" + - "y" + out: 2 + - name: case28 + in: + words: + elemType: "string" + value: + - "a" + - "c" + - "e" + - "g" + - "i" + - "k" + out: 6 + - name: case29 + in: + words: + elemType: "string" + value: + - "b" + - "d" + - "f" + - "b" + - "d" + - "f" + out: 3 + - name: case30 + in: + words: + elemType: "string" + value: + - "p" + - "q" + - "r" + - "s" + - "t" + - "u" + - "v" + - "w" + - "x" + - "y" + - "z" + out: 11 + - name: case31 + in: + words: + elemType: "string" + value: + - "a" + - "a" + - "b" + - "b" + - "c" + - "c" + out: 3 + - name: case32 + in: + words: + elemType: "string" + value: + - "d" + - "e" + - "f" + - "g" + - "h" + - "i" + - "j" + - "k" + out: 8 + - name: case33 + in: + words: + elemType: "string" + value: + - "l" + - "m" + - "n" + - "o" + - "p" + - "q" + out: 6 + - name: case34 + in: + words: + elemType: "string" + value: + - "r" + - "s" + - "t" + - "u" + - "v" + - "w" + out: 6 + - name: case35 + in: + words: + elemType: "string" + value: + - "x" + - "y" + - "z" + - "x" + out: 3 diff --git a/tests/501-1000/804. unique-morse-code-words/sol.cpp b/tests/501-1000/804. unique-morse-code-words/sol.cpp new file mode 100644 index 00000000..0bf0e2cd --- /dev/null +++ b/tests/501-1000/804. unique-morse-code-words/sol.cpp @@ -0,0 +1,23 @@ +class Solution { +public: + int uniqueMorseRepresentations(vector& words) { + vector storage = { + ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", + "....", "..", ".---", "-.-", ".-..", "--", "-.", + "---", ".--.", "--.-", ".-.", "...", "-", "..-", + "...-", ".--", "-..-", "-.--", "--.." + }; + + unordered_set st; + + for (const string& word : words) { + string temp = ""; + for (char ch : word) { + temp += storage[ch - 'a']; + } + st.insert(temp); + } + + return st.size(); + } +}; diff --git a/tests/501-1000/804. unique-morse-code-words/sol.cs b/tests/501-1000/804. unique-morse-code-words/sol.cs new file mode 100644 index 00000000..b34f91b1 --- /dev/null +++ b/tests/501-1000/804. unique-morse-code-words/sol.cs @@ -0,0 +1,22 @@ +public class Solution { + public int UniqueMorseRepresentations(string[] words) { + string[] storage = { + ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", + "....", "..", ".---", "-.-", ".-..", "--", "-.", + "---", ".--.", "--.-", ".-.", "...", "-", "..-", + "...-", ".--", "-..-", "-.--", "--.." + }; + + HashSet st = new HashSet(); + + foreach (string word in words) { + string temp = ""; + foreach (char ch in word) { + temp += storage[ch - 'a']; + } + st.Add(temp); + } + + return st.Count; + } +} diff --git a/tests/501-1000/804. unique-morse-code-words/sol.dart b/tests/501-1000/804. unique-morse-code-words/sol.dart new file mode 100644 index 00000000..3f2133fa --- /dev/null +++ b/tests/501-1000/804. unique-morse-code-words/sol.dart @@ -0,0 +1,22 @@ +class Solution { + int uniqueMorseRepresentations(List words) { + final storage = [ + ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", + "....", "..", ".---", "-.-", ".-..", "--", "-.", + "---", ".--.", "--.-", ".-.", "...", "-", "..-", + "...-", ".--", "-..-", "-.--", "--.." + ]; + + final st = {}; + + for (final word in words) { + String temp = ""; + for (final ch in word.split('')) { + temp += storage[ch.codeUnitAt(0) - 'a'.codeUnitAt(0)]; + } + st.add(temp); + } + + return st.length; + } +} diff --git a/tests/501-1000/804. unique-morse-code-words/sol.go b/tests/501-1000/804. unique-morse-code-words/sol.go new file mode 100644 index 00000000..bd5d1fd8 --- /dev/null +++ b/tests/501-1000/804. unique-morse-code-words/sol.go @@ -0,0 +1,20 @@ +func uniqueMorseRepresentations(words []string) int { + storage := []string{ + ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", + "....", "..", ".---", "-.-", ".-..", "--", "-.", + "---", ".--.", "--.-", ".-.", "...", "-", "..-", + "...-", ".--", "-..-", "-.--", "--..", + } + + st := make(map[string]bool) + + for _, word := range words { + temp := "" + for _, ch := range word { + temp += storage[ch-'a'] + } + st[temp] = true + } + + return len(st) +} diff --git a/tests/501-1000/804. unique-morse-code-words/sol.java b/tests/501-1000/804. unique-morse-code-words/sol.java new file mode 100644 index 00000000..cd4497e6 --- /dev/null +++ b/tests/501-1000/804. unique-morse-code-words/sol.java @@ -0,0 +1,22 @@ +class Solution { + public int uniqueMorseRepresentations(String[] words) { + String[] storage = { + ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", + "....", "..", ".---", "-.-", ".-..", "--", "-.", + "---", ".--.", "--.-", ".-.", "...", "-", "..-", + "...-", ".--", "-..-", "-.--", "--.." + }; + + Set st = new HashSet<>(); + + for (String word : words) { + StringBuilder temp = new StringBuilder(); + for (char ch : word.toCharArray()) { + temp.append(storage[ch - 'a']); + } + st.add(temp.toString()); + } + + return st.size(); + } +} diff --git a/tests/501-1000/804. unique-morse-code-words/sol.kt b/tests/501-1000/804. unique-morse-code-words/sol.kt new file mode 100644 index 00000000..74752417 --- /dev/null +++ b/tests/501-1000/804. unique-morse-code-words/sol.kt @@ -0,0 +1,22 @@ +class Solution { + fun uniqueMorseRepresentations(words: Array): Int { + val storage = arrayOf( + ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", + "....", "..", ".---", "-.-", ".-..", "--", "-.", + "---", ".--.", "--.-", ".-.", "...", "-", "..-", + "...-", ".--", "-..-", "-.--", "--.." + ) + + val st = mutableSetOf() + + for (word in words) { + val temp = StringBuilder() + for (ch in word) { + temp.append(storage[ch - 'a']) + } + st.add(temp.toString()) + } + + return st.size + } +} diff --git a/tests/501-1000/804. unique-morse-code-words/sol.py b/tests/501-1000/804. unique-morse-code-words/sol.py new file mode 100644 index 00000000..51823d30 --- /dev/null +++ b/tests/501-1000/804. unique-morse-code-words/sol.py @@ -0,0 +1,43 @@ +class Solution: + def uniqueMorseRepresentations(self, words): + + storage = [ + ".-", + "-...", + "-.-.", + "-..", + ".", + "..-.", + "--.", + "....", + "..", + ".---", + "-.-", + ".-..", + "--", + "-.", + "---", + ".--.", + "--.-", + ".-.", + "...", + "-", + "..-", + "...-", + ".--", + "-..-", + "-.--", + "--..", + ] + + st = set() + + for word in words: + temp = "" + + for ch in word: + temp += storage[ord(ch) - ord("a")] + + st.add(temp) + + return len(st) diff --git a/tests/501-1000/804. unique-morse-code-words/sol.py2 b/tests/501-1000/804. unique-morse-code-words/sol.py2 new file mode 100644 index 00000000..f860b1e6 --- /dev/null +++ b/tests/501-1000/804. unique-morse-code-words/sol.py2 @@ -0,0 +1,22 @@ +class Solution(object): + def uniqueMorseRepresentations(self, words): + """ + :type words: List[str] + :rtype: int + """ + storage = [ + ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", + "....", "..", ".---", "-.-", ".-..", "--", "-.", + "---", ".--.", "--.-", ".-.", "...", "-", "..-", + "...-", ".--", "-..-", "-.--", "--.." + ] + + st = set() + + for word in words: + temp = "" + for ch in word: + temp += storage[ord(ch) - ord('a')] + st.add(temp) + + return len(st) diff --git a/tests/501-1000/804. unique-morse-code-words/sol.rb b/tests/501-1000/804. unique-morse-code-words/sol.rb new file mode 100644 index 00000000..db3bcbc4 --- /dev/null +++ b/tests/501-1000/804. unique-morse-code-words/sol.rb @@ -0,0 +1,22 @@ +# @param {String[]} words +# @return {Integer} +def unique_morse_representations(words) + storage = [ + ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", + "....", "..", ".---", "-.-", ".-..", "--", "-.", + "---", ".--.", "--.-", ".-.", "...", "-", "..-", + "...-", ".--", "-..-", "-.--", "--.." + ] + + st = Set.new + + words.each do |word| + temp = "" + word.each_char do |ch| + temp += storage[ch.ord - 'a'.ord] + end + st.add(temp) + end + + st.size +end diff --git a/tests/501-1000/804. unique-morse-code-words/sol.rs b/tests/501-1000/804. unique-morse-code-words/sol.rs new file mode 100644 index 00000000..938945bc --- /dev/null +++ b/tests/501-1000/804. unique-morse-code-words/sol.rs @@ -0,0 +1,23 @@ +impl Solution { + pub fn unique_morse_representations(words: Vec) -> i32 { + let storage = [ + ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", + "....", "..", ".---", "-.-", ".-..", "--", "-.", + "---", ".--.", "--.-", ".-.", "...", "-", "..-", + "...-", ".--", "-..-", "-.--", "--.." + ]; + + let mut st = std::collections::HashSet::new(); + + for word in words { + let mut temp = String::new(); + for ch in word.chars() { + let index = (ch as u8 - b'a') as usize; + temp.push_str(storage[index]); + } + st.insert(temp); + } + + st.len() as i32 + } +} diff --git a/tests/501-1000/804. unique-morse-code-words/sol.swift b/tests/501-1000/804. unique-morse-code-words/sol.swift new file mode 100644 index 00000000..5dfca281 --- /dev/null +++ b/tests/501-1000/804. unique-morse-code-words/sol.swift @@ -0,0 +1,23 @@ +class Solution { + func uniqueMorseRepresentations(_ words: [String]) -> Int { + let storage = [ + ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", + "....", "..", ".---", "-.-", ".-..", "--", "-.", + "---", ".--.", "--.-", ".-.", "...", "-", "..-", + "...-", ".--", "-..-", "-.--", "--.." + ] + + var st = Set() + + for word in words { + var temp = "" + for ch in word { + let index = Int(ch.asciiValue! - Character("a").asciiValue!) + temp += storage[index] + } + st.insert(temp) + } + + return st.count + } +} diff --git a/tests/501-1000/804. unique-morse-code-words/sol.ts b/tests/501-1000/804. unique-morse-code-words/sol.ts new file mode 100644 index 00000000..c8d07c59 --- /dev/null +++ b/tests/501-1000/804. unique-morse-code-words/sol.ts @@ -0,0 +1,42 @@ +function uniqueMorseRepresentations(words: string[]): number { + const storage = [ + ".-", + "-...", + "-.-.", + "-..", + ".", + "..-.", + "--.", + "....", + "..", + ".---", + "-.-", + ".-..", + "--", + "-.", + "---", + ".--.", + "--.-", + ".-.", + "...", + "-", + "..-", + "...-", + ".--", + "-..-", + "-.--", + "--..", + ]; + + const st = new Set(); + + for (const word of words) { + let temp = ""; + for (const ch of word) { + temp += storage[ch.charCodeAt(0) - "a".charCodeAt(0)]; + } + st.add(temp); + } + + return st.size; +} diff --git a/tests/501-1000/805. split-array-with-same-average/manifest.yaml b/tests/501-1000/805. split-array-with-same-average/manifest.yaml new file mode 100644 index 00000000..0d614526 --- /dev/null +++ b/tests/501-1000/805. split-array-with-same-average/manifest.yaml @@ -0,0 +1,161 @@ +entry: + id: 805 + title: "split-array-with-same-average" + params: + nums: + type: array + items: + type: int + call: + cpp: Solution().splitArraySameAverage({nums}) + rust: Solution::split_array_same_average({nums}) + python3: Solution().splitArraySameAverage({nums}) + python2: Solution().splitArraySameAverage({nums}) + ruby: split_array_same_average({nums}) + java: new Solution().splitArraySameAverage({nums}) + csharp: new Solution().SplitArraySameAverage({nums}) + kotlin: Solution().splitArraySameAverage({nums}) + go: splitArraySameAverage({nums}) + dart: Solution().splitArraySameAverage({nums}) + swift: Solution().splitArraySameAverage({nums}) + typescript: splitArraySameAverage({nums}) + +judge: + type: "exact" + +limits: + time_ms: 1000 + memory_mb: 256 + +oracle: + python3: + call: "Checker().check(nums, {result})" + checker: | + class Checker: + def check(self, nums, result): + n = len(nums) + total = sum(nums) + nums = sorted(nums) + + possible = [set() for _ in range(n // 2 + 1)] + possible[0].add(0) + for x in nums: + for size in range(len(possible) - 1, 0, -1): + for prev in list(possible[size - 1]): + possible[size].add(prev + x) + + expected = False + for size in range(1, n // 2 + 1): + if (total * size) % n == 0 and (total * size) // n in possible[size]: + expected = True + break + return bool(result) == expected + +seed: 805 + +tests: + - name: case01 + in: + nums: [1, 2] + - name: case02 + in: + nums: [3, 1] + - name: case03 + in: + nums: [1, 2, 3, 4] + - name: case04 + in: + nums: [5, 5, 5, 5] + - name: case05 + in: + nums: [1, 2, 5] + - name: case06 + in: + nums: [2, 0, 5, 6, 16, 12, 15, 7] + - name: case07 + in: + nums: [1, 3, 2, 4, 6] + - name: case08 + in: + nums: [0, 0, 0, 0, 1] + - name: case09 + in: + nums: [18, 0, 16, 2] + - name: case10 + in: + nums: [3, 1, 4, 2, 2] + - name: case11 + in: + nums: [1, 1, 1, 1, 1, 1] + - name: case12 + in: + nums: [2, 2, 2, 2, 2] + - name: case13 + in: + nums: [1, 5, 7, 11] + - name: case14 + in: + nums: [6, 8, 2, 4, 10, 12] + - name: case15 + in: + nums: [1, 7, 15, 29, 11, 9] + - name: case16 + in: + nums: [0, 1, 2, 3, 4, 5] + - name: case17 + in: + nums: [10, 20, 30, 40, 50, 60] + - name: case18 + in: + nums: [1, 2, 4, 8, 16, 32] + - name: case19 + in: + nums: [7, 7, 7, 8, 8, 8] + - name: case20 + in: + nums: [2, 3, 5, 7, 11, 13] + - name: case21 + in: + nums: [9, 1, 2, 3, 4, 5, 6] + - name: case22 + in: + nums: [4, 4, 4, 4, 6, 6, 6, 6] + - name: case23 + in: + nums: [1, 9, 17, 25, 33] + - name: case24 + in: + nums: [1, 2, 3, 5, 8, 13] + - name: case25 + in: + nums: [12, 12, 12, 12, 18, 18] + - name: case26 + in: + nums: [2, 4, 6, 8, 10, 12, 14, 16] + - name: case27 + in: + nums: [1, 100, 2, 99, 3, 98] + - name: case28 + in: + nums: [5, 10, 15, 20, 25, 30, 35] + - name: case29 + in: + nums: [1, 2, 6, 14, 30] + - name: case30 + in: + nums: [3, 6, 9, 12, 15, 18, 21] + - name: case31 + in: + nums: [0, 2, 4, 6, 8, 10] + - name: case32 + in: + nums: [11, 22, 33, 44, 55, 66] + - name: case33 + in: + nums: [1, 4, 9, 16, 25, 36] + - name: case34 + in: + nums: [8, 8, 8, 8, 8, 9] + - name: case35 + in: + nums: [1, 2, 2, 3, 3, 4, 4, 5] diff --git a/tests/501-1000/805. split-array-with-same-average/sol.cpp b/tests/501-1000/805. split-array-with-same-average/sol.cpp new file mode 100644 index 00000000..f2d37a4a --- /dev/null +++ b/tests/501-1000/805. split-array-with-same-average/sol.cpp @@ -0,0 +1,50 @@ +class Solution { +public: + bool splitArraySameAverage(vector& nums) { + int n = nums.size(); + if (n < 2) return false; + int total = accumulate(nums.begin(), nums.end(), 0); + vector transformed(n); + for (int i = 0; i < n; i++) { + transformed[i] = nums[i] * n - total; + } + + int mid = n >> 1; + auto generate = [](const vector& arr) -> unordered_map> { + unordered_map> mp; + int len = arr.size(); + for (int mask = 1; mask < (1 << len); mask++) { + int sum = 0, cnt = 0; + for (int i = 0; i < len; i++) { + if (mask & (1 << i)) { + sum += arr[i]; + cnt++; + } + } + mp[cnt].insert(sum); + } + return mp; + }; + + auto mpA = generate(vector(transformed.begin(), transformed.begin() + mid)); + auto mpB = generate(vector(transformed.begin() + mid, transformed.end())); + + for (auto& [cnt, st] : mpA) { + if (st.count(0) && cnt != 0) return true; + } + for (auto& [cnt, st] : mpB) { + if (st.count(0) && cnt != 0) return true; + } + + for (auto& [cntA, stA] : mpA) { + for (auto& [cntB, stB] : mpB) { + int totalCnt = cntA + cntB; + if (totalCnt == 0 || totalCnt == n) continue; + for (int val : stA) { + if (stB.count(-val)) return true; + } + } + } + return false; + } +}; diff --git a/tests/501-1000/805. split-array-with-same-average/sol.cs b/tests/501-1000/805. split-array-with-same-average/sol.cs new file mode 100644 index 00000000..2957d555 --- /dev/null +++ b/tests/501-1000/805. split-array-with-same-average/sol.cs @@ -0,0 +1,50 @@ +public class Solution { + public bool SplitArraySameAverage(int[] nums) { + int n = nums.Length; + if (n < 2) return false; + int total = nums.Sum(); + int[] transformed = new int[n]; + for (int i = 0; i < n; i++) { + transformed[i] = nums[i] * n - total; + } + + int mid = n >> 1; + Dictionary> Generate(int[] arr) { + var mp = new Dictionary>(); + int len = arr.Length; + for (int mask = 1; mask < (1 << len); mask++) { + int sum = 0, cnt = 0; + for (int i = 0; i < len; i++) { + if ((mask & (1 << i)) != 0) { + sum += arr[i]; + cnt++; + } + } + if (!mp.ContainsKey(cnt)) mp[cnt] = new HashSet(); + mp[cnt].Add(sum); + } + return mp; + } + + var mpA = Generate(transformed.Take(mid).ToArray()); + var mpB = Generate(transformed.Skip(mid).ToArray()); + + foreach (var kvp in mpA) { + if (kvp.Value.Contains(0) && kvp.Key != 0) return true; + } + foreach (var kvp in mpB) { + if (kvp.Value.Contains(0) && kvp.Key != 0) return true; + } + + foreach (var kvpA in mpA) { + foreach (var kvpB in mpB) { + int totalCnt = kvpA.Key + kvpB.Key; + if (totalCnt == 0 || totalCnt == n) continue; + foreach (int val in kvpA.Value) { + if (kvpB.Value.Contains(-val)) return true; + } + } + } + return false; + } +} diff --git a/tests/501-1000/805. split-array-with-same-average/sol.dart b/tests/501-1000/805. split-array-with-same-average/sol.dart new file mode 100644 index 00000000..c6bd3de9 --- /dev/null +++ b/tests/501-1000/805. split-array-with-same-average/sol.dart @@ -0,0 +1,46 @@ +class Solution { + bool splitArraySameAverage(List nums) { + int n = nums.length; + if (n < 2) return false; + int total = nums.reduce((a, b) => a + b); + List transformed = nums.map((v) => v * n - total).toList(); + + int mid = n >> 1; + Map> generate(List arr) { + Map> mp = {}; + for (int mask = 1; mask < (1 << arr.length); mask++) { + int sum = 0, cnt = 0; + for (int i = 0; i < arr.length; i++) { + if ((mask & (1 << i)) != 0) { + sum += arr[i]; + cnt++; + } + } + mp.putIfAbsent(cnt, () => {}); + mp[cnt]!.add(sum); + } + return mp; + } + + Map> mpA = generate(transformed.sublist(0, mid)); + Map> mpB = generate(transformed.sublist(mid)); + + for (var entry in mpA.entries) { + if (entry.value.contains(0) && entry.key != 0) return true; + } + for (var entry in mpB.entries) { + if (entry.value.contains(0) && entry.key != 0) return true; + } + + for (var entryA in mpA.entries) { + for (var entryB in mpB.entries) { + int totalCnt = entryA.key + entryB.key; + if (totalCnt == 0 || totalCnt == n) continue; + for (int v in entryA.value) { + if (entryB.value.contains(-v)) return true; + } + } + } + return false; + } +} diff --git a/tests/501-1000/805. split-array-with-same-average/sol.go b/tests/501-1000/805. split-array-with-same-average/sol.go new file mode 100644 index 00000000..fecceeae --- /dev/null +++ b/tests/501-1000/805. split-array-with-same-average/sol.go @@ -0,0 +1,62 @@ +func splitArraySameAverage(nums []int) bool { + n := len(nums) + if n < 2 { + return false + } + total := 0 + for _, v := range nums { + total += v + } + transformed := make([]int, n) + for i, v := range nums { + transformed[i] = v * n - total + } + + mid := n >> 1 + generate := func(arr []int) map[int]map[int]bool { + mp := make(map[int]map[int]bool) + for mask := 1; mask < (1 << len(arr)); mask++ { + sum, cnt := 0, 0 + for i, v := range arr { + if mask & (1 << i) != 0 { + sum += v + cnt++ + } + } + if mp[cnt] == nil { + mp[cnt] = make(map[int]bool) + } + mp[cnt][sum] = true + } + return mp + } + + mpA := generate(transformed[:mid]) + mpB := generate(transformed[mid:]) + + for cnt, set := range mpA { + if set[0] && cnt != 0 { + return true + } + } + for cnt, set := range mpB { + if set[0] && cnt != 0 { + return true + } + } + + for cntA, setA := range mpA { + for cntB, setB := range mpB { + totalCnt := cntA + cntB + if totalCnt == 0 || totalCnt == n { + continue + } + for v := range setA { + if setB[-v] { + return true + } + } + } + } + return false +} diff --git a/tests/501-1000/805. split-array-with-same-average/sol.java b/tests/501-1000/805. split-array-with-same-average/sol.java new file mode 100644 index 00000000..d8a623dd --- /dev/null +++ b/tests/501-1000/805. split-array-with-same-average/sol.java @@ -0,0 +1,59 @@ +class Solution { + public boolean splitArraySameAverage(int[] nums) { + int n = nums.length; + if (n < 2) return false; + int total = 0; + for (int num : nums) total += num; + int[] transformed = new int[n]; + for (int i = 0; i < n; i++) { + transformed[i] = nums[i] * n - total; + } + + int mid = n >> 1; + Map> mpA = new HashMap<>(); + int[] arr = Arrays.copyOfRange(transformed, 0, mid); + int len = arr.length; + for (int mask = 1; mask < (1 << len); mask++) { + int sum = 0, cnt = 0; + for (int i = 0; i < len; i++) { + if ((mask & (1 << i)) != 0) { + sum += arr[i]; + cnt++; + } + } + mpA.computeIfAbsent(cnt, k -> new HashSet<>()).add(sum); + } + + Map> mpB = new HashMap<>(); + arr = Arrays.copyOfRange(transformed, mid, n); + len = arr.length; + for (int mask = 1; mask < (1 << len); mask++) { + int sum = 0, cnt = 0; + for (int i = 0; i < len; i++) { + if ((mask & (1 << i)) != 0) { + sum += arr[i]; + cnt++; + } + } + mpB.computeIfAbsent(cnt, k -> new HashSet<>()).add(sum); + } + + for (int cnt : mpA.keySet()) { + if (mpA.get(cnt).contains(0) && cnt != 0) return true; + } + for (int cnt : mpB.keySet()) { + if (mpB.get(cnt).contains(0) && cnt != 0) return true; + } + + for (int cntA : mpA.keySet()) { + for (int cntB : mpB.keySet()) { + int totalCnt = cntA + cntB; + if (totalCnt == 0 || totalCnt == n) continue; + for (int val : mpA.get(cntA)) { + if (mpB.get(cntB).contains(-val)) return true; + } + } + } + return false; + } +} diff --git a/tests/501-1000/805. split-array-with-same-average/sol.kt b/tests/501-1000/805. split-array-with-same-average/sol.kt new file mode 100644 index 00000000..5b0d068e --- /dev/null +++ b/tests/501-1000/805. split-array-with-same-average/sol.kt @@ -0,0 +1,46 @@ +class Solution { + fun splitArraySameAverage(nums: IntArray): Boolean { + val n = nums.size + if (n < 2) return false + val total = nums.sum() + val transformed = nums.map { it * n - total } + + val mid = n shr 1 + fun generate(arr: List): Map> { + val mp = mutableMapOf>() + for (mask in 1 until (1 shl arr.size)) { + var sum = 0 + var cnt = 0 + for (i in arr.indices) { + if (mask and (1 shl i) != 0) { + sum += arr[i] + cnt++ + } + } + mp.getOrPut(cnt) { mutableSetOf() }.add(sum) + } + return mp + } + + val mpA = generate(transformed.take(mid)) + val mpB = generate(transformed.drop(mid)) + + for ((cnt, set) in mpA) { + if (0 in set && cnt != 0) return true + } + for ((cnt, set) in mpB) { + if (0 in set && cnt != 0) return true + } + + for ((cntA, setA) in mpA) { + for ((cntB, setB) in mpB) { + val totalCnt = cntA + cntB + if (totalCnt == 0 || totalCnt == n) continue + for (v in setA) { + if (-v in setB) return true + } + } + } + return false + } +} diff --git a/tests/501-1000/805. split-array-with-same-average/sol.py b/tests/501-1000/805. split-array-with-same-average/sol.py new file mode 100644 index 00000000..586a65c3 --- /dev/null +++ b/tests/501-1000/805. split-array-with-same-average/sol.py @@ -0,0 +1,66 @@ +class Solution: + def splitArraySameAverage(self, nums: List[int]) -> bool: + if len(nums) < 2: + return False + """ + step 1 + splitting the array into two parts with same average + + ------------------------------------- + + + sum(a)/x==sum(b)/x=k + (sum(a)+sum(b))//2x + (kx+kx)//2x -> k + + + so average of both the subarrays and overall subarray is equal + """ + k = sum(nums) / len(nums) + total = sum(nums) + nums = [(nums[i] * len(nums) - total) for i in range(len(nums))] + print(nums) + """ + step 3 + now in this subarray find if it is possible to find a subsequence + + of size n//2 such that it's sum is equal to 0 + + """ + + """ + How will u iterate over a Fixed mask length But Bro Is it Required + Yes we Cant we do 2^30 -> Do MIM + + """ + + def gen(arr): + mp = defaultdict(set) + for mask in range(1, 1 << len(arr)): + total = 0 + for i in range(len(arr)): + if mask & (1 << i): + total += arr[i] + mp[bin(mask).count("1")].add(total) + return mp + + mid = (len(nums)) >> 1 + mp_a = gen(nums[:mid]) + mp_b = gen(nums[mid:]) + for val in mp_a: + if 0 in mp_a[val] and val != 0: + print(val) + return True + for val in mp_b: + if 0 in mp_b[val] and val != 0: + print(val) + return True + for length_a in mp_a: + for length_b in mp_b: + total_len = length_a + length_b + if total_len == 0 or total_len == len(nums): + continue + for val in mp_a[length_a]: + if -val in mp_b[length_b]: + return True + return False diff --git a/tests/501-1000/805. split-array-with-same-average/sol.py2 b/tests/501-1000/805. split-array-with-same-average/sol.py2 new file mode 100644 index 00000000..b602b4e1 --- /dev/null +++ b/tests/501-1000/805. split-array-with-same-average/sol.py2 @@ -0,0 +1,56 @@ +class Solution(object): + def splitArraySameAverage(self, nums): + """ + :type nums: List[int] + :rtype: bool + """ + if len(nums) < 2: + return False + total = sum(nums) + n = len(nums) + k = total / float(n) + nums = [nums[i] * n - total for i in range(n)] + + mp_a = {} + mid = n >> 1 + arr = nums[:mid] + for mask in range(1, 1 << len(arr)): + s = 0 + cnt = 0 + for i in range(len(arr)): + if mask & (1 << i): + s += arr[i] + cnt += 1 + if cnt not in mp_a: + mp_a[cnt] = set() + mp_a[cnt].add(s) + + mp_b = {} + arr = nums[mid:] + for mask in range(1, 1 << len(arr)): + s = 0 + cnt = 0 + for i in range(len(arr)): + if mask & (1 << i): + s += arr[i] + cnt += 1 + if cnt not in mp_b: + mp_b[cnt] = set() + mp_b[cnt].add(s) + + for cnt in mp_a: + if 0 in mp_a[cnt] and cnt != 0: + return True + for cnt in mp_b: + if 0 in mp_b[cnt] and cnt != 0: + return True + + for cnt_a in mp_a: + for cnt_b in mp_b: + total_cnt = cnt_a + cnt_b + if total_cnt == 0 or total_cnt == n: + continue + for val in mp_a[cnt_a]: + if -val in mp_b[cnt_b]: + return True + return False diff --git a/tests/501-1000/805. split-array-with-same-average/sol.rb b/tests/501-1000/805. split-array-with-same-average/sol.rb new file mode 100644 index 00000000..3d62a4ce --- /dev/null +++ b/tests/501-1000/805. split-array-with-same-average/sol.rb @@ -0,0 +1,63 @@ +# @param {Integer[]} nums +# @return {Boolean} +def split_array_same_average(nums) + return false if nums.length < 2 + total = nums.sum + n = nums.length + nums = nums.map { |num| num * n - total } + + mp_a = {} + mid = n >> 1 + arr = nums[0...mid] + (1...(1 << arr.length)).each do |mask| + s = 0 + cnt = 0 + arr.each_with_index do |val, i| + if mask & (1 << i) != 0 + s += val + cnt += 1 + end + end + mp_a[cnt] ||= Set.new + mp_a[cnt].add(s) + end + + mp_b = {} + arr = nums[mid..-1] + (1...(1 << arr.length)).each do |mask| + s = 0 + cnt = 0 + arr.each_with_index do |val, i| + if mask & (1 << i) != 0 + s += val + cnt += 1 + end + end + mp_b[cnt] ||= Set.new + mp_b[cnt].add(s) + end + + mp_a.each do |cnt, set| + if set.include?(0) && cnt != 0 + return true + end + end + mp_b.each do |cnt, set| + if set.include?(0) && cnt != 0 + return true + end + end + + mp_a.each do |cnt_a, set_a| + mp_b.each do |cnt_b, set_b| + total_cnt = cnt_a + cnt_b + next if total_cnt == 0 || total_cnt == n + set_a.each do |val| + if set_b.include?(-val) + return true + end + end + end + end + false +end diff --git a/tests/501-1000/805. split-array-with-same-average/sol.rs b/tests/501-1000/805. split-array-with-same-average/sol.rs new file mode 100644 index 00000000..639cc38a --- /dev/null +++ b/tests/501-1000/805. split-array-with-same-average/sol.rs @@ -0,0 +1,59 @@ +impl Solution { + pub fn split_array_same_average(nums: Vec) -> bool { + let n = nums.len(); + if n < 2 { + return false; + } + let total: i32 = nums.iter().sum(); + let transformed: Vec = nums.iter().map(|&v| v * n as i32 - total).collect(); + + let mid = n >> 1; + use std::collections::{HashMap, HashSet}; + + fn generate(arr: &[i32]) -> HashMap> { + let mut mp: HashMap> = HashMap::new(); + let len = arr.len(); + for mask in 1..(1 << len) { + let mut sum = 0; + let mut cnt = 0; + for i in 0..len { + if mask & (1 << i) != 0 { + sum += arr[i]; + cnt += 1; + } + } + mp.entry(cnt).or_insert_with(HashSet::new).insert(sum); + } + mp + } + + let mp_a = generate(&transformed[..mid]); + let mp_b = generate(&transformed[mid..]); + + for (cnt, set) in &mp_a { + if set.contains(&0) && *cnt != 0 { + return true; + } + } + for (cnt, set) in &mp_b { + if set.contains(&0) && *cnt != 0 { + return true; + } + } + + for (cnt_a, set_a) in &mp_a { + for (cnt_b, set_b) in &mp_b { + let total_cnt = cnt_a + cnt_b; + if total_cnt == 0 || total_cnt == n { + continue; + } + for val in set_a { + if set_b.contains(&(-val)) { + return true; + } + } + } + } + false + } +} diff --git a/tests/501-1000/805. split-array-with-same-average/sol.swift b/tests/501-1000/805. split-array-with-same-average/sol.swift new file mode 100644 index 00000000..c745ea3b --- /dev/null +++ b/tests/501-1000/805. split-array-with-same-average/sol.swift @@ -0,0 +1,45 @@ +class Solution { + func splitArraySameAverage(_ nums: [Int]) -> Bool { + let n = nums.count + if n < 2 { return false } + let total = nums.reduce(0, +) + let transformed = nums.map { $0 * n - total } + + let mid = n >> 1 + func generate(_ arr: [Int]) -> [Int: Set] { + var mp = [Int: Set]() + for mask in 1..<(1 << arr.count) { + var sum = 0, cnt = 0 + for i in 0..()].insert(sum) + } + return mp + } + + let mpA = generate(Array(transformed[0.. a + b, 0); + const transformed = nums.map((v) => v * n - total); + + const mid = n >> 1; + function generate(arr: number[]): Map> { + const mp = new Map>(); + for (let mask = 1; mask < 1 << arr.length; mask++) { + let sum = 0, + cnt = 0; + for (let i = 0; i < arr.length; i++) { + if (mask & (1 << i)) { + sum += arr[i]; + cnt++; + } + } + if (!mp.has(cnt)) mp.set(cnt, new Set()); + mp.get(cnt)!.add(sum); + } + return mp; + } + + const mpA = generate(transformed.slice(0, mid)); + const mpB = generate(transformed.slice(mid)); + + for (const [cnt, set] of mpA) { + if (set.has(0) && cnt !== 0) return true; + } + for (const [cnt, set] of mpB) { + if (set.has(0) && cnt !== 0) return true; + } + + for (const [cntA, setA] of mpA) { + for (const [cntB, setB] of mpB) { + const totalCnt = cntA + cntB; + if (totalCnt === 0 || totalCnt === n) continue; + for (const v of setA) { + if (setB.has(-v)) return true; + } + } + } + return false; +} diff --git a/tests/501-1000/806. number-of-lines-to-write-string/manifest.yaml b/tests/501-1000/806. number-of-lines-to-write-string/manifest.yaml new file mode 100644 index 00000000..7e090f06 --- /dev/null +++ b/tests/501-1000/806. number-of-lines-to-write-string/manifest.yaml @@ -0,0 +1,1267 @@ +entry: + id: 806 + title: "number-of-lines-to-write-string" + params: + widths: + type: array + items: + type: int + s: + type: string + call: + cpp: Solution().numberOfLines({widths}, {s}) + rust: Solution::number_of_lines({widths}, {s}) + python3: Solution().numberOfLines({widths}, {s}) + python2: Solution().numberOfLines({widths}, {s}) + ruby: number_of_lines({widths}, {s}) + java: new Solution().numberOfLines({widths}, {s}) + csharp: new Solution().NumberOfLines({widths}, {s}) + kotlin: Solution().numberOfLines({widths}, {s}) + go: numberOfLines({widths}, {s}) + dart: Solution().numberOfLines({widths}, {s}) + swift: Solution().numberOfLines({widths}, {s}) + typescript: numberOfLines({widths}, {s}) + +judge: + type: "exact" + +limits: + time_ms: 200 + memory_mb: 128 + +oracle: + python3: + call: "Checker().check({widths}, {s}, {result})" + checker: | + class Checker: + def check(self, *args): + return True + +seed: 806 + +tests: + - name: case01 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: a + out: + - 1 + - 10 + - name: case02 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aa + out: + - 1 + - 20 + - name: case03 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaa + out: + - 1 + - 30 + - name: case04 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaa + out: + - 1 + - 40 + - name: case05 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaa + out: + - 1 + - 50 + - name: case06 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaa + out: + - 1 + - 60 + - name: case07 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaa + out: + - 1 + - 70 + - name: case08 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaa + out: + - 1 + - 80 + - name: case09 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaa + out: + - 1 + - 90 + - name: case10 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaaa + out: + - 1 + - 100 + - name: case11 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaaaa + out: + - 2 + - 10 + - name: case12 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaaaaa + out: + - 2 + - 20 + - name: case13 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaaaaaa + out: + - 2 + - 30 + - name: case14 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaaaaaaa + out: + - 2 + - 40 + - name: case15 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaaaaaaaa + out: + - 2 + - 50 + - name: case16 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaaaaaaaaa + out: + - 2 + - 60 + - name: case17 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaaaaaaaaaa + out: + - 2 + - 70 + - name: case18 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaaaaaaaaaaa + out: + - 2 + - 80 + - name: case19 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaaaaaaaaaaaa + out: + - 2 + - 90 + - name: case20 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaaaaaaaaaaaaa + out: + - 2 + - 100 + - name: case21 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaaaaaaaaaaaaaa + out: + - 3 + - 10 + - name: case22 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaaaaaaaaaaaaaaa + out: + - 3 + - 20 + - name: case23 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaaaaaaaaaaaaaaaa + out: + - 3 + - 30 + - name: case24 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaaaaaaaaaaaaaaaaa + out: + - 3 + - 40 + - name: case25 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaaaaaaaaaaaaaaaaaa + out: + - 3 + - 50 + - name: case26 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaaaaaaaaaaaaaaaaaaa + out: + - 3 + - 60 + - name: case27 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaaaaaaaaaaaaaaaaaaaa + out: + - 3 + - 70 + - name: case28 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaaaaaaaaaaaaaaaaaaaaa + out: + - 3 + - 80 + - name: case29 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaaaaaaaaaaaaaaaaaaaaaa + out: + - 3 + - 90 + - name: case30 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + out: + - 3 + - 100 + - name: case31 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + out: + - 4 + - 10 + - name: case32 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + out: + - 4 + - 20 + - name: case33 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + out: + - 4 + - 30 + - name: case34 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + out: + - 4 + - 40 + - name: case35 + in: + widths: + [ + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + ] + s: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + out: + - 4 + - 50 diff --git a/tests/501-1000/806. number-of-lines-to-write-string/sol.cpp b/tests/501-1000/806. number-of-lines-to-write-string/sol.cpp new file mode 100644 index 00000000..eef77d82 --- /dev/null +++ b/tests/501-1000/806. number-of-lines-to-write-string/sol.cpp @@ -0,0 +1,17 @@ +class Solution { +public: + vector numberOfLines(vector& widths, string s) { + int lines = 1; + int current = 0; + for (char c : s) { + int w = widths[c - 'a']; + if (current + w > 100) { + lines++; + current = w; + } else { + current += w; + } + } + return {lines, current}; + } +}; diff --git a/tests/501-1000/806. number-of-lines-to-write-string/sol.cs b/tests/501-1000/806. number-of-lines-to-write-string/sol.cs new file mode 100644 index 00000000..97842ff8 --- /dev/null +++ b/tests/501-1000/806. number-of-lines-to-write-string/sol.cs @@ -0,0 +1,16 @@ +public class Solution { + public int[] NumberOfLines(int[] widths, string s) { + int lines = 1; + int current = 0; + foreach (char c in s) { + int w = widths[c - 'a']; + if (current + w > 100) { + lines++; + current = w; + } else { + current += w; + } + } + return new int[] { lines, current }; + } +} diff --git a/tests/501-1000/806. number-of-lines-to-write-string/sol.dart b/tests/501-1000/806. number-of-lines-to-write-string/sol.dart new file mode 100644 index 00000000..e6d7b767 --- /dev/null +++ b/tests/501-1000/806. number-of-lines-to-write-string/sol.dart @@ -0,0 +1,18 @@ +class Solution { + List numberOfLines(List widths, String s) { + int lines = 1; + int current = 0; + + for (int codeUnit in s.codeUnits) { + int width = widths[codeUnit - 97]; + if (current + width > 100) { + lines++; + current = width; + } else { + current += width; + } + } + + return [lines, current]; + } +} diff --git a/tests/501-1000/806. number-of-lines-to-write-string/sol.go b/tests/501-1000/806. number-of-lines-to-write-string/sol.go new file mode 100644 index 00000000..a208c040 --- /dev/null +++ b/tests/501-1000/806. number-of-lines-to-write-string/sol.go @@ -0,0 +1,14 @@ +func numberOfLines(widths []int, s string) []int { + lines := 1 + current := 0 + for _, c := range s { + w := widths[c - 'a'] + if current + w > 100 { + lines++ + current = w + } else { + current += w + } + } + return []int{lines, current} +} diff --git a/tests/501-1000/806. number-of-lines-to-write-string/sol.java b/tests/501-1000/806. number-of-lines-to-write-string/sol.java new file mode 100644 index 00000000..ba13a035 --- /dev/null +++ b/tests/501-1000/806. number-of-lines-to-write-string/sol.java @@ -0,0 +1,16 @@ +class Solution { + public int[] numberOfLines(int[] widths, String s) { + int lines = 1; + int current = 0; + for (char c : s.toCharArray()) { + int w = widths[c - 'a']; + if (current + w > 100) { + lines++; + current = w; + } else { + current += w; + } + } + return new int[]{lines, current}; + } +} diff --git a/tests/501-1000/806. number-of-lines-to-write-string/sol.kt b/tests/501-1000/806. number-of-lines-to-write-string/sol.kt new file mode 100644 index 00000000..8f935409 --- /dev/null +++ b/tests/501-1000/806. number-of-lines-to-write-string/sol.kt @@ -0,0 +1,16 @@ +class Solution { + fun numberOfLines(widths: IntArray, s: String): IntArray { + var lines = 1 + var current = 0 + for (c in s) { + val w = widths[c.code - 97] + if (current + w > 100) { + lines++ + current = w + } else { + current += w + } + } + return intArrayOf(lines, current) + } +} diff --git a/tests/501-1000/806. number-of-lines-to-write-string/sol.py b/tests/501-1000/806. number-of-lines-to-write-string/sol.py new file mode 100644 index 00000000..6607f8cb --- /dev/null +++ b/tests/501-1000/806. number-of-lines-to-write-string/sol.py @@ -0,0 +1,12 @@ +class Solution(object): + def numberOfLines(self, widths, s): + lines = 1 + current = 0 + for c in s: + w = widths[ord(c) - 97] + if current + w > 100: + lines += 1 + current = w + else: + current += w + return [lines, current] diff --git a/tests/501-1000/806. number-of-lines-to-write-string/sol.py2 b/tests/501-1000/806. number-of-lines-to-write-string/sol.py2 new file mode 100644 index 00000000..6607f8cb --- /dev/null +++ b/tests/501-1000/806. number-of-lines-to-write-string/sol.py2 @@ -0,0 +1,12 @@ +class Solution(object): + def numberOfLines(self, widths, s): + lines = 1 + current = 0 + for c in s: + w = widths[ord(c) - 97] + if current + w > 100: + lines += 1 + current = w + else: + current += w + return [lines, current] diff --git a/tests/501-1000/806. number-of-lines-to-write-string/sol.rb b/tests/501-1000/806. number-of-lines-to-write-string/sol.rb new file mode 100644 index 00000000..41fbc2a7 --- /dev/null +++ b/tests/501-1000/806. number-of-lines-to-write-string/sol.rb @@ -0,0 +1,17 @@ +# @param {Integer[]} widths +# @param {String} s +# @return {Integer[]} +def number_of_lines(widths, s) + lines = 1 + current = 0 + s.each_char do |c| + w = widths[c.ord - 97] + if current + w > 100 + lines += 1 + current = w + else + current += w + end + end + [lines, current] +end diff --git a/tests/501-1000/806. number-of-lines-to-write-string/sol.rs b/tests/501-1000/806. number-of-lines-to-write-string/sol.rs new file mode 100644 index 00000000..5f89423b --- /dev/null +++ b/tests/501-1000/806. number-of-lines-to-write-string/sol.rs @@ -0,0 +1,16 @@ +impl Solution { + pub fn number_of_lines(widths: Vec, s: String) -> Vec { + let mut lines = 1; + let mut current = 0; + for c in s.chars() { + let w = widths[(c as u8 - b'a') as usize]; + if current + w > 100 { + lines += 1; + current = w; + } else { + current += w; + } + } + vec![lines, current] + } +} diff --git a/tests/501-1000/806. number-of-lines-to-write-string/sol.swift b/tests/501-1000/806. number-of-lines-to-write-string/sol.swift new file mode 100644 index 00000000..3c53740c --- /dev/null +++ b/tests/501-1000/806. number-of-lines-to-write-string/sol.swift @@ -0,0 +1,16 @@ +class Solution { + func numberOfLines(_ widths: [Int], _ s: String) -> [Int] { + var lines = 1 + var current = 0 + for c in s { + let w = widths[Int(c.asciiValue!) - 97] + if current + w > 100 { + lines += 1 + current = w + } else { + current += w + } + } + return [lines, current] + } +} diff --git a/tests/501-1000/806. number-of-lines-to-write-string/sol.ts b/tests/501-1000/806. number-of-lines-to-write-string/sol.ts new file mode 100644 index 00000000..0702df5e --- /dev/null +++ b/tests/501-1000/806. number-of-lines-to-write-string/sol.ts @@ -0,0 +1,14 @@ +function numberOfLines(widths: number[], s: string): number[] { + let lines = 1; + let current = 0; + for (const c of s) { + const w = widths[c.charCodeAt(0) - 97]; + if (current + w > 100) { + lines++; + current = w; + } else { + current += w; + } + } + return [lines, current]; +} diff --git a/tests/501-1000/807. max-increase-to-keep-city-skyline/manifest.yaml b/tests/501-1000/807. max-increase-to-keep-city-skyline/manifest.yaml new file mode 100644 index 00000000..2e20867b --- /dev/null +++ b/tests/501-1000/807. max-increase-to-keep-city-skyline/manifest.yaml @@ -0,0 +1,360 @@ +entry: + id: 807 + title: max-increase-to-keep-city-skyline + params: + grid: + type: array + items: + type: array + items: + type: int + call: + cpp: Solution().maxIncreaseKeepingSkyline({grid}) + rust: Solution::max_increase_keeping_skyline({grid}) + python3: Solution().maxIncreaseKeepingSkyline({grid}) + python2: Solution().maxIncreaseKeepingSkyline({grid}) + ruby: max_increase_keeping_skyline({grid}) + java: new Solution().maxIncreaseKeepingSkyline({grid}) + csharp: new Solution().MaxIncreaseKeepingSkyline({grid}) + kotlin: Solution().maxIncreaseKeepingSkyline({grid}) + go: maxIncreaseKeepingSkyline({grid}) + dart: Solution().maxIncreaseKeepingSkyline({grid}) + swift: Solution().maxIncreaseKeepingSkyline({grid}) + typescript: maxIncreaseKeepingSkyline({grid}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().maxIncreaseKeepingSkyline(grid, {result}) + checker: | + class Checker: + def maxIncreaseKeepingSkyline(self, grid, result): + n = len(grid) + row_max = [max(row) for row in grid] + col_max = [max(grid[r][c] for r in range(n)) for c in range(n)] + expected = 0 + for r in range(n): + for c in range(n): + expected += min(row_max[r], col_max[c]) - grid[r][c] + return result == expected +seed: 807 +tests: + - name: example + in: + grid: + elemType: int + value: + - [3, 0, 8, 4] + - [2, 4, 5, 7] + - [9, 2, 6, 3] + - [0, 3, 1, 0] + out: 35 + - name: all-zero + in: + grid: + elemType: int + value: + - [0, 0, 0] + - [0, 0, 0] + - [0, 0, 0] + out: 0 + - name: single-zero + in: + grid: + elemType: int + value: + - [0] + out: 0 + - name: single-nine + in: + grid: + elemType: int + value: + - [9] + out: 0 + - name: two-flat + in: + grid: + elemType: int + value: + - [1, 1] + - [1, 1] + out: 0 + - name: two-diagonal + in: + grid: + elemType: int + value: + - [1, 2] + - [3, 4] + out: 1 + - name: mixed-small + in: + grid: + elemType: int + value: + - [2, 4] + - [3, 1] + - name: symmetric + in: + grid: + elemType: int + value: + - [1, 2, 1] + - [2, 3, 2] + - [1, 2, 1] + - name: center-zero + in: + grid: + elemType: int + value: + - [5, 0, 5] + - [0, 0, 0] + - [5, 0, 5] + - name: ascending-rows + in: + grid: + elemType: int + value: + - [1, 2, 3, 4, 5] + - [1, 2, 3, 4, 5] + - [1, 2, 3, 4, 5] + - [1, 2, 3, 4, 5] + - [1, 2, 3, 4, 5] + - name: descending-rows + in: + grid: + elemType: int + value: + - [5, 4, 3, 2, 1] + - [5, 4, 3, 2, 1] + - [5, 4, 3, 2, 1] + - [5, 4, 3, 2, 1] + - [5, 4, 3, 2, 1] + - name: high-border + in: + grid: + elemType: int + value: + - [9, 9, 9, 9, 9, 9] + - [9, 1, 1, 1, 1, 9] + - [9, 1, 1, 1, 1, 9] + - [9, 1, 1, 1, 1, 9] + - [9, 1, 1, 1, 1, 9] + - [9, 9, 9, 9, 9, 9] + - name: checkerboard-5 + in: + grid: + elemType: int + value: + - [0, 1, 0, 1, 0] + - [1, 0, 1, 0, 1] + - [0, 1, 0, 1, 0] + - [1, 0, 1, 0, 1] + - [0, 1, 0, 1, 0] + - name: flat-three + in: + grid: + elemType: int + value: + - [2, 2, 2] + - [2, 2, 2] + - [2, 2, 2] + out: 0 + - name: three-ramp + in: + grid: + elemType: int + value: + - [1, 2, 3] + - [2, 3, 1] + - [3, 1, 2] + - name: lopsided-row-max + in: + grid: + elemType: int + value: + - [4, 1, 4] + - [1, 1, 1] + - [4, 1, 4] + out: 0 + - name: inner-valley + in: + grid: + elemType: int + value: + - [7, 6, 7, 6] + - [6, 1, 1, 6] + - [7, 1, 1, 7] + - [6, 6, 6, 6] + - name: border-dominates + in: + grid: + elemType: int + value: + - [8, 8, 8, 8] + - [8, 0, 0, 8] + - [8, 0, 0, 8] + - [8, 8, 8, 8] + - name: mixed-4x4 + in: + grid: + elemType: int + value: + - [4, 2, 6, 3] + - [1, 5, 2, 4] + - [7, 1, 3, 2] + - [6, 4, 5, 1] + - name: descending-3x3 + in: + grid: + elemType: int + value: + - [9, 8, 7] + - [6, 5, 4] + - [3, 2, 1] + out: 6 + - name: staircase + in: + grid: + elemType: int + value: + - [0, 2, 4, 6] + - [1, 3, 5, 7] + - [2, 4, 6, 8] + - [3, 5, 7, 9] + - name: mixed-high-corners + in: + grid: + elemType: int + value: + - [6, 6, 1, 6] + - [6, 2, 2, 6] + - [1, 2, 2, 1] + - [6, 6, 1, 6] + - name: sparse-peaks + in: + grid: + elemType: int + value: + - [2, 0, 2, 0, 2] + - [0, 2, 0, 2, 0] + - [2, 0, 3, 0, 2] + - [0, 2, 0, 2, 0] + - [2, 0, 2, 0, 2] + - name: alternating-4x4 + in: + grid: + elemType: int + value: + - [1, 3, 1, 3] + - [3, 1, 3, 1] + - [1, 3, 1, 3] + - [3, 1, 3, 1] + out: 16 + - name: maxed-row-and-col + in: + grid: + elemType: int + value: + - [9, 1, 9] + - [1, 1, 1] + - [9, 1, 9] + out: 0 + - name: two-by-two-slope + in: + grid: + elemType: int + value: + - [2, 4] + - [4, 2] + out: 4 + - name: four-by-four-shifted + in: + grid: + elemType: int + value: + - [2, 4, 1, 3] + - [3, 1, 4, 2] + - [4, 2, 3, 1] + - [1, 3, 2, 4] + - name: low-center-high-edge + in: + grid: + elemType: int + value: + - [5, 5, 5, 5] + - [5, 1, 2, 5] + - [5, 2, 1, 5] + - [5, 5, 5, 5] + - name: row-peaks + in: + grid: + elemType: int + value: + - [9, 1, 1, 1, 1] + - [1, 8, 1, 1, 1] + - [1, 1, 7, 1, 1] + - [1, 1, 1, 6, 1] + - [1, 1, 1, 1, 5] + - name: column-peaks + in: + grid: + elemType: int + value: + - [9, 1, 1, 1, 1] + - [8, 1, 1, 1, 1] + - [7, 1, 1, 1, 1] + - [6, 1, 1, 1, 1] + - [5, 1, 1, 1, 1] + - name: center-plateau + in: + grid: + elemType: int + value: + - [4, 4, 4, 4, 4] + - [4, 7, 7, 7, 4] + - [4, 7, 1, 7, 4] + - [4, 7, 7, 7, 4] + - [4, 4, 4, 4, 4] + - name: valley-five + in: + grid: + elemType: int + value: + - [6, 6, 6, 6, 6] + - [6, 2, 2, 2, 6] + - [6, 2, 0, 2, 6] + - [6, 2, 2, 2, 6] + - [6, 6, 6, 6, 6] + - name: randomish-five + in: + grid: + elemType: int + value: + - [3, 7, 2, 5, 1] + - [6, 1, 4, 2, 8] + - [5, 3, 9, 1, 4] + - [2, 8, 6, 3, 7] + - [1, 4, 5, 7, 2] + - name: corners-only + in: + grid: + elemType: int + value: + - [9, 0, 0, 9] + - [0, 0, 0, 0] + - [0, 0, 0, 0] + - [9, 0, 0, 9] + - name: anti-diagonal-heavy + in: + grid: + elemType: int + value: + - [1, 1, 1, 9] + - [1, 1, 8, 1] + - [1, 7, 1, 1] + - [6, 1, 1, 1] diff --git a/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.cpp b/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.cpp new file mode 100644 index 00000000..391f50d3 --- /dev/null +++ b/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.cpp @@ -0,0 +1,24 @@ +class Solution { +public: + int maxIncreaseKeepingSkyline(vector>& grid) { + int n = grid.size(); + vector rowMax(n, 0), colMax(n, 0); + for (int r = 0; r < n; r++) { + rowMax[r] = *max_element(grid[r].begin(), grid[r].end()); + } + for (int c = 0; c < n; c++) { + int maxVal = 0; + for (int r = 0; r < n; r++) { + maxVal = max(maxVal, grid[r][c]); + } + colMax[c] = maxVal; + } + int gain = 0; + for (int r = 0; r < n; r++) { + for (int c = 0; c < n; c++) { + gain += min(rowMax[r], colMax[c]) - grid[r][c]; + } + } + return gain; + } +}; diff --git a/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.cs b/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.cs new file mode 100644 index 00000000..924a0f47 --- /dev/null +++ b/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.cs @@ -0,0 +1,28 @@ +public class Solution { + public int MaxIncreaseKeepingSkyline(int[][] grid) { + int n = grid.Length; + int[] rowMax = new int[n]; + int[] colMax = new int[n]; + for (int r = 0; r < n; r++) { + int maxVal = 0; + for (int c = 0; c < n; c++) { + maxVal = Math.Max(maxVal, grid[r][c]); + } + rowMax[r] = maxVal; + } + for (int c = 0; c < n; c++) { + int maxVal = 0; + for (int r = 0; r < n; r++) { + maxVal = Math.Max(maxVal, grid[r][c]); + } + colMax[c] = maxVal; + } + int gain = 0; + for (int r = 0; r < n; r++) { + for (int c = 0; c < n; c++) { + gain += Math.Min(rowMax[r], colMax[c]) - grid[r][c]; + } + } + return gain; + } +} diff --git a/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.dart b/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.dart new file mode 100644 index 00000000..f1b751bf --- /dev/null +++ b/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.dart @@ -0,0 +1,21 @@ +class Solution { + int maxIncreaseKeepingSkyline(List> grid) { + int n = grid.length; + List rowMax = List.generate(n, (r) => grid[r].reduce((a, b) => a > b ? a : b)); + List colMax = List.generate(n, (c) { + int maxVal = 0; + for (int r = 0; r < n; r++) { + if (grid[r][c] > maxVal) maxVal = grid[r][c]; + } + return maxVal; + }); + int gain = 0; + for (int r = 0; r < n; r++) { + for (int c = 0; c < n; c++) { + int minVal = rowMax[r] < colMax[c] ? rowMax[r] : colMax[c]; + gain += minVal - grid[r][c]; + } + } + return gain; + } +} diff --git a/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.go b/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.go new file mode 100644 index 00000000..52afda82 --- /dev/null +++ b/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.go @@ -0,0 +1,34 @@ +func maxIncreaseKeepingSkyline(grid [][]int) int { + n := len(grid) + rowMax := make([]int, n) + colMax := make([]int, n) + for r := 0; r < n; r++ { + maxVal := 0 + for _, val := range grid[r] { + if val > maxVal { + maxVal = val + } + } + rowMax[r] = maxVal + } + for c := 0; c < n; c++ { + maxVal := 0 + for r := 0; r < n; r++ { + if grid[r][c] > maxVal { + maxVal = grid[r][c] + } + } + colMax[c] = maxVal + } + gain := 0 + for r := 0; r < n; r++ { + for c := 0; c < n; c++ { + minVal := rowMax[r] + if colMax[c] < minVal { + minVal = colMax[c] + } + gain += minVal - grid[r][c] + } + } + return gain +} diff --git a/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.java b/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.java new file mode 100644 index 00000000..f24ccab3 --- /dev/null +++ b/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.java @@ -0,0 +1,28 @@ +class Solution { + public int maxIncreaseKeepingSkyline(int[][] grid) { + int n = grid.length; + int[] rowMax = new int[n]; + int[] colMax = new int[n]; + for (int r = 0; r < n; r++) { + int maxVal = 0; + for (int c = 0; c < n; c++) { + maxVal = Math.max(maxVal, grid[r][c]); + } + rowMax[r] = maxVal; + } + for (int c = 0; c < n; c++) { + int maxVal = 0; + for (int r = 0; r < n; r++) { + maxVal = Math.max(maxVal, grid[r][c]); + } + colMax[c] = maxVal; + } + int gain = 0; + for (int r = 0; r < n; r++) { + for (int c = 0; c < n; c++) { + gain += Math.min(rowMax[r], colMax[c]) - grid[r][c]; + } + } + return gain; + } +} diff --git a/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.kt b/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.kt new file mode 100644 index 00000000..2163ff8a --- /dev/null +++ b/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.kt @@ -0,0 +1,14 @@ +class Solution { + fun maxIncreaseKeepingSkyline(grid: Array): Int { + val n = grid.size + val rowMax = IntArray(n) { r -> grid[r].max() } + val colMax = IntArray(n) { c -> (0 until n).maxOf { r -> grid[r][c] } } + var gain = 0 + for (r in 0 until n) { + for (c in 0 until n) { + gain += minOf(rowMax[r], colMax[c]) - grid[r][c] + } + } + return gain + } +} diff --git a/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.py b/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.py new file mode 100644 index 00000000..1d9b08f2 --- /dev/null +++ b/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.py @@ -0,0 +1,10 @@ +class Solution(object): + def maxIncreaseKeepingSkyline(self, grid): + n = len(grid) + rowMax = [max(row) for row in grid] + colMax = [max(grid[r][c] for r in range(n)) for c in range(n)] + gain = 0 + for r in range(n): + for c in range(n): + gain += min(rowMax[r], colMax[c]) - grid[r][c] + return gain diff --git a/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.py2 b/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.py2 new file mode 100644 index 00000000..1d9b08f2 --- /dev/null +++ b/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.py2 @@ -0,0 +1,10 @@ +class Solution(object): + def maxIncreaseKeepingSkyline(self, grid): + n = len(grid) + rowMax = [max(row) for row in grid] + colMax = [max(grid[r][c] for r in range(n)) for c in range(n)] + gain = 0 + for r in range(n): + for c in range(n): + gain += min(rowMax[r], colMax[c]) - grid[r][c] + return gain diff --git a/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.rb b/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.rb new file mode 100644 index 00000000..c9adffe5 --- /dev/null +++ b/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.rb @@ -0,0 +1,14 @@ +# @param {Integer[][]} grid +# @return {Integer} +def max_increase_keeping_skyline(grid) + n = grid.length + row_max = grid.map { |row| row.max } + col_max = (0...n).map { |c| grid.map { |row| row[c] }.max } + gain = 0 + (0...n).each do |r| + (0...n).each do |c| + gain += [row_max[r], col_max[c]].min - grid[r][c] + end + end + gain +end diff --git a/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.rs b/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.rs new file mode 100644 index 00000000..b0032951 --- /dev/null +++ b/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.rs @@ -0,0 +1,21 @@ +impl Solution { + pub fn max_increase_keeping_skyline(grid: Vec>) -> i32 { + let n = grid.len(); + let row_max: Vec = grid.iter().map(|row| *row.iter().max().unwrap()).collect(); + let mut col_max = vec![0; n]; + for c in 0..n { + let mut max_val = 0; + for r in 0..n { + max_val = max_val.max(grid[r][c]); + } + col_max[c] = max_val; + } + let mut gain = 0; + for r in 0..n { + for c in 0..n { + gain += row_max[r].min(col_max[c]) - grid[r][c]; + } + } + gain + } +} diff --git a/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.swift b/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.swift new file mode 100644 index 00000000..4ba1fa54 --- /dev/null +++ b/tests/501-1000/807. max-increase-to-keep-city-skyline/sol.swift @@ -0,0 +1,24 @@ +class Solution { + func maxIncreaseKeepingSkyline(_ grid: [[Int]]) -> Int { + let n = grid.count + var rowMax = [Int](repeating: 0, count: n) + var colMax = [Int](repeating: 0, count: n) + for r in 0.. 5000:\n return\ + \ abs(result - 1.0) <= 1e-5\n units = math.ceil(n / 25)\n\n @lru_cache(None)\n\ + \ def calc(a, b):\n if a <= 0 and b <= 0:\n \ + \ return 0.5\n if a <= 0:\n return 1.0\n \ + \ if b <= 0:\n return 0.0\n return 0.25 * (calc(a\ + \ - 4, b) + calc(a - 3, b - 1) + calc(a - 2, b - 2) + calc(a - 1, b - 3))\n\n\ + \ expected = calc(units, units)\n return abs(result - expected)\ + \ <= 1e-5\n" +seed: 808 +tests: + - name: n-zero + in: + n: 0 + - name: example-50 + in: + n: 50 + - name: example-100 + in: + n: 100 + - name: quarter-step + in: + n: 25 + - name: fifty + in: + n: 75 + - name: seventy-five + in: + n: 125 + - name: hundred-fifty + in: + n: 150 + - name: two-hundred + in: + n: 200 + - name: two-fifty + in: + n: 250 + - name: three-hundred + in: + n: 300 + - name: four-hundred + in: + n: 400 + - name: five-hundred + in: + n: 500 + - name: nine-hundred-ninety-nine + in: + n: 999 + - name: one-thousand + in: + n: 1000 + - name: large-threshold + in: + n: 5001 + - name: tiny-one + in: + n: 1 + - name: tiny-twenty-four + in: + n: 24 + - name: boundary-twenty-five + in: + n: 25 + - name: boundary-twenty-six + in: + n: 26 + - name: boundary-forty-nine + in: + n: 49 + - name: boundary-fifty-one + in: + n: 51 + - name: boundary-seventy-four + in: + n: 74 + - name: boundary-seventy-six + in: + n: 76 + - name: one-hundred-fifty + in: + n: 150 + - name: two-hundred + in: + n: 200 + - name: three-hundred + in: + n: 300 + - name: four-hundred + in: + n: 400 + - name: five-hundred + in: + n: 500 + - name: one-thousand + in: + n: 1000 + - name: three-thousand + in: + n: 3000 + - name: five-thousand + in: + n: 5000 + - name: just-over-threshold + in: + n: 5001 + - name: much-over-threshold + in: + n: 100000 + - name: enormous + in: + n: 1000000000 diff --git a/tests/501-1000/808. soup-servings/sol.cpp b/tests/501-1000/808. soup-servings/sol.cpp new file mode 100644 index 00000000..4d7d7b8c --- /dev/null +++ b/tests/501-1000/808. soup-servings/sol.cpp @@ -0,0 +1,37 @@ +class Solution { +private: + unordered_map memo; + + double calcProb(int soupA, int soupB) { + string key = to_string(soupA) + "," + to_string(soupB); + if (memo.count(key)) { + return memo[key]; + } + if (soupA <= 0 && soupB <= 0) { + return 0.5; + } + if (soupA <= 0) { + return 1.0; + } + if (soupB <= 0) { + return 0.0; + } + double result = 0.25 * ( + calcProb(soupA - 4, soupB) + + calcProb(soupA - 3, soupB - 1) + + calcProb(soupA - 2, soupB - 2) + + calcProb(soupA - 1, soupB - 3) + ); + memo[key] = result; + return result; + } + +public: + double soupServings(int n) { + if (n > 5000) { + return 1.0; + } + int units = ceil(n / 25.0); + return calcProb(units, units); + } +}; diff --git a/tests/501-1000/808. soup-servings/sol.cs b/tests/501-1000/808. soup-servings/sol.cs new file mode 100644 index 00000000..e6111e25 --- /dev/null +++ b/tests/501-1000/808. soup-servings/sol.cs @@ -0,0 +1,35 @@ +public class Solution { + private Dictionary<(int, int), double> memo; + + public double SoupServings(int n) { + if (n > 5000) { + return 1.0; + } + int units = (int)Math.Ceiling(n / 25.0); + memo = new Dictionary<(int, int), double>(); + return CalcProb(units, units); + } + + private double CalcProb(int soupA, int soupB) { + if (memo.TryGetValue((soupA, soupB), out double val)) { + return val; + } + if (soupA <= 0 && soupB <= 0) { + return 0.5; + } + if (soupA <= 0) { + return 1.0; + } + if (soupB <= 0) { + return 0.0; + } + double result = 0.25 * ( + CalcProb(soupA - 4, soupB) + + CalcProb(soupA - 3, soupB - 1) + + CalcProb(soupA - 2, soupB - 2) + + CalcProb(soupA - 1, soupB - 3) + ); + memo[(soupA, soupB)] = result; + return result; + } +} diff --git a/tests/501-1000/808. soup-servings/sol.dart b/tests/501-1000/808. soup-servings/sol.dart new file mode 100644 index 00000000..0cd9a925 --- /dev/null +++ b/tests/501-1000/808. soup-servings/sol.dart @@ -0,0 +1,34 @@ +class Solution { + double soupServings(int n) { + if (n > 5000) { + return 1.0; + } + int units = (n / 25).ceil(); + Map memo = {}; + + double calcProb(int soupA, int soupB) { + String key = '$soupA,$soupB'; + if (memo.containsKey(key)) { + return memo[key]!; + } + if (soupA <= 0 && soupB <= 0) { + return 0.5; + } + if (soupA <= 0) { + return 1.0; + } + if (soupB <= 0) { + return 0.0; + } + double result = 0.25 * ( + calcProb(soupA - 4, soupB) + + calcProb(soupA - 3, soupB - 1) + + calcProb(soupA - 2, soupB - 2) + + calcProb(soupA - 1, soupB - 3)); + memo[key] = result; + return result; + } + + return calcProb(units, units); + } +} diff --git a/tests/501-1000/808. soup-servings/sol.go b/tests/501-1000/808. soup-servings/sol.go new file mode 100644 index 00000000..efee1137 --- /dev/null +++ b/tests/501-1000/808. soup-servings/sol.go @@ -0,0 +1,33 @@ +func soupServings(n int) float64 { + if n > 5000 { + return 1.0 + } + units := int(math.Ceil(float64(n) / 25.0)) + memo := make(map[string]float64) + + var calcProb func(int, int) float64 + calcProb = func(soupA, soupB int) float64 { + key := fmt.Sprintf("%d,%d", soupA, soupB) + if val, ok := memo[key]; ok { + return val + } + if soupA <= 0 && soupB <= 0 { + return 0.5 + } + if soupA <= 0 { + return 1.0 + } + if soupB <= 0 { + return 0.0 + } + result := 0.25 * ( + calcProb(soupA-4, soupB) + + calcProb(soupA-3, soupB-1) + + calcProb(soupA-2, soupB-2) + + calcProb(soupA-1, soupB-3)) + memo[key] = result + return result + } + + return calcProb(units, units) +} diff --git a/tests/501-1000/808. soup-servings/sol.java b/tests/501-1000/808. soup-servings/sol.java new file mode 100644 index 00000000..01aac477 --- /dev/null +++ b/tests/501-1000/808. soup-servings/sol.java @@ -0,0 +1,36 @@ +class Solution { + private java.util.Map memo; + + public double soupServings(int n) { + if (n > 5000) { + return 1.0; + } + int units = (int) Math.ceil(n / 25.0); + memo = new java.util.HashMap<>(); + return calcProb(units, units); + } + + private double calcProb(int soupA, int soupB) { + String key = soupA + "," + soupB; + if (memo.containsKey(key)) { + return memo.get(key); + } + if (soupA <= 0 && soupB <= 0) { + return 0.5; + } + if (soupA <= 0) { + return 1.0; + } + if (soupB <= 0) { + return 0.0; + } + double result = 0.25 * ( + calcProb(soupA - 4, soupB) + + calcProb(soupA - 3, soupB - 1) + + calcProb(soupA - 2, soupB - 2) + + calcProb(soupA - 1, soupB - 3) + ); + memo.put(key, result); + return result; + } +} diff --git a/tests/501-1000/808. soup-servings/sol.kt b/tests/501-1000/808. soup-servings/sol.kt new file mode 100644 index 00000000..9e415177 --- /dev/null +++ b/tests/501-1000/808. soup-servings/sol.kt @@ -0,0 +1,27 @@ +class Solution { + fun soupServings(n: Int): Double { + if (n > 5000) { + return 1.0 + } + val units = Math.ceil(n / 25.0).toInt() + val memo = mutableMapOf, Double>() + + fun calcProb(soupA: Int, soupB: Int): Double { + val key = Pair(soupA, soupB) + memo[key]?.let { return it } + if (soupA <= 0 && soupB <= 0) return 0.5 + if (soupA <= 0) return 1.0 + if (soupB <= 0) return 0.0 + val result = 0.25 * ( + calcProb(soupA - 4, soupB) + + calcProb(soupA - 3, soupB - 1) + + calcProb(soupA - 2, soupB - 2) + + calcProb(soupA - 1, soupB - 3) + ) + memo[key] = result + return result + } + + return calcProb(units, units) + } +} diff --git a/tests/501-1000/808. soup-servings/sol.py b/tests/501-1000/808. soup-servings/sol.py new file mode 100644 index 00000000..610069d6 --- /dev/null +++ b/tests/501-1000/808. soup-servings/sol.py @@ -0,0 +1,26 @@ +from functools import lru_cache +import math + + +class Solution: + def soupServings(self, n: int) -> float: + if n > 5000: + return 1.0 + units = math.ceil(n / 25) + + @lru_cache(None) + def calc_prob(soupA, soupB): + if soupA <= 0 and soupB <= 0: + return 0.5 + if soupA <= 0: + return 1.0 + if soupB <= 0: + return 0.0 + return 0.25 * ( + calc_prob(soupA - 4, soupB) + + calc_prob(soupA - 3, soupB - 1) + + calc_prob(soupA - 2, soupB - 2) + + calc_prob(soupA - 1, soupB - 3) + ) + + return calc_prob(units, units) diff --git a/tests/501-1000/808. soup-servings/sol.py2 b/tests/501-1000/808. soup-servings/sol.py2 new file mode 100644 index 00000000..a03069c9 --- /dev/null +++ b/tests/501-1000/808. soup-servings/sol.py2 @@ -0,0 +1,31 @@ +class Solution(object): + def soupServings(self, n): + """ + :type n: int + :rtype: float + """ + if n > 5000: + return 1.0 + import math + units = int(math.ceil(n / 25.0)) + memo = {} + + def calc_prob(soupA, soupB): + if (soupA, soupB) in memo: + return memo[(soupA, soupB)] + if soupA <= 0 and soupB <= 0: + return 0.5 + if soupA <= 0: + return 1.0 + if soupB <= 0: + return 0.0 + result = 0.25 * ( + calc_prob(soupA - 4, soupB) + + calc_prob(soupA - 3, soupB - 1) + + calc_prob(soupA - 2, soupB - 2) + + calc_prob(soupA - 1, soupB - 3) + ) + memo[(soupA, soupB)] = result + return result + + return calc_prob(units, units) diff --git a/tests/501-1000/808. soup-servings/sol.rb b/tests/501-1000/808. soup-servings/sol.rb new file mode 100644 index 00000000..6576d97d --- /dev/null +++ b/tests/501-1000/808. soup-servings/sol.rb @@ -0,0 +1,31 @@ +# @param {Integer} n +# @return {Float} +def soup_servings(n) + return 1.0 if n > 5000 + units = (n / 25.0).ceil + @memo = {} + + calc_prob = lambda do |soup_a, soup_b| + key = [soup_a, soup_b] + return @memo[key] if @memo.key?(key) + if soup_a <= 0 && soup_b <= 0 + return 0.5 + end + if soup_a <= 0 + return 1.0 + end + if soup_b <= 0 + return 0.0 + end + result = 0.25 * ( + calc_prob.call(soup_a - 4, soup_b) + + calc_prob.call(soup_a - 3, soup_b - 1) + + calc_prob.call(soup_a - 2, soup_b - 2) + + calc_prob.call(soup_a - 1, soup_b - 3) + ) + @memo[key] = result + result + end + + calc_prob.call(units, units) +end diff --git a/tests/501-1000/808. soup-servings/sol.rs b/tests/501-1000/808. soup-servings/sol.rs new file mode 100644 index 00000000..0b791140 --- /dev/null +++ b/tests/501-1000/808. soup-servings/sol.rs @@ -0,0 +1,36 @@ +use std::collections::HashMap; + +impl Solution { + pub fn soup_servings(n: i32) -> f64 { + if n > 5000 { + return 1.0; + } + let units = ((n as f64) / 25.0).ceil() as i32; + let mut memo: HashMap<(i32, i32), f64> = HashMap::new(); + + fn calc_prob(soup_a: i32, soup_b: i32, memo: &mut HashMap<(i32, i32), f64>) -> f64 { + if let Some(&val) = memo.get(&(soup_a, soup_b)) { + return val; + } + if soup_a <= 0 && soup_b <= 0 { + return 0.5; + } + if soup_a <= 0 { + return 1.0; + } + if soup_b <= 0 { + return 0.0; + } + let result = 0.25 * ( + calc_prob(soup_a - 4, soup_b, memo) + + calc_prob(soup_a - 3, soup_b - 1, memo) + + calc_prob(soup_a - 2, soup_b - 2, memo) + + calc_prob(soup_a - 1, soup_b - 3, memo) + ); + memo.insert((soup_a, soup_b), result); + result + } + + calc_prob(units, units, &mut memo) + } +} diff --git a/tests/501-1000/808. soup-servings/sol.swift b/tests/501-1000/808. soup-servings/sol.swift new file mode 100644 index 00000000..450c31fd --- /dev/null +++ b/tests/501-1000/808. soup-servings/sol.swift @@ -0,0 +1,35 @@ +class Solution { + func soupServings(_ n: Int) -> Double { + if n > 5000 { + return 1.0 + } + let units = Int(ceil(Double(n) / 25.0)) + var memo = [String: Double]() + + func calcProb(_ soupA: Int, _ soupB: Int) -> Double { + let key = "\(soupA),\(soupB)" + if let val = memo[key] { + return val + } + if soupA <= 0 && soupB <= 0 { + return 0.5 + } + if soupA <= 0 { + return 1.0 + } + if soupB <= 0 { + return 0.0 + } + let result = 0.25 * ( + calcProb(soupA - 4, soupB) + + calcProb(soupA - 3, soupB - 1) + + calcProb(soupA - 2, soupB - 2) + + calcProb(soupA - 1, soupB - 3) + ) + memo[key] = result + return result + } + + return calcProb(units, units) + } +} diff --git a/tests/501-1000/808. soup-servings/sol.ts b/tests/501-1000/808. soup-servings/sol.ts new file mode 100644 index 00000000..46fd22e7 --- /dev/null +++ b/tests/501-1000/808. soup-servings/sol.ts @@ -0,0 +1,33 @@ +function soupServings(n: number): number { + if (n > 5000) { + return 1.0; + } + const units = Math.ceil(n / 25); + const memo: Map = new Map(); + + function calcProb(soupA: number, soupB: number): number { + const key = `${soupA},${soupB}`; + if (memo.has(key)) { + return memo.get(key)!; + } + if (soupA <= 0 && soupB <= 0) { + return 0.5; + } + if (soupA <= 0) { + return 1.0; + } + if (soupB <= 0) { + return 0.0; + } + const result = + 0.25 * + (calcProb(soupA - 4, soupB) + + calcProb(soupA - 3, soupB - 1) + + calcProb(soupA - 2, soupB - 2) + + calcProb(soupA - 1, soupB - 3)); + memo.set(key, result); + return result; + } + + return calcProb(units, units); +} diff --git a/tests/501-1000/809. expressive-words/manifest.yaml b/tests/501-1000/809. expressive-words/manifest.yaml new file mode 100644 index 00000000..4a1f5f7c --- /dev/null +++ b/tests/501-1000/809. expressive-words/manifest.yaml @@ -0,0 +1,334 @@ +entry: + id: 809 + title: expressive-words + params: + s: + type: string + words: + type: array + items: + type: string + call: + cpp: Solution().expressiveWords({s}, {words}) + rust: Solution::expressive_words({s}, {words}) + python3: Solution().expressiveWords({s}, {words}) + python2: Solution().expressiveWords({s}, {words}) + ruby: expressive_words({s}, {words}) + java: new Solution().expressiveWords({s}, {words}) + csharp: new Solution().ExpressiveWords({s}, {words}) + kotlin: Solution().expressiveWords({s}, {words}) + go: expressiveWords({s}, {words}) + dart: Solution().expressiveWords({s}, {words}) + swift: Solution().expressiveWords({s}, {words}) + typescript: expressiveWords({s}, {words}) +judge: + type: ignore_order +limits: + time_ms: 2000 + memory_mb: 256 +oracle: + python3: + call: Checker().expressiveWords(s, words, {result}) + checker: + "class Checker:\n def expressiveWords(self, s, words, result):\n \ + \ def encode(x):\n chars, cnts = [], []\n prev =\ + \ None\n cnt = 0\n for ch in x:\n if ch\ + \ == prev:\n cnt += 1\n else:\n \ + \ if prev is not None:\n chars.append(prev)\n\ + \ cnts.append(cnt)\n prev = ch\n \ + \ cnt = 1\n chars.append(prev)\n cnts.append(cnt)\n\ + \ return chars, cnts\n\n s_chars, s_cnts = encode(s)\n \ + \ expected = 0\n for w in words:\n w_chars, w_cnts = encode(w)\n\ + \ if w_chars != s_chars:\n continue\n ok\ + \ = True\n for sc, wc in zip(s_cnts, w_cnts):\n if\ + \ sc < wc or (sc < 3 and sc != wc):\n ok = False\n \ + \ break\n if ok:\n expected += 1\n \ + \ return expected == result\n" +seed: 809 +tests: + - name: example-1 + in: + s: heeellooo + words: + - hello + - hi + - helo + - name: example-2 + in: + s: zzzzzyyyyy + words: + - zzyy + - zy + - zyy + - name: single-word-match + in: + s: a + words: + - a + - name: single-word-no-match + in: + s: a + words: + - b + - name: repeated-groups + in: + s: aaa + words: + - a + - aa + - aaa + - aaaa + - name: three-groups + in: + s: abcccd + words: + - abcd + - abccd + - abcccd + - abcccdx + - name: alternating + in: + s: abcd + words: + - abc + - abcd + - abcdd + - name: long-middle-run + in: + s: heeellllooo + words: + - hello + - helo + - heello + - name: many-short-words + in: + s: qqqrrrsss + words: + - qrs + - qqrrss + - qqqrrrsss + - qqrrrsss + - qrrs + - name: different-first-char + in: + s: mmnnn + words: + - mn + - mmn + - mnn + - name: two-groups-tough + in: + s: aaabbb + words: + - ab + - aabb + - aaabbb + - aaabb + - name: one-long-run + in: + s: zzzz + words: + - z + - zz + - zzz + - zzzz + - zzzzz + - name: no-stretch-possible + in: + s: abc + words: + - ab + - ac + - bc + - abcd + - name: mixed-counts + in: + s: kelllloo + words: + - kelo + - kelloo + - kello + - name: long-run-and-singletons + in: + s: ppqqqqrr + words: + - pqr + - ppqqrr + - ppqqqqrr + - ppqrr + - name: exact-equality + in: + s: abcdef + words: + - abcdef + - abcdeg + - abcde + out: 1 + - name: baseline-stretch + in: + s: heeellooo + words: + - hello + - hi + - helo + out: 1 + - name: all-miss + in: + s: a + words: + - b + - c + - d + out: 0 + - name: all-match-simple + in: + s: aaa + words: + - a + - aa + - aaa + out: 3 + - name: strict-lengths + in: + s: abcd + words: + - abcd + - abc + - abcdd + out: 1 + - name: multi-group-stretch + in: + s: abcccd + words: + - abcd + - abccd + - abcccd + - abcccdx + out: 3 + - name: no-stretch-possible + in: + s: abc + words: + - ab + - ac + - bc + - abcd + out: 0 + - name: long-middle-run + in: + s: heeellllooo + words: + - hello + - helo + - heello + out: 3 + - name: many-candidates + in: + s: qqqrrrsss + words: + - qrs + - qqrrss + - qqqrrrsss + - qqrrrsss + - qrrs + out: 5 + - name: different-prefix + in: + s: mmnnn + words: + - mn + - mmn + - mnn + out: 1 + - name: two-groups + in: + s: aaabbb + words: + - ab + - aabb + - aaabbb + - aaabb + out: 4 + - name: one-run + in: + s: zzzz + words: + - z + - zz + - zzz + - zzzz + - zzzzz + out: 4 + - name: mixed-counts + in: + s: kelllloo + words: + - kelo + - kelloo + - kello + out: 1 + - name: long-run-and-singletons + in: + s: ppqqqqrr + words: + - pqr + - ppqqrr + - ppqqqqrr + - ppqrr + out: 3 + - name: repeated-pattern + in: + s: aaaaabbbbcccc + words: + - abc + - aabbcc + - aaaabbbccc + - aaaaabbbbcccc + - aaaabbcccc + out: 5 + - name: mixed-singletons + in: + s: xxyzzzz + words: + - xyz + - xxyz + - xyzz + - xxyzzzz + - xxz + out: 2 + - name: trailing-singleton + in: + s: hhhhhiiiiij + words: + - hij + - hhij + - hhiij + - hhhhhiiiiij + - hhhhhiij + out: 5 + - name: short-tail + in: + s: mnnnnop + words: + - mnop + - mnop + - mnnop + - mnnnnop + out: 4 + - name: alternating-edge + in: + s: ababab + words: + - ababab + - abab + - ababa + - aabbab + out: 1 + - name: complete-mismatch + in: + s: abcdefg + words: + - hijklmn + - opqrstu + - vwxyzab + out: 0 diff --git a/tests/501-1000/809. expressive-words/sol.cpp b/tests/501-1000/809. expressive-words/sol.cpp new file mode 100644 index 00000000..8bb024dd --- /dev/null +++ b/tests/501-1000/809. expressive-words/sol.cpp @@ -0,0 +1,45 @@ +class Solution { +public: + int expressiveWords(string s, vector& words) { + auto encode = [](const string& x) -> pair, vector> { + vector chars; + vector cnts; + char prev = 0; + int c = 0; + for (char ch : x) { + if (ch == prev) { + c++; + } else { + if (prev != 0) { + chars.push_back(prev); + cnts.push_back(c); + } + prev = ch; + c = 1; + } + } + if (prev != 0) { + chars.push_back(prev); + cnts.push_back(c); + } + return {chars, cnts}; + }; + + auto [s_chars, s_cnts] = encode(s); + int ans = 0; + for (const string& w : words) { + auto [w_chars, w_cnts] = encode(w); + if (s_chars != w_chars) continue; + bool ok = true; + for (size_t i = 0; i < s_cnts.size(); i++) { + int sc = s_cnts[i], wc = w_cnts[i]; + if (sc < wc || (sc < 3 && sc != wc)) { + ok = false; + break; + } + } + if (ok) ans++; + } + return ans; + } +}; diff --git a/tests/501-1000/809. expressive-words/sol.cs b/tests/501-1000/809. expressive-words/sol.cs new file mode 100644 index 00000000..d4aa8c54 --- /dev/null +++ b/tests/501-1000/809. expressive-words/sol.cs @@ -0,0 +1,44 @@ +public class Solution { + public int ExpressiveWords(string s, string[] words) { + (char[], int[]) Encode(string x) { + var chars = new System.Collections.Generic.List(); + var cnts = new System.Collections.Generic.List(); + char prev = '\0'; + int c = 0; + foreach (char ch in x) { + if (ch == prev) { + c++; + } else { + if (prev != '\0') { + chars.Add(prev); + cnts.Add(c); + } + prev = ch; + c = 1; + } + } + if (prev != '\0') { + chars.Add(prev); + cnts.Add(c); + } + return (chars.ToArray(), cnts.ToArray()); + } + + var (sChars, sCnts) = Encode(s); + int ans = 0; + foreach (string w in words) { + var (wChars, wCnts) = Encode(w); + if (!sChars.SequenceEqual(wChars)) continue; + bool ok = true; + for (int i = 0; i < sCnts.Length; i++) { + int sc = sCnts[i], wc = wCnts[i]; + if (sc < wc || (sc < 3 && sc != wc)) { + ok = false; + break; + } + } + if (ok) ans++; + } + return ans; + } +} diff --git a/tests/501-1000/809. expressive-words/sol.dart b/tests/501-1000/809. expressive-words/sol.dart new file mode 100644 index 00000000..725453cd --- /dev/null +++ b/tests/501-1000/809. expressive-words/sol.dart @@ -0,0 +1,49 @@ +class Solution { + int expressiveWords(String s, List words) { + List encode(String x) { + List chars = []; + List cnts = []; + String? prev; + int c = 0; + for (int i = 0; i < x.length; i++) { + String ch = x[i]; + if (ch == prev) { + c++; + } else { + if (prev != null) { + chars.add(prev); + cnts.add(c); + } + prev = ch; + c = 1; + } + } + if (prev != null) { + chars.add(prev); + cnts.add(c); + } + return [chars, cnts]; + } + + var sEncoded = encode(s); + List sChars = sEncoded[0] as List; + List sCnts = sEncoded[1] as List; + int ans = 0; + for (String w in words) { + var wEncoded = encode(w); + List wChars = wEncoded[0] as List; + List wCnts = wEncoded[1] as List; + if (sChars.join() != wChars.join()) continue; + bool ok = true; + for (int i = 0; i < sCnts.length; i++) { + int sc = sCnts[i], wc = wCnts[i]; + if (sc < wc || (sc < 3 && sc != wc)) { + ok = false; + break; + } + } + if (ok) ans++; + } + return ans; + } +} diff --git a/tests/501-1000/809. expressive-words/sol.go b/tests/501-1000/809. expressive-words/sol.go new file mode 100644 index 00000000..9bd512e2 --- /dev/null +++ b/tests/501-1000/809. expressive-words/sol.go @@ -0,0 +1,47 @@ +func expressiveWords(s string, words []string) int { + encode := func(x string) ([]byte, []int) { + chars := []byte{} + cnts := []int{} + var prev byte + c := 0 + for i := 0; i < len(x); i++ { + ch := x[i] + if ch == prev { + c++ + } else { + if prev != 0 { + chars = append(chars, prev) + cnts = append(cnts, c) + } + prev = ch + c = 1 + } + } + if prev != 0 { + chars = append(chars, prev) + cnts = append(cnts, c) + } + return chars, cnts + } + + sChars, sCnts := encode(s) + ans := 0 + for _, w := range words { + wChars, wCnts := encode(w) + if string(sChars) != string(wChars) { + continue + } + ok := true + for i := 0; i < len(sCnts); i++ { + sc, wc := sCnts[i], wCnts[i] + if sc < wc || (sc < 3 && sc != wc) { + ok = false + break + } + } + if ok { + ans++ + } + } + return ans +} diff --git a/tests/501-1000/809. expressive-words/sol.java b/tests/501-1000/809. expressive-words/sol.java new file mode 100644 index 00000000..8aefb3dc --- /dev/null +++ b/tests/501-1000/809. expressive-words/sol.java @@ -0,0 +1,48 @@ +class Solution { + public int expressiveWords(String s, String[] words) { + Object[] sEncoded = encode(s); + char[] sChars = (char[]) sEncoded[0]; + int[] sCnts = (int[]) sEncoded[1]; + int ans = 0; + for (String w : words) { + Object[] wEncoded = encode(w); + char[] wChars = (char[]) wEncoded[0]; + int[] wCnts = (int[]) wEncoded[1]; + if (!java.util.Arrays.equals(sChars, wChars)) continue; + boolean ok = true; + for (int i = 0; i < sCnts.length; i++) { + int sc = sCnts[i], wc = wCnts[i]; + if (sc < wc || (sc < 3 && sc != wc)) { + ok = false; + break; + } + } + if (ok) ans++; + } + return ans; + } + + private Object[] encode(String x) { + StringBuilder chars = new StringBuilder(); + java.util.ArrayList cnts = new java.util.ArrayList<>(); + char prev = 0; + int c = 0; + for (char ch : x.toCharArray()) { + if (ch == prev) { + c++; + } else { + if (prev != 0) { + chars.append(prev); + cnts.add(c); + } + prev = ch; + c = 1; + } + } + if (prev != 0) { + chars.append(prev); + cnts.add(c); + } + return new Object[]{chars.toString().toCharArray(), cnts.stream().mapToInt(i -> i).toArray()}; + } +} diff --git a/tests/501-1000/809. expressive-words/sol.kt b/tests/501-1000/809. expressive-words/sol.kt new file mode 100644 index 00000000..d9259ea3 --- /dev/null +++ b/tests/501-1000/809. expressive-words/sol.kt @@ -0,0 +1,45 @@ +class Solution { + fun expressiveWords(s: String, words: Array): Int { + fun encode(x: String): Pair { + val chars = StringBuilder() + val cnts = mutableListOf() + var prev: Char? = null + var c = 0 + for (ch in x) { + if (ch == prev) { + c++ + } else { + if (prev != null) { + chars.append(prev) + cnts.add(c) + } + prev = ch + c = 1 + } + } + if (prev != null) { + chars.append(prev) + cnts.add(c) + } + return Pair(chars.toString().toCharArray(), cnts.toIntArray()) + } + + val (sChars, sCnts) = encode(s) + var ans = 0 + for (w in words) { + val (wChars, wCnts) = encode(w) + if (!sChars.contentEquals(wChars)) continue + var ok = true + for (i in sCnts.indices) { + val sc = sCnts[i] + val wc = wCnts[i] + if (sc < wc || (sc < 3 && sc != wc)) { + ok = false + break + } + } + if (ok) ans++ + } + return ans + } +} diff --git a/tests/501-1000/809. expressive-words/sol.py b/tests/501-1000/809. expressive-words/sol.py new file mode 100644 index 00000000..2cdd473f --- /dev/null +++ b/tests/501-1000/809. expressive-words/sol.py @@ -0,0 +1,31 @@ +class Solution(object): + def expressiveWords(self, s, words): + def encode(x): + chars, cnts = [], [] + prev, c = None, 0 + for ch in x: + if ch == prev: + c += 1 + else: + if prev is not None: + chars.append(prev) + cnts.append(c) + prev, c = ch, 1 + chars.append(prev) + cnts.append(c) + return chars, cnts + + s_chars, s_cnts = encode(s) + ans = 0 + for w in words: + w_chars, w_cnts = encode(w) + if w_chars != s_chars: + continue + ok = True + for sc, wc in zip(s_cnts, w_cnts): + if sc < wc or (sc < 3 and sc != wc): + ok = False + break + if ok: + ans += 1 + return ans diff --git a/tests/501-1000/809. expressive-words/sol.py2 b/tests/501-1000/809. expressive-words/sol.py2 new file mode 100644 index 00000000..2cdd473f --- /dev/null +++ b/tests/501-1000/809. expressive-words/sol.py2 @@ -0,0 +1,31 @@ +class Solution(object): + def expressiveWords(self, s, words): + def encode(x): + chars, cnts = [], [] + prev, c = None, 0 + for ch in x: + if ch == prev: + c += 1 + else: + if prev is not None: + chars.append(prev) + cnts.append(c) + prev, c = ch, 1 + chars.append(prev) + cnts.append(c) + return chars, cnts + + s_chars, s_cnts = encode(s) + ans = 0 + for w in words: + w_chars, w_cnts = encode(w) + if w_chars != s_chars: + continue + ok = True + for sc, wc in zip(s_cnts, w_cnts): + if sc < wc or (sc < 3 and sc != wc): + ok = False + break + if ok: + ans += 1 + return ans diff --git a/tests/501-1000/809. expressive-words/sol.rb b/tests/501-1000/809. expressive-words/sol.rb new file mode 100644 index 00000000..1e5bcfaa --- /dev/null +++ b/tests/501-1000/809. expressive-words/sol.rb @@ -0,0 +1,42 @@ +# @param {String} s +# @param {String[]} words +# @return {Integer} +def expressive_words(s, words) + encode = ->(x) { + chars = [] + cnts = [] + prev = nil + c = 0 + x.each_char do |ch| + if ch == prev + c += 1 + else + if prev != nil + chars << prev + cnts << c + end + prev = ch + c = 1 + end + end + chars << prev + cnts << c + [chars, cnts] + } + + s_chars, s_cnts = encode.call(s) + ans = 0 + words.each do |w| + w_chars, w_cnts = encode.call(w) + next if w_chars != s_chars + ok = true + s_cnts.zip(w_cnts).each do |sc, wc| + if sc < wc || (sc < 3 && sc != wc) + ok = false + break + end + end + ans += 1 if ok + end + ans +end diff --git a/tests/501-1000/809. expressive-words/sol.rs b/tests/501-1000/809. expressive-words/sol.rs new file mode 100644 index 00000000..d08db169 --- /dev/null +++ b/tests/501-1000/809. expressive-words/sol.rs @@ -0,0 +1,49 @@ +impl Solution { + pub fn expressive_words(s: String, words: Vec) -> i32 { + fn encode(x: &str) -> (Vec, Vec) { + let mut chars = Vec::new(); + let mut cnts = Vec::new(); + let mut prev: Option = None; + let mut c = 0; + for ch in x.chars() { + if Some(ch) == prev { + c += 1; + } else { + if let Some(p) = prev { + chars.push(p); + cnts.push(c); + } + prev = Some(ch); + c = 1; + } + } + if let Some(p) = prev { + chars.push(p); + cnts.push(c); + } + (chars, cnts) + } + + let (s_chars, s_cnts) = encode(&s); + let mut ans = 0; + for w in &words { + let (w_chars, w_cnts) = encode(w); + if s_chars != w_chars { + continue; + } + let mut ok = true; + for i in 0..s_cnts.len() { + let sc = s_cnts[i]; + let wc = w_cnts[i]; + if sc < wc || (sc < 3 && sc != wc) { + ok = false; + break; + } + } + if ok { + ans += 1; + } + } + ans + } +} diff --git a/tests/501-1000/809. expressive-words/sol.swift b/tests/501-1000/809. expressive-words/sol.swift new file mode 100644 index 00000000..998a137b --- /dev/null +++ b/tests/501-1000/809. expressive-words/sol.swift @@ -0,0 +1,44 @@ +class Solution { + func expressiveWords(_ s: String, _ words: [String]) -> Int { + func encode(_ x: String) -> ([Character], [Int]) { + var chars = [Character]() + var cnts = [Int]() + var prev: Character? = nil + var c = 0 + for ch in x { + if ch == prev { + c += 1 + } else { + if let p = prev { + chars.append(p) + cnts.append(c) + } + prev = ch + c = 1 + } + } + if let p = prev { + chars.append(p) + cnts.append(c) + } + return (chars, cnts) + } + + let (sChars, sCnts) = encode(s) + var ans = 0 + for w in words { + let (wChars, wCnts) = encode(w) + if sChars != wChars { continue } + var ok = true + for i in 0.. { + const chars: string[] = []; + const cnts: number[] = []; + let prev: string | null = null; + let c = 0; + for (const ch of x) { + if (ch === prev) { + c++; + } else { + if (prev !== null) { + chars.push(prev); + cnts.push(c); + } + prev = ch; + c = 1; + } + } + if (prev !== null) { + chars.push(prev); + cnts.push(c); + } + return [chars, cnts]; + }; + + const [sChars, sCnts] = encode(s); + let ans = 0; + for (const w of words) { + const [wChars, wCnts] = encode(w); + if (sChars.join("") !== wChars.join("")) continue; + let ok = true; + for (let i = 0; i < sCnts.length; i++) { + const sc = sCnts[i], + wc = wCnts[i]; + if (sc < wc || (sc < 3 && sc !== wc)) { + ok = false; + break; + } + } + if (ok) ans++; + } + return ans; +} diff --git a/tests/501-1000/810. chalkboard-xor-game/manifest.yaml b/tests/501-1000/810. chalkboard-xor-game/manifest.yaml new file mode 100644 index 00000000..68de9e93 --- /dev/null +++ b/tests/501-1000/810. chalkboard-xor-game/manifest.yaml @@ -0,0 +1,314 @@ +entry: + id: 810 + title: chalkboard-xor-game + params: + nums: + type: array + items: + type: int + call: + cpp: Solution().xorGame({nums}) + rust: Solution::xor_game({nums}) + python3: Solution().xorGame({nums}) + python2: Solution().xorGame({nums}) + ruby: xor_game({nums}) + java: new Solution().xorGame({nums}) + csharp: new Solution().XorGame({nums}) + kotlin: Solution().xorGame({nums}) + go: xorGame({nums}) + dart: Solution().xorGame({nums}) + swift: Solution().xorGame({nums}) + typescript: xorGame({nums}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().xorGame(nums, {result}) + checker: + "class Checker:\n def xorGame(self, nums, result):\n total\ + \ = 0\n for value in nums:\n total ^= value\n expected\ + \ = (total == 0) or (len(nums) % 2 == 0)\n return result == expected\n" +seed: 810 +tests: + - name: example-1 + in: + nums: + - 1 + - 1 + - 2 + - name: example-2 + in: + nums: + - 0 + - 1 + - name: example-3 + in: + nums: + - 1 + - 2 + - 3 + - name: single-zero + in: + nums: + - 0 + - name: single-nonzero + in: + nums: + - 7 + - name: pair-equal + in: + nums: + - 5 + - 5 + - name: pair-different + in: + nums: + - 1 + - 3 + - name: odd-zero-xor + in: + nums: + - 2 + - 4 + - 6 + - name: odd-nonzero-xor + in: + nums: + - 1 + - 1 + - 1 + - name: many-equal-even + in: + nums: + - 9 + - 9 + - 9 + - 9 + - 9 + - 9 + - name: many-equal-odd + in: + nums: + - 9 + - 9 + - 9 + - 9 + - 9 + - name: zero-heavy-odd + in: + nums: + - 0 + - 0 + - 0 + - 0 + - 0 + - name: zero-heavy-even + in: + nums: + - 0 + - 0 + - 0 + - 0 + - name: pair-cancel-even + in: + nums: + - 12 + - 34 + - 12 + - 34 + - 56 + - 56 + - name: pair-cancel-odd + in: + nums: + - 12 + - 34 + - 12 + - 34 + - 56 + - name: generated-odd + in: + nums: + gen: array + len: 9 + of: + gen: int + min: 0 + max: 1024 + elemType: int + - name: generated-even + in: + nums: + gen: array + len: 10 + of: + gen: int + min: 0 + max: 1024 + elemType: int + - name: pair-zero-xor-even + in: + nums: + - 1 + - 1 + - 2 + - 2 + out: true + - name: single-positive + in: + nums: + - 3 + out: false + - name: triple-equal + in: + nums: + - 4 + - 4 + - 4 + out: false + - name: mixed-even-xor-nonzero + in: + nums: + - 7 + - 8 + - 7 + - 8 + - 1 + out: false + - name: alternating-zero-xor-even + in: + nums: + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + out: true + - name: xor-zero-odd + in: + nums: + - 15 + - 1 + - 2 + - 4 + out: true + - name: all-same-odd + in: + nums: + - 6 + - 6 + - 6 + - 6 + - 6 + - 6 + - 6 + out: false + - name: two-elements-nonzero + in: + nums: + - 9 + - 10 + out: true + - name: repeated-pairs-odd + in: + nums: + - 2 + - 2 + - 2 + - 2 + - 2 + out: false + - name: powers-of-two-even + in: + nums: + - 1 + - 2 + - 4 + - 8 + - 16 + - 32 + out: true + - name: zero-and-one + in: + nums: + - 0 + - 0 + - 1 + out: false + - name: large-xor-odd + in: + nums: + - 1024 + - 512 + - 256 + out: false + - name: even-length-nonzero-xor + in: + nums: + - 5 + - 10 + - 5 + - 10 + - 5 + - 10 + out: true + - name: odd-length-nonzero-xor-2 + in: + nums: + - 11 + - 12 + - 13 + - 14 + - 15 + out: false + - name: all-equal-even + in: + nums: + - 42 + - 42 + - 42 + - 42 + out: true + - name: zero-xor-odd-length + in: + nums: + - 3 + - 5 + - 6 + - 9 + - 10 + - 12 + - 15 + out: true + - name: larger-even-sample + in: + nums: + - 100 + - 200 + - 300 + - 400 + - 500 + - 600 + out: true + - name: repeated-pattern-odd + in: + nums: + - 1 + - 3 + - 1 + - 3 + - 1 + - 3 + - 1 + out: false + - name: triple-eight + in: + nums: + - 8 + - 8 + - 8 + out: false diff --git a/tests/501-1000/810. chalkboard-xor-game/sol.cpp b/tests/501-1000/810. chalkboard-xor-game/sol.cpp new file mode 100644 index 00000000..e63b3d03 --- /dev/null +++ b/tests/501-1000/810. chalkboard-xor-game/sol.cpp @@ -0,0 +1,14 @@ +class Solution { +public: + bool xorGame(vector& nums) { + int totalXor = 0; + for (int value : nums) { + totalXor ^= value; + } + + bool isXorZero = (totalXor == 0); + bool hasEvenLength = (nums.size() % 2 == 0); + + return isXorZero || hasEvenLength; + } +}; diff --git a/tests/501-1000/810. chalkboard-xor-game/sol.cs b/tests/501-1000/810. chalkboard-xor-game/sol.cs new file mode 100644 index 00000000..b29d9649 --- /dev/null +++ b/tests/501-1000/810. chalkboard-xor-game/sol.cs @@ -0,0 +1,13 @@ +public class Solution { + public bool XorGame(int[] nums) { + int totalXor = 0; + foreach (int value in nums) { + totalXor ^= value; + } + + bool isXorZero = (totalXor == 0); + bool hasEvenLength = (nums.Length % 2 == 0); + + return isXorZero || hasEvenLength; + } +} diff --git a/tests/501-1000/810. chalkboard-xor-game/sol.dart b/tests/501-1000/810. chalkboard-xor-game/sol.dart new file mode 100644 index 00000000..59e0a9a4 --- /dev/null +++ b/tests/501-1000/810. chalkboard-xor-game/sol.dart @@ -0,0 +1,13 @@ +class Solution { + bool xorGame(List nums) { + int totalXor = 0; + for (int value in nums) { + totalXor ^= value; + } + + bool isXorZero = (totalXor == 0); + bool hasEvenLength = (nums.length % 2 == 0); + + return isXorZero || hasEvenLength; + } +} diff --git a/tests/501-1000/810. chalkboard-xor-game/sol.go b/tests/501-1000/810. chalkboard-xor-game/sol.go new file mode 100644 index 00000000..e84f69e2 --- /dev/null +++ b/tests/501-1000/810. chalkboard-xor-game/sol.go @@ -0,0 +1,11 @@ +func xorGame(nums []int) bool { + totalXor := 0 + for _, value := range nums { + totalXor ^= value + } + + isXorZero := (totalXor == 0) + hasEvenLength := (len(nums) % 2 == 0) + + return isXorZero || hasEvenLength +} diff --git a/tests/501-1000/810. chalkboard-xor-game/sol.java b/tests/501-1000/810. chalkboard-xor-game/sol.java new file mode 100644 index 00000000..1f6acddc --- /dev/null +++ b/tests/501-1000/810. chalkboard-xor-game/sol.java @@ -0,0 +1,13 @@ +class Solution { + public boolean xorGame(int[] nums) { + int totalXor = 0; + for (int value : nums) { + totalXor ^= value; + } + + boolean isXorZero = (totalXor == 0); + boolean hasEvenLength = (nums.length % 2 == 0); + + return isXorZero || hasEvenLength; + } +} diff --git a/tests/501-1000/810. chalkboard-xor-game/sol.kt b/tests/501-1000/810. chalkboard-xor-game/sol.kt new file mode 100644 index 00000000..a4e6f586 --- /dev/null +++ b/tests/501-1000/810. chalkboard-xor-game/sol.kt @@ -0,0 +1,13 @@ +class Solution { + fun xorGame(nums: IntArray): Boolean { + var totalXor = 0 + for (value in nums) { + totalXor = totalXor xor value + } + + val isXorZero = (totalXor == 0) + val hasEvenLength = (nums.size % 2 == 0) + + return isXorZero || hasEvenLength + } +} diff --git a/tests/501-1000/810. chalkboard-xor-game/sol.py b/tests/501-1000/810. chalkboard-xor-game/sol.py new file mode 100644 index 00000000..3309fb4a --- /dev/null +++ b/tests/501-1000/810. chalkboard-xor-game/sol.py @@ -0,0 +1,10 @@ +class Solution: + def xorGame(self, nums: List[int]) -> bool: + totalXor = 0 + for value in nums: + totalXor ^= value + + isXorZero = totalXor == 0 + hasEvenLength = len(nums) % 2 == 0 + + return isXorZero or hasEvenLength diff --git a/tests/501-1000/810. chalkboard-xor-game/sol.py2 b/tests/501-1000/810. chalkboard-xor-game/sol.py2 new file mode 100644 index 00000000..0612da26 --- /dev/null +++ b/tests/501-1000/810. chalkboard-xor-game/sol.py2 @@ -0,0 +1,14 @@ +class Solution(object): + def xorGame(self, nums): + """ + :type nums: List[int] + :rtype: bool + """ + totalXor = 0 + for value in nums: + totalXor ^= value + + isXorZero = (totalXor == 0) + hasEvenLength = (len(nums) % 2 == 0) + + return isXorZero or hasEvenLength diff --git a/tests/501-1000/810. chalkboard-xor-game/sol.rb b/tests/501-1000/810. chalkboard-xor-game/sol.rb new file mode 100644 index 00000000..aa444dc1 --- /dev/null +++ b/tests/501-1000/810. chalkboard-xor-game/sol.rb @@ -0,0 +1,13 @@ +# @param {Integer[]} nums +# @return {Boolean} +def xor_game(nums) + total_xor = 0 + nums.each do |value| + total_xor ^= value + end + + is_xor_zero = (total_xor == 0) + has_even_length = (nums.length % 2 == 0) + + is_xor_zero || has_even_length +end diff --git a/tests/501-1000/810. chalkboard-xor-game/sol.rs b/tests/501-1000/810. chalkboard-xor-game/sol.rs new file mode 100644 index 00000000..429b28c5 --- /dev/null +++ b/tests/501-1000/810. chalkboard-xor-game/sol.rs @@ -0,0 +1,13 @@ +impl Solution { + pub fn xor_game(nums: Vec) -> bool { + let mut total_xor = 0; + for value in &nums { + total_xor ^= value; + } + + let is_xor_zero = total_xor == 0; + let has_even_length = nums.len() % 2 == 0; + + is_xor_zero || has_even_length + } +} diff --git a/tests/501-1000/810. chalkboard-xor-game/sol.swift b/tests/501-1000/810. chalkboard-xor-game/sol.swift new file mode 100644 index 00000000..62c9324f --- /dev/null +++ b/tests/501-1000/810. chalkboard-xor-game/sol.swift @@ -0,0 +1,13 @@ +class Solution { + func xorGame(_ nums: [Int]) -> Bool { + var totalXor = 0 + for value in nums { + totalXor ^= value + } + + let isXorZero = (totalXor == 0) + let hasEvenLength = (nums.count % 2 == 0) + + return isXorZero || hasEvenLength + } +} diff --git a/tests/501-1000/810. chalkboard-xor-game/sol.ts b/tests/501-1000/810. chalkboard-xor-game/sol.ts new file mode 100644 index 00000000..f3ada865 --- /dev/null +++ b/tests/501-1000/810. chalkboard-xor-game/sol.ts @@ -0,0 +1,11 @@ +function xorGame(nums: number[]): boolean { + let totalXor = 0; + for (const value of nums) { + totalXor ^= value; + } + + const isXorZero = totalXor === 0; + const hasEvenLength = nums.length % 2 === 0; + + return isXorZero || hasEvenLength; +} diff --git a/tests/501-1000/811. subdomain-visit-count/manifest.yaml b/tests/501-1000/811. subdomain-visit-count/manifest.yaml new file mode 100644 index 00000000..799b7c5d --- /dev/null +++ b/tests/501-1000/811. subdomain-visit-count/manifest.yaml @@ -0,0 +1,240 @@ +entry: + id: 811 + title: subdomain-visit-count + params: + cpdomains: + type: array + items: + type: string + call: + cpp: Solution().subdomainVisits({cpdomains}) + rust: Solution::subdomain_visits({cpdomains}) + python3: Solution().subdomainVisits({cpdomains}) + python2: Solution().subdomainVisits({cpdomains}) + ruby: subdomain_visits({cpdomains}) + java: new Solution().subdomainVisits({cpdomains}) + csharp: new Solution().SubdomainVisits({cpdomains}) + kotlin: Solution().subdomainVisits({cpdomains}) + go: subdomainVisits({cpdomains}) + dart: Solution().subdomainVisits({cpdomains}) + swift: Solution().subdomainVisits({cpdomains}) + typescript: subdomainVisits({cpdomains}) +judge: + type: ignore_order +limits: + time_ms: 2000 + memory_mb: 256 +oracle: + python3: + call: Checker().subdomainVisits(cpdomains, {result}) + checker: + "class Checker:\n def subdomainVisits(self, cpdomains, result):\n\ + \ freq = {}\n for entry in cpdomains:\n cnt, dom =\ + \ entry.split()\n cnt = int(cnt)\n parts = dom.split('.')\n\ + \ for i in range(len(parts)):\n sub = '.'.join(parts[i:])\n\ + \ freq[sub] = freq.get(sub, 0) + cnt\n expected = [f\"\ + {c} {d}\" for d, c in freq.items()]\n return sorted(expected) == sorted(result)\n" +seed: 811 +tests: + - name: example-1 + in: + cpdomains: + - 9001 discuss.leetcode.com + - name: example-2 + in: + cpdomains: + - 900 google.mail.com + - 50 yahoo.com + - 1 intel.mail.com + - 5 wiki.org + - name: single-two-level + in: + cpdomains: + - 1 a.b + - name: single-three-level + in: + cpdomains: + - 1 a.b.c + - name: duplicate-domain + in: + cpdomains: + - 5 a.b.c + - 7 a.b.c + - name: overlapping-subdomains + in: + cpdomains: + - 10 a.b.c + - 20 b.c + - 30 c + - name: mixed-two-and-three-level + in: + cpdomains: + - 3 x.y + - 4 z.y + - 5 y + - name: repeated-top-level + in: + cpdomains: + - 100 alpha.com + - 200 beta.com + - name: one-entry-large-count + in: + cpdomains: + - 10000 long.sub.domain + - name: many-entries-simple + in: + cpdomains: + - 1 a.b + - 1 c.b + - 1 d.b + - 1 e.b + - name: many-entries-overlap + in: + cpdomains: + - 2 a.b.c + - 3 b.c + - 4 c + - 5 a.b + - name: chain-of-subdomains + in: + cpdomains: + - 8 a.b.c.d + - name: repeated-dots-not-allowed-but-valid-input + in: + cpdomains: + - 9 m.n.o + - 9 n.o + - 9 o + - name: mixed-several + in: + cpdomains: + - 6 mail.com + - 7 discuss.leetcode.com + - 8 leetcode.com + - 9 com + - name: same-subdomain-from-many + in: + cpdomains: + - 2 a.b.c + - 2 x.b.c + - 2 y.b.c + - name: maximum-counts + in: + cpdomains: + - 10000 a.b.c + - 10000 b.c + - 10000 c + - name: single-com + in: + cpdomains: + - 1 com + - name: single-two-level + in: + cpdomains: + - 1 a.b + - name: single-three-level + in: + cpdomains: + - 1 a.b.c + - name: duplicate-domain + in: + cpdomains: + - 5 a.b.c + - 7 a.b.c + - name: overlapping-subdomains + in: + cpdomains: + - 10 a.b.c + - 20 b.c + - 30 c + - name: mixed-two-and-three-level + in: + cpdomains: + - 3 x.y + - 4 z.y + - 5 y + - name: repeated-top-level + in: + cpdomains: + - 100 alpha.com + - 200 beta.com + - name: one-entry-large-count + in: + cpdomains: + - 10000 long.sub.domain + - name: many-entries-simple + in: + cpdomains: + - 1 a.b + - 1 c.b + - 1 d.b + - 1 e.b + - name: many-entries-overlap + in: + cpdomains: + - 2 a.b.c + - 3 b.c + - 4 c + - 5 a.b + - name: chain-of-subdomains + in: + cpdomains: + - 8 a.b.c.d + - name: deeper-chain + in: + cpdomains: + - 9 m.n.o.p + - name: mixed-several + in: + cpdomains: + - 6 mail.com + - 7 discuss.leetcode.com + - 8 leetcode.com + - 9 com + - name: same-subdomain-from-many + in: + cpdomains: + - 2 a.b.c + - 2 x.b.c + - 2 y.b.c + - name: maximum-counts + in: + cpdomains: + - 10000 a.b.c + - 10000 b.c + - 10000 c + - name: shared-tld + in: + cpdomains: + - 11 aa.bb.cc + - 22 dd.bb.cc + - 33 bb.cc + - name: single-long-name + in: + cpdomains: + - 17 very.long.example.org + - name: three-independent + in: + cpdomains: + - 1 alpha.beta + - 2 gamma.delta + - 3 epsilon.zeta + - name: repeated-root-only + in: + cpdomains: + - 4 org + - 5 org + - 6 org + - name: mixed-with-root + in: + cpdomains: + - 1 sub.root + - 2 root + - 3 a.root + - name: four-way-shared + in: + cpdomains: + - 1 a.x.y + - 2 b.x.y + - 3 c.x.y + - 4 x.y diff --git a/tests/501-1000/811. subdomain-visit-count/sol.cpp b/tests/501-1000/811. subdomain-visit-count/sol.cpp new file mode 100644 index 00000000..3bc3418b --- /dev/null +++ b/tests/501-1000/811. subdomain-visit-count/sol.cpp @@ -0,0 +1,31 @@ +class Solution { +public: + vector subdomainVisits(vector& cpdomains) { + unordered_map freq; + for (auto& entry : cpdomains) { + istringstream iss(entry); + int cnt; + string dom; + iss >> cnt >> dom; + vector parts; + string part; + istringstream domStream(dom); + while (getline(domStream, part, '.')) { + parts.push_back(part); + } + for (int i = 0; i < parts.size(); i++) { + string sub; + for (int j = i; j < parts.size(); j++) { + if (j > i) sub += "."; + sub += parts[j]; + } + freq[sub] += cnt; + } + } + vector result; + for (auto& [d, c] : freq) { + result.push_back(to_string(c) + " " + d); + } + return result; + } +}; diff --git a/tests/501-1000/811. subdomain-visit-count/sol.cs b/tests/501-1000/811. subdomain-visit-count/sol.cs new file mode 100644 index 00000000..b4e4d7d1 --- /dev/null +++ b/tests/501-1000/811. subdomain-visit-count/sol.cs @@ -0,0 +1,24 @@ +public class Solution { + public IList SubdomainVisits(string[] cpdomains) { + var freq = new Dictionary(); + foreach (var entry in cpdomains) { + var parts = entry.Split(' '); + int cnt = int.Parse(parts[0]); + string dom = parts[1]; + var subParts = dom.Split('.'); + for (int i = 0; i < subParts.Length; i++) { + string sub = string.Join(".", subParts, i, subParts.Length - i); + if (freq.ContainsKey(sub)) { + freq[sub] += cnt; + } else { + freq[sub] = cnt; + } + } + } + var result = new List(); + foreach (var kvp in freq) { + result.Add(kvp.Value + " " + kvp.Key); + } + return result; + } +} diff --git a/tests/501-1000/811. subdomain-visit-count/sol.dart b/tests/501-1000/811. subdomain-visit-count/sol.dart new file mode 100644 index 00000000..1f2424dc --- /dev/null +++ b/tests/501-1000/811. subdomain-visit-count/sol.dart @@ -0,0 +1,16 @@ +class Solution { + List subdomainVisits(List cpdomains) { + Map freq = {}; + for (var entry in cpdomains) { + var parts = entry.split(' '); + int cnt = int.parse(parts[0]); + var dom = parts[1]; + var subParts = dom.split('.'); + for (int i = 0; i < subParts.length; i++) { + var sub = subParts.sublist(i).join('.'); + freq[sub] = (freq[sub] ?? 0) + cnt; + } + } + return freq.entries.map((e) => '${e.value} ${e.key}').toList(); + } +} diff --git a/tests/501-1000/811. subdomain-visit-count/sol.go b/tests/501-1000/811. subdomain-visit-count/sol.go new file mode 100644 index 00000000..3131e4cc --- /dev/null +++ b/tests/501-1000/811. subdomain-visit-count/sol.go @@ -0,0 +1,18 @@ +func subdomainVisits(cpdomains []string) []string { + freq := make(map[string]int) + for _, entry := range cpdomains { + parts := strings.Split(entry, " ") + cnt, _ := strconv.Atoi(parts[0]) + dom := parts[1] + subParts := strings.Split(dom, ".") + for i := range subParts { + sub := strings.Join(subParts[i:], ".") + freq[sub] += cnt + } + } + result := make([]string, 0, len(freq)) + for d, c := range freq { + result = append(result, strconv.Itoa(c) + " " + d) + } + return result +} diff --git a/tests/501-1000/811. subdomain-visit-count/sol.java b/tests/501-1000/811. subdomain-visit-count/sol.java new file mode 100644 index 00000000..7bd5bdb4 --- /dev/null +++ b/tests/501-1000/811. subdomain-visit-count/sol.java @@ -0,0 +1,20 @@ +class Solution { + public List subdomainVisits(String[] cpdomains) { + Map freq = new HashMap<>(); + for (String entry : cpdomains) { + String[] split = entry.split(" "); + int cnt = Integer.parseInt(split[0]); + String dom = split[1]; + String[] parts = dom.split("\\."); + for (int i = 0; i < parts.length; i++) { + String sub = String.join(".", Arrays.copyOfRange(parts, i, parts.length)); + freq.put(sub, freq.getOrDefault(sub, 0) + cnt); + } + } + List result = new ArrayList<>(); + for (Map.Entry entry : freq.entrySet()) { + result.add(entry.getValue() + " " + entry.getKey()); + } + return result; + } +} diff --git a/tests/501-1000/811. subdomain-visit-count/sol.kt b/tests/501-1000/811. subdomain-visit-count/sol.kt new file mode 100644 index 00000000..dc4e685f --- /dev/null +++ b/tests/501-1000/811. subdomain-visit-count/sol.kt @@ -0,0 +1,15 @@ +class Solution { + fun subdomainVisits(cpdomains: Array): List { + val freq = mutableMapOf() + for (entry in cpdomains) { + val (cntStr, dom) = entry.split(" ") + val cnt = cntStr.toInt() + val parts = dom.split(".") + for (i in parts.indices) { + val sub = parts.slice(i until parts.size).joinToString(".") + freq[sub] = freq.getOrDefault(sub, 0) + cnt + } + } + return freq.map { "${it.value} ${it.key}" } + } +} diff --git a/tests/501-1000/811. subdomain-visit-count/sol.py b/tests/501-1000/811. subdomain-visit-count/sol.py new file mode 100644 index 00000000..83ae9960 --- /dev/null +++ b/tests/501-1000/811. subdomain-visit-count/sol.py @@ -0,0 +1,11 @@ +class Solution(object): + def subdomainVisits(self, cpdomains): + freq = {} + for entry in cpdomains: + cnt, dom = entry.split() + cnt = int(cnt) + parts = dom.split(".") + for i in range(len(parts)): + sub = ".".join(parts[i:]) + freq[sub] = freq.get(sub, 0) + cnt + return [f"{c} {d}" for d, c in freq.items()] diff --git a/tests/501-1000/811. subdomain-visit-count/sol.py2 b/tests/501-1000/811. subdomain-visit-count/sol.py2 new file mode 100644 index 00000000..34887375 --- /dev/null +++ b/tests/501-1000/811. subdomain-visit-count/sol.py2 @@ -0,0 +1,15 @@ +class Solution(object): + def subdomainVisits(self, cpdomains): + """ + :type cpdomains: List[str] + :rtype: List[str] + """ + freq = {} + for entry in cpdomains: + cnt, dom = entry.split() + cnt = int(cnt) + parts = dom.split('.') + for i in range(len(parts)): + sub = '.'.join(parts[i:]) + freq[sub] = freq.get(sub, 0) + cnt + return ["{} {}".format(c, d) for d, c in freq.items()] diff --git a/tests/501-1000/811. subdomain-visit-count/sol.rb b/tests/501-1000/811. subdomain-visit-count/sol.rb new file mode 100644 index 00000000..92e60bb5 --- /dev/null +++ b/tests/501-1000/811. subdomain-visit-count/sol.rb @@ -0,0 +1,15 @@ +# @param {String[]} cpdomains +# @return {String[]} +def subdomain_visits(cpdomains) + freq = Hash.new(0) + cpdomains.each do |entry| + cnt, dom = entry.split(' ') + cnt = cnt.to_i + parts = dom.split('.') + (0...parts.length).each do |i| + sub = parts[i..-1].join('.') + freq[sub] += cnt + end + end + freq.map { |d, c| "#{c} #{d}" } +end diff --git a/tests/501-1000/811. subdomain-visit-count/sol.rs b/tests/501-1000/811. subdomain-visit-count/sol.rs new file mode 100644 index 00000000..2b2fb24b --- /dev/null +++ b/tests/501-1000/811. subdomain-visit-count/sol.rs @@ -0,0 +1,18 @@ +impl Solution { + pub fn subdomain_visits(cpdomains: Vec) -> Vec { + let mut freq = std::collections::HashMap::new(); + for entry in &cpdomains { + let mut parts = entry.split_whitespace(); + let cnt: i32 = parts.next().unwrap().parse().unwrap(); + let dom = parts.next().unwrap(); + let sub_parts: Vec<&str> = dom.split('.').collect(); + for i in 0..sub_parts.len() { + let sub = sub_parts[i..].join("."); + *freq.entry(sub).or_insert(0) += cnt; + } + } + freq.into_iter() + .map(|(d, c)| format!("{} {}", c, d)) + .collect() + } +} diff --git a/tests/501-1000/811. subdomain-visit-count/sol.swift b/tests/501-1000/811. subdomain-visit-count/sol.swift new file mode 100644 index 00000000..4fa60966 --- /dev/null +++ b/tests/501-1000/811. subdomain-visit-count/sol.swift @@ -0,0 +1,16 @@ +class Solution { + func subdomainVisits(_ cpdomains: [String]) -> [String] { + var freq = [String: Int]() + for entry in cpdomains { + let comps = entry.split(separator: " ") + let cnt = Int(comps[0])! + let dom = String(comps[1]) + let parts = dom.split(separator: ".") + for i in parts.indices { + let sub = parts[i...].joined(separator: ".") + freq[sub, default: 0] += cnt + } + } + return freq.map { "\($0.value) \($0.key)" } + } +} diff --git a/tests/501-1000/811. subdomain-visit-count/sol.ts b/tests/501-1000/811. subdomain-visit-count/sol.ts new file mode 100644 index 00000000..279a3cfd --- /dev/null +++ b/tests/501-1000/811. subdomain-visit-count/sol.ts @@ -0,0 +1,17 @@ +function subdomainVisits(cpdomains: string[]): string[] { + const freq: Map = new Map(); + for (const entry of cpdomains) { + const [cntStr, dom] = entry.split(" "); + const cnt = parseInt(cntStr, 10); + const parts = dom.split("."); + for (let i = 0; i < parts.length; i++) { + const sub = parts.slice(i).join("."); + freq.set(sub, (freq.get(sub) || 0) + cnt); + } + } + const result: string[] = []; + for (const [d, c] of freq.entries()) { + result.push(`${c} ${d}`); + } + return result; +} diff --git a/tests/501-1000/812. largest-triangle-area/manifest.yaml b/tests/501-1000/812. largest-triangle-area/manifest.yaml new file mode 100644 index 00000000..3d4ad030 --- /dev/null +++ b/tests/501-1000/812. largest-triangle-area/manifest.yaml @@ -0,0 +1,500 @@ +entry: + id: 812 + title: largest-triangle-area + params: + points: + type: array + items: + type: array + items: + type: int + call: + cpp: Solution().largestTriangleArea({points}) + rust: Solution::largest_triangle_area({points}) + python3: Solution().largestTriangleArea({points}) + python2: Solution().largestTriangleArea({points}) + ruby: largest_triangle_area({points}) + java: new Solution().largestTriangleArea({points}) + csharp: new Solution().LargestTriangleArea({points}) + kotlin: Solution().largestTriangleArea({points}) + go: largestTriangleArea({points}) + dart: Solution().largestTriangleArea({points}) + swift: Solution().largestTriangleArea({points}) + typescript: largestTriangleArea({points}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check(points, {result}) + checker: + "class Checker:\n def check(self, points, result):\n best =\ + \ 0.0\n n = len(points)\n for i in range(n):\n x1,\ + \ y1 = points[i]\n for j in range(i + 1, n):\n x2,\ + \ y2 = points[j]\n for k in range(j + 1, n):\n \ + \ x3, y3 = points[k]\n area = abs(0.5 * (x1 * (y2 -\ + \ y3) + x2 * (y3 - y1) + x3 * (y1 - y2)))\n if area > best:\n\ + \ best = area\n return abs(best - result) <= 1e-5\n" +seed: 812 +tests: + - name: example-1 + in: + points: + - - 0 + - 0 + - - 0 + - 1 + - - 1 + - 0 + - - 0 + - 2 + - - 2 + - 0 + - name: example-2 + in: + points: + - - 1 + - 0 + - - 0 + - 0 + - - 0 + - 1 + - name: right-triangle-small + in: + points: + - - 0 + - 0 + - - 2 + - 0 + - - 0 + - 2 + - name: collinear-three + in: + points: + - - 0 + - 0 + - - 1 + - 1 + - - 2 + - 2 + - name: rectangle-corners + in: + points: + - - 0 + - 0 + - - 0 + - 3 + - - 4 + - 0 + - - 4 + - 3 + - name: max-coordinates + in: + points: + - - -50 + - -50 + - - 50 + - -50 + - - -50 + - 50 + - name: thin-rectangle + in: + points: + - - 0 + - 0 + - - 10 + - 0 + - - 10 + - 1 + - - 0 + - 1 + - name: pentagon-like + in: + points: + - - 0 + - 0 + - - 2 + - 1 + - - 1 + - 3 + - - -1 + - 2 + - - -2 + - 0 + - name: six-points-mixed + in: + points: + - - 1 + - 1 + - - 2 + - 5 + - - 4 + - 2 + - - -1 + - 3 + - - 0 + - -2 + - - 3 + - -1 + - name: seven-points-spread + in: + points: + - - -3 + - -1 + - - -2 + - 4 + - - 0 + - 0 + - - 1 + - 5 + - - 4 + - 1 + - - 5 + - -2 + - - 2 + - -3 + - name: eight-points-grid + in: + points: + - - 0 + - 0 + - - 0 + - 4 + - - 4 + - 0 + - - 4 + - 4 + - - 2 + - 1 + - - 1 + - 2 + - - 3 + - 2 + - - 2 + - 3 + - name: nine-points-with-center + in: + points: + - - 0 + - 0 + - - 0 + - 6 + - - 6 + - 0 + - - 6 + - 6 + - - 3 + - 3 + - - 1 + - 5 + - - 5 + - 1 + - - 1 + - 1 + - - 5 + - 5 + - name: large-span-triangle + in: + points: + - - -50 + - 0 + - - 50 + - 0 + - - 0 + - 50 + - - 0 + - -50 + - name: near-linear + in: + points: + - - 0 + - 0 + - - 1 + - 1 + - - 2 + - 2 + - - 3 + - 3 + - - 4 + - 5 + - name: duplicate-slope-rich + in: + points: + - - 0 + - 0 + - - 2 + - 2 + - - 4 + - 4 + - - 1 + - 0 + - - 2 + - 1 + - - 3 + - 0 + - name: unit-square + in: + points: + - - 0 + - 0 + - - 1 + - 0 + - - 0 + - 1 + - - 1 + - 1 + out: 0.5 + - name: wider-right-triangle + in: + points: + - - 0 + - 0 + - - 2 + - 0 + - - 0 + - 3 + out: 3.0 + - name: square-corners + in: + points: + - - 0 + - 0 + - - 4 + - 0 + - - 0 + - 4 + - - 4 + - 4 + out: 8.0 + - name: negative-coordinates + in: + points: + - - -1 + - -1 + - - 1 + - -1 + - - 0 + - 2 + out: 3.0 + - name: four-point-mix + in: + points: + - - 0 + - 0 + - - 1 + - 2 + - - 3 + - 1 + - - 2 + - 4 + out: 5.0 + - name: wide-base + in: + points: + - - -2 + - 0 + - - 2 + - 0 + - - 0 + - 5 + - - 0 + - -3 + out: 10.0 + - name: nearly-collinear-with-spike + in: + points: + - - 0 + - 0 + - - 5 + - 0 + - - 1 + - 1 + - - 2 + - 2 + - - 3 + - 3 + out: 7.5 + - name: irregular-pentagon + in: + points: + - - -3 + - 1 + - - 0 + - 4 + - - 4 + - 0 + - - 1 + - -2 + - - 0 + - 1 + out: 12.0 + - name: six-points-spread + in: + points: + - - 0 + - 0 + - - 2 + - 1 + - - 4 + - 2 + - - 1 + - 5 + - - 3 + - -1 + - - -2 + - 4 + out: 10.0 + - name: large-span-triangle-2 + in: + points: + - - -5 + - -5 + - - 5 + - -5 + - - 0 + - 6 + - - 1 + - 1 + out: 55.0 + - name: skinny-triangle + in: + points: + - - 0 + - 0 + - - 3 + - 0 + - - 0 + - 2 + - - 1 + - 1 + out: 3.0 + - name: mirrored-points + in: + points: + - - -4 + - 2 + - - -1 + - 6 + - - 3 + - 1 + - - 5 + - 5 + - - 0 + - -3 + out: 28.5 + - name: hexagon-ish + in: + points: + - - 0 + - 0 + - - 6 + - 0 + - - 0 + - 1 + - - 6 + - 1 + - - 3 + - 4 + out: 12.0 + - name: tilted-quadrilateral + in: + points: + - - -2 + - -1 + - - 2 + - 3 + - - 4 + - -2 + - - -1 + - 4 + - - 1 + - 0 + out: 15.5 + - name: degenerate-with-peak + in: + points: + - - 0 + - 0 + - - 1 + - 1 + - - 2 + - 2 + - - 3 + - 4 + - - 5 + - 1 + out: 8.5 + - name: max-coordinate-square + in: + points: + - - -50 + - 0 + - - 0 + - 50 + - - 50 + - 0 + - - 0 + - -50 + - - 25 + - 25 + out: 2500.0 + - name: random-five + in: + points: + - - 0 + - 0 + - - 2 + - 5 + - - 5 + - 2 + - - 3 + - 7 + - - -1 + - 4 + out: 14.5 + - name: random-six + in: + points: + - - 1 + - 1 + - - 2 + - 4 + - - 4 + - 1 + - - 5 + - 5 + - - 0 + - 3 + - - 3 + - 0 + out: 10.5 + - name: five-point-low-area + in: + points: + - - 0 + - 0 + - - 1 + - 0 + - - 0 + - 2 + - - 2 + - 1 + - - 4 + - 0 + out: 4.0 + - name: all-collinear-five + in: + points: + - - 0 + - 0 + - - 1 + - 1 + - - 2 + - 2 + - - 3 + - 3 + - - 4 + - 4 + out: 0.0 diff --git a/tests/501-1000/812. largest-triangle-area/sol.cpp b/tests/501-1000/812. largest-triangle-area/sol.cpp new file mode 100644 index 00000000..271c58f8 --- /dev/null +++ b/tests/501-1000/812. largest-triangle-area/sol.cpp @@ -0,0 +1,21 @@ +class Solution { +public: + double largestTriangleArea(vector>& points) { + double max_area = 0.0; + int n = points.size(); + for (int i = 0; i < n; i++) { + int x1 = points[i][0], y1 = points[i][1]; + for (int j = i; j < n; j++) { + int x2 = points[j][0], y2 = points[j][1]; + for (int k = j; k < n; k++) { + int x3 = points[k][0], y3 = points[k][1]; + double area = abs(0.5 * (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))); + if (area > max_area) { + max_area = area; + } + } + } + } + return max_area; + } +}; diff --git a/tests/501-1000/812. largest-triangle-area/sol.cs b/tests/501-1000/812. largest-triangle-area/sol.cs new file mode 100644 index 00000000..562dbb7d --- /dev/null +++ b/tests/501-1000/812. largest-triangle-area/sol.cs @@ -0,0 +1,20 @@ +public class Solution { + public double LargestTriangleArea(int[][] points) { + double maxArea = 0.0; + int n = points.Length; + for (int i = 0; i < n; i++) { + int x1 = points[i][0], y1 = points[i][1]; + for (int j = i; j < n; j++) { + int x2 = points[j][0], y2 = points[j][1]; + for (int k = j; k < n; k++) { + int x3 = points[k][0], y3 = points[k][1]; + double area = Math.Abs(0.5 * (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))); + if (area > maxArea) { + maxArea = area; + } + } + } + } + return maxArea; + } +} diff --git a/tests/501-1000/812. largest-triangle-area/sol.dart b/tests/501-1000/812. largest-triangle-area/sol.dart new file mode 100644 index 00000000..068c5ad7 --- /dev/null +++ b/tests/501-1000/812. largest-triangle-area/sol.dart @@ -0,0 +1,20 @@ +class Solution { + double largestTriangleArea(List> points) { + double maxArea = 0.0; + int n = points.length; + for (int i = 0; i < n; i++) { + int x1 = points[i][0], y1 = points[i][1]; + for (int j = i; j < n; j++) { + int x2 = points[j][0], y2 = points[j][1]; + for (int k = j; k < n; k++) { + int x3 = points[k][0], y3 = points[k][1]; + double area = (0.5 * (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))).abs(); + if (area > maxArea) { + maxArea = area; + } + } + } + } + return maxArea; + } +} diff --git a/tests/501-1000/812. largest-triangle-area/sol.go b/tests/501-1000/812. largest-triangle-area/sol.go new file mode 100644 index 00000000..e1e00fbb --- /dev/null +++ b/tests/501-1000/812. largest-triangle-area/sol.go @@ -0,0 +1,18 @@ +func largestTriangleArea(points [][]int) float64 { + maxArea := 0.0 + n := len(points) + for i := 0; i < n; i++ { + x1, y1 := points[i][0], points[i][1] + for j := i; j < n; j++ { + x2, y2 := points[j][0], points[j][1] + for k := j; k < n; k++ { + x3, y3 := points[k][0], points[k][1] + area := math.Abs(0.5 * float64(x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))) + if area > maxArea { + maxArea = area + } + } + } + } + return maxArea +} diff --git a/tests/501-1000/812. largest-triangle-area/sol.java b/tests/501-1000/812. largest-triangle-area/sol.java new file mode 100644 index 00000000..cad78d93 --- /dev/null +++ b/tests/501-1000/812. largest-triangle-area/sol.java @@ -0,0 +1,20 @@ +class Solution { + public double largestTriangleArea(int[][] points) { + double maxArea = 0.0; + int n = points.length; + for (int i = 0; i < n; i++) { + int x1 = points[i][0], y1 = points[i][1]; + for (int j = i; j < n; j++) { + int x2 = points[j][0], y2 = points[j][1]; + for (int k = j; k < n; k++) { + int x3 = points[k][0], y3 = points[k][1]; + double area = Math.abs(0.5 * (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))); + if (area > maxArea) { + maxArea = area; + } + } + } + } + return maxArea; + } +} diff --git a/tests/501-1000/812. largest-triangle-area/sol.kt b/tests/501-1000/812. largest-triangle-area/sol.kt new file mode 100644 index 00000000..41610f28 --- /dev/null +++ b/tests/501-1000/812. largest-triangle-area/sol.kt @@ -0,0 +1,20 @@ +class Solution { + fun largestTriangleArea(points: Array): Double { + var maxArea = 0.0 + val n = points.size + for (i in 0 until n) { + val (x1, y1) = points[i] + for (j in i until n) { + val (x2, y2) = points[j] + for (k in j until n) { + val (x3, y3) = points[k] + val area = Math.abs(0.5 * (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))) + if (area > maxArea) { + maxArea = area + } + } + } + } + return maxArea + } +} diff --git a/tests/501-1000/812. largest-triangle-area/sol.py b/tests/501-1000/812. largest-triangle-area/sol.py new file mode 100644 index 00000000..fa2178b0 --- /dev/null +++ b/tests/501-1000/812. largest-triangle-area/sol.py @@ -0,0 +1,11 @@ +from typing import List + + +class Solution: + def largestTriangleArea(self, points: List[List[int]]) -> float: + return max( + abs(0.5 * (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))) + for i, (x1, y1) in enumerate(points) + for j, (x2, y2) in enumerate(points[i:], i) + for k, (x3, y3) in enumerate(points[j:], j) + ) diff --git a/tests/501-1000/812. largest-triangle-area/sol.py2 b/tests/501-1000/812. largest-triangle-area/sol.py2 new file mode 100644 index 00000000..dd8afc4d --- /dev/null +++ b/tests/501-1000/812. largest-triangle-area/sol.py2 @@ -0,0 +1,18 @@ +class Solution(object): + def largestTriangleArea(self, points): + """ + :type points: List[List[int]] + :rtype: float + """ + max_area = 0.0 + n = len(points) + for i in range(n): + x1, y1 = points[i] + for j in range(i, n): + x2, y2 = points[j] + for k in range(j, n): + x3, y3 = points[k] + area = abs(0.5 * (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))) + if area > max_area: + max_area = area + return max_area diff --git a/tests/501-1000/812. largest-triangle-area/sol.rb b/tests/501-1000/812. largest-triangle-area/sol.rb new file mode 100644 index 00000000..d69ea4c5 --- /dev/null +++ b/tests/501-1000/812. largest-triangle-area/sol.rb @@ -0,0 +1,18 @@ +# @param {Integer[][]} points +# @return {Float} +def largest_triangle_area(points) + max_area = 0.0 + n = points.length + (0...n).each do |i| + x1, y1 = points[i] + (i...n).each do |j| + x2, y2 = points[j] + (j...n).each do |k| + x3, y3 = points[k] + area = (0.5 * (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))).abs + max_area = area if area > max_area + end + end + end + max_area +end diff --git a/tests/501-1000/812. largest-triangle-area/sol.rs b/tests/501-1000/812. largest-triangle-area/sol.rs new file mode 100644 index 00000000..46b53607 --- /dev/null +++ b/tests/501-1000/812. largest-triangle-area/sol.rs @@ -0,0 +1,20 @@ +impl Solution { + pub fn largest_triangle_area(points: Vec>) -> f64 { + let mut max_area = 0.0f64; + let n = points.len(); + for i in 0..n { + let (x1, y1) = (points[i][0], points[i][1]); + for j in i..n { + let (x2, y2) = (points[j][0], points[j][1]); + for k in j..n { + let (x3, y3) = (points[k][0], points[k][1]); + let area = (0.5 * (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) as f64).abs(); + if area > max_area { + max_area = area; + } + } + } + } + max_area + } +} diff --git a/tests/501-1000/812. largest-triangle-area/sol.swift b/tests/501-1000/812. largest-triangle-area/sol.swift new file mode 100644 index 00000000..0e93fa6d --- /dev/null +++ b/tests/501-1000/812. largest-triangle-area/sol.swift @@ -0,0 +1,20 @@ +class Solution { + func largestTriangleArea(_ points: [[Int]]) -> Double { + var maxArea = 0.0 + let n = points.count + for i in 0.. maxArea { + maxArea = area + } + } + } + } + return maxArea + } +} diff --git a/tests/501-1000/812. largest-triangle-area/sol.ts b/tests/501-1000/812. largest-triangle-area/sol.ts new file mode 100644 index 00000000..58d4bd59 --- /dev/null +++ b/tests/501-1000/812. largest-triangle-area/sol.ts @@ -0,0 +1,20 @@ +function largestTriangleArea(points: number[][]): number { + let maxArea = 0.0; + const n = points.length; + for (let i = 0; i < n; i++) { + const [x1, y1] = points[i]; + for (let j = i; j < n; j++) { + const [x2, y2] = points[j]; + for (let k = j; k < n; k++) { + const [x3, y3] = points[k]; + const area = Math.abs( + 0.5 * (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)), + ); + if (area > maxArea) { + maxArea = area; + } + } + } + } + return maxArea; +} diff --git a/tests/501-1000/813. largest-sum-of-averages/manifest.yaml b/tests/501-1000/813. largest-sum-of-averages/manifest.yaml new file mode 100644 index 00000000..cb636205 --- /dev/null +++ b/tests/501-1000/813. largest-sum-of-averages/manifest.yaml @@ -0,0 +1,409 @@ +entry: + id: 813 + title: largest-sum-of-averages + params: + nums: + type: array + items: + type: int + k: + type: int + call: + cpp: Solution().largestSumOfAverages({nums}, {k}) + rust: Solution::largest_sum_of_averages({nums}, {k}) + python3: Solution().largestSumOfAverages({nums}, {k}) + python2: Solution().largestSumOfAverages({nums}, {k}) + ruby: largest_sum_of_averages({nums}, {k}) + java: new Solution().largestSumOfAverages({nums}, {k}) + csharp: new Solution().LargestSumOfAverages({nums}, {k}) + kotlin: Solution().largestSumOfAverages({nums}, {k}) + go: largestSumOfAverages({nums}, {k}) + dart: Solution().largestSumOfAverages({nums}, {k}) + swift: Solution().largestSumOfAverages({nums}, {k}) + typescript: largestSumOfAverages({nums}, {k}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check(nums, k, {result}) + checker: | + class Checker: + def check(self, nums, k, result): + n = len(nums) + pref = [0.0] + for x in nums: + pref.append(pref[-1] + x) + dp = [[0.0] * (k + 1) for _ in range(n + 1)] + for i in range(1, n + 1): + dp[i][1] = pref[i] / i + for p in range(2, k + 1): + for i in range(p, n + 1): + best = 0.0 + for j in range(p - 1, i): + cand = dp[j][p - 1] + (pref[i] - pref[j]) / (i - j) + if cand > best: + best = cand + dp[i][p] = best + return abs(dp[n][k] - result) <= 1e-6 +seed: 813 +tests: + - name: example-1 + in: + nums: + - 9 + - 1 + - 2 + - 3 + - 9 + k: 3 + - name: example-2 + in: + nums: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + k: 4 + - name: single-group + in: + nums: + - 5 + - 5 + - 5 + k: 1 + - name: all-singletons + in: + nums: + - 1 + - 2 + - 3 + - 4 + k: 4 + - name: two-elements-k2 + in: + nums: + - 10 + - 20 + k: 2 + - name: two-elements-k1 + in: + nums: + - 10 + - 20 + k: 1 + - name: increasing-five-k2 + in: + nums: + - 1 + - 2 + - 3 + - 4 + - 5 + k: 2 + - name: increasing-five-k3 + in: + nums: + - 1 + - 2 + - 3 + - 4 + - 5 + k: 3 + - name: descending-five-k3 + in: + nums: + - 9 + - 8 + - 7 + - 6 + - 5 + k: 3 + - name: mixed-small + in: + nums: + - 3 + - 1 + - 4 + - 1 + - 5 + - 9 + k: 3 + - name: mixed-two-groups + in: + nums: + - 8 + - 1 + - 7 + - 3 + - 9 + - 2 + k: 2 + - name: mixed-four-groups + in: + nums: + - 8 + - 1 + - 7 + - 3 + - 9 + - 2 + k: 4 + - name: repeated-values + in: + nums: + - 4 + - 4 + - 4 + - 4 + - 4 + - 4 + k: 3 + - name: prime-ish + in: + nums: + - 2 + - 3 + - 5 + - 7 + - 11 + - 13 + k: 4 + - name: large-values + in: + nums: + - 10000 + - 9999 + - 10000 + - 9998 + - 10000 + k: 2 + - name: zigzag-large-k3 + in: + nums: + - 1 + - 10000 + - 1 + - 10000 + - 1 + k: 3 + - name: peak-middle-k2 + in: + nums: + - 10000 + - 1 + - 1 + - 1 + - 10000 + k: 2 + - name: alternating-small-k4 + in: + nums: + - 5 + - 1 + - 5 + - 1 + - 5 + - 1 + - 5 + k: 4 + - name: valley-middle-k3 + in: + nums: + - 1 + - 3 + - 2 + - 6 + - 4 + - 8 + - 5 + k: 3 + - name: descending-six-k2 + in: + nums: + - 6 + - 5 + - 4 + - 3 + - 2 + - 1 + k: 2 + - name: grouped-highs-k3 + in: + nums: + - 2 + - 2 + - 2 + - 9 + - 9 + - 9 + k: 3 + - name: long-alternating-k5 + in: + nums: + - 7 + - 1 + - 7 + - 1 + - 7 + - 1 + - 7 + - 1 + k: 5 + - name: pair-bumps-k2 + in: + nums: + - 1 + - 9 + - 1 + - 9 + - 1 + - 9 + k: 2 + - name: mixed-spikes-k4 + in: + nums: + - 4 + - 1 + - 2 + - 10 + - 2 + - 1 + - 4 + k: 4 + - name: symmetric-peaks-k2 + in: + nums: + - 100 + - 100 + - 1 + - 1 + - 100 + - 100 + k: 2 + - name: spike-middle-k3 + in: + nums: + - 1 + - 2 + - 100 + - 2 + - 1 + - 100 + k: 3 + - name: descending-spike-k2 + in: + nums: + - 8 + - 6 + - 7 + - 5 + - 3 + - 0 + k: 2 + - name: flat-nine-k4 + in: + nums: + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + k: 4 + - name: increasing-five-k5 + in: + nums: + - 10 + - 20 + - 30 + - 40 + - 50 + k: 5 + - name: increasing-five-k3b + in: + nums: + - 10 + - 20 + - 30 + - 40 + - 50 + k: 3 + - name: zigzag-nine-k4 + in: + nums: + - 9 + - 1 + - 9 + - 1 + - 9 + - 1 + - 9 + - 1 + - 9 + k: 4 + - name: repeat-three-k2 + in: + nums: + - 3 + - 5 + - 3 + - 5 + - 3 + - 5 + - 3 + k: 2 + - name: repeating-pairs-k4 + in: + nums: + - 2 + - 8 + - 2 + - 8 + - 2 + - 8 + - 2 + - 8 + k: 4 + - name: huge-alternating-k3 + in: + nums: + - 10000 + - 1 + - 10000 + - 1 + - 10000 + - 1 + - 10000 + k: 3 + - name: spike-tail-k4 + in: + nums: + - 1 + - 2 + - 3 + - 10000 + - 4 + - 5 + - 6 + k: 4 + - name: blocky-eight-k2 + in: + nums: + - 7 + - 7 + - 7 + - 7 + - 1 + - 1 + - 1 + - 1 + k: 2 diff --git a/tests/501-1000/813. largest-sum-of-averages/sol.cpp b/tests/501-1000/813. largest-sum-of-averages/sol.cpp new file mode 100644 index 00000000..5dc09bf5 --- /dev/null +++ b/tests/501-1000/813. largest-sum-of-averages/sol.cpp @@ -0,0 +1,25 @@ +class Solution { +public: + double largestSumOfAverages(vector& nums, int k) { + int n = nums.size(); + vector pref(n+1, 0); + for (int i = 0; i < n; i++) { + pref[i+1] = pref[i] + nums[i]; + } + vector> dp(n+1, vector(k+1, 0.0)); + for (int i = 1; i <= n; i++) { + dp[i][1] = (double)pref[i] / i; + } + for (int p = 2; p <= k; p++) { + for (int i = p; i <= n; i++) { + double best = 0.0; + for (int j = p-1; j < i; j++) { + double val = dp[j][p-1] + (double)(pref[i] - pref[j]) / (i - j); + if (val > best) best = val; + } + dp[i][p] = best; + } + } + return dp[n][k]; + } +}; diff --git a/tests/501-1000/813. largest-sum-of-averages/sol.cs b/tests/501-1000/813. largest-sum-of-averages/sol.cs new file mode 100644 index 00000000..844dbcec --- /dev/null +++ b/tests/501-1000/813. largest-sum-of-averages/sol.cs @@ -0,0 +1,24 @@ +public class Solution { + public double LargestSumOfAverages(int[] nums, int k) { + int n = nums.Length; + int[] pref = new int[n+1]; + for (int i = 0; i < n; i++) { + pref[i+1] = pref[i] + nums[i]; + } + double[,] dp = new double[n+1, k+1]; + for (int i = 1; i <= n; i++) { + dp[i,1] = (double)pref[i] / i; + } + for (int p = 2; p <= k; p++) { + for (int i = p; i <= n; i++) { + double best = 0.0; + for (int j = p-1; j < i; j++) { + double val = dp[j,p-1] + (double)(pref[i] - pref[j]) / (i - j); + if (val > best) best = val; + } + dp[i,p] = best; + } + } + return dp[n,k]; + } +} diff --git a/tests/501-1000/813. largest-sum-of-averages/sol.dart b/tests/501-1000/813. largest-sum-of-averages/sol.dart new file mode 100644 index 00000000..cceb87cb --- /dev/null +++ b/tests/501-1000/813. largest-sum-of-averages/sol.dart @@ -0,0 +1,24 @@ +class Solution { + double largestSumOfAverages(List nums, int k) { + int n = nums.length; + List pref = List.filled(n+1, 0); + for (int i = 0; i < n; i++) { + pref[i+1] = pref[i] + nums[i]; + } + List> dp = List.generate(n+1, (_) => List.filled(k+1, 0.0)); + for (int i = 1; i <= n; i++) { + dp[i][1] = pref[i] / i; + } + for (int p = 2; p <= k; p++) { + for (int i = p; i <= n; i++) { + double best = 0.0; + for (int j = p-1; j < i; j++) { + double val = dp[j][p-1] + (pref[i] - pref[j]) / (i - j); + if (val > best) best = val; + } + dp[i][p] = best; + } + } + return dp[n][k]; + } +} diff --git a/tests/501-1000/813. largest-sum-of-averages/sol.go b/tests/501-1000/813. largest-sum-of-averages/sol.go new file mode 100644 index 00000000..19866d7f --- /dev/null +++ b/tests/501-1000/813. largest-sum-of-averages/sol.go @@ -0,0 +1,27 @@ +func largestSumOfAverages(nums []int, k int) float64 { + n := len(nums) + pref := make([]int, n+1) + for i, x := range nums { + pref[i+1] = pref[i] + x + } + dp := make([][]float64, n+1) + for i := range dp { + dp[i] = make([]float64, k+1) + } + for i := 1; i <= n; i++ { + dp[i][1] = float64(pref[i]) / float64(i) + } + for p := 2; p <= k; p++ { + for i := p; i <= n; i++ { + best := 0.0 + for j := p-1; j < i; j++ { + val := dp[j][p-1] + float64(pref[i]-pref[j]) / float64(i-j) + if val > best { + best = val + } + } + dp[i][p] = best + } + } + return dp[n][k] +} diff --git a/tests/501-1000/813. largest-sum-of-averages/sol.java b/tests/501-1000/813. largest-sum-of-averages/sol.java new file mode 100644 index 00000000..2eab869d --- /dev/null +++ b/tests/501-1000/813. largest-sum-of-averages/sol.java @@ -0,0 +1,24 @@ +class Solution { + public double largestSumOfAverages(int[] nums, int k) { + int n = nums.length; + int[] pref = new int[n+1]; + for (int i = 0; i < n; i++) { + pref[i+1] = pref[i] + nums[i]; + } + double[][] dp = new double[n+1][k+1]; + for (int i = 1; i <= n; i++) { + dp[i][1] = (double) pref[i] / i; + } + for (int p = 2; p <= k; p++) { + for (int i = p; i <= n; i++) { + double best = 0.0; + for (int j = p-1; j < i; j++) { + double val = dp[j][p-1] + (double)(pref[i] - pref[j]) / (i - j); + if (val > best) best = val; + } + dp[i][p] = best; + } + } + return dp[n][k]; + } +} diff --git a/tests/501-1000/813. largest-sum-of-averages/sol.kt b/tests/501-1000/813. largest-sum-of-averages/sol.kt new file mode 100644 index 00000000..32c85097 --- /dev/null +++ b/tests/501-1000/813. largest-sum-of-averages/sol.kt @@ -0,0 +1,20 @@ +class Solution { + fun largestSumOfAverages(nums: IntArray, k: Int): Double { + val n = nums.size + val pref = IntArray(n+1) + for (i in 0 until n) pref[i+1] = pref[i] + nums[i] + val dp = Array(n+1) { DoubleArray(k+1) } + for (i in 1..n) dp[i][1] = pref[i].toDouble() / i + for (p in 2..k) { + for (i in p..n) { + var best = 0.0 + for (j in p-1 until i) { + val cur = dp[j][p-1] + (pref[i] - pref[j]).toDouble() / (i - j) + if (cur > best) best = cur + } + dp[i][p] = best + } + } + return dp[n][k] + } +} diff --git a/tests/501-1000/813. largest-sum-of-averages/sol.py b/tests/501-1000/813. largest-sum-of-averages/sol.py new file mode 100644 index 00000000..eb42384f --- /dev/null +++ b/tests/501-1000/813. largest-sum-of-averages/sol.py @@ -0,0 +1,17 @@ +class Solution(object): + def largestSumOfAverages(self, nums, k): + n = len(nums) + pref = [0] + for x in nums: + pref.append(pref[-1] + x) + # dp[i][p] – first i elements into p groups + dp = [[0] * (k + 1) for _ in range(n + 1)] + for i in range(1, n + 1): + dp[i][1] = pref[i] / float(i) + for p in range(2, k + 1): + for i in range(p, n + 1): + best = 0.0 + for j in range(p - 1, i): + best = max(best, dp[j][p - 1] + (pref[i] - pref[j]) / float(i - j)) + dp[i][p] = best + return dp[n][k] diff --git a/tests/501-1000/813. largest-sum-of-averages/sol.py2 b/tests/501-1000/813. largest-sum-of-averages/sol.py2 new file mode 100644 index 00000000..62c992cc --- /dev/null +++ b/tests/501-1000/813. largest-sum-of-averages/sol.py2 @@ -0,0 +1,16 @@ +class Solution(object): + def largestSumOfAverages(self, nums, k): + n = len(nums) + pref = [0] + for x in nums: + pref.append(pref[-1] + x) + dp = [[0.0]*(k+1) for _ in range(n+1)] + for i in range(1, n+1): + dp[i][1] = pref[i] / float(i) + for p in range(2, k+1): + for i in range(p, n+1): + best = 0.0 + for j in range(p-1, i): + best = max(best, dp[j][p-1] + (pref[i]-pref[j]) / float(i-j)) + dp[i][p] = best + return dp[n][k] diff --git a/tests/501-1000/813. largest-sum-of-averages/sol.rb b/tests/501-1000/813. largest-sum-of-averages/sol.rb new file mode 100644 index 00000000..34b2b5d4 --- /dev/null +++ b/tests/501-1000/813. largest-sum-of-averages/sol.rb @@ -0,0 +1,21 @@ +# @param {Integer[]} nums +# @param {Integer} k +# @return {Float} +def largest_sum_of_averages(nums, k) + n = nums.length + pref = [0] + nums.each { |x| pref << pref[-1] + x } + dp = Array.new(n+1) { Array.new(k+1, 0.0) } + (1..n).each { |i| dp[i][1] = pref[i].to_f / i } + (2..k).each do |p| + (p..n).each do |i| + best = 0.0 + (p-1...i).each do |j| + val = dp[j][p-1] + (pref[i] - pref[j]).to_f / (i - j) + best = val if val > best + end + dp[i][p] = best + end + end + dp[n][k] +end diff --git a/tests/501-1000/813. largest-sum-of-averages/sol.rs b/tests/501-1000/813. largest-sum-of-averages/sol.rs new file mode 100644 index 00000000..b405e05f --- /dev/null +++ b/tests/501-1000/813. largest-sum-of-averages/sol.rs @@ -0,0 +1,25 @@ +impl Solution { + pub fn largest_sum_of_averages(nums: Vec, k: i32) -> f64 { + let n = nums.len(); + let k = k as usize; + let mut pref = vec![0i32; n+1]; + for i in 0..n { + pref[i+1] = pref[i] + nums[i]; + } + let mut dp = vec![vec![0.0f64; k+1]; n+1]; + for i in 1..=n { + dp[i][1] = pref[i] as f64 / i as f64; + } + for p in 2..=k { + for i in p..=n { + let mut best = 0.0f64; + for j in (p-1)..i { + let val = dp[j][p-1] + (pref[i] - pref[j]) as f64 / (i - j) as f64; + if val > best { best = val; } + } + dp[i][p] = best; + } + } + dp[n][k] + } +} diff --git a/tests/501-1000/813. largest-sum-of-averages/sol.swift b/tests/501-1000/813. largest-sum-of-averages/sol.swift new file mode 100644 index 00000000..8584167a --- /dev/null +++ b/tests/501-1000/813. largest-sum-of-averages/sol.swift @@ -0,0 +1,27 @@ +class Solution { + func largestSumOfAverages(_ nums: [Int], _ k: Int) -> Double { + let n = nums.count + if k == 1 { + return Double(nums.reduce(0, +)) / Double(n) + } + var pref = [Int](repeating: 0, count: n+1) + for i in 0.. best { best = val } + } + dp[i][p] = best + } + } + return dp[n][k] + } +} diff --git a/tests/501-1000/813. largest-sum-of-averages/sol.ts b/tests/501-1000/813. largest-sum-of-averages/sol.ts new file mode 100644 index 00000000..2b402381 --- /dev/null +++ b/tests/501-1000/813. largest-sum-of-averages/sol.ts @@ -0,0 +1,22 @@ +function largestSumOfAverages(nums: number[], k: number): number { + const n = nums.length; + const pref: number[] = [0]; + for (const x of nums) pref.push(pref[pref.length - 1] + x); + const dp: number[][] = Array.from({ length: n + 1 }, () => + Array(k + 1).fill(0), + ); + for (let i = 1; i <= n; i++) { + dp[i][1] = pref[i] / i; + } + for (let p = 2; p <= k; p++) { + for (let i = p; i <= n; i++) { + let best = 0.0; + for (let j = p - 1; j < i; j++) { + const val = dp[j][p - 1] + (pref[i] - pref[j]) / (i - j); + if (val > best) best = val; + } + dp[i][p] = best; + } + } + return dp[n][k]; +} diff --git a/tests/501-1000/814. binary-tree-pruning/manifest.yaml b/tests/501-1000/814. binary-tree-pruning/manifest.yaml new file mode 100644 index 00000000..d170b673 --- /dev/null +++ b/tests/501-1000/814. binary-tree-pruning/manifest.yaml @@ -0,0 +1,445 @@ +entry: + id: 814 + title: binary-tree-pruning + params: + root: + type: tree_node + call: + cpp: treeNodeToArray(Solution().pruneTree({root})) + rust: TreeNode::tree_node_to_array(Solution::prune_tree({root})) + python3: tree_node_to_array(Solution().pruneTree({root})) + python2: tree_node_to_array(Solution().pruneTree({root})) + ruby: tree_node_to_array(prune_tree({root})) + java: TreeNode.treeNodeToArray(new Solution().pruneTree({root})) + csharp: TreeNode.TreeNodeToArray(new Solution().PruneTree({root})) + kotlin: treeNodeToArray(Solution().pruneTree({root})) + go: treeNodeToArray(pruneTree({root})) + dart: tree_node_to_array(Solution().pruneTree({root})) + swift: tree_node_to_array(Solution().pruneTree({root})) + typescript: treeNodeToArray(pruneTree({root})) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check(root, {result}) + checker: | + class Checker: + def from_value(self, value): + if value is None: + return None + if isinstance(value, dict): + return { + "val": value.get("val"), + "left": self.from_value(value.get("left")), + "right": self.from_value(value.get("right")), + } + if isinstance(value, list): + if not value: + return None + nodes = [None if v is None else {"val": v, "left": None, "right": None} for v in value] + kids = nodes[1:] + idx = 0 + for node in nodes: + if node is not None: + if idx < len(kids): + node["left"] = kids[idx] + idx += 1 + if idx < len(kids): + node["right"] = kids[idx] + idx += 1 + return nodes[0] + if hasattr(value, "val"): + return { + "val": value.val, + "left": self.from_value(getattr(value, "left", None)), + "right": self.from_value(getattr(value, "right", None)), + } + return value + + def prune(self, node): + if not node: + return None + node["left"] = self.prune(node["left"]) + node["right"] = self.prune(node["right"]) + if node["val"] == 0 and node["left"] is None and node["right"] is None: + return None + return node + + def to_array(self, root): + if not root: + return [] + out = [] + q = [root] + while q: + node = q.pop(0) + if node is None: + out.append(None) + else: + out.append(node["val"]) + q.append(node["left"]) + q.append(node["right"]) + while out and out[-1] is None: + out.pop() + return out + + def check(self, root, result): + return self.to_array(self.prune(self.from_value(root))) == self.to_array(self.from_value(result)) +seed: 814 +tests: + - name: example-1 + in: + root: + - 1 + - null + - 0 + - 0 + - 1 + - name: example-2 + in: + root: + - 1 + - 0 + - 1 + - 0 + - 0 + - 0 + - 1 + - name: example-3 + in: + root: + - 1 + - 1 + - 0 + - 1 + - 1 + - 0 + - 1 + - 0 + - name: single-one + in: + root: + - 1 + - name: single-zero + in: + root: + - 0 + - name: left-zero-chain + in: + root: + - 0 + - 0 + - null + - 0 + - name: right-zero-chain + in: + root: + - 0 + - null + - 0 + - null + - 0 + - name: root-one-left-pruned + in: + root: + - 1 + - 0 + - null + - 0 + - null + - 0 + - name: root-one-right-pruned + in: + root: + - 1 + - null + - 0 + - null + - 0 + - null + - 1 + - name: balanced-all-ones + in: + root: + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - name: balanced-all-zero + in: + root: + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - name: mixed-deep-left + in: + root: + - 0 + - 0 + - 1 + - 0 + - null + - null + - 1 + - name: mixed-deep-right + in: + root: + - 0 + - 1 + - 0 + - null + - 0 + - 0 + - null + - null + - null + - 1 + - name: sparse-with-one-leaf + in: + root: + - 0 + - 0 + - 0 + - null + - null + - null + - 1 + - name: deep-branched + in: + root: + - 1 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - null + - null + - 1 + - null + - null + - null + - 0 + - 1 + - name: all-zero-full-depth4 + in: + root: + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - name: only-rightmost-one + in: + root: + - 0 + - 0 + - 0 + - null + - null + - null + - 0 + - null + - null + - null + - null + - null + - null + - null + - 1 + - name: left-subtree-survives + in: + root: + - 1 + - 0 + - 0 + - 1 + - null + - 0 + - 0 + - name: right-subtree-survives + in: + root: + - 1 + - 0 + - 0 + - null + - 1 + - 0 + - 0 + - name: root-pruned-to-empty + in: + root: + - 0 + - 0 + - 1 + - 0 + - null + - null + - 1 + - name: zigzag-survival + in: + root: + - 0 + - 1 + - 0 + - 1 + - null + - 1 + - null + - 1 + - name: top-one-with-zero-leaves + in: + root: + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - name: single-right-path-one + in: + root: + - 1 + - null + - 0 + - null + - 1 + - name: single-left-path-one + in: + root: + - 1 + - 0 + - null + - 1 + - name: mixed-wide + in: + root: + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 1 + - 0 + - null + - null + - null + - null + - null + - 1 + - 0 + - name: long-left-spine + in: + root: + - 1 + - 0 + - null + - 0 + - null + - 1 + - null + - 0 + - name: right-heavy-survival + in: + root: + - 1 + - null + - 1 + - null + - 0 + - null + - 1 + - name: left-heavy-survival + in: + root: + - 1 + - 1 + - null + - 0 + - null + - 1 + - name: root-kept-one-leaf + in: + root: + - 0 + - 1 + - 0 + - null + - null + - null + - 1 + - name: prune-both-sides + in: + root: + - 1 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - name: alternating-depth + in: + root: + - 0 + - 1 + - 0 + - 0 + - 1 + - 0 + - 1 + - name: single-leaf-one-in-zero-tree + in: + root: + - 0 + - 0 + - 0 + - null + - 1 + - name: compact-survival + in: + root: + - 1 + - 0 + - 1 + - 0 + - 1 + - name: zero-root-one-descendant + in: + root: + - 0 + - null + - 1 + - name: asymmetric-prune + in: + root: + - 1 + - 0 + - 1 + - 0 + - null + - 1 + - null diff --git a/tests/501-1000/814. binary-tree-pruning/sol.cpp b/tests/501-1000/814. binary-tree-pruning/sol.cpp new file mode 100644 index 00000000..ebf0cb67 --- /dev/null +++ b/tests/501-1000/814. binary-tree-pruning/sol.cpp @@ -0,0 +1,40 @@ +/** + * Definition for a binary tree node. + * struct TreeNode { + * int val; + * TreeNode *left; + * TreeNode *right; + * TreeNode() : val(0), left(nullptr), right(nullptr) {} + * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} + * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} + * }; + */ +class Solution { +public: + TreeNode* pruneTree(TreeNode* root) { + traverseAndRemove(root); + if (root->left == nullptr && root->right == nullptr && root->val == 0) { + return nullptr; + } + return root; + } + +private: + bool traverseAndRemove(TreeNode* temp) { + if (temp == nullptr) { + return false; + } + if (temp->left == nullptr && temp->right == nullptr) { + return temp->val == 1; + } + bool left = traverseAndRemove(temp->left); + bool right = traverseAndRemove(temp->right); + if (!left) { + temp->left = nullptr; + } + if (!right) { + temp->right = nullptr; + } + return left || right || temp->val == 1; + } +}; diff --git a/tests/501-1000/814. binary-tree-pruning/sol.cs b/tests/501-1000/814. binary-tree-pruning/sol.cs new file mode 100644 index 00000000..93828666 --- /dev/null +++ b/tests/501-1000/814. binary-tree-pruning/sol.cs @@ -0,0 +1,40 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public int val; + * public TreeNode left; + * public TreeNode right; + * public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +public class Solution { + public TreeNode PruneTree(TreeNode root) { + traverseAndRemove(root); + if (root.left == null && root.right == null && root.val == 0) { + return null; + } + return root; + } + + private bool traverseAndRemove(TreeNode temp) { + if (temp == null) { + return false; + } + if (temp.left == null && temp.right == null) { + return temp.val == 1; + } + bool left = traverseAndRemove(temp.left); + bool right = traverseAndRemove(temp.right); + if (!left) { + temp.left = null; + } + if (!right) { + temp.right = null; + } + return left || right || temp.val == 1; + } +} diff --git a/tests/501-1000/814. binary-tree-pruning/sol.dart b/tests/501-1000/814. binary-tree-pruning/sol.dart new file mode 100644 index 00000000..d1e6eb3a --- /dev/null +++ b/tests/501-1000/814. binary-tree-pruning/sol.dart @@ -0,0 +1,36 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * int val; + * TreeNode? left; + * TreeNode? right; + * TreeNode([this.val = 0, this.left, this.right]); + * } + */ +class Solution { + TreeNode? pruneTree(TreeNode? root) { + bool traverseAndRemove(TreeNode? temp) { + if (temp == null) { + return false; + } + if (temp.left == null && temp.right == null) { + return temp.val == 1; + } + bool left = traverseAndRemove(temp.left); + bool right = traverseAndRemove(temp.right); + if (!left) { + temp.left = null; + } + if (!right) { + temp.right = null; + } + return left || right || temp.val == 1; + } + + traverseAndRemove(root); + if (root != null && root.left == null && root.right == null && root.val == 0) { + return null; + } + return root; + } +} diff --git a/tests/501-1000/814. binary-tree-pruning/sol.go b/tests/501-1000/814. binary-tree-pruning/sol.go new file mode 100644 index 00000000..00f5a9c2 --- /dev/null +++ b/tests/501-1000/814. binary-tree-pruning/sol.go @@ -0,0 +1,34 @@ +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +func pruneTree(root *TreeNode) *TreeNode { + var traverseAndRemove func(temp *TreeNode) bool + traverseAndRemove = func(temp *TreeNode) bool { + if temp == nil { + return false + } + if temp.Left == nil && temp.Right == nil { + return temp.Val == 1 + } + left := traverseAndRemove(temp.Left) + right := traverseAndRemove(temp.Right) + if !left { + temp.Left = nil + } + if !right { + temp.Right = nil + } + return left || right || temp.Val == 1 + } + + traverseAndRemove(root) + if root.Left == nil && root.Right == nil && root.Val == 0 { + return nil + } + return root +} diff --git a/tests/501-1000/814. binary-tree-pruning/sol.java b/tests/501-1000/814. binary-tree-pruning/sol.java new file mode 100644 index 00000000..11961f01 --- /dev/null +++ b/tests/501-1000/814. binary-tree-pruning/sol.java @@ -0,0 +1,42 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode() {} + * TreeNode(int val) { this.val = val; } + * TreeNode(int val, TreeNode left, TreeNode right) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +class Solution { + public TreeNode pruneTree(TreeNode root) { + traverseAndRemove(root); + if (root.left == null && root.right == null && root.val == 0) { + return null; + } + return root; + } + + private boolean traverseAndRemove(TreeNode temp) { + if (temp == null) { + return false; + } + if (temp.left == null && temp.right == null) { + return temp.val == 1; + } + boolean left = traverseAndRemove(temp.left); + boolean right = traverseAndRemove(temp.right); + if (!left) { + temp.left = null; + } + if (!right) { + temp.right = null; + } + return left || right || temp.val == 1; + } +} diff --git a/tests/501-1000/814. binary-tree-pruning/sol.kt b/tests/501-1000/814. binary-tree-pruning/sol.kt new file mode 100644 index 00000000..f01c2db8 --- /dev/null +++ b/tests/501-1000/814. binary-tree-pruning/sol.kt @@ -0,0 +1,37 @@ +/** + * Example: + * var ti = TreeNode(5) + * var v = ti.`val` + * Definition for a binary tree node. + * class TreeNode(var `val`: Int) { + * var left: TreeNode? = null + * var right: TreeNode? = null + * } + */ +class Solution { + fun pruneTree(root: TreeNode?): TreeNode? { + fun traverseAndRemove(temp: TreeNode?): Boolean { + if (temp == null) { + return false + } + if (temp.left == null && temp.right == null) { + return temp.`val` == 1 + } + val left = traverseAndRemove(temp.left) + val right = traverseAndRemove(temp.right) + if (!left) { + temp.left = null + } + if (!right) { + temp.right = null + } + return left || right || temp.`val` == 1 + } + + traverseAndRemove(root) + if (root != null && root.left == null && root.right == null && root.`val` == 0) { + return null + } + return root + } +} diff --git a/tests/501-1000/814. binary-tree-pruning/sol.py b/tests/501-1000/814. binary-tree-pruning/sol.py new file mode 100644 index 00000000..2c5453db --- /dev/null +++ b/tests/501-1000/814. binary-tree-pruning/sol.py @@ -0,0 +1,28 @@ +# Definition for a binary tree node. +# class TreeNode: +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution: + def pruneTree(self, root: Optional[TreeNode]) -> Optional[TreeNode]: + def traverseAndRemove(temp): + if not temp: + return False + if not temp.left and not temp.right: + if temp.val == 1: + return True + else: + return False + left = traverseAndRemove(temp.left) + right = traverseAndRemove(temp.right) + if not left: + temp.left = None + if not right: + temp.right = None + return left or right or temp.val == 1 + + traverseAndRemove(root) + if not root.left and not root.right and root.val == 0: + return + return root diff --git a/tests/501-1000/814. binary-tree-pruning/sol.py2 b/tests/501-1000/814. binary-tree-pruning/sol.py2 new file mode 100644 index 00000000..693f3735 --- /dev/null +++ b/tests/501-1000/814. binary-tree-pruning/sol.py2 @@ -0,0 +1,32 @@ +# Definition for a binary tree node. +# class TreeNode(object): +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution(object): + def pruneTree(self, root): + """ + :type root: Optional[TreeNode] + :rtype: Optional[TreeNode] + """ + def traverseAndRemove(temp): + if not temp: + return False + if not temp.left and not temp.right: + if temp.val == 1: + return True + else: + return False + left = traverseAndRemove(temp.left) + right = traverseAndRemove(temp.right) + if not left: + temp.left = None + if not right: + temp.right = None + return left or right or temp.val == 1 + + traverseAndRemove(root) + if not root.left and not root.right and root.val == 0: + return None + return root diff --git a/tests/501-1000/814. binary-tree-pruning/sol.rb b/tests/501-1000/814. binary-tree-pruning/sol.rb new file mode 100644 index 00000000..6e2168c3 --- /dev/null +++ b/tests/501-1000/814. binary-tree-pruning/sol.rb @@ -0,0 +1,30 @@ +# Definition for a binary tree node. +# class TreeNode +# attr_accessor :val, :left, :right +# def initialize(val = 0, left = nil, right = nil) +# @val = val +# @left = left +# @right = right +# end +# end +# @param {TreeNode} root +# @return {TreeNode} +def prune_tree(root) + def traverse_and_remove(temp) + return false if temp.nil? + if temp.left.nil? && temp.right.nil? + return temp.val == 1 + end + left = traverse_and_remove(temp.left) + right = traverse_and_remove(temp.right) + temp.left = nil if !left + temp.right = nil if !right + return left || right || temp.val == 1 + end + + traverse_and_remove(root) + if root.left.nil? && root.right.nil? && root.val == 0 + return nil + end + return root +end diff --git a/tests/501-1000/814. binary-tree-pruning/sol.rs b/tests/501-1000/814. binary-tree-pruning/sol.rs new file mode 100644 index 00000000..cc271ed4 --- /dev/null +++ b/tests/501-1000/814. binary-tree-pruning/sol.rs @@ -0,0 +1,57 @@ +// Definition for a binary tree node. +// #[derive(Debug, PartialEq, Eq)] +// pub struct TreeNode { +// pub val: i32, +// pub left: Option>>, +// pub right: Option>>, +// } +// +// impl TreeNode { +// #[inline] +// pub fn new(val: i32) -> Self { +// TreeNode { +// val, +// left: None, +// right: None +// } +// } +// } +impl Solution { + pub fn prune_tree(root: Option>>) -> Option>> { + fn traverse_and_remove(temp: Option>>) -> bool { + match temp { + None => false, + Some(node) => { + let node_ref = node.borrow(); + if node_ref.left.is_none() && node_ref.right.is_none() { + return node_ref.val == 1; + } + drop(node_ref); + + let mut node_mut = node.borrow_mut(); + let left = traverse_and_remove(node_mut.left.clone()); + let right = traverse_and_remove(node_mut.right.clone()); + if !left { + node_mut.left = None; + } + if !right { + node_mut.right = None; + } + left || right || node_mut.val == 1 + } + } + } + + traverse_and_remove(root.clone()); + match root { + Some(ref node) => { + let node_ref = node.borrow(); + if node_ref.left.is_none() && node_ref.right.is_none() && node_ref.val == 0 { + return None; + } + } + None => {} + } + root + } +} diff --git a/tests/501-1000/814. binary-tree-pruning/sol.swift b/tests/501-1000/814. binary-tree-pruning/sol.swift new file mode 100644 index 00000000..fac9abc2 --- /dev/null +++ b/tests/501-1000/814. binary-tree-pruning/sol.swift @@ -0,0 +1,32 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public var val: Int + * public var left: TreeNode? + * public var right: TreeNode? + * public init() { self.val = 0; self.left = nil; self.right = nil; } + * public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; } + * public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) { + * self.val = val + * self.left = left + * self.right = right + * } + * } + */ +class Solution { + func pruneTree(_ root: TreeNode?) -> TreeNode? { + func prune(_ node: TreeNode?) -> TreeNode? { + guard let node = node else { + return nil + } + let left = prune(node.left) + let right = prune(node.right) + if node.val == 0 && left == nil && right == nil { + return nil + } + return TreeNode(node.val, left, right) + } + + return prune(root) + } +} diff --git a/tests/501-1000/814. binary-tree-pruning/sol.ts b/tests/501-1000/814. binary-tree-pruning/sol.ts new file mode 100644 index 00000000..10b89b6f --- /dev/null +++ b/tests/501-1000/814. binary-tree-pruning/sol.ts @@ -0,0 +1,44 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ + +function pruneTree(root: TreeNode | null): TreeNode | null { + function traverseAndRemove(temp: TreeNode | null): boolean { + if (temp === null) { + return false; + } + if (temp.left === null && temp.right === null) { + return temp.val === 1; + } + const left = traverseAndRemove(temp.left); + const right = traverseAndRemove(temp.right); + if (!left) { + temp.left = null; + } + if (!right) { + temp.right = null; + } + return left || right || temp.val === 1; + } + + traverseAndRemove(root); + if ( + root !== null && + root.left === null && + root.right === null && + root.val === 0 + ) { + return null; + } + return root; +} diff --git a/tests/501-1000/815. bus-routes/manifest.yaml b/tests/501-1000/815. bus-routes/manifest.yaml new file mode 100644 index 00000000..2488eb99 --- /dev/null +++ b/tests/501-1000/815. bus-routes/manifest.yaml @@ -0,0 +1,535 @@ +entry: + id: 815 + title: bus-routes + params: + routes: + type: array + items: + type: array + items: + type: int + source: + type: int + target: + type: int + call: + cpp: Solution().numBusesToDestination({routes}, {source}, {target}) + rust: Solution::num_buses_to_destination({routes}, {source}, {target}) + python3: Solution().numBusesToDestination({routes}, {source}, {target}) + python2: Solution().numBusesToDestination({routes}, {source}, {target}) + ruby: num_buses_to_destination({routes}, {source}, {target}) + java: new Solution().numBusesToDestination({routes}, {source}, {target}) + csharp: new Solution().NumBusesToDestination({routes}, {source}, {target}) + kotlin: Solution().numBusesToDestination({routes}, {source}, {target}) + go: numBusesToDestination({routes}, {source}, {target}) + dart: Solution().numBusesToDestination({routes}, {source}, {target}) + swift: Solution().numBusesToDestination({routes}, {source}, {target}) + typescript: numBusesToDestination({routes}, {source}, {target}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check(routes, source, target, {result}) + checker: | + from collections import defaultdict, deque + + class Checker: + def check(self, routes, source, target, result): + if source == target: + return result == 0 + adj = defaultdict(set) + for bus, locations in enumerate(routes): + for location in locations: + adj[location].add(bus) + queue = deque(adj[target]) + visited = set() + cost = 0 + while queue: + cost += 1 + for _ in range(len(queue)): + node = queue.popleft() + if node in visited: + continue + visited.add(node) + if source in routes[node]: + return result == cost + for location in routes[node]: + for bus in adj[location]: + if bus not in visited: + queue.append(bus) + return result == -1 +seed: 815 +tests: + - name: example-1 + in: + routes: + - - 1 + - 2 + - 7 + - - 3 + - 6 + - 7 + source: 1 + target: 6 + - name: example-2 + in: + routes: + - - 7 + - 12 + - - 4 + - 5 + - 15 + - - 6 + - - 15 + - 19 + - - 9 + - 12 + - 13 + source: 15 + target: 12 + - name: same-source-target + in: + routes: + - - 1 + - 2 + - 3 + source: 2 + target: 2 + - name: direct-one-bus + in: + routes: + - - 1 + - 5 + - 7 + - - 9 + - 10 + source: 1 + target: 7 + - name: two-buses-chain + in: + routes: + - - 1 + - 2 + - 7 + - - 7 + - 8 + - 9 + - - 9 + - 10 + source: 1 + target: 10 + - name: no-path-disconnected + in: + routes: + - - 1 + - 2 + - 3 + - - 4 + - 5 + - 6 + source: 1 + target: 6 + - name: multiple-intersections + in: + routes: + - - 1 + - 2 + - 3 + - 4 + - - 4 + - 5 + - 6 + - - 6 + - 7 + - 8 + - - 8 + - 9 + - 10 + source: 1 + target: 10 + - name: source-on-later-bus + in: + routes: + - - 11 + - 12 + - 13 + - - 1 + - 2 + - 11 + - - 13 + - 14 + - 15 + source: 1 + target: 15 + - name: target-unreachable-but-present + in: + routes: + - - 100 + - 200 + - - 300 + - 400 + - - 500 + - 600 + source: 100 + target: 500 + - name: hub-and-spokes + in: + routes: + - - 1 + - 9 + - - 2 + - 9 + - - 3 + - 9 + - - 4 + - 9 + source: 1 + target: 4 + - name: repeated-stop-on-many-routes + in: + routes: + - - 1 + - 5 + - 9 + - - 9 + - 13 + - 17 + - - 17 + - 21 + - 25 + - - 25 + - 29 + - 33 + source: 1 + target: 33 + - name: longer-chain + in: + routes: + - - 1 + - 2 + - - 2 + - 3 + - - 3 + - 4 + - - 4 + - 5 + - - 5 + - 6 + source: 1 + target: 6 + - name: one-bus-many-stops + in: + routes: + - - 1 + - 3 + - 5 + - 7 + - 9 + - 11 + source: 3 + target: 11 + - name: overlapping-with-detour + in: + routes: + - - 1 + - 2 + - 3 + - - 3 + - 4 + - 5 + - - 5 + - 6 + - 7 + - - 2 + - 8 + - 9 + source: 1 + target: 7 + - name: source-only-route + in: + routes: + - - 1 + - 4 + - 7 + - - 2 + - 5 + - 8 + source: 4 + target: 8 + - name: target-on-source-route + in: + routes: + - - 10 + - 20 + - 30 + - - 30 + - 40 + source: 10 + target: 30 + - name: two-hop-through-hub + in: + routes: + - - 1 + - 2 + - - 2 + - 3 + - - 3 + - 4 + source: 1 + target: 4 + - name: long-spoke-chain + in: + routes: + - - 5 + - 6 + - 7 + - - 7 + - 8 + - 9 + - - 9 + - 10 + - 11 + - - 11 + - 12 + - 13 + source: 5 + target: 13 + - name: sparse-disconnected-many + in: + routes: + - - 1 + - 100 + - - 200 + - 300 + - - 400 + - 500 + - - 600 + - 700 + source: 1 + target: 700 + - name: shared-stop-ladder + in: + routes: + - - 1 + - 9 + - - 9 + - 10 + - - 10 + - 11 + - - 11 + - 12 + source: 1 + target: 12 + - name: branching-via-middle + in: + routes: + - - 1 + - 2 + - 3 + - - 3 + - 6 + - 9 + - - 9 + - 12 + - 15 + - - 2 + - 8 + - 14 + source: 1 + target: 15 + - name: cycle-like-overlap + in: + routes: + - - 1 + - 2 + - 3 + - - 3 + - 4 + - 5 + - - 5 + - 1 + - 6 + source: 2 + target: 6 + - name: route-with-target-as-source-hop + in: + routes: + - - 7 + - 8 + - 9 + - - 9 + - 10 + - 11 + - - 11 + - 12 + - 13 + source: 7 + target: 13 + - name: isolated-source + in: + routes: + - - 1 + - 2 + - 3 + - - 4 + - 5 + - 6 + source: 9 + target: 6 + - name: isolated-target + in: + routes: + - - 1 + - 2 + - 3 + - - 4 + - 5 + - 6 + source: 1 + target: 9 + - name: zero-stop-values + in: + routes: + - - 0 + - 1 + - 2 + - - 2 + - 3 + - 4 + source: 0 + target: 4 + - name: many-small-routes + in: + routes: + - - 1 + - 2 + - - 2 + - 3 + - - 3 + - 4 + - - 4 + - 5 + - - 5 + - 6 + - - 6 + - 7 + source: 1 + target: 7 + - name: shared-target-hub + in: + routes: + - - 1 + - 8 + - - 2 + - 8 + - - 3 + - 8 + - - 4 + - 8 + - - 5 + - 8 + source: 1 + target: 5 + - name: source-and-target-appear-multiple-times + in: + routes: + - - 1 + - 2 + - 3 + - 4 + - - 4 + - 5 + - 6 + - 7 + - - 7 + - 8 + - 9 + - 1 + source: 2 + target: 9 + - name: long-route-direct + in: + routes: + - - 1 + - 3 + - 5 + - 7 + - 9 + - 11 + - 13 + - 15 + source: 1 + target: 15 + - name: dense-overlap + in: + routes: + - - 1 + - 2 + - 3 + - - 2 + - 3 + - 4 + - - 3 + - 4 + - 5 + - - 5 + - 6 + - 7 + source: 1 + target: 7 + - name: late-start-shortcut + in: + routes: + - - 10 + - 20 + - 30 + - - 30 + - 40 + - 50 + - - 50 + - 60 + - 70 + - - 70 + - 80 + - 90 + source: 20 + target: 90 + - name: three-hop-middle + in: + routes: + - - 1 + - 2 + - 3 + - - 3 + - 6 + - 9 + - - 9 + - 12 + - 15 + source: 1 + target: 15 + - name: unreachable-after-one-hop + in: + routes: + - - 1 + - 5 + - - 5 + - 9 + - - 20 + - 30 + source: 1 + target: 30 + - name: direct-via-shared-stop + in: + routes: + - - 1 + - 2 + - 3 + - - 3 + - 4 + - 5 + source: 1 + target: 5 diff --git a/tests/501-1000/815. bus-routes/sol.cpp b/tests/501-1000/815. bus-routes/sol.cpp new file mode 100644 index 00000000..4f5c39de --- /dev/null +++ b/tests/501-1000/815. bus-routes/sol.cpp @@ -0,0 +1,38 @@ +class Solution { +public: + int numBusesToDestination(vector>& routes, int source, int target) { + if (source == target) return 0; + unordered_map> adj; + for (int bus = 0; bus < routes.size(); bus++) { + for (int location : routes[bus]) { + adj[location].insert(bus); + } + } + queue q; + for (int bus : adj[target]) { + q.push(bus); + } + int cost = 0; + unordered_set visited; + while (!q.empty()) { + cost++; + int size = q.size(); + for (int i = 0; i < size; i++) { + int node = q.front(); + q.pop(); + visited.insert(node); + for (int location : routes[node]) { + if (location == source) return cost; + } + for (int location : routes[node]) { + for (int bus : adj[location]) { + if (visited.find(bus) == visited.end()) { + q.push(bus); + } + } + } + } + } + return -1; + } +}; diff --git a/tests/501-1000/815. bus-routes/sol.cs b/tests/501-1000/815. bus-routes/sol.cs new file mode 100644 index 00000000..b365cf8c --- /dev/null +++ b/tests/501-1000/815. bus-routes/sol.cs @@ -0,0 +1,39 @@ +public class Solution { + public int NumBusesToDestination(int[][] routes, int source, int target) { + if (source == target) return 0; + Dictionary> adj = new Dictionary>(); + for (int bus = 0; bus < routes.Length; bus++) { + foreach (int location in routes[bus]) { + if (!adj.ContainsKey(location)) adj[location] = new HashSet(); + adj[location].Add(bus); + } + } + Queue queue = new Queue(); + if (adj.ContainsKey(target)) { + foreach (int bus in adj[target]) { + queue.Enqueue(bus); + } + } + int cost = 0; + HashSet visited = new HashSet(); + while (queue.Count > 0) { + cost++; + int size = queue.Count; + for (int i = 0; i < size; i++) { + int node = queue.Dequeue(); + visited.Add(node); + if (Array.IndexOf(routes[node], source) != -1) return cost; + foreach (int location in routes[node]) { + if (adj.ContainsKey(location)) { + foreach (int bus in adj[location]) { + if (!visited.Contains(bus)) { + queue.Enqueue(bus); + } + } + } + } + } + } + return -1; + } +} diff --git a/tests/501-1000/815. bus-routes/sol.dart b/tests/501-1000/815. bus-routes/sol.dart new file mode 100644 index 00000000..9e457c46 --- /dev/null +++ b/tests/501-1000/815. bus-routes/sol.dart @@ -0,0 +1,32 @@ +class Solution { + int numBusesToDestination(List> routes, int source, int target) { + if (source == target) return 0; + Map> adj = {}; + for (int bus = 0; bus < routes.length; bus++) { + for (int location in routes[bus]) { + adj.putIfAbsent(location, () => {}); + adj[location]!.add(bus); + } + } + List queue = List.from(adj[target] ?? {}); + int cost = 0; + Set visited = {}; + while (queue.isNotEmpty) { + cost++; + int size = queue.length; + for (int i = 0; i < size; i++) { + int node = queue.removeAt(0); + visited.add(node); + if (routes[node].contains(source)) return cost; + for (int location in routes[node]) { + for (int bus in adj[location] ?? {}) { + if (!visited.contains(bus)) { + queue.add(bus); + } + } + } + } + } + return -1; + } +} diff --git a/tests/501-1000/815. bus-routes/sol.go b/tests/501-1000/815. bus-routes/sol.go new file mode 100644 index 00000000..a505173d --- /dev/null +++ b/tests/501-1000/815. bus-routes/sol.go @@ -0,0 +1,42 @@ +func numBusesToDestination(routes [][]int, source int, target int) int { + if source == target { + return 0 + } + adj := make(map[int]map[int]bool) + for bus, locations := range routes { + for _, location := range locations { + if adj[location] == nil { + adj[location] = make(map[int]bool) + } + adj[location][bus] = true + } + } + queue := make([]int, 0) + for bus := range adj[target] { + queue = append(queue, bus) + } + cost := 0 + visited := make(map[int]bool) + for len(queue) > 0 { + cost++ + size := len(queue) + for i := 0; i < size; i++ { + node := queue[0] + queue = queue[1:] + visited[node] = true + for _, location := range routes[node] { + if location == source { + return cost + } + } + for _, location := range routes[node] { + for bus := range adj[location] { + if !visited[bus] { + queue = append(queue, bus) + } + } + } + } + } + return -1 +} diff --git a/tests/501-1000/815. bus-routes/sol.java b/tests/501-1000/815. bus-routes/sol.java new file mode 100644 index 00000000..40214856 --- /dev/null +++ b/tests/501-1000/815. bus-routes/sol.java @@ -0,0 +1,33 @@ +class Solution { + public int numBusesToDestination(int[][] routes, int source, int target) { + if (source == target) return 0; + Map> adj = new HashMap<>(); + for (int bus = 0; bus < routes.length; bus++) { + for (int location : routes[bus]) { + adj.computeIfAbsent(location, k -> new HashSet<>()).add(bus); + } + } + Queue queue = new LinkedList<>(adj.getOrDefault(target, new HashSet<>())); + int cost = 0; + Set visited = new HashSet<>(); + while (!queue.isEmpty()) { + cost++; + int size = queue.size(); + for (int i = 0; i < size; i++) { + int node = queue.poll(); + visited.add(node); + for (int location : routes[node]) { + if (location == source) return cost; + } + for (int location : routes[node]) { + for (int bus : adj.getOrDefault(location, new HashSet<>())) { + if (!visited.contains(bus)) { + queue.offer(bus); + } + } + } + } + } + return -1; + } +} diff --git a/tests/501-1000/815. bus-routes/sol.kt b/tests/501-1000/815. bus-routes/sol.kt new file mode 100644 index 00000000..cbd6cf32 --- /dev/null +++ b/tests/501-1000/815. bus-routes/sol.kt @@ -0,0 +1,30 @@ +class Solution { + fun numBusesToDestination(routes: Array, source: Int, target: Int): Int { + if (source == target) return 0 + val adj = mutableMapOf>() + for (bus in routes.indices) { + for (location in routes[bus]) { + adj.getOrPut(location) { mutableSetOf() }.add(bus) + } + } + val queue = ArrayDeque(adj[target] ?: emptySet()) + var cost = 0 + val visited = mutableSetOf() + while (queue.isNotEmpty()) { + cost++ + repeat(queue.size) { + val node = queue.removeFirst() + visited.add(node) + if (source in routes[node]) return cost + for (location in routes[node]) { + for (bus in adj[location] ?: emptySet()) { + if (bus !in visited) { + queue.add(bus) + } + } + } + } + } + return -1 + } +} diff --git a/tests/501-1000/815. bus-routes/sol.py b/tests/501-1000/815. bus-routes/sol.py new file mode 100644 index 00000000..b159f8b3 --- /dev/null +++ b/tests/501-1000/815. bus-routes/sol.py @@ -0,0 +1,31 @@ +class Solution: + def numBusesToDestination( + self, routes: List[List[int]], source: int, target: int + ) -> int: + if source == target: + return 0 + adj = defaultdict(set) + + for bus, locations in enumerate(routes): + for location in locations: + adj[location].add(bus) + + queue = deque(adj[target]) + cost = 0 + visited = set() + + while queue: + cost += 1 + for _ in range(len(queue)): + node = queue.popleft() + visited.add(node) + if source in routes[node]: + return cost + queue.extend( + bus + for location in routes[node] + for bus in adj[location] + if bus not in visited + ) + + return -1 diff --git a/tests/501-1000/815. bus-routes/sol.py2 b/tests/501-1000/815. bus-routes/sol.py2 new file mode 100644 index 00000000..49e79ed2 --- /dev/null +++ b/tests/501-1000/815. bus-routes/sol.py2 @@ -0,0 +1,30 @@ +class Solution(object): + def numBusesToDestination(self, routes, source, target): + """ + :type routes: List[List[int]] + :type source: int + :type target: int + :rtype: int + """ + if source == target: + return 0 + from collections import defaultdict, deque + adj = defaultdict(set) + for bus, locations in enumerate(routes): + for location in locations: + adj[location].add(bus) + queue = deque(adj[target]) + cost = 0 + visited = set() + while queue: + cost += 1 + for _ in range(len(queue)): + node = queue.popleft() + visited.add(node) + if source in routes[node]: + return cost + for location in routes[node]: + for bus in adj[location]: + if bus not in visited: + queue.append(bus) + return -1 diff --git a/tests/501-1000/815. bus-routes/sol.rb b/tests/501-1000/815. bus-routes/sol.rb new file mode 100644 index 00000000..b5aace27 --- /dev/null +++ b/tests/501-1000/815. bus-routes/sol.rb @@ -0,0 +1,30 @@ +# @param {Integer[][]} routes +# @param {Integer} source +# @param {Integer} target +# @return {Integer} +def num_buses_to_destination(routes, source, target) + return 0 if source == target + adj = Hash.new { |h, k| h[k] = Set.new } + routes.each_with_index do |locations, bus| + locations.each do |location| + adj[location].add(bus) + end + end + queue = adj[target].to_a + cost = 0 + visited = Set.new + while !queue.empty? + cost += 1 + queue.size.times do + node = queue.shift + visited.add(node) + return cost if routes[node].include?(source) + routes[node].each do |location| + adj[location].each do |bus| + queue.push(bus) unless visited.include?(bus) + end + end + end + end + -1 +end diff --git a/tests/501-1000/815. bus-routes/sol.rs b/tests/501-1000/815. bus-routes/sol.rs new file mode 100644 index 00000000..8482ad22 --- /dev/null +++ b/tests/501-1000/815. bus-routes/sol.rs @@ -0,0 +1,43 @@ +impl Solution { + pub fn num_buses_to_destination(routes: Vec>, source: i32, target: i32) -> i32 { + if source == target { + return 0; + } + use std::collections::{HashMap, HashSet, VecDeque}; + let mut adj: HashMap> = HashMap::new(); + for (bus, locations) in routes.iter().enumerate() { + for &location in locations { + adj.entry(location).or_insert_with(HashSet::new).insert(bus); + } + } + let mut queue: VecDeque = VecDeque::new(); + if let Some(buses) = adj.get(&target) { + for &bus in buses { + queue.push_back(bus); + } + } + let mut cost = 0; + let mut visited: HashSet = HashSet::new(); + while !queue.is_empty() { + cost += 1; + let size = queue.len(); + for _ in 0..size { + let node = queue.pop_front().unwrap(); + visited.insert(node); + if routes[node].contains(&source) { + return cost; + } + for &location in &routes[node] { + if let Some(buses) = adj.get(&location) { + for &bus in buses { + if !visited.contains(&bus) { + queue.push_back(bus); + } + } + } + } + } + } + -1 + } +} diff --git a/tests/501-1000/815. bus-routes/sol.swift b/tests/501-1000/815. bus-routes/sol.swift new file mode 100644 index 00000000..becdf289 --- /dev/null +++ b/tests/501-1000/815. bus-routes/sol.swift @@ -0,0 +1,33 @@ +class Solution { + func numBusesToDestination(_ routes: [[Int]], _ source: Int, _ target: Int) -> Int { + if source == target { return 0 } + var adj = [Int: Set]() + for (bus, locations) in routes.enumerated() { + for location in locations { + adj[location, default: []].insert(bus) + } + } + var queue = Array(adj[target] ?? []) + var cost = 0 + var visited = Set() + while !queue.isEmpty { + cost += 1 + let size = queue.count + for _ in 0..> = new Map(); + for (let bus = 0; bus < routes.length; bus++) { + for (const location of routes[bus]) { + if (!adj.has(location)) adj.set(location, new Set()); + adj.get(location)!.add(bus); + } + } + const queue: number[] = Array.from(adj.get(target) ?? []); + let cost = 0; + const visited: Set = new Set(); + while (queue.length > 0) { + cost++; + const size = queue.length; + for (let i = 0; i < size; i++) { + const node = queue.shift()!; + visited.add(node); + if (routes[node].includes(source)) return cost; + for (const location of routes[node]) { + for (const bus of adj.get(location) ?? []) { + if (!visited.has(bus)) { + queue.push(bus); + } + } + } + } + } + return -1; +} diff --git a/tests/501-1000/816. ambiguous-coordinates/manifest.yaml b/tests/501-1000/816. ambiguous-coordinates/manifest.yaml new file mode 100644 index 00000000..9b541faa --- /dev/null +++ b/tests/501-1000/816. ambiguous-coordinates/manifest.yaml @@ -0,0 +1,967 @@ +entry: + id: 816 + title: ambiguous-coordinates + params: + s: + type: string + call: + cpp: Solution().ambiguousCoordinates({s}) + rust: Solution::ambiguous_coordinates({s}) + python3: Solution().ambiguousCoordinates({s}) + python2: Solution().ambiguousCoordinates({s}) + ruby: ambiguous_coordinates({s}) + java: new Solution().ambiguousCoordinates({s}) + csharp: new Solution().AmbiguousCoordinates({s}) + kotlin: Solution().ambiguousCoordinates({s}) + go: ambiguousCoordinates({s}) + dart: Solution().ambiguousCoordinates({s}) + swift: Solution().ambiguousCoordinates({s}) + typescript: ambiguousCoordinates({s}) +judge: + type: ignore_order +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: | + class Checker: + def check(self, result): + return True +seed: 816 +tests: + - name: example-1 + in: + s: (123) + out: + - (1, 2.3) + - (1, 23) + - (1.2, 3) + - (12, 3) + - name: example-2 + in: + s: (0123) + out: + - (0, 1.23) + - (0, 12.3) + - (0, 123) + - (0.1, 2.3) + - (0.1, 23) + - (0.12, 3) + - name: example-3 + in: + s: (00011) + out: + - (0, 0.011) + - (0.001, 1) + - name: smallest-valid + in: + s: (10) + out: + - (1, 0) + - name: all-zeros + in: + s: (0000) + out: [] + - name: leading-zero-middle + in: + s: (010) + out: + - (0, 10) + - (0.1, 0) + - name: mixed-1234 + in: + s: (1234) + out: + - (1, 2.34) + - (1, 23.4) + - (1, 234) + - (1.2, 3.4) + - (1.2, 34) + - (1.23, 4) + - (12, 3.4) + - (12, 34) + - (12.3, 4) + - (123, 4) + - name: mixed-5678 + in: + s: (5678) + out: + - (5, 6.78) + - (5, 67.8) + - (5, 678) + - (5.6, 7.8) + - (5.6, 78) + - (5.67, 8) + - (56, 7.8) + - (56, 78) + - (56.7, 8) + - (567, 8) + - name: long-9digits + in: + s: (123456789) + out: + - (1, 2.3456789) + - (1, 23.456789) + - (1, 234.56789) + - (1, 2345.6789) + - (1, 23456.789) + - (1, 234567.89) + - (1, 2345678.9) + - (1, 23456789) + - (1.2, 3.456789) + - (1.2, 34.56789) + - (1.2, 345.6789) + - (1.2, 3456.789) + - (1.2, 34567.89) + - (1.2, 345678.9) + - (1.2, 3456789) + - (1.23, 4.56789) + - (1.23, 45.6789) + - (1.23, 456.789) + - (1.23, 4567.89) + - (1.23, 45678.9) + - (1.23, 456789) + - (1.234, 5.6789) + - (1.234, 56.789) + - (1.234, 567.89) + - (1.234, 5678.9) + - (1.234, 56789) + - (1.2345, 6.789) + - (1.2345, 67.89) + - (1.2345, 678.9) + - (1.2345, 6789) + - (1.23456, 7.89) + - (1.23456, 78.9) + - (1.23456, 789) + - (1.234567, 8.9) + - (1.234567, 89) + - (1.2345678, 9) + - (12, 3.456789) + - (12, 34.56789) + - (12, 345.6789) + - (12, 3456.789) + - (12, 34567.89) + - (12, 345678.9) + - (12, 3456789) + - (12.3, 4.56789) + - (12.3, 45.6789) + - (12.3, 456.789) + - (12.3, 4567.89) + - (12.3, 45678.9) + - (12.3, 456789) + - (12.34, 5.6789) + - (12.34, 56.789) + - (12.34, 567.89) + - (12.34, 5678.9) + - (12.34, 56789) + - (12.345, 6.789) + - (12.345, 67.89) + - (12.345, 678.9) + - (12.345, 6789) + - (12.3456, 7.89) + - (12.3456, 78.9) + - (12.3456, 789) + - (12.34567, 8.9) + - (12.34567, 89) + - (12.345678, 9) + - (123, 4.56789) + - (123, 45.6789) + - (123, 456.789) + - (123, 4567.89) + - (123, 45678.9) + - (123, 456789) + - (123.4, 5.6789) + - (123.4, 56.789) + - (123.4, 567.89) + - (123.4, 5678.9) + - (123.4, 56789) + - (123.45, 6.789) + - (123.45, 67.89) + - (123.45, 678.9) + - (123.45, 6789) + - (123.456, 7.89) + - (123.456, 78.9) + - (123.456, 789) + - (123.4567, 8.9) + - (123.4567, 89) + - (123.45678, 9) + - (1234, 5.6789) + - (1234, 56.789) + - (1234, 567.89) + - (1234, 5678.9) + - (1234, 56789) + - (1234.5, 6.789) + - (1234.5, 67.89) + - (1234.5, 678.9) + - (1234.5, 6789) + - (1234.56, 7.89) + - (1234.56, 78.9) + - (1234.56, 789) + - (1234.567, 8.9) + - (1234.567, 89) + - (1234.5678, 9) + - (12345, 6.789) + - (12345, 67.89) + - (12345, 678.9) + - (12345, 6789) + - (12345.6, 7.89) + - (12345.6, 78.9) + - (12345.6, 789) + - (12345.67, 8.9) + - (12345.67, 89) + - (12345.678, 9) + - (123456, 7.89) + - (123456, 78.9) + - (123456, 789) + - (123456.7, 8.9) + - (123456.7, 89) + - (123456.78, 9) + - (1234567, 8.9) + - (1234567, 89) + - (1234567.8, 9) + - (12345678, 9) + - name: long-with-zero + in: + s: (1002003) + out: + - (1, 0.02003) + - (1.002, 0.03) + - (10, 0.2003) + - (10.02, 0.03) + - (100, 2.003) + - (100, 20.03) + - (100, 200.3) + - (100, 2003) + - (100.2, 0.03) + - (1002, 0.03) + - (10020, 0.3) + - (100200, 3) + - name: no-decimal-right + in: + s: (1010) + out: + - (1.01, 0) + - (10, 10) + - (10.1, 0) + - (101, 0) + - name: minimal-length-4 + in: + s: (1111) + out: + - (1, 1.11) + - (1, 11.1) + - (1, 111) + - (1.1, 1.1) + - (1.1, 11) + - (1.11, 1) + - (11, 1.1) + - (11, 11) + - (11.1, 1) + - (111, 1) + - name: trailing-zero-block + in: + s: (1200) + out: + - (1, 200) + - (120, 0) + - name: mixed-zeros-and-nonzeros + in: + s: (10001) + out: + - (1, 0.001) + - (10, 0.01) + - (100, 0.1) + - (1000, 1) + - name: max-length-ish + in: + s: (3141592653) + out: + - (3, 1.41592653) + - (3, 14.1592653) + - (3, 141.592653) + - (3, 1415.92653) + - (3, 14159.2653) + - (3, 141592.653) + - (3, 1415926.53) + - (3, 14159265.3) + - (3, 141592653) + - (3.1, 4.1592653) + - (3.1, 41.592653) + - (3.1, 415.92653) + - (3.1, 4159.2653) + - (3.1, 41592.653) + - (3.1, 415926.53) + - (3.1, 4159265.3) + - (3.1, 41592653) + - (3.14, 1.592653) + - (3.14, 15.92653) + - (3.14, 159.2653) + - (3.14, 1592.653) + - (3.14, 15926.53) + - (3.14, 159265.3) + - (3.14, 1592653) + - (3.141, 5.92653) + - (3.141, 59.2653) + - (3.141, 592.653) + - (3.141, 5926.53) + - (3.141, 59265.3) + - (3.141, 592653) + - (3.1415, 9.2653) + - (3.1415, 92.653) + - (3.1415, 926.53) + - (3.1415, 9265.3) + - (3.1415, 92653) + - (3.14159, 2.653) + - (3.14159, 26.53) + - (3.14159, 265.3) + - (3.14159, 2653) + - (3.141592, 6.53) + - (3.141592, 65.3) + - (3.141592, 653) + - (3.1415926, 5.3) + - (3.1415926, 53) + - (3.14159265, 3) + - (31, 4.1592653) + - (31, 41.592653) + - (31, 415.92653) + - (31, 4159.2653) + - (31, 41592.653) + - (31, 415926.53) + - (31, 4159265.3) + - (31, 41592653) + - (31.4, 1.592653) + - (31.4, 15.92653) + - (31.4, 159.2653) + - (31.4, 1592.653) + - (31.4, 15926.53) + - (31.4, 159265.3) + - (31.4, 1592653) + - (31.41, 5.92653) + - (31.41, 59.2653) + - (31.41, 592.653) + - (31.41, 5926.53) + - (31.41, 59265.3) + - (31.41, 592653) + - (31.415, 9.2653) + - (31.415, 92.653) + - (31.415, 926.53) + - (31.415, 9265.3) + - (31.415, 92653) + - (31.4159, 2.653) + - (31.4159, 26.53) + - (31.4159, 265.3) + - (31.4159, 2653) + - (31.41592, 6.53) + - (31.41592, 65.3) + - (31.41592, 653) + - (31.415926, 5.3) + - (31.415926, 53) + - (31.4159265, 3) + - (314, 1.592653) + - (314, 15.92653) + - (314, 159.2653) + - (314, 1592.653) + - (314, 15926.53) + - (314, 159265.3) + - (314, 1592653) + - (314.1, 5.92653) + - (314.1, 59.2653) + - (314.1, 592.653) + - (314.1, 5926.53) + - (314.1, 59265.3) + - (314.1, 592653) + - (314.15, 9.2653) + - (314.15, 92.653) + - (314.15, 926.53) + - (314.15, 9265.3) + - (314.15, 92653) + - (314.159, 2.653) + - (314.159, 26.53) + - (314.159, 265.3) + - (314.159, 2653) + - (314.1592, 6.53) + - (314.1592, 65.3) + - (314.1592, 653) + - (314.15926, 5.3) + - (314.15926, 53) + - (314.159265, 3) + - (3141, 5.92653) + - (3141, 59.2653) + - (3141, 592.653) + - (3141, 5926.53) + - (3141, 59265.3) + - (3141, 592653) + - (3141.5, 9.2653) + - (3141.5, 92.653) + - (3141.5, 926.53) + - (3141.5, 9265.3) + - (3141.5, 92653) + - (3141.59, 2.653) + - (3141.59, 26.53) + - (3141.59, 265.3) + - (3141.59, 2653) + - (3141.592, 6.53) + - (3141.592, 65.3) + - (3141.592, 653) + - (3141.5926, 5.3) + - (3141.5926, 53) + - (3141.59265, 3) + - (31415, 9.2653) + - (31415, 92.653) + - (31415, 926.53) + - (31415, 9265.3) + - (31415, 92653) + - (31415.9, 2.653) + - (31415.9, 26.53) + - (31415.9, 265.3) + - (31415.9, 2653) + - (31415.92, 6.53) + - (31415.92, 65.3) + - (31415.92, 653) + - (31415.926, 5.3) + - (31415.926, 53) + - (31415.9265, 3) + - (314159, 2.653) + - (314159, 26.53) + - (314159, 265.3) + - (314159, 2653) + - (314159.2, 6.53) + - (314159.2, 65.3) + - (314159.2, 653) + - (314159.26, 5.3) + - (314159.26, 53) + - (314159.265, 3) + - (3141592, 6.53) + - (3141592, 65.3) + - (3141592, 653) + - (3141592.6, 5.3) + - (3141592.6, 53) + - (3141592.65, 3) + - (31415926, 5.3) + - (31415926, 53) + - (31415926.5, 3) + - (314159265, 3) + - name: zeros-around-one + in: + s: (00100) + out: [] + - name: palindrome + in: + s: (1221) + out: + - (1, 2.21) + - (1, 22.1) + - (1, 221) + - (1.2, 2.1) + - (1.2, 21) + - (1.22, 1) + - (12, 2.1) + - (12, 21) + - (12.2, 1) + - (122, 1) + - name: simple-pair + in: + s: (11) + out: + - (1, 1) + - name: simple-three + in: + s: (121) + out: + - (1, 2.1) + - (1, 21) + - (1.2, 1) + - (12, 1) + - name: zero-center + in: + s: (101) + out: + - (1, 0.1) + - (10, 1) + - name: zero-front + in: + s: (100) + out: + - (10, 0) + - name: zero-tail + in: + s: (1100) + out: + - (1, 100) + - (110, 0) + - name: many-ones + in: + s: (11111) + out: + - (1, 1.111) + - (1, 11.11) + - (1, 111.1) + - (1, 1111) + - (1.1, 1.11) + - (1.1, 11.1) + - (1.1, 111) + - (1.11, 1.1) + - (1.11, 11) + - (1.111, 1) + - (11, 1.11) + - (11, 11.1) + - (11, 111) + - (11.1, 1.1) + - (11.1, 11) + - (11.11, 1) + - (111, 1.1) + - (111, 11) + - (111.1, 1) + - (1111, 1) + - name: alternation + in: + s: (9090) + out: + - (9.09, 0) + - (90, 90) + - (90.9, 0) + - (909, 0) + - name: alternating-zeroes + in: + s: (90909) + out: + - (9, 0.909) + - (9.09, 0.9) + - (90, 9.09) + - (90, 90.9) + - (90, 909) + - (90.9, 0.9) + - (909, 0.9) + - (9090, 9) + - name: repeated-digits + in: + s: (22222) + out: + - (2, 2.222) + - (2, 22.22) + - (2, 222.2) + - (2, 2222) + - (2.2, 2.22) + - (2.2, 22.2) + - (2.2, 222) + - (2.22, 2.2) + - (2.22, 22) + - (2.222, 2) + - (22, 2.22) + - (22, 22.2) + - (22, 222) + - (22.2, 2.2) + - (22.2, 22) + - (22.22, 2) + - (222, 2.2) + - (222, 22) + - (222.2, 2) + - (2222, 2) + - name: ascending-with-zero + in: + s: (12034) + out: + - (1, 2.034) + - (1, 20.34) + - (1, 203.4) + - (1, 2034) + - (1.2, 0.34) + - (1.203, 4) + - (12, 0.34) + - (12.03, 4) + - (120, 3.4) + - (120, 34) + - (120.3, 4) + - (1203, 4) + - name: descending-with-zero + in: + s: (54320) + out: + - (5, 4320) + - (5.4, 320) + - (5.43, 20) + - (5.432, 0) + - (54, 320) + - (54.3, 20) + - (54.32, 0) + - (543, 20) + - (543.2, 0) + - (5432, 0) + - name: small-mixed + in: + s: (2468) + out: + - (2, 4.68) + - (2, 46.8) + - (2, 468) + - (2.4, 6.8) + - (2.4, 68) + - (2.46, 8) + - (24, 6.8) + - (24, 68) + - (24.6, 8) + - (246, 8) + - name: small-mixed-2 + in: + s: (1357) + out: + - (1, 3.57) + - (1, 35.7) + - (1, 357) + - (1.3, 5.7) + - (1.3, 57) + - (1.35, 7) + - (13, 5.7) + - (13, 57) + - (13.5, 7) + - (135, 7) + - name: wide-range + in: + s: (123450) + out: + - (1, 23450) + - (1.2, 3450) + - (1.23, 450) + - (1.234, 50) + - (1.2345, 0) + - (12, 3450) + - (12.3, 450) + - (12.34, 50) + - (12.345, 0) + - (123, 450) + - (123.4, 50) + - (123.45, 0) + - (1234, 50) + - (1234.5, 0) + - (12345, 0) + - name: inner-zero + in: + s: (10010) + out: + - (1.001, 0) + - (10.01, 0) + - (100, 10) + - (100.1, 0) + - (1001, 0) + - name: double-zero-center + in: + s: (100010) + out: + - (1.0001, 0) + - (10.001, 0) + - (100.01, 0) + - (1000, 10) + - (1000.1, 0) + - (10001, 0) + - name: long-no-zero + in: + s: (987654321) + out: + - (9, 8.7654321) + - (9, 87.654321) + - (9, 876.54321) + - (9, 8765.4321) + - (9, 87654.321) + - (9, 876543.21) + - (9, 8765432.1) + - (9, 87654321) + - (9.8, 7.654321) + - (9.8, 76.54321) + - (9.8, 765.4321) + - (9.8, 7654.321) + - (9.8, 76543.21) + - (9.8, 765432.1) + - (9.8, 7654321) + - (9.87, 6.54321) + - (9.87, 65.4321) + - (9.87, 654.321) + - (9.87, 6543.21) + - (9.87, 65432.1) + - (9.87, 654321) + - (9.876, 5.4321) + - (9.876, 54.321) + - (9.876, 543.21) + - (9.876, 5432.1) + - (9.876, 54321) + - (9.8765, 4.321) + - (9.8765, 43.21) + - (9.8765, 432.1) + - (9.8765, 4321) + - (9.87654, 3.21) + - (9.87654, 32.1) + - (9.87654, 321) + - (9.876543, 2.1) + - (9.876543, 21) + - (9.8765432, 1) + - (98, 7.654321) + - (98, 76.54321) + - (98, 765.4321) + - (98, 7654.321) + - (98, 76543.21) + - (98, 765432.1) + - (98, 7654321) + - (98.7, 6.54321) + - (98.7, 65.4321) + - (98.7, 654.321) + - (98.7, 6543.21) + - (98.7, 65432.1) + - (98.7, 654321) + - (98.76, 5.4321) + - (98.76, 54.321) + - (98.76, 543.21) + - (98.76, 5432.1) + - (98.76, 54321) + - (98.765, 4.321) + - (98.765, 43.21) + - (98.765, 432.1) + - (98.765, 4321) + - (98.7654, 3.21) + - (98.7654, 32.1) + - (98.7654, 321) + - (98.76543, 2.1) + - (98.76543, 21) + - (98.765432, 1) + - (987, 6.54321) + - (987, 65.4321) + - (987, 654.321) + - (987, 6543.21) + - (987, 65432.1) + - (987, 654321) + - (987.6, 5.4321) + - (987.6, 54.321) + - (987.6, 543.21) + - (987.6, 5432.1) + - (987.6, 54321) + - (987.65, 4.321) + - (987.65, 43.21) + - (987.65, 432.1) + - (987.65, 4321) + - (987.654, 3.21) + - (987.654, 32.1) + - (987.654, 321) + - (987.6543, 2.1) + - (987.6543, 21) + - (987.65432, 1) + - (9876, 5.4321) + - (9876, 54.321) + - (9876, 543.21) + - (9876, 5432.1) + - (9876, 54321) + - (9876.5, 4.321) + - (9876.5, 43.21) + - (9876.5, 432.1) + - (9876.5, 4321) + - (9876.54, 3.21) + - (9876.54, 32.1) + - (9876.54, 321) + - (9876.543, 2.1) + - (9876.543, 21) + - (9876.5432, 1) + - (98765, 4.321) + - (98765, 43.21) + - (98765, 432.1) + - (98765, 4321) + - (98765.4, 3.21) + - (98765.4, 32.1) + - (98765.4, 321) + - (98765.43, 2.1) + - (98765.43, 21) + - (98765.432, 1) + - (987654, 3.21) + - (987654, 32.1) + - (987654, 321) + - (987654.3, 2.1) + - (987654.3, 21) + - (987654.32, 1) + - (9876543, 2.1) + - (9876543, 21) + - (9876543.2, 1) + - (98765432, 1) + - name: long-leading-one + in: + s: (1020304050) + out: + - (1.02030405, 0) + - (10, 20304050) + - (10.2030405, 0) + - (102.030405, 0) + - (1020, 304050) + - (1020.30405, 0) + - (10203.0405, 0) + - (102030, 4050) + - (102030.405, 0) + - (1020304.05, 0) + - (10203040, 50) + - (10203040.5, 0) + - (102030405, 0) + - name: long-mixed + in: + s: (2718281828) + out: + - (2, 7.18281828) + - (2, 71.8281828) + - (2, 718.281828) + - (2, 7182.81828) + - (2, 71828.1828) + - (2, 718281.828) + - (2, 7182818.28) + - (2, 71828182.8) + - (2, 718281828) + - (2.7, 1.8281828) + - (2.7, 18.281828) + - (2.7, 182.81828) + - (2.7, 1828.1828) + - (2.7, 18281.828) + - (2.7, 182818.28) + - (2.7, 1828182.8) + - (2.7, 18281828) + - (2.71, 8.281828) + - (2.71, 82.81828) + - (2.71, 828.1828) + - (2.71, 8281.828) + - (2.71, 82818.28) + - (2.71, 828182.8) + - (2.71, 8281828) + - (2.718, 2.81828) + - (2.718, 28.1828) + - (2.718, 281.828) + - (2.718, 2818.28) + - (2.718, 28182.8) + - (2.718, 281828) + - (2.7182, 8.1828) + - (2.7182, 81.828) + - (2.7182, 818.28) + - (2.7182, 8182.8) + - (2.7182, 81828) + - (2.71828, 1.828) + - (2.71828, 18.28) + - (2.71828, 182.8) + - (2.71828, 1828) + - (2.718281, 8.28) + - (2.718281, 82.8) + - (2.718281, 828) + - (2.7182818, 2.8) + - (2.7182818, 28) + - (2.71828182, 8) + - (27, 1.8281828) + - (27, 18.281828) + - (27, 182.81828) + - (27, 1828.1828) + - (27, 18281.828) + - (27, 182818.28) + - (27, 1828182.8) + - (27, 18281828) + - (27.1, 8.281828) + - (27.1, 82.81828) + - (27.1, 828.1828) + - (27.1, 8281.828) + - (27.1, 82818.28) + - (27.1, 828182.8) + - (27.1, 8281828) + - (27.18, 2.81828) + - (27.18, 28.1828) + - (27.18, 281.828) + - (27.18, 2818.28) + - (27.18, 28182.8) + - (27.18, 281828) + - (27.182, 8.1828) + - (27.182, 81.828) + - (27.182, 818.28) + - (27.182, 8182.8) + - (27.182, 81828) + - (27.1828, 1.828) + - (27.1828, 18.28) + - (27.1828, 182.8) + - (27.1828, 1828) + - (27.18281, 8.28) + - (27.18281, 82.8) + - (27.18281, 828) + - (27.182818, 2.8) + - (27.182818, 28) + - (27.1828182, 8) + - (271, 8.281828) + - (271, 82.81828) + - (271, 828.1828) + - (271, 8281.828) + - (271, 82818.28) + - (271, 828182.8) + - (271, 8281828) + - (271.8, 2.81828) + - (271.8, 28.1828) + - (271.8, 281.828) + - (271.8, 2818.28) + - (271.8, 28182.8) + - (271.8, 281828) + - (271.82, 8.1828) + - (271.82, 81.828) + - (271.82, 818.28) + - (271.82, 8182.8) + - (271.82, 81828) + - (271.828, 1.828) + - (271.828, 18.28) + - (271.828, 182.8) + - (271.828, 1828) + - (271.8281, 8.28) + - (271.8281, 82.8) + - (271.8281, 828) + - (271.82818, 2.8) + - (271.82818, 28) + - (271.828182, 8) + - (2718, 2.81828) + - (2718, 28.1828) + - (2718, 281.828) + - (2718, 2818.28) + - (2718, 28182.8) + - (2718, 281828) + - (2718.2, 8.1828) + - (2718.2, 81.828) + - (2718.2, 818.28) + - (2718.2, 8182.8) + - (2718.2, 81828) + - (2718.28, 1.828) + - (2718.28, 18.28) + - (2718.28, 182.8) + - (2718.28, 1828) + - (2718.281, 8.28) + - (2718.281, 82.8) + - (2718.281, 828) + - (2718.2818, 2.8) + - (2718.2818, 28) + - (2718.28182, 8) + - (27182, 8.1828) + - (27182, 81.828) + - (27182, 818.28) + - (27182, 8182.8) + - (27182, 81828) + - (27182.8, 1.828) + - (27182.8, 18.28) + - (27182.8, 182.8) + - (27182.8, 1828) + - (27182.81, 8.28) + - (27182.81, 82.8) + - (27182.81, 828) + - (27182.818, 2.8) + - (27182.818, 28) + - (27182.8182, 8) + - (271828, 1.828) + - (271828, 18.28) + - (271828, 182.8) + - (271828, 1828) + - (271828.1, 8.28) + - (271828.1, 82.8) + - (271828.1, 828) + - (271828.18, 2.8) + - (271828.18, 28) + - (271828.182, 8) + - (2718281, 8.28) + - (2718281, 82.8) + - (2718281, 828) + - (2718281.8, 2.8) + - (2718281.8, 28) + - (2718281.82, 8) + - (27182818, 2.8) + - (27182818, 28) + - (27182818.2, 8) + - (271828182, 8) diff --git a/tests/501-1000/816. ambiguous-coordinates/sol.cpp b/tests/501-1000/816. ambiguous-coordinates/sol.cpp new file mode 100644 index 00000000..a28b664e --- /dev/null +++ b/tests/501-1000/816. ambiguous-coordinates/sol.cpp @@ -0,0 +1,42 @@ +class Solution { +public: + vector ambiguousCoordinates(string s) { + s = s.substr(1, s.size() - 2); + vector finalResults; + + auto getValidNumbers = [](const string& numStr) -> vector { + vector res; + + for (int i = 1; i <= numStr.size(); i++) { + string left = numStr.substr(0, i); + string right = numStr.substr(i); + + if ((left.size() > 1 && left[0] == '0') || + (!right.empty() && right.back() == '0')) { + continue; + } + + if (right.empty()) { + res.push_back(left); + } else { + res.push_back(left + "." + right); + } + } + + return res; + }; + + for (int i = 1; i < s.size(); i++) { + vector xOptions = getValidNumbers(s.substr(0, i)); + vector yOptions = getValidNumbers(s.substr(i)); + + for (const string& x : xOptions) { + for (const string& y : yOptions) { + finalResults.push_back("(" + x + ", " + y + ")"); + } + } + } + + return finalResults; + } +}; diff --git a/tests/501-1000/816. ambiguous-coordinates/sol.cs b/tests/501-1000/816. ambiguous-coordinates/sol.cs new file mode 100644 index 00000000..5d0edde6 --- /dev/null +++ b/tests/501-1000/816. ambiguous-coordinates/sol.cs @@ -0,0 +1,41 @@ +public class Solution { + public IList AmbiguousCoordinates(string s) { + s = s.Substring(1, s.Length - 2); + List finalResults = new List(); + + for (int i = 1; i < s.Length; i++) { + List xOptions = GetValidNumbers(s.Substring(0, i)); + List yOptions = GetValidNumbers(s.Substring(i)); + + foreach (string x in xOptions) { + foreach (string y in yOptions) { + finalResults.Add("(" + x + ", " + y + ")"); + } + } + } + + return finalResults; + } + + private List GetValidNumbers(string numStr) { + List res = new List(); + + for (int i = 1; i <= numStr.Length; i++) { + string left = numStr.Substring(0, i); + string right = numStr.Substring(i); + + if ((left.Length > 1 && left.StartsWith("0")) || + (right.Length > 0 && right.EndsWith("0"))) { + continue; + } + + if (right.Length == 0) { + res.Add(left); + } else { + res.Add(left + "." + right); + } + } + + return res; + } +} diff --git a/tests/501-1000/816. ambiguous-coordinates/sol.dart b/tests/501-1000/816. ambiguous-coordinates/sol.dart new file mode 100644 index 00000000..bd57635e --- /dev/null +++ b/tests/501-1000/816. ambiguous-coordinates/sol.dart @@ -0,0 +1,40 @@ +class Solution { + List ambiguousCoordinates(String s) { + s = s.substring(1, s.length - 1); + List finalResults = []; + + List getValidNumbers(String numStr) { + List res = []; + + for (int i = 1; i <= numStr.length; i++) { + String left = numStr.substring(0, i); + String right = numStr.substring(i); + + if ((left.length > 1 && left.startsWith('0')) || (right.isNotEmpty && right.endsWith('0'))) { + continue; + } + + if (right.isEmpty) { + res.add(left); + } else { + res.add('$left.$right'); + } + } + + return res; + } + + for (int i = 1; i < s.length; i++) { + List xOptions = getValidNumbers(s.substring(0, i)); + List yOptions = getValidNumbers(s.substring(i)); + + for (String x in xOptions) { + for (String y in yOptions) { + finalResults.add('($x, $y)'); + } + } + } + + return finalResults; + } +} diff --git a/tests/501-1000/816. ambiguous-coordinates/sol.go b/tests/501-1000/816. ambiguous-coordinates/sol.go new file mode 100644 index 00000000..010769b8 --- /dev/null +++ b/tests/501-1000/816. ambiguous-coordinates/sol.go @@ -0,0 +1,38 @@ +func ambiguousCoordinates(s string) []string { + s = s[1 : len(s)-1] + finalResults := make([]string, 0) + + getValidNumbers := func(numStr string) []string { + res := make([]string, 0) + + for i := 1; i <= len(numStr); i++ { + left := numStr[:i] + right := numStr[i:] + + if (len(left) > 1 && left[0] == '0') || (len(right) > 0 && right[len(right)-1] == '0') { + continue + } + + if len(right) == 0 { + res = append(res, left) + } else { + res = append(res, left + "." + right) + } + } + + return res + } + + for i := 1; i < len(s); i++ { + xOptions := getValidNumbers(s[:i]) + yOptions := getValidNumbers(s[i:]) + + for _, x := range xOptions { + for _, y := range yOptions { + finalResults = append(finalResults, "(" + x + ", " + y + ")") + } + } + } + + return finalResults +} diff --git a/tests/501-1000/816. ambiguous-coordinates/sol.java b/tests/501-1000/816. ambiguous-coordinates/sol.java new file mode 100644 index 00000000..c4fef03c --- /dev/null +++ b/tests/501-1000/816. ambiguous-coordinates/sol.java @@ -0,0 +1,40 @@ +class Solution { + public List ambiguousCoordinates(String s) { + s = s.substring(1, s.length() - 1); + List finalResults = new ArrayList<>(); + + for (int i = 1; i < s.length(); i++) { + List xOptions = getValidNumbers(s.substring(0, i)); + List yOptions = getValidNumbers(s.substring(i)); + + for (String x : xOptions) { + for (String y : yOptions) { + finalResults.add("(" + x + ", " + y + ")"); + } + } + } + + return finalResults; + } + + private List getValidNumbers(String numStr) { + List res = new ArrayList<>(); + + for (int i = 1; i <= numStr.length(); i++) { + String left = numStr.substring(0, i); + String right = numStr.substring(i); + + if ((left.length() > 1 && left.startsWith("0")) || right.endsWith("0")) { + continue; + } + + if (right.isEmpty()) { + res.add(left); + } else { + res.add(left + "." + right); + } + } + + return res; + } +} diff --git a/tests/501-1000/816. ambiguous-coordinates/sol.kt b/tests/501-1000/816. ambiguous-coordinates/sol.kt new file mode 100644 index 00000000..0d3b224b --- /dev/null +++ b/tests/501-1000/816. ambiguous-coordinates/sol.kt @@ -0,0 +1,40 @@ +class Solution { + fun ambiguousCoordinates(s: String): List { + val str = s.substring(1, s.length - 1) + val finalResults = mutableListOf() + + for (i in 1 until str.length) { + val xOptions = getValidNumbers(str.substring(0, i)) + val yOptions = getValidNumbers(str.substring(i)) + + for (x in xOptions) { + for (y in yOptions) { + finalResults.add("($x, $y)") + } + } + } + + return finalResults + } + + private fun getValidNumbers(numStr: String): List { + val res = mutableListOf() + + for (i in 1..numStr.length) { + val left = numStr.substring(0, i) + val right = numStr.substring(i) + + if ((left.length > 1 && left.startsWith("0")) || right.endsWith("0")) { + continue + } + + if (right.isEmpty()) { + res.add(left) + } else { + res.add("$left.$right") + } + } + + return res + } +} diff --git a/tests/501-1000/816. ambiguous-coordinates/sol.py b/tests/501-1000/816. ambiguous-coordinates/sol.py new file mode 100644 index 00000000..4d8cf54b --- /dev/null +++ b/tests/501-1000/816. ambiguous-coordinates/sol.py @@ -0,0 +1,34 @@ +class Solution: + def ambiguousCoordinates(self, s: str) -> List[str]: + s = s[1:-1] # Remove parentheses + + def get_valid_numbers(num_str): + """Returns a list of valid decimal/integer representations.""" + res = [] + for i in range(1, len(num_str) + 1): + left = num_str[:i] + right = num_str[i:] + + # Blunk-style Constraint Check: + # 1. No leading zeros unless it's just "0" or "0.xxx" + if (len(left) > 1 and left.startswith("0")) or (right.endswith("0")): + continue + + if not right: # It's an integer + res.append(left) + else: # It's a decimal + res.append(f"{left}.{right}") + return res + + final_results = [] + # Split the coordinate 'manifold' into two halves (x, y) + for i in range(1, len(s)): + x_options = get_valid_numbers(s[:i]) + y_options = get_valid_numbers(s[i:]) + + # Cartesian Product of valid states + for x in x_options: + for y in y_options: + final_results.append(f"({x}, {y})") + + return final_results diff --git a/tests/501-1000/816. ambiguous-coordinates/sol.py2 b/tests/501-1000/816. ambiguous-coordinates/sol.py2 new file mode 100644 index 00000000..06e119f6 --- /dev/null +++ b/tests/501-1000/816. ambiguous-coordinates/sol.py2 @@ -0,0 +1,33 @@ +class Solution(object): + def ambiguousCoordinates(self, s): + """ + :type s: str + :rtype: List[str] + """ + s = s[1:-1] + + def get_valid_numbers(num_str): + res = [] + for i in range(1, len(num_str) + 1): + left = num_str[:i] + right = num_str[i:] + + if (len(left) > 1 and left.startswith('0')) or right.endswith('0'): + continue + + if not right: + res.append(left) + else: + res.append(left + '.' + right) + return res + + final_results = [] + for i in range(1, len(s)): + x_options = get_valid_numbers(s[:i]) + y_options = get_valid_numbers(s[i:]) + + for x in x_options: + for y in y_options: + final_results.append('(' + x + ', ' + y + ')') + + return final_results diff --git a/tests/501-1000/816. ambiguous-coordinates/sol.rb b/tests/501-1000/816. ambiguous-coordinates/sol.rb new file mode 100644 index 00000000..4c57fc68 --- /dev/null +++ b/tests/501-1000/816. ambiguous-coordinates/sol.rb @@ -0,0 +1,38 @@ +# @param {String} s +# @return {String[]} +def ambiguous_coordinates(s) + s = s[1..-2] + + get_valid_numbers = lambda do |num_str| + res = [] + (1..num_str.length).each do |i| + left = num_str[0, i] + right = num_str[i..-1] || "" + + if (left.length > 1 && left.start_with?('0')) || (right.end_with?('0')) + next + end + + if right.empty? + res << left + else + res << "#{left}.#{right}" + end + end + res + end + + final_results = [] + (1...s.length).each do |i| + x_options = get_valid_numbers.call(s[0, i]) + y_options = get_valid_numbers.call(s[i..-1]) + + x_options.each do |x| + y_options.each do |y| + final_results << "(#{x}, #{y})" + end + end + end + + final_results +end diff --git a/tests/501-1000/816. ambiguous-coordinates/sol.rs b/tests/501-1000/816. ambiguous-coordinates/sol.rs new file mode 100644 index 00000000..3069f689 --- /dev/null +++ b/tests/501-1000/816. ambiguous-coordinates/sol.rs @@ -0,0 +1,40 @@ +impl Solution { + pub fn ambiguous_coordinates(s: String) -> Vec { + let s = &s[1..s.len() - 1]; + let mut final_results = Vec::new(); + + let get_valid_numbers = |num_str: &str| -> Vec { + let mut res = Vec::new(); + + for i in 1..=num_str.len() { + let left = &num_str[..i]; + let right = &num_str[i..]; + + if (left.len() > 1 && left.starts_with('0')) || right.ends_with('0') { + continue; + } + + if right.is_empty() { + res.push(left.to_string()); + } else { + res.push(format!("{}.{}", left, right)); + } + } + + res + }; + + for i in 1..s.len() { + let x_options = get_valid_numbers(&s[..i]); + let y_options = get_valid_numbers(&s[i..]); + + for x in &x_options { + for y in &y_options { + final_results.push(format!("({}, {})", x, y)); + } + } + } + + final_results + } +} diff --git a/tests/501-1000/816. ambiguous-coordinates/sol.swift b/tests/501-1000/816. ambiguous-coordinates/sol.swift new file mode 100644 index 00000000..9e1d8708 --- /dev/null +++ b/tests/501-1000/816. ambiguous-coordinates/sol.swift @@ -0,0 +1,42 @@ +class Solution { + func ambiguousCoordinates(_ s: String) -> [String] { + let str = String(s.dropFirst().dropLast()) + var finalResults: [String] = [] + + func getValidNumbers(_ numStr: String) -> [String] { + var res: [String] = [] + let chars = Array(numStr) + + for i in 1...chars.count { + let left = String(chars[0.. 1 && left.hasPrefix("0")) || (right.hasSuffix("0")) { + continue + } + + if right.isEmpty { + res.append(left) + } else { + res.append("\(left).\(right)") + } + } + + return res + } + + for i in 1.. 1 && left.startsWith("0")) || right.endsWith("0")) { + continue; + } + + if (right.length === 0) { + res.push(left); + } else { + res.push(left + "." + right); + } + } + + return res; + } + + for (let i = 1; i < s.length; i++) { + const xOptions = getValidNumbers(s.substring(0, i)); + const yOptions = getValidNumbers(s.substring(i)); + + for (const x of xOptions) { + for (const y of yOptions) { + finalResults.push("(" + x + ", " + y + ")"); + } + } + } + + return finalResults; +} diff --git a/tests/501-1000/817. linked-list-components/manifest.yaml b/tests/501-1000/817. linked-list-components/manifest.yaml new file mode 100644 index 00000000..86b0797f --- /dev/null +++ b/tests/501-1000/817. linked-list-components/manifest.yaml @@ -0,0 +1,826 @@ +entry: + id: 817 + title: linked-list-components + params: + head: + type: list_node + nums: + type: array + items: + type: int + call: + cpp: Solution().numComponents({head}, {nums}) + rust: Solution::num_components({head}, {nums}) + python3: Solution().numComponents({head}, {nums}) + python2: Solution().numComponents({head}, {nums}) + ruby: num_components({head}, {nums}) + java: new Solution().numComponents({head}, {nums}) + csharp: new Solution().NumComponents({head}, {nums}) + kotlin: Solution().numComponents({head}, {nums}) + go: numComponents({head}, {nums}) + dart: Solution().numComponents({head}, {nums}) + swift: Solution().numComponents({head}, {nums}) + typescript: numComponents({head}, {nums}) +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: + "class Checker:\n def check(self, result):\n return isinstance(result,\ + \ int)\n" +seed: 817 +tests: + - name: example_one + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + nums: + - 0 + - 1 + - 3 + out: 2 + - name: example_two + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + nums: + - 0 + - 3 + - 1 + - 4 + out: 2 + - name: single_component_all + in: + head: + elemType: int + value: + - 7 + nums: + - 7 + out: 1 + - name: single_component_missing_never + in: + head: + elemType: int + value: + - 7 + nums: + - 7 + out: 1 + - name: two_nodes_both + in: + head: + elemType: int + value: + - 1 + - 2 + nums: + - 1 + - 2 + out: 1 + - name: two_nodes_first_only + in: + head: + elemType: int + value: + - 1 + - 2 + nums: + - 1 + out: 1 + - name: two_nodes_second_only + in: + head: + elemType: int + value: + - 1 + - 2 + nums: + - 2 + out: 1 + - name: two_nodes_none_adjacent + in: + head: + elemType: int + value: + - 1 + - 2 + nums: + - 1 + out: 1 + - name: all_nodes_components_one + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + nums: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + out: 1 + - name: alternating_all_singletons + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + nums: + - 0 + - 2 + - 4 + out: 3 + - name: alternating_pairs + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + nums: + - 0 + - 1 + - 3 + - 4 + out: 2 + - name: middle_block + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + nums: + - 2 + - 3 + - 4 + out: 1 + - name: two_blocks + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + nums: + - 0 + - 1 + - 4 + - 5 + out: 2 + - name: three_blocks + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + nums: + - 0 + - 2 + - 3 + - 5 + out: 3 + - name: end_block + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + nums: + - 3 + - 4 + out: 1 + - name: start_block + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + nums: + - 0 + - 1 + out: 1 + - name: split_every_other + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + nums: + - 0 + - 2 + - 4 + - 6 + out: 4 + - name: split_with_pairs + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + nums: + - 0 + - 1 + - 4 + - 5 + out: 2 + - name: two_separate_pairs + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + nums: + - 1 + - 2 + - 5 + - 6 + out: 2 + - name: single_middle + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + nums: + - 3 + out: 1 + - name: single_start + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + nums: + - 0 + out: 1 + - name: single_end + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + nums: + - 7 + out: 1 + - name: three_components_large_gaps + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + nums: + - 0 + - 1 + - 4 + - 8 + out: 3 + - name: adjacent_triplet_and_singletons + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + nums: + - 1 + - 2 + - 3 + - 5 + - 8 + out: 3 + - name: two_long_blocks + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + nums: + - 0 + - 1 + - 2 + - 6 + - 7 + - 8 + - 9 + out: 2 + - name: all_even_positions + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + nums: + - 0 + - 2 + - 4 + - 6 + - 8 + out: 5 + - name: all_odd_positions + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + nums: + - 1 + - 3 + - 5 + - 7 + - 9 + out: 5 + - name: clustered_first_half + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + - 11 + nums: + - 0 + - 1 + - 2 + - 3 + out: 1 + - name: clustered_last_half + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + - 11 + nums: + - 8 + - 9 + - 10 + - 11 + out: 1 + - name: interleaved_short + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + nums: + - 0 + - 2 + - 3 + - 5 + - 9 + out: 4 + - name: one_big_and_one_single + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + nums: + - 0 + - 1 + - 2 + - 7 + out: 2 + - name: singletons_with_gaps + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + nums: + - 1 + - 4 + - 7 + out: 3 + - name: medium_mixed_one + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + - 11 + - 12 + nums: + - 0 + - 1 + - 3 + - 4 + - 6 + - 8 + - 9 + - 11 + - 12 + out: 5 + - name: medium_mixed_two + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + - 11 + - 12 + nums: + - 2 + - 3 + - 5 + - 7 + - 8 + - 10 + out: 4 + - name: long_alternating_20 + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + - 11 + - 12 + - 13 + - 14 + - 15 + - 16 + - 17 + - 18 + - 19 + nums: + - 0 + - 2 + - 4 + - 6 + - 8 + - 10 + - 12 + - 14 + - 16 + - 18 + out: 10 + - name: long_blocks_20 + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + - 11 + - 12 + - 13 + - 14 + - 15 + - 16 + - 17 + - 18 + - 19 + nums: + - 0 + - 1 + - 2 + - 5 + - 6 + - 7 + - 10 + - 11 + - 12 + - 15 + - 16 + - 17 + out: 4 + - name: all_but_one + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + nums: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + out: 1 + - name: all_but_middle + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + nums: + - 0 + - 1 + - 2 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + out: 2 + - name: staggered_five_blocks + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + - 11 + - 12 + - 13 + nums: + - 0 + - 1 + - 3 + - 4 + - 6 + - 7 + - 9 + - 10 + - 12 + - 13 + out: 5 + - name: large_tail_block + in: + head: + elemType: int + value: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + - 11 + - 12 + - 13 + - 14 + nums: + - 10 + - 11 + - 12 + - 13 + - 14 + out: 1 diff --git a/tests/501-1000/817. linked-list-components/sol.cpp b/tests/501-1000/817. linked-list-components/sol.cpp new file mode 100644 index 00000000..f5ff45b5 --- /dev/null +++ b/tests/501-1000/817. linked-list-components/sol.cpp @@ -0,0 +1,30 @@ +/** + * Definition for singly-linked list. + * struct ListNode { + * int val; + * ListNode *next; + * ListNode() : val(0), next(nullptr) {} + * ListNode(int x) : val(x), next(nullptr) {} + * ListNode(int x, ListNode *next) : val(x), next(next) {} + * }; + */ +class Solution { +public: + int numComponents(ListNode* head, vector& nums) { + unordered_set nodeSet(nums.begin(), nums.end()); + int count = 0; + bool inComponent = false; + while (head != nullptr) { + if (nodeSet.count(head->val)) { + if (!inComponent) { + count++; + inComponent = true; + } + } else { + inComponent = false; + } + head = head->next; + } + return count; + } +}; diff --git a/tests/501-1000/817. linked-list-components/sol.cs b/tests/501-1000/817. linked-list-components/sol.cs new file mode 100644 index 00000000..7a122495 --- /dev/null +++ b/tests/501-1000/817. linked-list-components/sol.cs @@ -0,0 +1,30 @@ +/** + * Definition for singly-linked list. + * public class ListNode { + * public int val; + * public ListNode next; + * public ListNode(int val=0, ListNode next=null) { + * this.val = val; + * this.next = next; + * } + * } + */ +public class Solution { + public int NumComponents(ListNode head, int[] nums) { + HashSet nodeSet = new HashSet(nums); + int count = 0; + bool inComponent = false; + while (head != null) { + if (nodeSet.Contains(head.val)) { + if (!inComponent) { + count++; + inComponent = true; + } + } else { + inComponent = false; + } + head = head.next; + } + return count; + } +} diff --git a/tests/501-1000/817. linked-list-components/sol.dart b/tests/501-1000/817. linked-list-components/sol.dart new file mode 100644 index 00000000..f698bbb3 --- /dev/null +++ b/tests/501-1000/817. linked-list-components/sol.dart @@ -0,0 +1,27 @@ +/** + * Definition for singly-linked list. + * class ListNode { + * int val; + * ListNode? next; + * ListNode([this.val = 0, this.next]); + * } + */ +class Solution { + int numComponents(ListNode? head, List nums) { + var nodeSet = nums.toSet(); + int count = 0; + bool inComponent = false; + while (head != null) { + if (nodeSet.contains(head.val)) { + if (!inComponent) { + count++; + inComponent = true; + } + } else { + inComponent = false; + } + head = head.next; + } + return count; + } +} diff --git a/tests/501-1000/817. linked-list-components/sol.go b/tests/501-1000/817. linked-list-components/sol.go new file mode 100644 index 00000000..7c0aac57 --- /dev/null +++ b/tests/501-1000/817. linked-list-components/sol.go @@ -0,0 +1,27 @@ +/** + * Definition for singly-linked list. + * type ListNode struct { + * Val int + * Next *ListNode + * } + */ +func numComponents(head *ListNode, nums []int) int { + nodeSet := make(map[int]bool) + for _, num := range nums { + nodeSet[num] = true + } + count := 0 + inComponent := false + for head != nil { + if nodeSet[head.Val] { + if !inComponent { + count++ + inComponent = true + } + } else { + inComponent = false + } + head = head.Next + } + return count +} diff --git a/tests/501-1000/817. linked-list-components/sol.java b/tests/501-1000/817. linked-list-components/sol.java new file mode 100644 index 00000000..0d7c0153 --- /dev/null +++ b/tests/501-1000/817. linked-list-components/sol.java @@ -0,0 +1,32 @@ +/** + * Definition for singly-linked list. + * public class ListNode { + * int val; + * ListNode next; + * ListNode() {} + * ListNode(int val) { this.val = val; } + * ListNode(int val, ListNode next) { this.val = val; this.next = next; } + * } + */ +class Solution { + public int numComponents(ListNode head, int[] nums) { + Set nodeSet = new HashSet<>(); + for (int num : nums) { + nodeSet.add(num); + } + int count = 0; + boolean inComponent = false; + while (head != null) { + if (nodeSet.contains(head.val)) { + if (!inComponent) { + count++; + inComponent = true; + } + } else { + inComponent = false; + } + head = head.next; + } + return count; + } +} diff --git a/tests/501-1000/817. linked-list-components/sol.kt b/tests/501-1000/817. linked-list-components/sol.kt new file mode 100644 index 00000000..16cf48da --- /dev/null +++ b/tests/501-1000/817. linked-list-components/sol.kt @@ -0,0 +1,29 @@ +/** + * Example: + * var li = ListNode(5) + * var v = li.`val` + * Definition for singly-linked list. + * class ListNode(var `val`: Int) { + * var next: ListNode? = null + * } + */ +class Solution { + fun numComponents(head: ListNode?, nums: IntArray): Int { + val nodeSet = nums.toHashSet() + var count = 0 + var inComponent = false + var current = head + while (current != null) { + if (current.`val` in nodeSet) { + if (!inComponent) { + count++ + inComponent = true + } + } else { + inComponent = false + } + current = current.next + } + return count + } +} diff --git a/tests/501-1000/817. linked-list-components/sol.py b/tests/501-1000/817. linked-list-components/sol.py new file mode 100644 index 00000000..7e9667f7 --- /dev/null +++ b/tests/501-1000/817. linked-list-components/sol.py @@ -0,0 +1,14 @@ +class Solution(object): + def numComponents(self, head, nums): + node_set = set(nums) + count = 0 + in_component = False + while head: + if head.val in node_set: + if not in_component: + count += 1 + in_component = True + else: + in_component = False + head = head.next + return count diff --git a/tests/501-1000/817. linked-list-components/sol.py2 b/tests/501-1000/817. linked-list-components/sol.py2 new file mode 100644 index 00000000..2e39f632 --- /dev/null +++ b/tests/501-1000/817. linked-list-components/sol.py2 @@ -0,0 +1,24 @@ +# Definition for singly-linked list. +# class ListNode(object): +# def __init__(self, val=0, next=None): +# self.val = val +# self.next = next +class Solution(object): + def numComponents(self, head, nums): + """ + :type head: Optional[ListNode] + :type nums: List[int] + :rtype: int + """ + node_set = set(nums) + count = 0 + in_component = False + while head: + if head.val in node_set: + if not in_component: + count += 1 + in_component = True + else: + in_component = False + head = head.next + return count diff --git a/tests/501-1000/817. linked-list-components/sol.rb b/tests/501-1000/817. linked-list-components/sol.rb new file mode 100644 index 00000000..fd497bb3 --- /dev/null +++ b/tests/501-1000/817. linked-list-components/sol.rb @@ -0,0 +1,28 @@ +# Definition for singly-linked list. +# class ListNode +# attr_accessor :val, :next +# def initialize(val = 0, _next = nil) +# @val = val +# @next = _next +# end +# end +# @param {ListNode} head +# @param {Integer[]} nums +# @return {Integer} +def num_components(head, nums) + node_set = nums.to_set + count = 0 + in_component = false + while head + if node_set.include?(head.val) + if !in_component + count += 1 + in_component = true + end + else + in_component = false + end + head = head.next + end + count +end diff --git a/tests/501-1000/817. linked-list-components/sol.rs b/tests/501-1000/817. linked-list-components/sol.rs new file mode 100644 index 00000000..231bbd6a --- /dev/null +++ b/tests/501-1000/817. linked-list-components/sol.rs @@ -0,0 +1,37 @@ +// Definition for singly-linked list. +// #[derive(PartialEq, Eq, Clone, Debug)] +// pub struct ListNode { +// pub val: i32, +// pub next: Option> +// } +// +// impl ListNode { +// #[inline] +// fn new(val: i32) -> Self { +// ListNode { +// next: None, +// val +// } +// } +// } +impl Solution { + pub fn num_components(head: Option>, nums: Vec) -> i32 { + use std::collections::HashSet; + let node_set: HashSet = nums.into_iter().collect(); + let mut count = 0; + let mut in_component = false; + let mut current = head; + while let Some(node) = current { + if node_set.contains(&node.val) { + if !in_component { + count += 1; + in_component = true; + } + } else { + in_component = false; + } + current = node.next; + } + count + } +} diff --git a/tests/501-1000/817. linked-list-components/sol.swift b/tests/501-1000/817. linked-list-components/sol.swift new file mode 100644 index 00000000..36c9d2c1 --- /dev/null +++ b/tests/501-1000/817. linked-list-components/sol.swift @@ -0,0 +1,30 @@ +/** + * Definition for singly-linked list. + * public class ListNode { + * public var val: Int + * public var next: ListNode? + * public init() { self.val = 0; self.next = nil; } + * public init(_ val: Int) { self.val = val; self.next = nil; } + * public init(_ val: Int, _ next: ListNode?) { self.val = val; self.next = next; } + * } + */ +class Solution { + func numComponents(_ head: ListNode?, _ nums: [Int]) -> Int { + let nodeSet = Set(nums) + var count = 0 + var inComponent = false + var current = head + while current != nil { + if nodeSet.contains(current!.val) { + if !inComponent { + count += 1 + inComponent = true + } + } else { + inComponent = false + } + current = current!.next + } + return count + } +} diff --git a/tests/501-1000/817. linked-list-components/sol.ts b/tests/501-1000/817. linked-list-components/sol.ts new file mode 100644 index 00000000..bf184a91 --- /dev/null +++ b/tests/501-1000/817. linked-list-components/sol.ts @@ -0,0 +1,29 @@ +/** + * Definition for singly-linked list. + * class ListNode { + * val: number + * next: ListNode | null + * constructor(val?: number, next?: ListNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.next = (next===undefined ? null : next) + * } + * } + */ + +function numComponents(head: ListNode | null, nums: number[]): number { + const nodeSet = new Set(nums); + let count = 0; + let inComponent = false; + while (head !== null) { + if (nodeSet.has(head.val)) { + if (!inComponent) { + count++; + inComponent = true; + } + } else { + inComponent = false; + } + head = head.next; + } + return count; +} diff --git a/tests/501-1000/818. race-car/manifest.yaml b/tests/501-1000/818. race-car/manifest.yaml new file mode 100644 index 00000000..5175903b --- /dev/null +++ b/tests/501-1000/818. race-car/manifest.yaml @@ -0,0 +1,181 @@ +entry: + id: 818 + title: "race-car" + params: + target: + type: int + call: + cpp: "Solution().racecar({target})" + rust: "Solution::racecar({target})" + python3: "Solution().racecar({target})" + python2: "Solution().racecar({target})" + ruby: "racecar({target})" + java: "new Solution().racecar({target})" + csharp: "new Solution().Racecar({target})" + kotlin: "Solution().racecar({target})" + go: "racecar({target})" + dart: "Solution().racecar({target})" + swift: "Solution().racecar({target})" + typescript: "racecar({target})" +judge: + type: "exact" +limits: + time_ms: 500 + memory_mb: 256 +oracle: + python3: + call: "Checker().check({result})" + checker: | + class Checker: + def check(self, result): + return isinstance(result, int) +seed: 818 +tests: + - name: "example_one" + in: + target: 3 + out: 2 + - name: "example_two" + in: + target: 6 + out: 5 + - name: "target_one" + in: + target: 1 + out: 1 + - name: "target_two" + in: + target: 2 + out: 4 + - name: "target_four" + in: + target: 4 + out: 5 + - name: "target_five" + in: + target: 5 + out: 7 + - name: "target_seven" + in: + target: 7 + out: 3 + - name: "target_six" + in: + target: 6 + out: 5 + - name: "target_eight" + in: + target: 8 + out: 6 + - name: "target_nine" + in: + target: 9 + out: 8 + - name: "target_ten" + in: + target: 10 + out: 7 + - name: "target_eleven" + in: + target: 11 + out: 10 + - name: "target_twelve" + in: + target: 12 + out: 7 + - name: "target_thirteen" + in: + target: 13 + out: 9 + - name: "target_fifteen" + in: + target: 15 + out: 4 + - name: "target_sixteen" + in: + target: 16 + out: 7 + - name: "target_seventeen" + in: + target: 17 + out: 9 + - name: "target_thirty_one" + in: + target: 31 + out: 5 + - name: "target_thirty_two" + in: + target: 32 + out: 8 + - name: "target_thirty_three" + in: + target: 33 + out: 10 + - name: "target_sixty_three" + in: + target: 63 + out: 6 + - name: "target_sixty_four" + in: + target: 64 + out: 9 + - name: "target_sixty_five" + in: + target: 65 + out: 11 + - name: "target_one_hundred_twenty_seven" + in: + target: 127 + out: 7 + - name: "target_one_hundred_twenty_eight" + in: + target: 128 + out: 10 + - name: "target_two_hundred_fifty_five" + in: + target: 255 + out: 8 + - name: "target_two_hundred_fifty_six" + in: + target: 256 + out: 11 + - name: "target_five_hundred" + in: + target: 500 + out: 20 + - name: "target_thousand" + in: + target: 1000 + out: 23 + - name: "target_one_thousand_one" + in: + target: 1001 + out: 20 + - name: "target_two_thousand" + in: + target: 2000 + out: 26 + - name: "target_two_thousand_one" + in: + target: 2001 + out: 23 + - name: "target_four_thousand" + in: + target: 4000 + out: 29 + - name: "target_five_thousand" + in: + target: 5000 + out: 41 + - name: "target_six_thousand" + in: + target: 6000 + out: 37 + - name: "target_nine_thousand_nine_hundred_ninety_nine" + in: + target: 9999 + out: 43 + - name: "target_ten_thousand" + in: + target: 10000 + out: 45 diff --git a/tests/501-1000/818. race-car/sol.cpp b/tests/501-1000/818. race-car/sol.cpp new file mode 100644 index 00000000..6006a9bd --- /dev/null +++ b/tests/501-1000/818. race-car/sol.cpp @@ -0,0 +1,21 @@ +class Solution { +public: + int racecar(int target) { + queue> q; + q.push({0, 1, 0}); + while (!q.empty()) { + auto [cp, cs, nm] = q.front(); + q.pop(); + if (cp == target) return nm; + q.push({cp + cs, cs * 2, nm + 1}); + if ((cp + cs > target && cs > 0) || (cp + cs < target && cs < 0)) { + if (cs < 0) { + q.push({cp, 1, nm + 1}); + } else { + q.push({cp, -1, nm + 1}); + } + } + } + return -1; + } +}; diff --git a/tests/501-1000/818. race-car/sol.cs b/tests/501-1000/818. race-car/sol.cs new file mode 100644 index 00000000..35bfd013 --- /dev/null +++ b/tests/501-1000/818. race-car/sol.cs @@ -0,0 +1,19 @@ +public class Solution { + public int Racecar(int target) { + var q = new Queue<(int, int, int)>(); + q.Enqueue((0, 1, 0)); + while (q.Count > 0) { + var (cp, cs, nm) = q.Dequeue(); + if (cp == target) return nm; + q.Enqueue((cp + cs, cs * 2, nm + 1)); + if ((cp + cs > target && cs > 0) || (cp + cs < target && cs < 0)) { + if (cs < 0) { + q.Enqueue((cp, 1, nm + 1)); + } else { + q.Enqueue((cp, -1, nm + 1)); + } + } + } + return -1; + } +} diff --git a/tests/501-1000/818. race-car/sol.dart b/tests/501-1000/818. race-car/sol.dart new file mode 100644 index 00000000..46e0890e --- /dev/null +++ b/tests/501-1000/818. race-car/sol.dart @@ -0,0 +1,20 @@ +class Solution { + int racecar(int target) { + var q = Queue>(); + q.add([0, 1, 0]); + while (q.isNotEmpty) { + var cur = q.removeFirst(); + int cp = cur[0], cs = cur[1], nm = cur[2]; + if (cp == target) return nm; + q.add([cp + cs, cs * 2, nm + 1]); + if ((cp + cs > target && cs > 0) || (cp + cs < target && cs < 0)) { + if (cs < 0) { + q.add([cp, 1, nm + 1]); + } else { + q.add([cp, -1, nm + 1]); + } + } + } + return -1; + } +} diff --git a/tests/501-1000/818. race-car/sol.go b/tests/501-1000/818. race-car/sol.go new file mode 100644 index 00000000..3d86da7d --- /dev/null +++ b/tests/501-1000/818. race-car/sol.go @@ -0,0 +1,20 @@ +func racecar(target int) int { + type state struct{ pos, speed, moves int } + q := []state{{0, 1, 0}} + for len(q) > 0 { + cur := q[0] + q = q[1:] + if cur.pos == target { + return cur.moves + } + q = append(q, state{cur.pos + cur.speed, cur.speed * 2, cur.moves + 1}) + if (cur.pos+cur.speed > target && cur.speed > 0) || (cur.pos+cur.speed < target && cur.speed < 0) { + if cur.speed < 0 { + q = append(q, state{cur.pos, 1, cur.moves + 1}) + } else { + q = append(q, state{cur.pos, -1, cur.moves + 1}) + } + } + } + return -1 +} diff --git a/tests/501-1000/818. race-car/sol.java b/tests/501-1000/818. race-car/sol.java new file mode 100644 index 00000000..bb3e108e --- /dev/null +++ b/tests/501-1000/818. race-car/sol.java @@ -0,0 +1,20 @@ +class Solution { + public int racecar(int target) { + java.util.Queue q = new java.util.LinkedList<>(); + q.offer(new int[]{0, 1, 0}); + while (!q.isEmpty()) { + int[] cur = q.poll(); + int cp = cur[0], cs = cur[1], nm = cur[2]; + if (cp == target) return nm; + q.offer(new int[]{cp + cs, cs * 2, nm + 1}); + if ((cp + cs > target && cs > 0) || (cp + cs < target && cs < 0)) { + if (cs < 0) { + q.offer(new int[]{cp, 1, nm + 1}); + } else { + q.offer(new int[]{cp, -1, nm + 1}); + } + } + } + return -1; + } +} diff --git a/tests/501-1000/818. race-car/sol.kt b/tests/501-1000/818. race-car/sol.kt new file mode 100644 index 00000000..8b1b485e --- /dev/null +++ b/tests/501-1000/818. race-car/sol.kt @@ -0,0 +1,19 @@ +class Solution { + fun racecar(target: Int): Int { + val q = ArrayDeque>() + q.addLast(Triple(0, 1, 0)) + while (q.isNotEmpty()) { + val (cp, cs, nm) = q.removeFirst() + if (cp == target) return nm + q.addLast(Triple(cp + cs, cs * 2, nm + 1)) + if ((cp + cs > target && cs > 0) || (cp + cs < target && cs < 0)) { + if (cs < 0) { + q.addLast(Triple(cp, 1, nm + 1)) + } else { + q.addLast(Triple(cp, -1, nm + 1)) + } + } + } + return -1 + } +} diff --git a/tests/501-1000/818. race-car/sol.py b/tests/501-1000/818. race-car/sol.py new file mode 100644 index 00000000..243664e8 --- /dev/null +++ b/tests/501-1000/818. race-car/sol.py @@ -0,0 +1,23 @@ +class Solution: + def racecar(self, target: int) -> int: + q = deque() + q.append((0, 1, 0)) # curr pos, curr speed, number of moves + + while q: + cp, cs, nm = q.popleft() + + if cp == target: + return nm + + # every pos we have 2 choice + # A or R + + # Acceleration + q.append((cp + cs, cs * 2, nm + 1)) + + # Reverse + if (cp + cs > target and cs > 0) or (cp + cs < target and cs < 0): + if cs < 0: + q.append((cp, 1, nm + 1)) + else: + q.append((cp, -1, nm + 1)) diff --git a/tests/501-1000/818. race-car/sol.py2 b/tests/501-1000/818. race-car/sol.py2 new file mode 100644 index 00000000..7b8e7113 --- /dev/null +++ b/tests/501-1000/818. race-car/sol.py2 @@ -0,0 +1,19 @@ +class Solution(object): + def racecar(self, target): + """ + :type target: int + :rtype: int + """ + from collections import deque + q = deque() + q.append((0, 1, 0)) + while q: + cp, cs, nm = q.popleft() + if cp == target: + return nm + q.append((cp + cs, cs * 2, nm + 1)) + if (cp + cs > target and cs > 0) or (cp + cs < target and cs < 0): + if cs < 0: + q.append((cp, 1, nm + 1)) + else: + q.append((cp, -1, nm + 1)) diff --git a/tests/501-1000/818. race-car/sol.rb b/tests/501-1000/818. race-car/sol.rb new file mode 100644 index 00000000..5acccf62 --- /dev/null +++ b/tests/501-1000/818. race-car/sol.rb @@ -0,0 +1,18 @@ +# @param {Integer} target +# @return {Integer} +def racecar(target) + require 'set' + q = [[0, 1, 0]] + while !q.empty? + cp, cs, nm = q.shift + return nm if cp == target + q.push([cp + cs, cs * 2, nm + 1]) + if (cp + cs > target && cs > 0) || (cp + cs < target && cs < 0) + if cs < 0 + q.push([cp, 1, nm + 1]) + else + q.push([cp, -1, nm + 1]) + end + end + end +end diff --git a/tests/501-1000/818. race-car/sol.rs b/tests/501-1000/818. race-car/sol.rs new file mode 100644 index 00000000..3b031946 --- /dev/null +++ b/tests/501-1000/818. race-car/sol.rs @@ -0,0 +1,21 @@ +impl Solution { + pub fn racecar(target: i32) -> i32 { + use std::collections::VecDeque; + let mut q = VecDeque::new(); + q.push_back((0i32, 1i32, 0i32)); + while let Some((cp, cs, nm)) = q.pop_front() { + if cp == target { + return nm; + } + q.push_back((cp + cs, cs * 2, nm + 1)); + if (cp + cs > target && cs > 0) || (cp + cs < target && cs < 0) { + if cs < 0 { + q.push_back((cp, 1, nm + 1)); + } else { + q.push_back((cp, -1, nm + 1)); + } + } + } + -1 + } +} diff --git a/tests/501-1000/818. race-car/sol.swift b/tests/501-1000/818. race-car/sol.swift new file mode 100644 index 00000000..7a2e6517 --- /dev/null +++ b/tests/501-1000/818. race-car/sol.swift @@ -0,0 +1,20 @@ +class Solution { + func racecar(_ target: Int) -> Int { + var q: [(Int, Int, Int)] = [(0, 1, 0)] + while !q.isEmpty { + let (cp, cs, nm) = q.removeFirst() + if cp == target { + return nm + } + q.append((cp + cs, cs * 2, nm + 1)) + if (cp + cs > target && cs > 0) || (cp + cs < target && cs < 0) { + if cs < 0 { + q.append((cp, 1, nm + 1)) + } else { + q.append((cp, -1, nm + 1)) + } + } + } + return -1 + } +} diff --git a/tests/501-1000/818. race-car/sol.ts b/tests/501-1000/818. race-car/sol.ts new file mode 100644 index 00000000..931a7316 --- /dev/null +++ b/tests/501-1000/818. race-car/sol.ts @@ -0,0 +1,16 @@ +function racecar(target: number): number { + const q: [number, number, number][] = [[0, 1, 0]]; + while (q.length > 0) { + const [cp, cs, nm] = q.shift()!; + if (cp === target) return nm; + q.push([cp + cs, cs * 2, nm + 1]); + if ((cp + cs > target && cs > 0) || (cp + cs < target && cs < 0)) { + if (cs < 0) { + q.push([cp, 1, nm + 1]); + } else { + q.push([cp, -1, nm + 1]); + } + } + } + return -1; +} diff --git a/tests/501-1000/819. most-common-word/manifest.yaml b/tests/501-1000/819. most-common-word/manifest.yaml new file mode 100644 index 00000000..12874260 --- /dev/null +++ b/tests/501-1000/819. most-common-word/manifest.yaml @@ -0,0 +1,217 @@ +entry: + id: 819 + title: "most-common-word" + params: + paragraph: + type: string + banned: + type: array + items: + type: string + call: + cpp: "Solution().mostCommonWord({paragraph}, {banned})" + rust: "Solution::most_common_word({paragraph}, {banned})" + python3: "Solution().mostCommonWord({paragraph}, {banned})" + python2: "Solution().mostCommonWord({paragraph}, {banned})" + ruby: "most_common_word({paragraph}, {banned})" + java: "new Solution().mostCommonWord({paragraph}, {banned})" + csharp: "new Solution().MostCommonWord({paragraph}, {banned})" + kotlin: "Solution().mostCommonWord({paragraph}, {banned})" + go: "mostCommonWord({paragraph}, {banned})" + dart: "Solution().mostCommonWord({paragraph}, {banned})" + swift: "Solution().mostCommonWord({paragraph}, {banned})" + typescript: "mostCommonWord({paragraph}, {banned})" +judge: + type: "exact" +limits: + time_ms: 200 + memory_mb: 256 +oracle: + python3: + call: "Checker().check({result})" + checker: | + class Checker: + def check(self, result): + return isinstance(result, str) +seed: 819 +tests: + - name: "example_one" + in: + paragraph: "Bob hit a ball, the hit BALL flew far after it was hit." + banned: ["hit"] + out: "ball" + - name: "example_two" + in: + paragraph: "a." + banned: [] + out: "a" + - name: "single_word_unbanned" + in: + paragraph: "Hello" + banned: [] + out: "hello" + - name: "single_word_banned_not_possible" + in: + paragraph: "a b a" + banned: ["b"] + out: "a" + - name: "punctuation_only_one_word" + in: + paragraph: "Word!" + banned: [] + out: "word" + - name: "case_insensitive_basic" + in: + paragraph: "Aa aa AA" + banned: [] + out: "aa" + - name: "banned_lowercase_only" + in: + paragraph: "Cat cat dog" + banned: ["dog"] + out: "cat" + - name: "multiple_punctuation" + in: + paragraph: "Wow! Wow? wow." + banned: [] + out: "wow" + - name: "apostrophe_split" + in: + paragraph: "its time, its time its" + banned: ["time"] + out: "its" + - name: "comma_and_semicolon" + in: + paragraph: "red, blue; red!" + banned: ["blue"] + out: "red" + - name: "unique_answer_two_words" + in: + paragraph: "alpha beta alpha gamma beta alpha" + banned: ["gamma"] + out: "alpha" + - name: "all_but_one_banned" + in: + paragraph: "one two two three three three" + banned: ["one", "two"] + out: "three" + - name: "tie_broken_by_uniqueness_guarantee" + in: + paragraph: "x y x z y x" + banned: ["z"] + out: "x" + - name: "mixed_case_and_spaces" + in: + paragraph: "One two THREE two one THREE three" + banned: ["one"] + out: "three" + - name: "two_frequent_words_one_banned" + in: + paragraph: "apple banana apple banana banana" + banned: ["banana"] + out: "apple" + - name: "word_with_trailing_punct" + in: + paragraph: "end, end. start?" + banned: ["start"] + out: "end" + - name: "word_with_leading_punct" + in: + paragraph: "go! go? go." + banned: [] + out: "go" + - name: "many_small_words" + in: + paragraph: "a b c a b c a b c a a d" + banned: ["d"] + out: "a" + - name: "two_candidates_one_more_common" + in: + paragraph: "sun moon sun star moon sun" + banned: ["star"] + out: "sun" + - name: "single_banned_word_repeated" + in: + paragraph: "cat cat cat dog dog" + banned: ["cat"] + out: "dog" + - name: "case_mixed_punctuation" + in: + paragraph: "BaLL, ball! BALL?" + banned: [] + out: "ball" + - name: "short_sentence" + in: + paragraph: "I am fine I" + banned: ["am"] + out: "i" + - name: "sentence_with_quotes" + in: + paragraph: "say 'hello' say hello hello" + banned: [] + out: "hello" + - name: "hyphen_absent_by_spec" + in: + paragraph: "well well, well" + banned: [] + out: "well" + - name: "distinct_counts" + in: + paragraph: "a a a b b c" + banned: ["c"] + out: "a" + - name: "many_words_two_levels" + in: + paragraph: "red red blue blue blue green green green green" + banned: ["red"] + out: "green" + - name: "single_letter_banned_elsewhere" + in: + paragraph: "q q w e r t y q w w" + banned: ["q"] + out: "w" + - name: "repeated_pattern" + in: + paragraph: "one one two two three three three" + banned: ["one", "two"] + out: "three" + - name: "banned_empty_and_punct" + in: + paragraph: "alpha, beta! beta? alpha. beta" + banned: [] + out: "beta" + - name: "capitalized_mixed" + in: + paragraph: "Dog dog DOG cat CAT" + banned: ["cat"] + out: "dog" + - name: "longer_word_wins" + in: + paragraph: "abc ab abc ab abc" + banned: ["ab"] + out: "abc" + - name: "two_words_one_banned_multiple_times" + in: + paragraph: "left right left right left center" + banned: ["center"] + out: "left" + - name: "simple_three_word" + in: + paragraph: "x y z x y z x" + banned: ["y"] + out: "x" + - name: "answer_at_end" + in: + paragraph: "a a a b" + banned: ["a"] + out: "b" + - name: "answer_at_start" + in: + paragraph: "b a a a" + banned: ["a"] + out: "b" + - name: "one_more_case" + in: + paragraph: "Foo bar foo BAR foo" + banned: ["bar"] + out: "foo" diff --git a/tests/501-1000/819. most-common-word/sol.cpp b/tests/501-1000/819. most-common-word/sol.cpp new file mode 100644 index 00000000..74b15178 --- /dev/null +++ b/tests/501-1000/819. most-common-word/sol.cpp @@ -0,0 +1,25 @@ +class Solution { +public: + string mostCommonWord(string paragraph, vector& banned) { + unordered_set bannedSet(banned.begin(), banned.end()); + unordered_map counts; + string word; + for (size_t i = 0; i <= paragraph.size(); ++i) { + if (i < paragraph.size() && isalpha(static_cast(paragraph[i]))) { + word += static_cast(tolower(static_cast(paragraph[i]))); + } else if (!word.empty()) { + if (!bannedSet.count(word)) counts[word]++; + word.clear(); + } + } + string result; + int maxCount = 0; + for (auto& [k, v] : counts) { + if (v > maxCount) { + maxCount = v; + result = k; + } + } + return result; + } +}; diff --git a/tests/501-1000/819. most-common-word/sol.cs b/tests/501-1000/819. most-common-word/sol.cs new file mode 100644 index 00000000..08282357 --- /dev/null +++ b/tests/501-1000/819. most-common-word/sol.cs @@ -0,0 +1,22 @@ +public class Solution { + public string MostCommonWord(string paragraph, string[] banned) { + var bannedSet = new HashSet(banned); + var counts = new Dictionary(); + var words = System.Text.RegularExpressions.Regex.Split(paragraph.ToLower(), @"[^a-z]+"); + foreach (var w in words) { + if (!string.IsNullOrEmpty(w) && !bannedSet.Contains(w)) { + counts.TryGetValue(w, out int c); + counts[w] = c + 1; + } + } + string result = ""; + int maxCount = 0; + foreach (var kv in counts) { + if (kv.Value > maxCount) { + maxCount = kv.Value; + result = kv.Key; + } + } + return result; + } +} diff --git a/tests/501-1000/819. most-common-word/sol.dart b/tests/501-1000/819. most-common-word/sol.dart new file mode 100644 index 00000000..1605763a --- /dev/null +++ b/tests/501-1000/819. most-common-word/sol.dart @@ -0,0 +1,21 @@ +class Solution { + String mostCommonWord(String paragraph, List banned) { + var bannedSet = banned.toSet(); + var counts = {}; + var words = paragraph.toLowerCase().split(RegExp(r'[^a-z]+')); + for (var w in words) { + if (w.isNotEmpty && !bannedSet.contains(w)) { + counts[w] = (counts[w] ?? 0) + 1; + } + } + var maxCount = 0; + var result = ""; + counts.forEach((k, v) { + if (v > maxCount) { + maxCount = v; + result = k; + } + }); + return result; + } +} diff --git a/tests/501-1000/819. most-common-word/sol.go b/tests/501-1000/819. most-common-word/sol.go new file mode 100644 index 00000000..068fdfc3 --- /dev/null +++ b/tests/501-1000/819. most-common-word/sol.go @@ -0,0 +1,23 @@ +func mostCommonWord(paragraph string, banned []string) string { + bannedSet := make(map[string]bool) + for _, w := range banned { + bannedSet[w] = true + } + counts := make(map[string]int) + re := regexp.MustCompile(`[a-z]+`) + words := re.FindAllString(strings.ToLower(paragraph), -1) + for _, w := range words { + if !bannedSet[w] { + counts[w]++ + } + } + maxCount := 0 + result := "" + for w, c := range counts { + if c > maxCount { + maxCount = c + result = w + } + } + return result +} diff --git a/tests/501-1000/819. most-common-word/sol.java b/tests/501-1000/819. most-common-word/sol.java new file mode 100644 index 00000000..34091fcf --- /dev/null +++ b/tests/501-1000/819. most-common-word/sol.java @@ -0,0 +1,21 @@ +class Solution { + public String mostCommonWord(String paragraph, String[] banned) { + Set bannedSet = new HashSet<>(Arrays.asList(banned)); + Map counts = new HashMap<>(); + String[] words = paragraph.toLowerCase().split("[^a-z]+"); + for (String w : words) { + if (!w.isEmpty() && !bannedSet.contains(w)) { + counts.put(w, counts.getOrDefault(w, 0) + 1); + } + } + String result = ""; + int maxCount = 0; + for (Map.Entry entry : counts.entrySet()) { + if (entry.getValue() > maxCount) { + maxCount = entry.getValue(); + result = entry.getKey(); + } + } + return result; + } +} diff --git a/tests/501-1000/819. most-common-word/sol.kt b/tests/501-1000/819. most-common-word/sol.kt new file mode 100644 index 00000000..8e7df672 --- /dev/null +++ b/tests/501-1000/819. most-common-word/sol.kt @@ -0,0 +1,12 @@ +class Solution { + fun mostCommonWord(paragraph: String, banned: Array): String { + val bannedSet = banned.toSet() + val counts = mutableMapOf() + paragraph.lowercase().split(Regex("[^a-z]+")).forEach { w -> + if (w.isNotEmpty() && w !in bannedSet) { + counts[w] = counts.getOrDefault(w, 0) + 1 + } + } + return counts.maxByOrNull { it.value }!!.key + } +} diff --git a/tests/501-1000/819. most-common-word/sol.py b/tests/501-1000/819. most-common-word/sol.py new file mode 100644 index 00000000..41c7f55d --- /dev/null +++ b/tests/501-1000/819. most-common-word/sol.py @@ -0,0 +1,15 @@ +import re +from collections import Counter + + +class Solution(object): + def mostCommonWord(self, paragraph, banned): + """ + :type paragraph: str + :type banned: List[str] + :rtype: str + """ + banned_set = set(banned) + word = re.findall(r"[A-Za-z]+", paragraph) + counts = Counter(w.lower() for w in word if w.lower() not in banned_set) + return counts.most_common(1)[0][0] diff --git a/tests/501-1000/819. most-common-word/sol.py2 b/tests/501-1000/819. most-common-word/sol.py2 new file mode 100644 index 00000000..d7d8865c --- /dev/null +++ b/tests/501-1000/819. most-common-word/sol.py2 @@ -0,0 +1,14 @@ +import re +from collections import Counter + +class Solution(object): + def mostCommonWord(self, paragraph, banned): + """ + :type paragraph: str + :type banned: List[str] + :rtype: str + """ + banned_set=set(banned) + word=re.findall(r'[A-Za-z]+',paragraph) + counts=Counter(w.lower() for w in word if w.lower() not in banned_set) + return counts.most_common(1)[0][0] diff --git a/tests/501-1000/819. most-common-word/sol.rb b/tests/501-1000/819. most-common-word/sol.rb new file mode 100644 index 00000000..e7f091d3 --- /dev/null +++ b/tests/501-1000/819. most-common-word/sol.rb @@ -0,0 +1,10 @@ +# @param {String} paragraph +# @param {String[]} banned +# @return {String} +def most_common_word(paragraph, banned) + banned_set = banned.to_set + words = paragraph.downcase.scan(/[a-z]+/) + counts = Hash.new(0) + words.each { |w| counts[w] += 1 unless banned_set.include?(w) } + counts.max_by { |k, v| v }[0] +end diff --git a/tests/501-1000/819. most-common-word/sol.rs b/tests/501-1000/819. most-common-word/sol.rs new file mode 100644 index 00000000..a0560349 --- /dev/null +++ b/tests/501-1000/819. most-common-word/sol.rs @@ -0,0 +1,15 @@ +impl Solution { + pub fn most_common_word(paragraph: String, banned: Vec) -> String { + use std::collections::{HashMap, HashSet}; + let banned_set: HashSet = banned.into_iter().collect(); + let mut counts = HashMap::new(); + let re = regex::Regex::new(r"[a-z]+").unwrap(); + for w in re.find_iter(¶graph.to_lowercase()) { + let w = w.as_str().to_string(); + if !banned_set.contains(&w) { + *counts.entry(w).or_insert(0) += 1; + } + } + counts.into_iter().max_by_key(|&(_, v)| v).unwrap().0 + } +} diff --git a/tests/501-1000/819. most-common-word/sol.swift b/tests/501-1000/819. most-common-word/sol.swift new file mode 100644 index 00000000..605c272b --- /dev/null +++ b/tests/501-1000/819. most-common-word/sol.swift @@ -0,0 +1,13 @@ +class Solution { + func mostCommonWord(_ paragraph: String, _ banned: [String]) -> String { + let bannedSet = Set(banned) + var counts = [String: Int]() + let words = paragraph.lowercased().split { !$0.isLetter }.map(String.init) + for w in words { + if !bannedSet.contains(w) { + counts[w, default: 0] += 1 + } + } + return counts.max { $0.value < $1.value }!.key + } +} diff --git a/tests/501-1000/819. most-common-word/sol.ts b/tests/501-1000/819. most-common-word/sol.ts new file mode 100644 index 00000000..45ce3bfb --- /dev/null +++ b/tests/501-1000/819. most-common-word/sol.ts @@ -0,0 +1,19 @@ +function mostCommonWord(paragraph: string, banned: string[]): string { + const bannedSet = new Set(banned); + const counts: Map = new Map(); + const words = paragraph.toLowerCase().split(/[^a-z]+/); + for (const w of words) { + if (w && !bannedSet.has(w)) { + counts.set(w, (counts.get(w) || 0) + 1); + } + } + let result = ""; + let maxCount = 0; + for (const [k, v] of counts) { + if (v > maxCount) { + maxCount = v; + result = k; + } + } + return result; +} diff --git a/tests/501-1000/820. short-encoding-of-words/manifest.yaml b/tests/501-1000/820. short-encoding-of-words/manifest.yaml new file mode 100644 index 00000000..bb62a051 --- /dev/null +++ b/tests/501-1000/820. short-encoding-of-words/manifest.yaml @@ -0,0 +1,273 @@ +entry: + id: 820 + title: short-encoding-of-words + params: + words: + type: array + items: + type: string + call: + cpp: Solution().minimumLengthEncoding({words}) + rust: Solution::minimum_length_encoding({words}) + python3: Solution().minimumLengthEncoding({words}) + python2: Solution().minimumLengthEncoding({words}) + ruby: minimum_length_encoding({words}) + java: new Solution().minimumLengthEncoding({words}) + csharp: new Solution().MinimumLengthEncoding({words}) + kotlin: Solution().minimumLengthEncoding({words}) + go: minimumLengthEncoding({words}) + dart: Solution().minimumLengthEncoding({words}) + swift: Solution().minimumLengthEncoding({words}) + typescript: minimumLengthEncoding({words}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().minimumLengthEncoding(words, {result}) + checker: + "class Checker:\n def minimumLengthEncoding(self, words, result):\n\ + \ if not isinstance(result, int):\n return False\n \ + \ words = list(set(words))\n words.sort(key=len, reverse=True)\n \ + \ seen = set()\n total = 0\n for word in words:\n \ + \ if word in seen:\n continue\n total += len(word)\ + \ + 1\n for i in range(len(word)):\n seen.add(word[i:])\n\ + \ return result == total\n" +seed: 820 +tests: + - name: ex1 + in: + words: + - time + - me + - bell + - name: ex2 + in: + words: + - t + - name: dup + in: + words: + - time + - time + - me + - name: suffix_chain + in: + words: + - a + - ba + - cba + - dcba + - name: no_overlap + in: + words: + - go + - dog + - cat + - name: all_same + in: + words: + - aa + - aa + - aa + - name: nested + in: + words: + - me + - time + - ime + - e + - name: shorts + in: + words: + - a + - b + - c + - name: mix1 + in: + words: + - fever + - ever + - ver + - er + - r + - name: mix2 + in: + words: + - abc + - xbc + - bc + - c + - name: mix3 + in: + words: + - abcdef + - def + - ef + - f + - name: mix4 + in: + words: + - xyz + - yz + - z + - xy + - name: mix5 + in: + words: + - hello + - ello + - llo + - lo + - o + - name: mix6 + in: + words: + - ab + - bab + - cab + - name: mix7 + in: + words: + - tt + - ttt + - tttt + - name: mix8 + in: + words: + - code + - leetcode + - eetcode + - name: mix9 + in: + words: + - sun + - fun + - run + - name: mix10 + in: + words: + - one + - tone + - stone + - name: mix11 + in: + words: + - abcde + - bcde + - cde + - name: mix12 + in: + words: + - k + - kk + - kkk + - kkkk + - name: mix13 + in: + words: + - qwerty + - werty + - erty + - rty + - name: mix14 + in: + words: + - end + - bend + - send + - tend + - name: mix15 + in: + words: + - aaa + - baa + - caa + - name: mix16 + in: + words: + - zx + - x + - yx + - name: mix17 + in: + words: + - alpha + - lpha + - pha + - ha + - a + - name: mix18 + in: + words: + - bbb + - bb + - b + - name: mix19 + in: + words: + - mno + - "no" + - o + - p + - name: mix20 + in: + words: + - x + - xy + - xyz + - name: mix21 + in: + words: + - abca + - bca + - ca + - a + - name: mix22 + in: + words: + - moon + - soon + - noon + - name: mix23 + in: + words: + - red + - ed + - d + - blue + - name: mix24 + in: + words: + - longword + - word + - ord + - rd + - d + - name: mix25 + in: + words: + - p + - qp + - rqp + - name: mix26 + in: + words: + - abcabc + - bcabc + - cabc + - name: mix27 + in: + words: + - abc + - def + - ghi + - name: mix28 + in: + words: + - zz + - zzz + - zzzz + - yzzzz diff --git a/tests/501-1000/820. short-encoding-of-words/sol.cpp b/tests/501-1000/820. short-encoding-of-words/sol.cpp new file mode 100644 index 00000000..52d4697e --- /dev/null +++ b/tests/501-1000/820. short-encoding-of-words/sol.cpp @@ -0,0 +1,32 @@ +class Solution { +public: + int minimumLengthEncoding(vector& words) { + unordered_set unique(words.begin(), words.end()); + words.assign(unique.begin(), unique.end()); + TrieNode* trie = new TrieNode(); + vector nodes; + for (const auto& word : words) { + TrieNode* node = trie; + for (int i = word.size() - 1; i >= 0; i--) { + char ch = word[i]; + if (!node->children.count(ch)) { + node->children[ch] = new TrieNode(); + } + node = node->children[ch]; + } + nodes.push_back(node); + } + int ans = 0; + for (int i = 0; i < words.size(); i++) { + if (nodes[i]->children.empty()) { + ans += words[i].size() + 1; + } + } + return ans; + } + +private: + struct TrieNode { + unordered_map children; + }; +}; diff --git a/tests/501-1000/820. short-encoding-of-words/sol.cs b/tests/501-1000/820. short-encoding-of-words/sol.cs new file mode 100644 index 00000000..9ce9b96f --- /dev/null +++ b/tests/501-1000/820. short-encoding-of-words/sol.cs @@ -0,0 +1,29 @@ +public class Solution { + public int MinimumLengthEncoding(string[] words) { + words = new HashSet(words).ToArray(); + var trie = new TrieNode(); + var nodes = new TrieNode[words.Length]; + for (int i = 0; i < words.Length; i++) { + var node = trie; + for (int j = words[i].Length - 1; j >= 0; j--) { + char ch = words[i][j]; + if (!node.Children.ContainsKey(ch)) { + node.Children[ch] = new TrieNode(); + } + node = node.Children[ch]; + } + nodes[i] = node; + } + int ans = 0; + for (int i = 0; i < words.Length; i++) { + if (nodes[i].Children.Count == 0) { + ans += words[i].Length + 1; + } + } + return ans; + } + + private class TrieNode { + public Dictionary Children = new Dictionary(); + } +} diff --git a/tests/501-1000/820. short-encoding-of-words/sol.dart b/tests/501-1000/820. short-encoding-of-words/sol.dart new file mode 100644 index 00000000..2be34c1b --- /dev/null +++ b/tests/501-1000/820. short-encoding-of-words/sol.dart @@ -0,0 +1,25 @@ +class Solution { + int minimumLengthEncoding(List words) { + words = words.toSet().toList(); + var trie = TrieNode(); + var nodes = []; + for (var word in words) { + var node = trie; + for (var i = word.length - 1; i >= 0; i--) { + node = node.children.putIfAbsent(word[i], () => TrieNode()); + } + nodes.add(node); + } + var ans = 0; + for (var i = 0; i < words.length; i++) { + if (nodes[i].children.isEmpty) { + ans += words[i].length + 1; + } + } + return ans; + } +} + +class TrieNode { + Map children = {}; +} diff --git a/tests/501-1000/820. short-encoding-of-words/sol.go b/tests/501-1000/820. short-encoding-of-words/sol.go new file mode 100644 index 00000000..025d16fc --- /dev/null +++ b/tests/501-1000/820. short-encoding-of-words/sol.go @@ -0,0 +1,36 @@ +func minimumLengthEncoding(words []string) int { + seen := make(map[string]bool) + for _, w := range words { + seen[w] = true + } + unique := make([]string, 0, len(seen)) + for w := range seen { + unique = append(unique, w) + } + + trie := &TrieNode{children: make(map[byte]*TrieNode)} + nodes := make([]*TrieNode, len(unique)) + for i, word := range unique { + node := trie + for j := len(word) - 1; j >= 0; j-- { + ch := word[j] + if _, ok := node.children[ch]; !ok { + node.children[ch] = &TrieNode{children: make(map[byte]*TrieNode)} + } + node = node.children[ch] + } + nodes[i] = node + } + + ans := 0 + for i, word := range unique { + if len(nodes[i].children) == 0 { + ans += len(word) + 1 + } + } + return ans +} + +type TrieNode struct { + children map[byte]*TrieNode +} diff --git a/tests/501-1000/820. short-encoding-of-words/sol.java b/tests/501-1000/820. short-encoding-of-words/sol.java new file mode 100644 index 00000000..1fb39610 --- /dev/null +++ b/tests/501-1000/820. short-encoding-of-words/sol.java @@ -0,0 +1,26 @@ +class Solution { + public int minimumLengthEncoding(String[] words) { + Set unique = new HashSet<>(Arrays.asList(words)); + words = unique.toArray(new String[0]); + TrieNode trie = new TrieNode(); + TrieNode[] nodes = new TrieNode[words.length]; + for (int i = 0; i < words.length; i++) { + TrieNode node = trie; + for (int j = words[i].length() - 1; j >= 0; j--) { + node = node.children.computeIfAbsent(words[i].charAt(j), k -> new TrieNode()); + } + nodes[i] = node; + } + int ans = 0; + for (int i = 0; i < words.length; i++) { + if (nodes[i].children.isEmpty()) { + ans += words[i].length() + 1; + } + } + return ans; + } + + static class TrieNode { + Map children = new HashMap<>(); + } +} diff --git a/tests/501-1000/820. short-encoding-of-words/sol.kt b/tests/501-1000/820. short-encoding-of-words/sol.kt new file mode 100644 index 00000000..00db6fdc --- /dev/null +++ b/tests/501-1000/820. short-encoding-of-words/sol.kt @@ -0,0 +1,20 @@ +class Solution { + fun minimumLengthEncoding(words: Array): Int { + val unique = words.toSet().toTypedArray() + val trie = TrieNode() + val nodes = unique.map { word -> + var node = trie + for (ch in word.reversed()) { + node = node.children.getOrPut(ch) { TrieNode() } + } + node + } + return unique.zip(nodes).sumOf { (word, node) -> + if (node.children.isEmpty()) word.length + 1 else 0 + } + } + + class TrieNode { + val children = mutableMapOf() + } +} diff --git a/tests/501-1000/820. short-encoding-of-words/sol.py b/tests/501-1000/820. short-encoding-of-words/sol.py new file mode 100644 index 00000000..4e1eb6f7 --- /dev/null +++ b/tests/501-1000/820. short-encoding-of-words/sol.py @@ -0,0 +1,13 @@ +from collections import defaultdict +from functools import reduce +from typing import List + + +class Solution: + def minimumLengthEncoding(self, words: List[str]) -> int: + words = list(set(words)) + trie = (d := lambda: defaultdict(d))() + nodes = [reduce(dict.__getitem__, word[::-1], trie) for word in words] + return sum( + (len(word) + 1) for word, node in zip(words, nodes) if len(node) == 0 + ) diff --git a/tests/501-1000/820. short-encoding-of-words/sol.py2 b/tests/501-1000/820. short-encoding-of-words/sol.py2 new file mode 100644 index 00000000..9108f3cc --- /dev/null +++ b/tests/501-1000/820. short-encoding-of-words/sol.py2 @@ -0,0 +1,9 @@ +class Solution: + def minimumLengthEncoding(self, words): + words = set(words) + total = 0 + for word in list(words): + if any(other != word and other.endswith(word) for other in words): + continue + total += len(word) + 1 + return total diff --git a/tests/501-1000/820. short-encoding-of-words/sol.rb b/tests/501-1000/820. short-encoding-of-words/sol.rb new file mode 100644 index 00000000..1023c5d1 --- /dev/null +++ b/tests/501-1000/820. short-encoding-of-words/sol.rb @@ -0,0 +1,10 @@ +# @param {String[]} words +# @return {Integer} +def minimum_length_encoding(words) + words = words.uniq + trie = Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) } + nodes = words.map do |word| + word.reverse.each_char.reduce(trie) { |node, ch| node[ch] } + end + words.zip(nodes).sum { |word, node| node.empty? ? word.length + 1 : 0 } +end diff --git a/tests/501-1000/820. short-encoding-of-words/sol.rs b/tests/501-1000/820. short-encoding-of-words/sol.rs new file mode 100644 index 00000000..a4c6b4f9 --- /dev/null +++ b/tests/501-1000/820. short-encoding-of-words/sol.rs @@ -0,0 +1,17 @@ +impl Solution { + pub fn minimum_length_encoding(words: Vec) -> i32 { + use std::collections::HashSet; + + let uniq: Vec = words.into_iter().collect::>().into_iter().collect(); + let mut ans = 0; + 'outer: for word in &uniq { + for other in &uniq { + if word != other && other.ends_with(word) { + continue 'outer; + } + } + ans += word.len() as i32 + 1; + } + ans + } +} diff --git a/tests/501-1000/820. short-encoding-of-words/sol.swift b/tests/501-1000/820. short-encoding-of-words/sol.swift new file mode 100644 index 00000000..fb02d92f --- /dev/null +++ b/tests/501-1000/820. short-encoding-of-words/sol.swift @@ -0,0 +1,31 @@ +class Solution { + func minimumLengthEncoding(_ words: [String]) -> Int { + let unique = Array(Set(words)) + let trie = TrieNode() + var nodes: [TrieNode] = [] + for word in unique { + var node = trie + for ch in word.reversed() { + if let next = node.children[ch] { + node = next + } else { + let newNode = TrieNode() + node.children[ch] = newNode + node = newNode + } + } + nodes.append(node) + } + var ans = 0 + for (i, word) in unique.enumerated() { + if nodes[i].children.isEmpty { + ans += word.count + 1 + } + } + return ans + } +} + +class TrieNode { + var children: [Character: TrieNode] = [:] +} diff --git a/tests/501-1000/820. short-encoding-of-words/sol.ts b/tests/501-1000/820. short-encoding-of-words/sol.ts new file mode 100644 index 00000000..1d717cec --- /dev/null +++ b/tests/501-1000/820. short-encoding-of-words/sol.ts @@ -0,0 +1,23 @@ +function minimumLengthEncoding(words: string[]): number { + words = [...new Set(words)]; + const trie: Record = {}; + const nodes: Record[] = []; + for (const word of words) { + let node = trie; + for (let i = word.length - 1; i >= 0; i--) { + const ch = word[i]; + if (!(ch in node)) { + node[ch] = {}; + } + node = node[ch]; + } + nodes.push(node); + } + let ans = 0; + for (let i = 0; i < words.length; i++) { + if (Object.keys(nodes[i]).length === 0) { + ans += words[i].length + 1; + } + } + return ans; +} diff --git a/tests/501-1000/821. shortest-distance-to-a-character/manifest.yaml b/tests/501-1000/821. shortest-distance-to-a-character/manifest.yaml new file mode 100644 index 00000000..71aa632f --- /dev/null +++ b/tests/501-1000/821. shortest-distance-to-a-character/manifest.yaml @@ -0,0 +1,215 @@ +entry: + id: 821 + title: shortest-distance-to-a-character + params: + s: + type: string + c: + type: char + call: + cpp: Solution().shortestToChar({s}, {c}) + rust: Solution::shortest_to_char({s}, {c}) + python3: Solution().shortestToChar({s}, {c}) + python2: Solution().shortestToChar({s}, {c}) + ruby: shortest_to_char({s}, {c}) + java: new Solution().shortestToChar({s}, {c}) + csharp: new Solution().ShortestToChar({s}, {c}) + kotlin: Solution().shortestToChar({s}, {c}) + go: shortestToChar({s}, {c}) + dart: Solution().shortestToChar({s}, {c}) + swift: Solution().shortestToChar({s}, {c}) + typescript: shortestToChar({s}, {c}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().check({result})" + checker: | + class Checker: + def check(self, result): + return isinstance(result, list) +seed: 821 +tests: + - name: example-1 + in: + s: loveleetcode + c: "e" + out: [3, 2, 1, 0, 1, 0, 0, 1, 2, 2, 1, 0] + - name: example-2 + in: + s: aaab + c: "b" + out: [3, 2, 1, 0] + - name: single + in: + s: a + c: "a" + out: [0] + - name: two-left + in: + s: ab + c: "a" + out: [0, 1] + - name: two-right + in: + s: ab + c: "b" + out: [1, 0] + - name: aba-a + in: + s: aba + c: "a" + out: [0, 1, 0] + - name: aba-b + in: + s: aba + c: "b" + out: [1, 0, 1] + - name: abca-a + in: + s: abca + c: "a" + out: [0, 1, 1, 0] + - name: abca-c + in: + s: abca + c: "c" + out: [2, 1, 0, 1] + - name: all-same + in: + s: zzzz + c: "z" + out: [0, 0, 0, 0] + - name: trailing-target + in: + s: zzzzy + c: "y" + out: [4, 3, 2, 1, 0] + - name: leading-target + in: + s: yzzzz + c: "y" + out: [0, 1, 2, 3, 4] + - name: abcde-a + in: + s: abcde + c: "a" + out: [0, 1, 2, 3, 4] + - name: abcde-e + in: + s: abcde + c: "e" + out: [4, 3, 2, 1, 0] + - name: abcde-c + in: + s: abcde + c: "c" + out: [2, 1, 0, 1, 2] + - name: alternating-a + in: + s: ababab + c: "a" + out: [0, 1, 0, 1, 0, 1] + - name: alternating-b + in: + s: ababab + c: "b" + out: [1, 0, 1, 0, 1, 0] + - name: baaaab-b + in: + s: baaaab + c: "b" + out: [0, 1, 2, 2, 1, 0] + - name: baaaab-a + in: + s: baaaab + c: "a" + out: [1, 0, 0, 0, 0, 1] + - name: aaaab-b + in: + s: aaaab + c: "b" + out: [4, 3, 2, 1, 0] + - name: bbaab-a + in: + s: bbaab + c: "a" + out: [2, 1, 0, 0, 1] + - name: cabba-c + in: + s: cabba + c: "c" + out: [0, 1, 2, 3, 4] + - name: cabba-b + in: + s: cabba + c: "b" + out: [2, 1, 0, 0, 1] + - name: mississippi-i + in: + s: mississippi + c: "i" + out: [1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0] + - name: mississippi-m + in: + s: mississippi + c: "m" + out: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + - name: leetcode-l + in: + s: leetcode + c: "l" + out: [0, 1, 2, 3, 4, 5, 6, 7] + - name: leetcode-t + in: + s: leetcode + c: "t" + out: [3, 2, 1, 0, 1, 2, 3, 4] + - name: prefix-run + in: + s: eeeeabc + c: "a" + out: [4, 3, 2, 1, 0, 1, 2] + - name: double-center + in: + s: abcdeedcba + c: "e" + out: [4, 3, 2, 1, 0, 0, 1, 2, 3, 4] + - name: aabbccdd-c + in: + s: aabbccdd + c: "c" + out: [4, 3, 2, 1, 0, 0, 1, 2] + - name: repeated-block-q + in: + s: qwertyqwerty + c: "q" + out: [0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 4, 5] + - name: long-tail + in: + s: xxxxxxxxxy + c: "y" + out: [9, 8, 7, 6, 5, 4, 3, 2, 1, 0] + - name: long-head + in: + s: yxxxxxxxxx + c: "y" + out: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + - name: symmetric-a + in: + s: abbbbba + c: "a" + out: [0, 1, 2, 3, 2, 1, 0] + - name: repeated-b + in: + s: abcabcabc + c: "b" + out: [1, 0, 1, 1, 0, 1, 1, 0, 1] + - name: centered-a + in: + s: ccccabcccc + c: "a" + out: [4, 3, 2, 1, 0, 1, 2, 3, 4, 5] diff --git a/tests/501-1000/821. shortest-distance-to-a-character/sol.cpp b/tests/501-1000/821. shortest-distance-to-a-character/sol.cpp new file mode 100644 index 00000000..290ff947 --- /dev/null +++ b/tests/501-1000/821. shortest-distance-to-a-character/sol.cpp @@ -0,0 +1,22 @@ +class Solution { +public: + vector shortestToChar(string s, char c) { + int n = s.size(); + vector ans(n, n); + int prev = -n; + for (int i = 0; i < n; i++) { + if (s[i] == c) { + prev = i; + } + ans[i] = i - prev; + } + prev = 2 * n; + for (int i = n - 1; i >= 0; i--) { + if (s[i] == c) { + prev = i; + } + ans[i] = min(ans[i], prev - i); + } + return ans; + } +}; diff --git a/tests/501-1000/821. shortest-distance-to-a-character/sol.cs b/tests/501-1000/821. shortest-distance-to-a-character/sol.cs new file mode 100644 index 00000000..c486711c --- /dev/null +++ b/tests/501-1000/821. shortest-distance-to-a-character/sol.cs @@ -0,0 +1,21 @@ +public class Solution { + public int[] ShortestToChar(string s, char c) { + int n = s.Length; + int[] ans = new int[n]; + int prev = -n; + for (int i = 0; i < n; i++) { + if (s[i] == c) { + prev = i; + } + ans[i] = i - prev; + } + prev = 2 * n; + for (int i = n - 1; i >= 0; i--) { + if (s[i] == c) { + prev = i; + } + ans[i] = Math.Min(ans[i], prev - i); + } + return ans; + } +} diff --git a/tests/501-1000/821. shortest-distance-to-a-character/sol.dart b/tests/501-1000/821. shortest-distance-to-a-character/sol.dart new file mode 100644 index 00000000..8a6ccfc4 --- /dev/null +++ b/tests/501-1000/821. shortest-distance-to-a-character/sol.dart @@ -0,0 +1,21 @@ +class Solution { + List shortestToChar(String s, String c) { + int n = s.length; + List ans = List.filled(n, n); + int prev = -n; + for (int i = 0; i < n; i++) { + if (s[i] == c) { + prev = i; + } + ans[i] = i - prev; + } + prev = 2 * n; + for (int i = n - 1; i >= 0; i--) { + if (s[i] == c) { + prev = i; + } + ans[i] = ans[i] < prev - i ? ans[i] : prev - i; + } + return ans; + } +} diff --git a/tests/501-1000/821. shortest-distance-to-a-character/sol.go b/tests/501-1000/821. shortest-distance-to-a-character/sol.go new file mode 100644 index 00000000..35afc99b --- /dev/null +++ b/tests/501-1000/821. shortest-distance-to-a-character/sol.go @@ -0,0 +1,21 @@ +func shortestToChar(s string, c byte) []int { + n := len(s) + ans := make([]int, n) + prev := -n + for i := 0; i < n; i++ { + if s[i] == c { + prev = i + } + ans[i] = i - prev + } + prev = 2 * n + for i := n - 1; i >= 0; i-- { + if s[i] == c { + prev = i + } + if prev-i < ans[i] { + ans[i] = prev - i + } + } + return ans +} diff --git a/tests/501-1000/821. shortest-distance-to-a-character/sol.java b/tests/501-1000/821. shortest-distance-to-a-character/sol.java new file mode 100644 index 00000000..b5cba024 --- /dev/null +++ b/tests/501-1000/821. shortest-distance-to-a-character/sol.java @@ -0,0 +1,21 @@ +class Solution { + public int[] shortestToChar(String s, char c) { + int n = s.length(); + int[] ans = new int[n]; + int prev = -n; + for (int i = 0; i < n; i++) { + if (s.charAt(i) == c) { + prev = i; + } + ans[i] = i - prev; + } + prev = 2 * n; + for (int i = n - 1; i >= 0; i--) { + if (s.charAt(i) == c) { + prev = i; + } + ans[i] = Math.min(ans[i], prev - i); + } + return ans; + } +} diff --git a/tests/501-1000/821. shortest-distance-to-a-character/sol.kt b/tests/501-1000/821. shortest-distance-to-a-character/sol.kt new file mode 100644 index 00000000..07d52107 --- /dev/null +++ b/tests/501-1000/821. shortest-distance-to-a-character/sol.kt @@ -0,0 +1,21 @@ +class Solution { + fun shortestToChar(s: String, c: Char): IntArray { + val n = s.length + val ans = IntArray(n) + var prev = -n + for (i in 0 until n) { + if (s[i] == c) { + prev = i + } + ans[i] = i - prev + } + prev = 2 * n + for (i in n - 1 downTo 0) { + if (s[i] == c) { + prev = i + } + ans[i] = minOf(ans[i], prev - i) + } + return ans + } +} diff --git a/tests/501-1000/821. shortest-distance-to-a-character/sol.py b/tests/501-1000/821. shortest-distance-to-a-character/sol.py new file mode 100644 index 00000000..efbf11ec --- /dev/null +++ b/tests/501-1000/821. shortest-distance-to-a-character/sol.py @@ -0,0 +1,18 @@ +from typing import List + + +class Solution: + def shortestToChar(self, s, c): + n = len(s) + ans = [n] * n + prev = -n + for i, ch in enumerate(s): + if ch == c: + prev = i + ans[i] = i - prev + prev = 2 * n + for i in range(n - 1, -1, -1): + if s[i] == c: + prev = i + ans[i] = min(ans[i], prev - i) + return ans diff --git a/tests/501-1000/821. shortest-distance-to-a-character/sol.py2 b/tests/501-1000/821. shortest-distance-to-a-character/sol.py2 new file mode 100644 index 00000000..98cc5518 --- /dev/null +++ b/tests/501-1000/821. shortest-distance-to-a-character/sol.py2 @@ -0,0 +1,20 @@ +class Solution(object): + def shortestToChar(self, s, c): + """ + :type s: str + :type c: str + :rtype: List[int] + """ + n = len(s) + ans = [n] * n + prev = -n + for i, ch in enumerate(s): + if ch == c: + prev = i + ans[i] = i - prev + prev = 2 * n + for i in range(n - 1, -1, -1): + if s[i] == c: + prev = i + ans[i] = min(ans[i], prev - i) + return ans diff --git a/tests/501-1000/821. shortest-distance-to-a-character/sol.rb b/tests/501-1000/821. shortest-distance-to-a-character/sol.rb new file mode 100644 index 00000000..f5088b84 --- /dev/null +++ b/tests/501-1000/821. shortest-distance-to-a-character/sol.rb @@ -0,0 +1,22 @@ +# @param {String} s +# @param {Character} c +# @return {Integer[]} +def shortest_to_char(s, c) + n = s.length + ans = Array.new(n, n) + prev = -n + s.chars.each_with_index do |ch, i| + if ch == c + prev = i + end + ans[i] = i - prev + end + prev = 2 * n + (n - 1).downto(0) do |i| + if s[i] == c + prev = i + end + ans[i] = [ans[i], prev - i].min + end + ans +end diff --git a/tests/501-1000/821. shortest-distance-to-a-character/sol.rs b/tests/501-1000/821. shortest-distance-to-a-character/sol.rs new file mode 100644 index 00000000..e0003f5e --- /dev/null +++ b/tests/501-1000/821. shortest-distance-to-a-character/sol.rs @@ -0,0 +1,22 @@ +impl Solution { + pub fn shortest_to_char(s: String, c: char) -> Vec { + let n = s.len() as i32; + let mut ans = vec![n; n as usize]; + let mut prev = -n; + for (i, ch) in s.chars().enumerate() { + if ch == c { + prev = i as i32; + } + ans[i] = i as i32 - prev; + } + prev = 2 * n; + for (i, ch) in s.chars().rev().enumerate() { + let idx = (n as usize) - 1 - i; + if ch == c { + prev = idx as i32; + } + ans[idx] = ans[idx].min(prev - idx as i32); + } + ans + } +} diff --git a/tests/501-1000/821. shortest-distance-to-a-character/sol.swift b/tests/501-1000/821. shortest-distance-to-a-character/sol.swift new file mode 100644 index 00000000..7e03dffb --- /dev/null +++ b/tests/501-1000/821. shortest-distance-to-a-character/sol.swift @@ -0,0 +1,22 @@ +class Solution { + func shortestToChar(_ s: String, _ c: Character) -> [Int] { + let n = s.count + var ans = Array(repeating: n, count: n) + var prev = -n + let chars = Array(s) + for i in 0..= 0; i--) { + if (s[i] === c) { + prev = i; + } + ans[i] = Math.min(ans[i], prev - i); + } + return ans; +} diff --git a/tests/501-1000/822. card-flipping-game/manifest.yaml b/tests/501-1000/822. card-flipping-game/manifest.yaml new file mode 100644 index 00000000..6e67ae7c --- /dev/null +++ b/tests/501-1000/822. card-flipping-game/manifest.yaml @@ -0,0 +1,471 @@ +entry: + id: 822 + title: card-flipping-game + params: + fronts: + type: array + items: + type: int + backs: + type: array + items: + type: int + call: + cpp: Solution().flipgame({fronts}, {backs}) + rust: Solution::flipgame({fronts}, {backs}) + python3: Solution().flipgame({fronts}, {backs}) + python2: Solution().flipgame({fronts}, {backs}) + ruby: flipgame({fronts}, {backs}) + java: new Solution().flipgame({fronts}, {backs}) + csharp: new Solution().Flipgame({fronts}, {backs}) + kotlin: Solution().flipgame({fronts}, {backs}) + go: flipgame({fronts}, {backs}) + dart: Solution().flipgame({fronts}, {backs}) + swift: Solution().flipgame({fronts}, {backs}) + typescript: flipgame({fronts}, {backs}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 128 +oracle: + python3: + call: Checker().check(fronts, backs, {result}) + checker: | + class Checker: + def check(self, fronts, backs, result): + return isinstance(result, int) +seed: 822 +tests: + - name: ex1 + in: + fronts: + - 1 + - 2 + - 4 + - 4 + - 7 + backs: + - 1 + - 3 + - 4 + - 1 + - 3 + out: 2 + - name: ex2 + in: + fronts: + - 1 + backs: + - 1 + out: 0 + - name: two_cards_swap + in: + fronts: + - 1 + - 2 + backs: + - 2 + - 1 + out: 1 + - name: all_pairs_same + in: + fronts: + - 2 + - 2 + backs: + - 2 + - 3 + out: 3 + - name: no_good_due_to_same + in: + fronts: + - 5 + - 6 + - 7 + backs: + - 1 + - 1 + - 1 + out: 1 + - name: duplicate_fronts + in: + fronts: + - 1 + - 1 + - 1 + backs: + - 2 + - 3 + - 4 + out: 1 + - name: all_same_both + in: + fronts: + - 2 + - 3 + - 4 + backs: + - 2 + - 3 + - 4 + out: 0 + - name: increasing_values + in: + fronts: + - 1 + - 3 + - 5 + backs: + - 2 + - 4 + - 6 + out: 1 + - name: mirrored_values + in: + fronts: + - 10 + - 20 + - 30 + backs: + - 30 + - 20 + - 10 + out: 10 + - name: mixed_small + in: + fronts: + - 2 + - 8 + - 6 + backs: + - 6 + - 8 + - 2 + out: 2 + - name: single_good_back + in: + fronts: + - 9 + backs: + - 8 + out: 8 + - name: single_bad_same + in: + fronts: + - 8 + backs: + - 8 + out: 0 + - name: two_good_candidates + in: + fronts: + - 4 + - 5 + backs: + - 6 + - 7 + out: 4 + - name: same_good_values + in: + fronts: + - 4 + - 5 + backs: + - 5 + - 4 + out: 4 + - name: same_on_front_bad + in: + fronts: + - 6 + - 1 + backs: + - 6 + - 2 + out: 1 + - name: all_back_small + in: + fronts: + - 9 + - 9 + - 9 + backs: + - 1 + - 2 + - 3 + out: 1 + - name: all_front_small + in: + fronts: + - 1 + - 2 + - 3 + backs: + - 9 + - 9 + - 9 + out: 1 + - name: contains_zero_answer + in: + fronts: + - 2 + - 3 + - 4 + - 5 + backs: + - 2 + - 1 + - 4 + - 6 + out: 1 + - name: all_equal_nonbad + in: + fronts: + - 7 + - 7 + - 7 + backs: + - 8 + - 9 + - 10 + out: 7 + - name: scattered + in: + fronts: + - 12 + - 14 + - 16 + - 18 + backs: + - 13 + - 15 + - 17 + - 19 + out: 12 + - name: min_edge + in: + fronts: + - 1 + - 2 + - 3 + - 4 + backs: + - 4 + - 3 + - 2 + - 1 + out: 1 + - name: max_edge + in: + fronts: + - 2000 + - 1999 + backs: + - 1998 + - 1997 + out: 1997 + - name: max_edge_bad + in: + fronts: + - 2000 + - 2000 + backs: + - 2000 + - 1999 + out: 1999 + - name: mix_duplicate_fronts + in: + fronts: + - 11 + - 11 + - 12 + backs: + - 13 + - 14 + - 15 + out: 11 + - name: mix_duplicate_backs + in: + fronts: + - 13 + - 14 + - 15 + backs: + - 11 + - 11 + - 12 + out: 11 + - name: unavoidable_zero + in: + fronts: + - 1 + - 2 + - 1 + backs: + - 1 + - 2 + - 1 + out: 0 + - name: min_back_only + in: + fronts: + - 3 + - 4 + - 5 + backs: + - 2 + - 2 + - 2 + out: 2 + - name: alternating + in: + fronts: + - 4 + - 1 + - 6 + - 2 + backs: + - 5 + - 3 + - 7 + - 8 + out: 1 + - name: same_front_back_mix + in: + fronts: + - 9 + - 10 + - 11 + - 12 + backs: + - 9 + - 13 + - 14 + - 15 + out: 10 + - name: another_mix + in: + fronts: + - 20 + - 21 + - 22 + - 23 + backs: + - 24 + - 20 + - 25 + - 26 + out: 20 + - name: low_values + in: + fronts: + - 2 + - 3 + - 4 + - 5 + - 6 + backs: + - 7 + - 8 + - 9 + - 10 + - 11 + out: 2 + - name: repeated_nonbad + in: + fronts: + - 30 + - 30 + - 31 + backs: + - 32 + - 33 + - 34 + out: 30 + - name: repeated_with_bad + in: + fronts: + - 40 + - 41 + - 41 + backs: + - 41 + - 42 + - 43 + out: 40 + - name: last_small + in: + fronts: + - 50 + - 60 + - 70 + backs: + - 80 + - 90 + - 100 + out: 50 + - name: min-singleton-bad + in: + fronts: + - 1 + backs: + - 1 + out: 0 + - name: large-gap + in: + fronts: + - 100 + - 200 + - 300 + backs: + - 400 + - 500 + - 600 + out: 100 + - name: duplicate-good-candidate + in: + fronts: + - 15 + - 15 + - 16 + - 17 + backs: + - 18 + - 19 + - 20 + - 21 + out: 15 + - name: bad-candidate-hidden + in: + fronts: + - 25 + - 26 + - 27 + backs: + - 25 + - 28 + - 29 + out: 26 + - name: no-bad-minimal + in: + fronts: + - 1 + - 4 + - 7 + backs: + - 2 + - 5 + - 8 + out: 1 + - name: duplicate-good-high + in: + fronts: + - 10 + - 10 + - 11 + backs: + - 12 + - 13 + - 14 + out: 10 diff --git a/tests/501-1000/822. card-flipping-game/sol.cpp b/tests/501-1000/822. card-flipping-game/sol.cpp new file mode 100644 index 00000000..03086d2a --- /dev/null +++ b/tests/501-1000/822. card-flipping-game/sol.cpp @@ -0,0 +1,21 @@ +class Solution { +public: + int flipgame(vector& fronts, vector& backs) { + unordered_set bad; + for (int i = 0; i < fronts.size(); i++) { + if (fronts[i] == backs[i]) { + bad.insert(fronts[i]); + } + } + int best = 2001; + for (int i = 0; i < fronts.size(); i++) { + if (bad.find(fronts[i]) == bad.end() && fronts[i] < best) { + best = fronts[i]; + } + if (bad.find(backs[i]) == bad.end() && backs[i] < best) { + best = backs[i]; + } + } + return best <= 2000 ? best : 0; + } +}; diff --git a/tests/501-1000/822. card-flipping-game/sol.cs b/tests/501-1000/822. card-flipping-game/sol.cs new file mode 100644 index 00000000..95d8167b --- /dev/null +++ b/tests/501-1000/822. card-flipping-game/sol.cs @@ -0,0 +1,20 @@ +public class Solution { + public int Flipgame(int[] fronts, int[] backs) { + HashSet bad = new HashSet(); + for (int i = 0; i < fronts.Length; i++) { + if (fronts[i] == backs[i]) { + bad.Add(fronts[i]); + } + } + int best = 2001; + for (int i = 0; i < fronts.Length; i++) { + if (!bad.Contains(fronts[i]) && fronts[i] < best) { + best = fronts[i]; + } + if (!bad.Contains(backs[i]) && backs[i] < best) { + best = backs[i]; + } + } + return best <= 2000 ? best : 0; + } +} diff --git a/tests/501-1000/822. card-flipping-game/sol.dart b/tests/501-1000/822. card-flipping-game/sol.dart new file mode 100644 index 00000000..37247a51 --- /dev/null +++ b/tests/501-1000/822. card-flipping-game/sol.dart @@ -0,0 +1,20 @@ +class Solution { + int flipgame(List fronts, List backs) { + var bad = {}; + for (int i = 0; i < fronts.length; i++) { + if (fronts[i] == backs[i]) { + bad.add(fronts[i]); + } + } + int best = 2001; + for (int i = 0; i < fronts.length; i++) { + if (!bad.contains(fronts[i]) && fronts[i] < best) { + best = fronts[i]; + } + if (!bad.contains(backs[i]) && backs[i] < best) { + best = backs[i]; + } + } + return best <= 2000 ? best : 0; + } +} diff --git a/tests/501-1000/822. card-flipping-game/sol.go b/tests/501-1000/822. card-flipping-game/sol.go new file mode 100644 index 00000000..0b7b712b --- /dev/null +++ b/tests/501-1000/822. card-flipping-game/sol.go @@ -0,0 +1,21 @@ +func flipgame(fronts []int, backs []int) int { + bad := make(map[int]bool) + for i := 0; i < len(fronts); i++ { + if fronts[i] == backs[i] { + bad[fronts[i]] = true + } + } + best := 2001 + for i := 0; i < len(fronts); i++ { + if !bad[fronts[i]] && fronts[i] < best { + best = fronts[i] + } + if !bad[backs[i]] && backs[i] < best { + best = backs[i] + } + } + if best <= 2000 { + return best + } + return 0 +} diff --git a/tests/501-1000/822. card-flipping-game/sol.java b/tests/501-1000/822. card-flipping-game/sol.java new file mode 100644 index 00000000..c8673998 --- /dev/null +++ b/tests/501-1000/822. card-flipping-game/sol.java @@ -0,0 +1,20 @@ +class Solution { + public int flipgame(int[] fronts, int[] backs) { + java.util.HashSet bad = new java.util.HashSet<>(); + for (int i = 0; i < fronts.length; i++) { + if (fronts[i] == backs[i]) { + bad.add(fronts[i]); + } + } + int best = 2001; + for (int i = 0; i < fronts.length; i++) { + if (!bad.contains(fronts[i]) && fronts[i] < best) { + best = fronts[i]; + } + if (!bad.contains(backs[i]) && backs[i] < best) { + best = backs[i]; + } + } + return best <= 2000 ? best : 0; + } +} diff --git a/tests/501-1000/822. card-flipping-game/sol.kt b/tests/501-1000/822. card-flipping-game/sol.kt new file mode 100644 index 00000000..852f911c --- /dev/null +++ b/tests/501-1000/822. card-flipping-game/sol.kt @@ -0,0 +1,20 @@ +class Solution { + fun flipgame(fronts: IntArray, backs: IntArray): Int { + val bad = HashSet() + for (i in fronts.indices) { + if (fronts[i] == backs[i]) { + bad.add(fronts[i]) + } + } + var best = 2001 + for (i in fronts.indices) { + if (fronts[i] !in bad && fronts[i] < best) { + best = fronts[i] + } + if (backs[i] !in bad && backs[i] < best) { + best = backs[i] + } + } + return if (best <= 2000) best else 0 + } +} diff --git a/tests/501-1000/822. card-flipping-game/sol.py b/tests/501-1000/822. card-flipping-game/sol.py new file mode 100644 index 00000000..af6986e0 --- /dev/null +++ b/tests/501-1000/822. card-flipping-game/sol.py @@ -0,0 +1,10 @@ +class Solution(object): + def flipgame(self, fronts, backs): + bad = {a for a, b in zip(fronts, backs) if a == b} + best = 2001 + for a, b in zip(fronts, backs): + if a not in bad and a < best: + best = a + if b not in bad and b < best: + best = b + return best if best <= 2000 else 0 diff --git a/tests/501-1000/822. card-flipping-game/sol.py2 b/tests/501-1000/822. card-flipping-game/sol.py2 new file mode 100644 index 00000000..d9727d33 --- /dev/null +++ b/tests/501-1000/822. card-flipping-game/sol.py2 @@ -0,0 +1,15 @@ +class Solution(object): + def flipgame(self, fronts, backs): + """ + :type fronts: List[int] + :type backs: List[int] + :rtype: int + """ + bad = {a for a, b in zip(fronts, backs) if a == b} + best = 2001 + for a, b in zip(fronts, backs): + if a not in bad and a < best: + best = a + if b not in bad and b < best: + best = b + return best if best <= 2000 else 0 diff --git a/tests/501-1000/822. card-flipping-game/sol.rb b/tests/501-1000/822. card-flipping-game/sol.rb new file mode 100644 index 00000000..35b776e3 --- /dev/null +++ b/tests/501-1000/822. card-flipping-game/sol.rb @@ -0,0 +1,19 @@ +# @param {Integer[]} fronts +# @param {Integer[]} backs +# @return {Integer} +def flipgame(fronts, backs) + bad = Set.new + fronts.zip(backs).each do |a, b| + bad.add(a) if a == b + end + best = 2001 + fronts.zip(backs).each do |a, b| + if !bad.include?(a) && a < best + best = a + end + if !bad.include?(b) && b < best + best = b + end + end + best <= 2000 ? best : 0 +end diff --git a/tests/501-1000/822. card-flipping-game/sol.rs b/tests/501-1000/822. card-flipping-game/sol.rs new file mode 100644 index 00000000..cef08569 --- /dev/null +++ b/tests/501-1000/822. card-flipping-game/sol.rs @@ -0,0 +1,20 @@ +impl Solution { + pub fn flipgame(fronts: Vec, backs: Vec) -> i32 { + let mut bad = std::collections::HashSet::new(); + for i in 0..fronts.len() { + if fronts[i] == backs[i] { + bad.insert(fronts[i]); + } + } + let mut best = 2001; + for i in 0..fronts.len() { + if !bad.contains(&fronts[i]) && fronts[i] < best { + best = fronts[i]; + } + if !bad.contains(&backs[i]) && backs[i] < best { + best = backs[i]; + } + } + if best <= 2000 { best } else { 0 } + } +} diff --git a/tests/501-1000/822. card-flipping-game/sol.swift b/tests/501-1000/822. card-flipping-game/sol.swift new file mode 100644 index 00000000..50ff4d0d --- /dev/null +++ b/tests/501-1000/822. card-flipping-game/sol.swift @@ -0,0 +1,20 @@ +class Solution { + func flipgame(_ fronts: [Int], _ backs: [Int]) -> Int { + var bad = Set() + for i in 0..(); + for (let i = 0; i < fronts.length; i++) { + if (fronts[i] === backs[i]) { + bad.add(fronts[i]); + } + } + let best = 2001; + for (let i = 0; i < fronts.length; i++) { + if (!bad.has(fronts[i]) && fronts[i] < best) { + best = fronts[i]; + } + if (!bad.has(backs[i]) && backs[i] < best) { + best = backs[i]; + } + } + return best <= 2000 ? best : 0; +} diff --git a/tests/501-1000/823. binary-trees-with-factors/manifest.yaml b/tests/501-1000/823. binary-trees-with-factors/manifest.yaml new file mode 100644 index 00000000..227554e3 --- /dev/null +++ b/tests/501-1000/823. binary-trees-with-factors/manifest.yaml @@ -0,0 +1,179 @@ +entry: + id: 823 + title: binary-trees-with-factors + params: + arr: + type: array + items: + type: int + call: + cpp: Solution().numFactoredBinaryTrees({arr}) + rust: Solution::num_factored_binary_trees({arr}) + python3: Solution().numFactoredBinaryTrees({arr}) + python2: Solution().numFactoredBinaryTrees({arr}) + ruby: num_factored_binary_trees({arr}) + java: new Solution().numFactoredBinaryTrees({arr}) + csharp: new Solution().NumFactoredBinaryTrees({arr}) + kotlin: Solution().numFactoredBinaryTrees({arr}) + go: numFactoredBinaryTrees({arr}) + dart: Solution().numFactoredBinaryTrees({arr}) + swift: Solution().numFactoredBinaryTrees({arr}) + typescript: numFactoredBinaryTrees({arr}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 128 +oracle: + python3: + call: Checker().check(arr, {result}) + checker: | + class Checker: + def check(self, arr, result): + return isinstance(result, int) +seed: 823 +tests: + - name: ex1 + in: + arr: [2, 4] + out: 3 + - name: ex2 + in: + arr: [2, 4, 5, 10] + out: 7 + - name: single_small + in: + arr: [18] + out: 1 + - name: pair_two_three + in: + arr: [2, 3, 6] + out: 5 + - name: chain_12 + in: + arr: [2, 3, 4, 6, 12] + out: 18 + - name: powers_two + in: + arr: [2, 4, 8, 16] + out: 23 + - name: five_values + in: + arr: [2, 5, 10, 20, 25, 50] + out: 25 + - name: mixed_chain + in: + arr: [3, 6, 9, 18] + out: 7 + - name: longer_chain + in: + arr: [2, 6, 12, 24, 48] + out: 27 + - name: another_mixed + in: + arr: [2, 4, 5, 8, 10, 20] + out: 23 + - name: prime_only + in: + arr: [3, 5, 7, 11, 13] + out: 5 + - name: two_primes + in: + arr: [17, 19] + out: 2 + - name: sorted_input + in: + arr: [2, 8, 4] + out: 8 + - name: no_factors + in: + arr: [2, 7, 11] + out: 3 + - name: simple_mult + in: + arr: [2, 4, 8] + out: 8 + - name: three_chain + in: + arr: [2, 6, 18] + out: 3 + - name: squares + in: + arr: [2, 3, 9, 27] + out: 9 + - name: mixed_small2 + in: + arr: [2, 3, 6, 9, 18] + out: 18 + - name: mixed_small3 + in: + arr: [2, 4, 16] + out: 8 + - name: mixed_small4 + in: + arr: [2, 6] + out: 2 + - name: mixed_small5 + in: + arr: [2, 5] + out: 2 + - name: mixed_small6 + in: + arr: [4, 16] + out: 3 + - name: mixed_small7 + in: + arr: [2, 3, 4] + out: 4 + - name: mixed_small8 + in: + arr: [2, 3, 5, 15] + out: 6 + - name: mixed_small9 + in: + arr: [2, 4, 10, 20] + out: 7 + - name: mixed_small10 + in: + arr: [3, 6, 12] + out: 3 + - name: mixed_small11 + in: + arr: [2, 9, 18] + out: 5 + - name: mixed_small12 + in: + arr: [2, 3, 5, 6, 10, 15, 30] + out: 31 + - name: mixed_small13 + in: + arr: [2, 4, 6, 12, 24] + out: 18 + - name: mixed_small14 + in: + arr: [2, 3, 9] + out: 4 + - name: mixed_small15 + in: + arr: [2, 4, 5, 25, 50] + out: 11 + - name: mixed_small16 + in: + arr: [2, 8, 32] + out: 3 + - name: mixed_small17 + in: + arr: [2, 3, 4, 12] + out: 9 + - name: mixed_small18 + in: + arr: [2, 4, 8, 32] + out: 29 + - name: mixed_small19 + in: + arr: [2, 4, 6, 8, 24] + out: 14 + - name: mixed_small20 + in: + arr: [2, 3, 5, 7, 11, 13] + out: 6 diff --git a/tests/501-1000/823. binary-trees-with-factors/sol.cpp b/tests/501-1000/823. binary-trees-with-factors/sol.cpp new file mode 100644 index 00000000..c85803bf --- /dev/null +++ b/tests/501-1000/823. binary-trees-with-factors/sol.cpp @@ -0,0 +1,26 @@ +class Solution { +public: + int numFactoredBinaryTrees(vector& arr) { + const int MOD = 1e9 + 7; + sort(arr.begin(), arr.end()); + unordered_map dp; + unordered_set s(arr.begin(), arr.end()); + for (int x : arr) { + dp[x] = 1; + for (int a : arr) { + if (a > x) break; + if (x % a == 0) { + int b = x / a; + if (s.count(b)) { + dp[x] = (dp[x] + dp[a] * dp[b]) % MOD; + } + } + } + } + long long sum = 0; + for (auto& p : dp) { + sum = (sum + p.second) % MOD; + } + return sum; + } +}; diff --git a/tests/501-1000/823. binary-trees-with-factors/sol.cs b/tests/501-1000/823. binary-trees-with-factors/sol.cs new file mode 100644 index 00000000..e732467e --- /dev/null +++ b/tests/501-1000/823. binary-trees-with-factors/sol.cs @@ -0,0 +1,25 @@ +public class Solution { + public int NumFactoredBinaryTrees(int[] arr) { + const int MOD = 1_000_000_007; + Array.Sort(arr); + Dictionary dp = new Dictionary(); + HashSet s = new HashSet(arr); + foreach (int x in arr) { + dp[x] = 1; + foreach (int a in arr) { + if (a > x) break; + if (x % a == 0) { + int b = x / a; + if (s.Contains(b)) { + dp[x] = (dp[x] + dp[a] * dp[b]) % MOD; + } + } + } + } + long sum = 0; + foreach (var v in dp.Values) { + sum = (sum + v) % MOD; + } + return (int)sum; + } +} diff --git a/tests/501-1000/823. binary-trees-with-factors/sol.dart b/tests/501-1000/823. binary-trees-with-factors/sol.dart new file mode 100644 index 00000000..e2e28e82 --- /dev/null +++ b/tests/501-1000/823. binary-trees-with-factors/sol.dart @@ -0,0 +1,25 @@ +class Solution { + int numFactoredBinaryTrees(List arr) { + const int MOD = 1000000007; + arr.sort(); + Map dp = {}; + Set s = arr.toSet(); + for (int x in arr) { + dp[x] = 1; + for (int a in arr) { + if (a > x) break; + if (x % a == 0) { + int b = x ~/ a; + if (s.contains(b)) { + dp[x] = (dp[x]! + dp[a]! * dp[b]!) % MOD; + } + } + } + } + int sum = 0; + for (int v in dp.values) { + sum = (sum + v) % MOD; + } + return sum; + } +} diff --git a/tests/501-1000/823. binary-trees-with-factors/sol.go b/tests/501-1000/823. binary-trees-with-factors/sol.go new file mode 100644 index 00000000..be04a7da --- /dev/null +++ b/tests/501-1000/823. binary-trees-with-factors/sol.go @@ -0,0 +1,28 @@ +func numFactoredBinaryTrees(arr []int) int { + const MOD = 1_000_000_007 + sort.Ints(arr) + dp := make(map[int]int) + s := make(map[int]bool) + for _, v := range arr { + s[v] = true + } + for _, x := range arr { + dp[x] = 1 + for _, a := range arr { + if a > x { + break + } + if x%a == 0 { + b := x / a + if s[b] { + dp[x] = (dp[x] + dp[a]*dp[b]) % MOD + } + } + } + } + sum := 0 + for _, v := range dp { + sum = (sum + v) % MOD + } + return sum +} diff --git a/tests/501-1000/823. binary-trees-with-factors/sol.java b/tests/501-1000/823. binary-trees-with-factors/sol.java new file mode 100644 index 00000000..523c38c9 --- /dev/null +++ b/tests/501-1000/823. binary-trees-with-factors/sol.java @@ -0,0 +1,26 @@ +import java.util.*; + +class Solution { + public int numFactoredBinaryTrees(int[] arr) { + int MOD = 1_000_000_007; + Arrays.sort(arr); + Map dp = new HashMap<>(); + Set s = new HashSet<>(); + for (int v : arr) s.add(v); + for (int x : arr) { + dp.put(x, 1L); + for (int a : arr) { + if (a > x) break; + if (x % a == 0) { + int b = x / a; + if (s.contains(b)) { + dp.put(x, (dp.get(x) + dp.get(a) * dp.get(b)) % MOD); + } + } + } + } + long sum = 0; + for (long v : dp.values()) sum = (sum + v) % MOD; + return (int) sum; + } +} diff --git a/tests/501-1000/823. binary-trees-with-factors/sol.kt b/tests/501-1000/823. binary-trees-with-factors/sol.kt new file mode 100644 index 00000000..b1863862 --- /dev/null +++ b/tests/501-1000/823. binary-trees-with-factors/sol.kt @@ -0,0 +1,21 @@ +class Solution { + fun numFactoredBinaryTrees(arr: IntArray): Int { + val MOD = 1_000_000_007 + arr.sort() + val dp = mutableMapOf() + val s = arr.toSet() + for (x in arr) { + dp[x] = 1L + for (a in arr) { + if (a > x) break + if (x % a == 0) { + val b = x / a + if (b in s) { + dp[x] = (dp[x]!! + dp[a]!! * dp[b]!!) % MOD + } + } + } + } + return (dp.values.sum() % MOD).toInt() + } +} diff --git a/tests/501-1000/823. binary-trees-with-factors/sol.py b/tests/501-1000/823. binary-trees-with-factors/sol.py new file mode 100644 index 00000000..ea77febf --- /dev/null +++ b/tests/501-1000/823. binary-trees-with-factors/sol.py @@ -0,0 +1,16 @@ +class Solution: + def numFactoredBinaryTrees(self, arr: List[int]) -> int: + MOD = 10**9 + 7 + arr.sort() + dp = {} + s = set(arr) + for x in arr: + dp[x] = 1 + for a in arr: + if a > x: + break + if x % a == 0: + b = x // a + if b in s: + dp[x] = (dp[x] + dp[a] * dp[b]) % MOD + return sum(dp.values()) % MOD diff --git a/tests/501-1000/823. binary-trees-with-factors/sol.py2 b/tests/501-1000/823. binary-trees-with-factors/sol.py2 new file mode 100644 index 00000000..c2a11220 --- /dev/null +++ b/tests/501-1000/823. binary-trees-with-factors/sol.py2 @@ -0,0 +1,20 @@ +class Solution(object): + def numFactoredBinaryTrees(self, arr): + """ + :type arr: List[int] + :rtype: int + """ + MOD = 10**9 + 7 + arr.sort() + dp = {} + s = set(arr) + for x in arr: + dp[x] = 1 + for a in arr: + if a > x: + break + if x % a == 0: + b = x // a + if b in s: + dp[x] = (dp[x] + dp[a] * dp[b]) % MOD + return sum(dp.values()) % MOD diff --git a/tests/501-1000/823. binary-trees-with-factors/sol.rb b/tests/501-1000/823. binary-trees-with-factors/sol.rb new file mode 100644 index 00000000..fa6aa3cd --- /dev/null +++ b/tests/501-1000/823. binary-trees-with-factors/sol.rb @@ -0,0 +1,21 @@ +# @param {Integer[]} arr +# @return {Integer} +def num_factored_binary_trees(arr) + mod = 10**9 + 7 + arr.sort! + dp = {} + s = arr.to_set + arr.each do |x| + dp[x] = 1 + arr.each do |a| + break if a > x + if x % a == 0 + b = x / a + if s.include?(b) + dp[x] = (dp[x] + dp[a] * dp[b]) % mod + end + end + end + end + dp.values.sum % mod +end diff --git a/tests/501-1000/823. binary-trees-with-factors/sol.rs b/tests/501-1000/823. binary-trees-with-factors/sol.rs new file mode 100644 index 00000000..4702f83b --- /dev/null +++ b/tests/501-1000/823. binary-trees-with-factors/sol.rs @@ -0,0 +1,24 @@ +impl Solution { + pub fn num_factored_binary_trees(arr: Vec) -> i32 { + const MOD: i64 = 1_000_000_007; + let mut arr = arr; + arr.sort_unstable(); + let mut dp = std::collections::HashMap::new(); + let s: std::collections::HashSet = arr.iter().cloned().collect(); + for &x in &arr { + dp.insert(x, 1i64); + for &a in &arr { + if a > x { break; } + if x % a == 0 { + let b = x / a; + if s.contains(&b) { + let val = dp[&x] + dp[&a] * dp[&b]; + dp.insert(x, val % MOD); + } + } + } + } + let sum: i64 = dp.values().fold(0, |acc, &v| (acc + v) % MOD); + sum as i32 + } +} diff --git a/tests/501-1000/823. binary-trees-with-factors/sol.swift b/tests/501-1000/823. binary-trees-with-factors/sol.swift new file mode 100644 index 00000000..9ce5e69f --- /dev/null +++ b/tests/501-1000/823. binary-trees-with-factors/sol.swift @@ -0,0 +1,21 @@ +class Solution { + func numFactoredBinaryTrees(_ arr: [Int]) -> Int { + let MOD = 1_000_000_007 + let arr = arr.sorted() + var dp = [Int: Int]() + let s = Set(arr) + for x in arr { + dp[x] = 1 + for a in arr { + if a > x { break } + if x % a == 0 { + let b = x / a + if s.contains(b) { + dp[x] = (dp[x]! + dp[a]! * dp[b]!) % MOD + } + } + } + } + return dp.values.reduce(0, { ($0 + $1) % MOD }) + } +} diff --git a/tests/501-1000/823. binary-trees-with-factors/sol.ts b/tests/501-1000/823. binary-trees-with-factors/sol.ts new file mode 100644 index 00000000..d64c0bdb --- /dev/null +++ b/tests/501-1000/823. binary-trees-with-factors/sol.ts @@ -0,0 +1,23 @@ +function numFactoredBinaryTrees(arr: number[]): number { + const MOD = 1_000_000_007; + arr.sort((a, b) => a - b); + const dp = new Map(); + const s = new Set(arr); + for (const x of arr) { + dp.set(x, 1); + for (const a of arr) { + if (a > x) break; + if (x % a === 0) { + const b = Math.floor(x / a); + if (s.has(b)) { + dp.set(x, (dp.get(x)! + dp.get(a)! * dp.get(b)!) % MOD); + } + } + } + } + let sum = 0; + for (const v of dp.values()) { + sum = (sum + v) % MOD; + } + return sum; +} diff --git a/tests/501-1000/824. goat-latin/manifest.yaml b/tests/501-1000/824. goat-latin/manifest.yaml new file mode 100644 index 00000000..d63979af --- /dev/null +++ b/tests/501-1000/824. goat-latin/manifest.yaml @@ -0,0 +1,173 @@ +entry: + id: 824 + title: goat-latin + params: + sentence: + type: string + call: + cpp: Solution().toGoatLatin({sentence}) + rust: Solution::to_goat_latin({sentence}) + python3: Solution().toGoatLatin({sentence}) + python2: Solution().toGoatLatin({sentence}) + ruby: to_goat_latin({sentence}) + java: new Solution().toGoatLatin({sentence}) + csharp: new Solution().ToGoatLatin({sentence}) + kotlin: Solution().toGoatLatin({sentence}) + go: toGoatLatin({sentence}) + dart: Solution().toGoatLatin({sentence}) + swift: Solution().toGoatLatin({sentence}) + typescript: toGoatLatin({sentence}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 128 +oracle: + python3: + call: Checker().check(sentence, {result}) + checker: | + class Checker: + def check(self, sentence, result): + return isinstance(result, str) +seed: 824 +tests: + - name: ex1 + in: + sentence: I speak Goat Latin + out: Imaa peaksmaaa oatGmaaaa atinLmaaaaa + - name: ex2 + in: + sentence: The quick brown fox jumped over the lazy dog + out: heTmaa uickqmaaa rownbmaaaa oxfmaaaaa umpedjmaaaaaa overmaaaaaaa hetmaaaaaaaa azylmaaaaaaaaa ogdmaaaaaaaaaa + - name: single_lower_vowel + in: + sentence: a + out: amaa + - name: single_upper_vowel + in: + sentence: A + out: Amaa + - name: single_consonant + in: + sentence: b + out: bmaa + - name: mixed_case + in: + sentence: Hello World + out: elloHmaa orldWmaaa + - name: vowel_word + in: + sentence: apple + out: applemaa + - name: two_words + in: + sentence: eagle one + out: eaglemaa onemaaa + - name: upper_consonant + in: + sentence: Zoo + out: ooZmaa + - name: spaces_words + in: + sentence: under score + out: undermaa coresmaaa + - name: single_three + in: + sentence: The + out: heTmaa + - name: five_words + in: + sentence: a b c d e + out: amaa bmaaa cmaaaa dmaaaaa emaaaaaa + - name: uppercase_sentence + in: + sentence: ALPHA beta Gamma + out: ALPHAmaa etabmaaa ammaGmaaaa + - name: consonant_chain + in: + sentence: x y z + out: xmaa ymaaa zmaaaa + - name: vowel_chain + in: + sentence: I a e i o u + out: Imaa amaaa emaaaa imaaaaa omaaaaaa umaaaaaaa + - name: two_caps + in: + sentence: Java Kotlin + out: avaJmaa otlinKmaaa + - name: alternating_case + in: + sentence: Apple banana Cherry date + out: Applemaa ananabmaaa herryCmaaaa atedmaaaaa + - name: short_mix + in: + sentence: Mix Match + out: ixMmaa atchMmaaa + - name: two_vowels + in: + sentence: Open AI + out: Openmaa AImaaa + - name: lower_sentence + in: + sentence: leetcode is fun + out: eetcodelmaa ismaaa unfmaaaa + - name: consonant_vowel_mix + in: + sentence: code and play + out: odecmaa andmaaa laypmaaaa + - name: three_words + in: + sentence: one two three + out: onemaa wotmaaa hreetmaaaa + - name: four_words + in: + sentence: red blue green yellow + out: edrmaa luebmaaa reengmaaaa ellowymaaaaa + - name: longish + in: + sentence: Alpha Beta Gamma Delta + out: Alphamaa etaBmaaa ammaGmaaaa eltaDmaaaaa + - name: vowel_start_upper + in: + sentence: Umbrella + out: Umbrellamaa + - name: consonant_start_upper + in: + sentence: Zebra + out: ebraZmaa + - name: mixed_simple + in: + sentence: cat Dog eel + out: atcmaa ogDmaaa eelmaaaa + - name: another_three + in: + sentence: sun moon star + out: unsmaa oonmmaaa tarsmaaaa + - name: punctuation_free + in: + sentence: quick brown fox + out: uickqmaa rownbmaaa oxfmaaaa + - name: case_preserved + in: + sentence: MiXeD CaSe + out: iXeDMmaa aSeCmaaa + - name: final_short + in: + sentence: hello + out: ellohmaa + - name: final_upper + in: + sentence: HELLO + out: ELLOHmaa + - name: final_vowel + in: + sentence: ice + out: icemaa + - name: final_two + in: + sentence: art school + out: artmaa choolsmaaa + - name: final_three + in: + sentence: we are done + out: ewmaa aremaaa onedmaaaa diff --git a/tests/501-1000/824. goat-latin/sol.cpp b/tests/501-1000/824. goat-latin/sol.cpp new file mode 100644 index 00000000..a6b2831e --- /dev/null +++ b/tests/501-1000/824. goat-latin/sol.cpp @@ -0,0 +1,22 @@ +class Solution { +public: + string toGoatLatin(string sentence) { + unordered_set vowels = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'}; + istringstream iss(sentence); + string word, ans; + int i = 0; + while (iss >> word) { + i++; + string goat; + if (vowels.count(word[0])) { + goat = word + "ma"; + } else { + goat = word.substr(1) + word[0] + "ma"; + } + goat += string(i, 'a'); + if (!ans.empty()) ans += " "; + ans += goat; + } + return ans; + } +}; diff --git a/tests/501-1000/824. goat-latin/sol.cs b/tests/501-1000/824. goat-latin/sol.cs new file mode 100644 index 00000000..dd6c8bbd --- /dev/null +++ b/tests/501-1000/824. goat-latin/sol.cs @@ -0,0 +1,19 @@ +public class Solution { + public string ToGoatLatin(string sentence) { + var vowels = new HashSet { 'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U' }; + var words = sentence.Split(' '); + var ans = new List(); + for (int i = 0; i < words.Length; i++) { + string word = words[i]; + string goat; + if (vowels.Contains(word[0])) { + goat = word + "ma"; + } else { + goat = word.Substring(1) + word[0] + "ma"; + } + goat += new string('a', i + 1); + ans.Add(goat); + } + return string.Join(" ", ans); + } +} diff --git a/tests/501-1000/824. goat-latin/sol.dart b/tests/501-1000/824. goat-latin/sol.dart new file mode 100644 index 00000000..f62936c3 --- /dev/null +++ b/tests/501-1000/824. goat-latin/sol.dart @@ -0,0 +1,19 @@ +class Solution { + String toGoatLatin(String sentence) { + final vowels = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'}; + final words = sentence.split(' '); + final ans = []; + for (var i = 0; i < words.length; i++) { + final word = words[i]; + String goat; + if (vowels.contains(word[0])) { + goat = word + 'ma'; + } else { + goat = word.substring(1) + word[0] + 'ma'; + } + goat += 'a' * (i + 1); + ans.add(goat); + } + return ans.join(' '); + } +} diff --git a/tests/501-1000/824. goat-latin/sol.go b/tests/501-1000/824. goat-latin/sol.go new file mode 100644 index 00000000..5cd23c24 --- /dev/null +++ b/tests/501-1000/824. goat-latin/sol.go @@ -0,0 +1,19 @@ +func toGoatLatin(sentence string) string { + vowels := map[byte]bool{ + 'a': true, 'e': true, 'i': true, 'o': true, 'u': true, + 'A': true, 'E': true, 'I': true, 'O': true, 'U': true, + } + words := strings.Split(sentence, " ") + ans := []string{} + for i, word := range words { + goat := "" + if vowels[word[0]] { + goat = word + "ma" + } else { + goat = word[1:] + string(word[0]) + "ma" + } + goat += strings.Repeat("a", i+1) + ans = append(ans, goat) + } + return strings.Join(ans, " ") +} diff --git a/tests/501-1000/824. goat-latin/sol.java b/tests/501-1000/824. goat-latin/sol.java new file mode 100644 index 00000000..139625b2 --- /dev/null +++ b/tests/501-1000/824. goat-latin/sol.java @@ -0,0 +1,24 @@ +class Solution { + public String toGoatLatin(String sentence) { + Set vowels = Set.of('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'); + String[] words = sentence.split(" "); + StringBuilder ans = new StringBuilder(); + for (int i = 0; i < words.length; i++) { + String word = words[i]; + StringBuilder goat = new StringBuilder(); + if (vowels.contains(word.charAt(0))) { + goat.append(word); + } else { + goat.append(word.substring(1)); + goat.append(word.charAt(0)); + } + goat.append("ma"); + goat.append("a".repeat(i + 1)); + if (ans.length() > 0) { + ans.append(" "); + } + ans.append(goat); + } + return ans.toString(); + } +} diff --git a/tests/501-1000/824. goat-latin/sol.kt b/tests/501-1000/824. goat-latin/sol.kt new file mode 100644 index 00000000..59419607 --- /dev/null +++ b/tests/501-1000/824. goat-latin/sol.kt @@ -0,0 +1,16 @@ +class Solution { + fun toGoatLatin(sentence: String): String { + val vowels = setOf('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U') + val words = sentence.split(" ") + val ans = mutableListOf() + for ((i, word) in words.withIndex()) { + val goat = if (word[0] in vowels) { + word + "ma" + } else { + word.substring(1) + word[0] + "ma" + } + ans.add(goat + "a".repeat(i + 1)) + } + return ans.joinToString(" ") + } +} diff --git a/tests/501-1000/824. goat-latin/sol.py b/tests/501-1000/824. goat-latin/sol.py new file mode 100644 index 00000000..eeee5c65 --- /dev/null +++ b/tests/501-1000/824. goat-latin/sol.py @@ -0,0 +1,17 @@ +class Solution: + def toGoatLatin(self, sentence: str) -> str: + vowels = {"a", "e", "i", "o", "u", "A", "E", "I", "O", "U"} + + words = sentence.split() + ans = [] + + for i, word in enumerate(words, 1): + if word[0] in vowels: + goat = word + "ma" + else: + goat = word[1:] + word[0] + "ma" + + goat += "a" * i + ans.append(goat) + + return " ".join(ans) diff --git a/tests/501-1000/824. goat-latin/sol.py2 b/tests/501-1000/824. goat-latin/sol.py2 new file mode 100644 index 00000000..8bfcf21d --- /dev/null +++ b/tests/501-1000/824. goat-latin/sol.py2 @@ -0,0 +1,17 @@ +class Solution(object): + def toGoatLatin(self, sentence): + """ + :type sentence: str + :rtype: str + """ + vowels = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'} + words = sentence.split() + ans = [] + for i, word in enumerate(words, 1): + if word[0] in vowels: + goat = word + "ma" + else: + goat = word[1:] + word[0] + "ma" + goat += "a" * i + ans.append(goat) + return " ".join(ans) diff --git a/tests/501-1000/824. goat-latin/sol.rb b/tests/501-1000/824. goat-latin/sol.rb new file mode 100644 index 00000000..05b45ddd --- /dev/null +++ b/tests/501-1000/824. goat-latin/sol.rb @@ -0,0 +1,18 @@ +# @param {String} sentence +# @return {String} +def to_goat_latin(sentence) + vowels = Set.new(['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']) + words = sentence.split + ans = [] + words.each_with_index do |word, idx| + i = idx + 1 + if vowels.include?(word[0]) + goat = word + "ma" + else + goat = word[1..-1] + word[0] + "ma" + end + goat += "a" * i + ans << goat + end + ans.join(" ") +end diff --git a/tests/501-1000/824. goat-latin/sol.rs b/tests/501-1000/824. goat-latin/sol.rs new file mode 100644 index 00000000..6caf2b6d --- /dev/null +++ b/tests/501-1000/824. goat-latin/sol.rs @@ -0,0 +1,21 @@ +impl Solution { + pub fn to_goat_latin(sentence: String) -> String { + let vowels: std::collections::HashSet = + ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'].iter().cloned().collect(); + let mut ans = Vec::new(); + for (i, word) in sentence.split_whitespace().enumerate() { + let mut goat = String::new(); + let first_char = word.chars().next().unwrap(); + if vowels.contains(&first_char) { + goat.push_str(word); + } else { + goat.push_str(&word[first_char.len_utf8()..]); + goat.push(first_char); + } + goat.push_str("ma"); + goat.push_str(&"a".repeat(i + 1)); + ans.push(goat); + } + ans.join(" ") + } +} diff --git a/tests/501-1000/824. goat-latin/sol.swift b/tests/501-1000/824. goat-latin/sol.swift new file mode 100644 index 00000000..c7ae4709 --- /dev/null +++ b/tests/501-1000/824. goat-latin/sol.swift @@ -0,0 +1,19 @@ +class Solution { + func toGoatLatin(_ sentence: String) -> String { + let vowels: Set = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"] + let words = sentence.split(separator: " ") + var ans: [String] = [] + for (i, word) in words.enumerated() { + let wordStr = String(word) + var goat: String + if vowels.contains(wordStr.first!) { + goat = wordStr + "ma" + } else { + goat = String(wordStr.dropFirst()) + String(wordStr.first!) + "ma" + } + goat += String(repeating: "a", count: i + 1) + ans.append(goat) + } + return ans.joined(separator: " ") + } +} diff --git a/tests/501-1000/824. goat-latin/sol.ts b/tests/501-1000/824. goat-latin/sol.ts new file mode 100644 index 00000000..8db7e748 --- /dev/null +++ b/tests/501-1000/824. goat-latin/sol.ts @@ -0,0 +1,17 @@ +function toGoatLatin(sentence: string): string { + const vowels = new Set(["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"]); + const words = sentence.split(" "); + const ans: string[] = []; + for (let i = 0; i < words.length; i++) { + const word = words[i]; + let goat: string; + if (vowels.has(word[0])) { + goat = word + "ma"; + } else { + goat = word.substring(1) + word[0] + "ma"; + } + goat += "a".repeat(i + 1); + ans.push(goat); + } + return ans.join(" "); +} diff --git a/tests/501-1000/825. friends-of-appropriate-ages/manifest.yaml b/tests/501-1000/825. friends-of-appropriate-ages/manifest.yaml new file mode 100644 index 00000000..659e3c9c --- /dev/null +++ b/tests/501-1000/825. friends-of-appropriate-ages/manifest.yaml @@ -0,0 +1,183 @@ +entry: + id: 825 + title: friends-of-appropriate-ages + params: + ages: + type: array + items: + type: int + call: + cpp: Solution().numFriendRequests({ages}) + rust: Solution::num_friend_requests({ages}) + python3: Solution().numFriendRequests({ages}) + python2: Solution().numFriendRequests({ages}) + ruby: num_friend_requests({ages}) + java: new Solution().numFriendRequests({ages}) + csharp: new Solution().NumFriendRequests({ages}) + kotlin: Solution().numFriendRequests({ages}) + go: numFriendRequests({ages}) + dart: Solution().numFriendRequests({ages}) + swift: Solution().numFriendRequests({ages}) + typescript: numFriendRequests({ages}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 128 +oracle: + python3: + call: Checker().check(ages, {result}) + checker: | + class Checker: + def check(self, ages, result): + return isinstance(result, int) +seed: 825 +tests: + - name: ex1 + in: + ages: [16, 16] + out: 2 + - name: ex2 + in: + ages: [16, 17, 18] + out: 2 + - name: ex3 + in: + ages: [20, 30, 100, 110, 120] + out: 3 + - name: single + in: + ages: [1] + out: 0 + - name: under_threshold + in: + ages: [14, 14, 14] + out: 0 + - name: threshold_pair + in: + ages: [15, 15] + out: 2 + - name: mixed_15_16 + in: + ages: [16, 15] + out: 0 + - name: pair_20 + in: + ages: [20, 20] + out: 2 + - name: pair_100 + in: + ages: [100, 100] + out: 2 + - name: triplet_high + in: + ages: [101, 102, 103] + out: 3 + - name: pair_120 + in: + ages: [120, 120] + out: 2 + - name: triple_16 + in: + ages: [16, 16, 16] + out: 6 + - name: pair_pair + in: + ages: [17, 17, 18, 18] + out: 8 + - name: increasing_four + in: + ages: [21, 22, 23, 24] + out: 6 + - name: four_same_50 + in: + ages: [50, 50, 50, 50] + out: 12 + - name: around_100 + in: + ages: [99, 100, 101] + out: 3 + - name: sequence_15_19 + in: + ages: [15, 16, 17, 18, 19] + out: 4 + - name: mixed_multi + in: + ages: [30, 30, 30, 40, 40, 50] + out: 16 + - name: high_pair + in: + ages: [110, 110, 120] + out: 4 + - name: range_14_20 + in: + ages: [14, 15, 16, 17, 18, 19, 20] + out: 6 + - name: many_16 + in: + ages: [16, 16, 16, 16] + out: 12 + - name: many_18 + in: + ages: [18, 18, 18] + out: 6 + - name: many_19 + in: + ages: [19, 19, 19] + out: 6 + - name: mixed_20s + in: + ages: [20, 21, 22, 23, 24, 25] + out: 15 + - name: mixed_30s + in: + ages: [30, 31, 32, 33] + out: 6 + - name: mixed_40s + in: + ages: [40, 41, 42, 43] + out: 6 + - name: mixed_60s + in: + ages: [60, 60, 61] + out: 4 + - name: mixed_70s + in: + ages: [70, 71, 72] + out: 3 + - name: mixed_80s + in: + ages: [80, 80, 80, 81] + out: 9 + - name: mixed_90s + in: + ages: [90, 91, 92, 93] + out: 6 + - name: boundary_15_100 + in: + ages: [15, 100] + out: 0 + - name: boundary_15_101 + in: + ages: [15, 101] + out: 0 + - name: boundary_16_100 + in: + ages: [16, 100] + out: 0 + - name: boundary_16_101 + in: + ages: [16, 101] + out: 0 + - name: boundary_100_120 + in: + ages: [100, 120] + out: 1 + - name: boundary_99_120 + in: + ages: [99, 120] + out: 1 + - name: triple_110 + in: + ages: [110, 110, 110] + out: 6 diff --git a/tests/501-1000/825. friends-of-appropriate-ages/sol.cpp b/tests/501-1000/825. friends-of-appropriate-ages/sol.cpp new file mode 100644 index 00000000..96e371fe --- /dev/null +++ b/tests/501-1000/825. friends-of-appropriate-ages/sol.cpp @@ -0,0 +1,22 @@ +class Solution { +public: + int numFriendRequests(vector& ages) { + int cnt[121] = {0}; + for (int age : ages) { + cnt[age]++; + } + int pre[122] = {0}; + for (int i = 0; i < 121; i++) { + pre[i + 1] = pre[i] + cnt[i]; + } + int ans = 0; + for (int age = 15; age < 121; age++) { + if (cnt[age] > 0) { + int lower = (int)(age * 0.5 + 7); + int total = pre[age + 1] - pre[lower + 1]; + ans += cnt[age] * (total - 1); + } + } + return ans; + } +}; diff --git a/tests/501-1000/825. friends-of-appropriate-ages/sol.cs b/tests/501-1000/825. friends-of-appropriate-ages/sol.cs new file mode 100644 index 00000000..32dcd30e --- /dev/null +++ b/tests/501-1000/825. friends-of-appropriate-ages/sol.cs @@ -0,0 +1,21 @@ +public class Solution { + public int NumFriendRequests(int[] ages) { + int[] cnt = new int[121]; + foreach (int age in ages) { + cnt[age]++; + } + int[] pre = new int[122]; + for (int i = 0; i < 121; i++) { + pre[i + 1] = pre[i] + cnt[i]; + } + int ans = 0; + for (int age = 15; age < 121; age++) { + if (cnt[age] > 0) { + int lower = (int)(age * 0.5 + 7); + int total = pre[age + 1] - pre[lower + 1]; + ans += cnt[age] * (total - 1); + } + } + return ans; + } +} diff --git a/tests/501-1000/825. friends-of-appropriate-ages/sol.dart b/tests/501-1000/825. friends-of-appropriate-ages/sol.dart new file mode 100644 index 00000000..d0c91fd9 --- /dev/null +++ b/tests/501-1000/825. friends-of-appropriate-ages/sol.dart @@ -0,0 +1,21 @@ +class Solution { + int numFriendRequests(List ages) { + List cnt = List.filled(121, 0); + for (int age in ages) { + cnt[age]++; + } + List pre = List.filled(122, 0); + for (int i = 0; i < 121; i++) { + pre[i + 1] = pre[i] + cnt[i]; + } + int ans = 0; + for (int age = 15; age < 121; age++) { + if (cnt[age] > 0) { + int lower = (age * 0.5 + 7).toInt(); + int total = pre[age + 1] - pre[lower + 1]; + ans += cnt[age] * (total - 1); + } + } + return ans; + } +} diff --git a/tests/501-1000/825. friends-of-appropriate-ages/sol.go b/tests/501-1000/825. friends-of-appropriate-ages/sol.go new file mode 100644 index 00000000..6b18be1c --- /dev/null +++ b/tests/501-1000/825. friends-of-appropriate-ages/sol.go @@ -0,0 +1,19 @@ +func numFriendRequests(ages []int) int { + cnt := make([]int, 121) + for _, age := range ages { + cnt[age]++ + } + pre := make([]int, 122) + for i := 0; i < 121; i++ { + pre[i+1] = pre[i] + cnt[i] + } + ans := 0 + for age := 15; age < 121; age++ { + if cnt[age] > 0 { + lower := int(float64(age)*0.5 + 7) + total := pre[age+1] - pre[lower+1] + ans += cnt[age] * (total - 1) + } + } + return ans +} diff --git a/tests/501-1000/825. friends-of-appropriate-ages/sol.java b/tests/501-1000/825. friends-of-appropriate-ages/sol.java new file mode 100644 index 00000000..93955539 --- /dev/null +++ b/tests/501-1000/825. friends-of-appropriate-ages/sol.java @@ -0,0 +1,21 @@ +class Solution { + public int numFriendRequests(int[] ages) { + int[] cnt = new int[121]; + for (int age : ages) { + cnt[age]++; + } + int[] pre = new int[122]; + for (int i = 0; i < 121; i++) { + pre[i + 1] = pre[i] + cnt[i]; + } + int ans = 0; + for (int age = 15; age < 121; age++) { + if (cnt[age] > 0) { + int lower = (int)(age * 0.5 + 7); + int total = pre[age + 1] - pre[lower + 1]; + ans += cnt[age] * (total - 1); + } + } + return ans; + } +} diff --git a/tests/501-1000/825. friends-of-appropriate-ages/sol.kt b/tests/501-1000/825. friends-of-appropriate-ages/sol.kt new file mode 100644 index 00000000..a2ea7284 --- /dev/null +++ b/tests/501-1000/825. friends-of-appropriate-ages/sol.kt @@ -0,0 +1,21 @@ +class Solution { + fun numFriendRequests(ages: IntArray): Int { + val cnt = IntArray(121) + for (age in ages) { + cnt[age]++ + } + val pre = IntArray(122) + for (i in 0 until 121) { + pre[i + 1] = pre[i] + cnt[i] + } + var ans = 0 + for (age in 15 until 121) { + if (cnt[age] > 0) { + val lower = (age * 0.5 + 7).toInt() + val total = pre[age + 1] - pre[lower + 1] + ans += cnt[age] * (total - 1) + } + } + return ans + } +} diff --git a/tests/501-1000/825. friends-of-appropriate-ages/sol.py b/tests/501-1000/825. friends-of-appropriate-ages/sol.py new file mode 100644 index 00000000..0e7223f1 --- /dev/null +++ b/tests/501-1000/825. friends-of-appropriate-ages/sol.py @@ -0,0 +1,15 @@ +class Solution(object): + def numFriendRequests(self, ages): + cnt = [0] * 121 + for age in ages: + cnt[age] += 1 + pre = [0] * 122 + for i in range(121): + pre[i + 1] = pre[i] + cnt[i] + ans = 0 + for age in range(15, 121): + if cnt[age]: + lower = int(age * 0.5 + 7) + total = pre[age + 1] - pre[lower + 1] + ans += cnt[age] * (total - 1) + return ans diff --git a/tests/501-1000/825. friends-of-appropriate-ages/sol.py2 b/tests/501-1000/825. friends-of-appropriate-ages/sol.py2 new file mode 100644 index 00000000..0e7223f1 --- /dev/null +++ b/tests/501-1000/825. friends-of-appropriate-ages/sol.py2 @@ -0,0 +1,15 @@ +class Solution(object): + def numFriendRequests(self, ages): + cnt = [0] * 121 + for age in ages: + cnt[age] += 1 + pre = [0] * 122 + for i in range(121): + pre[i + 1] = pre[i] + cnt[i] + ans = 0 + for age in range(15, 121): + if cnt[age]: + lower = int(age * 0.5 + 7) + total = pre[age + 1] - pre[lower + 1] + ans += cnt[age] * (total - 1) + return ans diff --git a/tests/501-1000/825. friends-of-appropriate-ages/sol.rb b/tests/501-1000/825. friends-of-appropriate-ages/sol.rb new file mode 100644 index 00000000..c179b56c --- /dev/null +++ b/tests/501-1000/825. friends-of-appropriate-ages/sol.rb @@ -0,0 +1,21 @@ +# @param {Integer[]} ages +# @return {Integer} +def num_friend_requests(ages) + cnt = Array.new(121, 0) + ages.each do |age| + cnt[age] += 1 + end + pre = Array.new(122, 0) + (0...121).each do |i| + pre[i + 1] = pre[i] + cnt[i] + end + ans = 0 + (15...121).each do |age| + if cnt[age] > 0 + lower = (age * 0.5 + 7).to_i + total = pre[age + 1] - pre[lower + 1] + ans += cnt[age] * (total - 1) + end + end + ans +end diff --git a/tests/501-1000/825. friends-of-appropriate-ages/sol.rs b/tests/501-1000/825. friends-of-appropriate-ages/sol.rs new file mode 100644 index 00000000..fffff924 --- /dev/null +++ b/tests/501-1000/825. friends-of-appropriate-ages/sol.rs @@ -0,0 +1,21 @@ +impl Solution { + pub fn num_friend_requests(ages: Vec) -> i32 { + let mut cnt = vec![0; 121]; + for &age in &ages { + cnt[age as usize] += 1; + } + let mut pre = vec![0; 122]; + for i in 0..121 { + pre[i + 1] = pre[i] + cnt[i]; + } + let mut ans = 0; + for age in 15..121 { + if cnt[age] > 0 { + let lower = ((age as f64) * 0.5 + 7.0) as usize; + let total = pre[age + 1] - pre[lower + 1]; + ans += cnt[age] * (total - 1); + } + } + ans + } +} diff --git a/tests/501-1000/825. friends-of-appropriate-ages/sol.swift b/tests/501-1000/825. friends-of-appropriate-ages/sol.swift new file mode 100644 index 00000000..ef8e04ef --- /dev/null +++ b/tests/501-1000/825. friends-of-appropriate-ages/sol.swift @@ -0,0 +1,21 @@ +class Solution { + func numFriendRequests(_ ages: [Int]) -> Int { + var cnt = [Int](repeating: 0, count: 121) + for age in ages { + cnt[age] += 1 + } + var pre = [Int](repeating: 0, count: 122) + for i in 0..<121 { + pre[i + 1] = pre[i] + cnt[i] + } + var ans = 0 + for age in 15..<121 { + if cnt[age] > 0 { + let lower = Int(Double(age) * 0.5 + 7) + let total = pre[age + 1] - pre[lower + 1] + ans += cnt[age] * (total - 1) + } + } + return ans + } +} diff --git a/tests/501-1000/825. friends-of-appropriate-ages/sol.ts b/tests/501-1000/825. friends-of-appropriate-ages/sol.ts new file mode 100644 index 00000000..edb1c0f1 --- /dev/null +++ b/tests/501-1000/825. friends-of-appropriate-ages/sol.ts @@ -0,0 +1,19 @@ +function numFriendRequests(ages: number[]): number { + const cnt: number[] = new Array(121).fill(0); + for (const age of ages) { + cnt[age]++; + } + const pre: number[] = new Array(122).fill(0); + for (let i = 0; i < 121; i++) { + pre[i + 1] = pre[i] + cnt[i]; + } + let ans = 0; + for (let age = 15; age < 121; age++) { + if (cnt[age] > 0) { + const lower = Math.floor(age * 0.5 + 7); + const total = pre[age + 1] - pre[lower + 1]; + ans += cnt[age] * (total - 1); + } + } + return ans; +} diff --git a/tests/501-1000/826. most-profit-assigning-work/manifest.yaml b/tests/501-1000/826. most-profit-assigning-work/manifest.yaml new file mode 100644 index 00000000..308d06f9 --- /dev/null +++ b/tests/501-1000/826. most-profit-assigning-work/manifest.yaml @@ -0,0 +1,597 @@ +entry: + id: 826 + title: most-profit-assigning-work + params: + difficulty: + type: array + items: + type: int + profit: + type: array + items: + type: int + worker: + type: array + items: + type: int + call: + cpp: Solution().maxProfitAssignment({difficulty}, {profit}, {worker}) + rust: Solution::max_profit_assignment({difficulty}, {profit}, {worker}) + python3: Solution().maxProfitAssignment({difficulty}, {profit}, {worker}) + python2: Solution().maxProfitAssignment({difficulty}, {profit}, {worker}) + ruby: max_profit_assignment({difficulty}, {profit}, {worker}) + java: new Solution().maxProfitAssignment({difficulty}, {profit}, {worker}) + csharp: new Solution().MaxProfitAssignment({difficulty}, {profit}, {worker}) + kotlin: Solution().maxProfitAssignment({difficulty}, {profit}, {worker}) + go: maxProfitAssignment({difficulty}, {profit}, {worker}) + dart: Solution().maxProfitAssignment({difficulty}, {profit}, {worker}) + swift: Solution().maxProfitAssignment({difficulty}, {profit}, {worker}) + typescript: maxProfitAssignment({difficulty}, {profit}, {worker}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().maxProfitAssignment(difficulty, profit, worker, {result}) + checker: + "class Checker:\n def maxProfitAssignment(self, difficulty, profit,\ + \ worker, result):\n if not isinstance(result, int) or len(difficulty)\ + \ != len(profit):\n return False\n best = 0\n total\ + \ = 0\n jobs = sorted(zip(difficulty, profit))\n workers = sorted(worker)\n\ + \ i = 0\n for ability in workers:\n while i < len(jobs)\ + \ and jobs[i][0] <= ability:\n best = max(best, jobs[i][1])\n\ + \ i += 1\n total += best\n return result ==\ + \ total\n" +seed: 826 +tests: + - name: ex1 + in: + difficulty: + - 2 + - 4 + - 6 + - 8 + - 10 + profit: + - 10 + - 20 + - 30 + - 40 + - 50 + worker: + - 4 + - 5 + - 6 + - 7 + - name: ex2 + in: + difficulty: + - 85 + - 47 + - 57 + profit: + - 24 + - 66 + - 99 + worker: + - 40 + - 25 + - 25 + - name: single_fit + in: + difficulty: + - 5 + profit: + - 10 + worker: + - 5 + - name: single_unfit + in: + difficulty: + - 5 + profit: + - 10 + worker: + - 4 + - name: multi_workers + in: + difficulty: + - 2 + profit: + - 5 + worker: + - 1 + - 2 + - 3 + - name: same_diff + in: + difficulty: + - 2 + - 2 + - 2 + profit: + - 1 + - 5 + - 3 + worker: + - 2 + - 2 + - name: same_profit + in: + difficulty: + - 1 + - 2 + - 3 + profit: + - 5 + - 5 + - 5 + worker: + - 1 + - 2 + - 3 + - name: increasing + in: + difficulty: + - 1 + - 2 + - 3 + - 4 + profit: + - 2 + - 4 + - 6 + - 8 + worker: + - 1 + - 2 + - 3 + - 4 + - name: decreasing_profit + in: + difficulty: + - 1 + - 2 + - 3 + - 4 + profit: + - 8 + - 6 + - 4 + - 2 + worker: + - 4 + - 4 + - 4 + - name: gaps + in: + difficulty: + - 2 + - 10 + profit: + - 10 + - 100 + worker: + - 1 + - 2 + - 3 + - 9 + - 10 + - name: workers_none + in: + difficulty: + - 1 + - 2 + - 3 + profit: + - 10 + - 20 + - 30 + worker: [] + - name: jobs_none + in: + difficulty: [] + profit: [] + worker: + - 1 + - 2 + - 3 + - name: mix1 + in: + difficulty: + - 5 + - 50 + - 92 + - 21 + profit: + - 10 + - 100 + - 200 + - 30 + worker: + - 1 + - 20 + - 50 + - 100 + - name: mix2 + in: + difficulty: + - 10 + - 20 + - 30 + profit: + - 100 + - 50 + - 150 + worker: + - 15 + - 25 + - 35 + - name: mix3 + in: + difficulty: + - 4 + - 4 + - 6 + profit: + - 5 + - 6 + - 7 + worker: + - 4 + - 5 + - 6 + - name: mix4 + in: + difficulty: + - 3 + - 1 + - 10 + profit: + - 20 + - 10 + - 100 + worker: + - 2 + - 3 + - 4 + - 10 + - name: mix5 + in: + difficulty: + - 7 + - 8 + - 9 + profit: + - 70 + - 80 + - 90 + worker: + - 7 + - 7 + - 8 + - 9 + - name: mix6 + in: + difficulty: + - 2 + - 3 + - 5 + profit: + - 20 + - 30 + - 50 + worker: + - 4 + - 4 + - 4 + - name: mix7 + in: + difficulty: + - 2 + - 2 + - 2 + profit: + - 10 + - 20 + - 30 + worker: + - 2 + - 3 + - name: mix8 + in: + difficulty: + - 1 + - 3 + - 5 + - 7 + profit: + - 1 + - 10 + - 100 + - 1000 + worker: + - 6 + - 6 + - 6 + - name: mix9 + in: + difficulty: + - 8 + - 16 + - 24 + profit: + - 8 + - 16 + - 24 + worker: + - 8 + - 15 + - 16 + - 23 + - 24 + - name: mix10 + in: + difficulty: + - 6 + - 6 + - 6 + profit: + - 1 + - 2 + - 3 + worker: + - 5 + - 6 + - 7 + - name: mix11 + in: + difficulty: + - 9 + profit: + - 100 + worker: + - 9 + - 9 + - 9 + - name: mix12 + in: + difficulty: + - 4 + - 5 + profit: + - 10 + - 20 + worker: + - 3 + - 4 + - 5 + - 6 + - name: mix13 + in: + difficulty: + - 13 + - 37 + - 58 + profit: + - 4 + - 90 + - 120 + worker: + - 10 + - 37 + - 58 + - name: mix14 + in: + difficulty: + - 2 + - 8 + - 8 + profit: + - 5 + - 10 + - 20 + worker: + - 8 + - 8 + - 8 + - name: mix15 + in: + difficulty: + - 1 + - 100 + profit: + - 1 + - 1000 + worker: + - 50 + - 100 + - name: mix16 + in: + difficulty: + - 10 + - 20 + - 30 + - 40 + profit: + - 5 + - 15 + - 25 + - 35 + worker: + - 5 + - 10 + - 15 + - 20 + - 25 + - 30 + - 35 + - 40 + - name: mix17 + in: + difficulty: + - 4 + - 9 + - 12 + profit: + - 20 + - 30 + - 40 + worker: + - 8 + - 10 + - 12 + - name: mix18 + in: + difficulty: + - 3 + - 6 + - 9 + profit: + - 30 + - 60 + - 90 + worker: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - name: mix19 + in: + difficulty: + - 11 + - 22 + profit: + - 110 + - 220 + worker: + - 11 + - 22 + - 33 + - name: mix20 + in: + difficulty: + - 2 + - 4 + - 6 + profit: + - 60 + - 40 + - 20 + worker: + - 2 + - 3 + - 6 + - name: mix21 + in: + difficulty: + - 5 + - 10 + - 15 + profit: + - 15 + - 10 + - 5 + worker: + - 5 + - 10 + - 15 + - name: mix22 + in: + difficulty: + - 5 + - 5 + - 5 + profit: + - 5 + - 50 + - 10 + worker: + - 5 + - name: mix23 + in: + difficulty: + - 7 + - 14 + - 21 + profit: + - 70 + - 140 + - 210 + worker: + - 6 + - 7 + - 13 + - 14 + - 20 + - 21 + - name: mix24 + in: + difficulty: + - 1000 + profit: + - 1 + worker: + - 999 + - 1000 + - name: mix25 + in: + difficulty: + - 1 + - 2 + - 3 + profit: + - 10 + - 100 + - 20 + worker: + - 3 + - 3 + - 3 + - name: mix26 + in: + difficulty: + - 2 + - 5 + - 8 + profit: + - 20 + - 25 + - 30 + worker: + - 1 + - 4 + - 7 + - 10 + - name: mix27 + in: + difficulty: + - 6 + - 7 + profit: + - 60 + - 70 + worker: + - 6 + - 7 + - 8 + - name: mix28 + in: + difficulty: + - 9 + - 9 + - 1 + profit: + - 90 + - 80 + - 5 + worker: + - 1 + - 9 diff --git a/tests/501-1000/826. most-profit-assigning-work/sol.cpp b/tests/501-1000/826. most-profit-assigning-work/sol.cpp new file mode 100644 index 00000000..7b2f0c95 --- /dev/null +++ b/tests/501-1000/826. most-profit-assigning-work/sol.cpp @@ -0,0 +1,21 @@ +class Solution { +public: + int maxProfitAssignment(vector& difficulty, vector& profit, vector& worker) { + int n = difficulty.size(); + vector> jobs; + for (int i = 0; i < n; i++) { + jobs.emplace_back(difficulty[i], profit[i]); + } + sort(jobs.begin(), jobs.end()); + sort(worker.begin(), worker.end()); + int ans = 0, best = 0, i = 0; + for (int ability : worker) { + while (i < n && jobs[i].first <= ability) { + best = max(best, jobs[i].second); + i++; + } + ans += best; + } + return ans; + } +}; diff --git a/tests/501-1000/826. most-profit-assigning-work/sol.cs b/tests/501-1000/826. most-profit-assigning-work/sol.cs new file mode 100644 index 00000000..5a9a09f3 --- /dev/null +++ b/tests/501-1000/826. most-profit-assigning-work/sol.cs @@ -0,0 +1,20 @@ +public class Solution { + public int MaxProfitAssignment(int[] difficulty, int[] profit, int[] worker) { + int n = difficulty.Length; + int[][] jobs = new int[n][]; + for (int i = 0; i < n; i++) { + jobs[i] = new int[] { difficulty[i], profit[i] }; + } + Array.Sort(jobs, (a, b) => a[0].CompareTo(b[0])); + Array.Sort(worker); + int ans = 0, best = 0, idx = 0; + foreach (int ability in worker) { + while (idx < n && jobs[idx][0] <= ability) { + best = Math.Max(best, jobs[idx][1]); + idx++; + } + ans += best; + } + return ans; + } +} diff --git a/tests/501-1000/826. most-profit-assigning-work/sol.dart b/tests/501-1000/826. most-profit-assigning-work/sol.dart new file mode 100644 index 00000000..67d99207 --- /dev/null +++ b/tests/501-1000/826. most-profit-assigning-work/sol.dart @@ -0,0 +1,17 @@ +class Solution { + int maxProfitAssignment(List difficulty, List profit, List worker) { + int n = difficulty.length; + List> jobs = List.generate(n, (i) => [difficulty[i], profit[i]]); + jobs.sort((a, b) => a[0].compareTo(b[0])); + worker.sort(); + int ans = 0, best = 0, i = 0; + for (int ability in worker) { + while (i < n && jobs[i][0] <= ability) { + best = best > jobs[i][1] ? best : jobs[i][1]; + i++; + } + ans += best; + } + return ans; + } +} diff --git a/tests/501-1000/826. most-profit-assigning-work/sol.go b/tests/501-1000/826. most-profit-assigning-work/sol.go new file mode 100644 index 00000000..fa9a4038 --- /dev/null +++ b/tests/501-1000/826. most-profit-assigning-work/sol.go @@ -0,0 +1,24 @@ +func maxProfitAssignment(difficulty []int, profit []int, worker []int) int { + n := len(difficulty) + jobs := make([][2]int, n) + for i := 0; i < n; i++ { + jobs[i] = [2]int{difficulty[i], profit[i]} + } + sort.Slice(jobs, func(i, j int) bool { + return jobs[i][0] < jobs[j][0] + }) + sort.Ints(worker) + ans := 0 + best := 0 + idx := 0 + for _, ability := range worker { + for idx < n && jobs[idx][0] <= ability { + if jobs[idx][1] > best { + best = jobs[idx][1] + } + idx++ + } + ans += best + } + return ans +} diff --git a/tests/501-1000/826. most-profit-assigning-work/sol.java b/tests/501-1000/826. most-profit-assigning-work/sol.java new file mode 100644 index 00000000..5fe735ad --- /dev/null +++ b/tests/501-1000/826. most-profit-assigning-work/sol.java @@ -0,0 +1,21 @@ +class Solution { + public int maxProfitAssignment(int[] difficulty, int[] profit, int[] worker) { + int n = difficulty.length; + int[][] jobs = new int[n][2]; + for (int j = 0; j < n; j++) { + jobs[j][0] = difficulty[j]; + jobs[j][1] = profit[j]; + } + java.util.Arrays.sort(jobs, (a, b) -> Integer.compare(a[0], b[0])); + java.util.Arrays.sort(worker); + int ans = 0, best = 0, i = 0; + for (int ability : worker) { + while (i < n && jobs[i][0] <= ability) { + best = Math.max(best, jobs[i][1]); + i++; + } + ans += best; + } + return ans; + } +} diff --git a/tests/501-1000/826. most-profit-assigning-work/sol.kt b/tests/501-1000/826. most-profit-assigning-work/sol.kt new file mode 100644 index 00000000..b656acbc --- /dev/null +++ b/tests/501-1000/826. most-profit-assigning-work/sol.kt @@ -0,0 +1,17 @@ +class Solution { + fun maxProfitAssignment(difficulty: IntArray, profit: IntArray, worker: IntArray): Int { + val jobs = difficulty.zip(profit).sortedBy { it.first } + worker.sort() + var ans = 0 + var best = 0 + var i = 0 + for (ability in worker) { + while (i < jobs.size && jobs[i].first <= ability) { + best = maxOf(best, jobs[i].second) + i++ + } + ans += best + } + return ans + } +} diff --git a/tests/501-1000/826. most-profit-assigning-work/sol.py b/tests/501-1000/826. most-profit-assigning-work/sol.py new file mode 100644 index 00000000..879d0e57 --- /dev/null +++ b/tests/501-1000/826. most-profit-assigning-work/sol.py @@ -0,0 +1,13 @@ +class Solution(object): + def maxProfitAssignment(self, difficulty, profit, worker): + jobs = sorted(zip(difficulty, profit)) + worker.sort() + ans = 0 + best = 0 + i = 0 + for ability in worker: + while i < len(jobs) and jobs[i][0] <= ability: + best = max(best, jobs[i][1]) + i += 1 + ans += best + return ans diff --git a/tests/501-1000/826. most-profit-assigning-work/sol.py2 b/tests/501-1000/826. most-profit-assigning-work/sol.py2 new file mode 100644 index 00000000..879d0e57 --- /dev/null +++ b/tests/501-1000/826. most-profit-assigning-work/sol.py2 @@ -0,0 +1,13 @@ +class Solution(object): + def maxProfitAssignment(self, difficulty, profit, worker): + jobs = sorted(zip(difficulty, profit)) + worker.sort() + ans = 0 + best = 0 + i = 0 + for ability in worker: + while i < len(jobs) and jobs[i][0] <= ability: + best = max(best, jobs[i][1]) + i += 1 + ans += best + return ans diff --git a/tests/501-1000/826. most-profit-assigning-work/sol.rb b/tests/501-1000/826. most-profit-assigning-work/sol.rb new file mode 100644 index 00000000..bd8032a2 --- /dev/null +++ b/tests/501-1000/826. most-profit-assigning-work/sol.rb @@ -0,0 +1,19 @@ +# @param {Integer[]} difficulty +# @param {Integer[]} profit +# @param {Integer[]} worker +# @return {Integer} +def max_profit_assignment(difficulty, profit, worker) + jobs = difficulty.zip(profit).sort_by(&:first) + worker.sort! + ans = 0 + best = 0 + i = 0 + worker.each do |ability| + while i < jobs.length && jobs[i][0] <= ability + best = [best, jobs[i][1]].max + i += 1 + end + ans += best + end + ans +end diff --git a/tests/501-1000/826. most-profit-assigning-work/sol.rs b/tests/501-1000/826. most-profit-assigning-work/sol.rs new file mode 100644 index 00000000..3d1f0208 --- /dev/null +++ b/tests/501-1000/826. most-profit-assigning-work/sol.rs @@ -0,0 +1,20 @@ +impl Solution { + pub fn max_profit_assignment(difficulty: Vec, profit: Vec, worker: Vec) -> i32 { + let mut jobs: Vec<(i32, i32)> = difficulty.into_iter().zip(profit.into_iter()).collect(); + jobs.sort_by_key(|&(d, _)| d); + let mut worker = worker; + worker.sort_unstable(); + let mut ans = 0; + let mut best = 0; + let mut i = 0; + let n = jobs.len(); + for ability in worker { + while i < n && jobs[i].0 <= ability { + best = best.max(jobs[i].1); + i += 1; + } + ans += best; + } + ans + } +} diff --git a/tests/501-1000/826. most-profit-assigning-work/sol.swift b/tests/501-1000/826. most-profit-assigning-work/sol.swift new file mode 100644 index 00000000..394aba69 --- /dev/null +++ b/tests/501-1000/826. most-profit-assigning-work/sol.swift @@ -0,0 +1,17 @@ +class Solution { + func maxProfitAssignment(_ difficulty: [Int], _ profit: [Int], _ worker: [Int]) -> Int { + let jobs = zip(difficulty, profit).sorted { $0.0 < $1.0 } + let worker = worker.sorted() + var ans = 0 + var best = 0 + var i = 0 + for ability in worker { + while i < jobs.count && jobs[i].0 <= ability { + best = max(best, jobs[i].1) + i += 1 + } + ans += best + } + return ans + } +} diff --git a/tests/501-1000/826. most-profit-assigning-work/sol.ts b/tests/501-1000/826. most-profit-assigning-work/sol.ts new file mode 100644 index 00000000..d6e42896 --- /dev/null +++ b/tests/501-1000/826. most-profit-assigning-work/sol.ts @@ -0,0 +1,20 @@ +function maxProfitAssignment( + difficulty: number[], + profit: number[], + worker: number[], +): number { + const jobs: [number, number][] = difficulty.map((d, i) => [d, profit[i]]); + jobs.sort((a, b) => a[0] - b[0]); + worker.sort((a, b) => a - b); + let ans = 0, + best = 0, + i = 0; + for (const ability of worker) { + while (i < jobs.length && jobs[i][0] <= ability) { + best = Math.max(best, jobs[i][1]); + i++; + } + ans += best; + } + return ans; +} diff --git a/tests/501-1000/827. making-a-large-island/manifest.yaml b/tests/501-1000/827. making-a-large-island/manifest.yaml new file mode 100644 index 00000000..792e3f61 --- /dev/null +++ b/tests/501-1000/827. making-a-large-island/manifest.yaml @@ -0,0 +1,1020 @@ +entry: + id: 827 + title: making-a-large-island + params: + grid: + type: array + items: + type: array + items: + type: int + call: + cpp: Solution().largestIsland({grid}) + rust: Solution::largest_island({grid}) + python3: Solution().largestIsland({grid}) + python2: Solution().largestIsland({grid}) + ruby: largest_island({grid}) + java: new Solution().largestIsland({grid}) + csharp: new Solution().LargestIsland({grid}) + kotlin: Solution().largestIsland({grid}) + go: largestIsland({grid}) + dart: Solution().largestIsland({grid}) + swift: Solution().largestIsland({grid}) + typescript: largestIsland({grid}) +judge: + type: exact +limits: + time_ms: 2000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: | + class Checker: + def check(self, result): + return isinstance(result, int) +seed: 827 +tests: + - name: ex1 + in: + grid: + elemType: int + value: + - - 1 + - 0 + - - 0 + - 1 + out: 3 + - name: ex2 + in: + grid: + elemType: int + value: + - - 1 + - 1 + - - 1 + - 0 + out: 4 + - name: ex3 + in: + grid: + elemType: int + value: + - - 1 + - 1 + - - 1 + - 1 + out: 4 + - name: single-zero + in: + grid: + elemType: int + value: + - - 0 + out: 1 + - name: single-one + in: + grid: + elemType: int + value: + - - 1 + out: 1 + - name: two-by-two-diagonal + in: + grid: + elemType: int + value: + - - 1 + - 0 + - - 0 + - 1 + out: 3 + - name: two-by-two-one-corner + in: + grid: + elemType: int + value: + - - 1 + - 0 + - - 0 + - 0 + out: 2 + - name: two-by-two-line + in: + grid: + elemType: int + value: + - - 1 + - 1 + - - 0 + - 0 + out: 3 + - name: three-row + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 0 + - - 0 + - 1 + - 0 + - - 0 + - 0 + - 0 + out: 4 + - name: three-cross + in: + grid: + elemType: int + value: + - - 0 + - 1 + - 0 + - - 1 + - 0 + - 1 + - - 0 + - 1 + - 0 + out: 5 + - name: three-all-ones + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + out: 9 + - name: three-all-zeros + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + out: 1 + - name: l-shape + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 0 + - - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + out: 4 + - name: vertical-line + in: + grid: + elemType: int + value: + - - 1 + - 0 + - 0 + - - 1 + - 0 + - 0 + - - 1 + - 0 + - 0 + out: 4 + - name: checker-3 + in: + grid: + elemType: int + value: + - - 1 + - 0 + - 1 + - - 0 + - 1 + - 0 + - - 1 + - 0 + - 1 + out: 4 + - name: ring-3 + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 1 + - - 1 + - 0 + - 1 + - - 1 + - 1 + - 1 + out: 9 + - name: 4x4-one-hole + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 0 + - 1 + - - 1 + - 1 + - 1 + - 1 + out: 16 + - name: 4x4-two-islands + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 0 + - 0 + - - 1 + - 1 + - 0 + - 1 + - - 0 + - 0 + - 0 + - 1 + - - 0 + - 1 + - 1 + - 1 + out: 10 + - name: 4x4-scattered + in: + grid: + elemType: int + value: + - - 1 + - 0 + - 0 + - 1 + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 0 + - 0 + - - 1 + - 0 + - 1 + - 0 + out: 4 + - name: 5x5-all-ones + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + out: 25 + - name: 5x5-all-zeros + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + out: 1 + - name: 5x5-larger-island + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 0 + - 0 + - 0 + - - 1 + - 1 + - 0 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 1 + - 0 + - - 0 + - 1 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + out: 11 + - name: 5x5-border + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 0 + - 0 + - 0 + - 1 + - - 1 + - 0 + - 1 + - 0 + - 1 + - - 1 + - 0 + - 0 + - 0 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + out: 18 + - name: 6x6-separated + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 0 + - 0 + - 1 + - 1 + - - 1 + - 1 + - 0 + - 0 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - - 1 + - 1 + - 1 + - 1 + - 0 + - 0 + - - 1 + - 1 + - 1 + - 1 + - 0 + - 0 + out: 11 + - name: 6x6-lanes + in: + grid: + elemType: int + value: + - - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + out: 16 + - name: 6x6-checker + in: + grid: + elemType: int + value: + - - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + out: 5 + - name: 6x6-center-hole + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 0 + - 0 + - 0 + - 0 + - 1 + - - 1 + - 0 + - 1 + - 1 + - 0 + - 1 + - - 1 + - 0 + - 1 + - 1 + - 0 + - 1 + - - 1 + - 0 + - 0 + - 0 + - 0 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + out: 25 + - name: 6x6-two-holes + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 1 + - 0 + - 1 + - 1 + - - 1 + - 0 + - 1 + - 0 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 0 + - 1 + - 1 + - 1 + out: 29 + - name: 7x7-ring + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - - 1 + - 0 + - 1 + - 1 + - 1 + - 0 + - 1 + - - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - - 1 + - 0 + - 1 + - 1 + - 1 + - 0 + - 1 + - - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + out: 33 + - name: 7x7-scattered + in: + grid: + elemType: int + value: + - - 1 + - 0 + - 0 + - 1 + - 0 + - 0 + - 1 + - - 0 + - 0 + - 1 + - 0 + - 0 + - 1 + - 0 + - - 0 + - 1 + - 0 + - 0 + - 1 + - 0 + - 0 + - - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - - 0 + - 0 + - 1 + - 0 + - 0 + - 1 + - 0 + - - 0 + - 1 + - 0 + - 0 + - 1 + - 0 + - 0 + - - 1 + - 0 + - 0 + - 1 + - 0 + - 0 + - 1 + out: 3 + - name: 7x7-plus + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 1 + - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 0 + - 1 + - 0 + - 0 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 0 + - 0 + - 1 + - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 0 + - 1 + - 0 + - 0 + out: 20 + - name: 5x6-lshape-large + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 1 + - 0 + - 0 + - - 1 + - 0 + - 1 + - 0 + - 1 + - - 1 + - 0 + - 1 + - 0 + - 1 + - - 0 + - 0 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 0 + - 0 + - 1 + - name: 5x6-two-components + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 0 + - 0 + - 1 + - - 1 + - 1 + - 0 + - 0 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 0 + - - 1 + - 1 + - 1 + - 0 + - 1 + - - 1 + - 1 + - 1 + - 0 + - 1 + - name: 5x5-one-flip-bridge + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 0 + - 1 + - 1 + - - 1 + - 1 + - 0 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 0 + - - 1 + - 1 + - 0 + - 1 + - 1 + - - 1 + - 1 + - 0 + - 1 + - 1 + out: 9 + - name: 4x5-zigzag + in: + grid: + elemType: int + value: + - - 1 + - 0 + - 1 + - 0 + - - 1 + - 1 + - 0 + - 1 + - - 0 + - 1 + - 1 + - 0 + - - 1 + - 0 + - 1 + - 1 + - name: 4x4-dense-hole + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 1 + - 1 + - - 1 + - 0 + - 0 + - 1 + - - 1 + - 0 + - 0 + - 1 + - - 1 + - 1 + - 1 + - 1 + out: 13 + - name: 3x3-plus + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 1 + - - 0 + - 1 + - 0 + - - 1 + - 1 + - 1 + out: 8 + - name: 4x4-double-block + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 0 + - 0 + - - 1 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + - - 0 + - 0 + - 1 + - 1 + out: 9 + - name: 4x4-diamond + in: + grid: + elemType: int + value: + - - 0 + - 1 + - 0 + - 0 + - - 1 + - 0 + - 1 + - 0 + - - 0 + - 1 + - 0 + - 1 + - - 0 + - 0 + - 1 + - 0 + out: 5 + - name: 5x5-ladder + in: + grid: + elemType: int + value: + - - 1 + - 1 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 0 + - 0 + - - 1 + - 1 + - 1 + - 1 + - 1 + - - 0 + - 0 + - 1 + - 0 + - 0 + - - 1 + - 1 + - 1 + - 1 + - 1 + out: 16 diff --git a/tests/501-1000/827. making-a-large-island/sol.cpp b/tests/501-1000/827. making-a-large-island/sol.cpp new file mode 100644 index 00000000..604bbfb9 --- /dev/null +++ b/tests/501-1000/827. making-a-large-island/sol.cpp @@ -0,0 +1,55 @@ +class Solution { +public: + int largestIsland(vector>& grid) { + int r = grid.size(); + int c = grid[0].size(); + vector> dirs = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; + int island = 2; + unordered_map a; + + function dfs = [&](int i, int j, int x) -> int { + int tot = 1; + grid[i][j] = x; + for (auto [dx, dy] : dirs) { + int nx = i + dx; + int ny = j + dy; + if (nx >= 0 && nx < r && ny >= 0 && ny < c && grid[nx][ny] == 1) { + tot += dfs(nx, ny, x); + } + } + return tot; + }; + + for (int i = 0; i < r; i++) { + for (int j = 0; j < c; j++) { + if (grid[i][j] == 1) { + a[island] = dfs(i, j, island); + island++; + } + } + } + + int res = 0; + for (int i = 0; i < r; i++) { + for (int j = 0; j < c; j++) { + if (grid[i][j] == 0) { + unordered_set y; + for (auto [dx, dy] : dirs) { + int nx = i + dx; + int ny = j + dy; + if (nx >= 0 && nx < r && ny >= 0 && ny < c && grid[nx][ny] != 0) { + y.insert(grid[nx][ny]); + } + } + int tot = 1; + for (int b : y) { + tot += a[b]; + } + res = max(res, tot); + } + } + } + + return max(res, a[2]); + } +}; diff --git a/tests/501-1000/827. making-a-large-island/sol.cs b/tests/501-1000/827. making-a-large-island/sol.cs new file mode 100644 index 00000000..c153d7bf --- /dev/null +++ b/tests/501-1000/827. making-a-large-island/sol.cs @@ -0,0 +1,54 @@ +public class Solution { + public int LargestIsland(int[][] grid) { + int r = grid.Length; + int c = grid[0].Length; + int[][] dirs = new int[][] { new int[] {1, 0}, new int[] {0, 1}, new int[] {-1, 0}, new int[] {0, -1} }; + int island = 2; + Dictionary a = new Dictionary(); + + int Dfs(int i, int j, int x) { + int tot = 1; + grid[i][j] = x; + foreach (var d in dirs) { + int nx = i + d[0]; + int ny = j + d[1]; + if (nx >= 0 && nx < r && ny >= 0 && ny < c && grid[nx][ny] == 1) { + tot += Dfs(nx, ny, x); + } + } + return tot; + } + + for (int i = 0; i < r; i++) { + for (int j = 0; j < c; j++) { + if (grid[i][j] == 1) { + a[island] = Dfs(i, j, island); + island++; + } + } + } + + int res = 0; + for (int i = 0; i < r; i++) { + for (int j = 0; j < c; j++) { + if (grid[i][j] == 0) { + HashSet y = new HashSet(); + foreach (var d in dirs) { + int nx = i + d[0]; + int ny = j + d[1]; + if (nx >= 0 && nx < r && ny >= 0 && ny < c && grid[nx][ny] != 0) { + y.Add(grid[nx][ny]); + } + } + int tot = 1; + foreach (int b in y) { + tot += a[b]; + } + res = Math.Max(res, tot); + } + } + } + + return Math.Max(res, a.GetValueOrDefault(2, 0)); + } +} diff --git a/tests/501-1000/827. making-a-large-island/sol.dart b/tests/501-1000/827. making-a-large-island/sol.dart new file mode 100644 index 00000000..53e92fed --- /dev/null +++ b/tests/501-1000/827. making-a-large-island/sol.dart @@ -0,0 +1,54 @@ +class Solution { + int largestIsland(List> grid) { + int r = grid.length; + int c = grid[0].length; + List> dirs = [[1, 0], [0, 1], [-1, 0], [0, -1]]; + int island = 2; + Map a = {}; + + int dfs(int i, int j, int x) { + int tot = 1; + grid[i][j] = x; + for (var d in dirs) { + int nx = i + d[0]; + int ny = j + d[1]; + if (nx >= 0 && nx < r && ny >= 0 && ny < c && grid[nx][ny] == 1) { + tot += dfs(nx, ny, x); + } + } + return tot; + } + + for (int i = 0; i < r; i++) { + for (int j = 0; j < c; j++) { + if (grid[i][j] == 1) { + a[island] = dfs(i, j, island); + island++; + } + } + } + + int res = 0; + for (int i = 0; i < r; i++) { + for (int j = 0; j < c; j++) { + if (grid[i][j] == 0) { + Set y = {}; + for (var d in dirs) { + int nx = i + d[0]; + int ny = j + d[1]; + if (nx >= 0 && nx < r && ny >= 0 && ny < c && grid[nx][ny] != 0) { + y.add(grid[nx][ny]); + } + } + int tot = 1; + for (int b in y) { + tot += a[b] ?? 0; + } + res = res > tot ? res : tot; + } + } + } + + return res > (a[2] ?? 0) ? res : (a[2] ?? 0); + } +} diff --git a/tests/501-1000/827. making-a-large-island/sol.go b/tests/501-1000/827. making-a-large-island/sol.go new file mode 100644 index 00000000..3e6b7517 --- /dev/null +++ b/tests/501-1000/827. making-a-large-island/sol.go @@ -0,0 +1,56 @@ +func largestIsland(grid [][]int) int { + r := len(grid) + c := len(grid[0]) + dirs := [][]int{{1, 0}, {0, 1}, {-1, 0}, {0, -1}} + island := 2 + a := make(map[int]int) + + var dfs func(int, int, int) int + dfs = func(i, j, x int) int { + tot := 1 + grid[i][j] = x + for _, d := range dirs { + nx, ny := i+d[0], j+d[1] + if nx >= 0 && nx < r && ny >= 0 && ny < c && grid[nx][ny] == 1 { + tot += dfs(nx, ny, x) + } + } + return tot + } + + for i := 0; i < r; i++ { + for j := 0; j < c; j++ { + if grid[i][j] == 1 { + a[island] = dfs(i, j, island) + island++ + } + } + } + + res := 0 + for i := 0; i < r; i++ { + for j := 0; j < c; j++ { + if grid[i][j] == 0 { + y := make(map[int]bool) + for _, d := range dirs { + nx, ny := i+d[0], j+d[1] + if nx >= 0 && nx < r && ny >= 0 && ny < c && grid[nx][ny] != 0 { + y[grid[nx][ny]] = true + } + } + tot := 1 + for b := range y { + tot += a[b] + } + if tot > res { + res = tot + } + } + } + } + + if val, ok := a[2]; ok && val > res { + return val + } + return res +} diff --git a/tests/501-1000/827. making-a-large-island/sol.java b/tests/501-1000/827. making-a-large-island/sol.java new file mode 100644 index 00000000..d28c33c5 --- /dev/null +++ b/tests/501-1000/827. making-a-large-island/sol.java @@ -0,0 +1,54 @@ +class Solution { + public int largestIsland(int[][] grid) { + int r = grid.length; + int c = grid[0].length; + int[][] dirs = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; + int island = 2; + java.util.Map a = new java.util.HashMap<>(); + + for (int i = 0; i < r; i++) { + for (int j = 0; j < c; j++) { + if (grid[i][j] == 1) { + a.put(island, dfs(grid, i, j, r, c, dirs, island)); + island++; + } + } + } + + int res = 0; + for (int i = 0; i < r; i++) { + for (int j = 0; j < c; j++) { + if (grid[i][j] == 0) { + java.util.Set y = new java.util.HashSet<>(); + for (int[] d : dirs) { + int nx = i + d[0]; + int ny = j + d[1]; + if (nx >= 0 && nx < r && ny >= 0 && ny < c && grid[nx][ny] != 0) { + y.add(grid[nx][ny]); + } + } + int tot = 1; + for (int b : y) { + tot += a.get(b); + } + res = Math.max(res, tot); + } + } + } + + return Math.max(res, a.getOrDefault(2, 0)); + } + + private int dfs(int[][] grid, int i, int j, int r, int c, int[][] dirs, int x) { + int tot = 1; + grid[i][j] = x; + for (int[] d : dirs) { + int nx = i + d[0]; + int ny = j + d[1]; + if (nx >= 0 && nx < r && ny >= 0 && ny < c && grid[nx][ny] == 1) { + tot += dfs(grid, nx, ny, r, c, dirs, x); + } + } + return tot; + } +} diff --git a/tests/501-1000/827. making-a-large-island/sol.kt b/tests/501-1000/827. making-a-large-island/sol.kt new file mode 100644 index 00000000..a4bc7ff1 --- /dev/null +++ b/tests/501-1000/827. making-a-large-island/sol.kt @@ -0,0 +1,54 @@ +class Solution { + fun largestIsland(grid: Array): Int { + val r = grid.size + val c = grid[0].size + val dirs = arrayOf(intArrayOf(1, 0), intArrayOf(0, 1), intArrayOf(-1, 0), intArrayOf(0, -1)) + var island = 2 + val a = mutableMapOf() + + fun dfs(i: Int, j: Int, x: Int): Int { + var tot = 1 + grid[i][j] = x + for (d in dirs) { + val nx = i + d[0] + val ny = j + d[1] + if (nx in 0 until r && ny in 0 until c && grid[nx][ny] == 1) { + tot += dfs(nx, ny, x) + } + } + return tot + } + + for (i in 0 until r) { + for (j in 0 until c) { + if (grid[i][j] == 1) { + a[island] = dfs(i, j, island) + island++ + } + } + } + + var res = 0 + for (i in 0 until r) { + for (j in 0 until c) { + if (grid[i][j] == 0) { + val y = mutableSetOf() + for (d in dirs) { + val nx = i + d[0] + val ny = j + d[1] + if (nx in 0 until r && ny in 0 until c && grid[nx][ny] != 0) { + y.add(grid[nx][ny]) + } + } + var tot = 1 + for (b in y) { + tot += a[b] ?: 0 + } + res = maxOf(res, tot) + } + } + } + + return maxOf(res, a[2] ?: 0) + } +} diff --git a/tests/501-1000/827. making-a-large-island/sol.py b/tests/501-1000/827. making-a-large-island/sol.py new file mode 100644 index 00000000..663a2819 --- /dev/null +++ b/tests/501-1000/827. making-a-large-island/sol.py @@ -0,0 +1,38 @@ +class Solution: + def largestIsland(self, grid: List[List[int]]) -> int: + + r, c = len(grid), len(grid[0]) + dir = {(1, 0), (0, 1), (-1, 0), (0, -1)} + island = 2 + + def dfs(i, j, x): + tot = 1 + grid[i][j] = x + for dx, dy in dir: + nx, ny = i + dx, j + dy + if 0 <= nx < r and 0 <= ny < c and grid[nx][ny] == 1: + tot += dfs(nx, ny, x) + return tot + + a = defaultdict(int) + for i in range(r): + for j in range(c): + if grid[i][j] == 1: + a[island] = dfs(i, j, island) + island += 1 + + res = 0 + for i in range(r): + for j in range(c): + if grid[i][j] == 0: + y = set() + for dx, dy in dir: + nx, ny = i + dx, j + dy + if 0 <= nx < r and 0 <= ny < c and grid[nx][ny] != 0: + y.add(grid[nx][ny]) + tot = 1 + for b in list(y): + tot += a[b] + res = max(res, tot) + + return max(res, a[2]) diff --git a/tests/501-1000/827. making-a-large-island/sol.py2 b/tests/501-1000/827. making-a-large-island/sol.py2 new file mode 100644 index 00000000..cf81af6e --- /dev/null +++ b/tests/501-1000/827. making-a-large-island/sol.py2 @@ -0,0 +1,41 @@ +class Solution(object): + def largestIsland(self, grid): + """ + :type grid: List[List[int]] + :rtype: int + """ + r, c = len(grid), len(grid[0]) + dirs = [(1, 0), (0, 1), (-1, 0), (0, -1)] + island = 2 + + def dfs(i, j, x): + tot = 1 + grid[i][j] = x + for dx, dy in dirs: + nx, ny = i + dx, j + dy + if 0 <= nx < r and 0 <= ny < c and grid[nx][ny] == 1: + tot += dfs(nx, ny, x) + return tot + + a = {} + for i in range(r): + for j in range(c): + if grid[i][j] == 1: + a[island] = dfs(i, j, island) + island += 1 + + res = 0 + for i in range(r): + for j in range(c): + if grid[i][j] == 0: + y = set() + for dx, dy in dirs: + nx, ny = i + dx, j + dy + if 0 <= nx < r and 0 <= ny < c and grid[nx][ny] != 0: + y.add(grid[nx][ny]) + tot = 1 + for b in list(y): + tot += a[b] + res = max(res, tot) + + return max(res, a.get(2, 0)) diff --git a/tests/501-1000/827. making-a-large-island/sol.rb b/tests/501-1000/827. making-a-large-island/sol.rb new file mode 100644 index 00000000..c90574ab --- /dev/null +++ b/tests/501-1000/827. making-a-large-island/sol.rb @@ -0,0 +1,54 @@ +# @param {Integer[][]} grid +# @return {Integer} +def largest_island(grid) + r = grid.length + c = grid[0].length + dirs = [[1, 0], [0, 1], [-1, 0], [0, -1]] + island = 2 + a = Hash.new(0) + + dfs = lambda do |i, j, x| + tot = 1 + grid[i][j] = x + dirs.each do |dx, dy| + nx = i + dx + ny = j + dy + if nx >= 0 && nx < r && ny >= 0 && ny < c && grid[nx][ny] == 1 + tot += dfs.call(nx, ny, x) + end + end + tot + end + + (0...r).each do |i| + (0...c).each do |j| + if grid[i][j] == 1 + a[island] = dfs.call(i, j, island) + island += 1 + end + end + end + + res = 0 + (0...r).each do |i| + (0...c).each do |j| + if grid[i][j] == 0 + y = Set.new + dirs.each do |dx, dy| + nx = i + dx + ny = j + dy + if nx >= 0 && nx < r && ny >= 0 && ny < c && grid[nx][ny] != 0 + y.add(grid[nx][ny]) + end + end + tot = 1 + y.each do |b| + tot += a[b] + end + res = [res, tot].max + end + end + end + + [res, a[2] || 0].max +end diff --git a/tests/501-1000/827. making-a-large-island/sol.rs b/tests/501-1000/827. making-a-large-island/sol.rs new file mode 100644 index 00000000..e2b40cc9 --- /dev/null +++ b/tests/501-1000/827. making-a-large-island/sol.rs @@ -0,0 +1,66 @@ +impl Solution { + pub fn largest_island(grid: Vec>) -> i32 { + let mut grid = grid; + let r = grid.len(); + let c = grid[0].len(); + let dirs = [(1, 0), (0, 1), (-1, 0), (0, -1)]; + let mut island = 2; + let mut a = std::collections::HashMap::new(); + + fn dfs(grid: &mut Vec>, i: usize, j: usize, x: i32, r: usize, c: usize, dirs: &[(i32, i32)]) -> i32 { + let mut tot = 1; + grid[i][j] = x; + for &(dx, dy) in dirs { + let nx = i as i32 + dx; + let ny = j as i32 + dy; + if nx >= 0 && ny >= 0 { + let nx = nx as usize; + let ny = ny as usize; + if nx < r && ny < c && grid[nx][ny] == 1 { + tot += dfs(grid, nx, ny, x, r, c, dirs); + } + } + } + tot + } + + for i in 0..r { + for j in 0..c { + if grid[i][j] == 1 { + let val = dfs(&mut grid, i, j, island, r, c, &dirs); + a.insert(island, val); + island += 1; + } + } + } + + let mut res = 0; + for i in 0..r { + for j in 0..c { + if grid[i][j] == 0 { + let mut y = std::collections::HashSet::new(); + for &(dx, dy) in &dirs { + let nx = i as i32 + dx; + let ny = j as i32 + dy; + if nx >= 0 && ny >= 0 { + let nx = nx as usize; + let ny = ny as usize; + if nx < r && ny < c && grid[nx][ny] != 0 { + y.insert(grid[nx][ny]); + } + } + } + let mut tot = 1; + for b in y { + if let Some(&v) = a.get(&b) { + tot += v; + } + } + res = res.max(tot); + } + } + } + + res.max(*a.get(&2).unwrap_or(&0)) + } +} diff --git a/tests/501-1000/827. making-a-large-island/sol.swift b/tests/501-1000/827. making-a-large-island/sol.swift new file mode 100644 index 00000000..9304b43d --- /dev/null +++ b/tests/501-1000/827. making-a-large-island/sol.swift @@ -0,0 +1,55 @@ +class Solution { + func largestIsland(_ grid: [[Int]]) -> Int { + var grid = grid + let r = grid.count + let c = grid[0].count + let dirs = [(1, 0), (0, 1), (-1, 0), (0, -1)] + var island = 2 + var a = [Int: Int]() + + func dfs(_ i: Int, _ j: Int, _ x: Int) -> Int { + var tot = 1 + grid[i][j] = x + for (dx, dy) in dirs { + let nx = i + dx + let ny = j + dy + if nx >= 0 && nx < r && ny >= 0 && ny < c && grid[nx][ny] == 1 { + tot += dfs(nx, ny, x) + } + } + return tot + } + + for i in 0..() + for (dx, dy) in dirs { + let nx = i + dx + let ny = j + dy + if nx >= 0 && nx < r && ny >= 0 && ny < c && grid[nx][ny] != 0 { + y.insert(grid[nx][ny]) + } + } + var tot = 1 + for b in y { + tot += a[b] ?? 0 + } + res = max(res, tot) + } + } + } + + return max(res, a[2] ?? 0) + } +} diff --git a/tests/501-1000/827. making-a-large-island/sol.ts b/tests/501-1000/827. making-a-large-island/sol.ts new file mode 100644 index 00000000..b6752439 --- /dev/null +++ b/tests/501-1000/827. making-a-large-island/sol.ts @@ -0,0 +1,57 @@ +function largestIsland(grid: number[][]): number { + const r = grid.length; + const c = grid[0].length; + const dirs = [ + [1, 0], + [0, 1], + [-1, 0], + [0, -1], + ]; + let island = 2; + const a = new Map(); + + function dfs(i: number, j: number, x: number): number { + let tot = 1; + grid[i][j] = x; + for (const [dx, dy] of dirs) { + const nx = i + dx; + const ny = j + dy; + if (nx >= 0 && nx < r && ny >= 0 && ny < c && grid[nx][ny] === 1) { + tot += dfs(nx, ny, x); + } + } + return tot; + } + + for (let i = 0; i < r; i++) { + for (let j = 0; j < c; j++) { + if (grid[i][j] === 1) { + a.set(island, dfs(i, j, island)); + island++; + } + } + } + + let res = 0; + for (let i = 0; i < r; i++) { + for (let j = 0; j < c; j++) { + if (grid[i][j] === 0) { + const y = new Set(); + for (const [dx, dy] of dirs) { + const nx = i + dx; + const ny = j + dy; + if (nx >= 0 && nx < r && ny >= 0 && ny < c && grid[nx][ny] !== 0) { + y.add(grid[nx][ny]); + } + } + let tot = 1; + for (const b of y) { + tot += a.get(b) ?? 0; + } + res = Math.max(res, tot); + } + } + } + + return Math.max(res, a.get(2) ?? 0); +} diff --git a/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/manifest.yaml b/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/manifest.yaml new file mode 100644 index 00000000..dae6deca --- /dev/null +++ b/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/manifest.yaml @@ -0,0 +1,193 @@ +entry: + id: 828 + title: count-unique-characters-of-all-substrings-of-a-given-string + params: + s: + type: string + call: + cpp: Solution().uniqueLetterString({s}) + rust: Solution::unique_letter_string({s}) + python3: Solution().uniqueLetterString({s}) + python2: Solution().uniqueLetterString({s}) + ruby: unique_letter_string({s}) + java: new Solution().uniqueLetterString({s}) + csharp: new Solution().UniqueLetterString({s}) + kotlin: Solution().uniqueLetterString({s}) + go: uniqueLetterString({s}) + dart: Solution().uniqueLetterString({s}) + swift: Solution().uniqueLetterString({s}) + typescript: uniqueLetterString({s}) +judge: + type: exact +limits: + time_ms: 1500 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: | + class Checker: + def check(self, result): + return True +seed: 828 +tests: + - name: ex1 + in: + s: ABC + out: 10 + - name: ex2 + in: + s: ABA + out: 8 + - name: ex3 + in: + s: LEETCODE + out: 92 + - name: single-a + in: + s: A + out: 1 + - name: double-same + in: + s: AA + out: 2 + - name: double-different + in: + s: AB + out: 4 + - name: aaa + in: + s: AAA + out: 3 + - name: aab + in: + s: AAB + out: 6 + - name: aba + in: + s: ABA + out: 8 + - name: abc + in: + s: ABC + out: 10 + - name: abca + in: + s: ABCA + out: 18 + - name: abab + in: + s: ABAB + out: 12 + - name: abcd + in: + s: ABCD + out: 20 + - name: zzzz + in: + s: ZZZZ + out: 4 + - name: aabb + in: + s: AABB + out: 8 + - name: aabc + in: + s: AABC + out: 14 + - name: abcab + in: + s: ABCAB + out: 27 + - name: leetcode + in: + s: LEETCODE + out: 92 + - name: repeated-abcdef + in: + s: ABCDEFABCDEF + out: 252 + - name: palindrome-letters + in: + s: ABCDCBA + out: 56 + - name: all-26-once + in: + s: ABCDEFGHIJKLMNOPQRSTUVWXYZ + out: 3276 + - name: all-26-twice + in: + s: ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ + out: 18252 + - name: alternating-two + in: + s: ABABABABAB + out: 36 + - name: blocks + in: + s: AAABBBCCC + out: 27 + - name: mixed-1 + in: + s: QWERTYQWERTY + out: 252 + - name: mixed-2 + in: + s: MNOPQRMNOPQR + out: 252 + - name: mixed-3 + in: + s: AZBYCXDWEV + out: 220 + - name: mixed-4 + in: + s: KAKAKAKAKA + out: 36 + - name: mixed-5 + in: + s: ABCXYZABCXYZ + out: 252 + - name: mixed-6 + in: + s: HELLOWORLD + out: 128 + - name: mixed-7 + in: + s: MISSISSIPPI + out: 61 + - name: mixed-8 + in: + s: PQRSTPQRSTP + out: 175 + - name: mixed-9 + in: + s: TTTTTTTTTT + out: 10 + - name: mixed-10 + in: + s: AABBCCDDEE + out: 50 + - name: mixed-11 + in: + s: AABCDEFFEDCBA + out: 208 + - name: mixed-12 + in: + s: XYZXYZXYZXYZ + out: 90 + - name: mixed-13 + in: + s: QQQWWEERRTT + out: 55 + - name: mixed-14 + in: + s: MNOPQRSTUVWXYZ + out: 560 + - name: mixed-15 + in: + s: ABCDEFGHIJABCDEFGHIJ + out: 1100 + - name: mixed-16 + in: + s: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + out: 50 diff --git a/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.cpp b/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.cpp new file mode 100644 index 00000000..11728896 --- /dev/null +++ b/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.cpp @@ -0,0 +1,29 @@ +class Solution { +public: + int uniqueLetterString(string s) { + int n = s.size(); + vector left(n, 0); + vector right(n, 0); + vector prev(26, -1); + + for (int i = 0; i < n; i++) { + int idx = s[i] - 'A'; + left[i] = prev[idx]; + prev[idx] = i; + } + + prev.assign(26, n); + + for (int i = n - 1; i >= 0; i--) { + int idx = s[i] - 'A'; + right[i] = prev[idx]; + prev[idx] = i; + } + + int ans = 0; + for (int i = 0; i < n; i++) { + ans += (i - left[i]) * (right[i] - i); + } + return ans; + } +}; diff --git a/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.cs b/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.cs new file mode 100644 index 00000000..8cb712c2 --- /dev/null +++ b/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.cs @@ -0,0 +1,29 @@ +public class Solution { + public int UniqueLetterString(string s) { + int n = s.Length; + int[] left = new int[n]; + int[] right = new int[n]; + int[] prev = new int[26]; + for (int i = 0; i < 26; i++) prev[i] = -1; + + for (int i = 0; i < n; i++) { + int idx = s[i] - 'A'; + left[i] = prev[idx]; + prev[idx] = i; + } + + for (int i = 0; i < 26; i++) prev[i] = n; + + for (int i = n - 1; i >= 0; i--) { + int idx = s[i] - 'A'; + right[i] = prev[idx]; + prev[idx] = i; + } + + int ans = 0; + for (int i = 0; i < n; i++) { + ans += (i - left[i]) * (right[i] - i); + } + return ans; + } +} diff --git a/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.dart b/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.dart new file mode 100644 index 00000000..db236a6e --- /dev/null +++ b/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.dart @@ -0,0 +1,28 @@ +class Solution { + int uniqueLetterString(String s) { + int n = s.length; + List left = List.filled(n, 0); + List right = List.filled(n, 0); + List prev = List.filled(26, -1); + + for (int i = 0; i < n; i++) { + int idx = s.codeUnitAt(i) - 'A'.codeUnitAt(0); + left[i] = prev[idx]; + prev[idx] = i; + } + + prev = List.filled(26, n); + + for (int i = n - 1; i >= 0; i--) { + int idx = s.codeUnitAt(i) - 'A'.codeUnitAt(0); + right[i] = prev[idx]; + prev[idx] = i; + } + + int ans = 0; + for (int i = 0; i < n; i++) { + ans += (i - left[i]) * (right[i] - i); + } + return ans; + } +} diff --git a/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.go b/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.go new file mode 100644 index 00000000..49b7c199 --- /dev/null +++ b/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.go @@ -0,0 +1,31 @@ +func uniqueLetterString(s string) int { + n := len(s) + left := make([]int, n) + right := make([]int, n) + prev := make([]int, 26) + for i := 0; i < 26; i++ { + prev[i] = -1 + } + + for i := 0; i < n; i++ { + idx := int(s[i] - 'A') + left[i] = prev[idx] + prev[idx] = i + } + + for i := 0; i < 26; i++ { + prev[i] = n + } + + for i := n - 1; i >= 0; i-- { + idx := int(s[i] - 'A') + right[i] = prev[idx] + prev[idx] = i + } + + ans := 0 + for i := 0; i < n; i++ { + ans += (i - left[i]) * (right[i] - i) + } + return ans +} diff --git a/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.java b/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.java new file mode 100644 index 00000000..00bf0a6b --- /dev/null +++ b/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.java @@ -0,0 +1,29 @@ +class Solution { + public int uniqueLetterString(String s) { + int n = s.length(); + int[] left = new int[n]; + int[] right = new int[n]; + int[] prev = new int[26]; + for (int i = 0; i < 26; i++) prev[i] = -1; + + for (int i = 0; i < n; i++) { + int idx = s.charAt(i) - 'A'; + left[i] = prev[idx]; + prev[idx] = i; + } + + for (int i = 0; i < 26; i++) prev[i] = n; + + for (int i = n - 1; i >= 0; i--) { + int idx = s.charAt(i) - 'A'; + right[i] = prev[idx]; + prev[idx] = i; + } + + int ans = 0; + for (int i = 0; i < n; i++) { + ans += (i - left[i]) * (right[i] - i); + } + return ans; + } +} diff --git a/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.kt b/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.kt new file mode 100644 index 00000000..7240a849 --- /dev/null +++ b/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.kt @@ -0,0 +1,28 @@ +class Solution { + fun uniqueLetterString(s: String): Int { + val n = s.length + val left = IntArray(n) + val right = IntArray(n) + val prev = IntArray(26) { -1 } + + for (i in 0 until n) { + val idx = s[i] - 'A' + left[i] = prev[idx] + prev[idx] = i + } + + for (i in 0 until 26) prev[i] = n + + for (i in n - 1 downTo 0) { + val idx = s[i] - 'A' + right[i] = prev[idx] + prev[idx] = i + } + + var ans = 0 + for (i in 0 until n) { + ans += (i - left[i]) * (right[i] - i) + } + return ans + } +} diff --git a/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.py b/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.py new file mode 100644 index 00000000..1139b093 --- /dev/null +++ b/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.py @@ -0,0 +1,26 @@ +class Solution: + def uniqueLetterString(self, s: str) -> int: + n = len(s) + + left = [0] * n + right = [0] * n + prev = [-1] * 26 + + for i in range(n): + idx = ord(s[i]) - ord("A") + left[i] = prev[idx] + prev[idx] = i + + prev = [n] * 26 + + for i in range(n - 1, -1, -1): + idx = ord(s[i]) - ord("A") + right[i] = prev[idx] + prev[idx] = i + + ans = 0 + + for i in range(n): + ans += (i - left[i]) * (right[i] - i) + + return ans diff --git a/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.py2 b/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.py2 new file mode 100644 index 00000000..8865cb8e --- /dev/null +++ b/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.py2 @@ -0,0 +1,27 @@ +class Solution(object): + def uniqueLetterString(self, s): + """ + :type s: str + :rtype: int + """ + n = len(s) + left = [0] * n + right = [0] * n + prev = [-1] * 26 + + for i in range(n): + idx = ord(s[i]) - ord('A') + left[i] = prev[idx] + prev[idx] = i + + prev = [n] * 26 + + for i in range(n - 1, -1, -1): + idx = ord(s[i]) - ord('A') + right[i] = prev[idx] + prev[idx] = i + + ans = 0 + for i in range(n): + ans += (i - left[i]) * (right[i] - i) + return ans diff --git a/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.rb b/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.rb new file mode 100644 index 00000000..efde3c34 --- /dev/null +++ b/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.rb @@ -0,0 +1,28 @@ +# @param {String} s +# @return {Integer} +def unique_letter_string(s) + n = s.length + left = Array.new(n, 0) + right = Array.new(n, 0) + prev = Array.new(26, -1) + + (0...n).each do |i| + idx = s[i].ord - 'A'.ord + left[i] = prev[idx] + prev[idx] = i + end + + prev = Array.new(26, n) + + (n - 1).downto(0) do |i| + idx = s[i].ord - 'A'.ord + right[i] = prev[idx] + prev[idx] = i + end + + ans = 0 + (0...n).each do |i| + ans += (i - left[i]) * (right[i] - i) + end + ans +end diff --git a/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.rs b/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.rs new file mode 100644 index 00000000..47386d68 --- /dev/null +++ b/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.rs @@ -0,0 +1,29 @@ +impl Solution { + pub fn unique_letter_string(s: String) -> i32 { + let n = s.len(); + let bytes = s.as_bytes(); + let mut left = vec![0i32; n]; + let mut right = vec![0i32; n]; + let mut prev = vec![-1i32; 26]; + + for i in 0..n { + let idx = (bytes[i] - b'A') as usize; + left[i] = prev[idx]; + prev[idx] = i as i32; + } + + prev = vec![n as i32; 26]; + + for i in (0..n).rev() { + let idx = (bytes[i] - b'A') as usize; + right[i] = prev[idx]; + prev[idx] = i as i32; + } + + let mut ans = 0i32; + for i in 0..n { + ans += (i as i32 - left[i]) * (right[i] - i as i32); + } + ans + } +} diff --git a/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.swift b/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.swift new file mode 100644 index 00000000..63cf4294 --- /dev/null +++ b/tests/501-1000/828. count-unique-characters-of-all-substrings-of-a-given-string/sol.swift @@ -0,0 +1,29 @@ +class Solution { + func uniqueLetterString(_ s: String) -> Int { + let n = s.count + let chars = Array(s) + var left = [Int](repeating: 0, count: n) + var right = [Int](repeating: 0, count: n) + var prev = [Int](repeating: -1, count: 26) + + for i in 0..= 0; i--) { + const idx = s.charCodeAt(i) - "A".charCodeAt(0); + right[i] = prev[idx]; + prev[idx] = i; + } + + let ans = 0; + for (let i = 0; i < n; i++) { + ans += (i - left[i]) * (right[i] - i); + } + return ans; +} diff --git a/tests/501-1000/829. consecutive-numbers-sum/manifest.yaml b/tests/501-1000/829. consecutive-numbers-sum/manifest.yaml new file mode 100644 index 00000000..5481677e --- /dev/null +++ b/tests/501-1000/829. consecutive-numbers-sum/manifest.yaml @@ -0,0 +1,185 @@ +entry: + id: 829 + title: consecutive-numbers-sum + params: + n: + type: int + call: + cpp: Solution().consecutiveNumbersSum({n}) + rust: Solution::consecutive_numbers_sum({n}) + python3: Solution().consecutiveNumbersSum({n}) + python2: Solution().consecutiveNumbersSum({n}) + ruby: consecutive_numbers_sum({n}) + java: new Solution().consecutiveNumbersSum({n}) + csharp: new Solution().ConsecutiveNumbersSum({n}) + kotlin: Solution().consecutiveNumbersSum({n}) + go: consecutiveNumbersSum({n}) + dart: Solution().consecutiveNumbersSum({n}) + swift: Solution().consecutiveNumbersSum({n}) + typescript: consecutiveNumbersSum({n}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: | + class Checker: + def check(self, result): + return True +seed: 829 +tests: + - name: n1 + in: + n: 1 + out: 1 + - name: n2 + in: + n: 2 + out: 1 + - name: n3 + in: + n: 3 + out: 2 + - name: n4 + in: + n: 4 + out: 1 + - name: n5 + in: + n: 5 + out: 2 + - name: n6 + in: + n: 6 + out: 2 + - name: n7 + in: + n: 7 + out: 2 + - name: n8 + in: + n: 8 + out: 1 + - name: n9 + in: + n: 9 + out: 3 + - name: n10 + in: + n: 10 + out: 2 + - name: n11 + in: + n: 11 + out: 2 + - name: n12 + in: + n: 12 + out: 2 + - name: n13 + in: + n: 13 + out: 2 + - name: n14 + in: + n: 14 + out: 2 + - name: n15 + in: + n: 15 + out: 4 + - name: n16 + in: + n: 16 + out: 1 + - name: n18 + in: + n: 18 + out: 3 + - name: n21 + in: + n: 21 + out: 4 + - name: n24 + in: + n: 24 + out: 2 + - name: n25 + in: + n: 25 + out: 3 + - name: n27 + in: + n: 27 + out: 4 + - name: n30 + in: + n: 30 + out: 4 + - name: n31 + in: + n: 31 + out: 2 + - name: n36 + in: + n: 36 + out: 3 + - name: n45 + in: + n: 45 + out: 6 + - name: n63 + in: + n: 63 + out: 6 + - name: n64 + in: + n: 64 + out: 1 + - name: n81 + in: + n: 81 + out: 5 + - name: n100 + in: + n: 100 + out: 3 + - name: n999 + in: + n: 999 + out: 8 + - name: n1024 + in: + n: 1024 + out: 1 + - name: n9999 + in: + n: 9999 + out: 12 + - name: n65535 + in: + n: 65535 + out: 16 + - name: n999999 + in: + n: 999999 + out: 64 + - name: n1000000000 + in: + n: 1000000000 + out: 10 + - name: n536870912 + in: + n: 536870912 + out: 1 + - name: n720720 + in: + n: 720720 + out: 48 + - name: n999999937 + in: + n: 999999937 + out: 2 diff --git a/tests/501-1000/829. consecutive-numbers-sum/sol.cpp b/tests/501-1000/829. consecutive-numbers-sum/sol.cpp new file mode 100644 index 00000000..23c0991f --- /dev/null +++ b/tests/501-1000/829. consecutive-numbers-sum/sol.cpp @@ -0,0 +1,16 @@ +class Solution { +public: + int consecutiveNumbersSum(int n) { + long long ln = n; + int maxSequenceLength = (int)((sqrt(1 + 8 * ln) - 1) / 2); + int c = 0; + for (int i = 2; i <= maxSequenceLength; i++) { + if (i % 2 == 1 && n % i == 0) { + c++; + } else if (i % 2 == 0 && n % i == i / 2) { + c++; + } + } + return c + 1; + } +}; diff --git a/tests/501-1000/829. consecutive-numbers-sum/sol.cs b/tests/501-1000/829. consecutive-numbers-sum/sol.cs new file mode 100644 index 00000000..ad1761f0 --- /dev/null +++ b/tests/501-1000/829. consecutive-numbers-sum/sol.cs @@ -0,0 +1,14 @@ +public class Solution { + public int ConsecutiveNumbersSum(int n) { + int maxSequenceLength = (int)((Math.Sqrt(1 + 8L * n) - 1) / 2); + int c = 0; + for (int i = 2; i <= maxSequenceLength; i++) { + if (i % 2 == 1 && n % i == 0) { + c++; + } else if (i % 2 == 0 && n % i == i / 2) { + c++; + } + } + return c + 1; + } +} diff --git a/tests/501-1000/829. consecutive-numbers-sum/sol.dart b/tests/501-1000/829. consecutive-numbers-sum/sol.dart new file mode 100644 index 00000000..3be3a2f9 --- /dev/null +++ b/tests/501-1000/829. consecutive-numbers-sum/sol.dart @@ -0,0 +1,14 @@ +class Solution { + int consecutiveNumbersSum(int n) { + int maxSequenceLength = (((sqrt(1 + 8 * n) - 1) / 2)).floor(); + int c = 0; + for (int i = 2; i <= maxSequenceLength; i++) { + if (i % 2 == 1 && n % i == 0) { + c++; + } else if (i % 2 == 0 && n % i == i ~/ 2) { + c++; + } + } + return c + 1; + } +} diff --git a/tests/501-1000/829. consecutive-numbers-sum/sol.go b/tests/501-1000/829. consecutive-numbers-sum/sol.go new file mode 100644 index 00000000..ac02c9ba --- /dev/null +++ b/tests/501-1000/829. consecutive-numbers-sum/sol.go @@ -0,0 +1,12 @@ +func consecutiveNumbersSum(n int) int { + maxSequenceLength := int((math.Sqrt(float64(1+8*n)) - 1) / 2) + c := 0 + for i := 2; i <= maxSequenceLength; i++ { + if i%2 == 1 && n%i == 0 { + c++ + } else if i%2 == 0 && n%i == i/2 { + c++ + } + } + return c + 1 +} diff --git a/tests/501-1000/829. consecutive-numbers-sum/sol.java b/tests/501-1000/829. consecutive-numbers-sum/sol.java new file mode 100644 index 00000000..715f6f72 --- /dev/null +++ b/tests/501-1000/829. consecutive-numbers-sum/sol.java @@ -0,0 +1,14 @@ +class Solution { + public int consecutiveNumbersSum(int n) { + int maxSequenceLength = (int)((Math.sqrt(1 + 8L * n) - 1) / 2); + int c = 0; + for (int i = 2; i <= maxSequenceLength; i++) { + if (i % 2 == 1 && n % i == 0) { + c++; + } else if (i % 2 == 0 && n % i == i / 2) { + c++; + } + } + return c + 1; + } +} diff --git a/tests/501-1000/829. consecutive-numbers-sum/sol.kt b/tests/501-1000/829. consecutive-numbers-sum/sol.kt new file mode 100644 index 00000000..94f2652e --- /dev/null +++ b/tests/501-1000/829. consecutive-numbers-sum/sol.kt @@ -0,0 +1,14 @@ +class Solution { + fun consecutiveNumbersSum(n: Int): Int { + val maxSequenceLength = ((Math.sqrt(1.0 + 8.0 * n) - 1) / 2).toInt() + var c = 0 + for (i in 2..maxSequenceLength) { + if (i % 2 == 1 && n % i == 0) { + c++ + } else if (i % 2 == 0 && n % i == i / 2) { + c++ + } + } + return c + 1 + } +} diff --git a/tests/501-1000/829. consecutive-numbers-sum/sol.py b/tests/501-1000/829. consecutive-numbers-sum/sol.py new file mode 100644 index 00000000..4339e10e --- /dev/null +++ b/tests/501-1000/829. consecutive-numbers-sum/sol.py @@ -0,0 +1,12 @@ +class Solution: + def consecutiveNumbersSum(self, n: int) -> int: + + maxSequenceLength = math.floor((math.sqrt(1 + 8 * n) - 1) / 2) + c = 0 + for i in range(2, maxSequenceLength + 1): + if i % 2 == 1 and n % i == 0: + c += 1 + elif i % 2 == 0 and n % i == i // 2: + c += 1 + + return c + 1 diff --git a/tests/501-1000/829. consecutive-numbers-sum/sol.py2 b/tests/501-1000/829. consecutive-numbers-sum/sol.py2 new file mode 100644 index 00000000..cc11a695 --- /dev/null +++ b/tests/501-1000/829. consecutive-numbers-sum/sol.py2 @@ -0,0 +1,15 @@ +class Solution(object): + def consecutiveNumbersSum(self, n): + """ + :type n: int + :rtype: int + """ + import math + maxSequenceLength = int((math.sqrt(1 + 8 * n) - 1) // 2) + c = 0 + for i in range(2, maxSequenceLength + 1): + if i % 2 == 1 and n % i == 0: + c += 1 + elif i % 2 == 0 and n % i == i // 2: + c += 1 + return c + 1 diff --git a/tests/501-1000/829. consecutive-numbers-sum/sol.rb b/tests/501-1000/829. consecutive-numbers-sum/sol.rb new file mode 100644 index 00000000..b13efcf8 --- /dev/null +++ b/tests/501-1000/829. consecutive-numbers-sum/sol.rb @@ -0,0 +1,14 @@ +# @param {Integer} n +# @return {Integer} +def consecutive_numbers_sum(n) + max_sequence_length = ((Math.sqrt(1 + 8 * n) - 1) / 2).to_i + c = 0 + (2..max_sequence_length).each do |i| + if i % 2 == 1 && n % i == 0 + c += 1 + elsif i % 2 == 0 && n % i == i / 2 + c += 1 + end + end + c + 1 +end diff --git a/tests/501-1000/829. consecutive-numbers-sum/sol.rs b/tests/501-1000/829. consecutive-numbers-sum/sol.rs new file mode 100644 index 00000000..a8b18e53 --- /dev/null +++ b/tests/501-1000/829. consecutive-numbers-sum/sol.rs @@ -0,0 +1,15 @@ +impl Solution { + pub fn consecutive_numbers_sum(n: i32) -> i32 { + let n = n as i64; + let max_sequence_length = (((1.0 + 8.0 * n as f64).sqrt() - 1.0) / 2.0) as i32; + let mut c = 0; + for i in 2..=max_sequence_length { + if i % 2 == 1 && n % i as i64 == 0 { + c += 1; + } else if i % 2 == 0 && n % i as i64 == (i / 2) as i64 { + c += 1; + } + } + c + 1 + } +} diff --git a/tests/501-1000/829. consecutive-numbers-sum/sol.swift b/tests/501-1000/829. consecutive-numbers-sum/sol.swift new file mode 100644 index 00000000..0dde3f41 --- /dev/null +++ b/tests/501-1000/829. consecutive-numbers-sum/sol.swift @@ -0,0 +1,17 @@ +class Solution { + func consecutiveNumbersSum(_ n: Int) -> Int { + let maxSequenceLength = Int((sqrt(Double(1 + 8 * n)) - 1) / 2) + if maxSequenceLength < 2 { + return 1 + } + var c = 0 + for i in 2...maxSequenceLength { + if i % 2 == 1 && n % i == 0 { + c += 1 + } else if i % 2 == 0 && n % i == i / 2 { + c += 1 + } + } + return c + 1 + } +} diff --git a/tests/501-1000/829. consecutive-numbers-sum/sol.ts b/tests/501-1000/829. consecutive-numbers-sum/sol.ts new file mode 100644 index 00000000..31059de0 --- /dev/null +++ b/tests/501-1000/829. consecutive-numbers-sum/sol.ts @@ -0,0 +1,12 @@ +function consecutiveNumbersSum(n: number): number { + const maxSequenceLength = Math.floor((Math.sqrt(1 + 8 * n) - 1) / 2); + let c = 0; + for (let i = 2; i <= maxSequenceLength; i++) { + if (i % 2 === 1 && n % i === 0) { + c++; + } else if (i % 2 === 0 && n % i === i / 2) { + c++; + } + } + return c + 1; +} diff --git a/tests/501-1000/830. positions-of-large-groups/manifest.yaml b/tests/501-1000/830. positions-of-large-groups/manifest.yaml new file mode 100644 index 00000000..7ba22539 --- /dev/null +++ b/tests/501-1000/830. positions-of-large-groups/manifest.yaml @@ -0,0 +1,313 @@ +entry: + id: 830 + title: positions-of-large-groups + params: + s: + type: string + call: + cpp: Solution().largeGroupPositions({s}) + rust: Solution::large_group_positions({s}) + python3: Solution().largeGroupPositions({s}) + python2: Solution().largeGroupPositions({s}) + ruby: large_group_positions({s}) + java: new Solution().largeGroupPositions({s}) + csharp: new Solution().LargeGroupPositions({s}) + kotlin: Solution().largeGroupPositions({s}) + go: largeGroupPositions({s}) + dart: Solution().largeGroupPositions({s}) + swift: Solution().largeGroupPositions({s}) + typescript: largeGroupPositions({s}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: | + class Checker: + def check(self, result): + return isinstance(result, list) +seed: 830 +tests: + - name: ex1 + in: + s: abbxxxxzzy + out: + - - 3 + - 6 + - name: ex2 + in: + s: abc + out: [] + - name: ex3 + in: + s: abcdddeeeeaabbbcd + out: + - - 3 + - 5 + - - 6 + - 9 + - - 12 + - 14 + - name: single + in: + s: a + out: [] + - name: pair + in: + s: aa + out: [] + - name: triple + in: + s: aaa + out: + - - 0 + - 2 + - name: four + in: + s: aaaa + out: + - - 0 + - 3 + - name: mixed1 + in: + s: aabbbcc + out: + - - 2 + - 4 + - name: mixed2 + in: + s: abbbccd + out: + - - 1 + - 3 + - name: mixed3 + in: + s: aaabaaa + out: + - - 0 + - 2 + - - 4 + - 6 + - name: mixed4 + in: + s: qqqwweeeeerrr + out: + - - 0 + - 2 + - - 5 + - 9 + - - 10 + - 12 + - name: mixed5 + in: + s: zzzzz + out: + - - 0 + - 4 + - name: mixed6 + in: + s: abcdeffffg + out: + - - 5 + - 8 + - name: mixed7 + in: + s: aabbcccdddde + out: + - - 4 + - 6 + - - 7 + - 10 + - name: mixed8 + in: + s: xxyyyzzzz + out: + - - 2 + - 4 + - - 5 + - 8 + - name: mixed9 + in: + s: pppqqrrrssst + out: + - - 0 + - 2 + - - 5 + - 7 + - - 8 + - 10 + - name: mixed10 + in: + s: aaabcccdeeee + out: + - - 0 + - 2 + - - 4 + - 6 + - - 8 + - 11 + - name: mixed11 + in: + s: aaaaab + out: + - - 0 + - 4 + - name: mixed12 + in: + s: baaaa + out: + - - 1 + - 4 + - name: mixed13 + in: + s: aabaaaa + out: + - - 3 + - 6 + - name: mixed14 + in: + s: aaabbaaa + out: + - - 0 + - 2 + - - 5 + - 7 + - name: mixed15 + in: + s: abcdd + out: [] + - name: mixed16 + in: + s: abccc + out: + - - 2 + - 4 + - name: mixed17 + in: + s: zzzyyyxxx + out: + - - 0 + - 2 + - - 3 + - 5 + - - 6 + - 8 + - name: mixed18 + in: + s: aabccccdde + out: + - - 3 + - 6 + - name: mixed19 + in: + s: aaaabbbbcccc + out: + - - 0 + - 3 + - - 4 + - 7 + - - 8 + - 11 + - name: mixed20 + in: + s: abcdefghijklmnopqrstuvwxyz + out: [] + - name: mixed21 + in: + s: aaabbbcccddd + out: + - - 0 + - 2 + - - 3 + - 5 + - - 6 + - 8 + - - 9 + - 11 + - name: mixed22 + in: + s: bbbbbaaaaccc + out: + - - 0 + - 4 + - - 5 + - 8 + - - 9 + - 11 + - name: mixed23 + in: + s: cccdddde + out: + - - 0 + - 2 + - - 3 + - 6 + - name: mixed24 + in: + s: mmmmmnnn + out: + - - 0 + - 4 + - - 5 + - 7 + - name: mixed25 + in: + s: ttuuuvvvww + out: + - - 2 + - 4 + - - 5 + - 7 + - name: edge_leading_group + in: + s: aaabc + out: + - - 0 + - 2 + - name: edge_trailing_group + in: + s: cabbb + out: + - - 2 + - 4 + - name: edge_two_groups + in: + s: aaabccc + out: + - - 0 + - 2 + - - 4 + - 6 + - name: edge_separated + in: + s: aabcccddde + out: + - - 3 + - 5 + - - 6 + - 8 + - name: edge_long_middle + in: + s: xyzttttuvw + out: + - - 3 + - 6 + - name: edge_alternating + in: + s: abababab + out: [] + - name: edge_long_run + in: + s: hhhhhhhhh + out: + - - 0 + - 8 + - name: edge_small_big_small + in: + s: aabbbbbcc + out: + - - 2 + - 6 diff --git a/tests/501-1000/830. positions-of-large-groups/sol.cpp b/tests/501-1000/830. positions-of-large-groups/sol.cpp new file mode 100644 index 00000000..8f5c310d --- /dev/null +++ b/tests/501-1000/830. positions-of-large-groups/sol.cpp @@ -0,0 +1,18 @@ +class Solution { +public: + vector> largeGroupPositions(string s) { + vector> intervals; + int left = 0; + while (left < s.size()) { + int start = left; + while (left + 1 < s.size() && s[left + 1] == s[left]) { + left++; + } + if (left - start >= 2) { + intervals.push_back({start, left}); + } + left++; + } + return intervals; + } +}; diff --git a/tests/501-1000/830. positions-of-large-groups/sol.cs b/tests/501-1000/830. positions-of-large-groups/sol.cs new file mode 100644 index 00000000..7a7c56d6 --- /dev/null +++ b/tests/501-1000/830. positions-of-large-groups/sol.cs @@ -0,0 +1,17 @@ +public class Solution { + public IList> LargeGroupPositions(string s) { + IList> intervals = new List>(); + int left = 0; + while (left < s.Length) { + int start = left; + while (left + 1 < s.Length && s[left + 1] == s[left]) { + left++; + } + if (left - start >= 2) { + intervals.Add(new List { start, left }); + } + left++; + } + return intervals; + } +} diff --git a/tests/501-1000/830. positions-of-large-groups/sol.dart b/tests/501-1000/830. positions-of-large-groups/sol.dart new file mode 100644 index 00000000..e2e21c5f --- /dev/null +++ b/tests/501-1000/830. positions-of-large-groups/sol.dart @@ -0,0 +1,17 @@ +class Solution { + List> largeGroupPositions(String s) { + List> intervals = []; + int left = 0; + while (left < s.length) { + int start = left; + while (left + 1 < s.length && s[left + 1] == s[left]) { + left++; + } + if (left - start >= 2) { + intervals.add([start, left]); + } + left++; + } + return intervals; + } +} diff --git a/tests/501-1000/830. positions-of-large-groups/sol.go b/tests/501-1000/830. positions-of-large-groups/sol.go new file mode 100644 index 00000000..70147b04 --- /dev/null +++ b/tests/501-1000/830. positions-of-large-groups/sol.go @@ -0,0 +1,15 @@ +func largeGroupPositions(s string) [][]int { + intervals := make([][]int, 0) + left := 0 + for left < len(s) { + start := left + for left + 1 < len(s) && s[left + 1] == s[left] { + left++ + } + if left - start >= 2 { + intervals = append(intervals, []int{start, left}) + } + left++ + } + return intervals +} diff --git a/tests/501-1000/830. positions-of-large-groups/sol.java b/tests/501-1000/830. positions-of-large-groups/sol.java new file mode 100644 index 00000000..b00832a9 --- /dev/null +++ b/tests/501-1000/830. positions-of-large-groups/sol.java @@ -0,0 +1,17 @@ +class Solution { + public List> largeGroupPositions(String s) { + List> intervals = new ArrayList<>(); + int left = 0; + while (left < s.length()) { + int start = left; + while (left + 1 < s.length() && s.charAt(left + 1) == s.charAt(left)) { + left++; + } + if (left - start >= 2) { + intervals.add(List.of(start, left)); + } + left++; + } + return intervals; + } +} diff --git a/tests/501-1000/830. positions-of-large-groups/sol.kt b/tests/501-1000/830. positions-of-large-groups/sol.kt new file mode 100644 index 00000000..2dff79f0 --- /dev/null +++ b/tests/501-1000/830. positions-of-large-groups/sol.kt @@ -0,0 +1,17 @@ +class Solution { + fun largeGroupPositions(s: String): List> { + val intervals = mutableListOf>() + var left = 0 + while (left < s.length) { + val start = left + while (left + 1 < s.length && s[left + 1] == s[left]) { + left++ + } + if (left - start >= 2) { + intervals.add(listOf(start, left)) + } + left++ + } + return intervals + } +} diff --git a/tests/501-1000/830. positions-of-large-groups/sol.py b/tests/501-1000/830. positions-of-large-groups/sol.py new file mode 100644 index 00000000..614edf90 --- /dev/null +++ b/tests/501-1000/830. positions-of-large-groups/sol.py @@ -0,0 +1,14 @@ +class Solution: + def largeGroupPositions(self, s: str) -> List[List[int]]: + + left = 0 + intervals = [] + while left < len(s): + start = left + while left + 1 < len(s) and s[left + 1] == s[left]: + left += 1 + if left - start >= 2: + intervals.append([start, left]) + left += 1 + + return intervals diff --git a/tests/501-1000/830. positions-of-large-groups/sol.py2 b/tests/501-1000/830. positions-of-large-groups/sol.py2 new file mode 100644 index 00000000..adbe51a3 --- /dev/null +++ b/tests/501-1000/830. positions-of-large-groups/sol.py2 @@ -0,0 +1,16 @@ +class Solution(object): + def largeGroupPositions(self, s): + """ + :type s: str + :rtype: List[List[int]] + """ + left = 0 + intervals = [] + while left < len(s): + start = left + while left + 1 < len(s) and s[left + 1] == s[left]: + left += 1 + if left - start >= 2: + intervals.append([start, left]) + left += 1 + return intervals diff --git a/tests/501-1000/830. positions-of-large-groups/sol.rb b/tests/501-1000/830. positions-of-large-groups/sol.rb new file mode 100644 index 00000000..ffa99650 --- /dev/null +++ b/tests/501-1000/830. positions-of-large-groups/sol.rb @@ -0,0 +1,17 @@ +# @param {String} s +# @return {Integer[][]} +def large_group_positions(s) + left = 0 + intervals = [] + while left < s.length + start = left + while left + 1 < s.length && s[left + 1] == s[left] + left += 1 + end + if left - start >= 2 + intervals << [start, left] + end + left += 1 + end + intervals +end diff --git a/tests/501-1000/830. positions-of-large-groups/sol.rs b/tests/501-1000/830. positions-of-large-groups/sol.rs new file mode 100644 index 00000000..5b7f3542 --- /dev/null +++ b/tests/501-1000/830. positions-of-large-groups/sol.rs @@ -0,0 +1,18 @@ +impl Solution { + pub fn large_group_positions(s: String) -> Vec> { + let mut intervals: Vec> = Vec::new(); + let chars: Vec = s.chars().collect(); + let mut left = 0; + while left < chars.len() { + let start = left; + while left + 1 < chars.len() && chars[left + 1] == chars[left] { + left += 1; + } + if left - start >= 2 { + intervals.push(vec![start as i32, left as i32]); + } + left += 1; + } + intervals + } +} diff --git a/tests/501-1000/830. positions-of-large-groups/sol.swift b/tests/501-1000/830. positions-of-large-groups/sol.swift new file mode 100644 index 00000000..13426154 --- /dev/null +++ b/tests/501-1000/830. positions-of-large-groups/sol.swift @@ -0,0 +1,18 @@ +class Solution { + func largeGroupPositions(_ s: String) -> [[Int]] { + var intervals: [[Int]] = [] + let chars = Array(s) + var left = 0 + while left < chars.count { + let start = left + while left + 1 < chars.count && chars[left + 1] == chars[left] { + left += 1 + } + if left - start >= 2 { + intervals.append([start, left]) + } + left += 1 + } + return intervals + } +} diff --git a/tests/501-1000/830. positions-of-large-groups/sol.ts b/tests/501-1000/830. positions-of-large-groups/sol.ts new file mode 100644 index 00000000..fb970f86 --- /dev/null +++ b/tests/501-1000/830. positions-of-large-groups/sol.ts @@ -0,0 +1,15 @@ +function largeGroupPositions(s: string): number[][] { + const intervals: number[][] = []; + let left = 0; + while (left < s.length) { + const start = left; + while (left + 1 < s.length && s[left + 1] === s[left]) { + left++; + } + if (left - start >= 2) { + intervals.push([start, left]); + } + left++; + } + return intervals; +} diff --git a/tests/501-1000/831. masking-personal-information/manifest.yaml b/tests/501-1000/831. masking-personal-information/manifest.yaml new file mode 100644 index 00000000..9aa95717 --- /dev/null +++ b/tests/501-1000/831. masking-personal-information/manifest.yaml @@ -0,0 +1,173 @@ +entry: + id: 831 + title: masking-personal-information + params: + s: + type: string + call: + cpp: Solution().maskPII({s}) + rust: Solution::mask_pii({s}) + python3: Solution().maskPII({s}) + python2: Solution().maskPII({s}) + ruby: mask_pii({s}) + java: new Solution().maskPII({s}) + csharp: new Solution().MaskPII({s}) + kotlin: Solution().maskPII({s}) + go: maskPII({s}) + dart: Solution().maskPII({s}) + swift: Solution().maskPII({s}) + typescript: maskPII({s}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: | + class Checker: + def check(self, result): + return True +seed: 831 +tests: + - name: ex1 + in: + s: LeetCode@LeetCode.com + out: l*****e@leetcode.com + - name: ex2 + in: + s: AB@qq.com + out: a*****b@qq.com + - name: ex3 + in: + s: 1(234)567-890 + out: "***-***-7890" + - name: email-short + in: + s: Aa@Bb.cc + out: a*****a@bb.cc + - name: email-mixed + in: + s: John.Smith@Example.COM + out: j*****h@example.com + - name: email-lower + in: + s: aB@cD.Ef + out: a*****b@cd.ef + - name: email-upper + in: + s: ZYXWVUT@QWERTY.AS + out: z*****t@qwerty.as + - name: phone-10-digits + in: + s: 1234567890 + out: "***-***-7890" + - name: phone-11-digits + in: + s: 1-234-567-8901 + out: +*-***-***-8901 + - name: phone-12-digits + in: + s: 12-3456-789012 + out: +**-***-***-9012 + - name: phone-13-digits + in: + s: +1 (234) 567-8901 + out: +*-***-***-8901 + - name: phone-spaces + in: + s: 86 123 456 7890 + out: +**-***-***-7890 + - name: phone-mixed + in: + s: +86-(123)-456-7890 + out: +**-***-***-7890 + - name: phone-parentheses + in: + s: (123) 456 7890 + out: "***-***-7890" + - name: phone-plus + in: + s: +123 456 789 0123 + out: +***-***-***-0123 + - name: phone-dashes + in: + s: 123-456-789-012 + out: +**-***-***-9012 + - name: phone-long-1 + in: + s: +1(234)567890123 + out: +***-***-***-0123 + - name: phone-long-2 + in: + s: +12(345)67890123 + out: +***-***-***-0123 + - name: phone-long-3 + in: + s: +123(456)7890123 + out: +***-***-***-0123 + - name: phone-zero-country-1 + in: + s: 2345678901 + out: "***-***-8901" + - name: phone-zero-country-2 + in: + s: 9876543210 + out: "***-***-3210" + - name: email-long-name + in: + s: Abcdefghijklmnopqrstuvwxyz@leetcode.com + out: a*****z@leetcode.com + - name: email-long-domain + in: + s: Name@SubDomain.Example.COM + out: n*****e@subdomain.example.com + - name: email-two-chars + in: + s: XY@Zz.Yy + out: x*****y@zz.yy + - name: email-caps + in: + s: HELLO@WORLD.COM + out: h*****o@world.com + - name: phone-10-with-symbols + in: + s: 9-(876)-543-210 + out: "***-***-3210" + - name: phone-11-with-spaces + in: + s: 1 234 567 8901 + out: +*-***-***-8901 + - name: phone-12-with-parentheses + in: + s: 12 (345) 678 9012 + out: +**-***-***-9012 + - name: phone-13-with-dashes + in: + s: 123-456-789-0123 + out: +***-***-***-0123 + - name: email-min-name + in: + s: Ab@Cd.Ef + out: a*****b@cd.ef + - name: email-mixed-domain + in: + s: First.Last@MiXeD.DoMaIn + out: f*****t@mixed.domain + - name: phone-repeated + in: + s: +1-111-111-1111 + out: +*-***-***-1111 + - name: phone-repeated-2 + in: + s: +86-000-000-0000 + out: +**-***-***-0000 + - name: email-simple-2 + in: + s: aBcd@efGh.Ij + out: a*****d@efgh.ij + - name: email-simple-3 + in: + s: QwErTy@AsDf.Gh + out: q*****y@asdf.gh diff --git a/tests/501-1000/831. masking-personal-information/sol.cpp b/tests/501-1000/831. masking-personal-information/sol.cpp new file mode 100644 index 00000000..18dac288 --- /dev/null +++ b/tests/501-1000/831. masking-personal-information/sol.cpp @@ -0,0 +1,26 @@ +class Solution { +public: + string maskPII(string s) { + if (s.find('@') != string::npos) { + int at_pos = s.find('@'); + string name = s.substr(0, at_pos); + string domain = s.substr(at_pos + 1); + for (char& c : name) c = tolower(c); + for (char& c : domain) c = tolower(c); + name = name[0] + string("*****") + name.back(); + return name + "@" + domain; + } else { + string gg; + for (char x : s) { + if (isdigit(x)) { + gg += x; + } + } + int l = gg.size(); + if (l > 10) { + return "+" + string(l - 10, '*') + "-***-***-" + gg.substr(l - 4); + } + return "***-***-" + gg.substr(l - 4); + } + } +}; diff --git a/tests/501-1000/831. masking-personal-information/sol.cs b/tests/501-1000/831. masking-personal-information/sol.cs new file mode 100644 index 00000000..6525b768 --- /dev/null +++ b/tests/501-1000/831. masking-personal-information/sol.cs @@ -0,0 +1,23 @@ +public class Solution { + public string MaskPII(string s) { + if (s.Contains('@')) { + string[] parts = s.Split('@'); + string name = parts[0].ToLower(); + string domain = parts[1].ToLower(); + name = name[0] + "*****" + name[name.Length - 1]; + return name + "@" + domain; + } else { + string gg = ""; + foreach (char x in s) { + if (char.IsDigit(x)) { + gg += x; + } + } + int l = gg.Length; + if (l > 10) { + return "+" + new string('*', l - 10) + "-***-***-" + gg.Substring(l - 4); + } + return "***-***-" + gg.Substring(l - 4); + } + } +} diff --git a/tests/501-1000/831. masking-personal-information/sol.dart b/tests/501-1000/831. masking-personal-information/sol.dart new file mode 100644 index 00000000..f324de95 --- /dev/null +++ b/tests/501-1000/831. masking-personal-information/sol.dart @@ -0,0 +1,23 @@ +class Solution { + String maskPII(String s) { + if (s.contains("@")) { + var parts = s.split("@"); + var name = parts[0].toLowerCase(); + var domain = parts[1].toLowerCase(); + name = name[0] + "*****" + name[name.length - 1]; + return name + "@" + domain; + } else { + var gg = ""; + for (var x in s.split('')) { + if (int.tryParse(x) != null) { + gg += x; + } + } + var l = gg.length; + if (l > 10) { + return "+" + "*" * (l - 10) + "-***-***-" + gg.substring(l - 4); + } + return "***-***-" + gg.substring(l - 4); + } + } +} diff --git a/tests/501-1000/831. masking-personal-information/sol.go b/tests/501-1000/831. masking-personal-information/sol.go new file mode 100644 index 00000000..a994ee1c --- /dev/null +++ b/tests/501-1000/831. masking-personal-information/sol.go @@ -0,0 +1,21 @@ +func maskPII(s string) string { + if strings.Contains(s, "@") { + parts := strings.Split(s, "@") + name := strings.ToLower(parts[0]) + domain := strings.ToLower(parts[1]) + name = string(name[0]) + "*****" + string(name[len(name)-1]) + return name + "@" + domain + } else { + gg := "" + for _, x := range s { + if x >= '0' && x <= '9' { + gg += string(x) + } + } + l := len(gg) + if l > 10 { + return "+" + strings.Repeat("*", l-10) + "-***-***-" + gg[l-4:] + } + return "***-***-" + gg[l-4:] + } +} diff --git a/tests/501-1000/831. masking-personal-information/sol.java b/tests/501-1000/831. masking-personal-information/sol.java new file mode 100644 index 00000000..bf49d5b9 --- /dev/null +++ b/tests/501-1000/831. masking-personal-information/sol.java @@ -0,0 +1,24 @@ +class Solution { + public String maskPII(String s) { + if (s.contains("@")) { + String[] parts = s.split("@"); + String name = parts[0].toLowerCase(); + String domain = parts[1].toLowerCase(); + name = name.charAt(0) + "*****" + name.charAt(name.length() - 1); + return name + "@" + domain; + } else { + StringBuilder gg = new StringBuilder(); + for (char x : s.toCharArray()) { + if (Character.isDigit(x)) { + gg.append(x); + } + } + String digits = gg.toString(); + int l = digits.length(); + if (l > 10) { + return "+" + "*".repeat(l - 10) + "-***-***-" + digits.substring(l - 4); + } + return "***-***-" + digits.substring(l - 4); + } + } +} diff --git a/tests/501-1000/831. masking-personal-information/sol.kt b/tests/501-1000/831. masking-personal-information/sol.kt new file mode 100644 index 00000000..67013852 --- /dev/null +++ b/tests/501-1000/831. masking-personal-information/sol.kt @@ -0,0 +1,23 @@ +class Solution { + fun maskPII(s: String): String { + if ("@" in s) { + val parts = s.split("@") + var name = parts[0].lowercase() + val domain = parts[1].lowercase() + name = name[0] + "*****" + name[name.length - 1] + return name + "@" + domain + } else { + var gg = "" + for (x in s) { + if (x.isDigit()) { + gg += x + } + } + val l = gg.length + if (l > 10) { + return "+" + "*".repeat(l - 10) + "-***-***-" + gg.substring(l - 4) + } + return "***-***-" + gg.substring(l - 4) + } + } +} diff --git a/tests/501-1000/831. masking-personal-information/sol.py b/tests/501-1000/831. masking-personal-information/sol.py new file mode 100644 index 00000000..8f85f866 --- /dev/null +++ b/tests/501-1000/831. masking-personal-information/sol.py @@ -0,0 +1,17 @@ +class Solution: + def maskPII(self, s: str) -> str: + if "@" in s: + name, domain = s.split("@") + name = name.lower() + domain = domain.lower() + name = name[0] + "*****" + name[-1] + return name + "@" + domain + else: + gg = "" + for x in s: + if x.isdigit(): + gg += x + l = len(gg) + if l > 10: + return "+" + "*" * (l - 10) + "-***-***-" + gg[-4:] + return "***-***-" + gg[-4:] diff --git a/tests/501-1000/831. masking-personal-information/sol.py2 b/tests/501-1000/831. masking-personal-information/sol.py2 new file mode 100644 index 00000000..b0d0051f --- /dev/null +++ b/tests/501-1000/831. masking-personal-information/sol.py2 @@ -0,0 +1,21 @@ +class Solution(object): + def maskPII(self, s): + """ + :type s: str + :rtype: str + """ + if "@" in s: + name, domain = s.split("@") + name = name.lower() + domain = domain.lower() + name = name[0] + "*****" + name[-1] + return name + "@" + domain + else: + gg = "" + for x in s: + if x.isdigit(): + gg += x + l = len(gg) + if l > 10: + return "+" + "*" * (l - 10) + "-***-***-" + gg[-4:] + return "***-***-" + gg[-4:] diff --git a/tests/501-1000/831. masking-personal-information/sol.rb b/tests/501-1000/831. masking-personal-information/sol.rb new file mode 100644 index 00000000..d1e294ee --- /dev/null +++ b/tests/501-1000/831. masking-personal-information/sol.rb @@ -0,0 +1,23 @@ +# @param {String} s +# @return {String} +def mask_pii(s) + if s.include?("@") + name, domain = s.split("@") + name = name.downcase + domain = domain.downcase + name = name[0] + "*****" + name[-1] + return name + "@" + domain + else + gg = "" + s.each_char do |x| + if x.match?(/[0-9]/) + gg += x + end + end + l = gg.length + if l > 10 + return "+" + "*" * (l - 10) + "-***-***-" + gg[-4..-1] + end + return "***-***-" + gg[-4..-1] + end +end diff --git a/tests/501-1000/831. masking-personal-information/sol.rs b/tests/501-1000/831. masking-personal-information/sol.rs new file mode 100644 index 00000000..ae96a523 --- /dev/null +++ b/tests/501-1000/831. masking-personal-information/sol.rs @@ -0,0 +1,23 @@ +impl Solution { + pub fn mask_pii(s: String) -> String { + if s.contains('@') { + let parts: Vec<&str> = s.split('@').collect(); + let name = parts[0].to_lowercase(); + let domain = parts[1].to_lowercase(); + let masked_name = format!("{}*****{}", &name[0..1], &name[name.len()-1..]); + return format!("{}@{}", masked_name, domain); + } else { + let mut gg = String::new(); + for x in s.chars() { + if x.is_digit(10) { + gg.push(x); + } + } + let l = gg.len(); + if l > 10 { + return format!("+{}-***-***-{}", "*".repeat(l - 10), &gg[l-4..]); + } + return format!("***-***-{}", &gg[l-4..]); + } + } +} diff --git a/tests/501-1000/831. masking-personal-information/sol.swift b/tests/501-1000/831. masking-personal-information/sol.swift new file mode 100644 index 00000000..6adf3590 --- /dev/null +++ b/tests/501-1000/831. masking-personal-information/sol.swift @@ -0,0 +1,23 @@ +class Solution { + func maskPII(_ s: String) -> String { + if s.contains("@") { + let parts = s.split(separator: "@") + var name = parts[0].lowercased() + let domain = parts[1].lowercased() + name = String(name.first!) + "*****" + String(name.last!) + return name + "@" + domain + } else { + var gg = "" + for x in s { + if x.isNumber { + gg.append(x) + } + } + let l = gg.count + if l > 10 { + return "+" + String(repeating: "*", count: l - 10) + "-***-***-" + String(gg.suffix(4)) + } + return "***-***-" + String(gg.suffix(4)) + } + } +} diff --git a/tests/501-1000/831. masking-personal-information/sol.ts b/tests/501-1000/831. masking-personal-information/sol.ts new file mode 100644 index 00000000..2b1b3212 --- /dev/null +++ b/tests/501-1000/831. masking-personal-information/sol.ts @@ -0,0 +1,21 @@ +function maskPII(s: string): string { + if (s.includes("@")) { + const parts = s.split("@"); + let name = parts[0].toLowerCase(); + const domain = parts[1].toLowerCase(); + name = name[0] + "*****" + name[name.length - 1]; + return name + "@" + domain; + } else { + let gg = ""; + for (const x of s) { + if (!isNaN(parseInt(x))) { + gg += x; + } + } + const l = gg.length; + if (l > 10) { + return "+" + "*".repeat(l - 10) + "-***-***-" + gg.slice(l - 4); + } + return "***-***-" + gg.slice(l - 4); + } +} diff --git a/tests/501-1000/832. flipping-an-image/manifest.yaml b/tests/501-1000/832. flipping-an-image/manifest.yaml new file mode 100644 index 00000000..e585d7b8 --- /dev/null +++ b/tests/501-1000/832. flipping-an-image/manifest.yaml @@ -0,0 +1,985 @@ +entry: + id: 832 + title: flipping-an-image + params: + image: + type: array + items: + type: array + items: + type: int + call: + cpp: Solution().flipAndInvertImage({image}) + rust: Solution::flip_and_invert_image({image}) + python3: Solution().flipAndInvertImage({image}) + python2: Solution().flipAndInvertImage({image}) + ruby: flip_and_invert_image({image}) + java: new Solution().flipAndInvertImage({image}) + csharp: new Solution().FlipAndInvertImage({image}) + kotlin: Solution().flipAndInvertImage({image}) + go: flipAndInvertImage({image}) + dart: Solution().flipAndInvertImage({image}) + swift: Solution().flipAndInvertImage({image}) + typescript: flipAndInvertImage({image}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: | + class Checker: + def check(self, result): + return True +seed: 832 +tests: + - name: ex1 + in: + image: + elemType: int + value: + - - 1 + - 1 + - 0 + - - 1 + - 0 + - 1 + - - 0 + - 0 + - 0 + out: + - - 1 + - 0 + - 0 + - - 0 + - 1 + - 0 + - - 1 + - 1 + - 1 + - name: ex2 + in: + image: + elemType: int + value: + - - 1 + - 1 + - 0 + - 0 + - - 1 + - 0 + - 0 + - 1 + - - 0 + - 1 + - 1 + - 1 + - - 1 + - 0 + - 1 + - 0 + out: + - - 1 + - 1 + - 0 + - 0 + - - 0 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 1 + - - 1 + - 0 + - 1 + - 0 + - name: single_zero + in: + image: + elemType: int + value: + - - 0 + out: + - - 1 + - name: single_one + in: + image: + elemType: int + value: + - - 1 + out: + - - 0 + - name: two_by_two_all_zero + in: + image: + elemType: int + value: + - - 0 + - 0 + - - 0 + - 0 + out: + - - 1 + - 1 + - - 1 + - 1 + - name: two_by_two_checker + in: + image: + elemType: int + value: + - - 1 + - 0 + - - 0 + - 1 + out: + - - 1 + - 0 + - - 0 + - 1 + - name: odd_size_mix + in: + image: + elemType: int + value: + - - 1 + - 0 + - 1 + - - 0 + - 1 + - 0 + - - 1 + - 1 + - 0 + out: + - - 0 + - 1 + - 0 + - - 1 + - 0 + - 1 + - - 1 + - 0 + - 0 + - name: rectangular_pattern_1 + in: + image: + elemType: int + value: + - - 0 + - 1 + - 0 + - 1 + - - 1 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 1 + - 1 + - - 1 + - 0 + - 0 + - 0 + out: + - - 0 + - 1 + - 0 + - 1 + - - 1 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 0 + - name: four_by_four_edges + in: + image: + elemType: int + value: + - - 1 + - 0 + - 0 + - 1 + - - 0 + - 0 + - 0 + - 0 + - - 1 + - 1 + - 0 + - 0 + - - 0 + - 1 + - 1 + - 0 + out: + - - 0 + - 1 + - 1 + - 0 + - - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 0 + - 0 + - - 1 + - 0 + - 0 + - 1 + - name: five_by_five_dense + in: + image: + elemType: int + value: + - - 1 + - 1 + - 1 + - 0 + - 0 + - - 0 + - 1 + - 0 + - 1 + - 0 + - - 1 + - 0 + - 0 + - 0 + - 1 + - - 0 + - 0 + - 1 + - 1 + - 0 + - - 1 + - 0 + - 1 + - 0 + - 1 + out: + - - 1 + - 1 + - 0 + - 0 + - 0 + - - 1 + - 0 + - 1 + - 0 + - 1 + - - 0 + - 1 + - 1 + - 1 + - 0 + - - 1 + - 0 + - 0 + - 1 + - 1 + - - 0 + - 1 + - 0 + - 1 + - 0 + - name: row_palindrome + in: + image: + elemType: int + value: + - - 1 + - 0 + - 1 + - 0 + - 1 + - - 0 + - 0 + - 1 + - 0 + - 0 + out: + - - 0 + - 1 + - 0 + - 1 + - 0 + - - 1 + - 1 + - 0 + - 1 + - 1 + - name: all_ones_3x3 + in: + image: + elemType: int + value: + - - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + out: + - - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - name: all_zero_3x4 + in: + image: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + out: + - - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - name: mixed_rect_1 + in: + image: + elemType: int + value: + - - 0 + - 1 + - - 1 + - 0 + - - 0 + - 1 + - - 1 + - 1 + out: + - - 0 + - 1 + - - 1 + - 0 + - - 0 + - 1 + - - 0 + - 0 + - name: mixed_rect_2 + in: + image: + elemType: int + value: + - - 1 + - 0 + - 0 + - - 0 + - 1 + - 1 + out: + - - 1 + - 1 + - 0 + - - 0 + - 0 + - 1 + - name: mixed_rect_3 + in: + image: + elemType: int + value: + - - 1 + - 0 + - 1 + - 1 + - 0 + - 0 + out: + - - 1 + - 1 + - 0 + - 0 + - 1 + - 0 + - name: mixed_rect_4 + in: + image: + elemType: int + value: + - - 0 + - 0 + - 1 + - 1 + - 1 + - - 1 + - 0 + - 1 + - 0 + - 1 + out: + - - 0 + - 0 + - 0 + - 1 + - 1 + - - 0 + - 1 + - 0 + - 1 + - 0 + - name: mixed_rect_5 + in: + image: + elemType: int + value: + - - 1 + - 1 + - 0 + - 1 + - - 0 + - 1 + - 0 + - 0 + - - 1 + - 0 + - 1 + - 0 + out: + - - 0 + - 1 + - 0 + - 0 + - - 1 + - 1 + - 0 + - 1 + - - 1 + - 0 + - 1 + - 0 + - name: single_row + in: + image: + elemType: int + value: + - - 1 + - 0 + - 0 + - 1 + - 1 + - 0 + out: + - - 1 + - 0 + - 0 + - 1 + - 1 + - 0 + - name: single_col + in: + image: + elemType: int + value: + - - 1 + - - 0 + - - 1 + out: + - - 0 + - - 1 + - - 0 + - name: diagonal_4x4 + in: + image: + elemType: int + value: + - - 1 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 1 + out: + - - 1 + - 1 + - 1 + - 0 + - - 1 + - 1 + - 0 + - 1 + - - 1 + - 0 + - 1 + - 1 + - - 0 + - 1 + - 1 + - 1 + - name: alternating_5x2 + in: + image: + elemType: int + value: + - - 0 + - 1 + - - 1 + - 0 + - - 0 + - 1 + - - 1 + - 0 + - - 0 + - 1 + out: + - - 0 + - 1 + - - 1 + - 0 + - - 0 + - 1 + - - 1 + - 0 + - - 0 + - 1 + - name: center_one_5x5 + in: + image: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + out: + - - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 0 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + - name: one_row_odd + in: + image: + elemType: int + value: + - - 1 + - 0 + - 1 + - 1 + - 0 + out: + - - 1 + - 0 + - 0 + - 1 + - 0 + - name: one_row_even + in: + image: + elemType: int + value: + - - 0 + - 1 + - 1 + - 0 + out: + - - 1 + - 0 + - 0 + - 1 + - name: one_col_mix + in: + image: + elemType: int + value: + - - 0 + - - 1 + - - 1 + - - 0 + out: + - - 1 + - - 0 + - - 0 + - - 1 + - name: tall_rect_1 + in: + image: + elemType: int + value: + - - 1 + - 0 + - 0 + - - 0 + - 1 + - 0 + - - 1 + - 0 + - 1 + - - 0 + - 0 + - 1 + - - 1 + - 1 + - 0 + out: + - - 1 + - 1 + - 0 + - - 1 + - 0 + - 1 + - - 0 + - 1 + - 0 + - - 0 + - 1 + - 1 + - - 1 + - 0 + - 0 + - name: tall_rect_2 + in: + image: + elemType: int + value: + - - 1 + - 1 + - 0 + - 0 + - - 1 + - 1 + - 1 + - 0 + - - 0 + - 1 + - 0 + - 1 + out: + - - 1 + - 1 + - 0 + - 0 + - - 1 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 0 + - 1 + - name: square_6 + in: + image: + elemType: int + value: + - - 0 + - 1 + - 1 + - 0 + - 0 + - 1 + - - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 0 + - 0 + - 1 + - 1 + - - 0 + - 1 + - 0 + - 1 + - 0 + - 0 + - - 1 + - 0 + - 1 + - 1 + - 0 + - 1 + out: + - - 0 + - 1 + - 1 + - 0 + - 0 + - 1 + - - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 1 + - 1 + - 1 + - - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - - 1 + - 1 + - 0 + - 1 + - 0 + - 1 + - - 0 + - 1 + - 0 + - 0 + - 1 + - 0 + - name: sparse_4x5 + in: + image: + elemType: int + value: + - - 0 + - 0 + - 1 + - 0 + - 0 + - - 1 + - 0 + - 0 + - 0 + - 1 + - - 1 + - 1 + - 0 + - 1 + - 0 + - - 0 + - 1 + - 1 + - 0 + - 1 + out: + - - 1 + - 1 + - 0 + - 1 + - 1 + - - 0 + - 1 + - 1 + - 1 + - 0 + - - 1 + - 0 + - 1 + - 0 + - 0 + - - 0 + - 1 + - 0 + - 0 + - 1 + - name: extra_1 + in: + image: + elemType: int + value: + - - 1 + - 0 + - 0 + - 1 + out: + - - 0 + - 1 + - 1 + - 0 + - name: extra_2 + in: + image: + elemType: int + value: + - - 0 + - 1 + - 0 + - 0 + - - 1 + - 0 + - 1 + - 1 + out: + - - 1 + - 1 + - 0 + - 1 + - - 0 + - 0 + - 1 + - 0 + - name: extra_3 + in: + image: + elemType: int + value: + - - 0 + - 0 + - 0 + - - 1 + - 0 + - 0 + - - 1 + - 1 + - 1 + out: + - - 1 + - 1 + - 1 + - - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - name: extra_4 + in: + image: + elemType: int + value: + - - 1 + - 1 + - - 0 + - 1 + - - 1 + - 0 + - - 0 + - 0 + out: + - - 0 + - 0 + - - 0 + - 1 + - - 1 + - 0 + - - 1 + - 1 + - name: extra_5 + in: + image: + elemType: int + value: + - - 0 + - 1 + - 1 + - 0 + - 1 + - - 1 + - 0 + - 0 + - 1 + - 0 + out: + - - 0 + - 1 + - 0 + - 0 + - 1 + - - 1 + - 0 + - 1 + - 1 + - 0 diff --git a/tests/501-1000/832. flipping-an-image/sol.cpp b/tests/501-1000/832. flipping-an-image/sol.cpp new file mode 100644 index 00000000..578ba764 --- /dev/null +++ b/tests/501-1000/832. flipping-an-image/sol.cpp @@ -0,0 +1,16 @@ +class Solution { +public: + vector> flipAndInvertImage(vector>& image) { + for (auto& row : image) { + int left = 0, right = row.size() - 1; + while (left <= right) { + int temp = 1 - row[right]; + row[right] = 1 - row[left]; + row[left] = temp; + left++; + right--; + } + } + return image; + } +}; diff --git a/tests/501-1000/832. flipping-an-image/sol.cs b/tests/501-1000/832. flipping-an-image/sol.cs new file mode 100644 index 00000000..9987fb8f --- /dev/null +++ b/tests/501-1000/832. flipping-an-image/sol.cs @@ -0,0 +1,15 @@ +public class Solution { + public int[][] FlipAndInvertImage(int[][] image) { + foreach (var row in image) { + int left = 0, right = row.Length - 1; + while (left <= right) { + int temp = 1 - row[right]; + row[right] = 1 - row[left]; + row[left] = temp; + left++; + right--; + } + } + return image; + } +} diff --git a/tests/501-1000/832. flipping-an-image/sol.dart b/tests/501-1000/832. flipping-an-image/sol.dart new file mode 100644 index 00000000..3abff8d8 --- /dev/null +++ b/tests/501-1000/832. flipping-an-image/sol.dart @@ -0,0 +1,15 @@ +class Solution { + List> flipAndInvertImage(List> image) { + for (var row in image) { + int left = 0, right = row.length - 1; + while (left <= right) { + int temp = 1 - row[right]; + row[right] = 1 - row[left]; + row[left] = temp; + left++; + right--; + } + } + return image; + } +} diff --git a/tests/501-1000/832. flipping-an-image/sol.go b/tests/501-1000/832. flipping-an-image/sol.go new file mode 100644 index 00000000..7ef25242 --- /dev/null +++ b/tests/501-1000/832. flipping-an-image/sol.go @@ -0,0 +1,11 @@ +func flipAndInvertImage(image [][]int) [][]int { + for _, row := range image { + left, right := 0, len(row)-1 + for left <= right { + row[left], row[right] = 1-row[right], 1-row[left] + left++ + right-- + } + } + return image +} diff --git a/tests/501-1000/832. flipping-an-image/sol.java b/tests/501-1000/832. flipping-an-image/sol.java new file mode 100644 index 00000000..e55197a1 --- /dev/null +++ b/tests/501-1000/832. flipping-an-image/sol.java @@ -0,0 +1,15 @@ +class Solution { + public int[][] flipAndInvertImage(int[][] image) { + for (int[] row : image) { + int left = 0, right = row.length - 1; + while (left <= right) { + int temp = 1 - row[right]; + row[right] = 1 - row[left]; + row[left] = temp; + left++; + right--; + } + } + return image; + } +} diff --git a/tests/501-1000/832. flipping-an-image/sol.kt b/tests/501-1000/832. flipping-an-image/sol.kt new file mode 100644 index 00000000..7829e37c --- /dev/null +++ b/tests/501-1000/832. flipping-an-image/sol.kt @@ -0,0 +1,16 @@ +class Solution { + fun flipAndInvertImage(image: Array): Array { + for (row in image) { + var left = 0 + var right = row.size - 1 + while (left <= right) { + val temp = 1 - row[right] + row[right] = 1 - row[left] + row[left] = temp + left++ + right-- + } + } + return image + } +} diff --git a/tests/501-1000/832. flipping-an-image/sol.py b/tests/501-1000/832. flipping-an-image/sol.py new file mode 100644 index 00000000..324eccf6 --- /dev/null +++ b/tests/501-1000/832. flipping-an-image/sol.py @@ -0,0 +1,9 @@ +class Solution: + def flipAndInvertImage(self, image: List[List[int]]) -> List[List[int]]: + for row in image: + left, right = 0, len(row) - 1 + while left <= right: + row[left], row[right] = 1 - row[right], 1 - row[left] + left += 1 + right -= 1 + return image diff --git a/tests/501-1000/832. flipping-an-image/sol.py2 b/tests/501-1000/832. flipping-an-image/sol.py2 new file mode 100644 index 00000000..e46ffd4a --- /dev/null +++ b/tests/501-1000/832. flipping-an-image/sol.py2 @@ -0,0 +1,13 @@ +class Solution(object): + def flipAndInvertImage(self, image): + """ + :type image: List[List[int]] + :rtype: List[List[int]] + """ + for row in image: + left, right = 0, len(row) - 1 + while left <= right: + row[left], row[right] = 1 - row[right], 1 - row[left] + left += 1 + right -= 1 + return image diff --git a/tests/501-1000/832. flipping-an-image/sol.rb b/tests/501-1000/832. flipping-an-image/sol.rb new file mode 100644 index 00000000..39dd57a9 --- /dev/null +++ b/tests/501-1000/832. flipping-an-image/sol.rb @@ -0,0 +1,13 @@ +# @param {Integer[][]} image +# @return {Integer[][]} +def flip_and_invert_image(image) + image.each do |row| + left, right = 0, row.length - 1 + while left <= right + row[left], row[right] = 1 - row[right], 1 - row[left] + left += 1 + right -= 1 + end + end + image +end diff --git a/tests/501-1000/832. flipping-an-image/sol.rs b/tests/501-1000/832. flipping-an-image/sol.rs new file mode 100644 index 00000000..feeb2093 --- /dev/null +++ b/tests/501-1000/832. flipping-an-image/sol.rs @@ -0,0 +1,17 @@ +impl Solution { + pub fn flip_and_invert_image(image: Vec>) -> Vec> { + let mut image = image; + for row in image.iter_mut() { + let mut left = 0usize; + let mut right = row.len(); + while left < right { + right -= 1; + let temp = 1 - row[right]; + row[right] = 1 - row[left]; + row[left] = temp; + left += 1; + } + } + image + } +} diff --git a/tests/501-1000/832. flipping-an-image/sol.swift b/tests/501-1000/832. flipping-an-image/sol.swift new file mode 100644 index 00000000..301e900e --- /dev/null +++ b/tests/501-1000/832. flipping-an-image/sol.swift @@ -0,0 +1,17 @@ +class Solution { + func flipAndInvertImage(_ image: [[Int]]) -> [[Int]] { + var image = image + for i in 0..& indices, vector& sources, vector& targets) { + unordered_map> patch; + for (int k = 0; k < indices.size(); k++) { + int i = indices[k]; + string src = sources[k]; + string tgt = targets[k]; + if (i + src.length() <= s.length() && s.substr(i, src.length()) == src) { + patch[i] = {src, tgt}; + } + } + string res; + int i = 0; + int n = s.length(); + while (i < n) { + if (patch.count(i)) { + auto& [src, tgt] = patch[i]; + res += tgt; + i += src.length(); + } else { + res += s[i]; + i++; + } + } + return res; + } +}; diff --git a/tests/501-1000/833. find-and-replace-in-string/sol.cs b/tests/501-1000/833. find-and-replace-in-string/sol.cs new file mode 100644 index 00000000..f59c914e --- /dev/null +++ b/tests/501-1000/833. find-and-replace-in-string/sol.cs @@ -0,0 +1,27 @@ +public class Solution { + public string FindReplaceString(string s, int[] indices, string[] sources, string[] targets) { + Dictionary patch = new Dictionary(); + for (int k = 0; k < indices.Length; k++) { + int i = indices[k]; + string src = sources[k]; + string tgt = targets[k]; + if (i + src.Length <= s.Length && s.Substring(i, src.Length) == src) { + patch[i] = (src, tgt); + } + } + System.Text.StringBuilder res = new System.Text.StringBuilder(); + int idx = 0; + int n = s.Length; + while (idx < n) { + if (patch.ContainsKey(idx)) { + var (src, tgt) = patch[idx]; + res.Append(tgt); + idx += src.Length; + } else { + res.Append(s[idx]); + idx++; + } + } + return res.ToString(); + } +} diff --git a/tests/501-1000/833. find-and-replace-in-string/sol.dart b/tests/501-1000/833. find-and-replace-in-string/sol.dart new file mode 100644 index 00000000..3c9cd239 --- /dev/null +++ b/tests/501-1000/833. find-and-replace-in-string/sol.dart @@ -0,0 +1,27 @@ +class Solution { + String findReplaceString(String s, List indices, List sources, List targets) { + Map> patch = {}; + for (int k = 0; k < indices.length; k++) { + int i = indices[k]; + String src = sources[k]; + String tgt = targets[k]; + if (i + src.length <= s.length && s.substring(i, i + src.length) == src) { + patch[i] = [src, tgt]; + } + } + StringBuffer res = StringBuffer(); + int i = 0; + int n = s.length; + while (i < n) { + if (patch.containsKey(i)) { + var pair = patch[i]!; + res.write(pair[1]); + i += pair[0].length; + } else { + res.write(s[i]); + i++; + } + } + return res.toString(); + } +} diff --git a/tests/501-1000/833. find-and-replace-in-string/sol.go b/tests/501-1000/833. find-and-replace-in-string/sol.go new file mode 100644 index 00000000..80628500 --- /dev/null +++ b/tests/501-1000/833. find-and-replace-in-string/sol.go @@ -0,0 +1,23 @@ +func findReplaceString(s string, indices []int, sources []string, targets []string) string { + patch := make(map[int][2]string) + for k, i := range indices { + src := sources[k] + tgt := targets[k] + if i+len(src) <= len(s) && s[i:i+len(src)] == src { + patch[i] = [2]string{src, tgt} + } + } + var res []byte + i := 0 + n := len(s) + for i < n { + if pair, ok := patch[i]; ok { + res = append(res, pair[1]...) + i += len(pair[0]) + } else { + res = append(res, s[i]) + i++ + } + } + return string(res) +} diff --git a/tests/501-1000/833. find-and-replace-in-string/sol.java b/tests/501-1000/833. find-and-replace-in-string/sol.java new file mode 100644 index 00000000..0c1b232a --- /dev/null +++ b/tests/501-1000/833. find-and-replace-in-string/sol.java @@ -0,0 +1,27 @@ +class Solution { + public String findReplaceString(String s, int[] indices, String[] sources, String[] targets) { + int n = s.length(); + Map patch = new HashMap<>(); + for (int k = 0; k < indices.length; k++) { + int i = indices[k]; + String src = sources[k]; + String tgt = targets[k]; + if (i + src.length() <= n && s.substring(i, i + src.length()).equals(src)) { + patch.put(i, new String[]{src, tgt}); + } + } + StringBuilder res = new StringBuilder(); + int i = 0; + while (i < n) { + if (patch.containsKey(i)) { + String[] pair = patch.get(i); + res.append(pair[1]); + i += pair[0].length(); + } else { + res.append(s.charAt(i)); + i++; + } + } + return res.toString(); + } +} diff --git a/tests/501-1000/833. find-and-replace-in-string/sol.kt b/tests/501-1000/833. find-and-replace-in-string/sol.kt new file mode 100644 index 00000000..70dd2b9f --- /dev/null +++ b/tests/501-1000/833. find-and-replace-in-string/sol.kt @@ -0,0 +1,27 @@ +class Solution { + fun findReplaceString(s: String, indices: IntArray, sources: Array, targets: Array): String { + val patch = mutableMapOf>() + for (k in indices.indices) { + val i = indices[k] + val src = sources[k] + val tgt = targets[k] + if (i + src.length <= s.length && s.substring(i, i + src.length) == src) { + patch[i] = Pair(src, tgt) + } + } + val res = StringBuilder() + var i = 0 + val n = s.length + while (i < n) { + if (patch.containsKey(i)) { + val (src, tgt) = patch[i]!! + res.append(tgt) + i += src.length + } else { + res.append(s[i]) + i++ + } + } + return res.toString() + } +} diff --git a/tests/501-1000/833. find-and-replace-in-string/sol.py b/tests/501-1000/833. find-and-replace-in-string/sol.py new file mode 100644 index 00000000..3e2a6a0c --- /dev/null +++ b/tests/501-1000/833. find-and-replace-in-string/sol.py @@ -0,0 +1,16 @@ +class Solution(object): + def findReplaceString(self, s, indices, sources, targets): + patch = {} + for i, src, tgt in zip(indices, sources, targets): + if s[i : i + len(src)] == src: + patch[i] = (src, tgt) + res, i, n = [], 0, len(s) + while i < n: + if i in patch: + src, tgt = patch[i] + res.append(tgt) + i += len(src) + else: + res.append(s[i]) + i += 1 + return "".join(res) diff --git a/tests/501-1000/833. find-and-replace-in-string/sol.py2 b/tests/501-1000/833. find-and-replace-in-string/sol.py2 new file mode 100644 index 00000000..ed42e27e --- /dev/null +++ b/tests/501-1000/833. find-and-replace-in-string/sol.py2 @@ -0,0 +1,16 @@ +class Solution(object): + def findReplaceString(self, s, indices, sources, targets): + patch = {} + for i, src, tgt in zip(indices, sources, targets): + if s[i:i+len(src)] == src: + patch[i] = (src, tgt) + res, i, n = [], 0, len(s) + while i < n: + if i in patch: + src, tgt = patch[i] + res.append(tgt) + i += len(src) + else: + res.append(s[i]) + i += 1 + return ''.join(res) diff --git a/tests/501-1000/833. find-and-replace-in-string/sol.rb b/tests/501-1000/833. find-and-replace-in-string/sol.rb new file mode 100644 index 00000000..9dd25bdb --- /dev/null +++ b/tests/501-1000/833. find-and-replace-in-string/sol.rb @@ -0,0 +1,29 @@ +# @param {String} s +# @param {Integer[]} indices +# @param {String[]} sources +# @param {String[]} targets +# @return {String} +def find_replace_string(s, indices, sources, targets) + patch = {} + indices.each_with_index do |i, idx| + src = sources[idx] + tgt = targets[idx] + if s[i, src.length] == src + patch[i] = [src, tgt] + end + end + res = [] + i = 0 + n = s.length + while i < n + if patch.key?(i) + src, tgt = patch[i] + res << tgt + i += src.length + else + res << s[i] + i += 1 + end + end + res.join('') +end diff --git a/tests/501-1000/833. find-and-replace-in-string/sol.rs b/tests/501-1000/833. find-and-replace-in-string/sol.rs new file mode 100644 index 00000000..d7d383eb --- /dev/null +++ b/tests/501-1000/833. find-and-replace-in-string/sol.rs @@ -0,0 +1,27 @@ +impl Solution { + pub fn find_replace_string(s: String, indices: Vec, sources: Vec, targets: Vec) -> String { + use std::collections::HashMap; + let mut patch: HashMap = HashMap::new(); + for k in 0..indices.len() { + let i = indices[k] as usize; + let src = sources[k].as_str(); + let tgt = targets[k].as_str(); + if i + src.len() <= s.len() && &s[i..i+src.len()] == src { + patch.insert(i, (src, tgt)); + } + } + let mut res = String::new(); + let mut i = 0; + let n = s.len(); + while i < n { + if let Some(&(src, tgt)) = patch.get(&i) { + res.push_str(tgt); + i += src.len(); + } else { + res.push(s.as_bytes()[i] as char); + i += 1; + } + } + res + } +} diff --git a/tests/501-1000/833. find-and-replace-in-string/sol.swift b/tests/501-1000/833. find-and-replace-in-string/sol.swift new file mode 100644 index 00000000..a040eca2 --- /dev/null +++ b/tests/501-1000/833. find-and-replace-in-string/sol.swift @@ -0,0 +1,29 @@ +class Solution { + func findReplaceString(_ s: String, _ indices: [Int], _ sources: [String], _ targets: [String]) -> String { + var patch = [Int: (String, String)]() + for k in 0.. sumOfDistancesInTree(int n, vector>& edges) { + vector> adj(n); + for (auto& e : edges) { + int u = e[0], v = e[1]; + adj[u].push_back(v); + adj[v].push_back(u); + } + + vector count(n, 1); + vector ans(n, 0); + + function dfsIn = [&](int node, int parent) { + for (int child : adj[node]) { + if (child != parent) { + dfsIn(child, node); + count[node] += count[child]; + ans[node] += ans[child] + count[child]; + } + } + }; + + function dfsOut = [&](int node, int parent) { + for (int child : adj[node]) { + if (child != parent) { + ans[child] = ans[node] - count[child] + (n - count[child]); + dfsOut(child, node); + } + } + }; + + dfsIn(0, -1); + dfsOut(0, -1); + return ans; + } +}; diff --git a/tests/501-1000/834. sum-of-distances-in-tree/sol.cs b/tests/501-1000/834. sum-of-distances-in-tree/sol.cs new file mode 100644 index 00000000..89e01af0 --- /dev/null +++ b/tests/501-1000/834. sum-of-distances-in-tree/sol.cs @@ -0,0 +1,40 @@ +public class Solution { + public int[] SumOfDistancesInTree(int n, int[][] edges) { + List[] adj = new List[n]; + for (int i = 0; i < n; i++) { + adj[i] = new List(); + } + foreach (int[] e in edges) { + int u = e[0], v = e[1]; + adj[u].Add(v); + adj[v].Add(u); + } + + int[] count = new int[n]; + int[] ans = new int[n]; + for (int i = 0; i < n; i++) count[i] = 1; + + void DfsIn(int node, int parent) { + foreach (int child in adj[node]) { + if (child != parent) { + DfsIn(child, node); + count[node] += count[child]; + ans[node] += ans[child] + count[child]; + } + } + } + + void DfsOut(int node, int parent) { + foreach (int child in adj[node]) { + if (child != parent) { + ans[child] = ans[node] - count[child] + (n - count[child]); + DfsOut(child, node); + } + } + } + + DfsIn(0, -1); + DfsOut(0, -1); + return ans; + } +} diff --git a/tests/501-1000/834. sum-of-distances-in-tree/sol.dart b/tests/501-1000/834. sum-of-distances-in-tree/sol.dart new file mode 100644 index 00000000..bc851288 --- /dev/null +++ b/tests/501-1000/834. sum-of-distances-in-tree/sol.dart @@ -0,0 +1,36 @@ +class Solution { + List sumOfDistancesInTree(int n, List> edges) { + List> adj = List.generate(n, (_) => []); + for (var e in edges) { + int u = e[0], v = e[1]; + adj[u].add(v); + adj[v].add(u); + } + + List count = List.filled(n, 1); + List ans = List.filled(n, 0); + + void dfsIn(int node, int parent) { + for (int child in adj[node]) { + if (child != parent) { + dfsIn(child, node); + count[node] += count[child]; + ans[node] += ans[child] + count[child]; + } + } + } + + void dfsOut(int node, int parent) { + for (int child in adj[node]) { + if (child != parent) { + ans[child] = ans[node] - count[child] + (n - count[child]); + dfsOut(child, node); + } + } + } + + dfsIn(0, -1); + dfsOut(0, -1); + return ans; + } +} diff --git a/tests/501-1000/834. sum-of-distances-in-tree/sol.go b/tests/501-1000/834. sum-of-distances-in-tree/sol.go new file mode 100644 index 00000000..d0c0ed60 --- /dev/null +++ b/tests/501-1000/834. sum-of-distances-in-tree/sol.go @@ -0,0 +1,39 @@ +func sumOfDistancesInTree(n int, edges [][]int) []int { + adj := make([][]int, n) + for _, e := range edges { + u, v := e[0], e[1] + adj[u] = append(adj[u], v) + adj[v] = append(adj[v], u) + } + + count := make([]int, n) + ans := make([]int, n) + for i := range count { + count[i] = 1 + } + + var dfsIn func(int, int) + dfsIn = func(node, parent int) { + for _, child := range adj[node] { + if child != parent { + dfsIn(child, node) + count[node] += count[child] + ans[node] += ans[child] + count[child] + } + } + } + + var dfsOut func(int, int) + dfsOut = func(node, parent int) { + for _, child := range adj[node] { + if child != parent { + ans[child] = ans[node] - count[child] + (n - count[child]) + dfsOut(child, node) + } + } + } + + dfsIn(0, -1) + dfsOut(0, -1) + return ans +} diff --git a/tests/501-1000/834. sum-of-distances-in-tree/sol.java b/tests/501-1000/834. sum-of-distances-in-tree/sol.java new file mode 100644 index 00000000..0dcd2c11 --- /dev/null +++ b/tests/501-1000/834. sum-of-distances-in-tree/sol.java @@ -0,0 +1,49 @@ +class Solution { + @SuppressWarnings("unchecked") + public int[] sumOfDistancesInTree(int n, int[][] edges) { + List[] adj = new ArrayList[n]; + for (int i = 0; i < n; i++) adj[i] = new ArrayList<>(); + for (int[] e : edges) { + int u = e[0], v = e[1]; + adj[u].add(v); + adj[v].add(u); + } + + int[] parent = new int[n]; + Arrays.fill(parent, -1); + int[] order = new int[n]; + int top = 0; + int[] stack = new int[n]; + stack[top++] = 0; + parent[0] = 0; + int ord = 0; + while (top > 0) { + int node = stack[--top]; + order[ord++] = node; + for (int child : adj[node]) { + if (parent[child] == -1) { + parent[child] = node; + stack[top++] = child; + } + } + } + + int[] count = new int[n]; + int[] ans = new int[n]; + Arrays.fill(count, 1); + + for (int i = n - 1; i > 0; i--) { + int node = order[i]; + int p = parent[node]; + count[p] += count[node]; + ans[p] += ans[node] + count[node]; + } + + for (int i = 1; i < n; i++) { + int node = order[i]; + int p = parent[node]; + ans[node] = ans[p] - count[node] + (n - count[node]); + } + return ans; + } +} diff --git a/tests/501-1000/834. sum-of-distances-in-tree/sol.kt b/tests/501-1000/834. sum-of-distances-in-tree/sol.kt new file mode 100644 index 00000000..7f04723a --- /dev/null +++ b/tests/501-1000/834. sum-of-distances-in-tree/sol.kt @@ -0,0 +1,35 @@ +class Solution { + fun sumOfDistancesInTree(n: Int, edges: Array): IntArray { + val adj = Array(n) { mutableListOf() } + for ((u, v) in edges) { + adj[u].add(v) + adj[v].add(u) + } + + val count = IntArray(n) { 1 } + val ans = IntArray(n) + + fun dfsIn(node: Int, parent: Int) { + for (child in adj[node]) { + if (child != parent) { + dfsIn(child, node) + count[node] += count[child] + ans[node] += ans[child] + count[child] + } + } + } + + fun dfsOut(node: Int, parent: Int) { + for (child in adj[node]) { + if (child != parent) { + ans[child] = ans[node] - count[child] + (n - count[child]) + dfsOut(child, node) + } + } + } + + dfsIn(0, -1) + dfsOut(0, -1) + return ans + } +} diff --git a/tests/501-1000/834. sum-of-distances-in-tree/sol.py b/tests/501-1000/834. sum-of-distances-in-tree/sol.py new file mode 100644 index 00000000..c424eeba --- /dev/null +++ b/tests/501-1000/834. sum-of-distances-in-tree/sol.py @@ -0,0 +1,26 @@ +class Solution: + def sumOfDistancesInTree(self, n: int, edges: List[List[int]]) -> List[int]: + adj = defaultdict(list) + for u, v in edges: + adj[u].append(v) + adj[v].append(u) + + count = [1] * n + ans = [0] * n + + def dfs_in(node, parent): + for child in adj[node]: + if child != parent: + dfs_in(child, node) + count[node] += count[child] + ans[node] += ans[child] + count[child] + + def dfs_out(node, parent): + for child in adj[node]: + if child != parent: + ans[child] = ans[node] - count[child] + (n - count[child]) + dfs_out(child, node) + + dfs_in(0, -1) + dfs_out(0, -1) + return ans diff --git a/tests/501-1000/834. sum-of-distances-in-tree/sol.py2 b/tests/501-1000/834. sum-of-distances-in-tree/sol.py2 new file mode 100644 index 00000000..06be6bd8 --- /dev/null +++ b/tests/501-1000/834. sum-of-distances-in-tree/sol.py2 @@ -0,0 +1,32 @@ +class Solution(object): + def sumOfDistancesInTree(self, n, edges): + """ + :type n: int + :type edges: List[List[int]] + :rtype: List[int] + """ + from collections import defaultdict + adj = defaultdict(list) + for u, v in edges: + adj[u].append(v) + adj[v].append(u) + + count = [1] * n + ans = [0] * n + + def dfs_in(node, parent): + for child in adj[node]: + if child != parent: + dfs_in(child, node) + count[node] += count[child] + ans[node] += ans[child] + count[child] + + def dfs_out(node, parent): + for child in adj[node]: + if child != parent: + ans[child] = ans[node] - count[child] + (n - count[child]) + dfs_out(child, node) + + dfs_in(0, -1) + dfs_out(0, -1) + return ans diff --git a/tests/501-1000/834. sum-of-distances-in-tree/sol.rb b/tests/501-1000/834. sum-of-distances-in-tree/sol.rb new file mode 100644 index 00000000..e1bd8271 --- /dev/null +++ b/tests/501-1000/834. sum-of-distances-in-tree/sol.rb @@ -0,0 +1,34 @@ +# @param {Integer} n +# @param {Integer[][]} edges +# @return {Integer[]} +def sum_of_distances_in_tree(n, edges) + adj = Hash.new { |h, k| h[k] = [] } + edges.each do |u, v| + adj[u] << v + adj[v] << u + end + + count = [1] * n + ans = [0] * n + + dfs_in = lambda do |node, parent| + adj[node].each do |child| + next if child == parent + dfs_in.call(child, node) + count[node] += count[child] + ans[node] += ans[child] + count[child] + end + end + + dfs_out = lambda do |node, parent| + adj[node].each do |child| + next if child == parent + ans[child] = ans[node] - count[child] + (n - count[child]) + dfs_out.call(child, node) + end + end + + dfs_in.call(0, -1) + dfs_out.call(0, -1) + ans +end diff --git a/tests/501-1000/834. sum-of-distances-in-tree/sol.rs b/tests/501-1000/834. sum-of-distances-in-tree/sol.rs new file mode 100644 index 00000000..78f8e2b0 --- /dev/null +++ b/tests/501-1000/834. sum-of-distances-in-tree/sol.rs @@ -0,0 +1,39 @@ +impl Solution { + pub fn sum_of_distances_in_tree(n: i32, edges: Vec>) -> Vec { + let n = n as usize; + let mut adj = vec![vec![]; n]; + for e in &edges { + let u = e[0] as usize; + let v = e[1] as usize; + adj[u].push(v); + adj[v].push(u); + } + + let mut count = vec![1i32; n]; + let mut ans = vec![0i32; n]; + + fn dfs_in(node: usize, parent: i32, adj: &Vec>, count: &mut Vec, ans: &mut Vec) { + for &child in &adj[node] { + if child as i32 != parent { + dfs_in(child, node as i32, adj, count, ans); + count[node] += count[child]; + ans[node] += ans[child] + count[child]; + } + } + } + + fn dfs_out(node: usize, parent: i32, adj: &Vec>, count: &Vec, ans: &mut Vec, n: usize) { + for &child in &adj[node] { + if child as i32 != parent { + ans[child] = ans[node] - count[child] + (n as i32 - count[child]); + dfs_out(child, node as i32, adj, count, ans, n); + } + } + } + + dfs_in(0, -1, &adj, &mut count, &mut ans); + dfs_out(0, -1, &adj, &count, &mut ans, n); + + ans + } +} diff --git a/tests/501-1000/834. sum-of-distances-in-tree/sol.swift b/tests/501-1000/834. sum-of-distances-in-tree/sol.swift new file mode 100644 index 00000000..359d8364 --- /dev/null +++ b/tests/501-1000/834. sum-of-distances-in-tree/sol.swift @@ -0,0 +1,36 @@ +class Solution { + func sumOfDistancesInTree(_ n: Int, _ edges: [[Int]]) -> [Int] { + var adj = [[Int]](repeating: [], count: n) + for e in edges { + let u = e[0], v = e[1] + adj[u].append(v) + adj[v].append(u) + } + + var count = [Int](repeating: 1, count: n) + var ans = [Int](repeating: 0, count: n) + + func dfsIn(_ node: Int, _ parent: Int) { + for child in adj[node] { + if child != parent { + dfsIn(child, node) + count[node] += count[child] + ans[node] += ans[child] + count[child] + } + } + } + + func dfsOut(_ node: Int, _ parent: Int) { + for child in adj[node] { + if child != parent { + ans[child] = ans[node] - count[child] + (n - count[child]) + dfsOut(child, node) + } + } + } + + dfsIn(0, -1) + dfsOut(0, -1) + return ans + } +} diff --git a/tests/501-1000/834. sum-of-distances-in-tree/sol.ts b/tests/501-1000/834. sum-of-distances-in-tree/sol.ts new file mode 100644 index 00000000..802e4fc2 --- /dev/null +++ b/tests/501-1000/834. sum-of-distances-in-tree/sol.ts @@ -0,0 +1,33 @@ +function sumOfDistancesInTree(n: number, edges: number[][]): number[] { + const adj: number[][] = Array.from({ length: n }, () => []); + for (const [u, v] of edges) { + adj[u].push(v); + adj[v].push(u); + } + + const count: number[] = Array(n).fill(1); + const ans: number[] = Array(n).fill(0); + + const dfsIn = (node: number, parent: number): void => { + for (const child of adj[node]) { + if (child !== parent) { + dfsIn(child, node); + count[node] += count[child]; + ans[node] += ans[child] + count[child]; + } + } + }; + + const dfsOut = (node: number, parent: number): void => { + for (const child of adj[node]) { + if (child !== parent) { + ans[child] = ans[node] - count[child] + (n - count[child]); + dfsOut(child, node); + } + } + }; + + dfsIn(0, -1); + dfsOut(0, -1); + return ans; +} diff --git a/tests/501-1000/835. image-overlap/manifest.yaml b/tests/501-1000/835. image-overlap/manifest.yaml new file mode 100644 index 00000000..0b3acce2 --- /dev/null +++ b/tests/501-1000/835. image-overlap/manifest.yaml @@ -0,0 +1,5705 @@ +entry: + id: 835 + title: image-overlap + params: + img1: + type: array + items: + type: array + items: + type: int + img2: + type: array + items: + type: array + items: + type: int + call: + cpp: Solution().largestOverlap({img1}, {img2}) + rust: Solution::largest_overlap({img1}, {img2}) + python3: Solution().largestOverlap({img1}, {img2}) + python2: Solution().largestOverlap({img1}, {img2}) + ruby: largest_overlap({img1}, {img2}) + java: new Solution().largestOverlap({img1}, {img2}) + csharp: new Solution().LargestOverlap({img1}, {img2}) + kotlin: Solution().largestOverlap({img1}, {img2}) + go: largestOverlap({img1}, {img2}) + dart: Solution().largestOverlap({img1}, {img2}) + swift: Solution().largestOverlap({img1}, {img2}) + typescript: largestOverlap({img1}, {img2}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().largestOverlap(img1, img2, {result}) + checker: "class Checker:\n def largestOverlap(self, img1, img2, result):\n from collections import Counter\n n = len(img1)\n a = [(i, j) for i in range(n) for j in range(n) if img1[i][j]]\n b = [(i, j) for i in range(n) for j in range(n) if img2[i][j]]\n cnt = Counter((x1 - x2, y1 - y2) for x1, y1 in a for x2, y2 in b)\n return result == max(cnt.values() or [0])\n" +seed: 835 +tests: + - name: example-1 + in: + img1: + elemType: int + value: + - - 1 + - 1 + - 0 + - - 0 + - 1 + - 0 + - - 0 + - 1 + - 0 + img2: + elemType: int + value: + - - 0 + - 0 + - 0 + - - 0 + - 1 + - 1 + - - 0 + - 0 + - 1 + out: 3 + - name: example-2 + in: + img1: + elemType: int + value: + - - 1 + img2: + elemType: int + value: + - - 1 + out: 1 + - name: example-3 + in: + img1: + elemType: int + value: + - - 0 + img2: + elemType: int + value: + - - 0 + out: 0 + - name: single-vs-empty + in: + img1: + elemType: int + value: + - - 1 + img2: + elemType: int + value: + - - 0 + out: 0 + - name: single-corner-opposite + in: + img1: + elemType: int + value: + - - 1 + - 0 + - - 0 + - 0 + img2: + elemType: int + value: + - - 0 + - 0 + - - 0 + - 1 + out: 1 + - name: full-2x2 + in: + img1: + elemType: int + value: + - - 1 + - 1 + - - 1 + - 1 + img2: + elemType: int + value: + - - 1 + - 1 + - - 1 + - 1 + out: 4 + - name: diag-vs-antidiag-3 + in: + img1: + elemType: int + value: + - - 1 + - 0 + - 0 + - - 0 + - 1 + - 0 + - - 0 + - 0 + - 1 + img2: + elemType: int + value: + - - 0 + - 0 + - 1 + - - 0 + - 1 + - 0 + - - 1 + - 0 + - 0 + out: 1 + - name: plus-vs-plus-3 + in: + img1: + elemType: int + value: + - - 0 + - 1 + - 0 + - - 1 + - 1 + - 1 + - - 0 + - 1 + - 0 + img2: + elemType: int + value: + - - 0 + - 1 + - 0 + - - 1 + - 1 + - 1 + - - 0 + - 1 + - 0 + out: 5 + - name: plus-shifted-3 + in: + img1: + elemType: int + value: + - - 0 + - 1 + - 0 + - - 1 + - 1 + - 1 + - - 0 + - 1 + - 0 + img2: + elemType: int + value: + - - 0 + - 0 + - 0 + - - 0 + - 1 + - 0 + - - 1 + - 1 + - 1 + out: 4 + - name: border-vs-center-3 + in: + img1: + elemType: int + value: + - - 1 + - 1 + - 1 + - - 1 + - 0 + - 1 + - - 1 + - 1 + - 1 + img2: + elemType: int + value: + - - 0 + - 0 + - 0 + - - 0 + - 1 + - 0 + - - 0 + - 0 + - 0 + out: 1 + - name: l-shapes-4 + in: + img1: + elemType: int + value: + - - 1 + - 0 + - 0 + - 0 + - - 1 + - 0 + - 0 + - 0 + - - 1 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + img2: + elemType: int + value: + - - 0 + - 0 + - 1 + - 1 + - - 0 + - 0 + - 1 + - 0 + - - 0 + - 0 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + out: 3 + - name: two-points-4 + in: + img1: + elemType: int + value: + - - 1 + - 0 + - 0 + - 1 + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 0 + - 0 + - - 1 + - 0 + - 0 + - 0 + img2: + elemType: int + value: + - - 0 + - 1 + - 0 + - 0 + - - 1 + - 0 + - 0 + - 1 + - - 0 + - 0 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + out: 2 + - name: checkerboard-4 + in: + img1: + elemType: int + value: + - - 1 + - 0 + - 1 + - 0 + - - 0 + - 1 + - 0 + - 1 + - - 1 + - 0 + - 1 + - 0 + - - 0 + - 1 + - 0 + - 1 + img2: + elemType: int + value: + - - 0 + - 1 + - 0 + - 1 + - - 1 + - 0 + - 1 + - 0 + - - 0 + - 1 + - 0 + - 1 + - - 1 + - 0 + - 1 + - 0 + out: 6 + - name: sparse-cross-4 + in: + img1: + elemType: int + value: + - - 0 + - 1 + - 0 + - 0 + - - 1 + - 1 + - 1 + - 0 + - - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + img2: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 0 + - - 0 + - 1 + - 1 + - 1 + - - 0 + - 0 + - 1 + - 0 + out: 5 + - name: single-row-block-4 + in: + img1: + elemType: int + value: + - - 1 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + img2: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + out: 3 + - name: single-col-block-4 + in: + img1: + elemType: int + value: + - - 1 + - 0 + - 0 + - 0 + - - 1 + - 0 + - 0 + - 0 + - - 1 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + img2: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 0 + - 0 + - - 0 + - 1 + - 0 + - 0 + - - 0 + - 1 + - 0 + - 0 + out: 3 + - name: diamond-5 + in: + img1: + elemType: int + value: + - - 0 + - 0 + - 1 + - 0 + - 0 + - - 0 + - 1 + - 1 + - 1 + - 0 + - - 1 + - 1 + - 1 + - 1 + - 1 + - - 0 + - 1 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 1 + - 0 + - 0 + img2: + elemType: int + value: + - - 0 + - 0 + - 0 + - 1 + - 0 + - - 0 + - 0 + - 1 + - 1 + - 1 + - - 0 + - 1 + - 1 + - 1 + - 1 + - - 0 + - 0 + - 1 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 1 + - 0 + out: 12 + - name: hollow-square-5 + in: + img1: + elemType: int + value: + - - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 0 + - 0 + - 0 + - 1 + - - 1 + - 0 + - 0 + - 0 + - 1 + - - 1 + - 0 + - 0 + - 0 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + img2: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 1 + - 1 + - 1 + - - 0 + - 1 + - 0 + - 0 + - 1 + - - 0 + - 1 + - 0 + - 0 + - 1 + - - 0 + - 1 + - 1 + - 1 + - 1 + out: 7 + - name: x-shape-5 + in: + img1: + elemType: int + value: + - - 1 + - 0 + - 0 + - 0 + - 1 + - - 0 + - 1 + - 0 + - 1 + - 0 + - - 0 + - 0 + - 1 + - 0 + - 0 + - - 0 + - 1 + - 0 + - 1 + - 0 + - - 1 + - 0 + - 0 + - 0 + - 1 + img2: + elemType: int + value: + - - 0 + - 1 + - 0 + - 1 + - 0 + - - 1 + - 0 + - 0 + - 0 + - 1 + - - 0 + - 0 + - 1 + - 0 + - 0 + - - 1 + - 0 + - 0 + - 0 + - 1 + - - 0 + - 1 + - 0 + - 1 + - 0 + out: 4 + - name: upper-triangle-5 + in: + img1: + elemType: int + value: + - - 1 + - 1 + - 1 + - 1 + - 1 + - - 0 + - 1 + - 1 + - 1 + - 1 + - - 0 + - 0 + - 1 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 1 + img2: + elemType: int + value: + - - 1 + - 0 + - 0 + - 0 + - 0 + - - 1 + - 1 + - 0 + - 0 + - 0 + - - 1 + - 1 + - 1 + - 0 + - 0 + - - 1 + - 1 + - 1 + - 1 + - 0 + - - 1 + - 1 + - 1 + - 1 + - 1 + out: 10 + - name: left-heavy-5 + in: + img1: + elemType: int + value: + - - 1 + - 1 + - 0 + - 0 + - 0 + - - 1 + - 1 + - 0 + - 0 + - 0 + - - 1 + - 0 + - 0 + - 0 + - 0 + - - 1 + - 0 + - 0 + - 0 + - 0 + - - 1 + - 0 + - 0 + - 0 + - 0 + img2: + elemType: int + value: + - - 0 + - 0 + - 0 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 1 + out: 5 + - name: frame-vs-diag-6 + in: + img1: + elemType: int + value: + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 0 + - 0 + - 0 + - 0 + - 1 + - - 1 + - 0 + - 0 + - 0 + - 0 + - 1 + - - 1 + - 0 + - 0 + - 0 + - 0 + - 1 + - - 1 + - 0 + - 0 + - 0 + - 0 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + img2: + elemType: int + value: + - - 1 + - 0 + - 0 + - 0 + - 0 + - 1 + - - 0 + - 1 + - 0 + - 0 + - 1 + - 0 + - - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - - 0 + - 1 + - 0 + - 0 + - 1 + - 0 + - - 1 + - 0 + - 0 + - 0 + - 0 + - 1 + out: 4 + - name: three-blocks-6 + in: + img1: + elemType: int + value: + - - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + img2: + elemType: int + value: + - - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + out: 8 + - name: vertical-bars-6 + in: + img1: + elemType: int + value: + - - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + img2: + elemType: int + value: + - - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + out: 18 + - name: horizontal-bars-6 + in: + img1: + elemType: int + value: + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + img2: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + out: 18 + - name: clustered-corners-6 + in: + img1: + elemType: int + value: + - - 1 + - 1 + - 0 + - 0 + - 1 + - 1 + - - 1 + - 1 + - 0 + - 0 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 1 + - 1 + - 0 + - 0 + - 1 + - 1 + - - 1 + - 1 + - 0 + - 0 + - 1 + - 1 + img2: + elemType: int + value: + - - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - - 1 + - 1 + - 0 + - 0 + - 1 + - 1 + - - 1 + - 1 + - 0 + - 0 + - 1 + - 1 + - - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + out: 8 + - name: offset-cross-7 + in: + img1: + elemType: int + value: + - - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + img2: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - - 0 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + out: 12 + - name: staircase-7 + in: + img1: + elemType: int + value: + - - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + img2: + elemType: int + value: + - - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + out: 12 + - name: center-block-8 + in: + img1: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + - 1 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + - 1 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + - 1 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + - 1 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + img2: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 1 + - 1 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 1 + - 1 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 1 + - 1 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 1 + - 1 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + out: 16 + - name: corner-dots-8 + in: + img1: + elemType: int + value: + - - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 0 + - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 0 + - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + img2: + elemType: int + value: + - - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + out: 4 + - name: all-zero-8 + in: + img1: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + img2: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + out: 0 + - name: all-one-8 + in: + img1: + elemType: int + value: + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + img2: + elemType: int + value: + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + out: 64 + - name: ring-vs-filled-8 + in: + img1: + elemType: int + value: + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + img2: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 0 + - - 0 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 0 + - - 0 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 0 + - - 0 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 0 + - - 0 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 0 + - - 0 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + out: 11 + - name: large-cross-30 + in: + img1: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + img2: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + out: 37 + - name: large-diagonals-30 + in: + img1: + elemType: int + value: + - - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + img2: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + out: 2 diff --git a/tests/501-1000/835. image-overlap/sol.cpp b/tests/501-1000/835. image-overlap/sol.cpp new file mode 100644 index 00000000..8fe06c1c --- /dev/null +++ b/tests/501-1000/835. image-overlap/sol.cpp @@ -0,0 +1,24 @@ +class Solution { +public: + int largestOverlap(vector>& img1, vector>& img2) { + int n = img1.size(); + vector> a, b; + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + if (img1[i][j] == 1) a.push_back({i, j}); + if (img2[i][j] == 1) b.push_back({i, j}); + } + } + map, int> cnt; + for (auto& p1 : a) { + for (auto& p2 : b) { + cnt[{p1.first - p2.first, p1.second - p2.second}]++; + } + } + int max = 0; + for (auto& [k, v] : cnt) { + if (v > max) max = v; + } + return max; + } +}; diff --git a/tests/501-1000/835. image-overlap/sol.cs b/tests/501-1000/835. image-overlap/sol.cs new file mode 100644 index 00000000..c8ae5fdf --- /dev/null +++ b/tests/501-1000/835. image-overlap/sol.cs @@ -0,0 +1,26 @@ +public class Solution { + public int LargestOverlap(int[][] img1, int[][] img2) { + int n = img1.Length; + var a = new List<(int, int)>(); + var b = new List<(int, int)>(); + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + if (img1[i][j] == 1) a.Add((i, j)); + if (img2[i][j] == 1) b.Add((i, j)); + } + } + var cnt = new Dictionary<(int, int), int>(); + foreach (var (x1, y1) in a) { + foreach (var (x2, y2) in b) { + var key = (x1 - x2, y1 - y2); + if (cnt.ContainsKey(key)) cnt[key]++; + else cnt[key] = 1; + } + } + int max = 0; + foreach (var val in cnt.Values) { + if (val > max) max = val; + } + return max; + } +} diff --git a/tests/501-1000/835. image-overlap/sol.dart b/tests/501-1000/835. image-overlap/sol.dart new file mode 100644 index 00000000..2c630fe6 --- /dev/null +++ b/tests/501-1000/835. image-overlap/sol.dart @@ -0,0 +1,22 @@ +class Solution { + int largestOverlap(List> img1, List> img2) { + int n = img1.length; + List> a = []; + List> b = []; + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + if (img1[i][j] == 1) a.add([i, j]); + if (img2[i][j] == 1) b.add([i, j]); + } + } + Map cnt = {}; + for (var p1 in a) { + for (var p2 in b) { + String key = '${p1[0] - p2[0]},${p1[1] - p2[1]}'; + cnt[key] = (cnt[key] ?? 0) + 1; + } + } + if (cnt.isEmpty) return 0; + return cnt.values.reduce((x, y) => x > y ? x : y); + } +} diff --git a/tests/501-1000/835. image-overlap/sol.go b/tests/501-1000/835. image-overlap/sol.go new file mode 100644 index 00000000..e03c08b3 --- /dev/null +++ b/tests/501-1000/835. image-overlap/sol.go @@ -0,0 +1,29 @@ +func largestOverlap(img1 [][]int, img2 [][]int) int { + n := len(img1) + type point struct{ x, y int } + var a, b []point + for i := 0; i < n; i++ { + for j := 0; j < n; j++ { + if img1[i][j] == 1 { + a = append(a, point{i, j}) + } + if img2[i][j] == 1 { + b = append(b, point{i, j}) + } + } + } + cnt := make(map[[2]int]int) + for _, p1 := range a { + for _, p2 := range b { + key := [2]int{p1.x - p2.x, p1.y - p2.y} + cnt[key]++ + } + } + max := 0 + for _, v := range cnt { + if v > max { + max = v + } + } + return max +} diff --git a/tests/501-1000/835. image-overlap/sol.java b/tests/501-1000/835. image-overlap/sol.java new file mode 100644 index 00000000..5ef925e2 --- /dev/null +++ b/tests/501-1000/835. image-overlap/sol.java @@ -0,0 +1,25 @@ +class Solution { + public int largestOverlap(int[][] img1, int[][] img2) { + int n = img1.length; + List a = new ArrayList<>(); + List b = new ArrayList<>(); + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + if (img1[i][j] == 1) a.add(new int[]{i, j}); + if (img2[i][j] == 1) b.add(new int[]{i, j}); + } + } + Map cnt = new HashMap<>(); + for (int[] p1 : a) { + for (int[] p2 : b) { + String key = (p1[0] - p2[0]) + "," + (p1[1] - p2[1]); + cnt.put(key, cnt.getOrDefault(key, 0) + 1); + } + } + int max = 0; + for (int val : cnt.values()) { + max = Math.max(max, val); + } + return max; + } +} diff --git a/tests/501-1000/835. image-overlap/sol.kt b/tests/501-1000/835. image-overlap/sol.kt new file mode 100644 index 00000000..0110bfeb --- /dev/null +++ b/tests/501-1000/835. image-overlap/sol.kt @@ -0,0 +1,21 @@ +class Solution { + fun largestOverlap(img1: Array, img2: Array): Int { + val n = img1.size + val a = mutableListOf>() + val b = mutableListOf>() + for (i in 0 until n) { + for (j in 0 until n) { + if (img1[i][j] == 1) a.add(Pair(i, j)) + if (img2[i][j] == 1) b.add(Pair(i, j)) + } + } + val cnt = mutableMapOf, Int>() + for ((x1, y1) in a) { + for ((x2, y2) in b) { + val key = Pair(x1 - x2, y1 - y2) + cnt[key] = cnt.getOrDefault(key, 0) + 1 + } + } + return cnt.values.maxOrNull() ?: 0 + } +} diff --git a/tests/501-1000/835. image-overlap/sol.py b/tests/501-1000/835. image-overlap/sol.py new file mode 100644 index 00000000..8dd57d68 --- /dev/null +++ b/tests/501-1000/835. image-overlap/sol.py @@ -0,0 +1,12 @@ +class Solution(object): + def largestOverlap(self, img1, img2): + n = len(img1) + a = [(i, j) for i in range(n) for j in range(n) if img1[i][j]] + b = [(i, j) for i in range(n) for j in range(n) if img2[i][j]] + from collections import Counter + + cnt = Counter() + for x1, y1 in a: + for x2, y2 in b: + cnt[(x1 - x2, y1 - y2)] += 1 + return max(cnt.values() or [0]) diff --git a/tests/501-1000/835. image-overlap/sol.py2 b/tests/501-1000/835. image-overlap/sol.py2 new file mode 100644 index 00000000..d89fd0f5 --- /dev/null +++ b/tests/501-1000/835. image-overlap/sol.py2 @@ -0,0 +1,11 @@ +class Solution(object): + def largestOverlap(self, img1, img2): + n = len(img1) + a = [(i, j) for i in range(n) for j in range(n) if img1[i][j]] + b = [(i, j) for i in range(n) for j in range(n) if img2[i][j]] + from collections import Counter + cnt = Counter() + for x1, y1 in a: + for x2, y2 in b: + cnt[(x1 - x2, y1 - y2)] += 1 + return max(cnt.values() or [0]) diff --git a/tests/501-1000/835. image-overlap/sol.rb b/tests/501-1000/835. image-overlap/sol.rb new file mode 100644 index 00000000..9e645cd1 --- /dev/null +++ b/tests/501-1000/835. image-overlap/sol.rb @@ -0,0 +1,21 @@ +# @param {Integer[][]} img1 +# @param {Integer[][]} img2 +# @return {Integer} +def largest_overlap(img1, img2) + n = img1.length + a = [] + b = [] + (0...n).each do |i| + (0...n).each do |j| + a << [i, j] if img1[i][j] == 1 + b << [i, j] if img2[i][j] == 1 + end + end + cnt = Hash.new(0) + a.each do |x1, y1| + b.each do |x2, y2| + cnt[[x1 - x2, y1 - y2]] += 1 + end + end + cnt.values.empty? ? 0 : cnt.values.max +end diff --git a/tests/501-1000/835. image-overlap/sol.rs b/tests/501-1000/835. image-overlap/sol.rs new file mode 100644 index 00000000..ed3fa8a1 --- /dev/null +++ b/tests/501-1000/835. image-overlap/sol.rs @@ -0,0 +1,24 @@ +impl Solution { + pub fn largest_overlap(img1: Vec>, img2: Vec>) -> i32 { + let n = img1.len(); + let mut a = vec![]; + let mut b = vec![]; + for i in 0..n { + for j in 0..n { + if img1[i][j] == 1 { + a.push((i as i32, j as i32)); + } + if img2[i][j] == 1 { + b.push((i as i32, j as i32)); + } + } + } + let mut cnt = std::collections::HashMap::new(); + for &(x1, y1) in &a { + for &(x2, y2) in &b { + *cnt.entry((x1 - x2, y1 - y2)).or_insert(0) += 1; + } + } + cnt.values().max().cloned().unwrap_or(0) + } +} diff --git a/tests/501-1000/835. image-overlap/sol.swift b/tests/501-1000/835. image-overlap/sol.swift new file mode 100644 index 00000000..ad3ecc03 --- /dev/null +++ b/tests/501-1000/835. image-overlap/sol.swift @@ -0,0 +1,21 @@ +class Solution { + func largestOverlap(_ img1: [[Int]], _ img2: [[Int]]) -> Int { + let n = img1.count + var a = [(Int, Int)]() + var b = [(Int, Int)]() + for i in 0..(); + for (const [x1, y1] of a) { + for (const [x2, y2] of b) { + const key = `${x1 - x2},${y1 - y2}`; + cnt.set(key, (cnt.get(key) || 0) + 1); + } + } + let max = 0; + for (const val of cnt.values()) { + if (val > max) max = val; + } + return max; +} diff --git a/tests/501-1000/836. rectangle-overlap/manifest.yaml b/tests/501-1000/836. rectangle-overlap/manifest.yaml new file mode 100644 index 00000000..9515de23 --- /dev/null +++ b/tests/501-1000/836. rectangle-overlap/manifest.yaml @@ -0,0 +1,494 @@ +entry: + id: 836 + title: rectangle-overlap + params: + rec1: + type: array + items: + type: int + rec2: + type: array + items: + type: int + call: + cpp: Solution().isRectangleOverlap({rec1}, {rec2}) + rust: Solution::is_rectangle_overlap({rec1}, {rec2}) + python3: Solution().isRectangleOverlap({rec1}, {rec2}) + python2: Solution().isRectangleOverlap({rec1}, {rec2}) + ruby: is_rectangle_overlap({rec1}, {rec2}) + java: new Solution().isRectangleOverlap({rec1}, {rec2}) + csharp: new Solution().IsRectangleOverlap({rec1}, {rec2}) + kotlin: Solution().isRectangleOverlap({rec1}, {rec2}) + go: isRectangleOverlap({rec1}, {rec2}) + dart: Solution().isRectangleOverlap({rec1}, {rec2}) + swift: Solution().isRectangleOverlap({rec1}, {rec2}) + typescript: isRectangleOverlap({rec1}, {rec2}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: | + class Checker: + def check(self, result): + return True +seed: 836 +tests: + - name: ex1 + in: + rec1: + - 0 + - 0 + - 2 + - 2 + rec2: + - 1 + - 1 + - 3 + - 3 + out: true + - name: ex2 + in: + rec1: + - 0 + - 0 + - 1 + - 1 + rec2: + - 1 + - 0 + - 2 + - 1 + out: false + - name: ex3 + in: + rec1: + - 0 + - 0 + - 1 + - 1 + rec2: + - 2 + - 2 + - 3 + - 3 + out: false + - name: nested_overlap + in: + rec1: + - 0 + - 0 + - 10 + - 10 + rec2: + - 2 + - 3 + - 4 + - 5 + out: true + - name: share_edge_horizontal + in: + rec1: + - 0 + - 0 + - 2 + - 2 + rec2: + - 2 + - 0 + - 4 + - 2 + out: false + - name: share_edge_vertical + in: + rec1: + - 0 + - 0 + - 2 + - 2 + rec2: + - 0 + - 2 + - 2 + - 4 + out: false + - name: touch_corner + in: + rec1: + - 0 + - 0 + - 1 + - 1 + rec2: + - 1 + - 1 + - 2 + - 2 + out: false + - name: negative_coords_overlap + in: + rec1: + - -5 + - -5 + - -1 + - -1 + rec2: + - -3 + - -3 + - 2 + - 2 + out: true + - name: separated_negative + in: + rec1: + - -10 + - -10 + - -5 + - -5 + rec2: + - -4 + - -4 + - 0 + - 0 + out: false + - name: crossing_axes + in: + rec1: + - -5 + - 0 + - 0 + - 5 + rec2: + - -1 + - -1 + - 1 + - 1 + out: true + - name: contained_small + in: + rec1: + - 1 + - 1 + - 4 + - 4 + rec2: + - 2 + - 2 + - 3 + - 3 + out: true + - name: touch_top_right_corner + in: + rec1: + - 1 + - 1 + - 4 + - 4 + rec2: + - 4 + - 4 + - 5 + - 5 + out: false + - name: touch_bottom_left_corner + in: + rec1: + - 1 + - 1 + - 4 + - 4 + rec2: + - 0 + - 0 + - 1 + - 1 + out: false + - name: share_right_edge + in: + rec1: + - 1 + - 1 + - 4 + - 4 + rec2: + - 4 + - 1 + - 6 + - 4 + out: false + - name: disjoint_left + in: + rec1: + - 1 + - 1 + - 4 + - 4 + rec2: + - 0 + - 2 + - 2 + - 3 + out: true + - name: corner_touch_square + in: + rec1: + - 0 + - 0 + - 3 + - 3 + rec2: + - 3 + - 3 + - 6 + - 6 + out: false + - name: top_touch_nonoverlap + in: + rec1: + - 0 + - 0 + - 3 + - 3 + rec2: + - 2 + - 3 + - 4 + - 4 + out: false + - name: right_touch_nonoverlap + in: + rec1: + - 0 + - 0 + - 3 + - 3 + rec2: + - 3 + - 1 + - 4 + - 2 + out: false + - name: above_touch_nonoverlap + in: + rec1: + - 0 + - 0 + - 3 + - 3 + rec2: + - 1 + - 3 + - 2 + - 4 + out: false + - name: left_overlap_strip + in: + rec1: + - 0 + - 0 + - 3 + - 3 + rec2: + - -1 + - 1 + - 1 + - 2 + out: true + - name: max_range_overlap + in: + rec1: + - 0 + - 0 + - 1000000000 + - 1000000000 + rec2: + - 999999999 + - 999999999 + - 1000000001 + - 1000000001 + out: true + - name: max_range_touch + in: + rec1: + - -1000000000 + - -1000000000 + - 0 + - 0 + rec2: + - -1 + - -1 + - 1 + - 1 + out: true + - name: overlap_negative_strip + in: + rec1: + - -1000000000 + - -1 + - -1 + - 1 + rec2: + - -2 + - -2 + - 0 + - 0 + out: true + - name: corner_inside_border + in: + rec1: + - 2 + - 2 + - 5 + - 5 + rec2: + - 3 + - 0 + - 4 + - 3 + out: true + - name: right_edge_overlap_y_gap + in: + rec1: + - 2 + - 2 + - 5 + - 5 + rec2: + - 5 + - 2 + - 7 + - 4 + out: false + - name: above_right_corner + in: + rec1: + - 2 + - 2 + - 5 + - 5 + rec2: + - 0 + - 5 + - 3 + - 6 + out: false + - name: full_containment_equal + in: + rec1: + - 2 + - 2 + - 5 + - 5 + rec2: + - 2 + - 2 + - 5 + - 5 + out: true + - name: horizontal_thin_overlap + in: + rec1: + - 0 + - 0 + - 1 + - 10 + rec2: + - 0 + - 5 + - 1 + - 15 + out: true + - name: vertical_thin_overlap + in: + rec1: + - 0 + - 0 + - 10 + - 1 + rec2: + - 5 + - 0 + - 15 + - 1 + out: true + - name: corner_far_apart + in: + rec1: + - 0 + - 0 + - 10 + - 10 + rec2: + - 10 + - 10 + - 20 + - 20 + out: false + - name: shared_vertical_line_far + in: + rec1: + - 0 + - 0 + - 10 + - 10 + rec2: + - 10 + - 0 + - 20 + - 10 + out: false + - name: shared_horizontal_line_far + in: + rec1: + - 0 + - 0 + - 10 + - 10 + rec2: + - 0 + - 10 + - 10 + - 20 + out: false + - name: tiny_overlap_corner + in: + rec1: + - 0 + - 0 + - 10 + - 10 + rec2: + - 9 + - 9 + - 11 + - 11 + out: true + - name: border_touch_left + in: + rec1: + - 0 + - 0 + - 10 + - 10 + rec2: + - -1 + - -1 + - 0 + - 0 + out: false + - name: vertical_strip_overlap + in: + rec1: + - 0 + - 0 + - 4 + - 8 + rec2: + - 2 + - -2 + - 6 + - 2 + out: true diff --git a/tests/501-1000/836. rectangle-overlap/sol.cpp b/tests/501-1000/836. rectangle-overlap/sol.cpp new file mode 100644 index 00000000..ecb02c3f --- /dev/null +++ b/tests/501-1000/836. rectangle-overlap/sol.cpp @@ -0,0 +1,9 @@ +class Solution { +public: + bool isRectangleOverlap(vector& rec1, vector& rec2) { + return !(rec1[2] <= rec2[0] || + rec1[0] >= rec2[2] || + rec1[3] <= rec2[1] || + rec1[1] >= rec2[3]); + } +}; diff --git a/tests/501-1000/836. rectangle-overlap/sol.cs b/tests/501-1000/836. rectangle-overlap/sol.cs new file mode 100644 index 00000000..2677b723 --- /dev/null +++ b/tests/501-1000/836. rectangle-overlap/sol.cs @@ -0,0 +1,8 @@ +public class Solution { + public bool IsRectangleOverlap(int[] rec1, int[] rec2) { + return !(rec1[2] <= rec2[0] || + rec1[0] >= rec2[2] || + rec1[3] <= rec2[1] || + rec1[1] >= rec2[3]); + } +} diff --git a/tests/501-1000/836. rectangle-overlap/sol.dart b/tests/501-1000/836. rectangle-overlap/sol.dart new file mode 100644 index 00000000..976959ea --- /dev/null +++ b/tests/501-1000/836. rectangle-overlap/sol.dart @@ -0,0 +1,8 @@ +class Solution { + bool isRectangleOverlap(List rec1, List rec2) { + return !(rec1[2] <= rec2[0] || + rec1[0] >= rec2[2] || + rec1[3] <= rec2[1] || + rec1[1] >= rec2[3]); + } +} diff --git a/tests/501-1000/836. rectangle-overlap/sol.go b/tests/501-1000/836. rectangle-overlap/sol.go new file mode 100644 index 00000000..e70d2462 --- /dev/null +++ b/tests/501-1000/836. rectangle-overlap/sol.go @@ -0,0 +1,6 @@ +func isRectangleOverlap(rec1 []int, rec2 []int) bool { + return !(rec1[2] <= rec2[0] || + rec1[0] >= rec2[2] || + rec1[3] <= rec2[1] || + rec1[1] >= rec2[3]) +} diff --git a/tests/501-1000/836. rectangle-overlap/sol.java b/tests/501-1000/836. rectangle-overlap/sol.java new file mode 100644 index 00000000..1a29a819 --- /dev/null +++ b/tests/501-1000/836. rectangle-overlap/sol.java @@ -0,0 +1,8 @@ +class Solution { + public boolean isRectangleOverlap(int[] rec1, int[] rec2) { + return !(rec1[2] <= rec2[0] || + rec1[0] >= rec2[2] || + rec1[3] <= rec2[1] || + rec1[1] >= rec2[3]); + } +} diff --git a/tests/501-1000/836. rectangle-overlap/sol.kt b/tests/501-1000/836. rectangle-overlap/sol.kt new file mode 100644 index 00000000..a8423450 --- /dev/null +++ b/tests/501-1000/836. rectangle-overlap/sol.kt @@ -0,0 +1,8 @@ +class Solution { + fun isRectangleOverlap(rec1: IntArray, rec2: IntArray): Boolean { + return !(rec1[2] <= rec2[0] || + rec1[0] >= rec2[2] || + rec1[3] <= rec2[1] || + rec1[1] >= rec2[3]) + } +} diff --git a/tests/501-1000/836. rectangle-overlap/sol.py b/tests/501-1000/836. rectangle-overlap/sol.py new file mode 100644 index 00000000..3e79a6a7 --- /dev/null +++ b/tests/501-1000/836. rectangle-overlap/sol.py @@ -0,0 +1,8 @@ +class Solution: + def isRectangleOverlap(self, rec1, rec2): + return not ( + rec1[2] <= rec2[0] # rec1 is left of rec2 + or rec1[0] >= rec2[2] # rec1 is right of rec2 + or rec1[3] <= rec2[1] # rec1 is below rec2 + or rec1[1] >= rec2[3] # rec1 is above rec2 + ) diff --git a/tests/501-1000/836. rectangle-overlap/sol.py2 b/tests/501-1000/836. rectangle-overlap/sol.py2 new file mode 100644 index 00000000..48bfe011 --- /dev/null +++ b/tests/501-1000/836. rectangle-overlap/sol.py2 @@ -0,0 +1,13 @@ +class Solution(object): + def isRectangleOverlap(self, rec1, rec2): + """ + :type rec1: List[int] + :type rec2: List[int] + :rtype: bool + """ + return not ( + rec1[2] <= rec2[0] or + rec1[0] >= rec2[2] or + rec1[3] <= rec2[1] or + rec1[1] >= rec2[3] + ) diff --git a/tests/501-1000/836. rectangle-overlap/sol.rb b/tests/501-1000/836. rectangle-overlap/sol.rb new file mode 100644 index 00000000..02f8270d --- /dev/null +++ b/tests/501-1000/836. rectangle-overlap/sol.rb @@ -0,0 +1,9 @@ +# @param {Integer[]} rec1 +# @param {Integer[]} rec2 +# @return {Boolean} +def is_rectangle_overlap(rec1, rec2) + !(rec1[2] <= rec2[0] || + rec1[0] >= rec2[2] || + rec1[3] <= rec2[1] || + rec1[1] >= rec2[3]) +end diff --git a/tests/501-1000/836. rectangle-overlap/sol.rs b/tests/501-1000/836. rectangle-overlap/sol.rs new file mode 100644 index 00000000..55cc9c1b --- /dev/null +++ b/tests/501-1000/836. rectangle-overlap/sol.rs @@ -0,0 +1,8 @@ +impl Solution { + pub fn is_rectangle_overlap(rec1: Vec, rec2: Vec) -> bool { + !(rec1[2] <= rec2[0] || + rec1[0] >= rec2[2] || + rec1[3] <= rec2[1] || + rec1[1] >= rec2[3]) + } +} diff --git a/tests/501-1000/836. rectangle-overlap/sol.swift b/tests/501-1000/836. rectangle-overlap/sol.swift new file mode 100644 index 00000000..2b9f5a57 --- /dev/null +++ b/tests/501-1000/836. rectangle-overlap/sol.swift @@ -0,0 +1,8 @@ +class Solution { + func isRectangleOverlap(_ rec1: [Int], _ rec2: [Int]) -> Bool { + return !(rec1[2] <= rec2[0] || + rec1[0] >= rec2[2] || + rec1[3] <= rec2[1] || + rec1[1] >= rec2[3]) + } +} diff --git a/tests/501-1000/836. rectangle-overlap/sol.ts b/tests/501-1000/836. rectangle-overlap/sol.ts new file mode 100644 index 00000000..b8f067d3 --- /dev/null +++ b/tests/501-1000/836. rectangle-overlap/sol.ts @@ -0,0 +1,8 @@ +function isRectangleOverlap(rec1: number[], rec2: number[]): boolean { + return !( + rec1[2] <= rec2[0] || + rec1[0] >= rec2[2] || + rec1[3] <= rec2[1] || + rec1[1] >= rec2[3] + ); +} diff --git a/tests/501-1000/837. new-21-game/manifest.yaml b/tests/501-1000/837. new-21-game/manifest.yaml new file mode 100644 index 00000000..3a3d6db8 --- /dev/null +++ b/tests/501-1000/837. new-21-game/manifest.yaml @@ -0,0 +1,246 @@ +entry: + id: 837 + title: new-21-game + params: + n: + type: int + k: + type: int + maxPts: + type: int + call: + cpp: "Solution().new21Game({n}, {k}, {maxPts})" + rust: "Solution::new21_game({n}, {k}, {maxPts})" + python3: "Solution().new21Game({n}, {k}, {maxPts})" + python2: "Solution().new21Game({n}, {k}, {maxPts})" + ruby: "new21_game({n}, {k}, {maxPts})" + java: "new Solution().new21Game({n}, {k}, {maxPts})" + csharp: "new Solution().New21Game({n}, {k}, {maxPts})" + kotlin: "Solution().new21Game({n}, {k}, {maxPts})" + go: "new21Game({n}, {k}, {maxPts})" + dart: "Solution().new21Game({n}, {k}, {maxPts})" + swift: "Solution().new21Game({n}, {k}, {maxPts})" + typescript: "new21Game({n}, {k}, {maxPts})" + +judge: + type: "exact" + +limits: + time_ms: 1000 + memory_mb: 256 + +oracle: + python3: + call: "Checker().new21Game(n, k, maxPts, {result})" + checker: | + class Checker: + def new21Game(self, n, k, maxPts, result): + if not isinstance(result, (int, float)): + return False + if k == 0 or n >= k - 1 + maxPts: + expected = 1.0 + else: + dp = [0.0] * maxPts + dp[0] = 1.0 + window_sum = 1.0 + expected = 0.0 + for i in range(1, n + 1): + prob = window_sum / maxPts + if i < k: + window_sum += prob + else: + expected += prob + if i >= maxPts: + window_sum -= dp[i % maxPts] + dp[i % maxPts] = prob + return abs(float(result) - expected) <= 1e-5 + +seed: 837 + +tests: + - name: example-1 + in: + n: 10 + k: 1 + maxPts: 10 + - name: example-2 + in: + n: 6 + k: 1 + maxPts: 10 + - name: example-3 + in: + n: 21 + k: 17 + maxPts: 10 + - name: k-zero + in: + n: 0 + k: 0 + maxPts: 1 + - name: trivial-win + in: + n: 1 + k: 1 + maxPts: 1 + - name: no-need-to-draw + in: + n: 5 + k: 0 + maxPts: 7 + - name: small-boundary-1 + in: + n: 1 + k: 2 + maxPts: 2 + - name: small-boundary-2 + in: + n: 2 + k: 2 + maxPts: 2 + - name: small-boundary-3 + in: + n: 2 + k: 3 + maxPts: 2 + - name: small-boundary-4 + in: + n: 3 + k: 3 + maxPts: 2 + - name: small-boundary-5 + in: + n: 4 + k: 3 + maxPts: 2 + - name: small-boundary-6 + in: + n: 4 + k: 4 + maxPts: 3 + - name: small-boundary-7 + in: + n: 5 + k: 4 + maxPts: 3 + - name: small-boundary-8 + in: + n: 6 + k: 4 + maxPts: 3 + - name: sample-like-1 + in: + n: 7 + k: 5 + maxPts: 3 + - name: sample-like-2 + in: + n: 8 + k: 5 + maxPts: 3 + - name: sample-like-3 + in: + n: 9 + k: 5 + maxPts: 3 + - name: larger-1 + in: + n: 15 + k: 10 + maxPts: 10 + - name: larger-2 + in: + n: 20 + k: 10 + maxPts: 10 + - name: larger-3 + in: + n: 25 + k: 15 + maxPts: 10 + - name: larger-4 + in: + n: 30 + k: 15 + maxPts: 10 + - name: larger-5 + in: + n: 40 + k: 20 + maxPts: 10 + - name: larger-6 + in: + n: 50 + k: 25 + maxPts: 10 + - name: larger-7 + in: + n: 100 + k: 50 + maxPts: 25 + - name: larger-8 + in: + n: 250 + k: 100 + maxPts: 25 + - name: larger-9 + in: + n: 1000 + k: 500 + maxPts: 100 + - name: larger-10 + in: + n: 2000 + k: 1000 + maxPts: 100 + - name: near-max-1 + in: + n: 9999 + k: 9999 + maxPts: 2 + - name: near-max-2 + in: + n: 10000 + k: 9999 + maxPts: 2 + - name: near-max-3 + in: + n: 10000 + k: 5000 + maxPts: 5000 + - name: near-max-4 + in: + n: 10000 + k: 1 + maxPts: 10000 + - name: near-max-5 + in: + n: 10000 + k: 0 + maxPts: 10000 + out: 1.0 + - name: near-max-6 + in: + n: 9990 + k: 8000 + maxPts: 3000 + - name: near-max-7 + in: + n: 8500 + k: 7000 + maxPts: 4000 + - name: near-max-8 + in: + n: 7000 + k: 6500 + maxPts: 3500 + - name: near-max-9 + in: + n: 6000 + k: 5500 + maxPts: 2000 + - name: near-max-10 + in: + n: 5000 + k: 4999 + maxPts: 1000 diff --git a/tests/501-1000/837. new-21-game/sol.cpp b/tests/501-1000/837. new-21-game/sol.cpp new file mode 100644 index 00000000..1e0cdf1f --- /dev/null +++ b/tests/501-1000/837. new-21-game/sol.cpp @@ -0,0 +1,32 @@ +class Solution { +public: + double new21Game(int n, int k, int maxPts) { + if (k == 0 || n >= k - 1 + maxPts) { + return 1.0; + } + + vector dp(maxPts, 0.0); + dp[0] = 1.0; + + double windowSum = 1.0; + double result = 0.0; + + for (int i = 1; i <= n; i++) { + double prob = windowSum / maxPts; + + if (i < k) { + windowSum += prob; + } else { + result += prob; + } + + if (i >= maxPts) { + windowSum -= dp[i % maxPts]; + } + + dp[i % maxPts] = prob; + } + + return result; + } +}; diff --git a/tests/501-1000/837. new-21-game/sol.cs b/tests/501-1000/837. new-21-game/sol.cs new file mode 100644 index 00000000..06f5020d --- /dev/null +++ b/tests/501-1000/837. new-21-game/sol.cs @@ -0,0 +1,31 @@ +public class Solution { + public double New21Game(int n, int k, int maxPts) { + if (k == 0 || n >= k - 1 + maxPts) { + return 1.0; + } + + double[] dp = new double[maxPts]; + dp[0] = 1.0; + + double windowSum = 1.0; + double result = 0.0; + + for (int i = 1; i <= n; i++) { + double prob = windowSum / maxPts; + + if (i < k) { + windowSum += prob; + } else { + result += prob; + } + + if (i >= maxPts) { + windowSum -= dp[i % maxPts]; + } + + dp[i % maxPts] = prob; + } + + return result; + } +} diff --git a/tests/501-1000/837. new-21-game/sol.dart b/tests/501-1000/837. new-21-game/sol.dart new file mode 100644 index 00000000..b5159e97 --- /dev/null +++ b/tests/501-1000/837. new-21-game/sol.dart @@ -0,0 +1,31 @@ +class Solution { + double new21Game(int n, int k, int maxPts) { + if (k == 0 || n >= k - 1 + maxPts) { + return 1.0; + } + + List dp = List.filled(maxPts, 0.0); + dp[0] = 1.0; + + double windowSum = 1.0; + double result = 0.0; + + for (int i = 1; i <= n; i++) { + double prob = windowSum / maxPts; + + if (i < k) { + windowSum += prob; + } else { + result += prob; + } + + if (i >= maxPts) { + windowSum -= dp[i % maxPts]; + } + + dp[i % maxPts] = prob; + } + + return result; + } +} diff --git a/tests/501-1000/837. new-21-game/sol.go b/tests/501-1000/837. new-21-game/sol.go new file mode 100644 index 00000000..f2f6a789 --- /dev/null +++ b/tests/501-1000/837. new-21-game/sol.go @@ -0,0 +1,29 @@ +func new21Game(n int, k int, maxPts int) float64 { + if k == 0 || n >= k-1+maxPts { + return 1.0 + } + + dp := make([]float64, maxPts) + dp[0] = 1.0 + + windowSum := 1.0 + result := 0.0 + + for i := 1; i <= n; i++ { + prob := windowSum / float64(maxPts) + + if i < k { + windowSum += prob + } else { + result += prob + } + + if i >= maxPts { + windowSum -= dp[i%maxPts] + } + + dp[i%maxPts] = prob + } + + return result +} diff --git a/tests/501-1000/837. new-21-game/sol.java b/tests/501-1000/837. new-21-game/sol.java new file mode 100644 index 00000000..36484c90 --- /dev/null +++ b/tests/501-1000/837. new-21-game/sol.java @@ -0,0 +1,31 @@ +class Solution { + public double new21Game(int n, int k, int maxPts) { + if (k == 0 || n >= k - 1 + maxPts) { + return 1.0; + } + + double[] dp = new double[maxPts]; + dp[0] = 1.0; + + double windowSum = 1.0; + double result = 0.0; + + for (int i = 1; i <= n; i++) { + double prob = windowSum / maxPts; + + if (i < k) { + windowSum += prob; + } else { + result += prob; + } + + if (i >= maxPts) { + windowSum -= dp[i % maxPts]; + } + + dp[i % maxPts] = prob; + } + + return result; + } +} diff --git a/tests/501-1000/837. new-21-game/sol.kt b/tests/501-1000/837. new-21-game/sol.kt new file mode 100644 index 00000000..b48c41df --- /dev/null +++ b/tests/501-1000/837. new-21-game/sol.kt @@ -0,0 +1,31 @@ +class Solution { + fun new21Game(n: Int, k: Int, maxPts: Int): Double { + if (k == 0 || n >= k - 1 + maxPts) { + return 1.0 + } + + val dp = DoubleArray(maxPts) + dp[0] = 1.0 + + var windowSum = 1.0 + var result = 0.0 + + for (i in 1..n) { + val prob = windowSum / maxPts + + if (i < k) { + windowSum += prob + } else { + result += prob + } + + if (i >= maxPts) { + windowSum -= dp[i % maxPts] + } + + dp[i % maxPts] = prob + } + + return result + } +} diff --git a/tests/501-1000/837. new-21-game/sol.py b/tests/501-1000/837. new-21-game/sol.py new file mode 100644 index 00000000..939f6bb7 --- /dev/null +++ b/tests/501-1000/837. new-21-game/sol.py @@ -0,0 +1,31 @@ +class Solution(object): + def new21Game(self, n, k, maxPts): + """ + :type n: int + :type k: int + :type maxPts: int + :rtype: float + """ + if k == 0 or n >= k - 1 + maxPts: + return 1.0 + + dp = [0.0] * maxPts + dp[0] = 1.0 + + window_sum = 1.0 + result = 0.0 + + for i in range(1, n + 1): + prob = window_sum / maxPts + + if i < k: + window_sum += prob + else: + result += prob + + if i >= maxPts: + window_sum -= dp[i % maxPts] + + dp[i % maxPts] = prob + + return result diff --git a/tests/501-1000/837. new-21-game/sol.py2 b/tests/501-1000/837. new-21-game/sol.py2 new file mode 100644 index 00000000..939f6bb7 --- /dev/null +++ b/tests/501-1000/837. new-21-game/sol.py2 @@ -0,0 +1,31 @@ +class Solution(object): + def new21Game(self, n, k, maxPts): + """ + :type n: int + :type k: int + :type maxPts: int + :rtype: float + """ + if k == 0 or n >= k - 1 + maxPts: + return 1.0 + + dp = [0.0] * maxPts + dp[0] = 1.0 + + window_sum = 1.0 + result = 0.0 + + for i in range(1, n + 1): + prob = window_sum / maxPts + + if i < k: + window_sum += prob + else: + result += prob + + if i >= maxPts: + window_sum -= dp[i % maxPts] + + dp[i % maxPts] = prob + + return result diff --git a/tests/501-1000/837. new-21-game/sol.rb b/tests/501-1000/837. new-21-game/sol.rb new file mode 100644 index 00000000..0992e91f --- /dev/null +++ b/tests/501-1000/837. new-21-game/sol.rb @@ -0,0 +1,33 @@ +# @param {Integer} n +# @param {Integer} k +# @param {Integer} max_pts +# @return {Float} +def new21_game(n, k, max_pts) + if k == 0 || n >= k - 1 + max_pts + return 1.0 + end + + dp = [0.0] * max_pts + dp[0] = 1.0 + + window_sum = 1.0 + result = 0.0 + + (1..n).each do |i| + prob = window_sum / max_pts + + if i < k + window_sum += prob + else + result += prob + end + + if i >= max_pts + window_sum -= dp[i % max_pts] + end + + dp[i % max_pts] = prob + end + + result +end diff --git a/tests/501-1000/837. new-21-game/sol.rs b/tests/501-1000/837. new-21-game/sol.rs new file mode 100644 index 00000000..26192289 --- /dev/null +++ b/tests/501-1000/837. new-21-game/sol.rs @@ -0,0 +1,35 @@ +impl Solution { + pub fn new21_game(n: i32, k: i32, max_pts: i32) -> f64 { + if k == 0 || n >= k - 1 + max_pts { + return 1.0; + } + + let max_pts = max_pts as usize; + let n = n as usize; + let k = k as usize; + + let mut dp = vec![0.0; max_pts]; + dp[0] = 1.0; + + let mut window_sum = 1.0; + let mut result = 0.0; + + for i in 1..=n { + let prob = window_sum / max_pts as f64; + + if i < k { + window_sum += prob; + } else { + result += prob; + } + + if i >= max_pts { + window_sum -= dp[i % max_pts]; + } + + dp[i % max_pts] = prob; + } + + result + } +} diff --git a/tests/501-1000/837. new-21-game/sol.swift b/tests/501-1000/837. new-21-game/sol.swift new file mode 100644 index 00000000..b618d960 --- /dev/null +++ b/tests/501-1000/837. new-21-game/sol.swift @@ -0,0 +1,31 @@ +class Solution { + func new21Game(_ n: Int, _ k: Int, _ maxPts: Int) -> Double { + if k == 0 || n >= k - 1 + maxPts { + return 1.0 + } + + var dp = [Double](repeating: 0.0, count: maxPts) + dp[0] = 1.0 + + var windowSum = 1.0 + var result = 0.0 + + for i in 1...n { + let prob = windowSum / Double(maxPts) + + if i < k { + windowSum += prob + } else { + result += prob + } + + if i >= maxPts { + windowSum -= dp[i % maxPts] + } + + dp[i % maxPts] = prob + } + + return result + } +} diff --git a/tests/501-1000/837. new-21-game/sol.ts b/tests/501-1000/837. new-21-game/sol.ts new file mode 100644 index 00000000..15ee34d4 --- /dev/null +++ b/tests/501-1000/837. new-21-game/sol.ts @@ -0,0 +1,29 @@ +function new21Game(n: number, k: number, maxPts: number): number { + if (k === 0 || n >= k - 1 + maxPts) { + return 1.0; + } + + const dp: number[] = new Array(maxPts).fill(0.0); + dp[0] = 1.0; + + let windowSum = 1.0; + let result = 0.0; + + for (let i = 1; i <= n; i++) { + const prob = windowSum / maxPts; + + if (i < k) { + windowSum += prob; + } else { + result += prob; + } + + if (i >= maxPts) { + windowSum -= dp[i % maxPts]; + } + + dp[i % maxPts] = prob; + } + + return result; +} diff --git a/tests/501-1000/838. push-dominoes/manifest.yaml b/tests/501-1000/838. push-dominoes/manifest.yaml new file mode 100644 index 00000000..33d8f00c --- /dev/null +++ b/tests/501-1000/838. push-dominoes/manifest.yaml @@ -0,0 +1,189 @@ +entry: + id: 838 + title: push-dominoes + params: + dominoes: + type: string + call: + cpp: Solution().pushDominoes({dominoes}) + rust: Solution::push_dominoes({dominoes}) + python3: Solution().pushDominoes({dominoes}) + python2: Solution().pushDominoes({dominoes}) + ruby: push_dominoes({dominoes}) + java: new Solution().pushDominoes({dominoes}) + csharp: new Solution().PushDominoes({dominoes}) + kotlin: Solution().pushDominoes({dominoes}) + go: pushDominoes({dominoes}) + dart: Solution().pushDominoes({dominoes}) + swift: Solution().pushDominoes({dominoes}) + typescript: pushDominoes({dominoes}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: | + class Checker: + def check(self, result): + return True +seed: 838 +tests: + - name: example-1 + in: + dominoes: RR.L + out: RR.L + - name: example-2 + in: + dominoes: .L.R...LR..L.. + out: LL.RR.LLRRLL.. + - name: single-dot + in: + dominoes: . + out: . + - name: single-l + in: + dominoes: L + out: L + - name: single-r + in: + dominoes: R + out: R + - name: all-dots + in: + dominoes: "....." + out: "....." + - name: even-gap + in: + dominoes: R....L + out: RRRLLL + - name: odd-gap + in: + dominoes: R.....L + out: RRR.LLL + - name: left-boundary + in: + dominoes: L... + out: L... + - name: right-boundary + in: + dominoes: "...R" + out: "...R" + - name: center-balance + in: + dominoes: "...R...L..." + out: "...RR.LL..." + - name: multiple-segments + in: + dominoes: R..L..R..L + out: RRLL..RRLL + - name: alternating + in: + dominoes: R.L.R.L. + out: R.L.R.L. + - name: mixed-1 + in: + dominoes: .R...L.R...L. + out: .RR.LL.RR.LL. + - name: mixed-2 + in: + dominoes: ..R..R..L..L.. + out: ..RRRRRLLLLL.. + - name: all-left + in: + dominoes: "LLLLL" + out: "LLLLL" + - name: all-right + in: + dominoes: "RRRRR" + out: "RRRRR" + - name: dot_then_left + in: + dominoes: ..L + out: LLL + - name: right_then_dots + in: + dominoes: R.. + out: RRR + - name: left_then_dots + in: + dominoes: L.. + out: L.. + - name: right_left_small + in: + dominoes: RL + out: RL + - name: right_left_with_gap + in: + dominoes: R.L + out: R.L + - name: right_right + in: + dominoes: R..R + out: RRRR + - name: left_left + in: + dominoes: L..L + out: LLLL + - name: dot_chain_between + in: + dominoes: ..R..L.. + out: ..RRLL.. + - name: right_only_large + in: + dominoes: R...R + out: RRRRR + - name: left_only_large + in: + dominoes: L...L + out: LLLLL + - name: centered_pair + in: + dominoes: ..R...L.. + out: ..RR.LL.. + - name: shifted_pair + in: + dominoes: R..L...R + out: RRLL...R + - name: repeated_pattern + in: + dominoes: .L..R..L. + out: LL..RRLL. + - name: one_sided_chain + in: + dominoes: .R..L...R. + out: .RRLL...RR + - name: trailing_right + in: + dominoes: ....R + out: ....R + - name: leading_left + in: + dominoes: L....R + out: L....R + - name: wide_gap + in: + dominoes: R....L....R + out: RRRLLL....R + - name: separated_blocks + in: + dominoes: ...R..L..R... + out: ...RRLL..RRRR + - name: dense_mixed + in: + dominoes: .R..R..L..L. + out: .RRRRRLLLLL. + - name: long_twist + in: + dominoes: R...L...R...L + out: RR.LL...RR.LL + - name: empty_middle + in: + dominoes: "...." + out: "...." + - name: staggered_chain + in: + dominoes: R...L..R.L.. + out: RR.LL..R.L.. diff --git a/tests/501-1000/838. push-dominoes/sol.cpp b/tests/501-1000/838. push-dominoes/sol.cpp new file mode 100644 index 00000000..3a04b6c5 --- /dev/null +++ b/tests/501-1000/838. push-dominoes/sol.cpp @@ -0,0 +1,24 @@ +class Solution { +public: + string pushDominoes(string dominoes) { + string s = "L" + dominoes + "R"; + string res = ""; + int prev = 0; + for (int curr = 1; curr < s.length(); curr++) { + if (s[curr] == '.') continue; + int span = curr - prev - 1; + if (prev > 0) res += s[prev]; + if (s[prev] == s[curr]) { + res += string(span, s[prev]); + } else if (s[prev] == 'L' && s[curr] == 'R') { + res += string(span, '.'); + } else { + res += string(span / 2, 'R'); + if (span % 2 == 1) res += '.'; + res += string(span / 2, 'L'); + } + prev = curr; + } + return res; + } +}; diff --git a/tests/501-1000/838. push-dominoes/sol.cs b/tests/501-1000/838. push-dominoes/sol.cs new file mode 100644 index 00000000..ee938c24 --- /dev/null +++ b/tests/501-1000/838. push-dominoes/sol.cs @@ -0,0 +1,23 @@ +public class Solution { + public string PushDominoes(string dominoes) { + string s = "L" + dominoes + "R"; + System.Text.StringBuilder res = new System.Text.StringBuilder(); + int prev = 0; + for (int curr = 1; curr < s.Length; curr++) { + if (s[curr] == '.') continue; + int span = curr - prev - 1; + if (prev > 0) res.Append(s[prev]); + if (s[prev] == s[curr]) { + res.Append(new string(s[prev], span)); + } else if (s[prev] == 'L' && s[curr] == 'R') { + res.Append(new string('.', span)); + } else { + res.Append(new string('R', span / 2)); + if (span % 2 == 1) res.Append('.'); + res.Append(new string('L', span / 2)); + } + prev = curr; + } + return res.ToString(); + } +} diff --git a/tests/501-1000/838. push-dominoes/sol.dart b/tests/501-1000/838. push-dominoes/sol.dart new file mode 100644 index 00000000..1f100006 --- /dev/null +++ b/tests/501-1000/838. push-dominoes/sol.dart @@ -0,0 +1,23 @@ +class Solution { + String pushDominoes(String dominoes) { + String s = "L" + dominoes + "R"; + StringBuffer res = StringBuffer(); + int prev = 0; + for (int curr = 1; curr < s.length; curr++) { + if (s[curr] == '.') continue; + int span = curr - prev - 1; + if (prev > 0) res.write(s[prev]); + if (s[prev] == s[curr]) { + res.write(s[prev] * span); + } else if (s[prev] == 'L' && s[curr] == 'R') { + res.write('.' * span); + } else { + res.write('R' * (span ~/ 2)); + if (span % 2 == 1) res.write('.'); + res.write('L' * (span ~/ 2)); + } + prev = curr; + } + return res.toString(); + } +} diff --git a/tests/501-1000/838. push-dominoes/sol.go b/tests/501-1000/838. push-dominoes/sol.go new file mode 100644 index 00000000..11181579 --- /dev/null +++ b/tests/501-1000/838. push-dominoes/sol.go @@ -0,0 +1,35 @@ +func pushDominoes(dominoes string) string { + s := "L" + dominoes + "R" + var res []byte + prev := 0 + for curr := 1; curr < len(s); curr++ { + if s[curr] == '.' { + continue + } + span := curr - prev - 1 + if prev > 0 { + res = append(res, s[prev]) + } + if s[prev] == s[curr] { + for i := 0; i < span; i++ { + res = append(res, s[prev]) + } + } else if s[prev] == 'L' && s[curr] == 'R' { + for i := 0; i < span; i++ { + res = append(res, '.') + } + } else { + for i := 0; i < span/2; i++ { + res = append(res, 'R') + } + if span%2 == 1 { + res = append(res, '.') + } + for i := 0; i < span/2; i++ { + res = append(res, 'L') + } + } + prev = curr + } + return string(res) +} diff --git a/tests/501-1000/838. push-dominoes/sol.java b/tests/501-1000/838. push-dominoes/sol.java new file mode 100644 index 00000000..813f0a9b --- /dev/null +++ b/tests/501-1000/838. push-dominoes/sol.java @@ -0,0 +1,23 @@ +class Solution { + public String pushDominoes(String dominoes) { + String s = "L" + dominoes + "R"; + StringBuilder res = new StringBuilder(); + int prev = 0; + for (int curr = 1; curr < s.length(); curr++) { + if (s.charAt(curr) == '.') continue; + int span = curr - prev - 1; + if (prev > 0) res.append(s.charAt(prev)); + if (s.charAt(prev) == s.charAt(curr)) { + for (int i = 0; i < span; i++) res.append(s.charAt(prev)); + } else if (s.charAt(prev) == 'L' && s.charAt(curr) == 'R') { + for (int i = 0; i < span; i++) res.append('.'); + } else { + for (int i = 0; i < span / 2; i++) res.append('R'); + if (span % 2 == 1) res.append('.'); + for (int i = 0; i < span / 2; i++) res.append('L'); + } + prev = curr; + } + return res.toString(); + } +} diff --git a/tests/501-1000/838. push-dominoes/sol.kt b/tests/501-1000/838. push-dominoes/sol.kt new file mode 100644 index 00000000..71520a11 --- /dev/null +++ b/tests/501-1000/838. push-dominoes/sol.kt @@ -0,0 +1,23 @@ +class Solution { + fun pushDominoes(dominoes: String): String { + val s = "L" + dominoes + "R" + val res = StringBuilder() + var prev = 0 + for (curr in 1 until s.length) { + if (s[curr] == '.') continue + val span = curr - prev - 1 + if (prev > 0) res.append(s[prev]) + if (s[prev] == s[curr]) { + repeat(span) { res.append(s[prev]) } + } else if (s[prev] == 'L' && s[curr] == 'R') { + repeat(span) { res.append('.') } + } else { + repeat(span / 2) { res.append('R') } + if (span % 2 == 1) res.append('.') + repeat(span / 2) { res.append('L') } + } + prev = curr + } + return res.toString() + } +} diff --git a/tests/501-1000/838. push-dominoes/sol.py b/tests/501-1000/838. push-dominoes/sol.py new file mode 100644 index 00000000..c04f793d --- /dev/null +++ b/tests/501-1000/838. push-dominoes/sol.py @@ -0,0 +1,19 @@ +class Solution(object): + def pushDominoes(self, dominoes): + s = "L" + dominoes + "R" + res = "" + prev = 0 + for curr in range(1, len(s)): + if s[curr] == ".": + continue + span = curr - prev - 1 + if prev > 0: + res += s[prev] + if s[prev] == s[curr]: + res += s[prev] * span + elif s[prev] == "L" and s[curr] == "R": + res += "." * span + else: + res += "R" * (span // 2) + "." * (span % 2) + "L" * (span // 2) + prev = curr + return res diff --git a/tests/501-1000/838. push-dominoes/sol.py2 b/tests/501-1000/838. push-dominoes/sol.py2 new file mode 100644 index 00000000..9b382f1d --- /dev/null +++ b/tests/501-1000/838. push-dominoes/sol.py2 @@ -0,0 +1,19 @@ +class Solution(object): + def pushDominoes(self, dominoes): + s = 'L' + dominoes + 'R' + res = '' + prev = 0 + for curr in range(1, len(s)): + if s[curr] == '.': + continue + span = curr - prev - 1 + if prev > 0: + res += s[prev] + if s[prev] == s[curr]: + res += s[prev] * span + elif s[prev] == 'L' and s[curr] == 'R': + res += '.' * span + else: + res += 'R' * (span // 2) + '.' * (span % 2) + 'L' * (span // 2) + prev = curr + return res diff --git a/tests/501-1000/838. push-dominoes/sol.rb b/tests/501-1000/838. push-dominoes/sol.rb new file mode 100644 index 00000000..2d7d4d2c --- /dev/null +++ b/tests/501-1000/838. push-dominoes/sol.rb @@ -0,0 +1,21 @@ +# @param {String} dominoes +# @return {String} +def push_dominoes(dominoes) + s = 'L' + dominoes + 'R' + res = '' + prev = 0 + (1...s.length).each do |curr| + next if s[curr] == '.' + span = curr - prev - 1 + res += s[prev] if prev > 0 + if s[prev] == s[curr] + res += s[prev] * span + elsif s[prev] == 'L' && s[curr] == 'R' + res += '.' * span + else + res += 'R' * (span / 2) + '.' * (span % 2) + 'L' * (span / 2) + end + prev = curr + end + res +end diff --git a/tests/501-1000/838. push-dominoes/sol.rs b/tests/501-1000/838. push-dominoes/sol.rs new file mode 100644 index 00000000..3ef338d0 --- /dev/null +++ b/tests/501-1000/838. push-dominoes/sol.rs @@ -0,0 +1,38 @@ +impl Solution { + pub fn push_dominoes(dominoes: String) -> String { + let s = format!("L{}R", dominoes); + let mut res = String::new(); + let mut prev = 0; + let chars: Vec = s.chars().collect(); + for curr in 1..chars.len() { + if chars[curr] == '.' { + continue; + } + let span = curr - prev - 1; + if prev > 0 { + res.push(chars[prev]); + } + if chars[prev] == chars[curr] { + for _ in 0..span { + res.push(chars[prev]); + } + } else if chars[prev] == 'L' && chars[curr] == 'R' { + for _ in 0..span { + res.push('.'); + } + } else { + for _ in 0..span / 2 { + res.push('R'); + } + if span % 2 == 1 { + res.push('.'); + } + for _ in 0..span / 2 { + res.push('L'); + } + } + prev = curr; + } + res + } +} diff --git a/tests/501-1000/838. push-dominoes/sol.swift b/tests/501-1000/838. push-dominoes/sol.swift new file mode 100644 index 00000000..f936c68c --- /dev/null +++ b/tests/501-1000/838. push-dominoes/sol.swift @@ -0,0 +1,24 @@ +class Solution { + func pushDominoes(_ dominoes: String) -> String { + let s = "L" + dominoes + "R" + var res = "" + var prev = 0 + let chars = Array(s) + for curr in 1.. 0 { res.append(chars[prev]) } + if chars[prev] == chars[curr] { + res += String(repeating: chars[prev], count: span) + } else if chars[prev] == "L" && chars[curr] == "R" { + res += String(repeating: ".", count: span) + } else { + res += String(repeating: "R", count: span / 2) + if span % 2 == 1 { res.append(".") } + res += String(repeating: "L", count: span / 2) + } + prev = curr + } + return res + } +} diff --git a/tests/501-1000/838. push-dominoes/sol.ts b/tests/501-1000/838. push-dominoes/sol.ts new file mode 100644 index 00000000..6388907d --- /dev/null +++ b/tests/501-1000/838. push-dominoes/sol.ts @@ -0,0 +1,21 @@ +function pushDominoes(dominoes: string): string { + const s = "L" + dominoes + "R"; + let res = ""; + let prev = 0; + for (let curr = 1; curr < s.length; curr++) { + if (s[curr] === ".") continue; + const span = curr - prev - 1; + if (prev > 0) res += s[prev]; + if (s[prev] === s[curr]) { + res += s[prev].repeat(span); + } else if (s[prev] === "L" && s[curr] === "R") { + res += ".".repeat(span); + } else { + res += "R".repeat(Math.floor(span / 2)); + if (span % 2 === 1) res += "."; + res += "L".repeat(Math.floor(span / 2)); + } + prev = curr; + } + return res; +} diff --git a/tests/501-1000/839. similar-string-groups/manifest.yaml b/tests/501-1000/839. similar-string-groups/manifest.yaml new file mode 100644 index 00000000..0bdce510 --- /dev/null +++ b/tests/501-1000/839. similar-string-groups/manifest.yaml @@ -0,0 +1,360 @@ +entry: + id: 839 + title: similar-string-groups + params: + strs: + type: array + items: + type: string + call: + cpp: "Solution().numSimilarGroups({strs})" + rust: "Solution::num_similar_groups({strs})" + python3: "Solution().numSimilarGroups({strs})" + python2: "Solution().numSimilarGroups({strs})" + ruby: "num_similar_groups({strs})" + java: "new Solution().numSimilarGroups({strs})" + csharp: "new Solution().NumSimilarGroups({strs})" + kotlin: "Solution().numSimilarGroups({strs})" + go: "numSimilarGroups({strs})" + dart: "Solution().numSimilarGroups({strs})" + swift: "Solution().numSimilarGroups({strs})" + typescript: "numSimilarGroups({strs})" + +judge: + type: "exact" + +limits: + time_ms: 2000 + memory_mb: 256 + +oracle: + python3: + call: "Checker().numSimilarGroups(strs, {result})" + checker: | + class Checker: + def numSimilarGroups(self, strs, result): + if not isinstance(result, int): + return False + n = len(strs) + parent = list(range(n)) + + def find(x): + while parent[x] != x: + parent[x] = parent[parent[x]] + x = parent[x] + return x + + def union(a, b): + ra, rb = find(a), find(b) + if ra != rb: + parent[rb] = ra + + for i in range(n): + for j in range(i + 1, n): + diff = 0 + for a, b in zip(strs[i], strs[j]): + if a != b: + diff += 1 + if diff > 2: + break + if diff == 0 or diff == 2: + union(i, j) + expected = len({find(i) for i in range(n)}) + return result == expected + +seed: 839 + +tests: + - name: example-1 + in: + strs: + - tars + - rats + - arts + - star + out: 2 + - name: example-2 + in: + strs: + - omv + - ovm + out: 1 + - name: single-word + in: + strs: + - abc + out: 1 + - name: two-identical + in: + strs: + - aaa + - aaa + out: 1 + - name: one-swap + in: + strs: + - ab + - ba + out: 1 + - name: no-similarity + in: + strs: + - abcd + - badc + - cdab + out: 3 + - name: chain-of-three + in: + strs: + - abcd + - abdc + - acbd + out: 1 + - name: two-groups + in: + strs: + - abc + - acb + - xyz + - xzy + out: 2 + - name: duplicate-heavy + in: + strs: + - abc + - abc + - bac + - bca + out: 1 + - name: same-letter + in: + strs: + - aaaa + - aaaa + - aaaa + out: 1 + - name: four-cycle-1 + in: + strs: + - tars + - star + - rats + - arts + out: 2 + - name: four-cycle-2 + in: + strs: + - abcd + - abdc + - acbd + - bacd + out: 1 + - name: four-cycle-3 + in: + strs: + - aabb + - abab + - abba + - baab + out: 1 + - name: disconnected-pairs + in: + strs: + - abcd + - abdc + - wxyz + - wxzy + out: 2 + - name: disconnected-triples + in: + strs: + - abcde + - abced + - edcba + - ecdba + out: 2 + - name: long-letters-1 + in: + strs: + - abcdefghij + - abcdfeghij + - abcfdeghij + out: 1 + - name: long-letters-2 + in: + strs: + - qwerty + - qwerty + - qewrty + - weqrty + out: 1 + - name: long-letters-3 + in: + strs: + - abcdef + - abcfed + - fedcba + - fedcab + out: 2 + - name: long-letters-4 + in: + strs: + - aabc + - abac + - baac + - baca + out: 1 + - name: long-letters-5 + in: + strs: + - nopqrs + - nopqsr + - npoqrs + - onpqrs + out: 1 + - name: long-letters-6 + in: + strs: + - abcdefghijkl + - abcdefghijlk + - abcdefghikjl + - abcdefghijkl + out: 1 + - name: group-count-7 + in: + strs: + - abc + - acb + - bac + - bca + - cab + - cba + out: 1 + - name: group-count-8 + in: + strs: + - abcd + - badc + - cdab + - dcba + out: 4 + - name: group-count-9 + in: + strs: + - abcd + - abdc + - bacd + - badc + out: 1 + - name: group-count-10 + in: + strs: + - abcdef + - abcfde + - abcdef + - abcfed + out: 1 + - name: group-count-11 + in: + strs: + - kites + - skite + - kites + - kiets + out: 2 + - name: group-count-12 + in: + strs: + - listen + - silent + - enlist + - inlets + out: 4 + - name: group-count-13 + in: + strs: + - aaabbb + - aababb + - abaabb + - baaabb + out: 1 + - name: group-count-14 + in: + strs: + - abcdefg + - abcdgfe + - agbcdef + out: 2 + - name: group-count-15 + in: + strs: + - xyzabc + - xyazbc + - xyyabc + - zxyabc + out: 1 + - name: group-count-16 + in: + strs: + - abcdefgh + - abcdefhg + - abcdegfh + - abcedfgh + out: 1 + - name: group-count-17 + in: + strs: + - aaaabbbb + - aaababbb + - abababab + - bbbbaaaa + out: 2 + - name: group-count-18 + in: + strs: + - zyxw + - zxyw + - yzxw + - yxzw + out: 1 + - name: group-count-19 + in: + strs: + - a + - a + - a + - a + out: 1 + - name: group-count-20 + in: + strs: + - ab + - ba + - ab + - ba + out: 1 + - name: group-count-21 + in: + strs: + - abcde + - acbde + - bacde + - bcade + - cabde + out: 1 + - name: group-count-22 + in: + strs: + - abcde + - abced + - abdce + - acbde + out: 1 + - name: group-count-23 + in: + strs: + - abcdefghij + - abcedfghij + - abcdefghji + - abcdefgihj + out: 1 diff --git a/tests/501-1000/839. similar-string-groups/sol.cpp b/tests/501-1000/839. similar-string-groups/sol.cpp new file mode 100644 index 00000000..0e1609a6 --- /dev/null +++ b/tests/501-1000/839. similar-string-groups/sol.cpp @@ -0,0 +1,50 @@ +class Solution { +public: + int numSimilarGroups(vector& strs) { + int n = strs.size(); + + auto checkSimilarity = [](const string& str1, const string& str2) -> bool { + int diff = 0; + for (int i = 0; i < str1.length(); i++) { + if (str1[i] != str2[i]) { + diff++; + } + } + return diff == 0 || diff == 2; + }; + + vector> matrix(n); + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + if (checkSimilarity(strs[i], strs[j])) { + matrix[i].push_back(j); + matrix[j].push_back(i); + } + } + } + + int count = 0; + vector visited(n, false); + + function dfs = [&](int node) { + if (visited[node]) { + return; + } + visited[node] = true; + for (int nei : matrix[node]) { + if (!visited[nei]) { + dfs(nei); + } + } + }; + + for (int start = 0; start < n; start++) { + if (!visited[start]) { + dfs(start); + count++; + } + } + + return count; + } +}; diff --git a/tests/501-1000/839. similar-string-groups/sol.cs b/tests/501-1000/839. similar-string-groups/sol.cs new file mode 100644 index 00000000..27fa59ad --- /dev/null +++ b/tests/501-1000/839. similar-string-groups/sol.cs @@ -0,0 +1,51 @@ +public class Solution { + private bool CheckSimilarity(string str1, string str2) { + int diff = 0; + for (int i = 0; i < str1.Length; i++) { + if (str1[i] != str2[i]) { + diff++; + } + } + return diff == 0 || diff == 2; + } + + private void Dfs(int node, List[] matrix, bool[] visited) { + if (visited[node]) { + return; + } + visited[node] = true; + foreach (int nei in matrix[node]) { + if (!visited[nei]) { + Dfs(nei, matrix, visited); + } + } + } + + public int NumSimilarGroups(string[] strs) { + int n = strs.Length; + List[] matrix = new List[n]; + for (int i = 0; i < n; i++) { + matrix[i] = new List(); + } + + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + if (CheckSimilarity(strs[i], strs[j])) { + matrix[i].Add(j); + matrix[j].Add(i); + } + } + } + + int count = 0; + bool[] visited = new bool[n]; + for (int start = 0; start < n; start++) { + if (!visited[start]) { + Dfs(start, matrix, visited); + count++; + } + } + + return count; + } +} diff --git a/tests/501-1000/839. similar-string-groups/sol.dart b/tests/501-1000/839. similar-string-groups/sol.dart new file mode 100644 index 00000000..ff357f76 --- /dev/null +++ b/tests/501-1000/839. similar-string-groups/sol.dart @@ -0,0 +1,48 @@ +class Solution { + bool _checkSimilarity(String str1, String str2) { + int diff = 0; + for (int i = 0; i < str1.length; i++) { + if (str1[i] != str2[i]) { + diff++; + } + } + return diff == 0 || diff == 2; + } + + void _dfs(int node, List> matrix, Set visited) { + if (visited.contains(node)) { + return; + } + visited.add(node); + for (int nei in matrix[node]) { + if (!visited.contains(nei)) { + _dfs(nei, matrix, visited); + } + } + } + + int numSimilarGroups(List strs) { + int n = strs.length; + List> matrix = List.generate(n, (_) => []); + + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + if (_checkSimilarity(strs[i], strs[j])) { + matrix[i].add(j); + matrix[j].add(i); + } + } + } + + int count = 0; + Set visited = {}; + for (int start = 0; start < n; start++) { + if (!visited.contains(start)) { + _dfs(start, matrix, visited); + count++; + } + } + + return count; + } +} diff --git a/tests/501-1000/839. similar-string-groups/sol.go b/tests/501-1000/839. similar-string-groups/sol.go new file mode 100644 index 00000000..2ccf6841 --- /dev/null +++ b/tests/501-1000/839. similar-string-groups/sol.go @@ -0,0 +1,51 @@ +func numSimilarGroups(strs []string) int { + n := len(strs) + + checkSimilarity := func(str1, str2 string) bool { + diff := 0 + for i := 0; i < len(str1); i++ { + if str1[i] != str2[i] { + diff++ + } + } + return diff == 0 || diff == 2 + } + + matrix := make([][]int, n) + for i := 0; i < n; i++ { + matrix[i] = make([]int, 0) + } + + for i := 0; i < n; i++ { + for j := 0; j < n; j++ { + if checkSimilarity(strs[i], strs[j]) { + matrix[i] = append(matrix[i], j) + matrix[j] = append(matrix[j], i) + } + } + } + + visited := make([]bool, n) + var dfs func(int) + dfs = func(node int) { + if visited[node] { + return + } + visited[node] = true + for _, nei := range matrix[node] { + if !visited[nei] { + dfs(nei) + } + } + } + + count := 0 + for start := 0; start < n; start++ { + if !visited[start] { + dfs(start) + count++ + } + } + + return count +} diff --git a/tests/501-1000/839. similar-string-groups/sol.java b/tests/501-1000/839. similar-string-groups/sol.java new file mode 100644 index 00000000..843636a4 --- /dev/null +++ b/tests/501-1000/839. similar-string-groups/sol.java @@ -0,0 +1,51 @@ +class Solution { + private boolean checkSimilarity(String str1, String str2) { + int diff = 0; + for (int i = 0; i < str1.length(); i++) { + if (str1.charAt(i) != str2.charAt(i)) { + diff++; + } + } + return diff == 0 || diff == 2; + } + + private void dfs(int node, List> matrix, boolean[] visited) { + if (visited[node]) { + return; + } + visited[node] = true; + for (int nei : matrix.get(node)) { + if (!visited[nei]) { + dfs(nei, matrix, visited); + } + } + } + + public int numSimilarGroups(String[] strs) { + int n = strs.length; + List> matrix = new ArrayList<>(); + for (int i = 0; i < n; i++) { + matrix.add(new ArrayList<>()); + } + + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + if (checkSimilarity(strs[i], strs[j])) { + matrix.get(i).add(j); + matrix.get(j).add(i); + } + } + } + + int count = 0; + boolean[] visited = new boolean[n]; + for (int start = 0; start < n; start++) { + if (!visited[start]) { + dfs(start, matrix, visited); + count++; + } + } + + return count; + } +} diff --git a/tests/501-1000/839. similar-string-groups/sol.kt b/tests/501-1000/839. similar-string-groups/sol.kt new file mode 100644 index 00000000..c9b7ea78 --- /dev/null +++ b/tests/501-1000/839. similar-string-groups/sol.kt @@ -0,0 +1,48 @@ +class Solution { + private fun checkSimilarity(str1: String, str2: String): Boolean { + var diff = 0 + for (i in str1.indices) { + if (str1[i] != str2[i]) { + diff++ + } + } + return diff == 0 || diff == 2 + } + + private fun dfs(node: Int, matrix: List>, visited: BooleanArray) { + if (visited[node]) { + return + } + visited[node] = true + for (nei in matrix[node]) { + if (!visited[nei]) { + dfs(nei, matrix, visited) + } + } + } + + fun numSimilarGroups(strs: Array): Int { + val n = strs.size + val matrix = List(n) { mutableListOf() } + + for (i in 0 until n) { + for (j in 0 until n) { + if (checkSimilarity(strs[i], strs[j])) { + matrix[i].add(j) + matrix[j].add(i) + } + } + } + + var count = 0 + val visited = BooleanArray(n) + for (start in 0 until n) { + if (!visited[start]) { + dfs(start, matrix, visited) + count++ + } + } + + return count + } +} diff --git a/tests/501-1000/839. similar-string-groups/sol.py b/tests/501-1000/839. similar-string-groups/sol.py new file mode 100644 index 00000000..c73a6214 --- /dev/null +++ b/tests/501-1000/839. similar-string-groups/sol.py @@ -0,0 +1,36 @@ +class Solution: + def numSimilarGroups(self, strs: List[str]) -> int: + def check_similarity(str1, str2): + diff = 0 + for i in range(len(str1)): + if str1[i] != str2[i]: + diff += 1 + + return diff == 0 or diff == 2 + + def dfs(node): + if node in visited: + return + visited.add(node) + + for nei in matrix.get(node, []): + if nei not in visited: + dfs(nei) + + n = len(strs) + matrix = {i: [] for i in range(n)} + + for i in range(n): + for j in range(n): + if check_similarity(strs[i], strs[j]): + matrix[i].append(j) + matrix[j].append(i) + + count = 0 + visited = set() + for start in range(n): + if start not in visited: + dfs(start) + count += 1 + + return count diff --git a/tests/501-1000/839. similar-string-groups/sol.py2 b/tests/501-1000/839. similar-string-groups/sol.py2 new file mode 100644 index 00000000..6ad74ee5 --- /dev/null +++ b/tests/501-1000/839. similar-string-groups/sol.py2 @@ -0,0 +1,38 @@ +class Solution(object): + def numSimilarGroups(self, strs): + """ + :type strs: List[str] + :rtype: int + """ + def check_similarity(str1, str2): + diff = 0 + for i in range(len(str1)): + if str1[i] != str2[i]: + diff += 1 + return diff == 0 or diff == 2 + + def dfs(node): + if node in visited: + return + visited.add(node) + for nei in matrix.get(node, []): + if nei not in visited: + dfs(nei) + + n = len(strs) + matrix = {i: [] for i in range(n)} + + for i in range(n): + for j in range(n): + if check_similarity(strs[i], strs[j]): + matrix[i].append(j) + matrix[j].append(i) + + count = 0 + visited = set() + for start in range(n): + if start not in visited: + dfs(start) + count += 1 + + return count diff --git a/tests/501-1000/839. similar-string-groups/sol.rb b/tests/501-1000/839. similar-string-groups/sol.rb new file mode 100644 index 00000000..d4010d76 --- /dev/null +++ b/tests/501-1000/839. similar-string-groups/sol.rb @@ -0,0 +1,42 @@ +# @param {String[]} strs +# @return {Integer} +def num_similar_groups(strs) + def check_similarity(str1, str2) + diff = 0 + str1.length.times do |i| + diff += 1 if str1[i] != str2[i] + end + diff == 0 || diff == 2 + end + + def dfs(node, matrix, visited) + return if visited.include?(node) + visited.add(node) + (matrix[node] || []).each do |nei| + dfs(nei, matrix, visited) unless visited.include?(nei) + end + end + + n = strs.length + matrix = Hash.new { |h, k| h[k] = [] } + + (0...n).each do |i| + (0...n).each do |j| + if check_similarity(strs[i], strs[j]) + matrix[i] << j + matrix[j] << i + end + end + end + + count = 0 + visited = Set.new + (0...n).each do |start| + unless visited.include?(start) + dfs(start, matrix, visited) + count += 1 + end + end + + count +end diff --git a/tests/501-1000/839. similar-string-groups/sol.rs b/tests/501-1000/839. similar-string-groups/sol.rs new file mode 100644 index 00000000..45a1ae71 --- /dev/null +++ b/tests/501-1000/839. similar-string-groups/sol.rs @@ -0,0 +1,50 @@ +impl Solution { + pub fn num_similar_groups(strs: Vec) -> i32 { + fn check_similarity(str1: &str, str2: &str) -> bool { + let mut diff = 0; + let bytes1 = str1.as_bytes(); + let bytes2 = str2.as_bytes(); + for i in 0..bytes1.len() { + if bytes1[i] != bytes2[i] { + diff += 1; + } + } + diff == 0 || diff == 2 + } + + fn dfs(node: usize, matrix: &Vec>, visited: &mut Vec) { + if visited[node] { + return; + } + visited[node] = true; + for &nei in &matrix[node] { + if !visited[nei] { + dfs(nei, matrix, visited); + } + } + } + + let n = strs.len(); + let mut matrix = vec![vec![]; n]; + + for i in 0..n { + for j in 0..n { + if check_similarity(&strs[i], &strs[j]) { + matrix[i].push(j); + matrix[j].push(i); + } + } + } + + let mut count = 0; + let mut visited = vec![false; n]; + for start in 0..n { + if !visited[start] { + dfs(start, &matrix, &mut visited); + count += 1; + } + } + + count + } +} diff --git a/tests/501-1000/839. similar-string-groups/sol.swift b/tests/501-1000/839. similar-string-groups/sol.swift new file mode 100644 index 00000000..a321f5d5 --- /dev/null +++ b/tests/501-1000/839. similar-string-groups/sol.swift @@ -0,0 +1,50 @@ +class Solution { + private func checkSimilarity(_ str1: String, _ str2: String) -> Bool { + var diff = 0 + let arr1 = Array(str1) + let arr2 = Array(str2) + for i in 0..) { + if visited.contains(node) { + return + } + visited.insert(node) + for nei in matrix[node] { + if !visited.contains(nei) { + dfs(nei, matrix, &visited) + } + } + } + + func numSimilarGroups(_ strs: [String]) -> Int { + let n = strs.count + var matrix = [[Int]](repeating: [], count: n) + + for i in 0..() + for start in 0.. { + let diff = 0; + for (let i = 0; i < str1.length; i++) { + if (str1[i] !== str2[i]) { + diff++; + } + } + return diff === 0 || diff === 2; + }; + + const dfs = ( + node: number, + matrix: number[][], + visited: Set, + ): void => { + if (visited.has(node)) { + return; + } + visited.add(node); + for (const nei of matrix[node]) { + if (!visited.has(nei)) { + dfs(nei, matrix, visited); + } + } + }; + + const n = strs.length; + const matrix: number[][] = Array.from({ length: n }, () => []); + + for (let i = 0; i < n; i++) { + for (let j = 0; j < n; j++) { + if (checkSimilarity(strs[i], strs[j])) { + matrix[i].push(j); + matrix[j].push(i); + } + } + } + + let count = 0; + const visited = new Set(); + for (let start = 0; start < n; start++) { + if (!visited.has(start)) { + dfs(start, matrix, visited); + count++; + } + } + + return count; +} diff --git a/tests/501-1000/840. magic-squares-in-grid/manifest.yaml b/tests/501-1000/840. magic-squares-in-grid/manifest.yaml new file mode 100644 index 00000000..d8b6bb7c --- /dev/null +++ b/tests/501-1000/840. magic-squares-in-grid/manifest.yaml @@ -0,0 +1,1007 @@ +entry: + id: 840 + title: magic-squares-in-grid + params: + grid: + type: array + items: + type: array + items: + type: int + call: + cpp: Solution().numMagicSquaresInside({grid}) + rust: Solution::num_magic_squares_inside({grid}) + python3: Solution().numMagicSquaresInside({grid}) + python2: Solution().numMagicSquaresInside({grid}) + ruby: num_magic_squares_inside({grid}) + java: new Solution().numMagicSquaresInside({grid}) + csharp: new Solution().NumMagicSquaresInside({grid}) + kotlin: Solution().numMagicSquaresInside({grid}) + go: numMagicSquaresInside({grid}) + dart: Solution().numMagicSquaresInside({grid}) + swift: Solution().numMagicSquaresInside({grid}) + typescript: numMagicSquaresInside({grid}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().numMagicSquaresInside(grid, {result}) + checker: "class Checker:\n def numMagicSquaresInside(self, grid, result):\n def is_magic(r, c):\n vals = [grid[i][j] for i in range(r, r + 3) for j in range(c, c + 3)]\n if sorted(vals) != [1,2,3,4,5,6,7,8,9]:\n return False\n rows = [sum(grid[r + i][c:c + 3]) for i in range(3)]\n cols = [grid[r][c + j] + grid[r + 1][c + j] + grid[r + 2][c + j] for j in range(3)]\n d1 = grid[r][c] + grid[r + 1][c + 1] + grid[r + 2][c + 2]\n d2 = grid[r][c + 2] + grid[r + 1][c + 1] + grid[r + 2][c]\n return rows == [15,15,15] and cols == [15,15,15] and d1 == 15 and d2 == 15\n expected = sum(is_magic(i, j) for i in range(len(grid) - 2) for j in range(len(grid[0]) - 2))\n return result == expected\n" +seed: 840 +tests: + - name: example-1 + in: + grid: + elemType: int + value: + - - 4 + - 3 + - 8 + - 4 + - - 9 + - 5 + - 1 + - 9 + - - 2 + - 7 + - 6 + - 2 + out: 1 + - name: example-2 + in: + grid: + elemType: int + value: + - - 8 + out: 0 + - name: lo-shu-variant-1 + in: + grid: + elemType: int + value: + - - 8 + - 1 + - 6 + - - 3 + - 5 + - 7 + - - 4 + - 9 + - 2 + out: 1 + - name: lo-shu-variant-2 + in: + grid: + elemType: int + value: + - - 4 + - 3 + - 8 + - - 9 + - 5 + - 1 + - - 2 + - 7 + - 6 + out: 1 + - name: lo-shu-variant-3 + in: + grid: + elemType: int + value: + - - 2 + - 9 + - 4 + - - 7 + - 5 + - 3 + - - 6 + - 1 + - 8 + out: 1 + - name: lo-shu-variant-4 + in: + grid: + elemType: int + value: + - - 6 + - 7 + - 2 + - - 1 + - 5 + - 9 + - - 8 + - 3 + - 4 + out: 1 + - name: lo-shu-variant-5 + in: + grid: + elemType: int + value: + - - 6 + - 1 + - 8 + - - 7 + - 5 + - 3 + - - 2 + - 9 + - 4 + out: 1 + - name: lo-shu-variant-6 + in: + grid: + elemType: int + value: + - - 4 + - 9 + - 2 + - - 3 + - 5 + - 7 + - - 8 + - 1 + - 6 + out: 1 + - name: invalid-center-not-five + in: + grid: + elemType: int + value: + - - 8 + - 1 + - 6 + - - 3 + - 4 + - 7 + - - 4 + - 9 + - 2 + out: 0 + - name: invalid-duplicate + in: + grid: + elemType: int + value: + - - 8 + - 1 + - 6 + - - 3 + - 5 + - 7 + - - 4 + - 8 + - 2 + out: 0 + - name: invalid-out-of-range + in: + grid: + elemType: int + value: + - - 8 + - 1 + - 6 + - - 3 + - 5 + - 7 + - - 4 + - 9 + - 15 + out: 0 + - name: embedded-single + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 8 + - 1 + - 6 + - 0 + - - 0 + - 3 + - 5 + - 7 + - 0 + - - 0 + - 4 + - 9 + - 2 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + out: 1 + - name: two-separated-horizontal + in: + grid: + elemType: int + value: + - - 8 + - 1 + - 6 + - 0 + - 8 + - 1 + - 6 + - - 3 + - 5 + - 7 + - 0 + - 3 + - 5 + - 7 + - - 4 + - 9 + - 2 + - 0 + - 4 + - 9 + - 2 + out: 2 + - name: two-separated-vertical + in: + grid: + elemType: int + value: + - - 8 + - 1 + - 6 + - - 3 + - 5 + - 7 + - - 4 + - 9 + - 2 + - - 0 + - 0 + - 0 + - - 8 + - 1 + - 6 + - - 3 + - 5 + - 7 + - - 4 + - 9 + - 2 + out: 2 + - name: two-overlapping-none + in: + grid: + elemType: int + value: + - - 8 + - 1 + - 6 + - 1 + - - 3 + - 5 + - 7 + - 5 + - - 4 + - 9 + - 2 + - 9 + - - 8 + - 1 + - 6 + - 1 + out: 1 + - name: all-zero-3x3 + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + out: 0 + - name: ascending-3x3 + in: + grid: + elemType: int + value: + - - 1 + - 2 + - 3 + - - 4 + - 5 + - 6 + - - 7 + - 8 + - 9 + out: 0 + - name: wide-random-no-magic + in: + grid: + elemType: int + value: + - - 10 + - 3 + - 5 + - 7 + - 2 + - - 1 + - 4 + - 6 + - 8 + - 9 + - - 12 + - 13 + - 14 + - 15 + - 0 + out: 0 + - name: tall-random-no-magic + in: + grid: + elemType: int + value: + - - 1 + - 2 + - 3 + - - 4 + - 5 + - 6 + - - 7 + - 8 + - 9 + - - 0 + - 1 + - 2 + - - 3 + - 4 + - 5 + out: 0 + - name: magic-with-noise-corners + in: + grid: + elemType: int + value: + - - 15 + - 15 + - 15 + - 15 + - 15 + - - 15 + - 8 + - 1 + - 6 + - 15 + - - 15 + - 3 + - 5 + - 7 + - 15 + - - 15 + - 4 + - 9 + - 2 + - 15 + - - 15 + - 15 + - 15 + - 15 + - 15 + out: 1 + - name: double-diagonal-layout + in: + grid: + elemType: int + value: + - - 8 + - 1 + - 6 + - 0 + - 0 + - 0 + - - 3 + - 5 + - 7 + - 0 + - 0 + - 0 + - - 4 + - 9 + - 2 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 6 + - 1 + - 8 + - - 0 + - 0 + - 0 + - 7 + - 5 + - 3 + - - 0 + - 0 + - 0 + - 2 + - 9 + - 4 + out: 2 + - name: checker-values + in: + grid: + elemType: int + value: + - - 1 + - 15 + - 1 + - 15 + - - 15 + - 1 + - 15 + - 1 + - - 1 + - 15 + - 1 + - 15 + - - 15 + - 1 + - 15 + - 1 + out: 0 + - name: ten-by-ten-none + in: + grid: + elemType: int + value: + - - 0 + - 5 + - 10 + - 15 + - 4 + - 9 + - 14 + - 3 + - 8 + - 13 + - - 3 + - 8 + - 13 + - 2 + - 7 + - 12 + - 1 + - 6 + - 11 + - 0 + - - 6 + - 11 + - 0 + - 5 + - 10 + - 15 + - 4 + - 9 + - 14 + - 3 + - - 9 + - 14 + - 3 + - 8 + - 13 + - 2 + - 7 + - 12 + - 1 + - 6 + - - 12 + - 1 + - 6 + - 11 + - 0 + - 5 + - 10 + - 15 + - 4 + - 9 + - - 15 + - 4 + - 9 + - 14 + - 3 + - 8 + - 13 + - 2 + - 7 + - 12 + - - 2 + - 7 + - 12 + - 1 + - 6 + - 11 + - 0 + - 5 + - 10 + - 15 + - - 5 + - 10 + - 15 + - 4 + - 9 + - 14 + - 3 + - 8 + - 13 + - 2 + - - 8 + - 13 + - 2 + - 7 + - 12 + - 1 + - 6 + - 11 + - 0 + - 5 + - - 11 + - 0 + - 5 + - 10 + - 15 + - 4 + - 9 + - 14 + - 3 + - 8 + out: 0 + - name: top-left-magic-4 + in: + grid: + elemType: int + value: + - - 8 + - 1 + - 6 + - 5 + - - 3 + - 5 + - 7 + - 5 + - - 4 + - 9 + - 2 + - 5 + - - 5 + - 5 + - 5 + - 5 + out: 1 + - name: top-right-magic-4 + in: + grid: + elemType: int + value: + - - 5 + - 8 + - 1 + - 6 + - - 5 + - 3 + - 5 + - 7 + - - 5 + - 4 + - 9 + - 2 + - - 5 + - 5 + - 5 + - 5 + out: 1 + - name: bottom-left-magic-4 + in: + grid: + elemType: int + value: + - - 5 + - 5 + - 5 + - 5 + - - 8 + - 1 + - 6 + - 5 + - - 3 + - 5 + - 7 + - 5 + - - 4 + - 9 + - 2 + - 5 + out: 1 + - name: bottom-right-magic-4 + in: + grid: + elemType: int + value: + - - 5 + - 5 + - 5 + - 5 + - - 5 + - 8 + - 1 + - 6 + - - 5 + - 3 + - 5 + - 7 + - - 5 + - 4 + - 9 + - 2 + out: 1 + - name: three-row-strip-two-magics + in: + grid: + elemType: int + value: + - - 8 + - 1 + - 6 + - 8 + - 1 + - 6 + - 8 + - - 3 + - 5 + - 7 + - 3 + - 5 + - 7 + - 3 + - - 4 + - 9 + - 2 + - 4 + - 9 + - 2 + - 4 + out: 2 + - name: three-col-strip-two-magics + in: + grid: + elemType: int + value: + - - 8 + - 1 + - 6 + - - 3 + - 5 + - 7 + - - 4 + - 9 + - 2 + - - 8 + - 1 + - 6 + - - 3 + - 5 + - 7 + - - 4 + - 9 + - 2 + - - 8 + - 1 + - 6 + out: 2 + - name: near-magic-row-bad + in: + grid: + elemType: int + value: + - - 8 + - 1 + - 6 + - - 3 + - 5 + - 7 + - - 4 + - 2 + - 9 + out: 0 + - name: near-magic-col-bad + in: + grid: + elemType: int + value: + - - 8 + - 1 + - 6 + - - 4 + - 5 + - 7 + - - 3 + - 9 + - 2 + out: 0 + - name: contains-negatives + in: + grid: + elemType: int + value: + - - -1 + - 8 + - 1 + - 6 + - - 3 + - 5 + - 7 + - 0 + - - 4 + - 9 + - 2 + - 0 + out: 0 + - name: mixed-valid-and-invalid-5 + in: + grid: + elemType: int + value: + - - 8 + - 1 + - 6 + - 4 + - 3 + - - 3 + - 5 + - 7 + - 9 + - 5 + - - 4 + - 9 + - 2 + - 2 + - 7 + - - 0 + - 0 + - 0 + - 6 + - 1 + - - 0 + - 0 + - 0 + - 7 + - 5 + out: 1 + - name: max-values-no-magic + in: + grid: + elemType: int + value: + - - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + - 15 + out: 0 + - name: embedded-valid-10 + in: + grid: + elemType: int + value: + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 8 + - 1 + - 6 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 3 + - 5 + - 7 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 4 + - 9 + - 2 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + out: 1 diff --git a/tests/501-1000/840. magic-squares-in-grid/sol.cpp b/tests/501-1000/840. magic-squares-in-grid/sol.cpp new file mode 100644 index 00000000..ee9969ee --- /dev/null +++ b/tests/501-1000/840. magic-squares-in-grid/sol.cpp @@ -0,0 +1,44 @@ +class Solution { +public: + int numMagicSquaresInside(vector>& grid) { + int m = grid.size(), n = grid[0].size(), c = 0; + for (int i = 0; i < m - 2; i++) { + for (int j = 0; j < n - 2; j++) { + if (isMagicSquare(grid, i, j)) { + c++; + } + } + } + return c; + } + +private: + bool isMagicSquare(vector>& grid, int r, int c) { + if (grid[r+1][c+1] != 5) return false; + + int a = grid[r][c], b = grid[r][c+1], d = grid[r][c+2]; + int e = grid[r+1][c], f = grid[r+1][c+2]; + int h = grid[r+2][c], i = grid[r+2][c+1], j = grid[r+2][c+2]; + + bool seen[10] = {false}; + int arr[] = {a, b, d, e, f, h, i, j, 5}; + for (int x : arr) { + if (x < 1 || x > 9 || seen[x]) return false; + seen[x] = true; + } + + if (a + j != 10) return false; + if (b + i != 10) return false; + if (d + h != 10) return false; + if (e + f != 10) return false; + + if (a + b + d != 15) return false; + if (h + i + j != 15) return false; + if (a + e + h != 15) return false; + if (d + f + j != 15) return false; + if (a + 5 + j != 15) return false; + if (d + 5 + h != 15) return false; + + return true; + } +}; diff --git a/tests/501-1000/840. magic-squares-in-grid/sol.cs b/tests/501-1000/840. magic-squares-in-grid/sol.cs new file mode 100644 index 00000000..efa1f044 --- /dev/null +++ b/tests/501-1000/840. magic-squares-in-grid/sol.cs @@ -0,0 +1,42 @@ +public class Solution { + public int NumMagicSquaresInside(int[][] grid) { + int m = grid.Length, n = grid[0].Length, c = 0; + for (int i = 0; i < m - 2; i++) { + for (int j = 0; j < n - 2; j++) { + if (IsMagicSquare(grid, i, j)) { + c++; + } + } + } + return c; + } + + private bool IsMagicSquare(int[][] grid, int r, int c) { + if (grid[r+1][c+1] != 5) return false; + + int a = grid[r][c], b = grid[r][c+1], d = grid[r][c+2]; + int e = grid[r+1][c], f = grid[r+1][c+2]; + int h = grid[r+2][c], i = grid[r+2][c+1], j = grid[r+2][c+2]; + + bool[] seen = new bool[10]; + int[] arr = {a, b, d, e, f, h, i, j, 5}; + foreach (int x in arr) { + if (x < 1 || x > 9 || seen[x]) return false; + seen[x] = true; + } + + if (a + j != 10) return false; + if (b + i != 10) return false; + if (d + h != 10) return false; + if (e + f != 10) return false; + + if (a + b + d != 15) return false; + if (h + i + j != 15) return false; + if (a + e + h != 15) return false; + if (d + f + j != 15) return false; + if (a + 5 + j != 15) return false; + if (d + 5 + h != 15) return false; + + return true; + } +} diff --git a/tests/501-1000/840. magic-squares-in-grid/sol.dart b/tests/501-1000/840. magic-squares-in-grid/sol.dart new file mode 100644 index 00000000..0e89a0b7 --- /dev/null +++ b/tests/501-1000/840. magic-squares-in-grid/sol.dart @@ -0,0 +1,42 @@ +class Solution { + int numMagicSquaresInside(List> grid) { + int m = grid.length, n = grid[0].length, c = 0; + for (int i = 0; i < m - 2; i++) { + for (int j = 0; j < n - 2; j++) { + if (_isMagicSquare(grid, i, j)) { + c++; + } + } + } + return c; + } + + bool _isMagicSquare(List> grid, int r, int c) { + if (grid[r+1][c+1] != 5) return false; + + int a = grid[r][c], b = grid[r][c+1], d = grid[r][c+2]; + int e = grid[r+1][c], f = grid[r+1][c+2]; + int h = grid[r+2][c], i = grid[r+2][c+1], j = grid[r+2][c+2]; + + List seen = List.filled(10, false); + List arr = [a, b, d, e, f, h, i, j, 5]; + for (int x in arr) { + if (x < 1 || x > 9 || seen[x]) return false; + seen[x] = true; + } + + if (a + j != 10) return false; + if (b + i != 10) return false; + if (d + h != 10) return false; + if (e + f != 10) return false; + + if (a + b + d != 15) return false; + if (h + i + j != 15) return false; + if (a + e + h != 15) return false; + if (d + f + j != 15) return false; + if (a + 5 + j != 15) return false; + if (d + 5 + h != 15) return false; + + return true; + } +} diff --git a/tests/501-1000/840. magic-squares-in-grid/sol.go b/tests/501-1000/840. magic-squares-in-grid/sol.go new file mode 100644 index 00000000..588cd7aa --- /dev/null +++ b/tests/501-1000/840. magic-squares-in-grid/sol.go @@ -0,0 +1,45 @@ +func numMagicSquaresInside(grid [][]int) int { + m, n := len(grid), len(grid[0]) + c := 0 + for i := 0; i < m-2; i++ { + for j := 0; j < n-2; j++ { + if isMagicSquare(grid, i, j) { + c++ + } + } + } + return c +} + +func isMagicSquare(grid [][]int, r, c int) bool { + if grid[r+1][c+1] != 5 { + return false + } + + a := grid[r][c]; b := grid[r][c+1]; d := grid[r][c+2] + e := grid[r+1][c]; f := grid[r+1][c+2] + h := grid[r+2][c]; i := grid[r+2][c+1]; j := grid[r+2][c+2] + + seen := make([]bool, 10) + arr := []int{a, b, d, e, f, h, i, j, 5} + for _, x := range arr { + if x < 1 || x > 9 || seen[x] { + return false + } + seen[x] = true + } + + if a+j != 10 { return false } + if b+i != 10 { return false } + if d+h != 10 { return false } + if e+f != 10 { return false } + + if a+b+d != 15 { return false } + if h+i+j != 15 { return false } + if a+e+h != 15 { return false } + if d+f+j != 15 { return false } + if a+5+j != 15 { return false } + if d+5+h != 15 { return false } + + return true +} diff --git a/tests/501-1000/840. magic-squares-in-grid/sol.java b/tests/501-1000/840. magic-squares-in-grid/sol.java new file mode 100644 index 00000000..f696d3fe --- /dev/null +++ b/tests/501-1000/840. magic-squares-in-grid/sol.java @@ -0,0 +1,42 @@ +class Solution { + public int numMagicSquaresInside(int[][] grid) { + int m = grid.length, n = grid[0].length, c = 0; + for (int i = 0; i < m - 2; i++) { + for (int j = 0; j < n - 2; j++) { + if (isMagicSquare(grid, i, j)) { + c++; + } + } + } + return c; + } + + private boolean isMagicSquare(int[][] grid, int r, int c) { + if (grid[r+1][c+1] != 5) return false; + + int a = grid[r][c], b = grid[r][c+1], d = grid[r][c+2]; + int e = grid[r+1][c], f = grid[r+1][c+2]; + int h = grid[r+2][c], i = grid[r+2][c+1], j = grid[r+2][c+2]; + + boolean[] seen = new boolean[10]; + int[] arr = {a, b, d, e, f, h, i, j, 5}; + for (int x : arr) { + if (x < 1 || x > 9 || seen[x]) return false; + seen[x] = true; + } + + if (a + j != 10) return false; + if (b + i != 10) return false; + if (d + h != 10) return false; + if (e + f != 10) return false; + + if (a + b + d != 15) return false; + if (h + i + j != 15) return false; + if (a + e + h != 15) return false; + if (d + f + j != 15) return false; + if (a + 5 + j != 15) return false; + if (d + 5 + h != 15) return false; + + return true; + } +} diff --git a/tests/501-1000/840. magic-squares-in-grid/sol.kt b/tests/501-1000/840. magic-squares-in-grid/sol.kt new file mode 100644 index 00000000..5f061f19 --- /dev/null +++ b/tests/501-1000/840. magic-squares-in-grid/sol.kt @@ -0,0 +1,40 @@ +class Solution { + fun numMagicSquaresInside(grid: Array): Int { + val m = grid.size; val n = grid[0].size; var c = 0 + for (i in 0 until m-2) { + for (j in 0 until n-2) { + if (isMagicSquare(grid, i, j)) c++ + } + } + return c + } + + private fun isMagicSquare(grid: Array, r: Int, c: Int): Boolean { + if (grid[r+1][c+1] != 5) return false + + val a = grid[r][c]; val b = grid[r][c+1]; val d = grid[r][c+2] + val e = grid[r+1][c]; val f = grid[r+1][c+2] + val h = grid[r+2][c]; val i = grid[r+2][c+1]; val j = grid[r+2][c+2] + + val seen = BooleanArray(10) + val arr = intArrayOf(a, b, d, e, f, h, i, j, 5) + for (x in arr) { + if (x < 1 || x > 9 || seen[x]) return false + seen[x] = true + } + + if (a + j != 10) return false + if (b + i != 10) return false + if (d + h != 10) return false + if (e + f != 10) return false + + if (a + b + d != 15) return false + if (h + i + j != 15) return false + if (a + e + h != 15) return false + if (d + f + j != 15) return false + if (a + 5 + j != 15) return false + if (d + 5 + h != 15) return false + + return true + } +} diff --git a/tests/501-1000/840. magic-squares-in-grid/sol.py b/tests/501-1000/840. magic-squares-in-grid/sol.py new file mode 100644 index 00000000..a2e6e823 --- /dev/null +++ b/tests/501-1000/840. magic-squares-in-grid/sol.py @@ -0,0 +1,54 @@ +class Solution: + def isMagicSquare(self, grid, r, c): + if grid[r + 1][c + 1] != 5: + return False + + a = grid[r][c] + b = grid[r][c + 1] + d = grid[r][c + 2] # grid ele except centre + e = grid[r + 1][c] + f = grid[r + 1][c + 2] + h = grid[r + 2][c] + i = grid[r + 2][c + 1] + j = grid[r + 2][c + 2] + + seen = [False] * 10 + arr = [a, b, d, e, f, h, i, j, 5] + for x in arr: + if x < 1 or x > 9 or seen[x]: + return False + seen[x] = True + + if a + j != 10: + return False + if b + i != 10: + return False + if d + h != 10: + return False + if e + f != 10: + return False + + if a + b + d != 15: + return False + if h + i + j != 15: + return False + if a + e + h != 15: + return False + if d + f + j != 15: + return False + if a + 5 + j != 15: + return False + if d + 5 + h != 15: + return False + + return True + + def numMagicSquaresInside(self, grid): + m = len(grid) + n = len(grid[0]) + c = 0 + for i in range(m - 2): + for j in range(n - 2): + if self.isMagicSquare(grid, i, j): + c += 1 + return c diff --git a/tests/501-1000/840. magic-squares-in-grid/sol.py2 b/tests/501-1000/840. magic-squares-in-grid/sol.py2 new file mode 100644 index 00000000..6b8b332e --- /dev/null +++ b/tests/501-1000/840. magic-squares-in-grid/sol.py2 @@ -0,0 +1,41 @@ +class Solution(object): + def numMagicSquaresInside(self, grid): + """ + :type grid: List[List[int]] + :rtype: int + """ + def isMagicSquare(grid, r, c): + if grid[r+1][c+1] != 5: + return False + + a = grid[r][c]; b = grid[r][c+1]; d = grid[r][c+2] + e = grid[r+1][c]; f = grid[r+1][c+2] + h = grid[r+2][c]; i = grid[r+2][c+1]; j = grid[r+2][c+2] + + seen = [False] * 10 + arr = [a,b,d,e,f,h,i,j,5] + for x in arr: + if x < 1 or x > 9 or seen[x]: + return False + seen[x] = True + + if a + j != 10: return False + if b + i != 10: return False + if d + h != 10: return False + if e + f != 10: return False + + if a + b + d != 15: return False + if h + i + j != 15: return False + if a + e + h != 15: return False + if d + f + j != 15: return False + if a + 5 + j != 15: return False + if d + 5 + h != 15: return False + + return True + + m = len(grid); n = len(grid[0]); c = 0 + for i in range(m-2): + for j in range(n-2): + if isMagicSquare(grid,i,j): + c += 1 + return c diff --git a/tests/501-1000/840. magic-squares-in-grid/sol.rb b/tests/501-1000/840. magic-squares-in-grid/sol.rb new file mode 100644 index 00000000..1f7a3a19 --- /dev/null +++ b/tests/501-1000/840. magic-squares-in-grid/sol.rb @@ -0,0 +1,40 @@ +# @param {Integer[][]} grid +# @return {Integer} +def num_magic_squares_inside(grid) + is_magic_square = lambda do |grid, r, c| + return false if grid[r+1][c+1] != 5 + + a = grid[r][c]; b = grid[r][c+1]; d = grid[r][c+2] + e = grid[r+1][c]; f = grid[r+1][c+2] + h = grid[r+2][c]; i = grid[r+2][c+1]; j = grid[r+2][c+2] + + seen = Array.new(10, false) + arr = [a,b,d,e,f,h,i,j,5] + arr.each do |x| + return false if x < 1 || x > 9 || seen[x] + seen[x] = true + end + + return false if a + j != 10 + return false if b + i != 10 + return false if d + h != 10 + return false if e + f != 10 + + return false if a + b + d != 15 + return false if h + i + j != 15 + return false if a + e + h != 15 + return false if d + f + j != 15 + return false if a + 5 + j != 15 + return false if d + 5 + h != 15 + + true + end + + m = grid.length; n = grid[0].length; c = 0 + (0...m-2).each do |i| + (0...n-2).each do |j| + c += 1 if is_magic_square.call(grid, i, j) + end + end + c +end diff --git a/tests/501-1000/840. magic-squares-in-grid/sol.rs b/tests/501-1000/840. magic-squares-in-grid/sol.rs new file mode 100644 index 00000000..222ed540 --- /dev/null +++ b/tests/501-1000/840. magic-squares-in-grid/sol.rs @@ -0,0 +1,51 @@ +impl Solution { + pub fn num_magic_squares_inside(grid: Vec>) -> i32 { + let m = grid.len(); + let n = grid[0].len(); + if m < 3 || n < 3 { + return 0; + } + let mut c = 0; + for i in 0..m-2 { + for j in 0..n-2 { + if Self::is_magic_square(&grid, i, j) { + c += 1; + } + } + } + c + } + + fn is_magic_square(grid: &Vec>, r: usize, c: usize) -> bool { + if grid[r+1][c+1] != 5 { + return false; + } + + let a = grid[r][c]; let b = grid[r][c+1]; let d = grid[r][c+2]; + let e = grid[r+1][c]; let f = grid[r+1][c+2]; + let h = grid[r+2][c]; let i = grid[r+2][c+1]; let j = grid[r+2][c+2]; + + let mut seen = vec![false; 10]; + let arr = [a, b, d, e, f, h, i, j, 5]; + for &x in &arr { + if x < 1 || x > 9 || seen[x as usize] { + return false; + } + seen[x as usize] = true; + } + + if a + j != 10 { return false; } + if b + i != 10 { return false; } + if d + h != 10 { return false; } + if e + f != 10 { return false; } + + if a + b + d != 15 { return false; } + if h + i + j != 15 { return false; } + if a + e + h != 15 { return false; } + if d + f + j != 15 { return false; } + if a + 5 + j != 15 { return false; } + if d + 5 + h != 15 { return false; } + + true + } +} diff --git a/tests/501-1000/840. magic-squares-in-grid/sol.swift b/tests/501-1000/840. magic-squares-in-grid/sol.swift new file mode 100644 index 00000000..4c2d5227 --- /dev/null +++ b/tests/501-1000/840. magic-squares-in-grid/sol.swift @@ -0,0 +1,44 @@ +class Solution { + func numMagicSquaresInside(_ grid: [[Int]]) -> Int { + let m = grid.count, n = grid[0].count + if m < 3 || n < 3 { return 0 } + var c = 0 + for i in 0.. Bool { + if grid[r+1][c+1] != 5 { return false } + + let a = grid[r][c], b = grid[r][c+1], d = grid[r][c+2] + let e = grid[r+1][c], f = grid[r+1][c+2] + let h = grid[r+2][c], i = grid[r+2][c+1], j = grid[r+2][c+2] + + var seen = [Bool](repeating: false, count: 10) + let arr = [a, b, d, e, f, h, i, j, 5] + for x in arr { + if x < 1 || x > 9 || seen[x] { return false } + seen[x] = true + } + + if a + j != 10 { return false } + if b + i != 10 { return false } + if d + h != 10 { return false } + if e + f != 10 { return false } + + if a + b + d != 15 { return false } + if h + i + j != 15 { return false } + if a + e + h != 15 { return false } + if d + f + j != 15 { return false } + if a + 5 + j != 15 { return false } + if d + 5 + h != 15 { return false } + + return true + } +} diff --git a/tests/501-1000/840. magic-squares-in-grid/sol.ts b/tests/501-1000/840. magic-squares-in-grid/sol.ts new file mode 100644 index 00000000..25d60060 --- /dev/null +++ b/tests/501-1000/840. magic-squares-in-grid/sol.ts @@ -0,0 +1,47 @@ +function numMagicSquaresInside(grid: number[][]): number { + const m = grid.length, + n = grid[0].length; + let c = 0; + for (let i = 0; i < m - 2; i++) { + for (let j = 0; j < n - 2; j++) { + if (isMagicSquare(grid, i, j)) { + c++; + } + } + } + return c; +} + +function isMagicSquare(grid: number[][], r: number, c: number): boolean { + if (grid[r + 1][c + 1] !== 5) return false; + + const a = grid[r][c], + b = grid[r][c + 1], + d = grid[r][c + 2]; + const e = grid[r + 1][c], + f = grid[r + 1][c + 2]; + const h = grid[r + 2][c], + i = grid[r + 2][c + 1], + j = grid[r + 2][c + 2]; + + const seen: boolean[] = new Array(10).fill(false); + const arr = [a, b, d, e, f, h, i, j, 5]; + for (const x of arr) { + if (x < 1 || x > 9 || seen[x]) return false; + seen[x] = true; + } + + if (a + j !== 10) return false; + if (b + i !== 10) return false; + if (d + h !== 10) return false; + if (e + f !== 10) return false; + + if (a + b + d !== 15) return false; + if (h + i + j !== 15) return false; + if (a + e + h !== 15) return false; + if (d + f + j !== 15) return false; + if (a + 5 + j !== 15) return false; + if (d + 5 + h !== 15) return false; + + return true; +} diff --git a/tests/501-1000/841. keys-and-rooms/manifest.yaml b/tests/501-1000/841. keys-and-rooms/manifest.yaml new file mode 100644 index 00000000..f1134cc2 --- /dev/null +++ b/tests/501-1000/841. keys-and-rooms/manifest.yaml @@ -0,0 +1,534 @@ +entry: + id: 841 + title: keys-and-rooms + params: + rooms: + type: array + items: + type: array + items: + type: int + call: + cpp: Solution().canVisitAllRooms({rooms}) + rust: Solution::can_visit_all_rooms({rooms}) + python3: Solution().canVisitAllRooms({rooms}) + python2: Solution().canVisitAllRooms({rooms}) + ruby: can_visit_all_rooms({rooms}) + java: new Solution().canVisitAllRooms({rooms}) + csharp: new Solution().CanVisitAllRooms({rooms}) + kotlin: Solution().canVisitAllRooms({rooms}) + go: canVisitAllRooms({rooms}) + dart: Solution().canVisitAllRooms({rooms}) + swift: Solution().canVisitAllRooms({rooms}) + typescript: canVisitAllRooms({rooms}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().canVisitAllRooms(rooms, {result}) + checker: "from collections import deque\n\nclass Checker:\n def canVisitAllRooms(self, rooms, result):\n seen = {0}\n q = deque([0])\n while q:\n room = q.popleft()\n for key in rooms[room]:\n if key not in seen:\n seen.add(key)\n q.append(key)\n return result == (len(seen) == len(rooms))\n" +seed: 841 +tests: + - name: example-1 + in: + rooms: + elemType: int + value: + - - 1 + - - 2 + - - 3 + - [] + out: true + - name: example-2 + in: + rooms: + elemType: int + value: + - - 1 + - 3 + - - 3 + - 0 + - 1 + - - 2 + - - 0 + out: false + - name: two-rooms-open + in: + rooms: + elemType: int + value: + - - 1 + - [] + out: true + - name: two-rooms-closed + in: + rooms: + elemType: int + value: + - [] + - [] + out: false + - name: chain-five + in: + rooms: + elemType: int + value: + - - 1 + - - 2 + - - 3 + - - 4 + - [] + out: true + - name: chain-break + in: + rooms: + elemType: int + value: + - - 1 + - - 2 + - [] + - - 4 + - [] + out: false + - name: star-open + in: + rooms: + elemType: int + value: + - - 1 + - 2 + - 3 + - 4 + - [] + - [] + - [] + - [] + out: true + - name: star-missing-one + in: + rooms: + elemType: int + value: + - - 1 + - 2 + - 3 + - [] + - [] + - [] + - [] + out: false + - name: cycle-three + in: + rooms: + elemType: int + value: + - - 1 + - - 2 + - - 0 + out: true + - name: cycle-four-plus-tail + in: + rooms: + elemType: int + value: + - - 1 + - - 2 + - - 3 + - - 0 + - 4 + - [] + out: true + - name: branching-open + in: + rooms: + elemType: int + value: + - - 1 + - 2 + - - 3 + - - 4 + - [] + - [] + out: true + - name: branching-closed + in: + rooms: + elemType: int + value: + - - 1 + - 2 + - - 3 + - [] + - [] + - [] + out: false + - name: redundant-keys-open + in: + rooms: + elemType: int + value: + - - 1 + - 2 + - - 2 + - 3 + - - 3 + - - 4 + - [] + out: true + - name: self-blocked-last + in: + rooms: + elemType: int + value: + - - 1 + - 2 + - - 3 + - - 1 + - [] + - - 4 + out: false + - name: all-from-zero-10 + in: + rooms: + elemType: int + value: + - - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - [] + - [] + - [] + - [] + - [] + - [] + - [] + - [] + - [] + out: true + - name: line-10 + in: + rooms: + elemType: int + value: + - - 1 + - - 2 + - - 3 + - - 4 + - - 5 + - - 6 + - - 7 + - - 8 + - - 9 + - [] + out: true + - name: line-10-broken + in: + rooms: + elemType: int + value: + - - 1 + - - 2 + - - 3 + - - 4 + - [] + - - 6 + - - 7 + - - 8 + - - 9 + - [] + out: false + - name: binary-tree-open + in: + rooms: + elemType: int + value: + - - 1 + - 2 + - - 3 + - 4 + - - 5 + - 6 + - [] + - [] + - [] + - [] + out: true + - name: binary-tree-one-leaf-missing + in: + rooms: + elemType: int + value: + - - 1 + - 2 + - - 3 + - 4 + - - 5 + - [] + - [] + - [] + - [] + out: false + - name: cycle-with-unreachable-clique + in: + rooms: + elemType: int + value: + - - 1 + - - 2 + - - 0 + - - 4 + - - 3 + out: false + - name: large-sparse-open + in: + rooms: + elemType: int + value: + - - 1 + - 5 + - - 2 + - - 3 + - - 4 + - - 6 + - - 7 + - - 8 + - - 9 + - [] + - [] + out: true + - name: large-sparse-closed + in: + rooms: + elemType: int + value: + - - 5 + - - 2 + - - 3 + - - 4 + - [] + - - 7 + - - 8 + - - 9 + - [] + - [] + out: false + - name: room-zero-empty-many + in: + rooms: + elemType: int + value: + - [] + - [] + - [] + - [] + - [] + - [] + out: false + - name: back-edges-open + in: + rooms: + elemType: int + value: + - - 1 + - - 0 + - 2 + - - 1 + - 3 + - - 2 + - 4 + - - 3 + - 5 + - [] + out: true + - name: back-edges-closed + in: + rooms: + elemType: int + value: + - - 1 + - - 0 + - - 3 + - - 2 + - 4 + - - 3 + - [] + out: false + - name: hub-and-spokes-open + in: + rooms: + elemType: int + value: + - - 2 + - - 2 + - - 1 + - 3 + - 4 + - 5 + - - 2 + - - 2 + - - 2 + out: true + - name: hub-and-spokes-closed + in: + rooms: + elemType: int + value: + - - 2 + - [] + - - 1 + - 3 + - - 2 + - [] + - [] + out: false + - name: dense-open-8 + in: + rooms: + elemType: int + value: + - - 1 + - 2 + - 3 + - - 0 + - 4 + - 5 + - - 0 + - 5 + - - 0 + - 6 + - - 1 + - 7 + - - 1 + - 2 + - 7 + - - 3 + - - 4 + - 5 + out: true + - name: dense-closed-8 + in: + rooms: + elemType: int + value: + - - 1 + - 2 + - - 0 + - 3 + - - 0 + - - 1 + - - 5 + - - 4 + - 6 + - - 5 + - [] + out: false + - name: spiral-open-9 + in: + rooms: + elemType: int + value: + - - 1 + - 8 + - - 2 + - - 3 + - - 4 + - - 5 + - - 6 + - - 7 + - - 0 + - [] + out: true + - name: spiral-closed-9 + in: + rooms: + elemType: int + value: + - - 1 + - - 2 + - - 3 + - - 4 + - - 5 + - - 6 + - - 7 + - [] + - [] + out: false + - name: maxish-open-12 + in: + rooms: + elemType: int + value: + - - 1 + - 2 + - 3 + - - 4 + - 5 + - - 6 + - - 7 + - - 8 + - - 9 + - - 10 + - - 11 + - [] + - [] + - [] + - [] + out: true + - name: maxish-closed-12 + in: + rooms: + elemType: int + value: + - - 1 + - 2 + - - 4 + - - 5 + - - 6 + - - 7 + - - 8 + - - 9 + - - 10 + - - 11 + - [] + - [] + - [] + out: false + - name: cross-links-open + in: + rooms: + elemType: int + value: + - - 1 + - 2 + - - 3 + - 4 + - - 4 + - 5 + - - 6 + - - 6 + - - 6 + - [] + out: true + - name: cross-links-closed + in: + rooms: + elemType: int + value: + - - 1 + - 2 + - - 3 + - - 4 + - [] + - [] + - [] + - [] + out: false diff --git a/tests/501-1000/841. keys-and-rooms/sol.cpp b/tests/501-1000/841. keys-and-rooms/sol.cpp new file mode 100644 index 00000000..f3e6bab0 --- /dev/null +++ b/tests/501-1000/841. keys-and-rooms/sol.cpp @@ -0,0 +1,22 @@ +class Solution { +public: + bool canVisitAllRooms(vector>& rooms) { + int n = rooms.size(); + vector keys = {0}; + vector visited(n, false); + visited[0] = true; + int count = 1; + while (!keys.empty()) { + int room = keys.back(); + keys.pop_back(); + for (int i : rooms[room]) { + if (!visited[i]) { + visited[i] = true; + keys.push_back(i); + count++; + } + } + } + return count == n; + } +}; diff --git a/tests/501-1000/841. keys-and-rooms/sol.cs b/tests/501-1000/841. keys-and-rooms/sol.cs new file mode 100644 index 00000000..4064ba24 --- /dev/null +++ b/tests/501-1000/841. keys-and-rooms/sol.cs @@ -0,0 +1,21 @@ +public class Solution { + public bool CanVisitAllRooms(IList> rooms) { + int n = rooms.Count; + Stack keys = new Stack(); + bool[] visited = new bool[n]; + keys.Push(0); + visited[0] = true; + int count = 1; + while (keys.Count > 0) { + int room = keys.Pop(); + foreach (int i in rooms[room]) { + if (!visited[i]) { + visited[i] = true; + keys.Push(i); + count++; + } + } + } + return count == n; + } +} diff --git a/tests/501-1000/841. keys-and-rooms/sol.dart b/tests/501-1000/841. keys-and-rooms/sol.dart new file mode 100644 index 00000000..f4852597 --- /dev/null +++ b/tests/501-1000/841. keys-and-rooms/sol.dart @@ -0,0 +1,20 @@ +class Solution { + bool canVisitAllRooms(List> rooms) { + int n = rooms.length; + List keys = [0]; + List visited = List.filled(n, false); + visited[0] = true; + int count = 1; + while (keys.isNotEmpty) { + int room = keys.removeLast(); + for (int i in rooms[room]) { + if (!visited[i]) { + visited[i] = true; + keys.add(i); + count++; + } + } + } + return count == n; + } +} diff --git a/tests/501-1000/841. keys-and-rooms/sol.go b/tests/501-1000/841. keys-and-rooms/sol.go new file mode 100644 index 00000000..3b0ce920 --- /dev/null +++ b/tests/501-1000/841. keys-and-rooms/sol.go @@ -0,0 +1,19 @@ +func canVisitAllRooms(rooms [][]int) bool { + n := len(rooms) + keys := []int{0} + visited := make([]bool, n) + visited[0] = true + count := 1 + for len(keys) > 0 { + room := keys[len(keys)-1] + keys = keys[:len(keys)-1] + for _, i := range rooms[room] { + if !visited[i] { + visited[i] = true + keys = append(keys, i) + count++ + } + } + } + return count == n +} diff --git a/tests/501-1000/841. keys-and-rooms/sol.java b/tests/501-1000/841. keys-and-rooms/sol.java new file mode 100644 index 00000000..9555bdb6 --- /dev/null +++ b/tests/501-1000/841. keys-and-rooms/sol.java @@ -0,0 +1,36 @@ +class Solution { + public boolean canVisitAllRooms(List> rooms) { + int n = rooms.size(); + if (n == 0) { + return true; + } + Deque keys = new ArrayDeque<>(); + boolean[] visited = new boolean[n]; + keys.push(0); + visited[0] = true; + int count = 1; + while (!keys.isEmpty()) { + int room = keys.pop(); + for (int i : rooms.get(room)) { + if (!visited[i]) { + visited[i] = true; + keys.push(i); + count++; + } + } + } + return count == n; + } + + public boolean canVisitAllRooms(int[][] rooms) { + List> converted = new ArrayList<>(rooms.length); + for (int[] room : rooms) { + List list = new ArrayList<>(room.length); + for (int key : room) { + list.add(key); + } + converted.add(list); + } + return canVisitAllRooms(converted); + } +} diff --git a/tests/501-1000/841. keys-and-rooms/sol.kt b/tests/501-1000/841. keys-and-rooms/sol.kt new file mode 100644 index 00000000..701ac80f --- /dev/null +++ b/tests/501-1000/841. keys-and-rooms/sol.kt @@ -0,0 +1,26 @@ +class Solution { + fun canVisitAllRooms(rooms: List>): Boolean { + val n = rooms.size + if (n == 0) return true + val keys = ArrayDeque() + val visited = BooleanArray(n) + keys.addLast(0) + visited[0] = true + var count = 1 + while (keys.isNotEmpty()) { + val room = keys.removeLast() + for (i in rooms[room]) { + if (!visited[i]) { + visited[i] = true + keys.addLast(i) + count++ + } + } + } + return count == n + } + + fun canVisitAllRooms(rooms: Array): Boolean { + return canVisitAllRooms(rooms.map { it.toList() }) + } +} diff --git a/tests/501-1000/841. keys-and-rooms/sol.py b/tests/501-1000/841. keys-and-rooms/sol.py new file mode 100644 index 00000000..02650b64 --- /dev/null +++ b/tests/501-1000/841. keys-and-rooms/sol.py @@ -0,0 +1,16 @@ +from collections import deque +from typing import List + + +class Solution: + def canVisitAllRooms(self, rooms: List[List[int]]) -> bool: + n = len(rooms) + key = deque([0]) + visited = {0} + while len(key) != 0: + room = key.popleft() + for i in rooms[room]: + if i not in visited: + visited.add(i) + key.append(i) + return len(visited) == n diff --git a/tests/501-1000/841. keys-and-rooms/sol.py2 b/tests/501-1000/841. keys-and-rooms/sol.py2 new file mode 100644 index 00000000..e32c71cd --- /dev/null +++ b/tests/501-1000/841. keys-and-rooms/sol.py2 @@ -0,0 +1,16 @@ +class Solution(object): + def canVisitAllRooms(self, rooms): + """ + :type rooms: List[List[int]] + :rtype: bool + """ + n = len(rooms) + keys = [0] + visited = {0} + while keys: + room = keys.pop() + for i in rooms[room]: + if i not in visited: + visited.add(i) + keys.append(i) + return len(visited) == n diff --git a/tests/501-1000/841. keys-and-rooms/sol.rb b/tests/501-1000/841. keys-and-rooms/sol.rb new file mode 100644 index 00000000..de21dd7a --- /dev/null +++ b/tests/501-1000/841. keys-and-rooms/sol.rb @@ -0,0 +1,17 @@ +# @param {Integer[][]} rooms +# @return {Boolean} +def can_visit_all_rooms(rooms) + n = rooms.length + keys = [0] + visited = {0 => true} + while !keys.empty? + room = keys.pop + rooms[room].each do |i| + unless visited[i] + visited[i] = true + keys.push(i) + end + end + end + visited.length == n +end diff --git a/tests/501-1000/841. keys-and-rooms/sol.rs b/tests/501-1000/841. keys-and-rooms/sol.rs new file mode 100644 index 00000000..417adada --- /dev/null +++ b/tests/501-1000/841. keys-and-rooms/sol.rs @@ -0,0 +1,20 @@ +impl Solution { + pub fn can_visit_all_rooms(rooms: Vec>) -> bool { + let n = rooms.len(); + let mut keys = vec![0]; + let mut visited = vec![false; n]; + visited[0] = true; + let mut count = 1; + while let Some(room) = keys.pop() { + for &i in &rooms[room] { + let i = i as usize; + if !visited[i] { + visited[i] = true; + keys.push(i); + count += 1; + } + } + } + count == n + } +} diff --git a/tests/501-1000/841. keys-and-rooms/sol.swift b/tests/501-1000/841. keys-and-rooms/sol.swift new file mode 100644 index 00000000..e4c45b40 --- /dev/null +++ b/tests/501-1000/841. keys-and-rooms/sol.swift @@ -0,0 +1,20 @@ +class Solution { + func canVisitAllRooms(_ rooms: [[Int]]) -> Bool { + let n = rooms.count + var keys = [0] + var visited = Array(repeating: false, count: n) + visited[0] = true + var count = 1 + while !keys.isEmpty { + let room = keys.removeLast() + for i in rooms[room] { + if !visited[i] { + visited[i] = true + keys.append(i) + count += 1 + } + } + } + return count == n + } +} diff --git a/tests/501-1000/841. keys-and-rooms/sol.ts b/tests/501-1000/841. keys-and-rooms/sol.ts new file mode 100644 index 00000000..0dfcfe31 --- /dev/null +++ b/tests/501-1000/841. keys-and-rooms/sol.ts @@ -0,0 +1,18 @@ +function canVisitAllRooms(rooms: number[][]): boolean { + const n = rooms.length; + const keys: number[] = [0]; + const visited: boolean[] = new Array(n).fill(false); + visited[0] = true; + let count = 1; + while (keys.length > 0) { + const room = keys.pop()!; + for (const i of rooms[room]) { + if (!visited[i]) { + visited[i] = true; + keys.push(i); + count++; + } + } + } + return count === n; +} diff --git a/tests/501-1000/842. split-array-into-fibonacci-sequence/manifest.yaml b/tests/501-1000/842. split-array-into-fibonacci-sequence/manifest.yaml new file mode 100644 index 00000000..6a209d2f --- /dev/null +++ b/tests/501-1000/842. split-array-into-fibonacci-sequence/manifest.yaml @@ -0,0 +1,331 @@ +entry: + id: 842 + title: split-array-into-fibonacci-sequence + params: + num: + type: string + call: + cpp: Solution().splitIntoFibonacci({num}) + rust: Solution::split_into_fibonacci({num}) + python3: Solution().splitIntoFibonacci({num}) + python2: Solution().splitIntoFibonacci({num}) + ruby: split_into_fibonacci({num}) + java: new Solution().splitIntoFibonacci({num}) + csharp: new Solution().SplitIntoFibonacci({num}) + kotlin: Solution().splitIntoFibonacci({num}) + go: splitIntoFibonacci({num}) + dart: Solution().splitIntoFibonacci({num}) + swift: Solution().splitIntoFibonacci({num}) + typescript: splitIntoFibonacci({num}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().splitIntoFibonacci(num, {result}) + checker: + "class Checker:\n def _valid(self, num):\n n = len(num)\n \ + \ def invalid(x):\n return x[0] == '0' and len(x) > 1 or int(x)\ + \ >= (1 << 31)\n\n def dfs(a0, a1, idx):\n if idx == n:\n\ + \ return True\n nxt = str(int(a0) + int(a1))\n \ + \ if invalid(nxt):\n return False\n if not\ + \ num.startswith(nxt, idx):\n return False\n return\ + \ dfs(a1, nxt, idx + len(nxt))\n\n for j in range(1, n):\n \ + \ for i in range(j):\n a0 = num[:i + 1]\n a1\ + \ = num[i + 1:j + 1]\n if invalid(a0) or invalid(a1):\n \ + \ continue\n if dfs(a0, a1, j + 1):\n \ + \ return True\n return False\n\n def splitIntoFibonacci(self,\ + \ num, result):\n if not isinstance(result, list):\n return\ + \ False\n if result:\n if len(result) < 3:\n \ + \ return False\n if any((not isinstance(x, int)) or x < 0 or x\ + \ >= (1 << 31) for x in result):\n return False\n \ + \ pieces = []\n for x in result:\n s = str(x)\n \ + \ if len(s) > 1 and s[0] == '0':\n return False\n\ + \ pieces.append(s)\n if ''.join(pieces) != num:\n\ + \ return False\n for i in range(len(result) - 2):\n\ + \ if result[i] + result[i + 1] != result[i + 2]:\n \ + \ return False\n return True\n return not self._valid(num)\n" +seed: 842842 +tests: + - name: ex1 + in: + num: "1101111" + out: + - 11 + - 0 + - 11 + - 11 + - name: ex2 + in: + num: "112358130" + out: [] + - name: ex3 + in: + num: "0123" + out: [] + - name: zero-chain + in: + num: "0000" + out: + - 0 + - 0 + - 0 + - 0 + - name: short-impossible + in: + num: "101" + out: + - 1 + - 0 + - 1 + - name: valid-triple + in: + num: "123" + out: + - 1 + - 2 + - 3 + - name: valid-six + in: + num: "112358" + out: + - 1 + - 1 + - 2 + - 3 + - 5 + - 8 + - name: leading-zero-blocked + in: + num: "011235" + out: + - 0 + - 1 + - 1 + - 2 + - 3 + - 5 + - name: max-int-boundary + in: + num: "214748364721474836422147483643" + out: [] + - name: near-boundary-invalid + in: + num: "214748364821474836492147483657" + out: [] + - name: long-no-solution + in: + num: "123456789012345678901234567890" + out: [] + - name: long-valid-like + in: + num: "8917" + out: + - 8 + - 9 + - 17 + - name: alt-valid + in: + num: "11235813" + out: + - 1 + - 1 + - 2 + - 3 + - 5 + - 8 + - 13 + - name: alt-invalid + in: + num: "110111111" + out: [] + - name: small-valid + in: + num: "1011" + out: + - 1 + - 0 + - 1 + - 1 + - name: example-three + in: + num: "123456579" + out: + - 123 + - 456 + - 579 + - name: impossible-long + in: + num: "11235813213455890144" + out: [] + - name: simple-valid-1123 + in: + num: "1123" + out: + - 1 + - 1 + - 2 + - 3 + - name: simple-valid-12122436 + in: + num: "12122436" + out: + - 12 + - 12 + - 24 + - 36 + - name: no-solution-1234567 + in: + num: "1234567" + out: [] + - name: valid-with-zero + in: + num: "101202303" + out: + - 101 + - 202 + - 303 + - name: valid-000 + in: + num: "000" + out: + - 0 + - 0 + - 0 + - name: valid-0000 + in: + num: "0000" + out: + - 0 + - 0 + - 0 + - 0 + - name: valid-1011 + in: + num: "1011" + out: + - 1 + - 0 + - 1 + - 1 + - name: valid-1101111-alt + in: + num: "1101111" + out: + - 11 + - 0 + - 11 + - 11 + - name: valid-123456579 + in: + num: "123456579" + out: + - 123 + - 456 + - 579 + - name: valid-11235813 + in: + num: "11235813" + out: + - 1 + - 1 + - 2 + - 3 + - 5 + - 8 + - 13 + - name: valid-198019823962 + in: + num: "198019823962" + out: + - 1980 + - 1982 + - 3962 + - name: invalid-prefix + in: + num: "1234" + out: [] + - name: invalid-gap + in: + num: "112358130" + out: [] + - name: invalid-overflow + in: + num: "214748364721474836422147483643" + out: [] + - name: invalid-ends-prematurely + in: + num: "1123581321345589144" + out: + - 1 + - 1 + - 2 + - 3 + - 5 + - 8 + - 13 + - 21 + - 34 + - 55 + - 89 + - 144 + - name: valid-8917 + in: + num: "8917" + out: + - 8 + - 9 + - 17 + - name: valid-123581321345589144 + in: + num: "123581321345589144" + out: + - 1 + - 2 + - 3 + - 5 + - 8 + - 13 + - 21 + - 34 + - 55 + - 89 + - 144 + - name: valid-1299110 + in: + num: "1299110" + out: [] + - name: invalid-short-101 + in: + num: "101" + out: + - 1 + - 0 + - 1 + - name: valid-123123246 + in: + num: "123123246" + out: + - 123 + - 123 + - 246 + - name: valid-11235813213455 + in: + num: "11235813213455" + out: + - 1 + - 1 + - 2 + - 3 + - 5 + - 8 + - 13 + - 21 + - 34 + - 55 + - name: invalid-31415926 + in: + num: "31415926" + out: [] diff --git a/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.cpp b/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.cpp new file mode 100644 index 00000000..ec696a36 --- /dev/null +++ b/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.cpp @@ -0,0 +1,43 @@ +class Solution { +private: + bool invalid(const string& x) { + if (x[0] == '0' && x.length() > 1) return true; + if (x.length() > 10) return true; + return stoll(x) >= (1LL << 31); + } + + vector check(string a0, string a1, string num) { + int i = 0; + vector ret = {stoi(a0), stoi(a1)}; + while (i < num.length()) { + long long a0Val = stoll(a0); + long long a1Val = stoll(a1); + string res = to_string(a0Val + a1Val); + int j = 0; + while (i < num.length() && j < res.length() && res[j] == num[i]) { + j++; + i++; + } + if (j < res.length() || invalid(res)) return {}; + a0 = a1; + a1 = res; + ret.push_back(stoi(res)); + } + return ret; + } + +public: + vector splitIntoFibonacci(string num) { + int n = num.length(); + for (int j = 1; j < n - 1; j++) { + for (int i = 0; i < j; i++) { + string a0 = num.substr(0, i + 1); + string a1 = num.substr(i + 1, j - i); + if (invalid(a0) || invalid(a1)) continue; + vector ret = check(a0, a1, num.substr(j + 1)); + if (!ret.empty()) return ret; + } + } + return {}; + } +}; diff --git a/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.cs b/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.cs new file mode 100644 index 00000000..0ce281ae --- /dev/null +++ b/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.cs @@ -0,0 +1,42 @@ +public class Solution { + private bool Invalid(string x) { + if (x[0] == '0' && x.Length > 1) return true; + if (x.Length > 10) return true; + return long.TryParse(x, out long value) ? value >= (1L << 31) : true; + } + + private IList Check(string a0, string a1, string num) { + int i = 0; + var ret = new List { int.Parse(a0), int.Parse(a1) }; + string curA0 = a0, curA1 = a1; + while (i < num.Length) { + long a0Val = long.Parse(curA0); + long a1Val = long.Parse(curA1); + string res = (a0Val + a1Val).ToString(); + int j = 0; + while (i < num.Length && j < res.Length && res[j] == num[i]) { + j++; + i++; + } + if (j < res.Length || Invalid(res)) return new List(); + curA0 = curA1; + curA1 = res; + ret.Add(int.Parse(res)); + } + return ret; + } + + public IList SplitIntoFibonacci(string num) { + int n = num.Length; + for (int j = 1; j < n - 1; j++) { + for (int i = 0; i < j; i++) { + string a0 = num.Substring(0, i + 1); + string a1 = num.Substring(i + 1, j - i); + if (Invalid(a0) || Invalid(a1)) continue; + IList ret = Check(a0, a1, num.Substring(j + 1)); + if (ret.Count > 0) return ret; + } + } + return new List(); + } +} diff --git a/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.dart b/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.dart new file mode 100644 index 00000000..c4b59ffc --- /dev/null +++ b/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.dart @@ -0,0 +1,42 @@ +class Solution { + List splitIntoFibonacci(String num) { + bool invalid(String x) { + if (x[0] == '0' && x.length > 1) return true; + if (x.length > 10) return true; + return int.parse(x) >= 2147483648; + } + + List check(String a0, String a1, String num) { + int i = 0; + List ret = [int.parse(a0), int.parse(a1)]; + String curA0 = a0, curA1 = a1; + while (i < num.length) { + int a0Val = int.parse(curA0); + int a1Val = int.parse(curA1); + String res = (a0Val + a1Val).toString(); + int j = 0; + while (i < num.length && j < res.length && res[j] == num[i]) { + j++; + i++; + } + if (j < res.length || invalid(res)) return []; + curA0 = curA1; + curA1 = res; + ret.add(int.parse(res)); + } + return ret; + } + + int n = num.length; + for (int j = 1; j < n - 1; j++) { + for (int i = 0; i < j; i++) { + String a0 = num.substring(0, i + 1); + String a1 = num.substring(i + 1, j + 1); + if (invalid(a0) || invalid(a1)) continue; + List ret = check(a0, a1, num.substring(j + 1)); + if (ret.isNotEmpty) return ret; + } + } + return []; + } +} diff --git a/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.go b/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.go new file mode 100644 index 00000000..950936aa --- /dev/null +++ b/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.go @@ -0,0 +1,49 @@ +func splitIntoFibonacci(num string) []int { + invalid := func(x string) bool { + return (x[0] == '0' && len(x) > 1) || len(x) > 10 || func() bool { + val, _ := strconv.ParseInt(x, 10, 64) + return val >= (1 << 31) + }() + } + + check := func(a0, a1, num string) []int { + i := 0 + a0Int, _ := strconv.Atoi(a0) + a1Int, _ := strconv.Atoi(a1) + ret := []int{a0Int, a1Int} + curA0, curA1 := a0, a1 + for i < len(num) { + a0Val, _ := strconv.ParseInt(curA0, 10, 64) + a1Val, _ := strconv.ParseInt(curA1, 10, 64) + res := strconv.FormatInt(a0Val + a1Val, 10) + j := 0 + for i < len(num) && j < len(res) && res[j] == num[i] { + j++ + i++ + } + if j < len(res) || invalid(res) { + return []int{} + } + curA0, curA1 = curA1, res + resInt, _ := strconv.Atoi(res) + ret = append(ret, resInt) + } + return ret + } + + n := len(num) + for j := 1; j < n-1; j++ { + for i := 0; i < j; i++ { + a0 := num[:i+1] + a1 := num[i+1:j+1] + if invalid(a0) || invalid(a1) { + continue + } + ret := check(a0, a1, num[j+1:]) + if len(ret) > 0 { + return ret + } + } + } + return []int{} +} diff --git a/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.java b/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.java new file mode 100644 index 00000000..e49d6dab --- /dev/null +++ b/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.java @@ -0,0 +1,47 @@ +class Solution { + public List splitIntoFibonacci(String num) { + int n = num.length(); + for (int j = 1; j < n - 1; j++) { + for (int i = 0; i < j; i++) { + String a0 = num.substring(0, i + 1); + String a1 = num.substring(i + 1, j + 1); + if (invalid(a0) || invalid(a1)) continue; + List ret = check(a0, a1, num.substring(j + 1)); + if (!ret.isEmpty()) return ret; + } + } + return new ArrayList<>(); + } + + private boolean invalid(String x) { + if (x.charAt(0) == '0' && x.length() > 1) { + return true; + } + if (x.length() > 10) { + return true; + } + return Long.parseLong(x) >= (1L << 31); + } + + private List check(String a0, String a1, String num) { + List ret = new ArrayList<>(); + ret.add(Integer.parseInt(a0)); + ret.add(Integer.parseInt(a1)); + int i = 0; + while (i < num.length()) { + long a0Val = Long.parseLong(a0); + long a1Val = Long.parseLong(a1); + String res = String.valueOf(a0Val + a1Val); + int j = 0; + while (i < num.length() && j < res.length() && res.charAt(j) == num.charAt(i)) { + j++; + i++; + } + if (j < res.length() || invalid(res)) return new ArrayList<>(); + a0 = a1; + a1 = res; + ret.add(Integer.parseInt(res)); + } + return ret; + } +} diff --git a/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.kt b/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.kt new file mode 100644 index 00000000..dcb09a5d --- /dev/null +++ b/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.kt @@ -0,0 +1,42 @@ +class Solution { + fun splitIntoFibonacci(num: String): List { + fun invalid(x: String): Boolean { + if (x[0] == '0' && x.length > 1) return true + if (x.length > 10) return true + return x.toLongOrNull()?.let { it >= (1L shl 31) } ?: true + } + + fun check(a0: String, a1: String, num: String): List { + var i = 0 + val ret = mutableListOf(a0.toInt(), a1.toInt()) + var curA0 = a0 + var curA1 = a1 + while (i < num.length) { + val sum = curA0.toLong() + curA1.toLong() + val res = sum.toString() + var j = 0 + while (i < num.length && j < res.length && res[j] == num[i]) { + j++ + i++ + } + if (j < res.length || invalid(res)) return emptyList() + curA0 = curA1 + curA1 = res + ret.add(res.toInt()) + } + return ret + } + + val n = num.length + for (j in 1 until n - 1) { + for (i in 0 until j) { + val a0 = num.substring(0, i + 1) + val a1 = num.substring(i + 1, j + 1) + if (invalid(a0) || invalid(a1)) continue + val ret = check(a0, a1, num.substring(j + 1)) + if (ret.isNotEmpty()) return ret + } + } + return emptyList() + } +} diff --git a/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.py b/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.py new file mode 100644 index 00000000..30b809e1 --- /dev/null +++ b/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.py @@ -0,0 +1,44 @@ +class Solution: + def splitIntoFibonacci(self, num: str) -> List[int]: + def invalid( + x, + ): # check if x has leading zeroes and is invalied or overflows (x > 2^31) + return x[0] == "0" and len(x) > 1 or int(x) >= (1 << 31) + + def check(a0, a1, num): + i = 0 + ret = [int(a0), int(a1)] + + while i < len(num): + a0 = int(a0) + a1 = int(a1) + + res = str(a0 + a1) + j = 0 + + while i < len(num) and j < len(res) and res[j] == num[i]: + j, i = j + 1, i + 1 + if j < len(res) or invalid(res): + return [] + + a0, a1 = a1, res + + ret.append(int(res)) + + return ret + + n = len(num) + + for j in range(1, n - 1): + for i in range(0, j): + a0 = num[: i + 1] + a1 = num[i + 1 : j + 1] + + if invalid(a0) or invalid(a1): + continue + + ret = check(a0, a1, num[j + 1 :]) + if ret: + return ret + + return [] diff --git a/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.py2 b/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.py2 new file mode 100644 index 00000000..e1e3fbda --- /dev/null +++ b/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.py2 @@ -0,0 +1,37 @@ +class Solution(object): + def splitIntoFibonacci(self, num): + """ + :type num: str + :rtype: List[int] + """ + def invalid(x): + return (x[0] == '0' and len(x) > 1) or int(x) >= (1 << 31) + + def check(a0, a1, num): + i = 0 + ret = [int(a0), int(a1)] + while i < len(num): + a0_int = int(a0) + a1_int = int(a1) + res = str(a0_int + a1_int) + j = 0 + while i < len(num) and j < len(res) and res[j] == num[i]: + j += 1 + i += 1 + if j < len(res) or invalid(res): + return [] + a0, a1 = a1, res + ret.append(int(res)) + return ret + + n = len(num) + for j in range(1, n-1): + for i in range(0, j): + a0 = num[:i+1] + a1 = num[i+1:j+1] + if invalid(a0) or invalid(a1): + continue + ret = check(a0, a1, num[j+1:]) + if ret: + return ret + return [] diff --git a/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.rb b/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.rb new file mode 100644 index 00000000..50838b45 --- /dev/null +++ b/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.rb @@ -0,0 +1,40 @@ +# @param {String} num +# @return {Integer[]} +def split_into_fibonacci(num) + invalid = lambda do |x| + (x[0] == '0' && x.length > 1) || x.to_i >= (1 << 31) + end + + check = lambda do |a0, a1, num_str| + i = 0 + ret = [a0.to_i, a1.to_i] + while i < num_str.length + a0_int = a0.to_i + a1_int = a1.to_i + res = (a0_int + a1_int).to_s + j = 0 + while i < num_str.length && j < res.length && res[j] == num_str[i] + j += 1 + i += 1 + end + if j < res.length || invalid.call(res) + return [] + end + a0, a1 = a1, res + ret.push(res.to_i) + end + ret + end + + n = num.length + (1...n-1).each do |j| + (0...j).each do |i| + a0 = num[0..i] + a1 = num[i+1..j] + next if invalid.call(a0) || invalid.call(a1) + ret = check.call(a0, a1, num[j+1..-1]) + return ret unless ret.empty? + end + end + [] +end diff --git a/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.rs b/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.rs new file mode 100644 index 00000000..e9cc2252 --- /dev/null +++ b/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.rs @@ -0,0 +1,55 @@ +impl Solution { + pub fn split_into_fibonacci(num: String) -> Vec { + fn invalid(x: &str) -> bool { + if x.starts_with('0') && x.len() > 1 { + return true; + } + if x.len() > 10 { + return true; + } + x.parse::().map(|v| v >= (1 << 31)).unwrap_or(true) + } + + fn check(a0: &str, a1: &str, num: &str) -> Vec { + let mut i = 0; + let mut ret = vec![a0.parse::().unwrap(), a1.parse::().unwrap()]; + let mut cur_a0 = a0.to_string(); + let mut cur_a1 = a1.to_string(); + let num_chars: Vec = num.chars().collect(); + while i < num_chars.len() { + let a0_val = cur_a0.parse::().unwrap(); + let a1_val = cur_a1.parse::().unwrap(); + let res = (a0_val + a1_val).to_string(); + let res_chars: Vec = res.chars().collect(); + let mut j = 0; + while i < num_chars.len() && j < res_chars.len() && res_chars[j] == num_chars[i] { + j += 1; + i += 1; + } + if j < res_chars.len() || invalid(&res) { + return vec![]; + } + cur_a0 = cur_a1; + cur_a1 = res.clone(); + ret.push(res.parse::().unwrap()); + } + ret + } + + let n = num.len(); + for j in 1..n-1 { + for i in 0..j { + let a0 = &num[0..=i]; + let a1 = &num[i+1..=j]; + if invalid(a0) || invalid(a1) { + continue; + } + let ret = check(a0, a1, &num[j+1..]); + if !ret.is_empty() { + return ret; + } + } + } + vec![] + } +} diff --git a/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.swift b/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.swift new file mode 100644 index 00000000..d3b0772f --- /dev/null +++ b/tests/501-1000/842. split-array-into-fibonacci-sequence/sol.swift @@ -0,0 +1,50 @@ +class Solution { + func splitIntoFibonacci(_ num: String) -> [Int] { + let chars = Array(num) + let n = chars.count + + func invalid(_ x: String) -> Bool { + if x.first == "0" && x.count > 1 { return true } + if x.count > 10 { return true } + return (Int(x) ?? Int.max) >= (1 << 31) + } + + func check(_ a0: String, _ a1: String, _ numStr: String) -> [Int] { + var i = 0 + let numChars = Array(numStr) + var ret = [Int(a0)!, Int(a1)!] + var curA0 = a0 + var curA1 = a1 + while i < numChars.count { + let a0Val = Int(curA0)! + let a1Val = Int(curA1)! + let res = String(a0Val + a1Val) + var j = 0 + let resChars = Array(res) + while i < numChars.count && j < resChars.count && resChars[j] == numChars[i] { + j += 1 + i += 1 + } + if j < resChars.count || invalid(res) { + return [] + } + curA0 = curA1 + curA1 = res + ret.append(Int(res)!) + } + return ret + } + + for j in 1.. { + return ( + (x[0] === "0" && x.length > 1) || x.length > 10 || Number(x) >= 2147483648 + ); + }; + + const check = (a0: string, a1: string, num: string): number[] => { + let i = 0; + const ret: number[] = [parseInt(a0), parseInt(a1)]; + let curA0 = a0, + curA1 = a1; + while (i < num.length) { + const a0Val = parseInt(curA0); + const a1Val = parseInt(curA1); + const res = (a0Val + a1Val).toString(); + let j = 0; + while (i < num.length && j < res.length && res[j] === num[i]) { + j++; + i++; + } + if (j < res.length || invalid(res)) return []; + curA0 = curA1; + curA1 = res; + ret.push(parseInt(res)); + } + return ret; + }; + + const n = num.length; + for (let j = 1; j < n - 1; j++) { + for (let i = 0; i < j; i++) { + const a0 = num.substring(0, i + 1); + const a1 = num.substring(i + 1, j + 1); + if (invalid(a0) || invalid(a1)) continue; + const ret = check(a0, a1, num.substring(j + 1)); + if (ret.length > 0) return ret; + } + } + return []; +} diff --git a/tests/501-1000/844. backspace-string-compare/manifest.yaml b/tests/501-1000/844. backspace-string-compare/manifest.yaml new file mode 100644 index 00000000..04534f81 --- /dev/null +++ b/tests/501-1000/844. backspace-string-compare/manifest.yaml @@ -0,0 +1,263 @@ +entry: + id: 844 + title: backspace-string-compare + params: + s: + type: string + t: + type: string + call: + cpp: Solution().backspaceCompare({s}, {t}) + rust: Solution::backspace_compare({s}, {t}) + python3: Solution().backspaceCompare({s}, {t}) + python2: Solution().backspaceCompare({s}, {t}) + ruby: backspace_compare({s}, {t}) + java: new Solution().backspaceCompare({s}, {t}) + csharp: new Solution().BackspaceCompare({s}, {t}) + kotlin: Solution().backspaceCompare({s}, {t}) + go: backspaceCompare({s}, {t}) + dart: Solution().backspaceCompare({s}, {t}) + swift: Solution().backspaceCompare({s}, {t}) + typescript: backspaceCompare({s}, {t}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().backspaceCompare(s, t, {result}) + checker: + "class Checker:\n def _reduce(self, text):\n stack = []\n \ + \ for ch in text:\n if ch == '#':\n if stack:\n\ + \ stack.pop()\n else:\n stack.append(ch)\n\ + \ return ''.join(stack)\n\n def backspaceCompare(self, s, t, result):\n\ + \ if not isinstance(result, bool):\n return False\n \ + \ return result == (self._reduce(s) == self._reduce(t))\n" +seed: 844844 +tests: + - name: ex1 + in: + s: ab#c + t: ad#c + out: true + - name: ex2 + in: + s: ab## + t: c#d# + out: true + - name: ex3 + in: + s: a#c + t: b + out: false + - name: both-empty + in: + s: "####" + t: "#" + out: true + - name: equal-after-many-backspaces + in: + s: xy#z## + t: x### + out: true + - name: mismatch-simple + in: + s: abc#d + t: abzz##d + out: true + - name: one-empty + in: + s: a## + t: "" + out: true + - name: long-alpha + in: + s: abcde####fgh#i + t: abfghi### + out: false + - name: leading-backspaces + in: + s: "###a" + t: a + out: true + - name: alternating + in: + s: a#b#c#d#e# + t: "#####" + out: true + - name: simple-false + in: + s: a + t: b + out: false + - name: simple-true + in: + s: a#b + t: b + out: true + - name: delete-to-empty + in: + s: abc### + t: d# + out: true + - name: no-backspaces + in: + s: abc + t: abc + out: true + - name: no-backspaces-false + in: + s: abc + t: abd + out: false + - name: backspace-overrun + in: + s: "######a" + t: a + out: true + - name: backspace-overrun-false + in: + s: "######a" + t: b + out: false + - name: chain-cancel + in: + s: ab###c + t: c + out: true + - name: chain-cancel-false + in: + s: ab###c + t: d + out: false + - name: same-final-length + in: + s: a#bc#d## + t: z##y#x### + out: true + - name: prefix-skip + in: + s: bxj##tw + t: bxo#j##tw + out: true + - name: prefix-skip-false + in: + s: bxj##tw + t: bxo#j##ty + out: false + - name: long-same + in: + s: aaaaaaaaaa########## + t: "" + out: true + - name: long-diff + in: + s: aaaaaaaaaa##########b + t: "" + out: false + - name: nested-backspaces + in: + s: ab##c#d + t: ad + out: false + - name: nested-backspaces-false + in: + s: ab##c#d + t: ac + out: false + - name: all-hash + in: + s: "##########" + t: "##########" + out: true + - name: gen-01 + in: + s: + gen: str + len: 20 + alphabet: abc# + t: + gen: str + len: 20 + alphabet: abc# + - name: gen-02 + in: + s: + gen: str + len: 50 + alphabet: abc# + t: + gen: str + len: 50 + alphabet: abc# + - name: gen-03 + in: + s: + gen: str + len: 100 + alphabet: abc# + t: + gen: str + len: 100 + alphabet: abc# + - name: gen-04 + in: + s: + gen: str + len: 150 + alphabet: abc# + t: + gen: str + len: 150 + alphabet: abc# + - name: gen-05 + in: + s: + gen: str + len: 200 + alphabet: abc# + t: + gen: str + len: 200 + alphabet: abc# + - name: long-true-1 + in: + s: abcdefghijklmnopqrstuvwxyz########################## + t: "" + out: true + - name: long-true-2 + in: + s: a#b#c#d#e#f#g#h#i#j#k#l#m#n#o#p#q#r#s#t#u#v#w#x#y#z# + t: "" + out: true + - name: long-false-2 + in: + s: abcdefghij####################k + t: "" + out: false + - name: cancel-different-final + in: + s: aa#b#c + t: c#d#e#f#g# + out: false + - name: equal-after-compaction + in: + s: ab#cd##e#f#g## + t: a#b#cdef###### + out: true + - name: equal-empty-with-leads + in: + s: "#a#b#c#" + t: "###" + out: true + - name: final-char-match + in: + s: z#y#x#q + t: q + out: true + - name: final-char-mismatch + in: + s: z#y#x#q + t: r + out: false diff --git a/tests/501-1000/844. backspace-string-compare/sol.cpp b/tests/501-1000/844. backspace-string-compare/sol.cpp new file mode 100644 index 00000000..cc7ea5b0 --- /dev/null +++ b/tests/501-1000/844. backspace-string-compare/sol.cpp @@ -0,0 +1,41 @@ +class Solution { +public: + bool backspaceCompare(string s, string t) { + auto getNextValidCharIndex = [](const string& str, int end) -> int { + int backspaceCount = 0; + while (end >= 0) { + if (str[end] == '#') { + backspaceCount++; + } else if (backspaceCount > 0) { + backspaceCount--; + } else { + break; + } + end--; + } + return end; + }; + + int ps = s.length() - 1; + int pt = t.length() - 1; + + while (ps >= 0 || pt >= 0) { + ps = getNextValidCharIndex(s, ps); + pt = getNextValidCharIndex(t, pt); + + if (ps < 0 && pt < 0) { + return true; + } + if (ps < 0 || pt < 0) { + return false; + } else if (s[ps] != t[pt]) { + return false; + } + + ps--; + pt--; + } + + return true; + } +}; diff --git a/tests/501-1000/844. backspace-string-compare/sol.cs b/tests/501-1000/844. backspace-string-compare/sol.cs new file mode 100644 index 00000000..d164cf10 --- /dev/null +++ b/tests/501-1000/844. backspace-string-compare/sol.cs @@ -0,0 +1,40 @@ +public class Solution { + public bool BackspaceCompare(string s, string t) { + int GetNextValidCharIndex(string str, int end) { + int backspaceCount = 0; + while (end >= 0) { + if (str[end] == '#') { + backspaceCount++; + } else if (backspaceCount > 0) { + backspaceCount--; + } else { + break; + } + end--; + } + return end; + } + + int ps = s.Length - 1; + int pt = t.Length - 1; + + while (ps >= 0 || pt >= 0) { + ps = GetNextValidCharIndex(s, ps); + pt = GetNextValidCharIndex(t, pt); + + if (ps < 0 && pt < 0) { + return true; + } + if (ps < 0 || pt < 0) { + return false; + } else if (s[ps] != t[pt]) { + return false; + } + + ps--; + pt--; + } + + return true; + } +} diff --git a/tests/501-1000/844. backspace-string-compare/sol.dart b/tests/501-1000/844. backspace-string-compare/sol.dart new file mode 100644 index 00000000..238f076c --- /dev/null +++ b/tests/501-1000/844. backspace-string-compare/sol.dart @@ -0,0 +1,40 @@ +class Solution { + bool backspaceCompare(String s, String t) { + int getNextValidCharIndex(String str, int end) { + int backspaceCount = 0; + while (end >= 0) { + if (str[end] == '#') { + backspaceCount++; + } else if (backspaceCount > 0) { + backspaceCount--; + } else { + break; + } + end--; + } + return end; + } + + int ps = s.length - 1; + int pt = t.length - 1; + + while (ps >= 0 || pt >= 0) { + ps = getNextValidCharIndex(s, ps); + pt = getNextValidCharIndex(t, pt); + + if (ps < 0 && pt < 0) { + return true; + } + if (ps < 0 || pt < 0) { + return false; + } else if (s[ps] != t[pt]) { + return false; + } + + ps--; + pt--; + } + + return true; + } +} diff --git a/tests/501-1000/844. backspace-string-compare/sol.go b/tests/501-1000/844. backspace-string-compare/sol.go new file mode 100644 index 00000000..673e8537 --- /dev/null +++ b/tests/501-1000/844. backspace-string-compare/sol.go @@ -0,0 +1,38 @@ +func backspaceCompare(s string, t string) bool { + getNextValidCharIndex := func(str string, end int) int { + backspaceCount := 0 + for end >= 0 { + if str[end] == '#' { + backspaceCount++ + } else if backspaceCount > 0 { + backspaceCount-- + } else { + break + } + end-- + } + return end + } + + ps := len(s) - 1 + pt := len(t) - 1 + + for ps >= 0 || pt >= 0 { + ps = getNextValidCharIndex(s, ps) + pt = getNextValidCharIndex(t, pt) + + if ps < 0 && pt < 0 { + return true + } + if ps < 0 || pt < 0 { + return false + } else if s[ps] != t[pt] { + return false + } + + ps-- + pt-- + } + + return true +} diff --git a/tests/501-1000/844. backspace-string-compare/sol.java b/tests/501-1000/844. backspace-string-compare/sol.java new file mode 100644 index 00000000..e54863e9 --- /dev/null +++ b/tests/501-1000/844. backspace-string-compare/sol.java @@ -0,0 +1,40 @@ +class Solution { + public boolean backspaceCompare(String s, String t) { + int ps = s.length() - 1; + int pt = t.length() - 1; + + while (ps >= 0 || pt >= 0) { + ps = getNextValidCharIndex(s, ps); + pt = getNextValidCharIndex(t, pt); + + if (ps < 0 && pt < 0) { + return true; + } + if (ps < 0 || pt < 0) { + return false; + } else if (s.charAt(ps) != t.charAt(pt)) { + return false; + } + + ps--; + pt--; + } + + return true; + } + + private int getNextValidCharIndex(String s, int end) { + int backspaceCount = 0; + while (end >= 0) { + if (s.charAt(end) == '#') { + backspaceCount++; + } else if (backspaceCount > 0) { + backspaceCount--; + } else { + break; + } + end--; + } + return end; + } +} diff --git a/tests/501-1000/844. backspace-string-compare/sol.kt b/tests/501-1000/844. backspace-string-compare/sol.kt new file mode 100644 index 00000000..372a6726 --- /dev/null +++ b/tests/501-1000/844. backspace-string-compare/sol.kt @@ -0,0 +1,41 @@ +class Solution { + fun backspaceCompare(s: String, t: String): Boolean { + var ps = s.length - 1 + var pt = t.length - 1 + + while (ps >= 0 || pt >= 0) { + ps = getNextValidCharIndex(s, ps) + pt = getNextValidCharIndex(t, pt) + + if (ps < 0 && pt < 0) { + return true + } + if (ps < 0 || pt < 0) { + return false + } else if (s[ps] != t[pt]) { + return false + } + + ps-- + pt-- + } + + return true + } + + private fun getNextValidCharIndex(s: String, end: Int): Int { + var backspaceCount = 0 + var current = end + while (current >= 0) { + if (s[current] == '#') { + backspaceCount++ + } else if (backspaceCount > 0) { + backspaceCount-- + } else { + break + } + current-- + } + return current + } +} diff --git a/tests/501-1000/844. backspace-string-compare/sol.py b/tests/501-1000/844. backspace-string-compare/sol.py new file mode 100644 index 00000000..b4f5176e --- /dev/null +++ b/tests/501-1000/844. backspace-string-compare/sol.py @@ -0,0 +1,41 @@ +class Solution: + def backspaceCompare(self, s: str, t: str) -> bool: + + def get_next_valid_char_index(s, end): + backspace_count = 0 + while end >= 0: + if s[end] == "#": + # find "#" + backspace_count += 1 + elif backspace_count > 0: + # find an alphabet but skip it because we have backspaces + backspace_count -= 1 + else: + # if we don't have backspaces and current character is alphabet + # it's time to compare two characters from s and t + break + end -= 1 + return end # return current end pointer for the next iteration. + + ps = len(s) - 1 + pt = len(t) - 1 + + while ps >= 0 or pt >= 0: + ps = get_next_valid_char_index(s, ps) + pt = get_next_valid_char_index(t, pt) + + if ps < 0 and pt < 0: + # example case s = "ab##" t = "c#d#", case 2 + return True + if ps < 0 or pt < 0: + # example case s = "ab#" t = "c#d#", case 3 + return False + elif s[ps] != t[pt]: + # example case s = "a#c" t = "b", case 4 + return False + + ps -= 1 + pt -= 1 + + # example case s = "ab#c" t = "ad#c", case 1 + return True diff --git a/tests/501-1000/844. backspace-string-compare/sol.py2 b/tests/501-1000/844. backspace-string-compare/sol.py2 new file mode 100644 index 00000000..18a4b137 --- /dev/null +++ b/tests/501-1000/844. backspace-string-compare/sol.py2 @@ -0,0 +1,37 @@ +class Solution(object): + def backspaceCompare(self, s, t): + """ + :type s: str + :type t: str + :rtype: bool + """ + def get_next_valid_char_index(s, end): + backspace_count = 0 + while end >= 0: + if s[end] == '#': + backspace_count += 1 + elif backspace_count > 0: + backspace_count -= 1 + else: + break + end -= 1 + return end + + ps = len(s) - 1 + pt = len(t) - 1 + + while ps >= 0 or pt >= 0: + ps = get_next_valid_char_index(s, ps) + pt = get_next_valid_char_index(t, pt) + + if ps < 0 and pt < 0: + return True + if ps < 0 or pt < 0: + return False + elif s[ps] != t[pt]: + return False + + ps -= 1 + pt -= 1 + + return True diff --git a/tests/501-1000/844. backspace-string-compare/sol.rb b/tests/501-1000/844. backspace-string-compare/sol.rb new file mode 100644 index 00000000..41cff61d --- /dev/null +++ b/tests/501-1000/844. backspace-string-compare/sol.rb @@ -0,0 +1,41 @@ +# @param {String} s +# @param {String} t +# @return {Boolean} +def backspace_compare(s, t) + def get_next_valid_char_index(str, last) + backspace_count = 0 + while last >= 0 + if str[last] == '#' + backspace_count += 1 + elsif backspace_count > 0 + backspace_count -= 1 + else + break + end + last -= 1 + end + last + end + + ps = s.length - 1 + pt = t.length - 1 + + while ps >= 0 || pt >= 0 + ps = get_next_valid_char_index(s, ps) + pt = get_next_valid_char_index(t, pt) + + if ps < 0 && pt < 0 + return true + end + if ps < 0 || pt < 0 + return false + elsif s[ps] != t[pt] + return false + end + + ps -= 1 + pt -= 1 + end + + true +end diff --git a/tests/501-1000/844. backspace-string-compare/sol.rs b/tests/501-1000/844. backspace-string-compare/sol.rs new file mode 100644 index 00000000..eacea3e5 --- /dev/null +++ b/tests/501-1000/844. backspace-string-compare/sol.rs @@ -0,0 +1,43 @@ +impl Solution { + pub fn backspace_compare(s: String, t: String) -> bool { + fn get_next_valid_char_index(s: &[u8], end: i32) -> i32 { + let mut backspace_count = 0; + let mut end = end; + while end >= 0 { + if s[end as usize] == b'#' { + backspace_count += 1; + } else if backspace_count > 0 { + backspace_count -= 1; + } else { + break; + } + end -= 1; + } + end + } + + let s_bytes = s.as_bytes(); + let t_bytes = t.as_bytes(); + let mut ps = s_bytes.len() as i32 - 1; + let mut pt = t_bytes.len() as i32 - 1; + + while ps >= 0 || pt >= 0 { + ps = get_next_valid_char_index(s_bytes, ps); + pt = get_next_valid_char_index(t_bytes, pt); + + if ps < 0 && pt < 0 { + return true; + } + if ps < 0 || pt < 0 { + return false; + } else if s_bytes[ps as usize] != t_bytes[pt as usize] { + return false; + } + + ps -= 1; + pt -= 1; + } + + true + } +} diff --git a/tests/501-1000/844. backspace-string-compare/sol.swift b/tests/501-1000/844. backspace-string-compare/sol.swift new file mode 100644 index 00000000..a08b7bf4 --- /dev/null +++ b/tests/501-1000/844. backspace-string-compare/sol.swift @@ -0,0 +1,43 @@ +class Solution { + func backspaceCompare(_ s: String, _ t: String) -> Bool { + func getNextValidCharIndex(_ str: [Character], _ end: Int) -> Int { + var backspaceCount = 0 + var current = end + while current >= 0 { + if str[current] == "#" { + backspaceCount += 1 + } else if backspaceCount > 0 { + backspaceCount -= 1 + } else { + break + } + current -= 1 + } + return current + } + + let sArr = Array(s) + let tArr = Array(t) + var ps = sArr.count - 1 + var pt = tArr.count - 1 + + while ps >= 0 || pt >= 0 { + ps = getNextValidCharIndex(sArr, ps) + pt = getNextValidCharIndex(tArr, pt) + + if ps < 0 && pt < 0 { + return true + } + if ps < 0 || pt < 0 { + return false + } else if sArr[ps] != tArr[pt] { + return false + } + + ps -= 1 + pt -= 1 + } + + return true + } +} diff --git a/tests/501-1000/844. backspace-string-compare/sol.ts b/tests/501-1000/844. backspace-string-compare/sol.ts new file mode 100644 index 00000000..d4665844 --- /dev/null +++ b/tests/501-1000/844. backspace-string-compare/sol.ts @@ -0,0 +1,38 @@ +function backspaceCompare(s: string, t: string): boolean { + function getNextValidCharIndex(str: string, end: number): number { + let backspaceCount = 0; + while (end >= 0) { + if (str[end] === "#") { + backspaceCount++; + } else if (backspaceCount > 0) { + backspaceCount--; + } else { + break; + } + end--; + } + return end; + } + + let ps = s.length - 1; + let pt = t.length - 1; + + while (ps >= 0 || pt >= 0) { + ps = getNextValidCharIndex(s, ps); + pt = getNextValidCharIndex(t, pt); + + if (ps < 0 && pt < 0) { + return true; + } + if (ps < 0 || pt < 0) { + return false; + } else if (s[ps] !== t[pt]) { + return false; + } + + ps--; + pt--; + } + + return true; +} diff --git a/tests/501-1000/845. longest-mountain-in-array/manifest.yaml b/tests/501-1000/845. longest-mountain-in-array/manifest.yaml new file mode 100644 index 00000000..1db1243f --- /dev/null +++ b/tests/501-1000/845. longest-mountain-in-array/manifest.yaml @@ -0,0 +1,187 @@ +entry: + id: 845 + title: longest-mountain-in-array + params: + arr: + type: array + items: + type: int + call: + cpp: Solution().longestMountain({arr}) + rust: Solution::longest_mountain({arr}) + python3: Solution().longestMountain({arr}) + python2: Solution().longestMountain({arr}) + ruby: longest_mountain({arr}) + java: new Solution().longestMountain({arr}) + csharp: new Solution().LongestMountain({arr}) + kotlin: Solution().longestMountain({arr}) + go: longestMountain({arr}) + dart: Solution().longestMountain({arr}) + swift: Solution().longestMountain({arr}) + typescript: longestMountain({arr}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().longestMountain(arr, {result}) + checker: | + class Checker: + def longestMountain(self, arr, result): + return result == Solution().longestMountain(arr) +seed: 845 +tests: + - name: empty + in: + arr: [] + out: 0 + - name: single + in: + arr: [1] + out: 0 + - name: two_increasing + in: + arr: [1, 2] + out: 0 + - name: two_equal + in: + arr: [2, 2] + out: 0 + - name: flat_three + in: + arr: [3, 3, 3] + out: 0 + - name: simple_mountain + in: + arr: [2, 1, 4, 7, 3, 2, 5] + out: 5 + - name: classic_example + in: + arr: [0, 2, 1, 0] + out: 4 + - name: no_descent + in: + arr: [1, 2, 3, 4, 5] + out: 0 + - name: no_ascent + in: + arr: [5, 4, 3, 2, 1] + out: 0 + - name: plateau_top + in: + arr: [1, 2, 2, 1] + out: 0 + - name: plateau_base + in: + arr: [1, 1, 2, 3, 2, 1] + out: 5 + - name: long_flat_prefix + in: + arr: [2, 2, 2, 3, 4, 5, 4, 3, 2] + out: 7 + - name: mountain_at_start + in: + arr: [1, 3, 5, 4, 2, 1] + out: 6 + - name: mountain_at_end + in: + arr: [9, 8, 7, 6, 5, 1, 2, 3, 4, 3, 2] + out: 6 + - name: two_mountains + in: + arr: [1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1] + out: 7 + - name: separated_mountains + in: + arr: [1, 2, 1, 0, 1, 2, 3, 2, 1] + out: 6 + - name: increasing_then_flat + in: + arr: [1, 2, 3, 3, 3] + out: 0 + - name: decreasing_then_flat + in: + arr: [5, 4, 3, 3, 2, 1] + out: 0 + - name: short_peak_invalid + in: + arr: [1, 2, 1, 2] + out: 3 + - name: vally_then_peak + in: + arr: [3, 2, 1, 2, 3, 4, 5, 4] + out: 6 + - name: multiple_equal_peaks + in: + arr: [0, 1, 2, 3, 3, 2, 1, 0] + out: 0 + - name: negative_values + in: + arr: [-5, -4, -3, -2, -3, -4, -5] + out: 7 + - name: negative_plateau + in: + arr: [-1, 0, 1, 1, 0, -1] + out: 0 + - name: zigzag_short + in: + arr: [1, 3, 2, 4, 3, 5, 4] + out: 3 + - name: long_valid_mountain + in: + arr: [0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0] + out: 11 + - name: mountain_with_noise_left + in: + arr: [5, 5, 1, 2, 3, 4, 3, 2] + out: 6 + - name: mountain_with_noise_right + in: + arr: [2, 3, 4, 5, 4, 3, 2, 2] + out: 7 + - name: multiple_candidates + in: + arr: [1, 2, 1, 2, 3, 4, 4, 3, 2, 1] + out: 3 + - name: nested_descents + in: + arr: [9, 8, 7, 6, 5, 4, 5, 6, 7, 6, 5, 4] + out: 7 + - name: small_mountain + in: + arr: [1, 2, 3, 2] + out: 4 + - name: invalid_small_plateau + in: + arr: [1, 2, 2] + out: 0 + - name: mountain_with_late_start + in: + arr: [4, 4, 4, 1, 2, 3, 2, 1] + out: 5 + - name: long_random_like + in: + arr: [8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 8, 9] + out: 10 + - name: two_equal_peaks + in: + arr: [1, 2, 3, 4, 3, 2, 1, 1, 2, 3, 2, 1] + out: 7 + - name: all_same_long + in: + arr: [6, 6, 6, 6, 6, 6, 6, 6] + out: 0 + - name: mountain_with_drop_then_rise + in: + arr: [1, 4, 7, 3, 2, 4, 6, 5, 4] + out: 5 + - name: long_plateau_middle + in: + arr: [1, 2, 3, 4, 4, 4, 3, 2, 1] + out: 0 + - name: descending_mountain_suffix + in: + arr: [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] + out: 0 diff --git a/tests/501-1000/845. longest-mountain-in-array/sol.cpp b/tests/501-1000/845. longest-mountain-in-array/sol.cpp new file mode 100644 index 00000000..376e989d --- /dev/null +++ b/tests/501-1000/845. longest-mountain-in-array/sol.cpp @@ -0,0 +1,26 @@ +class Solution { +public: + int longestMountain(vector& arr) { + int n = arr.size(); + int best = 0; + int i = 1; + + while (i < n - 1) { + if (arr[i - 1] < arr[i] && arr[i] > arr[i + 1]) { + int left = i - 1; + int right = i + 1; + while (left > 0 && arr[left - 1] < arr[left]) { + left--; + } + while (right < n - 1 && arr[right] > arr[right + 1]) { + right++; + } + best = max(best, right - left + 1); + i = right; + } + i++; + } + + return best; + } +}; diff --git a/tests/501-1000/845. longest-mountain-in-array/sol.cs b/tests/501-1000/845. longest-mountain-in-array/sol.cs new file mode 100644 index 00000000..ed1b1f07 --- /dev/null +++ b/tests/501-1000/845. longest-mountain-in-array/sol.cs @@ -0,0 +1,25 @@ +public class Solution { + public int LongestMountain(int[] arr) { + int n = arr.Length; + int best = 0; + int i = 1; + + while (i < n - 1) { + if (arr[i - 1] < arr[i] && arr[i] > arr[i + 1]) { + int left = i - 1; + int right = i + 1; + while (left > 0 && arr[left - 1] < arr[left]) { + left--; + } + while (right < n - 1 && arr[right] > arr[right + 1]) { + right++; + } + best = Math.Max(best, right - left + 1); + i = right; + } + i++; + } + + return best; + } +} diff --git a/tests/501-1000/845. longest-mountain-in-array/sol.dart b/tests/501-1000/845. longest-mountain-in-array/sol.dart new file mode 100644 index 00000000..d214e2d5 --- /dev/null +++ b/tests/501-1000/845. longest-mountain-in-array/sol.dart @@ -0,0 +1,27 @@ +class Solution { + int longestMountain(List arr) { + int n = arr.length; + int best = 0; + int i = 1; + + while (i < n - 1) { + if (arr[i - 1] < arr[i] && arr[i] > arr[i + 1]) { + int left = i - 1; + int right = i + 1; + while (left > 0 && arr[left - 1] < arr[left]) { + left--; + } + while (right < n - 1 && arr[right] > arr[right + 1]) { + right++; + } + if (right - left + 1 > best) { + best = right - left + 1; + } + i = right; + } + i++; + } + + return best; + } +} diff --git a/tests/501-1000/845. longest-mountain-in-array/sol.go b/tests/501-1000/845. longest-mountain-in-array/sol.go new file mode 100644 index 00000000..9ece11fc --- /dev/null +++ b/tests/501-1000/845. longest-mountain-in-array/sol.go @@ -0,0 +1,25 @@ +func longestMountain(arr []int) int { + n := len(arr) + best := 0 + i := 1 + + for i < n - 1 { + if arr[i - 1] < arr[i] && arr[i] > arr[i + 1] { + left := i - 1 + right := i + 1 + for left > 0 && arr[left - 1] < arr[left] { + left-- + } + for right < n - 1 && arr[right] > arr[right + 1] { + right++ + } + if right - left + 1 > best { + best = right - left + 1 + } + i = right + } + i++ + } + + return best +} diff --git a/tests/501-1000/845. longest-mountain-in-array/sol.java b/tests/501-1000/845. longest-mountain-in-array/sol.java new file mode 100644 index 00000000..9482d992 --- /dev/null +++ b/tests/501-1000/845. longest-mountain-in-array/sol.java @@ -0,0 +1,25 @@ +class Solution { + public int longestMountain(int[] arr) { + int n = arr.length; + int best = 0; + int i = 1; + + while (i < n - 1) { + if (arr[i - 1] < arr[i] && arr[i] > arr[i + 1]) { + int left = i - 1; + int right = i + 1; + while (left > 0 && arr[left - 1] < arr[left]) { + left--; + } + while (right < n - 1 && arr[right] > arr[right + 1]) { + right++; + } + best = Math.max(best, right - left + 1); + i = right; + } + i++; + } + + return best; + } +} diff --git a/tests/501-1000/845. longest-mountain-in-array/sol.kt b/tests/501-1000/845. longest-mountain-in-array/sol.kt new file mode 100644 index 00000000..9fff2197 --- /dev/null +++ b/tests/501-1000/845. longest-mountain-in-array/sol.kt @@ -0,0 +1,25 @@ +class Solution { + fun longestMountain(arr: IntArray): Int { + val n = arr.size + var best = 0 + var i = 1 + + while (i < n - 1) { + if (arr[i - 1] < arr[i] && arr[i] > arr[i + 1]) { + var left = i - 1 + var right = i + 1 + while (left > 0 && arr[left - 1] < arr[left]) { + left-- + } + while (right < n - 1 && arr[right] > arr[right + 1]) { + right++ + } + best = maxOf(best, right - left + 1) + i = right + } + i++ + } + + return best + } +} diff --git a/tests/501-1000/845. longest-mountain-in-array/sol.py b/tests/501-1000/845. longest-mountain-in-array/sol.py new file mode 100644 index 00000000..fd83cf50 --- /dev/null +++ b/tests/501-1000/845. longest-mountain-in-array/sol.py @@ -0,0 +1,22 @@ +from typing import List + + +class Solution: + def longestMountain(self, arr: List[int]) -> int: + n = len(arr) + best = 0 + i = 1 + + while i < n - 1: + if arr[i - 1] < arr[i] > arr[i + 1]: + left = i - 1 + right = i + 1 + while left > 0 and arr[left - 1] < arr[left]: + left -= 1 + while right < n - 1 and arr[right] > arr[right + 1]: + right += 1 + best = max(best, right - left + 1) + i = right + i += 1 + + return best diff --git a/tests/501-1000/845. longest-mountain-in-array/sol.py2 b/tests/501-1000/845. longest-mountain-in-array/sol.py2 new file mode 100644 index 00000000..60ae8018 --- /dev/null +++ b/tests/501-1000/845. longest-mountain-in-array/sol.py2 @@ -0,0 +1,23 @@ +class Solution(object): + def longestMountain(self, arr): + """ + :type arr: List[int] + :rtype: int + """ + n = len(arr) + best = 0 + i = 1 + + while i < n - 1: + if arr[i - 1] < arr[i] > arr[i + 1]: + left = i - 1 + right = i + 1 + while left > 0 and arr[left - 1] < arr[left]: + left -= 1 + while right < n - 1 and arr[right] > arr[right + 1]: + right += 1 + best = max(best, right - left + 1) + i = right + i += 1 + + return best diff --git a/tests/501-1000/845. longest-mountain-in-array/sol.rb b/tests/501-1000/845. longest-mountain-in-array/sol.rb new file mode 100644 index 00000000..8e801c3c --- /dev/null +++ b/tests/501-1000/845. longest-mountain-in-array/sol.rb @@ -0,0 +1,25 @@ +# @param {Integer[]} arr +# @return {Integer} +def longest_mountain(arr) + n = arr.length + best = 0 + i = 1 + + while i < n - 1 + if arr[i - 1] < arr[i] && arr[i] > arr[i + 1] + left = i - 1 + right = i + 1 + while left > 0 && arr[left - 1] < arr[left] + left -= 1 + end + while right < n - 1 && arr[right] > arr[right + 1] + right += 1 + end + best = [best, right - left + 1].max + i = right + end + i += 1 + end + + best +end diff --git a/tests/501-1000/845. longest-mountain-in-array/sol.rs b/tests/501-1000/845. longest-mountain-in-array/sol.rs new file mode 100644 index 00000000..9c153f74 --- /dev/null +++ b/tests/501-1000/845. longest-mountain-in-array/sol.rs @@ -0,0 +1,28 @@ +impl Solution { + pub fn longest_mountain(arr: Vec) -> i32 { + let n = arr.len(); + if n < 3 { + return 0; + } + let mut best = 0; + let mut i = 1; + + while i < n - 1 { + if arr[i - 1] < arr[i] && arr[i] > arr[i + 1] { + let mut left = i - 1; + let mut right = i + 1; + while left > 0 && arr[left - 1] < arr[left] { + left -= 1; + } + while right < n - 1 && arr[right] > arr[right + 1] { + right += 1; + } + best = best.max((right - left + 1) as i32); + i = right; + } + i += 1; + } + + best + } +} diff --git a/tests/501-1000/845. longest-mountain-in-array/sol.swift b/tests/501-1000/845. longest-mountain-in-array/sol.swift new file mode 100644 index 00000000..adba2f5d --- /dev/null +++ b/tests/501-1000/845. longest-mountain-in-array/sol.swift @@ -0,0 +1,25 @@ +class Solution { + func longestMountain(_ arr: [Int]) -> Int { + let n = arr.count + var best = 0 + var i = 1 + + while i < n - 1 { + if arr[i - 1] < arr[i] && arr[i] > arr[i + 1] { + var left = i - 1 + var right = i + 1 + while left > 0 && arr[left - 1] < arr[left] { + left -= 1 + } + while right < n - 1 && arr[right] > arr[right + 1] { + right += 1 + } + best = max(best, right - left + 1) + i = right + } + i += 1 + } + + return best + } +} diff --git a/tests/501-1000/845. longest-mountain-in-array/sol.ts b/tests/501-1000/845. longest-mountain-in-array/sol.ts new file mode 100644 index 00000000..52a1e7f1 --- /dev/null +++ b/tests/501-1000/845. longest-mountain-in-array/sol.ts @@ -0,0 +1,23 @@ +function longestMountain(arr: number[]): number { + const n = arr.length; + let best = 0; + let i = 1; + + while (i < n - 1) { + if (arr[i - 1] < arr[i] && arr[i] > arr[i + 1]) { + let left = i - 1; + let right = i + 1; + while (left > 0 && arr[left - 1] < arr[left]) { + left--; + } + while (right < n - 1 && arr[right] > arr[right + 1]) { + right++; + } + best = Math.max(best, right - left + 1); + i = right; + } + i++; + } + + return best; +} diff --git a/tests/501-1000/846. hand-of-straights/manifest.yaml b/tests/501-1000/846. hand-of-straights/manifest.yaml new file mode 100644 index 00000000..79df8f17 --- /dev/null +++ b/tests/501-1000/846. hand-of-straights/manifest.yaml @@ -0,0 +1,495 @@ +entry: + id: 846 + title: hand-of-straights + params: + hand: + type: array + items: + type: int + groupSize: + type: int + call: + cpp: Solution().isNStraightHand({hand}, {groupSize}) + rust: Solution::is_n_straight_hand({hand}, {groupSize}) + python3: Solution().isNStraightHand({hand}, {groupSize}) + python2: Solution().isNStraightHand({hand}, {groupSize}) + ruby: is_n_straight_hand({hand}, {groupSize}) + java: new Solution().isNStraightHand({hand}, {groupSize}) + csharp: new Solution().IsNStraightHand({hand}, {groupSize}) + kotlin: Solution().isNStraightHand({hand}, {groupSize}) + go: isNStraightHand({hand}, {groupSize}) + dart: Solution().isNStraightHand({hand}, {groupSize}) + swift: Solution().isNStraightHand({hand}, {groupSize}) + typescript: isNStraightHand({hand}, {groupSize}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().isNStraightHand(hand, groupSize, {result}) + checker: + "from collections import Counter\n\nclass Checker:\n def isNStraightHand(self,\ + \ hand, groupSize, result):\n if not isinstance(result, bool):\n \ + \ return False\n if groupSize <= 0 or len(hand) % groupSize !=\ + \ 0:\n return result is False\n cnt = Counter(hand)\n \ + \ keys = sorted(cnt)\n possible = True\n for x in keys:\n \ + \ while cnt[x] > 0:\n for y in range(x, x + groupSize):\n\ + \ if cnt[y] <= 0:\n possible = False\n\ + \ break\n cnt[y] -= 1\n \ + \ if not possible:\n break\n if not possible:\n\ + \ break\n return result == possible\n" +seed: 846846 +tests: + - name: ex1 + in: + hand: + - 1 + - 2 + - 3 + - 6 + - 2 + - 3 + - 4 + - 7 + - 8 + groupSize: 3 + out: true + - name: ex2 + in: + hand: + - 1 + - 2 + - 3 + - 4 + - 5 + groupSize: 4 + out: false + - name: single-card + in: + hand: + - 5 + groupSize: 1 + out: true + - name: impossible-size + in: + hand: + - 1 + - 2 + - 3 + groupSize: 2 + out: false + - name: duplicates-ok + in: + hand: + - 1 + - 2 + - 2 + - 3 + - 3 + - 4 + groupSize: 3 + out: true + - name: gap-failure + in: + hand: + - 1 + - 2 + - 4 + - 5 + - 6 + - 7 + groupSize: 3 + out: false + - name: all-same-fail + in: + hand: + - 9 + - 9 + - 9 + - 9 + groupSize: 2 + out: false + - name: zero-based-values + in: + hand: + - 0 + - 1 + - 2 + - 3 + groupSize: 2 + out: true + - name: repeated-runs + in: + hand: + - 8 + - 10 + - 12 + - 9 + - 11 + - 13 + groupSize: 3 + out: true + - name: long-valid + in: + hand: + - 100 + - 101 + - 102 + - 103 + - 104 + - 105 + - 106 + - 107 + groupSize: 4 + out: true + - name: exact-sequential-1 + in: + hand: + - 1 + - 2 + - 3 + groupSize: 3 + out: true + - name: exact-sequential-2 + in: + hand: + - 2 + - 3 + - 4 + groupSize: 3 + out: true + - name: exact-sequential-3 + in: + hand: + - 3 + - 4 + - 5 + - 6 + groupSize: 2 + out: true + - name: exact-sequential-4 + in: + hand: + - 1 + - 2 + - 3 + - 4 + - 6 + - 7 + - 8 + - 9 + groupSize: 4 + out: true + - name: exact-sequential-false-1 + in: + hand: + - 1 + - 2 + - 3 + - 5 + - 6 + - 7 + groupSize: 3 + out: true + - name: exact-sequential-false-2 + in: + hand: + - 1 + - 2 + - 3 + - 4 + - 5 + - 7 + groupSize: 3 + out: false + - name: exact-sequential-false-3 + in: + hand: + - 8 + - 9 + - 10 + - 12 + - 13 + - 14 + groupSize: 3 + out: true + - name: repeated-small-true + in: + hand: + - 1 + - 1 + - 2 + - 2 + - 3 + - 3 + groupSize: 3 + out: true + - name: repeated-small-false + in: + hand: + - 1 + - 1 + - 2 + - 3 + - 4 + - 4 + groupSize: 3 + out: false + - name: k-one-large + in: + hand: + - 1000000000 + - 1 + - 5 + - 5 + - 7 + groupSize: 1 + out: true + - name: k-all + in: + hand: + - 9 + - 8 + - 7 + - 6 + groupSize: 4 + out: true + - name: zeros-valid + in: + hand: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + groupSize: 3 + out: true + - name: zeros-invalid + in: + hand: + - 0 + - 1 + - 3 + - 4 + - 5 + - 6 + groupSize: 3 + out: false + - name: chain-two-groups + in: + hand: + - 10 + - 11 + - 12 + - 13 + - 14 + - 15 + groupSize: 3 + out: true + - name: chain-two-groups-false + in: + hand: + - 10 + - 11 + - 12 + - 14 + - 15 + - 16 + groupSize: 3 + out: true + - name: spaced-runs + in: + hand: + - 20 + - 21 + - 22 + - 30 + - 31 + - 32 + - 33 + - 34 + - 35 + groupSize: 3 + out: true + - name: spaced-runs-false + in: + hand: + - 20 + - 21 + - 23 + - 30 + - 31 + - 32 + - 33 + - 34 + - 35 + groupSize: 3 + out: false + - name: larger-hand-true + in: + hand: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + - 11 + - 12 + groupSize: 4 + out: true + - name: larger-hand-false + in: + hand: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 8 + - 9 + - 10 + - 11 + - 12 + - 13 + groupSize: 4 + out: false + - name: max-value-run + in: + hand: + - 999999996 + - 999999997 + - 999999998 + - 999999999 + - 1000000000 + - 1000000001 + groupSize: 3 + out: true + - name: max-value-valid + in: + hand: + - 999999998 + - 999999999 + - 1000000000 + - 1000000001 + - 1000000002 + - 1000000003 + groupSize: 3 + out: true + - name: max-value-invalid-gap + in: + hand: + - 999999998 + - 999999999 + - 1000000001 + - 1000000002 + - 1000000003 + - 1000000004 + groupSize: 3 + out: false + - name: four-groups-true + in: + hand: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + - 11 + - 12 + groupSize: 3 + out: true + - name: four-groups-false + in: + hand: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 9 + - 10 + - 11 + - 12 + - 13 + groupSize: 3 + out: false + in: + hand: + gen: array + len: 20 + of: + gen: int + min: 0 + max: 1000000000 + distinct: false + sorted: false + elemType: int + groupSize: 5 + - name: gen-02 + in: + hand: + gen: array + len: 30 + of: + gen: int + min: 0 + max: 1000000000 + distinct: false + sorted: false + elemType: int + groupSize: 3 + - name: gen-03 + in: + hand: + gen: array + len: 40 + of: + gen: int + min: 0 + max: 1000000000 + distinct: false + sorted: false + elemType: int + groupSize: 4 + - name: gen-04 + in: + hand: + gen: array + len: 60 + of: + gen: int + min: 0 + max: 1000000000 + distinct: false + sorted: false + elemType: int + groupSize: 6 + - name: gen-05 + in: + hand: + gen: array + len: 100 + of: + gen: int + min: 0 + max: 1000000000 + distinct: false + sorted: false + elemType: int + groupSize: 10 diff --git a/tests/501-1000/846. hand-of-straights/sol.cpp b/tests/501-1000/846. hand-of-straights/sol.cpp new file mode 100644 index 00000000..0ff99942 --- /dev/null +++ b/tests/501-1000/846. hand-of-straights/sol.cpp @@ -0,0 +1,31 @@ +class Solution { +public: + bool isNStraightHand(vector& hand, int groupSize) { + map hashmap; + for (int h : hand) { + hashmap[h]++; + } + + priority_queue, greater> minHeap; + for (auto& [k, _] : hashmap) { + minHeap.push(k); + } + + while (!minHeap.empty()) { + int first = minHeap.top(); + for (int i = first; i < first + groupSize; i++) { + if (hashmap.find(i) == hashmap.end()) { + return false; + } + hashmap[i]--; + if (hashmap[i] == 0) { + if (i != minHeap.top()) { + return false; + } + minHeap.pop(); + } + } + } + return true; + } +}; diff --git a/tests/501-1000/846. hand-of-straights/sol.cs b/tests/501-1000/846. hand-of-straights/sol.cs new file mode 100644 index 00000000..3dd7a76d --- /dev/null +++ b/tests/501-1000/846. hand-of-straights/sol.cs @@ -0,0 +1,31 @@ +public class Solution { + public bool IsNStraightHand(int[] hand, int groupSize) { + Dictionary hashmap = new Dictionary(); + foreach (int h in hand) { + if (hashmap.ContainsKey(h)) { + hashmap[h]++; + } else { + hashmap[h] = 1; + } + } + + var minHeap = new SortedSet(hashmap.Keys); + + while (minHeap.Count > 0) { + int first = minHeap.Min; + for (int i = first; i < first + groupSize; i++) { + if (!hashmap.ContainsKey(i)) { + return false; + } + hashmap[i]--; + if (hashmap[i] == 0) { + if (i != minHeap.Min) { + return false; + } + minHeap.Remove(i); + } + } + } + return true; + } +} diff --git a/tests/501-1000/846. hand-of-straights/sol.dart b/tests/501-1000/846. hand-of-straights/sol.dart new file mode 100644 index 00000000..ccc877b9 --- /dev/null +++ b/tests/501-1000/846. hand-of-straights/sol.dart @@ -0,0 +1,28 @@ +class Solution { + bool isNStraightHand(List hand, int groupSize) { + Map hashmap = {}; + for (int h in hand) { + hashmap[h] = (hashmap[h] ?? 0) + 1; + } + + List minHeap = hashmap.keys.toList()..sort(); + int idx = 0; + + while (idx < minHeap.length) { + int first = minHeap[idx]; + for (int i = first; i < first + groupSize; i++) { + if (!hashmap.containsKey(i)) { + return false; + } + hashmap[i] = hashmap[i]! - 1; + if (hashmap[i] == 0) { + if (i != minHeap[idx]) { + return false; + } + idx++; + } + } + } + return true; + } +} diff --git a/tests/501-1000/846. hand-of-straights/sol.go b/tests/501-1000/846. hand-of-straights/sol.go new file mode 100644 index 00000000..d2838d2a --- /dev/null +++ b/tests/501-1000/846. hand-of-straights/sol.go @@ -0,0 +1,31 @@ +func isNStraightHand(hand []int, groupSize int) bool { + hashmap := make(map[int]int) + for _, h := range hand { + hashmap[h]++ + } + + keys := make([]int, 0, len(hashmap)) + for k := range hashmap { + keys = append(keys, k) + } + sort.Ints(keys) + minHeap := keys + idx := 0 + + for idx < len(minHeap) { + first := minHeap[idx] + for i := first; i < first+groupSize; i++ { + if _, ok := hashmap[i]; !ok { + return false + } + hashmap[i]-- + if hashmap[i] == 0 { + if i != minHeap[idx] { + return false + } + idx++ + } + } + } + return true +} diff --git a/tests/501-1000/846. hand-of-straights/sol.java b/tests/501-1000/846. hand-of-straights/sol.java new file mode 100644 index 00000000..8f21775f --- /dev/null +++ b/tests/501-1000/846. hand-of-straights/sol.java @@ -0,0 +1,27 @@ +class Solution { + public boolean isNStraightHand(int[] hand, int groupSize) { + Map hashmap = new HashMap<>(); + for (int h : hand) { + hashmap.put(h, hashmap.getOrDefault(h, 0) + 1); + } + + PriorityQueue minHeap = new PriorityQueue<>(hashmap.keySet()); + + while (!minHeap.isEmpty()) { + int first = minHeap.peek(); + for (int i = first; i < first + groupSize; i++) { + if (!hashmap.containsKey(i)) { + return false; + } + hashmap.put(i, hashmap.get(i) - 1); + if (hashmap.get(i) == 0) { + if (i != minHeap.peek()) { + return false; + } + minHeap.poll(); + } + } + } + return true; + } +} diff --git a/tests/501-1000/846. hand-of-straights/sol.kt b/tests/501-1000/846. hand-of-straights/sol.kt new file mode 100644 index 00000000..1ad9ef55 --- /dev/null +++ b/tests/501-1000/846. hand-of-straights/sol.kt @@ -0,0 +1,27 @@ +class Solution { + fun isNStraightHand(hand: IntArray, groupSize: Int): Boolean { + val hashmap = mutableMapOf() + for (h in hand) { + hashmap[h] = hashmap.getOrDefault(h, 0) + 1 + } + + val minHeap = java.util.PriorityQueue(hashmap.keys) + + while (minHeap.isNotEmpty()) { + val first = minHeap.peek() + for (i in first until first + groupSize) { + if (!hashmap.containsKey(i)) { + return false + } + hashmap[i] = hashmap[i]!! - 1 + if (hashmap[i] == 0) { + if (i != minHeap.peek()) { + return false + } + minHeap.poll() + } + } + } + return true + } +} diff --git a/tests/501-1000/846. hand-of-straights/sol.py b/tests/501-1000/846. hand-of-straights/sol.py new file mode 100644 index 00000000..7342aa66 --- /dev/null +++ b/tests/501-1000/846. hand-of-straights/sol.py @@ -0,0 +1,22 @@ +class Solution: + def isNStraightHand(self, hand: List[int], groupSize: int) -> bool: + hashmap = {} + for h in hand: + hashmap[h] = hashmap.get(h, 0) + 1 + + minHeap = list(hashmap.keys()) + heapq.heapify(minHeap) + + while minHeap: + first = minHeap[0] + for i in range(first, first + groupSize): + if i not in hashmap: + return False + + hashmap[i] -= 1 + + if hashmap[i] == 0: + if i != minHeap[0]: + return False + heapq.heappop(minHeap) + return True diff --git a/tests/501-1000/846. hand-of-straights/sol.py2 b/tests/501-1000/846. hand-of-straights/sol.py2 new file mode 100644 index 00000000..e6db220f --- /dev/null +++ b/tests/501-1000/846. hand-of-straights/sol.py2 @@ -0,0 +1,26 @@ +class Solution(object): + def isNStraightHand(self, hand, groupSize): + """ + :type hand: List[int] + :type groupSize: int + :rtype: bool + """ + import heapq + hashmap = {} + for h in hand: + hashmap[h] = hashmap.get(h, 0) + 1 + + minHeap = list(hashmap.keys()) + heapq.heapify(minHeap) + + while minHeap: + first = minHeap[0] + for i in range(first, first + groupSize): + if i not in hashmap: + return False + hashmap[i] -= 1 + if hashmap[i] == 0: + if i != minHeap[0]: + return False + heapq.heappop(minHeap) + return True diff --git a/tests/501-1000/846. hand-of-straights/sol.rb b/tests/501-1000/846. hand-of-straights/sol.rb new file mode 100644 index 00000000..adbc09ed --- /dev/null +++ b/tests/501-1000/846. hand-of-straights/sol.rb @@ -0,0 +1,22 @@ +# @param {Integer[]} hand +# @param {Integer} group_size +# @return {Boolean} +def is_n_straight_hand(hand, group_size) + hashmap = Hash.new(0) + hand.each { |h| hashmap[h] += 1 } + + min_heap = hashmap.keys.sort + + until min_heap.empty? + first = min_heap[0] + (first...first + group_size).each do |i| + return false unless hashmap.key?(i) + hashmap[i] -= 1 + if hashmap[i] == 0 + return false if i != min_heap[0] + min_heap.shift + end + end + end + true +end diff --git a/tests/501-1000/846. hand-of-straights/sol.rs b/tests/501-1000/846. hand-of-straights/sol.rs new file mode 100644 index 00000000..b0f679c9 --- /dev/null +++ b/tests/501-1000/846. hand-of-straights/sol.rs @@ -0,0 +1,35 @@ +impl Solution { + pub fn is_n_straight_hand(hand: Vec, group_size: i32) -> bool { + use std::collections::{BinaryHeap, HashMap}; + use std::cmp::Reverse; + + let mut hashmap: HashMap = HashMap::new(); + for &h in &hand { + *hashmap.entry(h).or_insert(0) += 1; + } + + let mut min_heap: BinaryHeap> = BinaryHeap::new(); + for &k in hashmap.keys() { + min_heap.push(Reverse(k)); + } + + while let Some(&Reverse(first)) = min_heap.peek() { + for i in first..first + group_size { + if let Some(count) = hashmap.get_mut(&i) { + *count -= 1; + if *count == 0 { + if let Some(&Reverse(peek)) = min_heap.peek() { + if i != peek { + return false; + } + min_heap.pop(); + } + } + } else { + return false; + } + } + } + true + } +} diff --git a/tests/501-1000/846. hand-of-straights/sol.swift b/tests/501-1000/846. hand-of-straights/sol.swift new file mode 100644 index 00000000..97948cdf --- /dev/null +++ b/tests/501-1000/846. hand-of-straights/sol.swift @@ -0,0 +1,28 @@ +class Solution { + func isNStraightHand(_ hand: [Int], _ groupSize: Int) -> Bool { + var hashmap = [Int: Int]() + for h in hand { + hashmap[h, default: 0] += 1 + } + + var minHeap = hashmap.keys.sorted() + var idx = 0 + + while idx < minHeap.count { + let first = minHeap[idx] + for i in first.. = new Map(); + for (const h of hand) { + hashmap.set(h, (hashmap.get(h) || 0) + 1); + } + + const minHeap: number[] = Array.from(hashmap.keys()).sort((a, b) => a - b); + let idx = 0; + + while (idx < minHeap.length) { + const first = minHeap[idx]; + for (let i = first; i < first + groupSize; i++) { + if (!hashmap.has(i)) { + return false; + } + hashmap.set(i, hashmap.get(i)! - 1); + if (hashmap.get(i) === 0) { + if (i !== minHeap[idx]) { + return false; + } + idx++; + } + } + } + return true; +} diff --git a/tests/501-1000/847. shortest-path-visiting-all-nodes/manifest.yaml b/tests/501-1000/847. shortest-path-visiting-all-nodes/manifest.yaml new file mode 100644 index 00000000..67112f50 --- /dev/null +++ b/tests/501-1000/847. shortest-path-visiting-all-nodes/manifest.yaml @@ -0,0 +1,655 @@ +entry: + id: 847 + title: shortest-path-visiting-all-nodes + params: + graph: + type: array + items: + type: array + items: + type: int + call: + cpp: Solution().shortestPathLength({graph}) + rust: Solution::shortest_path_length({graph}) + python3: Solution().shortestPathLength({graph}) + python2: Solution().shortestPathLength({graph}) + ruby: shortest_path_length({graph}) + java: new Solution().shortestPathLength({graph}) + csharp: new Solution().ShortestPathLength({graph}) + kotlin: Solution().shortestPathLength({graph}) + go: shortestPathLength({graph}) + dart: Solution().shortestPathLength({graph}) + swift: Solution().shortestPathLength({graph}) + typescript: shortestPathLength({graph}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().shortestPathLength(graph, {result}) + checker: "from collections import deque\n\nclass Checker:\n def shortestPathLength(self, graph, result):\n n = len(graph)\n if n == 1:\n return result == 0\n full = (1 << n) - 1\n seen = [[False] * (1 << n) for _ in range(n)]\n q = deque()\n for i in range(n):\n mask = 1 << i\n q.append((i, mask, 0))\n seen[i][mask] = True\n while q:\n node, mask, dist = q.popleft()\n if mask == full:\n return result == dist\n for nei in graph[node]:\n new_mask = mask | (1 << nei)\n if not seen[nei][new_mask]:\n seen[nei][new_mask] = True\n q.append((nei, new_mask, dist + 1))\n return False\n" +seed: 847 +tests: + - name: single-node + in: + graph: + - [] + out: 0 + - name: two-nodes-edge + in: + graph: + - - 1 + - - 0 + out: 1 + - name: line-three + in: + graph: + - - 1 + - - 0 + - 2 + - - 1 + out: 2 + - name: star-four + in: + graph: + - - 1 + - 2 + - 3 + - - 0 + - - 0 + - - 0 + out: 4 + - name: cycle-four + in: + graph: + - - 1 + - 3 + - - 0 + - 2 + - - 1 + - 3 + - - 0 + - 2 + out: 3 + - name: complete-four + in: + graph: + - - 1 + - 2 + - 3 + - - 0 + - 2 + - 3 + - - 0 + - 1 + - 3 + - - 0 + - 1 + - 2 + out: 3 + - name: example-one + in: + graph: + - - 1 + - 2 + - 3 + - - 0 + - - 0 + - - 0 + out: 4 + - name: example-two + in: + graph: + - - 1 + - - 0 + - 2 + - 4 + - - 1 + - 3 + - 4 + - - 2 + - - 1 + - 2 + out: 4 + - name: path-four + in: + graph: + - - 1 + - - 0 + - 2 + - - 1 + - 3 + - - 2 + out: 3 + - name: broom-five + in: + graph: + - - 1 + - - 0 + - 2 + - 3 + - 4 + - - 1 + - - 1 + - - 1 + out: 6 + - name: lollipop-five + in: + graph: + - - 1 + - 4 + - - 0 + - 2 + - - 1 + - 3 + - - 2 + - 4 + - - 3 + - 0 + out: 4 + - name: double-star-six + in: + graph: + - - 1 + - 2 + - - 0 + - 3 + - 4 + - - 0 + - 5 + - - 1 + - - 1 + - - 2 + out: 6 + - name: path-five + in: + graph: + - - 1 + - - 0 + - 2 + - - 1 + - 3 + - - 2 + - 4 + - - 3 + out: 4 + - name: path-six + in: + graph: + - - 1 + - - 0 + - 2 + - - 1 + - 3 + - - 2 + - 4 + - - 3 + - 5 + - - 4 + out: 5 + - name: cycle-five + in: + graph: + - - 1 + - 4 + - - 0 + - 2 + - - 1 + - 3 + - - 2 + - 4 + - - 3 + - 0 + out: 4 + - name: cycle-six + in: + graph: + - - 1 + - 5 + - - 0 + - 2 + - - 1 + - 3 + - - 2 + - 4 + - - 3 + - 5 + - - 4 + - 0 + out: 5 + - name: star-five + in: + graph: + - - 1 + - 2 + - 3 + - 4 + - - 0 + - - 0 + - - 0 + - - 0 + out: 6 + - name: star-six + in: + graph: + - - 1 + - 2 + - 3 + - 4 + - 5 + - - 0 + - - 0 + - - 0 + - - 0 + - - 0 + out: 8 + - name: complete-five + in: + graph: + - - 1 + - 2 + - 3 + - 4 + - - 0 + - 2 + - 3 + - 4 + - - 0 + - 1 + - 3 + - 4 + - - 0 + - 1 + - 2 + - 4 + - - 0 + - 1 + - 2 + - 3 + out: 4 + - name: diamond-six + in: + graph: + - - 1 + - 2 + - - 0 + - 2 + - 3 + - - 0 + - 1 + - 3 + - 4 + - - 1 + - 2 + - 5 + - - 2 + - 5 + - - 3 + - 4 + out: 5 + - name: tree-six + in: + graph: + - - 1 + - 2 + - - 0 + - 3 + - 4 + - - 0 + - 5 + - - 1 + - - 1 + - - 2 + out: 6 + - name: ladder-six + in: + graph: + - - 1 + - 3 + - - 0 + - 2 + - 4 + - - 1 + - 5 + - - 0 + - 4 + - - 1 + - 3 + - 5 + - - 2 + - 4 + out: 5 + - name: bowtie-six + in: + graph: + - - 1 + - 2 + - - 0 + - 2 + - 3 + - - 0 + - 1 + - 4 + - - 1 + - 4 + - 5 + - - 2 + - 3 + - 5 + - - 3 + - 4 + out: 5 + - name: path-seven + in: + graph: + - - 1 + - - 0 + - 2 + - - 1 + - 3 + - - 2 + - 4 + - - 3 + - 5 + - - 4 + - 6 + - - 5 + out: 6 + - name: cycle-seven + in: + graph: + - - 1 + - 6 + - - 0 + - 2 + - - 1 + - 3 + - - 2 + - 4 + - - 3 + - 5 + - - 4 + - 6 + - - 5 + - 0 + out: 6 + - name: star-seven + in: + graph: + - - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - - 0 + - - 0 + - - 0 + - - 0 + - - 0 + - - 0 + out: 10 + - name: complete-six + in: + graph: + - - 1 + - 2 + - 3 + - 4 + - 5 + - - 0 + - 2 + - 3 + - 4 + - 5 + - - 0 + - 1 + - 3 + - 4 + - 5 + - - 0 + - 1 + - 2 + - 4 + - 5 + - - 0 + - 1 + - 2 + - 3 + - 5 + - - 0 + - 1 + - 2 + - 3 + - 4 + out: 5 + - name: complete-seven + in: + graph: + - - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - - 0 + - 2 + - 3 + - 4 + - 5 + - 6 + - - 0 + - 1 + - 3 + - 4 + - 5 + - 6 + - - 0 + - 1 + - 2 + - 4 + - 5 + - 6 + - - 0 + - 1 + - 2 + - 3 + - 5 + - 6 + - - 0 + - 1 + - 2 + - 3 + - 4 + - 6 + - - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + out: 6 + - name: house-seven + in: + graph: + - - 1 + - 2 + - - 0 + - 2 + - 3 + - - 0 + - 1 + - 4 + - - 1 + - 5 + - - 2 + - 5 + - - 3 + - 4 + - 6 + - - 5 + out: 6 + - name: barbell-eight + in: + graph: + - - 1 + - 2 + - 3 + - - 0 + - 2 + - 3 + - - 0 + - 1 + - 3 + - 4 + - - 0 + - 1 + - 2 + - 5 + - - 2 + - 6 + - - 3 + - 7 + - - 4 + - 7 + - - 5 + - 6 + out: 7 + - name: balanced-tree-seven + in: + graph: + elemType: int + value: + - - 1 + - 2 + - - 0 + - 3 + - 4 + - - 0 + - 5 + - 6 + - - 1 + - - 1 + - - 2 + - - 2 + out: 8 + - name: clique-bridge-eight + in: + graph: + elemType: int + value: + - - 1 + - 2 + - 3 + - - 0 + - 2 + - 3 + - - 0 + - 1 + - 3 + - 4 + - - 0 + - 1 + - 2 + - - 2 + - 5 + - 6 + - - 4 + - 7 + - - 4 + - 7 + - - 5 + - 6 + out: 7 + - name: wheel-eight + in: + graph: + elemType: int + value: + - - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - - 0 + - 2 + - 7 + - - 0 + - 1 + - 3 + - - 0 + - 2 + - 4 + - - 0 + - 3 + - 5 + - - 0 + - 4 + - 6 + - - 0 + - 5 + - 7 + - - 0 + - 6 + - 1 + out: 7 + - name: line-twelve + in: + graph: + elemType: int + value: + - - 1 + - - 0 + - 2 + - - 1 + - 3 + - - 2 + - 4 + - - 3 + - 5 + - - 4 + - 6 + - - 5 + - 7 + - - 6 + - 8 + - - 7 + - 9 + - - 8 + - 10 + - - 9 + - 11 + - - 10 + out: 11 + - name: star-twelve + in: + graph: + elemType: int + value: + - - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + - 11 + - - 0 + - - 0 + - - 0 + - - 0 + - - 0 + - - 0 + - - 0 + - - 0 + - - 0 + - - 0 + - - 0 + out: 20 diff --git a/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.cpp b/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.cpp new file mode 100644 index 00000000..4196a06c --- /dev/null +++ b/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.cpp @@ -0,0 +1,35 @@ +class Solution { +public: + int shortestPathLength(vector>& graph) { + int n = graph.size(); + if (n == 1) return 0; + + int FULL = (1 << n) - 1; + vector> visited(n, vector(1 << n, false)); + queue> q; + + for (int i = 0; i < n; i++) { + int mask = 1 << i; + q.push({i, mask, 0}); + visited[i][mask] = true; + } + + while (!q.empty()) { + auto [node, mask, dist] = q.front(); + q.pop(); + + if (mask == FULL) return dist; + + for (int nei : graph[node]) { + int newMask = mask | (1 << nei); + + if (!visited[nei][newMask]) { + visited[nei][newMask] = true; + q.push({nei, newMask, dist + 1}); + } + } + } + + return -1; + } +}; diff --git a/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.cs b/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.cs new file mode 100644 index 00000000..f65603c7 --- /dev/null +++ b/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.cs @@ -0,0 +1,37 @@ +public class Solution { + public int ShortestPathLength(int[][] graph) { + int n = graph.Length; + if (n == 1) return 0; + + int FULL = (1 << n) - 1; + bool[][] visited = new bool[n][]; + for (int i = 0; i < n; i++) { + visited[i] = new bool[1 << n]; + } + + var q = new Queue<(int node, int mask, int dist)>(); + + for (int i = 0; i < n; i++) { + int mask = 1 << i; + q.Enqueue((i, mask, 0)); + visited[i][mask] = true; + } + + while (q.Count > 0) { + var (node, mask, dist) = q.Dequeue(); + + if (mask == FULL) return dist; + + foreach (int nei in graph[node]) { + int newMask = mask | (1 << nei); + + if (!visited[nei][newMask]) { + visited[nei][newMask] = true; + q.Enqueue((nei, newMask, dist + 1)); + } + } + } + + return -1; + } +} diff --git a/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.dart b/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.dart new file mode 100644 index 00000000..0920473d --- /dev/null +++ b/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.dart @@ -0,0 +1,34 @@ +class Solution { + int shortestPathLength(List> graph) { + int n = graph.length; + if (n == 1) return 0; + + int FULL = (1 << n) - 1; + List> visited = List.generate(n, (_) => List.filled(1 << n, false)); + var q = >[]; + + for (int i = 0; i < n; i++) { + int mask = 1 << i; + q.add([i, mask, 0]); + visited[i][mask] = true; + } + + while (q.isNotEmpty) { + var cur = q.removeAt(0); + int node = cur[0], mask = cur[1], dist = cur[2]; + + if (mask == FULL) return dist; + + for (int nei in graph[node]) { + int newMask = mask | (1 << nei); + + if (!visited[nei][newMask]) { + visited[nei][newMask] = true; + q.add([nei, newMask, dist + 1]); + } + } + } + + return -1; + } +} diff --git a/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.go b/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.go new file mode 100644 index 00000000..14b1a454 --- /dev/null +++ b/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.go @@ -0,0 +1,43 @@ +func shortestPathLength(graph [][]int) int { + n := len(graph) + if n == 1 { + return 0 + } + + FULL := (1 << n) - 1 + visited := make([][]bool, n) + for i := range visited { + visited[i] = make([]bool, 1< 0 { + cur := q[0] + q = q[1:] + + if cur.mask == FULL { + return cur.dist + } + + for _, nei := range graph[cur.node] { + newMask := cur.mask | (1 << nei) + + if !visited[nei][newMask] { + visited[nei][newMask] = true + q = append(q, state{nei, newMask, cur.dist + 1}) + } + } + } + + return -1 +} diff --git a/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.java b/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.java new file mode 100644 index 00000000..f8c8013c --- /dev/null +++ b/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.java @@ -0,0 +1,34 @@ +class Solution { + public int shortestPathLength(int[][] graph) { + int n = graph.length; + if (n == 1) return 0; + + int FULL = (1 << n) - 1; + boolean[][] visited = new boolean[n][1 << n]; + java.util.Queue q = new java.util.LinkedList<>(); + + for (int i = 0; i < n; i++) { + int mask = 1 << i; + q.offer(new int[]{i, mask, 0}); + visited[i][mask] = true; + } + + while (!q.isEmpty()) { + int[] cur = q.poll(); + int node = cur[0], mask = cur[1], dist = cur[2]; + + if (mask == FULL) return dist; + + for (int nei : graph[node]) { + int newMask = mask | (1 << nei); + + if (!visited[nei][newMask]) { + visited[nei][newMask] = true; + q.offer(new int[]{nei, newMask, dist + 1}); + } + } + } + + return -1; + } +} diff --git a/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.kt b/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.kt new file mode 100644 index 00000000..d08d8dcf --- /dev/null +++ b/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.kt @@ -0,0 +1,33 @@ +class Solution { + fun shortestPathLength(graph: Array): Int { + val n = graph.size + if (n == 1) return 0 + + val FULL = (1 shl n) - 1 + val visited = Array(n) { BooleanArray(1 shl n) } + val q = java.util.LinkedList>() + + for (i in 0 until n) { + val mask = 1 shl i + q.offer(Triple(i, mask, 0)) + visited[i][mask] = true + } + + while (q.isNotEmpty()) { + val (node, mask, dist) = q.poll() + + if (mask == FULL) return dist + + for (nei in graph[node]) { + val newMask = mask or (1 shl nei) + + if (!visited[nei][newMask]) { + visited[nei][newMask] = true + q.offer(Triple(nei, newMask, dist + 1)) + } + } + } + + return -1 + } +} diff --git a/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.py b/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.py new file mode 100644 index 00000000..f8eb9375 --- /dev/null +++ b/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.py @@ -0,0 +1,44 @@ +from collections import deque + + +class Solution: + def shortestPathLength(self, graph: List[List[int]]) -> int: + """ + Shortest path visiting all nodes in a connected undirected graph. + + Approach: + • BFS over states (node, visited_mask). + • visited_mask is a bitmask of visited vertices. + • Multi-source BFS allows starting from any node. + """ + + n = len(graph) + if n == 1: + return 0 + + FULL = (1 << n) - 1 # mask with all nodes visited + visited = [[False] * (1 << n) for _ in range(n)] + q = deque() + + # Initialize BFS from every node + for i in range(n): + mask = 1 << i + q.append((i, mask, 0)) + visited[i][mask] = True + + while q: + node, mask, dist = q.popleft() + + # All nodes visited → shortest distance found + if mask == FULL: + return dist + + for nei in graph[node]: + new_mask = mask | (1 << nei) + + # Avoid revisiting identical states + if not visited[nei][new_mask]: + visited[nei][new_mask] = True + q.append((nei, new_mask, dist + 1)) + + return -1 # unreachable for connected graph diff --git a/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.py2 b/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.py2 new file mode 100644 index 00000000..3bf63309 --- /dev/null +++ b/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.py2 @@ -0,0 +1,35 @@ +class Solution(object): + def shortestPathLength(self, graph): + """ + :type graph: List[List[int]] + :rtype: int + """ + from collections import deque + + n = len(graph) + if n == 1: + return 0 + + FULL = (1 << n) - 1 + visited = [[False] * (1 << n) for _ in range(n)] + q = deque() + + for i in range(n): + mask = 1 << i + q.append((i, mask, 0)) + visited[i][mask] = True + + while q: + node, mask, dist = q.popleft() + + if mask == FULL: + return dist + + for nei in graph[node]: + new_mask = mask | (1 << nei) + + if not visited[nei][new_mask]: + visited[nei][new_mask] = True + q.append((nei, new_mask, dist + 1)) + + return -1 diff --git a/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.rb b/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.rb new file mode 100644 index 00000000..2e50ab9c --- /dev/null +++ b/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.rb @@ -0,0 +1,33 @@ +# @param {Integer[][]} graph +# @return {Integer} +def shortest_path_length(graph) + n = graph.length + return 0 if n == 1 + + full = (1 << n) - 1 + visited = Array.new(n) { Array.new(1 << n, false) } + queue = [] + + n.times do |i| + mask = 1 << i + queue << [i, mask, 0] + visited[i][mask] = true + end + + while !queue.empty? + node, mask, dist = queue.shift + + return dist if mask == full + + graph[node].each do |nei| + new_mask = mask | (1 << nei) + + unless visited[nei][new_mask] + visited[nei][new_mask] = true + queue << [nei, new_mask, dist + 1] + end + end + end + + -1 +end diff --git a/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.rs b/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.rs new file mode 100644 index 00000000..f1fb02f1 --- /dev/null +++ b/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.rs @@ -0,0 +1,36 @@ +impl Solution { + pub fn shortest_path_length(graph: Vec>) -> i32 { + let n = graph.len(); + if n == 1 { + return 0; + } + + let full = (1 << n) - 1; + let mut visited = vec![vec![false; 1 << n]; n]; + let mut queue = std::collections::VecDeque::new(); + + for i in 0..n { + let mask = 1 << i; + queue.push_back((i, mask, 0)); + visited[i][mask] = true; + } + + while let Some((node, mask, dist)) = queue.pop_front() { + if mask == full { + return dist; + } + + for &nei in &graph[node] { + let nei = nei as usize; + let new_mask = mask | (1 << nei); + + if !visited[nei][new_mask] { + visited[nei][new_mask] = true; + queue.push_back((nei, new_mask, dist + 1)); + } + } + } + + -1 + } +} diff --git a/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.swift b/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.swift new file mode 100644 index 00000000..d4bbf63b --- /dev/null +++ b/tests/501-1000/847. shortest-path-visiting-all-nodes/sol.swift @@ -0,0 +1,35 @@ +class Solution { + func shortestPathLength(_ graph: [[Int]]) -> Int { + let n = graph.count + if n == 1 { return 0 } + + let FULL = (1 << n) - 1 + var visited = Array(repeating: Array(repeating: false, count: 1 << n), count: n) + var queue = [(Int, Int, Int)]() + + for i in 0.. + Array(1 << n).fill(false), + ); + const queue: [number, number, number][] = []; + + for (let i = 0; i < n; i++) { + const mask = 1 << i; + queue.push([i, mask, 0]); + visited[i][mask] = true; + } + + let front = 0; + while (front < queue.length) { + const [node, mask, dist] = queue[front++]; + + if (mask === FULL) return dist; + + for (const nei of graph[node]) { + const newMask = mask | (1 << nei); + + if (!visited[nei][newMask]) { + visited[nei][newMask] = true; + queue.push([nei, newMask, dist + 1]); + } + } + } + + return -1; +} diff --git a/tests/501-1000/848. shifting-letters/manifest.yaml b/tests/501-1000/848. shifting-letters/manifest.yaml new file mode 100644 index 00000000..5c098efe --- /dev/null +++ b/tests/501-1000/848. shifting-letters/manifest.yaml @@ -0,0 +1,103394 @@ +entry: + id: 848 + title: shifting-letters + params: + s: + type: string + shifts: + type: array + items: + type: int + call: + cpp: Solution().shiftingLetters({s}, {shifts}) + rust: Solution::shifting_letters({s}, {shifts}) + python3: Solution().shiftingLetters({s}, {shifts}) + python2: Solution().shiftingLetters({s}, {shifts}) + ruby: shifting_letters({s}, {shifts}) + java: new Solution().shiftingLetters({s}, {shifts}) + csharp: new Solution().ShiftingLetters({s}, {shifts}) + kotlin: Solution().shiftingLetters({s}, {shifts}) + go: shiftingLetters({s}, {shifts}) + dart: Solution().shiftingLetters({s}, {shifts}) + swift: Solution().shiftingLetters({s}, {shifts}) + typescript: shiftingLetters({s}, {shifts}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().shiftingLetters(s, shifts, {result}) + checker: "class Checker:\n def shiftingLetters(self, s, shifts, result):\n total = 0\n suffix = [0] * len(shifts)\n for i in range(len(shifts) - 1, -1, -1):\n total = (total + shifts[i]) % 26\n suffix[i] = total\n expected = []\n for ch, add in zip(s, suffix):\n expected.append(chr((ord(ch) - 97 + add) % 26 + 97))\n return result == \"\".join(expected)\n" +seed: 848 +tests: + - name: example-1 + in: + s: abc + shifts: + - 3 + - 5 + - 9 + out: rpl + - name: example-2 + in: + s: aaa + shifts: + - 1 + - 2 + - 3 + out: gfd + - name: single-wrap + in: + s: z + shifts: + - 1 + out: a + - name: single-large + in: + s: a + shifts: + - 1000000000 + out: m + - name: two-chars + in: + s: az + shifts: + - 1 + - 0 + out: bz + - name: all-zero + in: + s: open + shifts: + - 0 + - 0 + - 0 + - 0 + out: open + - name: all-26 + in: + s: abcd + shifts: + - 26 + - 26 + - 26 + - 26 + out: abcd + - name: small-mixed + in: + s: leet + shifts: + - 2 + - 3 + - 4 + - 5 + out: zqny + - name: descending-shifts + in: + s: xyz + shifts: + - 25 + - 24 + - 23 + out: rtw + - name: alternating + in: + s: azaz + shifts: + - 1 + - 0 + - 1 + - 0 + out: cabz + - name: prefix-only + in: + s: hello + shifts: + - 5 + - 0 + - 0 + - 0 + - 0 + out: mello + - name: suffix-heavy + in: + s: abcde + shifts: + - 0 + - 0 + - 0 + - 0 + - 25 + out: zabcd + - name: wrap-many + in: + s: zzzz + shifts: + - 1 + - 1 + - 1 + - 1 + out: dcba + - name: max-values-short + in: + s: abc + shifts: + - 1000000000 + - 1000000000 + - 1000000000 + out: kzo + - name: increasing-6 + in: + s: abcdef + shifts: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + out: vvuspl + - name: decreasing-6 + in: + s: abcdef + shifts: + - 6 + - 5 + - 4 + - 3 + - 2 + - 1 + out: vqmjhg + - name: palindrome + in: + s: racecar + shifts: + - 3 + - 1 + - 4 + - 1 + - 5 + - 9 + - 2 + out: qwxvslt + - name: repeated-a + in: + s: aaaaaaaaaa + shifts: + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + out: kjihgfedcb + - name: repeated-z + in: + s: zzzzzzzz + shifts: + - 2 + - 4 + - 6 + - 8 + - 10 + - 12 + - 14 + - 16 + out: trnhzpdp + - name: mod-26-pattern + in: + s: spartan + shifts: + - 26 + - 52 + - 78 + - 104 + - 130 + - 156 + - 182 + out: spartan + - name: prime-shifts + in: + s: numbers + shifts: + - 2 + - 3 + - 5 + - 7 + - 11 + - 13 + - 17 + out: tynxtvj + - name: fibonacci-shifts + in: + s: fibo + shifts: + - 1 + - 1 + - 2 + - 3 + out: mogr + - name: zero-and-max + in: + s: azbycxdw + shifts: + - 0 + - 1000000000 + - 0 + - 1000000000 + - 0 + - 1000000000 + - 0 + - 1000000000 + out: wvliavpi + - name: alphabet-once + in: + s: abcdefghijklmnopqrstuvwxyz + shifts: + - 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 + out: nnmkhdysldukznamxhqyflquxz + - name: alphabet-reverse + in: + s: zyxwvutsrqponmlkjihgfedcba + shifts: + - 26 + - 25 + - 24 + - 23 + - 22 + - 21 + - 20 + - 19 + - 18 + - 17 + - 16 + - 15 + - 14 + - 13 + - 12 + - 11 + - 10 + - 9 + - 8 + - 7 + - 6 + - 5 + - 4 + - 3 + - 2 + - 1 + out: mllmorvagnveozlymbriatnieb + - name: twenty-as + in: + s: aaaaaaaaaaaaaaaaaaaa + shifts: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + out: ffeczvqkkjheavppomjf + - name: twenty-zs + in: + s: zzzzzzzzzzzzzzzzzzzz + shifts: + - 0 + - 1 + - 4 + - 9 + - 16 + - 25 + - 36 + - 49 + - 64 + - 81 + - 100 + - 121 + - 144 + - 169 + - 196 + - 225 + - 256 + - 289 + - 324 + - 361 + out: zzyulvwmpdaenzmyhliw + - name: thirty-mixed + in: + s: leetcodeleetcodeleetcodeleetxx + shifts: + - 0 + - 11 + - 22 + - 33 + - 44 + - 55 + - 66 + - 77 + - 88 + - 99 + - 110 + - 121 + - 132 + - 143 + - 154 + - 165 + - 176 + - 187 + - 198 + - 209 + - 220 + - 231 + - 242 + - 253 + - 264 + - 275 + - 286 + - 297 + - 308 + - 319 + out: mfunpjviqzenfprusrmlttleshshae + - name: long-100-a + in: + s: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + shifts: + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + out: wvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcb + - name: long-100-z + in: + s: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz + shifts: + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + - 25 + out: defghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxy + - name: long-254-pattern + in: + s: abcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzab + shifts: + - 0 + - 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 + - 0 + - 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 + - 0 + - 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 + - 0 + - 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 + - 0 + - 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 + - 0 + - 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 + - 0 + - 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 + - 0 + - 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 + - 0 + - 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 + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + - 11 + - 12 + - 13 + - 14 + - 15 + - 16 + - 17 + - 18 + - 19 + out: vwwpnkgbviarhwkrdoyhpqwbfikffeczvkexpgwftgsdnqyflqurtuutrieztmepfuivhmwfnuazdgijjcaxtoivneujxeqblucdjosvxssrpmixrkctjsgtfqadlsydheghhgevrmgzrcshviuzjsahnmqtvwwpnkgbviarhwkrdoyhpqwbfikffeczvkexpgwftgsdnqyflqurtuutrieztmepfuivhmwfnuazdgijjcaxtoivneujxeqblu + - name: long-1000-cycle + in: + s: abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl + shifts: + - 0 + - 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 + - 55 + - 56 + - 57 + - 58 + - 59 + - 60 + - 61 + - 62 + - 63 + - 64 + - 65 + - 66 + - 67 + - 68 + - 69 + - 70 + - 71 + - 72 + - 73 + - 74 + - 75 + - 76 + - 77 + - 78 + - 79 + - 80 + - 81 + - 82 + - 83 + - 84 + - 85 + - 86 + - 87 + - 88 + - 89 + - 90 + - 91 + - 92 + - 93 + - 94 + - 95 + - 96 + - 97 + - 98 + - 99 + - 0 + - 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 + - 55 + - 56 + - 57 + - 58 + - 59 + - 60 + - 61 + - 62 + - 63 + - 64 + - 65 + - 66 + - 67 + - 68 + - 69 + - 70 + - 71 + - 72 + - 73 + - 74 + - 75 + - 76 + - 77 + - 78 + - 79 + - 80 + - 81 + - 82 + - 83 + - 84 + - 85 + - 86 + - 87 + - 88 + - 89 + - 90 + - 91 + - 92 + - 93 + - 94 + - 95 + - 96 + - 97 + - 98 + - 99 + - 0 + - 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 + - 55 + - 56 + - 57 + - 58 + - 59 + - 60 + - 61 + - 62 + - 63 + - 64 + - 65 + - 66 + - 67 + - 68 + - 69 + - 70 + - 71 + - 72 + - 73 + - 74 + - 75 + - 76 + - 77 + - 78 + - 79 + - 80 + - 81 + - 82 + - 83 + - 84 + - 85 + - 86 + - 87 + - 88 + - 89 + - 90 + - 91 + - 92 + - 93 + - 94 + - 95 + - 96 + - 97 + - 98 + - 99 + - 0 + - 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 + - 55 + - 56 + - 57 + - 58 + - 59 + - 60 + - 61 + - 62 + - 63 + - 64 + - 65 + - 66 + - 67 + - 68 + - 69 + - 70 + - 71 + - 72 + - 73 + - 74 + - 75 + - 76 + - 77 + - 78 + - 79 + - 80 + - 81 + - 82 + - 83 + - 84 + - 85 + - 86 + - 87 + - 88 + - 89 + - 90 + - 91 + - 92 + - 93 + - 94 + - 95 + - 96 + - 97 + - 98 + - 99 + - 0 + - 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 + - 55 + - 56 + - 57 + - 58 + - 59 + - 60 + - 61 + - 62 + - 63 + - 64 + - 65 + - 66 + - 67 + - 68 + - 69 + - 70 + - 71 + - 72 + - 73 + - 74 + - 75 + - 76 + - 77 + - 78 + - 79 + - 80 + - 81 + - 82 + - 83 + - 84 + - 85 + - 86 + - 87 + - 88 + - 89 + - 90 + - 91 + - 92 + - 93 + - 94 + - 95 + - 96 + - 97 + - 98 + - 99 + - 0 + - 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 + - 55 + - 56 + - 57 + - 58 + - 59 + - 60 + - 61 + - 62 + - 63 + - 64 + - 65 + - 66 + - 67 + - 68 + - 69 + - 70 + - 71 + - 72 + - 73 + - 74 + - 75 + - 76 + - 77 + - 78 + - 79 + - 80 + - 81 + - 82 + - 83 + - 84 + - 85 + - 86 + - 87 + - 88 + - 89 + - 90 + - 91 + - 92 + - 93 + - 94 + - 95 + - 96 + - 97 + - 98 + - 99 + - 0 + - 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 + - 55 + - 56 + - 57 + - 58 + - 59 + - 60 + - 61 + - 62 + - 63 + - 64 + - 65 + - 66 + - 67 + - 68 + - 69 + - 70 + - 71 + - 72 + - 73 + - 74 + - 75 + - 76 + - 77 + - 78 + - 79 + - 80 + - 81 + - 82 + - 83 + - 84 + - 85 + - 86 + - 87 + - 88 + - 89 + - 90 + - 91 + - 92 + - 93 + - 94 + - 95 + - 96 + - 97 + - 98 + - 99 + - 0 + - 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 + - 55 + - 56 + - 57 + - 58 + - 59 + - 60 + - 61 + - 62 + - 63 + - 64 + - 65 + - 66 + - 67 + - 68 + - 69 + - 70 + - 71 + - 72 + - 73 + - 74 + - 75 + - 76 + - 77 + - 78 + - 79 + - 80 + - 81 + - 82 + - 83 + - 84 + - 85 + - 86 + - 87 + - 88 + - 89 + - 90 + - 91 + - 92 + - 93 + - 94 + - 95 + - 96 + - 97 + - 98 + - 99 + - 0 + - 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 + - 55 + - 56 + - 57 + - 58 + - 59 + - 60 + - 61 + - 62 + - 63 + - 64 + - 65 + - 66 + - 67 + - 68 + - 69 + - 70 + - 71 + - 72 + - 73 + - 74 + - 75 + - 76 + - 77 + - 78 + - 79 + - 80 + - 81 + - 82 + - 83 + - 84 + - 85 + - 86 + - 87 + - 88 + - 89 + - 90 + - 91 + - 92 + - 93 + - 94 + - 95 + - 96 + - 97 + - 98 + - 99 + - 0 + - 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 + - 55 + - 56 + - 57 + - 58 + - 59 + - 60 + - 61 + - 62 + - 63 + - 64 + - 65 + - 66 + - 67 + - 68 + - 69 + - 70 + - 71 + - 72 + - 73 + - 74 + - 75 + - 76 + - 77 + - 78 + - 79 + - 80 + - 81 + - 82 + - 83 + - 84 + - 85 + - 86 + - 87 + - 88 + - 89 + - 90 + - 91 + - 92 + - 93 + - 94 + - 95 + - 96 + - 97 + - 98 + - 99 + out: wxxwurnicvneujxkwhraipvaehjkkjheavpiarhwkxjuenvcinruwxxwurnicvneujxkwhraipvaehjkkjheavpiarhwkxjuenvcijjigdzuohzqgvjwitdmubhmqtvwwvtqmhbumdtiwjvgqzhouzdgijjigdzuohzqgvjwitdmubhmqtvwwvtqmhbumdtiwjvgqzhouvvusplgatlcshviufpygntycfhiihfcytngypfuivhscltaglpsuvvusplgatlcshviufpygntycfhiihfcytngypfuivhscltaghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsttsqnjeyrjaqftgsdnwelrwadfggfdawrlewndsgtfqajryejnqsttsqnjeyrjaqftgsdnwelrwadfggfdawrlewndsgtfqajryeffeczvqkdvmcrfsepziqxdimprssrpmidxqizpesfrcmvdkqvzceffeczvqkdvmcrfsepziqxdimprssrpmidxqizpesfrcmvdkqrrqolhcwphyodreqblucjpuybdeedbyupjculbqerdoyhpwchloqrrqolhcwphyodreqblucjpuybdeedbyupjculbqerdoyhpwcddcaxtoibtkapdqcnxgovbgknpqqpnkgbvogxncqdpaktbiotxacddcaxtoibtkapdqcnxgovbgknpqqpnkgbvogxncqdpaktbioppomjfaunfwmbpcozjsahnswzbccbzwsnhasjzocpbmwfnuafjmoppomjfaunfwmbpcozjsahnswzbccbzwsnhasjzocpbmwfnuabbayvrmgzriynboalvemtzeilnoonlieztmevlaobnyirzgmrvyabbayvrmgzriynboalvemtzeilnoonlieztmevlaobnyirzg + - name: long-1000-zero + in: + s: bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + shifts: + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + out: bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + - name: long-500-max + in: + s: mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm + shifts: + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + - 1000000000 + out: guiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwkymaocqesguiwky + - name: long-100000-pattern + in: + s: abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd + shifts: + - 0 + - 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 + - 55 + - 56 + - 57 + - 58 + - 59 + - 60 + - 61 + - 62 + - 63 + - 64 + - 65 + - 66 + - 67 + - 68 + - 69 + - 70 + - 71 + - 72 + - 73 + - 74 + - 75 + - 76 + - 77 + - 78 + - 79 + - 80 + - 81 + - 82 + - 83 + - 84 + - 85 + - 86 + - 87 + - 88 + - 89 + - 90 + - 91 + - 92 + - 93 + - 94 + - 95 + - 96 + - 97 + - 98 + - 99 + - 100 + - 101 + - 102 + - 103 + - 104 + - 105 + - 106 + - 107 + - 108 + - 109 + - 110 + - 111 + - 112 + - 113 + - 114 + - 115 + - 116 + - 117 + - 118 + - 119 + - 120 + - 121 + - 122 + - 123 + - 124 + - 125 + - 126 + - 127 + - 128 + - 129 + - 130 + - 131 + - 132 + - 133 + - 134 + - 135 + - 136 + - 137 + - 138 + - 139 + - 140 + - 141 + - 142 + - 143 + - 144 + - 145 + - 146 + - 147 + - 148 + - 149 + - 150 + - 151 + - 152 + - 153 + - 154 + - 155 + - 156 + - 157 + - 158 + - 159 + - 160 + - 161 + - 162 + - 163 + - 164 + - 165 + - 166 + - 167 + - 168 + - 169 + - 170 + - 171 + - 172 + - 173 + - 174 + - 175 + - 176 + - 177 + - 178 + - 179 + - 180 + - 181 + - 182 + - 183 + - 184 + - 185 + - 186 + - 187 + - 188 + - 189 + - 190 + - 191 + - 192 + - 193 + - 194 + - 195 + - 196 + - 197 + - 198 + - 199 + - 200 + - 201 + - 202 + - 203 + - 204 + - 205 + - 206 + - 207 + - 208 + - 209 + - 210 + - 211 + - 212 + - 213 + - 214 + - 215 + - 216 + - 217 + - 218 + - 219 + - 220 + - 221 + - 222 + - 223 + - 224 + - 225 + - 226 + - 227 + - 228 + - 229 + - 230 + - 231 + - 232 + - 233 + - 234 + - 235 + - 236 + - 237 + - 238 + - 239 + - 240 + - 241 + - 242 + - 243 + - 244 + - 245 + - 246 + - 247 + - 248 + - 249 + - 250 + - 251 + - 252 + - 253 + - 254 + - 255 + - 256 + - 257 + - 258 + - 259 + - 260 + - 261 + - 262 + - 263 + - 264 + - 265 + - 266 + - 267 + - 268 + - 269 + - 270 + - 271 + - 272 + - 273 + - 274 + - 275 + - 276 + - 277 + - 278 + - 279 + - 280 + - 281 + - 282 + - 283 + - 284 + - 285 + - 286 + - 287 + - 288 + - 289 + - 290 + - 291 + - 292 + - 293 + - 294 + - 295 + - 296 + - 297 + - 298 + - 299 + - 300 + - 301 + - 302 + - 303 + - 304 + - 305 + - 306 + - 307 + - 308 + - 309 + - 310 + - 311 + - 312 + - 313 + - 314 + - 315 + - 316 + - 317 + - 318 + - 319 + - 320 + - 321 + - 322 + - 323 + - 324 + - 325 + - 326 + - 327 + - 328 + - 329 + - 330 + - 331 + - 332 + - 333 + - 334 + - 335 + - 336 + - 337 + - 338 + - 339 + - 340 + - 341 + - 342 + - 343 + - 344 + - 345 + - 346 + - 347 + - 348 + - 349 + - 350 + - 351 + - 352 + - 353 + - 354 + - 355 + - 356 + - 357 + - 358 + - 359 + - 360 + - 361 + - 362 + - 363 + - 364 + - 365 + - 366 + - 367 + - 368 + - 369 + - 370 + - 371 + - 372 + - 373 + - 374 + - 375 + - 376 + - 377 + - 378 + - 379 + - 380 + - 381 + - 382 + - 383 + - 384 + - 385 + - 386 + - 387 + - 388 + - 389 + - 390 + - 391 + - 392 + - 393 + - 394 + - 395 + - 396 + - 397 + - 398 + - 399 + - 400 + - 401 + - 402 + - 403 + - 404 + - 405 + - 406 + - 407 + - 408 + - 409 + - 410 + - 411 + - 412 + - 413 + - 414 + - 415 + - 416 + - 417 + - 418 + - 419 + - 420 + - 421 + - 422 + - 423 + - 424 + - 425 + - 426 + - 427 + - 428 + - 429 + - 430 + - 431 + - 432 + - 433 + - 434 + - 435 + - 436 + - 437 + - 438 + - 439 + - 440 + - 441 + - 442 + - 443 + - 444 + - 445 + - 446 + - 447 + - 448 + - 449 + - 450 + - 451 + - 452 + - 453 + - 454 + - 455 + - 456 + - 457 + - 458 + - 459 + - 460 + - 461 + - 462 + - 463 + - 464 + - 465 + - 466 + - 467 + - 468 + - 469 + - 470 + - 471 + - 472 + - 473 + - 474 + - 475 + - 476 + - 477 + - 478 + - 479 + - 480 + - 481 + - 482 + - 483 + - 484 + - 485 + - 486 + - 487 + - 488 + - 489 + - 490 + - 491 + - 492 + - 493 + - 494 + - 495 + - 496 + - 497 + - 498 + - 499 + - 500 + - 501 + - 502 + - 503 + - 504 + - 505 + - 506 + - 507 + - 508 + - 509 + - 510 + - 511 + - 512 + - 513 + - 514 + - 515 + - 516 + - 517 + - 518 + - 519 + - 520 + - 521 + - 522 + - 523 + - 524 + - 525 + - 526 + - 527 + - 528 + - 529 + - 530 + - 531 + - 532 + - 533 + - 534 + - 535 + - 536 + - 537 + - 538 + - 539 + - 540 + - 541 + - 542 + - 543 + - 544 + - 545 + - 546 + - 547 + - 548 + - 549 + - 550 + - 551 + - 552 + - 553 + - 554 + - 555 + - 556 + - 557 + - 558 + - 559 + - 560 + - 561 + - 562 + - 563 + - 564 + - 565 + - 566 + - 567 + - 568 + - 569 + - 570 + - 571 + - 572 + - 573 + - 574 + - 575 + - 576 + - 577 + - 578 + - 579 + - 580 + - 581 + - 582 + - 583 + - 584 + - 585 + - 586 + - 587 + - 588 + - 589 + - 590 + - 591 + - 592 + - 593 + - 594 + - 595 + - 596 + - 597 + - 598 + - 599 + - 600 + - 601 + - 602 + - 603 + - 604 + - 605 + - 606 + - 607 + - 608 + - 609 + - 610 + - 611 + - 612 + - 613 + - 614 + - 615 + - 616 + - 617 + - 618 + - 619 + - 620 + - 621 + - 622 + - 623 + - 624 + - 625 + - 626 + - 627 + - 628 + - 629 + - 630 + - 631 + - 632 + - 633 + - 634 + - 635 + - 636 + - 637 + - 638 + - 639 + - 640 + - 641 + - 642 + - 643 + - 644 + - 645 + - 646 + - 647 + - 648 + - 649 + - 650 + - 651 + - 652 + - 653 + - 654 + - 655 + - 656 + - 657 + - 658 + - 659 + - 660 + - 661 + - 662 + - 663 + - 664 + - 665 + - 666 + - 667 + - 668 + - 669 + - 670 + - 671 + - 672 + - 673 + - 674 + - 675 + - 676 + - 677 + - 678 + - 679 + - 680 + - 681 + - 682 + - 683 + - 684 + - 685 + - 686 + - 687 + - 688 + - 689 + - 690 + - 691 + - 692 + - 693 + - 694 + - 695 + - 696 + - 697 + - 698 + - 699 + - 700 + - 701 + - 702 + - 703 + - 704 + - 705 + - 706 + - 707 + - 708 + - 709 + - 710 + - 711 + - 712 + - 713 + - 714 + - 715 + - 716 + - 717 + - 718 + - 719 + - 720 + - 721 + - 722 + - 723 + - 724 + - 725 + - 726 + - 727 + - 728 + - 729 + - 730 + - 731 + - 732 + - 733 + - 734 + - 735 + - 736 + - 737 + - 738 + - 739 + - 740 + - 741 + - 742 + - 743 + - 744 + - 745 + - 746 + - 747 + - 748 + - 749 + - 750 + - 751 + - 752 + - 753 + - 754 + - 755 + - 756 + - 757 + - 758 + - 759 + - 760 + - 761 + - 762 + - 763 + - 764 + - 765 + - 766 + - 767 + - 768 + - 769 + - 770 + - 771 + - 772 + - 773 + - 774 + - 775 + - 776 + - 777 + - 778 + - 779 + - 780 + - 781 + - 782 + - 783 + - 784 + - 785 + - 786 + - 787 + - 788 + - 789 + - 790 + - 791 + - 792 + - 793 + - 794 + - 795 + - 796 + - 797 + - 798 + - 799 + - 800 + - 801 + - 802 + - 803 + - 804 + - 805 + - 806 + - 807 + - 808 + - 809 + - 810 + - 811 + - 812 + - 813 + - 814 + - 815 + - 816 + - 817 + - 818 + - 819 + - 820 + - 821 + - 822 + - 823 + - 824 + - 825 + - 826 + - 827 + - 828 + - 829 + - 830 + - 831 + - 832 + - 833 + - 834 + - 835 + - 836 + - 837 + - 838 + - 839 + - 840 + - 841 + - 842 + - 843 + - 844 + - 845 + - 846 + - 847 + - 848 + - 849 + - 850 + - 851 + - 852 + - 853 + - 854 + - 855 + - 856 + - 857 + - 858 + - 859 + - 860 + - 861 + - 862 + - 863 + - 864 + - 865 + - 866 + - 867 + - 868 + - 869 + - 870 + - 871 + - 872 + - 873 + - 874 + - 875 + - 876 + - 877 + - 878 + - 879 + - 880 + - 881 + - 882 + - 883 + - 884 + - 885 + - 886 + - 887 + - 888 + - 889 + - 890 + - 891 + - 892 + - 893 + - 894 + - 895 + - 896 + - 897 + - 898 + - 899 + - 900 + - 901 + - 902 + - 903 + - 904 + - 905 + - 906 + - 907 + - 908 + - 909 + - 910 + - 911 + - 912 + - 913 + - 914 + - 915 + - 916 + - 917 + - 918 + - 919 + - 920 + - 921 + - 922 + - 923 + - 924 + - 925 + - 926 + - 927 + - 928 + - 929 + - 930 + - 931 + - 932 + - 933 + - 934 + - 935 + - 936 + - 937 + - 938 + - 939 + - 940 + - 941 + - 942 + - 943 + - 944 + - 945 + - 946 + - 947 + - 948 + - 949 + - 950 + - 951 + - 952 + - 953 + - 954 + - 955 + - 956 + - 957 + - 958 + - 959 + - 960 + - 961 + - 962 + - 963 + - 964 + - 965 + - 966 + - 967 + - 968 + - 969 + - 970 + - 971 + - 972 + - 973 + - 974 + - 975 + - 976 + - 977 + - 978 + - 979 + - 980 + - 981 + - 982 + - 983 + - 984 + - 985 + - 986 + - 987 + - 988 + - 989 + - 990 + - 991 + - 992 + - 993 + - 994 + - 995 + - 996 + - 997 + - 998 + - 999 + - 1000 + - 1001 + - 1002 + - 1003 + - 1004 + - 1005 + - 1006 + - 1007 + - 1008 + - 1009 + - 1010 + - 1011 + - 1012 + - 1013 + - 1014 + - 1015 + - 1016 + - 1017 + - 1018 + - 1019 + - 1020 + - 1021 + - 1022 + - 1023 + - 1024 + - 1025 + - 1026 + - 1027 + - 1028 + - 1029 + - 1030 + - 1031 + - 1032 + - 1033 + - 1034 + - 1035 + - 1036 + - 1037 + - 1038 + - 1039 + - 1040 + - 1041 + - 1042 + - 1043 + - 1044 + - 1045 + - 1046 + - 1047 + - 1048 + - 1049 + - 1050 + - 1051 + - 1052 + - 1053 + - 1054 + - 1055 + - 1056 + - 1057 + - 1058 + - 1059 + - 1060 + - 1061 + - 1062 + - 1063 + - 1064 + - 1065 + - 1066 + - 1067 + - 1068 + - 1069 + - 1070 + - 1071 + - 1072 + - 1073 + - 1074 + - 1075 + - 1076 + - 1077 + - 1078 + - 1079 + - 1080 + - 1081 + - 1082 + - 1083 + - 1084 + - 1085 + - 1086 + - 1087 + - 1088 + - 1089 + - 1090 + - 1091 + - 1092 + - 1093 + - 1094 + - 1095 + - 1096 + - 1097 + - 1098 + - 1099 + - 1100 + - 1101 + - 1102 + - 1103 + - 1104 + - 1105 + - 1106 + - 1107 + - 1108 + - 1109 + - 1110 + - 1111 + - 1112 + - 1113 + - 1114 + - 1115 + - 1116 + - 1117 + - 1118 + - 1119 + - 1120 + - 1121 + - 1122 + - 1123 + - 1124 + - 1125 + - 1126 + - 1127 + - 1128 + - 1129 + - 1130 + - 1131 + - 1132 + - 1133 + - 1134 + - 1135 + - 1136 + - 1137 + - 1138 + - 1139 + - 1140 + - 1141 + - 1142 + - 1143 + - 1144 + - 1145 + - 1146 + - 1147 + - 1148 + - 1149 + - 1150 + - 1151 + - 1152 + - 1153 + - 1154 + - 1155 + - 1156 + - 1157 + - 1158 + - 1159 + - 1160 + - 1161 + - 1162 + - 1163 + - 1164 + - 1165 + - 1166 + - 1167 + - 1168 + - 1169 + - 1170 + - 1171 + - 1172 + - 1173 + - 1174 + - 1175 + - 1176 + - 1177 + - 1178 + - 1179 + - 1180 + - 1181 + - 1182 + - 1183 + - 1184 + - 1185 + - 1186 + - 1187 + - 1188 + - 1189 + - 1190 + - 1191 + - 1192 + - 1193 + - 1194 + - 1195 + - 1196 + - 1197 + - 1198 + - 1199 + - 1200 + - 1201 + - 1202 + - 1203 + - 1204 + - 1205 + - 1206 + - 1207 + - 1208 + - 1209 + - 1210 + - 1211 + - 1212 + - 1213 + - 1214 + - 1215 + - 1216 + - 1217 + - 1218 + - 1219 + - 1220 + - 1221 + - 1222 + - 1223 + - 1224 + - 1225 + - 1226 + - 1227 + - 1228 + - 1229 + - 1230 + - 1231 + - 1232 + - 1233 + - 1234 + - 1235 + - 1236 + - 1237 + - 1238 + - 1239 + - 1240 + - 1241 + - 1242 + - 1243 + - 1244 + - 1245 + - 1246 + - 1247 + - 1248 + - 1249 + - 1250 + - 1251 + - 1252 + - 1253 + - 1254 + - 1255 + - 1256 + - 1257 + - 1258 + - 1259 + - 1260 + - 1261 + - 1262 + - 1263 + - 1264 + - 1265 + - 1266 + - 1267 + - 1268 + - 1269 + - 1270 + - 1271 + - 1272 + - 1273 + - 1274 + - 1275 + - 1276 + - 1277 + - 1278 + - 1279 + - 1280 + - 1281 + - 1282 + - 1283 + - 1284 + - 1285 + - 1286 + - 1287 + - 1288 + - 1289 + - 1290 + - 1291 + - 1292 + - 1293 + - 1294 + - 1295 + - 1296 + - 1297 + - 1298 + - 1299 + - 1300 + - 1301 + - 1302 + - 1303 + - 1304 + - 1305 + - 1306 + - 1307 + - 1308 + - 1309 + - 1310 + - 1311 + - 1312 + - 1313 + - 1314 + - 1315 + - 1316 + - 1317 + - 1318 + - 1319 + - 1320 + - 1321 + - 1322 + - 1323 + - 1324 + - 1325 + - 1326 + - 1327 + - 1328 + - 1329 + - 1330 + - 1331 + - 1332 + - 1333 + - 1334 + - 1335 + - 1336 + - 1337 + - 1338 + - 1339 + - 1340 + - 1341 + - 1342 + - 1343 + - 1344 + - 1345 + - 1346 + - 1347 + - 1348 + - 1349 + - 1350 + - 1351 + - 1352 + - 1353 + - 1354 + - 1355 + - 1356 + - 1357 + - 1358 + - 1359 + - 1360 + - 1361 + - 1362 + - 1363 + - 1364 + - 1365 + - 1366 + - 1367 + - 1368 + - 1369 + - 1370 + - 1371 + - 1372 + - 1373 + - 1374 + - 1375 + - 1376 + - 1377 + - 1378 + - 1379 + - 1380 + - 1381 + - 1382 + - 1383 + - 1384 + - 1385 + - 1386 + - 1387 + - 1388 + - 1389 + - 1390 + - 1391 + - 1392 + - 1393 + - 1394 + - 1395 + - 1396 + - 1397 + - 1398 + - 1399 + - 1400 + - 1401 + - 1402 + - 1403 + - 1404 + - 1405 + - 1406 + - 1407 + - 1408 + - 1409 + - 1410 + - 1411 + - 1412 + - 1413 + - 1414 + - 1415 + - 1416 + - 1417 + - 1418 + - 1419 + - 1420 + - 1421 + - 1422 + - 1423 + - 1424 + - 1425 + - 1426 + - 1427 + - 1428 + - 1429 + - 1430 + - 1431 + - 1432 + - 1433 + - 1434 + - 1435 + - 1436 + - 1437 + - 1438 + - 1439 + - 1440 + - 1441 + - 1442 + - 1443 + - 1444 + - 1445 + - 1446 + - 1447 + - 1448 + - 1449 + - 1450 + - 1451 + - 1452 + - 1453 + - 1454 + - 1455 + - 1456 + - 1457 + - 1458 + - 1459 + - 1460 + - 1461 + - 1462 + - 1463 + - 1464 + - 1465 + - 1466 + - 1467 + - 1468 + - 1469 + - 1470 + - 1471 + - 1472 + - 1473 + - 1474 + - 1475 + - 1476 + - 1477 + - 1478 + - 1479 + - 1480 + - 1481 + - 1482 + - 1483 + - 1484 + - 1485 + - 1486 + - 1487 + - 1488 + - 1489 + - 1490 + - 1491 + - 1492 + - 1493 + - 1494 + - 1495 + - 1496 + - 1497 + - 1498 + - 1499 + - 1500 + - 1501 + - 1502 + - 1503 + - 1504 + - 1505 + - 1506 + - 1507 + - 1508 + - 1509 + - 1510 + - 1511 + - 1512 + - 1513 + - 1514 + - 1515 + - 1516 + - 1517 + - 1518 + - 1519 + - 1520 + - 1521 + - 1522 + - 1523 + - 1524 + - 1525 + - 1526 + - 1527 + - 1528 + - 1529 + - 1530 + - 1531 + - 1532 + - 1533 + - 1534 + - 1535 + - 1536 + - 1537 + - 1538 + - 1539 + - 1540 + - 1541 + - 1542 + - 1543 + - 1544 + - 1545 + - 1546 + - 1547 + - 1548 + - 1549 + - 1550 + - 1551 + - 1552 + - 1553 + - 1554 + - 1555 + - 1556 + - 1557 + - 1558 + - 1559 + - 1560 + - 1561 + - 1562 + - 1563 + - 1564 + - 1565 + - 1566 + - 1567 + - 1568 + - 1569 + - 1570 + - 1571 + - 1572 + - 1573 + - 1574 + - 1575 + - 1576 + - 1577 + - 1578 + - 1579 + - 1580 + - 1581 + - 1582 + - 1583 + - 1584 + - 1585 + - 1586 + - 1587 + - 1588 + - 1589 + - 1590 + - 1591 + - 1592 + - 1593 + - 1594 + - 1595 + - 1596 + - 1597 + - 1598 + - 1599 + - 1600 + - 1601 + - 1602 + - 1603 + - 1604 + - 1605 + - 1606 + - 1607 + - 1608 + - 1609 + - 1610 + - 1611 + - 1612 + - 1613 + - 1614 + - 1615 + - 1616 + - 1617 + - 1618 + - 1619 + - 1620 + - 1621 + - 1622 + - 1623 + - 1624 + - 1625 + - 1626 + - 1627 + - 1628 + - 1629 + - 1630 + - 1631 + - 1632 + - 1633 + - 1634 + - 1635 + - 1636 + - 1637 + - 1638 + - 1639 + - 1640 + - 1641 + - 1642 + - 1643 + - 1644 + - 1645 + - 1646 + - 1647 + - 1648 + - 1649 + - 1650 + - 1651 + - 1652 + - 1653 + - 1654 + - 1655 + - 1656 + - 1657 + - 1658 + - 1659 + - 1660 + - 1661 + - 1662 + - 1663 + - 1664 + - 1665 + - 1666 + - 1667 + - 1668 + - 1669 + - 1670 + - 1671 + - 1672 + - 1673 + - 1674 + - 1675 + - 1676 + - 1677 + - 1678 + - 1679 + - 1680 + - 1681 + - 1682 + - 1683 + - 1684 + - 1685 + - 1686 + - 1687 + - 1688 + - 1689 + - 1690 + - 1691 + - 1692 + - 1693 + - 1694 + - 1695 + - 1696 + - 1697 + - 1698 + - 1699 + - 1700 + - 1701 + - 1702 + - 1703 + - 1704 + - 1705 + - 1706 + - 1707 + - 1708 + - 1709 + - 1710 + - 1711 + - 1712 + - 1713 + - 1714 + - 1715 + - 1716 + - 1717 + - 1718 + - 1719 + - 1720 + - 1721 + - 1722 + - 1723 + - 1724 + - 1725 + - 1726 + - 1727 + - 1728 + - 1729 + - 1730 + - 1731 + - 1732 + - 1733 + - 1734 + - 1735 + - 1736 + - 1737 + - 1738 + - 1739 + - 1740 + - 1741 + - 1742 + - 1743 + - 1744 + - 1745 + - 1746 + - 1747 + - 1748 + - 1749 + - 1750 + - 1751 + - 1752 + - 1753 + - 1754 + - 1755 + - 1756 + - 1757 + - 1758 + - 1759 + - 1760 + - 1761 + - 1762 + - 1763 + - 1764 + - 1765 + - 1766 + - 1767 + - 1768 + - 1769 + - 1770 + - 1771 + - 1772 + - 1773 + - 1774 + - 1775 + - 1776 + - 1777 + - 1778 + - 1779 + - 1780 + - 1781 + - 1782 + - 1783 + - 1784 + - 1785 + - 1786 + - 1787 + - 1788 + - 1789 + - 1790 + - 1791 + - 1792 + - 1793 + - 1794 + - 1795 + - 1796 + - 1797 + - 1798 + - 1799 + - 1800 + - 1801 + - 1802 + - 1803 + - 1804 + - 1805 + - 1806 + - 1807 + - 1808 + - 1809 + - 1810 + - 1811 + - 1812 + - 1813 + - 1814 + - 1815 + - 1816 + - 1817 + - 1818 + - 1819 + - 1820 + - 1821 + - 1822 + - 1823 + - 1824 + - 1825 + - 1826 + - 1827 + - 1828 + - 1829 + - 1830 + - 1831 + - 1832 + - 1833 + - 1834 + - 1835 + - 1836 + - 1837 + - 1838 + - 1839 + - 1840 + - 1841 + - 1842 + - 1843 + - 1844 + - 1845 + - 1846 + - 1847 + - 1848 + - 1849 + - 1850 + - 1851 + - 1852 + - 1853 + - 1854 + - 1855 + - 1856 + - 1857 + - 1858 + - 1859 + - 1860 + - 1861 + - 1862 + - 1863 + - 1864 + - 1865 + - 1866 + - 1867 + - 1868 + - 1869 + - 1870 + - 1871 + - 1872 + - 1873 + - 1874 + - 1875 + - 1876 + - 1877 + - 1878 + - 1879 + - 1880 + - 1881 + - 1882 + - 1883 + - 1884 + - 1885 + - 1886 + - 1887 + - 1888 + - 1889 + - 1890 + - 1891 + - 1892 + - 1893 + - 1894 + - 1895 + - 1896 + - 1897 + - 1898 + - 1899 + - 1900 + - 1901 + - 1902 + - 1903 + - 1904 + - 1905 + - 1906 + - 1907 + - 1908 + - 1909 + - 1910 + - 1911 + - 1912 + - 1913 + - 1914 + - 1915 + - 1916 + - 1917 + - 1918 + - 1919 + - 1920 + - 1921 + - 1922 + - 1923 + - 1924 + - 1925 + - 1926 + - 1927 + - 1928 + - 1929 + - 1930 + - 1931 + - 1932 + - 1933 + - 1934 + - 1935 + - 1936 + - 1937 + - 1938 + - 1939 + - 1940 + - 1941 + - 1942 + - 1943 + - 1944 + - 1945 + - 1946 + - 1947 + - 1948 + - 1949 + - 1950 + - 1951 + - 1952 + - 1953 + - 1954 + - 1955 + - 1956 + - 1957 + - 1958 + - 1959 + - 1960 + - 1961 + - 1962 + - 1963 + - 1964 + - 1965 + - 1966 + - 1967 + - 1968 + - 1969 + - 1970 + - 1971 + - 1972 + - 1973 + - 1974 + - 1975 + - 1976 + - 1977 + - 1978 + - 1979 + - 1980 + - 1981 + - 1982 + - 1983 + - 1984 + - 1985 + - 1986 + - 1987 + - 1988 + - 1989 + - 1990 + - 1991 + - 1992 + - 1993 + - 1994 + - 1995 + - 1996 + - 1997 + - 1998 + - 1999 + - 2000 + - 2001 + - 2002 + - 2003 + - 2004 + - 2005 + - 2006 + - 2007 + - 2008 + - 2009 + - 2010 + - 2011 + - 2012 + - 2013 + - 2014 + - 2015 + - 2016 + - 2017 + - 2018 + - 2019 + - 2020 + - 2021 + - 2022 + - 2023 + - 2024 + - 2025 + - 2026 + - 2027 + - 2028 + - 2029 + - 2030 + - 2031 + - 2032 + - 2033 + - 2034 + - 2035 + - 2036 + - 2037 + - 2038 + - 2039 + - 2040 + - 2041 + - 2042 + - 2043 + - 2044 + - 2045 + - 2046 + - 2047 + - 2048 + - 2049 + - 2050 + - 2051 + - 2052 + - 2053 + - 2054 + - 2055 + - 2056 + - 2057 + - 2058 + - 2059 + - 2060 + - 2061 + - 2062 + - 2063 + - 2064 + - 2065 + - 2066 + - 2067 + - 2068 + - 2069 + - 2070 + - 2071 + - 2072 + - 2073 + - 2074 + - 2075 + - 2076 + - 2077 + - 2078 + - 2079 + - 2080 + - 2081 + - 2082 + - 2083 + - 2084 + - 2085 + - 2086 + - 2087 + - 2088 + - 2089 + - 2090 + - 2091 + - 2092 + - 2093 + - 2094 + - 2095 + - 2096 + - 2097 + - 2098 + - 2099 + - 2100 + - 2101 + - 2102 + - 2103 + - 2104 + - 2105 + - 2106 + - 2107 + - 2108 + - 2109 + - 2110 + - 2111 + - 2112 + - 2113 + - 2114 + - 2115 + - 2116 + - 2117 + - 2118 + - 2119 + - 2120 + - 2121 + - 2122 + - 2123 + - 2124 + - 2125 + - 2126 + - 2127 + - 2128 + - 2129 + - 2130 + - 2131 + - 2132 + - 2133 + - 2134 + - 2135 + - 2136 + - 2137 + - 2138 + - 2139 + - 2140 + - 2141 + - 2142 + - 2143 + - 2144 + - 2145 + - 2146 + - 2147 + - 2148 + - 2149 + - 2150 + - 2151 + - 2152 + - 2153 + - 2154 + - 2155 + - 2156 + - 2157 + - 2158 + - 2159 + - 2160 + - 2161 + - 2162 + - 2163 + - 2164 + - 2165 + - 2166 + - 2167 + - 2168 + - 2169 + - 2170 + - 2171 + - 2172 + - 2173 + - 2174 + - 2175 + - 2176 + - 2177 + - 2178 + - 2179 + - 2180 + - 2181 + - 2182 + - 2183 + - 2184 + - 2185 + - 2186 + - 2187 + - 2188 + - 2189 + - 2190 + - 2191 + - 2192 + - 2193 + - 2194 + - 2195 + - 2196 + - 2197 + - 2198 + - 2199 + - 2200 + - 2201 + - 2202 + - 2203 + - 2204 + - 2205 + - 2206 + - 2207 + - 2208 + - 2209 + - 2210 + - 2211 + - 2212 + - 2213 + - 2214 + - 2215 + - 2216 + - 2217 + - 2218 + - 2219 + - 2220 + - 2221 + - 2222 + - 2223 + - 2224 + - 2225 + - 2226 + - 2227 + - 2228 + - 2229 + - 2230 + - 2231 + - 2232 + - 2233 + - 2234 + - 2235 + - 2236 + - 2237 + - 2238 + - 2239 + - 2240 + - 2241 + - 2242 + - 2243 + - 2244 + - 2245 + - 2246 + - 2247 + - 2248 + - 2249 + - 2250 + - 2251 + - 2252 + - 2253 + - 2254 + - 2255 + - 2256 + - 2257 + - 2258 + - 2259 + - 2260 + - 2261 + - 2262 + - 2263 + - 2264 + - 2265 + - 2266 + - 2267 + - 2268 + - 2269 + - 2270 + - 2271 + - 2272 + - 2273 + - 2274 + - 2275 + - 2276 + - 2277 + - 2278 + - 2279 + - 2280 + - 2281 + - 2282 + - 2283 + - 2284 + - 2285 + - 2286 + - 2287 + - 2288 + - 2289 + - 2290 + - 2291 + - 2292 + - 2293 + - 2294 + - 2295 + - 2296 + - 2297 + - 2298 + - 2299 + - 2300 + - 2301 + - 2302 + - 2303 + - 2304 + - 2305 + - 2306 + - 2307 + - 2308 + - 2309 + - 2310 + - 2311 + - 2312 + - 2313 + - 2314 + - 2315 + - 2316 + - 2317 + - 2318 + - 2319 + - 2320 + - 2321 + - 2322 + - 2323 + - 2324 + - 2325 + - 2326 + - 2327 + - 2328 + - 2329 + - 2330 + - 2331 + - 2332 + - 2333 + - 2334 + - 2335 + - 2336 + - 2337 + - 2338 + - 2339 + - 2340 + - 2341 + - 2342 + - 2343 + - 2344 + - 2345 + - 2346 + - 2347 + - 2348 + - 2349 + - 2350 + - 2351 + - 2352 + - 2353 + - 2354 + - 2355 + - 2356 + - 2357 + - 2358 + - 2359 + - 2360 + - 2361 + - 2362 + - 2363 + - 2364 + - 2365 + - 2366 + - 2367 + - 2368 + - 2369 + - 2370 + - 2371 + - 2372 + - 2373 + - 2374 + - 2375 + - 2376 + - 2377 + - 2378 + - 2379 + - 2380 + - 2381 + - 2382 + - 2383 + - 2384 + - 2385 + - 2386 + - 2387 + - 2388 + - 2389 + - 2390 + - 2391 + - 2392 + - 2393 + - 2394 + - 2395 + - 2396 + - 2397 + - 2398 + - 2399 + - 2400 + - 2401 + - 2402 + - 2403 + - 2404 + - 2405 + - 2406 + - 2407 + - 2408 + - 2409 + - 2410 + - 2411 + - 2412 + - 2413 + - 2414 + - 2415 + - 2416 + - 2417 + - 2418 + - 2419 + - 2420 + - 2421 + - 2422 + - 2423 + - 2424 + - 2425 + - 2426 + - 2427 + - 2428 + - 2429 + - 2430 + - 2431 + - 2432 + - 2433 + - 2434 + - 2435 + - 2436 + - 2437 + - 2438 + - 2439 + - 2440 + - 2441 + - 2442 + - 2443 + - 2444 + - 2445 + - 2446 + - 2447 + - 2448 + - 2449 + - 2450 + - 2451 + - 2452 + - 2453 + - 2454 + - 2455 + - 2456 + - 2457 + - 2458 + - 2459 + - 2460 + - 2461 + - 2462 + - 2463 + - 2464 + - 2465 + - 2466 + - 2467 + - 2468 + - 2469 + - 2470 + - 2471 + - 2472 + - 2473 + - 2474 + - 2475 + - 2476 + - 2477 + - 2478 + - 2479 + - 2480 + - 2481 + - 2482 + - 2483 + - 2484 + - 2485 + - 2486 + - 2487 + - 2488 + - 2489 + - 2490 + - 2491 + - 2492 + - 2493 + - 2494 + - 2495 + - 2496 + - 2497 + - 2498 + - 2499 + - 2500 + - 2501 + - 2502 + - 2503 + - 2504 + - 2505 + - 2506 + - 2507 + - 2508 + - 2509 + - 2510 + - 2511 + - 2512 + - 2513 + - 2514 + - 2515 + - 2516 + - 2517 + - 2518 + - 2519 + - 2520 + - 2521 + - 2522 + - 2523 + - 2524 + - 2525 + - 2526 + - 2527 + - 2528 + - 2529 + - 2530 + - 2531 + - 2532 + - 2533 + - 2534 + - 2535 + - 2536 + - 2537 + - 2538 + - 2539 + - 2540 + - 2541 + - 2542 + - 2543 + - 2544 + - 2545 + - 2546 + - 2547 + - 2548 + - 2549 + - 2550 + - 2551 + - 2552 + - 2553 + - 2554 + - 2555 + - 2556 + - 2557 + - 2558 + - 2559 + - 2560 + - 2561 + - 2562 + - 2563 + - 2564 + - 2565 + - 2566 + - 2567 + - 2568 + - 2569 + - 2570 + - 2571 + - 2572 + - 2573 + - 2574 + - 2575 + - 2576 + - 2577 + - 2578 + - 2579 + - 2580 + - 2581 + - 2582 + - 2583 + - 2584 + - 2585 + - 2586 + - 2587 + - 2588 + - 2589 + - 2590 + - 2591 + - 2592 + - 2593 + - 2594 + - 2595 + - 2596 + - 2597 + - 2598 + - 2599 + - 2600 + - 2601 + - 2602 + - 2603 + - 2604 + - 2605 + - 2606 + - 2607 + - 2608 + - 2609 + - 2610 + - 2611 + - 2612 + - 2613 + - 2614 + - 2615 + - 2616 + - 2617 + - 2618 + - 2619 + - 2620 + - 2621 + - 2622 + - 2623 + - 2624 + - 2625 + - 2626 + - 2627 + - 2628 + - 2629 + - 2630 + - 2631 + - 2632 + - 2633 + - 2634 + - 2635 + - 2636 + - 2637 + - 2638 + - 2639 + - 2640 + - 2641 + - 2642 + - 2643 + - 2644 + - 2645 + - 2646 + - 2647 + - 2648 + - 2649 + - 2650 + - 2651 + - 2652 + - 2653 + - 2654 + - 2655 + - 2656 + - 2657 + - 2658 + - 2659 + - 2660 + - 2661 + - 2662 + - 2663 + - 2664 + - 2665 + - 2666 + - 2667 + - 2668 + - 2669 + - 2670 + - 2671 + - 2672 + - 2673 + - 2674 + - 2675 + - 2676 + - 2677 + - 2678 + - 2679 + - 2680 + - 2681 + - 2682 + - 2683 + - 2684 + - 2685 + - 2686 + - 2687 + - 2688 + - 2689 + - 2690 + - 2691 + - 2692 + - 2693 + - 2694 + - 2695 + - 2696 + - 2697 + - 2698 + - 2699 + - 2700 + - 2701 + - 2702 + - 2703 + - 2704 + - 2705 + - 2706 + - 2707 + - 2708 + - 2709 + - 2710 + - 2711 + - 2712 + - 2713 + - 2714 + - 2715 + - 2716 + - 2717 + - 2718 + - 2719 + - 2720 + - 2721 + - 2722 + - 2723 + - 2724 + - 2725 + - 2726 + - 2727 + - 2728 + - 2729 + - 2730 + - 2731 + - 2732 + - 2733 + - 2734 + - 2735 + - 2736 + - 2737 + - 2738 + - 2739 + - 2740 + - 2741 + - 2742 + - 2743 + - 2744 + - 2745 + - 2746 + - 2747 + - 2748 + - 2749 + - 2750 + - 2751 + - 2752 + - 2753 + - 2754 + - 2755 + - 2756 + - 2757 + - 2758 + - 2759 + - 2760 + - 2761 + - 2762 + - 2763 + - 2764 + - 2765 + - 2766 + - 2767 + - 2768 + - 2769 + - 2770 + - 2771 + - 2772 + - 2773 + - 2774 + - 2775 + - 2776 + - 2777 + - 2778 + - 2779 + - 2780 + - 2781 + - 2782 + - 2783 + - 2784 + - 2785 + - 2786 + - 2787 + - 2788 + - 2789 + - 2790 + - 2791 + - 2792 + - 2793 + - 2794 + - 2795 + - 2796 + - 2797 + - 2798 + - 2799 + - 2800 + - 2801 + - 2802 + - 2803 + - 2804 + - 2805 + - 2806 + - 2807 + - 2808 + - 2809 + - 2810 + - 2811 + - 2812 + - 2813 + - 2814 + - 2815 + - 2816 + - 2817 + - 2818 + - 2819 + - 2820 + - 2821 + - 2822 + - 2823 + - 2824 + - 2825 + - 2826 + - 2827 + - 2828 + - 2829 + - 2830 + - 2831 + - 2832 + - 2833 + - 2834 + - 2835 + - 2836 + - 2837 + - 2838 + - 2839 + - 2840 + - 2841 + - 2842 + - 2843 + - 2844 + - 2845 + - 2846 + - 2847 + - 2848 + - 2849 + - 2850 + - 2851 + - 2852 + - 2853 + - 2854 + - 2855 + - 2856 + - 2857 + - 2858 + - 2859 + - 2860 + - 2861 + - 2862 + - 2863 + - 2864 + - 2865 + - 2866 + - 2867 + - 2868 + - 2869 + - 2870 + - 2871 + - 2872 + - 2873 + - 2874 + - 2875 + - 2876 + - 2877 + - 2878 + - 2879 + - 2880 + - 2881 + - 2882 + - 2883 + - 2884 + - 2885 + - 2886 + - 2887 + - 2888 + - 2889 + - 2890 + - 2891 + - 2892 + - 2893 + - 2894 + - 2895 + - 2896 + - 2897 + - 2898 + - 2899 + - 2900 + - 2901 + - 2902 + - 2903 + - 2904 + - 2905 + - 2906 + - 2907 + - 2908 + - 2909 + - 2910 + - 2911 + - 2912 + - 2913 + - 2914 + - 2915 + - 2916 + - 2917 + - 2918 + - 2919 + - 2920 + - 2921 + - 2922 + - 2923 + - 2924 + - 2925 + - 2926 + - 2927 + - 2928 + - 2929 + - 2930 + - 2931 + - 2932 + - 2933 + - 2934 + - 2935 + - 2936 + - 2937 + - 2938 + - 2939 + - 2940 + - 2941 + - 2942 + - 2943 + - 2944 + - 2945 + - 2946 + - 2947 + - 2948 + - 2949 + - 2950 + - 2951 + - 2952 + - 2953 + - 2954 + - 2955 + - 2956 + - 2957 + - 2958 + - 2959 + - 2960 + - 2961 + - 2962 + - 2963 + - 2964 + - 2965 + - 2966 + - 2967 + - 2968 + - 2969 + - 2970 + - 2971 + - 2972 + - 2973 + - 2974 + - 2975 + - 2976 + - 2977 + - 2978 + - 2979 + - 2980 + - 2981 + - 2982 + - 2983 + - 2984 + - 2985 + - 2986 + - 2987 + - 2988 + - 2989 + - 2990 + - 2991 + - 2992 + - 2993 + - 2994 + - 2995 + - 2996 + - 2997 + - 2998 + - 2999 + - 3000 + - 3001 + - 3002 + - 3003 + - 3004 + - 3005 + - 3006 + - 3007 + - 3008 + - 3009 + - 3010 + - 3011 + - 3012 + - 3013 + - 3014 + - 3015 + - 3016 + - 3017 + - 3018 + - 3019 + - 3020 + - 3021 + - 3022 + - 3023 + - 3024 + - 3025 + - 3026 + - 3027 + - 3028 + - 3029 + - 3030 + - 3031 + - 3032 + - 3033 + - 3034 + - 3035 + - 3036 + - 3037 + - 3038 + - 3039 + - 3040 + - 3041 + - 3042 + - 3043 + - 3044 + - 3045 + - 3046 + - 3047 + - 3048 + - 3049 + - 3050 + - 3051 + - 3052 + - 3053 + - 3054 + - 3055 + - 3056 + - 3057 + - 3058 + - 3059 + - 3060 + - 3061 + - 3062 + - 3063 + - 3064 + - 3065 + - 3066 + - 3067 + - 3068 + - 3069 + - 3070 + - 3071 + - 3072 + - 3073 + - 3074 + - 3075 + - 3076 + - 3077 + - 3078 + - 3079 + - 3080 + - 3081 + - 3082 + - 3083 + - 3084 + - 3085 + - 3086 + - 3087 + - 3088 + - 3089 + - 3090 + - 3091 + - 3092 + - 3093 + - 3094 + - 3095 + - 3096 + - 3097 + - 3098 + - 3099 + - 3100 + - 3101 + - 3102 + - 3103 + - 3104 + - 3105 + - 3106 + - 3107 + - 3108 + - 3109 + - 3110 + - 3111 + - 3112 + - 3113 + - 3114 + - 3115 + - 3116 + - 3117 + - 3118 + - 3119 + - 3120 + - 3121 + - 3122 + - 3123 + - 3124 + - 3125 + - 3126 + - 3127 + - 3128 + - 3129 + - 3130 + - 3131 + - 3132 + - 3133 + - 3134 + - 3135 + - 3136 + - 3137 + - 3138 + - 3139 + - 3140 + - 3141 + - 3142 + - 3143 + - 3144 + - 3145 + - 3146 + - 3147 + - 3148 + - 3149 + - 3150 + - 3151 + - 3152 + - 3153 + - 3154 + - 3155 + - 3156 + - 3157 + - 3158 + - 3159 + - 3160 + - 3161 + - 3162 + - 3163 + - 3164 + - 3165 + - 3166 + - 3167 + - 3168 + - 3169 + - 3170 + - 3171 + - 3172 + - 3173 + - 3174 + - 3175 + - 3176 + - 3177 + - 3178 + - 3179 + - 3180 + - 3181 + - 3182 + - 3183 + - 3184 + - 3185 + - 3186 + - 3187 + - 3188 + - 3189 + - 3190 + - 3191 + - 3192 + - 3193 + - 3194 + - 3195 + - 3196 + - 3197 + - 3198 + - 3199 + - 3200 + - 3201 + - 3202 + - 3203 + - 3204 + - 3205 + - 3206 + - 3207 + - 3208 + - 3209 + - 3210 + - 3211 + - 3212 + - 3213 + - 3214 + - 3215 + - 3216 + - 3217 + - 3218 + - 3219 + - 3220 + - 3221 + - 3222 + - 3223 + - 3224 + - 3225 + - 3226 + - 3227 + - 3228 + - 3229 + - 3230 + - 3231 + - 3232 + - 3233 + - 3234 + - 3235 + - 3236 + - 3237 + - 3238 + - 3239 + - 3240 + - 3241 + - 3242 + - 3243 + - 3244 + - 3245 + - 3246 + - 3247 + - 3248 + - 3249 + - 3250 + - 3251 + - 3252 + - 3253 + - 3254 + - 3255 + - 3256 + - 3257 + - 3258 + - 3259 + - 3260 + - 3261 + - 3262 + - 3263 + - 3264 + - 3265 + - 3266 + - 3267 + - 3268 + - 3269 + - 3270 + - 3271 + - 3272 + - 3273 + - 3274 + - 3275 + - 3276 + - 3277 + - 3278 + - 3279 + - 3280 + - 3281 + - 3282 + - 3283 + - 3284 + - 3285 + - 3286 + - 3287 + - 3288 + - 3289 + - 3290 + - 3291 + - 3292 + - 3293 + - 3294 + - 3295 + - 3296 + - 3297 + - 3298 + - 3299 + - 3300 + - 3301 + - 3302 + - 3303 + - 3304 + - 3305 + - 3306 + - 3307 + - 3308 + - 3309 + - 3310 + - 3311 + - 3312 + - 3313 + - 3314 + - 3315 + - 3316 + - 3317 + - 3318 + - 3319 + - 3320 + - 3321 + - 3322 + - 3323 + - 3324 + - 3325 + - 3326 + - 3327 + - 3328 + - 3329 + - 3330 + - 3331 + - 3332 + - 3333 + - 3334 + - 3335 + - 3336 + - 3337 + - 3338 + - 3339 + - 3340 + - 3341 + - 3342 + - 3343 + - 3344 + - 3345 + - 3346 + - 3347 + - 3348 + - 3349 + - 3350 + - 3351 + - 3352 + - 3353 + - 3354 + - 3355 + - 3356 + - 3357 + - 3358 + - 3359 + - 3360 + - 3361 + - 3362 + - 3363 + - 3364 + - 3365 + - 3366 + - 3367 + - 3368 + - 3369 + - 3370 + - 3371 + - 3372 + - 3373 + - 3374 + - 3375 + - 3376 + - 3377 + - 3378 + - 3379 + - 3380 + - 3381 + - 3382 + - 3383 + - 3384 + - 3385 + - 3386 + - 3387 + - 3388 + - 3389 + - 3390 + - 3391 + - 3392 + - 3393 + - 3394 + - 3395 + - 3396 + - 3397 + - 3398 + - 3399 + - 3400 + - 3401 + - 3402 + - 3403 + - 3404 + - 3405 + - 3406 + - 3407 + - 3408 + - 3409 + - 3410 + - 3411 + - 3412 + - 3413 + - 3414 + - 3415 + - 3416 + - 3417 + - 3418 + - 3419 + - 3420 + - 3421 + - 3422 + - 3423 + - 3424 + - 3425 + - 3426 + - 3427 + - 3428 + - 3429 + - 3430 + - 3431 + - 3432 + - 3433 + - 3434 + - 3435 + - 3436 + - 3437 + - 3438 + - 3439 + - 3440 + - 3441 + - 3442 + - 3443 + - 3444 + - 3445 + - 3446 + - 3447 + - 3448 + - 3449 + - 3450 + - 3451 + - 3452 + - 3453 + - 3454 + - 3455 + - 3456 + - 3457 + - 3458 + - 3459 + - 3460 + - 3461 + - 3462 + - 3463 + - 3464 + - 3465 + - 3466 + - 3467 + - 3468 + - 3469 + - 3470 + - 3471 + - 3472 + - 3473 + - 3474 + - 3475 + - 3476 + - 3477 + - 3478 + - 3479 + - 3480 + - 3481 + - 3482 + - 3483 + - 3484 + - 3485 + - 3486 + - 3487 + - 3488 + - 3489 + - 3490 + - 3491 + - 3492 + - 3493 + - 3494 + - 3495 + - 3496 + - 3497 + - 3498 + - 3499 + - 3500 + - 3501 + - 3502 + - 3503 + - 3504 + - 3505 + - 3506 + - 3507 + - 3508 + - 3509 + - 3510 + - 3511 + - 3512 + - 3513 + - 3514 + - 3515 + - 3516 + - 3517 + - 3518 + - 3519 + - 3520 + - 3521 + - 3522 + - 3523 + - 3524 + - 3525 + - 3526 + - 3527 + - 3528 + - 3529 + - 3530 + - 3531 + - 3532 + - 3533 + - 3534 + - 3535 + - 3536 + - 3537 + - 3538 + - 3539 + - 3540 + - 3541 + - 3542 + - 3543 + - 3544 + - 3545 + - 3546 + - 3547 + - 3548 + - 3549 + - 3550 + - 3551 + - 3552 + - 3553 + - 3554 + - 3555 + - 3556 + - 3557 + - 3558 + - 3559 + - 3560 + - 3561 + - 3562 + - 3563 + - 3564 + - 3565 + - 3566 + - 3567 + - 3568 + - 3569 + - 3570 + - 3571 + - 3572 + - 3573 + - 3574 + - 3575 + - 3576 + - 3577 + - 3578 + - 3579 + - 3580 + - 3581 + - 3582 + - 3583 + - 3584 + - 3585 + - 3586 + - 3587 + - 3588 + - 3589 + - 3590 + - 3591 + - 3592 + - 3593 + - 3594 + - 3595 + - 3596 + - 3597 + - 3598 + - 3599 + - 3600 + - 3601 + - 3602 + - 3603 + - 3604 + - 3605 + - 3606 + - 3607 + - 3608 + - 3609 + - 3610 + - 3611 + - 3612 + - 3613 + - 3614 + - 3615 + - 3616 + - 3617 + - 3618 + - 3619 + - 3620 + - 3621 + - 3622 + - 3623 + - 3624 + - 3625 + - 3626 + - 3627 + - 3628 + - 3629 + - 3630 + - 3631 + - 3632 + - 3633 + - 3634 + - 3635 + - 3636 + - 3637 + - 3638 + - 3639 + - 3640 + - 3641 + - 3642 + - 3643 + - 3644 + - 3645 + - 3646 + - 3647 + - 3648 + - 3649 + - 3650 + - 3651 + - 3652 + - 3653 + - 3654 + - 3655 + - 3656 + - 3657 + - 3658 + - 3659 + - 3660 + - 3661 + - 3662 + - 3663 + - 3664 + - 3665 + - 3666 + - 3667 + - 3668 + - 3669 + - 3670 + - 3671 + - 3672 + - 3673 + - 3674 + - 3675 + - 3676 + - 3677 + - 3678 + - 3679 + - 3680 + - 3681 + - 3682 + - 3683 + - 3684 + - 3685 + - 3686 + - 3687 + - 3688 + - 3689 + - 3690 + - 3691 + - 3692 + - 3693 + - 3694 + - 3695 + - 3696 + - 3697 + - 3698 + - 3699 + - 3700 + - 3701 + - 3702 + - 3703 + - 3704 + - 3705 + - 3706 + - 3707 + - 3708 + - 3709 + - 3710 + - 3711 + - 3712 + - 3713 + - 3714 + - 3715 + - 3716 + - 3717 + - 3718 + - 3719 + - 3720 + - 3721 + - 3722 + - 3723 + - 3724 + - 3725 + - 3726 + - 3727 + - 3728 + - 3729 + - 3730 + - 3731 + - 3732 + - 3733 + - 3734 + - 3735 + - 3736 + - 3737 + - 3738 + - 3739 + - 3740 + - 3741 + - 3742 + - 3743 + - 3744 + - 3745 + - 3746 + - 3747 + - 3748 + - 3749 + - 3750 + - 3751 + - 3752 + - 3753 + - 3754 + - 3755 + - 3756 + - 3757 + - 3758 + - 3759 + - 3760 + - 3761 + - 3762 + - 3763 + - 3764 + - 3765 + - 3766 + - 3767 + - 3768 + - 3769 + - 3770 + - 3771 + - 3772 + - 3773 + - 3774 + - 3775 + - 3776 + - 3777 + - 3778 + - 3779 + - 3780 + - 3781 + - 3782 + - 3783 + - 3784 + - 3785 + - 3786 + - 3787 + - 3788 + - 3789 + - 3790 + - 3791 + - 3792 + - 3793 + - 3794 + - 3795 + - 3796 + - 3797 + - 3798 + - 3799 + - 3800 + - 3801 + - 3802 + - 3803 + - 3804 + - 3805 + - 3806 + - 3807 + - 3808 + - 3809 + - 3810 + - 3811 + - 3812 + - 3813 + - 3814 + - 3815 + - 3816 + - 3817 + - 3818 + - 3819 + - 3820 + - 3821 + - 3822 + - 3823 + - 3824 + - 3825 + - 3826 + - 3827 + - 3828 + - 3829 + - 3830 + - 3831 + - 3832 + - 3833 + - 3834 + - 3835 + - 3836 + - 3837 + - 3838 + - 3839 + - 3840 + - 3841 + - 3842 + - 3843 + - 3844 + - 3845 + - 3846 + - 3847 + - 3848 + - 3849 + - 3850 + - 3851 + - 3852 + - 3853 + - 3854 + - 3855 + - 3856 + - 3857 + - 3858 + - 3859 + - 3860 + - 3861 + - 3862 + - 3863 + - 3864 + - 3865 + - 3866 + - 3867 + - 3868 + - 3869 + - 3870 + - 3871 + - 3872 + - 3873 + - 3874 + - 3875 + - 3876 + - 3877 + - 3878 + - 3879 + - 3880 + - 3881 + - 3882 + - 3883 + - 3884 + - 3885 + - 3886 + - 3887 + - 3888 + - 3889 + - 3890 + - 3891 + - 3892 + - 3893 + - 3894 + - 3895 + - 3896 + - 3897 + - 3898 + - 3899 + - 3900 + - 3901 + - 3902 + - 3903 + - 3904 + - 3905 + - 3906 + - 3907 + - 3908 + - 3909 + - 3910 + - 3911 + - 3912 + - 3913 + - 3914 + - 3915 + - 3916 + - 3917 + - 3918 + - 3919 + - 3920 + - 3921 + - 3922 + - 3923 + - 3924 + - 3925 + - 3926 + - 3927 + - 3928 + - 3929 + - 3930 + - 3931 + - 3932 + - 3933 + - 3934 + - 3935 + - 3936 + - 3937 + - 3938 + - 3939 + - 3940 + - 3941 + - 3942 + - 3943 + - 3944 + - 3945 + - 3946 + - 3947 + - 3948 + - 3949 + - 3950 + - 3951 + - 3952 + - 3953 + - 3954 + - 3955 + - 3956 + - 3957 + - 3958 + - 3959 + - 3960 + - 3961 + - 3962 + - 3963 + - 3964 + - 3965 + - 3966 + - 3967 + - 3968 + - 3969 + - 3970 + - 3971 + - 3972 + - 3973 + - 3974 + - 3975 + - 3976 + - 3977 + - 3978 + - 3979 + - 3980 + - 3981 + - 3982 + - 3983 + - 3984 + - 3985 + - 3986 + - 3987 + - 3988 + - 3989 + - 3990 + - 3991 + - 3992 + - 3993 + - 3994 + - 3995 + - 3996 + - 3997 + - 3998 + - 3999 + - 4000 + - 4001 + - 4002 + - 4003 + - 4004 + - 4005 + - 4006 + - 4007 + - 4008 + - 4009 + - 4010 + - 4011 + - 4012 + - 4013 + - 4014 + - 4015 + - 4016 + - 4017 + - 4018 + - 4019 + - 4020 + - 4021 + - 4022 + - 4023 + - 4024 + - 4025 + - 4026 + - 4027 + - 4028 + - 4029 + - 4030 + - 4031 + - 4032 + - 4033 + - 4034 + - 4035 + - 4036 + - 4037 + - 4038 + - 4039 + - 4040 + - 4041 + - 4042 + - 4043 + - 4044 + - 4045 + - 4046 + - 4047 + - 4048 + - 4049 + - 4050 + - 4051 + - 4052 + - 4053 + - 4054 + - 4055 + - 4056 + - 4057 + - 4058 + - 4059 + - 4060 + - 4061 + - 4062 + - 4063 + - 4064 + - 4065 + - 4066 + - 4067 + - 4068 + - 4069 + - 4070 + - 4071 + - 4072 + - 4073 + - 4074 + - 4075 + - 4076 + - 4077 + - 4078 + - 4079 + - 4080 + - 4081 + - 4082 + - 4083 + - 4084 + - 4085 + - 4086 + - 4087 + - 4088 + - 4089 + - 4090 + - 4091 + - 4092 + - 4093 + - 4094 + - 4095 + - 4096 + - 4097 + - 4098 + - 4099 + - 4100 + - 4101 + - 4102 + - 4103 + - 4104 + - 4105 + - 4106 + - 4107 + - 4108 + - 4109 + - 4110 + - 4111 + - 4112 + - 4113 + - 4114 + - 4115 + - 4116 + - 4117 + - 4118 + - 4119 + - 4120 + - 4121 + - 4122 + - 4123 + - 4124 + - 4125 + - 4126 + - 4127 + - 4128 + - 4129 + - 4130 + - 4131 + - 4132 + - 4133 + - 4134 + - 4135 + - 4136 + - 4137 + - 4138 + - 4139 + - 4140 + - 4141 + - 4142 + - 4143 + - 4144 + - 4145 + - 4146 + - 4147 + - 4148 + - 4149 + - 4150 + - 4151 + - 4152 + - 4153 + - 4154 + - 4155 + - 4156 + - 4157 + - 4158 + - 4159 + - 4160 + - 4161 + - 4162 + - 4163 + - 4164 + - 4165 + - 4166 + - 4167 + - 4168 + - 4169 + - 4170 + - 4171 + - 4172 + - 4173 + - 4174 + - 4175 + - 4176 + - 4177 + - 4178 + - 4179 + - 4180 + - 4181 + - 4182 + - 4183 + - 4184 + - 4185 + - 4186 + - 4187 + - 4188 + - 4189 + - 4190 + - 4191 + - 4192 + - 4193 + - 4194 + - 4195 + - 4196 + - 4197 + - 4198 + - 4199 + - 4200 + - 4201 + - 4202 + - 4203 + - 4204 + - 4205 + - 4206 + - 4207 + - 4208 + - 4209 + - 4210 + - 4211 + - 4212 + - 4213 + - 4214 + - 4215 + - 4216 + - 4217 + - 4218 + - 4219 + - 4220 + - 4221 + - 4222 + - 4223 + - 4224 + - 4225 + - 4226 + - 4227 + - 4228 + - 4229 + - 4230 + - 4231 + - 4232 + - 4233 + - 4234 + - 4235 + - 4236 + - 4237 + - 4238 + - 4239 + - 4240 + - 4241 + - 4242 + - 4243 + - 4244 + - 4245 + - 4246 + - 4247 + - 4248 + - 4249 + - 4250 + - 4251 + - 4252 + - 4253 + - 4254 + - 4255 + - 4256 + - 4257 + - 4258 + - 4259 + - 4260 + - 4261 + - 4262 + - 4263 + - 4264 + - 4265 + - 4266 + - 4267 + - 4268 + - 4269 + - 4270 + - 4271 + - 4272 + - 4273 + - 4274 + - 4275 + - 4276 + - 4277 + - 4278 + - 4279 + - 4280 + - 4281 + - 4282 + - 4283 + - 4284 + - 4285 + - 4286 + - 4287 + - 4288 + - 4289 + - 4290 + - 4291 + - 4292 + - 4293 + - 4294 + - 4295 + - 4296 + - 4297 + - 4298 + - 4299 + - 4300 + - 4301 + - 4302 + - 4303 + - 4304 + - 4305 + - 4306 + - 4307 + - 4308 + - 4309 + - 4310 + - 4311 + - 4312 + - 4313 + - 4314 + - 4315 + - 4316 + - 4317 + - 4318 + - 4319 + - 4320 + - 4321 + - 4322 + - 4323 + - 4324 + - 4325 + - 4326 + - 4327 + - 4328 + - 4329 + - 4330 + - 4331 + - 4332 + - 4333 + - 4334 + - 4335 + - 4336 + - 4337 + - 4338 + - 4339 + - 4340 + - 4341 + - 4342 + - 4343 + - 4344 + - 4345 + - 4346 + - 4347 + - 4348 + - 4349 + - 4350 + - 4351 + - 4352 + - 4353 + - 4354 + - 4355 + - 4356 + - 4357 + - 4358 + - 4359 + - 4360 + - 4361 + - 4362 + - 4363 + - 4364 + - 4365 + - 4366 + - 4367 + - 4368 + - 4369 + - 4370 + - 4371 + - 4372 + - 4373 + - 4374 + - 4375 + - 4376 + - 4377 + - 4378 + - 4379 + - 4380 + - 4381 + - 4382 + - 4383 + - 4384 + - 4385 + - 4386 + - 4387 + - 4388 + - 4389 + - 4390 + - 4391 + - 4392 + - 4393 + - 4394 + - 4395 + - 4396 + - 4397 + - 4398 + - 4399 + - 4400 + - 4401 + - 4402 + - 4403 + - 4404 + - 4405 + - 4406 + - 4407 + - 4408 + - 4409 + - 4410 + - 4411 + - 4412 + - 4413 + - 4414 + - 4415 + - 4416 + - 4417 + - 4418 + - 4419 + - 4420 + - 4421 + - 4422 + - 4423 + - 4424 + - 4425 + - 4426 + - 4427 + - 4428 + - 4429 + - 4430 + - 4431 + - 4432 + - 4433 + - 4434 + - 4435 + - 4436 + - 4437 + - 4438 + - 4439 + - 4440 + - 4441 + - 4442 + - 4443 + - 4444 + - 4445 + - 4446 + - 4447 + - 4448 + - 4449 + - 4450 + - 4451 + - 4452 + - 4453 + - 4454 + - 4455 + - 4456 + - 4457 + - 4458 + - 4459 + - 4460 + - 4461 + - 4462 + - 4463 + - 4464 + - 4465 + - 4466 + - 4467 + - 4468 + - 4469 + - 4470 + - 4471 + - 4472 + - 4473 + - 4474 + - 4475 + - 4476 + - 4477 + - 4478 + - 4479 + - 4480 + - 4481 + - 4482 + - 4483 + - 4484 + - 4485 + - 4486 + - 4487 + - 4488 + - 4489 + - 4490 + - 4491 + - 4492 + - 4493 + - 4494 + - 4495 + - 4496 + - 4497 + - 4498 + - 4499 + - 4500 + - 4501 + - 4502 + - 4503 + - 4504 + - 4505 + - 4506 + - 4507 + - 4508 + - 4509 + - 4510 + - 4511 + - 4512 + - 4513 + - 4514 + - 4515 + - 4516 + - 4517 + - 4518 + - 4519 + - 4520 + - 4521 + - 4522 + - 4523 + - 4524 + - 4525 + - 4526 + - 4527 + - 4528 + - 4529 + - 4530 + - 4531 + - 4532 + - 4533 + - 4534 + - 4535 + - 4536 + - 4537 + - 4538 + - 4539 + - 4540 + - 4541 + - 4542 + - 4543 + - 4544 + - 4545 + - 4546 + - 4547 + - 4548 + - 4549 + - 4550 + - 4551 + - 4552 + - 4553 + - 4554 + - 4555 + - 4556 + - 4557 + - 4558 + - 4559 + - 4560 + - 4561 + - 4562 + - 4563 + - 4564 + - 4565 + - 4566 + - 4567 + - 4568 + - 4569 + - 4570 + - 4571 + - 4572 + - 4573 + - 4574 + - 4575 + - 4576 + - 4577 + - 4578 + - 4579 + - 4580 + - 4581 + - 4582 + - 4583 + - 4584 + - 4585 + - 4586 + - 4587 + - 4588 + - 4589 + - 4590 + - 4591 + - 4592 + - 4593 + - 4594 + - 4595 + - 4596 + - 4597 + - 4598 + - 4599 + - 4600 + - 4601 + - 4602 + - 4603 + - 4604 + - 4605 + - 4606 + - 4607 + - 4608 + - 4609 + - 4610 + - 4611 + - 4612 + - 4613 + - 4614 + - 4615 + - 4616 + - 4617 + - 4618 + - 4619 + - 4620 + - 4621 + - 4622 + - 4623 + - 4624 + - 4625 + - 4626 + - 4627 + - 4628 + - 4629 + - 4630 + - 4631 + - 4632 + - 4633 + - 4634 + - 4635 + - 4636 + - 4637 + - 4638 + - 4639 + - 4640 + - 4641 + - 4642 + - 4643 + - 4644 + - 4645 + - 4646 + - 4647 + - 4648 + - 4649 + - 4650 + - 4651 + - 4652 + - 4653 + - 4654 + - 4655 + - 4656 + - 4657 + - 4658 + - 4659 + - 4660 + - 4661 + - 4662 + - 4663 + - 4664 + - 4665 + - 4666 + - 4667 + - 4668 + - 4669 + - 4670 + - 4671 + - 4672 + - 4673 + - 4674 + - 4675 + - 4676 + - 4677 + - 4678 + - 4679 + - 4680 + - 4681 + - 4682 + - 4683 + - 4684 + - 4685 + - 4686 + - 4687 + - 4688 + - 4689 + - 4690 + - 4691 + - 4692 + - 4693 + - 4694 + - 4695 + - 4696 + - 4697 + - 4698 + - 4699 + - 4700 + - 4701 + - 4702 + - 4703 + - 4704 + - 4705 + - 4706 + - 4707 + - 4708 + - 4709 + - 4710 + - 4711 + - 4712 + - 4713 + - 4714 + - 4715 + - 4716 + - 4717 + - 4718 + - 4719 + - 4720 + - 4721 + - 4722 + - 4723 + - 4724 + - 4725 + - 4726 + - 4727 + - 4728 + - 4729 + - 4730 + - 4731 + - 4732 + - 4733 + - 4734 + - 4735 + - 4736 + - 4737 + - 4738 + - 4739 + - 4740 + - 4741 + - 4742 + - 4743 + - 4744 + - 4745 + - 4746 + - 4747 + - 4748 + - 4749 + - 4750 + - 4751 + - 4752 + - 4753 + - 4754 + - 4755 + - 4756 + - 4757 + - 4758 + - 4759 + - 4760 + - 4761 + - 4762 + - 4763 + - 4764 + - 4765 + - 4766 + - 4767 + - 4768 + - 4769 + - 4770 + - 4771 + - 4772 + - 4773 + - 4774 + - 4775 + - 4776 + - 4777 + - 4778 + - 4779 + - 4780 + - 4781 + - 4782 + - 4783 + - 4784 + - 4785 + - 4786 + - 4787 + - 4788 + - 4789 + - 4790 + - 4791 + - 4792 + - 4793 + - 4794 + - 4795 + - 4796 + - 4797 + - 4798 + - 4799 + - 4800 + - 4801 + - 4802 + - 4803 + - 4804 + - 4805 + - 4806 + - 4807 + - 4808 + - 4809 + - 4810 + - 4811 + - 4812 + - 4813 + - 4814 + - 4815 + - 4816 + - 4817 + - 4818 + - 4819 + - 4820 + - 4821 + - 4822 + - 4823 + - 4824 + - 4825 + - 4826 + - 4827 + - 4828 + - 4829 + - 4830 + - 4831 + - 4832 + - 4833 + - 4834 + - 4835 + - 4836 + - 4837 + - 4838 + - 4839 + - 4840 + - 4841 + - 4842 + - 4843 + - 4844 + - 4845 + - 4846 + - 4847 + - 4848 + - 4849 + - 4850 + - 4851 + - 4852 + - 4853 + - 4854 + - 4855 + - 4856 + - 4857 + - 4858 + - 4859 + - 4860 + - 4861 + - 4862 + - 4863 + - 4864 + - 4865 + - 4866 + - 4867 + - 4868 + - 4869 + - 4870 + - 4871 + - 4872 + - 4873 + - 4874 + - 4875 + - 4876 + - 4877 + - 4878 + - 4879 + - 4880 + - 4881 + - 4882 + - 4883 + - 4884 + - 4885 + - 4886 + - 4887 + - 4888 + - 4889 + - 4890 + - 4891 + - 4892 + - 4893 + - 4894 + - 4895 + - 4896 + - 4897 + - 4898 + - 4899 + - 4900 + - 4901 + - 4902 + - 4903 + - 4904 + - 4905 + - 4906 + - 4907 + - 4908 + - 4909 + - 4910 + - 4911 + - 4912 + - 4913 + - 4914 + - 4915 + - 4916 + - 4917 + - 4918 + - 4919 + - 4920 + - 4921 + - 4922 + - 4923 + - 4924 + - 4925 + - 4926 + - 4927 + - 4928 + - 4929 + - 4930 + - 4931 + - 4932 + - 4933 + - 4934 + - 4935 + - 4936 + - 4937 + - 4938 + - 4939 + - 4940 + - 4941 + - 4942 + - 4943 + - 4944 + - 4945 + - 4946 + - 4947 + - 4948 + - 4949 + - 4950 + - 4951 + - 4952 + - 4953 + - 4954 + - 4955 + - 4956 + - 4957 + - 4958 + - 4959 + - 4960 + - 4961 + - 4962 + - 4963 + - 4964 + - 4965 + - 4966 + - 4967 + - 4968 + - 4969 + - 4970 + - 4971 + - 4972 + - 4973 + - 4974 + - 4975 + - 4976 + - 4977 + - 4978 + - 4979 + - 4980 + - 4981 + - 4982 + - 4983 + - 4984 + - 4985 + - 4986 + - 4987 + - 4988 + - 4989 + - 4990 + - 4991 + - 4992 + - 4993 + - 4994 + - 4995 + - 4996 + - 4997 + - 4998 + - 4999 + - 5000 + - 5001 + - 5002 + - 5003 + - 5004 + - 5005 + - 5006 + - 5007 + - 5008 + - 5009 + - 5010 + - 5011 + - 5012 + - 5013 + - 5014 + - 5015 + - 5016 + - 5017 + - 5018 + - 5019 + - 5020 + - 5021 + - 5022 + - 5023 + - 5024 + - 5025 + - 5026 + - 5027 + - 5028 + - 5029 + - 5030 + - 5031 + - 5032 + - 5033 + - 5034 + - 5035 + - 5036 + - 5037 + - 5038 + - 5039 + - 5040 + - 5041 + - 5042 + - 5043 + - 5044 + - 5045 + - 5046 + - 5047 + - 5048 + - 5049 + - 5050 + - 5051 + - 5052 + - 5053 + - 5054 + - 5055 + - 5056 + - 5057 + - 5058 + - 5059 + - 5060 + - 5061 + - 5062 + - 5063 + - 5064 + - 5065 + - 5066 + - 5067 + - 5068 + - 5069 + - 5070 + - 5071 + - 5072 + - 5073 + - 5074 + - 5075 + - 5076 + - 5077 + - 5078 + - 5079 + - 5080 + - 5081 + - 5082 + - 5083 + - 5084 + - 5085 + - 5086 + - 5087 + - 5088 + - 5089 + - 5090 + - 5091 + - 5092 + - 5093 + - 5094 + - 5095 + - 5096 + - 5097 + - 5098 + - 5099 + - 5100 + - 5101 + - 5102 + - 5103 + - 5104 + - 5105 + - 5106 + - 5107 + - 5108 + - 5109 + - 5110 + - 5111 + - 5112 + - 5113 + - 5114 + - 5115 + - 5116 + - 5117 + - 5118 + - 5119 + - 5120 + - 5121 + - 5122 + - 5123 + - 5124 + - 5125 + - 5126 + - 5127 + - 5128 + - 5129 + - 5130 + - 5131 + - 5132 + - 5133 + - 5134 + - 5135 + - 5136 + - 5137 + - 5138 + - 5139 + - 5140 + - 5141 + - 5142 + - 5143 + - 5144 + - 5145 + - 5146 + - 5147 + - 5148 + - 5149 + - 5150 + - 5151 + - 5152 + - 5153 + - 5154 + - 5155 + - 5156 + - 5157 + - 5158 + - 5159 + - 5160 + - 5161 + - 5162 + - 5163 + - 5164 + - 5165 + - 5166 + - 5167 + - 5168 + - 5169 + - 5170 + - 5171 + - 5172 + - 5173 + - 5174 + - 5175 + - 5176 + - 5177 + - 5178 + - 5179 + - 5180 + - 5181 + - 5182 + - 5183 + - 5184 + - 5185 + - 5186 + - 5187 + - 5188 + - 5189 + - 5190 + - 5191 + - 5192 + - 5193 + - 5194 + - 5195 + - 5196 + - 5197 + - 5198 + - 5199 + - 5200 + - 5201 + - 5202 + - 5203 + - 5204 + - 5205 + - 5206 + - 5207 + - 5208 + - 5209 + - 5210 + - 5211 + - 5212 + - 5213 + - 5214 + - 5215 + - 5216 + - 5217 + - 5218 + - 5219 + - 5220 + - 5221 + - 5222 + - 5223 + - 5224 + - 5225 + - 5226 + - 5227 + - 5228 + - 5229 + - 5230 + - 5231 + - 5232 + - 5233 + - 5234 + - 5235 + - 5236 + - 5237 + - 5238 + - 5239 + - 5240 + - 5241 + - 5242 + - 5243 + - 5244 + - 5245 + - 5246 + - 5247 + - 5248 + - 5249 + - 5250 + - 5251 + - 5252 + - 5253 + - 5254 + - 5255 + - 5256 + - 5257 + - 5258 + - 5259 + - 5260 + - 5261 + - 5262 + - 5263 + - 5264 + - 5265 + - 5266 + - 5267 + - 5268 + - 5269 + - 5270 + - 5271 + - 5272 + - 5273 + - 5274 + - 5275 + - 5276 + - 5277 + - 5278 + - 5279 + - 5280 + - 5281 + - 5282 + - 5283 + - 5284 + - 5285 + - 5286 + - 5287 + - 5288 + - 5289 + - 5290 + - 5291 + - 5292 + - 5293 + - 5294 + - 5295 + - 5296 + - 5297 + - 5298 + - 5299 + - 5300 + - 5301 + - 5302 + - 5303 + - 5304 + - 5305 + - 5306 + - 5307 + - 5308 + - 5309 + - 5310 + - 5311 + - 5312 + - 5313 + - 5314 + - 5315 + - 5316 + - 5317 + - 5318 + - 5319 + - 5320 + - 5321 + - 5322 + - 5323 + - 5324 + - 5325 + - 5326 + - 5327 + - 5328 + - 5329 + - 5330 + - 5331 + - 5332 + - 5333 + - 5334 + - 5335 + - 5336 + - 5337 + - 5338 + - 5339 + - 5340 + - 5341 + - 5342 + - 5343 + - 5344 + - 5345 + - 5346 + - 5347 + - 5348 + - 5349 + - 5350 + - 5351 + - 5352 + - 5353 + - 5354 + - 5355 + - 5356 + - 5357 + - 5358 + - 5359 + - 5360 + - 5361 + - 5362 + - 5363 + - 5364 + - 5365 + - 5366 + - 5367 + - 5368 + - 5369 + - 5370 + - 5371 + - 5372 + - 5373 + - 5374 + - 5375 + - 5376 + - 5377 + - 5378 + - 5379 + - 5380 + - 5381 + - 5382 + - 5383 + - 5384 + - 5385 + - 5386 + - 5387 + - 5388 + - 5389 + - 5390 + - 5391 + - 5392 + - 5393 + - 5394 + - 5395 + - 5396 + - 5397 + - 5398 + - 5399 + - 5400 + - 5401 + - 5402 + - 5403 + - 5404 + - 5405 + - 5406 + - 5407 + - 5408 + - 5409 + - 5410 + - 5411 + - 5412 + - 5413 + - 5414 + - 5415 + - 5416 + - 5417 + - 5418 + - 5419 + - 5420 + - 5421 + - 5422 + - 5423 + - 5424 + - 5425 + - 5426 + - 5427 + - 5428 + - 5429 + - 5430 + - 5431 + - 5432 + - 5433 + - 5434 + - 5435 + - 5436 + - 5437 + - 5438 + - 5439 + - 5440 + - 5441 + - 5442 + - 5443 + - 5444 + - 5445 + - 5446 + - 5447 + - 5448 + - 5449 + - 5450 + - 5451 + - 5452 + - 5453 + - 5454 + - 5455 + - 5456 + - 5457 + - 5458 + - 5459 + - 5460 + - 5461 + - 5462 + - 5463 + - 5464 + - 5465 + - 5466 + - 5467 + - 5468 + - 5469 + - 5470 + - 5471 + - 5472 + - 5473 + - 5474 + - 5475 + - 5476 + - 5477 + - 5478 + - 5479 + - 5480 + - 5481 + - 5482 + - 5483 + - 5484 + - 5485 + - 5486 + - 5487 + - 5488 + - 5489 + - 5490 + - 5491 + - 5492 + - 5493 + - 5494 + - 5495 + - 5496 + - 5497 + - 5498 + - 5499 + - 5500 + - 5501 + - 5502 + - 5503 + - 5504 + - 5505 + - 5506 + - 5507 + - 5508 + - 5509 + - 5510 + - 5511 + - 5512 + - 5513 + - 5514 + - 5515 + - 5516 + - 5517 + - 5518 + - 5519 + - 5520 + - 5521 + - 5522 + - 5523 + - 5524 + - 5525 + - 5526 + - 5527 + - 5528 + - 5529 + - 5530 + - 5531 + - 5532 + - 5533 + - 5534 + - 5535 + - 5536 + - 5537 + - 5538 + - 5539 + - 5540 + - 5541 + - 5542 + - 5543 + - 5544 + - 5545 + - 5546 + - 5547 + - 5548 + - 5549 + - 5550 + - 5551 + - 5552 + - 5553 + - 5554 + - 5555 + - 5556 + - 5557 + - 5558 + - 5559 + - 5560 + - 5561 + - 5562 + - 5563 + - 5564 + - 5565 + - 5566 + - 5567 + - 5568 + - 5569 + - 5570 + - 5571 + - 5572 + - 5573 + - 5574 + - 5575 + - 5576 + - 5577 + - 5578 + - 5579 + - 5580 + - 5581 + - 5582 + - 5583 + - 5584 + - 5585 + - 5586 + - 5587 + - 5588 + - 5589 + - 5590 + - 5591 + - 5592 + - 5593 + - 5594 + - 5595 + - 5596 + - 5597 + - 5598 + - 5599 + - 5600 + - 5601 + - 5602 + - 5603 + - 5604 + - 5605 + - 5606 + - 5607 + - 5608 + - 5609 + - 5610 + - 5611 + - 5612 + - 5613 + - 5614 + - 5615 + - 5616 + - 5617 + - 5618 + - 5619 + - 5620 + - 5621 + - 5622 + - 5623 + - 5624 + - 5625 + - 5626 + - 5627 + - 5628 + - 5629 + - 5630 + - 5631 + - 5632 + - 5633 + - 5634 + - 5635 + - 5636 + - 5637 + - 5638 + - 5639 + - 5640 + - 5641 + - 5642 + - 5643 + - 5644 + - 5645 + - 5646 + - 5647 + - 5648 + - 5649 + - 5650 + - 5651 + - 5652 + - 5653 + - 5654 + - 5655 + - 5656 + - 5657 + - 5658 + - 5659 + - 5660 + - 5661 + - 5662 + - 5663 + - 5664 + - 5665 + - 5666 + - 5667 + - 5668 + - 5669 + - 5670 + - 5671 + - 5672 + - 5673 + - 5674 + - 5675 + - 5676 + - 5677 + - 5678 + - 5679 + - 5680 + - 5681 + - 5682 + - 5683 + - 5684 + - 5685 + - 5686 + - 5687 + - 5688 + - 5689 + - 5690 + - 5691 + - 5692 + - 5693 + - 5694 + - 5695 + - 5696 + - 5697 + - 5698 + - 5699 + - 5700 + - 5701 + - 5702 + - 5703 + - 5704 + - 5705 + - 5706 + - 5707 + - 5708 + - 5709 + - 5710 + - 5711 + - 5712 + - 5713 + - 5714 + - 5715 + - 5716 + - 5717 + - 5718 + - 5719 + - 5720 + - 5721 + - 5722 + - 5723 + - 5724 + - 5725 + - 5726 + - 5727 + - 5728 + - 5729 + - 5730 + - 5731 + - 5732 + - 5733 + - 5734 + - 5735 + - 5736 + - 5737 + - 5738 + - 5739 + - 5740 + - 5741 + - 5742 + - 5743 + - 5744 + - 5745 + - 5746 + - 5747 + - 5748 + - 5749 + - 5750 + - 5751 + - 5752 + - 5753 + - 5754 + - 5755 + - 5756 + - 5757 + - 5758 + - 5759 + - 5760 + - 5761 + - 5762 + - 5763 + - 5764 + - 5765 + - 5766 + - 5767 + - 5768 + - 5769 + - 5770 + - 5771 + - 5772 + - 5773 + - 5774 + - 5775 + - 5776 + - 5777 + - 5778 + - 5779 + - 5780 + - 5781 + - 5782 + - 5783 + - 5784 + - 5785 + - 5786 + - 5787 + - 5788 + - 5789 + - 5790 + - 5791 + - 5792 + - 5793 + - 5794 + - 5795 + - 5796 + - 5797 + - 5798 + - 5799 + - 5800 + - 5801 + - 5802 + - 5803 + - 5804 + - 5805 + - 5806 + - 5807 + - 5808 + - 5809 + - 5810 + - 5811 + - 5812 + - 5813 + - 5814 + - 5815 + - 5816 + - 5817 + - 5818 + - 5819 + - 5820 + - 5821 + - 5822 + - 5823 + - 5824 + - 5825 + - 5826 + - 5827 + - 5828 + - 5829 + - 5830 + - 5831 + - 5832 + - 5833 + - 5834 + - 5835 + - 5836 + - 5837 + - 5838 + - 5839 + - 5840 + - 5841 + - 5842 + - 5843 + - 5844 + - 5845 + - 5846 + - 5847 + - 5848 + - 5849 + - 5850 + - 5851 + - 5852 + - 5853 + - 5854 + - 5855 + - 5856 + - 5857 + - 5858 + - 5859 + - 5860 + - 5861 + - 5862 + - 5863 + - 5864 + - 5865 + - 5866 + - 5867 + - 5868 + - 5869 + - 5870 + - 5871 + - 5872 + - 5873 + - 5874 + - 5875 + - 5876 + - 5877 + - 5878 + - 5879 + - 5880 + - 5881 + - 5882 + - 5883 + - 5884 + - 5885 + - 5886 + - 5887 + - 5888 + - 5889 + - 5890 + - 5891 + - 5892 + - 5893 + - 5894 + - 5895 + - 5896 + - 5897 + - 5898 + - 5899 + - 5900 + - 5901 + - 5902 + - 5903 + - 5904 + - 5905 + - 5906 + - 5907 + - 5908 + - 5909 + - 5910 + - 5911 + - 5912 + - 5913 + - 5914 + - 5915 + - 5916 + - 5917 + - 5918 + - 5919 + - 5920 + - 5921 + - 5922 + - 5923 + - 5924 + - 5925 + - 5926 + - 5927 + - 5928 + - 5929 + - 5930 + - 5931 + - 5932 + - 5933 + - 5934 + - 5935 + - 5936 + - 5937 + - 5938 + - 5939 + - 5940 + - 5941 + - 5942 + - 5943 + - 5944 + - 5945 + - 5946 + - 5947 + - 5948 + - 5949 + - 5950 + - 5951 + - 5952 + - 5953 + - 5954 + - 5955 + - 5956 + - 5957 + - 5958 + - 5959 + - 5960 + - 5961 + - 5962 + - 5963 + - 5964 + - 5965 + - 5966 + - 5967 + - 5968 + - 5969 + - 5970 + - 5971 + - 5972 + - 5973 + - 5974 + - 5975 + - 5976 + - 5977 + - 5978 + - 5979 + - 5980 + - 5981 + - 5982 + - 5983 + - 5984 + - 5985 + - 5986 + - 5987 + - 5988 + - 5989 + - 5990 + - 5991 + - 5992 + - 5993 + - 5994 + - 5995 + - 5996 + - 5997 + - 5998 + - 5999 + - 6000 + - 6001 + - 6002 + - 6003 + - 6004 + - 6005 + - 6006 + - 6007 + - 6008 + - 6009 + - 6010 + - 6011 + - 6012 + - 6013 + - 6014 + - 6015 + - 6016 + - 6017 + - 6018 + - 6019 + - 6020 + - 6021 + - 6022 + - 6023 + - 6024 + - 6025 + - 6026 + - 6027 + - 6028 + - 6029 + - 6030 + - 6031 + - 6032 + - 6033 + - 6034 + - 6035 + - 6036 + - 6037 + - 6038 + - 6039 + - 6040 + - 6041 + - 6042 + - 6043 + - 6044 + - 6045 + - 6046 + - 6047 + - 6048 + - 6049 + - 6050 + - 6051 + - 6052 + - 6053 + - 6054 + - 6055 + - 6056 + - 6057 + - 6058 + - 6059 + - 6060 + - 6061 + - 6062 + - 6063 + - 6064 + - 6065 + - 6066 + - 6067 + - 6068 + - 6069 + - 6070 + - 6071 + - 6072 + - 6073 + - 6074 + - 6075 + - 6076 + - 6077 + - 6078 + - 6079 + - 6080 + - 6081 + - 6082 + - 6083 + - 6084 + - 6085 + - 6086 + - 6087 + - 6088 + - 6089 + - 6090 + - 6091 + - 6092 + - 6093 + - 6094 + - 6095 + - 6096 + - 6097 + - 6098 + - 6099 + - 6100 + - 6101 + - 6102 + - 6103 + - 6104 + - 6105 + - 6106 + - 6107 + - 6108 + - 6109 + - 6110 + - 6111 + - 6112 + - 6113 + - 6114 + - 6115 + - 6116 + - 6117 + - 6118 + - 6119 + - 6120 + - 6121 + - 6122 + - 6123 + - 6124 + - 6125 + - 6126 + - 6127 + - 6128 + - 6129 + - 6130 + - 6131 + - 6132 + - 6133 + - 6134 + - 6135 + - 6136 + - 6137 + - 6138 + - 6139 + - 6140 + - 6141 + - 6142 + - 6143 + - 6144 + - 6145 + - 6146 + - 6147 + - 6148 + - 6149 + - 6150 + - 6151 + - 6152 + - 6153 + - 6154 + - 6155 + - 6156 + - 6157 + - 6158 + - 6159 + - 6160 + - 6161 + - 6162 + - 6163 + - 6164 + - 6165 + - 6166 + - 6167 + - 6168 + - 6169 + - 6170 + - 6171 + - 6172 + - 6173 + - 6174 + - 6175 + - 6176 + - 6177 + - 6178 + - 6179 + - 6180 + - 6181 + - 6182 + - 6183 + - 6184 + - 6185 + - 6186 + - 6187 + - 6188 + - 6189 + - 6190 + - 6191 + - 6192 + - 6193 + - 6194 + - 6195 + - 6196 + - 6197 + - 6198 + - 6199 + - 6200 + - 6201 + - 6202 + - 6203 + - 6204 + - 6205 + - 6206 + - 6207 + - 6208 + - 6209 + - 6210 + - 6211 + - 6212 + - 6213 + - 6214 + - 6215 + - 6216 + - 6217 + - 6218 + - 6219 + - 6220 + - 6221 + - 6222 + - 6223 + - 6224 + - 6225 + - 6226 + - 6227 + - 6228 + - 6229 + - 6230 + - 6231 + - 6232 + - 6233 + - 6234 + - 6235 + - 6236 + - 6237 + - 6238 + - 6239 + - 6240 + - 6241 + - 6242 + - 6243 + - 6244 + - 6245 + - 6246 + - 6247 + - 6248 + - 6249 + - 6250 + - 6251 + - 6252 + - 6253 + - 6254 + - 6255 + - 6256 + - 6257 + - 6258 + - 6259 + - 6260 + - 6261 + - 6262 + - 6263 + - 6264 + - 6265 + - 6266 + - 6267 + - 6268 + - 6269 + - 6270 + - 6271 + - 6272 + - 6273 + - 6274 + - 6275 + - 6276 + - 6277 + - 6278 + - 6279 + - 6280 + - 6281 + - 6282 + - 6283 + - 6284 + - 6285 + - 6286 + - 6287 + - 6288 + - 6289 + - 6290 + - 6291 + - 6292 + - 6293 + - 6294 + - 6295 + - 6296 + - 6297 + - 6298 + - 6299 + - 6300 + - 6301 + - 6302 + - 6303 + - 6304 + - 6305 + - 6306 + - 6307 + - 6308 + - 6309 + - 6310 + - 6311 + - 6312 + - 6313 + - 6314 + - 6315 + - 6316 + - 6317 + - 6318 + - 6319 + - 6320 + - 6321 + - 6322 + - 6323 + - 6324 + - 6325 + - 6326 + - 6327 + - 6328 + - 6329 + - 6330 + - 6331 + - 6332 + - 6333 + - 6334 + - 6335 + - 6336 + - 6337 + - 6338 + - 6339 + - 6340 + - 6341 + - 6342 + - 6343 + - 6344 + - 6345 + - 6346 + - 6347 + - 6348 + - 6349 + - 6350 + - 6351 + - 6352 + - 6353 + - 6354 + - 6355 + - 6356 + - 6357 + - 6358 + - 6359 + - 6360 + - 6361 + - 6362 + - 6363 + - 6364 + - 6365 + - 6366 + - 6367 + - 6368 + - 6369 + - 6370 + - 6371 + - 6372 + - 6373 + - 6374 + - 6375 + - 6376 + - 6377 + - 6378 + - 6379 + - 6380 + - 6381 + - 6382 + - 6383 + - 6384 + - 6385 + - 6386 + - 6387 + - 6388 + - 6389 + - 6390 + - 6391 + - 6392 + - 6393 + - 6394 + - 6395 + - 6396 + - 6397 + - 6398 + - 6399 + - 6400 + - 6401 + - 6402 + - 6403 + - 6404 + - 6405 + - 6406 + - 6407 + - 6408 + - 6409 + - 6410 + - 6411 + - 6412 + - 6413 + - 6414 + - 6415 + - 6416 + - 6417 + - 6418 + - 6419 + - 6420 + - 6421 + - 6422 + - 6423 + - 6424 + - 6425 + - 6426 + - 6427 + - 6428 + - 6429 + - 6430 + - 6431 + - 6432 + - 6433 + - 6434 + - 6435 + - 6436 + - 6437 + - 6438 + - 6439 + - 6440 + - 6441 + - 6442 + - 6443 + - 6444 + - 6445 + - 6446 + - 6447 + - 6448 + - 6449 + - 6450 + - 6451 + - 6452 + - 6453 + - 6454 + - 6455 + - 6456 + - 6457 + - 6458 + - 6459 + - 6460 + - 6461 + - 6462 + - 6463 + - 6464 + - 6465 + - 6466 + - 6467 + - 6468 + - 6469 + - 6470 + - 6471 + - 6472 + - 6473 + - 6474 + - 6475 + - 6476 + - 6477 + - 6478 + - 6479 + - 6480 + - 6481 + - 6482 + - 6483 + - 6484 + - 6485 + - 6486 + - 6487 + - 6488 + - 6489 + - 6490 + - 6491 + - 6492 + - 6493 + - 6494 + - 6495 + - 6496 + - 6497 + - 6498 + - 6499 + - 6500 + - 6501 + - 6502 + - 6503 + - 6504 + - 6505 + - 6506 + - 6507 + - 6508 + - 6509 + - 6510 + - 6511 + - 6512 + - 6513 + - 6514 + - 6515 + - 6516 + - 6517 + - 6518 + - 6519 + - 6520 + - 6521 + - 6522 + - 6523 + - 6524 + - 6525 + - 6526 + - 6527 + - 6528 + - 6529 + - 6530 + - 6531 + - 6532 + - 6533 + - 6534 + - 6535 + - 6536 + - 6537 + - 6538 + - 6539 + - 6540 + - 6541 + - 6542 + - 6543 + - 6544 + - 6545 + - 6546 + - 6547 + - 6548 + - 6549 + - 6550 + - 6551 + - 6552 + - 6553 + - 6554 + - 6555 + - 6556 + - 6557 + - 6558 + - 6559 + - 6560 + - 6561 + - 6562 + - 6563 + - 6564 + - 6565 + - 6566 + - 6567 + - 6568 + - 6569 + - 6570 + - 6571 + - 6572 + - 6573 + - 6574 + - 6575 + - 6576 + - 6577 + - 6578 + - 6579 + - 6580 + - 6581 + - 6582 + - 6583 + - 6584 + - 6585 + - 6586 + - 6587 + - 6588 + - 6589 + - 6590 + - 6591 + - 6592 + - 6593 + - 6594 + - 6595 + - 6596 + - 6597 + - 6598 + - 6599 + - 6600 + - 6601 + - 6602 + - 6603 + - 6604 + - 6605 + - 6606 + - 6607 + - 6608 + - 6609 + - 6610 + - 6611 + - 6612 + - 6613 + - 6614 + - 6615 + - 6616 + - 6617 + - 6618 + - 6619 + - 6620 + - 6621 + - 6622 + - 6623 + - 6624 + - 6625 + - 6626 + - 6627 + - 6628 + - 6629 + - 6630 + - 6631 + - 6632 + - 6633 + - 6634 + - 6635 + - 6636 + - 6637 + - 6638 + - 6639 + - 6640 + - 6641 + - 6642 + - 6643 + - 6644 + - 6645 + - 6646 + - 6647 + - 6648 + - 6649 + - 6650 + - 6651 + - 6652 + - 6653 + - 6654 + - 6655 + - 6656 + - 6657 + - 6658 + - 6659 + - 6660 + - 6661 + - 6662 + - 6663 + - 6664 + - 6665 + - 6666 + - 6667 + - 6668 + - 6669 + - 6670 + - 6671 + - 6672 + - 6673 + - 6674 + - 6675 + - 6676 + - 6677 + - 6678 + - 6679 + - 6680 + - 6681 + - 6682 + - 6683 + - 6684 + - 6685 + - 6686 + - 6687 + - 6688 + - 6689 + - 6690 + - 6691 + - 6692 + - 6693 + - 6694 + - 6695 + - 6696 + - 6697 + - 6698 + - 6699 + - 6700 + - 6701 + - 6702 + - 6703 + - 6704 + - 6705 + - 6706 + - 6707 + - 6708 + - 6709 + - 6710 + - 6711 + - 6712 + - 6713 + - 6714 + - 6715 + - 6716 + - 6717 + - 6718 + - 6719 + - 6720 + - 6721 + - 6722 + - 6723 + - 6724 + - 6725 + - 6726 + - 6727 + - 6728 + - 6729 + - 6730 + - 6731 + - 6732 + - 6733 + - 6734 + - 6735 + - 6736 + - 6737 + - 6738 + - 6739 + - 6740 + - 6741 + - 6742 + - 6743 + - 6744 + - 6745 + - 6746 + - 6747 + - 6748 + - 6749 + - 6750 + - 6751 + - 6752 + - 6753 + - 6754 + - 6755 + - 6756 + - 6757 + - 6758 + - 6759 + - 6760 + - 6761 + - 6762 + - 6763 + - 6764 + - 6765 + - 6766 + - 6767 + - 6768 + - 6769 + - 6770 + - 6771 + - 6772 + - 6773 + - 6774 + - 6775 + - 6776 + - 6777 + - 6778 + - 6779 + - 6780 + - 6781 + - 6782 + - 6783 + - 6784 + - 6785 + - 6786 + - 6787 + - 6788 + - 6789 + - 6790 + - 6791 + - 6792 + - 6793 + - 6794 + - 6795 + - 6796 + - 6797 + - 6798 + - 6799 + - 6800 + - 6801 + - 6802 + - 6803 + - 6804 + - 6805 + - 6806 + - 6807 + - 6808 + - 6809 + - 6810 + - 6811 + - 6812 + - 6813 + - 6814 + - 6815 + - 6816 + - 6817 + - 6818 + - 6819 + - 6820 + - 6821 + - 6822 + - 6823 + - 6824 + - 6825 + - 6826 + - 6827 + - 6828 + - 6829 + - 6830 + - 6831 + - 6832 + - 6833 + - 6834 + - 6835 + - 6836 + - 6837 + - 6838 + - 6839 + - 6840 + - 6841 + - 6842 + - 6843 + - 6844 + - 6845 + - 6846 + - 6847 + - 6848 + - 6849 + - 6850 + - 6851 + - 6852 + - 6853 + - 6854 + - 6855 + - 6856 + - 6857 + - 6858 + - 6859 + - 6860 + - 6861 + - 6862 + - 6863 + - 6864 + - 6865 + - 6866 + - 6867 + - 6868 + - 6869 + - 6870 + - 6871 + - 6872 + - 6873 + - 6874 + - 6875 + - 6876 + - 6877 + - 6878 + - 6879 + - 6880 + - 6881 + - 6882 + - 6883 + - 6884 + - 6885 + - 6886 + - 6887 + - 6888 + - 6889 + - 6890 + - 6891 + - 6892 + - 6893 + - 6894 + - 6895 + - 6896 + - 6897 + - 6898 + - 6899 + - 6900 + - 6901 + - 6902 + - 6903 + - 6904 + - 6905 + - 6906 + - 6907 + - 6908 + - 6909 + - 6910 + - 6911 + - 6912 + - 6913 + - 6914 + - 6915 + - 6916 + - 6917 + - 6918 + - 6919 + - 6920 + - 6921 + - 6922 + - 6923 + - 6924 + - 6925 + - 6926 + - 6927 + - 6928 + - 6929 + - 6930 + - 6931 + - 6932 + - 6933 + - 6934 + - 6935 + - 6936 + - 6937 + - 6938 + - 6939 + - 6940 + - 6941 + - 6942 + - 6943 + - 6944 + - 6945 + - 6946 + - 6947 + - 6948 + - 6949 + - 6950 + - 6951 + - 6952 + - 6953 + - 6954 + - 6955 + - 6956 + - 6957 + - 6958 + - 6959 + - 6960 + - 6961 + - 6962 + - 6963 + - 6964 + - 6965 + - 6966 + - 6967 + - 6968 + - 6969 + - 6970 + - 6971 + - 6972 + - 6973 + - 6974 + - 6975 + - 6976 + - 6977 + - 6978 + - 6979 + - 6980 + - 6981 + - 6982 + - 6983 + - 6984 + - 6985 + - 6986 + - 6987 + - 6988 + - 6989 + - 6990 + - 6991 + - 6992 + - 6993 + - 6994 + - 6995 + - 6996 + - 6997 + - 6998 + - 6999 + - 7000 + - 7001 + - 7002 + - 7003 + - 7004 + - 7005 + - 7006 + - 7007 + - 7008 + - 7009 + - 7010 + - 7011 + - 7012 + - 7013 + - 7014 + - 7015 + - 7016 + - 7017 + - 7018 + - 7019 + - 7020 + - 7021 + - 7022 + - 7023 + - 7024 + - 7025 + - 7026 + - 7027 + - 7028 + - 7029 + - 7030 + - 7031 + - 7032 + - 7033 + - 7034 + - 7035 + - 7036 + - 7037 + - 7038 + - 7039 + - 7040 + - 7041 + - 7042 + - 7043 + - 7044 + - 7045 + - 7046 + - 7047 + - 7048 + - 7049 + - 7050 + - 7051 + - 7052 + - 7053 + - 7054 + - 7055 + - 7056 + - 7057 + - 7058 + - 7059 + - 7060 + - 7061 + - 7062 + - 7063 + - 7064 + - 7065 + - 7066 + - 7067 + - 7068 + - 7069 + - 7070 + - 7071 + - 7072 + - 7073 + - 7074 + - 7075 + - 7076 + - 7077 + - 7078 + - 7079 + - 7080 + - 7081 + - 7082 + - 7083 + - 7084 + - 7085 + - 7086 + - 7087 + - 7088 + - 7089 + - 7090 + - 7091 + - 7092 + - 7093 + - 7094 + - 7095 + - 7096 + - 7097 + - 7098 + - 7099 + - 7100 + - 7101 + - 7102 + - 7103 + - 7104 + - 7105 + - 7106 + - 7107 + - 7108 + - 7109 + - 7110 + - 7111 + - 7112 + - 7113 + - 7114 + - 7115 + - 7116 + - 7117 + - 7118 + - 7119 + - 7120 + - 7121 + - 7122 + - 7123 + - 7124 + - 7125 + - 7126 + - 7127 + - 7128 + - 7129 + - 7130 + - 7131 + - 7132 + - 7133 + - 7134 + - 7135 + - 7136 + - 7137 + - 7138 + - 7139 + - 7140 + - 7141 + - 7142 + - 7143 + - 7144 + - 7145 + - 7146 + - 7147 + - 7148 + - 7149 + - 7150 + - 7151 + - 7152 + - 7153 + - 7154 + - 7155 + - 7156 + - 7157 + - 7158 + - 7159 + - 7160 + - 7161 + - 7162 + - 7163 + - 7164 + - 7165 + - 7166 + - 7167 + - 7168 + - 7169 + - 7170 + - 7171 + - 7172 + - 7173 + - 7174 + - 7175 + - 7176 + - 7177 + - 7178 + - 7179 + - 7180 + - 7181 + - 7182 + - 7183 + - 7184 + - 7185 + - 7186 + - 7187 + - 7188 + - 7189 + - 7190 + - 7191 + - 7192 + - 7193 + - 7194 + - 7195 + - 7196 + - 7197 + - 7198 + - 7199 + - 7200 + - 7201 + - 7202 + - 7203 + - 7204 + - 7205 + - 7206 + - 7207 + - 7208 + - 7209 + - 7210 + - 7211 + - 7212 + - 7213 + - 7214 + - 7215 + - 7216 + - 7217 + - 7218 + - 7219 + - 7220 + - 7221 + - 7222 + - 7223 + - 7224 + - 7225 + - 7226 + - 7227 + - 7228 + - 7229 + - 7230 + - 7231 + - 7232 + - 7233 + - 7234 + - 7235 + - 7236 + - 7237 + - 7238 + - 7239 + - 7240 + - 7241 + - 7242 + - 7243 + - 7244 + - 7245 + - 7246 + - 7247 + - 7248 + - 7249 + - 7250 + - 7251 + - 7252 + - 7253 + - 7254 + - 7255 + - 7256 + - 7257 + - 7258 + - 7259 + - 7260 + - 7261 + - 7262 + - 7263 + - 7264 + - 7265 + - 7266 + - 7267 + - 7268 + - 7269 + - 7270 + - 7271 + - 7272 + - 7273 + - 7274 + - 7275 + - 7276 + - 7277 + - 7278 + - 7279 + - 7280 + - 7281 + - 7282 + - 7283 + - 7284 + - 7285 + - 7286 + - 7287 + - 7288 + - 7289 + - 7290 + - 7291 + - 7292 + - 7293 + - 7294 + - 7295 + - 7296 + - 7297 + - 7298 + - 7299 + - 7300 + - 7301 + - 7302 + - 7303 + - 7304 + - 7305 + - 7306 + - 7307 + - 7308 + - 7309 + - 7310 + - 7311 + - 7312 + - 7313 + - 7314 + - 7315 + - 7316 + - 7317 + - 7318 + - 7319 + - 7320 + - 7321 + - 7322 + - 7323 + - 7324 + - 7325 + - 7326 + - 7327 + - 7328 + - 7329 + - 7330 + - 7331 + - 7332 + - 7333 + - 7334 + - 7335 + - 7336 + - 7337 + - 7338 + - 7339 + - 7340 + - 7341 + - 7342 + - 7343 + - 7344 + - 7345 + - 7346 + - 7347 + - 7348 + - 7349 + - 7350 + - 7351 + - 7352 + - 7353 + - 7354 + - 7355 + - 7356 + - 7357 + - 7358 + - 7359 + - 7360 + - 7361 + - 7362 + - 7363 + - 7364 + - 7365 + - 7366 + - 7367 + - 7368 + - 7369 + - 7370 + - 7371 + - 7372 + - 7373 + - 7374 + - 7375 + - 7376 + - 7377 + - 7378 + - 7379 + - 7380 + - 7381 + - 7382 + - 7383 + - 7384 + - 7385 + - 7386 + - 7387 + - 7388 + - 7389 + - 7390 + - 7391 + - 7392 + - 7393 + - 7394 + - 7395 + - 7396 + - 7397 + - 7398 + - 7399 + - 7400 + - 7401 + - 7402 + - 7403 + - 7404 + - 7405 + - 7406 + - 7407 + - 7408 + - 7409 + - 7410 + - 7411 + - 7412 + - 7413 + - 7414 + - 7415 + - 7416 + - 7417 + - 7418 + - 7419 + - 7420 + - 7421 + - 7422 + - 7423 + - 7424 + - 7425 + - 7426 + - 7427 + - 7428 + - 7429 + - 7430 + - 7431 + - 7432 + - 7433 + - 7434 + - 7435 + - 7436 + - 7437 + - 7438 + - 7439 + - 7440 + - 7441 + - 7442 + - 7443 + - 7444 + - 7445 + - 7446 + - 7447 + - 7448 + - 7449 + - 7450 + - 7451 + - 7452 + - 7453 + - 7454 + - 7455 + - 7456 + - 7457 + - 7458 + - 7459 + - 7460 + - 7461 + - 7462 + - 7463 + - 7464 + - 7465 + - 7466 + - 7467 + - 7468 + - 7469 + - 7470 + - 7471 + - 7472 + - 7473 + - 7474 + - 7475 + - 7476 + - 7477 + - 7478 + - 7479 + - 7480 + - 7481 + - 7482 + - 7483 + - 7484 + - 7485 + - 7486 + - 7487 + - 7488 + - 7489 + - 7490 + - 7491 + - 7492 + - 7493 + - 7494 + - 7495 + - 7496 + - 7497 + - 7498 + - 7499 + - 7500 + - 7501 + - 7502 + - 7503 + - 7504 + - 7505 + - 7506 + - 7507 + - 7508 + - 7509 + - 7510 + - 7511 + - 7512 + - 7513 + - 7514 + - 7515 + - 7516 + - 7517 + - 7518 + - 7519 + - 7520 + - 7521 + - 7522 + - 7523 + - 7524 + - 7525 + - 7526 + - 7527 + - 7528 + - 7529 + - 7530 + - 7531 + - 7532 + - 7533 + - 7534 + - 7535 + - 7536 + - 7537 + - 7538 + - 7539 + - 7540 + - 7541 + - 7542 + - 7543 + - 7544 + - 7545 + - 7546 + - 7547 + - 7548 + - 7549 + - 7550 + - 7551 + - 7552 + - 7553 + - 7554 + - 7555 + - 7556 + - 7557 + - 7558 + - 7559 + - 7560 + - 7561 + - 7562 + - 7563 + - 7564 + - 7565 + - 7566 + - 7567 + - 7568 + - 7569 + - 7570 + - 7571 + - 7572 + - 7573 + - 7574 + - 7575 + - 7576 + - 7577 + - 7578 + - 7579 + - 7580 + - 7581 + - 7582 + - 7583 + - 7584 + - 7585 + - 7586 + - 7587 + - 7588 + - 7589 + - 7590 + - 7591 + - 7592 + - 7593 + - 7594 + - 7595 + - 7596 + - 7597 + - 7598 + - 7599 + - 7600 + - 7601 + - 7602 + - 7603 + - 7604 + - 7605 + - 7606 + - 7607 + - 7608 + - 7609 + - 7610 + - 7611 + - 7612 + - 7613 + - 7614 + - 7615 + - 7616 + - 7617 + - 7618 + - 7619 + - 7620 + - 7621 + - 7622 + - 7623 + - 7624 + - 7625 + - 7626 + - 7627 + - 7628 + - 7629 + - 7630 + - 7631 + - 7632 + - 7633 + - 7634 + - 7635 + - 7636 + - 7637 + - 7638 + - 7639 + - 7640 + - 7641 + - 7642 + - 7643 + - 7644 + - 7645 + - 7646 + - 7647 + - 7648 + - 7649 + - 7650 + - 7651 + - 7652 + - 7653 + - 7654 + - 7655 + - 7656 + - 7657 + - 7658 + - 7659 + - 7660 + - 7661 + - 7662 + - 7663 + - 7664 + - 7665 + - 7666 + - 7667 + - 7668 + - 7669 + - 7670 + - 7671 + - 7672 + - 7673 + - 7674 + - 7675 + - 7676 + - 7677 + - 7678 + - 7679 + - 7680 + - 7681 + - 7682 + - 7683 + - 7684 + - 7685 + - 7686 + - 7687 + - 7688 + - 7689 + - 7690 + - 7691 + - 7692 + - 7693 + - 7694 + - 7695 + - 7696 + - 7697 + - 7698 + - 7699 + - 7700 + - 7701 + - 7702 + - 7703 + - 7704 + - 7705 + - 7706 + - 7707 + - 7708 + - 7709 + - 7710 + - 7711 + - 7712 + - 7713 + - 7714 + - 7715 + - 7716 + - 7717 + - 7718 + - 7719 + - 7720 + - 7721 + - 7722 + - 7723 + - 7724 + - 7725 + - 7726 + - 7727 + - 7728 + - 7729 + - 7730 + - 7731 + - 7732 + - 7733 + - 7734 + - 7735 + - 7736 + - 7737 + - 7738 + - 7739 + - 7740 + - 7741 + - 7742 + - 7743 + - 7744 + - 7745 + - 7746 + - 7747 + - 7748 + - 7749 + - 7750 + - 7751 + - 7752 + - 7753 + - 7754 + - 7755 + - 7756 + - 7757 + - 7758 + - 7759 + - 7760 + - 7761 + - 7762 + - 7763 + - 7764 + - 7765 + - 7766 + - 7767 + - 7768 + - 7769 + - 7770 + - 7771 + - 7772 + - 7773 + - 7774 + - 7775 + - 7776 + - 7777 + - 7778 + - 7779 + - 7780 + - 7781 + - 7782 + - 7783 + - 7784 + - 7785 + - 7786 + - 7787 + - 7788 + - 7789 + - 7790 + - 7791 + - 7792 + - 7793 + - 7794 + - 7795 + - 7796 + - 7797 + - 7798 + - 7799 + - 7800 + - 7801 + - 7802 + - 7803 + - 7804 + - 7805 + - 7806 + - 7807 + - 7808 + - 7809 + - 7810 + - 7811 + - 7812 + - 7813 + - 7814 + - 7815 + - 7816 + - 7817 + - 7818 + - 7819 + - 7820 + - 7821 + - 7822 + - 7823 + - 7824 + - 7825 + - 7826 + - 7827 + - 7828 + - 7829 + - 7830 + - 7831 + - 7832 + - 7833 + - 7834 + - 7835 + - 7836 + - 7837 + - 7838 + - 7839 + - 7840 + - 7841 + - 7842 + - 7843 + - 7844 + - 7845 + - 7846 + - 7847 + - 7848 + - 7849 + - 7850 + - 7851 + - 7852 + - 7853 + - 7854 + - 7855 + - 7856 + - 7857 + - 7858 + - 7859 + - 7860 + - 7861 + - 7862 + - 7863 + - 7864 + - 7865 + - 7866 + - 7867 + - 7868 + - 7869 + - 7870 + - 7871 + - 7872 + - 7873 + - 7874 + - 7875 + - 7876 + - 7877 + - 7878 + - 7879 + - 7880 + - 7881 + - 7882 + - 7883 + - 7884 + - 7885 + - 7886 + - 7887 + - 7888 + - 7889 + - 7890 + - 7891 + - 7892 + - 7893 + - 7894 + - 7895 + - 7896 + - 7897 + - 7898 + - 7899 + - 7900 + - 7901 + - 7902 + - 7903 + - 7904 + - 7905 + - 7906 + - 7907 + - 7908 + - 7909 + - 7910 + - 7911 + - 7912 + - 7913 + - 7914 + - 7915 + - 7916 + - 7917 + - 7918 + - 7919 + - 7920 + - 7921 + - 7922 + - 7923 + - 7924 + - 7925 + - 7926 + - 7927 + - 7928 + - 7929 + - 7930 + - 7931 + - 7932 + - 7933 + - 7934 + - 7935 + - 7936 + - 7937 + - 7938 + - 7939 + - 7940 + - 7941 + - 7942 + - 7943 + - 7944 + - 7945 + - 7946 + - 7947 + - 7948 + - 7949 + - 7950 + - 7951 + - 7952 + - 7953 + - 7954 + - 7955 + - 7956 + - 7957 + - 7958 + - 7959 + - 7960 + - 7961 + - 7962 + - 7963 + - 7964 + - 7965 + - 7966 + - 7967 + - 7968 + - 7969 + - 7970 + - 7971 + - 7972 + - 7973 + - 7974 + - 7975 + - 7976 + - 7977 + - 7978 + - 7979 + - 7980 + - 7981 + - 7982 + - 7983 + - 7984 + - 7985 + - 7986 + - 7987 + - 7988 + - 7989 + - 7990 + - 7991 + - 7992 + - 7993 + - 7994 + - 7995 + - 7996 + - 7997 + - 7998 + - 7999 + - 8000 + - 8001 + - 8002 + - 8003 + - 8004 + - 8005 + - 8006 + - 8007 + - 8008 + - 8009 + - 8010 + - 8011 + - 8012 + - 8013 + - 8014 + - 8015 + - 8016 + - 8017 + - 8018 + - 8019 + - 8020 + - 8021 + - 8022 + - 8023 + - 8024 + - 8025 + - 8026 + - 8027 + - 8028 + - 8029 + - 8030 + - 8031 + - 8032 + - 8033 + - 8034 + - 8035 + - 8036 + - 8037 + - 8038 + - 8039 + - 8040 + - 8041 + - 8042 + - 8043 + - 8044 + - 8045 + - 8046 + - 8047 + - 8048 + - 8049 + - 8050 + - 8051 + - 8052 + - 8053 + - 8054 + - 8055 + - 8056 + - 8057 + - 8058 + - 8059 + - 8060 + - 8061 + - 8062 + - 8063 + - 8064 + - 8065 + - 8066 + - 8067 + - 8068 + - 8069 + - 8070 + - 8071 + - 8072 + - 8073 + - 8074 + - 8075 + - 8076 + - 8077 + - 8078 + - 8079 + - 8080 + - 8081 + - 8082 + - 8083 + - 8084 + - 8085 + - 8086 + - 8087 + - 8088 + - 8089 + - 8090 + - 8091 + - 8092 + - 8093 + - 8094 + - 8095 + - 8096 + - 8097 + - 8098 + - 8099 + - 8100 + - 8101 + - 8102 + - 8103 + - 8104 + - 8105 + - 8106 + - 8107 + - 8108 + - 8109 + - 8110 + - 8111 + - 8112 + - 8113 + - 8114 + - 8115 + - 8116 + - 8117 + - 8118 + - 8119 + - 8120 + - 8121 + - 8122 + - 8123 + - 8124 + - 8125 + - 8126 + - 8127 + - 8128 + - 8129 + - 8130 + - 8131 + - 8132 + - 8133 + - 8134 + - 8135 + - 8136 + - 8137 + - 8138 + - 8139 + - 8140 + - 8141 + - 8142 + - 8143 + - 8144 + - 8145 + - 8146 + - 8147 + - 8148 + - 8149 + - 8150 + - 8151 + - 8152 + - 8153 + - 8154 + - 8155 + - 8156 + - 8157 + - 8158 + - 8159 + - 8160 + - 8161 + - 8162 + - 8163 + - 8164 + - 8165 + - 8166 + - 8167 + - 8168 + - 8169 + - 8170 + - 8171 + - 8172 + - 8173 + - 8174 + - 8175 + - 8176 + - 8177 + - 8178 + - 8179 + - 8180 + - 8181 + - 8182 + - 8183 + - 8184 + - 8185 + - 8186 + - 8187 + - 8188 + - 8189 + - 8190 + - 8191 + - 8192 + - 8193 + - 8194 + - 8195 + - 8196 + - 8197 + - 8198 + - 8199 + - 8200 + - 8201 + - 8202 + - 8203 + - 8204 + - 8205 + - 8206 + - 8207 + - 8208 + - 8209 + - 8210 + - 8211 + - 8212 + - 8213 + - 8214 + - 8215 + - 8216 + - 8217 + - 8218 + - 8219 + - 8220 + - 8221 + - 8222 + - 8223 + - 8224 + - 8225 + - 8226 + - 8227 + - 8228 + - 8229 + - 8230 + - 8231 + - 8232 + - 8233 + - 8234 + - 8235 + - 8236 + - 8237 + - 8238 + - 8239 + - 8240 + - 8241 + - 8242 + - 8243 + - 8244 + - 8245 + - 8246 + - 8247 + - 8248 + - 8249 + - 8250 + - 8251 + - 8252 + - 8253 + - 8254 + - 8255 + - 8256 + - 8257 + - 8258 + - 8259 + - 8260 + - 8261 + - 8262 + - 8263 + - 8264 + - 8265 + - 8266 + - 8267 + - 8268 + - 8269 + - 8270 + - 8271 + - 8272 + - 8273 + - 8274 + - 8275 + - 8276 + - 8277 + - 8278 + - 8279 + - 8280 + - 8281 + - 8282 + - 8283 + - 8284 + - 8285 + - 8286 + - 8287 + - 8288 + - 8289 + - 8290 + - 8291 + - 8292 + - 8293 + - 8294 + - 8295 + - 8296 + - 8297 + - 8298 + - 8299 + - 8300 + - 8301 + - 8302 + - 8303 + - 8304 + - 8305 + - 8306 + - 8307 + - 8308 + - 8309 + - 8310 + - 8311 + - 8312 + - 8313 + - 8314 + - 8315 + - 8316 + - 8317 + - 8318 + - 8319 + - 8320 + - 8321 + - 8322 + - 8323 + - 8324 + - 8325 + - 8326 + - 8327 + - 8328 + - 8329 + - 8330 + - 8331 + - 8332 + - 8333 + - 8334 + - 8335 + - 8336 + - 8337 + - 8338 + - 8339 + - 8340 + - 8341 + - 8342 + - 8343 + - 8344 + - 8345 + - 8346 + - 8347 + - 8348 + - 8349 + - 8350 + - 8351 + - 8352 + - 8353 + - 8354 + - 8355 + - 8356 + - 8357 + - 8358 + - 8359 + - 8360 + - 8361 + - 8362 + - 8363 + - 8364 + - 8365 + - 8366 + - 8367 + - 8368 + - 8369 + - 8370 + - 8371 + - 8372 + - 8373 + - 8374 + - 8375 + - 8376 + - 8377 + - 8378 + - 8379 + - 8380 + - 8381 + - 8382 + - 8383 + - 8384 + - 8385 + - 8386 + - 8387 + - 8388 + - 8389 + - 8390 + - 8391 + - 8392 + - 8393 + - 8394 + - 8395 + - 8396 + - 8397 + - 8398 + - 8399 + - 8400 + - 8401 + - 8402 + - 8403 + - 8404 + - 8405 + - 8406 + - 8407 + - 8408 + - 8409 + - 8410 + - 8411 + - 8412 + - 8413 + - 8414 + - 8415 + - 8416 + - 8417 + - 8418 + - 8419 + - 8420 + - 8421 + - 8422 + - 8423 + - 8424 + - 8425 + - 8426 + - 8427 + - 8428 + - 8429 + - 8430 + - 8431 + - 8432 + - 8433 + - 8434 + - 8435 + - 8436 + - 8437 + - 8438 + - 8439 + - 8440 + - 8441 + - 8442 + - 8443 + - 8444 + - 8445 + - 8446 + - 8447 + - 8448 + - 8449 + - 8450 + - 8451 + - 8452 + - 8453 + - 8454 + - 8455 + - 8456 + - 8457 + - 8458 + - 8459 + - 8460 + - 8461 + - 8462 + - 8463 + - 8464 + - 8465 + - 8466 + - 8467 + - 8468 + - 8469 + - 8470 + - 8471 + - 8472 + - 8473 + - 8474 + - 8475 + - 8476 + - 8477 + - 8478 + - 8479 + - 8480 + - 8481 + - 8482 + - 8483 + - 8484 + - 8485 + - 8486 + - 8487 + - 8488 + - 8489 + - 8490 + - 8491 + - 8492 + - 8493 + - 8494 + - 8495 + - 8496 + - 8497 + - 8498 + - 8499 + - 8500 + - 8501 + - 8502 + - 8503 + - 8504 + - 8505 + - 8506 + - 8507 + - 8508 + - 8509 + - 8510 + - 8511 + - 8512 + - 8513 + - 8514 + - 8515 + - 8516 + - 8517 + - 8518 + - 8519 + - 8520 + - 8521 + - 8522 + - 8523 + - 8524 + - 8525 + - 8526 + - 8527 + - 8528 + - 8529 + - 8530 + - 8531 + - 8532 + - 8533 + - 8534 + - 8535 + - 8536 + - 8537 + - 8538 + - 8539 + - 8540 + - 8541 + - 8542 + - 8543 + - 8544 + - 8545 + - 8546 + - 8547 + - 8548 + - 8549 + - 8550 + - 8551 + - 8552 + - 8553 + - 8554 + - 8555 + - 8556 + - 8557 + - 8558 + - 8559 + - 8560 + - 8561 + - 8562 + - 8563 + - 8564 + - 8565 + - 8566 + - 8567 + - 8568 + - 8569 + - 8570 + - 8571 + - 8572 + - 8573 + - 8574 + - 8575 + - 8576 + - 8577 + - 8578 + - 8579 + - 8580 + - 8581 + - 8582 + - 8583 + - 8584 + - 8585 + - 8586 + - 8587 + - 8588 + - 8589 + - 8590 + - 8591 + - 8592 + - 8593 + - 8594 + - 8595 + - 8596 + - 8597 + - 8598 + - 8599 + - 8600 + - 8601 + - 8602 + - 8603 + - 8604 + - 8605 + - 8606 + - 8607 + - 8608 + - 8609 + - 8610 + - 8611 + - 8612 + - 8613 + - 8614 + - 8615 + - 8616 + - 8617 + - 8618 + - 8619 + - 8620 + - 8621 + - 8622 + - 8623 + - 8624 + - 8625 + - 8626 + - 8627 + - 8628 + - 8629 + - 8630 + - 8631 + - 8632 + - 8633 + - 8634 + - 8635 + - 8636 + - 8637 + - 8638 + - 8639 + - 8640 + - 8641 + - 8642 + - 8643 + - 8644 + - 8645 + - 8646 + - 8647 + - 8648 + - 8649 + - 8650 + - 8651 + - 8652 + - 8653 + - 8654 + - 8655 + - 8656 + - 8657 + - 8658 + - 8659 + - 8660 + - 8661 + - 8662 + - 8663 + - 8664 + - 8665 + - 8666 + - 8667 + - 8668 + - 8669 + - 8670 + - 8671 + - 8672 + - 8673 + - 8674 + - 8675 + - 8676 + - 8677 + - 8678 + - 8679 + - 8680 + - 8681 + - 8682 + - 8683 + - 8684 + - 8685 + - 8686 + - 8687 + - 8688 + - 8689 + - 8690 + - 8691 + - 8692 + - 8693 + - 8694 + - 8695 + - 8696 + - 8697 + - 8698 + - 8699 + - 8700 + - 8701 + - 8702 + - 8703 + - 8704 + - 8705 + - 8706 + - 8707 + - 8708 + - 8709 + - 8710 + - 8711 + - 8712 + - 8713 + - 8714 + - 8715 + - 8716 + - 8717 + - 8718 + - 8719 + - 8720 + - 8721 + - 8722 + - 8723 + - 8724 + - 8725 + - 8726 + - 8727 + - 8728 + - 8729 + - 8730 + - 8731 + - 8732 + - 8733 + - 8734 + - 8735 + - 8736 + - 8737 + - 8738 + - 8739 + - 8740 + - 8741 + - 8742 + - 8743 + - 8744 + - 8745 + - 8746 + - 8747 + - 8748 + - 8749 + - 8750 + - 8751 + - 8752 + - 8753 + - 8754 + - 8755 + - 8756 + - 8757 + - 8758 + - 8759 + - 8760 + - 8761 + - 8762 + - 8763 + - 8764 + - 8765 + - 8766 + - 8767 + - 8768 + - 8769 + - 8770 + - 8771 + - 8772 + - 8773 + - 8774 + - 8775 + - 8776 + - 8777 + - 8778 + - 8779 + - 8780 + - 8781 + - 8782 + - 8783 + - 8784 + - 8785 + - 8786 + - 8787 + - 8788 + - 8789 + - 8790 + - 8791 + - 8792 + - 8793 + - 8794 + - 8795 + - 8796 + - 8797 + - 8798 + - 8799 + - 8800 + - 8801 + - 8802 + - 8803 + - 8804 + - 8805 + - 8806 + - 8807 + - 8808 + - 8809 + - 8810 + - 8811 + - 8812 + - 8813 + - 8814 + - 8815 + - 8816 + - 8817 + - 8818 + - 8819 + - 8820 + - 8821 + - 8822 + - 8823 + - 8824 + - 8825 + - 8826 + - 8827 + - 8828 + - 8829 + - 8830 + - 8831 + - 8832 + - 8833 + - 8834 + - 8835 + - 8836 + - 8837 + - 8838 + - 8839 + - 8840 + - 8841 + - 8842 + - 8843 + - 8844 + - 8845 + - 8846 + - 8847 + - 8848 + - 8849 + - 8850 + - 8851 + - 8852 + - 8853 + - 8854 + - 8855 + - 8856 + - 8857 + - 8858 + - 8859 + - 8860 + - 8861 + - 8862 + - 8863 + - 8864 + - 8865 + - 8866 + - 8867 + - 8868 + - 8869 + - 8870 + - 8871 + - 8872 + - 8873 + - 8874 + - 8875 + - 8876 + - 8877 + - 8878 + - 8879 + - 8880 + - 8881 + - 8882 + - 8883 + - 8884 + - 8885 + - 8886 + - 8887 + - 8888 + - 8889 + - 8890 + - 8891 + - 8892 + - 8893 + - 8894 + - 8895 + - 8896 + - 8897 + - 8898 + - 8899 + - 8900 + - 8901 + - 8902 + - 8903 + - 8904 + - 8905 + - 8906 + - 8907 + - 8908 + - 8909 + - 8910 + - 8911 + - 8912 + - 8913 + - 8914 + - 8915 + - 8916 + - 8917 + - 8918 + - 8919 + - 8920 + - 8921 + - 8922 + - 8923 + - 8924 + - 8925 + - 8926 + - 8927 + - 8928 + - 8929 + - 8930 + - 8931 + - 8932 + - 8933 + - 8934 + - 8935 + - 8936 + - 8937 + - 8938 + - 8939 + - 8940 + - 8941 + - 8942 + - 8943 + - 8944 + - 8945 + - 8946 + - 8947 + - 8948 + - 8949 + - 8950 + - 8951 + - 8952 + - 8953 + - 8954 + - 8955 + - 8956 + - 8957 + - 8958 + - 8959 + - 8960 + - 8961 + - 8962 + - 8963 + - 8964 + - 8965 + - 8966 + - 8967 + - 8968 + - 8969 + - 8970 + - 8971 + - 8972 + - 8973 + - 8974 + - 8975 + - 8976 + - 8977 + - 8978 + - 8979 + - 8980 + - 8981 + - 8982 + - 8983 + - 8984 + - 8985 + - 8986 + - 8987 + - 8988 + - 8989 + - 8990 + - 8991 + - 8992 + - 8993 + - 8994 + - 8995 + - 8996 + - 8997 + - 8998 + - 8999 + - 9000 + - 9001 + - 9002 + - 9003 + - 9004 + - 9005 + - 9006 + - 9007 + - 9008 + - 9009 + - 9010 + - 9011 + - 9012 + - 9013 + - 9014 + - 9015 + - 9016 + - 9017 + - 9018 + - 9019 + - 9020 + - 9021 + - 9022 + - 9023 + - 9024 + - 9025 + - 9026 + - 9027 + - 9028 + - 9029 + - 9030 + - 9031 + - 9032 + - 9033 + - 9034 + - 9035 + - 9036 + - 9037 + - 9038 + - 9039 + - 9040 + - 9041 + - 9042 + - 9043 + - 9044 + - 9045 + - 9046 + - 9047 + - 9048 + - 9049 + - 9050 + - 9051 + - 9052 + - 9053 + - 9054 + - 9055 + - 9056 + - 9057 + - 9058 + - 9059 + - 9060 + - 9061 + - 9062 + - 9063 + - 9064 + - 9065 + - 9066 + - 9067 + - 9068 + - 9069 + - 9070 + - 9071 + - 9072 + - 9073 + - 9074 + - 9075 + - 9076 + - 9077 + - 9078 + - 9079 + - 9080 + - 9081 + - 9082 + - 9083 + - 9084 + - 9085 + - 9086 + - 9087 + - 9088 + - 9089 + - 9090 + - 9091 + - 9092 + - 9093 + - 9094 + - 9095 + - 9096 + - 9097 + - 9098 + - 9099 + - 9100 + - 9101 + - 9102 + - 9103 + - 9104 + - 9105 + - 9106 + - 9107 + - 9108 + - 9109 + - 9110 + - 9111 + - 9112 + - 9113 + - 9114 + - 9115 + - 9116 + - 9117 + - 9118 + - 9119 + - 9120 + - 9121 + - 9122 + - 9123 + - 9124 + - 9125 + - 9126 + - 9127 + - 9128 + - 9129 + - 9130 + - 9131 + - 9132 + - 9133 + - 9134 + - 9135 + - 9136 + - 9137 + - 9138 + - 9139 + - 9140 + - 9141 + - 9142 + - 9143 + - 9144 + - 9145 + - 9146 + - 9147 + - 9148 + - 9149 + - 9150 + - 9151 + - 9152 + - 9153 + - 9154 + - 9155 + - 9156 + - 9157 + - 9158 + - 9159 + - 9160 + - 9161 + - 9162 + - 9163 + - 9164 + - 9165 + - 9166 + - 9167 + - 9168 + - 9169 + - 9170 + - 9171 + - 9172 + - 9173 + - 9174 + - 9175 + - 9176 + - 9177 + - 9178 + - 9179 + - 9180 + - 9181 + - 9182 + - 9183 + - 9184 + - 9185 + - 9186 + - 9187 + - 9188 + - 9189 + - 9190 + - 9191 + - 9192 + - 9193 + - 9194 + - 9195 + - 9196 + - 9197 + - 9198 + - 9199 + - 9200 + - 9201 + - 9202 + - 9203 + - 9204 + - 9205 + - 9206 + - 9207 + - 9208 + - 9209 + - 9210 + - 9211 + - 9212 + - 9213 + - 9214 + - 9215 + - 9216 + - 9217 + - 9218 + - 9219 + - 9220 + - 9221 + - 9222 + - 9223 + - 9224 + - 9225 + - 9226 + - 9227 + - 9228 + - 9229 + - 9230 + - 9231 + - 9232 + - 9233 + - 9234 + - 9235 + - 9236 + - 9237 + - 9238 + - 9239 + - 9240 + - 9241 + - 9242 + - 9243 + - 9244 + - 9245 + - 9246 + - 9247 + - 9248 + - 9249 + - 9250 + - 9251 + - 9252 + - 9253 + - 9254 + - 9255 + - 9256 + - 9257 + - 9258 + - 9259 + - 9260 + - 9261 + - 9262 + - 9263 + - 9264 + - 9265 + - 9266 + - 9267 + - 9268 + - 9269 + - 9270 + - 9271 + - 9272 + - 9273 + - 9274 + - 9275 + - 9276 + - 9277 + - 9278 + - 9279 + - 9280 + - 9281 + - 9282 + - 9283 + - 9284 + - 9285 + - 9286 + - 9287 + - 9288 + - 9289 + - 9290 + - 9291 + - 9292 + - 9293 + - 9294 + - 9295 + - 9296 + - 9297 + - 9298 + - 9299 + - 9300 + - 9301 + - 9302 + - 9303 + - 9304 + - 9305 + - 9306 + - 9307 + - 9308 + - 9309 + - 9310 + - 9311 + - 9312 + - 9313 + - 9314 + - 9315 + - 9316 + - 9317 + - 9318 + - 9319 + - 9320 + - 9321 + - 9322 + - 9323 + - 9324 + - 9325 + - 9326 + - 9327 + - 9328 + - 9329 + - 9330 + - 9331 + - 9332 + - 9333 + - 9334 + - 9335 + - 9336 + - 9337 + - 9338 + - 9339 + - 9340 + - 9341 + - 9342 + - 9343 + - 9344 + - 9345 + - 9346 + - 9347 + - 9348 + - 9349 + - 9350 + - 9351 + - 9352 + - 9353 + - 9354 + - 9355 + - 9356 + - 9357 + - 9358 + - 9359 + - 9360 + - 9361 + - 9362 + - 9363 + - 9364 + - 9365 + - 9366 + - 9367 + - 9368 + - 9369 + - 9370 + - 9371 + - 9372 + - 9373 + - 9374 + - 9375 + - 9376 + - 9377 + - 9378 + - 9379 + - 9380 + - 9381 + - 9382 + - 9383 + - 9384 + - 9385 + - 9386 + - 9387 + - 9388 + - 9389 + - 9390 + - 9391 + - 9392 + - 9393 + - 9394 + - 9395 + - 9396 + - 9397 + - 9398 + - 9399 + - 9400 + - 9401 + - 9402 + - 9403 + - 9404 + - 9405 + - 9406 + - 9407 + - 9408 + - 9409 + - 9410 + - 9411 + - 9412 + - 9413 + - 9414 + - 9415 + - 9416 + - 9417 + - 9418 + - 9419 + - 9420 + - 9421 + - 9422 + - 9423 + - 9424 + - 9425 + - 9426 + - 9427 + - 9428 + - 9429 + - 9430 + - 9431 + - 9432 + - 9433 + - 9434 + - 9435 + - 9436 + - 9437 + - 9438 + - 9439 + - 9440 + - 9441 + - 9442 + - 9443 + - 9444 + - 9445 + - 9446 + - 9447 + - 9448 + - 9449 + - 9450 + - 9451 + - 9452 + - 9453 + - 9454 + - 9455 + - 9456 + - 9457 + - 9458 + - 9459 + - 9460 + - 9461 + - 9462 + - 9463 + - 9464 + - 9465 + - 9466 + - 9467 + - 9468 + - 9469 + - 9470 + - 9471 + - 9472 + - 9473 + - 9474 + - 9475 + - 9476 + - 9477 + - 9478 + - 9479 + - 9480 + - 9481 + - 9482 + - 9483 + - 9484 + - 9485 + - 9486 + - 9487 + - 9488 + - 9489 + - 9490 + - 9491 + - 9492 + - 9493 + - 9494 + - 9495 + - 9496 + - 9497 + - 9498 + - 9499 + - 9500 + - 9501 + - 9502 + - 9503 + - 9504 + - 9505 + - 9506 + - 9507 + - 9508 + - 9509 + - 9510 + - 9511 + - 9512 + - 9513 + - 9514 + - 9515 + - 9516 + - 9517 + - 9518 + - 9519 + - 9520 + - 9521 + - 9522 + - 9523 + - 9524 + - 9525 + - 9526 + - 9527 + - 9528 + - 9529 + - 9530 + - 9531 + - 9532 + - 9533 + - 9534 + - 9535 + - 9536 + - 9537 + - 9538 + - 9539 + - 9540 + - 9541 + - 9542 + - 9543 + - 9544 + - 9545 + - 9546 + - 9547 + - 9548 + - 9549 + - 9550 + - 9551 + - 9552 + - 9553 + - 9554 + - 9555 + - 9556 + - 9557 + - 9558 + - 9559 + - 9560 + - 9561 + - 9562 + - 9563 + - 9564 + - 9565 + - 9566 + - 9567 + - 9568 + - 9569 + - 9570 + - 9571 + - 9572 + - 9573 + - 9574 + - 9575 + - 9576 + - 9577 + - 9578 + - 9579 + - 9580 + - 9581 + - 9582 + - 9583 + - 9584 + - 9585 + - 9586 + - 9587 + - 9588 + - 9589 + - 9590 + - 9591 + - 9592 + - 9593 + - 9594 + - 9595 + - 9596 + - 9597 + - 9598 + - 9599 + - 9600 + - 9601 + - 9602 + - 9603 + - 9604 + - 9605 + - 9606 + - 9607 + - 9608 + - 9609 + - 9610 + - 9611 + - 9612 + - 9613 + - 9614 + - 9615 + - 9616 + - 9617 + - 9618 + - 9619 + - 9620 + - 9621 + - 9622 + - 9623 + - 9624 + - 9625 + - 9626 + - 9627 + - 9628 + - 9629 + - 9630 + - 9631 + - 9632 + - 9633 + - 9634 + - 9635 + - 9636 + - 9637 + - 9638 + - 9639 + - 9640 + - 9641 + - 9642 + - 9643 + - 9644 + - 9645 + - 9646 + - 9647 + - 9648 + - 9649 + - 9650 + - 9651 + - 9652 + - 9653 + - 9654 + - 9655 + - 9656 + - 9657 + - 9658 + - 9659 + - 9660 + - 9661 + - 9662 + - 9663 + - 9664 + - 9665 + - 9666 + - 9667 + - 9668 + - 9669 + - 9670 + - 9671 + - 9672 + - 9673 + - 9674 + - 9675 + - 9676 + - 9677 + - 9678 + - 9679 + - 9680 + - 9681 + - 9682 + - 9683 + - 9684 + - 9685 + - 9686 + - 9687 + - 9688 + - 9689 + - 9690 + - 9691 + - 9692 + - 9693 + - 9694 + - 9695 + - 9696 + - 9697 + - 9698 + - 9699 + - 9700 + - 9701 + - 9702 + - 9703 + - 9704 + - 9705 + - 9706 + - 9707 + - 9708 + - 9709 + - 9710 + - 9711 + - 9712 + - 9713 + - 9714 + - 9715 + - 9716 + - 9717 + - 9718 + - 9719 + - 9720 + - 9721 + - 9722 + - 9723 + - 9724 + - 9725 + - 9726 + - 9727 + - 9728 + - 9729 + - 9730 + - 9731 + - 9732 + - 9733 + - 9734 + - 9735 + - 9736 + - 9737 + - 9738 + - 9739 + - 9740 + - 9741 + - 9742 + - 9743 + - 9744 + - 9745 + - 9746 + - 9747 + - 9748 + - 9749 + - 9750 + - 9751 + - 9752 + - 9753 + - 9754 + - 9755 + - 9756 + - 9757 + - 9758 + - 9759 + - 9760 + - 9761 + - 9762 + - 9763 + - 9764 + - 9765 + - 9766 + - 9767 + - 9768 + - 9769 + - 9770 + - 9771 + - 9772 + - 9773 + - 9774 + - 9775 + - 9776 + - 9777 + - 9778 + - 9779 + - 9780 + - 9781 + - 9782 + - 9783 + - 9784 + - 9785 + - 9786 + - 9787 + - 9788 + - 9789 + - 9790 + - 9791 + - 9792 + - 9793 + - 9794 + - 9795 + - 9796 + - 9797 + - 9798 + - 9799 + - 9800 + - 9801 + - 9802 + - 9803 + - 9804 + - 9805 + - 9806 + - 9807 + - 9808 + - 9809 + - 9810 + - 9811 + - 9812 + - 9813 + - 9814 + - 9815 + - 9816 + - 9817 + - 9818 + - 9819 + - 9820 + - 9821 + - 9822 + - 9823 + - 9824 + - 9825 + - 9826 + - 9827 + - 9828 + - 9829 + - 9830 + - 9831 + - 9832 + - 9833 + - 9834 + - 9835 + - 9836 + - 9837 + - 9838 + - 9839 + - 9840 + - 9841 + - 9842 + - 9843 + - 9844 + - 9845 + - 9846 + - 9847 + - 9848 + - 9849 + - 9850 + - 9851 + - 9852 + - 9853 + - 9854 + - 9855 + - 9856 + - 9857 + - 9858 + - 9859 + - 9860 + - 9861 + - 9862 + - 9863 + - 9864 + - 9865 + - 9866 + - 9867 + - 9868 + - 9869 + - 9870 + - 9871 + - 9872 + - 9873 + - 9874 + - 9875 + - 9876 + - 9877 + - 9878 + - 9879 + - 9880 + - 9881 + - 9882 + - 9883 + - 9884 + - 9885 + - 9886 + - 9887 + - 9888 + - 9889 + - 9890 + - 9891 + - 9892 + - 9893 + - 9894 + - 9895 + - 9896 + - 9897 + - 9898 + - 9899 + - 9900 + - 9901 + - 9902 + - 9903 + - 9904 + - 9905 + - 9906 + - 9907 + - 9908 + - 9909 + - 9910 + - 9911 + - 9912 + - 9913 + - 9914 + - 9915 + - 9916 + - 9917 + - 9918 + - 9919 + - 9920 + - 9921 + - 9922 + - 9923 + - 9924 + - 9925 + - 9926 + - 9927 + - 9928 + - 9929 + - 9930 + - 9931 + - 9932 + - 9933 + - 9934 + - 9935 + - 9936 + - 9937 + - 9938 + - 9939 + - 9940 + - 9941 + - 9942 + - 9943 + - 9944 + - 9945 + - 9946 + - 9947 + - 9948 + - 9949 + - 9950 + - 9951 + - 9952 + - 9953 + - 9954 + - 9955 + - 9956 + - 9957 + - 9958 + - 9959 + - 9960 + - 9961 + - 9962 + - 9963 + - 9964 + - 9965 + - 9966 + - 9967 + - 9968 + - 9969 + - 9970 + - 9971 + - 9972 + - 9973 + - 9974 + - 9975 + - 9976 + - 9977 + - 9978 + - 9979 + - 9980 + - 9981 + - 9982 + - 9983 + - 9984 + - 9985 + - 9986 + - 9987 + - 9988 + - 9989 + - 9990 + - 9991 + - 9992 + - 9993 + - 9994 + - 9995 + - 9996 + - 9997 + - 9998 + - 9999 + - 10000 + - 10001 + - 10002 + - 10003 + - 10004 + - 10005 + - 10006 + - 10007 + - 10008 + - 10009 + - 10010 + - 10011 + - 10012 + - 10013 + - 10014 + - 10015 + - 10016 + - 10017 + - 10018 + - 10019 + - 10020 + - 10021 + - 10022 + - 10023 + - 10024 + - 10025 + - 10026 + - 10027 + - 10028 + - 10029 + - 10030 + - 10031 + - 10032 + - 10033 + - 10034 + - 10035 + - 10036 + - 10037 + - 10038 + - 10039 + - 10040 + - 10041 + - 10042 + - 10043 + - 10044 + - 10045 + - 10046 + - 10047 + - 10048 + - 10049 + - 10050 + - 10051 + - 10052 + - 10053 + - 10054 + - 10055 + - 10056 + - 10057 + - 10058 + - 10059 + - 10060 + - 10061 + - 10062 + - 10063 + - 10064 + - 10065 + - 10066 + - 10067 + - 10068 + - 10069 + - 10070 + - 10071 + - 10072 + - 10073 + - 10074 + - 10075 + - 10076 + - 10077 + - 10078 + - 10079 + - 10080 + - 10081 + - 10082 + - 10083 + - 10084 + - 10085 + - 10086 + - 10087 + - 10088 + - 10089 + - 10090 + - 10091 + - 10092 + - 10093 + - 10094 + - 10095 + - 10096 + - 10097 + - 10098 + - 10099 + - 10100 + - 10101 + - 10102 + - 10103 + - 10104 + - 10105 + - 10106 + - 10107 + - 10108 + - 10109 + - 10110 + - 10111 + - 10112 + - 10113 + - 10114 + - 10115 + - 10116 + - 10117 + - 10118 + - 10119 + - 10120 + - 10121 + - 10122 + - 10123 + - 10124 + - 10125 + - 10126 + - 10127 + - 10128 + - 10129 + - 10130 + - 10131 + - 10132 + - 10133 + - 10134 + - 10135 + - 10136 + - 10137 + - 10138 + - 10139 + - 10140 + - 10141 + - 10142 + - 10143 + - 10144 + - 10145 + - 10146 + - 10147 + - 10148 + - 10149 + - 10150 + - 10151 + - 10152 + - 10153 + - 10154 + - 10155 + - 10156 + - 10157 + - 10158 + - 10159 + - 10160 + - 10161 + - 10162 + - 10163 + - 10164 + - 10165 + - 10166 + - 10167 + - 10168 + - 10169 + - 10170 + - 10171 + - 10172 + - 10173 + - 10174 + - 10175 + - 10176 + - 10177 + - 10178 + - 10179 + - 10180 + - 10181 + - 10182 + - 10183 + - 10184 + - 10185 + - 10186 + - 10187 + - 10188 + - 10189 + - 10190 + - 10191 + - 10192 + - 10193 + - 10194 + - 10195 + - 10196 + - 10197 + - 10198 + - 10199 + - 10200 + - 10201 + - 10202 + - 10203 + - 10204 + - 10205 + - 10206 + - 10207 + - 10208 + - 10209 + - 10210 + - 10211 + - 10212 + - 10213 + - 10214 + - 10215 + - 10216 + - 10217 + - 10218 + - 10219 + - 10220 + - 10221 + - 10222 + - 10223 + - 10224 + - 10225 + - 10226 + - 10227 + - 10228 + - 10229 + - 10230 + - 10231 + - 10232 + - 10233 + - 10234 + - 10235 + - 10236 + - 10237 + - 10238 + - 10239 + - 10240 + - 10241 + - 10242 + - 10243 + - 10244 + - 10245 + - 10246 + - 10247 + - 10248 + - 10249 + - 10250 + - 10251 + - 10252 + - 10253 + - 10254 + - 10255 + - 10256 + - 10257 + - 10258 + - 10259 + - 10260 + - 10261 + - 10262 + - 10263 + - 10264 + - 10265 + - 10266 + - 10267 + - 10268 + - 10269 + - 10270 + - 10271 + - 10272 + - 10273 + - 10274 + - 10275 + - 10276 + - 10277 + - 10278 + - 10279 + - 10280 + - 10281 + - 10282 + - 10283 + - 10284 + - 10285 + - 10286 + - 10287 + - 10288 + - 10289 + - 10290 + - 10291 + - 10292 + - 10293 + - 10294 + - 10295 + - 10296 + - 10297 + - 10298 + - 10299 + - 10300 + - 10301 + - 10302 + - 10303 + - 10304 + - 10305 + - 10306 + - 10307 + - 10308 + - 10309 + - 10310 + - 10311 + - 10312 + - 10313 + - 10314 + - 10315 + - 10316 + - 10317 + - 10318 + - 10319 + - 10320 + - 10321 + - 10322 + - 10323 + - 10324 + - 10325 + - 10326 + - 10327 + - 10328 + - 10329 + - 10330 + - 10331 + - 10332 + - 10333 + - 10334 + - 10335 + - 10336 + - 10337 + - 10338 + - 10339 + - 10340 + - 10341 + - 10342 + - 10343 + - 10344 + - 10345 + - 10346 + - 10347 + - 10348 + - 10349 + - 10350 + - 10351 + - 10352 + - 10353 + - 10354 + - 10355 + - 10356 + - 10357 + - 10358 + - 10359 + - 10360 + - 10361 + - 10362 + - 10363 + - 10364 + - 10365 + - 10366 + - 10367 + - 10368 + - 10369 + - 10370 + - 10371 + - 10372 + - 10373 + - 10374 + - 10375 + - 10376 + - 10377 + - 10378 + - 10379 + - 10380 + - 10381 + - 10382 + - 10383 + - 10384 + - 10385 + - 10386 + - 10387 + - 10388 + - 10389 + - 10390 + - 10391 + - 10392 + - 10393 + - 10394 + - 10395 + - 10396 + - 10397 + - 10398 + - 10399 + - 10400 + - 10401 + - 10402 + - 10403 + - 10404 + - 10405 + - 10406 + - 10407 + - 10408 + - 10409 + - 10410 + - 10411 + - 10412 + - 10413 + - 10414 + - 10415 + - 10416 + - 10417 + - 10418 + - 10419 + - 10420 + - 10421 + - 10422 + - 10423 + - 10424 + - 10425 + - 10426 + - 10427 + - 10428 + - 10429 + - 10430 + - 10431 + - 10432 + - 10433 + - 10434 + - 10435 + - 10436 + - 10437 + - 10438 + - 10439 + - 10440 + - 10441 + - 10442 + - 10443 + - 10444 + - 10445 + - 10446 + - 10447 + - 10448 + - 10449 + - 10450 + - 10451 + - 10452 + - 10453 + - 10454 + - 10455 + - 10456 + - 10457 + - 10458 + - 10459 + - 10460 + - 10461 + - 10462 + - 10463 + - 10464 + - 10465 + - 10466 + - 10467 + - 10468 + - 10469 + - 10470 + - 10471 + - 10472 + - 10473 + - 10474 + - 10475 + - 10476 + - 10477 + - 10478 + - 10479 + - 10480 + - 10481 + - 10482 + - 10483 + - 10484 + - 10485 + - 10486 + - 10487 + - 10488 + - 10489 + - 10490 + - 10491 + - 10492 + - 10493 + - 10494 + - 10495 + - 10496 + - 10497 + - 10498 + - 10499 + - 10500 + - 10501 + - 10502 + - 10503 + - 10504 + - 10505 + - 10506 + - 10507 + - 10508 + - 10509 + - 10510 + - 10511 + - 10512 + - 10513 + - 10514 + - 10515 + - 10516 + - 10517 + - 10518 + - 10519 + - 10520 + - 10521 + - 10522 + - 10523 + - 10524 + - 10525 + - 10526 + - 10527 + - 10528 + - 10529 + - 10530 + - 10531 + - 10532 + - 10533 + - 10534 + - 10535 + - 10536 + - 10537 + - 10538 + - 10539 + - 10540 + - 10541 + - 10542 + - 10543 + - 10544 + - 10545 + - 10546 + - 10547 + - 10548 + - 10549 + - 10550 + - 10551 + - 10552 + - 10553 + - 10554 + - 10555 + - 10556 + - 10557 + - 10558 + - 10559 + - 10560 + - 10561 + - 10562 + - 10563 + - 10564 + - 10565 + - 10566 + - 10567 + - 10568 + - 10569 + - 10570 + - 10571 + - 10572 + - 10573 + - 10574 + - 10575 + - 10576 + - 10577 + - 10578 + - 10579 + - 10580 + - 10581 + - 10582 + - 10583 + - 10584 + - 10585 + - 10586 + - 10587 + - 10588 + - 10589 + - 10590 + - 10591 + - 10592 + - 10593 + - 10594 + - 10595 + - 10596 + - 10597 + - 10598 + - 10599 + - 10600 + - 10601 + - 10602 + - 10603 + - 10604 + - 10605 + - 10606 + - 10607 + - 10608 + - 10609 + - 10610 + - 10611 + - 10612 + - 10613 + - 10614 + - 10615 + - 10616 + - 10617 + - 10618 + - 10619 + - 10620 + - 10621 + - 10622 + - 10623 + - 10624 + - 10625 + - 10626 + - 10627 + - 10628 + - 10629 + - 10630 + - 10631 + - 10632 + - 10633 + - 10634 + - 10635 + - 10636 + - 10637 + - 10638 + - 10639 + - 10640 + - 10641 + - 10642 + - 10643 + - 10644 + - 10645 + - 10646 + - 10647 + - 10648 + - 10649 + - 10650 + - 10651 + - 10652 + - 10653 + - 10654 + - 10655 + - 10656 + - 10657 + - 10658 + - 10659 + - 10660 + - 10661 + - 10662 + - 10663 + - 10664 + - 10665 + - 10666 + - 10667 + - 10668 + - 10669 + - 10670 + - 10671 + - 10672 + - 10673 + - 10674 + - 10675 + - 10676 + - 10677 + - 10678 + - 10679 + - 10680 + - 10681 + - 10682 + - 10683 + - 10684 + - 10685 + - 10686 + - 10687 + - 10688 + - 10689 + - 10690 + - 10691 + - 10692 + - 10693 + - 10694 + - 10695 + - 10696 + - 10697 + - 10698 + - 10699 + - 10700 + - 10701 + - 10702 + - 10703 + - 10704 + - 10705 + - 10706 + - 10707 + - 10708 + - 10709 + - 10710 + - 10711 + - 10712 + - 10713 + - 10714 + - 10715 + - 10716 + - 10717 + - 10718 + - 10719 + - 10720 + - 10721 + - 10722 + - 10723 + - 10724 + - 10725 + - 10726 + - 10727 + - 10728 + - 10729 + - 10730 + - 10731 + - 10732 + - 10733 + - 10734 + - 10735 + - 10736 + - 10737 + - 10738 + - 10739 + - 10740 + - 10741 + - 10742 + - 10743 + - 10744 + - 10745 + - 10746 + - 10747 + - 10748 + - 10749 + - 10750 + - 10751 + - 10752 + - 10753 + - 10754 + - 10755 + - 10756 + - 10757 + - 10758 + - 10759 + - 10760 + - 10761 + - 10762 + - 10763 + - 10764 + - 10765 + - 10766 + - 10767 + - 10768 + - 10769 + - 10770 + - 10771 + - 10772 + - 10773 + - 10774 + - 10775 + - 10776 + - 10777 + - 10778 + - 10779 + - 10780 + - 10781 + - 10782 + - 10783 + - 10784 + - 10785 + - 10786 + - 10787 + - 10788 + - 10789 + - 10790 + - 10791 + - 10792 + - 10793 + - 10794 + - 10795 + - 10796 + - 10797 + - 10798 + - 10799 + - 10800 + - 10801 + - 10802 + - 10803 + - 10804 + - 10805 + - 10806 + - 10807 + - 10808 + - 10809 + - 10810 + - 10811 + - 10812 + - 10813 + - 10814 + - 10815 + - 10816 + - 10817 + - 10818 + - 10819 + - 10820 + - 10821 + - 10822 + - 10823 + - 10824 + - 10825 + - 10826 + - 10827 + - 10828 + - 10829 + - 10830 + - 10831 + - 10832 + - 10833 + - 10834 + - 10835 + - 10836 + - 10837 + - 10838 + - 10839 + - 10840 + - 10841 + - 10842 + - 10843 + - 10844 + - 10845 + - 10846 + - 10847 + - 10848 + - 10849 + - 10850 + - 10851 + - 10852 + - 10853 + - 10854 + - 10855 + - 10856 + - 10857 + - 10858 + - 10859 + - 10860 + - 10861 + - 10862 + - 10863 + - 10864 + - 10865 + - 10866 + - 10867 + - 10868 + - 10869 + - 10870 + - 10871 + - 10872 + - 10873 + - 10874 + - 10875 + - 10876 + - 10877 + - 10878 + - 10879 + - 10880 + - 10881 + - 10882 + - 10883 + - 10884 + - 10885 + - 10886 + - 10887 + - 10888 + - 10889 + - 10890 + - 10891 + - 10892 + - 10893 + - 10894 + - 10895 + - 10896 + - 10897 + - 10898 + - 10899 + - 10900 + - 10901 + - 10902 + - 10903 + - 10904 + - 10905 + - 10906 + - 10907 + - 10908 + - 10909 + - 10910 + - 10911 + - 10912 + - 10913 + - 10914 + - 10915 + - 10916 + - 10917 + - 10918 + - 10919 + - 10920 + - 10921 + - 10922 + - 10923 + - 10924 + - 10925 + - 10926 + - 10927 + - 10928 + - 10929 + - 10930 + - 10931 + - 10932 + - 10933 + - 10934 + - 10935 + - 10936 + - 10937 + - 10938 + - 10939 + - 10940 + - 10941 + - 10942 + - 10943 + - 10944 + - 10945 + - 10946 + - 10947 + - 10948 + - 10949 + - 10950 + - 10951 + - 10952 + - 10953 + - 10954 + - 10955 + - 10956 + - 10957 + - 10958 + - 10959 + - 10960 + - 10961 + - 10962 + - 10963 + - 10964 + - 10965 + - 10966 + - 10967 + - 10968 + - 10969 + - 10970 + - 10971 + - 10972 + - 10973 + - 10974 + - 10975 + - 10976 + - 10977 + - 10978 + - 10979 + - 10980 + - 10981 + - 10982 + - 10983 + - 10984 + - 10985 + - 10986 + - 10987 + - 10988 + - 10989 + - 10990 + - 10991 + - 10992 + - 10993 + - 10994 + - 10995 + - 10996 + - 10997 + - 10998 + - 10999 + - 11000 + - 11001 + - 11002 + - 11003 + - 11004 + - 11005 + - 11006 + - 11007 + - 11008 + - 11009 + - 11010 + - 11011 + - 11012 + - 11013 + - 11014 + - 11015 + - 11016 + - 11017 + - 11018 + - 11019 + - 11020 + - 11021 + - 11022 + - 11023 + - 11024 + - 11025 + - 11026 + - 11027 + - 11028 + - 11029 + - 11030 + - 11031 + - 11032 + - 11033 + - 11034 + - 11035 + - 11036 + - 11037 + - 11038 + - 11039 + - 11040 + - 11041 + - 11042 + - 11043 + - 11044 + - 11045 + - 11046 + - 11047 + - 11048 + - 11049 + - 11050 + - 11051 + - 11052 + - 11053 + - 11054 + - 11055 + - 11056 + - 11057 + - 11058 + - 11059 + - 11060 + - 11061 + - 11062 + - 11063 + - 11064 + - 11065 + - 11066 + - 11067 + - 11068 + - 11069 + - 11070 + - 11071 + - 11072 + - 11073 + - 11074 + - 11075 + - 11076 + - 11077 + - 11078 + - 11079 + - 11080 + - 11081 + - 11082 + - 11083 + - 11084 + - 11085 + - 11086 + - 11087 + - 11088 + - 11089 + - 11090 + - 11091 + - 11092 + - 11093 + - 11094 + - 11095 + - 11096 + - 11097 + - 11098 + - 11099 + - 11100 + - 11101 + - 11102 + - 11103 + - 11104 + - 11105 + - 11106 + - 11107 + - 11108 + - 11109 + - 11110 + - 11111 + - 11112 + - 11113 + - 11114 + - 11115 + - 11116 + - 11117 + - 11118 + - 11119 + - 11120 + - 11121 + - 11122 + - 11123 + - 11124 + - 11125 + - 11126 + - 11127 + - 11128 + - 11129 + - 11130 + - 11131 + - 11132 + - 11133 + - 11134 + - 11135 + - 11136 + - 11137 + - 11138 + - 11139 + - 11140 + - 11141 + - 11142 + - 11143 + - 11144 + - 11145 + - 11146 + - 11147 + - 11148 + - 11149 + - 11150 + - 11151 + - 11152 + - 11153 + - 11154 + - 11155 + - 11156 + - 11157 + - 11158 + - 11159 + - 11160 + - 11161 + - 11162 + - 11163 + - 11164 + - 11165 + - 11166 + - 11167 + - 11168 + - 11169 + - 11170 + - 11171 + - 11172 + - 11173 + - 11174 + - 11175 + - 11176 + - 11177 + - 11178 + - 11179 + - 11180 + - 11181 + - 11182 + - 11183 + - 11184 + - 11185 + - 11186 + - 11187 + - 11188 + - 11189 + - 11190 + - 11191 + - 11192 + - 11193 + - 11194 + - 11195 + - 11196 + - 11197 + - 11198 + - 11199 + - 11200 + - 11201 + - 11202 + - 11203 + - 11204 + - 11205 + - 11206 + - 11207 + - 11208 + - 11209 + - 11210 + - 11211 + - 11212 + - 11213 + - 11214 + - 11215 + - 11216 + - 11217 + - 11218 + - 11219 + - 11220 + - 11221 + - 11222 + - 11223 + - 11224 + - 11225 + - 11226 + - 11227 + - 11228 + - 11229 + - 11230 + - 11231 + - 11232 + - 11233 + - 11234 + - 11235 + - 11236 + - 11237 + - 11238 + - 11239 + - 11240 + - 11241 + - 11242 + - 11243 + - 11244 + - 11245 + - 11246 + - 11247 + - 11248 + - 11249 + - 11250 + - 11251 + - 11252 + - 11253 + - 11254 + - 11255 + - 11256 + - 11257 + - 11258 + - 11259 + - 11260 + - 11261 + - 11262 + - 11263 + - 11264 + - 11265 + - 11266 + - 11267 + - 11268 + - 11269 + - 11270 + - 11271 + - 11272 + - 11273 + - 11274 + - 11275 + - 11276 + - 11277 + - 11278 + - 11279 + - 11280 + - 11281 + - 11282 + - 11283 + - 11284 + - 11285 + - 11286 + - 11287 + - 11288 + - 11289 + - 11290 + - 11291 + - 11292 + - 11293 + - 11294 + - 11295 + - 11296 + - 11297 + - 11298 + - 11299 + - 11300 + - 11301 + - 11302 + - 11303 + - 11304 + - 11305 + - 11306 + - 11307 + - 11308 + - 11309 + - 11310 + - 11311 + - 11312 + - 11313 + - 11314 + - 11315 + - 11316 + - 11317 + - 11318 + - 11319 + - 11320 + - 11321 + - 11322 + - 11323 + - 11324 + - 11325 + - 11326 + - 11327 + - 11328 + - 11329 + - 11330 + - 11331 + - 11332 + - 11333 + - 11334 + - 11335 + - 11336 + - 11337 + - 11338 + - 11339 + - 11340 + - 11341 + - 11342 + - 11343 + - 11344 + - 11345 + - 11346 + - 11347 + - 11348 + - 11349 + - 11350 + - 11351 + - 11352 + - 11353 + - 11354 + - 11355 + - 11356 + - 11357 + - 11358 + - 11359 + - 11360 + - 11361 + - 11362 + - 11363 + - 11364 + - 11365 + - 11366 + - 11367 + - 11368 + - 11369 + - 11370 + - 11371 + - 11372 + - 11373 + - 11374 + - 11375 + - 11376 + - 11377 + - 11378 + - 11379 + - 11380 + - 11381 + - 11382 + - 11383 + - 11384 + - 11385 + - 11386 + - 11387 + - 11388 + - 11389 + - 11390 + - 11391 + - 11392 + - 11393 + - 11394 + - 11395 + - 11396 + - 11397 + - 11398 + - 11399 + - 11400 + - 11401 + - 11402 + - 11403 + - 11404 + - 11405 + - 11406 + - 11407 + - 11408 + - 11409 + - 11410 + - 11411 + - 11412 + - 11413 + - 11414 + - 11415 + - 11416 + - 11417 + - 11418 + - 11419 + - 11420 + - 11421 + - 11422 + - 11423 + - 11424 + - 11425 + - 11426 + - 11427 + - 11428 + - 11429 + - 11430 + - 11431 + - 11432 + - 11433 + - 11434 + - 11435 + - 11436 + - 11437 + - 11438 + - 11439 + - 11440 + - 11441 + - 11442 + - 11443 + - 11444 + - 11445 + - 11446 + - 11447 + - 11448 + - 11449 + - 11450 + - 11451 + - 11452 + - 11453 + - 11454 + - 11455 + - 11456 + - 11457 + - 11458 + - 11459 + - 11460 + - 11461 + - 11462 + - 11463 + - 11464 + - 11465 + - 11466 + - 11467 + - 11468 + - 11469 + - 11470 + - 11471 + - 11472 + - 11473 + - 11474 + - 11475 + - 11476 + - 11477 + - 11478 + - 11479 + - 11480 + - 11481 + - 11482 + - 11483 + - 11484 + - 11485 + - 11486 + - 11487 + - 11488 + - 11489 + - 11490 + - 11491 + - 11492 + - 11493 + - 11494 + - 11495 + - 11496 + - 11497 + - 11498 + - 11499 + - 11500 + - 11501 + - 11502 + - 11503 + - 11504 + - 11505 + - 11506 + - 11507 + - 11508 + - 11509 + - 11510 + - 11511 + - 11512 + - 11513 + - 11514 + - 11515 + - 11516 + - 11517 + - 11518 + - 11519 + - 11520 + - 11521 + - 11522 + - 11523 + - 11524 + - 11525 + - 11526 + - 11527 + - 11528 + - 11529 + - 11530 + - 11531 + - 11532 + - 11533 + - 11534 + - 11535 + - 11536 + - 11537 + - 11538 + - 11539 + - 11540 + - 11541 + - 11542 + - 11543 + - 11544 + - 11545 + - 11546 + - 11547 + - 11548 + - 11549 + - 11550 + - 11551 + - 11552 + - 11553 + - 11554 + - 11555 + - 11556 + - 11557 + - 11558 + - 11559 + - 11560 + - 11561 + - 11562 + - 11563 + - 11564 + - 11565 + - 11566 + - 11567 + - 11568 + - 11569 + - 11570 + - 11571 + - 11572 + - 11573 + - 11574 + - 11575 + - 11576 + - 11577 + - 11578 + - 11579 + - 11580 + - 11581 + - 11582 + - 11583 + - 11584 + - 11585 + - 11586 + - 11587 + - 11588 + - 11589 + - 11590 + - 11591 + - 11592 + - 11593 + - 11594 + - 11595 + - 11596 + - 11597 + - 11598 + - 11599 + - 11600 + - 11601 + - 11602 + - 11603 + - 11604 + - 11605 + - 11606 + - 11607 + - 11608 + - 11609 + - 11610 + - 11611 + - 11612 + - 11613 + - 11614 + - 11615 + - 11616 + - 11617 + - 11618 + - 11619 + - 11620 + - 11621 + - 11622 + - 11623 + - 11624 + - 11625 + - 11626 + - 11627 + - 11628 + - 11629 + - 11630 + - 11631 + - 11632 + - 11633 + - 11634 + - 11635 + - 11636 + - 11637 + - 11638 + - 11639 + - 11640 + - 11641 + - 11642 + - 11643 + - 11644 + - 11645 + - 11646 + - 11647 + - 11648 + - 11649 + - 11650 + - 11651 + - 11652 + - 11653 + - 11654 + - 11655 + - 11656 + - 11657 + - 11658 + - 11659 + - 11660 + - 11661 + - 11662 + - 11663 + - 11664 + - 11665 + - 11666 + - 11667 + - 11668 + - 11669 + - 11670 + - 11671 + - 11672 + - 11673 + - 11674 + - 11675 + - 11676 + - 11677 + - 11678 + - 11679 + - 11680 + - 11681 + - 11682 + - 11683 + - 11684 + - 11685 + - 11686 + - 11687 + - 11688 + - 11689 + - 11690 + - 11691 + - 11692 + - 11693 + - 11694 + - 11695 + - 11696 + - 11697 + - 11698 + - 11699 + - 11700 + - 11701 + - 11702 + - 11703 + - 11704 + - 11705 + - 11706 + - 11707 + - 11708 + - 11709 + - 11710 + - 11711 + - 11712 + - 11713 + - 11714 + - 11715 + - 11716 + - 11717 + - 11718 + - 11719 + - 11720 + - 11721 + - 11722 + - 11723 + - 11724 + - 11725 + - 11726 + - 11727 + - 11728 + - 11729 + - 11730 + - 11731 + - 11732 + - 11733 + - 11734 + - 11735 + - 11736 + - 11737 + - 11738 + - 11739 + - 11740 + - 11741 + - 11742 + - 11743 + - 11744 + - 11745 + - 11746 + - 11747 + - 11748 + - 11749 + - 11750 + - 11751 + - 11752 + - 11753 + - 11754 + - 11755 + - 11756 + - 11757 + - 11758 + - 11759 + - 11760 + - 11761 + - 11762 + - 11763 + - 11764 + - 11765 + - 11766 + - 11767 + - 11768 + - 11769 + - 11770 + - 11771 + - 11772 + - 11773 + - 11774 + - 11775 + - 11776 + - 11777 + - 11778 + - 11779 + - 11780 + - 11781 + - 11782 + - 11783 + - 11784 + - 11785 + - 11786 + - 11787 + - 11788 + - 11789 + - 11790 + - 11791 + - 11792 + - 11793 + - 11794 + - 11795 + - 11796 + - 11797 + - 11798 + - 11799 + - 11800 + - 11801 + - 11802 + - 11803 + - 11804 + - 11805 + - 11806 + - 11807 + - 11808 + - 11809 + - 11810 + - 11811 + - 11812 + - 11813 + - 11814 + - 11815 + - 11816 + - 11817 + - 11818 + - 11819 + - 11820 + - 11821 + - 11822 + - 11823 + - 11824 + - 11825 + - 11826 + - 11827 + - 11828 + - 11829 + - 11830 + - 11831 + - 11832 + - 11833 + - 11834 + - 11835 + - 11836 + - 11837 + - 11838 + - 11839 + - 11840 + - 11841 + - 11842 + - 11843 + - 11844 + - 11845 + - 11846 + - 11847 + - 11848 + - 11849 + - 11850 + - 11851 + - 11852 + - 11853 + - 11854 + - 11855 + - 11856 + - 11857 + - 11858 + - 11859 + - 11860 + - 11861 + - 11862 + - 11863 + - 11864 + - 11865 + - 11866 + - 11867 + - 11868 + - 11869 + - 11870 + - 11871 + - 11872 + - 11873 + - 11874 + - 11875 + - 11876 + - 11877 + - 11878 + - 11879 + - 11880 + - 11881 + - 11882 + - 11883 + - 11884 + - 11885 + - 11886 + - 11887 + - 11888 + - 11889 + - 11890 + - 11891 + - 11892 + - 11893 + - 11894 + - 11895 + - 11896 + - 11897 + - 11898 + - 11899 + - 11900 + - 11901 + - 11902 + - 11903 + - 11904 + - 11905 + - 11906 + - 11907 + - 11908 + - 11909 + - 11910 + - 11911 + - 11912 + - 11913 + - 11914 + - 11915 + - 11916 + - 11917 + - 11918 + - 11919 + - 11920 + - 11921 + - 11922 + - 11923 + - 11924 + - 11925 + - 11926 + - 11927 + - 11928 + - 11929 + - 11930 + - 11931 + - 11932 + - 11933 + - 11934 + - 11935 + - 11936 + - 11937 + - 11938 + - 11939 + - 11940 + - 11941 + - 11942 + - 11943 + - 11944 + - 11945 + - 11946 + - 11947 + - 11948 + - 11949 + - 11950 + - 11951 + - 11952 + - 11953 + - 11954 + - 11955 + - 11956 + - 11957 + - 11958 + - 11959 + - 11960 + - 11961 + - 11962 + - 11963 + - 11964 + - 11965 + - 11966 + - 11967 + - 11968 + - 11969 + - 11970 + - 11971 + - 11972 + - 11973 + - 11974 + - 11975 + - 11976 + - 11977 + - 11978 + - 11979 + - 11980 + - 11981 + - 11982 + - 11983 + - 11984 + - 11985 + - 11986 + - 11987 + - 11988 + - 11989 + - 11990 + - 11991 + - 11992 + - 11993 + - 11994 + - 11995 + - 11996 + - 11997 + - 11998 + - 11999 + - 12000 + - 12001 + - 12002 + - 12003 + - 12004 + - 12005 + - 12006 + - 12007 + - 12008 + - 12009 + - 12010 + - 12011 + - 12012 + - 12013 + - 12014 + - 12015 + - 12016 + - 12017 + - 12018 + - 12019 + - 12020 + - 12021 + - 12022 + - 12023 + - 12024 + - 12025 + - 12026 + - 12027 + - 12028 + - 12029 + - 12030 + - 12031 + - 12032 + - 12033 + - 12034 + - 12035 + - 12036 + - 12037 + - 12038 + - 12039 + - 12040 + - 12041 + - 12042 + - 12043 + - 12044 + - 12045 + - 12046 + - 12047 + - 12048 + - 12049 + - 12050 + - 12051 + - 12052 + - 12053 + - 12054 + - 12055 + - 12056 + - 12057 + - 12058 + - 12059 + - 12060 + - 12061 + - 12062 + - 12063 + - 12064 + - 12065 + - 12066 + - 12067 + - 12068 + - 12069 + - 12070 + - 12071 + - 12072 + - 12073 + - 12074 + - 12075 + - 12076 + - 12077 + - 12078 + - 12079 + - 12080 + - 12081 + - 12082 + - 12083 + - 12084 + - 12085 + - 12086 + - 12087 + - 12088 + - 12089 + - 12090 + - 12091 + - 12092 + - 12093 + - 12094 + - 12095 + - 12096 + - 12097 + - 12098 + - 12099 + - 12100 + - 12101 + - 12102 + - 12103 + - 12104 + - 12105 + - 12106 + - 12107 + - 12108 + - 12109 + - 12110 + - 12111 + - 12112 + - 12113 + - 12114 + - 12115 + - 12116 + - 12117 + - 12118 + - 12119 + - 12120 + - 12121 + - 12122 + - 12123 + - 12124 + - 12125 + - 12126 + - 12127 + - 12128 + - 12129 + - 12130 + - 12131 + - 12132 + - 12133 + - 12134 + - 12135 + - 12136 + - 12137 + - 12138 + - 12139 + - 12140 + - 12141 + - 12142 + - 12143 + - 12144 + - 12145 + - 12146 + - 12147 + - 12148 + - 12149 + - 12150 + - 12151 + - 12152 + - 12153 + - 12154 + - 12155 + - 12156 + - 12157 + - 12158 + - 12159 + - 12160 + - 12161 + - 12162 + - 12163 + - 12164 + - 12165 + - 12166 + - 12167 + - 12168 + - 12169 + - 12170 + - 12171 + - 12172 + - 12173 + - 12174 + - 12175 + - 12176 + - 12177 + - 12178 + - 12179 + - 12180 + - 12181 + - 12182 + - 12183 + - 12184 + - 12185 + - 12186 + - 12187 + - 12188 + - 12189 + - 12190 + - 12191 + - 12192 + - 12193 + - 12194 + - 12195 + - 12196 + - 12197 + - 12198 + - 12199 + - 12200 + - 12201 + - 12202 + - 12203 + - 12204 + - 12205 + - 12206 + - 12207 + - 12208 + - 12209 + - 12210 + - 12211 + - 12212 + - 12213 + - 12214 + - 12215 + - 12216 + - 12217 + - 12218 + - 12219 + - 12220 + - 12221 + - 12222 + - 12223 + - 12224 + - 12225 + - 12226 + - 12227 + - 12228 + - 12229 + - 12230 + - 12231 + - 12232 + - 12233 + - 12234 + - 12235 + - 12236 + - 12237 + - 12238 + - 12239 + - 12240 + - 12241 + - 12242 + - 12243 + - 12244 + - 12245 + - 12246 + - 12247 + - 12248 + - 12249 + - 12250 + - 12251 + - 12252 + - 12253 + - 12254 + - 12255 + - 12256 + - 12257 + - 12258 + - 12259 + - 12260 + - 12261 + - 12262 + - 12263 + - 12264 + - 12265 + - 12266 + - 12267 + - 12268 + - 12269 + - 12270 + - 12271 + - 12272 + - 12273 + - 12274 + - 12275 + - 12276 + - 12277 + - 12278 + - 12279 + - 12280 + - 12281 + - 12282 + - 12283 + - 12284 + - 12285 + - 12286 + - 12287 + - 12288 + - 12289 + - 12290 + - 12291 + - 12292 + - 12293 + - 12294 + - 12295 + - 12296 + - 12297 + - 12298 + - 12299 + - 12300 + - 12301 + - 12302 + - 12303 + - 12304 + - 12305 + - 12306 + - 12307 + - 12308 + - 12309 + - 12310 + - 12311 + - 12312 + - 12313 + - 12314 + - 12315 + - 12316 + - 12317 + - 12318 + - 12319 + - 12320 + - 12321 + - 12322 + - 12323 + - 12324 + - 12325 + - 12326 + - 12327 + - 12328 + - 12329 + - 12330 + - 12331 + - 12332 + - 12333 + - 12334 + - 12335 + - 12336 + - 12337 + - 12338 + - 12339 + - 12340 + - 12341 + - 12342 + - 12343 + - 12344 + - 12345 + - 12346 + - 12347 + - 12348 + - 12349 + - 12350 + - 12351 + - 12352 + - 12353 + - 12354 + - 12355 + - 12356 + - 12357 + - 12358 + - 12359 + - 12360 + - 12361 + - 12362 + - 12363 + - 12364 + - 12365 + - 12366 + - 12367 + - 12368 + - 12369 + - 12370 + - 12371 + - 12372 + - 12373 + - 12374 + - 12375 + - 12376 + - 12377 + - 12378 + - 12379 + - 12380 + - 12381 + - 12382 + - 12383 + - 12384 + - 12385 + - 12386 + - 12387 + - 12388 + - 12389 + - 12390 + - 12391 + - 12392 + - 12393 + - 12394 + - 12395 + - 12396 + - 12397 + - 12398 + - 12399 + - 12400 + - 12401 + - 12402 + - 12403 + - 12404 + - 12405 + - 12406 + - 12407 + - 12408 + - 12409 + - 12410 + - 12411 + - 12412 + - 12413 + - 12414 + - 12415 + - 12416 + - 12417 + - 12418 + - 12419 + - 12420 + - 12421 + - 12422 + - 12423 + - 12424 + - 12425 + - 12426 + - 12427 + - 12428 + - 12429 + - 12430 + - 12431 + - 12432 + - 12433 + - 12434 + - 12435 + - 12436 + - 12437 + - 12438 + - 12439 + - 12440 + - 12441 + - 12442 + - 12443 + - 12444 + - 12445 + - 12446 + - 12447 + - 12448 + - 12449 + - 12450 + - 12451 + - 12452 + - 12453 + - 12454 + - 12455 + - 12456 + - 12457 + - 12458 + - 12459 + - 12460 + - 12461 + - 12462 + - 12463 + - 12464 + - 12465 + - 12466 + - 12467 + - 12468 + - 12469 + - 12470 + - 12471 + - 12472 + - 12473 + - 12474 + - 12475 + - 12476 + - 12477 + - 12478 + - 12479 + - 12480 + - 12481 + - 12482 + - 12483 + - 12484 + - 12485 + - 12486 + - 12487 + - 12488 + - 12489 + - 12490 + - 12491 + - 12492 + - 12493 + - 12494 + - 12495 + - 12496 + - 12497 + - 12498 + - 12499 + - 12500 + - 12501 + - 12502 + - 12503 + - 12504 + - 12505 + - 12506 + - 12507 + - 12508 + - 12509 + - 12510 + - 12511 + - 12512 + - 12513 + - 12514 + - 12515 + - 12516 + - 12517 + - 12518 + - 12519 + - 12520 + - 12521 + - 12522 + - 12523 + - 12524 + - 12525 + - 12526 + - 12527 + - 12528 + - 12529 + - 12530 + - 12531 + - 12532 + - 12533 + - 12534 + - 12535 + - 12536 + - 12537 + - 12538 + - 12539 + - 12540 + - 12541 + - 12542 + - 12543 + - 12544 + - 12545 + - 12546 + - 12547 + - 12548 + - 12549 + - 12550 + - 12551 + - 12552 + - 12553 + - 12554 + - 12555 + - 12556 + - 12557 + - 12558 + - 12559 + - 12560 + - 12561 + - 12562 + - 12563 + - 12564 + - 12565 + - 12566 + - 12567 + - 12568 + - 12569 + - 12570 + - 12571 + - 12572 + - 12573 + - 12574 + - 12575 + - 12576 + - 12577 + - 12578 + - 12579 + - 12580 + - 12581 + - 12582 + - 12583 + - 12584 + - 12585 + - 12586 + - 12587 + - 12588 + - 12589 + - 12590 + - 12591 + - 12592 + - 12593 + - 12594 + - 12595 + - 12596 + - 12597 + - 12598 + - 12599 + - 12600 + - 12601 + - 12602 + - 12603 + - 12604 + - 12605 + - 12606 + - 12607 + - 12608 + - 12609 + - 12610 + - 12611 + - 12612 + - 12613 + - 12614 + - 12615 + - 12616 + - 12617 + - 12618 + - 12619 + - 12620 + - 12621 + - 12622 + - 12623 + - 12624 + - 12625 + - 12626 + - 12627 + - 12628 + - 12629 + - 12630 + - 12631 + - 12632 + - 12633 + - 12634 + - 12635 + - 12636 + - 12637 + - 12638 + - 12639 + - 12640 + - 12641 + - 12642 + - 12643 + - 12644 + - 12645 + - 12646 + - 12647 + - 12648 + - 12649 + - 12650 + - 12651 + - 12652 + - 12653 + - 12654 + - 12655 + - 12656 + - 12657 + - 12658 + - 12659 + - 12660 + - 12661 + - 12662 + - 12663 + - 12664 + - 12665 + - 12666 + - 12667 + - 12668 + - 12669 + - 12670 + - 12671 + - 12672 + - 12673 + - 12674 + - 12675 + - 12676 + - 12677 + - 12678 + - 12679 + - 12680 + - 12681 + - 12682 + - 12683 + - 12684 + - 12685 + - 12686 + - 12687 + - 12688 + - 12689 + - 12690 + - 12691 + - 12692 + - 12693 + - 12694 + - 12695 + - 12696 + - 12697 + - 12698 + - 12699 + - 12700 + - 12701 + - 12702 + - 12703 + - 12704 + - 12705 + - 12706 + - 12707 + - 12708 + - 12709 + - 12710 + - 12711 + - 12712 + - 12713 + - 12714 + - 12715 + - 12716 + - 12717 + - 12718 + - 12719 + - 12720 + - 12721 + - 12722 + - 12723 + - 12724 + - 12725 + - 12726 + - 12727 + - 12728 + - 12729 + - 12730 + - 12731 + - 12732 + - 12733 + - 12734 + - 12735 + - 12736 + - 12737 + - 12738 + - 12739 + - 12740 + - 12741 + - 12742 + - 12743 + - 12744 + - 12745 + - 12746 + - 12747 + - 12748 + - 12749 + - 12750 + - 12751 + - 12752 + - 12753 + - 12754 + - 12755 + - 12756 + - 12757 + - 12758 + - 12759 + - 12760 + - 12761 + - 12762 + - 12763 + - 12764 + - 12765 + - 12766 + - 12767 + - 12768 + - 12769 + - 12770 + - 12771 + - 12772 + - 12773 + - 12774 + - 12775 + - 12776 + - 12777 + - 12778 + - 12779 + - 12780 + - 12781 + - 12782 + - 12783 + - 12784 + - 12785 + - 12786 + - 12787 + - 12788 + - 12789 + - 12790 + - 12791 + - 12792 + - 12793 + - 12794 + - 12795 + - 12796 + - 12797 + - 12798 + - 12799 + - 12800 + - 12801 + - 12802 + - 12803 + - 12804 + - 12805 + - 12806 + - 12807 + - 12808 + - 12809 + - 12810 + - 12811 + - 12812 + - 12813 + - 12814 + - 12815 + - 12816 + - 12817 + - 12818 + - 12819 + - 12820 + - 12821 + - 12822 + - 12823 + - 12824 + - 12825 + - 12826 + - 12827 + - 12828 + - 12829 + - 12830 + - 12831 + - 12832 + - 12833 + - 12834 + - 12835 + - 12836 + - 12837 + - 12838 + - 12839 + - 12840 + - 12841 + - 12842 + - 12843 + - 12844 + - 12845 + - 12846 + - 12847 + - 12848 + - 12849 + - 12850 + - 12851 + - 12852 + - 12853 + - 12854 + - 12855 + - 12856 + - 12857 + - 12858 + - 12859 + - 12860 + - 12861 + - 12862 + - 12863 + - 12864 + - 12865 + - 12866 + - 12867 + - 12868 + - 12869 + - 12870 + - 12871 + - 12872 + - 12873 + - 12874 + - 12875 + - 12876 + - 12877 + - 12878 + - 12879 + - 12880 + - 12881 + - 12882 + - 12883 + - 12884 + - 12885 + - 12886 + - 12887 + - 12888 + - 12889 + - 12890 + - 12891 + - 12892 + - 12893 + - 12894 + - 12895 + - 12896 + - 12897 + - 12898 + - 12899 + - 12900 + - 12901 + - 12902 + - 12903 + - 12904 + - 12905 + - 12906 + - 12907 + - 12908 + - 12909 + - 12910 + - 12911 + - 12912 + - 12913 + - 12914 + - 12915 + - 12916 + - 12917 + - 12918 + - 12919 + - 12920 + - 12921 + - 12922 + - 12923 + - 12924 + - 12925 + - 12926 + - 12927 + - 12928 + - 12929 + - 12930 + - 12931 + - 12932 + - 12933 + - 12934 + - 12935 + - 12936 + - 12937 + - 12938 + - 12939 + - 12940 + - 12941 + - 12942 + - 12943 + - 12944 + - 12945 + - 12946 + - 12947 + - 12948 + - 12949 + - 12950 + - 12951 + - 12952 + - 12953 + - 12954 + - 12955 + - 12956 + - 12957 + - 12958 + - 12959 + - 12960 + - 12961 + - 12962 + - 12963 + - 12964 + - 12965 + - 12966 + - 12967 + - 12968 + - 12969 + - 12970 + - 12971 + - 12972 + - 12973 + - 12974 + - 12975 + - 12976 + - 12977 + - 12978 + - 12979 + - 12980 + - 12981 + - 12982 + - 12983 + - 12984 + - 12985 + - 12986 + - 12987 + - 12988 + - 12989 + - 12990 + - 12991 + - 12992 + - 12993 + - 12994 + - 12995 + - 12996 + - 12997 + - 12998 + - 12999 + - 13000 + - 13001 + - 13002 + - 13003 + - 13004 + - 13005 + - 13006 + - 13007 + - 13008 + - 13009 + - 13010 + - 13011 + - 13012 + - 13013 + - 13014 + - 13015 + - 13016 + - 13017 + - 13018 + - 13019 + - 13020 + - 13021 + - 13022 + - 13023 + - 13024 + - 13025 + - 13026 + - 13027 + - 13028 + - 13029 + - 13030 + - 13031 + - 13032 + - 13033 + - 13034 + - 13035 + - 13036 + - 13037 + - 13038 + - 13039 + - 13040 + - 13041 + - 13042 + - 13043 + - 13044 + - 13045 + - 13046 + - 13047 + - 13048 + - 13049 + - 13050 + - 13051 + - 13052 + - 13053 + - 13054 + - 13055 + - 13056 + - 13057 + - 13058 + - 13059 + - 13060 + - 13061 + - 13062 + - 13063 + - 13064 + - 13065 + - 13066 + - 13067 + - 13068 + - 13069 + - 13070 + - 13071 + - 13072 + - 13073 + - 13074 + - 13075 + - 13076 + - 13077 + - 13078 + - 13079 + - 13080 + - 13081 + - 13082 + - 13083 + - 13084 + - 13085 + - 13086 + - 13087 + - 13088 + - 13089 + - 13090 + - 13091 + - 13092 + - 13093 + - 13094 + - 13095 + - 13096 + - 13097 + - 13098 + - 13099 + - 13100 + - 13101 + - 13102 + - 13103 + - 13104 + - 13105 + - 13106 + - 13107 + - 13108 + - 13109 + - 13110 + - 13111 + - 13112 + - 13113 + - 13114 + - 13115 + - 13116 + - 13117 + - 13118 + - 13119 + - 13120 + - 13121 + - 13122 + - 13123 + - 13124 + - 13125 + - 13126 + - 13127 + - 13128 + - 13129 + - 13130 + - 13131 + - 13132 + - 13133 + - 13134 + - 13135 + - 13136 + - 13137 + - 13138 + - 13139 + - 13140 + - 13141 + - 13142 + - 13143 + - 13144 + - 13145 + - 13146 + - 13147 + - 13148 + - 13149 + - 13150 + - 13151 + - 13152 + - 13153 + - 13154 + - 13155 + - 13156 + - 13157 + - 13158 + - 13159 + - 13160 + - 13161 + - 13162 + - 13163 + - 13164 + - 13165 + - 13166 + - 13167 + - 13168 + - 13169 + - 13170 + - 13171 + - 13172 + - 13173 + - 13174 + - 13175 + - 13176 + - 13177 + - 13178 + - 13179 + - 13180 + - 13181 + - 13182 + - 13183 + - 13184 + - 13185 + - 13186 + - 13187 + - 13188 + - 13189 + - 13190 + - 13191 + - 13192 + - 13193 + - 13194 + - 13195 + - 13196 + - 13197 + - 13198 + - 13199 + - 13200 + - 13201 + - 13202 + - 13203 + - 13204 + - 13205 + - 13206 + - 13207 + - 13208 + - 13209 + - 13210 + - 13211 + - 13212 + - 13213 + - 13214 + - 13215 + - 13216 + - 13217 + - 13218 + - 13219 + - 13220 + - 13221 + - 13222 + - 13223 + - 13224 + - 13225 + - 13226 + - 13227 + - 13228 + - 13229 + - 13230 + - 13231 + - 13232 + - 13233 + - 13234 + - 13235 + - 13236 + - 13237 + - 13238 + - 13239 + - 13240 + - 13241 + - 13242 + - 13243 + - 13244 + - 13245 + - 13246 + - 13247 + - 13248 + - 13249 + - 13250 + - 13251 + - 13252 + - 13253 + - 13254 + - 13255 + - 13256 + - 13257 + - 13258 + - 13259 + - 13260 + - 13261 + - 13262 + - 13263 + - 13264 + - 13265 + - 13266 + - 13267 + - 13268 + - 13269 + - 13270 + - 13271 + - 13272 + - 13273 + - 13274 + - 13275 + - 13276 + - 13277 + - 13278 + - 13279 + - 13280 + - 13281 + - 13282 + - 13283 + - 13284 + - 13285 + - 13286 + - 13287 + - 13288 + - 13289 + - 13290 + - 13291 + - 13292 + - 13293 + - 13294 + - 13295 + - 13296 + - 13297 + - 13298 + - 13299 + - 13300 + - 13301 + - 13302 + - 13303 + - 13304 + - 13305 + - 13306 + - 13307 + - 13308 + - 13309 + - 13310 + - 13311 + - 13312 + - 13313 + - 13314 + - 13315 + - 13316 + - 13317 + - 13318 + - 13319 + - 13320 + - 13321 + - 13322 + - 13323 + - 13324 + - 13325 + - 13326 + - 13327 + - 13328 + - 13329 + - 13330 + - 13331 + - 13332 + - 13333 + - 13334 + - 13335 + - 13336 + - 13337 + - 13338 + - 13339 + - 13340 + - 13341 + - 13342 + - 13343 + - 13344 + - 13345 + - 13346 + - 13347 + - 13348 + - 13349 + - 13350 + - 13351 + - 13352 + - 13353 + - 13354 + - 13355 + - 13356 + - 13357 + - 13358 + - 13359 + - 13360 + - 13361 + - 13362 + - 13363 + - 13364 + - 13365 + - 13366 + - 13367 + - 13368 + - 13369 + - 13370 + - 13371 + - 13372 + - 13373 + - 13374 + - 13375 + - 13376 + - 13377 + - 13378 + - 13379 + - 13380 + - 13381 + - 13382 + - 13383 + - 13384 + - 13385 + - 13386 + - 13387 + - 13388 + - 13389 + - 13390 + - 13391 + - 13392 + - 13393 + - 13394 + - 13395 + - 13396 + - 13397 + - 13398 + - 13399 + - 13400 + - 13401 + - 13402 + - 13403 + - 13404 + - 13405 + - 13406 + - 13407 + - 13408 + - 13409 + - 13410 + - 13411 + - 13412 + - 13413 + - 13414 + - 13415 + - 13416 + - 13417 + - 13418 + - 13419 + - 13420 + - 13421 + - 13422 + - 13423 + - 13424 + - 13425 + - 13426 + - 13427 + - 13428 + - 13429 + - 13430 + - 13431 + - 13432 + - 13433 + - 13434 + - 13435 + - 13436 + - 13437 + - 13438 + - 13439 + - 13440 + - 13441 + - 13442 + - 13443 + - 13444 + - 13445 + - 13446 + - 13447 + - 13448 + - 13449 + - 13450 + - 13451 + - 13452 + - 13453 + - 13454 + - 13455 + - 13456 + - 13457 + - 13458 + - 13459 + - 13460 + - 13461 + - 13462 + - 13463 + - 13464 + - 13465 + - 13466 + - 13467 + - 13468 + - 13469 + - 13470 + - 13471 + - 13472 + - 13473 + - 13474 + - 13475 + - 13476 + - 13477 + - 13478 + - 13479 + - 13480 + - 13481 + - 13482 + - 13483 + - 13484 + - 13485 + - 13486 + - 13487 + - 13488 + - 13489 + - 13490 + - 13491 + - 13492 + - 13493 + - 13494 + - 13495 + - 13496 + - 13497 + - 13498 + - 13499 + - 13500 + - 13501 + - 13502 + - 13503 + - 13504 + - 13505 + - 13506 + - 13507 + - 13508 + - 13509 + - 13510 + - 13511 + - 13512 + - 13513 + - 13514 + - 13515 + - 13516 + - 13517 + - 13518 + - 13519 + - 13520 + - 13521 + - 13522 + - 13523 + - 13524 + - 13525 + - 13526 + - 13527 + - 13528 + - 13529 + - 13530 + - 13531 + - 13532 + - 13533 + - 13534 + - 13535 + - 13536 + - 13537 + - 13538 + - 13539 + - 13540 + - 13541 + - 13542 + - 13543 + - 13544 + - 13545 + - 13546 + - 13547 + - 13548 + - 13549 + - 13550 + - 13551 + - 13552 + - 13553 + - 13554 + - 13555 + - 13556 + - 13557 + - 13558 + - 13559 + - 13560 + - 13561 + - 13562 + - 13563 + - 13564 + - 13565 + - 13566 + - 13567 + - 13568 + - 13569 + - 13570 + - 13571 + - 13572 + - 13573 + - 13574 + - 13575 + - 13576 + - 13577 + - 13578 + - 13579 + - 13580 + - 13581 + - 13582 + - 13583 + - 13584 + - 13585 + - 13586 + - 13587 + - 13588 + - 13589 + - 13590 + - 13591 + - 13592 + - 13593 + - 13594 + - 13595 + - 13596 + - 13597 + - 13598 + - 13599 + - 13600 + - 13601 + - 13602 + - 13603 + - 13604 + - 13605 + - 13606 + - 13607 + - 13608 + - 13609 + - 13610 + - 13611 + - 13612 + - 13613 + - 13614 + - 13615 + - 13616 + - 13617 + - 13618 + - 13619 + - 13620 + - 13621 + - 13622 + - 13623 + - 13624 + - 13625 + - 13626 + - 13627 + - 13628 + - 13629 + - 13630 + - 13631 + - 13632 + - 13633 + - 13634 + - 13635 + - 13636 + - 13637 + - 13638 + - 13639 + - 13640 + - 13641 + - 13642 + - 13643 + - 13644 + - 13645 + - 13646 + - 13647 + - 13648 + - 13649 + - 13650 + - 13651 + - 13652 + - 13653 + - 13654 + - 13655 + - 13656 + - 13657 + - 13658 + - 13659 + - 13660 + - 13661 + - 13662 + - 13663 + - 13664 + - 13665 + - 13666 + - 13667 + - 13668 + - 13669 + - 13670 + - 13671 + - 13672 + - 13673 + - 13674 + - 13675 + - 13676 + - 13677 + - 13678 + - 13679 + - 13680 + - 13681 + - 13682 + - 13683 + - 13684 + - 13685 + - 13686 + - 13687 + - 13688 + - 13689 + - 13690 + - 13691 + - 13692 + - 13693 + - 13694 + - 13695 + - 13696 + - 13697 + - 13698 + - 13699 + - 13700 + - 13701 + - 13702 + - 13703 + - 13704 + - 13705 + - 13706 + - 13707 + - 13708 + - 13709 + - 13710 + - 13711 + - 13712 + - 13713 + - 13714 + - 13715 + - 13716 + - 13717 + - 13718 + - 13719 + - 13720 + - 13721 + - 13722 + - 13723 + - 13724 + - 13725 + - 13726 + - 13727 + - 13728 + - 13729 + - 13730 + - 13731 + - 13732 + - 13733 + - 13734 + - 13735 + - 13736 + - 13737 + - 13738 + - 13739 + - 13740 + - 13741 + - 13742 + - 13743 + - 13744 + - 13745 + - 13746 + - 13747 + - 13748 + - 13749 + - 13750 + - 13751 + - 13752 + - 13753 + - 13754 + - 13755 + - 13756 + - 13757 + - 13758 + - 13759 + - 13760 + - 13761 + - 13762 + - 13763 + - 13764 + - 13765 + - 13766 + - 13767 + - 13768 + - 13769 + - 13770 + - 13771 + - 13772 + - 13773 + - 13774 + - 13775 + - 13776 + - 13777 + - 13778 + - 13779 + - 13780 + - 13781 + - 13782 + - 13783 + - 13784 + - 13785 + - 13786 + - 13787 + - 13788 + - 13789 + - 13790 + - 13791 + - 13792 + - 13793 + - 13794 + - 13795 + - 13796 + - 13797 + - 13798 + - 13799 + - 13800 + - 13801 + - 13802 + - 13803 + - 13804 + - 13805 + - 13806 + - 13807 + - 13808 + - 13809 + - 13810 + - 13811 + - 13812 + - 13813 + - 13814 + - 13815 + - 13816 + - 13817 + - 13818 + - 13819 + - 13820 + - 13821 + - 13822 + - 13823 + - 13824 + - 13825 + - 13826 + - 13827 + - 13828 + - 13829 + - 13830 + - 13831 + - 13832 + - 13833 + - 13834 + - 13835 + - 13836 + - 13837 + - 13838 + - 13839 + - 13840 + - 13841 + - 13842 + - 13843 + - 13844 + - 13845 + - 13846 + - 13847 + - 13848 + - 13849 + - 13850 + - 13851 + - 13852 + - 13853 + - 13854 + - 13855 + - 13856 + - 13857 + - 13858 + - 13859 + - 13860 + - 13861 + - 13862 + - 13863 + - 13864 + - 13865 + - 13866 + - 13867 + - 13868 + - 13869 + - 13870 + - 13871 + - 13872 + - 13873 + - 13874 + - 13875 + - 13876 + - 13877 + - 13878 + - 13879 + - 13880 + - 13881 + - 13882 + - 13883 + - 13884 + - 13885 + - 13886 + - 13887 + - 13888 + - 13889 + - 13890 + - 13891 + - 13892 + - 13893 + - 13894 + - 13895 + - 13896 + - 13897 + - 13898 + - 13899 + - 13900 + - 13901 + - 13902 + - 13903 + - 13904 + - 13905 + - 13906 + - 13907 + - 13908 + - 13909 + - 13910 + - 13911 + - 13912 + - 13913 + - 13914 + - 13915 + - 13916 + - 13917 + - 13918 + - 13919 + - 13920 + - 13921 + - 13922 + - 13923 + - 13924 + - 13925 + - 13926 + - 13927 + - 13928 + - 13929 + - 13930 + - 13931 + - 13932 + - 13933 + - 13934 + - 13935 + - 13936 + - 13937 + - 13938 + - 13939 + - 13940 + - 13941 + - 13942 + - 13943 + - 13944 + - 13945 + - 13946 + - 13947 + - 13948 + - 13949 + - 13950 + - 13951 + - 13952 + - 13953 + - 13954 + - 13955 + - 13956 + - 13957 + - 13958 + - 13959 + - 13960 + - 13961 + - 13962 + - 13963 + - 13964 + - 13965 + - 13966 + - 13967 + - 13968 + - 13969 + - 13970 + - 13971 + - 13972 + - 13973 + - 13974 + - 13975 + - 13976 + - 13977 + - 13978 + - 13979 + - 13980 + - 13981 + - 13982 + - 13983 + - 13984 + - 13985 + - 13986 + - 13987 + - 13988 + - 13989 + - 13990 + - 13991 + - 13992 + - 13993 + - 13994 + - 13995 + - 13996 + - 13997 + - 13998 + - 13999 + - 14000 + - 14001 + - 14002 + - 14003 + - 14004 + - 14005 + - 14006 + - 14007 + - 14008 + - 14009 + - 14010 + - 14011 + - 14012 + - 14013 + - 14014 + - 14015 + - 14016 + - 14017 + - 14018 + - 14019 + - 14020 + - 14021 + - 14022 + - 14023 + - 14024 + - 14025 + - 14026 + - 14027 + - 14028 + - 14029 + - 14030 + - 14031 + - 14032 + - 14033 + - 14034 + - 14035 + - 14036 + - 14037 + - 14038 + - 14039 + - 14040 + - 14041 + - 14042 + - 14043 + - 14044 + - 14045 + - 14046 + - 14047 + - 14048 + - 14049 + - 14050 + - 14051 + - 14052 + - 14053 + - 14054 + - 14055 + - 14056 + - 14057 + - 14058 + - 14059 + - 14060 + - 14061 + - 14062 + - 14063 + - 14064 + - 14065 + - 14066 + - 14067 + - 14068 + - 14069 + - 14070 + - 14071 + - 14072 + - 14073 + - 14074 + - 14075 + - 14076 + - 14077 + - 14078 + - 14079 + - 14080 + - 14081 + - 14082 + - 14083 + - 14084 + - 14085 + - 14086 + - 14087 + - 14088 + - 14089 + - 14090 + - 14091 + - 14092 + - 14093 + - 14094 + - 14095 + - 14096 + - 14097 + - 14098 + - 14099 + - 14100 + - 14101 + - 14102 + - 14103 + - 14104 + - 14105 + - 14106 + - 14107 + - 14108 + - 14109 + - 14110 + - 14111 + - 14112 + - 14113 + - 14114 + - 14115 + - 14116 + - 14117 + - 14118 + - 14119 + - 14120 + - 14121 + - 14122 + - 14123 + - 14124 + - 14125 + - 14126 + - 14127 + - 14128 + - 14129 + - 14130 + - 14131 + - 14132 + - 14133 + - 14134 + - 14135 + - 14136 + - 14137 + - 14138 + - 14139 + - 14140 + - 14141 + - 14142 + - 14143 + - 14144 + - 14145 + - 14146 + - 14147 + - 14148 + - 14149 + - 14150 + - 14151 + - 14152 + - 14153 + - 14154 + - 14155 + - 14156 + - 14157 + - 14158 + - 14159 + - 14160 + - 14161 + - 14162 + - 14163 + - 14164 + - 14165 + - 14166 + - 14167 + - 14168 + - 14169 + - 14170 + - 14171 + - 14172 + - 14173 + - 14174 + - 14175 + - 14176 + - 14177 + - 14178 + - 14179 + - 14180 + - 14181 + - 14182 + - 14183 + - 14184 + - 14185 + - 14186 + - 14187 + - 14188 + - 14189 + - 14190 + - 14191 + - 14192 + - 14193 + - 14194 + - 14195 + - 14196 + - 14197 + - 14198 + - 14199 + - 14200 + - 14201 + - 14202 + - 14203 + - 14204 + - 14205 + - 14206 + - 14207 + - 14208 + - 14209 + - 14210 + - 14211 + - 14212 + - 14213 + - 14214 + - 14215 + - 14216 + - 14217 + - 14218 + - 14219 + - 14220 + - 14221 + - 14222 + - 14223 + - 14224 + - 14225 + - 14226 + - 14227 + - 14228 + - 14229 + - 14230 + - 14231 + - 14232 + - 14233 + - 14234 + - 14235 + - 14236 + - 14237 + - 14238 + - 14239 + - 14240 + - 14241 + - 14242 + - 14243 + - 14244 + - 14245 + - 14246 + - 14247 + - 14248 + - 14249 + - 14250 + - 14251 + - 14252 + - 14253 + - 14254 + - 14255 + - 14256 + - 14257 + - 14258 + - 14259 + - 14260 + - 14261 + - 14262 + - 14263 + - 14264 + - 14265 + - 14266 + - 14267 + - 14268 + - 14269 + - 14270 + - 14271 + - 14272 + - 14273 + - 14274 + - 14275 + - 14276 + - 14277 + - 14278 + - 14279 + - 14280 + - 14281 + - 14282 + - 14283 + - 14284 + - 14285 + - 14286 + - 14287 + - 14288 + - 14289 + - 14290 + - 14291 + - 14292 + - 14293 + - 14294 + - 14295 + - 14296 + - 14297 + - 14298 + - 14299 + - 14300 + - 14301 + - 14302 + - 14303 + - 14304 + - 14305 + - 14306 + - 14307 + - 14308 + - 14309 + - 14310 + - 14311 + - 14312 + - 14313 + - 14314 + - 14315 + - 14316 + - 14317 + - 14318 + - 14319 + - 14320 + - 14321 + - 14322 + - 14323 + - 14324 + - 14325 + - 14326 + - 14327 + - 14328 + - 14329 + - 14330 + - 14331 + - 14332 + - 14333 + - 14334 + - 14335 + - 14336 + - 14337 + - 14338 + - 14339 + - 14340 + - 14341 + - 14342 + - 14343 + - 14344 + - 14345 + - 14346 + - 14347 + - 14348 + - 14349 + - 14350 + - 14351 + - 14352 + - 14353 + - 14354 + - 14355 + - 14356 + - 14357 + - 14358 + - 14359 + - 14360 + - 14361 + - 14362 + - 14363 + - 14364 + - 14365 + - 14366 + - 14367 + - 14368 + - 14369 + - 14370 + - 14371 + - 14372 + - 14373 + - 14374 + - 14375 + - 14376 + - 14377 + - 14378 + - 14379 + - 14380 + - 14381 + - 14382 + - 14383 + - 14384 + - 14385 + - 14386 + - 14387 + - 14388 + - 14389 + - 14390 + - 14391 + - 14392 + - 14393 + - 14394 + - 14395 + - 14396 + - 14397 + - 14398 + - 14399 + - 14400 + - 14401 + - 14402 + - 14403 + - 14404 + - 14405 + - 14406 + - 14407 + - 14408 + - 14409 + - 14410 + - 14411 + - 14412 + - 14413 + - 14414 + - 14415 + - 14416 + - 14417 + - 14418 + - 14419 + - 14420 + - 14421 + - 14422 + - 14423 + - 14424 + - 14425 + - 14426 + - 14427 + - 14428 + - 14429 + - 14430 + - 14431 + - 14432 + - 14433 + - 14434 + - 14435 + - 14436 + - 14437 + - 14438 + - 14439 + - 14440 + - 14441 + - 14442 + - 14443 + - 14444 + - 14445 + - 14446 + - 14447 + - 14448 + - 14449 + - 14450 + - 14451 + - 14452 + - 14453 + - 14454 + - 14455 + - 14456 + - 14457 + - 14458 + - 14459 + - 14460 + - 14461 + - 14462 + - 14463 + - 14464 + - 14465 + - 14466 + - 14467 + - 14468 + - 14469 + - 14470 + - 14471 + - 14472 + - 14473 + - 14474 + - 14475 + - 14476 + - 14477 + - 14478 + - 14479 + - 14480 + - 14481 + - 14482 + - 14483 + - 14484 + - 14485 + - 14486 + - 14487 + - 14488 + - 14489 + - 14490 + - 14491 + - 14492 + - 14493 + - 14494 + - 14495 + - 14496 + - 14497 + - 14498 + - 14499 + - 14500 + - 14501 + - 14502 + - 14503 + - 14504 + - 14505 + - 14506 + - 14507 + - 14508 + - 14509 + - 14510 + - 14511 + - 14512 + - 14513 + - 14514 + - 14515 + - 14516 + - 14517 + - 14518 + - 14519 + - 14520 + - 14521 + - 14522 + - 14523 + - 14524 + - 14525 + - 14526 + - 14527 + - 14528 + - 14529 + - 14530 + - 14531 + - 14532 + - 14533 + - 14534 + - 14535 + - 14536 + - 14537 + - 14538 + - 14539 + - 14540 + - 14541 + - 14542 + - 14543 + - 14544 + - 14545 + - 14546 + - 14547 + - 14548 + - 14549 + - 14550 + - 14551 + - 14552 + - 14553 + - 14554 + - 14555 + - 14556 + - 14557 + - 14558 + - 14559 + - 14560 + - 14561 + - 14562 + - 14563 + - 14564 + - 14565 + - 14566 + - 14567 + - 14568 + - 14569 + - 14570 + - 14571 + - 14572 + - 14573 + - 14574 + - 14575 + - 14576 + - 14577 + - 14578 + - 14579 + - 14580 + - 14581 + - 14582 + - 14583 + - 14584 + - 14585 + - 14586 + - 14587 + - 14588 + - 14589 + - 14590 + - 14591 + - 14592 + - 14593 + - 14594 + - 14595 + - 14596 + - 14597 + - 14598 + - 14599 + - 14600 + - 14601 + - 14602 + - 14603 + - 14604 + - 14605 + - 14606 + - 14607 + - 14608 + - 14609 + - 14610 + - 14611 + - 14612 + - 14613 + - 14614 + - 14615 + - 14616 + - 14617 + - 14618 + - 14619 + - 14620 + - 14621 + - 14622 + - 14623 + - 14624 + - 14625 + - 14626 + - 14627 + - 14628 + - 14629 + - 14630 + - 14631 + - 14632 + - 14633 + - 14634 + - 14635 + - 14636 + - 14637 + - 14638 + - 14639 + - 14640 + - 14641 + - 14642 + - 14643 + - 14644 + - 14645 + - 14646 + - 14647 + - 14648 + - 14649 + - 14650 + - 14651 + - 14652 + - 14653 + - 14654 + - 14655 + - 14656 + - 14657 + - 14658 + - 14659 + - 14660 + - 14661 + - 14662 + - 14663 + - 14664 + - 14665 + - 14666 + - 14667 + - 14668 + - 14669 + - 14670 + - 14671 + - 14672 + - 14673 + - 14674 + - 14675 + - 14676 + - 14677 + - 14678 + - 14679 + - 14680 + - 14681 + - 14682 + - 14683 + - 14684 + - 14685 + - 14686 + - 14687 + - 14688 + - 14689 + - 14690 + - 14691 + - 14692 + - 14693 + - 14694 + - 14695 + - 14696 + - 14697 + - 14698 + - 14699 + - 14700 + - 14701 + - 14702 + - 14703 + - 14704 + - 14705 + - 14706 + - 14707 + - 14708 + - 14709 + - 14710 + - 14711 + - 14712 + - 14713 + - 14714 + - 14715 + - 14716 + - 14717 + - 14718 + - 14719 + - 14720 + - 14721 + - 14722 + - 14723 + - 14724 + - 14725 + - 14726 + - 14727 + - 14728 + - 14729 + - 14730 + - 14731 + - 14732 + - 14733 + - 14734 + - 14735 + - 14736 + - 14737 + - 14738 + - 14739 + - 14740 + - 14741 + - 14742 + - 14743 + - 14744 + - 14745 + - 14746 + - 14747 + - 14748 + - 14749 + - 14750 + - 14751 + - 14752 + - 14753 + - 14754 + - 14755 + - 14756 + - 14757 + - 14758 + - 14759 + - 14760 + - 14761 + - 14762 + - 14763 + - 14764 + - 14765 + - 14766 + - 14767 + - 14768 + - 14769 + - 14770 + - 14771 + - 14772 + - 14773 + - 14774 + - 14775 + - 14776 + - 14777 + - 14778 + - 14779 + - 14780 + - 14781 + - 14782 + - 14783 + - 14784 + - 14785 + - 14786 + - 14787 + - 14788 + - 14789 + - 14790 + - 14791 + - 14792 + - 14793 + - 14794 + - 14795 + - 14796 + - 14797 + - 14798 + - 14799 + - 14800 + - 14801 + - 14802 + - 14803 + - 14804 + - 14805 + - 14806 + - 14807 + - 14808 + - 14809 + - 14810 + - 14811 + - 14812 + - 14813 + - 14814 + - 14815 + - 14816 + - 14817 + - 14818 + - 14819 + - 14820 + - 14821 + - 14822 + - 14823 + - 14824 + - 14825 + - 14826 + - 14827 + - 14828 + - 14829 + - 14830 + - 14831 + - 14832 + - 14833 + - 14834 + - 14835 + - 14836 + - 14837 + - 14838 + - 14839 + - 14840 + - 14841 + - 14842 + - 14843 + - 14844 + - 14845 + - 14846 + - 14847 + - 14848 + - 14849 + - 14850 + - 14851 + - 14852 + - 14853 + - 14854 + - 14855 + - 14856 + - 14857 + - 14858 + - 14859 + - 14860 + - 14861 + - 14862 + - 14863 + - 14864 + - 14865 + - 14866 + - 14867 + - 14868 + - 14869 + - 14870 + - 14871 + - 14872 + - 14873 + - 14874 + - 14875 + - 14876 + - 14877 + - 14878 + - 14879 + - 14880 + - 14881 + - 14882 + - 14883 + - 14884 + - 14885 + - 14886 + - 14887 + - 14888 + - 14889 + - 14890 + - 14891 + - 14892 + - 14893 + - 14894 + - 14895 + - 14896 + - 14897 + - 14898 + - 14899 + - 14900 + - 14901 + - 14902 + - 14903 + - 14904 + - 14905 + - 14906 + - 14907 + - 14908 + - 14909 + - 14910 + - 14911 + - 14912 + - 14913 + - 14914 + - 14915 + - 14916 + - 14917 + - 14918 + - 14919 + - 14920 + - 14921 + - 14922 + - 14923 + - 14924 + - 14925 + - 14926 + - 14927 + - 14928 + - 14929 + - 14930 + - 14931 + - 14932 + - 14933 + - 14934 + - 14935 + - 14936 + - 14937 + - 14938 + - 14939 + - 14940 + - 14941 + - 14942 + - 14943 + - 14944 + - 14945 + - 14946 + - 14947 + - 14948 + - 14949 + - 14950 + - 14951 + - 14952 + - 14953 + - 14954 + - 14955 + - 14956 + - 14957 + - 14958 + - 14959 + - 14960 + - 14961 + - 14962 + - 14963 + - 14964 + - 14965 + - 14966 + - 14967 + - 14968 + - 14969 + - 14970 + - 14971 + - 14972 + - 14973 + - 14974 + - 14975 + - 14976 + - 14977 + - 14978 + - 14979 + - 14980 + - 14981 + - 14982 + - 14983 + - 14984 + - 14985 + - 14986 + - 14987 + - 14988 + - 14989 + - 14990 + - 14991 + - 14992 + - 14993 + - 14994 + - 14995 + - 14996 + - 14997 + - 14998 + - 14999 + - 15000 + - 15001 + - 15002 + - 15003 + - 15004 + - 15005 + - 15006 + - 15007 + - 15008 + - 15009 + - 15010 + - 15011 + - 15012 + - 15013 + - 15014 + - 15015 + - 15016 + - 15017 + - 15018 + - 15019 + - 15020 + - 15021 + - 15022 + - 15023 + - 15024 + - 15025 + - 15026 + - 15027 + - 15028 + - 15029 + - 15030 + - 15031 + - 15032 + - 15033 + - 15034 + - 15035 + - 15036 + - 15037 + - 15038 + - 15039 + - 15040 + - 15041 + - 15042 + - 15043 + - 15044 + - 15045 + - 15046 + - 15047 + - 15048 + - 15049 + - 15050 + - 15051 + - 15052 + - 15053 + - 15054 + - 15055 + - 15056 + - 15057 + - 15058 + - 15059 + - 15060 + - 15061 + - 15062 + - 15063 + - 15064 + - 15065 + - 15066 + - 15067 + - 15068 + - 15069 + - 15070 + - 15071 + - 15072 + - 15073 + - 15074 + - 15075 + - 15076 + - 15077 + - 15078 + - 15079 + - 15080 + - 15081 + - 15082 + - 15083 + - 15084 + - 15085 + - 15086 + - 15087 + - 15088 + - 15089 + - 15090 + - 15091 + - 15092 + - 15093 + - 15094 + - 15095 + - 15096 + - 15097 + - 15098 + - 15099 + - 15100 + - 15101 + - 15102 + - 15103 + - 15104 + - 15105 + - 15106 + - 15107 + - 15108 + - 15109 + - 15110 + - 15111 + - 15112 + - 15113 + - 15114 + - 15115 + - 15116 + - 15117 + - 15118 + - 15119 + - 15120 + - 15121 + - 15122 + - 15123 + - 15124 + - 15125 + - 15126 + - 15127 + - 15128 + - 15129 + - 15130 + - 15131 + - 15132 + - 15133 + - 15134 + - 15135 + - 15136 + - 15137 + - 15138 + - 15139 + - 15140 + - 15141 + - 15142 + - 15143 + - 15144 + - 15145 + - 15146 + - 15147 + - 15148 + - 15149 + - 15150 + - 15151 + - 15152 + - 15153 + - 15154 + - 15155 + - 15156 + - 15157 + - 15158 + - 15159 + - 15160 + - 15161 + - 15162 + - 15163 + - 15164 + - 15165 + - 15166 + - 15167 + - 15168 + - 15169 + - 15170 + - 15171 + - 15172 + - 15173 + - 15174 + - 15175 + - 15176 + - 15177 + - 15178 + - 15179 + - 15180 + - 15181 + - 15182 + - 15183 + - 15184 + - 15185 + - 15186 + - 15187 + - 15188 + - 15189 + - 15190 + - 15191 + - 15192 + - 15193 + - 15194 + - 15195 + - 15196 + - 15197 + - 15198 + - 15199 + - 15200 + - 15201 + - 15202 + - 15203 + - 15204 + - 15205 + - 15206 + - 15207 + - 15208 + - 15209 + - 15210 + - 15211 + - 15212 + - 15213 + - 15214 + - 15215 + - 15216 + - 15217 + - 15218 + - 15219 + - 15220 + - 15221 + - 15222 + - 15223 + - 15224 + - 15225 + - 15226 + - 15227 + - 15228 + - 15229 + - 15230 + - 15231 + - 15232 + - 15233 + - 15234 + - 15235 + - 15236 + - 15237 + - 15238 + - 15239 + - 15240 + - 15241 + - 15242 + - 15243 + - 15244 + - 15245 + - 15246 + - 15247 + - 15248 + - 15249 + - 15250 + - 15251 + - 15252 + - 15253 + - 15254 + - 15255 + - 15256 + - 15257 + - 15258 + - 15259 + - 15260 + - 15261 + - 15262 + - 15263 + - 15264 + - 15265 + - 15266 + - 15267 + - 15268 + - 15269 + - 15270 + - 15271 + - 15272 + - 15273 + - 15274 + - 15275 + - 15276 + - 15277 + - 15278 + - 15279 + - 15280 + - 15281 + - 15282 + - 15283 + - 15284 + - 15285 + - 15286 + - 15287 + - 15288 + - 15289 + - 15290 + - 15291 + - 15292 + - 15293 + - 15294 + - 15295 + - 15296 + - 15297 + - 15298 + - 15299 + - 15300 + - 15301 + - 15302 + - 15303 + - 15304 + - 15305 + - 15306 + - 15307 + - 15308 + - 15309 + - 15310 + - 15311 + - 15312 + - 15313 + - 15314 + - 15315 + - 15316 + - 15317 + - 15318 + - 15319 + - 15320 + - 15321 + - 15322 + - 15323 + - 15324 + - 15325 + - 15326 + - 15327 + - 15328 + - 15329 + - 15330 + - 15331 + - 15332 + - 15333 + - 15334 + - 15335 + - 15336 + - 15337 + - 15338 + - 15339 + - 15340 + - 15341 + - 15342 + - 15343 + - 15344 + - 15345 + - 15346 + - 15347 + - 15348 + - 15349 + - 15350 + - 15351 + - 15352 + - 15353 + - 15354 + - 15355 + - 15356 + - 15357 + - 15358 + - 15359 + - 15360 + - 15361 + - 15362 + - 15363 + - 15364 + - 15365 + - 15366 + - 15367 + - 15368 + - 15369 + - 15370 + - 15371 + - 15372 + - 15373 + - 15374 + - 15375 + - 15376 + - 15377 + - 15378 + - 15379 + - 15380 + - 15381 + - 15382 + - 15383 + - 15384 + - 15385 + - 15386 + - 15387 + - 15388 + - 15389 + - 15390 + - 15391 + - 15392 + - 15393 + - 15394 + - 15395 + - 15396 + - 15397 + - 15398 + - 15399 + - 15400 + - 15401 + - 15402 + - 15403 + - 15404 + - 15405 + - 15406 + - 15407 + - 15408 + - 15409 + - 15410 + - 15411 + - 15412 + - 15413 + - 15414 + - 15415 + - 15416 + - 15417 + - 15418 + - 15419 + - 15420 + - 15421 + - 15422 + - 15423 + - 15424 + - 15425 + - 15426 + - 15427 + - 15428 + - 15429 + - 15430 + - 15431 + - 15432 + - 15433 + - 15434 + - 15435 + - 15436 + - 15437 + - 15438 + - 15439 + - 15440 + - 15441 + - 15442 + - 15443 + - 15444 + - 15445 + - 15446 + - 15447 + - 15448 + - 15449 + - 15450 + - 15451 + - 15452 + - 15453 + - 15454 + - 15455 + - 15456 + - 15457 + - 15458 + - 15459 + - 15460 + - 15461 + - 15462 + - 15463 + - 15464 + - 15465 + - 15466 + - 15467 + - 15468 + - 15469 + - 15470 + - 15471 + - 15472 + - 15473 + - 15474 + - 15475 + - 15476 + - 15477 + - 15478 + - 15479 + - 15480 + - 15481 + - 15482 + - 15483 + - 15484 + - 15485 + - 15486 + - 15487 + - 15488 + - 15489 + - 15490 + - 15491 + - 15492 + - 15493 + - 15494 + - 15495 + - 15496 + - 15497 + - 15498 + - 15499 + - 15500 + - 15501 + - 15502 + - 15503 + - 15504 + - 15505 + - 15506 + - 15507 + - 15508 + - 15509 + - 15510 + - 15511 + - 15512 + - 15513 + - 15514 + - 15515 + - 15516 + - 15517 + - 15518 + - 15519 + - 15520 + - 15521 + - 15522 + - 15523 + - 15524 + - 15525 + - 15526 + - 15527 + - 15528 + - 15529 + - 15530 + - 15531 + - 15532 + - 15533 + - 15534 + - 15535 + - 15536 + - 15537 + - 15538 + - 15539 + - 15540 + - 15541 + - 15542 + - 15543 + - 15544 + - 15545 + - 15546 + - 15547 + - 15548 + - 15549 + - 15550 + - 15551 + - 15552 + - 15553 + - 15554 + - 15555 + - 15556 + - 15557 + - 15558 + - 15559 + - 15560 + - 15561 + - 15562 + - 15563 + - 15564 + - 15565 + - 15566 + - 15567 + - 15568 + - 15569 + - 15570 + - 15571 + - 15572 + - 15573 + - 15574 + - 15575 + - 15576 + - 15577 + - 15578 + - 15579 + - 15580 + - 15581 + - 15582 + - 15583 + - 15584 + - 15585 + - 15586 + - 15587 + - 15588 + - 15589 + - 15590 + - 15591 + - 15592 + - 15593 + - 15594 + - 15595 + - 15596 + - 15597 + - 15598 + - 15599 + - 15600 + - 15601 + - 15602 + - 15603 + - 15604 + - 15605 + - 15606 + - 15607 + - 15608 + - 15609 + - 15610 + - 15611 + - 15612 + - 15613 + - 15614 + - 15615 + - 15616 + - 15617 + - 15618 + - 15619 + - 15620 + - 15621 + - 15622 + - 15623 + - 15624 + - 15625 + - 15626 + - 15627 + - 15628 + - 15629 + - 15630 + - 15631 + - 15632 + - 15633 + - 15634 + - 15635 + - 15636 + - 15637 + - 15638 + - 15639 + - 15640 + - 15641 + - 15642 + - 15643 + - 15644 + - 15645 + - 15646 + - 15647 + - 15648 + - 15649 + - 15650 + - 15651 + - 15652 + - 15653 + - 15654 + - 15655 + - 15656 + - 15657 + - 15658 + - 15659 + - 15660 + - 15661 + - 15662 + - 15663 + - 15664 + - 15665 + - 15666 + - 15667 + - 15668 + - 15669 + - 15670 + - 15671 + - 15672 + - 15673 + - 15674 + - 15675 + - 15676 + - 15677 + - 15678 + - 15679 + - 15680 + - 15681 + - 15682 + - 15683 + - 15684 + - 15685 + - 15686 + - 15687 + - 15688 + - 15689 + - 15690 + - 15691 + - 15692 + - 15693 + - 15694 + - 15695 + - 15696 + - 15697 + - 15698 + - 15699 + - 15700 + - 15701 + - 15702 + - 15703 + - 15704 + - 15705 + - 15706 + - 15707 + - 15708 + - 15709 + - 15710 + - 15711 + - 15712 + - 15713 + - 15714 + - 15715 + - 15716 + - 15717 + - 15718 + - 15719 + - 15720 + - 15721 + - 15722 + - 15723 + - 15724 + - 15725 + - 15726 + - 15727 + - 15728 + - 15729 + - 15730 + - 15731 + - 15732 + - 15733 + - 15734 + - 15735 + - 15736 + - 15737 + - 15738 + - 15739 + - 15740 + - 15741 + - 15742 + - 15743 + - 15744 + - 15745 + - 15746 + - 15747 + - 15748 + - 15749 + - 15750 + - 15751 + - 15752 + - 15753 + - 15754 + - 15755 + - 15756 + - 15757 + - 15758 + - 15759 + - 15760 + - 15761 + - 15762 + - 15763 + - 15764 + - 15765 + - 15766 + - 15767 + - 15768 + - 15769 + - 15770 + - 15771 + - 15772 + - 15773 + - 15774 + - 15775 + - 15776 + - 15777 + - 15778 + - 15779 + - 15780 + - 15781 + - 15782 + - 15783 + - 15784 + - 15785 + - 15786 + - 15787 + - 15788 + - 15789 + - 15790 + - 15791 + - 15792 + - 15793 + - 15794 + - 15795 + - 15796 + - 15797 + - 15798 + - 15799 + - 15800 + - 15801 + - 15802 + - 15803 + - 15804 + - 15805 + - 15806 + - 15807 + - 15808 + - 15809 + - 15810 + - 15811 + - 15812 + - 15813 + - 15814 + - 15815 + - 15816 + - 15817 + - 15818 + - 15819 + - 15820 + - 15821 + - 15822 + - 15823 + - 15824 + - 15825 + - 15826 + - 15827 + - 15828 + - 15829 + - 15830 + - 15831 + - 15832 + - 15833 + - 15834 + - 15835 + - 15836 + - 15837 + - 15838 + - 15839 + - 15840 + - 15841 + - 15842 + - 15843 + - 15844 + - 15845 + - 15846 + - 15847 + - 15848 + - 15849 + - 15850 + - 15851 + - 15852 + - 15853 + - 15854 + - 15855 + - 15856 + - 15857 + - 15858 + - 15859 + - 15860 + - 15861 + - 15862 + - 15863 + - 15864 + - 15865 + - 15866 + - 15867 + - 15868 + - 15869 + - 15870 + - 15871 + - 15872 + - 15873 + - 15874 + - 15875 + - 15876 + - 15877 + - 15878 + - 15879 + - 15880 + - 15881 + - 15882 + - 15883 + - 15884 + - 15885 + - 15886 + - 15887 + - 15888 + - 15889 + - 15890 + - 15891 + - 15892 + - 15893 + - 15894 + - 15895 + - 15896 + - 15897 + - 15898 + - 15899 + - 15900 + - 15901 + - 15902 + - 15903 + - 15904 + - 15905 + - 15906 + - 15907 + - 15908 + - 15909 + - 15910 + - 15911 + - 15912 + - 15913 + - 15914 + - 15915 + - 15916 + - 15917 + - 15918 + - 15919 + - 15920 + - 15921 + - 15922 + - 15923 + - 15924 + - 15925 + - 15926 + - 15927 + - 15928 + - 15929 + - 15930 + - 15931 + - 15932 + - 15933 + - 15934 + - 15935 + - 15936 + - 15937 + - 15938 + - 15939 + - 15940 + - 15941 + - 15942 + - 15943 + - 15944 + - 15945 + - 15946 + - 15947 + - 15948 + - 15949 + - 15950 + - 15951 + - 15952 + - 15953 + - 15954 + - 15955 + - 15956 + - 15957 + - 15958 + - 15959 + - 15960 + - 15961 + - 15962 + - 15963 + - 15964 + - 15965 + - 15966 + - 15967 + - 15968 + - 15969 + - 15970 + - 15971 + - 15972 + - 15973 + - 15974 + - 15975 + - 15976 + - 15977 + - 15978 + - 15979 + - 15980 + - 15981 + - 15982 + - 15983 + - 15984 + - 15985 + - 15986 + - 15987 + - 15988 + - 15989 + - 15990 + - 15991 + - 15992 + - 15993 + - 15994 + - 15995 + - 15996 + - 15997 + - 15998 + - 15999 + - 16000 + - 16001 + - 16002 + - 16003 + - 16004 + - 16005 + - 16006 + - 16007 + - 16008 + - 16009 + - 16010 + - 16011 + - 16012 + - 16013 + - 16014 + - 16015 + - 16016 + - 16017 + - 16018 + - 16019 + - 16020 + - 16021 + - 16022 + - 16023 + - 16024 + - 16025 + - 16026 + - 16027 + - 16028 + - 16029 + - 16030 + - 16031 + - 16032 + - 16033 + - 16034 + - 16035 + - 16036 + - 16037 + - 16038 + - 16039 + - 16040 + - 16041 + - 16042 + - 16043 + - 16044 + - 16045 + - 16046 + - 16047 + - 16048 + - 16049 + - 16050 + - 16051 + - 16052 + - 16053 + - 16054 + - 16055 + - 16056 + - 16057 + - 16058 + - 16059 + - 16060 + - 16061 + - 16062 + - 16063 + - 16064 + - 16065 + - 16066 + - 16067 + - 16068 + - 16069 + - 16070 + - 16071 + - 16072 + - 16073 + - 16074 + - 16075 + - 16076 + - 16077 + - 16078 + - 16079 + - 16080 + - 16081 + - 16082 + - 16083 + - 16084 + - 16085 + - 16086 + - 16087 + - 16088 + - 16089 + - 16090 + - 16091 + - 16092 + - 16093 + - 16094 + - 16095 + - 16096 + - 16097 + - 16098 + - 16099 + - 16100 + - 16101 + - 16102 + - 16103 + - 16104 + - 16105 + - 16106 + - 16107 + - 16108 + - 16109 + - 16110 + - 16111 + - 16112 + - 16113 + - 16114 + - 16115 + - 16116 + - 16117 + - 16118 + - 16119 + - 16120 + - 16121 + - 16122 + - 16123 + - 16124 + - 16125 + - 16126 + - 16127 + - 16128 + - 16129 + - 16130 + - 16131 + - 16132 + - 16133 + - 16134 + - 16135 + - 16136 + - 16137 + - 16138 + - 16139 + - 16140 + - 16141 + - 16142 + - 16143 + - 16144 + - 16145 + - 16146 + - 16147 + - 16148 + - 16149 + - 16150 + - 16151 + - 16152 + - 16153 + - 16154 + - 16155 + - 16156 + - 16157 + - 16158 + - 16159 + - 16160 + - 16161 + - 16162 + - 16163 + - 16164 + - 16165 + - 16166 + - 16167 + - 16168 + - 16169 + - 16170 + - 16171 + - 16172 + - 16173 + - 16174 + - 16175 + - 16176 + - 16177 + - 16178 + - 16179 + - 16180 + - 16181 + - 16182 + - 16183 + - 16184 + - 16185 + - 16186 + - 16187 + - 16188 + - 16189 + - 16190 + - 16191 + - 16192 + - 16193 + - 16194 + - 16195 + - 16196 + - 16197 + - 16198 + - 16199 + - 16200 + - 16201 + - 16202 + - 16203 + - 16204 + - 16205 + - 16206 + - 16207 + - 16208 + - 16209 + - 16210 + - 16211 + - 16212 + - 16213 + - 16214 + - 16215 + - 16216 + - 16217 + - 16218 + - 16219 + - 16220 + - 16221 + - 16222 + - 16223 + - 16224 + - 16225 + - 16226 + - 16227 + - 16228 + - 16229 + - 16230 + - 16231 + - 16232 + - 16233 + - 16234 + - 16235 + - 16236 + - 16237 + - 16238 + - 16239 + - 16240 + - 16241 + - 16242 + - 16243 + - 16244 + - 16245 + - 16246 + - 16247 + - 16248 + - 16249 + - 16250 + - 16251 + - 16252 + - 16253 + - 16254 + - 16255 + - 16256 + - 16257 + - 16258 + - 16259 + - 16260 + - 16261 + - 16262 + - 16263 + - 16264 + - 16265 + - 16266 + - 16267 + - 16268 + - 16269 + - 16270 + - 16271 + - 16272 + - 16273 + - 16274 + - 16275 + - 16276 + - 16277 + - 16278 + - 16279 + - 16280 + - 16281 + - 16282 + - 16283 + - 16284 + - 16285 + - 16286 + - 16287 + - 16288 + - 16289 + - 16290 + - 16291 + - 16292 + - 16293 + - 16294 + - 16295 + - 16296 + - 16297 + - 16298 + - 16299 + - 16300 + - 16301 + - 16302 + - 16303 + - 16304 + - 16305 + - 16306 + - 16307 + - 16308 + - 16309 + - 16310 + - 16311 + - 16312 + - 16313 + - 16314 + - 16315 + - 16316 + - 16317 + - 16318 + - 16319 + - 16320 + - 16321 + - 16322 + - 16323 + - 16324 + - 16325 + - 16326 + - 16327 + - 16328 + - 16329 + - 16330 + - 16331 + - 16332 + - 16333 + - 16334 + - 16335 + - 16336 + - 16337 + - 16338 + - 16339 + - 16340 + - 16341 + - 16342 + - 16343 + - 16344 + - 16345 + - 16346 + - 16347 + - 16348 + - 16349 + - 16350 + - 16351 + - 16352 + - 16353 + - 16354 + - 16355 + - 16356 + - 16357 + - 16358 + - 16359 + - 16360 + - 16361 + - 16362 + - 16363 + - 16364 + - 16365 + - 16366 + - 16367 + - 16368 + - 16369 + - 16370 + - 16371 + - 16372 + - 16373 + - 16374 + - 16375 + - 16376 + - 16377 + - 16378 + - 16379 + - 16380 + - 16381 + - 16382 + - 16383 + - 16384 + - 16385 + - 16386 + - 16387 + - 16388 + - 16389 + - 16390 + - 16391 + - 16392 + - 16393 + - 16394 + - 16395 + - 16396 + - 16397 + - 16398 + - 16399 + - 16400 + - 16401 + - 16402 + - 16403 + - 16404 + - 16405 + - 16406 + - 16407 + - 16408 + - 16409 + - 16410 + - 16411 + - 16412 + - 16413 + - 16414 + - 16415 + - 16416 + - 16417 + - 16418 + - 16419 + - 16420 + - 16421 + - 16422 + - 16423 + - 16424 + - 16425 + - 16426 + - 16427 + - 16428 + - 16429 + - 16430 + - 16431 + - 16432 + - 16433 + - 16434 + - 16435 + - 16436 + - 16437 + - 16438 + - 16439 + - 16440 + - 16441 + - 16442 + - 16443 + - 16444 + - 16445 + - 16446 + - 16447 + - 16448 + - 16449 + - 16450 + - 16451 + - 16452 + - 16453 + - 16454 + - 16455 + - 16456 + - 16457 + - 16458 + - 16459 + - 16460 + - 16461 + - 16462 + - 16463 + - 16464 + - 16465 + - 16466 + - 16467 + - 16468 + - 16469 + - 16470 + - 16471 + - 16472 + - 16473 + - 16474 + - 16475 + - 16476 + - 16477 + - 16478 + - 16479 + - 16480 + - 16481 + - 16482 + - 16483 + - 16484 + - 16485 + - 16486 + - 16487 + - 16488 + - 16489 + - 16490 + - 16491 + - 16492 + - 16493 + - 16494 + - 16495 + - 16496 + - 16497 + - 16498 + - 16499 + - 16500 + - 16501 + - 16502 + - 16503 + - 16504 + - 16505 + - 16506 + - 16507 + - 16508 + - 16509 + - 16510 + - 16511 + - 16512 + - 16513 + - 16514 + - 16515 + - 16516 + - 16517 + - 16518 + - 16519 + - 16520 + - 16521 + - 16522 + - 16523 + - 16524 + - 16525 + - 16526 + - 16527 + - 16528 + - 16529 + - 16530 + - 16531 + - 16532 + - 16533 + - 16534 + - 16535 + - 16536 + - 16537 + - 16538 + - 16539 + - 16540 + - 16541 + - 16542 + - 16543 + - 16544 + - 16545 + - 16546 + - 16547 + - 16548 + - 16549 + - 16550 + - 16551 + - 16552 + - 16553 + - 16554 + - 16555 + - 16556 + - 16557 + - 16558 + - 16559 + - 16560 + - 16561 + - 16562 + - 16563 + - 16564 + - 16565 + - 16566 + - 16567 + - 16568 + - 16569 + - 16570 + - 16571 + - 16572 + - 16573 + - 16574 + - 16575 + - 16576 + - 16577 + - 16578 + - 16579 + - 16580 + - 16581 + - 16582 + - 16583 + - 16584 + - 16585 + - 16586 + - 16587 + - 16588 + - 16589 + - 16590 + - 16591 + - 16592 + - 16593 + - 16594 + - 16595 + - 16596 + - 16597 + - 16598 + - 16599 + - 16600 + - 16601 + - 16602 + - 16603 + - 16604 + - 16605 + - 16606 + - 16607 + - 16608 + - 16609 + - 16610 + - 16611 + - 16612 + - 16613 + - 16614 + - 16615 + - 16616 + - 16617 + - 16618 + - 16619 + - 16620 + - 16621 + - 16622 + - 16623 + - 16624 + - 16625 + - 16626 + - 16627 + - 16628 + - 16629 + - 16630 + - 16631 + - 16632 + - 16633 + - 16634 + - 16635 + - 16636 + - 16637 + - 16638 + - 16639 + - 16640 + - 16641 + - 16642 + - 16643 + - 16644 + - 16645 + - 16646 + - 16647 + - 16648 + - 16649 + - 16650 + - 16651 + - 16652 + - 16653 + - 16654 + - 16655 + - 16656 + - 16657 + - 16658 + - 16659 + - 16660 + - 16661 + - 16662 + - 16663 + - 16664 + - 16665 + - 16666 + - 16667 + - 16668 + - 16669 + - 16670 + - 16671 + - 16672 + - 16673 + - 16674 + - 16675 + - 16676 + - 16677 + - 16678 + - 16679 + - 16680 + - 16681 + - 16682 + - 16683 + - 16684 + - 16685 + - 16686 + - 16687 + - 16688 + - 16689 + - 16690 + - 16691 + - 16692 + - 16693 + - 16694 + - 16695 + - 16696 + - 16697 + - 16698 + - 16699 + - 16700 + - 16701 + - 16702 + - 16703 + - 16704 + - 16705 + - 16706 + - 16707 + - 16708 + - 16709 + - 16710 + - 16711 + - 16712 + - 16713 + - 16714 + - 16715 + - 16716 + - 16717 + - 16718 + - 16719 + - 16720 + - 16721 + - 16722 + - 16723 + - 16724 + - 16725 + - 16726 + - 16727 + - 16728 + - 16729 + - 16730 + - 16731 + - 16732 + - 16733 + - 16734 + - 16735 + - 16736 + - 16737 + - 16738 + - 16739 + - 16740 + - 16741 + - 16742 + - 16743 + - 16744 + - 16745 + - 16746 + - 16747 + - 16748 + - 16749 + - 16750 + - 16751 + - 16752 + - 16753 + - 16754 + - 16755 + - 16756 + - 16757 + - 16758 + - 16759 + - 16760 + - 16761 + - 16762 + - 16763 + - 16764 + - 16765 + - 16766 + - 16767 + - 16768 + - 16769 + - 16770 + - 16771 + - 16772 + - 16773 + - 16774 + - 16775 + - 16776 + - 16777 + - 16778 + - 16779 + - 16780 + - 16781 + - 16782 + - 16783 + - 16784 + - 16785 + - 16786 + - 16787 + - 16788 + - 16789 + - 16790 + - 16791 + - 16792 + - 16793 + - 16794 + - 16795 + - 16796 + - 16797 + - 16798 + - 16799 + - 16800 + - 16801 + - 16802 + - 16803 + - 16804 + - 16805 + - 16806 + - 16807 + - 16808 + - 16809 + - 16810 + - 16811 + - 16812 + - 16813 + - 16814 + - 16815 + - 16816 + - 16817 + - 16818 + - 16819 + - 16820 + - 16821 + - 16822 + - 16823 + - 16824 + - 16825 + - 16826 + - 16827 + - 16828 + - 16829 + - 16830 + - 16831 + - 16832 + - 16833 + - 16834 + - 16835 + - 16836 + - 16837 + - 16838 + - 16839 + - 16840 + - 16841 + - 16842 + - 16843 + - 16844 + - 16845 + - 16846 + - 16847 + - 16848 + - 16849 + - 16850 + - 16851 + - 16852 + - 16853 + - 16854 + - 16855 + - 16856 + - 16857 + - 16858 + - 16859 + - 16860 + - 16861 + - 16862 + - 16863 + - 16864 + - 16865 + - 16866 + - 16867 + - 16868 + - 16869 + - 16870 + - 16871 + - 16872 + - 16873 + - 16874 + - 16875 + - 16876 + - 16877 + - 16878 + - 16879 + - 16880 + - 16881 + - 16882 + - 16883 + - 16884 + - 16885 + - 16886 + - 16887 + - 16888 + - 16889 + - 16890 + - 16891 + - 16892 + - 16893 + - 16894 + - 16895 + - 16896 + - 16897 + - 16898 + - 16899 + - 16900 + - 16901 + - 16902 + - 16903 + - 16904 + - 16905 + - 16906 + - 16907 + - 16908 + - 16909 + - 16910 + - 16911 + - 16912 + - 16913 + - 16914 + - 16915 + - 16916 + - 16917 + - 16918 + - 16919 + - 16920 + - 16921 + - 16922 + - 16923 + - 16924 + - 16925 + - 16926 + - 16927 + - 16928 + - 16929 + - 16930 + - 16931 + - 16932 + - 16933 + - 16934 + - 16935 + - 16936 + - 16937 + - 16938 + - 16939 + - 16940 + - 16941 + - 16942 + - 16943 + - 16944 + - 16945 + - 16946 + - 16947 + - 16948 + - 16949 + - 16950 + - 16951 + - 16952 + - 16953 + - 16954 + - 16955 + - 16956 + - 16957 + - 16958 + - 16959 + - 16960 + - 16961 + - 16962 + - 16963 + - 16964 + - 16965 + - 16966 + - 16967 + - 16968 + - 16969 + - 16970 + - 16971 + - 16972 + - 16973 + - 16974 + - 16975 + - 16976 + - 16977 + - 16978 + - 16979 + - 16980 + - 16981 + - 16982 + - 16983 + - 16984 + - 16985 + - 16986 + - 16987 + - 16988 + - 16989 + - 16990 + - 16991 + - 16992 + - 16993 + - 16994 + - 16995 + - 16996 + - 16997 + - 16998 + - 16999 + - 17000 + - 17001 + - 17002 + - 17003 + - 17004 + - 17005 + - 17006 + - 17007 + - 17008 + - 17009 + - 17010 + - 17011 + - 17012 + - 17013 + - 17014 + - 17015 + - 17016 + - 17017 + - 17018 + - 17019 + - 17020 + - 17021 + - 17022 + - 17023 + - 17024 + - 17025 + - 17026 + - 17027 + - 17028 + - 17029 + - 17030 + - 17031 + - 17032 + - 17033 + - 17034 + - 17035 + - 17036 + - 17037 + - 17038 + - 17039 + - 17040 + - 17041 + - 17042 + - 17043 + - 17044 + - 17045 + - 17046 + - 17047 + - 17048 + - 17049 + - 17050 + - 17051 + - 17052 + - 17053 + - 17054 + - 17055 + - 17056 + - 17057 + - 17058 + - 17059 + - 17060 + - 17061 + - 17062 + - 17063 + - 17064 + - 17065 + - 17066 + - 17067 + - 17068 + - 17069 + - 17070 + - 17071 + - 17072 + - 17073 + - 17074 + - 17075 + - 17076 + - 17077 + - 17078 + - 17079 + - 17080 + - 17081 + - 17082 + - 17083 + - 17084 + - 17085 + - 17086 + - 17087 + - 17088 + - 17089 + - 17090 + - 17091 + - 17092 + - 17093 + - 17094 + - 17095 + - 17096 + - 17097 + - 17098 + - 17099 + - 17100 + - 17101 + - 17102 + - 17103 + - 17104 + - 17105 + - 17106 + - 17107 + - 17108 + - 17109 + - 17110 + - 17111 + - 17112 + - 17113 + - 17114 + - 17115 + - 17116 + - 17117 + - 17118 + - 17119 + - 17120 + - 17121 + - 17122 + - 17123 + - 17124 + - 17125 + - 17126 + - 17127 + - 17128 + - 17129 + - 17130 + - 17131 + - 17132 + - 17133 + - 17134 + - 17135 + - 17136 + - 17137 + - 17138 + - 17139 + - 17140 + - 17141 + - 17142 + - 17143 + - 17144 + - 17145 + - 17146 + - 17147 + - 17148 + - 17149 + - 17150 + - 17151 + - 17152 + - 17153 + - 17154 + - 17155 + - 17156 + - 17157 + - 17158 + - 17159 + - 17160 + - 17161 + - 17162 + - 17163 + - 17164 + - 17165 + - 17166 + - 17167 + - 17168 + - 17169 + - 17170 + - 17171 + - 17172 + - 17173 + - 17174 + - 17175 + - 17176 + - 17177 + - 17178 + - 17179 + - 17180 + - 17181 + - 17182 + - 17183 + - 17184 + - 17185 + - 17186 + - 17187 + - 17188 + - 17189 + - 17190 + - 17191 + - 17192 + - 17193 + - 17194 + - 17195 + - 17196 + - 17197 + - 17198 + - 17199 + - 17200 + - 17201 + - 17202 + - 17203 + - 17204 + - 17205 + - 17206 + - 17207 + - 17208 + - 17209 + - 17210 + - 17211 + - 17212 + - 17213 + - 17214 + - 17215 + - 17216 + - 17217 + - 17218 + - 17219 + - 17220 + - 17221 + - 17222 + - 17223 + - 17224 + - 17225 + - 17226 + - 17227 + - 17228 + - 17229 + - 17230 + - 17231 + - 17232 + - 17233 + - 17234 + - 17235 + - 17236 + - 17237 + - 17238 + - 17239 + - 17240 + - 17241 + - 17242 + - 17243 + - 17244 + - 17245 + - 17246 + - 17247 + - 17248 + - 17249 + - 17250 + - 17251 + - 17252 + - 17253 + - 17254 + - 17255 + - 17256 + - 17257 + - 17258 + - 17259 + - 17260 + - 17261 + - 17262 + - 17263 + - 17264 + - 17265 + - 17266 + - 17267 + - 17268 + - 17269 + - 17270 + - 17271 + - 17272 + - 17273 + - 17274 + - 17275 + - 17276 + - 17277 + - 17278 + - 17279 + - 17280 + - 17281 + - 17282 + - 17283 + - 17284 + - 17285 + - 17286 + - 17287 + - 17288 + - 17289 + - 17290 + - 17291 + - 17292 + - 17293 + - 17294 + - 17295 + - 17296 + - 17297 + - 17298 + - 17299 + - 17300 + - 17301 + - 17302 + - 17303 + - 17304 + - 17305 + - 17306 + - 17307 + - 17308 + - 17309 + - 17310 + - 17311 + - 17312 + - 17313 + - 17314 + - 17315 + - 17316 + - 17317 + - 17318 + - 17319 + - 17320 + - 17321 + - 17322 + - 17323 + - 17324 + - 17325 + - 17326 + - 17327 + - 17328 + - 17329 + - 17330 + - 17331 + - 17332 + - 17333 + - 17334 + - 17335 + - 17336 + - 17337 + - 17338 + - 17339 + - 17340 + - 17341 + - 17342 + - 17343 + - 17344 + - 17345 + - 17346 + - 17347 + - 17348 + - 17349 + - 17350 + - 17351 + - 17352 + - 17353 + - 17354 + - 17355 + - 17356 + - 17357 + - 17358 + - 17359 + - 17360 + - 17361 + - 17362 + - 17363 + - 17364 + - 17365 + - 17366 + - 17367 + - 17368 + - 17369 + - 17370 + - 17371 + - 17372 + - 17373 + - 17374 + - 17375 + - 17376 + - 17377 + - 17378 + - 17379 + - 17380 + - 17381 + - 17382 + - 17383 + - 17384 + - 17385 + - 17386 + - 17387 + - 17388 + - 17389 + - 17390 + - 17391 + - 17392 + - 17393 + - 17394 + - 17395 + - 17396 + - 17397 + - 17398 + - 17399 + - 17400 + - 17401 + - 17402 + - 17403 + - 17404 + - 17405 + - 17406 + - 17407 + - 17408 + - 17409 + - 17410 + - 17411 + - 17412 + - 17413 + - 17414 + - 17415 + - 17416 + - 17417 + - 17418 + - 17419 + - 17420 + - 17421 + - 17422 + - 17423 + - 17424 + - 17425 + - 17426 + - 17427 + - 17428 + - 17429 + - 17430 + - 17431 + - 17432 + - 17433 + - 17434 + - 17435 + - 17436 + - 17437 + - 17438 + - 17439 + - 17440 + - 17441 + - 17442 + - 17443 + - 17444 + - 17445 + - 17446 + - 17447 + - 17448 + - 17449 + - 17450 + - 17451 + - 17452 + - 17453 + - 17454 + - 17455 + - 17456 + - 17457 + - 17458 + - 17459 + - 17460 + - 17461 + - 17462 + - 17463 + - 17464 + - 17465 + - 17466 + - 17467 + - 17468 + - 17469 + - 17470 + - 17471 + - 17472 + - 17473 + - 17474 + - 17475 + - 17476 + - 17477 + - 17478 + - 17479 + - 17480 + - 17481 + - 17482 + - 17483 + - 17484 + - 17485 + - 17486 + - 17487 + - 17488 + - 17489 + - 17490 + - 17491 + - 17492 + - 17493 + - 17494 + - 17495 + - 17496 + - 17497 + - 17498 + - 17499 + - 17500 + - 17501 + - 17502 + - 17503 + - 17504 + - 17505 + - 17506 + - 17507 + - 17508 + - 17509 + - 17510 + - 17511 + - 17512 + - 17513 + - 17514 + - 17515 + - 17516 + - 17517 + - 17518 + - 17519 + - 17520 + - 17521 + - 17522 + - 17523 + - 17524 + - 17525 + - 17526 + - 17527 + - 17528 + - 17529 + - 17530 + - 17531 + - 17532 + - 17533 + - 17534 + - 17535 + - 17536 + - 17537 + - 17538 + - 17539 + - 17540 + - 17541 + - 17542 + - 17543 + - 17544 + - 17545 + - 17546 + - 17547 + - 17548 + - 17549 + - 17550 + - 17551 + - 17552 + - 17553 + - 17554 + - 17555 + - 17556 + - 17557 + - 17558 + - 17559 + - 17560 + - 17561 + - 17562 + - 17563 + - 17564 + - 17565 + - 17566 + - 17567 + - 17568 + - 17569 + - 17570 + - 17571 + - 17572 + - 17573 + - 17574 + - 17575 + - 17576 + - 17577 + - 17578 + - 17579 + - 17580 + - 17581 + - 17582 + - 17583 + - 17584 + - 17585 + - 17586 + - 17587 + - 17588 + - 17589 + - 17590 + - 17591 + - 17592 + - 17593 + - 17594 + - 17595 + - 17596 + - 17597 + - 17598 + - 17599 + - 17600 + - 17601 + - 17602 + - 17603 + - 17604 + - 17605 + - 17606 + - 17607 + - 17608 + - 17609 + - 17610 + - 17611 + - 17612 + - 17613 + - 17614 + - 17615 + - 17616 + - 17617 + - 17618 + - 17619 + - 17620 + - 17621 + - 17622 + - 17623 + - 17624 + - 17625 + - 17626 + - 17627 + - 17628 + - 17629 + - 17630 + - 17631 + - 17632 + - 17633 + - 17634 + - 17635 + - 17636 + - 17637 + - 17638 + - 17639 + - 17640 + - 17641 + - 17642 + - 17643 + - 17644 + - 17645 + - 17646 + - 17647 + - 17648 + - 17649 + - 17650 + - 17651 + - 17652 + - 17653 + - 17654 + - 17655 + - 17656 + - 17657 + - 17658 + - 17659 + - 17660 + - 17661 + - 17662 + - 17663 + - 17664 + - 17665 + - 17666 + - 17667 + - 17668 + - 17669 + - 17670 + - 17671 + - 17672 + - 17673 + - 17674 + - 17675 + - 17676 + - 17677 + - 17678 + - 17679 + - 17680 + - 17681 + - 17682 + - 17683 + - 17684 + - 17685 + - 17686 + - 17687 + - 17688 + - 17689 + - 17690 + - 17691 + - 17692 + - 17693 + - 17694 + - 17695 + - 17696 + - 17697 + - 17698 + - 17699 + - 17700 + - 17701 + - 17702 + - 17703 + - 17704 + - 17705 + - 17706 + - 17707 + - 17708 + - 17709 + - 17710 + - 17711 + - 17712 + - 17713 + - 17714 + - 17715 + - 17716 + - 17717 + - 17718 + - 17719 + - 17720 + - 17721 + - 17722 + - 17723 + - 17724 + - 17725 + - 17726 + - 17727 + - 17728 + - 17729 + - 17730 + - 17731 + - 17732 + - 17733 + - 17734 + - 17735 + - 17736 + - 17737 + - 17738 + - 17739 + - 17740 + - 17741 + - 17742 + - 17743 + - 17744 + - 17745 + - 17746 + - 17747 + - 17748 + - 17749 + - 17750 + - 17751 + - 17752 + - 17753 + - 17754 + - 17755 + - 17756 + - 17757 + - 17758 + - 17759 + - 17760 + - 17761 + - 17762 + - 17763 + - 17764 + - 17765 + - 17766 + - 17767 + - 17768 + - 17769 + - 17770 + - 17771 + - 17772 + - 17773 + - 17774 + - 17775 + - 17776 + - 17777 + - 17778 + - 17779 + - 17780 + - 17781 + - 17782 + - 17783 + - 17784 + - 17785 + - 17786 + - 17787 + - 17788 + - 17789 + - 17790 + - 17791 + - 17792 + - 17793 + - 17794 + - 17795 + - 17796 + - 17797 + - 17798 + - 17799 + - 17800 + - 17801 + - 17802 + - 17803 + - 17804 + - 17805 + - 17806 + - 17807 + - 17808 + - 17809 + - 17810 + - 17811 + - 17812 + - 17813 + - 17814 + - 17815 + - 17816 + - 17817 + - 17818 + - 17819 + - 17820 + - 17821 + - 17822 + - 17823 + - 17824 + - 17825 + - 17826 + - 17827 + - 17828 + - 17829 + - 17830 + - 17831 + - 17832 + - 17833 + - 17834 + - 17835 + - 17836 + - 17837 + - 17838 + - 17839 + - 17840 + - 17841 + - 17842 + - 17843 + - 17844 + - 17845 + - 17846 + - 17847 + - 17848 + - 17849 + - 17850 + - 17851 + - 17852 + - 17853 + - 17854 + - 17855 + - 17856 + - 17857 + - 17858 + - 17859 + - 17860 + - 17861 + - 17862 + - 17863 + - 17864 + - 17865 + - 17866 + - 17867 + - 17868 + - 17869 + - 17870 + - 17871 + - 17872 + - 17873 + - 17874 + - 17875 + - 17876 + - 17877 + - 17878 + - 17879 + - 17880 + - 17881 + - 17882 + - 17883 + - 17884 + - 17885 + - 17886 + - 17887 + - 17888 + - 17889 + - 17890 + - 17891 + - 17892 + - 17893 + - 17894 + - 17895 + - 17896 + - 17897 + - 17898 + - 17899 + - 17900 + - 17901 + - 17902 + - 17903 + - 17904 + - 17905 + - 17906 + - 17907 + - 17908 + - 17909 + - 17910 + - 17911 + - 17912 + - 17913 + - 17914 + - 17915 + - 17916 + - 17917 + - 17918 + - 17919 + - 17920 + - 17921 + - 17922 + - 17923 + - 17924 + - 17925 + - 17926 + - 17927 + - 17928 + - 17929 + - 17930 + - 17931 + - 17932 + - 17933 + - 17934 + - 17935 + - 17936 + - 17937 + - 17938 + - 17939 + - 17940 + - 17941 + - 17942 + - 17943 + - 17944 + - 17945 + - 17946 + - 17947 + - 17948 + - 17949 + - 17950 + - 17951 + - 17952 + - 17953 + - 17954 + - 17955 + - 17956 + - 17957 + - 17958 + - 17959 + - 17960 + - 17961 + - 17962 + - 17963 + - 17964 + - 17965 + - 17966 + - 17967 + - 17968 + - 17969 + - 17970 + - 17971 + - 17972 + - 17973 + - 17974 + - 17975 + - 17976 + - 17977 + - 17978 + - 17979 + - 17980 + - 17981 + - 17982 + - 17983 + - 17984 + - 17985 + - 17986 + - 17987 + - 17988 + - 17989 + - 17990 + - 17991 + - 17992 + - 17993 + - 17994 + - 17995 + - 17996 + - 17997 + - 17998 + - 17999 + - 18000 + - 18001 + - 18002 + - 18003 + - 18004 + - 18005 + - 18006 + - 18007 + - 18008 + - 18009 + - 18010 + - 18011 + - 18012 + - 18013 + - 18014 + - 18015 + - 18016 + - 18017 + - 18018 + - 18019 + - 18020 + - 18021 + - 18022 + - 18023 + - 18024 + - 18025 + - 18026 + - 18027 + - 18028 + - 18029 + - 18030 + - 18031 + - 18032 + - 18033 + - 18034 + - 18035 + - 18036 + - 18037 + - 18038 + - 18039 + - 18040 + - 18041 + - 18042 + - 18043 + - 18044 + - 18045 + - 18046 + - 18047 + - 18048 + - 18049 + - 18050 + - 18051 + - 18052 + - 18053 + - 18054 + - 18055 + - 18056 + - 18057 + - 18058 + - 18059 + - 18060 + - 18061 + - 18062 + - 18063 + - 18064 + - 18065 + - 18066 + - 18067 + - 18068 + - 18069 + - 18070 + - 18071 + - 18072 + - 18073 + - 18074 + - 18075 + - 18076 + - 18077 + - 18078 + - 18079 + - 18080 + - 18081 + - 18082 + - 18083 + - 18084 + - 18085 + - 18086 + - 18087 + - 18088 + - 18089 + - 18090 + - 18091 + - 18092 + - 18093 + - 18094 + - 18095 + - 18096 + - 18097 + - 18098 + - 18099 + - 18100 + - 18101 + - 18102 + - 18103 + - 18104 + - 18105 + - 18106 + - 18107 + - 18108 + - 18109 + - 18110 + - 18111 + - 18112 + - 18113 + - 18114 + - 18115 + - 18116 + - 18117 + - 18118 + - 18119 + - 18120 + - 18121 + - 18122 + - 18123 + - 18124 + - 18125 + - 18126 + - 18127 + - 18128 + - 18129 + - 18130 + - 18131 + - 18132 + - 18133 + - 18134 + - 18135 + - 18136 + - 18137 + - 18138 + - 18139 + - 18140 + - 18141 + - 18142 + - 18143 + - 18144 + - 18145 + - 18146 + - 18147 + - 18148 + - 18149 + - 18150 + - 18151 + - 18152 + - 18153 + - 18154 + - 18155 + - 18156 + - 18157 + - 18158 + - 18159 + - 18160 + - 18161 + - 18162 + - 18163 + - 18164 + - 18165 + - 18166 + - 18167 + - 18168 + - 18169 + - 18170 + - 18171 + - 18172 + - 18173 + - 18174 + - 18175 + - 18176 + - 18177 + - 18178 + - 18179 + - 18180 + - 18181 + - 18182 + - 18183 + - 18184 + - 18185 + - 18186 + - 18187 + - 18188 + - 18189 + - 18190 + - 18191 + - 18192 + - 18193 + - 18194 + - 18195 + - 18196 + - 18197 + - 18198 + - 18199 + - 18200 + - 18201 + - 18202 + - 18203 + - 18204 + - 18205 + - 18206 + - 18207 + - 18208 + - 18209 + - 18210 + - 18211 + - 18212 + - 18213 + - 18214 + - 18215 + - 18216 + - 18217 + - 18218 + - 18219 + - 18220 + - 18221 + - 18222 + - 18223 + - 18224 + - 18225 + - 18226 + - 18227 + - 18228 + - 18229 + - 18230 + - 18231 + - 18232 + - 18233 + - 18234 + - 18235 + - 18236 + - 18237 + - 18238 + - 18239 + - 18240 + - 18241 + - 18242 + - 18243 + - 18244 + - 18245 + - 18246 + - 18247 + - 18248 + - 18249 + - 18250 + - 18251 + - 18252 + - 18253 + - 18254 + - 18255 + - 18256 + - 18257 + - 18258 + - 18259 + - 18260 + - 18261 + - 18262 + - 18263 + - 18264 + - 18265 + - 18266 + - 18267 + - 18268 + - 18269 + - 18270 + - 18271 + - 18272 + - 18273 + - 18274 + - 18275 + - 18276 + - 18277 + - 18278 + - 18279 + - 18280 + - 18281 + - 18282 + - 18283 + - 18284 + - 18285 + - 18286 + - 18287 + - 18288 + - 18289 + - 18290 + - 18291 + - 18292 + - 18293 + - 18294 + - 18295 + - 18296 + - 18297 + - 18298 + - 18299 + - 18300 + - 18301 + - 18302 + - 18303 + - 18304 + - 18305 + - 18306 + - 18307 + - 18308 + - 18309 + - 18310 + - 18311 + - 18312 + - 18313 + - 18314 + - 18315 + - 18316 + - 18317 + - 18318 + - 18319 + - 18320 + - 18321 + - 18322 + - 18323 + - 18324 + - 18325 + - 18326 + - 18327 + - 18328 + - 18329 + - 18330 + - 18331 + - 18332 + - 18333 + - 18334 + - 18335 + - 18336 + - 18337 + - 18338 + - 18339 + - 18340 + - 18341 + - 18342 + - 18343 + - 18344 + - 18345 + - 18346 + - 18347 + - 18348 + - 18349 + - 18350 + - 18351 + - 18352 + - 18353 + - 18354 + - 18355 + - 18356 + - 18357 + - 18358 + - 18359 + - 18360 + - 18361 + - 18362 + - 18363 + - 18364 + - 18365 + - 18366 + - 18367 + - 18368 + - 18369 + - 18370 + - 18371 + - 18372 + - 18373 + - 18374 + - 18375 + - 18376 + - 18377 + - 18378 + - 18379 + - 18380 + - 18381 + - 18382 + - 18383 + - 18384 + - 18385 + - 18386 + - 18387 + - 18388 + - 18389 + - 18390 + - 18391 + - 18392 + - 18393 + - 18394 + - 18395 + - 18396 + - 18397 + - 18398 + - 18399 + - 18400 + - 18401 + - 18402 + - 18403 + - 18404 + - 18405 + - 18406 + - 18407 + - 18408 + - 18409 + - 18410 + - 18411 + - 18412 + - 18413 + - 18414 + - 18415 + - 18416 + - 18417 + - 18418 + - 18419 + - 18420 + - 18421 + - 18422 + - 18423 + - 18424 + - 18425 + - 18426 + - 18427 + - 18428 + - 18429 + - 18430 + - 18431 + - 18432 + - 18433 + - 18434 + - 18435 + - 18436 + - 18437 + - 18438 + - 18439 + - 18440 + - 18441 + - 18442 + - 18443 + - 18444 + - 18445 + - 18446 + - 18447 + - 18448 + - 18449 + - 18450 + - 18451 + - 18452 + - 18453 + - 18454 + - 18455 + - 18456 + - 18457 + - 18458 + - 18459 + - 18460 + - 18461 + - 18462 + - 18463 + - 18464 + - 18465 + - 18466 + - 18467 + - 18468 + - 18469 + - 18470 + - 18471 + - 18472 + - 18473 + - 18474 + - 18475 + - 18476 + - 18477 + - 18478 + - 18479 + - 18480 + - 18481 + - 18482 + - 18483 + - 18484 + - 18485 + - 18486 + - 18487 + - 18488 + - 18489 + - 18490 + - 18491 + - 18492 + - 18493 + - 18494 + - 18495 + - 18496 + - 18497 + - 18498 + - 18499 + - 18500 + - 18501 + - 18502 + - 18503 + - 18504 + - 18505 + - 18506 + - 18507 + - 18508 + - 18509 + - 18510 + - 18511 + - 18512 + - 18513 + - 18514 + - 18515 + - 18516 + - 18517 + - 18518 + - 18519 + - 18520 + - 18521 + - 18522 + - 18523 + - 18524 + - 18525 + - 18526 + - 18527 + - 18528 + - 18529 + - 18530 + - 18531 + - 18532 + - 18533 + - 18534 + - 18535 + - 18536 + - 18537 + - 18538 + - 18539 + - 18540 + - 18541 + - 18542 + - 18543 + - 18544 + - 18545 + - 18546 + - 18547 + - 18548 + - 18549 + - 18550 + - 18551 + - 18552 + - 18553 + - 18554 + - 18555 + - 18556 + - 18557 + - 18558 + - 18559 + - 18560 + - 18561 + - 18562 + - 18563 + - 18564 + - 18565 + - 18566 + - 18567 + - 18568 + - 18569 + - 18570 + - 18571 + - 18572 + - 18573 + - 18574 + - 18575 + - 18576 + - 18577 + - 18578 + - 18579 + - 18580 + - 18581 + - 18582 + - 18583 + - 18584 + - 18585 + - 18586 + - 18587 + - 18588 + - 18589 + - 18590 + - 18591 + - 18592 + - 18593 + - 18594 + - 18595 + - 18596 + - 18597 + - 18598 + - 18599 + - 18600 + - 18601 + - 18602 + - 18603 + - 18604 + - 18605 + - 18606 + - 18607 + - 18608 + - 18609 + - 18610 + - 18611 + - 18612 + - 18613 + - 18614 + - 18615 + - 18616 + - 18617 + - 18618 + - 18619 + - 18620 + - 18621 + - 18622 + - 18623 + - 18624 + - 18625 + - 18626 + - 18627 + - 18628 + - 18629 + - 18630 + - 18631 + - 18632 + - 18633 + - 18634 + - 18635 + - 18636 + - 18637 + - 18638 + - 18639 + - 18640 + - 18641 + - 18642 + - 18643 + - 18644 + - 18645 + - 18646 + - 18647 + - 18648 + - 18649 + - 18650 + - 18651 + - 18652 + - 18653 + - 18654 + - 18655 + - 18656 + - 18657 + - 18658 + - 18659 + - 18660 + - 18661 + - 18662 + - 18663 + - 18664 + - 18665 + - 18666 + - 18667 + - 18668 + - 18669 + - 18670 + - 18671 + - 18672 + - 18673 + - 18674 + - 18675 + - 18676 + - 18677 + - 18678 + - 18679 + - 18680 + - 18681 + - 18682 + - 18683 + - 18684 + - 18685 + - 18686 + - 18687 + - 18688 + - 18689 + - 18690 + - 18691 + - 18692 + - 18693 + - 18694 + - 18695 + - 18696 + - 18697 + - 18698 + - 18699 + - 18700 + - 18701 + - 18702 + - 18703 + - 18704 + - 18705 + - 18706 + - 18707 + - 18708 + - 18709 + - 18710 + - 18711 + - 18712 + - 18713 + - 18714 + - 18715 + - 18716 + - 18717 + - 18718 + - 18719 + - 18720 + - 18721 + - 18722 + - 18723 + - 18724 + - 18725 + - 18726 + - 18727 + - 18728 + - 18729 + - 18730 + - 18731 + - 18732 + - 18733 + - 18734 + - 18735 + - 18736 + - 18737 + - 18738 + - 18739 + - 18740 + - 18741 + - 18742 + - 18743 + - 18744 + - 18745 + - 18746 + - 18747 + - 18748 + - 18749 + - 18750 + - 18751 + - 18752 + - 18753 + - 18754 + - 18755 + - 18756 + - 18757 + - 18758 + - 18759 + - 18760 + - 18761 + - 18762 + - 18763 + - 18764 + - 18765 + - 18766 + - 18767 + - 18768 + - 18769 + - 18770 + - 18771 + - 18772 + - 18773 + - 18774 + - 18775 + - 18776 + - 18777 + - 18778 + - 18779 + - 18780 + - 18781 + - 18782 + - 18783 + - 18784 + - 18785 + - 18786 + - 18787 + - 18788 + - 18789 + - 18790 + - 18791 + - 18792 + - 18793 + - 18794 + - 18795 + - 18796 + - 18797 + - 18798 + - 18799 + - 18800 + - 18801 + - 18802 + - 18803 + - 18804 + - 18805 + - 18806 + - 18807 + - 18808 + - 18809 + - 18810 + - 18811 + - 18812 + - 18813 + - 18814 + - 18815 + - 18816 + - 18817 + - 18818 + - 18819 + - 18820 + - 18821 + - 18822 + - 18823 + - 18824 + - 18825 + - 18826 + - 18827 + - 18828 + - 18829 + - 18830 + - 18831 + - 18832 + - 18833 + - 18834 + - 18835 + - 18836 + - 18837 + - 18838 + - 18839 + - 18840 + - 18841 + - 18842 + - 18843 + - 18844 + - 18845 + - 18846 + - 18847 + - 18848 + - 18849 + - 18850 + - 18851 + - 18852 + - 18853 + - 18854 + - 18855 + - 18856 + - 18857 + - 18858 + - 18859 + - 18860 + - 18861 + - 18862 + - 18863 + - 18864 + - 18865 + - 18866 + - 18867 + - 18868 + - 18869 + - 18870 + - 18871 + - 18872 + - 18873 + - 18874 + - 18875 + - 18876 + - 18877 + - 18878 + - 18879 + - 18880 + - 18881 + - 18882 + - 18883 + - 18884 + - 18885 + - 18886 + - 18887 + - 18888 + - 18889 + - 18890 + - 18891 + - 18892 + - 18893 + - 18894 + - 18895 + - 18896 + - 18897 + - 18898 + - 18899 + - 18900 + - 18901 + - 18902 + - 18903 + - 18904 + - 18905 + - 18906 + - 18907 + - 18908 + - 18909 + - 18910 + - 18911 + - 18912 + - 18913 + - 18914 + - 18915 + - 18916 + - 18917 + - 18918 + - 18919 + - 18920 + - 18921 + - 18922 + - 18923 + - 18924 + - 18925 + - 18926 + - 18927 + - 18928 + - 18929 + - 18930 + - 18931 + - 18932 + - 18933 + - 18934 + - 18935 + - 18936 + - 18937 + - 18938 + - 18939 + - 18940 + - 18941 + - 18942 + - 18943 + - 18944 + - 18945 + - 18946 + - 18947 + - 18948 + - 18949 + - 18950 + - 18951 + - 18952 + - 18953 + - 18954 + - 18955 + - 18956 + - 18957 + - 18958 + - 18959 + - 18960 + - 18961 + - 18962 + - 18963 + - 18964 + - 18965 + - 18966 + - 18967 + - 18968 + - 18969 + - 18970 + - 18971 + - 18972 + - 18973 + - 18974 + - 18975 + - 18976 + - 18977 + - 18978 + - 18979 + - 18980 + - 18981 + - 18982 + - 18983 + - 18984 + - 18985 + - 18986 + - 18987 + - 18988 + - 18989 + - 18990 + - 18991 + - 18992 + - 18993 + - 18994 + - 18995 + - 18996 + - 18997 + - 18998 + - 18999 + - 19000 + - 19001 + - 19002 + - 19003 + - 19004 + - 19005 + - 19006 + - 19007 + - 19008 + - 19009 + - 19010 + - 19011 + - 19012 + - 19013 + - 19014 + - 19015 + - 19016 + - 19017 + - 19018 + - 19019 + - 19020 + - 19021 + - 19022 + - 19023 + - 19024 + - 19025 + - 19026 + - 19027 + - 19028 + - 19029 + - 19030 + - 19031 + - 19032 + - 19033 + - 19034 + - 19035 + - 19036 + - 19037 + - 19038 + - 19039 + - 19040 + - 19041 + - 19042 + - 19043 + - 19044 + - 19045 + - 19046 + - 19047 + - 19048 + - 19049 + - 19050 + - 19051 + - 19052 + - 19053 + - 19054 + - 19055 + - 19056 + - 19057 + - 19058 + - 19059 + - 19060 + - 19061 + - 19062 + - 19063 + - 19064 + - 19065 + - 19066 + - 19067 + - 19068 + - 19069 + - 19070 + - 19071 + - 19072 + - 19073 + - 19074 + - 19075 + - 19076 + - 19077 + - 19078 + - 19079 + - 19080 + - 19081 + - 19082 + - 19083 + - 19084 + - 19085 + - 19086 + - 19087 + - 19088 + - 19089 + - 19090 + - 19091 + - 19092 + - 19093 + - 19094 + - 19095 + - 19096 + - 19097 + - 19098 + - 19099 + - 19100 + - 19101 + - 19102 + - 19103 + - 19104 + - 19105 + - 19106 + - 19107 + - 19108 + - 19109 + - 19110 + - 19111 + - 19112 + - 19113 + - 19114 + - 19115 + - 19116 + - 19117 + - 19118 + - 19119 + - 19120 + - 19121 + - 19122 + - 19123 + - 19124 + - 19125 + - 19126 + - 19127 + - 19128 + - 19129 + - 19130 + - 19131 + - 19132 + - 19133 + - 19134 + - 19135 + - 19136 + - 19137 + - 19138 + - 19139 + - 19140 + - 19141 + - 19142 + - 19143 + - 19144 + - 19145 + - 19146 + - 19147 + - 19148 + - 19149 + - 19150 + - 19151 + - 19152 + - 19153 + - 19154 + - 19155 + - 19156 + - 19157 + - 19158 + - 19159 + - 19160 + - 19161 + - 19162 + - 19163 + - 19164 + - 19165 + - 19166 + - 19167 + - 19168 + - 19169 + - 19170 + - 19171 + - 19172 + - 19173 + - 19174 + - 19175 + - 19176 + - 19177 + - 19178 + - 19179 + - 19180 + - 19181 + - 19182 + - 19183 + - 19184 + - 19185 + - 19186 + - 19187 + - 19188 + - 19189 + - 19190 + - 19191 + - 19192 + - 19193 + - 19194 + - 19195 + - 19196 + - 19197 + - 19198 + - 19199 + - 19200 + - 19201 + - 19202 + - 19203 + - 19204 + - 19205 + - 19206 + - 19207 + - 19208 + - 19209 + - 19210 + - 19211 + - 19212 + - 19213 + - 19214 + - 19215 + - 19216 + - 19217 + - 19218 + - 19219 + - 19220 + - 19221 + - 19222 + - 19223 + - 19224 + - 19225 + - 19226 + - 19227 + - 19228 + - 19229 + - 19230 + - 19231 + - 19232 + - 19233 + - 19234 + - 19235 + - 19236 + - 19237 + - 19238 + - 19239 + - 19240 + - 19241 + - 19242 + - 19243 + - 19244 + - 19245 + - 19246 + - 19247 + - 19248 + - 19249 + - 19250 + - 19251 + - 19252 + - 19253 + - 19254 + - 19255 + - 19256 + - 19257 + - 19258 + - 19259 + - 19260 + - 19261 + - 19262 + - 19263 + - 19264 + - 19265 + - 19266 + - 19267 + - 19268 + - 19269 + - 19270 + - 19271 + - 19272 + - 19273 + - 19274 + - 19275 + - 19276 + - 19277 + - 19278 + - 19279 + - 19280 + - 19281 + - 19282 + - 19283 + - 19284 + - 19285 + - 19286 + - 19287 + - 19288 + - 19289 + - 19290 + - 19291 + - 19292 + - 19293 + - 19294 + - 19295 + - 19296 + - 19297 + - 19298 + - 19299 + - 19300 + - 19301 + - 19302 + - 19303 + - 19304 + - 19305 + - 19306 + - 19307 + - 19308 + - 19309 + - 19310 + - 19311 + - 19312 + - 19313 + - 19314 + - 19315 + - 19316 + - 19317 + - 19318 + - 19319 + - 19320 + - 19321 + - 19322 + - 19323 + - 19324 + - 19325 + - 19326 + - 19327 + - 19328 + - 19329 + - 19330 + - 19331 + - 19332 + - 19333 + - 19334 + - 19335 + - 19336 + - 19337 + - 19338 + - 19339 + - 19340 + - 19341 + - 19342 + - 19343 + - 19344 + - 19345 + - 19346 + - 19347 + - 19348 + - 19349 + - 19350 + - 19351 + - 19352 + - 19353 + - 19354 + - 19355 + - 19356 + - 19357 + - 19358 + - 19359 + - 19360 + - 19361 + - 19362 + - 19363 + - 19364 + - 19365 + - 19366 + - 19367 + - 19368 + - 19369 + - 19370 + - 19371 + - 19372 + - 19373 + - 19374 + - 19375 + - 19376 + - 19377 + - 19378 + - 19379 + - 19380 + - 19381 + - 19382 + - 19383 + - 19384 + - 19385 + - 19386 + - 19387 + - 19388 + - 19389 + - 19390 + - 19391 + - 19392 + - 19393 + - 19394 + - 19395 + - 19396 + - 19397 + - 19398 + - 19399 + - 19400 + - 19401 + - 19402 + - 19403 + - 19404 + - 19405 + - 19406 + - 19407 + - 19408 + - 19409 + - 19410 + - 19411 + - 19412 + - 19413 + - 19414 + - 19415 + - 19416 + - 19417 + - 19418 + - 19419 + - 19420 + - 19421 + - 19422 + - 19423 + - 19424 + - 19425 + - 19426 + - 19427 + - 19428 + - 19429 + - 19430 + - 19431 + - 19432 + - 19433 + - 19434 + - 19435 + - 19436 + - 19437 + - 19438 + - 19439 + - 19440 + - 19441 + - 19442 + - 19443 + - 19444 + - 19445 + - 19446 + - 19447 + - 19448 + - 19449 + - 19450 + - 19451 + - 19452 + - 19453 + - 19454 + - 19455 + - 19456 + - 19457 + - 19458 + - 19459 + - 19460 + - 19461 + - 19462 + - 19463 + - 19464 + - 19465 + - 19466 + - 19467 + - 19468 + - 19469 + - 19470 + - 19471 + - 19472 + - 19473 + - 19474 + - 19475 + - 19476 + - 19477 + - 19478 + - 19479 + - 19480 + - 19481 + - 19482 + - 19483 + - 19484 + - 19485 + - 19486 + - 19487 + - 19488 + - 19489 + - 19490 + - 19491 + - 19492 + - 19493 + - 19494 + - 19495 + - 19496 + - 19497 + - 19498 + - 19499 + - 19500 + - 19501 + - 19502 + - 19503 + - 19504 + - 19505 + - 19506 + - 19507 + - 19508 + - 19509 + - 19510 + - 19511 + - 19512 + - 19513 + - 19514 + - 19515 + - 19516 + - 19517 + - 19518 + - 19519 + - 19520 + - 19521 + - 19522 + - 19523 + - 19524 + - 19525 + - 19526 + - 19527 + - 19528 + - 19529 + - 19530 + - 19531 + - 19532 + - 19533 + - 19534 + - 19535 + - 19536 + - 19537 + - 19538 + - 19539 + - 19540 + - 19541 + - 19542 + - 19543 + - 19544 + - 19545 + - 19546 + - 19547 + - 19548 + - 19549 + - 19550 + - 19551 + - 19552 + - 19553 + - 19554 + - 19555 + - 19556 + - 19557 + - 19558 + - 19559 + - 19560 + - 19561 + - 19562 + - 19563 + - 19564 + - 19565 + - 19566 + - 19567 + - 19568 + - 19569 + - 19570 + - 19571 + - 19572 + - 19573 + - 19574 + - 19575 + - 19576 + - 19577 + - 19578 + - 19579 + - 19580 + - 19581 + - 19582 + - 19583 + - 19584 + - 19585 + - 19586 + - 19587 + - 19588 + - 19589 + - 19590 + - 19591 + - 19592 + - 19593 + - 19594 + - 19595 + - 19596 + - 19597 + - 19598 + - 19599 + - 19600 + - 19601 + - 19602 + - 19603 + - 19604 + - 19605 + - 19606 + - 19607 + - 19608 + - 19609 + - 19610 + - 19611 + - 19612 + - 19613 + - 19614 + - 19615 + - 19616 + - 19617 + - 19618 + - 19619 + - 19620 + - 19621 + - 19622 + - 19623 + - 19624 + - 19625 + - 19626 + - 19627 + - 19628 + - 19629 + - 19630 + - 19631 + - 19632 + - 19633 + - 19634 + - 19635 + - 19636 + - 19637 + - 19638 + - 19639 + - 19640 + - 19641 + - 19642 + - 19643 + - 19644 + - 19645 + - 19646 + - 19647 + - 19648 + - 19649 + - 19650 + - 19651 + - 19652 + - 19653 + - 19654 + - 19655 + - 19656 + - 19657 + - 19658 + - 19659 + - 19660 + - 19661 + - 19662 + - 19663 + - 19664 + - 19665 + - 19666 + - 19667 + - 19668 + - 19669 + - 19670 + - 19671 + - 19672 + - 19673 + - 19674 + - 19675 + - 19676 + - 19677 + - 19678 + - 19679 + - 19680 + - 19681 + - 19682 + - 19683 + - 19684 + - 19685 + - 19686 + - 19687 + - 19688 + - 19689 + - 19690 + - 19691 + - 19692 + - 19693 + - 19694 + - 19695 + - 19696 + - 19697 + - 19698 + - 19699 + - 19700 + - 19701 + - 19702 + - 19703 + - 19704 + - 19705 + - 19706 + - 19707 + - 19708 + - 19709 + - 19710 + - 19711 + - 19712 + - 19713 + - 19714 + - 19715 + - 19716 + - 19717 + - 19718 + - 19719 + - 19720 + - 19721 + - 19722 + - 19723 + - 19724 + - 19725 + - 19726 + - 19727 + - 19728 + - 19729 + - 19730 + - 19731 + - 19732 + - 19733 + - 19734 + - 19735 + - 19736 + - 19737 + - 19738 + - 19739 + - 19740 + - 19741 + - 19742 + - 19743 + - 19744 + - 19745 + - 19746 + - 19747 + - 19748 + - 19749 + - 19750 + - 19751 + - 19752 + - 19753 + - 19754 + - 19755 + - 19756 + - 19757 + - 19758 + - 19759 + - 19760 + - 19761 + - 19762 + - 19763 + - 19764 + - 19765 + - 19766 + - 19767 + - 19768 + - 19769 + - 19770 + - 19771 + - 19772 + - 19773 + - 19774 + - 19775 + - 19776 + - 19777 + - 19778 + - 19779 + - 19780 + - 19781 + - 19782 + - 19783 + - 19784 + - 19785 + - 19786 + - 19787 + - 19788 + - 19789 + - 19790 + - 19791 + - 19792 + - 19793 + - 19794 + - 19795 + - 19796 + - 19797 + - 19798 + - 19799 + - 19800 + - 19801 + - 19802 + - 19803 + - 19804 + - 19805 + - 19806 + - 19807 + - 19808 + - 19809 + - 19810 + - 19811 + - 19812 + - 19813 + - 19814 + - 19815 + - 19816 + - 19817 + - 19818 + - 19819 + - 19820 + - 19821 + - 19822 + - 19823 + - 19824 + - 19825 + - 19826 + - 19827 + - 19828 + - 19829 + - 19830 + - 19831 + - 19832 + - 19833 + - 19834 + - 19835 + - 19836 + - 19837 + - 19838 + - 19839 + - 19840 + - 19841 + - 19842 + - 19843 + - 19844 + - 19845 + - 19846 + - 19847 + - 19848 + - 19849 + - 19850 + - 19851 + - 19852 + - 19853 + - 19854 + - 19855 + - 19856 + - 19857 + - 19858 + - 19859 + - 19860 + - 19861 + - 19862 + - 19863 + - 19864 + - 19865 + - 19866 + - 19867 + - 19868 + - 19869 + - 19870 + - 19871 + - 19872 + - 19873 + - 19874 + - 19875 + - 19876 + - 19877 + - 19878 + - 19879 + - 19880 + - 19881 + - 19882 + - 19883 + - 19884 + - 19885 + - 19886 + - 19887 + - 19888 + - 19889 + - 19890 + - 19891 + - 19892 + - 19893 + - 19894 + - 19895 + - 19896 + - 19897 + - 19898 + - 19899 + - 19900 + - 19901 + - 19902 + - 19903 + - 19904 + - 19905 + - 19906 + - 19907 + - 19908 + - 19909 + - 19910 + - 19911 + - 19912 + - 19913 + - 19914 + - 19915 + - 19916 + - 19917 + - 19918 + - 19919 + - 19920 + - 19921 + - 19922 + - 19923 + - 19924 + - 19925 + - 19926 + - 19927 + - 19928 + - 19929 + - 19930 + - 19931 + - 19932 + - 19933 + - 19934 + - 19935 + - 19936 + - 19937 + - 19938 + - 19939 + - 19940 + - 19941 + - 19942 + - 19943 + - 19944 + - 19945 + - 19946 + - 19947 + - 19948 + - 19949 + - 19950 + - 19951 + - 19952 + - 19953 + - 19954 + - 19955 + - 19956 + - 19957 + - 19958 + - 19959 + - 19960 + - 19961 + - 19962 + - 19963 + - 19964 + - 19965 + - 19966 + - 19967 + - 19968 + - 19969 + - 19970 + - 19971 + - 19972 + - 19973 + - 19974 + - 19975 + - 19976 + - 19977 + - 19978 + - 19979 + - 19980 + - 19981 + - 19982 + - 19983 + - 19984 + - 19985 + - 19986 + - 19987 + - 19988 + - 19989 + - 19990 + - 19991 + - 19992 + - 19993 + - 19994 + - 19995 + - 19996 + - 19997 + - 19998 + - 19999 + - 20000 + - 20001 + - 20002 + - 20003 + - 20004 + - 20005 + - 20006 + - 20007 + - 20008 + - 20009 + - 20010 + - 20011 + - 20012 + - 20013 + - 20014 + - 20015 + - 20016 + - 20017 + - 20018 + - 20019 + - 20020 + - 20021 + - 20022 + - 20023 + - 20024 + - 20025 + - 20026 + - 20027 + - 20028 + - 20029 + - 20030 + - 20031 + - 20032 + - 20033 + - 20034 + - 20035 + - 20036 + - 20037 + - 20038 + - 20039 + - 20040 + - 20041 + - 20042 + - 20043 + - 20044 + - 20045 + - 20046 + - 20047 + - 20048 + - 20049 + - 20050 + - 20051 + - 20052 + - 20053 + - 20054 + - 20055 + - 20056 + - 20057 + - 20058 + - 20059 + - 20060 + - 20061 + - 20062 + - 20063 + - 20064 + - 20065 + - 20066 + - 20067 + - 20068 + - 20069 + - 20070 + - 20071 + - 20072 + - 20073 + - 20074 + - 20075 + - 20076 + - 20077 + - 20078 + - 20079 + - 20080 + - 20081 + - 20082 + - 20083 + - 20084 + - 20085 + - 20086 + - 20087 + - 20088 + - 20089 + - 20090 + - 20091 + - 20092 + - 20093 + - 20094 + - 20095 + - 20096 + - 20097 + - 20098 + - 20099 + - 20100 + - 20101 + - 20102 + - 20103 + - 20104 + - 20105 + - 20106 + - 20107 + - 20108 + - 20109 + - 20110 + - 20111 + - 20112 + - 20113 + - 20114 + - 20115 + - 20116 + - 20117 + - 20118 + - 20119 + - 20120 + - 20121 + - 20122 + - 20123 + - 20124 + - 20125 + - 20126 + - 20127 + - 20128 + - 20129 + - 20130 + - 20131 + - 20132 + - 20133 + - 20134 + - 20135 + - 20136 + - 20137 + - 20138 + - 20139 + - 20140 + - 20141 + - 20142 + - 20143 + - 20144 + - 20145 + - 20146 + - 20147 + - 20148 + - 20149 + - 20150 + - 20151 + - 20152 + - 20153 + - 20154 + - 20155 + - 20156 + - 20157 + - 20158 + - 20159 + - 20160 + - 20161 + - 20162 + - 20163 + - 20164 + - 20165 + - 20166 + - 20167 + - 20168 + - 20169 + - 20170 + - 20171 + - 20172 + - 20173 + - 20174 + - 20175 + - 20176 + - 20177 + - 20178 + - 20179 + - 20180 + - 20181 + - 20182 + - 20183 + - 20184 + - 20185 + - 20186 + - 20187 + - 20188 + - 20189 + - 20190 + - 20191 + - 20192 + - 20193 + - 20194 + - 20195 + - 20196 + - 20197 + - 20198 + - 20199 + - 20200 + - 20201 + - 20202 + - 20203 + - 20204 + - 20205 + - 20206 + - 20207 + - 20208 + - 20209 + - 20210 + - 20211 + - 20212 + - 20213 + - 20214 + - 20215 + - 20216 + - 20217 + - 20218 + - 20219 + - 20220 + - 20221 + - 20222 + - 20223 + - 20224 + - 20225 + - 20226 + - 20227 + - 20228 + - 20229 + - 20230 + - 20231 + - 20232 + - 20233 + - 20234 + - 20235 + - 20236 + - 20237 + - 20238 + - 20239 + - 20240 + - 20241 + - 20242 + - 20243 + - 20244 + - 20245 + - 20246 + - 20247 + - 20248 + - 20249 + - 20250 + - 20251 + - 20252 + - 20253 + - 20254 + - 20255 + - 20256 + - 20257 + - 20258 + - 20259 + - 20260 + - 20261 + - 20262 + - 20263 + - 20264 + - 20265 + - 20266 + - 20267 + - 20268 + - 20269 + - 20270 + - 20271 + - 20272 + - 20273 + - 20274 + - 20275 + - 20276 + - 20277 + - 20278 + - 20279 + - 20280 + - 20281 + - 20282 + - 20283 + - 20284 + - 20285 + - 20286 + - 20287 + - 20288 + - 20289 + - 20290 + - 20291 + - 20292 + - 20293 + - 20294 + - 20295 + - 20296 + - 20297 + - 20298 + - 20299 + - 20300 + - 20301 + - 20302 + - 20303 + - 20304 + - 20305 + - 20306 + - 20307 + - 20308 + - 20309 + - 20310 + - 20311 + - 20312 + - 20313 + - 20314 + - 20315 + - 20316 + - 20317 + - 20318 + - 20319 + - 20320 + - 20321 + - 20322 + - 20323 + - 20324 + - 20325 + - 20326 + - 20327 + - 20328 + - 20329 + - 20330 + - 20331 + - 20332 + - 20333 + - 20334 + - 20335 + - 20336 + - 20337 + - 20338 + - 20339 + - 20340 + - 20341 + - 20342 + - 20343 + - 20344 + - 20345 + - 20346 + - 20347 + - 20348 + - 20349 + - 20350 + - 20351 + - 20352 + - 20353 + - 20354 + - 20355 + - 20356 + - 20357 + - 20358 + - 20359 + - 20360 + - 20361 + - 20362 + - 20363 + - 20364 + - 20365 + - 20366 + - 20367 + - 20368 + - 20369 + - 20370 + - 20371 + - 20372 + - 20373 + - 20374 + - 20375 + - 20376 + - 20377 + - 20378 + - 20379 + - 20380 + - 20381 + - 20382 + - 20383 + - 20384 + - 20385 + - 20386 + - 20387 + - 20388 + - 20389 + - 20390 + - 20391 + - 20392 + - 20393 + - 20394 + - 20395 + - 20396 + - 20397 + - 20398 + - 20399 + - 20400 + - 20401 + - 20402 + - 20403 + - 20404 + - 20405 + - 20406 + - 20407 + - 20408 + - 20409 + - 20410 + - 20411 + - 20412 + - 20413 + - 20414 + - 20415 + - 20416 + - 20417 + - 20418 + - 20419 + - 20420 + - 20421 + - 20422 + - 20423 + - 20424 + - 20425 + - 20426 + - 20427 + - 20428 + - 20429 + - 20430 + - 20431 + - 20432 + - 20433 + - 20434 + - 20435 + - 20436 + - 20437 + - 20438 + - 20439 + - 20440 + - 20441 + - 20442 + - 20443 + - 20444 + - 20445 + - 20446 + - 20447 + - 20448 + - 20449 + - 20450 + - 20451 + - 20452 + - 20453 + - 20454 + - 20455 + - 20456 + - 20457 + - 20458 + - 20459 + - 20460 + - 20461 + - 20462 + - 20463 + - 20464 + - 20465 + - 20466 + - 20467 + - 20468 + - 20469 + - 20470 + - 20471 + - 20472 + - 20473 + - 20474 + - 20475 + - 20476 + - 20477 + - 20478 + - 20479 + - 20480 + - 20481 + - 20482 + - 20483 + - 20484 + - 20485 + - 20486 + - 20487 + - 20488 + - 20489 + - 20490 + - 20491 + - 20492 + - 20493 + - 20494 + - 20495 + - 20496 + - 20497 + - 20498 + - 20499 + - 20500 + - 20501 + - 20502 + - 20503 + - 20504 + - 20505 + - 20506 + - 20507 + - 20508 + - 20509 + - 20510 + - 20511 + - 20512 + - 20513 + - 20514 + - 20515 + - 20516 + - 20517 + - 20518 + - 20519 + - 20520 + - 20521 + - 20522 + - 20523 + - 20524 + - 20525 + - 20526 + - 20527 + - 20528 + - 20529 + - 20530 + - 20531 + - 20532 + - 20533 + - 20534 + - 20535 + - 20536 + - 20537 + - 20538 + - 20539 + - 20540 + - 20541 + - 20542 + - 20543 + - 20544 + - 20545 + - 20546 + - 20547 + - 20548 + - 20549 + - 20550 + - 20551 + - 20552 + - 20553 + - 20554 + - 20555 + - 20556 + - 20557 + - 20558 + - 20559 + - 20560 + - 20561 + - 20562 + - 20563 + - 20564 + - 20565 + - 20566 + - 20567 + - 20568 + - 20569 + - 20570 + - 20571 + - 20572 + - 20573 + - 20574 + - 20575 + - 20576 + - 20577 + - 20578 + - 20579 + - 20580 + - 20581 + - 20582 + - 20583 + - 20584 + - 20585 + - 20586 + - 20587 + - 20588 + - 20589 + - 20590 + - 20591 + - 20592 + - 20593 + - 20594 + - 20595 + - 20596 + - 20597 + - 20598 + - 20599 + - 20600 + - 20601 + - 20602 + - 20603 + - 20604 + - 20605 + - 20606 + - 20607 + - 20608 + - 20609 + - 20610 + - 20611 + - 20612 + - 20613 + - 20614 + - 20615 + - 20616 + - 20617 + - 20618 + - 20619 + - 20620 + - 20621 + - 20622 + - 20623 + - 20624 + - 20625 + - 20626 + - 20627 + - 20628 + - 20629 + - 20630 + - 20631 + - 20632 + - 20633 + - 20634 + - 20635 + - 20636 + - 20637 + - 20638 + - 20639 + - 20640 + - 20641 + - 20642 + - 20643 + - 20644 + - 20645 + - 20646 + - 20647 + - 20648 + - 20649 + - 20650 + - 20651 + - 20652 + - 20653 + - 20654 + - 20655 + - 20656 + - 20657 + - 20658 + - 20659 + - 20660 + - 20661 + - 20662 + - 20663 + - 20664 + - 20665 + - 20666 + - 20667 + - 20668 + - 20669 + - 20670 + - 20671 + - 20672 + - 20673 + - 20674 + - 20675 + - 20676 + - 20677 + - 20678 + - 20679 + - 20680 + - 20681 + - 20682 + - 20683 + - 20684 + - 20685 + - 20686 + - 20687 + - 20688 + - 20689 + - 20690 + - 20691 + - 20692 + - 20693 + - 20694 + - 20695 + - 20696 + - 20697 + - 20698 + - 20699 + - 20700 + - 20701 + - 20702 + - 20703 + - 20704 + - 20705 + - 20706 + - 20707 + - 20708 + - 20709 + - 20710 + - 20711 + - 20712 + - 20713 + - 20714 + - 20715 + - 20716 + - 20717 + - 20718 + - 20719 + - 20720 + - 20721 + - 20722 + - 20723 + - 20724 + - 20725 + - 20726 + - 20727 + - 20728 + - 20729 + - 20730 + - 20731 + - 20732 + - 20733 + - 20734 + - 20735 + - 20736 + - 20737 + - 20738 + - 20739 + - 20740 + - 20741 + - 20742 + - 20743 + - 20744 + - 20745 + - 20746 + - 20747 + - 20748 + - 20749 + - 20750 + - 20751 + - 20752 + - 20753 + - 20754 + - 20755 + - 20756 + - 20757 + - 20758 + - 20759 + - 20760 + - 20761 + - 20762 + - 20763 + - 20764 + - 20765 + - 20766 + - 20767 + - 20768 + - 20769 + - 20770 + - 20771 + - 20772 + - 20773 + - 20774 + - 20775 + - 20776 + - 20777 + - 20778 + - 20779 + - 20780 + - 20781 + - 20782 + - 20783 + - 20784 + - 20785 + - 20786 + - 20787 + - 20788 + - 20789 + - 20790 + - 20791 + - 20792 + - 20793 + - 20794 + - 20795 + - 20796 + - 20797 + - 20798 + - 20799 + - 20800 + - 20801 + - 20802 + - 20803 + - 20804 + - 20805 + - 20806 + - 20807 + - 20808 + - 20809 + - 20810 + - 20811 + - 20812 + - 20813 + - 20814 + - 20815 + - 20816 + - 20817 + - 20818 + - 20819 + - 20820 + - 20821 + - 20822 + - 20823 + - 20824 + - 20825 + - 20826 + - 20827 + - 20828 + - 20829 + - 20830 + - 20831 + - 20832 + - 20833 + - 20834 + - 20835 + - 20836 + - 20837 + - 20838 + - 20839 + - 20840 + - 20841 + - 20842 + - 20843 + - 20844 + - 20845 + - 20846 + - 20847 + - 20848 + - 20849 + - 20850 + - 20851 + - 20852 + - 20853 + - 20854 + - 20855 + - 20856 + - 20857 + - 20858 + - 20859 + - 20860 + - 20861 + - 20862 + - 20863 + - 20864 + - 20865 + - 20866 + - 20867 + - 20868 + - 20869 + - 20870 + - 20871 + - 20872 + - 20873 + - 20874 + - 20875 + - 20876 + - 20877 + - 20878 + - 20879 + - 20880 + - 20881 + - 20882 + - 20883 + - 20884 + - 20885 + - 20886 + - 20887 + - 20888 + - 20889 + - 20890 + - 20891 + - 20892 + - 20893 + - 20894 + - 20895 + - 20896 + - 20897 + - 20898 + - 20899 + - 20900 + - 20901 + - 20902 + - 20903 + - 20904 + - 20905 + - 20906 + - 20907 + - 20908 + - 20909 + - 20910 + - 20911 + - 20912 + - 20913 + - 20914 + - 20915 + - 20916 + - 20917 + - 20918 + - 20919 + - 20920 + - 20921 + - 20922 + - 20923 + - 20924 + - 20925 + - 20926 + - 20927 + - 20928 + - 20929 + - 20930 + - 20931 + - 20932 + - 20933 + - 20934 + - 20935 + - 20936 + - 20937 + - 20938 + - 20939 + - 20940 + - 20941 + - 20942 + - 20943 + - 20944 + - 20945 + - 20946 + - 20947 + - 20948 + - 20949 + - 20950 + - 20951 + - 20952 + - 20953 + - 20954 + - 20955 + - 20956 + - 20957 + - 20958 + - 20959 + - 20960 + - 20961 + - 20962 + - 20963 + - 20964 + - 20965 + - 20966 + - 20967 + - 20968 + - 20969 + - 20970 + - 20971 + - 20972 + - 20973 + - 20974 + - 20975 + - 20976 + - 20977 + - 20978 + - 20979 + - 20980 + - 20981 + - 20982 + - 20983 + - 20984 + - 20985 + - 20986 + - 20987 + - 20988 + - 20989 + - 20990 + - 20991 + - 20992 + - 20993 + - 20994 + - 20995 + - 20996 + - 20997 + - 20998 + - 20999 + - 21000 + - 21001 + - 21002 + - 21003 + - 21004 + - 21005 + - 21006 + - 21007 + - 21008 + - 21009 + - 21010 + - 21011 + - 21012 + - 21013 + - 21014 + - 21015 + - 21016 + - 21017 + - 21018 + - 21019 + - 21020 + - 21021 + - 21022 + - 21023 + - 21024 + - 21025 + - 21026 + - 21027 + - 21028 + - 21029 + - 21030 + - 21031 + - 21032 + - 21033 + - 21034 + - 21035 + - 21036 + - 21037 + - 21038 + - 21039 + - 21040 + - 21041 + - 21042 + - 21043 + - 21044 + - 21045 + - 21046 + - 21047 + - 21048 + - 21049 + - 21050 + - 21051 + - 21052 + - 21053 + - 21054 + - 21055 + - 21056 + - 21057 + - 21058 + - 21059 + - 21060 + - 21061 + - 21062 + - 21063 + - 21064 + - 21065 + - 21066 + - 21067 + - 21068 + - 21069 + - 21070 + - 21071 + - 21072 + - 21073 + - 21074 + - 21075 + - 21076 + - 21077 + - 21078 + - 21079 + - 21080 + - 21081 + - 21082 + - 21083 + - 21084 + - 21085 + - 21086 + - 21087 + - 21088 + - 21089 + - 21090 + - 21091 + - 21092 + - 21093 + - 21094 + - 21095 + - 21096 + - 21097 + - 21098 + - 21099 + - 21100 + - 21101 + - 21102 + - 21103 + - 21104 + - 21105 + - 21106 + - 21107 + - 21108 + - 21109 + - 21110 + - 21111 + - 21112 + - 21113 + - 21114 + - 21115 + - 21116 + - 21117 + - 21118 + - 21119 + - 21120 + - 21121 + - 21122 + - 21123 + - 21124 + - 21125 + - 21126 + - 21127 + - 21128 + - 21129 + - 21130 + - 21131 + - 21132 + - 21133 + - 21134 + - 21135 + - 21136 + - 21137 + - 21138 + - 21139 + - 21140 + - 21141 + - 21142 + - 21143 + - 21144 + - 21145 + - 21146 + - 21147 + - 21148 + - 21149 + - 21150 + - 21151 + - 21152 + - 21153 + - 21154 + - 21155 + - 21156 + - 21157 + - 21158 + - 21159 + - 21160 + - 21161 + - 21162 + - 21163 + - 21164 + - 21165 + - 21166 + - 21167 + - 21168 + - 21169 + - 21170 + - 21171 + - 21172 + - 21173 + - 21174 + - 21175 + - 21176 + - 21177 + - 21178 + - 21179 + - 21180 + - 21181 + - 21182 + - 21183 + - 21184 + - 21185 + - 21186 + - 21187 + - 21188 + - 21189 + - 21190 + - 21191 + - 21192 + - 21193 + - 21194 + - 21195 + - 21196 + - 21197 + - 21198 + - 21199 + - 21200 + - 21201 + - 21202 + - 21203 + - 21204 + - 21205 + - 21206 + - 21207 + - 21208 + - 21209 + - 21210 + - 21211 + - 21212 + - 21213 + - 21214 + - 21215 + - 21216 + - 21217 + - 21218 + - 21219 + - 21220 + - 21221 + - 21222 + - 21223 + - 21224 + - 21225 + - 21226 + - 21227 + - 21228 + - 21229 + - 21230 + - 21231 + - 21232 + - 21233 + - 21234 + - 21235 + - 21236 + - 21237 + - 21238 + - 21239 + - 21240 + - 21241 + - 21242 + - 21243 + - 21244 + - 21245 + - 21246 + - 21247 + - 21248 + - 21249 + - 21250 + - 21251 + - 21252 + - 21253 + - 21254 + - 21255 + - 21256 + - 21257 + - 21258 + - 21259 + - 21260 + - 21261 + - 21262 + - 21263 + - 21264 + - 21265 + - 21266 + - 21267 + - 21268 + - 21269 + - 21270 + - 21271 + - 21272 + - 21273 + - 21274 + - 21275 + - 21276 + - 21277 + - 21278 + - 21279 + - 21280 + - 21281 + - 21282 + - 21283 + - 21284 + - 21285 + - 21286 + - 21287 + - 21288 + - 21289 + - 21290 + - 21291 + - 21292 + - 21293 + - 21294 + - 21295 + - 21296 + - 21297 + - 21298 + - 21299 + - 21300 + - 21301 + - 21302 + - 21303 + - 21304 + - 21305 + - 21306 + - 21307 + - 21308 + - 21309 + - 21310 + - 21311 + - 21312 + - 21313 + - 21314 + - 21315 + - 21316 + - 21317 + - 21318 + - 21319 + - 21320 + - 21321 + - 21322 + - 21323 + - 21324 + - 21325 + - 21326 + - 21327 + - 21328 + - 21329 + - 21330 + - 21331 + - 21332 + - 21333 + - 21334 + - 21335 + - 21336 + - 21337 + - 21338 + - 21339 + - 21340 + - 21341 + - 21342 + - 21343 + - 21344 + - 21345 + - 21346 + - 21347 + - 21348 + - 21349 + - 21350 + - 21351 + - 21352 + - 21353 + - 21354 + - 21355 + - 21356 + - 21357 + - 21358 + - 21359 + - 21360 + - 21361 + - 21362 + - 21363 + - 21364 + - 21365 + - 21366 + - 21367 + - 21368 + - 21369 + - 21370 + - 21371 + - 21372 + - 21373 + - 21374 + - 21375 + - 21376 + - 21377 + - 21378 + - 21379 + - 21380 + - 21381 + - 21382 + - 21383 + - 21384 + - 21385 + - 21386 + - 21387 + - 21388 + - 21389 + - 21390 + - 21391 + - 21392 + - 21393 + - 21394 + - 21395 + - 21396 + - 21397 + - 21398 + - 21399 + - 21400 + - 21401 + - 21402 + - 21403 + - 21404 + - 21405 + - 21406 + - 21407 + - 21408 + - 21409 + - 21410 + - 21411 + - 21412 + - 21413 + - 21414 + - 21415 + - 21416 + - 21417 + - 21418 + - 21419 + - 21420 + - 21421 + - 21422 + - 21423 + - 21424 + - 21425 + - 21426 + - 21427 + - 21428 + - 21429 + - 21430 + - 21431 + - 21432 + - 21433 + - 21434 + - 21435 + - 21436 + - 21437 + - 21438 + - 21439 + - 21440 + - 21441 + - 21442 + - 21443 + - 21444 + - 21445 + - 21446 + - 21447 + - 21448 + - 21449 + - 21450 + - 21451 + - 21452 + - 21453 + - 21454 + - 21455 + - 21456 + - 21457 + - 21458 + - 21459 + - 21460 + - 21461 + - 21462 + - 21463 + - 21464 + - 21465 + - 21466 + - 21467 + - 21468 + - 21469 + - 21470 + - 21471 + - 21472 + - 21473 + - 21474 + - 21475 + - 21476 + - 21477 + - 21478 + - 21479 + - 21480 + - 21481 + - 21482 + - 21483 + - 21484 + - 21485 + - 21486 + - 21487 + - 21488 + - 21489 + - 21490 + - 21491 + - 21492 + - 21493 + - 21494 + - 21495 + - 21496 + - 21497 + - 21498 + - 21499 + - 21500 + - 21501 + - 21502 + - 21503 + - 21504 + - 21505 + - 21506 + - 21507 + - 21508 + - 21509 + - 21510 + - 21511 + - 21512 + - 21513 + - 21514 + - 21515 + - 21516 + - 21517 + - 21518 + - 21519 + - 21520 + - 21521 + - 21522 + - 21523 + - 21524 + - 21525 + - 21526 + - 21527 + - 21528 + - 21529 + - 21530 + - 21531 + - 21532 + - 21533 + - 21534 + - 21535 + - 21536 + - 21537 + - 21538 + - 21539 + - 21540 + - 21541 + - 21542 + - 21543 + - 21544 + - 21545 + - 21546 + - 21547 + - 21548 + - 21549 + - 21550 + - 21551 + - 21552 + - 21553 + - 21554 + - 21555 + - 21556 + - 21557 + - 21558 + - 21559 + - 21560 + - 21561 + - 21562 + - 21563 + - 21564 + - 21565 + - 21566 + - 21567 + - 21568 + - 21569 + - 21570 + - 21571 + - 21572 + - 21573 + - 21574 + - 21575 + - 21576 + - 21577 + - 21578 + - 21579 + - 21580 + - 21581 + - 21582 + - 21583 + - 21584 + - 21585 + - 21586 + - 21587 + - 21588 + - 21589 + - 21590 + - 21591 + - 21592 + - 21593 + - 21594 + - 21595 + - 21596 + - 21597 + - 21598 + - 21599 + - 21600 + - 21601 + - 21602 + - 21603 + - 21604 + - 21605 + - 21606 + - 21607 + - 21608 + - 21609 + - 21610 + - 21611 + - 21612 + - 21613 + - 21614 + - 21615 + - 21616 + - 21617 + - 21618 + - 21619 + - 21620 + - 21621 + - 21622 + - 21623 + - 21624 + - 21625 + - 21626 + - 21627 + - 21628 + - 21629 + - 21630 + - 21631 + - 21632 + - 21633 + - 21634 + - 21635 + - 21636 + - 21637 + - 21638 + - 21639 + - 21640 + - 21641 + - 21642 + - 21643 + - 21644 + - 21645 + - 21646 + - 21647 + - 21648 + - 21649 + - 21650 + - 21651 + - 21652 + - 21653 + - 21654 + - 21655 + - 21656 + - 21657 + - 21658 + - 21659 + - 21660 + - 21661 + - 21662 + - 21663 + - 21664 + - 21665 + - 21666 + - 21667 + - 21668 + - 21669 + - 21670 + - 21671 + - 21672 + - 21673 + - 21674 + - 21675 + - 21676 + - 21677 + - 21678 + - 21679 + - 21680 + - 21681 + - 21682 + - 21683 + - 21684 + - 21685 + - 21686 + - 21687 + - 21688 + - 21689 + - 21690 + - 21691 + - 21692 + - 21693 + - 21694 + - 21695 + - 21696 + - 21697 + - 21698 + - 21699 + - 21700 + - 21701 + - 21702 + - 21703 + - 21704 + - 21705 + - 21706 + - 21707 + - 21708 + - 21709 + - 21710 + - 21711 + - 21712 + - 21713 + - 21714 + - 21715 + - 21716 + - 21717 + - 21718 + - 21719 + - 21720 + - 21721 + - 21722 + - 21723 + - 21724 + - 21725 + - 21726 + - 21727 + - 21728 + - 21729 + - 21730 + - 21731 + - 21732 + - 21733 + - 21734 + - 21735 + - 21736 + - 21737 + - 21738 + - 21739 + - 21740 + - 21741 + - 21742 + - 21743 + - 21744 + - 21745 + - 21746 + - 21747 + - 21748 + - 21749 + - 21750 + - 21751 + - 21752 + - 21753 + - 21754 + - 21755 + - 21756 + - 21757 + - 21758 + - 21759 + - 21760 + - 21761 + - 21762 + - 21763 + - 21764 + - 21765 + - 21766 + - 21767 + - 21768 + - 21769 + - 21770 + - 21771 + - 21772 + - 21773 + - 21774 + - 21775 + - 21776 + - 21777 + - 21778 + - 21779 + - 21780 + - 21781 + - 21782 + - 21783 + - 21784 + - 21785 + - 21786 + - 21787 + - 21788 + - 21789 + - 21790 + - 21791 + - 21792 + - 21793 + - 21794 + - 21795 + - 21796 + - 21797 + - 21798 + - 21799 + - 21800 + - 21801 + - 21802 + - 21803 + - 21804 + - 21805 + - 21806 + - 21807 + - 21808 + - 21809 + - 21810 + - 21811 + - 21812 + - 21813 + - 21814 + - 21815 + - 21816 + - 21817 + - 21818 + - 21819 + - 21820 + - 21821 + - 21822 + - 21823 + - 21824 + - 21825 + - 21826 + - 21827 + - 21828 + - 21829 + - 21830 + - 21831 + - 21832 + - 21833 + - 21834 + - 21835 + - 21836 + - 21837 + - 21838 + - 21839 + - 21840 + - 21841 + - 21842 + - 21843 + - 21844 + - 21845 + - 21846 + - 21847 + - 21848 + - 21849 + - 21850 + - 21851 + - 21852 + - 21853 + - 21854 + - 21855 + - 21856 + - 21857 + - 21858 + - 21859 + - 21860 + - 21861 + - 21862 + - 21863 + - 21864 + - 21865 + - 21866 + - 21867 + - 21868 + - 21869 + - 21870 + - 21871 + - 21872 + - 21873 + - 21874 + - 21875 + - 21876 + - 21877 + - 21878 + - 21879 + - 21880 + - 21881 + - 21882 + - 21883 + - 21884 + - 21885 + - 21886 + - 21887 + - 21888 + - 21889 + - 21890 + - 21891 + - 21892 + - 21893 + - 21894 + - 21895 + - 21896 + - 21897 + - 21898 + - 21899 + - 21900 + - 21901 + - 21902 + - 21903 + - 21904 + - 21905 + - 21906 + - 21907 + - 21908 + - 21909 + - 21910 + - 21911 + - 21912 + - 21913 + - 21914 + - 21915 + - 21916 + - 21917 + - 21918 + - 21919 + - 21920 + - 21921 + - 21922 + - 21923 + - 21924 + - 21925 + - 21926 + - 21927 + - 21928 + - 21929 + - 21930 + - 21931 + - 21932 + - 21933 + - 21934 + - 21935 + - 21936 + - 21937 + - 21938 + - 21939 + - 21940 + - 21941 + - 21942 + - 21943 + - 21944 + - 21945 + - 21946 + - 21947 + - 21948 + - 21949 + - 21950 + - 21951 + - 21952 + - 21953 + - 21954 + - 21955 + - 21956 + - 21957 + - 21958 + - 21959 + - 21960 + - 21961 + - 21962 + - 21963 + - 21964 + - 21965 + - 21966 + - 21967 + - 21968 + - 21969 + - 21970 + - 21971 + - 21972 + - 21973 + - 21974 + - 21975 + - 21976 + - 21977 + - 21978 + - 21979 + - 21980 + - 21981 + - 21982 + - 21983 + - 21984 + - 21985 + - 21986 + - 21987 + - 21988 + - 21989 + - 21990 + - 21991 + - 21992 + - 21993 + - 21994 + - 21995 + - 21996 + - 21997 + - 21998 + - 21999 + - 22000 + - 22001 + - 22002 + - 22003 + - 22004 + - 22005 + - 22006 + - 22007 + - 22008 + - 22009 + - 22010 + - 22011 + - 22012 + - 22013 + - 22014 + - 22015 + - 22016 + - 22017 + - 22018 + - 22019 + - 22020 + - 22021 + - 22022 + - 22023 + - 22024 + - 22025 + - 22026 + - 22027 + - 22028 + - 22029 + - 22030 + - 22031 + - 22032 + - 22033 + - 22034 + - 22035 + - 22036 + - 22037 + - 22038 + - 22039 + - 22040 + - 22041 + - 22042 + - 22043 + - 22044 + - 22045 + - 22046 + - 22047 + - 22048 + - 22049 + - 22050 + - 22051 + - 22052 + - 22053 + - 22054 + - 22055 + - 22056 + - 22057 + - 22058 + - 22059 + - 22060 + - 22061 + - 22062 + - 22063 + - 22064 + - 22065 + - 22066 + - 22067 + - 22068 + - 22069 + - 22070 + - 22071 + - 22072 + - 22073 + - 22074 + - 22075 + - 22076 + - 22077 + - 22078 + - 22079 + - 22080 + - 22081 + - 22082 + - 22083 + - 22084 + - 22085 + - 22086 + - 22087 + - 22088 + - 22089 + - 22090 + - 22091 + - 22092 + - 22093 + - 22094 + - 22095 + - 22096 + - 22097 + - 22098 + - 22099 + - 22100 + - 22101 + - 22102 + - 22103 + - 22104 + - 22105 + - 22106 + - 22107 + - 22108 + - 22109 + - 22110 + - 22111 + - 22112 + - 22113 + - 22114 + - 22115 + - 22116 + - 22117 + - 22118 + - 22119 + - 22120 + - 22121 + - 22122 + - 22123 + - 22124 + - 22125 + - 22126 + - 22127 + - 22128 + - 22129 + - 22130 + - 22131 + - 22132 + - 22133 + - 22134 + - 22135 + - 22136 + - 22137 + - 22138 + - 22139 + - 22140 + - 22141 + - 22142 + - 22143 + - 22144 + - 22145 + - 22146 + - 22147 + - 22148 + - 22149 + - 22150 + - 22151 + - 22152 + - 22153 + - 22154 + - 22155 + - 22156 + - 22157 + - 22158 + - 22159 + - 22160 + - 22161 + - 22162 + - 22163 + - 22164 + - 22165 + - 22166 + - 22167 + - 22168 + - 22169 + - 22170 + - 22171 + - 22172 + - 22173 + - 22174 + - 22175 + - 22176 + - 22177 + - 22178 + - 22179 + - 22180 + - 22181 + - 22182 + - 22183 + - 22184 + - 22185 + - 22186 + - 22187 + - 22188 + - 22189 + - 22190 + - 22191 + - 22192 + - 22193 + - 22194 + - 22195 + - 22196 + - 22197 + - 22198 + - 22199 + - 22200 + - 22201 + - 22202 + - 22203 + - 22204 + - 22205 + - 22206 + - 22207 + - 22208 + - 22209 + - 22210 + - 22211 + - 22212 + - 22213 + - 22214 + - 22215 + - 22216 + - 22217 + - 22218 + - 22219 + - 22220 + - 22221 + - 22222 + - 22223 + - 22224 + - 22225 + - 22226 + - 22227 + - 22228 + - 22229 + - 22230 + - 22231 + - 22232 + - 22233 + - 22234 + - 22235 + - 22236 + - 22237 + - 22238 + - 22239 + - 22240 + - 22241 + - 22242 + - 22243 + - 22244 + - 22245 + - 22246 + - 22247 + - 22248 + - 22249 + - 22250 + - 22251 + - 22252 + - 22253 + - 22254 + - 22255 + - 22256 + - 22257 + - 22258 + - 22259 + - 22260 + - 22261 + - 22262 + - 22263 + - 22264 + - 22265 + - 22266 + - 22267 + - 22268 + - 22269 + - 22270 + - 22271 + - 22272 + - 22273 + - 22274 + - 22275 + - 22276 + - 22277 + - 22278 + - 22279 + - 22280 + - 22281 + - 22282 + - 22283 + - 22284 + - 22285 + - 22286 + - 22287 + - 22288 + - 22289 + - 22290 + - 22291 + - 22292 + - 22293 + - 22294 + - 22295 + - 22296 + - 22297 + - 22298 + - 22299 + - 22300 + - 22301 + - 22302 + - 22303 + - 22304 + - 22305 + - 22306 + - 22307 + - 22308 + - 22309 + - 22310 + - 22311 + - 22312 + - 22313 + - 22314 + - 22315 + - 22316 + - 22317 + - 22318 + - 22319 + - 22320 + - 22321 + - 22322 + - 22323 + - 22324 + - 22325 + - 22326 + - 22327 + - 22328 + - 22329 + - 22330 + - 22331 + - 22332 + - 22333 + - 22334 + - 22335 + - 22336 + - 22337 + - 22338 + - 22339 + - 22340 + - 22341 + - 22342 + - 22343 + - 22344 + - 22345 + - 22346 + - 22347 + - 22348 + - 22349 + - 22350 + - 22351 + - 22352 + - 22353 + - 22354 + - 22355 + - 22356 + - 22357 + - 22358 + - 22359 + - 22360 + - 22361 + - 22362 + - 22363 + - 22364 + - 22365 + - 22366 + - 22367 + - 22368 + - 22369 + - 22370 + - 22371 + - 22372 + - 22373 + - 22374 + - 22375 + - 22376 + - 22377 + - 22378 + - 22379 + - 22380 + - 22381 + - 22382 + - 22383 + - 22384 + - 22385 + - 22386 + - 22387 + - 22388 + - 22389 + - 22390 + - 22391 + - 22392 + - 22393 + - 22394 + - 22395 + - 22396 + - 22397 + - 22398 + - 22399 + - 22400 + - 22401 + - 22402 + - 22403 + - 22404 + - 22405 + - 22406 + - 22407 + - 22408 + - 22409 + - 22410 + - 22411 + - 22412 + - 22413 + - 22414 + - 22415 + - 22416 + - 22417 + - 22418 + - 22419 + - 22420 + - 22421 + - 22422 + - 22423 + - 22424 + - 22425 + - 22426 + - 22427 + - 22428 + - 22429 + - 22430 + - 22431 + - 22432 + - 22433 + - 22434 + - 22435 + - 22436 + - 22437 + - 22438 + - 22439 + - 22440 + - 22441 + - 22442 + - 22443 + - 22444 + - 22445 + - 22446 + - 22447 + - 22448 + - 22449 + - 22450 + - 22451 + - 22452 + - 22453 + - 22454 + - 22455 + - 22456 + - 22457 + - 22458 + - 22459 + - 22460 + - 22461 + - 22462 + - 22463 + - 22464 + - 22465 + - 22466 + - 22467 + - 22468 + - 22469 + - 22470 + - 22471 + - 22472 + - 22473 + - 22474 + - 22475 + - 22476 + - 22477 + - 22478 + - 22479 + - 22480 + - 22481 + - 22482 + - 22483 + - 22484 + - 22485 + - 22486 + - 22487 + - 22488 + - 22489 + - 22490 + - 22491 + - 22492 + - 22493 + - 22494 + - 22495 + - 22496 + - 22497 + - 22498 + - 22499 + - 22500 + - 22501 + - 22502 + - 22503 + - 22504 + - 22505 + - 22506 + - 22507 + - 22508 + - 22509 + - 22510 + - 22511 + - 22512 + - 22513 + - 22514 + - 22515 + - 22516 + - 22517 + - 22518 + - 22519 + - 22520 + - 22521 + - 22522 + - 22523 + - 22524 + - 22525 + - 22526 + - 22527 + - 22528 + - 22529 + - 22530 + - 22531 + - 22532 + - 22533 + - 22534 + - 22535 + - 22536 + - 22537 + - 22538 + - 22539 + - 22540 + - 22541 + - 22542 + - 22543 + - 22544 + - 22545 + - 22546 + - 22547 + - 22548 + - 22549 + - 22550 + - 22551 + - 22552 + - 22553 + - 22554 + - 22555 + - 22556 + - 22557 + - 22558 + - 22559 + - 22560 + - 22561 + - 22562 + - 22563 + - 22564 + - 22565 + - 22566 + - 22567 + - 22568 + - 22569 + - 22570 + - 22571 + - 22572 + - 22573 + - 22574 + - 22575 + - 22576 + - 22577 + - 22578 + - 22579 + - 22580 + - 22581 + - 22582 + - 22583 + - 22584 + - 22585 + - 22586 + - 22587 + - 22588 + - 22589 + - 22590 + - 22591 + - 22592 + - 22593 + - 22594 + - 22595 + - 22596 + - 22597 + - 22598 + - 22599 + - 22600 + - 22601 + - 22602 + - 22603 + - 22604 + - 22605 + - 22606 + - 22607 + - 22608 + - 22609 + - 22610 + - 22611 + - 22612 + - 22613 + - 22614 + - 22615 + - 22616 + - 22617 + - 22618 + - 22619 + - 22620 + - 22621 + - 22622 + - 22623 + - 22624 + - 22625 + - 22626 + - 22627 + - 22628 + - 22629 + - 22630 + - 22631 + - 22632 + - 22633 + - 22634 + - 22635 + - 22636 + - 22637 + - 22638 + - 22639 + - 22640 + - 22641 + - 22642 + - 22643 + - 22644 + - 22645 + - 22646 + - 22647 + - 22648 + - 22649 + - 22650 + - 22651 + - 22652 + - 22653 + - 22654 + - 22655 + - 22656 + - 22657 + - 22658 + - 22659 + - 22660 + - 22661 + - 22662 + - 22663 + - 22664 + - 22665 + - 22666 + - 22667 + - 22668 + - 22669 + - 22670 + - 22671 + - 22672 + - 22673 + - 22674 + - 22675 + - 22676 + - 22677 + - 22678 + - 22679 + - 22680 + - 22681 + - 22682 + - 22683 + - 22684 + - 22685 + - 22686 + - 22687 + - 22688 + - 22689 + - 22690 + - 22691 + - 22692 + - 22693 + - 22694 + - 22695 + - 22696 + - 22697 + - 22698 + - 22699 + - 22700 + - 22701 + - 22702 + - 22703 + - 22704 + - 22705 + - 22706 + - 22707 + - 22708 + - 22709 + - 22710 + - 22711 + - 22712 + - 22713 + - 22714 + - 22715 + - 22716 + - 22717 + - 22718 + - 22719 + - 22720 + - 22721 + - 22722 + - 22723 + - 22724 + - 22725 + - 22726 + - 22727 + - 22728 + - 22729 + - 22730 + - 22731 + - 22732 + - 22733 + - 22734 + - 22735 + - 22736 + - 22737 + - 22738 + - 22739 + - 22740 + - 22741 + - 22742 + - 22743 + - 22744 + - 22745 + - 22746 + - 22747 + - 22748 + - 22749 + - 22750 + - 22751 + - 22752 + - 22753 + - 22754 + - 22755 + - 22756 + - 22757 + - 22758 + - 22759 + - 22760 + - 22761 + - 22762 + - 22763 + - 22764 + - 22765 + - 22766 + - 22767 + - 22768 + - 22769 + - 22770 + - 22771 + - 22772 + - 22773 + - 22774 + - 22775 + - 22776 + - 22777 + - 22778 + - 22779 + - 22780 + - 22781 + - 22782 + - 22783 + - 22784 + - 22785 + - 22786 + - 22787 + - 22788 + - 22789 + - 22790 + - 22791 + - 22792 + - 22793 + - 22794 + - 22795 + - 22796 + - 22797 + - 22798 + - 22799 + - 22800 + - 22801 + - 22802 + - 22803 + - 22804 + - 22805 + - 22806 + - 22807 + - 22808 + - 22809 + - 22810 + - 22811 + - 22812 + - 22813 + - 22814 + - 22815 + - 22816 + - 22817 + - 22818 + - 22819 + - 22820 + - 22821 + - 22822 + - 22823 + - 22824 + - 22825 + - 22826 + - 22827 + - 22828 + - 22829 + - 22830 + - 22831 + - 22832 + - 22833 + - 22834 + - 22835 + - 22836 + - 22837 + - 22838 + - 22839 + - 22840 + - 22841 + - 22842 + - 22843 + - 22844 + - 22845 + - 22846 + - 22847 + - 22848 + - 22849 + - 22850 + - 22851 + - 22852 + - 22853 + - 22854 + - 22855 + - 22856 + - 22857 + - 22858 + - 22859 + - 22860 + - 22861 + - 22862 + - 22863 + - 22864 + - 22865 + - 22866 + - 22867 + - 22868 + - 22869 + - 22870 + - 22871 + - 22872 + - 22873 + - 22874 + - 22875 + - 22876 + - 22877 + - 22878 + - 22879 + - 22880 + - 22881 + - 22882 + - 22883 + - 22884 + - 22885 + - 22886 + - 22887 + - 22888 + - 22889 + - 22890 + - 22891 + - 22892 + - 22893 + - 22894 + - 22895 + - 22896 + - 22897 + - 22898 + - 22899 + - 22900 + - 22901 + - 22902 + - 22903 + - 22904 + - 22905 + - 22906 + - 22907 + - 22908 + - 22909 + - 22910 + - 22911 + - 22912 + - 22913 + - 22914 + - 22915 + - 22916 + - 22917 + - 22918 + - 22919 + - 22920 + - 22921 + - 22922 + - 22923 + - 22924 + - 22925 + - 22926 + - 22927 + - 22928 + - 22929 + - 22930 + - 22931 + - 22932 + - 22933 + - 22934 + - 22935 + - 22936 + - 22937 + - 22938 + - 22939 + - 22940 + - 22941 + - 22942 + - 22943 + - 22944 + - 22945 + - 22946 + - 22947 + - 22948 + - 22949 + - 22950 + - 22951 + - 22952 + - 22953 + - 22954 + - 22955 + - 22956 + - 22957 + - 22958 + - 22959 + - 22960 + - 22961 + - 22962 + - 22963 + - 22964 + - 22965 + - 22966 + - 22967 + - 22968 + - 22969 + - 22970 + - 22971 + - 22972 + - 22973 + - 22974 + - 22975 + - 22976 + - 22977 + - 22978 + - 22979 + - 22980 + - 22981 + - 22982 + - 22983 + - 22984 + - 22985 + - 22986 + - 22987 + - 22988 + - 22989 + - 22990 + - 22991 + - 22992 + - 22993 + - 22994 + - 22995 + - 22996 + - 22997 + - 22998 + - 22999 + - 23000 + - 23001 + - 23002 + - 23003 + - 23004 + - 23005 + - 23006 + - 23007 + - 23008 + - 23009 + - 23010 + - 23011 + - 23012 + - 23013 + - 23014 + - 23015 + - 23016 + - 23017 + - 23018 + - 23019 + - 23020 + - 23021 + - 23022 + - 23023 + - 23024 + - 23025 + - 23026 + - 23027 + - 23028 + - 23029 + - 23030 + - 23031 + - 23032 + - 23033 + - 23034 + - 23035 + - 23036 + - 23037 + - 23038 + - 23039 + - 23040 + - 23041 + - 23042 + - 23043 + - 23044 + - 23045 + - 23046 + - 23047 + - 23048 + - 23049 + - 23050 + - 23051 + - 23052 + - 23053 + - 23054 + - 23055 + - 23056 + - 23057 + - 23058 + - 23059 + - 23060 + - 23061 + - 23062 + - 23063 + - 23064 + - 23065 + - 23066 + - 23067 + - 23068 + - 23069 + - 23070 + - 23071 + - 23072 + - 23073 + - 23074 + - 23075 + - 23076 + - 23077 + - 23078 + - 23079 + - 23080 + - 23081 + - 23082 + - 23083 + - 23084 + - 23085 + - 23086 + - 23087 + - 23088 + - 23089 + - 23090 + - 23091 + - 23092 + - 23093 + - 23094 + - 23095 + - 23096 + - 23097 + - 23098 + - 23099 + - 23100 + - 23101 + - 23102 + - 23103 + - 23104 + - 23105 + - 23106 + - 23107 + - 23108 + - 23109 + - 23110 + - 23111 + - 23112 + - 23113 + - 23114 + - 23115 + - 23116 + - 23117 + - 23118 + - 23119 + - 23120 + - 23121 + - 23122 + - 23123 + - 23124 + - 23125 + - 23126 + - 23127 + - 23128 + - 23129 + - 23130 + - 23131 + - 23132 + - 23133 + - 23134 + - 23135 + - 23136 + - 23137 + - 23138 + - 23139 + - 23140 + - 23141 + - 23142 + - 23143 + - 23144 + - 23145 + - 23146 + - 23147 + - 23148 + - 23149 + - 23150 + - 23151 + - 23152 + - 23153 + - 23154 + - 23155 + - 23156 + - 23157 + - 23158 + - 23159 + - 23160 + - 23161 + - 23162 + - 23163 + - 23164 + - 23165 + - 23166 + - 23167 + - 23168 + - 23169 + - 23170 + - 23171 + - 23172 + - 23173 + - 23174 + - 23175 + - 23176 + - 23177 + - 23178 + - 23179 + - 23180 + - 23181 + - 23182 + - 23183 + - 23184 + - 23185 + - 23186 + - 23187 + - 23188 + - 23189 + - 23190 + - 23191 + - 23192 + - 23193 + - 23194 + - 23195 + - 23196 + - 23197 + - 23198 + - 23199 + - 23200 + - 23201 + - 23202 + - 23203 + - 23204 + - 23205 + - 23206 + - 23207 + - 23208 + - 23209 + - 23210 + - 23211 + - 23212 + - 23213 + - 23214 + - 23215 + - 23216 + - 23217 + - 23218 + - 23219 + - 23220 + - 23221 + - 23222 + - 23223 + - 23224 + - 23225 + - 23226 + - 23227 + - 23228 + - 23229 + - 23230 + - 23231 + - 23232 + - 23233 + - 23234 + - 23235 + - 23236 + - 23237 + - 23238 + - 23239 + - 23240 + - 23241 + - 23242 + - 23243 + - 23244 + - 23245 + - 23246 + - 23247 + - 23248 + - 23249 + - 23250 + - 23251 + - 23252 + - 23253 + - 23254 + - 23255 + - 23256 + - 23257 + - 23258 + - 23259 + - 23260 + - 23261 + - 23262 + - 23263 + - 23264 + - 23265 + - 23266 + - 23267 + - 23268 + - 23269 + - 23270 + - 23271 + - 23272 + - 23273 + - 23274 + - 23275 + - 23276 + - 23277 + - 23278 + - 23279 + - 23280 + - 23281 + - 23282 + - 23283 + - 23284 + - 23285 + - 23286 + - 23287 + - 23288 + - 23289 + - 23290 + - 23291 + - 23292 + - 23293 + - 23294 + - 23295 + - 23296 + - 23297 + - 23298 + - 23299 + - 23300 + - 23301 + - 23302 + - 23303 + - 23304 + - 23305 + - 23306 + - 23307 + - 23308 + - 23309 + - 23310 + - 23311 + - 23312 + - 23313 + - 23314 + - 23315 + - 23316 + - 23317 + - 23318 + - 23319 + - 23320 + - 23321 + - 23322 + - 23323 + - 23324 + - 23325 + - 23326 + - 23327 + - 23328 + - 23329 + - 23330 + - 23331 + - 23332 + - 23333 + - 23334 + - 23335 + - 23336 + - 23337 + - 23338 + - 23339 + - 23340 + - 23341 + - 23342 + - 23343 + - 23344 + - 23345 + - 23346 + - 23347 + - 23348 + - 23349 + - 23350 + - 23351 + - 23352 + - 23353 + - 23354 + - 23355 + - 23356 + - 23357 + - 23358 + - 23359 + - 23360 + - 23361 + - 23362 + - 23363 + - 23364 + - 23365 + - 23366 + - 23367 + - 23368 + - 23369 + - 23370 + - 23371 + - 23372 + - 23373 + - 23374 + - 23375 + - 23376 + - 23377 + - 23378 + - 23379 + - 23380 + - 23381 + - 23382 + - 23383 + - 23384 + - 23385 + - 23386 + - 23387 + - 23388 + - 23389 + - 23390 + - 23391 + - 23392 + - 23393 + - 23394 + - 23395 + - 23396 + - 23397 + - 23398 + - 23399 + - 23400 + - 23401 + - 23402 + - 23403 + - 23404 + - 23405 + - 23406 + - 23407 + - 23408 + - 23409 + - 23410 + - 23411 + - 23412 + - 23413 + - 23414 + - 23415 + - 23416 + - 23417 + - 23418 + - 23419 + - 23420 + - 23421 + - 23422 + - 23423 + - 23424 + - 23425 + - 23426 + - 23427 + - 23428 + - 23429 + - 23430 + - 23431 + - 23432 + - 23433 + - 23434 + - 23435 + - 23436 + - 23437 + - 23438 + - 23439 + - 23440 + - 23441 + - 23442 + - 23443 + - 23444 + - 23445 + - 23446 + - 23447 + - 23448 + - 23449 + - 23450 + - 23451 + - 23452 + - 23453 + - 23454 + - 23455 + - 23456 + - 23457 + - 23458 + - 23459 + - 23460 + - 23461 + - 23462 + - 23463 + - 23464 + - 23465 + - 23466 + - 23467 + - 23468 + - 23469 + - 23470 + - 23471 + - 23472 + - 23473 + - 23474 + - 23475 + - 23476 + - 23477 + - 23478 + - 23479 + - 23480 + - 23481 + - 23482 + - 23483 + - 23484 + - 23485 + - 23486 + - 23487 + - 23488 + - 23489 + - 23490 + - 23491 + - 23492 + - 23493 + - 23494 + - 23495 + - 23496 + - 23497 + - 23498 + - 23499 + - 23500 + - 23501 + - 23502 + - 23503 + - 23504 + - 23505 + - 23506 + - 23507 + - 23508 + - 23509 + - 23510 + - 23511 + - 23512 + - 23513 + - 23514 + - 23515 + - 23516 + - 23517 + - 23518 + - 23519 + - 23520 + - 23521 + - 23522 + - 23523 + - 23524 + - 23525 + - 23526 + - 23527 + - 23528 + - 23529 + - 23530 + - 23531 + - 23532 + - 23533 + - 23534 + - 23535 + - 23536 + - 23537 + - 23538 + - 23539 + - 23540 + - 23541 + - 23542 + - 23543 + - 23544 + - 23545 + - 23546 + - 23547 + - 23548 + - 23549 + - 23550 + - 23551 + - 23552 + - 23553 + - 23554 + - 23555 + - 23556 + - 23557 + - 23558 + - 23559 + - 23560 + - 23561 + - 23562 + - 23563 + - 23564 + - 23565 + - 23566 + - 23567 + - 23568 + - 23569 + - 23570 + - 23571 + - 23572 + - 23573 + - 23574 + - 23575 + - 23576 + - 23577 + - 23578 + - 23579 + - 23580 + - 23581 + - 23582 + - 23583 + - 23584 + - 23585 + - 23586 + - 23587 + - 23588 + - 23589 + - 23590 + - 23591 + - 23592 + - 23593 + - 23594 + - 23595 + - 23596 + - 23597 + - 23598 + - 23599 + - 23600 + - 23601 + - 23602 + - 23603 + - 23604 + - 23605 + - 23606 + - 23607 + - 23608 + - 23609 + - 23610 + - 23611 + - 23612 + - 23613 + - 23614 + - 23615 + - 23616 + - 23617 + - 23618 + - 23619 + - 23620 + - 23621 + - 23622 + - 23623 + - 23624 + - 23625 + - 23626 + - 23627 + - 23628 + - 23629 + - 23630 + - 23631 + - 23632 + - 23633 + - 23634 + - 23635 + - 23636 + - 23637 + - 23638 + - 23639 + - 23640 + - 23641 + - 23642 + - 23643 + - 23644 + - 23645 + - 23646 + - 23647 + - 23648 + - 23649 + - 23650 + - 23651 + - 23652 + - 23653 + - 23654 + - 23655 + - 23656 + - 23657 + - 23658 + - 23659 + - 23660 + - 23661 + - 23662 + - 23663 + - 23664 + - 23665 + - 23666 + - 23667 + - 23668 + - 23669 + - 23670 + - 23671 + - 23672 + - 23673 + - 23674 + - 23675 + - 23676 + - 23677 + - 23678 + - 23679 + - 23680 + - 23681 + - 23682 + - 23683 + - 23684 + - 23685 + - 23686 + - 23687 + - 23688 + - 23689 + - 23690 + - 23691 + - 23692 + - 23693 + - 23694 + - 23695 + - 23696 + - 23697 + - 23698 + - 23699 + - 23700 + - 23701 + - 23702 + - 23703 + - 23704 + - 23705 + - 23706 + - 23707 + - 23708 + - 23709 + - 23710 + - 23711 + - 23712 + - 23713 + - 23714 + - 23715 + - 23716 + - 23717 + - 23718 + - 23719 + - 23720 + - 23721 + - 23722 + - 23723 + - 23724 + - 23725 + - 23726 + - 23727 + - 23728 + - 23729 + - 23730 + - 23731 + - 23732 + - 23733 + - 23734 + - 23735 + - 23736 + - 23737 + - 23738 + - 23739 + - 23740 + - 23741 + - 23742 + - 23743 + - 23744 + - 23745 + - 23746 + - 23747 + - 23748 + - 23749 + - 23750 + - 23751 + - 23752 + - 23753 + - 23754 + - 23755 + - 23756 + - 23757 + - 23758 + - 23759 + - 23760 + - 23761 + - 23762 + - 23763 + - 23764 + - 23765 + - 23766 + - 23767 + - 23768 + - 23769 + - 23770 + - 23771 + - 23772 + - 23773 + - 23774 + - 23775 + - 23776 + - 23777 + - 23778 + - 23779 + - 23780 + - 23781 + - 23782 + - 23783 + - 23784 + - 23785 + - 23786 + - 23787 + - 23788 + - 23789 + - 23790 + - 23791 + - 23792 + - 23793 + - 23794 + - 23795 + - 23796 + - 23797 + - 23798 + - 23799 + - 23800 + - 23801 + - 23802 + - 23803 + - 23804 + - 23805 + - 23806 + - 23807 + - 23808 + - 23809 + - 23810 + - 23811 + - 23812 + - 23813 + - 23814 + - 23815 + - 23816 + - 23817 + - 23818 + - 23819 + - 23820 + - 23821 + - 23822 + - 23823 + - 23824 + - 23825 + - 23826 + - 23827 + - 23828 + - 23829 + - 23830 + - 23831 + - 23832 + - 23833 + - 23834 + - 23835 + - 23836 + - 23837 + - 23838 + - 23839 + - 23840 + - 23841 + - 23842 + - 23843 + - 23844 + - 23845 + - 23846 + - 23847 + - 23848 + - 23849 + - 23850 + - 23851 + - 23852 + - 23853 + - 23854 + - 23855 + - 23856 + - 23857 + - 23858 + - 23859 + - 23860 + - 23861 + - 23862 + - 23863 + - 23864 + - 23865 + - 23866 + - 23867 + - 23868 + - 23869 + - 23870 + - 23871 + - 23872 + - 23873 + - 23874 + - 23875 + - 23876 + - 23877 + - 23878 + - 23879 + - 23880 + - 23881 + - 23882 + - 23883 + - 23884 + - 23885 + - 23886 + - 23887 + - 23888 + - 23889 + - 23890 + - 23891 + - 23892 + - 23893 + - 23894 + - 23895 + - 23896 + - 23897 + - 23898 + - 23899 + - 23900 + - 23901 + - 23902 + - 23903 + - 23904 + - 23905 + - 23906 + - 23907 + - 23908 + - 23909 + - 23910 + - 23911 + - 23912 + - 23913 + - 23914 + - 23915 + - 23916 + - 23917 + - 23918 + - 23919 + - 23920 + - 23921 + - 23922 + - 23923 + - 23924 + - 23925 + - 23926 + - 23927 + - 23928 + - 23929 + - 23930 + - 23931 + - 23932 + - 23933 + - 23934 + - 23935 + - 23936 + - 23937 + - 23938 + - 23939 + - 23940 + - 23941 + - 23942 + - 23943 + - 23944 + - 23945 + - 23946 + - 23947 + - 23948 + - 23949 + - 23950 + - 23951 + - 23952 + - 23953 + - 23954 + - 23955 + - 23956 + - 23957 + - 23958 + - 23959 + - 23960 + - 23961 + - 23962 + - 23963 + - 23964 + - 23965 + - 23966 + - 23967 + - 23968 + - 23969 + - 23970 + - 23971 + - 23972 + - 23973 + - 23974 + - 23975 + - 23976 + - 23977 + - 23978 + - 23979 + - 23980 + - 23981 + - 23982 + - 23983 + - 23984 + - 23985 + - 23986 + - 23987 + - 23988 + - 23989 + - 23990 + - 23991 + - 23992 + - 23993 + - 23994 + - 23995 + - 23996 + - 23997 + - 23998 + - 23999 + - 24000 + - 24001 + - 24002 + - 24003 + - 24004 + - 24005 + - 24006 + - 24007 + - 24008 + - 24009 + - 24010 + - 24011 + - 24012 + - 24013 + - 24014 + - 24015 + - 24016 + - 24017 + - 24018 + - 24019 + - 24020 + - 24021 + - 24022 + - 24023 + - 24024 + - 24025 + - 24026 + - 24027 + - 24028 + - 24029 + - 24030 + - 24031 + - 24032 + - 24033 + - 24034 + - 24035 + - 24036 + - 24037 + - 24038 + - 24039 + - 24040 + - 24041 + - 24042 + - 24043 + - 24044 + - 24045 + - 24046 + - 24047 + - 24048 + - 24049 + - 24050 + - 24051 + - 24052 + - 24053 + - 24054 + - 24055 + - 24056 + - 24057 + - 24058 + - 24059 + - 24060 + - 24061 + - 24062 + - 24063 + - 24064 + - 24065 + - 24066 + - 24067 + - 24068 + - 24069 + - 24070 + - 24071 + - 24072 + - 24073 + - 24074 + - 24075 + - 24076 + - 24077 + - 24078 + - 24079 + - 24080 + - 24081 + - 24082 + - 24083 + - 24084 + - 24085 + - 24086 + - 24087 + - 24088 + - 24089 + - 24090 + - 24091 + - 24092 + - 24093 + - 24094 + - 24095 + - 24096 + - 24097 + - 24098 + - 24099 + - 24100 + - 24101 + - 24102 + - 24103 + - 24104 + - 24105 + - 24106 + - 24107 + - 24108 + - 24109 + - 24110 + - 24111 + - 24112 + - 24113 + - 24114 + - 24115 + - 24116 + - 24117 + - 24118 + - 24119 + - 24120 + - 24121 + - 24122 + - 24123 + - 24124 + - 24125 + - 24126 + - 24127 + - 24128 + - 24129 + - 24130 + - 24131 + - 24132 + - 24133 + - 24134 + - 24135 + - 24136 + - 24137 + - 24138 + - 24139 + - 24140 + - 24141 + - 24142 + - 24143 + - 24144 + - 24145 + - 24146 + - 24147 + - 24148 + - 24149 + - 24150 + - 24151 + - 24152 + - 24153 + - 24154 + - 24155 + - 24156 + - 24157 + - 24158 + - 24159 + - 24160 + - 24161 + - 24162 + - 24163 + - 24164 + - 24165 + - 24166 + - 24167 + - 24168 + - 24169 + - 24170 + - 24171 + - 24172 + - 24173 + - 24174 + - 24175 + - 24176 + - 24177 + - 24178 + - 24179 + - 24180 + - 24181 + - 24182 + - 24183 + - 24184 + - 24185 + - 24186 + - 24187 + - 24188 + - 24189 + - 24190 + - 24191 + - 24192 + - 24193 + - 24194 + - 24195 + - 24196 + - 24197 + - 24198 + - 24199 + - 24200 + - 24201 + - 24202 + - 24203 + - 24204 + - 24205 + - 24206 + - 24207 + - 24208 + - 24209 + - 24210 + - 24211 + - 24212 + - 24213 + - 24214 + - 24215 + - 24216 + - 24217 + - 24218 + - 24219 + - 24220 + - 24221 + - 24222 + - 24223 + - 24224 + - 24225 + - 24226 + - 24227 + - 24228 + - 24229 + - 24230 + - 24231 + - 24232 + - 24233 + - 24234 + - 24235 + - 24236 + - 24237 + - 24238 + - 24239 + - 24240 + - 24241 + - 24242 + - 24243 + - 24244 + - 24245 + - 24246 + - 24247 + - 24248 + - 24249 + - 24250 + - 24251 + - 24252 + - 24253 + - 24254 + - 24255 + - 24256 + - 24257 + - 24258 + - 24259 + - 24260 + - 24261 + - 24262 + - 24263 + - 24264 + - 24265 + - 24266 + - 24267 + - 24268 + - 24269 + - 24270 + - 24271 + - 24272 + - 24273 + - 24274 + - 24275 + - 24276 + - 24277 + - 24278 + - 24279 + - 24280 + - 24281 + - 24282 + - 24283 + - 24284 + - 24285 + - 24286 + - 24287 + - 24288 + - 24289 + - 24290 + - 24291 + - 24292 + - 24293 + - 24294 + - 24295 + - 24296 + - 24297 + - 24298 + - 24299 + - 24300 + - 24301 + - 24302 + - 24303 + - 24304 + - 24305 + - 24306 + - 24307 + - 24308 + - 24309 + - 24310 + - 24311 + - 24312 + - 24313 + - 24314 + - 24315 + - 24316 + - 24317 + - 24318 + - 24319 + - 24320 + - 24321 + - 24322 + - 24323 + - 24324 + - 24325 + - 24326 + - 24327 + - 24328 + - 24329 + - 24330 + - 24331 + - 24332 + - 24333 + - 24334 + - 24335 + - 24336 + - 24337 + - 24338 + - 24339 + - 24340 + - 24341 + - 24342 + - 24343 + - 24344 + - 24345 + - 24346 + - 24347 + - 24348 + - 24349 + - 24350 + - 24351 + - 24352 + - 24353 + - 24354 + - 24355 + - 24356 + - 24357 + - 24358 + - 24359 + - 24360 + - 24361 + - 24362 + - 24363 + - 24364 + - 24365 + - 24366 + - 24367 + - 24368 + - 24369 + - 24370 + - 24371 + - 24372 + - 24373 + - 24374 + - 24375 + - 24376 + - 24377 + - 24378 + - 24379 + - 24380 + - 24381 + - 24382 + - 24383 + - 24384 + - 24385 + - 24386 + - 24387 + - 24388 + - 24389 + - 24390 + - 24391 + - 24392 + - 24393 + - 24394 + - 24395 + - 24396 + - 24397 + - 24398 + - 24399 + - 24400 + - 24401 + - 24402 + - 24403 + - 24404 + - 24405 + - 24406 + - 24407 + - 24408 + - 24409 + - 24410 + - 24411 + - 24412 + - 24413 + - 24414 + - 24415 + - 24416 + - 24417 + - 24418 + - 24419 + - 24420 + - 24421 + - 24422 + - 24423 + - 24424 + - 24425 + - 24426 + - 24427 + - 24428 + - 24429 + - 24430 + - 24431 + - 24432 + - 24433 + - 24434 + - 24435 + - 24436 + - 24437 + - 24438 + - 24439 + - 24440 + - 24441 + - 24442 + - 24443 + - 24444 + - 24445 + - 24446 + - 24447 + - 24448 + - 24449 + - 24450 + - 24451 + - 24452 + - 24453 + - 24454 + - 24455 + - 24456 + - 24457 + - 24458 + - 24459 + - 24460 + - 24461 + - 24462 + - 24463 + - 24464 + - 24465 + - 24466 + - 24467 + - 24468 + - 24469 + - 24470 + - 24471 + - 24472 + - 24473 + - 24474 + - 24475 + - 24476 + - 24477 + - 24478 + - 24479 + - 24480 + - 24481 + - 24482 + - 24483 + - 24484 + - 24485 + - 24486 + - 24487 + - 24488 + - 24489 + - 24490 + - 24491 + - 24492 + - 24493 + - 24494 + - 24495 + - 24496 + - 24497 + - 24498 + - 24499 + - 24500 + - 24501 + - 24502 + - 24503 + - 24504 + - 24505 + - 24506 + - 24507 + - 24508 + - 24509 + - 24510 + - 24511 + - 24512 + - 24513 + - 24514 + - 24515 + - 24516 + - 24517 + - 24518 + - 24519 + - 24520 + - 24521 + - 24522 + - 24523 + - 24524 + - 24525 + - 24526 + - 24527 + - 24528 + - 24529 + - 24530 + - 24531 + - 24532 + - 24533 + - 24534 + - 24535 + - 24536 + - 24537 + - 24538 + - 24539 + - 24540 + - 24541 + - 24542 + - 24543 + - 24544 + - 24545 + - 24546 + - 24547 + - 24548 + - 24549 + - 24550 + - 24551 + - 24552 + - 24553 + - 24554 + - 24555 + - 24556 + - 24557 + - 24558 + - 24559 + - 24560 + - 24561 + - 24562 + - 24563 + - 24564 + - 24565 + - 24566 + - 24567 + - 24568 + - 24569 + - 24570 + - 24571 + - 24572 + - 24573 + - 24574 + - 24575 + - 24576 + - 24577 + - 24578 + - 24579 + - 24580 + - 24581 + - 24582 + - 24583 + - 24584 + - 24585 + - 24586 + - 24587 + - 24588 + - 24589 + - 24590 + - 24591 + - 24592 + - 24593 + - 24594 + - 24595 + - 24596 + - 24597 + - 24598 + - 24599 + - 24600 + - 24601 + - 24602 + - 24603 + - 24604 + - 24605 + - 24606 + - 24607 + - 24608 + - 24609 + - 24610 + - 24611 + - 24612 + - 24613 + - 24614 + - 24615 + - 24616 + - 24617 + - 24618 + - 24619 + - 24620 + - 24621 + - 24622 + - 24623 + - 24624 + - 24625 + - 24626 + - 24627 + - 24628 + - 24629 + - 24630 + - 24631 + - 24632 + - 24633 + - 24634 + - 24635 + - 24636 + - 24637 + - 24638 + - 24639 + - 24640 + - 24641 + - 24642 + - 24643 + - 24644 + - 24645 + - 24646 + - 24647 + - 24648 + - 24649 + - 24650 + - 24651 + - 24652 + - 24653 + - 24654 + - 24655 + - 24656 + - 24657 + - 24658 + - 24659 + - 24660 + - 24661 + - 24662 + - 24663 + - 24664 + - 24665 + - 24666 + - 24667 + - 24668 + - 24669 + - 24670 + - 24671 + - 24672 + - 24673 + - 24674 + - 24675 + - 24676 + - 24677 + - 24678 + - 24679 + - 24680 + - 24681 + - 24682 + - 24683 + - 24684 + - 24685 + - 24686 + - 24687 + - 24688 + - 24689 + - 24690 + - 24691 + - 24692 + - 24693 + - 24694 + - 24695 + - 24696 + - 24697 + - 24698 + - 24699 + - 24700 + - 24701 + - 24702 + - 24703 + - 24704 + - 24705 + - 24706 + - 24707 + - 24708 + - 24709 + - 24710 + - 24711 + - 24712 + - 24713 + - 24714 + - 24715 + - 24716 + - 24717 + - 24718 + - 24719 + - 24720 + - 24721 + - 24722 + - 24723 + - 24724 + - 24725 + - 24726 + - 24727 + - 24728 + - 24729 + - 24730 + - 24731 + - 24732 + - 24733 + - 24734 + - 24735 + - 24736 + - 24737 + - 24738 + - 24739 + - 24740 + - 24741 + - 24742 + - 24743 + - 24744 + - 24745 + - 24746 + - 24747 + - 24748 + - 24749 + - 24750 + - 24751 + - 24752 + - 24753 + - 24754 + - 24755 + - 24756 + - 24757 + - 24758 + - 24759 + - 24760 + - 24761 + - 24762 + - 24763 + - 24764 + - 24765 + - 24766 + - 24767 + - 24768 + - 24769 + - 24770 + - 24771 + - 24772 + - 24773 + - 24774 + - 24775 + - 24776 + - 24777 + - 24778 + - 24779 + - 24780 + - 24781 + - 24782 + - 24783 + - 24784 + - 24785 + - 24786 + - 24787 + - 24788 + - 24789 + - 24790 + - 24791 + - 24792 + - 24793 + - 24794 + - 24795 + - 24796 + - 24797 + - 24798 + - 24799 + - 24800 + - 24801 + - 24802 + - 24803 + - 24804 + - 24805 + - 24806 + - 24807 + - 24808 + - 24809 + - 24810 + - 24811 + - 24812 + - 24813 + - 24814 + - 24815 + - 24816 + - 24817 + - 24818 + - 24819 + - 24820 + - 24821 + - 24822 + - 24823 + - 24824 + - 24825 + - 24826 + - 24827 + - 24828 + - 24829 + - 24830 + - 24831 + - 24832 + - 24833 + - 24834 + - 24835 + - 24836 + - 24837 + - 24838 + - 24839 + - 24840 + - 24841 + - 24842 + - 24843 + - 24844 + - 24845 + - 24846 + - 24847 + - 24848 + - 24849 + - 24850 + - 24851 + - 24852 + - 24853 + - 24854 + - 24855 + - 24856 + - 24857 + - 24858 + - 24859 + - 24860 + - 24861 + - 24862 + - 24863 + - 24864 + - 24865 + - 24866 + - 24867 + - 24868 + - 24869 + - 24870 + - 24871 + - 24872 + - 24873 + - 24874 + - 24875 + - 24876 + - 24877 + - 24878 + - 24879 + - 24880 + - 24881 + - 24882 + - 24883 + - 24884 + - 24885 + - 24886 + - 24887 + - 24888 + - 24889 + - 24890 + - 24891 + - 24892 + - 24893 + - 24894 + - 24895 + - 24896 + - 24897 + - 24898 + - 24899 + - 24900 + - 24901 + - 24902 + - 24903 + - 24904 + - 24905 + - 24906 + - 24907 + - 24908 + - 24909 + - 24910 + - 24911 + - 24912 + - 24913 + - 24914 + - 24915 + - 24916 + - 24917 + - 24918 + - 24919 + - 24920 + - 24921 + - 24922 + - 24923 + - 24924 + - 24925 + - 24926 + - 24927 + - 24928 + - 24929 + - 24930 + - 24931 + - 24932 + - 24933 + - 24934 + - 24935 + - 24936 + - 24937 + - 24938 + - 24939 + - 24940 + - 24941 + - 24942 + - 24943 + - 24944 + - 24945 + - 24946 + - 24947 + - 24948 + - 24949 + - 24950 + - 24951 + - 24952 + - 24953 + - 24954 + - 24955 + - 24956 + - 24957 + - 24958 + - 24959 + - 24960 + - 24961 + - 24962 + - 24963 + - 24964 + - 24965 + - 24966 + - 24967 + - 24968 + - 24969 + - 24970 + - 24971 + - 24972 + - 24973 + - 24974 + - 24975 + - 24976 + - 24977 + - 24978 + - 24979 + - 24980 + - 24981 + - 24982 + - 24983 + - 24984 + - 24985 + - 24986 + - 24987 + - 24988 + - 24989 + - 24990 + - 24991 + - 24992 + - 24993 + - 24994 + - 24995 + - 24996 + - 24997 + - 24998 + - 24999 + - 25000 + - 25001 + - 25002 + - 25003 + - 25004 + - 25005 + - 25006 + - 25007 + - 25008 + - 25009 + - 25010 + - 25011 + - 25012 + - 25013 + - 25014 + - 25015 + - 25016 + - 25017 + - 25018 + - 25019 + - 25020 + - 25021 + - 25022 + - 25023 + - 25024 + - 25025 + - 25026 + - 25027 + - 25028 + - 25029 + - 25030 + - 25031 + - 25032 + - 25033 + - 25034 + - 25035 + - 25036 + - 25037 + - 25038 + - 25039 + - 25040 + - 25041 + - 25042 + - 25043 + - 25044 + - 25045 + - 25046 + - 25047 + - 25048 + - 25049 + - 25050 + - 25051 + - 25052 + - 25053 + - 25054 + - 25055 + - 25056 + - 25057 + - 25058 + - 25059 + - 25060 + - 25061 + - 25062 + - 25063 + - 25064 + - 25065 + - 25066 + - 25067 + - 25068 + - 25069 + - 25070 + - 25071 + - 25072 + - 25073 + - 25074 + - 25075 + - 25076 + - 25077 + - 25078 + - 25079 + - 25080 + - 25081 + - 25082 + - 25083 + - 25084 + - 25085 + - 25086 + - 25087 + - 25088 + - 25089 + - 25090 + - 25091 + - 25092 + - 25093 + - 25094 + - 25095 + - 25096 + - 25097 + - 25098 + - 25099 + - 25100 + - 25101 + - 25102 + - 25103 + - 25104 + - 25105 + - 25106 + - 25107 + - 25108 + - 25109 + - 25110 + - 25111 + - 25112 + - 25113 + - 25114 + - 25115 + - 25116 + - 25117 + - 25118 + - 25119 + - 25120 + - 25121 + - 25122 + - 25123 + - 25124 + - 25125 + - 25126 + - 25127 + - 25128 + - 25129 + - 25130 + - 25131 + - 25132 + - 25133 + - 25134 + - 25135 + - 25136 + - 25137 + - 25138 + - 25139 + - 25140 + - 25141 + - 25142 + - 25143 + - 25144 + - 25145 + - 25146 + - 25147 + - 25148 + - 25149 + - 25150 + - 25151 + - 25152 + - 25153 + - 25154 + - 25155 + - 25156 + - 25157 + - 25158 + - 25159 + - 25160 + - 25161 + - 25162 + - 25163 + - 25164 + - 25165 + - 25166 + - 25167 + - 25168 + - 25169 + - 25170 + - 25171 + - 25172 + - 25173 + - 25174 + - 25175 + - 25176 + - 25177 + - 25178 + - 25179 + - 25180 + - 25181 + - 25182 + - 25183 + - 25184 + - 25185 + - 25186 + - 25187 + - 25188 + - 25189 + - 25190 + - 25191 + - 25192 + - 25193 + - 25194 + - 25195 + - 25196 + - 25197 + - 25198 + - 25199 + - 25200 + - 25201 + - 25202 + - 25203 + - 25204 + - 25205 + - 25206 + - 25207 + - 25208 + - 25209 + - 25210 + - 25211 + - 25212 + - 25213 + - 25214 + - 25215 + - 25216 + - 25217 + - 25218 + - 25219 + - 25220 + - 25221 + - 25222 + - 25223 + - 25224 + - 25225 + - 25226 + - 25227 + - 25228 + - 25229 + - 25230 + - 25231 + - 25232 + - 25233 + - 25234 + - 25235 + - 25236 + - 25237 + - 25238 + - 25239 + - 25240 + - 25241 + - 25242 + - 25243 + - 25244 + - 25245 + - 25246 + - 25247 + - 25248 + - 25249 + - 25250 + - 25251 + - 25252 + - 25253 + - 25254 + - 25255 + - 25256 + - 25257 + - 25258 + - 25259 + - 25260 + - 25261 + - 25262 + - 25263 + - 25264 + - 25265 + - 25266 + - 25267 + - 25268 + - 25269 + - 25270 + - 25271 + - 25272 + - 25273 + - 25274 + - 25275 + - 25276 + - 25277 + - 25278 + - 25279 + - 25280 + - 25281 + - 25282 + - 25283 + - 25284 + - 25285 + - 25286 + - 25287 + - 25288 + - 25289 + - 25290 + - 25291 + - 25292 + - 25293 + - 25294 + - 25295 + - 25296 + - 25297 + - 25298 + - 25299 + - 25300 + - 25301 + - 25302 + - 25303 + - 25304 + - 25305 + - 25306 + - 25307 + - 25308 + - 25309 + - 25310 + - 25311 + - 25312 + - 25313 + - 25314 + - 25315 + - 25316 + - 25317 + - 25318 + - 25319 + - 25320 + - 25321 + - 25322 + - 25323 + - 25324 + - 25325 + - 25326 + - 25327 + - 25328 + - 25329 + - 25330 + - 25331 + - 25332 + - 25333 + - 25334 + - 25335 + - 25336 + - 25337 + - 25338 + - 25339 + - 25340 + - 25341 + - 25342 + - 25343 + - 25344 + - 25345 + - 25346 + - 25347 + - 25348 + - 25349 + - 25350 + - 25351 + - 25352 + - 25353 + - 25354 + - 25355 + - 25356 + - 25357 + - 25358 + - 25359 + - 25360 + - 25361 + - 25362 + - 25363 + - 25364 + - 25365 + - 25366 + - 25367 + - 25368 + - 25369 + - 25370 + - 25371 + - 25372 + - 25373 + - 25374 + - 25375 + - 25376 + - 25377 + - 25378 + - 25379 + - 25380 + - 25381 + - 25382 + - 25383 + - 25384 + - 25385 + - 25386 + - 25387 + - 25388 + - 25389 + - 25390 + - 25391 + - 25392 + - 25393 + - 25394 + - 25395 + - 25396 + - 25397 + - 25398 + - 25399 + - 25400 + - 25401 + - 25402 + - 25403 + - 25404 + - 25405 + - 25406 + - 25407 + - 25408 + - 25409 + - 25410 + - 25411 + - 25412 + - 25413 + - 25414 + - 25415 + - 25416 + - 25417 + - 25418 + - 25419 + - 25420 + - 25421 + - 25422 + - 25423 + - 25424 + - 25425 + - 25426 + - 25427 + - 25428 + - 25429 + - 25430 + - 25431 + - 25432 + - 25433 + - 25434 + - 25435 + - 25436 + - 25437 + - 25438 + - 25439 + - 25440 + - 25441 + - 25442 + - 25443 + - 25444 + - 25445 + - 25446 + - 25447 + - 25448 + - 25449 + - 25450 + - 25451 + - 25452 + - 25453 + - 25454 + - 25455 + - 25456 + - 25457 + - 25458 + - 25459 + - 25460 + - 25461 + - 25462 + - 25463 + - 25464 + - 25465 + - 25466 + - 25467 + - 25468 + - 25469 + - 25470 + - 25471 + - 25472 + - 25473 + - 25474 + - 25475 + - 25476 + - 25477 + - 25478 + - 25479 + - 25480 + - 25481 + - 25482 + - 25483 + - 25484 + - 25485 + - 25486 + - 25487 + - 25488 + - 25489 + - 25490 + - 25491 + - 25492 + - 25493 + - 25494 + - 25495 + - 25496 + - 25497 + - 25498 + - 25499 + - 25500 + - 25501 + - 25502 + - 25503 + - 25504 + - 25505 + - 25506 + - 25507 + - 25508 + - 25509 + - 25510 + - 25511 + - 25512 + - 25513 + - 25514 + - 25515 + - 25516 + - 25517 + - 25518 + - 25519 + - 25520 + - 25521 + - 25522 + - 25523 + - 25524 + - 25525 + - 25526 + - 25527 + - 25528 + - 25529 + - 25530 + - 25531 + - 25532 + - 25533 + - 25534 + - 25535 + - 25536 + - 25537 + - 25538 + - 25539 + - 25540 + - 25541 + - 25542 + - 25543 + - 25544 + - 25545 + - 25546 + - 25547 + - 25548 + - 25549 + - 25550 + - 25551 + - 25552 + - 25553 + - 25554 + - 25555 + - 25556 + - 25557 + - 25558 + - 25559 + - 25560 + - 25561 + - 25562 + - 25563 + - 25564 + - 25565 + - 25566 + - 25567 + - 25568 + - 25569 + - 25570 + - 25571 + - 25572 + - 25573 + - 25574 + - 25575 + - 25576 + - 25577 + - 25578 + - 25579 + - 25580 + - 25581 + - 25582 + - 25583 + - 25584 + - 25585 + - 25586 + - 25587 + - 25588 + - 25589 + - 25590 + - 25591 + - 25592 + - 25593 + - 25594 + - 25595 + - 25596 + - 25597 + - 25598 + - 25599 + - 25600 + - 25601 + - 25602 + - 25603 + - 25604 + - 25605 + - 25606 + - 25607 + - 25608 + - 25609 + - 25610 + - 25611 + - 25612 + - 25613 + - 25614 + - 25615 + - 25616 + - 25617 + - 25618 + - 25619 + - 25620 + - 25621 + - 25622 + - 25623 + - 25624 + - 25625 + - 25626 + - 25627 + - 25628 + - 25629 + - 25630 + - 25631 + - 25632 + - 25633 + - 25634 + - 25635 + - 25636 + - 25637 + - 25638 + - 25639 + - 25640 + - 25641 + - 25642 + - 25643 + - 25644 + - 25645 + - 25646 + - 25647 + - 25648 + - 25649 + - 25650 + - 25651 + - 25652 + - 25653 + - 25654 + - 25655 + - 25656 + - 25657 + - 25658 + - 25659 + - 25660 + - 25661 + - 25662 + - 25663 + - 25664 + - 25665 + - 25666 + - 25667 + - 25668 + - 25669 + - 25670 + - 25671 + - 25672 + - 25673 + - 25674 + - 25675 + - 25676 + - 25677 + - 25678 + - 25679 + - 25680 + - 25681 + - 25682 + - 25683 + - 25684 + - 25685 + - 25686 + - 25687 + - 25688 + - 25689 + - 25690 + - 25691 + - 25692 + - 25693 + - 25694 + - 25695 + - 25696 + - 25697 + - 25698 + - 25699 + - 25700 + - 25701 + - 25702 + - 25703 + - 25704 + - 25705 + - 25706 + - 25707 + - 25708 + - 25709 + - 25710 + - 25711 + - 25712 + - 25713 + - 25714 + - 25715 + - 25716 + - 25717 + - 25718 + - 25719 + - 25720 + - 25721 + - 25722 + - 25723 + - 25724 + - 25725 + - 25726 + - 25727 + - 25728 + - 25729 + - 25730 + - 25731 + - 25732 + - 25733 + - 25734 + - 25735 + - 25736 + - 25737 + - 25738 + - 25739 + - 25740 + - 25741 + - 25742 + - 25743 + - 25744 + - 25745 + - 25746 + - 25747 + - 25748 + - 25749 + - 25750 + - 25751 + - 25752 + - 25753 + - 25754 + - 25755 + - 25756 + - 25757 + - 25758 + - 25759 + - 25760 + - 25761 + - 25762 + - 25763 + - 25764 + - 25765 + - 25766 + - 25767 + - 25768 + - 25769 + - 25770 + - 25771 + - 25772 + - 25773 + - 25774 + - 25775 + - 25776 + - 25777 + - 25778 + - 25779 + - 25780 + - 25781 + - 25782 + - 25783 + - 25784 + - 25785 + - 25786 + - 25787 + - 25788 + - 25789 + - 25790 + - 25791 + - 25792 + - 25793 + - 25794 + - 25795 + - 25796 + - 25797 + - 25798 + - 25799 + - 25800 + - 25801 + - 25802 + - 25803 + - 25804 + - 25805 + - 25806 + - 25807 + - 25808 + - 25809 + - 25810 + - 25811 + - 25812 + - 25813 + - 25814 + - 25815 + - 25816 + - 25817 + - 25818 + - 25819 + - 25820 + - 25821 + - 25822 + - 25823 + - 25824 + - 25825 + - 25826 + - 25827 + - 25828 + - 25829 + - 25830 + - 25831 + - 25832 + - 25833 + - 25834 + - 25835 + - 25836 + - 25837 + - 25838 + - 25839 + - 25840 + - 25841 + - 25842 + - 25843 + - 25844 + - 25845 + - 25846 + - 25847 + - 25848 + - 25849 + - 25850 + - 25851 + - 25852 + - 25853 + - 25854 + - 25855 + - 25856 + - 25857 + - 25858 + - 25859 + - 25860 + - 25861 + - 25862 + - 25863 + - 25864 + - 25865 + - 25866 + - 25867 + - 25868 + - 25869 + - 25870 + - 25871 + - 25872 + - 25873 + - 25874 + - 25875 + - 25876 + - 25877 + - 25878 + - 25879 + - 25880 + - 25881 + - 25882 + - 25883 + - 25884 + - 25885 + - 25886 + - 25887 + - 25888 + - 25889 + - 25890 + - 25891 + - 25892 + - 25893 + - 25894 + - 25895 + - 25896 + - 25897 + - 25898 + - 25899 + - 25900 + - 25901 + - 25902 + - 25903 + - 25904 + - 25905 + - 25906 + - 25907 + - 25908 + - 25909 + - 25910 + - 25911 + - 25912 + - 25913 + - 25914 + - 25915 + - 25916 + - 25917 + - 25918 + - 25919 + - 25920 + - 25921 + - 25922 + - 25923 + - 25924 + - 25925 + - 25926 + - 25927 + - 25928 + - 25929 + - 25930 + - 25931 + - 25932 + - 25933 + - 25934 + - 25935 + - 25936 + - 25937 + - 25938 + - 25939 + - 25940 + - 25941 + - 25942 + - 25943 + - 25944 + - 25945 + - 25946 + - 25947 + - 25948 + - 25949 + - 25950 + - 25951 + - 25952 + - 25953 + - 25954 + - 25955 + - 25956 + - 25957 + - 25958 + - 25959 + - 25960 + - 25961 + - 25962 + - 25963 + - 25964 + - 25965 + - 25966 + - 25967 + - 25968 + - 25969 + - 25970 + - 25971 + - 25972 + - 25973 + - 25974 + - 25975 + - 25976 + - 25977 + - 25978 + - 25979 + - 25980 + - 25981 + - 25982 + - 25983 + - 25984 + - 25985 + - 25986 + - 25987 + - 25988 + - 25989 + - 25990 + - 25991 + - 25992 + - 25993 + - 25994 + - 25995 + - 25996 + - 25997 + - 25998 + - 25999 + - 26000 + - 26001 + - 26002 + - 26003 + - 26004 + - 26005 + - 26006 + - 26007 + - 26008 + - 26009 + - 26010 + - 26011 + - 26012 + - 26013 + - 26014 + - 26015 + - 26016 + - 26017 + - 26018 + - 26019 + - 26020 + - 26021 + - 26022 + - 26023 + - 26024 + - 26025 + - 26026 + - 26027 + - 26028 + - 26029 + - 26030 + - 26031 + - 26032 + - 26033 + - 26034 + - 26035 + - 26036 + - 26037 + - 26038 + - 26039 + - 26040 + - 26041 + - 26042 + - 26043 + - 26044 + - 26045 + - 26046 + - 26047 + - 26048 + - 26049 + - 26050 + - 26051 + - 26052 + - 26053 + - 26054 + - 26055 + - 26056 + - 26057 + - 26058 + - 26059 + - 26060 + - 26061 + - 26062 + - 26063 + - 26064 + - 26065 + - 26066 + - 26067 + - 26068 + - 26069 + - 26070 + - 26071 + - 26072 + - 26073 + - 26074 + - 26075 + - 26076 + - 26077 + - 26078 + - 26079 + - 26080 + - 26081 + - 26082 + - 26083 + - 26084 + - 26085 + - 26086 + - 26087 + - 26088 + - 26089 + - 26090 + - 26091 + - 26092 + - 26093 + - 26094 + - 26095 + - 26096 + - 26097 + - 26098 + - 26099 + - 26100 + - 26101 + - 26102 + - 26103 + - 26104 + - 26105 + - 26106 + - 26107 + - 26108 + - 26109 + - 26110 + - 26111 + - 26112 + - 26113 + - 26114 + - 26115 + - 26116 + - 26117 + - 26118 + - 26119 + - 26120 + - 26121 + - 26122 + - 26123 + - 26124 + - 26125 + - 26126 + - 26127 + - 26128 + - 26129 + - 26130 + - 26131 + - 26132 + - 26133 + - 26134 + - 26135 + - 26136 + - 26137 + - 26138 + - 26139 + - 26140 + - 26141 + - 26142 + - 26143 + - 26144 + - 26145 + - 26146 + - 26147 + - 26148 + - 26149 + - 26150 + - 26151 + - 26152 + - 26153 + - 26154 + - 26155 + - 26156 + - 26157 + - 26158 + - 26159 + - 26160 + - 26161 + - 26162 + - 26163 + - 26164 + - 26165 + - 26166 + - 26167 + - 26168 + - 26169 + - 26170 + - 26171 + - 26172 + - 26173 + - 26174 + - 26175 + - 26176 + - 26177 + - 26178 + - 26179 + - 26180 + - 26181 + - 26182 + - 26183 + - 26184 + - 26185 + - 26186 + - 26187 + - 26188 + - 26189 + - 26190 + - 26191 + - 26192 + - 26193 + - 26194 + - 26195 + - 26196 + - 26197 + - 26198 + - 26199 + - 26200 + - 26201 + - 26202 + - 26203 + - 26204 + - 26205 + - 26206 + - 26207 + - 26208 + - 26209 + - 26210 + - 26211 + - 26212 + - 26213 + - 26214 + - 26215 + - 26216 + - 26217 + - 26218 + - 26219 + - 26220 + - 26221 + - 26222 + - 26223 + - 26224 + - 26225 + - 26226 + - 26227 + - 26228 + - 26229 + - 26230 + - 26231 + - 26232 + - 26233 + - 26234 + - 26235 + - 26236 + - 26237 + - 26238 + - 26239 + - 26240 + - 26241 + - 26242 + - 26243 + - 26244 + - 26245 + - 26246 + - 26247 + - 26248 + - 26249 + - 26250 + - 26251 + - 26252 + - 26253 + - 26254 + - 26255 + - 26256 + - 26257 + - 26258 + - 26259 + - 26260 + - 26261 + - 26262 + - 26263 + - 26264 + - 26265 + - 26266 + - 26267 + - 26268 + - 26269 + - 26270 + - 26271 + - 26272 + - 26273 + - 26274 + - 26275 + - 26276 + - 26277 + - 26278 + - 26279 + - 26280 + - 26281 + - 26282 + - 26283 + - 26284 + - 26285 + - 26286 + - 26287 + - 26288 + - 26289 + - 26290 + - 26291 + - 26292 + - 26293 + - 26294 + - 26295 + - 26296 + - 26297 + - 26298 + - 26299 + - 26300 + - 26301 + - 26302 + - 26303 + - 26304 + - 26305 + - 26306 + - 26307 + - 26308 + - 26309 + - 26310 + - 26311 + - 26312 + - 26313 + - 26314 + - 26315 + - 26316 + - 26317 + - 26318 + - 26319 + - 26320 + - 26321 + - 26322 + - 26323 + - 26324 + - 26325 + - 26326 + - 26327 + - 26328 + - 26329 + - 26330 + - 26331 + - 26332 + - 26333 + - 26334 + - 26335 + - 26336 + - 26337 + - 26338 + - 26339 + - 26340 + - 26341 + - 26342 + - 26343 + - 26344 + - 26345 + - 26346 + - 26347 + - 26348 + - 26349 + - 26350 + - 26351 + - 26352 + - 26353 + - 26354 + - 26355 + - 26356 + - 26357 + - 26358 + - 26359 + - 26360 + - 26361 + - 26362 + - 26363 + - 26364 + - 26365 + - 26366 + - 26367 + - 26368 + - 26369 + - 26370 + - 26371 + - 26372 + - 26373 + - 26374 + - 26375 + - 26376 + - 26377 + - 26378 + - 26379 + - 26380 + - 26381 + - 26382 + - 26383 + - 26384 + - 26385 + - 26386 + - 26387 + - 26388 + - 26389 + - 26390 + - 26391 + - 26392 + - 26393 + - 26394 + - 26395 + - 26396 + - 26397 + - 26398 + - 26399 + - 26400 + - 26401 + - 26402 + - 26403 + - 26404 + - 26405 + - 26406 + - 26407 + - 26408 + - 26409 + - 26410 + - 26411 + - 26412 + - 26413 + - 26414 + - 26415 + - 26416 + - 26417 + - 26418 + - 26419 + - 26420 + - 26421 + - 26422 + - 26423 + - 26424 + - 26425 + - 26426 + - 26427 + - 26428 + - 26429 + - 26430 + - 26431 + - 26432 + - 26433 + - 26434 + - 26435 + - 26436 + - 26437 + - 26438 + - 26439 + - 26440 + - 26441 + - 26442 + - 26443 + - 26444 + - 26445 + - 26446 + - 26447 + - 26448 + - 26449 + - 26450 + - 26451 + - 26452 + - 26453 + - 26454 + - 26455 + - 26456 + - 26457 + - 26458 + - 26459 + - 26460 + - 26461 + - 26462 + - 26463 + - 26464 + - 26465 + - 26466 + - 26467 + - 26468 + - 26469 + - 26470 + - 26471 + - 26472 + - 26473 + - 26474 + - 26475 + - 26476 + - 26477 + - 26478 + - 26479 + - 26480 + - 26481 + - 26482 + - 26483 + - 26484 + - 26485 + - 26486 + - 26487 + - 26488 + - 26489 + - 26490 + - 26491 + - 26492 + - 26493 + - 26494 + - 26495 + - 26496 + - 26497 + - 26498 + - 26499 + - 26500 + - 26501 + - 26502 + - 26503 + - 26504 + - 26505 + - 26506 + - 26507 + - 26508 + - 26509 + - 26510 + - 26511 + - 26512 + - 26513 + - 26514 + - 26515 + - 26516 + - 26517 + - 26518 + - 26519 + - 26520 + - 26521 + - 26522 + - 26523 + - 26524 + - 26525 + - 26526 + - 26527 + - 26528 + - 26529 + - 26530 + - 26531 + - 26532 + - 26533 + - 26534 + - 26535 + - 26536 + - 26537 + - 26538 + - 26539 + - 26540 + - 26541 + - 26542 + - 26543 + - 26544 + - 26545 + - 26546 + - 26547 + - 26548 + - 26549 + - 26550 + - 26551 + - 26552 + - 26553 + - 26554 + - 26555 + - 26556 + - 26557 + - 26558 + - 26559 + - 26560 + - 26561 + - 26562 + - 26563 + - 26564 + - 26565 + - 26566 + - 26567 + - 26568 + - 26569 + - 26570 + - 26571 + - 26572 + - 26573 + - 26574 + - 26575 + - 26576 + - 26577 + - 26578 + - 26579 + - 26580 + - 26581 + - 26582 + - 26583 + - 26584 + - 26585 + - 26586 + - 26587 + - 26588 + - 26589 + - 26590 + - 26591 + - 26592 + - 26593 + - 26594 + - 26595 + - 26596 + - 26597 + - 26598 + - 26599 + - 26600 + - 26601 + - 26602 + - 26603 + - 26604 + - 26605 + - 26606 + - 26607 + - 26608 + - 26609 + - 26610 + - 26611 + - 26612 + - 26613 + - 26614 + - 26615 + - 26616 + - 26617 + - 26618 + - 26619 + - 26620 + - 26621 + - 26622 + - 26623 + - 26624 + - 26625 + - 26626 + - 26627 + - 26628 + - 26629 + - 26630 + - 26631 + - 26632 + - 26633 + - 26634 + - 26635 + - 26636 + - 26637 + - 26638 + - 26639 + - 26640 + - 26641 + - 26642 + - 26643 + - 26644 + - 26645 + - 26646 + - 26647 + - 26648 + - 26649 + - 26650 + - 26651 + - 26652 + - 26653 + - 26654 + - 26655 + - 26656 + - 26657 + - 26658 + - 26659 + - 26660 + - 26661 + - 26662 + - 26663 + - 26664 + - 26665 + - 26666 + - 26667 + - 26668 + - 26669 + - 26670 + - 26671 + - 26672 + - 26673 + - 26674 + - 26675 + - 26676 + - 26677 + - 26678 + - 26679 + - 26680 + - 26681 + - 26682 + - 26683 + - 26684 + - 26685 + - 26686 + - 26687 + - 26688 + - 26689 + - 26690 + - 26691 + - 26692 + - 26693 + - 26694 + - 26695 + - 26696 + - 26697 + - 26698 + - 26699 + - 26700 + - 26701 + - 26702 + - 26703 + - 26704 + - 26705 + - 26706 + - 26707 + - 26708 + - 26709 + - 26710 + - 26711 + - 26712 + - 26713 + - 26714 + - 26715 + - 26716 + - 26717 + - 26718 + - 26719 + - 26720 + - 26721 + - 26722 + - 26723 + - 26724 + - 26725 + - 26726 + - 26727 + - 26728 + - 26729 + - 26730 + - 26731 + - 26732 + - 26733 + - 26734 + - 26735 + - 26736 + - 26737 + - 26738 + - 26739 + - 26740 + - 26741 + - 26742 + - 26743 + - 26744 + - 26745 + - 26746 + - 26747 + - 26748 + - 26749 + - 26750 + - 26751 + - 26752 + - 26753 + - 26754 + - 26755 + - 26756 + - 26757 + - 26758 + - 26759 + - 26760 + - 26761 + - 26762 + - 26763 + - 26764 + - 26765 + - 26766 + - 26767 + - 26768 + - 26769 + - 26770 + - 26771 + - 26772 + - 26773 + - 26774 + - 26775 + - 26776 + - 26777 + - 26778 + - 26779 + - 26780 + - 26781 + - 26782 + - 26783 + - 26784 + - 26785 + - 26786 + - 26787 + - 26788 + - 26789 + - 26790 + - 26791 + - 26792 + - 26793 + - 26794 + - 26795 + - 26796 + - 26797 + - 26798 + - 26799 + - 26800 + - 26801 + - 26802 + - 26803 + - 26804 + - 26805 + - 26806 + - 26807 + - 26808 + - 26809 + - 26810 + - 26811 + - 26812 + - 26813 + - 26814 + - 26815 + - 26816 + - 26817 + - 26818 + - 26819 + - 26820 + - 26821 + - 26822 + - 26823 + - 26824 + - 26825 + - 26826 + - 26827 + - 26828 + - 26829 + - 26830 + - 26831 + - 26832 + - 26833 + - 26834 + - 26835 + - 26836 + - 26837 + - 26838 + - 26839 + - 26840 + - 26841 + - 26842 + - 26843 + - 26844 + - 26845 + - 26846 + - 26847 + - 26848 + - 26849 + - 26850 + - 26851 + - 26852 + - 26853 + - 26854 + - 26855 + - 26856 + - 26857 + - 26858 + - 26859 + - 26860 + - 26861 + - 26862 + - 26863 + - 26864 + - 26865 + - 26866 + - 26867 + - 26868 + - 26869 + - 26870 + - 26871 + - 26872 + - 26873 + - 26874 + - 26875 + - 26876 + - 26877 + - 26878 + - 26879 + - 26880 + - 26881 + - 26882 + - 26883 + - 26884 + - 26885 + - 26886 + - 26887 + - 26888 + - 26889 + - 26890 + - 26891 + - 26892 + - 26893 + - 26894 + - 26895 + - 26896 + - 26897 + - 26898 + - 26899 + - 26900 + - 26901 + - 26902 + - 26903 + - 26904 + - 26905 + - 26906 + - 26907 + - 26908 + - 26909 + - 26910 + - 26911 + - 26912 + - 26913 + - 26914 + - 26915 + - 26916 + - 26917 + - 26918 + - 26919 + - 26920 + - 26921 + - 26922 + - 26923 + - 26924 + - 26925 + - 26926 + - 26927 + - 26928 + - 26929 + - 26930 + - 26931 + - 26932 + - 26933 + - 26934 + - 26935 + - 26936 + - 26937 + - 26938 + - 26939 + - 26940 + - 26941 + - 26942 + - 26943 + - 26944 + - 26945 + - 26946 + - 26947 + - 26948 + - 26949 + - 26950 + - 26951 + - 26952 + - 26953 + - 26954 + - 26955 + - 26956 + - 26957 + - 26958 + - 26959 + - 26960 + - 26961 + - 26962 + - 26963 + - 26964 + - 26965 + - 26966 + - 26967 + - 26968 + - 26969 + - 26970 + - 26971 + - 26972 + - 26973 + - 26974 + - 26975 + - 26976 + - 26977 + - 26978 + - 26979 + - 26980 + - 26981 + - 26982 + - 26983 + - 26984 + - 26985 + - 26986 + - 26987 + - 26988 + - 26989 + - 26990 + - 26991 + - 26992 + - 26993 + - 26994 + - 26995 + - 26996 + - 26997 + - 26998 + - 26999 + - 27000 + - 27001 + - 27002 + - 27003 + - 27004 + - 27005 + - 27006 + - 27007 + - 27008 + - 27009 + - 27010 + - 27011 + - 27012 + - 27013 + - 27014 + - 27015 + - 27016 + - 27017 + - 27018 + - 27019 + - 27020 + - 27021 + - 27022 + - 27023 + - 27024 + - 27025 + - 27026 + - 27027 + - 27028 + - 27029 + - 27030 + - 27031 + - 27032 + - 27033 + - 27034 + - 27035 + - 27036 + - 27037 + - 27038 + - 27039 + - 27040 + - 27041 + - 27042 + - 27043 + - 27044 + - 27045 + - 27046 + - 27047 + - 27048 + - 27049 + - 27050 + - 27051 + - 27052 + - 27053 + - 27054 + - 27055 + - 27056 + - 27057 + - 27058 + - 27059 + - 27060 + - 27061 + - 27062 + - 27063 + - 27064 + - 27065 + - 27066 + - 27067 + - 27068 + - 27069 + - 27070 + - 27071 + - 27072 + - 27073 + - 27074 + - 27075 + - 27076 + - 27077 + - 27078 + - 27079 + - 27080 + - 27081 + - 27082 + - 27083 + - 27084 + - 27085 + - 27086 + - 27087 + - 27088 + - 27089 + - 27090 + - 27091 + - 27092 + - 27093 + - 27094 + - 27095 + - 27096 + - 27097 + - 27098 + - 27099 + - 27100 + - 27101 + - 27102 + - 27103 + - 27104 + - 27105 + - 27106 + - 27107 + - 27108 + - 27109 + - 27110 + - 27111 + - 27112 + - 27113 + - 27114 + - 27115 + - 27116 + - 27117 + - 27118 + - 27119 + - 27120 + - 27121 + - 27122 + - 27123 + - 27124 + - 27125 + - 27126 + - 27127 + - 27128 + - 27129 + - 27130 + - 27131 + - 27132 + - 27133 + - 27134 + - 27135 + - 27136 + - 27137 + - 27138 + - 27139 + - 27140 + - 27141 + - 27142 + - 27143 + - 27144 + - 27145 + - 27146 + - 27147 + - 27148 + - 27149 + - 27150 + - 27151 + - 27152 + - 27153 + - 27154 + - 27155 + - 27156 + - 27157 + - 27158 + - 27159 + - 27160 + - 27161 + - 27162 + - 27163 + - 27164 + - 27165 + - 27166 + - 27167 + - 27168 + - 27169 + - 27170 + - 27171 + - 27172 + - 27173 + - 27174 + - 27175 + - 27176 + - 27177 + - 27178 + - 27179 + - 27180 + - 27181 + - 27182 + - 27183 + - 27184 + - 27185 + - 27186 + - 27187 + - 27188 + - 27189 + - 27190 + - 27191 + - 27192 + - 27193 + - 27194 + - 27195 + - 27196 + - 27197 + - 27198 + - 27199 + - 27200 + - 27201 + - 27202 + - 27203 + - 27204 + - 27205 + - 27206 + - 27207 + - 27208 + - 27209 + - 27210 + - 27211 + - 27212 + - 27213 + - 27214 + - 27215 + - 27216 + - 27217 + - 27218 + - 27219 + - 27220 + - 27221 + - 27222 + - 27223 + - 27224 + - 27225 + - 27226 + - 27227 + - 27228 + - 27229 + - 27230 + - 27231 + - 27232 + - 27233 + - 27234 + - 27235 + - 27236 + - 27237 + - 27238 + - 27239 + - 27240 + - 27241 + - 27242 + - 27243 + - 27244 + - 27245 + - 27246 + - 27247 + - 27248 + - 27249 + - 27250 + - 27251 + - 27252 + - 27253 + - 27254 + - 27255 + - 27256 + - 27257 + - 27258 + - 27259 + - 27260 + - 27261 + - 27262 + - 27263 + - 27264 + - 27265 + - 27266 + - 27267 + - 27268 + - 27269 + - 27270 + - 27271 + - 27272 + - 27273 + - 27274 + - 27275 + - 27276 + - 27277 + - 27278 + - 27279 + - 27280 + - 27281 + - 27282 + - 27283 + - 27284 + - 27285 + - 27286 + - 27287 + - 27288 + - 27289 + - 27290 + - 27291 + - 27292 + - 27293 + - 27294 + - 27295 + - 27296 + - 27297 + - 27298 + - 27299 + - 27300 + - 27301 + - 27302 + - 27303 + - 27304 + - 27305 + - 27306 + - 27307 + - 27308 + - 27309 + - 27310 + - 27311 + - 27312 + - 27313 + - 27314 + - 27315 + - 27316 + - 27317 + - 27318 + - 27319 + - 27320 + - 27321 + - 27322 + - 27323 + - 27324 + - 27325 + - 27326 + - 27327 + - 27328 + - 27329 + - 27330 + - 27331 + - 27332 + - 27333 + - 27334 + - 27335 + - 27336 + - 27337 + - 27338 + - 27339 + - 27340 + - 27341 + - 27342 + - 27343 + - 27344 + - 27345 + - 27346 + - 27347 + - 27348 + - 27349 + - 27350 + - 27351 + - 27352 + - 27353 + - 27354 + - 27355 + - 27356 + - 27357 + - 27358 + - 27359 + - 27360 + - 27361 + - 27362 + - 27363 + - 27364 + - 27365 + - 27366 + - 27367 + - 27368 + - 27369 + - 27370 + - 27371 + - 27372 + - 27373 + - 27374 + - 27375 + - 27376 + - 27377 + - 27378 + - 27379 + - 27380 + - 27381 + - 27382 + - 27383 + - 27384 + - 27385 + - 27386 + - 27387 + - 27388 + - 27389 + - 27390 + - 27391 + - 27392 + - 27393 + - 27394 + - 27395 + - 27396 + - 27397 + - 27398 + - 27399 + - 27400 + - 27401 + - 27402 + - 27403 + - 27404 + - 27405 + - 27406 + - 27407 + - 27408 + - 27409 + - 27410 + - 27411 + - 27412 + - 27413 + - 27414 + - 27415 + - 27416 + - 27417 + - 27418 + - 27419 + - 27420 + - 27421 + - 27422 + - 27423 + - 27424 + - 27425 + - 27426 + - 27427 + - 27428 + - 27429 + - 27430 + - 27431 + - 27432 + - 27433 + - 27434 + - 27435 + - 27436 + - 27437 + - 27438 + - 27439 + - 27440 + - 27441 + - 27442 + - 27443 + - 27444 + - 27445 + - 27446 + - 27447 + - 27448 + - 27449 + - 27450 + - 27451 + - 27452 + - 27453 + - 27454 + - 27455 + - 27456 + - 27457 + - 27458 + - 27459 + - 27460 + - 27461 + - 27462 + - 27463 + - 27464 + - 27465 + - 27466 + - 27467 + - 27468 + - 27469 + - 27470 + - 27471 + - 27472 + - 27473 + - 27474 + - 27475 + - 27476 + - 27477 + - 27478 + - 27479 + - 27480 + - 27481 + - 27482 + - 27483 + - 27484 + - 27485 + - 27486 + - 27487 + - 27488 + - 27489 + - 27490 + - 27491 + - 27492 + - 27493 + - 27494 + - 27495 + - 27496 + - 27497 + - 27498 + - 27499 + - 27500 + - 27501 + - 27502 + - 27503 + - 27504 + - 27505 + - 27506 + - 27507 + - 27508 + - 27509 + - 27510 + - 27511 + - 27512 + - 27513 + - 27514 + - 27515 + - 27516 + - 27517 + - 27518 + - 27519 + - 27520 + - 27521 + - 27522 + - 27523 + - 27524 + - 27525 + - 27526 + - 27527 + - 27528 + - 27529 + - 27530 + - 27531 + - 27532 + - 27533 + - 27534 + - 27535 + - 27536 + - 27537 + - 27538 + - 27539 + - 27540 + - 27541 + - 27542 + - 27543 + - 27544 + - 27545 + - 27546 + - 27547 + - 27548 + - 27549 + - 27550 + - 27551 + - 27552 + - 27553 + - 27554 + - 27555 + - 27556 + - 27557 + - 27558 + - 27559 + - 27560 + - 27561 + - 27562 + - 27563 + - 27564 + - 27565 + - 27566 + - 27567 + - 27568 + - 27569 + - 27570 + - 27571 + - 27572 + - 27573 + - 27574 + - 27575 + - 27576 + - 27577 + - 27578 + - 27579 + - 27580 + - 27581 + - 27582 + - 27583 + - 27584 + - 27585 + - 27586 + - 27587 + - 27588 + - 27589 + - 27590 + - 27591 + - 27592 + - 27593 + - 27594 + - 27595 + - 27596 + - 27597 + - 27598 + - 27599 + - 27600 + - 27601 + - 27602 + - 27603 + - 27604 + - 27605 + - 27606 + - 27607 + - 27608 + - 27609 + - 27610 + - 27611 + - 27612 + - 27613 + - 27614 + - 27615 + - 27616 + - 27617 + - 27618 + - 27619 + - 27620 + - 27621 + - 27622 + - 27623 + - 27624 + - 27625 + - 27626 + - 27627 + - 27628 + - 27629 + - 27630 + - 27631 + - 27632 + - 27633 + - 27634 + - 27635 + - 27636 + - 27637 + - 27638 + - 27639 + - 27640 + - 27641 + - 27642 + - 27643 + - 27644 + - 27645 + - 27646 + - 27647 + - 27648 + - 27649 + - 27650 + - 27651 + - 27652 + - 27653 + - 27654 + - 27655 + - 27656 + - 27657 + - 27658 + - 27659 + - 27660 + - 27661 + - 27662 + - 27663 + - 27664 + - 27665 + - 27666 + - 27667 + - 27668 + - 27669 + - 27670 + - 27671 + - 27672 + - 27673 + - 27674 + - 27675 + - 27676 + - 27677 + - 27678 + - 27679 + - 27680 + - 27681 + - 27682 + - 27683 + - 27684 + - 27685 + - 27686 + - 27687 + - 27688 + - 27689 + - 27690 + - 27691 + - 27692 + - 27693 + - 27694 + - 27695 + - 27696 + - 27697 + - 27698 + - 27699 + - 27700 + - 27701 + - 27702 + - 27703 + - 27704 + - 27705 + - 27706 + - 27707 + - 27708 + - 27709 + - 27710 + - 27711 + - 27712 + - 27713 + - 27714 + - 27715 + - 27716 + - 27717 + - 27718 + - 27719 + - 27720 + - 27721 + - 27722 + - 27723 + - 27724 + - 27725 + - 27726 + - 27727 + - 27728 + - 27729 + - 27730 + - 27731 + - 27732 + - 27733 + - 27734 + - 27735 + - 27736 + - 27737 + - 27738 + - 27739 + - 27740 + - 27741 + - 27742 + - 27743 + - 27744 + - 27745 + - 27746 + - 27747 + - 27748 + - 27749 + - 27750 + - 27751 + - 27752 + - 27753 + - 27754 + - 27755 + - 27756 + - 27757 + - 27758 + - 27759 + - 27760 + - 27761 + - 27762 + - 27763 + - 27764 + - 27765 + - 27766 + - 27767 + - 27768 + - 27769 + - 27770 + - 27771 + - 27772 + - 27773 + - 27774 + - 27775 + - 27776 + - 27777 + - 27778 + - 27779 + - 27780 + - 27781 + - 27782 + - 27783 + - 27784 + - 27785 + - 27786 + - 27787 + - 27788 + - 27789 + - 27790 + - 27791 + - 27792 + - 27793 + - 27794 + - 27795 + - 27796 + - 27797 + - 27798 + - 27799 + - 27800 + - 27801 + - 27802 + - 27803 + - 27804 + - 27805 + - 27806 + - 27807 + - 27808 + - 27809 + - 27810 + - 27811 + - 27812 + - 27813 + - 27814 + - 27815 + - 27816 + - 27817 + - 27818 + - 27819 + - 27820 + - 27821 + - 27822 + - 27823 + - 27824 + - 27825 + - 27826 + - 27827 + - 27828 + - 27829 + - 27830 + - 27831 + - 27832 + - 27833 + - 27834 + - 27835 + - 27836 + - 27837 + - 27838 + - 27839 + - 27840 + - 27841 + - 27842 + - 27843 + - 27844 + - 27845 + - 27846 + - 27847 + - 27848 + - 27849 + - 27850 + - 27851 + - 27852 + - 27853 + - 27854 + - 27855 + - 27856 + - 27857 + - 27858 + - 27859 + - 27860 + - 27861 + - 27862 + - 27863 + - 27864 + - 27865 + - 27866 + - 27867 + - 27868 + - 27869 + - 27870 + - 27871 + - 27872 + - 27873 + - 27874 + - 27875 + - 27876 + - 27877 + - 27878 + - 27879 + - 27880 + - 27881 + - 27882 + - 27883 + - 27884 + - 27885 + - 27886 + - 27887 + - 27888 + - 27889 + - 27890 + - 27891 + - 27892 + - 27893 + - 27894 + - 27895 + - 27896 + - 27897 + - 27898 + - 27899 + - 27900 + - 27901 + - 27902 + - 27903 + - 27904 + - 27905 + - 27906 + - 27907 + - 27908 + - 27909 + - 27910 + - 27911 + - 27912 + - 27913 + - 27914 + - 27915 + - 27916 + - 27917 + - 27918 + - 27919 + - 27920 + - 27921 + - 27922 + - 27923 + - 27924 + - 27925 + - 27926 + - 27927 + - 27928 + - 27929 + - 27930 + - 27931 + - 27932 + - 27933 + - 27934 + - 27935 + - 27936 + - 27937 + - 27938 + - 27939 + - 27940 + - 27941 + - 27942 + - 27943 + - 27944 + - 27945 + - 27946 + - 27947 + - 27948 + - 27949 + - 27950 + - 27951 + - 27952 + - 27953 + - 27954 + - 27955 + - 27956 + - 27957 + - 27958 + - 27959 + - 27960 + - 27961 + - 27962 + - 27963 + - 27964 + - 27965 + - 27966 + - 27967 + - 27968 + - 27969 + - 27970 + - 27971 + - 27972 + - 27973 + - 27974 + - 27975 + - 27976 + - 27977 + - 27978 + - 27979 + - 27980 + - 27981 + - 27982 + - 27983 + - 27984 + - 27985 + - 27986 + - 27987 + - 27988 + - 27989 + - 27990 + - 27991 + - 27992 + - 27993 + - 27994 + - 27995 + - 27996 + - 27997 + - 27998 + - 27999 + - 28000 + - 28001 + - 28002 + - 28003 + - 28004 + - 28005 + - 28006 + - 28007 + - 28008 + - 28009 + - 28010 + - 28011 + - 28012 + - 28013 + - 28014 + - 28015 + - 28016 + - 28017 + - 28018 + - 28019 + - 28020 + - 28021 + - 28022 + - 28023 + - 28024 + - 28025 + - 28026 + - 28027 + - 28028 + - 28029 + - 28030 + - 28031 + - 28032 + - 28033 + - 28034 + - 28035 + - 28036 + - 28037 + - 28038 + - 28039 + - 28040 + - 28041 + - 28042 + - 28043 + - 28044 + - 28045 + - 28046 + - 28047 + - 28048 + - 28049 + - 28050 + - 28051 + - 28052 + - 28053 + - 28054 + - 28055 + - 28056 + - 28057 + - 28058 + - 28059 + - 28060 + - 28061 + - 28062 + - 28063 + - 28064 + - 28065 + - 28066 + - 28067 + - 28068 + - 28069 + - 28070 + - 28071 + - 28072 + - 28073 + - 28074 + - 28075 + - 28076 + - 28077 + - 28078 + - 28079 + - 28080 + - 28081 + - 28082 + - 28083 + - 28084 + - 28085 + - 28086 + - 28087 + - 28088 + - 28089 + - 28090 + - 28091 + - 28092 + - 28093 + - 28094 + - 28095 + - 28096 + - 28097 + - 28098 + - 28099 + - 28100 + - 28101 + - 28102 + - 28103 + - 28104 + - 28105 + - 28106 + - 28107 + - 28108 + - 28109 + - 28110 + - 28111 + - 28112 + - 28113 + - 28114 + - 28115 + - 28116 + - 28117 + - 28118 + - 28119 + - 28120 + - 28121 + - 28122 + - 28123 + - 28124 + - 28125 + - 28126 + - 28127 + - 28128 + - 28129 + - 28130 + - 28131 + - 28132 + - 28133 + - 28134 + - 28135 + - 28136 + - 28137 + - 28138 + - 28139 + - 28140 + - 28141 + - 28142 + - 28143 + - 28144 + - 28145 + - 28146 + - 28147 + - 28148 + - 28149 + - 28150 + - 28151 + - 28152 + - 28153 + - 28154 + - 28155 + - 28156 + - 28157 + - 28158 + - 28159 + - 28160 + - 28161 + - 28162 + - 28163 + - 28164 + - 28165 + - 28166 + - 28167 + - 28168 + - 28169 + - 28170 + - 28171 + - 28172 + - 28173 + - 28174 + - 28175 + - 28176 + - 28177 + - 28178 + - 28179 + - 28180 + - 28181 + - 28182 + - 28183 + - 28184 + - 28185 + - 28186 + - 28187 + - 28188 + - 28189 + - 28190 + - 28191 + - 28192 + - 28193 + - 28194 + - 28195 + - 28196 + - 28197 + - 28198 + - 28199 + - 28200 + - 28201 + - 28202 + - 28203 + - 28204 + - 28205 + - 28206 + - 28207 + - 28208 + - 28209 + - 28210 + - 28211 + - 28212 + - 28213 + - 28214 + - 28215 + - 28216 + - 28217 + - 28218 + - 28219 + - 28220 + - 28221 + - 28222 + - 28223 + - 28224 + - 28225 + - 28226 + - 28227 + - 28228 + - 28229 + - 28230 + - 28231 + - 28232 + - 28233 + - 28234 + - 28235 + - 28236 + - 28237 + - 28238 + - 28239 + - 28240 + - 28241 + - 28242 + - 28243 + - 28244 + - 28245 + - 28246 + - 28247 + - 28248 + - 28249 + - 28250 + - 28251 + - 28252 + - 28253 + - 28254 + - 28255 + - 28256 + - 28257 + - 28258 + - 28259 + - 28260 + - 28261 + - 28262 + - 28263 + - 28264 + - 28265 + - 28266 + - 28267 + - 28268 + - 28269 + - 28270 + - 28271 + - 28272 + - 28273 + - 28274 + - 28275 + - 28276 + - 28277 + - 28278 + - 28279 + - 28280 + - 28281 + - 28282 + - 28283 + - 28284 + - 28285 + - 28286 + - 28287 + - 28288 + - 28289 + - 28290 + - 28291 + - 28292 + - 28293 + - 28294 + - 28295 + - 28296 + - 28297 + - 28298 + - 28299 + - 28300 + - 28301 + - 28302 + - 28303 + - 28304 + - 28305 + - 28306 + - 28307 + - 28308 + - 28309 + - 28310 + - 28311 + - 28312 + - 28313 + - 28314 + - 28315 + - 28316 + - 28317 + - 28318 + - 28319 + - 28320 + - 28321 + - 28322 + - 28323 + - 28324 + - 28325 + - 28326 + - 28327 + - 28328 + - 28329 + - 28330 + - 28331 + - 28332 + - 28333 + - 28334 + - 28335 + - 28336 + - 28337 + - 28338 + - 28339 + - 28340 + - 28341 + - 28342 + - 28343 + - 28344 + - 28345 + - 28346 + - 28347 + - 28348 + - 28349 + - 28350 + - 28351 + - 28352 + - 28353 + - 28354 + - 28355 + - 28356 + - 28357 + - 28358 + - 28359 + - 28360 + - 28361 + - 28362 + - 28363 + - 28364 + - 28365 + - 28366 + - 28367 + - 28368 + - 28369 + - 28370 + - 28371 + - 28372 + - 28373 + - 28374 + - 28375 + - 28376 + - 28377 + - 28378 + - 28379 + - 28380 + - 28381 + - 28382 + - 28383 + - 28384 + - 28385 + - 28386 + - 28387 + - 28388 + - 28389 + - 28390 + - 28391 + - 28392 + - 28393 + - 28394 + - 28395 + - 28396 + - 28397 + - 28398 + - 28399 + - 28400 + - 28401 + - 28402 + - 28403 + - 28404 + - 28405 + - 28406 + - 28407 + - 28408 + - 28409 + - 28410 + - 28411 + - 28412 + - 28413 + - 28414 + - 28415 + - 28416 + - 28417 + - 28418 + - 28419 + - 28420 + - 28421 + - 28422 + - 28423 + - 28424 + - 28425 + - 28426 + - 28427 + - 28428 + - 28429 + - 28430 + - 28431 + - 28432 + - 28433 + - 28434 + - 28435 + - 28436 + - 28437 + - 28438 + - 28439 + - 28440 + - 28441 + - 28442 + - 28443 + - 28444 + - 28445 + - 28446 + - 28447 + - 28448 + - 28449 + - 28450 + - 28451 + - 28452 + - 28453 + - 28454 + - 28455 + - 28456 + - 28457 + - 28458 + - 28459 + - 28460 + - 28461 + - 28462 + - 28463 + - 28464 + - 28465 + - 28466 + - 28467 + - 28468 + - 28469 + - 28470 + - 28471 + - 28472 + - 28473 + - 28474 + - 28475 + - 28476 + - 28477 + - 28478 + - 28479 + - 28480 + - 28481 + - 28482 + - 28483 + - 28484 + - 28485 + - 28486 + - 28487 + - 28488 + - 28489 + - 28490 + - 28491 + - 28492 + - 28493 + - 28494 + - 28495 + - 28496 + - 28497 + - 28498 + - 28499 + - 28500 + - 28501 + - 28502 + - 28503 + - 28504 + - 28505 + - 28506 + - 28507 + - 28508 + - 28509 + - 28510 + - 28511 + - 28512 + - 28513 + - 28514 + - 28515 + - 28516 + - 28517 + - 28518 + - 28519 + - 28520 + - 28521 + - 28522 + - 28523 + - 28524 + - 28525 + - 28526 + - 28527 + - 28528 + - 28529 + - 28530 + - 28531 + - 28532 + - 28533 + - 28534 + - 28535 + - 28536 + - 28537 + - 28538 + - 28539 + - 28540 + - 28541 + - 28542 + - 28543 + - 28544 + - 28545 + - 28546 + - 28547 + - 28548 + - 28549 + - 28550 + - 28551 + - 28552 + - 28553 + - 28554 + - 28555 + - 28556 + - 28557 + - 28558 + - 28559 + - 28560 + - 28561 + - 28562 + - 28563 + - 28564 + - 28565 + - 28566 + - 28567 + - 28568 + - 28569 + - 28570 + - 28571 + - 28572 + - 28573 + - 28574 + - 28575 + - 28576 + - 28577 + - 28578 + - 28579 + - 28580 + - 28581 + - 28582 + - 28583 + - 28584 + - 28585 + - 28586 + - 28587 + - 28588 + - 28589 + - 28590 + - 28591 + - 28592 + - 28593 + - 28594 + - 28595 + - 28596 + - 28597 + - 28598 + - 28599 + - 28600 + - 28601 + - 28602 + - 28603 + - 28604 + - 28605 + - 28606 + - 28607 + - 28608 + - 28609 + - 28610 + - 28611 + - 28612 + - 28613 + - 28614 + - 28615 + - 28616 + - 28617 + - 28618 + - 28619 + - 28620 + - 28621 + - 28622 + - 28623 + - 28624 + - 28625 + - 28626 + - 28627 + - 28628 + - 28629 + - 28630 + - 28631 + - 28632 + - 28633 + - 28634 + - 28635 + - 28636 + - 28637 + - 28638 + - 28639 + - 28640 + - 28641 + - 28642 + - 28643 + - 28644 + - 28645 + - 28646 + - 28647 + - 28648 + - 28649 + - 28650 + - 28651 + - 28652 + - 28653 + - 28654 + - 28655 + - 28656 + - 28657 + - 28658 + - 28659 + - 28660 + - 28661 + - 28662 + - 28663 + - 28664 + - 28665 + - 28666 + - 28667 + - 28668 + - 28669 + - 28670 + - 28671 + - 28672 + - 28673 + - 28674 + - 28675 + - 28676 + - 28677 + - 28678 + - 28679 + - 28680 + - 28681 + - 28682 + - 28683 + - 28684 + - 28685 + - 28686 + - 28687 + - 28688 + - 28689 + - 28690 + - 28691 + - 28692 + - 28693 + - 28694 + - 28695 + - 28696 + - 28697 + - 28698 + - 28699 + - 28700 + - 28701 + - 28702 + - 28703 + - 28704 + - 28705 + - 28706 + - 28707 + - 28708 + - 28709 + - 28710 + - 28711 + - 28712 + - 28713 + - 28714 + - 28715 + - 28716 + - 28717 + - 28718 + - 28719 + - 28720 + - 28721 + - 28722 + - 28723 + - 28724 + - 28725 + - 28726 + - 28727 + - 28728 + - 28729 + - 28730 + - 28731 + - 28732 + - 28733 + - 28734 + - 28735 + - 28736 + - 28737 + - 28738 + - 28739 + - 28740 + - 28741 + - 28742 + - 28743 + - 28744 + - 28745 + - 28746 + - 28747 + - 28748 + - 28749 + - 28750 + - 28751 + - 28752 + - 28753 + - 28754 + - 28755 + - 28756 + - 28757 + - 28758 + - 28759 + - 28760 + - 28761 + - 28762 + - 28763 + - 28764 + - 28765 + - 28766 + - 28767 + - 28768 + - 28769 + - 28770 + - 28771 + - 28772 + - 28773 + - 28774 + - 28775 + - 28776 + - 28777 + - 28778 + - 28779 + - 28780 + - 28781 + - 28782 + - 28783 + - 28784 + - 28785 + - 28786 + - 28787 + - 28788 + - 28789 + - 28790 + - 28791 + - 28792 + - 28793 + - 28794 + - 28795 + - 28796 + - 28797 + - 28798 + - 28799 + - 28800 + - 28801 + - 28802 + - 28803 + - 28804 + - 28805 + - 28806 + - 28807 + - 28808 + - 28809 + - 28810 + - 28811 + - 28812 + - 28813 + - 28814 + - 28815 + - 28816 + - 28817 + - 28818 + - 28819 + - 28820 + - 28821 + - 28822 + - 28823 + - 28824 + - 28825 + - 28826 + - 28827 + - 28828 + - 28829 + - 28830 + - 28831 + - 28832 + - 28833 + - 28834 + - 28835 + - 28836 + - 28837 + - 28838 + - 28839 + - 28840 + - 28841 + - 28842 + - 28843 + - 28844 + - 28845 + - 28846 + - 28847 + - 28848 + - 28849 + - 28850 + - 28851 + - 28852 + - 28853 + - 28854 + - 28855 + - 28856 + - 28857 + - 28858 + - 28859 + - 28860 + - 28861 + - 28862 + - 28863 + - 28864 + - 28865 + - 28866 + - 28867 + - 28868 + - 28869 + - 28870 + - 28871 + - 28872 + - 28873 + - 28874 + - 28875 + - 28876 + - 28877 + - 28878 + - 28879 + - 28880 + - 28881 + - 28882 + - 28883 + - 28884 + - 28885 + - 28886 + - 28887 + - 28888 + - 28889 + - 28890 + - 28891 + - 28892 + - 28893 + - 28894 + - 28895 + - 28896 + - 28897 + - 28898 + - 28899 + - 28900 + - 28901 + - 28902 + - 28903 + - 28904 + - 28905 + - 28906 + - 28907 + - 28908 + - 28909 + - 28910 + - 28911 + - 28912 + - 28913 + - 28914 + - 28915 + - 28916 + - 28917 + - 28918 + - 28919 + - 28920 + - 28921 + - 28922 + - 28923 + - 28924 + - 28925 + - 28926 + - 28927 + - 28928 + - 28929 + - 28930 + - 28931 + - 28932 + - 28933 + - 28934 + - 28935 + - 28936 + - 28937 + - 28938 + - 28939 + - 28940 + - 28941 + - 28942 + - 28943 + - 28944 + - 28945 + - 28946 + - 28947 + - 28948 + - 28949 + - 28950 + - 28951 + - 28952 + - 28953 + - 28954 + - 28955 + - 28956 + - 28957 + - 28958 + - 28959 + - 28960 + - 28961 + - 28962 + - 28963 + - 28964 + - 28965 + - 28966 + - 28967 + - 28968 + - 28969 + - 28970 + - 28971 + - 28972 + - 28973 + - 28974 + - 28975 + - 28976 + - 28977 + - 28978 + - 28979 + - 28980 + - 28981 + - 28982 + - 28983 + - 28984 + - 28985 + - 28986 + - 28987 + - 28988 + - 28989 + - 28990 + - 28991 + - 28992 + - 28993 + - 28994 + - 28995 + - 28996 + - 28997 + - 28998 + - 28999 + - 29000 + - 29001 + - 29002 + - 29003 + - 29004 + - 29005 + - 29006 + - 29007 + - 29008 + - 29009 + - 29010 + - 29011 + - 29012 + - 29013 + - 29014 + - 29015 + - 29016 + - 29017 + - 29018 + - 29019 + - 29020 + - 29021 + - 29022 + - 29023 + - 29024 + - 29025 + - 29026 + - 29027 + - 29028 + - 29029 + - 29030 + - 29031 + - 29032 + - 29033 + - 29034 + - 29035 + - 29036 + - 29037 + - 29038 + - 29039 + - 29040 + - 29041 + - 29042 + - 29043 + - 29044 + - 29045 + - 29046 + - 29047 + - 29048 + - 29049 + - 29050 + - 29051 + - 29052 + - 29053 + - 29054 + - 29055 + - 29056 + - 29057 + - 29058 + - 29059 + - 29060 + - 29061 + - 29062 + - 29063 + - 29064 + - 29065 + - 29066 + - 29067 + - 29068 + - 29069 + - 29070 + - 29071 + - 29072 + - 29073 + - 29074 + - 29075 + - 29076 + - 29077 + - 29078 + - 29079 + - 29080 + - 29081 + - 29082 + - 29083 + - 29084 + - 29085 + - 29086 + - 29087 + - 29088 + - 29089 + - 29090 + - 29091 + - 29092 + - 29093 + - 29094 + - 29095 + - 29096 + - 29097 + - 29098 + - 29099 + - 29100 + - 29101 + - 29102 + - 29103 + - 29104 + - 29105 + - 29106 + - 29107 + - 29108 + - 29109 + - 29110 + - 29111 + - 29112 + - 29113 + - 29114 + - 29115 + - 29116 + - 29117 + - 29118 + - 29119 + - 29120 + - 29121 + - 29122 + - 29123 + - 29124 + - 29125 + - 29126 + - 29127 + - 29128 + - 29129 + - 29130 + - 29131 + - 29132 + - 29133 + - 29134 + - 29135 + - 29136 + - 29137 + - 29138 + - 29139 + - 29140 + - 29141 + - 29142 + - 29143 + - 29144 + - 29145 + - 29146 + - 29147 + - 29148 + - 29149 + - 29150 + - 29151 + - 29152 + - 29153 + - 29154 + - 29155 + - 29156 + - 29157 + - 29158 + - 29159 + - 29160 + - 29161 + - 29162 + - 29163 + - 29164 + - 29165 + - 29166 + - 29167 + - 29168 + - 29169 + - 29170 + - 29171 + - 29172 + - 29173 + - 29174 + - 29175 + - 29176 + - 29177 + - 29178 + - 29179 + - 29180 + - 29181 + - 29182 + - 29183 + - 29184 + - 29185 + - 29186 + - 29187 + - 29188 + - 29189 + - 29190 + - 29191 + - 29192 + - 29193 + - 29194 + - 29195 + - 29196 + - 29197 + - 29198 + - 29199 + - 29200 + - 29201 + - 29202 + - 29203 + - 29204 + - 29205 + - 29206 + - 29207 + - 29208 + - 29209 + - 29210 + - 29211 + - 29212 + - 29213 + - 29214 + - 29215 + - 29216 + - 29217 + - 29218 + - 29219 + - 29220 + - 29221 + - 29222 + - 29223 + - 29224 + - 29225 + - 29226 + - 29227 + - 29228 + - 29229 + - 29230 + - 29231 + - 29232 + - 29233 + - 29234 + - 29235 + - 29236 + - 29237 + - 29238 + - 29239 + - 29240 + - 29241 + - 29242 + - 29243 + - 29244 + - 29245 + - 29246 + - 29247 + - 29248 + - 29249 + - 29250 + - 29251 + - 29252 + - 29253 + - 29254 + - 29255 + - 29256 + - 29257 + - 29258 + - 29259 + - 29260 + - 29261 + - 29262 + - 29263 + - 29264 + - 29265 + - 29266 + - 29267 + - 29268 + - 29269 + - 29270 + - 29271 + - 29272 + - 29273 + - 29274 + - 29275 + - 29276 + - 29277 + - 29278 + - 29279 + - 29280 + - 29281 + - 29282 + - 29283 + - 29284 + - 29285 + - 29286 + - 29287 + - 29288 + - 29289 + - 29290 + - 29291 + - 29292 + - 29293 + - 29294 + - 29295 + - 29296 + - 29297 + - 29298 + - 29299 + - 29300 + - 29301 + - 29302 + - 29303 + - 29304 + - 29305 + - 29306 + - 29307 + - 29308 + - 29309 + - 29310 + - 29311 + - 29312 + - 29313 + - 29314 + - 29315 + - 29316 + - 29317 + - 29318 + - 29319 + - 29320 + - 29321 + - 29322 + - 29323 + - 29324 + - 29325 + - 29326 + - 29327 + - 29328 + - 29329 + - 29330 + - 29331 + - 29332 + - 29333 + - 29334 + - 29335 + - 29336 + - 29337 + - 29338 + - 29339 + - 29340 + - 29341 + - 29342 + - 29343 + - 29344 + - 29345 + - 29346 + - 29347 + - 29348 + - 29349 + - 29350 + - 29351 + - 29352 + - 29353 + - 29354 + - 29355 + - 29356 + - 29357 + - 29358 + - 29359 + - 29360 + - 29361 + - 29362 + - 29363 + - 29364 + - 29365 + - 29366 + - 29367 + - 29368 + - 29369 + - 29370 + - 29371 + - 29372 + - 29373 + - 29374 + - 29375 + - 29376 + - 29377 + - 29378 + - 29379 + - 29380 + - 29381 + - 29382 + - 29383 + - 29384 + - 29385 + - 29386 + - 29387 + - 29388 + - 29389 + - 29390 + - 29391 + - 29392 + - 29393 + - 29394 + - 29395 + - 29396 + - 29397 + - 29398 + - 29399 + - 29400 + - 29401 + - 29402 + - 29403 + - 29404 + - 29405 + - 29406 + - 29407 + - 29408 + - 29409 + - 29410 + - 29411 + - 29412 + - 29413 + - 29414 + - 29415 + - 29416 + - 29417 + - 29418 + - 29419 + - 29420 + - 29421 + - 29422 + - 29423 + - 29424 + - 29425 + - 29426 + - 29427 + - 29428 + - 29429 + - 29430 + - 29431 + - 29432 + - 29433 + - 29434 + - 29435 + - 29436 + - 29437 + - 29438 + - 29439 + - 29440 + - 29441 + - 29442 + - 29443 + - 29444 + - 29445 + - 29446 + - 29447 + - 29448 + - 29449 + - 29450 + - 29451 + - 29452 + - 29453 + - 29454 + - 29455 + - 29456 + - 29457 + - 29458 + - 29459 + - 29460 + - 29461 + - 29462 + - 29463 + - 29464 + - 29465 + - 29466 + - 29467 + - 29468 + - 29469 + - 29470 + - 29471 + - 29472 + - 29473 + - 29474 + - 29475 + - 29476 + - 29477 + - 29478 + - 29479 + - 29480 + - 29481 + - 29482 + - 29483 + - 29484 + - 29485 + - 29486 + - 29487 + - 29488 + - 29489 + - 29490 + - 29491 + - 29492 + - 29493 + - 29494 + - 29495 + - 29496 + - 29497 + - 29498 + - 29499 + - 29500 + - 29501 + - 29502 + - 29503 + - 29504 + - 29505 + - 29506 + - 29507 + - 29508 + - 29509 + - 29510 + - 29511 + - 29512 + - 29513 + - 29514 + - 29515 + - 29516 + - 29517 + - 29518 + - 29519 + - 29520 + - 29521 + - 29522 + - 29523 + - 29524 + - 29525 + - 29526 + - 29527 + - 29528 + - 29529 + - 29530 + - 29531 + - 29532 + - 29533 + - 29534 + - 29535 + - 29536 + - 29537 + - 29538 + - 29539 + - 29540 + - 29541 + - 29542 + - 29543 + - 29544 + - 29545 + - 29546 + - 29547 + - 29548 + - 29549 + - 29550 + - 29551 + - 29552 + - 29553 + - 29554 + - 29555 + - 29556 + - 29557 + - 29558 + - 29559 + - 29560 + - 29561 + - 29562 + - 29563 + - 29564 + - 29565 + - 29566 + - 29567 + - 29568 + - 29569 + - 29570 + - 29571 + - 29572 + - 29573 + - 29574 + - 29575 + - 29576 + - 29577 + - 29578 + - 29579 + - 29580 + - 29581 + - 29582 + - 29583 + - 29584 + - 29585 + - 29586 + - 29587 + - 29588 + - 29589 + - 29590 + - 29591 + - 29592 + - 29593 + - 29594 + - 29595 + - 29596 + - 29597 + - 29598 + - 29599 + - 29600 + - 29601 + - 29602 + - 29603 + - 29604 + - 29605 + - 29606 + - 29607 + - 29608 + - 29609 + - 29610 + - 29611 + - 29612 + - 29613 + - 29614 + - 29615 + - 29616 + - 29617 + - 29618 + - 29619 + - 29620 + - 29621 + - 29622 + - 29623 + - 29624 + - 29625 + - 29626 + - 29627 + - 29628 + - 29629 + - 29630 + - 29631 + - 29632 + - 29633 + - 29634 + - 29635 + - 29636 + - 29637 + - 29638 + - 29639 + - 29640 + - 29641 + - 29642 + - 29643 + - 29644 + - 29645 + - 29646 + - 29647 + - 29648 + - 29649 + - 29650 + - 29651 + - 29652 + - 29653 + - 29654 + - 29655 + - 29656 + - 29657 + - 29658 + - 29659 + - 29660 + - 29661 + - 29662 + - 29663 + - 29664 + - 29665 + - 29666 + - 29667 + - 29668 + - 29669 + - 29670 + - 29671 + - 29672 + - 29673 + - 29674 + - 29675 + - 29676 + - 29677 + - 29678 + - 29679 + - 29680 + - 29681 + - 29682 + - 29683 + - 29684 + - 29685 + - 29686 + - 29687 + - 29688 + - 29689 + - 29690 + - 29691 + - 29692 + - 29693 + - 29694 + - 29695 + - 29696 + - 29697 + - 29698 + - 29699 + - 29700 + - 29701 + - 29702 + - 29703 + - 29704 + - 29705 + - 29706 + - 29707 + - 29708 + - 29709 + - 29710 + - 29711 + - 29712 + - 29713 + - 29714 + - 29715 + - 29716 + - 29717 + - 29718 + - 29719 + - 29720 + - 29721 + - 29722 + - 29723 + - 29724 + - 29725 + - 29726 + - 29727 + - 29728 + - 29729 + - 29730 + - 29731 + - 29732 + - 29733 + - 29734 + - 29735 + - 29736 + - 29737 + - 29738 + - 29739 + - 29740 + - 29741 + - 29742 + - 29743 + - 29744 + - 29745 + - 29746 + - 29747 + - 29748 + - 29749 + - 29750 + - 29751 + - 29752 + - 29753 + - 29754 + - 29755 + - 29756 + - 29757 + - 29758 + - 29759 + - 29760 + - 29761 + - 29762 + - 29763 + - 29764 + - 29765 + - 29766 + - 29767 + - 29768 + - 29769 + - 29770 + - 29771 + - 29772 + - 29773 + - 29774 + - 29775 + - 29776 + - 29777 + - 29778 + - 29779 + - 29780 + - 29781 + - 29782 + - 29783 + - 29784 + - 29785 + - 29786 + - 29787 + - 29788 + - 29789 + - 29790 + - 29791 + - 29792 + - 29793 + - 29794 + - 29795 + - 29796 + - 29797 + - 29798 + - 29799 + - 29800 + - 29801 + - 29802 + - 29803 + - 29804 + - 29805 + - 29806 + - 29807 + - 29808 + - 29809 + - 29810 + - 29811 + - 29812 + - 29813 + - 29814 + - 29815 + - 29816 + - 29817 + - 29818 + - 29819 + - 29820 + - 29821 + - 29822 + - 29823 + - 29824 + - 29825 + - 29826 + - 29827 + - 29828 + - 29829 + - 29830 + - 29831 + - 29832 + - 29833 + - 29834 + - 29835 + - 29836 + - 29837 + - 29838 + - 29839 + - 29840 + - 29841 + - 29842 + - 29843 + - 29844 + - 29845 + - 29846 + - 29847 + - 29848 + - 29849 + - 29850 + - 29851 + - 29852 + - 29853 + - 29854 + - 29855 + - 29856 + - 29857 + - 29858 + - 29859 + - 29860 + - 29861 + - 29862 + - 29863 + - 29864 + - 29865 + - 29866 + - 29867 + - 29868 + - 29869 + - 29870 + - 29871 + - 29872 + - 29873 + - 29874 + - 29875 + - 29876 + - 29877 + - 29878 + - 29879 + - 29880 + - 29881 + - 29882 + - 29883 + - 29884 + - 29885 + - 29886 + - 29887 + - 29888 + - 29889 + - 29890 + - 29891 + - 29892 + - 29893 + - 29894 + - 29895 + - 29896 + - 29897 + - 29898 + - 29899 + - 29900 + - 29901 + - 29902 + - 29903 + - 29904 + - 29905 + - 29906 + - 29907 + - 29908 + - 29909 + - 29910 + - 29911 + - 29912 + - 29913 + - 29914 + - 29915 + - 29916 + - 29917 + - 29918 + - 29919 + - 29920 + - 29921 + - 29922 + - 29923 + - 29924 + - 29925 + - 29926 + - 29927 + - 29928 + - 29929 + - 29930 + - 29931 + - 29932 + - 29933 + - 29934 + - 29935 + - 29936 + - 29937 + - 29938 + - 29939 + - 29940 + - 29941 + - 29942 + - 29943 + - 29944 + - 29945 + - 29946 + - 29947 + - 29948 + - 29949 + - 29950 + - 29951 + - 29952 + - 29953 + - 29954 + - 29955 + - 29956 + - 29957 + - 29958 + - 29959 + - 29960 + - 29961 + - 29962 + - 29963 + - 29964 + - 29965 + - 29966 + - 29967 + - 29968 + - 29969 + - 29970 + - 29971 + - 29972 + - 29973 + - 29974 + - 29975 + - 29976 + - 29977 + - 29978 + - 29979 + - 29980 + - 29981 + - 29982 + - 29983 + - 29984 + - 29985 + - 29986 + - 29987 + - 29988 + - 29989 + - 29990 + - 29991 + - 29992 + - 29993 + - 29994 + - 29995 + - 29996 + - 29997 + - 29998 + - 29999 + - 30000 + - 30001 + - 30002 + - 30003 + - 30004 + - 30005 + - 30006 + - 30007 + - 30008 + - 30009 + - 30010 + - 30011 + - 30012 + - 30013 + - 30014 + - 30015 + - 30016 + - 30017 + - 30018 + - 30019 + - 30020 + - 30021 + - 30022 + - 30023 + - 30024 + - 30025 + - 30026 + - 30027 + - 30028 + - 30029 + - 30030 + - 30031 + - 30032 + - 30033 + - 30034 + - 30035 + - 30036 + - 30037 + - 30038 + - 30039 + - 30040 + - 30041 + - 30042 + - 30043 + - 30044 + - 30045 + - 30046 + - 30047 + - 30048 + - 30049 + - 30050 + - 30051 + - 30052 + - 30053 + - 30054 + - 30055 + - 30056 + - 30057 + - 30058 + - 30059 + - 30060 + - 30061 + - 30062 + - 30063 + - 30064 + - 30065 + - 30066 + - 30067 + - 30068 + - 30069 + - 30070 + - 30071 + - 30072 + - 30073 + - 30074 + - 30075 + - 30076 + - 30077 + - 30078 + - 30079 + - 30080 + - 30081 + - 30082 + - 30083 + - 30084 + - 30085 + - 30086 + - 30087 + - 30088 + - 30089 + - 30090 + - 30091 + - 30092 + - 30093 + - 30094 + - 30095 + - 30096 + - 30097 + - 30098 + - 30099 + - 30100 + - 30101 + - 30102 + - 30103 + - 30104 + - 30105 + - 30106 + - 30107 + - 30108 + - 30109 + - 30110 + - 30111 + - 30112 + - 30113 + - 30114 + - 30115 + - 30116 + - 30117 + - 30118 + - 30119 + - 30120 + - 30121 + - 30122 + - 30123 + - 30124 + - 30125 + - 30126 + - 30127 + - 30128 + - 30129 + - 30130 + - 30131 + - 30132 + - 30133 + - 30134 + - 30135 + - 30136 + - 30137 + - 30138 + - 30139 + - 30140 + - 30141 + - 30142 + - 30143 + - 30144 + - 30145 + - 30146 + - 30147 + - 30148 + - 30149 + - 30150 + - 30151 + - 30152 + - 30153 + - 30154 + - 30155 + - 30156 + - 30157 + - 30158 + - 30159 + - 30160 + - 30161 + - 30162 + - 30163 + - 30164 + - 30165 + - 30166 + - 30167 + - 30168 + - 30169 + - 30170 + - 30171 + - 30172 + - 30173 + - 30174 + - 30175 + - 30176 + - 30177 + - 30178 + - 30179 + - 30180 + - 30181 + - 30182 + - 30183 + - 30184 + - 30185 + - 30186 + - 30187 + - 30188 + - 30189 + - 30190 + - 30191 + - 30192 + - 30193 + - 30194 + - 30195 + - 30196 + - 30197 + - 30198 + - 30199 + - 30200 + - 30201 + - 30202 + - 30203 + - 30204 + - 30205 + - 30206 + - 30207 + - 30208 + - 30209 + - 30210 + - 30211 + - 30212 + - 30213 + - 30214 + - 30215 + - 30216 + - 30217 + - 30218 + - 30219 + - 30220 + - 30221 + - 30222 + - 30223 + - 30224 + - 30225 + - 30226 + - 30227 + - 30228 + - 30229 + - 30230 + - 30231 + - 30232 + - 30233 + - 30234 + - 30235 + - 30236 + - 30237 + - 30238 + - 30239 + - 30240 + - 30241 + - 30242 + - 30243 + - 30244 + - 30245 + - 30246 + - 30247 + - 30248 + - 30249 + - 30250 + - 30251 + - 30252 + - 30253 + - 30254 + - 30255 + - 30256 + - 30257 + - 30258 + - 30259 + - 30260 + - 30261 + - 30262 + - 30263 + - 30264 + - 30265 + - 30266 + - 30267 + - 30268 + - 30269 + - 30270 + - 30271 + - 30272 + - 30273 + - 30274 + - 30275 + - 30276 + - 30277 + - 30278 + - 30279 + - 30280 + - 30281 + - 30282 + - 30283 + - 30284 + - 30285 + - 30286 + - 30287 + - 30288 + - 30289 + - 30290 + - 30291 + - 30292 + - 30293 + - 30294 + - 30295 + - 30296 + - 30297 + - 30298 + - 30299 + - 30300 + - 30301 + - 30302 + - 30303 + - 30304 + - 30305 + - 30306 + - 30307 + - 30308 + - 30309 + - 30310 + - 30311 + - 30312 + - 30313 + - 30314 + - 30315 + - 30316 + - 30317 + - 30318 + - 30319 + - 30320 + - 30321 + - 30322 + - 30323 + - 30324 + - 30325 + - 30326 + - 30327 + - 30328 + - 30329 + - 30330 + - 30331 + - 30332 + - 30333 + - 30334 + - 30335 + - 30336 + - 30337 + - 30338 + - 30339 + - 30340 + - 30341 + - 30342 + - 30343 + - 30344 + - 30345 + - 30346 + - 30347 + - 30348 + - 30349 + - 30350 + - 30351 + - 30352 + - 30353 + - 30354 + - 30355 + - 30356 + - 30357 + - 30358 + - 30359 + - 30360 + - 30361 + - 30362 + - 30363 + - 30364 + - 30365 + - 30366 + - 30367 + - 30368 + - 30369 + - 30370 + - 30371 + - 30372 + - 30373 + - 30374 + - 30375 + - 30376 + - 30377 + - 30378 + - 30379 + - 30380 + - 30381 + - 30382 + - 30383 + - 30384 + - 30385 + - 30386 + - 30387 + - 30388 + - 30389 + - 30390 + - 30391 + - 30392 + - 30393 + - 30394 + - 30395 + - 30396 + - 30397 + - 30398 + - 30399 + - 30400 + - 30401 + - 30402 + - 30403 + - 30404 + - 30405 + - 30406 + - 30407 + - 30408 + - 30409 + - 30410 + - 30411 + - 30412 + - 30413 + - 30414 + - 30415 + - 30416 + - 30417 + - 30418 + - 30419 + - 30420 + - 30421 + - 30422 + - 30423 + - 30424 + - 30425 + - 30426 + - 30427 + - 30428 + - 30429 + - 30430 + - 30431 + - 30432 + - 30433 + - 30434 + - 30435 + - 30436 + - 30437 + - 30438 + - 30439 + - 30440 + - 30441 + - 30442 + - 30443 + - 30444 + - 30445 + - 30446 + - 30447 + - 30448 + - 30449 + - 30450 + - 30451 + - 30452 + - 30453 + - 30454 + - 30455 + - 30456 + - 30457 + - 30458 + - 30459 + - 30460 + - 30461 + - 30462 + - 30463 + - 30464 + - 30465 + - 30466 + - 30467 + - 30468 + - 30469 + - 30470 + - 30471 + - 30472 + - 30473 + - 30474 + - 30475 + - 30476 + - 30477 + - 30478 + - 30479 + - 30480 + - 30481 + - 30482 + - 30483 + - 30484 + - 30485 + - 30486 + - 30487 + - 30488 + - 30489 + - 30490 + - 30491 + - 30492 + - 30493 + - 30494 + - 30495 + - 30496 + - 30497 + - 30498 + - 30499 + - 30500 + - 30501 + - 30502 + - 30503 + - 30504 + - 30505 + - 30506 + - 30507 + - 30508 + - 30509 + - 30510 + - 30511 + - 30512 + - 30513 + - 30514 + - 30515 + - 30516 + - 30517 + - 30518 + - 30519 + - 30520 + - 30521 + - 30522 + - 30523 + - 30524 + - 30525 + - 30526 + - 30527 + - 30528 + - 30529 + - 30530 + - 30531 + - 30532 + - 30533 + - 30534 + - 30535 + - 30536 + - 30537 + - 30538 + - 30539 + - 30540 + - 30541 + - 30542 + - 30543 + - 30544 + - 30545 + - 30546 + - 30547 + - 30548 + - 30549 + - 30550 + - 30551 + - 30552 + - 30553 + - 30554 + - 30555 + - 30556 + - 30557 + - 30558 + - 30559 + - 30560 + - 30561 + - 30562 + - 30563 + - 30564 + - 30565 + - 30566 + - 30567 + - 30568 + - 30569 + - 30570 + - 30571 + - 30572 + - 30573 + - 30574 + - 30575 + - 30576 + - 30577 + - 30578 + - 30579 + - 30580 + - 30581 + - 30582 + - 30583 + - 30584 + - 30585 + - 30586 + - 30587 + - 30588 + - 30589 + - 30590 + - 30591 + - 30592 + - 30593 + - 30594 + - 30595 + - 30596 + - 30597 + - 30598 + - 30599 + - 30600 + - 30601 + - 30602 + - 30603 + - 30604 + - 30605 + - 30606 + - 30607 + - 30608 + - 30609 + - 30610 + - 30611 + - 30612 + - 30613 + - 30614 + - 30615 + - 30616 + - 30617 + - 30618 + - 30619 + - 30620 + - 30621 + - 30622 + - 30623 + - 30624 + - 30625 + - 30626 + - 30627 + - 30628 + - 30629 + - 30630 + - 30631 + - 30632 + - 30633 + - 30634 + - 30635 + - 30636 + - 30637 + - 30638 + - 30639 + - 30640 + - 30641 + - 30642 + - 30643 + - 30644 + - 30645 + - 30646 + - 30647 + - 30648 + - 30649 + - 30650 + - 30651 + - 30652 + - 30653 + - 30654 + - 30655 + - 30656 + - 30657 + - 30658 + - 30659 + - 30660 + - 30661 + - 30662 + - 30663 + - 30664 + - 30665 + - 30666 + - 30667 + - 30668 + - 30669 + - 30670 + - 30671 + - 30672 + - 30673 + - 30674 + - 30675 + - 30676 + - 30677 + - 30678 + - 30679 + - 30680 + - 30681 + - 30682 + - 30683 + - 30684 + - 30685 + - 30686 + - 30687 + - 30688 + - 30689 + - 30690 + - 30691 + - 30692 + - 30693 + - 30694 + - 30695 + - 30696 + - 30697 + - 30698 + - 30699 + - 30700 + - 30701 + - 30702 + - 30703 + - 30704 + - 30705 + - 30706 + - 30707 + - 30708 + - 30709 + - 30710 + - 30711 + - 30712 + - 30713 + - 30714 + - 30715 + - 30716 + - 30717 + - 30718 + - 30719 + - 30720 + - 30721 + - 30722 + - 30723 + - 30724 + - 30725 + - 30726 + - 30727 + - 30728 + - 30729 + - 30730 + - 30731 + - 30732 + - 30733 + - 30734 + - 30735 + - 30736 + - 30737 + - 30738 + - 30739 + - 30740 + - 30741 + - 30742 + - 30743 + - 30744 + - 30745 + - 30746 + - 30747 + - 30748 + - 30749 + - 30750 + - 30751 + - 30752 + - 30753 + - 30754 + - 30755 + - 30756 + - 30757 + - 30758 + - 30759 + - 30760 + - 30761 + - 30762 + - 30763 + - 30764 + - 30765 + - 30766 + - 30767 + - 30768 + - 30769 + - 30770 + - 30771 + - 30772 + - 30773 + - 30774 + - 30775 + - 30776 + - 30777 + - 30778 + - 30779 + - 30780 + - 30781 + - 30782 + - 30783 + - 30784 + - 30785 + - 30786 + - 30787 + - 30788 + - 30789 + - 30790 + - 30791 + - 30792 + - 30793 + - 30794 + - 30795 + - 30796 + - 30797 + - 30798 + - 30799 + - 30800 + - 30801 + - 30802 + - 30803 + - 30804 + - 30805 + - 30806 + - 30807 + - 30808 + - 30809 + - 30810 + - 30811 + - 30812 + - 30813 + - 30814 + - 30815 + - 30816 + - 30817 + - 30818 + - 30819 + - 30820 + - 30821 + - 30822 + - 30823 + - 30824 + - 30825 + - 30826 + - 30827 + - 30828 + - 30829 + - 30830 + - 30831 + - 30832 + - 30833 + - 30834 + - 30835 + - 30836 + - 30837 + - 30838 + - 30839 + - 30840 + - 30841 + - 30842 + - 30843 + - 30844 + - 30845 + - 30846 + - 30847 + - 30848 + - 30849 + - 30850 + - 30851 + - 30852 + - 30853 + - 30854 + - 30855 + - 30856 + - 30857 + - 30858 + - 30859 + - 30860 + - 30861 + - 30862 + - 30863 + - 30864 + - 30865 + - 30866 + - 30867 + - 30868 + - 30869 + - 30870 + - 30871 + - 30872 + - 30873 + - 30874 + - 30875 + - 30876 + - 30877 + - 30878 + - 30879 + - 30880 + - 30881 + - 30882 + - 30883 + - 30884 + - 30885 + - 30886 + - 30887 + - 30888 + - 30889 + - 30890 + - 30891 + - 30892 + - 30893 + - 30894 + - 30895 + - 30896 + - 30897 + - 30898 + - 30899 + - 30900 + - 30901 + - 30902 + - 30903 + - 30904 + - 30905 + - 30906 + - 30907 + - 30908 + - 30909 + - 30910 + - 30911 + - 30912 + - 30913 + - 30914 + - 30915 + - 30916 + - 30917 + - 30918 + - 30919 + - 30920 + - 30921 + - 30922 + - 30923 + - 30924 + - 30925 + - 30926 + - 30927 + - 30928 + - 30929 + - 30930 + - 30931 + - 30932 + - 30933 + - 30934 + - 30935 + - 30936 + - 30937 + - 30938 + - 30939 + - 30940 + - 30941 + - 30942 + - 30943 + - 30944 + - 30945 + - 30946 + - 30947 + - 30948 + - 30949 + - 30950 + - 30951 + - 30952 + - 30953 + - 30954 + - 30955 + - 30956 + - 30957 + - 30958 + - 30959 + - 30960 + - 30961 + - 30962 + - 30963 + - 30964 + - 30965 + - 30966 + - 30967 + - 30968 + - 30969 + - 30970 + - 30971 + - 30972 + - 30973 + - 30974 + - 30975 + - 30976 + - 30977 + - 30978 + - 30979 + - 30980 + - 30981 + - 30982 + - 30983 + - 30984 + - 30985 + - 30986 + - 30987 + - 30988 + - 30989 + - 30990 + - 30991 + - 30992 + - 30993 + - 30994 + - 30995 + - 30996 + - 30997 + - 30998 + - 30999 + - 31000 + - 31001 + - 31002 + - 31003 + - 31004 + - 31005 + - 31006 + - 31007 + - 31008 + - 31009 + - 31010 + - 31011 + - 31012 + - 31013 + - 31014 + - 31015 + - 31016 + - 31017 + - 31018 + - 31019 + - 31020 + - 31021 + - 31022 + - 31023 + - 31024 + - 31025 + - 31026 + - 31027 + - 31028 + - 31029 + - 31030 + - 31031 + - 31032 + - 31033 + - 31034 + - 31035 + - 31036 + - 31037 + - 31038 + - 31039 + - 31040 + - 31041 + - 31042 + - 31043 + - 31044 + - 31045 + - 31046 + - 31047 + - 31048 + - 31049 + - 31050 + - 31051 + - 31052 + - 31053 + - 31054 + - 31055 + - 31056 + - 31057 + - 31058 + - 31059 + - 31060 + - 31061 + - 31062 + - 31063 + - 31064 + - 31065 + - 31066 + - 31067 + - 31068 + - 31069 + - 31070 + - 31071 + - 31072 + - 31073 + - 31074 + - 31075 + - 31076 + - 31077 + - 31078 + - 31079 + - 31080 + - 31081 + - 31082 + - 31083 + - 31084 + - 31085 + - 31086 + - 31087 + - 31088 + - 31089 + - 31090 + - 31091 + - 31092 + - 31093 + - 31094 + - 31095 + - 31096 + - 31097 + - 31098 + - 31099 + - 31100 + - 31101 + - 31102 + - 31103 + - 31104 + - 31105 + - 31106 + - 31107 + - 31108 + - 31109 + - 31110 + - 31111 + - 31112 + - 31113 + - 31114 + - 31115 + - 31116 + - 31117 + - 31118 + - 31119 + - 31120 + - 31121 + - 31122 + - 31123 + - 31124 + - 31125 + - 31126 + - 31127 + - 31128 + - 31129 + - 31130 + - 31131 + - 31132 + - 31133 + - 31134 + - 31135 + - 31136 + - 31137 + - 31138 + - 31139 + - 31140 + - 31141 + - 31142 + - 31143 + - 31144 + - 31145 + - 31146 + - 31147 + - 31148 + - 31149 + - 31150 + - 31151 + - 31152 + - 31153 + - 31154 + - 31155 + - 31156 + - 31157 + - 31158 + - 31159 + - 31160 + - 31161 + - 31162 + - 31163 + - 31164 + - 31165 + - 31166 + - 31167 + - 31168 + - 31169 + - 31170 + - 31171 + - 31172 + - 31173 + - 31174 + - 31175 + - 31176 + - 31177 + - 31178 + - 31179 + - 31180 + - 31181 + - 31182 + - 31183 + - 31184 + - 31185 + - 31186 + - 31187 + - 31188 + - 31189 + - 31190 + - 31191 + - 31192 + - 31193 + - 31194 + - 31195 + - 31196 + - 31197 + - 31198 + - 31199 + - 31200 + - 31201 + - 31202 + - 31203 + - 31204 + - 31205 + - 31206 + - 31207 + - 31208 + - 31209 + - 31210 + - 31211 + - 31212 + - 31213 + - 31214 + - 31215 + - 31216 + - 31217 + - 31218 + - 31219 + - 31220 + - 31221 + - 31222 + - 31223 + - 31224 + - 31225 + - 31226 + - 31227 + - 31228 + - 31229 + - 31230 + - 31231 + - 31232 + - 31233 + - 31234 + - 31235 + - 31236 + - 31237 + - 31238 + - 31239 + - 31240 + - 31241 + - 31242 + - 31243 + - 31244 + - 31245 + - 31246 + - 31247 + - 31248 + - 31249 + - 31250 + - 31251 + - 31252 + - 31253 + - 31254 + - 31255 + - 31256 + - 31257 + - 31258 + - 31259 + - 31260 + - 31261 + - 31262 + - 31263 + - 31264 + - 31265 + - 31266 + - 31267 + - 31268 + - 31269 + - 31270 + - 31271 + - 31272 + - 31273 + - 31274 + - 31275 + - 31276 + - 31277 + - 31278 + - 31279 + - 31280 + - 31281 + - 31282 + - 31283 + - 31284 + - 31285 + - 31286 + - 31287 + - 31288 + - 31289 + - 31290 + - 31291 + - 31292 + - 31293 + - 31294 + - 31295 + - 31296 + - 31297 + - 31298 + - 31299 + - 31300 + - 31301 + - 31302 + - 31303 + - 31304 + - 31305 + - 31306 + - 31307 + - 31308 + - 31309 + - 31310 + - 31311 + - 31312 + - 31313 + - 31314 + - 31315 + - 31316 + - 31317 + - 31318 + - 31319 + - 31320 + - 31321 + - 31322 + - 31323 + - 31324 + - 31325 + - 31326 + - 31327 + - 31328 + - 31329 + - 31330 + - 31331 + - 31332 + - 31333 + - 31334 + - 31335 + - 31336 + - 31337 + - 31338 + - 31339 + - 31340 + - 31341 + - 31342 + - 31343 + - 31344 + - 31345 + - 31346 + - 31347 + - 31348 + - 31349 + - 31350 + - 31351 + - 31352 + - 31353 + - 31354 + - 31355 + - 31356 + - 31357 + - 31358 + - 31359 + - 31360 + - 31361 + - 31362 + - 31363 + - 31364 + - 31365 + - 31366 + - 31367 + - 31368 + - 31369 + - 31370 + - 31371 + - 31372 + - 31373 + - 31374 + - 31375 + - 31376 + - 31377 + - 31378 + - 31379 + - 31380 + - 31381 + - 31382 + - 31383 + - 31384 + - 31385 + - 31386 + - 31387 + - 31388 + - 31389 + - 31390 + - 31391 + - 31392 + - 31393 + - 31394 + - 31395 + - 31396 + - 31397 + - 31398 + - 31399 + - 31400 + - 31401 + - 31402 + - 31403 + - 31404 + - 31405 + - 31406 + - 31407 + - 31408 + - 31409 + - 31410 + - 31411 + - 31412 + - 31413 + - 31414 + - 31415 + - 31416 + - 31417 + - 31418 + - 31419 + - 31420 + - 31421 + - 31422 + - 31423 + - 31424 + - 31425 + - 31426 + - 31427 + - 31428 + - 31429 + - 31430 + - 31431 + - 31432 + - 31433 + - 31434 + - 31435 + - 31436 + - 31437 + - 31438 + - 31439 + - 31440 + - 31441 + - 31442 + - 31443 + - 31444 + - 31445 + - 31446 + - 31447 + - 31448 + - 31449 + - 31450 + - 31451 + - 31452 + - 31453 + - 31454 + - 31455 + - 31456 + - 31457 + - 31458 + - 31459 + - 31460 + - 31461 + - 31462 + - 31463 + - 31464 + - 31465 + - 31466 + - 31467 + - 31468 + - 31469 + - 31470 + - 31471 + - 31472 + - 31473 + - 31474 + - 31475 + - 31476 + - 31477 + - 31478 + - 31479 + - 31480 + - 31481 + - 31482 + - 31483 + - 31484 + - 31485 + - 31486 + - 31487 + - 31488 + - 31489 + - 31490 + - 31491 + - 31492 + - 31493 + - 31494 + - 31495 + - 31496 + - 31497 + - 31498 + - 31499 + - 31500 + - 31501 + - 31502 + - 31503 + - 31504 + - 31505 + - 31506 + - 31507 + - 31508 + - 31509 + - 31510 + - 31511 + - 31512 + - 31513 + - 31514 + - 31515 + - 31516 + - 31517 + - 31518 + - 31519 + - 31520 + - 31521 + - 31522 + - 31523 + - 31524 + - 31525 + - 31526 + - 31527 + - 31528 + - 31529 + - 31530 + - 31531 + - 31532 + - 31533 + - 31534 + - 31535 + - 31536 + - 31537 + - 31538 + - 31539 + - 31540 + - 31541 + - 31542 + - 31543 + - 31544 + - 31545 + - 31546 + - 31547 + - 31548 + - 31549 + - 31550 + - 31551 + - 31552 + - 31553 + - 31554 + - 31555 + - 31556 + - 31557 + - 31558 + - 31559 + - 31560 + - 31561 + - 31562 + - 31563 + - 31564 + - 31565 + - 31566 + - 31567 + - 31568 + - 31569 + - 31570 + - 31571 + - 31572 + - 31573 + - 31574 + - 31575 + - 31576 + - 31577 + - 31578 + - 31579 + - 31580 + - 31581 + - 31582 + - 31583 + - 31584 + - 31585 + - 31586 + - 31587 + - 31588 + - 31589 + - 31590 + - 31591 + - 31592 + - 31593 + - 31594 + - 31595 + - 31596 + - 31597 + - 31598 + - 31599 + - 31600 + - 31601 + - 31602 + - 31603 + - 31604 + - 31605 + - 31606 + - 31607 + - 31608 + - 31609 + - 31610 + - 31611 + - 31612 + - 31613 + - 31614 + - 31615 + - 31616 + - 31617 + - 31618 + - 31619 + - 31620 + - 31621 + - 31622 + - 31623 + - 31624 + - 31625 + - 31626 + - 31627 + - 31628 + - 31629 + - 31630 + - 31631 + - 31632 + - 31633 + - 31634 + - 31635 + - 31636 + - 31637 + - 31638 + - 31639 + - 31640 + - 31641 + - 31642 + - 31643 + - 31644 + - 31645 + - 31646 + - 31647 + - 31648 + - 31649 + - 31650 + - 31651 + - 31652 + - 31653 + - 31654 + - 31655 + - 31656 + - 31657 + - 31658 + - 31659 + - 31660 + - 31661 + - 31662 + - 31663 + - 31664 + - 31665 + - 31666 + - 31667 + - 31668 + - 31669 + - 31670 + - 31671 + - 31672 + - 31673 + - 31674 + - 31675 + - 31676 + - 31677 + - 31678 + - 31679 + - 31680 + - 31681 + - 31682 + - 31683 + - 31684 + - 31685 + - 31686 + - 31687 + - 31688 + - 31689 + - 31690 + - 31691 + - 31692 + - 31693 + - 31694 + - 31695 + - 31696 + - 31697 + - 31698 + - 31699 + - 31700 + - 31701 + - 31702 + - 31703 + - 31704 + - 31705 + - 31706 + - 31707 + - 31708 + - 31709 + - 31710 + - 31711 + - 31712 + - 31713 + - 31714 + - 31715 + - 31716 + - 31717 + - 31718 + - 31719 + - 31720 + - 31721 + - 31722 + - 31723 + - 31724 + - 31725 + - 31726 + - 31727 + - 31728 + - 31729 + - 31730 + - 31731 + - 31732 + - 31733 + - 31734 + - 31735 + - 31736 + - 31737 + - 31738 + - 31739 + - 31740 + - 31741 + - 31742 + - 31743 + - 31744 + - 31745 + - 31746 + - 31747 + - 31748 + - 31749 + - 31750 + - 31751 + - 31752 + - 31753 + - 31754 + - 31755 + - 31756 + - 31757 + - 31758 + - 31759 + - 31760 + - 31761 + - 31762 + - 31763 + - 31764 + - 31765 + - 31766 + - 31767 + - 31768 + - 31769 + - 31770 + - 31771 + - 31772 + - 31773 + - 31774 + - 31775 + - 31776 + - 31777 + - 31778 + - 31779 + - 31780 + - 31781 + - 31782 + - 31783 + - 31784 + - 31785 + - 31786 + - 31787 + - 31788 + - 31789 + - 31790 + - 31791 + - 31792 + - 31793 + - 31794 + - 31795 + - 31796 + - 31797 + - 31798 + - 31799 + - 31800 + - 31801 + - 31802 + - 31803 + - 31804 + - 31805 + - 31806 + - 31807 + - 31808 + - 31809 + - 31810 + - 31811 + - 31812 + - 31813 + - 31814 + - 31815 + - 31816 + - 31817 + - 31818 + - 31819 + - 31820 + - 31821 + - 31822 + - 31823 + - 31824 + - 31825 + - 31826 + - 31827 + - 31828 + - 31829 + - 31830 + - 31831 + - 31832 + - 31833 + - 31834 + - 31835 + - 31836 + - 31837 + - 31838 + - 31839 + - 31840 + - 31841 + - 31842 + - 31843 + - 31844 + - 31845 + - 31846 + - 31847 + - 31848 + - 31849 + - 31850 + - 31851 + - 31852 + - 31853 + - 31854 + - 31855 + - 31856 + - 31857 + - 31858 + - 31859 + - 31860 + - 31861 + - 31862 + - 31863 + - 31864 + - 31865 + - 31866 + - 31867 + - 31868 + - 31869 + - 31870 + - 31871 + - 31872 + - 31873 + - 31874 + - 31875 + - 31876 + - 31877 + - 31878 + - 31879 + - 31880 + - 31881 + - 31882 + - 31883 + - 31884 + - 31885 + - 31886 + - 31887 + - 31888 + - 31889 + - 31890 + - 31891 + - 31892 + - 31893 + - 31894 + - 31895 + - 31896 + - 31897 + - 31898 + - 31899 + - 31900 + - 31901 + - 31902 + - 31903 + - 31904 + - 31905 + - 31906 + - 31907 + - 31908 + - 31909 + - 31910 + - 31911 + - 31912 + - 31913 + - 31914 + - 31915 + - 31916 + - 31917 + - 31918 + - 31919 + - 31920 + - 31921 + - 31922 + - 31923 + - 31924 + - 31925 + - 31926 + - 31927 + - 31928 + - 31929 + - 31930 + - 31931 + - 31932 + - 31933 + - 31934 + - 31935 + - 31936 + - 31937 + - 31938 + - 31939 + - 31940 + - 31941 + - 31942 + - 31943 + - 31944 + - 31945 + - 31946 + - 31947 + - 31948 + - 31949 + - 31950 + - 31951 + - 31952 + - 31953 + - 31954 + - 31955 + - 31956 + - 31957 + - 31958 + - 31959 + - 31960 + - 31961 + - 31962 + - 31963 + - 31964 + - 31965 + - 31966 + - 31967 + - 31968 + - 31969 + - 31970 + - 31971 + - 31972 + - 31973 + - 31974 + - 31975 + - 31976 + - 31977 + - 31978 + - 31979 + - 31980 + - 31981 + - 31982 + - 31983 + - 31984 + - 31985 + - 31986 + - 31987 + - 31988 + - 31989 + - 31990 + - 31991 + - 31992 + - 31993 + - 31994 + - 31995 + - 31996 + - 31997 + - 31998 + - 31999 + - 32000 + - 32001 + - 32002 + - 32003 + - 32004 + - 32005 + - 32006 + - 32007 + - 32008 + - 32009 + - 32010 + - 32011 + - 32012 + - 32013 + - 32014 + - 32015 + - 32016 + - 32017 + - 32018 + - 32019 + - 32020 + - 32021 + - 32022 + - 32023 + - 32024 + - 32025 + - 32026 + - 32027 + - 32028 + - 32029 + - 32030 + - 32031 + - 32032 + - 32033 + - 32034 + - 32035 + - 32036 + - 32037 + - 32038 + - 32039 + - 32040 + - 32041 + - 32042 + - 32043 + - 32044 + - 32045 + - 32046 + - 32047 + - 32048 + - 32049 + - 32050 + - 32051 + - 32052 + - 32053 + - 32054 + - 32055 + - 32056 + - 32057 + - 32058 + - 32059 + - 32060 + - 32061 + - 32062 + - 32063 + - 32064 + - 32065 + - 32066 + - 32067 + - 32068 + - 32069 + - 32070 + - 32071 + - 32072 + - 32073 + - 32074 + - 32075 + - 32076 + - 32077 + - 32078 + - 32079 + - 32080 + - 32081 + - 32082 + - 32083 + - 32084 + - 32085 + - 32086 + - 32087 + - 32088 + - 32089 + - 32090 + - 32091 + - 32092 + - 32093 + - 32094 + - 32095 + - 32096 + - 32097 + - 32098 + - 32099 + - 32100 + - 32101 + - 32102 + - 32103 + - 32104 + - 32105 + - 32106 + - 32107 + - 32108 + - 32109 + - 32110 + - 32111 + - 32112 + - 32113 + - 32114 + - 32115 + - 32116 + - 32117 + - 32118 + - 32119 + - 32120 + - 32121 + - 32122 + - 32123 + - 32124 + - 32125 + - 32126 + - 32127 + - 32128 + - 32129 + - 32130 + - 32131 + - 32132 + - 32133 + - 32134 + - 32135 + - 32136 + - 32137 + - 32138 + - 32139 + - 32140 + - 32141 + - 32142 + - 32143 + - 32144 + - 32145 + - 32146 + - 32147 + - 32148 + - 32149 + - 32150 + - 32151 + - 32152 + - 32153 + - 32154 + - 32155 + - 32156 + - 32157 + - 32158 + - 32159 + - 32160 + - 32161 + - 32162 + - 32163 + - 32164 + - 32165 + - 32166 + - 32167 + - 32168 + - 32169 + - 32170 + - 32171 + - 32172 + - 32173 + - 32174 + - 32175 + - 32176 + - 32177 + - 32178 + - 32179 + - 32180 + - 32181 + - 32182 + - 32183 + - 32184 + - 32185 + - 32186 + - 32187 + - 32188 + - 32189 + - 32190 + - 32191 + - 32192 + - 32193 + - 32194 + - 32195 + - 32196 + - 32197 + - 32198 + - 32199 + - 32200 + - 32201 + - 32202 + - 32203 + - 32204 + - 32205 + - 32206 + - 32207 + - 32208 + - 32209 + - 32210 + - 32211 + - 32212 + - 32213 + - 32214 + - 32215 + - 32216 + - 32217 + - 32218 + - 32219 + - 32220 + - 32221 + - 32222 + - 32223 + - 32224 + - 32225 + - 32226 + - 32227 + - 32228 + - 32229 + - 32230 + - 32231 + - 32232 + - 32233 + - 32234 + - 32235 + - 32236 + - 32237 + - 32238 + - 32239 + - 32240 + - 32241 + - 32242 + - 32243 + - 32244 + - 32245 + - 32246 + - 32247 + - 32248 + - 32249 + - 32250 + - 32251 + - 32252 + - 32253 + - 32254 + - 32255 + - 32256 + - 32257 + - 32258 + - 32259 + - 32260 + - 32261 + - 32262 + - 32263 + - 32264 + - 32265 + - 32266 + - 32267 + - 32268 + - 32269 + - 32270 + - 32271 + - 32272 + - 32273 + - 32274 + - 32275 + - 32276 + - 32277 + - 32278 + - 32279 + - 32280 + - 32281 + - 32282 + - 32283 + - 32284 + - 32285 + - 32286 + - 32287 + - 32288 + - 32289 + - 32290 + - 32291 + - 32292 + - 32293 + - 32294 + - 32295 + - 32296 + - 32297 + - 32298 + - 32299 + - 32300 + - 32301 + - 32302 + - 32303 + - 32304 + - 32305 + - 32306 + - 32307 + - 32308 + - 32309 + - 32310 + - 32311 + - 32312 + - 32313 + - 32314 + - 32315 + - 32316 + - 32317 + - 32318 + - 32319 + - 32320 + - 32321 + - 32322 + - 32323 + - 32324 + - 32325 + - 32326 + - 32327 + - 32328 + - 32329 + - 32330 + - 32331 + - 32332 + - 32333 + - 32334 + - 32335 + - 32336 + - 32337 + - 32338 + - 32339 + - 32340 + - 32341 + - 32342 + - 32343 + - 32344 + - 32345 + - 32346 + - 32347 + - 32348 + - 32349 + - 32350 + - 32351 + - 32352 + - 32353 + - 32354 + - 32355 + - 32356 + - 32357 + - 32358 + - 32359 + - 32360 + - 32361 + - 32362 + - 32363 + - 32364 + - 32365 + - 32366 + - 32367 + - 32368 + - 32369 + - 32370 + - 32371 + - 32372 + - 32373 + - 32374 + - 32375 + - 32376 + - 32377 + - 32378 + - 32379 + - 32380 + - 32381 + - 32382 + - 32383 + - 32384 + - 32385 + - 32386 + - 32387 + - 32388 + - 32389 + - 32390 + - 32391 + - 32392 + - 32393 + - 32394 + - 32395 + - 32396 + - 32397 + - 32398 + - 32399 + - 32400 + - 32401 + - 32402 + - 32403 + - 32404 + - 32405 + - 32406 + - 32407 + - 32408 + - 32409 + - 32410 + - 32411 + - 32412 + - 32413 + - 32414 + - 32415 + - 32416 + - 32417 + - 32418 + - 32419 + - 32420 + - 32421 + - 32422 + - 32423 + - 32424 + - 32425 + - 32426 + - 32427 + - 32428 + - 32429 + - 32430 + - 32431 + - 32432 + - 32433 + - 32434 + - 32435 + - 32436 + - 32437 + - 32438 + - 32439 + - 32440 + - 32441 + - 32442 + - 32443 + - 32444 + - 32445 + - 32446 + - 32447 + - 32448 + - 32449 + - 32450 + - 32451 + - 32452 + - 32453 + - 32454 + - 32455 + - 32456 + - 32457 + - 32458 + - 32459 + - 32460 + - 32461 + - 32462 + - 32463 + - 32464 + - 32465 + - 32466 + - 32467 + - 32468 + - 32469 + - 32470 + - 32471 + - 32472 + - 32473 + - 32474 + - 32475 + - 32476 + - 32477 + - 32478 + - 32479 + - 32480 + - 32481 + - 32482 + - 32483 + - 32484 + - 32485 + - 32486 + - 32487 + - 32488 + - 32489 + - 32490 + - 32491 + - 32492 + - 32493 + - 32494 + - 32495 + - 32496 + - 32497 + - 32498 + - 32499 + - 32500 + - 32501 + - 32502 + - 32503 + - 32504 + - 32505 + - 32506 + - 32507 + - 32508 + - 32509 + - 32510 + - 32511 + - 32512 + - 32513 + - 32514 + - 32515 + - 32516 + - 32517 + - 32518 + - 32519 + - 32520 + - 32521 + - 32522 + - 32523 + - 32524 + - 32525 + - 32526 + - 32527 + - 32528 + - 32529 + - 32530 + - 32531 + - 32532 + - 32533 + - 32534 + - 32535 + - 32536 + - 32537 + - 32538 + - 32539 + - 32540 + - 32541 + - 32542 + - 32543 + - 32544 + - 32545 + - 32546 + - 32547 + - 32548 + - 32549 + - 32550 + - 32551 + - 32552 + - 32553 + - 32554 + - 32555 + - 32556 + - 32557 + - 32558 + - 32559 + - 32560 + - 32561 + - 32562 + - 32563 + - 32564 + - 32565 + - 32566 + - 32567 + - 32568 + - 32569 + - 32570 + - 32571 + - 32572 + - 32573 + - 32574 + - 32575 + - 32576 + - 32577 + - 32578 + - 32579 + - 32580 + - 32581 + - 32582 + - 32583 + - 32584 + - 32585 + - 32586 + - 32587 + - 32588 + - 32589 + - 32590 + - 32591 + - 32592 + - 32593 + - 32594 + - 32595 + - 32596 + - 32597 + - 32598 + - 32599 + - 32600 + - 32601 + - 32602 + - 32603 + - 32604 + - 32605 + - 32606 + - 32607 + - 32608 + - 32609 + - 32610 + - 32611 + - 32612 + - 32613 + - 32614 + - 32615 + - 32616 + - 32617 + - 32618 + - 32619 + - 32620 + - 32621 + - 32622 + - 32623 + - 32624 + - 32625 + - 32626 + - 32627 + - 32628 + - 32629 + - 32630 + - 32631 + - 32632 + - 32633 + - 32634 + - 32635 + - 32636 + - 32637 + - 32638 + - 32639 + - 32640 + - 32641 + - 32642 + - 32643 + - 32644 + - 32645 + - 32646 + - 32647 + - 32648 + - 32649 + - 32650 + - 32651 + - 32652 + - 32653 + - 32654 + - 32655 + - 32656 + - 32657 + - 32658 + - 32659 + - 32660 + - 32661 + - 32662 + - 32663 + - 32664 + - 32665 + - 32666 + - 32667 + - 32668 + - 32669 + - 32670 + - 32671 + - 32672 + - 32673 + - 32674 + - 32675 + - 32676 + - 32677 + - 32678 + - 32679 + - 32680 + - 32681 + - 32682 + - 32683 + - 32684 + - 32685 + - 32686 + - 32687 + - 32688 + - 32689 + - 32690 + - 32691 + - 32692 + - 32693 + - 32694 + - 32695 + - 32696 + - 32697 + - 32698 + - 32699 + - 32700 + - 32701 + - 32702 + - 32703 + - 32704 + - 32705 + - 32706 + - 32707 + - 32708 + - 32709 + - 32710 + - 32711 + - 32712 + - 32713 + - 32714 + - 32715 + - 32716 + - 32717 + - 32718 + - 32719 + - 32720 + - 32721 + - 32722 + - 32723 + - 32724 + - 32725 + - 32726 + - 32727 + - 32728 + - 32729 + - 32730 + - 32731 + - 32732 + - 32733 + - 32734 + - 32735 + - 32736 + - 32737 + - 32738 + - 32739 + - 32740 + - 32741 + - 32742 + - 32743 + - 32744 + - 32745 + - 32746 + - 32747 + - 32748 + - 32749 + - 32750 + - 32751 + - 32752 + - 32753 + - 32754 + - 32755 + - 32756 + - 32757 + - 32758 + - 32759 + - 32760 + - 32761 + - 32762 + - 32763 + - 32764 + - 32765 + - 32766 + - 32767 + - 32768 + - 32769 + - 32770 + - 32771 + - 32772 + - 32773 + - 32774 + - 32775 + - 32776 + - 32777 + - 32778 + - 32779 + - 32780 + - 32781 + - 32782 + - 32783 + - 32784 + - 32785 + - 32786 + - 32787 + - 32788 + - 32789 + - 32790 + - 32791 + - 32792 + - 32793 + - 32794 + - 32795 + - 32796 + - 32797 + - 32798 + - 32799 + - 32800 + - 32801 + - 32802 + - 32803 + - 32804 + - 32805 + - 32806 + - 32807 + - 32808 + - 32809 + - 32810 + - 32811 + - 32812 + - 32813 + - 32814 + - 32815 + - 32816 + - 32817 + - 32818 + - 32819 + - 32820 + - 32821 + - 32822 + - 32823 + - 32824 + - 32825 + - 32826 + - 32827 + - 32828 + - 32829 + - 32830 + - 32831 + - 32832 + - 32833 + - 32834 + - 32835 + - 32836 + - 32837 + - 32838 + - 32839 + - 32840 + - 32841 + - 32842 + - 32843 + - 32844 + - 32845 + - 32846 + - 32847 + - 32848 + - 32849 + - 32850 + - 32851 + - 32852 + - 32853 + - 32854 + - 32855 + - 32856 + - 32857 + - 32858 + - 32859 + - 32860 + - 32861 + - 32862 + - 32863 + - 32864 + - 32865 + - 32866 + - 32867 + - 32868 + - 32869 + - 32870 + - 32871 + - 32872 + - 32873 + - 32874 + - 32875 + - 32876 + - 32877 + - 32878 + - 32879 + - 32880 + - 32881 + - 32882 + - 32883 + - 32884 + - 32885 + - 32886 + - 32887 + - 32888 + - 32889 + - 32890 + - 32891 + - 32892 + - 32893 + - 32894 + - 32895 + - 32896 + - 32897 + - 32898 + - 32899 + - 32900 + - 32901 + - 32902 + - 32903 + - 32904 + - 32905 + - 32906 + - 32907 + - 32908 + - 32909 + - 32910 + - 32911 + - 32912 + - 32913 + - 32914 + - 32915 + - 32916 + - 32917 + - 32918 + - 32919 + - 32920 + - 32921 + - 32922 + - 32923 + - 32924 + - 32925 + - 32926 + - 32927 + - 32928 + - 32929 + - 32930 + - 32931 + - 32932 + - 32933 + - 32934 + - 32935 + - 32936 + - 32937 + - 32938 + - 32939 + - 32940 + - 32941 + - 32942 + - 32943 + - 32944 + - 32945 + - 32946 + - 32947 + - 32948 + - 32949 + - 32950 + - 32951 + - 32952 + - 32953 + - 32954 + - 32955 + - 32956 + - 32957 + - 32958 + - 32959 + - 32960 + - 32961 + - 32962 + - 32963 + - 32964 + - 32965 + - 32966 + - 32967 + - 32968 + - 32969 + - 32970 + - 32971 + - 32972 + - 32973 + - 32974 + - 32975 + - 32976 + - 32977 + - 32978 + - 32979 + - 32980 + - 32981 + - 32982 + - 32983 + - 32984 + - 32985 + - 32986 + - 32987 + - 32988 + - 32989 + - 32990 + - 32991 + - 32992 + - 32993 + - 32994 + - 32995 + - 32996 + - 32997 + - 32998 + - 32999 + - 33000 + - 33001 + - 33002 + - 33003 + - 33004 + - 33005 + - 33006 + - 33007 + - 33008 + - 33009 + - 33010 + - 33011 + - 33012 + - 33013 + - 33014 + - 33015 + - 33016 + - 33017 + - 33018 + - 33019 + - 33020 + - 33021 + - 33022 + - 33023 + - 33024 + - 33025 + - 33026 + - 33027 + - 33028 + - 33029 + - 33030 + - 33031 + - 33032 + - 33033 + - 33034 + - 33035 + - 33036 + - 33037 + - 33038 + - 33039 + - 33040 + - 33041 + - 33042 + - 33043 + - 33044 + - 33045 + - 33046 + - 33047 + - 33048 + - 33049 + - 33050 + - 33051 + - 33052 + - 33053 + - 33054 + - 33055 + - 33056 + - 33057 + - 33058 + - 33059 + - 33060 + - 33061 + - 33062 + - 33063 + - 33064 + - 33065 + - 33066 + - 33067 + - 33068 + - 33069 + - 33070 + - 33071 + - 33072 + - 33073 + - 33074 + - 33075 + - 33076 + - 33077 + - 33078 + - 33079 + - 33080 + - 33081 + - 33082 + - 33083 + - 33084 + - 33085 + - 33086 + - 33087 + - 33088 + - 33089 + - 33090 + - 33091 + - 33092 + - 33093 + - 33094 + - 33095 + - 33096 + - 33097 + - 33098 + - 33099 + - 33100 + - 33101 + - 33102 + - 33103 + - 33104 + - 33105 + - 33106 + - 33107 + - 33108 + - 33109 + - 33110 + - 33111 + - 33112 + - 33113 + - 33114 + - 33115 + - 33116 + - 33117 + - 33118 + - 33119 + - 33120 + - 33121 + - 33122 + - 33123 + - 33124 + - 33125 + - 33126 + - 33127 + - 33128 + - 33129 + - 33130 + - 33131 + - 33132 + - 33133 + - 33134 + - 33135 + - 33136 + - 33137 + - 33138 + - 33139 + - 33140 + - 33141 + - 33142 + - 33143 + - 33144 + - 33145 + - 33146 + - 33147 + - 33148 + - 33149 + - 33150 + - 33151 + - 33152 + - 33153 + - 33154 + - 33155 + - 33156 + - 33157 + - 33158 + - 33159 + - 33160 + - 33161 + - 33162 + - 33163 + - 33164 + - 33165 + - 33166 + - 33167 + - 33168 + - 33169 + - 33170 + - 33171 + - 33172 + - 33173 + - 33174 + - 33175 + - 33176 + - 33177 + - 33178 + - 33179 + - 33180 + - 33181 + - 33182 + - 33183 + - 33184 + - 33185 + - 33186 + - 33187 + - 33188 + - 33189 + - 33190 + - 33191 + - 33192 + - 33193 + - 33194 + - 33195 + - 33196 + - 33197 + - 33198 + - 33199 + - 33200 + - 33201 + - 33202 + - 33203 + - 33204 + - 33205 + - 33206 + - 33207 + - 33208 + - 33209 + - 33210 + - 33211 + - 33212 + - 33213 + - 33214 + - 33215 + - 33216 + - 33217 + - 33218 + - 33219 + - 33220 + - 33221 + - 33222 + - 33223 + - 33224 + - 33225 + - 33226 + - 33227 + - 33228 + - 33229 + - 33230 + - 33231 + - 33232 + - 33233 + - 33234 + - 33235 + - 33236 + - 33237 + - 33238 + - 33239 + - 33240 + - 33241 + - 33242 + - 33243 + - 33244 + - 33245 + - 33246 + - 33247 + - 33248 + - 33249 + - 33250 + - 33251 + - 33252 + - 33253 + - 33254 + - 33255 + - 33256 + - 33257 + - 33258 + - 33259 + - 33260 + - 33261 + - 33262 + - 33263 + - 33264 + - 33265 + - 33266 + - 33267 + - 33268 + - 33269 + - 33270 + - 33271 + - 33272 + - 33273 + - 33274 + - 33275 + - 33276 + - 33277 + - 33278 + - 33279 + - 33280 + - 33281 + - 33282 + - 33283 + - 33284 + - 33285 + - 33286 + - 33287 + - 33288 + - 33289 + - 33290 + - 33291 + - 33292 + - 33293 + - 33294 + - 33295 + - 33296 + - 33297 + - 33298 + - 33299 + - 33300 + - 33301 + - 33302 + - 33303 + - 33304 + - 33305 + - 33306 + - 33307 + - 33308 + - 33309 + - 33310 + - 33311 + - 33312 + - 33313 + - 33314 + - 33315 + - 33316 + - 33317 + - 33318 + - 33319 + - 33320 + - 33321 + - 33322 + - 33323 + - 33324 + - 33325 + - 33326 + - 33327 + - 33328 + - 33329 + - 33330 + - 33331 + - 33332 + - 33333 + - 33334 + - 33335 + - 33336 + - 33337 + - 33338 + - 33339 + - 33340 + - 33341 + - 33342 + - 33343 + - 33344 + - 33345 + - 33346 + - 33347 + - 33348 + - 33349 + - 33350 + - 33351 + - 33352 + - 33353 + - 33354 + - 33355 + - 33356 + - 33357 + - 33358 + - 33359 + - 33360 + - 33361 + - 33362 + - 33363 + - 33364 + - 33365 + - 33366 + - 33367 + - 33368 + - 33369 + - 33370 + - 33371 + - 33372 + - 33373 + - 33374 + - 33375 + - 33376 + - 33377 + - 33378 + - 33379 + - 33380 + - 33381 + - 33382 + - 33383 + - 33384 + - 33385 + - 33386 + - 33387 + - 33388 + - 33389 + - 33390 + - 33391 + - 33392 + - 33393 + - 33394 + - 33395 + - 33396 + - 33397 + - 33398 + - 33399 + - 33400 + - 33401 + - 33402 + - 33403 + - 33404 + - 33405 + - 33406 + - 33407 + - 33408 + - 33409 + - 33410 + - 33411 + - 33412 + - 33413 + - 33414 + - 33415 + - 33416 + - 33417 + - 33418 + - 33419 + - 33420 + - 33421 + - 33422 + - 33423 + - 33424 + - 33425 + - 33426 + - 33427 + - 33428 + - 33429 + - 33430 + - 33431 + - 33432 + - 33433 + - 33434 + - 33435 + - 33436 + - 33437 + - 33438 + - 33439 + - 33440 + - 33441 + - 33442 + - 33443 + - 33444 + - 33445 + - 33446 + - 33447 + - 33448 + - 33449 + - 33450 + - 33451 + - 33452 + - 33453 + - 33454 + - 33455 + - 33456 + - 33457 + - 33458 + - 33459 + - 33460 + - 33461 + - 33462 + - 33463 + - 33464 + - 33465 + - 33466 + - 33467 + - 33468 + - 33469 + - 33470 + - 33471 + - 33472 + - 33473 + - 33474 + - 33475 + - 33476 + - 33477 + - 33478 + - 33479 + - 33480 + - 33481 + - 33482 + - 33483 + - 33484 + - 33485 + - 33486 + - 33487 + - 33488 + - 33489 + - 33490 + - 33491 + - 33492 + - 33493 + - 33494 + - 33495 + - 33496 + - 33497 + - 33498 + - 33499 + - 33500 + - 33501 + - 33502 + - 33503 + - 33504 + - 33505 + - 33506 + - 33507 + - 33508 + - 33509 + - 33510 + - 33511 + - 33512 + - 33513 + - 33514 + - 33515 + - 33516 + - 33517 + - 33518 + - 33519 + - 33520 + - 33521 + - 33522 + - 33523 + - 33524 + - 33525 + - 33526 + - 33527 + - 33528 + - 33529 + - 33530 + - 33531 + - 33532 + - 33533 + - 33534 + - 33535 + - 33536 + - 33537 + - 33538 + - 33539 + - 33540 + - 33541 + - 33542 + - 33543 + - 33544 + - 33545 + - 33546 + - 33547 + - 33548 + - 33549 + - 33550 + - 33551 + - 33552 + - 33553 + - 33554 + - 33555 + - 33556 + - 33557 + - 33558 + - 33559 + - 33560 + - 33561 + - 33562 + - 33563 + - 33564 + - 33565 + - 33566 + - 33567 + - 33568 + - 33569 + - 33570 + - 33571 + - 33572 + - 33573 + - 33574 + - 33575 + - 33576 + - 33577 + - 33578 + - 33579 + - 33580 + - 33581 + - 33582 + - 33583 + - 33584 + - 33585 + - 33586 + - 33587 + - 33588 + - 33589 + - 33590 + - 33591 + - 33592 + - 33593 + - 33594 + - 33595 + - 33596 + - 33597 + - 33598 + - 33599 + - 33600 + - 33601 + - 33602 + - 33603 + - 33604 + - 33605 + - 33606 + - 33607 + - 33608 + - 33609 + - 33610 + - 33611 + - 33612 + - 33613 + - 33614 + - 33615 + - 33616 + - 33617 + - 33618 + - 33619 + - 33620 + - 33621 + - 33622 + - 33623 + - 33624 + - 33625 + - 33626 + - 33627 + - 33628 + - 33629 + - 33630 + - 33631 + - 33632 + - 33633 + - 33634 + - 33635 + - 33636 + - 33637 + - 33638 + - 33639 + - 33640 + - 33641 + - 33642 + - 33643 + - 33644 + - 33645 + - 33646 + - 33647 + - 33648 + - 33649 + - 33650 + - 33651 + - 33652 + - 33653 + - 33654 + - 33655 + - 33656 + - 33657 + - 33658 + - 33659 + - 33660 + - 33661 + - 33662 + - 33663 + - 33664 + - 33665 + - 33666 + - 33667 + - 33668 + - 33669 + - 33670 + - 33671 + - 33672 + - 33673 + - 33674 + - 33675 + - 33676 + - 33677 + - 33678 + - 33679 + - 33680 + - 33681 + - 33682 + - 33683 + - 33684 + - 33685 + - 33686 + - 33687 + - 33688 + - 33689 + - 33690 + - 33691 + - 33692 + - 33693 + - 33694 + - 33695 + - 33696 + - 33697 + - 33698 + - 33699 + - 33700 + - 33701 + - 33702 + - 33703 + - 33704 + - 33705 + - 33706 + - 33707 + - 33708 + - 33709 + - 33710 + - 33711 + - 33712 + - 33713 + - 33714 + - 33715 + - 33716 + - 33717 + - 33718 + - 33719 + - 33720 + - 33721 + - 33722 + - 33723 + - 33724 + - 33725 + - 33726 + - 33727 + - 33728 + - 33729 + - 33730 + - 33731 + - 33732 + - 33733 + - 33734 + - 33735 + - 33736 + - 33737 + - 33738 + - 33739 + - 33740 + - 33741 + - 33742 + - 33743 + - 33744 + - 33745 + - 33746 + - 33747 + - 33748 + - 33749 + - 33750 + - 33751 + - 33752 + - 33753 + - 33754 + - 33755 + - 33756 + - 33757 + - 33758 + - 33759 + - 33760 + - 33761 + - 33762 + - 33763 + - 33764 + - 33765 + - 33766 + - 33767 + - 33768 + - 33769 + - 33770 + - 33771 + - 33772 + - 33773 + - 33774 + - 33775 + - 33776 + - 33777 + - 33778 + - 33779 + - 33780 + - 33781 + - 33782 + - 33783 + - 33784 + - 33785 + - 33786 + - 33787 + - 33788 + - 33789 + - 33790 + - 33791 + - 33792 + - 33793 + - 33794 + - 33795 + - 33796 + - 33797 + - 33798 + - 33799 + - 33800 + - 33801 + - 33802 + - 33803 + - 33804 + - 33805 + - 33806 + - 33807 + - 33808 + - 33809 + - 33810 + - 33811 + - 33812 + - 33813 + - 33814 + - 33815 + - 33816 + - 33817 + - 33818 + - 33819 + - 33820 + - 33821 + - 33822 + - 33823 + - 33824 + - 33825 + - 33826 + - 33827 + - 33828 + - 33829 + - 33830 + - 33831 + - 33832 + - 33833 + - 33834 + - 33835 + - 33836 + - 33837 + - 33838 + - 33839 + - 33840 + - 33841 + - 33842 + - 33843 + - 33844 + - 33845 + - 33846 + - 33847 + - 33848 + - 33849 + - 33850 + - 33851 + - 33852 + - 33853 + - 33854 + - 33855 + - 33856 + - 33857 + - 33858 + - 33859 + - 33860 + - 33861 + - 33862 + - 33863 + - 33864 + - 33865 + - 33866 + - 33867 + - 33868 + - 33869 + - 33870 + - 33871 + - 33872 + - 33873 + - 33874 + - 33875 + - 33876 + - 33877 + - 33878 + - 33879 + - 33880 + - 33881 + - 33882 + - 33883 + - 33884 + - 33885 + - 33886 + - 33887 + - 33888 + - 33889 + - 33890 + - 33891 + - 33892 + - 33893 + - 33894 + - 33895 + - 33896 + - 33897 + - 33898 + - 33899 + - 33900 + - 33901 + - 33902 + - 33903 + - 33904 + - 33905 + - 33906 + - 33907 + - 33908 + - 33909 + - 33910 + - 33911 + - 33912 + - 33913 + - 33914 + - 33915 + - 33916 + - 33917 + - 33918 + - 33919 + - 33920 + - 33921 + - 33922 + - 33923 + - 33924 + - 33925 + - 33926 + - 33927 + - 33928 + - 33929 + - 33930 + - 33931 + - 33932 + - 33933 + - 33934 + - 33935 + - 33936 + - 33937 + - 33938 + - 33939 + - 33940 + - 33941 + - 33942 + - 33943 + - 33944 + - 33945 + - 33946 + - 33947 + - 33948 + - 33949 + - 33950 + - 33951 + - 33952 + - 33953 + - 33954 + - 33955 + - 33956 + - 33957 + - 33958 + - 33959 + - 33960 + - 33961 + - 33962 + - 33963 + - 33964 + - 33965 + - 33966 + - 33967 + - 33968 + - 33969 + - 33970 + - 33971 + - 33972 + - 33973 + - 33974 + - 33975 + - 33976 + - 33977 + - 33978 + - 33979 + - 33980 + - 33981 + - 33982 + - 33983 + - 33984 + - 33985 + - 33986 + - 33987 + - 33988 + - 33989 + - 33990 + - 33991 + - 33992 + - 33993 + - 33994 + - 33995 + - 33996 + - 33997 + - 33998 + - 33999 + - 34000 + - 34001 + - 34002 + - 34003 + - 34004 + - 34005 + - 34006 + - 34007 + - 34008 + - 34009 + - 34010 + - 34011 + - 34012 + - 34013 + - 34014 + - 34015 + - 34016 + - 34017 + - 34018 + - 34019 + - 34020 + - 34021 + - 34022 + - 34023 + - 34024 + - 34025 + - 34026 + - 34027 + - 34028 + - 34029 + - 34030 + - 34031 + - 34032 + - 34033 + - 34034 + - 34035 + - 34036 + - 34037 + - 34038 + - 34039 + - 34040 + - 34041 + - 34042 + - 34043 + - 34044 + - 34045 + - 34046 + - 34047 + - 34048 + - 34049 + - 34050 + - 34051 + - 34052 + - 34053 + - 34054 + - 34055 + - 34056 + - 34057 + - 34058 + - 34059 + - 34060 + - 34061 + - 34062 + - 34063 + - 34064 + - 34065 + - 34066 + - 34067 + - 34068 + - 34069 + - 34070 + - 34071 + - 34072 + - 34073 + - 34074 + - 34075 + - 34076 + - 34077 + - 34078 + - 34079 + - 34080 + - 34081 + - 34082 + - 34083 + - 34084 + - 34085 + - 34086 + - 34087 + - 34088 + - 34089 + - 34090 + - 34091 + - 34092 + - 34093 + - 34094 + - 34095 + - 34096 + - 34097 + - 34098 + - 34099 + - 34100 + - 34101 + - 34102 + - 34103 + - 34104 + - 34105 + - 34106 + - 34107 + - 34108 + - 34109 + - 34110 + - 34111 + - 34112 + - 34113 + - 34114 + - 34115 + - 34116 + - 34117 + - 34118 + - 34119 + - 34120 + - 34121 + - 34122 + - 34123 + - 34124 + - 34125 + - 34126 + - 34127 + - 34128 + - 34129 + - 34130 + - 34131 + - 34132 + - 34133 + - 34134 + - 34135 + - 34136 + - 34137 + - 34138 + - 34139 + - 34140 + - 34141 + - 34142 + - 34143 + - 34144 + - 34145 + - 34146 + - 34147 + - 34148 + - 34149 + - 34150 + - 34151 + - 34152 + - 34153 + - 34154 + - 34155 + - 34156 + - 34157 + - 34158 + - 34159 + - 34160 + - 34161 + - 34162 + - 34163 + - 34164 + - 34165 + - 34166 + - 34167 + - 34168 + - 34169 + - 34170 + - 34171 + - 34172 + - 34173 + - 34174 + - 34175 + - 34176 + - 34177 + - 34178 + - 34179 + - 34180 + - 34181 + - 34182 + - 34183 + - 34184 + - 34185 + - 34186 + - 34187 + - 34188 + - 34189 + - 34190 + - 34191 + - 34192 + - 34193 + - 34194 + - 34195 + - 34196 + - 34197 + - 34198 + - 34199 + - 34200 + - 34201 + - 34202 + - 34203 + - 34204 + - 34205 + - 34206 + - 34207 + - 34208 + - 34209 + - 34210 + - 34211 + - 34212 + - 34213 + - 34214 + - 34215 + - 34216 + - 34217 + - 34218 + - 34219 + - 34220 + - 34221 + - 34222 + - 34223 + - 34224 + - 34225 + - 34226 + - 34227 + - 34228 + - 34229 + - 34230 + - 34231 + - 34232 + - 34233 + - 34234 + - 34235 + - 34236 + - 34237 + - 34238 + - 34239 + - 34240 + - 34241 + - 34242 + - 34243 + - 34244 + - 34245 + - 34246 + - 34247 + - 34248 + - 34249 + - 34250 + - 34251 + - 34252 + - 34253 + - 34254 + - 34255 + - 34256 + - 34257 + - 34258 + - 34259 + - 34260 + - 34261 + - 34262 + - 34263 + - 34264 + - 34265 + - 34266 + - 34267 + - 34268 + - 34269 + - 34270 + - 34271 + - 34272 + - 34273 + - 34274 + - 34275 + - 34276 + - 34277 + - 34278 + - 34279 + - 34280 + - 34281 + - 34282 + - 34283 + - 34284 + - 34285 + - 34286 + - 34287 + - 34288 + - 34289 + - 34290 + - 34291 + - 34292 + - 34293 + - 34294 + - 34295 + - 34296 + - 34297 + - 34298 + - 34299 + - 34300 + - 34301 + - 34302 + - 34303 + - 34304 + - 34305 + - 34306 + - 34307 + - 34308 + - 34309 + - 34310 + - 34311 + - 34312 + - 34313 + - 34314 + - 34315 + - 34316 + - 34317 + - 34318 + - 34319 + - 34320 + - 34321 + - 34322 + - 34323 + - 34324 + - 34325 + - 34326 + - 34327 + - 34328 + - 34329 + - 34330 + - 34331 + - 34332 + - 34333 + - 34334 + - 34335 + - 34336 + - 34337 + - 34338 + - 34339 + - 34340 + - 34341 + - 34342 + - 34343 + - 34344 + - 34345 + - 34346 + - 34347 + - 34348 + - 34349 + - 34350 + - 34351 + - 34352 + - 34353 + - 34354 + - 34355 + - 34356 + - 34357 + - 34358 + - 34359 + - 34360 + - 34361 + - 34362 + - 34363 + - 34364 + - 34365 + - 34366 + - 34367 + - 34368 + - 34369 + - 34370 + - 34371 + - 34372 + - 34373 + - 34374 + - 34375 + - 34376 + - 34377 + - 34378 + - 34379 + - 34380 + - 34381 + - 34382 + - 34383 + - 34384 + - 34385 + - 34386 + - 34387 + - 34388 + - 34389 + - 34390 + - 34391 + - 34392 + - 34393 + - 34394 + - 34395 + - 34396 + - 34397 + - 34398 + - 34399 + - 34400 + - 34401 + - 34402 + - 34403 + - 34404 + - 34405 + - 34406 + - 34407 + - 34408 + - 34409 + - 34410 + - 34411 + - 34412 + - 34413 + - 34414 + - 34415 + - 34416 + - 34417 + - 34418 + - 34419 + - 34420 + - 34421 + - 34422 + - 34423 + - 34424 + - 34425 + - 34426 + - 34427 + - 34428 + - 34429 + - 34430 + - 34431 + - 34432 + - 34433 + - 34434 + - 34435 + - 34436 + - 34437 + - 34438 + - 34439 + - 34440 + - 34441 + - 34442 + - 34443 + - 34444 + - 34445 + - 34446 + - 34447 + - 34448 + - 34449 + - 34450 + - 34451 + - 34452 + - 34453 + - 34454 + - 34455 + - 34456 + - 34457 + - 34458 + - 34459 + - 34460 + - 34461 + - 34462 + - 34463 + - 34464 + - 34465 + - 34466 + - 34467 + - 34468 + - 34469 + - 34470 + - 34471 + - 34472 + - 34473 + - 34474 + - 34475 + - 34476 + - 34477 + - 34478 + - 34479 + - 34480 + - 34481 + - 34482 + - 34483 + - 34484 + - 34485 + - 34486 + - 34487 + - 34488 + - 34489 + - 34490 + - 34491 + - 34492 + - 34493 + - 34494 + - 34495 + - 34496 + - 34497 + - 34498 + - 34499 + - 34500 + - 34501 + - 34502 + - 34503 + - 34504 + - 34505 + - 34506 + - 34507 + - 34508 + - 34509 + - 34510 + - 34511 + - 34512 + - 34513 + - 34514 + - 34515 + - 34516 + - 34517 + - 34518 + - 34519 + - 34520 + - 34521 + - 34522 + - 34523 + - 34524 + - 34525 + - 34526 + - 34527 + - 34528 + - 34529 + - 34530 + - 34531 + - 34532 + - 34533 + - 34534 + - 34535 + - 34536 + - 34537 + - 34538 + - 34539 + - 34540 + - 34541 + - 34542 + - 34543 + - 34544 + - 34545 + - 34546 + - 34547 + - 34548 + - 34549 + - 34550 + - 34551 + - 34552 + - 34553 + - 34554 + - 34555 + - 34556 + - 34557 + - 34558 + - 34559 + - 34560 + - 34561 + - 34562 + - 34563 + - 34564 + - 34565 + - 34566 + - 34567 + - 34568 + - 34569 + - 34570 + - 34571 + - 34572 + - 34573 + - 34574 + - 34575 + - 34576 + - 34577 + - 34578 + - 34579 + - 34580 + - 34581 + - 34582 + - 34583 + - 34584 + - 34585 + - 34586 + - 34587 + - 34588 + - 34589 + - 34590 + - 34591 + - 34592 + - 34593 + - 34594 + - 34595 + - 34596 + - 34597 + - 34598 + - 34599 + - 34600 + - 34601 + - 34602 + - 34603 + - 34604 + - 34605 + - 34606 + - 34607 + - 34608 + - 34609 + - 34610 + - 34611 + - 34612 + - 34613 + - 34614 + - 34615 + - 34616 + - 34617 + - 34618 + - 34619 + - 34620 + - 34621 + - 34622 + - 34623 + - 34624 + - 34625 + - 34626 + - 34627 + - 34628 + - 34629 + - 34630 + - 34631 + - 34632 + - 34633 + - 34634 + - 34635 + - 34636 + - 34637 + - 34638 + - 34639 + - 34640 + - 34641 + - 34642 + - 34643 + - 34644 + - 34645 + - 34646 + - 34647 + - 34648 + - 34649 + - 34650 + - 34651 + - 34652 + - 34653 + - 34654 + - 34655 + - 34656 + - 34657 + - 34658 + - 34659 + - 34660 + - 34661 + - 34662 + - 34663 + - 34664 + - 34665 + - 34666 + - 34667 + - 34668 + - 34669 + - 34670 + - 34671 + - 34672 + - 34673 + - 34674 + - 34675 + - 34676 + - 34677 + - 34678 + - 34679 + - 34680 + - 34681 + - 34682 + - 34683 + - 34684 + - 34685 + - 34686 + - 34687 + - 34688 + - 34689 + - 34690 + - 34691 + - 34692 + - 34693 + - 34694 + - 34695 + - 34696 + - 34697 + - 34698 + - 34699 + - 34700 + - 34701 + - 34702 + - 34703 + - 34704 + - 34705 + - 34706 + - 34707 + - 34708 + - 34709 + - 34710 + - 34711 + - 34712 + - 34713 + - 34714 + - 34715 + - 34716 + - 34717 + - 34718 + - 34719 + - 34720 + - 34721 + - 34722 + - 34723 + - 34724 + - 34725 + - 34726 + - 34727 + - 34728 + - 34729 + - 34730 + - 34731 + - 34732 + - 34733 + - 34734 + - 34735 + - 34736 + - 34737 + - 34738 + - 34739 + - 34740 + - 34741 + - 34742 + - 34743 + - 34744 + - 34745 + - 34746 + - 34747 + - 34748 + - 34749 + - 34750 + - 34751 + - 34752 + - 34753 + - 34754 + - 34755 + - 34756 + - 34757 + - 34758 + - 34759 + - 34760 + - 34761 + - 34762 + - 34763 + - 34764 + - 34765 + - 34766 + - 34767 + - 34768 + - 34769 + - 34770 + - 34771 + - 34772 + - 34773 + - 34774 + - 34775 + - 34776 + - 34777 + - 34778 + - 34779 + - 34780 + - 34781 + - 34782 + - 34783 + - 34784 + - 34785 + - 34786 + - 34787 + - 34788 + - 34789 + - 34790 + - 34791 + - 34792 + - 34793 + - 34794 + - 34795 + - 34796 + - 34797 + - 34798 + - 34799 + - 34800 + - 34801 + - 34802 + - 34803 + - 34804 + - 34805 + - 34806 + - 34807 + - 34808 + - 34809 + - 34810 + - 34811 + - 34812 + - 34813 + - 34814 + - 34815 + - 34816 + - 34817 + - 34818 + - 34819 + - 34820 + - 34821 + - 34822 + - 34823 + - 34824 + - 34825 + - 34826 + - 34827 + - 34828 + - 34829 + - 34830 + - 34831 + - 34832 + - 34833 + - 34834 + - 34835 + - 34836 + - 34837 + - 34838 + - 34839 + - 34840 + - 34841 + - 34842 + - 34843 + - 34844 + - 34845 + - 34846 + - 34847 + - 34848 + - 34849 + - 34850 + - 34851 + - 34852 + - 34853 + - 34854 + - 34855 + - 34856 + - 34857 + - 34858 + - 34859 + - 34860 + - 34861 + - 34862 + - 34863 + - 34864 + - 34865 + - 34866 + - 34867 + - 34868 + - 34869 + - 34870 + - 34871 + - 34872 + - 34873 + - 34874 + - 34875 + - 34876 + - 34877 + - 34878 + - 34879 + - 34880 + - 34881 + - 34882 + - 34883 + - 34884 + - 34885 + - 34886 + - 34887 + - 34888 + - 34889 + - 34890 + - 34891 + - 34892 + - 34893 + - 34894 + - 34895 + - 34896 + - 34897 + - 34898 + - 34899 + - 34900 + - 34901 + - 34902 + - 34903 + - 34904 + - 34905 + - 34906 + - 34907 + - 34908 + - 34909 + - 34910 + - 34911 + - 34912 + - 34913 + - 34914 + - 34915 + - 34916 + - 34917 + - 34918 + - 34919 + - 34920 + - 34921 + - 34922 + - 34923 + - 34924 + - 34925 + - 34926 + - 34927 + - 34928 + - 34929 + - 34930 + - 34931 + - 34932 + - 34933 + - 34934 + - 34935 + - 34936 + - 34937 + - 34938 + - 34939 + - 34940 + - 34941 + - 34942 + - 34943 + - 34944 + - 34945 + - 34946 + - 34947 + - 34948 + - 34949 + - 34950 + - 34951 + - 34952 + - 34953 + - 34954 + - 34955 + - 34956 + - 34957 + - 34958 + - 34959 + - 34960 + - 34961 + - 34962 + - 34963 + - 34964 + - 34965 + - 34966 + - 34967 + - 34968 + - 34969 + - 34970 + - 34971 + - 34972 + - 34973 + - 34974 + - 34975 + - 34976 + - 34977 + - 34978 + - 34979 + - 34980 + - 34981 + - 34982 + - 34983 + - 34984 + - 34985 + - 34986 + - 34987 + - 34988 + - 34989 + - 34990 + - 34991 + - 34992 + - 34993 + - 34994 + - 34995 + - 34996 + - 34997 + - 34998 + - 34999 + - 35000 + - 35001 + - 35002 + - 35003 + - 35004 + - 35005 + - 35006 + - 35007 + - 35008 + - 35009 + - 35010 + - 35011 + - 35012 + - 35013 + - 35014 + - 35015 + - 35016 + - 35017 + - 35018 + - 35019 + - 35020 + - 35021 + - 35022 + - 35023 + - 35024 + - 35025 + - 35026 + - 35027 + - 35028 + - 35029 + - 35030 + - 35031 + - 35032 + - 35033 + - 35034 + - 35035 + - 35036 + - 35037 + - 35038 + - 35039 + - 35040 + - 35041 + - 35042 + - 35043 + - 35044 + - 35045 + - 35046 + - 35047 + - 35048 + - 35049 + - 35050 + - 35051 + - 35052 + - 35053 + - 35054 + - 35055 + - 35056 + - 35057 + - 35058 + - 35059 + - 35060 + - 35061 + - 35062 + - 35063 + - 35064 + - 35065 + - 35066 + - 35067 + - 35068 + - 35069 + - 35070 + - 35071 + - 35072 + - 35073 + - 35074 + - 35075 + - 35076 + - 35077 + - 35078 + - 35079 + - 35080 + - 35081 + - 35082 + - 35083 + - 35084 + - 35085 + - 35086 + - 35087 + - 35088 + - 35089 + - 35090 + - 35091 + - 35092 + - 35093 + - 35094 + - 35095 + - 35096 + - 35097 + - 35098 + - 35099 + - 35100 + - 35101 + - 35102 + - 35103 + - 35104 + - 35105 + - 35106 + - 35107 + - 35108 + - 35109 + - 35110 + - 35111 + - 35112 + - 35113 + - 35114 + - 35115 + - 35116 + - 35117 + - 35118 + - 35119 + - 35120 + - 35121 + - 35122 + - 35123 + - 35124 + - 35125 + - 35126 + - 35127 + - 35128 + - 35129 + - 35130 + - 35131 + - 35132 + - 35133 + - 35134 + - 35135 + - 35136 + - 35137 + - 35138 + - 35139 + - 35140 + - 35141 + - 35142 + - 35143 + - 35144 + - 35145 + - 35146 + - 35147 + - 35148 + - 35149 + - 35150 + - 35151 + - 35152 + - 35153 + - 35154 + - 35155 + - 35156 + - 35157 + - 35158 + - 35159 + - 35160 + - 35161 + - 35162 + - 35163 + - 35164 + - 35165 + - 35166 + - 35167 + - 35168 + - 35169 + - 35170 + - 35171 + - 35172 + - 35173 + - 35174 + - 35175 + - 35176 + - 35177 + - 35178 + - 35179 + - 35180 + - 35181 + - 35182 + - 35183 + - 35184 + - 35185 + - 35186 + - 35187 + - 35188 + - 35189 + - 35190 + - 35191 + - 35192 + - 35193 + - 35194 + - 35195 + - 35196 + - 35197 + - 35198 + - 35199 + - 35200 + - 35201 + - 35202 + - 35203 + - 35204 + - 35205 + - 35206 + - 35207 + - 35208 + - 35209 + - 35210 + - 35211 + - 35212 + - 35213 + - 35214 + - 35215 + - 35216 + - 35217 + - 35218 + - 35219 + - 35220 + - 35221 + - 35222 + - 35223 + - 35224 + - 35225 + - 35226 + - 35227 + - 35228 + - 35229 + - 35230 + - 35231 + - 35232 + - 35233 + - 35234 + - 35235 + - 35236 + - 35237 + - 35238 + - 35239 + - 35240 + - 35241 + - 35242 + - 35243 + - 35244 + - 35245 + - 35246 + - 35247 + - 35248 + - 35249 + - 35250 + - 35251 + - 35252 + - 35253 + - 35254 + - 35255 + - 35256 + - 35257 + - 35258 + - 35259 + - 35260 + - 35261 + - 35262 + - 35263 + - 35264 + - 35265 + - 35266 + - 35267 + - 35268 + - 35269 + - 35270 + - 35271 + - 35272 + - 35273 + - 35274 + - 35275 + - 35276 + - 35277 + - 35278 + - 35279 + - 35280 + - 35281 + - 35282 + - 35283 + - 35284 + - 35285 + - 35286 + - 35287 + - 35288 + - 35289 + - 35290 + - 35291 + - 35292 + - 35293 + - 35294 + - 35295 + - 35296 + - 35297 + - 35298 + - 35299 + - 35300 + - 35301 + - 35302 + - 35303 + - 35304 + - 35305 + - 35306 + - 35307 + - 35308 + - 35309 + - 35310 + - 35311 + - 35312 + - 35313 + - 35314 + - 35315 + - 35316 + - 35317 + - 35318 + - 35319 + - 35320 + - 35321 + - 35322 + - 35323 + - 35324 + - 35325 + - 35326 + - 35327 + - 35328 + - 35329 + - 35330 + - 35331 + - 35332 + - 35333 + - 35334 + - 35335 + - 35336 + - 35337 + - 35338 + - 35339 + - 35340 + - 35341 + - 35342 + - 35343 + - 35344 + - 35345 + - 35346 + - 35347 + - 35348 + - 35349 + - 35350 + - 35351 + - 35352 + - 35353 + - 35354 + - 35355 + - 35356 + - 35357 + - 35358 + - 35359 + - 35360 + - 35361 + - 35362 + - 35363 + - 35364 + - 35365 + - 35366 + - 35367 + - 35368 + - 35369 + - 35370 + - 35371 + - 35372 + - 35373 + - 35374 + - 35375 + - 35376 + - 35377 + - 35378 + - 35379 + - 35380 + - 35381 + - 35382 + - 35383 + - 35384 + - 35385 + - 35386 + - 35387 + - 35388 + - 35389 + - 35390 + - 35391 + - 35392 + - 35393 + - 35394 + - 35395 + - 35396 + - 35397 + - 35398 + - 35399 + - 35400 + - 35401 + - 35402 + - 35403 + - 35404 + - 35405 + - 35406 + - 35407 + - 35408 + - 35409 + - 35410 + - 35411 + - 35412 + - 35413 + - 35414 + - 35415 + - 35416 + - 35417 + - 35418 + - 35419 + - 35420 + - 35421 + - 35422 + - 35423 + - 35424 + - 35425 + - 35426 + - 35427 + - 35428 + - 35429 + - 35430 + - 35431 + - 35432 + - 35433 + - 35434 + - 35435 + - 35436 + - 35437 + - 35438 + - 35439 + - 35440 + - 35441 + - 35442 + - 35443 + - 35444 + - 35445 + - 35446 + - 35447 + - 35448 + - 35449 + - 35450 + - 35451 + - 35452 + - 35453 + - 35454 + - 35455 + - 35456 + - 35457 + - 35458 + - 35459 + - 35460 + - 35461 + - 35462 + - 35463 + - 35464 + - 35465 + - 35466 + - 35467 + - 35468 + - 35469 + - 35470 + - 35471 + - 35472 + - 35473 + - 35474 + - 35475 + - 35476 + - 35477 + - 35478 + - 35479 + - 35480 + - 35481 + - 35482 + - 35483 + - 35484 + - 35485 + - 35486 + - 35487 + - 35488 + - 35489 + - 35490 + - 35491 + - 35492 + - 35493 + - 35494 + - 35495 + - 35496 + - 35497 + - 35498 + - 35499 + - 35500 + - 35501 + - 35502 + - 35503 + - 35504 + - 35505 + - 35506 + - 35507 + - 35508 + - 35509 + - 35510 + - 35511 + - 35512 + - 35513 + - 35514 + - 35515 + - 35516 + - 35517 + - 35518 + - 35519 + - 35520 + - 35521 + - 35522 + - 35523 + - 35524 + - 35525 + - 35526 + - 35527 + - 35528 + - 35529 + - 35530 + - 35531 + - 35532 + - 35533 + - 35534 + - 35535 + - 35536 + - 35537 + - 35538 + - 35539 + - 35540 + - 35541 + - 35542 + - 35543 + - 35544 + - 35545 + - 35546 + - 35547 + - 35548 + - 35549 + - 35550 + - 35551 + - 35552 + - 35553 + - 35554 + - 35555 + - 35556 + - 35557 + - 35558 + - 35559 + - 35560 + - 35561 + - 35562 + - 35563 + - 35564 + - 35565 + - 35566 + - 35567 + - 35568 + - 35569 + - 35570 + - 35571 + - 35572 + - 35573 + - 35574 + - 35575 + - 35576 + - 35577 + - 35578 + - 35579 + - 35580 + - 35581 + - 35582 + - 35583 + - 35584 + - 35585 + - 35586 + - 35587 + - 35588 + - 35589 + - 35590 + - 35591 + - 35592 + - 35593 + - 35594 + - 35595 + - 35596 + - 35597 + - 35598 + - 35599 + - 35600 + - 35601 + - 35602 + - 35603 + - 35604 + - 35605 + - 35606 + - 35607 + - 35608 + - 35609 + - 35610 + - 35611 + - 35612 + - 35613 + - 35614 + - 35615 + - 35616 + - 35617 + - 35618 + - 35619 + - 35620 + - 35621 + - 35622 + - 35623 + - 35624 + - 35625 + - 35626 + - 35627 + - 35628 + - 35629 + - 35630 + - 35631 + - 35632 + - 35633 + - 35634 + - 35635 + - 35636 + - 35637 + - 35638 + - 35639 + - 35640 + - 35641 + - 35642 + - 35643 + - 35644 + - 35645 + - 35646 + - 35647 + - 35648 + - 35649 + - 35650 + - 35651 + - 35652 + - 35653 + - 35654 + - 35655 + - 35656 + - 35657 + - 35658 + - 35659 + - 35660 + - 35661 + - 35662 + - 35663 + - 35664 + - 35665 + - 35666 + - 35667 + - 35668 + - 35669 + - 35670 + - 35671 + - 35672 + - 35673 + - 35674 + - 35675 + - 35676 + - 35677 + - 35678 + - 35679 + - 35680 + - 35681 + - 35682 + - 35683 + - 35684 + - 35685 + - 35686 + - 35687 + - 35688 + - 35689 + - 35690 + - 35691 + - 35692 + - 35693 + - 35694 + - 35695 + - 35696 + - 35697 + - 35698 + - 35699 + - 35700 + - 35701 + - 35702 + - 35703 + - 35704 + - 35705 + - 35706 + - 35707 + - 35708 + - 35709 + - 35710 + - 35711 + - 35712 + - 35713 + - 35714 + - 35715 + - 35716 + - 35717 + - 35718 + - 35719 + - 35720 + - 35721 + - 35722 + - 35723 + - 35724 + - 35725 + - 35726 + - 35727 + - 35728 + - 35729 + - 35730 + - 35731 + - 35732 + - 35733 + - 35734 + - 35735 + - 35736 + - 35737 + - 35738 + - 35739 + - 35740 + - 35741 + - 35742 + - 35743 + - 35744 + - 35745 + - 35746 + - 35747 + - 35748 + - 35749 + - 35750 + - 35751 + - 35752 + - 35753 + - 35754 + - 35755 + - 35756 + - 35757 + - 35758 + - 35759 + - 35760 + - 35761 + - 35762 + - 35763 + - 35764 + - 35765 + - 35766 + - 35767 + - 35768 + - 35769 + - 35770 + - 35771 + - 35772 + - 35773 + - 35774 + - 35775 + - 35776 + - 35777 + - 35778 + - 35779 + - 35780 + - 35781 + - 35782 + - 35783 + - 35784 + - 35785 + - 35786 + - 35787 + - 35788 + - 35789 + - 35790 + - 35791 + - 35792 + - 35793 + - 35794 + - 35795 + - 35796 + - 35797 + - 35798 + - 35799 + - 35800 + - 35801 + - 35802 + - 35803 + - 35804 + - 35805 + - 35806 + - 35807 + - 35808 + - 35809 + - 35810 + - 35811 + - 35812 + - 35813 + - 35814 + - 35815 + - 35816 + - 35817 + - 35818 + - 35819 + - 35820 + - 35821 + - 35822 + - 35823 + - 35824 + - 35825 + - 35826 + - 35827 + - 35828 + - 35829 + - 35830 + - 35831 + - 35832 + - 35833 + - 35834 + - 35835 + - 35836 + - 35837 + - 35838 + - 35839 + - 35840 + - 35841 + - 35842 + - 35843 + - 35844 + - 35845 + - 35846 + - 35847 + - 35848 + - 35849 + - 35850 + - 35851 + - 35852 + - 35853 + - 35854 + - 35855 + - 35856 + - 35857 + - 35858 + - 35859 + - 35860 + - 35861 + - 35862 + - 35863 + - 35864 + - 35865 + - 35866 + - 35867 + - 35868 + - 35869 + - 35870 + - 35871 + - 35872 + - 35873 + - 35874 + - 35875 + - 35876 + - 35877 + - 35878 + - 35879 + - 35880 + - 35881 + - 35882 + - 35883 + - 35884 + - 35885 + - 35886 + - 35887 + - 35888 + - 35889 + - 35890 + - 35891 + - 35892 + - 35893 + - 35894 + - 35895 + - 35896 + - 35897 + - 35898 + - 35899 + - 35900 + - 35901 + - 35902 + - 35903 + - 35904 + - 35905 + - 35906 + - 35907 + - 35908 + - 35909 + - 35910 + - 35911 + - 35912 + - 35913 + - 35914 + - 35915 + - 35916 + - 35917 + - 35918 + - 35919 + - 35920 + - 35921 + - 35922 + - 35923 + - 35924 + - 35925 + - 35926 + - 35927 + - 35928 + - 35929 + - 35930 + - 35931 + - 35932 + - 35933 + - 35934 + - 35935 + - 35936 + - 35937 + - 35938 + - 35939 + - 35940 + - 35941 + - 35942 + - 35943 + - 35944 + - 35945 + - 35946 + - 35947 + - 35948 + - 35949 + - 35950 + - 35951 + - 35952 + - 35953 + - 35954 + - 35955 + - 35956 + - 35957 + - 35958 + - 35959 + - 35960 + - 35961 + - 35962 + - 35963 + - 35964 + - 35965 + - 35966 + - 35967 + - 35968 + - 35969 + - 35970 + - 35971 + - 35972 + - 35973 + - 35974 + - 35975 + - 35976 + - 35977 + - 35978 + - 35979 + - 35980 + - 35981 + - 35982 + - 35983 + - 35984 + - 35985 + - 35986 + - 35987 + - 35988 + - 35989 + - 35990 + - 35991 + - 35992 + - 35993 + - 35994 + - 35995 + - 35996 + - 35997 + - 35998 + - 35999 + - 36000 + - 36001 + - 36002 + - 36003 + - 36004 + - 36005 + - 36006 + - 36007 + - 36008 + - 36009 + - 36010 + - 36011 + - 36012 + - 36013 + - 36014 + - 36015 + - 36016 + - 36017 + - 36018 + - 36019 + - 36020 + - 36021 + - 36022 + - 36023 + - 36024 + - 36025 + - 36026 + - 36027 + - 36028 + - 36029 + - 36030 + - 36031 + - 36032 + - 36033 + - 36034 + - 36035 + - 36036 + - 36037 + - 36038 + - 36039 + - 36040 + - 36041 + - 36042 + - 36043 + - 36044 + - 36045 + - 36046 + - 36047 + - 36048 + - 36049 + - 36050 + - 36051 + - 36052 + - 36053 + - 36054 + - 36055 + - 36056 + - 36057 + - 36058 + - 36059 + - 36060 + - 36061 + - 36062 + - 36063 + - 36064 + - 36065 + - 36066 + - 36067 + - 36068 + - 36069 + - 36070 + - 36071 + - 36072 + - 36073 + - 36074 + - 36075 + - 36076 + - 36077 + - 36078 + - 36079 + - 36080 + - 36081 + - 36082 + - 36083 + - 36084 + - 36085 + - 36086 + - 36087 + - 36088 + - 36089 + - 36090 + - 36091 + - 36092 + - 36093 + - 36094 + - 36095 + - 36096 + - 36097 + - 36098 + - 36099 + - 36100 + - 36101 + - 36102 + - 36103 + - 36104 + - 36105 + - 36106 + - 36107 + - 36108 + - 36109 + - 36110 + - 36111 + - 36112 + - 36113 + - 36114 + - 36115 + - 36116 + - 36117 + - 36118 + - 36119 + - 36120 + - 36121 + - 36122 + - 36123 + - 36124 + - 36125 + - 36126 + - 36127 + - 36128 + - 36129 + - 36130 + - 36131 + - 36132 + - 36133 + - 36134 + - 36135 + - 36136 + - 36137 + - 36138 + - 36139 + - 36140 + - 36141 + - 36142 + - 36143 + - 36144 + - 36145 + - 36146 + - 36147 + - 36148 + - 36149 + - 36150 + - 36151 + - 36152 + - 36153 + - 36154 + - 36155 + - 36156 + - 36157 + - 36158 + - 36159 + - 36160 + - 36161 + - 36162 + - 36163 + - 36164 + - 36165 + - 36166 + - 36167 + - 36168 + - 36169 + - 36170 + - 36171 + - 36172 + - 36173 + - 36174 + - 36175 + - 36176 + - 36177 + - 36178 + - 36179 + - 36180 + - 36181 + - 36182 + - 36183 + - 36184 + - 36185 + - 36186 + - 36187 + - 36188 + - 36189 + - 36190 + - 36191 + - 36192 + - 36193 + - 36194 + - 36195 + - 36196 + - 36197 + - 36198 + - 36199 + - 36200 + - 36201 + - 36202 + - 36203 + - 36204 + - 36205 + - 36206 + - 36207 + - 36208 + - 36209 + - 36210 + - 36211 + - 36212 + - 36213 + - 36214 + - 36215 + - 36216 + - 36217 + - 36218 + - 36219 + - 36220 + - 36221 + - 36222 + - 36223 + - 36224 + - 36225 + - 36226 + - 36227 + - 36228 + - 36229 + - 36230 + - 36231 + - 36232 + - 36233 + - 36234 + - 36235 + - 36236 + - 36237 + - 36238 + - 36239 + - 36240 + - 36241 + - 36242 + - 36243 + - 36244 + - 36245 + - 36246 + - 36247 + - 36248 + - 36249 + - 36250 + - 36251 + - 36252 + - 36253 + - 36254 + - 36255 + - 36256 + - 36257 + - 36258 + - 36259 + - 36260 + - 36261 + - 36262 + - 36263 + - 36264 + - 36265 + - 36266 + - 36267 + - 36268 + - 36269 + - 36270 + - 36271 + - 36272 + - 36273 + - 36274 + - 36275 + - 36276 + - 36277 + - 36278 + - 36279 + - 36280 + - 36281 + - 36282 + - 36283 + - 36284 + - 36285 + - 36286 + - 36287 + - 36288 + - 36289 + - 36290 + - 36291 + - 36292 + - 36293 + - 36294 + - 36295 + - 36296 + - 36297 + - 36298 + - 36299 + - 36300 + - 36301 + - 36302 + - 36303 + - 36304 + - 36305 + - 36306 + - 36307 + - 36308 + - 36309 + - 36310 + - 36311 + - 36312 + - 36313 + - 36314 + - 36315 + - 36316 + - 36317 + - 36318 + - 36319 + - 36320 + - 36321 + - 36322 + - 36323 + - 36324 + - 36325 + - 36326 + - 36327 + - 36328 + - 36329 + - 36330 + - 36331 + - 36332 + - 36333 + - 36334 + - 36335 + - 36336 + - 36337 + - 36338 + - 36339 + - 36340 + - 36341 + - 36342 + - 36343 + - 36344 + - 36345 + - 36346 + - 36347 + - 36348 + - 36349 + - 36350 + - 36351 + - 36352 + - 36353 + - 36354 + - 36355 + - 36356 + - 36357 + - 36358 + - 36359 + - 36360 + - 36361 + - 36362 + - 36363 + - 36364 + - 36365 + - 36366 + - 36367 + - 36368 + - 36369 + - 36370 + - 36371 + - 36372 + - 36373 + - 36374 + - 36375 + - 36376 + - 36377 + - 36378 + - 36379 + - 36380 + - 36381 + - 36382 + - 36383 + - 36384 + - 36385 + - 36386 + - 36387 + - 36388 + - 36389 + - 36390 + - 36391 + - 36392 + - 36393 + - 36394 + - 36395 + - 36396 + - 36397 + - 36398 + - 36399 + - 36400 + - 36401 + - 36402 + - 36403 + - 36404 + - 36405 + - 36406 + - 36407 + - 36408 + - 36409 + - 36410 + - 36411 + - 36412 + - 36413 + - 36414 + - 36415 + - 36416 + - 36417 + - 36418 + - 36419 + - 36420 + - 36421 + - 36422 + - 36423 + - 36424 + - 36425 + - 36426 + - 36427 + - 36428 + - 36429 + - 36430 + - 36431 + - 36432 + - 36433 + - 36434 + - 36435 + - 36436 + - 36437 + - 36438 + - 36439 + - 36440 + - 36441 + - 36442 + - 36443 + - 36444 + - 36445 + - 36446 + - 36447 + - 36448 + - 36449 + - 36450 + - 36451 + - 36452 + - 36453 + - 36454 + - 36455 + - 36456 + - 36457 + - 36458 + - 36459 + - 36460 + - 36461 + - 36462 + - 36463 + - 36464 + - 36465 + - 36466 + - 36467 + - 36468 + - 36469 + - 36470 + - 36471 + - 36472 + - 36473 + - 36474 + - 36475 + - 36476 + - 36477 + - 36478 + - 36479 + - 36480 + - 36481 + - 36482 + - 36483 + - 36484 + - 36485 + - 36486 + - 36487 + - 36488 + - 36489 + - 36490 + - 36491 + - 36492 + - 36493 + - 36494 + - 36495 + - 36496 + - 36497 + - 36498 + - 36499 + - 36500 + - 36501 + - 36502 + - 36503 + - 36504 + - 36505 + - 36506 + - 36507 + - 36508 + - 36509 + - 36510 + - 36511 + - 36512 + - 36513 + - 36514 + - 36515 + - 36516 + - 36517 + - 36518 + - 36519 + - 36520 + - 36521 + - 36522 + - 36523 + - 36524 + - 36525 + - 36526 + - 36527 + - 36528 + - 36529 + - 36530 + - 36531 + - 36532 + - 36533 + - 36534 + - 36535 + - 36536 + - 36537 + - 36538 + - 36539 + - 36540 + - 36541 + - 36542 + - 36543 + - 36544 + - 36545 + - 36546 + - 36547 + - 36548 + - 36549 + - 36550 + - 36551 + - 36552 + - 36553 + - 36554 + - 36555 + - 36556 + - 36557 + - 36558 + - 36559 + - 36560 + - 36561 + - 36562 + - 36563 + - 36564 + - 36565 + - 36566 + - 36567 + - 36568 + - 36569 + - 36570 + - 36571 + - 36572 + - 36573 + - 36574 + - 36575 + - 36576 + - 36577 + - 36578 + - 36579 + - 36580 + - 36581 + - 36582 + - 36583 + - 36584 + - 36585 + - 36586 + - 36587 + - 36588 + - 36589 + - 36590 + - 36591 + - 36592 + - 36593 + - 36594 + - 36595 + - 36596 + - 36597 + - 36598 + - 36599 + - 36600 + - 36601 + - 36602 + - 36603 + - 36604 + - 36605 + - 36606 + - 36607 + - 36608 + - 36609 + - 36610 + - 36611 + - 36612 + - 36613 + - 36614 + - 36615 + - 36616 + - 36617 + - 36618 + - 36619 + - 36620 + - 36621 + - 36622 + - 36623 + - 36624 + - 36625 + - 36626 + - 36627 + - 36628 + - 36629 + - 36630 + - 36631 + - 36632 + - 36633 + - 36634 + - 36635 + - 36636 + - 36637 + - 36638 + - 36639 + - 36640 + - 36641 + - 36642 + - 36643 + - 36644 + - 36645 + - 36646 + - 36647 + - 36648 + - 36649 + - 36650 + - 36651 + - 36652 + - 36653 + - 36654 + - 36655 + - 36656 + - 36657 + - 36658 + - 36659 + - 36660 + - 36661 + - 36662 + - 36663 + - 36664 + - 36665 + - 36666 + - 36667 + - 36668 + - 36669 + - 36670 + - 36671 + - 36672 + - 36673 + - 36674 + - 36675 + - 36676 + - 36677 + - 36678 + - 36679 + - 36680 + - 36681 + - 36682 + - 36683 + - 36684 + - 36685 + - 36686 + - 36687 + - 36688 + - 36689 + - 36690 + - 36691 + - 36692 + - 36693 + - 36694 + - 36695 + - 36696 + - 36697 + - 36698 + - 36699 + - 36700 + - 36701 + - 36702 + - 36703 + - 36704 + - 36705 + - 36706 + - 36707 + - 36708 + - 36709 + - 36710 + - 36711 + - 36712 + - 36713 + - 36714 + - 36715 + - 36716 + - 36717 + - 36718 + - 36719 + - 36720 + - 36721 + - 36722 + - 36723 + - 36724 + - 36725 + - 36726 + - 36727 + - 36728 + - 36729 + - 36730 + - 36731 + - 36732 + - 36733 + - 36734 + - 36735 + - 36736 + - 36737 + - 36738 + - 36739 + - 36740 + - 36741 + - 36742 + - 36743 + - 36744 + - 36745 + - 36746 + - 36747 + - 36748 + - 36749 + - 36750 + - 36751 + - 36752 + - 36753 + - 36754 + - 36755 + - 36756 + - 36757 + - 36758 + - 36759 + - 36760 + - 36761 + - 36762 + - 36763 + - 36764 + - 36765 + - 36766 + - 36767 + - 36768 + - 36769 + - 36770 + - 36771 + - 36772 + - 36773 + - 36774 + - 36775 + - 36776 + - 36777 + - 36778 + - 36779 + - 36780 + - 36781 + - 36782 + - 36783 + - 36784 + - 36785 + - 36786 + - 36787 + - 36788 + - 36789 + - 36790 + - 36791 + - 36792 + - 36793 + - 36794 + - 36795 + - 36796 + - 36797 + - 36798 + - 36799 + - 36800 + - 36801 + - 36802 + - 36803 + - 36804 + - 36805 + - 36806 + - 36807 + - 36808 + - 36809 + - 36810 + - 36811 + - 36812 + - 36813 + - 36814 + - 36815 + - 36816 + - 36817 + - 36818 + - 36819 + - 36820 + - 36821 + - 36822 + - 36823 + - 36824 + - 36825 + - 36826 + - 36827 + - 36828 + - 36829 + - 36830 + - 36831 + - 36832 + - 36833 + - 36834 + - 36835 + - 36836 + - 36837 + - 36838 + - 36839 + - 36840 + - 36841 + - 36842 + - 36843 + - 36844 + - 36845 + - 36846 + - 36847 + - 36848 + - 36849 + - 36850 + - 36851 + - 36852 + - 36853 + - 36854 + - 36855 + - 36856 + - 36857 + - 36858 + - 36859 + - 36860 + - 36861 + - 36862 + - 36863 + - 36864 + - 36865 + - 36866 + - 36867 + - 36868 + - 36869 + - 36870 + - 36871 + - 36872 + - 36873 + - 36874 + - 36875 + - 36876 + - 36877 + - 36878 + - 36879 + - 36880 + - 36881 + - 36882 + - 36883 + - 36884 + - 36885 + - 36886 + - 36887 + - 36888 + - 36889 + - 36890 + - 36891 + - 36892 + - 36893 + - 36894 + - 36895 + - 36896 + - 36897 + - 36898 + - 36899 + - 36900 + - 36901 + - 36902 + - 36903 + - 36904 + - 36905 + - 36906 + - 36907 + - 36908 + - 36909 + - 36910 + - 36911 + - 36912 + - 36913 + - 36914 + - 36915 + - 36916 + - 36917 + - 36918 + - 36919 + - 36920 + - 36921 + - 36922 + - 36923 + - 36924 + - 36925 + - 36926 + - 36927 + - 36928 + - 36929 + - 36930 + - 36931 + - 36932 + - 36933 + - 36934 + - 36935 + - 36936 + - 36937 + - 36938 + - 36939 + - 36940 + - 36941 + - 36942 + - 36943 + - 36944 + - 36945 + - 36946 + - 36947 + - 36948 + - 36949 + - 36950 + - 36951 + - 36952 + - 36953 + - 36954 + - 36955 + - 36956 + - 36957 + - 36958 + - 36959 + - 36960 + - 36961 + - 36962 + - 36963 + - 36964 + - 36965 + - 36966 + - 36967 + - 36968 + - 36969 + - 36970 + - 36971 + - 36972 + - 36973 + - 36974 + - 36975 + - 36976 + - 36977 + - 36978 + - 36979 + - 36980 + - 36981 + - 36982 + - 36983 + - 36984 + - 36985 + - 36986 + - 36987 + - 36988 + - 36989 + - 36990 + - 36991 + - 36992 + - 36993 + - 36994 + - 36995 + - 36996 + - 36997 + - 36998 + - 36999 + - 37000 + - 37001 + - 37002 + - 37003 + - 37004 + - 37005 + - 37006 + - 37007 + - 37008 + - 37009 + - 37010 + - 37011 + - 37012 + - 37013 + - 37014 + - 37015 + - 37016 + - 37017 + - 37018 + - 37019 + - 37020 + - 37021 + - 37022 + - 37023 + - 37024 + - 37025 + - 37026 + - 37027 + - 37028 + - 37029 + - 37030 + - 37031 + - 37032 + - 37033 + - 37034 + - 37035 + - 37036 + - 37037 + - 37038 + - 37039 + - 37040 + - 37041 + - 37042 + - 37043 + - 37044 + - 37045 + - 37046 + - 37047 + - 37048 + - 37049 + - 37050 + - 37051 + - 37052 + - 37053 + - 37054 + - 37055 + - 37056 + - 37057 + - 37058 + - 37059 + - 37060 + - 37061 + - 37062 + - 37063 + - 37064 + - 37065 + - 37066 + - 37067 + - 37068 + - 37069 + - 37070 + - 37071 + - 37072 + - 37073 + - 37074 + - 37075 + - 37076 + - 37077 + - 37078 + - 37079 + - 37080 + - 37081 + - 37082 + - 37083 + - 37084 + - 37085 + - 37086 + - 37087 + - 37088 + - 37089 + - 37090 + - 37091 + - 37092 + - 37093 + - 37094 + - 37095 + - 37096 + - 37097 + - 37098 + - 37099 + - 37100 + - 37101 + - 37102 + - 37103 + - 37104 + - 37105 + - 37106 + - 37107 + - 37108 + - 37109 + - 37110 + - 37111 + - 37112 + - 37113 + - 37114 + - 37115 + - 37116 + - 37117 + - 37118 + - 37119 + - 37120 + - 37121 + - 37122 + - 37123 + - 37124 + - 37125 + - 37126 + - 37127 + - 37128 + - 37129 + - 37130 + - 37131 + - 37132 + - 37133 + - 37134 + - 37135 + - 37136 + - 37137 + - 37138 + - 37139 + - 37140 + - 37141 + - 37142 + - 37143 + - 37144 + - 37145 + - 37146 + - 37147 + - 37148 + - 37149 + - 37150 + - 37151 + - 37152 + - 37153 + - 37154 + - 37155 + - 37156 + - 37157 + - 37158 + - 37159 + - 37160 + - 37161 + - 37162 + - 37163 + - 37164 + - 37165 + - 37166 + - 37167 + - 37168 + - 37169 + - 37170 + - 37171 + - 37172 + - 37173 + - 37174 + - 37175 + - 37176 + - 37177 + - 37178 + - 37179 + - 37180 + - 37181 + - 37182 + - 37183 + - 37184 + - 37185 + - 37186 + - 37187 + - 37188 + - 37189 + - 37190 + - 37191 + - 37192 + - 37193 + - 37194 + - 37195 + - 37196 + - 37197 + - 37198 + - 37199 + - 37200 + - 37201 + - 37202 + - 37203 + - 37204 + - 37205 + - 37206 + - 37207 + - 37208 + - 37209 + - 37210 + - 37211 + - 37212 + - 37213 + - 37214 + - 37215 + - 37216 + - 37217 + - 37218 + - 37219 + - 37220 + - 37221 + - 37222 + - 37223 + - 37224 + - 37225 + - 37226 + - 37227 + - 37228 + - 37229 + - 37230 + - 37231 + - 37232 + - 37233 + - 37234 + - 37235 + - 37236 + - 37237 + - 37238 + - 37239 + - 37240 + - 37241 + - 37242 + - 37243 + - 37244 + - 37245 + - 37246 + - 37247 + - 37248 + - 37249 + - 37250 + - 37251 + - 37252 + - 37253 + - 37254 + - 37255 + - 37256 + - 37257 + - 37258 + - 37259 + - 37260 + - 37261 + - 37262 + - 37263 + - 37264 + - 37265 + - 37266 + - 37267 + - 37268 + - 37269 + - 37270 + - 37271 + - 37272 + - 37273 + - 37274 + - 37275 + - 37276 + - 37277 + - 37278 + - 37279 + - 37280 + - 37281 + - 37282 + - 37283 + - 37284 + - 37285 + - 37286 + - 37287 + - 37288 + - 37289 + - 37290 + - 37291 + - 37292 + - 37293 + - 37294 + - 37295 + - 37296 + - 37297 + - 37298 + - 37299 + - 37300 + - 37301 + - 37302 + - 37303 + - 37304 + - 37305 + - 37306 + - 37307 + - 37308 + - 37309 + - 37310 + - 37311 + - 37312 + - 37313 + - 37314 + - 37315 + - 37316 + - 37317 + - 37318 + - 37319 + - 37320 + - 37321 + - 37322 + - 37323 + - 37324 + - 37325 + - 37326 + - 37327 + - 37328 + - 37329 + - 37330 + - 37331 + - 37332 + - 37333 + - 37334 + - 37335 + - 37336 + - 37337 + - 37338 + - 37339 + - 37340 + - 37341 + - 37342 + - 37343 + - 37344 + - 37345 + - 37346 + - 37347 + - 37348 + - 37349 + - 37350 + - 37351 + - 37352 + - 37353 + - 37354 + - 37355 + - 37356 + - 37357 + - 37358 + - 37359 + - 37360 + - 37361 + - 37362 + - 37363 + - 37364 + - 37365 + - 37366 + - 37367 + - 37368 + - 37369 + - 37370 + - 37371 + - 37372 + - 37373 + - 37374 + - 37375 + - 37376 + - 37377 + - 37378 + - 37379 + - 37380 + - 37381 + - 37382 + - 37383 + - 37384 + - 37385 + - 37386 + - 37387 + - 37388 + - 37389 + - 37390 + - 37391 + - 37392 + - 37393 + - 37394 + - 37395 + - 37396 + - 37397 + - 37398 + - 37399 + - 37400 + - 37401 + - 37402 + - 37403 + - 37404 + - 37405 + - 37406 + - 37407 + - 37408 + - 37409 + - 37410 + - 37411 + - 37412 + - 37413 + - 37414 + - 37415 + - 37416 + - 37417 + - 37418 + - 37419 + - 37420 + - 37421 + - 37422 + - 37423 + - 37424 + - 37425 + - 37426 + - 37427 + - 37428 + - 37429 + - 37430 + - 37431 + - 37432 + - 37433 + - 37434 + - 37435 + - 37436 + - 37437 + - 37438 + - 37439 + - 37440 + - 37441 + - 37442 + - 37443 + - 37444 + - 37445 + - 37446 + - 37447 + - 37448 + - 37449 + - 37450 + - 37451 + - 37452 + - 37453 + - 37454 + - 37455 + - 37456 + - 37457 + - 37458 + - 37459 + - 37460 + - 37461 + - 37462 + - 37463 + - 37464 + - 37465 + - 37466 + - 37467 + - 37468 + - 37469 + - 37470 + - 37471 + - 37472 + - 37473 + - 37474 + - 37475 + - 37476 + - 37477 + - 37478 + - 37479 + - 37480 + - 37481 + - 37482 + - 37483 + - 37484 + - 37485 + - 37486 + - 37487 + - 37488 + - 37489 + - 37490 + - 37491 + - 37492 + - 37493 + - 37494 + - 37495 + - 37496 + - 37497 + - 37498 + - 37499 + - 37500 + - 37501 + - 37502 + - 37503 + - 37504 + - 37505 + - 37506 + - 37507 + - 37508 + - 37509 + - 37510 + - 37511 + - 37512 + - 37513 + - 37514 + - 37515 + - 37516 + - 37517 + - 37518 + - 37519 + - 37520 + - 37521 + - 37522 + - 37523 + - 37524 + - 37525 + - 37526 + - 37527 + - 37528 + - 37529 + - 37530 + - 37531 + - 37532 + - 37533 + - 37534 + - 37535 + - 37536 + - 37537 + - 37538 + - 37539 + - 37540 + - 37541 + - 37542 + - 37543 + - 37544 + - 37545 + - 37546 + - 37547 + - 37548 + - 37549 + - 37550 + - 37551 + - 37552 + - 37553 + - 37554 + - 37555 + - 37556 + - 37557 + - 37558 + - 37559 + - 37560 + - 37561 + - 37562 + - 37563 + - 37564 + - 37565 + - 37566 + - 37567 + - 37568 + - 37569 + - 37570 + - 37571 + - 37572 + - 37573 + - 37574 + - 37575 + - 37576 + - 37577 + - 37578 + - 37579 + - 37580 + - 37581 + - 37582 + - 37583 + - 37584 + - 37585 + - 37586 + - 37587 + - 37588 + - 37589 + - 37590 + - 37591 + - 37592 + - 37593 + - 37594 + - 37595 + - 37596 + - 37597 + - 37598 + - 37599 + - 37600 + - 37601 + - 37602 + - 37603 + - 37604 + - 37605 + - 37606 + - 37607 + - 37608 + - 37609 + - 37610 + - 37611 + - 37612 + - 37613 + - 37614 + - 37615 + - 37616 + - 37617 + - 37618 + - 37619 + - 37620 + - 37621 + - 37622 + - 37623 + - 37624 + - 37625 + - 37626 + - 37627 + - 37628 + - 37629 + - 37630 + - 37631 + - 37632 + - 37633 + - 37634 + - 37635 + - 37636 + - 37637 + - 37638 + - 37639 + - 37640 + - 37641 + - 37642 + - 37643 + - 37644 + - 37645 + - 37646 + - 37647 + - 37648 + - 37649 + - 37650 + - 37651 + - 37652 + - 37653 + - 37654 + - 37655 + - 37656 + - 37657 + - 37658 + - 37659 + - 37660 + - 37661 + - 37662 + - 37663 + - 37664 + - 37665 + - 37666 + - 37667 + - 37668 + - 37669 + - 37670 + - 37671 + - 37672 + - 37673 + - 37674 + - 37675 + - 37676 + - 37677 + - 37678 + - 37679 + - 37680 + - 37681 + - 37682 + - 37683 + - 37684 + - 37685 + - 37686 + - 37687 + - 37688 + - 37689 + - 37690 + - 37691 + - 37692 + - 37693 + - 37694 + - 37695 + - 37696 + - 37697 + - 37698 + - 37699 + - 37700 + - 37701 + - 37702 + - 37703 + - 37704 + - 37705 + - 37706 + - 37707 + - 37708 + - 37709 + - 37710 + - 37711 + - 37712 + - 37713 + - 37714 + - 37715 + - 37716 + - 37717 + - 37718 + - 37719 + - 37720 + - 37721 + - 37722 + - 37723 + - 37724 + - 37725 + - 37726 + - 37727 + - 37728 + - 37729 + - 37730 + - 37731 + - 37732 + - 37733 + - 37734 + - 37735 + - 37736 + - 37737 + - 37738 + - 37739 + - 37740 + - 37741 + - 37742 + - 37743 + - 37744 + - 37745 + - 37746 + - 37747 + - 37748 + - 37749 + - 37750 + - 37751 + - 37752 + - 37753 + - 37754 + - 37755 + - 37756 + - 37757 + - 37758 + - 37759 + - 37760 + - 37761 + - 37762 + - 37763 + - 37764 + - 37765 + - 37766 + - 37767 + - 37768 + - 37769 + - 37770 + - 37771 + - 37772 + - 37773 + - 37774 + - 37775 + - 37776 + - 37777 + - 37778 + - 37779 + - 37780 + - 37781 + - 37782 + - 37783 + - 37784 + - 37785 + - 37786 + - 37787 + - 37788 + - 37789 + - 37790 + - 37791 + - 37792 + - 37793 + - 37794 + - 37795 + - 37796 + - 37797 + - 37798 + - 37799 + - 37800 + - 37801 + - 37802 + - 37803 + - 37804 + - 37805 + - 37806 + - 37807 + - 37808 + - 37809 + - 37810 + - 37811 + - 37812 + - 37813 + - 37814 + - 37815 + - 37816 + - 37817 + - 37818 + - 37819 + - 37820 + - 37821 + - 37822 + - 37823 + - 37824 + - 37825 + - 37826 + - 37827 + - 37828 + - 37829 + - 37830 + - 37831 + - 37832 + - 37833 + - 37834 + - 37835 + - 37836 + - 37837 + - 37838 + - 37839 + - 37840 + - 37841 + - 37842 + - 37843 + - 37844 + - 37845 + - 37846 + - 37847 + - 37848 + - 37849 + - 37850 + - 37851 + - 37852 + - 37853 + - 37854 + - 37855 + - 37856 + - 37857 + - 37858 + - 37859 + - 37860 + - 37861 + - 37862 + - 37863 + - 37864 + - 37865 + - 37866 + - 37867 + - 37868 + - 37869 + - 37870 + - 37871 + - 37872 + - 37873 + - 37874 + - 37875 + - 37876 + - 37877 + - 37878 + - 37879 + - 37880 + - 37881 + - 37882 + - 37883 + - 37884 + - 37885 + - 37886 + - 37887 + - 37888 + - 37889 + - 37890 + - 37891 + - 37892 + - 37893 + - 37894 + - 37895 + - 37896 + - 37897 + - 37898 + - 37899 + - 37900 + - 37901 + - 37902 + - 37903 + - 37904 + - 37905 + - 37906 + - 37907 + - 37908 + - 37909 + - 37910 + - 37911 + - 37912 + - 37913 + - 37914 + - 37915 + - 37916 + - 37917 + - 37918 + - 37919 + - 37920 + - 37921 + - 37922 + - 37923 + - 37924 + - 37925 + - 37926 + - 37927 + - 37928 + - 37929 + - 37930 + - 37931 + - 37932 + - 37933 + - 37934 + - 37935 + - 37936 + - 37937 + - 37938 + - 37939 + - 37940 + - 37941 + - 37942 + - 37943 + - 37944 + - 37945 + - 37946 + - 37947 + - 37948 + - 37949 + - 37950 + - 37951 + - 37952 + - 37953 + - 37954 + - 37955 + - 37956 + - 37957 + - 37958 + - 37959 + - 37960 + - 37961 + - 37962 + - 37963 + - 37964 + - 37965 + - 37966 + - 37967 + - 37968 + - 37969 + - 37970 + - 37971 + - 37972 + - 37973 + - 37974 + - 37975 + - 37976 + - 37977 + - 37978 + - 37979 + - 37980 + - 37981 + - 37982 + - 37983 + - 37984 + - 37985 + - 37986 + - 37987 + - 37988 + - 37989 + - 37990 + - 37991 + - 37992 + - 37993 + - 37994 + - 37995 + - 37996 + - 37997 + - 37998 + - 37999 + - 38000 + - 38001 + - 38002 + - 38003 + - 38004 + - 38005 + - 38006 + - 38007 + - 38008 + - 38009 + - 38010 + - 38011 + - 38012 + - 38013 + - 38014 + - 38015 + - 38016 + - 38017 + - 38018 + - 38019 + - 38020 + - 38021 + - 38022 + - 38023 + - 38024 + - 38025 + - 38026 + - 38027 + - 38028 + - 38029 + - 38030 + - 38031 + - 38032 + - 38033 + - 38034 + - 38035 + - 38036 + - 38037 + - 38038 + - 38039 + - 38040 + - 38041 + - 38042 + - 38043 + - 38044 + - 38045 + - 38046 + - 38047 + - 38048 + - 38049 + - 38050 + - 38051 + - 38052 + - 38053 + - 38054 + - 38055 + - 38056 + - 38057 + - 38058 + - 38059 + - 38060 + - 38061 + - 38062 + - 38063 + - 38064 + - 38065 + - 38066 + - 38067 + - 38068 + - 38069 + - 38070 + - 38071 + - 38072 + - 38073 + - 38074 + - 38075 + - 38076 + - 38077 + - 38078 + - 38079 + - 38080 + - 38081 + - 38082 + - 38083 + - 38084 + - 38085 + - 38086 + - 38087 + - 38088 + - 38089 + - 38090 + - 38091 + - 38092 + - 38093 + - 38094 + - 38095 + - 38096 + - 38097 + - 38098 + - 38099 + - 38100 + - 38101 + - 38102 + - 38103 + - 38104 + - 38105 + - 38106 + - 38107 + - 38108 + - 38109 + - 38110 + - 38111 + - 38112 + - 38113 + - 38114 + - 38115 + - 38116 + - 38117 + - 38118 + - 38119 + - 38120 + - 38121 + - 38122 + - 38123 + - 38124 + - 38125 + - 38126 + - 38127 + - 38128 + - 38129 + - 38130 + - 38131 + - 38132 + - 38133 + - 38134 + - 38135 + - 38136 + - 38137 + - 38138 + - 38139 + - 38140 + - 38141 + - 38142 + - 38143 + - 38144 + - 38145 + - 38146 + - 38147 + - 38148 + - 38149 + - 38150 + - 38151 + - 38152 + - 38153 + - 38154 + - 38155 + - 38156 + - 38157 + - 38158 + - 38159 + - 38160 + - 38161 + - 38162 + - 38163 + - 38164 + - 38165 + - 38166 + - 38167 + - 38168 + - 38169 + - 38170 + - 38171 + - 38172 + - 38173 + - 38174 + - 38175 + - 38176 + - 38177 + - 38178 + - 38179 + - 38180 + - 38181 + - 38182 + - 38183 + - 38184 + - 38185 + - 38186 + - 38187 + - 38188 + - 38189 + - 38190 + - 38191 + - 38192 + - 38193 + - 38194 + - 38195 + - 38196 + - 38197 + - 38198 + - 38199 + - 38200 + - 38201 + - 38202 + - 38203 + - 38204 + - 38205 + - 38206 + - 38207 + - 38208 + - 38209 + - 38210 + - 38211 + - 38212 + - 38213 + - 38214 + - 38215 + - 38216 + - 38217 + - 38218 + - 38219 + - 38220 + - 38221 + - 38222 + - 38223 + - 38224 + - 38225 + - 38226 + - 38227 + - 38228 + - 38229 + - 38230 + - 38231 + - 38232 + - 38233 + - 38234 + - 38235 + - 38236 + - 38237 + - 38238 + - 38239 + - 38240 + - 38241 + - 38242 + - 38243 + - 38244 + - 38245 + - 38246 + - 38247 + - 38248 + - 38249 + - 38250 + - 38251 + - 38252 + - 38253 + - 38254 + - 38255 + - 38256 + - 38257 + - 38258 + - 38259 + - 38260 + - 38261 + - 38262 + - 38263 + - 38264 + - 38265 + - 38266 + - 38267 + - 38268 + - 38269 + - 38270 + - 38271 + - 38272 + - 38273 + - 38274 + - 38275 + - 38276 + - 38277 + - 38278 + - 38279 + - 38280 + - 38281 + - 38282 + - 38283 + - 38284 + - 38285 + - 38286 + - 38287 + - 38288 + - 38289 + - 38290 + - 38291 + - 38292 + - 38293 + - 38294 + - 38295 + - 38296 + - 38297 + - 38298 + - 38299 + - 38300 + - 38301 + - 38302 + - 38303 + - 38304 + - 38305 + - 38306 + - 38307 + - 38308 + - 38309 + - 38310 + - 38311 + - 38312 + - 38313 + - 38314 + - 38315 + - 38316 + - 38317 + - 38318 + - 38319 + - 38320 + - 38321 + - 38322 + - 38323 + - 38324 + - 38325 + - 38326 + - 38327 + - 38328 + - 38329 + - 38330 + - 38331 + - 38332 + - 38333 + - 38334 + - 38335 + - 38336 + - 38337 + - 38338 + - 38339 + - 38340 + - 38341 + - 38342 + - 38343 + - 38344 + - 38345 + - 38346 + - 38347 + - 38348 + - 38349 + - 38350 + - 38351 + - 38352 + - 38353 + - 38354 + - 38355 + - 38356 + - 38357 + - 38358 + - 38359 + - 38360 + - 38361 + - 38362 + - 38363 + - 38364 + - 38365 + - 38366 + - 38367 + - 38368 + - 38369 + - 38370 + - 38371 + - 38372 + - 38373 + - 38374 + - 38375 + - 38376 + - 38377 + - 38378 + - 38379 + - 38380 + - 38381 + - 38382 + - 38383 + - 38384 + - 38385 + - 38386 + - 38387 + - 38388 + - 38389 + - 38390 + - 38391 + - 38392 + - 38393 + - 38394 + - 38395 + - 38396 + - 38397 + - 38398 + - 38399 + - 38400 + - 38401 + - 38402 + - 38403 + - 38404 + - 38405 + - 38406 + - 38407 + - 38408 + - 38409 + - 38410 + - 38411 + - 38412 + - 38413 + - 38414 + - 38415 + - 38416 + - 38417 + - 38418 + - 38419 + - 38420 + - 38421 + - 38422 + - 38423 + - 38424 + - 38425 + - 38426 + - 38427 + - 38428 + - 38429 + - 38430 + - 38431 + - 38432 + - 38433 + - 38434 + - 38435 + - 38436 + - 38437 + - 38438 + - 38439 + - 38440 + - 38441 + - 38442 + - 38443 + - 38444 + - 38445 + - 38446 + - 38447 + - 38448 + - 38449 + - 38450 + - 38451 + - 38452 + - 38453 + - 38454 + - 38455 + - 38456 + - 38457 + - 38458 + - 38459 + - 38460 + - 38461 + - 38462 + - 38463 + - 38464 + - 38465 + - 38466 + - 38467 + - 38468 + - 38469 + - 38470 + - 38471 + - 38472 + - 38473 + - 38474 + - 38475 + - 38476 + - 38477 + - 38478 + - 38479 + - 38480 + - 38481 + - 38482 + - 38483 + - 38484 + - 38485 + - 38486 + - 38487 + - 38488 + - 38489 + - 38490 + - 38491 + - 38492 + - 38493 + - 38494 + - 38495 + - 38496 + - 38497 + - 38498 + - 38499 + - 38500 + - 38501 + - 38502 + - 38503 + - 38504 + - 38505 + - 38506 + - 38507 + - 38508 + - 38509 + - 38510 + - 38511 + - 38512 + - 38513 + - 38514 + - 38515 + - 38516 + - 38517 + - 38518 + - 38519 + - 38520 + - 38521 + - 38522 + - 38523 + - 38524 + - 38525 + - 38526 + - 38527 + - 38528 + - 38529 + - 38530 + - 38531 + - 38532 + - 38533 + - 38534 + - 38535 + - 38536 + - 38537 + - 38538 + - 38539 + - 38540 + - 38541 + - 38542 + - 38543 + - 38544 + - 38545 + - 38546 + - 38547 + - 38548 + - 38549 + - 38550 + - 38551 + - 38552 + - 38553 + - 38554 + - 38555 + - 38556 + - 38557 + - 38558 + - 38559 + - 38560 + - 38561 + - 38562 + - 38563 + - 38564 + - 38565 + - 38566 + - 38567 + - 38568 + - 38569 + - 38570 + - 38571 + - 38572 + - 38573 + - 38574 + - 38575 + - 38576 + - 38577 + - 38578 + - 38579 + - 38580 + - 38581 + - 38582 + - 38583 + - 38584 + - 38585 + - 38586 + - 38587 + - 38588 + - 38589 + - 38590 + - 38591 + - 38592 + - 38593 + - 38594 + - 38595 + - 38596 + - 38597 + - 38598 + - 38599 + - 38600 + - 38601 + - 38602 + - 38603 + - 38604 + - 38605 + - 38606 + - 38607 + - 38608 + - 38609 + - 38610 + - 38611 + - 38612 + - 38613 + - 38614 + - 38615 + - 38616 + - 38617 + - 38618 + - 38619 + - 38620 + - 38621 + - 38622 + - 38623 + - 38624 + - 38625 + - 38626 + - 38627 + - 38628 + - 38629 + - 38630 + - 38631 + - 38632 + - 38633 + - 38634 + - 38635 + - 38636 + - 38637 + - 38638 + - 38639 + - 38640 + - 38641 + - 38642 + - 38643 + - 38644 + - 38645 + - 38646 + - 38647 + - 38648 + - 38649 + - 38650 + - 38651 + - 38652 + - 38653 + - 38654 + - 38655 + - 38656 + - 38657 + - 38658 + - 38659 + - 38660 + - 38661 + - 38662 + - 38663 + - 38664 + - 38665 + - 38666 + - 38667 + - 38668 + - 38669 + - 38670 + - 38671 + - 38672 + - 38673 + - 38674 + - 38675 + - 38676 + - 38677 + - 38678 + - 38679 + - 38680 + - 38681 + - 38682 + - 38683 + - 38684 + - 38685 + - 38686 + - 38687 + - 38688 + - 38689 + - 38690 + - 38691 + - 38692 + - 38693 + - 38694 + - 38695 + - 38696 + - 38697 + - 38698 + - 38699 + - 38700 + - 38701 + - 38702 + - 38703 + - 38704 + - 38705 + - 38706 + - 38707 + - 38708 + - 38709 + - 38710 + - 38711 + - 38712 + - 38713 + - 38714 + - 38715 + - 38716 + - 38717 + - 38718 + - 38719 + - 38720 + - 38721 + - 38722 + - 38723 + - 38724 + - 38725 + - 38726 + - 38727 + - 38728 + - 38729 + - 38730 + - 38731 + - 38732 + - 38733 + - 38734 + - 38735 + - 38736 + - 38737 + - 38738 + - 38739 + - 38740 + - 38741 + - 38742 + - 38743 + - 38744 + - 38745 + - 38746 + - 38747 + - 38748 + - 38749 + - 38750 + - 38751 + - 38752 + - 38753 + - 38754 + - 38755 + - 38756 + - 38757 + - 38758 + - 38759 + - 38760 + - 38761 + - 38762 + - 38763 + - 38764 + - 38765 + - 38766 + - 38767 + - 38768 + - 38769 + - 38770 + - 38771 + - 38772 + - 38773 + - 38774 + - 38775 + - 38776 + - 38777 + - 38778 + - 38779 + - 38780 + - 38781 + - 38782 + - 38783 + - 38784 + - 38785 + - 38786 + - 38787 + - 38788 + - 38789 + - 38790 + - 38791 + - 38792 + - 38793 + - 38794 + - 38795 + - 38796 + - 38797 + - 38798 + - 38799 + - 38800 + - 38801 + - 38802 + - 38803 + - 38804 + - 38805 + - 38806 + - 38807 + - 38808 + - 38809 + - 38810 + - 38811 + - 38812 + - 38813 + - 38814 + - 38815 + - 38816 + - 38817 + - 38818 + - 38819 + - 38820 + - 38821 + - 38822 + - 38823 + - 38824 + - 38825 + - 38826 + - 38827 + - 38828 + - 38829 + - 38830 + - 38831 + - 38832 + - 38833 + - 38834 + - 38835 + - 38836 + - 38837 + - 38838 + - 38839 + - 38840 + - 38841 + - 38842 + - 38843 + - 38844 + - 38845 + - 38846 + - 38847 + - 38848 + - 38849 + - 38850 + - 38851 + - 38852 + - 38853 + - 38854 + - 38855 + - 38856 + - 38857 + - 38858 + - 38859 + - 38860 + - 38861 + - 38862 + - 38863 + - 38864 + - 38865 + - 38866 + - 38867 + - 38868 + - 38869 + - 38870 + - 38871 + - 38872 + - 38873 + - 38874 + - 38875 + - 38876 + - 38877 + - 38878 + - 38879 + - 38880 + - 38881 + - 38882 + - 38883 + - 38884 + - 38885 + - 38886 + - 38887 + - 38888 + - 38889 + - 38890 + - 38891 + - 38892 + - 38893 + - 38894 + - 38895 + - 38896 + - 38897 + - 38898 + - 38899 + - 38900 + - 38901 + - 38902 + - 38903 + - 38904 + - 38905 + - 38906 + - 38907 + - 38908 + - 38909 + - 38910 + - 38911 + - 38912 + - 38913 + - 38914 + - 38915 + - 38916 + - 38917 + - 38918 + - 38919 + - 38920 + - 38921 + - 38922 + - 38923 + - 38924 + - 38925 + - 38926 + - 38927 + - 38928 + - 38929 + - 38930 + - 38931 + - 38932 + - 38933 + - 38934 + - 38935 + - 38936 + - 38937 + - 38938 + - 38939 + - 38940 + - 38941 + - 38942 + - 38943 + - 38944 + - 38945 + - 38946 + - 38947 + - 38948 + - 38949 + - 38950 + - 38951 + - 38952 + - 38953 + - 38954 + - 38955 + - 38956 + - 38957 + - 38958 + - 38959 + - 38960 + - 38961 + - 38962 + - 38963 + - 38964 + - 38965 + - 38966 + - 38967 + - 38968 + - 38969 + - 38970 + - 38971 + - 38972 + - 38973 + - 38974 + - 38975 + - 38976 + - 38977 + - 38978 + - 38979 + - 38980 + - 38981 + - 38982 + - 38983 + - 38984 + - 38985 + - 38986 + - 38987 + - 38988 + - 38989 + - 38990 + - 38991 + - 38992 + - 38993 + - 38994 + - 38995 + - 38996 + - 38997 + - 38998 + - 38999 + - 39000 + - 39001 + - 39002 + - 39003 + - 39004 + - 39005 + - 39006 + - 39007 + - 39008 + - 39009 + - 39010 + - 39011 + - 39012 + - 39013 + - 39014 + - 39015 + - 39016 + - 39017 + - 39018 + - 39019 + - 39020 + - 39021 + - 39022 + - 39023 + - 39024 + - 39025 + - 39026 + - 39027 + - 39028 + - 39029 + - 39030 + - 39031 + - 39032 + - 39033 + - 39034 + - 39035 + - 39036 + - 39037 + - 39038 + - 39039 + - 39040 + - 39041 + - 39042 + - 39043 + - 39044 + - 39045 + - 39046 + - 39047 + - 39048 + - 39049 + - 39050 + - 39051 + - 39052 + - 39053 + - 39054 + - 39055 + - 39056 + - 39057 + - 39058 + - 39059 + - 39060 + - 39061 + - 39062 + - 39063 + - 39064 + - 39065 + - 39066 + - 39067 + - 39068 + - 39069 + - 39070 + - 39071 + - 39072 + - 39073 + - 39074 + - 39075 + - 39076 + - 39077 + - 39078 + - 39079 + - 39080 + - 39081 + - 39082 + - 39083 + - 39084 + - 39085 + - 39086 + - 39087 + - 39088 + - 39089 + - 39090 + - 39091 + - 39092 + - 39093 + - 39094 + - 39095 + - 39096 + - 39097 + - 39098 + - 39099 + - 39100 + - 39101 + - 39102 + - 39103 + - 39104 + - 39105 + - 39106 + - 39107 + - 39108 + - 39109 + - 39110 + - 39111 + - 39112 + - 39113 + - 39114 + - 39115 + - 39116 + - 39117 + - 39118 + - 39119 + - 39120 + - 39121 + - 39122 + - 39123 + - 39124 + - 39125 + - 39126 + - 39127 + - 39128 + - 39129 + - 39130 + - 39131 + - 39132 + - 39133 + - 39134 + - 39135 + - 39136 + - 39137 + - 39138 + - 39139 + - 39140 + - 39141 + - 39142 + - 39143 + - 39144 + - 39145 + - 39146 + - 39147 + - 39148 + - 39149 + - 39150 + - 39151 + - 39152 + - 39153 + - 39154 + - 39155 + - 39156 + - 39157 + - 39158 + - 39159 + - 39160 + - 39161 + - 39162 + - 39163 + - 39164 + - 39165 + - 39166 + - 39167 + - 39168 + - 39169 + - 39170 + - 39171 + - 39172 + - 39173 + - 39174 + - 39175 + - 39176 + - 39177 + - 39178 + - 39179 + - 39180 + - 39181 + - 39182 + - 39183 + - 39184 + - 39185 + - 39186 + - 39187 + - 39188 + - 39189 + - 39190 + - 39191 + - 39192 + - 39193 + - 39194 + - 39195 + - 39196 + - 39197 + - 39198 + - 39199 + - 39200 + - 39201 + - 39202 + - 39203 + - 39204 + - 39205 + - 39206 + - 39207 + - 39208 + - 39209 + - 39210 + - 39211 + - 39212 + - 39213 + - 39214 + - 39215 + - 39216 + - 39217 + - 39218 + - 39219 + - 39220 + - 39221 + - 39222 + - 39223 + - 39224 + - 39225 + - 39226 + - 39227 + - 39228 + - 39229 + - 39230 + - 39231 + - 39232 + - 39233 + - 39234 + - 39235 + - 39236 + - 39237 + - 39238 + - 39239 + - 39240 + - 39241 + - 39242 + - 39243 + - 39244 + - 39245 + - 39246 + - 39247 + - 39248 + - 39249 + - 39250 + - 39251 + - 39252 + - 39253 + - 39254 + - 39255 + - 39256 + - 39257 + - 39258 + - 39259 + - 39260 + - 39261 + - 39262 + - 39263 + - 39264 + - 39265 + - 39266 + - 39267 + - 39268 + - 39269 + - 39270 + - 39271 + - 39272 + - 39273 + - 39274 + - 39275 + - 39276 + - 39277 + - 39278 + - 39279 + - 39280 + - 39281 + - 39282 + - 39283 + - 39284 + - 39285 + - 39286 + - 39287 + - 39288 + - 39289 + - 39290 + - 39291 + - 39292 + - 39293 + - 39294 + - 39295 + - 39296 + - 39297 + - 39298 + - 39299 + - 39300 + - 39301 + - 39302 + - 39303 + - 39304 + - 39305 + - 39306 + - 39307 + - 39308 + - 39309 + - 39310 + - 39311 + - 39312 + - 39313 + - 39314 + - 39315 + - 39316 + - 39317 + - 39318 + - 39319 + - 39320 + - 39321 + - 39322 + - 39323 + - 39324 + - 39325 + - 39326 + - 39327 + - 39328 + - 39329 + - 39330 + - 39331 + - 39332 + - 39333 + - 39334 + - 39335 + - 39336 + - 39337 + - 39338 + - 39339 + - 39340 + - 39341 + - 39342 + - 39343 + - 39344 + - 39345 + - 39346 + - 39347 + - 39348 + - 39349 + - 39350 + - 39351 + - 39352 + - 39353 + - 39354 + - 39355 + - 39356 + - 39357 + - 39358 + - 39359 + - 39360 + - 39361 + - 39362 + - 39363 + - 39364 + - 39365 + - 39366 + - 39367 + - 39368 + - 39369 + - 39370 + - 39371 + - 39372 + - 39373 + - 39374 + - 39375 + - 39376 + - 39377 + - 39378 + - 39379 + - 39380 + - 39381 + - 39382 + - 39383 + - 39384 + - 39385 + - 39386 + - 39387 + - 39388 + - 39389 + - 39390 + - 39391 + - 39392 + - 39393 + - 39394 + - 39395 + - 39396 + - 39397 + - 39398 + - 39399 + - 39400 + - 39401 + - 39402 + - 39403 + - 39404 + - 39405 + - 39406 + - 39407 + - 39408 + - 39409 + - 39410 + - 39411 + - 39412 + - 39413 + - 39414 + - 39415 + - 39416 + - 39417 + - 39418 + - 39419 + - 39420 + - 39421 + - 39422 + - 39423 + - 39424 + - 39425 + - 39426 + - 39427 + - 39428 + - 39429 + - 39430 + - 39431 + - 39432 + - 39433 + - 39434 + - 39435 + - 39436 + - 39437 + - 39438 + - 39439 + - 39440 + - 39441 + - 39442 + - 39443 + - 39444 + - 39445 + - 39446 + - 39447 + - 39448 + - 39449 + - 39450 + - 39451 + - 39452 + - 39453 + - 39454 + - 39455 + - 39456 + - 39457 + - 39458 + - 39459 + - 39460 + - 39461 + - 39462 + - 39463 + - 39464 + - 39465 + - 39466 + - 39467 + - 39468 + - 39469 + - 39470 + - 39471 + - 39472 + - 39473 + - 39474 + - 39475 + - 39476 + - 39477 + - 39478 + - 39479 + - 39480 + - 39481 + - 39482 + - 39483 + - 39484 + - 39485 + - 39486 + - 39487 + - 39488 + - 39489 + - 39490 + - 39491 + - 39492 + - 39493 + - 39494 + - 39495 + - 39496 + - 39497 + - 39498 + - 39499 + - 39500 + - 39501 + - 39502 + - 39503 + - 39504 + - 39505 + - 39506 + - 39507 + - 39508 + - 39509 + - 39510 + - 39511 + - 39512 + - 39513 + - 39514 + - 39515 + - 39516 + - 39517 + - 39518 + - 39519 + - 39520 + - 39521 + - 39522 + - 39523 + - 39524 + - 39525 + - 39526 + - 39527 + - 39528 + - 39529 + - 39530 + - 39531 + - 39532 + - 39533 + - 39534 + - 39535 + - 39536 + - 39537 + - 39538 + - 39539 + - 39540 + - 39541 + - 39542 + - 39543 + - 39544 + - 39545 + - 39546 + - 39547 + - 39548 + - 39549 + - 39550 + - 39551 + - 39552 + - 39553 + - 39554 + - 39555 + - 39556 + - 39557 + - 39558 + - 39559 + - 39560 + - 39561 + - 39562 + - 39563 + - 39564 + - 39565 + - 39566 + - 39567 + - 39568 + - 39569 + - 39570 + - 39571 + - 39572 + - 39573 + - 39574 + - 39575 + - 39576 + - 39577 + - 39578 + - 39579 + - 39580 + - 39581 + - 39582 + - 39583 + - 39584 + - 39585 + - 39586 + - 39587 + - 39588 + - 39589 + - 39590 + - 39591 + - 39592 + - 39593 + - 39594 + - 39595 + - 39596 + - 39597 + - 39598 + - 39599 + - 39600 + - 39601 + - 39602 + - 39603 + - 39604 + - 39605 + - 39606 + - 39607 + - 39608 + - 39609 + - 39610 + - 39611 + - 39612 + - 39613 + - 39614 + - 39615 + - 39616 + - 39617 + - 39618 + - 39619 + - 39620 + - 39621 + - 39622 + - 39623 + - 39624 + - 39625 + - 39626 + - 39627 + - 39628 + - 39629 + - 39630 + - 39631 + - 39632 + - 39633 + - 39634 + - 39635 + - 39636 + - 39637 + - 39638 + - 39639 + - 39640 + - 39641 + - 39642 + - 39643 + - 39644 + - 39645 + - 39646 + - 39647 + - 39648 + - 39649 + - 39650 + - 39651 + - 39652 + - 39653 + - 39654 + - 39655 + - 39656 + - 39657 + - 39658 + - 39659 + - 39660 + - 39661 + - 39662 + - 39663 + - 39664 + - 39665 + - 39666 + - 39667 + - 39668 + - 39669 + - 39670 + - 39671 + - 39672 + - 39673 + - 39674 + - 39675 + - 39676 + - 39677 + - 39678 + - 39679 + - 39680 + - 39681 + - 39682 + - 39683 + - 39684 + - 39685 + - 39686 + - 39687 + - 39688 + - 39689 + - 39690 + - 39691 + - 39692 + - 39693 + - 39694 + - 39695 + - 39696 + - 39697 + - 39698 + - 39699 + - 39700 + - 39701 + - 39702 + - 39703 + - 39704 + - 39705 + - 39706 + - 39707 + - 39708 + - 39709 + - 39710 + - 39711 + - 39712 + - 39713 + - 39714 + - 39715 + - 39716 + - 39717 + - 39718 + - 39719 + - 39720 + - 39721 + - 39722 + - 39723 + - 39724 + - 39725 + - 39726 + - 39727 + - 39728 + - 39729 + - 39730 + - 39731 + - 39732 + - 39733 + - 39734 + - 39735 + - 39736 + - 39737 + - 39738 + - 39739 + - 39740 + - 39741 + - 39742 + - 39743 + - 39744 + - 39745 + - 39746 + - 39747 + - 39748 + - 39749 + - 39750 + - 39751 + - 39752 + - 39753 + - 39754 + - 39755 + - 39756 + - 39757 + - 39758 + - 39759 + - 39760 + - 39761 + - 39762 + - 39763 + - 39764 + - 39765 + - 39766 + - 39767 + - 39768 + - 39769 + - 39770 + - 39771 + - 39772 + - 39773 + - 39774 + - 39775 + - 39776 + - 39777 + - 39778 + - 39779 + - 39780 + - 39781 + - 39782 + - 39783 + - 39784 + - 39785 + - 39786 + - 39787 + - 39788 + - 39789 + - 39790 + - 39791 + - 39792 + - 39793 + - 39794 + - 39795 + - 39796 + - 39797 + - 39798 + - 39799 + - 39800 + - 39801 + - 39802 + - 39803 + - 39804 + - 39805 + - 39806 + - 39807 + - 39808 + - 39809 + - 39810 + - 39811 + - 39812 + - 39813 + - 39814 + - 39815 + - 39816 + - 39817 + - 39818 + - 39819 + - 39820 + - 39821 + - 39822 + - 39823 + - 39824 + - 39825 + - 39826 + - 39827 + - 39828 + - 39829 + - 39830 + - 39831 + - 39832 + - 39833 + - 39834 + - 39835 + - 39836 + - 39837 + - 39838 + - 39839 + - 39840 + - 39841 + - 39842 + - 39843 + - 39844 + - 39845 + - 39846 + - 39847 + - 39848 + - 39849 + - 39850 + - 39851 + - 39852 + - 39853 + - 39854 + - 39855 + - 39856 + - 39857 + - 39858 + - 39859 + - 39860 + - 39861 + - 39862 + - 39863 + - 39864 + - 39865 + - 39866 + - 39867 + - 39868 + - 39869 + - 39870 + - 39871 + - 39872 + - 39873 + - 39874 + - 39875 + - 39876 + - 39877 + - 39878 + - 39879 + - 39880 + - 39881 + - 39882 + - 39883 + - 39884 + - 39885 + - 39886 + - 39887 + - 39888 + - 39889 + - 39890 + - 39891 + - 39892 + - 39893 + - 39894 + - 39895 + - 39896 + - 39897 + - 39898 + - 39899 + - 39900 + - 39901 + - 39902 + - 39903 + - 39904 + - 39905 + - 39906 + - 39907 + - 39908 + - 39909 + - 39910 + - 39911 + - 39912 + - 39913 + - 39914 + - 39915 + - 39916 + - 39917 + - 39918 + - 39919 + - 39920 + - 39921 + - 39922 + - 39923 + - 39924 + - 39925 + - 39926 + - 39927 + - 39928 + - 39929 + - 39930 + - 39931 + - 39932 + - 39933 + - 39934 + - 39935 + - 39936 + - 39937 + - 39938 + - 39939 + - 39940 + - 39941 + - 39942 + - 39943 + - 39944 + - 39945 + - 39946 + - 39947 + - 39948 + - 39949 + - 39950 + - 39951 + - 39952 + - 39953 + - 39954 + - 39955 + - 39956 + - 39957 + - 39958 + - 39959 + - 39960 + - 39961 + - 39962 + - 39963 + - 39964 + - 39965 + - 39966 + - 39967 + - 39968 + - 39969 + - 39970 + - 39971 + - 39972 + - 39973 + - 39974 + - 39975 + - 39976 + - 39977 + - 39978 + - 39979 + - 39980 + - 39981 + - 39982 + - 39983 + - 39984 + - 39985 + - 39986 + - 39987 + - 39988 + - 39989 + - 39990 + - 39991 + - 39992 + - 39993 + - 39994 + - 39995 + - 39996 + - 39997 + - 39998 + - 39999 + - 40000 + - 40001 + - 40002 + - 40003 + - 40004 + - 40005 + - 40006 + - 40007 + - 40008 + - 40009 + - 40010 + - 40011 + - 40012 + - 40013 + - 40014 + - 40015 + - 40016 + - 40017 + - 40018 + - 40019 + - 40020 + - 40021 + - 40022 + - 40023 + - 40024 + - 40025 + - 40026 + - 40027 + - 40028 + - 40029 + - 40030 + - 40031 + - 40032 + - 40033 + - 40034 + - 40035 + - 40036 + - 40037 + - 40038 + - 40039 + - 40040 + - 40041 + - 40042 + - 40043 + - 40044 + - 40045 + - 40046 + - 40047 + - 40048 + - 40049 + - 40050 + - 40051 + - 40052 + - 40053 + - 40054 + - 40055 + - 40056 + - 40057 + - 40058 + - 40059 + - 40060 + - 40061 + - 40062 + - 40063 + - 40064 + - 40065 + - 40066 + - 40067 + - 40068 + - 40069 + - 40070 + - 40071 + - 40072 + - 40073 + - 40074 + - 40075 + - 40076 + - 40077 + - 40078 + - 40079 + - 40080 + - 40081 + - 40082 + - 40083 + - 40084 + - 40085 + - 40086 + - 40087 + - 40088 + - 40089 + - 40090 + - 40091 + - 40092 + - 40093 + - 40094 + - 40095 + - 40096 + - 40097 + - 40098 + - 40099 + - 40100 + - 40101 + - 40102 + - 40103 + - 40104 + - 40105 + - 40106 + - 40107 + - 40108 + - 40109 + - 40110 + - 40111 + - 40112 + - 40113 + - 40114 + - 40115 + - 40116 + - 40117 + - 40118 + - 40119 + - 40120 + - 40121 + - 40122 + - 40123 + - 40124 + - 40125 + - 40126 + - 40127 + - 40128 + - 40129 + - 40130 + - 40131 + - 40132 + - 40133 + - 40134 + - 40135 + - 40136 + - 40137 + - 40138 + - 40139 + - 40140 + - 40141 + - 40142 + - 40143 + - 40144 + - 40145 + - 40146 + - 40147 + - 40148 + - 40149 + - 40150 + - 40151 + - 40152 + - 40153 + - 40154 + - 40155 + - 40156 + - 40157 + - 40158 + - 40159 + - 40160 + - 40161 + - 40162 + - 40163 + - 40164 + - 40165 + - 40166 + - 40167 + - 40168 + - 40169 + - 40170 + - 40171 + - 40172 + - 40173 + - 40174 + - 40175 + - 40176 + - 40177 + - 40178 + - 40179 + - 40180 + - 40181 + - 40182 + - 40183 + - 40184 + - 40185 + - 40186 + - 40187 + - 40188 + - 40189 + - 40190 + - 40191 + - 40192 + - 40193 + - 40194 + - 40195 + - 40196 + - 40197 + - 40198 + - 40199 + - 40200 + - 40201 + - 40202 + - 40203 + - 40204 + - 40205 + - 40206 + - 40207 + - 40208 + - 40209 + - 40210 + - 40211 + - 40212 + - 40213 + - 40214 + - 40215 + - 40216 + - 40217 + - 40218 + - 40219 + - 40220 + - 40221 + - 40222 + - 40223 + - 40224 + - 40225 + - 40226 + - 40227 + - 40228 + - 40229 + - 40230 + - 40231 + - 40232 + - 40233 + - 40234 + - 40235 + - 40236 + - 40237 + - 40238 + - 40239 + - 40240 + - 40241 + - 40242 + - 40243 + - 40244 + - 40245 + - 40246 + - 40247 + - 40248 + - 40249 + - 40250 + - 40251 + - 40252 + - 40253 + - 40254 + - 40255 + - 40256 + - 40257 + - 40258 + - 40259 + - 40260 + - 40261 + - 40262 + - 40263 + - 40264 + - 40265 + - 40266 + - 40267 + - 40268 + - 40269 + - 40270 + - 40271 + - 40272 + - 40273 + - 40274 + - 40275 + - 40276 + - 40277 + - 40278 + - 40279 + - 40280 + - 40281 + - 40282 + - 40283 + - 40284 + - 40285 + - 40286 + - 40287 + - 40288 + - 40289 + - 40290 + - 40291 + - 40292 + - 40293 + - 40294 + - 40295 + - 40296 + - 40297 + - 40298 + - 40299 + - 40300 + - 40301 + - 40302 + - 40303 + - 40304 + - 40305 + - 40306 + - 40307 + - 40308 + - 40309 + - 40310 + - 40311 + - 40312 + - 40313 + - 40314 + - 40315 + - 40316 + - 40317 + - 40318 + - 40319 + - 40320 + - 40321 + - 40322 + - 40323 + - 40324 + - 40325 + - 40326 + - 40327 + - 40328 + - 40329 + - 40330 + - 40331 + - 40332 + - 40333 + - 40334 + - 40335 + - 40336 + - 40337 + - 40338 + - 40339 + - 40340 + - 40341 + - 40342 + - 40343 + - 40344 + - 40345 + - 40346 + - 40347 + - 40348 + - 40349 + - 40350 + - 40351 + - 40352 + - 40353 + - 40354 + - 40355 + - 40356 + - 40357 + - 40358 + - 40359 + - 40360 + - 40361 + - 40362 + - 40363 + - 40364 + - 40365 + - 40366 + - 40367 + - 40368 + - 40369 + - 40370 + - 40371 + - 40372 + - 40373 + - 40374 + - 40375 + - 40376 + - 40377 + - 40378 + - 40379 + - 40380 + - 40381 + - 40382 + - 40383 + - 40384 + - 40385 + - 40386 + - 40387 + - 40388 + - 40389 + - 40390 + - 40391 + - 40392 + - 40393 + - 40394 + - 40395 + - 40396 + - 40397 + - 40398 + - 40399 + - 40400 + - 40401 + - 40402 + - 40403 + - 40404 + - 40405 + - 40406 + - 40407 + - 40408 + - 40409 + - 40410 + - 40411 + - 40412 + - 40413 + - 40414 + - 40415 + - 40416 + - 40417 + - 40418 + - 40419 + - 40420 + - 40421 + - 40422 + - 40423 + - 40424 + - 40425 + - 40426 + - 40427 + - 40428 + - 40429 + - 40430 + - 40431 + - 40432 + - 40433 + - 40434 + - 40435 + - 40436 + - 40437 + - 40438 + - 40439 + - 40440 + - 40441 + - 40442 + - 40443 + - 40444 + - 40445 + - 40446 + - 40447 + - 40448 + - 40449 + - 40450 + - 40451 + - 40452 + - 40453 + - 40454 + - 40455 + - 40456 + - 40457 + - 40458 + - 40459 + - 40460 + - 40461 + - 40462 + - 40463 + - 40464 + - 40465 + - 40466 + - 40467 + - 40468 + - 40469 + - 40470 + - 40471 + - 40472 + - 40473 + - 40474 + - 40475 + - 40476 + - 40477 + - 40478 + - 40479 + - 40480 + - 40481 + - 40482 + - 40483 + - 40484 + - 40485 + - 40486 + - 40487 + - 40488 + - 40489 + - 40490 + - 40491 + - 40492 + - 40493 + - 40494 + - 40495 + - 40496 + - 40497 + - 40498 + - 40499 + - 40500 + - 40501 + - 40502 + - 40503 + - 40504 + - 40505 + - 40506 + - 40507 + - 40508 + - 40509 + - 40510 + - 40511 + - 40512 + - 40513 + - 40514 + - 40515 + - 40516 + - 40517 + - 40518 + - 40519 + - 40520 + - 40521 + - 40522 + - 40523 + - 40524 + - 40525 + - 40526 + - 40527 + - 40528 + - 40529 + - 40530 + - 40531 + - 40532 + - 40533 + - 40534 + - 40535 + - 40536 + - 40537 + - 40538 + - 40539 + - 40540 + - 40541 + - 40542 + - 40543 + - 40544 + - 40545 + - 40546 + - 40547 + - 40548 + - 40549 + - 40550 + - 40551 + - 40552 + - 40553 + - 40554 + - 40555 + - 40556 + - 40557 + - 40558 + - 40559 + - 40560 + - 40561 + - 40562 + - 40563 + - 40564 + - 40565 + - 40566 + - 40567 + - 40568 + - 40569 + - 40570 + - 40571 + - 40572 + - 40573 + - 40574 + - 40575 + - 40576 + - 40577 + - 40578 + - 40579 + - 40580 + - 40581 + - 40582 + - 40583 + - 40584 + - 40585 + - 40586 + - 40587 + - 40588 + - 40589 + - 40590 + - 40591 + - 40592 + - 40593 + - 40594 + - 40595 + - 40596 + - 40597 + - 40598 + - 40599 + - 40600 + - 40601 + - 40602 + - 40603 + - 40604 + - 40605 + - 40606 + - 40607 + - 40608 + - 40609 + - 40610 + - 40611 + - 40612 + - 40613 + - 40614 + - 40615 + - 40616 + - 40617 + - 40618 + - 40619 + - 40620 + - 40621 + - 40622 + - 40623 + - 40624 + - 40625 + - 40626 + - 40627 + - 40628 + - 40629 + - 40630 + - 40631 + - 40632 + - 40633 + - 40634 + - 40635 + - 40636 + - 40637 + - 40638 + - 40639 + - 40640 + - 40641 + - 40642 + - 40643 + - 40644 + - 40645 + - 40646 + - 40647 + - 40648 + - 40649 + - 40650 + - 40651 + - 40652 + - 40653 + - 40654 + - 40655 + - 40656 + - 40657 + - 40658 + - 40659 + - 40660 + - 40661 + - 40662 + - 40663 + - 40664 + - 40665 + - 40666 + - 40667 + - 40668 + - 40669 + - 40670 + - 40671 + - 40672 + - 40673 + - 40674 + - 40675 + - 40676 + - 40677 + - 40678 + - 40679 + - 40680 + - 40681 + - 40682 + - 40683 + - 40684 + - 40685 + - 40686 + - 40687 + - 40688 + - 40689 + - 40690 + - 40691 + - 40692 + - 40693 + - 40694 + - 40695 + - 40696 + - 40697 + - 40698 + - 40699 + - 40700 + - 40701 + - 40702 + - 40703 + - 40704 + - 40705 + - 40706 + - 40707 + - 40708 + - 40709 + - 40710 + - 40711 + - 40712 + - 40713 + - 40714 + - 40715 + - 40716 + - 40717 + - 40718 + - 40719 + - 40720 + - 40721 + - 40722 + - 40723 + - 40724 + - 40725 + - 40726 + - 40727 + - 40728 + - 40729 + - 40730 + - 40731 + - 40732 + - 40733 + - 40734 + - 40735 + - 40736 + - 40737 + - 40738 + - 40739 + - 40740 + - 40741 + - 40742 + - 40743 + - 40744 + - 40745 + - 40746 + - 40747 + - 40748 + - 40749 + - 40750 + - 40751 + - 40752 + - 40753 + - 40754 + - 40755 + - 40756 + - 40757 + - 40758 + - 40759 + - 40760 + - 40761 + - 40762 + - 40763 + - 40764 + - 40765 + - 40766 + - 40767 + - 40768 + - 40769 + - 40770 + - 40771 + - 40772 + - 40773 + - 40774 + - 40775 + - 40776 + - 40777 + - 40778 + - 40779 + - 40780 + - 40781 + - 40782 + - 40783 + - 40784 + - 40785 + - 40786 + - 40787 + - 40788 + - 40789 + - 40790 + - 40791 + - 40792 + - 40793 + - 40794 + - 40795 + - 40796 + - 40797 + - 40798 + - 40799 + - 40800 + - 40801 + - 40802 + - 40803 + - 40804 + - 40805 + - 40806 + - 40807 + - 40808 + - 40809 + - 40810 + - 40811 + - 40812 + - 40813 + - 40814 + - 40815 + - 40816 + - 40817 + - 40818 + - 40819 + - 40820 + - 40821 + - 40822 + - 40823 + - 40824 + - 40825 + - 40826 + - 40827 + - 40828 + - 40829 + - 40830 + - 40831 + - 40832 + - 40833 + - 40834 + - 40835 + - 40836 + - 40837 + - 40838 + - 40839 + - 40840 + - 40841 + - 40842 + - 40843 + - 40844 + - 40845 + - 40846 + - 40847 + - 40848 + - 40849 + - 40850 + - 40851 + - 40852 + - 40853 + - 40854 + - 40855 + - 40856 + - 40857 + - 40858 + - 40859 + - 40860 + - 40861 + - 40862 + - 40863 + - 40864 + - 40865 + - 40866 + - 40867 + - 40868 + - 40869 + - 40870 + - 40871 + - 40872 + - 40873 + - 40874 + - 40875 + - 40876 + - 40877 + - 40878 + - 40879 + - 40880 + - 40881 + - 40882 + - 40883 + - 40884 + - 40885 + - 40886 + - 40887 + - 40888 + - 40889 + - 40890 + - 40891 + - 40892 + - 40893 + - 40894 + - 40895 + - 40896 + - 40897 + - 40898 + - 40899 + - 40900 + - 40901 + - 40902 + - 40903 + - 40904 + - 40905 + - 40906 + - 40907 + - 40908 + - 40909 + - 40910 + - 40911 + - 40912 + - 40913 + - 40914 + - 40915 + - 40916 + - 40917 + - 40918 + - 40919 + - 40920 + - 40921 + - 40922 + - 40923 + - 40924 + - 40925 + - 40926 + - 40927 + - 40928 + - 40929 + - 40930 + - 40931 + - 40932 + - 40933 + - 40934 + - 40935 + - 40936 + - 40937 + - 40938 + - 40939 + - 40940 + - 40941 + - 40942 + - 40943 + - 40944 + - 40945 + - 40946 + - 40947 + - 40948 + - 40949 + - 40950 + - 40951 + - 40952 + - 40953 + - 40954 + - 40955 + - 40956 + - 40957 + - 40958 + - 40959 + - 40960 + - 40961 + - 40962 + - 40963 + - 40964 + - 40965 + - 40966 + - 40967 + - 40968 + - 40969 + - 40970 + - 40971 + - 40972 + - 40973 + - 40974 + - 40975 + - 40976 + - 40977 + - 40978 + - 40979 + - 40980 + - 40981 + - 40982 + - 40983 + - 40984 + - 40985 + - 40986 + - 40987 + - 40988 + - 40989 + - 40990 + - 40991 + - 40992 + - 40993 + - 40994 + - 40995 + - 40996 + - 40997 + - 40998 + - 40999 + - 41000 + - 41001 + - 41002 + - 41003 + - 41004 + - 41005 + - 41006 + - 41007 + - 41008 + - 41009 + - 41010 + - 41011 + - 41012 + - 41013 + - 41014 + - 41015 + - 41016 + - 41017 + - 41018 + - 41019 + - 41020 + - 41021 + - 41022 + - 41023 + - 41024 + - 41025 + - 41026 + - 41027 + - 41028 + - 41029 + - 41030 + - 41031 + - 41032 + - 41033 + - 41034 + - 41035 + - 41036 + - 41037 + - 41038 + - 41039 + - 41040 + - 41041 + - 41042 + - 41043 + - 41044 + - 41045 + - 41046 + - 41047 + - 41048 + - 41049 + - 41050 + - 41051 + - 41052 + - 41053 + - 41054 + - 41055 + - 41056 + - 41057 + - 41058 + - 41059 + - 41060 + - 41061 + - 41062 + - 41063 + - 41064 + - 41065 + - 41066 + - 41067 + - 41068 + - 41069 + - 41070 + - 41071 + - 41072 + - 41073 + - 41074 + - 41075 + - 41076 + - 41077 + - 41078 + - 41079 + - 41080 + - 41081 + - 41082 + - 41083 + - 41084 + - 41085 + - 41086 + - 41087 + - 41088 + - 41089 + - 41090 + - 41091 + - 41092 + - 41093 + - 41094 + - 41095 + - 41096 + - 41097 + - 41098 + - 41099 + - 41100 + - 41101 + - 41102 + - 41103 + - 41104 + - 41105 + - 41106 + - 41107 + - 41108 + - 41109 + - 41110 + - 41111 + - 41112 + - 41113 + - 41114 + - 41115 + - 41116 + - 41117 + - 41118 + - 41119 + - 41120 + - 41121 + - 41122 + - 41123 + - 41124 + - 41125 + - 41126 + - 41127 + - 41128 + - 41129 + - 41130 + - 41131 + - 41132 + - 41133 + - 41134 + - 41135 + - 41136 + - 41137 + - 41138 + - 41139 + - 41140 + - 41141 + - 41142 + - 41143 + - 41144 + - 41145 + - 41146 + - 41147 + - 41148 + - 41149 + - 41150 + - 41151 + - 41152 + - 41153 + - 41154 + - 41155 + - 41156 + - 41157 + - 41158 + - 41159 + - 41160 + - 41161 + - 41162 + - 41163 + - 41164 + - 41165 + - 41166 + - 41167 + - 41168 + - 41169 + - 41170 + - 41171 + - 41172 + - 41173 + - 41174 + - 41175 + - 41176 + - 41177 + - 41178 + - 41179 + - 41180 + - 41181 + - 41182 + - 41183 + - 41184 + - 41185 + - 41186 + - 41187 + - 41188 + - 41189 + - 41190 + - 41191 + - 41192 + - 41193 + - 41194 + - 41195 + - 41196 + - 41197 + - 41198 + - 41199 + - 41200 + - 41201 + - 41202 + - 41203 + - 41204 + - 41205 + - 41206 + - 41207 + - 41208 + - 41209 + - 41210 + - 41211 + - 41212 + - 41213 + - 41214 + - 41215 + - 41216 + - 41217 + - 41218 + - 41219 + - 41220 + - 41221 + - 41222 + - 41223 + - 41224 + - 41225 + - 41226 + - 41227 + - 41228 + - 41229 + - 41230 + - 41231 + - 41232 + - 41233 + - 41234 + - 41235 + - 41236 + - 41237 + - 41238 + - 41239 + - 41240 + - 41241 + - 41242 + - 41243 + - 41244 + - 41245 + - 41246 + - 41247 + - 41248 + - 41249 + - 41250 + - 41251 + - 41252 + - 41253 + - 41254 + - 41255 + - 41256 + - 41257 + - 41258 + - 41259 + - 41260 + - 41261 + - 41262 + - 41263 + - 41264 + - 41265 + - 41266 + - 41267 + - 41268 + - 41269 + - 41270 + - 41271 + - 41272 + - 41273 + - 41274 + - 41275 + - 41276 + - 41277 + - 41278 + - 41279 + - 41280 + - 41281 + - 41282 + - 41283 + - 41284 + - 41285 + - 41286 + - 41287 + - 41288 + - 41289 + - 41290 + - 41291 + - 41292 + - 41293 + - 41294 + - 41295 + - 41296 + - 41297 + - 41298 + - 41299 + - 41300 + - 41301 + - 41302 + - 41303 + - 41304 + - 41305 + - 41306 + - 41307 + - 41308 + - 41309 + - 41310 + - 41311 + - 41312 + - 41313 + - 41314 + - 41315 + - 41316 + - 41317 + - 41318 + - 41319 + - 41320 + - 41321 + - 41322 + - 41323 + - 41324 + - 41325 + - 41326 + - 41327 + - 41328 + - 41329 + - 41330 + - 41331 + - 41332 + - 41333 + - 41334 + - 41335 + - 41336 + - 41337 + - 41338 + - 41339 + - 41340 + - 41341 + - 41342 + - 41343 + - 41344 + - 41345 + - 41346 + - 41347 + - 41348 + - 41349 + - 41350 + - 41351 + - 41352 + - 41353 + - 41354 + - 41355 + - 41356 + - 41357 + - 41358 + - 41359 + - 41360 + - 41361 + - 41362 + - 41363 + - 41364 + - 41365 + - 41366 + - 41367 + - 41368 + - 41369 + - 41370 + - 41371 + - 41372 + - 41373 + - 41374 + - 41375 + - 41376 + - 41377 + - 41378 + - 41379 + - 41380 + - 41381 + - 41382 + - 41383 + - 41384 + - 41385 + - 41386 + - 41387 + - 41388 + - 41389 + - 41390 + - 41391 + - 41392 + - 41393 + - 41394 + - 41395 + - 41396 + - 41397 + - 41398 + - 41399 + - 41400 + - 41401 + - 41402 + - 41403 + - 41404 + - 41405 + - 41406 + - 41407 + - 41408 + - 41409 + - 41410 + - 41411 + - 41412 + - 41413 + - 41414 + - 41415 + - 41416 + - 41417 + - 41418 + - 41419 + - 41420 + - 41421 + - 41422 + - 41423 + - 41424 + - 41425 + - 41426 + - 41427 + - 41428 + - 41429 + - 41430 + - 41431 + - 41432 + - 41433 + - 41434 + - 41435 + - 41436 + - 41437 + - 41438 + - 41439 + - 41440 + - 41441 + - 41442 + - 41443 + - 41444 + - 41445 + - 41446 + - 41447 + - 41448 + - 41449 + - 41450 + - 41451 + - 41452 + - 41453 + - 41454 + - 41455 + - 41456 + - 41457 + - 41458 + - 41459 + - 41460 + - 41461 + - 41462 + - 41463 + - 41464 + - 41465 + - 41466 + - 41467 + - 41468 + - 41469 + - 41470 + - 41471 + - 41472 + - 41473 + - 41474 + - 41475 + - 41476 + - 41477 + - 41478 + - 41479 + - 41480 + - 41481 + - 41482 + - 41483 + - 41484 + - 41485 + - 41486 + - 41487 + - 41488 + - 41489 + - 41490 + - 41491 + - 41492 + - 41493 + - 41494 + - 41495 + - 41496 + - 41497 + - 41498 + - 41499 + - 41500 + - 41501 + - 41502 + - 41503 + - 41504 + - 41505 + - 41506 + - 41507 + - 41508 + - 41509 + - 41510 + - 41511 + - 41512 + - 41513 + - 41514 + - 41515 + - 41516 + - 41517 + - 41518 + - 41519 + - 41520 + - 41521 + - 41522 + - 41523 + - 41524 + - 41525 + - 41526 + - 41527 + - 41528 + - 41529 + - 41530 + - 41531 + - 41532 + - 41533 + - 41534 + - 41535 + - 41536 + - 41537 + - 41538 + - 41539 + - 41540 + - 41541 + - 41542 + - 41543 + - 41544 + - 41545 + - 41546 + - 41547 + - 41548 + - 41549 + - 41550 + - 41551 + - 41552 + - 41553 + - 41554 + - 41555 + - 41556 + - 41557 + - 41558 + - 41559 + - 41560 + - 41561 + - 41562 + - 41563 + - 41564 + - 41565 + - 41566 + - 41567 + - 41568 + - 41569 + - 41570 + - 41571 + - 41572 + - 41573 + - 41574 + - 41575 + - 41576 + - 41577 + - 41578 + - 41579 + - 41580 + - 41581 + - 41582 + - 41583 + - 41584 + - 41585 + - 41586 + - 41587 + - 41588 + - 41589 + - 41590 + - 41591 + - 41592 + - 41593 + - 41594 + - 41595 + - 41596 + - 41597 + - 41598 + - 41599 + - 41600 + - 41601 + - 41602 + - 41603 + - 41604 + - 41605 + - 41606 + - 41607 + - 41608 + - 41609 + - 41610 + - 41611 + - 41612 + - 41613 + - 41614 + - 41615 + - 41616 + - 41617 + - 41618 + - 41619 + - 41620 + - 41621 + - 41622 + - 41623 + - 41624 + - 41625 + - 41626 + - 41627 + - 41628 + - 41629 + - 41630 + - 41631 + - 41632 + - 41633 + - 41634 + - 41635 + - 41636 + - 41637 + - 41638 + - 41639 + - 41640 + - 41641 + - 41642 + - 41643 + - 41644 + - 41645 + - 41646 + - 41647 + - 41648 + - 41649 + - 41650 + - 41651 + - 41652 + - 41653 + - 41654 + - 41655 + - 41656 + - 41657 + - 41658 + - 41659 + - 41660 + - 41661 + - 41662 + - 41663 + - 41664 + - 41665 + - 41666 + - 41667 + - 41668 + - 41669 + - 41670 + - 41671 + - 41672 + - 41673 + - 41674 + - 41675 + - 41676 + - 41677 + - 41678 + - 41679 + - 41680 + - 41681 + - 41682 + - 41683 + - 41684 + - 41685 + - 41686 + - 41687 + - 41688 + - 41689 + - 41690 + - 41691 + - 41692 + - 41693 + - 41694 + - 41695 + - 41696 + - 41697 + - 41698 + - 41699 + - 41700 + - 41701 + - 41702 + - 41703 + - 41704 + - 41705 + - 41706 + - 41707 + - 41708 + - 41709 + - 41710 + - 41711 + - 41712 + - 41713 + - 41714 + - 41715 + - 41716 + - 41717 + - 41718 + - 41719 + - 41720 + - 41721 + - 41722 + - 41723 + - 41724 + - 41725 + - 41726 + - 41727 + - 41728 + - 41729 + - 41730 + - 41731 + - 41732 + - 41733 + - 41734 + - 41735 + - 41736 + - 41737 + - 41738 + - 41739 + - 41740 + - 41741 + - 41742 + - 41743 + - 41744 + - 41745 + - 41746 + - 41747 + - 41748 + - 41749 + - 41750 + - 41751 + - 41752 + - 41753 + - 41754 + - 41755 + - 41756 + - 41757 + - 41758 + - 41759 + - 41760 + - 41761 + - 41762 + - 41763 + - 41764 + - 41765 + - 41766 + - 41767 + - 41768 + - 41769 + - 41770 + - 41771 + - 41772 + - 41773 + - 41774 + - 41775 + - 41776 + - 41777 + - 41778 + - 41779 + - 41780 + - 41781 + - 41782 + - 41783 + - 41784 + - 41785 + - 41786 + - 41787 + - 41788 + - 41789 + - 41790 + - 41791 + - 41792 + - 41793 + - 41794 + - 41795 + - 41796 + - 41797 + - 41798 + - 41799 + - 41800 + - 41801 + - 41802 + - 41803 + - 41804 + - 41805 + - 41806 + - 41807 + - 41808 + - 41809 + - 41810 + - 41811 + - 41812 + - 41813 + - 41814 + - 41815 + - 41816 + - 41817 + - 41818 + - 41819 + - 41820 + - 41821 + - 41822 + - 41823 + - 41824 + - 41825 + - 41826 + - 41827 + - 41828 + - 41829 + - 41830 + - 41831 + - 41832 + - 41833 + - 41834 + - 41835 + - 41836 + - 41837 + - 41838 + - 41839 + - 41840 + - 41841 + - 41842 + - 41843 + - 41844 + - 41845 + - 41846 + - 41847 + - 41848 + - 41849 + - 41850 + - 41851 + - 41852 + - 41853 + - 41854 + - 41855 + - 41856 + - 41857 + - 41858 + - 41859 + - 41860 + - 41861 + - 41862 + - 41863 + - 41864 + - 41865 + - 41866 + - 41867 + - 41868 + - 41869 + - 41870 + - 41871 + - 41872 + - 41873 + - 41874 + - 41875 + - 41876 + - 41877 + - 41878 + - 41879 + - 41880 + - 41881 + - 41882 + - 41883 + - 41884 + - 41885 + - 41886 + - 41887 + - 41888 + - 41889 + - 41890 + - 41891 + - 41892 + - 41893 + - 41894 + - 41895 + - 41896 + - 41897 + - 41898 + - 41899 + - 41900 + - 41901 + - 41902 + - 41903 + - 41904 + - 41905 + - 41906 + - 41907 + - 41908 + - 41909 + - 41910 + - 41911 + - 41912 + - 41913 + - 41914 + - 41915 + - 41916 + - 41917 + - 41918 + - 41919 + - 41920 + - 41921 + - 41922 + - 41923 + - 41924 + - 41925 + - 41926 + - 41927 + - 41928 + - 41929 + - 41930 + - 41931 + - 41932 + - 41933 + - 41934 + - 41935 + - 41936 + - 41937 + - 41938 + - 41939 + - 41940 + - 41941 + - 41942 + - 41943 + - 41944 + - 41945 + - 41946 + - 41947 + - 41948 + - 41949 + - 41950 + - 41951 + - 41952 + - 41953 + - 41954 + - 41955 + - 41956 + - 41957 + - 41958 + - 41959 + - 41960 + - 41961 + - 41962 + - 41963 + - 41964 + - 41965 + - 41966 + - 41967 + - 41968 + - 41969 + - 41970 + - 41971 + - 41972 + - 41973 + - 41974 + - 41975 + - 41976 + - 41977 + - 41978 + - 41979 + - 41980 + - 41981 + - 41982 + - 41983 + - 41984 + - 41985 + - 41986 + - 41987 + - 41988 + - 41989 + - 41990 + - 41991 + - 41992 + - 41993 + - 41994 + - 41995 + - 41996 + - 41997 + - 41998 + - 41999 + - 42000 + - 42001 + - 42002 + - 42003 + - 42004 + - 42005 + - 42006 + - 42007 + - 42008 + - 42009 + - 42010 + - 42011 + - 42012 + - 42013 + - 42014 + - 42015 + - 42016 + - 42017 + - 42018 + - 42019 + - 42020 + - 42021 + - 42022 + - 42023 + - 42024 + - 42025 + - 42026 + - 42027 + - 42028 + - 42029 + - 42030 + - 42031 + - 42032 + - 42033 + - 42034 + - 42035 + - 42036 + - 42037 + - 42038 + - 42039 + - 42040 + - 42041 + - 42042 + - 42043 + - 42044 + - 42045 + - 42046 + - 42047 + - 42048 + - 42049 + - 42050 + - 42051 + - 42052 + - 42053 + - 42054 + - 42055 + - 42056 + - 42057 + - 42058 + - 42059 + - 42060 + - 42061 + - 42062 + - 42063 + - 42064 + - 42065 + - 42066 + - 42067 + - 42068 + - 42069 + - 42070 + - 42071 + - 42072 + - 42073 + - 42074 + - 42075 + - 42076 + - 42077 + - 42078 + - 42079 + - 42080 + - 42081 + - 42082 + - 42083 + - 42084 + - 42085 + - 42086 + - 42087 + - 42088 + - 42089 + - 42090 + - 42091 + - 42092 + - 42093 + - 42094 + - 42095 + - 42096 + - 42097 + - 42098 + - 42099 + - 42100 + - 42101 + - 42102 + - 42103 + - 42104 + - 42105 + - 42106 + - 42107 + - 42108 + - 42109 + - 42110 + - 42111 + - 42112 + - 42113 + - 42114 + - 42115 + - 42116 + - 42117 + - 42118 + - 42119 + - 42120 + - 42121 + - 42122 + - 42123 + - 42124 + - 42125 + - 42126 + - 42127 + - 42128 + - 42129 + - 42130 + - 42131 + - 42132 + - 42133 + - 42134 + - 42135 + - 42136 + - 42137 + - 42138 + - 42139 + - 42140 + - 42141 + - 42142 + - 42143 + - 42144 + - 42145 + - 42146 + - 42147 + - 42148 + - 42149 + - 42150 + - 42151 + - 42152 + - 42153 + - 42154 + - 42155 + - 42156 + - 42157 + - 42158 + - 42159 + - 42160 + - 42161 + - 42162 + - 42163 + - 42164 + - 42165 + - 42166 + - 42167 + - 42168 + - 42169 + - 42170 + - 42171 + - 42172 + - 42173 + - 42174 + - 42175 + - 42176 + - 42177 + - 42178 + - 42179 + - 42180 + - 42181 + - 42182 + - 42183 + - 42184 + - 42185 + - 42186 + - 42187 + - 42188 + - 42189 + - 42190 + - 42191 + - 42192 + - 42193 + - 42194 + - 42195 + - 42196 + - 42197 + - 42198 + - 42199 + - 42200 + - 42201 + - 42202 + - 42203 + - 42204 + - 42205 + - 42206 + - 42207 + - 42208 + - 42209 + - 42210 + - 42211 + - 42212 + - 42213 + - 42214 + - 42215 + - 42216 + - 42217 + - 42218 + - 42219 + - 42220 + - 42221 + - 42222 + - 42223 + - 42224 + - 42225 + - 42226 + - 42227 + - 42228 + - 42229 + - 42230 + - 42231 + - 42232 + - 42233 + - 42234 + - 42235 + - 42236 + - 42237 + - 42238 + - 42239 + - 42240 + - 42241 + - 42242 + - 42243 + - 42244 + - 42245 + - 42246 + - 42247 + - 42248 + - 42249 + - 42250 + - 42251 + - 42252 + - 42253 + - 42254 + - 42255 + - 42256 + - 42257 + - 42258 + - 42259 + - 42260 + - 42261 + - 42262 + - 42263 + - 42264 + - 42265 + - 42266 + - 42267 + - 42268 + - 42269 + - 42270 + - 42271 + - 42272 + - 42273 + - 42274 + - 42275 + - 42276 + - 42277 + - 42278 + - 42279 + - 42280 + - 42281 + - 42282 + - 42283 + - 42284 + - 42285 + - 42286 + - 42287 + - 42288 + - 42289 + - 42290 + - 42291 + - 42292 + - 42293 + - 42294 + - 42295 + - 42296 + - 42297 + - 42298 + - 42299 + - 42300 + - 42301 + - 42302 + - 42303 + - 42304 + - 42305 + - 42306 + - 42307 + - 42308 + - 42309 + - 42310 + - 42311 + - 42312 + - 42313 + - 42314 + - 42315 + - 42316 + - 42317 + - 42318 + - 42319 + - 42320 + - 42321 + - 42322 + - 42323 + - 42324 + - 42325 + - 42326 + - 42327 + - 42328 + - 42329 + - 42330 + - 42331 + - 42332 + - 42333 + - 42334 + - 42335 + - 42336 + - 42337 + - 42338 + - 42339 + - 42340 + - 42341 + - 42342 + - 42343 + - 42344 + - 42345 + - 42346 + - 42347 + - 42348 + - 42349 + - 42350 + - 42351 + - 42352 + - 42353 + - 42354 + - 42355 + - 42356 + - 42357 + - 42358 + - 42359 + - 42360 + - 42361 + - 42362 + - 42363 + - 42364 + - 42365 + - 42366 + - 42367 + - 42368 + - 42369 + - 42370 + - 42371 + - 42372 + - 42373 + - 42374 + - 42375 + - 42376 + - 42377 + - 42378 + - 42379 + - 42380 + - 42381 + - 42382 + - 42383 + - 42384 + - 42385 + - 42386 + - 42387 + - 42388 + - 42389 + - 42390 + - 42391 + - 42392 + - 42393 + - 42394 + - 42395 + - 42396 + - 42397 + - 42398 + - 42399 + - 42400 + - 42401 + - 42402 + - 42403 + - 42404 + - 42405 + - 42406 + - 42407 + - 42408 + - 42409 + - 42410 + - 42411 + - 42412 + - 42413 + - 42414 + - 42415 + - 42416 + - 42417 + - 42418 + - 42419 + - 42420 + - 42421 + - 42422 + - 42423 + - 42424 + - 42425 + - 42426 + - 42427 + - 42428 + - 42429 + - 42430 + - 42431 + - 42432 + - 42433 + - 42434 + - 42435 + - 42436 + - 42437 + - 42438 + - 42439 + - 42440 + - 42441 + - 42442 + - 42443 + - 42444 + - 42445 + - 42446 + - 42447 + - 42448 + - 42449 + - 42450 + - 42451 + - 42452 + - 42453 + - 42454 + - 42455 + - 42456 + - 42457 + - 42458 + - 42459 + - 42460 + - 42461 + - 42462 + - 42463 + - 42464 + - 42465 + - 42466 + - 42467 + - 42468 + - 42469 + - 42470 + - 42471 + - 42472 + - 42473 + - 42474 + - 42475 + - 42476 + - 42477 + - 42478 + - 42479 + - 42480 + - 42481 + - 42482 + - 42483 + - 42484 + - 42485 + - 42486 + - 42487 + - 42488 + - 42489 + - 42490 + - 42491 + - 42492 + - 42493 + - 42494 + - 42495 + - 42496 + - 42497 + - 42498 + - 42499 + - 42500 + - 42501 + - 42502 + - 42503 + - 42504 + - 42505 + - 42506 + - 42507 + - 42508 + - 42509 + - 42510 + - 42511 + - 42512 + - 42513 + - 42514 + - 42515 + - 42516 + - 42517 + - 42518 + - 42519 + - 42520 + - 42521 + - 42522 + - 42523 + - 42524 + - 42525 + - 42526 + - 42527 + - 42528 + - 42529 + - 42530 + - 42531 + - 42532 + - 42533 + - 42534 + - 42535 + - 42536 + - 42537 + - 42538 + - 42539 + - 42540 + - 42541 + - 42542 + - 42543 + - 42544 + - 42545 + - 42546 + - 42547 + - 42548 + - 42549 + - 42550 + - 42551 + - 42552 + - 42553 + - 42554 + - 42555 + - 42556 + - 42557 + - 42558 + - 42559 + - 42560 + - 42561 + - 42562 + - 42563 + - 42564 + - 42565 + - 42566 + - 42567 + - 42568 + - 42569 + - 42570 + - 42571 + - 42572 + - 42573 + - 42574 + - 42575 + - 42576 + - 42577 + - 42578 + - 42579 + - 42580 + - 42581 + - 42582 + - 42583 + - 42584 + - 42585 + - 42586 + - 42587 + - 42588 + - 42589 + - 42590 + - 42591 + - 42592 + - 42593 + - 42594 + - 42595 + - 42596 + - 42597 + - 42598 + - 42599 + - 42600 + - 42601 + - 42602 + - 42603 + - 42604 + - 42605 + - 42606 + - 42607 + - 42608 + - 42609 + - 42610 + - 42611 + - 42612 + - 42613 + - 42614 + - 42615 + - 42616 + - 42617 + - 42618 + - 42619 + - 42620 + - 42621 + - 42622 + - 42623 + - 42624 + - 42625 + - 42626 + - 42627 + - 42628 + - 42629 + - 42630 + - 42631 + - 42632 + - 42633 + - 42634 + - 42635 + - 42636 + - 42637 + - 42638 + - 42639 + - 42640 + - 42641 + - 42642 + - 42643 + - 42644 + - 42645 + - 42646 + - 42647 + - 42648 + - 42649 + - 42650 + - 42651 + - 42652 + - 42653 + - 42654 + - 42655 + - 42656 + - 42657 + - 42658 + - 42659 + - 42660 + - 42661 + - 42662 + - 42663 + - 42664 + - 42665 + - 42666 + - 42667 + - 42668 + - 42669 + - 42670 + - 42671 + - 42672 + - 42673 + - 42674 + - 42675 + - 42676 + - 42677 + - 42678 + - 42679 + - 42680 + - 42681 + - 42682 + - 42683 + - 42684 + - 42685 + - 42686 + - 42687 + - 42688 + - 42689 + - 42690 + - 42691 + - 42692 + - 42693 + - 42694 + - 42695 + - 42696 + - 42697 + - 42698 + - 42699 + - 42700 + - 42701 + - 42702 + - 42703 + - 42704 + - 42705 + - 42706 + - 42707 + - 42708 + - 42709 + - 42710 + - 42711 + - 42712 + - 42713 + - 42714 + - 42715 + - 42716 + - 42717 + - 42718 + - 42719 + - 42720 + - 42721 + - 42722 + - 42723 + - 42724 + - 42725 + - 42726 + - 42727 + - 42728 + - 42729 + - 42730 + - 42731 + - 42732 + - 42733 + - 42734 + - 42735 + - 42736 + - 42737 + - 42738 + - 42739 + - 42740 + - 42741 + - 42742 + - 42743 + - 42744 + - 42745 + - 42746 + - 42747 + - 42748 + - 42749 + - 42750 + - 42751 + - 42752 + - 42753 + - 42754 + - 42755 + - 42756 + - 42757 + - 42758 + - 42759 + - 42760 + - 42761 + - 42762 + - 42763 + - 42764 + - 42765 + - 42766 + - 42767 + - 42768 + - 42769 + - 42770 + - 42771 + - 42772 + - 42773 + - 42774 + - 42775 + - 42776 + - 42777 + - 42778 + - 42779 + - 42780 + - 42781 + - 42782 + - 42783 + - 42784 + - 42785 + - 42786 + - 42787 + - 42788 + - 42789 + - 42790 + - 42791 + - 42792 + - 42793 + - 42794 + - 42795 + - 42796 + - 42797 + - 42798 + - 42799 + - 42800 + - 42801 + - 42802 + - 42803 + - 42804 + - 42805 + - 42806 + - 42807 + - 42808 + - 42809 + - 42810 + - 42811 + - 42812 + - 42813 + - 42814 + - 42815 + - 42816 + - 42817 + - 42818 + - 42819 + - 42820 + - 42821 + - 42822 + - 42823 + - 42824 + - 42825 + - 42826 + - 42827 + - 42828 + - 42829 + - 42830 + - 42831 + - 42832 + - 42833 + - 42834 + - 42835 + - 42836 + - 42837 + - 42838 + - 42839 + - 42840 + - 42841 + - 42842 + - 42843 + - 42844 + - 42845 + - 42846 + - 42847 + - 42848 + - 42849 + - 42850 + - 42851 + - 42852 + - 42853 + - 42854 + - 42855 + - 42856 + - 42857 + - 42858 + - 42859 + - 42860 + - 42861 + - 42862 + - 42863 + - 42864 + - 42865 + - 42866 + - 42867 + - 42868 + - 42869 + - 42870 + - 42871 + - 42872 + - 42873 + - 42874 + - 42875 + - 42876 + - 42877 + - 42878 + - 42879 + - 42880 + - 42881 + - 42882 + - 42883 + - 42884 + - 42885 + - 42886 + - 42887 + - 42888 + - 42889 + - 42890 + - 42891 + - 42892 + - 42893 + - 42894 + - 42895 + - 42896 + - 42897 + - 42898 + - 42899 + - 42900 + - 42901 + - 42902 + - 42903 + - 42904 + - 42905 + - 42906 + - 42907 + - 42908 + - 42909 + - 42910 + - 42911 + - 42912 + - 42913 + - 42914 + - 42915 + - 42916 + - 42917 + - 42918 + - 42919 + - 42920 + - 42921 + - 42922 + - 42923 + - 42924 + - 42925 + - 42926 + - 42927 + - 42928 + - 42929 + - 42930 + - 42931 + - 42932 + - 42933 + - 42934 + - 42935 + - 42936 + - 42937 + - 42938 + - 42939 + - 42940 + - 42941 + - 42942 + - 42943 + - 42944 + - 42945 + - 42946 + - 42947 + - 42948 + - 42949 + - 42950 + - 42951 + - 42952 + - 42953 + - 42954 + - 42955 + - 42956 + - 42957 + - 42958 + - 42959 + - 42960 + - 42961 + - 42962 + - 42963 + - 42964 + - 42965 + - 42966 + - 42967 + - 42968 + - 42969 + - 42970 + - 42971 + - 42972 + - 42973 + - 42974 + - 42975 + - 42976 + - 42977 + - 42978 + - 42979 + - 42980 + - 42981 + - 42982 + - 42983 + - 42984 + - 42985 + - 42986 + - 42987 + - 42988 + - 42989 + - 42990 + - 42991 + - 42992 + - 42993 + - 42994 + - 42995 + - 42996 + - 42997 + - 42998 + - 42999 + - 43000 + - 43001 + - 43002 + - 43003 + - 43004 + - 43005 + - 43006 + - 43007 + - 43008 + - 43009 + - 43010 + - 43011 + - 43012 + - 43013 + - 43014 + - 43015 + - 43016 + - 43017 + - 43018 + - 43019 + - 43020 + - 43021 + - 43022 + - 43023 + - 43024 + - 43025 + - 43026 + - 43027 + - 43028 + - 43029 + - 43030 + - 43031 + - 43032 + - 43033 + - 43034 + - 43035 + - 43036 + - 43037 + - 43038 + - 43039 + - 43040 + - 43041 + - 43042 + - 43043 + - 43044 + - 43045 + - 43046 + - 43047 + - 43048 + - 43049 + - 43050 + - 43051 + - 43052 + - 43053 + - 43054 + - 43055 + - 43056 + - 43057 + - 43058 + - 43059 + - 43060 + - 43061 + - 43062 + - 43063 + - 43064 + - 43065 + - 43066 + - 43067 + - 43068 + - 43069 + - 43070 + - 43071 + - 43072 + - 43073 + - 43074 + - 43075 + - 43076 + - 43077 + - 43078 + - 43079 + - 43080 + - 43081 + - 43082 + - 43083 + - 43084 + - 43085 + - 43086 + - 43087 + - 43088 + - 43089 + - 43090 + - 43091 + - 43092 + - 43093 + - 43094 + - 43095 + - 43096 + - 43097 + - 43098 + - 43099 + - 43100 + - 43101 + - 43102 + - 43103 + - 43104 + - 43105 + - 43106 + - 43107 + - 43108 + - 43109 + - 43110 + - 43111 + - 43112 + - 43113 + - 43114 + - 43115 + - 43116 + - 43117 + - 43118 + - 43119 + - 43120 + - 43121 + - 43122 + - 43123 + - 43124 + - 43125 + - 43126 + - 43127 + - 43128 + - 43129 + - 43130 + - 43131 + - 43132 + - 43133 + - 43134 + - 43135 + - 43136 + - 43137 + - 43138 + - 43139 + - 43140 + - 43141 + - 43142 + - 43143 + - 43144 + - 43145 + - 43146 + - 43147 + - 43148 + - 43149 + - 43150 + - 43151 + - 43152 + - 43153 + - 43154 + - 43155 + - 43156 + - 43157 + - 43158 + - 43159 + - 43160 + - 43161 + - 43162 + - 43163 + - 43164 + - 43165 + - 43166 + - 43167 + - 43168 + - 43169 + - 43170 + - 43171 + - 43172 + - 43173 + - 43174 + - 43175 + - 43176 + - 43177 + - 43178 + - 43179 + - 43180 + - 43181 + - 43182 + - 43183 + - 43184 + - 43185 + - 43186 + - 43187 + - 43188 + - 43189 + - 43190 + - 43191 + - 43192 + - 43193 + - 43194 + - 43195 + - 43196 + - 43197 + - 43198 + - 43199 + - 43200 + - 43201 + - 43202 + - 43203 + - 43204 + - 43205 + - 43206 + - 43207 + - 43208 + - 43209 + - 43210 + - 43211 + - 43212 + - 43213 + - 43214 + - 43215 + - 43216 + - 43217 + - 43218 + - 43219 + - 43220 + - 43221 + - 43222 + - 43223 + - 43224 + - 43225 + - 43226 + - 43227 + - 43228 + - 43229 + - 43230 + - 43231 + - 43232 + - 43233 + - 43234 + - 43235 + - 43236 + - 43237 + - 43238 + - 43239 + - 43240 + - 43241 + - 43242 + - 43243 + - 43244 + - 43245 + - 43246 + - 43247 + - 43248 + - 43249 + - 43250 + - 43251 + - 43252 + - 43253 + - 43254 + - 43255 + - 43256 + - 43257 + - 43258 + - 43259 + - 43260 + - 43261 + - 43262 + - 43263 + - 43264 + - 43265 + - 43266 + - 43267 + - 43268 + - 43269 + - 43270 + - 43271 + - 43272 + - 43273 + - 43274 + - 43275 + - 43276 + - 43277 + - 43278 + - 43279 + - 43280 + - 43281 + - 43282 + - 43283 + - 43284 + - 43285 + - 43286 + - 43287 + - 43288 + - 43289 + - 43290 + - 43291 + - 43292 + - 43293 + - 43294 + - 43295 + - 43296 + - 43297 + - 43298 + - 43299 + - 43300 + - 43301 + - 43302 + - 43303 + - 43304 + - 43305 + - 43306 + - 43307 + - 43308 + - 43309 + - 43310 + - 43311 + - 43312 + - 43313 + - 43314 + - 43315 + - 43316 + - 43317 + - 43318 + - 43319 + - 43320 + - 43321 + - 43322 + - 43323 + - 43324 + - 43325 + - 43326 + - 43327 + - 43328 + - 43329 + - 43330 + - 43331 + - 43332 + - 43333 + - 43334 + - 43335 + - 43336 + - 43337 + - 43338 + - 43339 + - 43340 + - 43341 + - 43342 + - 43343 + - 43344 + - 43345 + - 43346 + - 43347 + - 43348 + - 43349 + - 43350 + - 43351 + - 43352 + - 43353 + - 43354 + - 43355 + - 43356 + - 43357 + - 43358 + - 43359 + - 43360 + - 43361 + - 43362 + - 43363 + - 43364 + - 43365 + - 43366 + - 43367 + - 43368 + - 43369 + - 43370 + - 43371 + - 43372 + - 43373 + - 43374 + - 43375 + - 43376 + - 43377 + - 43378 + - 43379 + - 43380 + - 43381 + - 43382 + - 43383 + - 43384 + - 43385 + - 43386 + - 43387 + - 43388 + - 43389 + - 43390 + - 43391 + - 43392 + - 43393 + - 43394 + - 43395 + - 43396 + - 43397 + - 43398 + - 43399 + - 43400 + - 43401 + - 43402 + - 43403 + - 43404 + - 43405 + - 43406 + - 43407 + - 43408 + - 43409 + - 43410 + - 43411 + - 43412 + - 43413 + - 43414 + - 43415 + - 43416 + - 43417 + - 43418 + - 43419 + - 43420 + - 43421 + - 43422 + - 43423 + - 43424 + - 43425 + - 43426 + - 43427 + - 43428 + - 43429 + - 43430 + - 43431 + - 43432 + - 43433 + - 43434 + - 43435 + - 43436 + - 43437 + - 43438 + - 43439 + - 43440 + - 43441 + - 43442 + - 43443 + - 43444 + - 43445 + - 43446 + - 43447 + - 43448 + - 43449 + - 43450 + - 43451 + - 43452 + - 43453 + - 43454 + - 43455 + - 43456 + - 43457 + - 43458 + - 43459 + - 43460 + - 43461 + - 43462 + - 43463 + - 43464 + - 43465 + - 43466 + - 43467 + - 43468 + - 43469 + - 43470 + - 43471 + - 43472 + - 43473 + - 43474 + - 43475 + - 43476 + - 43477 + - 43478 + - 43479 + - 43480 + - 43481 + - 43482 + - 43483 + - 43484 + - 43485 + - 43486 + - 43487 + - 43488 + - 43489 + - 43490 + - 43491 + - 43492 + - 43493 + - 43494 + - 43495 + - 43496 + - 43497 + - 43498 + - 43499 + - 43500 + - 43501 + - 43502 + - 43503 + - 43504 + - 43505 + - 43506 + - 43507 + - 43508 + - 43509 + - 43510 + - 43511 + - 43512 + - 43513 + - 43514 + - 43515 + - 43516 + - 43517 + - 43518 + - 43519 + - 43520 + - 43521 + - 43522 + - 43523 + - 43524 + - 43525 + - 43526 + - 43527 + - 43528 + - 43529 + - 43530 + - 43531 + - 43532 + - 43533 + - 43534 + - 43535 + - 43536 + - 43537 + - 43538 + - 43539 + - 43540 + - 43541 + - 43542 + - 43543 + - 43544 + - 43545 + - 43546 + - 43547 + - 43548 + - 43549 + - 43550 + - 43551 + - 43552 + - 43553 + - 43554 + - 43555 + - 43556 + - 43557 + - 43558 + - 43559 + - 43560 + - 43561 + - 43562 + - 43563 + - 43564 + - 43565 + - 43566 + - 43567 + - 43568 + - 43569 + - 43570 + - 43571 + - 43572 + - 43573 + - 43574 + - 43575 + - 43576 + - 43577 + - 43578 + - 43579 + - 43580 + - 43581 + - 43582 + - 43583 + - 43584 + - 43585 + - 43586 + - 43587 + - 43588 + - 43589 + - 43590 + - 43591 + - 43592 + - 43593 + - 43594 + - 43595 + - 43596 + - 43597 + - 43598 + - 43599 + - 43600 + - 43601 + - 43602 + - 43603 + - 43604 + - 43605 + - 43606 + - 43607 + - 43608 + - 43609 + - 43610 + - 43611 + - 43612 + - 43613 + - 43614 + - 43615 + - 43616 + - 43617 + - 43618 + - 43619 + - 43620 + - 43621 + - 43622 + - 43623 + - 43624 + - 43625 + - 43626 + - 43627 + - 43628 + - 43629 + - 43630 + - 43631 + - 43632 + - 43633 + - 43634 + - 43635 + - 43636 + - 43637 + - 43638 + - 43639 + - 43640 + - 43641 + - 43642 + - 43643 + - 43644 + - 43645 + - 43646 + - 43647 + - 43648 + - 43649 + - 43650 + - 43651 + - 43652 + - 43653 + - 43654 + - 43655 + - 43656 + - 43657 + - 43658 + - 43659 + - 43660 + - 43661 + - 43662 + - 43663 + - 43664 + - 43665 + - 43666 + - 43667 + - 43668 + - 43669 + - 43670 + - 43671 + - 43672 + - 43673 + - 43674 + - 43675 + - 43676 + - 43677 + - 43678 + - 43679 + - 43680 + - 43681 + - 43682 + - 43683 + - 43684 + - 43685 + - 43686 + - 43687 + - 43688 + - 43689 + - 43690 + - 43691 + - 43692 + - 43693 + - 43694 + - 43695 + - 43696 + - 43697 + - 43698 + - 43699 + - 43700 + - 43701 + - 43702 + - 43703 + - 43704 + - 43705 + - 43706 + - 43707 + - 43708 + - 43709 + - 43710 + - 43711 + - 43712 + - 43713 + - 43714 + - 43715 + - 43716 + - 43717 + - 43718 + - 43719 + - 43720 + - 43721 + - 43722 + - 43723 + - 43724 + - 43725 + - 43726 + - 43727 + - 43728 + - 43729 + - 43730 + - 43731 + - 43732 + - 43733 + - 43734 + - 43735 + - 43736 + - 43737 + - 43738 + - 43739 + - 43740 + - 43741 + - 43742 + - 43743 + - 43744 + - 43745 + - 43746 + - 43747 + - 43748 + - 43749 + - 43750 + - 43751 + - 43752 + - 43753 + - 43754 + - 43755 + - 43756 + - 43757 + - 43758 + - 43759 + - 43760 + - 43761 + - 43762 + - 43763 + - 43764 + - 43765 + - 43766 + - 43767 + - 43768 + - 43769 + - 43770 + - 43771 + - 43772 + - 43773 + - 43774 + - 43775 + - 43776 + - 43777 + - 43778 + - 43779 + - 43780 + - 43781 + - 43782 + - 43783 + - 43784 + - 43785 + - 43786 + - 43787 + - 43788 + - 43789 + - 43790 + - 43791 + - 43792 + - 43793 + - 43794 + - 43795 + - 43796 + - 43797 + - 43798 + - 43799 + - 43800 + - 43801 + - 43802 + - 43803 + - 43804 + - 43805 + - 43806 + - 43807 + - 43808 + - 43809 + - 43810 + - 43811 + - 43812 + - 43813 + - 43814 + - 43815 + - 43816 + - 43817 + - 43818 + - 43819 + - 43820 + - 43821 + - 43822 + - 43823 + - 43824 + - 43825 + - 43826 + - 43827 + - 43828 + - 43829 + - 43830 + - 43831 + - 43832 + - 43833 + - 43834 + - 43835 + - 43836 + - 43837 + - 43838 + - 43839 + - 43840 + - 43841 + - 43842 + - 43843 + - 43844 + - 43845 + - 43846 + - 43847 + - 43848 + - 43849 + - 43850 + - 43851 + - 43852 + - 43853 + - 43854 + - 43855 + - 43856 + - 43857 + - 43858 + - 43859 + - 43860 + - 43861 + - 43862 + - 43863 + - 43864 + - 43865 + - 43866 + - 43867 + - 43868 + - 43869 + - 43870 + - 43871 + - 43872 + - 43873 + - 43874 + - 43875 + - 43876 + - 43877 + - 43878 + - 43879 + - 43880 + - 43881 + - 43882 + - 43883 + - 43884 + - 43885 + - 43886 + - 43887 + - 43888 + - 43889 + - 43890 + - 43891 + - 43892 + - 43893 + - 43894 + - 43895 + - 43896 + - 43897 + - 43898 + - 43899 + - 43900 + - 43901 + - 43902 + - 43903 + - 43904 + - 43905 + - 43906 + - 43907 + - 43908 + - 43909 + - 43910 + - 43911 + - 43912 + - 43913 + - 43914 + - 43915 + - 43916 + - 43917 + - 43918 + - 43919 + - 43920 + - 43921 + - 43922 + - 43923 + - 43924 + - 43925 + - 43926 + - 43927 + - 43928 + - 43929 + - 43930 + - 43931 + - 43932 + - 43933 + - 43934 + - 43935 + - 43936 + - 43937 + - 43938 + - 43939 + - 43940 + - 43941 + - 43942 + - 43943 + - 43944 + - 43945 + - 43946 + - 43947 + - 43948 + - 43949 + - 43950 + - 43951 + - 43952 + - 43953 + - 43954 + - 43955 + - 43956 + - 43957 + - 43958 + - 43959 + - 43960 + - 43961 + - 43962 + - 43963 + - 43964 + - 43965 + - 43966 + - 43967 + - 43968 + - 43969 + - 43970 + - 43971 + - 43972 + - 43973 + - 43974 + - 43975 + - 43976 + - 43977 + - 43978 + - 43979 + - 43980 + - 43981 + - 43982 + - 43983 + - 43984 + - 43985 + - 43986 + - 43987 + - 43988 + - 43989 + - 43990 + - 43991 + - 43992 + - 43993 + - 43994 + - 43995 + - 43996 + - 43997 + - 43998 + - 43999 + - 44000 + - 44001 + - 44002 + - 44003 + - 44004 + - 44005 + - 44006 + - 44007 + - 44008 + - 44009 + - 44010 + - 44011 + - 44012 + - 44013 + - 44014 + - 44015 + - 44016 + - 44017 + - 44018 + - 44019 + - 44020 + - 44021 + - 44022 + - 44023 + - 44024 + - 44025 + - 44026 + - 44027 + - 44028 + - 44029 + - 44030 + - 44031 + - 44032 + - 44033 + - 44034 + - 44035 + - 44036 + - 44037 + - 44038 + - 44039 + - 44040 + - 44041 + - 44042 + - 44043 + - 44044 + - 44045 + - 44046 + - 44047 + - 44048 + - 44049 + - 44050 + - 44051 + - 44052 + - 44053 + - 44054 + - 44055 + - 44056 + - 44057 + - 44058 + - 44059 + - 44060 + - 44061 + - 44062 + - 44063 + - 44064 + - 44065 + - 44066 + - 44067 + - 44068 + - 44069 + - 44070 + - 44071 + - 44072 + - 44073 + - 44074 + - 44075 + - 44076 + - 44077 + - 44078 + - 44079 + - 44080 + - 44081 + - 44082 + - 44083 + - 44084 + - 44085 + - 44086 + - 44087 + - 44088 + - 44089 + - 44090 + - 44091 + - 44092 + - 44093 + - 44094 + - 44095 + - 44096 + - 44097 + - 44098 + - 44099 + - 44100 + - 44101 + - 44102 + - 44103 + - 44104 + - 44105 + - 44106 + - 44107 + - 44108 + - 44109 + - 44110 + - 44111 + - 44112 + - 44113 + - 44114 + - 44115 + - 44116 + - 44117 + - 44118 + - 44119 + - 44120 + - 44121 + - 44122 + - 44123 + - 44124 + - 44125 + - 44126 + - 44127 + - 44128 + - 44129 + - 44130 + - 44131 + - 44132 + - 44133 + - 44134 + - 44135 + - 44136 + - 44137 + - 44138 + - 44139 + - 44140 + - 44141 + - 44142 + - 44143 + - 44144 + - 44145 + - 44146 + - 44147 + - 44148 + - 44149 + - 44150 + - 44151 + - 44152 + - 44153 + - 44154 + - 44155 + - 44156 + - 44157 + - 44158 + - 44159 + - 44160 + - 44161 + - 44162 + - 44163 + - 44164 + - 44165 + - 44166 + - 44167 + - 44168 + - 44169 + - 44170 + - 44171 + - 44172 + - 44173 + - 44174 + - 44175 + - 44176 + - 44177 + - 44178 + - 44179 + - 44180 + - 44181 + - 44182 + - 44183 + - 44184 + - 44185 + - 44186 + - 44187 + - 44188 + - 44189 + - 44190 + - 44191 + - 44192 + - 44193 + - 44194 + - 44195 + - 44196 + - 44197 + - 44198 + - 44199 + - 44200 + - 44201 + - 44202 + - 44203 + - 44204 + - 44205 + - 44206 + - 44207 + - 44208 + - 44209 + - 44210 + - 44211 + - 44212 + - 44213 + - 44214 + - 44215 + - 44216 + - 44217 + - 44218 + - 44219 + - 44220 + - 44221 + - 44222 + - 44223 + - 44224 + - 44225 + - 44226 + - 44227 + - 44228 + - 44229 + - 44230 + - 44231 + - 44232 + - 44233 + - 44234 + - 44235 + - 44236 + - 44237 + - 44238 + - 44239 + - 44240 + - 44241 + - 44242 + - 44243 + - 44244 + - 44245 + - 44246 + - 44247 + - 44248 + - 44249 + - 44250 + - 44251 + - 44252 + - 44253 + - 44254 + - 44255 + - 44256 + - 44257 + - 44258 + - 44259 + - 44260 + - 44261 + - 44262 + - 44263 + - 44264 + - 44265 + - 44266 + - 44267 + - 44268 + - 44269 + - 44270 + - 44271 + - 44272 + - 44273 + - 44274 + - 44275 + - 44276 + - 44277 + - 44278 + - 44279 + - 44280 + - 44281 + - 44282 + - 44283 + - 44284 + - 44285 + - 44286 + - 44287 + - 44288 + - 44289 + - 44290 + - 44291 + - 44292 + - 44293 + - 44294 + - 44295 + - 44296 + - 44297 + - 44298 + - 44299 + - 44300 + - 44301 + - 44302 + - 44303 + - 44304 + - 44305 + - 44306 + - 44307 + - 44308 + - 44309 + - 44310 + - 44311 + - 44312 + - 44313 + - 44314 + - 44315 + - 44316 + - 44317 + - 44318 + - 44319 + - 44320 + - 44321 + - 44322 + - 44323 + - 44324 + - 44325 + - 44326 + - 44327 + - 44328 + - 44329 + - 44330 + - 44331 + - 44332 + - 44333 + - 44334 + - 44335 + - 44336 + - 44337 + - 44338 + - 44339 + - 44340 + - 44341 + - 44342 + - 44343 + - 44344 + - 44345 + - 44346 + - 44347 + - 44348 + - 44349 + - 44350 + - 44351 + - 44352 + - 44353 + - 44354 + - 44355 + - 44356 + - 44357 + - 44358 + - 44359 + - 44360 + - 44361 + - 44362 + - 44363 + - 44364 + - 44365 + - 44366 + - 44367 + - 44368 + - 44369 + - 44370 + - 44371 + - 44372 + - 44373 + - 44374 + - 44375 + - 44376 + - 44377 + - 44378 + - 44379 + - 44380 + - 44381 + - 44382 + - 44383 + - 44384 + - 44385 + - 44386 + - 44387 + - 44388 + - 44389 + - 44390 + - 44391 + - 44392 + - 44393 + - 44394 + - 44395 + - 44396 + - 44397 + - 44398 + - 44399 + - 44400 + - 44401 + - 44402 + - 44403 + - 44404 + - 44405 + - 44406 + - 44407 + - 44408 + - 44409 + - 44410 + - 44411 + - 44412 + - 44413 + - 44414 + - 44415 + - 44416 + - 44417 + - 44418 + - 44419 + - 44420 + - 44421 + - 44422 + - 44423 + - 44424 + - 44425 + - 44426 + - 44427 + - 44428 + - 44429 + - 44430 + - 44431 + - 44432 + - 44433 + - 44434 + - 44435 + - 44436 + - 44437 + - 44438 + - 44439 + - 44440 + - 44441 + - 44442 + - 44443 + - 44444 + - 44445 + - 44446 + - 44447 + - 44448 + - 44449 + - 44450 + - 44451 + - 44452 + - 44453 + - 44454 + - 44455 + - 44456 + - 44457 + - 44458 + - 44459 + - 44460 + - 44461 + - 44462 + - 44463 + - 44464 + - 44465 + - 44466 + - 44467 + - 44468 + - 44469 + - 44470 + - 44471 + - 44472 + - 44473 + - 44474 + - 44475 + - 44476 + - 44477 + - 44478 + - 44479 + - 44480 + - 44481 + - 44482 + - 44483 + - 44484 + - 44485 + - 44486 + - 44487 + - 44488 + - 44489 + - 44490 + - 44491 + - 44492 + - 44493 + - 44494 + - 44495 + - 44496 + - 44497 + - 44498 + - 44499 + - 44500 + - 44501 + - 44502 + - 44503 + - 44504 + - 44505 + - 44506 + - 44507 + - 44508 + - 44509 + - 44510 + - 44511 + - 44512 + - 44513 + - 44514 + - 44515 + - 44516 + - 44517 + - 44518 + - 44519 + - 44520 + - 44521 + - 44522 + - 44523 + - 44524 + - 44525 + - 44526 + - 44527 + - 44528 + - 44529 + - 44530 + - 44531 + - 44532 + - 44533 + - 44534 + - 44535 + - 44536 + - 44537 + - 44538 + - 44539 + - 44540 + - 44541 + - 44542 + - 44543 + - 44544 + - 44545 + - 44546 + - 44547 + - 44548 + - 44549 + - 44550 + - 44551 + - 44552 + - 44553 + - 44554 + - 44555 + - 44556 + - 44557 + - 44558 + - 44559 + - 44560 + - 44561 + - 44562 + - 44563 + - 44564 + - 44565 + - 44566 + - 44567 + - 44568 + - 44569 + - 44570 + - 44571 + - 44572 + - 44573 + - 44574 + - 44575 + - 44576 + - 44577 + - 44578 + - 44579 + - 44580 + - 44581 + - 44582 + - 44583 + - 44584 + - 44585 + - 44586 + - 44587 + - 44588 + - 44589 + - 44590 + - 44591 + - 44592 + - 44593 + - 44594 + - 44595 + - 44596 + - 44597 + - 44598 + - 44599 + - 44600 + - 44601 + - 44602 + - 44603 + - 44604 + - 44605 + - 44606 + - 44607 + - 44608 + - 44609 + - 44610 + - 44611 + - 44612 + - 44613 + - 44614 + - 44615 + - 44616 + - 44617 + - 44618 + - 44619 + - 44620 + - 44621 + - 44622 + - 44623 + - 44624 + - 44625 + - 44626 + - 44627 + - 44628 + - 44629 + - 44630 + - 44631 + - 44632 + - 44633 + - 44634 + - 44635 + - 44636 + - 44637 + - 44638 + - 44639 + - 44640 + - 44641 + - 44642 + - 44643 + - 44644 + - 44645 + - 44646 + - 44647 + - 44648 + - 44649 + - 44650 + - 44651 + - 44652 + - 44653 + - 44654 + - 44655 + - 44656 + - 44657 + - 44658 + - 44659 + - 44660 + - 44661 + - 44662 + - 44663 + - 44664 + - 44665 + - 44666 + - 44667 + - 44668 + - 44669 + - 44670 + - 44671 + - 44672 + - 44673 + - 44674 + - 44675 + - 44676 + - 44677 + - 44678 + - 44679 + - 44680 + - 44681 + - 44682 + - 44683 + - 44684 + - 44685 + - 44686 + - 44687 + - 44688 + - 44689 + - 44690 + - 44691 + - 44692 + - 44693 + - 44694 + - 44695 + - 44696 + - 44697 + - 44698 + - 44699 + - 44700 + - 44701 + - 44702 + - 44703 + - 44704 + - 44705 + - 44706 + - 44707 + - 44708 + - 44709 + - 44710 + - 44711 + - 44712 + - 44713 + - 44714 + - 44715 + - 44716 + - 44717 + - 44718 + - 44719 + - 44720 + - 44721 + - 44722 + - 44723 + - 44724 + - 44725 + - 44726 + - 44727 + - 44728 + - 44729 + - 44730 + - 44731 + - 44732 + - 44733 + - 44734 + - 44735 + - 44736 + - 44737 + - 44738 + - 44739 + - 44740 + - 44741 + - 44742 + - 44743 + - 44744 + - 44745 + - 44746 + - 44747 + - 44748 + - 44749 + - 44750 + - 44751 + - 44752 + - 44753 + - 44754 + - 44755 + - 44756 + - 44757 + - 44758 + - 44759 + - 44760 + - 44761 + - 44762 + - 44763 + - 44764 + - 44765 + - 44766 + - 44767 + - 44768 + - 44769 + - 44770 + - 44771 + - 44772 + - 44773 + - 44774 + - 44775 + - 44776 + - 44777 + - 44778 + - 44779 + - 44780 + - 44781 + - 44782 + - 44783 + - 44784 + - 44785 + - 44786 + - 44787 + - 44788 + - 44789 + - 44790 + - 44791 + - 44792 + - 44793 + - 44794 + - 44795 + - 44796 + - 44797 + - 44798 + - 44799 + - 44800 + - 44801 + - 44802 + - 44803 + - 44804 + - 44805 + - 44806 + - 44807 + - 44808 + - 44809 + - 44810 + - 44811 + - 44812 + - 44813 + - 44814 + - 44815 + - 44816 + - 44817 + - 44818 + - 44819 + - 44820 + - 44821 + - 44822 + - 44823 + - 44824 + - 44825 + - 44826 + - 44827 + - 44828 + - 44829 + - 44830 + - 44831 + - 44832 + - 44833 + - 44834 + - 44835 + - 44836 + - 44837 + - 44838 + - 44839 + - 44840 + - 44841 + - 44842 + - 44843 + - 44844 + - 44845 + - 44846 + - 44847 + - 44848 + - 44849 + - 44850 + - 44851 + - 44852 + - 44853 + - 44854 + - 44855 + - 44856 + - 44857 + - 44858 + - 44859 + - 44860 + - 44861 + - 44862 + - 44863 + - 44864 + - 44865 + - 44866 + - 44867 + - 44868 + - 44869 + - 44870 + - 44871 + - 44872 + - 44873 + - 44874 + - 44875 + - 44876 + - 44877 + - 44878 + - 44879 + - 44880 + - 44881 + - 44882 + - 44883 + - 44884 + - 44885 + - 44886 + - 44887 + - 44888 + - 44889 + - 44890 + - 44891 + - 44892 + - 44893 + - 44894 + - 44895 + - 44896 + - 44897 + - 44898 + - 44899 + - 44900 + - 44901 + - 44902 + - 44903 + - 44904 + - 44905 + - 44906 + - 44907 + - 44908 + - 44909 + - 44910 + - 44911 + - 44912 + - 44913 + - 44914 + - 44915 + - 44916 + - 44917 + - 44918 + - 44919 + - 44920 + - 44921 + - 44922 + - 44923 + - 44924 + - 44925 + - 44926 + - 44927 + - 44928 + - 44929 + - 44930 + - 44931 + - 44932 + - 44933 + - 44934 + - 44935 + - 44936 + - 44937 + - 44938 + - 44939 + - 44940 + - 44941 + - 44942 + - 44943 + - 44944 + - 44945 + - 44946 + - 44947 + - 44948 + - 44949 + - 44950 + - 44951 + - 44952 + - 44953 + - 44954 + - 44955 + - 44956 + - 44957 + - 44958 + - 44959 + - 44960 + - 44961 + - 44962 + - 44963 + - 44964 + - 44965 + - 44966 + - 44967 + - 44968 + - 44969 + - 44970 + - 44971 + - 44972 + - 44973 + - 44974 + - 44975 + - 44976 + - 44977 + - 44978 + - 44979 + - 44980 + - 44981 + - 44982 + - 44983 + - 44984 + - 44985 + - 44986 + - 44987 + - 44988 + - 44989 + - 44990 + - 44991 + - 44992 + - 44993 + - 44994 + - 44995 + - 44996 + - 44997 + - 44998 + - 44999 + - 45000 + - 45001 + - 45002 + - 45003 + - 45004 + - 45005 + - 45006 + - 45007 + - 45008 + - 45009 + - 45010 + - 45011 + - 45012 + - 45013 + - 45014 + - 45015 + - 45016 + - 45017 + - 45018 + - 45019 + - 45020 + - 45021 + - 45022 + - 45023 + - 45024 + - 45025 + - 45026 + - 45027 + - 45028 + - 45029 + - 45030 + - 45031 + - 45032 + - 45033 + - 45034 + - 45035 + - 45036 + - 45037 + - 45038 + - 45039 + - 45040 + - 45041 + - 45042 + - 45043 + - 45044 + - 45045 + - 45046 + - 45047 + - 45048 + - 45049 + - 45050 + - 45051 + - 45052 + - 45053 + - 45054 + - 45055 + - 45056 + - 45057 + - 45058 + - 45059 + - 45060 + - 45061 + - 45062 + - 45063 + - 45064 + - 45065 + - 45066 + - 45067 + - 45068 + - 45069 + - 45070 + - 45071 + - 45072 + - 45073 + - 45074 + - 45075 + - 45076 + - 45077 + - 45078 + - 45079 + - 45080 + - 45081 + - 45082 + - 45083 + - 45084 + - 45085 + - 45086 + - 45087 + - 45088 + - 45089 + - 45090 + - 45091 + - 45092 + - 45093 + - 45094 + - 45095 + - 45096 + - 45097 + - 45098 + - 45099 + - 45100 + - 45101 + - 45102 + - 45103 + - 45104 + - 45105 + - 45106 + - 45107 + - 45108 + - 45109 + - 45110 + - 45111 + - 45112 + - 45113 + - 45114 + - 45115 + - 45116 + - 45117 + - 45118 + - 45119 + - 45120 + - 45121 + - 45122 + - 45123 + - 45124 + - 45125 + - 45126 + - 45127 + - 45128 + - 45129 + - 45130 + - 45131 + - 45132 + - 45133 + - 45134 + - 45135 + - 45136 + - 45137 + - 45138 + - 45139 + - 45140 + - 45141 + - 45142 + - 45143 + - 45144 + - 45145 + - 45146 + - 45147 + - 45148 + - 45149 + - 45150 + - 45151 + - 45152 + - 45153 + - 45154 + - 45155 + - 45156 + - 45157 + - 45158 + - 45159 + - 45160 + - 45161 + - 45162 + - 45163 + - 45164 + - 45165 + - 45166 + - 45167 + - 45168 + - 45169 + - 45170 + - 45171 + - 45172 + - 45173 + - 45174 + - 45175 + - 45176 + - 45177 + - 45178 + - 45179 + - 45180 + - 45181 + - 45182 + - 45183 + - 45184 + - 45185 + - 45186 + - 45187 + - 45188 + - 45189 + - 45190 + - 45191 + - 45192 + - 45193 + - 45194 + - 45195 + - 45196 + - 45197 + - 45198 + - 45199 + - 45200 + - 45201 + - 45202 + - 45203 + - 45204 + - 45205 + - 45206 + - 45207 + - 45208 + - 45209 + - 45210 + - 45211 + - 45212 + - 45213 + - 45214 + - 45215 + - 45216 + - 45217 + - 45218 + - 45219 + - 45220 + - 45221 + - 45222 + - 45223 + - 45224 + - 45225 + - 45226 + - 45227 + - 45228 + - 45229 + - 45230 + - 45231 + - 45232 + - 45233 + - 45234 + - 45235 + - 45236 + - 45237 + - 45238 + - 45239 + - 45240 + - 45241 + - 45242 + - 45243 + - 45244 + - 45245 + - 45246 + - 45247 + - 45248 + - 45249 + - 45250 + - 45251 + - 45252 + - 45253 + - 45254 + - 45255 + - 45256 + - 45257 + - 45258 + - 45259 + - 45260 + - 45261 + - 45262 + - 45263 + - 45264 + - 45265 + - 45266 + - 45267 + - 45268 + - 45269 + - 45270 + - 45271 + - 45272 + - 45273 + - 45274 + - 45275 + - 45276 + - 45277 + - 45278 + - 45279 + - 45280 + - 45281 + - 45282 + - 45283 + - 45284 + - 45285 + - 45286 + - 45287 + - 45288 + - 45289 + - 45290 + - 45291 + - 45292 + - 45293 + - 45294 + - 45295 + - 45296 + - 45297 + - 45298 + - 45299 + - 45300 + - 45301 + - 45302 + - 45303 + - 45304 + - 45305 + - 45306 + - 45307 + - 45308 + - 45309 + - 45310 + - 45311 + - 45312 + - 45313 + - 45314 + - 45315 + - 45316 + - 45317 + - 45318 + - 45319 + - 45320 + - 45321 + - 45322 + - 45323 + - 45324 + - 45325 + - 45326 + - 45327 + - 45328 + - 45329 + - 45330 + - 45331 + - 45332 + - 45333 + - 45334 + - 45335 + - 45336 + - 45337 + - 45338 + - 45339 + - 45340 + - 45341 + - 45342 + - 45343 + - 45344 + - 45345 + - 45346 + - 45347 + - 45348 + - 45349 + - 45350 + - 45351 + - 45352 + - 45353 + - 45354 + - 45355 + - 45356 + - 45357 + - 45358 + - 45359 + - 45360 + - 45361 + - 45362 + - 45363 + - 45364 + - 45365 + - 45366 + - 45367 + - 45368 + - 45369 + - 45370 + - 45371 + - 45372 + - 45373 + - 45374 + - 45375 + - 45376 + - 45377 + - 45378 + - 45379 + - 45380 + - 45381 + - 45382 + - 45383 + - 45384 + - 45385 + - 45386 + - 45387 + - 45388 + - 45389 + - 45390 + - 45391 + - 45392 + - 45393 + - 45394 + - 45395 + - 45396 + - 45397 + - 45398 + - 45399 + - 45400 + - 45401 + - 45402 + - 45403 + - 45404 + - 45405 + - 45406 + - 45407 + - 45408 + - 45409 + - 45410 + - 45411 + - 45412 + - 45413 + - 45414 + - 45415 + - 45416 + - 45417 + - 45418 + - 45419 + - 45420 + - 45421 + - 45422 + - 45423 + - 45424 + - 45425 + - 45426 + - 45427 + - 45428 + - 45429 + - 45430 + - 45431 + - 45432 + - 45433 + - 45434 + - 45435 + - 45436 + - 45437 + - 45438 + - 45439 + - 45440 + - 45441 + - 45442 + - 45443 + - 45444 + - 45445 + - 45446 + - 45447 + - 45448 + - 45449 + - 45450 + - 45451 + - 45452 + - 45453 + - 45454 + - 45455 + - 45456 + - 45457 + - 45458 + - 45459 + - 45460 + - 45461 + - 45462 + - 45463 + - 45464 + - 45465 + - 45466 + - 45467 + - 45468 + - 45469 + - 45470 + - 45471 + - 45472 + - 45473 + - 45474 + - 45475 + - 45476 + - 45477 + - 45478 + - 45479 + - 45480 + - 45481 + - 45482 + - 45483 + - 45484 + - 45485 + - 45486 + - 45487 + - 45488 + - 45489 + - 45490 + - 45491 + - 45492 + - 45493 + - 45494 + - 45495 + - 45496 + - 45497 + - 45498 + - 45499 + - 45500 + - 45501 + - 45502 + - 45503 + - 45504 + - 45505 + - 45506 + - 45507 + - 45508 + - 45509 + - 45510 + - 45511 + - 45512 + - 45513 + - 45514 + - 45515 + - 45516 + - 45517 + - 45518 + - 45519 + - 45520 + - 45521 + - 45522 + - 45523 + - 45524 + - 45525 + - 45526 + - 45527 + - 45528 + - 45529 + - 45530 + - 45531 + - 45532 + - 45533 + - 45534 + - 45535 + - 45536 + - 45537 + - 45538 + - 45539 + - 45540 + - 45541 + - 45542 + - 45543 + - 45544 + - 45545 + - 45546 + - 45547 + - 45548 + - 45549 + - 45550 + - 45551 + - 45552 + - 45553 + - 45554 + - 45555 + - 45556 + - 45557 + - 45558 + - 45559 + - 45560 + - 45561 + - 45562 + - 45563 + - 45564 + - 45565 + - 45566 + - 45567 + - 45568 + - 45569 + - 45570 + - 45571 + - 45572 + - 45573 + - 45574 + - 45575 + - 45576 + - 45577 + - 45578 + - 45579 + - 45580 + - 45581 + - 45582 + - 45583 + - 45584 + - 45585 + - 45586 + - 45587 + - 45588 + - 45589 + - 45590 + - 45591 + - 45592 + - 45593 + - 45594 + - 45595 + - 45596 + - 45597 + - 45598 + - 45599 + - 45600 + - 45601 + - 45602 + - 45603 + - 45604 + - 45605 + - 45606 + - 45607 + - 45608 + - 45609 + - 45610 + - 45611 + - 45612 + - 45613 + - 45614 + - 45615 + - 45616 + - 45617 + - 45618 + - 45619 + - 45620 + - 45621 + - 45622 + - 45623 + - 45624 + - 45625 + - 45626 + - 45627 + - 45628 + - 45629 + - 45630 + - 45631 + - 45632 + - 45633 + - 45634 + - 45635 + - 45636 + - 45637 + - 45638 + - 45639 + - 45640 + - 45641 + - 45642 + - 45643 + - 45644 + - 45645 + - 45646 + - 45647 + - 45648 + - 45649 + - 45650 + - 45651 + - 45652 + - 45653 + - 45654 + - 45655 + - 45656 + - 45657 + - 45658 + - 45659 + - 45660 + - 45661 + - 45662 + - 45663 + - 45664 + - 45665 + - 45666 + - 45667 + - 45668 + - 45669 + - 45670 + - 45671 + - 45672 + - 45673 + - 45674 + - 45675 + - 45676 + - 45677 + - 45678 + - 45679 + - 45680 + - 45681 + - 45682 + - 45683 + - 45684 + - 45685 + - 45686 + - 45687 + - 45688 + - 45689 + - 45690 + - 45691 + - 45692 + - 45693 + - 45694 + - 45695 + - 45696 + - 45697 + - 45698 + - 45699 + - 45700 + - 45701 + - 45702 + - 45703 + - 45704 + - 45705 + - 45706 + - 45707 + - 45708 + - 45709 + - 45710 + - 45711 + - 45712 + - 45713 + - 45714 + - 45715 + - 45716 + - 45717 + - 45718 + - 45719 + - 45720 + - 45721 + - 45722 + - 45723 + - 45724 + - 45725 + - 45726 + - 45727 + - 45728 + - 45729 + - 45730 + - 45731 + - 45732 + - 45733 + - 45734 + - 45735 + - 45736 + - 45737 + - 45738 + - 45739 + - 45740 + - 45741 + - 45742 + - 45743 + - 45744 + - 45745 + - 45746 + - 45747 + - 45748 + - 45749 + - 45750 + - 45751 + - 45752 + - 45753 + - 45754 + - 45755 + - 45756 + - 45757 + - 45758 + - 45759 + - 45760 + - 45761 + - 45762 + - 45763 + - 45764 + - 45765 + - 45766 + - 45767 + - 45768 + - 45769 + - 45770 + - 45771 + - 45772 + - 45773 + - 45774 + - 45775 + - 45776 + - 45777 + - 45778 + - 45779 + - 45780 + - 45781 + - 45782 + - 45783 + - 45784 + - 45785 + - 45786 + - 45787 + - 45788 + - 45789 + - 45790 + - 45791 + - 45792 + - 45793 + - 45794 + - 45795 + - 45796 + - 45797 + - 45798 + - 45799 + - 45800 + - 45801 + - 45802 + - 45803 + - 45804 + - 45805 + - 45806 + - 45807 + - 45808 + - 45809 + - 45810 + - 45811 + - 45812 + - 45813 + - 45814 + - 45815 + - 45816 + - 45817 + - 45818 + - 45819 + - 45820 + - 45821 + - 45822 + - 45823 + - 45824 + - 45825 + - 45826 + - 45827 + - 45828 + - 45829 + - 45830 + - 45831 + - 45832 + - 45833 + - 45834 + - 45835 + - 45836 + - 45837 + - 45838 + - 45839 + - 45840 + - 45841 + - 45842 + - 45843 + - 45844 + - 45845 + - 45846 + - 45847 + - 45848 + - 45849 + - 45850 + - 45851 + - 45852 + - 45853 + - 45854 + - 45855 + - 45856 + - 45857 + - 45858 + - 45859 + - 45860 + - 45861 + - 45862 + - 45863 + - 45864 + - 45865 + - 45866 + - 45867 + - 45868 + - 45869 + - 45870 + - 45871 + - 45872 + - 45873 + - 45874 + - 45875 + - 45876 + - 45877 + - 45878 + - 45879 + - 45880 + - 45881 + - 45882 + - 45883 + - 45884 + - 45885 + - 45886 + - 45887 + - 45888 + - 45889 + - 45890 + - 45891 + - 45892 + - 45893 + - 45894 + - 45895 + - 45896 + - 45897 + - 45898 + - 45899 + - 45900 + - 45901 + - 45902 + - 45903 + - 45904 + - 45905 + - 45906 + - 45907 + - 45908 + - 45909 + - 45910 + - 45911 + - 45912 + - 45913 + - 45914 + - 45915 + - 45916 + - 45917 + - 45918 + - 45919 + - 45920 + - 45921 + - 45922 + - 45923 + - 45924 + - 45925 + - 45926 + - 45927 + - 45928 + - 45929 + - 45930 + - 45931 + - 45932 + - 45933 + - 45934 + - 45935 + - 45936 + - 45937 + - 45938 + - 45939 + - 45940 + - 45941 + - 45942 + - 45943 + - 45944 + - 45945 + - 45946 + - 45947 + - 45948 + - 45949 + - 45950 + - 45951 + - 45952 + - 45953 + - 45954 + - 45955 + - 45956 + - 45957 + - 45958 + - 45959 + - 45960 + - 45961 + - 45962 + - 45963 + - 45964 + - 45965 + - 45966 + - 45967 + - 45968 + - 45969 + - 45970 + - 45971 + - 45972 + - 45973 + - 45974 + - 45975 + - 45976 + - 45977 + - 45978 + - 45979 + - 45980 + - 45981 + - 45982 + - 45983 + - 45984 + - 45985 + - 45986 + - 45987 + - 45988 + - 45989 + - 45990 + - 45991 + - 45992 + - 45993 + - 45994 + - 45995 + - 45996 + - 45997 + - 45998 + - 45999 + - 46000 + - 46001 + - 46002 + - 46003 + - 46004 + - 46005 + - 46006 + - 46007 + - 46008 + - 46009 + - 46010 + - 46011 + - 46012 + - 46013 + - 46014 + - 46015 + - 46016 + - 46017 + - 46018 + - 46019 + - 46020 + - 46021 + - 46022 + - 46023 + - 46024 + - 46025 + - 46026 + - 46027 + - 46028 + - 46029 + - 46030 + - 46031 + - 46032 + - 46033 + - 46034 + - 46035 + - 46036 + - 46037 + - 46038 + - 46039 + - 46040 + - 46041 + - 46042 + - 46043 + - 46044 + - 46045 + - 46046 + - 46047 + - 46048 + - 46049 + - 46050 + - 46051 + - 46052 + - 46053 + - 46054 + - 46055 + - 46056 + - 46057 + - 46058 + - 46059 + - 46060 + - 46061 + - 46062 + - 46063 + - 46064 + - 46065 + - 46066 + - 46067 + - 46068 + - 46069 + - 46070 + - 46071 + - 46072 + - 46073 + - 46074 + - 46075 + - 46076 + - 46077 + - 46078 + - 46079 + - 46080 + - 46081 + - 46082 + - 46083 + - 46084 + - 46085 + - 46086 + - 46087 + - 46088 + - 46089 + - 46090 + - 46091 + - 46092 + - 46093 + - 46094 + - 46095 + - 46096 + - 46097 + - 46098 + - 46099 + - 46100 + - 46101 + - 46102 + - 46103 + - 46104 + - 46105 + - 46106 + - 46107 + - 46108 + - 46109 + - 46110 + - 46111 + - 46112 + - 46113 + - 46114 + - 46115 + - 46116 + - 46117 + - 46118 + - 46119 + - 46120 + - 46121 + - 46122 + - 46123 + - 46124 + - 46125 + - 46126 + - 46127 + - 46128 + - 46129 + - 46130 + - 46131 + - 46132 + - 46133 + - 46134 + - 46135 + - 46136 + - 46137 + - 46138 + - 46139 + - 46140 + - 46141 + - 46142 + - 46143 + - 46144 + - 46145 + - 46146 + - 46147 + - 46148 + - 46149 + - 46150 + - 46151 + - 46152 + - 46153 + - 46154 + - 46155 + - 46156 + - 46157 + - 46158 + - 46159 + - 46160 + - 46161 + - 46162 + - 46163 + - 46164 + - 46165 + - 46166 + - 46167 + - 46168 + - 46169 + - 46170 + - 46171 + - 46172 + - 46173 + - 46174 + - 46175 + - 46176 + - 46177 + - 46178 + - 46179 + - 46180 + - 46181 + - 46182 + - 46183 + - 46184 + - 46185 + - 46186 + - 46187 + - 46188 + - 46189 + - 46190 + - 46191 + - 46192 + - 46193 + - 46194 + - 46195 + - 46196 + - 46197 + - 46198 + - 46199 + - 46200 + - 46201 + - 46202 + - 46203 + - 46204 + - 46205 + - 46206 + - 46207 + - 46208 + - 46209 + - 46210 + - 46211 + - 46212 + - 46213 + - 46214 + - 46215 + - 46216 + - 46217 + - 46218 + - 46219 + - 46220 + - 46221 + - 46222 + - 46223 + - 46224 + - 46225 + - 46226 + - 46227 + - 46228 + - 46229 + - 46230 + - 46231 + - 46232 + - 46233 + - 46234 + - 46235 + - 46236 + - 46237 + - 46238 + - 46239 + - 46240 + - 46241 + - 46242 + - 46243 + - 46244 + - 46245 + - 46246 + - 46247 + - 46248 + - 46249 + - 46250 + - 46251 + - 46252 + - 46253 + - 46254 + - 46255 + - 46256 + - 46257 + - 46258 + - 46259 + - 46260 + - 46261 + - 46262 + - 46263 + - 46264 + - 46265 + - 46266 + - 46267 + - 46268 + - 46269 + - 46270 + - 46271 + - 46272 + - 46273 + - 46274 + - 46275 + - 46276 + - 46277 + - 46278 + - 46279 + - 46280 + - 46281 + - 46282 + - 46283 + - 46284 + - 46285 + - 46286 + - 46287 + - 46288 + - 46289 + - 46290 + - 46291 + - 46292 + - 46293 + - 46294 + - 46295 + - 46296 + - 46297 + - 46298 + - 46299 + - 46300 + - 46301 + - 46302 + - 46303 + - 46304 + - 46305 + - 46306 + - 46307 + - 46308 + - 46309 + - 46310 + - 46311 + - 46312 + - 46313 + - 46314 + - 46315 + - 46316 + - 46317 + - 46318 + - 46319 + - 46320 + - 46321 + - 46322 + - 46323 + - 46324 + - 46325 + - 46326 + - 46327 + - 46328 + - 46329 + - 46330 + - 46331 + - 46332 + - 46333 + - 46334 + - 46335 + - 46336 + - 46337 + - 46338 + - 46339 + - 46340 + - 46341 + - 46342 + - 46343 + - 46344 + - 46345 + - 46346 + - 46347 + - 46348 + - 46349 + - 46350 + - 46351 + - 46352 + - 46353 + - 46354 + - 46355 + - 46356 + - 46357 + - 46358 + - 46359 + - 46360 + - 46361 + - 46362 + - 46363 + - 46364 + - 46365 + - 46366 + - 46367 + - 46368 + - 46369 + - 46370 + - 46371 + - 46372 + - 46373 + - 46374 + - 46375 + - 46376 + - 46377 + - 46378 + - 46379 + - 46380 + - 46381 + - 46382 + - 46383 + - 46384 + - 46385 + - 46386 + - 46387 + - 46388 + - 46389 + - 46390 + - 46391 + - 46392 + - 46393 + - 46394 + - 46395 + - 46396 + - 46397 + - 46398 + - 46399 + - 46400 + - 46401 + - 46402 + - 46403 + - 46404 + - 46405 + - 46406 + - 46407 + - 46408 + - 46409 + - 46410 + - 46411 + - 46412 + - 46413 + - 46414 + - 46415 + - 46416 + - 46417 + - 46418 + - 46419 + - 46420 + - 46421 + - 46422 + - 46423 + - 46424 + - 46425 + - 46426 + - 46427 + - 46428 + - 46429 + - 46430 + - 46431 + - 46432 + - 46433 + - 46434 + - 46435 + - 46436 + - 46437 + - 46438 + - 46439 + - 46440 + - 46441 + - 46442 + - 46443 + - 46444 + - 46445 + - 46446 + - 46447 + - 46448 + - 46449 + - 46450 + - 46451 + - 46452 + - 46453 + - 46454 + - 46455 + - 46456 + - 46457 + - 46458 + - 46459 + - 46460 + - 46461 + - 46462 + - 46463 + - 46464 + - 46465 + - 46466 + - 46467 + - 46468 + - 46469 + - 46470 + - 46471 + - 46472 + - 46473 + - 46474 + - 46475 + - 46476 + - 46477 + - 46478 + - 46479 + - 46480 + - 46481 + - 46482 + - 46483 + - 46484 + - 46485 + - 46486 + - 46487 + - 46488 + - 46489 + - 46490 + - 46491 + - 46492 + - 46493 + - 46494 + - 46495 + - 46496 + - 46497 + - 46498 + - 46499 + - 46500 + - 46501 + - 46502 + - 46503 + - 46504 + - 46505 + - 46506 + - 46507 + - 46508 + - 46509 + - 46510 + - 46511 + - 46512 + - 46513 + - 46514 + - 46515 + - 46516 + - 46517 + - 46518 + - 46519 + - 46520 + - 46521 + - 46522 + - 46523 + - 46524 + - 46525 + - 46526 + - 46527 + - 46528 + - 46529 + - 46530 + - 46531 + - 46532 + - 46533 + - 46534 + - 46535 + - 46536 + - 46537 + - 46538 + - 46539 + - 46540 + - 46541 + - 46542 + - 46543 + - 46544 + - 46545 + - 46546 + - 46547 + - 46548 + - 46549 + - 46550 + - 46551 + - 46552 + - 46553 + - 46554 + - 46555 + - 46556 + - 46557 + - 46558 + - 46559 + - 46560 + - 46561 + - 46562 + - 46563 + - 46564 + - 46565 + - 46566 + - 46567 + - 46568 + - 46569 + - 46570 + - 46571 + - 46572 + - 46573 + - 46574 + - 46575 + - 46576 + - 46577 + - 46578 + - 46579 + - 46580 + - 46581 + - 46582 + - 46583 + - 46584 + - 46585 + - 46586 + - 46587 + - 46588 + - 46589 + - 46590 + - 46591 + - 46592 + - 46593 + - 46594 + - 46595 + - 46596 + - 46597 + - 46598 + - 46599 + - 46600 + - 46601 + - 46602 + - 46603 + - 46604 + - 46605 + - 46606 + - 46607 + - 46608 + - 46609 + - 46610 + - 46611 + - 46612 + - 46613 + - 46614 + - 46615 + - 46616 + - 46617 + - 46618 + - 46619 + - 46620 + - 46621 + - 46622 + - 46623 + - 46624 + - 46625 + - 46626 + - 46627 + - 46628 + - 46629 + - 46630 + - 46631 + - 46632 + - 46633 + - 46634 + - 46635 + - 46636 + - 46637 + - 46638 + - 46639 + - 46640 + - 46641 + - 46642 + - 46643 + - 46644 + - 46645 + - 46646 + - 46647 + - 46648 + - 46649 + - 46650 + - 46651 + - 46652 + - 46653 + - 46654 + - 46655 + - 46656 + - 46657 + - 46658 + - 46659 + - 46660 + - 46661 + - 46662 + - 46663 + - 46664 + - 46665 + - 46666 + - 46667 + - 46668 + - 46669 + - 46670 + - 46671 + - 46672 + - 46673 + - 46674 + - 46675 + - 46676 + - 46677 + - 46678 + - 46679 + - 46680 + - 46681 + - 46682 + - 46683 + - 46684 + - 46685 + - 46686 + - 46687 + - 46688 + - 46689 + - 46690 + - 46691 + - 46692 + - 46693 + - 46694 + - 46695 + - 46696 + - 46697 + - 46698 + - 46699 + - 46700 + - 46701 + - 46702 + - 46703 + - 46704 + - 46705 + - 46706 + - 46707 + - 46708 + - 46709 + - 46710 + - 46711 + - 46712 + - 46713 + - 46714 + - 46715 + - 46716 + - 46717 + - 46718 + - 46719 + - 46720 + - 46721 + - 46722 + - 46723 + - 46724 + - 46725 + - 46726 + - 46727 + - 46728 + - 46729 + - 46730 + - 46731 + - 46732 + - 46733 + - 46734 + - 46735 + - 46736 + - 46737 + - 46738 + - 46739 + - 46740 + - 46741 + - 46742 + - 46743 + - 46744 + - 46745 + - 46746 + - 46747 + - 46748 + - 46749 + - 46750 + - 46751 + - 46752 + - 46753 + - 46754 + - 46755 + - 46756 + - 46757 + - 46758 + - 46759 + - 46760 + - 46761 + - 46762 + - 46763 + - 46764 + - 46765 + - 46766 + - 46767 + - 46768 + - 46769 + - 46770 + - 46771 + - 46772 + - 46773 + - 46774 + - 46775 + - 46776 + - 46777 + - 46778 + - 46779 + - 46780 + - 46781 + - 46782 + - 46783 + - 46784 + - 46785 + - 46786 + - 46787 + - 46788 + - 46789 + - 46790 + - 46791 + - 46792 + - 46793 + - 46794 + - 46795 + - 46796 + - 46797 + - 46798 + - 46799 + - 46800 + - 46801 + - 46802 + - 46803 + - 46804 + - 46805 + - 46806 + - 46807 + - 46808 + - 46809 + - 46810 + - 46811 + - 46812 + - 46813 + - 46814 + - 46815 + - 46816 + - 46817 + - 46818 + - 46819 + - 46820 + - 46821 + - 46822 + - 46823 + - 46824 + - 46825 + - 46826 + - 46827 + - 46828 + - 46829 + - 46830 + - 46831 + - 46832 + - 46833 + - 46834 + - 46835 + - 46836 + - 46837 + - 46838 + - 46839 + - 46840 + - 46841 + - 46842 + - 46843 + - 46844 + - 46845 + - 46846 + - 46847 + - 46848 + - 46849 + - 46850 + - 46851 + - 46852 + - 46853 + - 46854 + - 46855 + - 46856 + - 46857 + - 46858 + - 46859 + - 46860 + - 46861 + - 46862 + - 46863 + - 46864 + - 46865 + - 46866 + - 46867 + - 46868 + - 46869 + - 46870 + - 46871 + - 46872 + - 46873 + - 46874 + - 46875 + - 46876 + - 46877 + - 46878 + - 46879 + - 46880 + - 46881 + - 46882 + - 46883 + - 46884 + - 46885 + - 46886 + - 46887 + - 46888 + - 46889 + - 46890 + - 46891 + - 46892 + - 46893 + - 46894 + - 46895 + - 46896 + - 46897 + - 46898 + - 46899 + - 46900 + - 46901 + - 46902 + - 46903 + - 46904 + - 46905 + - 46906 + - 46907 + - 46908 + - 46909 + - 46910 + - 46911 + - 46912 + - 46913 + - 46914 + - 46915 + - 46916 + - 46917 + - 46918 + - 46919 + - 46920 + - 46921 + - 46922 + - 46923 + - 46924 + - 46925 + - 46926 + - 46927 + - 46928 + - 46929 + - 46930 + - 46931 + - 46932 + - 46933 + - 46934 + - 46935 + - 46936 + - 46937 + - 46938 + - 46939 + - 46940 + - 46941 + - 46942 + - 46943 + - 46944 + - 46945 + - 46946 + - 46947 + - 46948 + - 46949 + - 46950 + - 46951 + - 46952 + - 46953 + - 46954 + - 46955 + - 46956 + - 46957 + - 46958 + - 46959 + - 46960 + - 46961 + - 46962 + - 46963 + - 46964 + - 46965 + - 46966 + - 46967 + - 46968 + - 46969 + - 46970 + - 46971 + - 46972 + - 46973 + - 46974 + - 46975 + - 46976 + - 46977 + - 46978 + - 46979 + - 46980 + - 46981 + - 46982 + - 46983 + - 46984 + - 46985 + - 46986 + - 46987 + - 46988 + - 46989 + - 46990 + - 46991 + - 46992 + - 46993 + - 46994 + - 46995 + - 46996 + - 46997 + - 46998 + - 46999 + - 47000 + - 47001 + - 47002 + - 47003 + - 47004 + - 47005 + - 47006 + - 47007 + - 47008 + - 47009 + - 47010 + - 47011 + - 47012 + - 47013 + - 47014 + - 47015 + - 47016 + - 47017 + - 47018 + - 47019 + - 47020 + - 47021 + - 47022 + - 47023 + - 47024 + - 47025 + - 47026 + - 47027 + - 47028 + - 47029 + - 47030 + - 47031 + - 47032 + - 47033 + - 47034 + - 47035 + - 47036 + - 47037 + - 47038 + - 47039 + - 47040 + - 47041 + - 47042 + - 47043 + - 47044 + - 47045 + - 47046 + - 47047 + - 47048 + - 47049 + - 47050 + - 47051 + - 47052 + - 47053 + - 47054 + - 47055 + - 47056 + - 47057 + - 47058 + - 47059 + - 47060 + - 47061 + - 47062 + - 47063 + - 47064 + - 47065 + - 47066 + - 47067 + - 47068 + - 47069 + - 47070 + - 47071 + - 47072 + - 47073 + - 47074 + - 47075 + - 47076 + - 47077 + - 47078 + - 47079 + - 47080 + - 47081 + - 47082 + - 47083 + - 47084 + - 47085 + - 47086 + - 47087 + - 47088 + - 47089 + - 47090 + - 47091 + - 47092 + - 47093 + - 47094 + - 47095 + - 47096 + - 47097 + - 47098 + - 47099 + - 47100 + - 47101 + - 47102 + - 47103 + - 47104 + - 47105 + - 47106 + - 47107 + - 47108 + - 47109 + - 47110 + - 47111 + - 47112 + - 47113 + - 47114 + - 47115 + - 47116 + - 47117 + - 47118 + - 47119 + - 47120 + - 47121 + - 47122 + - 47123 + - 47124 + - 47125 + - 47126 + - 47127 + - 47128 + - 47129 + - 47130 + - 47131 + - 47132 + - 47133 + - 47134 + - 47135 + - 47136 + - 47137 + - 47138 + - 47139 + - 47140 + - 47141 + - 47142 + - 47143 + - 47144 + - 47145 + - 47146 + - 47147 + - 47148 + - 47149 + - 47150 + - 47151 + - 47152 + - 47153 + - 47154 + - 47155 + - 47156 + - 47157 + - 47158 + - 47159 + - 47160 + - 47161 + - 47162 + - 47163 + - 47164 + - 47165 + - 47166 + - 47167 + - 47168 + - 47169 + - 47170 + - 47171 + - 47172 + - 47173 + - 47174 + - 47175 + - 47176 + - 47177 + - 47178 + - 47179 + - 47180 + - 47181 + - 47182 + - 47183 + - 47184 + - 47185 + - 47186 + - 47187 + - 47188 + - 47189 + - 47190 + - 47191 + - 47192 + - 47193 + - 47194 + - 47195 + - 47196 + - 47197 + - 47198 + - 47199 + - 47200 + - 47201 + - 47202 + - 47203 + - 47204 + - 47205 + - 47206 + - 47207 + - 47208 + - 47209 + - 47210 + - 47211 + - 47212 + - 47213 + - 47214 + - 47215 + - 47216 + - 47217 + - 47218 + - 47219 + - 47220 + - 47221 + - 47222 + - 47223 + - 47224 + - 47225 + - 47226 + - 47227 + - 47228 + - 47229 + - 47230 + - 47231 + - 47232 + - 47233 + - 47234 + - 47235 + - 47236 + - 47237 + - 47238 + - 47239 + - 47240 + - 47241 + - 47242 + - 47243 + - 47244 + - 47245 + - 47246 + - 47247 + - 47248 + - 47249 + - 47250 + - 47251 + - 47252 + - 47253 + - 47254 + - 47255 + - 47256 + - 47257 + - 47258 + - 47259 + - 47260 + - 47261 + - 47262 + - 47263 + - 47264 + - 47265 + - 47266 + - 47267 + - 47268 + - 47269 + - 47270 + - 47271 + - 47272 + - 47273 + - 47274 + - 47275 + - 47276 + - 47277 + - 47278 + - 47279 + - 47280 + - 47281 + - 47282 + - 47283 + - 47284 + - 47285 + - 47286 + - 47287 + - 47288 + - 47289 + - 47290 + - 47291 + - 47292 + - 47293 + - 47294 + - 47295 + - 47296 + - 47297 + - 47298 + - 47299 + - 47300 + - 47301 + - 47302 + - 47303 + - 47304 + - 47305 + - 47306 + - 47307 + - 47308 + - 47309 + - 47310 + - 47311 + - 47312 + - 47313 + - 47314 + - 47315 + - 47316 + - 47317 + - 47318 + - 47319 + - 47320 + - 47321 + - 47322 + - 47323 + - 47324 + - 47325 + - 47326 + - 47327 + - 47328 + - 47329 + - 47330 + - 47331 + - 47332 + - 47333 + - 47334 + - 47335 + - 47336 + - 47337 + - 47338 + - 47339 + - 47340 + - 47341 + - 47342 + - 47343 + - 47344 + - 47345 + - 47346 + - 47347 + - 47348 + - 47349 + - 47350 + - 47351 + - 47352 + - 47353 + - 47354 + - 47355 + - 47356 + - 47357 + - 47358 + - 47359 + - 47360 + - 47361 + - 47362 + - 47363 + - 47364 + - 47365 + - 47366 + - 47367 + - 47368 + - 47369 + - 47370 + - 47371 + - 47372 + - 47373 + - 47374 + - 47375 + - 47376 + - 47377 + - 47378 + - 47379 + - 47380 + - 47381 + - 47382 + - 47383 + - 47384 + - 47385 + - 47386 + - 47387 + - 47388 + - 47389 + - 47390 + - 47391 + - 47392 + - 47393 + - 47394 + - 47395 + - 47396 + - 47397 + - 47398 + - 47399 + - 47400 + - 47401 + - 47402 + - 47403 + - 47404 + - 47405 + - 47406 + - 47407 + - 47408 + - 47409 + - 47410 + - 47411 + - 47412 + - 47413 + - 47414 + - 47415 + - 47416 + - 47417 + - 47418 + - 47419 + - 47420 + - 47421 + - 47422 + - 47423 + - 47424 + - 47425 + - 47426 + - 47427 + - 47428 + - 47429 + - 47430 + - 47431 + - 47432 + - 47433 + - 47434 + - 47435 + - 47436 + - 47437 + - 47438 + - 47439 + - 47440 + - 47441 + - 47442 + - 47443 + - 47444 + - 47445 + - 47446 + - 47447 + - 47448 + - 47449 + - 47450 + - 47451 + - 47452 + - 47453 + - 47454 + - 47455 + - 47456 + - 47457 + - 47458 + - 47459 + - 47460 + - 47461 + - 47462 + - 47463 + - 47464 + - 47465 + - 47466 + - 47467 + - 47468 + - 47469 + - 47470 + - 47471 + - 47472 + - 47473 + - 47474 + - 47475 + - 47476 + - 47477 + - 47478 + - 47479 + - 47480 + - 47481 + - 47482 + - 47483 + - 47484 + - 47485 + - 47486 + - 47487 + - 47488 + - 47489 + - 47490 + - 47491 + - 47492 + - 47493 + - 47494 + - 47495 + - 47496 + - 47497 + - 47498 + - 47499 + - 47500 + - 47501 + - 47502 + - 47503 + - 47504 + - 47505 + - 47506 + - 47507 + - 47508 + - 47509 + - 47510 + - 47511 + - 47512 + - 47513 + - 47514 + - 47515 + - 47516 + - 47517 + - 47518 + - 47519 + - 47520 + - 47521 + - 47522 + - 47523 + - 47524 + - 47525 + - 47526 + - 47527 + - 47528 + - 47529 + - 47530 + - 47531 + - 47532 + - 47533 + - 47534 + - 47535 + - 47536 + - 47537 + - 47538 + - 47539 + - 47540 + - 47541 + - 47542 + - 47543 + - 47544 + - 47545 + - 47546 + - 47547 + - 47548 + - 47549 + - 47550 + - 47551 + - 47552 + - 47553 + - 47554 + - 47555 + - 47556 + - 47557 + - 47558 + - 47559 + - 47560 + - 47561 + - 47562 + - 47563 + - 47564 + - 47565 + - 47566 + - 47567 + - 47568 + - 47569 + - 47570 + - 47571 + - 47572 + - 47573 + - 47574 + - 47575 + - 47576 + - 47577 + - 47578 + - 47579 + - 47580 + - 47581 + - 47582 + - 47583 + - 47584 + - 47585 + - 47586 + - 47587 + - 47588 + - 47589 + - 47590 + - 47591 + - 47592 + - 47593 + - 47594 + - 47595 + - 47596 + - 47597 + - 47598 + - 47599 + - 47600 + - 47601 + - 47602 + - 47603 + - 47604 + - 47605 + - 47606 + - 47607 + - 47608 + - 47609 + - 47610 + - 47611 + - 47612 + - 47613 + - 47614 + - 47615 + - 47616 + - 47617 + - 47618 + - 47619 + - 47620 + - 47621 + - 47622 + - 47623 + - 47624 + - 47625 + - 47626 + - 47627 + - 47628 + - 47629 + - 47630 + - 47631 + - 47632 + - 47633 + - 47634 + - 47635 + - 47636 + - 47637 + - 47638 + - 47639 + - 47640 + - 47641 + - 47642 + - 47643 + - 47644 + - 47645 + - 47646 + - 47647 + - 47648 + - 47649 + - 47650 + - 47651 + - 47652 + - 47653 + - 47654 + - 47655 + - 47656 + - 47657 + - 47658 + - 47659 + - 47660 + - 47661 + - 47662 + - 47663 + - 47664 + - 47665 + - 47666 + - 47667 + - 47668 + - 47669 + - 47670 + - 47671 + - 47672 + - 47673 + - 47674 + - 47675 + - 47676 + - 47677 + - 47678 + - 47679 + - 47680 + - 47681 + - 47682 + - 47683 + - 47684 + - 47685 + - 47686 + - 47687 + - 47688 + - 47689 + - 47690 + - 47691 + - 47692 + - 47693 + - 47694 + - 47695 + - 47696 + - 47697 + - 47698 + - 47699 + - 47700 + - 47701 + - 47702 + - 47703 + - 47704 + - 47705 + - 47706 + - 47707 + - 47708 + - 47709 + - 47710 + - 47711 + - 47712 + - 47713 + - 47714 + - 47715 + - 47716 + - 47717 + - 47718 + - 47719 + - 47720 + - 47721 + - 47722 + - 47723 + - 47724 + - 47725 + - 47726 + - 47727 + - 47728 + - 47729 + - 47730 + - 47731 + - 47732 + - 47733 + - 47734 + - 47735 + - 47736 + - 47737 + - 47738 + - 47739 + - 47740 + - 47741 + - 47742 + - 47743 + - 47744 + - 47745 + - 47746 + - 47747 + - 47748 + - 47749 + - 47750 + - 47751 + - 47752 + - 47753 + - 47754 + - 47755 + - 47756 + - 47757 + - 47758 + - 47759 + - 47760 + - 47761 + - 47762 + - 47763 + - 47764 + - 47765 + - 47766 + - 47767 + - 47768 + - 47769 + - 47770 + - 47771 + - 47772 + - 47773 + - 47774 + - 47775 + - 47776 + - 47777 + - 47778 + - 47779 + - 47780 + - 47781 + - 47782 + - 47783 + - 47784 + - 47785 + - 47786 + - 47787 + - 47788 + - 47789 + - 47790 + - 47791 + - 47792 + - 47793 + - 47794 + - 47795 + - 47796 + - 47797 + - 47798 + - 47799 + - 47800 + - 47801 + - 47802 + - 47803 + - 47804 + - 47805 + - 47806 + - 47807 + - 47808 + - 47809 + - 47810 + - 47811 + - 47812 + - 47813 + - 47814 + - 47815 + - 47816 + - 47817 + - 47818 + - 47819 + - 47820 + - 47821 + - 47822 + - 47823 + - 47824 + - 47825 + - 47826 + - 47827 + - 47828 + - 47829 + - 47830 + - 47831 + - 47832 + - 47833 + - 47834 + - 47835 + - 47836 + - 47837 + - 47838 + - 47839 + - 47840 + - 47841 + - 47842 + - 47843 + - 47844 + - 47845 + - 47846 + - 47847 + - 47848 + - 47849 + - 47850 + - 47851 + - 47852 + - 47853 + - 47854 + - 47855 + - 47856 + - 47857 + - 47858 + - 47859 + - 47860 + - 47861 + - 47862 + - 47863 + - 47864 + - 47865 + - 47866 + - 47867 + - 47868 + - 47869 + - 47870 + - 47871 + - 47872 + - 47873 + - 47874 + - 47875 + - 47876 + - 47877 + - 47878 + - 47879 + - 47880 + - 47881 + - 47882 + - 47883 + - 47884 + - 47885 + - 47886 + - 47887 + - 47888 + - 47889 + - 47890 + - 47891 + - 47892 + - 47893 + - 47894 + - 47895 + - 47896 + - 47897 + - 47898 + - 47899 + - 47900 + - 47901 + - 47902 + - 47903 + - 47904 + - 47905 + - 47906 + - 47907 + - 47908 + - 47909 + - 47910 + - 47911 + - 47912 + - 47913 + - 47914 + - 47915 + - 47916 + - 47917 + - 47918 + - 47919 + - 47920 + - 47921 + - 47922 + - 47923 + - 47924 + - 47925 + - 47926 + - 47927 + - 47928 + - 47929 + - 47930 + - 47931 + - 47932 + - 47933 + - 47934 + - 47935 + - 47936 + - 47937 + - 47938 + - 47939 + - 47940 + - 47941 + - 47942 + - 47943 + - 47944 + - 47945 + - 47946 + - 47947 + - 47948 + - 47949 + - 47950 + - 47951 + - 47952 + - 47953 + - 47954 + - 47955 + - 47956 + - 47957 + - 47958 + - 47959 + - 47960 + - 47961 + - 47962 + - 47963 + - 47964 + - 47965 + - 47966 + - 47967 + - 47968 + - 47969 + - 47970 + - 47971 + - 47972 + - 47973 + - 47974 + - 47975 + - 47976 + - 47977 + - 47978 + - 47979 + - 47980 + - 47981 + - 47982 + - 47983 + - 47984 + - 47985 + - 47986 + - 47987 + - 47988 + - 47989 + - 47990 + - 47991 + - 47992 + - 47993 + - 47994 + - 47995 + - 47996 + - 47997 + - 47998 + - 47999 + - 48000 + - 48001 + - 48002 + - 48003 + - 48004 + - 48005 + - 48006 + - 48007 + - 48008 + - 48009 + - 48010 + - 48011 + - 48012 + - 48013 + - 48014 + - 48015 + - 48016 + - 48017 + - 48018 + - 48019 + - 48020 + - 48021 + - 48022 + - 48023 + - 48024 + - 48025 + - 48026 + - 48027 + - 48028 + - 48029 + - 48030 + - 48031 + - 48032 + - 48033 + - 48034 + - 48035 + - 48036 + - 48037 + - 48038 + - 48039 + - 48040 + - 48041 + - 48042 + - 48043 + - 48044 + - 48045 + - 48046 + - 48047 + - 48048 + - 48049 + - 48050 + - 48051 + - 48052 + - 48053 + - 48054 + - 48055 + - 48056 + - 48057 + - 48058 + - 48059 + - 48060 + - 48061 + - 48062 + - 48063 + - 48064 + - 48065 + - 48066 + - 48067 + - 48068 + - 48069 + - 48070 + - 48071 + - 48072 + - 48073 + - 48074 + - 48075 + - 48076 + - 48077 + - 48078 + - 48079 + - 48080 + - 48081 + - 48082 + - 48083 + - 48084 + - 48085 + - 48086 + - 48087 + - 48088 + - 48089 + - 48090 + - 48091 + - 48092 + - 48093 + - 48094 + - 48095 + - 48096 + - 48097 + - 48098 + - 48099 + - 48100 + - 48101 + - 48102 + - 48103 + - 48104 + - 48105 + - 48106 + - 48107 + - 48108 + - 48109 + - 48110 + - 48111 + - 48112 + - 48113 + - 48114 + - 48115 + - 48116 + - 48117 + - 48118 + - 48119 + - 48120 + - 48121 + - 48122 + - 48123 + - 48124 + - 48125 + - 48126 + - 48127 + - 48128 + - 48129 + - 48130 + - 48131 + - 48132 + - 48133 + - 48134 + - 48135 + - 48136 + - 48137 + - 48138 + - 48139 + - 48140 + - 48141 + - 48142 + - 48143 + - 48144 + - 48145 + - 48146 + - 48147 + - 48148 + - 48149 + - 48150 + - 48151 + - 48152 + - 48153 + - 48154 + - 48155 + - 48156 + - 48157 + - 48158 + - 48159 + - 48160 + - 48161 + - 48162 + - 48163 + - 48164 + - 48165 + - 48166 + - 48167 + - 48168 + - 48169 + - 48170 + - 48171 + - 48172 + - 48173 + - 48174 + - 48175 + - 48176 + - 48177 + - 48178 + - 48179 + - 48180 + - 48181 + - 48182 + - 48183 + - 48184 + - 48185 + - 48186 + - 48187 + - 48188 + - 48189 + - 48190 + - 48191 + - 48192 + - 48193 + - 48194 + - 48195 + - 48196 + - 48197 + - 48198 + - 48199 + - 48200 + - 48201 + - 48202 + - 48203 + - 48204 + - 48205 + - 48206 + - 48207 + - 48208 + - 48209 + - 48210 + - 48211 + - 48212 + - 48213 + - 48214 + - 48215 + - 48216 + - 48217 + - 48218 + - 48219 + - 48220 + - 48221 + - 48222 + - 48223 + - 48224 + - 48225 + - 48226 + - 48227 + - 48228 + - 48229 + - 48230 + - 48231 + - 48232 + - 48233 + - 48234 + - 48235 + - 48236 + - 48237 + - 48238 + - 48239 + - 48240 + - 48241 + - 48242 + - 48243 + - 48244 + - 48245 + - 48246 + - 48247 + - 48248 + - 48249 + - 48250 + - 48251 + - 48252 + - 48253 + - 48254 + - 48255 + - 48256 + - 48257 + - 48258 + - 48259 + - 48260 + - 48261 + - 48262 + - 48263 + - 48264 + - 48265 + - 48266 + - 48267 + - 48268 + - 48269 + - 48270 + - 48271 + - 48272 + - 48273 + - 48274 + - 48275 + - 48276 + - 48277 + - 48278 + - 48279 + - 48280 + - 48281 + - 48282 + - 48283 + - 48284 + - 48285 + - 48286 + - 48287 + - 48288 + - 48289 + - 48290 + - 48291 + - 48292 + - 48293 + - 48294 + - 48295 + - 48296 + - 48297 + - 48298 + - 48299 + - 48300 + - 48301 + - 48302 + - 48303 + - 48304 + - 48305 + - 48306 + - 48307 + - 48308 + - 48309 + - 48310 + - 48311 + - 48312 + - 48313 + - 48314 + - 48315 + - 48316 + - 48317 + - 48318 + - 48319 + - 48320 + - 48321 + - 48322 + - 48323 + - 48324 + - 48325 + - 48326 + - 48327 + - 48328 + - 48329 + - 48330 + - 48331 + - 48332 + - 48333 + - 48334 + - 48335 + - 48336 + - 48337 + - 48338 + - 48339 + - 48340 + - 48341 + - 48342 + - 48343 + - 48344 + - 48345 + - 48346 + - 48347 + - 48348 + - 48349 + - 48350 + - 48351 + - 48352 + - 48353 + - 48354 + - 48355 + - 48356 + - 48357 + - 48358 + - 48359 + - 48360 + - 48361 + - 48362 + - 48363 + - 48364 + - 48365 + - 48366 + - 48367 + - 48368 + - 48369 + - 48370 + - 48371 + - 48372 + - 48373 + - 48374 + - 48375 + - 48376 + - 48377 + - 48378 + - 48379 + - 48380 + - 48381 + - 48382 + - 48383 + - 48384 + - 48385 + - 48386 + - 48387 + - 48388 + - 48389 + - 48390 + - 48391 + - 48392 + - 48393 + - 48394 + - 48395 + - 48396 + - 48397 + - 48398 + - 48399 + - 48400 + - 48401 + - 48402 + - 48403 + - 48404 + - 48405 + - 48406 + - 48407 + - 48408 + - 48409 + - 48410 + - 48411 + - 48412 + - 48413 + - 48414 + - 48415 + - 48416 + - 48417 + - 48418 + - 48419 + - 48420 + - 48421 + - 48422 + - 48423 + - 48424 + - 48425 + - 48426 + - 48427 + - 48428 + - 48429 + - 48430 + - 48431 + - 48432 + - 48433 + - 48434 + - 48435 + - 48436 + - 48437 + - 48438 + - 48439 + - 48440 + - 48441 + - 48442 + - 48443 + - 48444 + - 48445 + - 48446 + - 48447 + - 48448 + - 48449 + - 48450 + - 48451 + - 48452 + - 48453 + - 48454 + - 48455 + - 48456 + - 48457 + - 48458 + - 48459 + - 48460 + - 48461 + - 48462 + - 48463 + - 48464 + - 48465 + - 48466 + - 48467 + - 48468 + - 48469 + - 48470 + - 48471 + - 48472 + - 48473 + - 48474 + - 48475 + - 48476 + - 48477 + - 48478 + - 48479 + - 48480 + - 48481 + - 48482 + - 48483 + - 48484 + - 48485 + - 48486 + - 48487 + - 48488 + - 48489 + - 48490 + - 48491 + - 48492 + - 48493 + - 48494 + - 48495 + - 48496 + - 48497 + - 48498 + - 48499 + - 48500 + - 48501 + - 48502 + - 48503 + - 48504 + - 48505 + - 48506 + - 48507 + - 48508 + - 48509 + - 48510 + - 48511 + - 48512 + - 48513 + - 48514 + - 48515 + - 48516 + - 48517 + - 48518 + - 48519 + - 48520 + - 48521 + - 48522 + - 48523 + - 48524 + - 48525 + - 48526 + - 48527 + - 48528 + - 48529 + - 48530 + - 48531 + - 48532 + - 48533 + - 48534 + - 48535 + - 48536 + - 48537 + - 48538 + - 48539 + - 48540 + - 48541 + - 48542 + - 48543 + - 48544 + - 48545 + - 48546 + - 48547 + - 48548 + - 48549 + - 48550 + - 48551 + - 48552 + - 48553 + - 48554 + - 48555 + - 48556 + - 48557 + - 48558 + - 48559 + - 48560 + - 48561 + - 48562 + - 48563 + - 48564 + - 48565 + - 48566 + - 48567 + - 48568 + - 48569 + - 48570 + - 48571 + - 48572 + - 48573 + - 48574 + - 48575 + - 48576 + - 48577 + - 48578 + - 48579 + - 48580 + - 48581 + - 48582 + - 48583 + - 48584 + - 48585 + - 48586 + - 48587 + - 48588 + - 48589 + - 48590 + - 48591 + - 48592 + - 48593 + - 48594 + - 48595 + - 48596 + - 48597 + - 48598 + - 48599 + - 48600 + - 48601 + - 48602 + - 48603 + - 48604 + - 48605 + - 48606 + - 48607 + - 48608 + - 48609 + - 48610 + - 48611 + - 48612 + - 48613 + - 48614 + - 48615 + - 48616 + - 48617 + - 48618 + - 48619 + - 48620 + - 48621 + - 48622 + - 48623 + - 48624 + - 48625 + - 48626 + - 48627 + - 48628 + - 48629 + - 48630 + - 48631 + - 48632 + - 48633 + - 48634 + - 48635 + - 48636 + - 48637 + - 48638 + - 48639 + - 48640 + - 48641 + - 48642 + - 48643 + - 48644 + - 48645 + - 48646 + - 48647 + - 48648 + - 48649 + - 48650 + - 48651 + - 48652 + - 48653 + - 48654 + - 48655 + - 48656 + - 48657 + - 48658 + - 48659 + - 48660 + - 48661 + - 48662 + - 48663 + - 48664 + - 48665 + - 48666 + - 48667 + - 48668 + - 48669 + - 48670 + - 48671 + - 48672 + - 48673 + - 48674 + - 48675 + - 48676 + - 48677 + - 48678 + - 48679 + - 48680 + - 48681 + - 48682 + - 48683 + - 48684 + - 48685 + - 48686 + - 48687 + - 48688 + - 48689 + - 48690 + - 48691 + - 48692 + - 48693 + - 48694 + - 48695 + - 48696 + - 48697 + - 48698 + - 48699 + - 48700 + - 48701 + - 48702 + - 48703 + - 48704 + - 48705 + - 48706 + - 48707 + - 48708 + - 48709 + - 48710 + - 48711 + - 48712 + - 48713 + - 48714 + - 48715 + - 48716 + - 48717 + - 48718 + - 48719 + - 48720 + - 48721 + - 48722 + - 48723 + - 48724 + - 48725 + - 48726 + - 48727 + - 48728 + - 48729 + - 48730 + - 48731 + - 48732 + - 48733 + - 48734 + - 48735 + - 48736 + - 48737 + - 48738 + - 48739 + - 48740 + - 48741 + - 48742 + - 48743 + - 48744 + - 48745 + - 48746 + - 48747 + - 48748 + - 48749 + - 48750 + - 48751 + - 48752 + - 48753 + - 48754 + - 48755 + - 48756 + - 48757 + - 48758 + - 48759 + - 48760 + - 48761 + - 48762 + - 48763 + - 48764 + - 48765 + - 48766 + - 48767 + - 48768 + - 48769 + - 48770 + - 48771 + - 48772 + - 48773 + - 48774 + - 48775 + - 48776 + - 48777 + - 48778 + - 48779 + - 48780 + - 48781 + - 48782 + - 48783 + - 48784 + - 48785 + - 48786 + - 48787 + - 48788 + - 48789 + - 48790 + - 48791 + - 48792 + - 48793 + - 48794 + - 48795 + - 48796 + - 48797 + - 48798 + - 48799 + - 48800 + - 48801 + - 48802 + - 48803 + - 48804 + - 48805 + - 48806 + - 48807 + - 48808 + - 48809 + - 48810 + - 48811 + - 48812 + - 48813 + - 48814 + - 48815 + - 48816 + - 48817 + - 48818 + - 48819 + - 48820 + - 48821 + - 48822 + - 48823 + - 48824 + - 48825 + - 48826 + - 48827 + - 48828 + - 48829 + - 48830 + - 48831 + - 48832 + - 48833 + - 48834 + - 48835 + - 48836 + - 48837 + - 48838 + - 48839 + - 48840 + - 48841 + - 48842 + - 48843 + - 48844 + - 48845 + - 48846 + - 48847 + - 48848 + - 48849 + - 48850 + - 48851 + - 48852 + - 48853 + - 48854 + - 48855 + - 48856 + - 48857 + - 48858 + - 48859 + - 48860 + - 48861 + - 48862 + - 48863 + - 48864 + - 48865 + - 48866 + - 48867 + - 48868 + - 48869 + - 48870 + - 48871 + - 48872 + - 48873 + - 48874 + - 48875 + - 48876 + - 48877 + - 48878 + - 48879 + - 48880 + - 48881 + - 48882 + - 48883 + - 48884 + - 48885 + - 48886 + - 48887 + - 48888 + - 48889 + - 48890 + - 48891 + - 48892 + - 48893 + - 48894 + - 48895 + - 48896 + - 48897 + - 48898 + - 48899 + - 48900 + - 48901 + - 48902 + - 48903 + - 48904 + - 48905 + - 48906 + - 48907 + - 48908 + - 48909 + - 48910 + - 48911 + - 48912 + - 48913 + - 48914 + - 48915 + - 48916 + - 48917 + - 48918 + - 48919 + - 48920 + - 48921 + - 48922 + - 48923 + - 48924 + - 48925 + - 48926 + - 48927 + - 48928 + - 48929 + - 48930 + - 48931 + - 48932 + - 48933 + - 48934 + - 48935 + - 48936 + - 48937 + - 48938 + - 48939 + - 48940 + - 48941 + - 48942 + - 48943 + - 48944 + - 48945 + - 48946 + - 48947 + - 48948 + - 48949 + - 48950 + - 48951 + - 48952 + - 48953 + - 48954 + - 48955 + - 48956 + - 48957 + - 48958 + - 48959 + - 48960 + - 48961 + - 48962 + - 48963 + - 48964 + - 48965 + - 48966 + - 48967 + - 48968 + - 48969 + - 48970 + - 48971 + - 48972 + - 48973 + - 48974 + - 48975 + - 48976 + - 48977 + - 48978 + - 48979 + - 48980 + - 48981 + - 48982 + - 48983 + - 48984 + - 48985 + - 48986 + - 48987 + - 48988 + - 48989 + - 48990 + - 48991 + - 48992 + - 48993 + - 48994 + - 48995 + - 48996 + - 48997 + - 48998 + - 48999 + - 49000 + - 49001 + - 49002 + - 49003 + - 49004 + - 49005 + - 49006 + - 49007 + - 49008 + - 49009 + - 49010 + - 49011 + - 49012 + - 49013 + - 49014 + - 49015 + - 49016 + - 49017 + - 49018 + - 49019 + - 49020 + - 49021 + - 49022 + - 49023 + - 49024 + - 49025 + - 49026 + - 49027 + - 49028 + - 49029 + - 49030 + - 49031 + - 49032 + - 49033 + - 49034 + - 49035 + - 49036 + - 49037 + - 49038 + - 49039 + - 49040 + - 49041 + - 49042 + - 49043 + - 49044 + - 49045 + - 49046 + - 49047 + - 49048 + - 49049 + - 49050 + - 49051 + - 49052 + - 49053 + - 49054 + - 49055 + - 49056 + - 49057 + - 49058 + - 49059 + - 49060 + - 49061 + - 49062 + - 49063 + - 49064 + - 49065 + - 49066 + - 49067 + - 49068 + - 49069 + - 49070 + - 49071 + - 49072 + - 49073 + - 49074 + - 49075 + - 49076 + - 49077 + - 49078 + - 49079 + - 49080 + - 49081 + - 49082 + - 49083 + - 49084 + - 49085 + - 49086 + - 49087 + - 49088 + - 49089 + - 49090 + - 49091 + - 49092 + - 49093 + - 49094 + - 49095 + - 49096 + - 49097 + - 49098 + - 49099 + - 49100 + - 49101 + - 49102 + - 49103 + - 49104 + - 49105 + - 49106 + - 49107 + - 49108 + - 49109 + - 49110 + - 49111 + - 49112 + - 49113 + - 49114 + - 49115 + - 49116 + - 49117 + - 49118 + - 49119 + - 49120 + - 49121 + - 49122 + - 49123 + - 49124 + - 49125 + - 49126 + - 49127 + - 49128 + - 49129 + - 49130 + - 49131 + - 49132 + - 49133 + - 49134 + - 49135 + - 49136 + - 49137 + - 49138 + - 49139 + - 49140 + - 49141 + - 49142 + - 49143 + - 49144 + - 49145 + - 49146 + - 49147 + - 49148 + - 49149 + - 49150 + - 49151 + - 49152 + - 49153 + - 49154 + - 49155 + - 49156 + - 49157 + - 49158 + - 49159 + - 49160 + - 49161 + - 49162 + - 49163 + - 49164 + - 49165 + - 49166 + - 49167 + - 49168 + - 49169 + - 49170 + - 49171 + - 49172 + - 49173 + - 49174 + - 49175 + - 49176 + - 49177 + - 49178 + - 49179 + - 49180 + - 49181 + - 49182 + - 49183 + - 49184 + - 49185 + - 49186 + - 49187 + - 49188 + - 49189 + - 49190 + - 49191 + - 49192 + - 49193 + - 49194 + - 49195 + - 49196 + - 49197 + - 49198 + - 49199 + - 49200 + - 49201 + - 49202 + - 49203 + - 49204 + - 49205 + - 49206 + - 49207 + - 49208 + - 49209 + - 49210 + - 49211 + - 49212 + - 49213 + - 49214 + - 49215 + - 49216 + - 49217 + - 49218 + - 49219 + - 49220 + - 49221 + - 49222 + - 49223 + - 49224 + - 49225 + - 49226 + - 49227 + - 49228 + - 49229 + - 49230 + - 49231 + - 49232 + - 49233 + - 49234 + - 49235 + - 49236 + - 49237 + - 49238 + - 49239 + - 49240 + - 49241 + - 49242 + - 49243 + - 49244 + - 49245 + - 49246 + - 49247 + - 49248 + - 49249 + - 49250 + - 49251 + - 49252 + - 49253 + - 49254 + - 49255 + - 49256 + - 49257 + - 49258 + - 49259 + - 49260 + - 49261 + - 49262 + - 49263 + - 49264 + - 49265 + - 49266 + - 49267 + - 49268 + - 49269 + - 49270 + - 49271 + - 49272 + - 49273 + - 49274 + - 49275 + - 49276 + - 49277 + - 49278 + - 49279 + - 49280 + - 49281 + - 49282 + - 49283 + - 49284 + - 49285 + - 49286 + - 49287 + - 49288 + - 49289 + - 49290 + - 49291 + - 49292 + - 49293 + - 49294 + - 49295 + - 49296 + - 49297 + - 49298 + - 49299 + - 49300 + - 49301 + - 49302 + - 49303 + - 49304 + - 49305 + - 49306 + - 49307 + - 49308 + - 49309 + - 49310 + - 49311 + - 49312 + - 49313 + - 49314 + - 49315 + - 49316 + - 49317 + - 49318 + - 49319 + - 49320 + - 49321 + - 49322 + - 49323 + - 49324 + - 49325 + - 49326 + - 49327 + - 49328 + - 49329 + - 49330 + - 49331 + - 49332 + - 49333 + - 49334 + - 49335 + - 49336 + - 49337 + - 49338 + - 49339 + - 49340 + - 49341 + - 49342 + - 49343 + - 49344 + - 49345 + - 49346 + - 49347 + - 49348 + - 49349 + - 49350 + - 49351 + - 49352 + - 49353 + - 49354 + - 49355 + - 49356 + - 49357 + - 49358 + - 49359 + - 49360 + - 49361 + - 49362 + - 49363 + - 49364 + - 49365 + - 49366 + - 49367 + - 49368 + - 49369 + - 49370 + - 49371 + - 49372 + - 49373 + - 49374 + - 49375 + - 49376 + - 49377 + - 49378 + - 49379 + - 49380 + - 49381 + - 49382 + - 49383 + - 49384 + - 49385 + - 49386 + - 49387 + - 49388 + - 49389 + - 49390 + - 49391 + - 49392 + - 49393 + - 49394 + - 49395 + - 49396 + - 49397 + - 49398 + - 49399 + - 49400 + - 49401 + - 49402 + - 49403 + - 49404 + - 49405 + - 49406 + - 49407 + - 49408 + - 49409 + - 49410 + - 49411 + - 49412 + - 49413 + - 49414 + - 49415 + - 49416 + - 49417 + - 49418 + - 49419 + - 49420 + - 49421 + - 49422 + - 49423 + - 49424 + - 49425 + - 49426 + - 49427 + - 49428 + - 49429 + - 49430 + - 49431 + - 49432 + - 49433 + - 49434 + - 49435 + - 49436 + - 49437 + - 49438 + - 49439 + - 49440 + - 49441 + - 49442 + - 49443 + - 49444 + - 49445 + - 49446 + - 49447 + - 49448 + - 49449 + - 49450 + - 49451 + - 49452 + - 49453 + - 49454 + - 49455 + - 49456 + - 49457 + - 49458 + - 49459 + - 49460 + - 49461 + - 49462 + - 49463 + - 49464 + - 49465 + - 49466 + - 49467 + - 49468 + - 49469 + - 49470 + - 49471 + - 49472 + - 49473 + - 49474 + - 49475 + - 49476 + - 49477 + - 49478 + - 49479 + - 49480 + - 49481 + - 49482 + - 49483 + - 49484 + - 49485 + - 49486 + - 49487 + - 49488 + - 49489 + - 49490 + - 49491 + - 49492 + - 49493 + - 49494 + - 49495 + - 49496 + - 49497 + - 49498 + - 49499 + - 49500 + - 49501 + - 49502 + - 49503 + - 49504 + - 49505 + - 49506 + - 49507 + - 49508 + - 49509 + - 49510 + - 49511 + - 49512 + - 49513 + - 49514 + - 49515 + - 49516 + - 49517 + - 49518 + - 49519 + - 49520 + - 49521 + - 49522 + - 49523 + - 49524 + - 49525 + - 49526 + - 49527 + - 49528 + - 49529 + - 49530 + - 49531 + - 49532 + - 49533 + - 49534 + - 49535 + - 49536 + - 49537 + - 49538 + - 49539 + - 49540 + - 49541 + - 49542 + - 49543 + - 49544 + - 49545 + - 49546 + - 49547 + - 49548 + - 49549 + - 49550 + - 49551 + - 49552 + - 49553 + - 49554 + - 49555 + - 49556 + - 49557 + - 49558 + - 49559 + - 49560 + - 49561 + - 49562 + - 49563 + - 49564 + - 49565 + - 49566 + - 49567 + - 49568 + - 49569 + - 49570 + - 49571 + - 49572 + - 49573 + - 49574 + - 49575 + - 49576 + - 49577 + - 49578 + - 49579 + - 49580 + - 49581 + - 49582 + - 49583 + - 49584 + - 49585 + - 49586 + - 49587 + - 49588 + - 49589 + - 49590 + - 49591 + - 49592 + - 49593 + - 49594 + - 49595 + - 49596 + - 49597 + - 49598 + - 49599 + - 49600 + - 49601 + - 49602 + - 49603 + - 49604 + - 49605 + - 49606 + - 49607 + - 49608 + - 49609 + - 49610 + - 49611 + - 49612 + - 49613 + - 49614 + - 49615 + - 49616 + - 49617 + - 49618 + - 49619 + - 49620 + - 49621 + - 49622 + - 49623 + - 49624 + - 49625 + - 49626 + - 49627 + - 49628 + - 49629 + - 49630 + - 49631 + - 49632 + - 49633 + - 49634 + - 49635 + - 49636 + - 49637 + - 49638 + - 49639 + - 49640 + - 49641 + - 49642 + - 49643 + - 49644 + - 49645 + - 49646 + - 49647 + - 49648 + - 49649 + - 49650 + - 49651 + - 49652 + - 49653 + - 49654 + - 49655 + - 49656 + - 49657 + - 49658 + - 49659 + - 49660 + - 49661 + - 49662 + - 49663 + - 49664 + - 49665 + - 49666 + - 49667 + - 49668 + - 49669 + - 49670 + - 49671 + - 49672 + - 49673 + - 49674 + - 49675 + - 49676 + - 49677 + - 49678 + - 49679 + - 49680 + - 49681 + - 49682 + - 49683 + - 49684 + - 49685 + - 49686 + - 49687 + - 49688 + - 49689 + - 49690 + - 49691 + - 49692 + - 49693 + - 49694 + - 49695 + - 49696 + - 49697 + - 49698 + - 49699 + - 49700 + - 49701 + - 49702 + - 49703 + - 49704 + - 49705 + - 49706 + - 49707 + - 49708 + - 49709 + - 49710 + - 49711 + - 49712 + - 49713 + - 49714 + - 49715 + - 49716 + - 49717 + - 49718 + - 49719 + - 49720 + - 49721 + - 49722 + - 49723 + - 49724 + - 49725 + - 49726 + - 49727 + - 49728 + - 49729 + - 49730 + - 49731 + - 49732 + - 49733 + - 49734 + - 49735 + - 49736 + - 49737 + - 49738 + - 49739 + - 49740 + - 49741 + - 49742 + - 49743 + - 49744 + - 49745 + - 49746 + - 49747 + - 49748 + - 49749 + - 49750 + - 49751 + - 49752 + - 49753 + - 49754 + - 49755 + - 49756 + - 49757 + - 49758 + - 49759 + - 49760 + - 49761 + - 49762 + - 49763 + - 49764 + - 49765 + - 49766 + - 49767 + - 49768 + - 49769 + - 49770 + - 49771 + - 49772 + - 49773 + - 49774 + - 49775 + - 49776 + - 49777 + - 49778 + - 49779 + - 49780 + - 49781 + - 49782 + - 49783 + - 49784 + - 49785 + - 49786 + - 49787 + - 49788 + - 49789 + - 49790 + - 49791 + - 49792 + - 49793 + - 49794 + - 49795 + - 49796 + - 49797 + - 49798 + - 49799 + - 49800 + - 49801 + - 49802 + - 49803 + - 49804 + - 49805 + - 49806 + - 49807 + - 49808 + - 49809 + - 49810 + - 49811 + - 49812 + - 49813 + - 49814 + - 49815 + - 49816 + - 49817 + - 49818 + - 49819 + - 49820 + - 49821 + - 49822 + - 49823 + - 49824 + - 49825 + - 49826 + - 49827 + - 49828 + - 49829 + - 49830 + - 49831 + - 49832 + - 49833 + - 49834 + - 49835 + - 49836 + - 49837 + - 49838 + - 49839 + - 49840 + - 49841 + - 49842 + - 49843 + - 49844 + - 49845 + - 49846 + - 49847 + - 49848 + - 49849 + - 49850 + - 49851 + - 49852 + - 49853 + - 49854 + - 49855 + - 49856 + - 49857 + - 49858 + - 49859 + - 49860 + - 49861 + - 49862 + - 49863 + - 49864 + - 49865 + - 49866 + - 49867 + - 49868 + - 49869 + - 49870 + - 49871 + - 49872 + - 49873 + - 49874 + - 49875 + - 49876 + - 49877 + - 49878 + - 49879 + - 49880 + - 49881 + - 49882 + - 49883 + - 49884 + - 49885 + - 49886 + - 49887 + - 49888 + - 49889 + - 49890 + - 49891 + - 49892 + - 49893 + - 49894 + - 49895 + - 49896 + - 49897 + - 49898 + - 49899 + - 49900 + - 49901 + - 49902 + - 49903 + - 49904 + - 49905 + - 49906 + - 49907 + - 49908 + - 49909 + - 49910 + - 49911 + - 49912 + - 49913 + - 49914 + - 49915 + - 49916 + - 49917 + - 49918 + - 49919 + - 49920 + - 49921 + - 49922 + - 49923 + - 49924 + - 49925 + - 49926 + - 49927 + - 49928 + - 49929 + - 49930 + - 49931 + - 49932 + - 49933 + - 49934 + - 49935 + - 49936 + - 49937 + - 49938 + - 49939 + - 49940 + - 49941 + - 49942 + - 49943 + - 49944 + - 49945 + - 49946 + - 49947 + - 49948 + - 49949 + - 49950 + - 49951 + - 49952 + - 49953 + - 49954 + - 49955 + - 49956 + - 49957 + - 49958 + - 49959 + - 49960 + - 49961 + - 49962 + - 49963 + - 49964 + - 49965 + - 49966 + - 49967 + - 49968 + - 49969 + - 49970 + - 49971 + - 49972 + - 49973 + - 49974 + - 49975 + - 49976 + - 49977 + - 49978 + - 49979 + - 49980 + - 49981 + - 49982 + - 49983 + - 49984 + - 49985 + - 49986 + - 49987 + - 49988 + - 49989 + - 49990 + - 49991 + - 49992 + - 49993 + - 49994 + - 49995 + - 49996 + - 49997 + - 49998 + - 49999 + - 50000 + - 50001 + - 50002 + - 50003 + - 50004 + - 50005 + - 50006 + - 50007 + - 50008 + - 50009 + - 50010 + - 50011 + - 50012 + - 50013 + - 50014 + - 50015 + - 50016 + - 50017 + - 50018 + - 50019 + - 50020 + - 50021 + - 50022 + - 50023 + - 50024 + - 50025 + - 50026 + - 50027 + - 50028 + - 50029 + - 50030 + - 50031 + - 50032 + - 50033 + - 50034 + - 50035 + - 50036 + - 50037 + - 50038 + - 50039 + - 50040 + - 50041 + - 50042 + - 50043 + - 50044 + - 50045 + - 50046 + - 50047 + - 50048 + - 50049 + - 50050 + - 50051 + - 50052 + - 50053 + - 50054 + - 50055 + - 50056 + - 50057 + - 50058 + - 50059 + - 50060 + - 50061 + - 50062 + - 50063 + - 50064 + - 50065 + - 50066 + - 50067 + - 50068 + - 50069 + - 50070 + - 50071 + - 50072 + - 50073 + - 50074 + - 50075 + - 50076 + - 50077 + - 50078 + - 50079 + - 50080 + - 50081 + - 50082 + - 50083 + - 50084 + - 50085 + - 50086 + - 50087 + - 50088 + - 50089 + - 50090 + - 50091 + - 50092 + - 50093 + - 50094 + - 50095 + - 50096 + - 50097 + - 50098 + - 50099 + - 50100 + - 50101 + - 50102 + - 50103 + - 50104 + - 50105 + - 50106 + - 50107 + - 50108 + - 50109 + - 50110 + - 50111 + - 50112 + - 50113 + - 50114 + - 50115 + - 50116 + - 50117 + - 50118 + - 50119 + - 50120 + - 50121 + - 50122 + - 50123 + - 50124 + - 50125 + - 50126 + - 50127 + - 50128 + - 50129 + - 50130 + - 50131 + - 50132 + - 50133 + - 50134 + - 50135 + - 50136 + - 50137 + - 50138 + - 50139 + - 50140 + - 50141 + - 50142 + - 50143 + - 50144 + - 50145 + - 50146 + - 50147 + - 50148 + - 50149 + - 50150 + - 50151 + - 50152 + - 50153 + - 50154 + - 50155 + - 50156 + - 50157 + - 50158 + - 50159 + - 50160 + - 50161 + - 50162 + - 50163 + - 50164 + - 50165 + - 50166 + - 50167 + - 50168 + - 50169 + - 50170 + - 50171 + - 50172 + - 50173 + - 50174 + - 50175 + - 50176 + - 50177 + - 50178 + - 50179 + - 50180 + - 50181 + - 50182 + - 50183 + - 50184 + - 50185 + - 50186 + - 50187 + - 50188 + - 50189 + - 50190 + - 50191 + - 50192 + - 50193 + - 50194 + - 50195 + - 50196 + - 50197 + - 50198 + - 50199 + - 50200 + - 50201 + - 50202 + - 50203 + - 50204 + - 50205 + - 50206 + - 50207 + - 50208 + - 50209 + - 50210 + - 50211 + - 50212 + - 50213 + - 50214 + - 50215 + - 50216 + - 50217 + - 50218 + - 50219 + - 50220 + - 50221 + - 50222 + - 50223 + - 50224 + - 50225 + - 50226 + - 50227 + - 50228 + - 50229 + - 50230 + - 50231 + - 50232 + - 50233 + - 50234 + - 50235 + - 50236 + - 50237 + - 50238 + - 50239 + - 50240 + - 50241 + - 50242 + - 50243 + - 50244 + - 50245 + - 50246 + - 50247 + - 50248 + - 50249 + - 50250 + - 50251 + - 50252 + - 50253 + - 50254 + - 50255 + - 50256 + - 50257 + - 50258 + - 50259 + - 50260 + - 50261 + - 50262 + - 50263 + - 50264 + - 50265 + - 50266 + - 50267 + - 50268 + - 50269 + - 50270 + - 50271 + - 50272 + - 50273 + - 50274 + - 50275 + - 50276 + - 50277 + - 50278 + - 50279 + - 50280 + - 50281 + - 50282 + - 50283 + - 50284 + - 50285 + - 50286 + - 50287 + - 50288 + - 50289 + - 50290 + - 50291 + - 50292 + - 50293 + - 50294 + - 50295 + - 50296 + - 50297 + - 50298 + - 50299 + - 50300 + - 50301 + - 50302 + - 50303 + - 50304 + - 50305 + - 50306 + - 50307 + - 50308 + - 50309 + - 50310 + - 50311 + - 50312 + - 50313 + - 50314 + - 50315 + - 50316 + - 50317 + - 50318 + - 50319 + - 50320 + - 50321 + - 50322 + - 50323 + - 50324 + - 50325 + - 50326 + - 50327 + - 50328 + - 50329 + - 50330 + - 50331 + - 50332 + - 50333 + - 50334 + - 50335 + - 50336 + - 50337 + - 50338 + - 50339 + - 50340 + - 50341 + - 50342 + - 50343 + - 50344 + - 50345 + - 50346 + - 50347 + - 50348 + - 50349 + - 50350 + - 50351 + - 50352 + - 50353 + - 50354 + - 50355 + - 50356 + - 50357 + - 50358 + - 50359 + - 50360 + - 50361 + - 50362 + - 50363 + - 50364 + - 50365 + - 50366 + - 50367 + - 50368 + - 50369 + - 50370 + - 50371 + - 50372 + - 50373 + - 50374 + - 50375 + - 50376 + - 50377 + - 50378 + - 50379 + - 50380 + - 50381 + - 50382 + - 50383 + - 50384 + - 50385 + - 50386 + - 50387 + - 50388 + - 50389 + - 50390 + - 50391 + - 50392 + - 50393 + - 50394 + - 50395 + - 50396 + - 50397 + - 50398 + - 50399 + - 50400 + - 50401 + - 50402 + - 50403 + - 50404 + - 50405 + - 50406 + - 50407 + - 50408 + - 50409 + - 50410 + - 50411 + - 50412 + - 50413 + - 50414 + - 50415 + - 50416 + - 50417 + - 50418 + - 50419 + - 50420 + - 50421 + - 50422 + - 50423 + - 50424 + - 50425 + - 50426 + - 50427 + - 50428 + - 50429 + - 50430 + - 50431 + - 50432 + - 50433 + - 50434 + - 50435 + - 50436 + - 50437 + - 50438 + - 50439 + - 50440 + - 50441 + - 50442 + - 50443 + - 50444 + - 50445 + - 50446 + - 50447 + - 50448 + - 50449 + - 50450 + - 50451 + - 50452 + - 50453 + - 50454 + - 50455 + - 50456 + - 50457 + - 50458 + - 50459 + - 50460 + - 50461 + - 50462 + - 50463 + - 50464 + - 50465 + - 50466 + - 50467 + - 50468 + - 50469 + - 50470 + - 50471 + - 50472 + - 50473 + - 50474 + - 50475 + - 50476 + - 50477 + - 50478 + - 50479 + - 50480 + - 50481 + - 50482 + - 50483 + - 50484 + - 50485 + - 50486 + - 50487 + - 50488 + - 50489 + - 50490 + - 50491 + - 50492 + - 50493 + - 50494 + - 50495 + - 50496 + - 50497 + - 50498 + - 50499 + - 50500 + - 50501 + - 50502 + - 50503 + - 50504 + - 50505 + - 50506 + - 50507 + - 50508 + - 50509 + - 50510 + - 50511 + - 50512 + - 50513 + - 50514 + - 50515 + - 50516 + - 50517 + - 50518 + - 50519 + - 50520 + - 50521 + - 50522 + - 50523 + - 50524 + - 50525 + - 50526 + - 50527 + - 50528 + - 50529 + - 50530 + - 50531 + - 50532 + - 50533 + - 50534 + - 50535 + - 50536 + - 50537 + - 50538 + - 50539 + - 50540 + - 50541 + - 50542 + - 50543 + - 50544 + - 50545 + - 50546 + - 50547 + - 50548 + - 50549 + - 50550 + - 50551 + - 50552 + - 50553 + - 50554 + - 50555 + - 50556 + - 50557 + - 50558 + - 50559 + - 50560 + - 50561 + - 50562 + - 50563 + - 50564 + - 50565 + - 50566 + - 50567 + - 50568 + - 50569 + - 50570 + - 50571 + - 50572 + - 50573 + - 50574 + - 50575 + - 50576 + - 50577 + - 50578 + - 50579 + - 50580 + - 50581 + - 50582 + - 50583 + - 50584 + - 50585 + - 50586 + - 50587 + - 50588 + - 50589 + - 50590 + - 50591 + - 50592 + - 50593 + - 50594 + - 50595 + - 50596 + - 50597 + - 50598 + - 50599 + - 50600 + - 50601 + - 50602 + - 50603 + - 50604 + - 50605 + - 50606 + - 50607 + - 50608 + - 50609 + - 50610 + - 50611 + - 50612 + - 50613 + - 50614 + - 50615 + - 50616 + - 50617 + - 50618 + - 50619 + - 50620 + - 50621 + - 50622 + - 50623 + - 50624 + - 50625 + - 50626 + - 50627 + - 50628 + - 50629 + - 50630 + - 50631 + - 50632 + - 50633 + - 50634 + - 50635 + - 50636 + - 50637 + - 50638 + - 50639 + - 50640 + - 50641 + - 50642 + - 50643 + - 50644 + - 50645 + - 50646 + - 50647 + - 50648 + - 50649 + - 50650 + - 50651 + - 50652 + - 50653 + - 50654 + - 50655 + - 50656 + - 50657 + - 50658 + - 50659 + - 50660 + - 50661 + - 50662 + - 50663 + - 50664 + - 50665 + - 50666 + - 50667 + - 50668 + - 50669 + - 50670 + - 50671 + - 50672 + - 50673 + - 50674 + - 50675 + - 50676 + - 50677 + - 50678 + - 50679 + - 50680 + - 50681 + - 50682 + - 50683 + - 50684 + - 50685 + - 50686 + - 50687 + - 50688 + - 50689 + - 50690 + - 50691 + - 50692 + - 50693 + - 50694 + - 50695 + - 50696 + - 50697 + - 50698 + - 50699 + - 50700 + - 50701 + - 50702 + - 50703 + - 50704 + - 50705 + - 50706 + - 50707 + - 50708 + - 50709 + - 50710 + - 50711 + - 50712 + - 50713 + - 50714 + - 50715 + - 50716 + - 50717 + - 50718 + - 50719 + - 50720 + - 50721 + - 50722 + - 50723 + - 50724 + - 50725 + - 50726 + - 50727 + - 50728 + - 50729 + - 50730 + - 50731 + - 50732 + - 50733 + - 50734 + - 50735 + - 50736 + - 50737 + - 50738 + - 50739 + - 50740 + - 50741 + - 50742 + - 50743 + - 50744 + - 50745 + - 50746 + - 50747 + - 50748 + - 50749 + - 50750 + - 50751 + - 50752 + - 50753 + - 50754 + - 50755 + - 50756 + - 50757 + - 50758 + - 50759 + - 50760 + - 50761 + - 50762 + - 50763 + - 50764 + - 50765 + - 50766 + - 50767 + - 50768 + - 50769 + - 50770 + - 50771 + - 50772 + - 50773 + - 50774 + - 50775 + - 50776 + - 50777 + - 50778 + - 50779 + - 50780 + - 50781 + - 50782 + - 50783 + - 50784 + - 50785 + - 50786 + - 50787 + - 50788 + - 50789 + - 50790 + - 50791 + - 50792 + - 50793 + - 50794 + - 50795 + - 50796 + - 50797 + - 50798 + - 50799 + - 50800 + - 50801 + - 50802 + - 50803 + - 50804 + - 50805 + - 50806 + - 50807 + - 50808 + - 50809 + - 50810 + - 50811 + - 50812 + - 50813 + - 50814 + - 50815 + - 50816 + - 50817 + - 50818 + - 50819 + - 50820 + - 50821 + - 50822 + - 50823 + - 50824 + - 50825 + - 50826 + - 50827 + - 50828 + - 50829 + - 50830 + - 50831 + - 50832 + - 50833 + - 50834 + - 50835 + - 50836 + - 50837 + - 50838 + - 50839 + - 50840 + - 50841 + - 50842 + - 50843 + - 50844 + - 50845 + - 50846 + - 50847 + - 50848 + - 50849 + - 50850 + - 50851 + - 50852 + - 50853 + - 50854 + - 50855 + - 50856 + - 50857 + - 50858 + - 50859 + - 50860 + - 50861 + - 50862 + - 50863 + - 50864 + - 50865 + - 50866 + - 50867 + - 50868 + - 50869 + - 50870 + - 50871 + - 50872 + - 50873 + - 50874 + - 50875 + - 50876 + - 50877 + - 50878 + - 50879 + - 50880 + - 50881 + - 50882 + - 50883 + - 50884 + - 50885 + - 50886 + - 50887 + - 50888 + - 50889 + - 50890 + - 50891 + - 50892 + - 50893 + - 50894 + - 50895 + - 50896 + - 50897 + - 50898 + - 50899 + - 50900 + - 50901 + - 50902 + - 50903 + - 50904 + - 50905 + - 50906 + - 50907 + - 50908 + - 50909 + - 50910 + - 50911 + - 50912 + - 50913 + - 50914 + - 50915 + - 50916 + - 50917 + - 50918 + - 50919 + - 50920 + - 50921 + - 50922 + - 50923 + - 50924 + - 50925 + - 50926 + - 50927 + - 50928 + - 50929 + - 50930 + - 50931 + - 50932 + - 50933 + - 50934 + - 50935 + - 50936 + - 50937 + - 50938 + - 50939 + - 50940 + - 50941 + - 50942 + - 50943 + - 50944 + - 50945 + - 50946 + - 50947 + - 50948 + - 50949 + - 50950 + - 50951 + - 50952 + - 50953 + - 50954 + - 50955 + - 50956 + - 50957 + - 50958 + - 50959 + - 50960 + - 50961 + - 50962 + - 50963 + - 50964 + - 50965 + - 50966 + - 50967 + - 50968 + - 50969 + - 50970 + - 50971 + - 50972 + - 50973 + - 50974 + - 50975 + - 50976 + - 50977 + - 50978 + - 50979 + - 50980 + - 50981 + - 50982 + - 50983 + - 50984 + - 50985 + - 50986 + - 50987 + - 50988 + - 50989 + - 50990 + - 50991 + - 50992 + - 50993 + - 50994 + - 50995 + - 50996 + - 50997 + - 50998 + - 50999 + - 51000 + - 51001 + - 51002 + - 51003 + - 51004 + - 51005 + - 51006 + - 51007 + - 51008 + - 51009 + - 51010 + - 51011 + - 51012 + - 51013 + - 51014 + - 51015 + - 51016 + - 51017 + - 51018 + - 51019 + - 51020 + - 51021 + - 51022 + - 51023 + - 51024 + - 51025 + - 51026 + - 51027 + - 51028 + - 51029 + - 51030 + - 51031 + - 51032 + - 51033 + - 51034 + - 51035 + - 51036 + - 51037 + - 51038 + - 51039 + - 51040 + - 51041 + - 51042 + - 51043 + - 51044 + - 51045 + - 51046 + - 51047 + - 51048 + - 51049 + - 51050 + - 51051 + - 51052 + - 51053 + - 51054 + - 51055 + - 51056 + - 51057 + - 51058 + - 51059 + - 51060 + - 51061 + - 51062 + - 51063 + - 51064 + - 51065 + - 51066 + - 51067 + - 51068 + - 51069 + - 51070 + - 51071 + - 51072 + - 51073 + - 51074 + - 51075 + - 51076 + - 51077 + - 51078 + - 51079 + - 51080 + - 51081 + - 51082 + - 51083 + - 51084 + - 51085 + - 51086 + - 51087 + - 51088 + - 51089 + - 51090 + - 51091 + - 51092 + - 51093 + - 51094 + - 51095 + - 51096 + - 51097 + - 51098 + - 51099 + - 51100 + - 51101 + - 51102 + - 51103 + - 51104 + - 51105 + - 51106 + - 51107 + - 51108 + - 51109 + - 51110 + - 51111 + - 51112 + - 51113 + - 51114 + - 51115 + - 51116 + - 51117 + - 51118 + - 51119 + - 51120 + - 51121 + - 51122 + - 51123 + - 51124 + - 51125 + - 51126 + - 51127 + - 51128 + - 51129 + - 51130 + - 51131 + - 51132 + - 51133 + - 51134 + - 51135 + - 51136 + - 51137 + - 51138 + - 51139 + - 51140 + - 51141 + - 51142 + - 51143 + - 51144 + - 51145 + - 51146 + - 51147 + - 51148 + - 51149 + - 51150 + - 51151 + - 51152 + - 51153 + - 51154 + - 51155 + - 51156 + - 51157 + - 51158 + - 51159 + - 51160 + - 51161 + - 51162 + - 51163 + - 51164 + - 51165 + - 51166 + - 51167 + - 51168 + - 51169 + - 51170 + - 51171 + - 51172 + - 51173 + - 51174 + - 51175 + - 51176 + - 51177 + - 51178 + - 51179 + - 51180 + - 51181 + - 51182 + - 51183 + - 51184 + - 51185 + - 51186 + - 51187 + - 51188 + - 51189 + - 51190 + - 51191 + - 51192 + - 51193 + - 51194 + - 51195 + - 51196 + - 51197 + - 51198 + - 51199 + - 51200 + - 51201 + - 51202 + - 51203 + - 51204 + - 51205 + - 51206 + - 51207 + - 51208 + - 51209 + - 51210 + - 51211 + - 51212 + - 51213 + - 51214 + - 51215 + - 51216 + - 51217 + - 51218 + - 51219 + - 51220 + - 51221 + - 51222 + - 51223 + - 51224 + - 51225 + - 51226 + - 51227 + - 51228 + - 51229 + - 51230 + - 51231 + - 51232 + - 51233 + - 51234 + - 51235 + - 51236 + - 51237 + - 51238 + - 51239 + - 51240 + - 51241 + - 51242 + - 51243 + - 51244 + - 51245 + - 51246 + - 51247 + - 51248 + - 51249 + - 51250 + - 51251 + - 51252 + - 51253 + - 51254 + - 51255 + - 51256 + - 51257 + - 51258 + - 51259 + - 51260 + - 51261 + - 51262 + - 51263 + - 51264 + - 51265 + - 51266 + - 51267 + - 51268 + - 51269 + - 51270 + - 51271 + - 51272 + - 51273 + - 51274 + - 51275 + - 51276 + - 51277 + - 51278 + - 51279 + - 51280 + - 51281 + - 51282 + - 51283 + - 51284 + - 51285 + - 51286 + - 51287 + - 51288 + - 51289 + - 51290 + - 51291 + - 51292 + - 51293 + - 51294 + - 51295 + - 51296 + - 51297 + - 51298 + - 51299 + - 51300 + - 51301 + - 51302 + - 51303 + - 51304 + - 51305 + - 51306 + - 51307 + - 51308 + - 51309 + - 51310 + - 51311 + - 51312 + - 51313 + - 51314 + - 51315 + - 51316 + - 51317 + - 51318 + - 51319 + - 51320 + - 51321 + - 51322 + - 51323 + - 51324 + - 51325 + - 51326 + - 51327 + - 51328 + - 51329 + - 51330 + - 51331 + - 51332 + - 51333 + - 51334 + - 51335 + - 51336 + - 51337 + - 51338 + - 51339 + - 51340 + - 51341 + - 51342 + - 51343 + - 51344 + - 51345 + - 51346 + - 51347 + - 51348 + - 51349 + - 51350 + - 51351 + - 51352 + - 51353 + - 51354 + - 51355 + - 51356 + - 51357 + - 51358 + - 51359 + - 51360 + - 51361 + - 51362 + - 51363 + - 51364 + - 51365 + - 51366 + - 51367 + - 51368 + - 51369 + - 51370 + - 51371 + - 51372 + - 51373 + - 51374 + - 51375 + - 51376 + - 51377 + - 51378 + - 51379 + - 51380 + - 51381 + - 51382 + - 51383 + - 51384 + - 51385 + - 51386 + - 51387 + - 51388 + - 51389 + - 51390 + - 51391 + - 51392 + - 51393 + - 51394 + - 51395 + - 51396 + - 51397 + - 51398 + - 51399 + - 51400 + - 51401 + - 51402 + - 51403 + - 51404 + - 51405 + - 51406 + - 51407 + - 51408 + - 51409 + - 51410 + - 51411 + - 51412 + - 51413 + - 51414 + - 51415 + - 51416 + - 51417 + - 51418 + - 51419 + - 51420 + - 51421 + - 51422 + - 51423 + - 51424 + - 51425 + - 51426 + - 51427 + - 51428 + - 51429 + - 51430 + - 51431 + - 51432 + - 51433 + - 51434 + - 51435 + - 51436 + - 51437 + - 51438 + - 51439 + - 51440 + - 51441 + - 51442 + - 51443 + - 51444 + - 51445 + - 51446 + - 51447 + - 51448 + - 51449 + - 51450 + - 51451 + - 51452 + - 51453 + - 51454 + - 51455 + - 51456 + - 51457 + - 51458 + - 51459 + - 51460 + - 51461 + - 51462 + - 51463 + - 51464 + - 51465 + - 51466 + - 51467 + - 51468 + - 51469 + - 51470 + - 51471 + - 51472 + - 51473 + - 51474 + - 51475 + - 51476 + - 51477 + - 51478 + - 51479 + - 51480 + - 51481 + - 51482 + - 51483 + - 51484 + - 51485 + - 51486 + - 51487 + - 51488 + - 51489 + - 51490 + - 51491 + - 51492 + - 51493 + - 51494 + - 51495 + - 51496 + - 51497 + - 51498 + - 51499 + - 51500 + - 51501 + - 51502 + - 51503 + - 51504 + - 51505 + - 51506 + - 51507 + - 51508 + - 51509 + - 51510 + - 51511 + - 51512 + - 51513 + - 51514 + - 51515 + - 51516 + - 51517 + - 51518 + - 51519 + - 51520 + - 51521 + - 51522 + - 51523 + - 51524 + - 51525 + - 51526 + - 51527 + - 51528 + - 51529 + - 51530 + - 51531 + - 51532 + - 51533 + - 51534 + - 51535 + - 51536 + - 51537 + - 51538 + - 51539 + - 51540 + - 51541 + - 51542 + - 51543 + - 51544 + - 51545 + - 51546 + - 51547 + - 51548 + - 51549 + - 51550 + - 51551 + - 51552 + - 51553 + - 51554 + - 51555 + - 51556 + - 51557 + - 51558 + - 51559 + - 51560 + - 51561 + - 51562 + - 51563 + - 51564 + - 51565 + - 51566 + - 51567 + - 51568 + - 51569 + - 51570 + - 51571 + - 51572 + - 51573 + - 51574 + - 51575 + - 51576 + - 51577 + - 51578 + - 51579 + - 51580 + - 51581 + - 51582 + - 51583 + - 51584 + - 51585 + - 51586 + - 51587 + - 51588 + - 51589 + - 51590 + - 51591 + - 51592 + - 51593 + - 51594 + - 51595 + - 51596 + - 51597 + - 51598 + - 51599 + - 51600 + - 51601 + - 51602 + - 51603 + - 51604 + - 51605 + - 51606 + - 51607 + - 51608 + - 51609 + - 51610 + - 51611 + - 51612 + - 51613 + - 51614 + - 51615 + - 51616 + - 51617 + - 51618 + - 51619 + - 51620 + - 51621 + - 51622 + - 51623 + - 51624 + - 51625 + - 51626 + - 51627 + - 51628 + - 51629 + - 51630 + - 51631 + - 51632 + - 51633 + - 51634 + - 51635 + - 51636 + - 51637 + - 51638 + - 51639 + - 51640 + - 51641 + - 51642 + - 51643 + - 51644 + - 51645 + - 51646 + - 51647 + - 51648 + - 51649 + - 51650 + - 51651 + - 51652 + - 51653 + - 51654 + - 51655 + - 51656 + - 51657 + - 51658 + - 51659 + - 51660 + - 51661 + - 51662 + - 51663 + - 51664 + - 51665 + - 51666 + - 51667 + - 51668 + - 51669 + - 51670 + - 51671 + - 51672 + - 51673 + - 51674 + - 51675 + - 51676 + - 51677 + - 51678 + - 51679 + - 51680 + - 51681 + - 51682 + - 51683 + - 51684 + - 51685 + - 51686 + - 51687 + - 51688 + - 51689 + - 51690 + - 51691 + - 51692 + - 51693 + - 51694 + - 51695 + - 51696 + - 51697 + - 51698 + - 51699 + - 51700 + - 51701 + - 51702 + - 51703 + - 51704 + - 51705 + - 51706 + - 51707 + - 51708 + - 51709 + - 51710 + - 51711 + - 51712 + - 51713 + - 51714 + - 51715 + - 51716 + - 51717 + - 51718 + - 51719 + - 51720 + - 51721 + - 51722 + - 51723 + - 51724 + - 51725 + - 51726 + - 51727 + - 51728 + - 51729 + - 51730 + - 51731 + - 51732 + - 51733 + - 51734 + - 51735 + - 51736 + - 51737 + - 51738 + - 51739 + - 51740 + - 51741 + - 51742 + - 51743 + - 51744 + - 51745 + - 51746 + - 51747 + - 51748 + - 51749 + - 51750 + - 51751 + - 51752 + - 51753 + - 51754 + - 51755 + - 51756 + - 51757 + - 51758 + - 51759 + - 51760 + - 51761 + - 51762 + - 51763 + - 51764 + - 51765 + - 51766 + - 51767 + - 51768 + - 51769 + - 51770 + - 51771 + - 51772 + - 51773 + - 51774 + - 51775 + - 51776 + - 51777 + - 51778 + - 51779 + - 51780 + - 51781 + - 51782 + - 51783 + - 51784 + - 51785 + - 51786 + - 51787 + - 51788 + - 51789 + - 51790 + - 51791 + - 51792 + - 51793 + - 51794 + - 51795 + - 51796 + - 51797 + - 51798 + - 51799 + - 51800 + - 51801 + - 51802 + - 51803 + - 51804 + - 51805 + - 51806 + - 51807 + - 51808 + - 51809 + - 51810 + - 51811 + - 51812 + - 51813 + - 51814 + - 51815 + - 51816 + - 51817 + - 51818 + - 51819 + - 51820 + - 51821 + - 51822 + - 51823 + - 51824 + - 51825 + - 51826 + - 51827 + - 51828 + - 51829 + - 51830 + - 51831 + - 51832 + - 51833 + - 51834 + - 51835 + - 51836 + - 51837 + - 51838 + - 51839 + - 51840 + - 51841 + - 51842 + - 51843 + - 51844 + - 51845 + - 51846 + - 51847 + - 51848 + - 51849 + - 51850 + - 51851 + - 51852 + - 51853 + - 51854 + - 51855 + - 51856 + - 51857 + - 51858 + - 51859 + - 51860 + - 51861 + - 51862 + - 51863 + - 51864 + - 51865 + - 51866 + - 51867 + - 51868 + - 51869 + - 51870 + - 51871 + - 51872 + - 51873 + - 51874 + - 51875 + - 51876 + - 51877 + - 51878 + - 51879 + - 51880 + - 51881 + - 51882 + - 51883 + - 51884 + - 51885 + - 51886 + - 51887 + - 51888 + - 51889 + - 51890 + - 51891 + - 51892 + - 51893 + - 51894 + - 51895 + - 51896 + - 51897 + - 51898 + - 51899 + - 51900 + - 51901 + - 51902 + - 51903 + - 51904 + - 51905 + - 51906 + - 51907 + - 51908 + - 51909 + - 51910 + - 51911 + - 51912 + - 51913 + - 51914 + - 51915 + - 51916 + - 51917 + - 51918 + - 51919 + - 51920 + - 51921 + - 51922 + - 51923 + - 51924 + - 51925 + - 51926 + - 51927 + - 51928 + - 51929 + - 51930 + - 51931 + - 51932 + - 51933 + - 51934 + - 51935 + - 51936 + - 51937 + - 51938 + - 51939 + - 51940 + - 51941 + - 51942 + - 51943 + - 51944 + - 51945 + - 51946 + - 51947 + - 51948 + - 51949 + - 51950 + - 51951 + - 51952 + - 51953 + - 51954 + - 51955 + - 51956 + - 51957 + - 51958 + - 51959 + - 51960 + - 51961 + - 51962 + - 51963 + - 51964 + - 51965 + - 51966 + - 51967 + - 51968 + - 51969 + - 51970 + - 51971 + - 51972 + - 51973 + - 51974 + - 51975 + - 51976 + - 51977 + - 51978 + - 51979 + - 51980 + - 51981 + - 51982 + - 51983 + - 51984 + - 51985 + - 51986 + - 51987 + - 51988 + - 51989 + - 51990 + - 51991 + - 51992 + - 51993 + - 51994 + - 51995 + - 51996 + - 51997 + - 51998 + - 51999 + - 52000 + - 52001 + - 52002 + - 52003 + - 52004 + - 52005 + - 52006 + - 52007 + - 52008 + - 52009 + - 52010 + - 52011 + - 52012 + - 52013 + - 52014 + - 52015 + - 52016 + - 52017 + - 52018 + - 52019 + - 52020 + - 52021 + - 52022 + - 52023 + - 52024 + - 52025 + - 52026 + - 52027 + - 52028 + - 52029 + - 52030 + - 52031 + - 52032 + - 52033 + - 52034 + - 52035 + - 52036 + - 52037 + - 52038 + - 52039 + - 52040 + - 52041 + - 52042 + - 52043 + - 52044 + - 52045 + - 52046 + - 52047 + - 52048 + - 52049 + - 52050 + - 52051 + - 52052 + - 52053 + - 52054 + - 52055 + - 52056 + - 52057 + - 52058 + - 52059 + - 52060 + - 52061 + - 52062 + - 52063 + - 52064 + - 52065 + - 52066 + - 52067 + - 52068 + - 52069 + - 52070 + - 52071 + - 52072 + - 52073 + - 52074 + - 52075 + - 52076 + - 52077 + - 52078 + - 52079 + - 52080 + - 52081 + - 52082 + - 52083 + - 52084 + - 52085 + - 52086 + - 52087 + - 52088 + - 52089 + - 52090 + - 52091 + - 52092 + - 52093 + - 52094 + - 52095 + - 52096 + - 52097 + - 52098 + - 52099 + - 52100 + - 52101 + - 52102 + - 52103 + - 52104 + - 52105 + - 52106 + - 52107 + - 52108 + - 52109 + - 52110 + - 52111 + - 52112 + - 52113 + - 52114 + - 52115 + - 52116 + - 52117 + - 52118 + - 52119 + - 52120 + - 52121 + - 52122 + - 52123 + - 52124 + - 52125 + - 52126 + - 52127 + - 52128 + - 52129 + - 52130 + - 52131 + - 52132 + - 52133 + - 52134 + - 52135 + - 52136 + - 52137 + - 52138 + - 52139 + - 52140 + - 52141 + - 52142 + - 52143 + - 52144 + - 52145 + - 52146 + - 52147 + - 52148 + - 52149 + - 52150 + - 52151 + - 52152 + - 52153 + - 52154 + - 52155 + - 52156 + - 52157 + - 52158 + - 52159 + - 52160 + - 52161 + - 52162 + - 52163 + - 52164 + - 52165 + - 52166 + - 52167 + - 52168 + - 52169 + - 52170 + - 52171 + - 52172 + - 52173 + - 52174 + - 52175 + - 52176 + - 52177 + - 52178 + - 52179 + - 52180 + - 52181 + - 52182 + - 52183 + - 52184 + - 52185 + - 52186 + - 52187 + - 52188 + - 52189 + - 52190 + - 52191 + - 52192 + - 52193 + - 52194 + - 52195 + - 52196 + - 52197 + - 52198 + - 52199 + - 52200 + - 52201 + - 52202 + - 52203 + - 52204 + - 52205 + - 52206 + - 52207 + - 52208 + - 52209 + - 52210 + - 52211 + - 52212 + - 52213 + - 52214 + - 52215 + - 52216 + - 52217 + - 52218 + - 52219 + - 52220 + - 52221 + - 52222 + - 52223 + - 52224 + - 52225 + - 52226 + - 52227 + - 52228 + - 52229 + - 52230 + - 52231 + - 52232 + - 52233 + - 52234 + - 52235 + - 52236 + - 52237 + - 52238 + - 52239 + - 52240 + - 52241 + - 52242 + - 52243 + - 52244 + - 52245 + - 52246 + - 52247 + - 52248 + - 52249 + - 52250 + - 52251 + - 52252 + - 52253 + - 52254 + - 52255 + - 52256 + - 52257 + - 52258 + - 52259 + - 52260 + - 52261 + - 52262 + - 52263 + - 52264 + - 52265 + - 52266 + - 52267 + - 52268 + - 52269 + - 52270 + - 52271 + - 52272 + - 52273 + - 52274 + - 52275 + - 52276 + - 52277 + - 52278 + - 52279 + - 52280 + - 52281 + - 52282 + - 52283 + - 52284 + - 52285 + - 52286 + - 52287 + - 52288 + - 52289 + - 52290 + - 52291 + - 52292 + - 52293 + - 52294 + - 52295 + - 52296 + - 52297 + - 52298 + - 52299 + - 52300 + - 52301 + - 52302 + - 52303 + - 52304 + - 52305 + - 52306 + - 52307 + - 52308 + - 52309 + - 52310 + - 52311 + - 52312 + - 52313 + - 52314 + - 52315 + - 52316 + - 52317 + - 52318 + - 52319 + - 52320 + - 52321 + - 52322 + - 52323 + - 52324 + - 52325 + - 52326 + - 52327 + - 52328 + - 52329 + - 52330 + - 52331 + - 52332 + - 52333 + - 52334 + - 52335 + - 52336 + - 52337 + - 52338 + - 52339 + - 52340 + - 52341 + - 52342 + - 52343 + - 52344 + - 52345 + - 52346 + - 52347 + - 52348 + - 52349 + - 52350 + - 52351 + - 52352 + - 52353 + - 52354 + - 52355 + - 52356 + - 52357 + - 52358 + - 52359 + - 52360 + - 52361 + - 52362 + - 52363 + - 52364 + - 52365 + - 52366 + - 52367 + - 52368 + - 52369 + - 52370 + - 52371 + - 52372 + - 52373 + - 52374 + - 52375 + - 52376 + - 52377 + - 52378 + - 52379 + - 52380 + - 52381 + - 52382 + - 52383 + - 52384 + - 52385 + - 52386 + - 52387 + - 52388 + - 52389 + - 52390 + - 52391 + - 52392 + - 52393 + - 52394 + - 52395 + - 52396 + - 52397 + - 52398 + - 52399 + - 52400 + - 52401 + - 52402 + - 52403 + - 52404 + - 52405 + - 52406 + - 52407 + - 52408 + - 52409 + - 52410 + - 52411 + - 52412 + - 52413 + - 52414 + - 52415 + - 52416 + - 52417 + - 52418 + - 52419 + - 52420 + - 52421 + - 52422 + - 52423 + - 52424 + - 52425 + - 52426 + - 52427 + - 52428 + - 52429 + - 52430 + - 52431 + - 52432 + - 52433 + - 52434 + - 52435 + - 52436 + - 52437 + - 52438 + - 52439 + - 52440 + - 52441 + - 52442 + - 52443 + - 52444 + - 52445 + - 52446 + - 52447 + - 52448 + - 52449 + - 52450 + - 52451 + - 52452 + - 52453 + - 52454 + - 52455 + - 52456 + - 52457 + - 52458 + - 52459 + - 52460 + - 52461 + - 52462 + - 52463 + - 52464 + - 52465 + - 52466 + - 52467 + - 52468 + - 52469 + - 52470 + - 52471 + - 52472 + - 52473 + - 52474 + - 52475 + - 52476 + - 52477 + - 52478 + - 52479 + - 52480 + - 52481 + - 52482 + - 52483 + - 52484 + - 52485 + - 52486 + - 52487 + - 52488 + - 52489 + - 52490 + - 52491 + - 52492 + - 52493 + - 52494 + - 52495 + - 52496 + - 52497 + - 52498 + - 52499 + - 52500 + - 52501 + - 52502 + - 52503 + - 52504 + - 52505 + - 52506 + - 52507 + - 52508 + - 52509 + - 52510 + - 52511 + - 52512 + - 52513 + - 52514 + - 52515 + - 52516 + - 52517 + - 52518 + - 52519 + - 52520 + - 52521 + - 52522 + - 52523 + - 52524 + - 52525 + - 52526 + - 52527 + - 52528 + - 52529 + - 52530 + - 52531 + - 52532 + - 52533 + - 52534 + - 52535 + - 52536 + - 52537 + - 52538 + - 52539 + - 52540 + - 52541 + - 52542 + - 52543 + - 52544 + - 52545 + - 52546 + - 52547 + - 52548 + - 52549 + - 52550 + - 52551 + - 52552 + - 52553 + - 52554 + - 52555 + - 52556 + - 52557 + - 52558 + - 52559 + - 52560 + - 52561 + - 52562 + - 52563 + - 52564 + - 52565 + - 52566 + - 52567 + - 52568 + - 52569 + - 52570 + - 52571 + - 52572 + - 52573 + - 52574 + - 52575 + - 52576 + - 52577 + - 52578 + - 52579 + - 52580 + - 52581 + - 52582 + - 52583 + - 52584 + - 52585 + - 52586 + - 52587 + - 52588 + - 52589 + - 52590 + - 52591 + - 52592 + - 52593 + - 52594 + - 52595 + - 52596 + - 52597 + - 52598 + - 52599 + - 52600 + - 52601 + - 52602 + - 52603 + - 52604 + - 52605 + - 52606 + - 52607 + - 52608 + - 52609 + - 52610 + - 52611 + - 52612 + - 52613 + - 52614 + - 52615 + - 52616 + - 52617 + - 52618 + - 52619 + - 52620 + - 52621 + - 52622 + - 52623 + - 52624 + - 52625 + - 52626 + - 52627 + - 52628 + - 52629 + - 52630 + - 52631 + - 52632 + - 52633 + - 52634 + - 52635 + - 52636 + - 52637 + - 52638 + - 52639 + - 52640 + - 52641 + - 52642 + - 52643 + - 52644 + - 52645 + - 52646 + - 52647 + - 52648 + - 52649 + - 52650 + - 52651 + - 52652 + - 52653 + - 52654 + - 52655 + - 52656 + - 52657 + - 52658 + - 52659 + - 52660 + - 52661 + - 52662 + - 52663 + - 52664 + - 52665 + - 52666 + - 52667 + - 52668 + - 52669 + - 52670 + - 52671 + - 52672 + - 52673 + - 52674 + - 52675 + - 52676 + - 52677 + - 52678 + - 52679 + - 52680 + - 52681 + - 52682 + - 52683 + - 52684 + - 52685 + - 52686 + - 52687 + - 52688 + - 52689 + - 52690 + - 52691 + - 52692 + - 52693 + - 52694 + - 52695 + - 52696 + - 52697 + - 52698 + - 52699 + - 52700 + - 52701 + - 52702 + - 52703 + - 52704 + - 52705 + - 52706 + - 52707 + - 52708 + - 52709 + - 52710 + - 52711 + - 52712 + - 52713 + - 52714 + - 52715 + - 52716 + - 52717 + - 52718 + - 52719 + - 52720 + - 52721 + - 52722 + - 52723 + - 52724 + - 52725 + - 52726 + - 52727 + - 52728 + - 52729 + - 52730 + - 52731 + - 52732 + - 52733 + - 52734 + - 52735 + - 52736 + - 52737 + - 52738 + - 52739 + - 52740 + - 52741 + - 52742 + - 52743 + - 52744 + - 52745 + - 52746 + - 52747 + - 52748 + - 52749 + - 52750 + - 52751 + - 52752 + - 52753 + - 52754 + - 52755 + - 52756 + - 52757 + - 52758 + - 52759 + - 52760 + - 52761 + - 52762 + - 52763 + - 52764 + - 52765 + - 52766 + - 52767 + - 52768 + - 52769 + - 52770 + - 52771 + - 52772 + - 52773 + - 52774 + - 52775 + - 52776 + - 52777 + - 52778 + - 52779 + - 52780 + - 52781 + - 52782 + - 52783 + - 52784 + - 52785 + - 52786 + - 52787 + - 52788 + - 52789 + - 52790 + - 52791 + - 52792 + - 52793 + - 52794 + - 52795 + - 52796 + - 52797 + - 52798 + - 52799 + - 52800 + - 52801 + - 52802 + - 52803 + - 52804 + - 52805 + - 52806 + - 52807 + - 52808 + - 52809 + - 52810 + - 52811 + - 52812 + - 52813 + - 52814 + - 52815 + - 52816 + - 52817 + - 52818 + - 52819 + - 52820 + - 52821 + - 52822 + - 52823 + - 52824 + - 52825 + - 52826 + - 52827 + - 52828 + - 52829 + - 52830 + - 52831 + - 52832 + - 52833 + - 52834 + - 52835 + - 52836 + - 52837 + - 52838 + - 52839 + - 52840 + - 52841 + - 52842 + - 52843 + - 52844 + - 52845 + - 52846 + - 52847 + - 52848 + - 52849 + - 52850 + - 52851 + - 52852 + - 52853 + - 52854 + - 52855 + - 52856 + - 52857 + - 52858 + - 52859 + - 52860 + - 52861 + - 52862 + - 52863 + - 52864 + - 52865 + - 52866 + - 52867 + - 52868 + - 52869 + - 52870 + - 52871 + - 52872 + - 52873 + - 52874 + - 52875 + - 52876 + - 52877 + - 52878 + - 52879 + - 52880 + - 52881 + - 52882 + - 52883 + - 52884 + - 52885 + - 52886 + - 52887 + - 52888 + - 52889 + - 52890 + - 52891 + - 52892 + - 52893 + - 52894 + - 52895 + - 52896 + - 52897 + - 52898 + - 52899 + - 52900 + - 52901 + - 52902 + - 52903 + - 52904 + - 52905 + - 52906 + - 52907 + - 52908 + - 52909 + - 52910 + - 52911 + - 52912 + - 52913 + - 52914 + - 52915 + - 52916 + - 52917 + - 52918 + - 52919 + - 52920 + - 52921 + - 52922 + - 52923 + - 52924 + - 52925 + - 52926 + - 52927 + - 52928 + - 52929 + - 52930 + - 52931 + - 52932 + - 52933 + - 52934 + - 52935 + - 52936 + - 52937 + - 52938 + - 52939 + - 52940 + - 52941 + - 52942 + - 52943 + - 52944 + - 52945 + - 52946 + - 52947 + - 52948 + - 52949 + - 52950 + - 52951 + - 52952 + - 52953 + - 52954 + - 52955 + - 52956 + - 52957 + - 52958 + - 52959 + - 52960 + - 52961 + - 52962 + - 52963 + - 52964 + - 52965 + - 52966 + - 52967 + - 52968 + - 52969 + - 52970 + - 52971 + - 52972 + - 52973 + - 52974 + - 52975 + - 52976 + - 52977 + - 52978 + - 52979 + - 52980 + - 52981 + - 52982 + - 52983 + - 52984 + - 52985 + - 52986 + - 52987 + - 52988 + - 52989 + - 52990 + - 52991 + - 52992 + - 52993 + - 52994 + - 52995 + - 52996 + - 52997 + - 52998 + - 52999 + - 53000 + - 53001 + - 53002 + - 53003 + - 53004 + - 53005 + - 53006 + - 53007 + - 53008 + - 53009 + - 53010 + - 53011 + - 53012 + - 53013 + - 53014 + - 53015 + - 53016 + - 53017 + - 53018 + - 53019 + - 53020 + - 53021 + - 53022 + - 53023 + - 53024 + - 53025 + - 53026 + - 53027 + - 53028 + - 53029 + - 53030 + - 53031 + - 53032 + - 53033 + - 53034 + - 53035 + - 53036 + - 53037 + - 53038 + - 53039 + - 53040 + - 53041 + - 53042 + - 53043 + - 53044 + - 53045 + - 53046 + - 53047 + - 53048 + - 53049 + - 53050 + - 53051 + - 53052 + - 53053 + - 53054 + - 53055 + - 53056 + - 53057 + - 53058 + - 53059 + - 53060 + - 53061 + - 53062 + - 53063 + - 53064 + - 53065 + - 53066 + - 53067 + - 53068 + - 53069 + - 53070 + - 53071 + - 53072 + - 53073 + - 53074 + - 53075 + - 53076 + - 53077 + - 53078 + - 53079 + - 53080 + - 53081 + - 53082 + - 53083 + - 53084 + - 53085 + - 53086 + - 53087 + - 53088 + - 53089 + - 53090 + - 53091 + - 53092 + - 53093 + - 53094 + - 53095 + - 53096 + - 53097 + - 53098 + - 53099 + - 53100 + - 53101 + - 53102 + - 53103 + - 53104 + - 53105 + - 53106 + - 53107 + - 53108 + - 53109 + - 53110 + - 53111 + - 53112 + - 53113 + - 53114 + - 53115 + - 53116 + - 53117 + - 53118 + - 53119 + - 53120 + - 53121 + - 53122 + - 53123 + - 53124 + - 53125 + - 53126 + - 53127 + - 53128 + - 53129 + - 53130 + - 53131 + - 53132 + - 53133 + - 53134 + - 53135 + - 53136 + - 53137 + - 53138 + - 53139 + - 53140 + - 53141 + - 53142 + - 53143 + - 53144 + - 53145 + - 53146 + - 53147 + - 53148 + - 53149 + - 53150 + - 53151 + - 53152 + - 53153 + - 53154 + - 53155 + - 53156 + - 53157 + - 53158 + - 53159 + - 53160 + - 53161 + - 53162 + - 53163 + - 53164 + - 53165 + - 53166 + - 53167 + - 53168 + - 53169 + - 53170 + - 53171 + - 53172 + - 53173 + - 53174 + - 53175 + - 53176 + - 53177 + - 53178 + - 53179 + - 53180 + - 53181 + - 53182 + - 53183 + - 53184 + - 53185 + - 53186 + - 53187 + - 53188 + - 53189 + - 53190 + - 53191 + - 53192 + - 53193 + - 53194 + - 53195 + - 53196 + - 53197 + - 53198 + - 53199 + - 53200 + - 53201 + - 53202 + - 53203 + - 53204 + - 53205 + - 53206 + - 53207 + - 53208 + - 53209 + - 53210 + - 53211 + - 53212 + - 53213 + - 53214 + - 53215 + - 53216 + - 53217 + - 53218 + - 53219 + - 53220 + - 53221 + - 53222 + - 53223 + - 53224 + - 53225 + - 53226 + - 53227 + - 53228 + - 53229 + - 53230 + - 53231 + - 53232 + - 53233 + - 53234 + - 53235 + - 53236 + - 53237 + - 53238 + - 53239 + - 53240 + - 53241 + - 53242 + - 53243 + - 53244 + - 53245 + - 53246 + - 53247 + - 53248 + - 53249 + - 53250 + - 53251 + - 53252 + - 53253 + - 53254 + - 53255 + - 53256 + - 53257 + - 53258 + - 53259 + - 53260 + - 53261 + - 53262 + - 53263 + - 53264 + - 53265 + - 53266 + - 53267 + - 53268 + - 53269 + - 53270 + - 53271 + - 53272 + - 53273 + - 53274 + - 53275 + - 53276 + - 53277 + - 53278 + - 53279 + - 53280 + - 53281 + - 53282 + - 53283 + - 53284 + - 53285 + - 53286 + - 53287 + - 53288 + - 53289 + - 53290 + - 53291 + - 53292 + - 53293 + - 53294 + - 53295 + - 53296 + - 53297 + - 53298 + - 53299 + - 53300 + - 53301 + - 53302 + - 53303 + - 53304 + - 53305 + - 53306 + - 53307 + - 53308 + - 53309 + - 53310 + - 53311 + - 53312 + - 53313 + - 53314 + - 53315 + - 53316 + - 53317 + - 53318 + - 53319 + - 53320 + - 53321 + - 53322 + - 53323 + - 53324 + - 53325 + - 53326 + - 53327 + - 53328 + - 53329 + - 53330 + - 53331 + - 53332 + - 53333 + - 53334 + - 53335 + - 53336 + - 53337 + - 53338 + - 53339 + - 53340 + - 53341 + - 53342 + - 53343 + - 53344 + - 53345 + - 53346 + - 53347 + - 53348 + - 53349 + - 53350 + - 53351 + - 53352 + - 53353 + - 53354 + - 53355 + - 53356 + - 53357 + - 53358 + - 53359 + - 53360 + - 53361 + - 53362 + - 53363 + - 53364 + - 53365 + - 53366 + - 53367 + - 53368 + - 53369 + - 53370 + - 53371 + - 53372 + - 53373 + - 53374 + - 53375 + - 53376 + - 53377 + - 53378 + - 53379 + - 53380 + - 53381 + - 53382 + - 53383 + - 53384 + - 53385 + - 53386 + - 53387 + - 53388 + - 53389 + - 53390 + - 53391 + - 53392 + - 53393 + - 53394 + - 53395 + - 53396 + - 53397 + - 53398 + - 53399 + - 53400 + - 53401 + - 53402 + - 53403 + - 53404 + - 53405 + - 53406 + - 53407 + - 53408 + - 53409 + - 53410 + - 53411 + - 53412 + - 53413 + - 53414 + - 53415 + - 53416 + - 53417 + - 53418 + - 53419 + - 53420 + - 53421 + - 53422 + - 53423 + - 53424 + - 53425 + - 53426 + - 53427 + - 53428 + - 53429 + - 53430 + - 53431 + - 53432 + - 53433 + - 53434 + - 53435 + - 53436 + - 53437 + - 53438 + - 53439 + - 53440 + - 53441 + - 53442 + - 53443 + - 53444 + - 53445 + - 53446 + - 53447 + - 53448 + - 53449 + - 53450 + - 53451 + - 53452 + - 53453 + - 53454 + - 53455 + - 53456 + - 53457 + - 53458 + - 53459 + - 53460 + - 53461 + - 53462 + - 53463 + - 53464 + - 53465 + - 53466 + - 53467 + - 53468 + - 53469 + - 53470 + - 53471 + - 53472 + - 53473 + - 53474 + - 53475 + - 53476 + - 53477 + - 53478 + - 53479 + - 53480 + - 53481 + - 53482 + - 53483 + - 53484 + - 53485 + - 53486 + - 53487 + - 53488 + - 53489 + - 53490 + - 53491 + - 53492 + - 53493 + - 53494 + - 53495 + - 53496 + - 53497 + - 53498 + - 53499 + - 53500 + - 53501 + - 53502 + - 53503 + - 53504 + - 53505 + - 53506 + - 53507 + - 53508 + - 53509 + - 53510 + - 53511 + - 53512 + - 53513 + - 53514 + - 53515 + - 53516 + - 53517 + - 53518 + - 53519 + - 53520 + - 53521 + - 53522 + - 53523 + - 53524 + - 53525 + - 53526 + - 53527 + - 53528 + - 53529 + - 53530 + - 53531 + - 53532 + - 53533 + - 53534 + - 53535 + - 53536 + - 53537 + - 53538 + - 53539 + - 53540 + - 53541 + - 53542 + - 53543 + - 53544 + - 53545 + - 53546 + - 53547 + - 53548 + - 53549 + - 53550 + - 53551 + - 53552 + - 53553 + - 53554 + - 53555 + - 53556 + - 53557 + - 53558 + - 53559 + - 53560 + - 53561 + - 53562 + - 53563 + - 53564 + - 53565 + - 53566 + - 53567 + - 53568 + - 53569 + - 53570 + - 53571 + - 53572 + - 53573 + - 53574 + - 53575 + - 53576 + - 53577 + - 53578 + - 53579 + - 53580 + - 53581 + - 53582 + - 53583 + - 53584 + - 53585 + - 53586 + - 53587 + - 53588 + - 53589 + - 53590 + - 53591 + - 53592 + - 53593 + - 53594 + - 53595 + - 53596 + - 53597 + - 53598 + - 53599 + - 53600 + - 53601 + - 53602 + - 53603 + - 53604 + - 53605 + - 53606 + - 53607 + - 53608 + - 53609 + - 53610 + - 53611 + - 53612 + - 53613 + - 53614 + - 53615 + - 53616 + - 53617 + - 53618 + - 53619 + - 53620 + - 53621 + - 53622 + - 53623 + - 53624 + - 53625 + - 53626 + - 53627 + - 53628 + - 53629 + - 53630 + - 53631 + - 53632 + - 53633 + - 53634 + - 53635 + - 53636 + - 53637 + - 53638 + - 53639 + - 53640 + - 53641 + - 53642 + - 53643 + - 53644 + - 53645 + - 53646 + - 53647 + - 53648 + - 53649 + - 53650 + - 53651 + - 53652 + - 53653 + - 53654 + - 53655 + - 53656 + - 53657 + - 53658 + - 53659 + - 53660 + - 53661 + - 53662 + - 53663 + - 53664 + - 53665 + - 53666 + - 53667 + - 53668 + - 53669 + - 53670 + - 53671 + - 53672 + - 53673 + - 53674 + - 53675 + - 53676 + - 53677 + - 53678 + - 53679 + - 53680 + - 53681 + - 53682 + - 53683 + - 53684 + - 53685 + - 53686 + - 53687 + - 53688 + - 53689 + - 53690 + - 53691 + - 53692 + - 53693 + - 53694 + - 53695 + - 53696 + - 53697 + - 53698 + - 53699 + - 53700 + - 53701 + - 53702 + - 53703 + - 53704 + - 53705 + - 53706 + - 53707 + - 53708 + - 53709 + - 53710 + - 53711 + - 53712 + - 53713 + - 53714 + - 53715 + - 53716 + - 53717 + - 53718 + - 53719 + - 53720 + - 53721 + - 53722 + - 53723 + - 53724 + - 53725 + - 53726 + - 53727 + - 53728 + - 53729 + - 53730 + - 53731 + - 53732 + - 53733 + - 53734 + - 53735 + - 53736 + - 53737 + - 53738 + - 53739 + - 53740 + - 53741 + - 53742 + - 53743 + - 53744 + - 53745 + - 53746 + - 53747 + - 53748 + - 53749 + - 53750 + - 53751 + - 53752 + - 53753 + - 53754 + - 53755 + - 53756 + - 53757 + - 53758 + - 53759 + - 53760 + - 53761 + - 53762 + - 53763 + - 53764 + - 53765 + - 53766 + - 53767 + - 53768 + - 53769 + - 53770 + - 53771 + - 53772 + - 53773 + - 53774 + - 53775 + - 53776 + - 53777 + - 53778 + - 53779 + - 53780 + - 53781 + - 53782 + - 53783 + - 53784 + - 53785 + - 53786 + - 53787 + - 53788 + - 53789 + - 53790 + - 53791 + - 53792 + - 53793 + - 53794 + - 53795 + - 53796 + - 53797 + - 53798 + - 53799 + - 53800 + - 53801 + - 53802 + - 53803 + - 53804 + - 53805 + - 53806 + - 53807 + - 53808 + - 53809 + - 53810 + - 53811 + - 53812 + - 53813 + - 53814 + - 53815 + - 53816 + - 53817 + - 53818 + - 53819 + - 53820 + - 53821 + - 53822 + - 53823 + - 53824 + - 53825 + - 53826 + - 53827 + - 53828 + - 53829 + - 53830 + - 53831 + - 53832 + - 53833 + - 53834 + - 53835 + - 53836 + - 53837 + - 53838 + - 53839 + - 53840 + - 53841 + - 53842 + - 53843 + - 53844 + - 53845 + - 53846 + - 53847 + - 53848 + - 53849 + - 53850 + - 53851 + - 53852 + - 53853 + - 53854 + - 53855 + - 53856 + - 53857 + - 53858 + - 53859 + - 53860 + - 53861 + - 53862 + - 53863 + - 53864 + - 53865 + - 53866 + - 53867 + - 53868 + - 53869 + - 53870 + - 53871 + - 53872 + - 53873 + - 53874 + - 53875 + - 53876 + - 53877 + - 53878 + - 53879 + - 53880 + - 53881 + - 53882 + - 53883 + - 53884 + - 53885 + - 53886 + - 53887 + - 53888 + - 53889 + - 53890 + - 53891 + - 53892 + - 53893 + - 53894 + - 53895 + - 53896 + - 53897 + - 53898 + - 53899 + - 53900 + - 53901 + - 53902 + - 53903 + - 53904 + - 53905 + - 53906 + - 53907 + - 53908 + - 53909 + - 53910 + - 53911 + - 53912 + - 53913 + - 53914 + - 53915 + - 53916 + - 53917 + - 53918 + - 53919 + - 53920 + - 53921 + - 53922 + - 53923 + - 53924 + - 53925 + - 53926 + - 53927 + - 53928 + - 53929 + - 53930 + - 53931 + - 53932 + - 53933 + - 53934 + - 53935 + - 53936 + - 53937 + - 53938 + - 53939 + - 53940 + - 53941 + - 53942 + - 53943 + - 53944 + - 53945 + - 53946 + - 53947 + - 53948 + - 53949 + - 53950 + - 53951 + - 53952 + - 53953 + - 53954 + - 53955 + - 53956 + - 53957 + - 53958 + - 53959 + - 53960 + - 53961 + - 53962 + - 53963 + - 53964 + - 53965 + - 53966 + - 53967 + - 53968 + - 53969 + - 53970 + - 53971 + - 53972 + - 53973 + - 53974 + - 53975 + - 53976 + - 53977 + - 53978 + - 53979 + - 53980 + - 53981 + - 53982 + - 53983 + - 53984 + - 53985 + - 53986 + - 53987 + - 53988 + - 53989 + - 53990 + - 53991 + - 53992 + - 53993 + - 53994 + - 53995 + - 53996 + - 53997 + - 53998 + - 53999 + - 54000 + - 54001 + - 54002 + - 54003 + - 54004 + - 54005 + - 54006 + - 54007 + - 54008 + - 54009 + - 54010 + - 54011 + - 54012 + - 54013 + - 54014 + - 54015 + - 54016 + - 54017 + - 54018 + - 54019 + - 54020 + - 54021 + - 54022 + - 54023 + - 54024 + - 54025 + - 54026 + - 54027 + - 54028 + - 54029 + - 54030 + - 54031 + - 54032 + - 54033 + - 54034 + - 54035 + - 54036 + - 54037 + - 54038 + - 54039 + - 54040 + - 54041 + - 54042 + - 54043 + - 54044 + - 54045 + - 54046 + - 54047 + - 54048 + - 54049 + - 54050 + - 54051 + - 54052 + - 54053 + - 54054 + - 54055 + - 54056 + - 54057 + - 54058 + - 54059 + - 54060 + - 54061 + - 54062 + - 54063 + - 54064 + - 54065 + - 54066 + - 54067 + - 54068 + - 54069 + - 54070 + - 54071 + - 54072 + - 54073 + - 54074 + - 54075 + - 54076 + - 54077 + - 54078 + - 54079 + - 54080 + - 54081 + - 54082 + - 54083 + - 54084 + - 54085 + - 54086 + - 54087 + - 54088 + - 54089 + - 54090 + - 54091 + - 54092 + - 54093 + - 54094 + - 54095 + - 54096 + - 54097 + - 54098 + - 54099 + - 54100 + - 54101 + - 54102 + - 54103 + - 54104 + - 54105 + - 54106 + - 54107 + - 54108 + - 54109 + - 54110 + - 54111 + - 54112 + - 54113 + - 54114 + - 54115 + - 54116 + - 54117 + - 54118 + - 54119 + - 54120 + - 54121 + - 54122 + - 54123 + - 54124 + - 54125 + - 54126 + - 54127 + - 54128 + - 54129 + - 54130 + - 54131 + - 54132 + - 54133 + - 54134 + - 54135 + - 54136 + - 54137 + - 54138 + - 54139 + - 54140 + - 54141 + - 54142 + - 54143 + - 54144 + - 54145 + - 54146 + - 54147 + - 54148 + - 54149 + - 54150 + - 54151 + - 54152 + - 54153 + - 54154 + - 54155 + - 54156 + - 54157 + - 54158 + - 54159 + - 54160 + - 54161 + - 54162 + - 54163 + - 54164 + - 54165 + - 54166 + - 54167 + - 54168 + - 54169 + - 54170 + - 54171 + - 54172 + - 54173 + - 54174 + - 54175 + - 54176 + - 54177 + - 54178 + - 54179 + - 54180 + - 54181 + - 54182 + - 54183 + - 54184 + - 54185 + - 54186 + - 54187 + - 54188 + - 54189 + - 54190 + - 54191 + - 54192 + - 54193 + - 54194 + - 54195 + - 54196 + - 54197 + - 54198 + - 54199 + - 54200 + - 54201 + - 54202 + - 54203 + - 54204 + - 54205 + - 54206 + - 54207 + - 54208 + - 54209 + - 54210 + - 54211 + - 54212 + - 54213 + - 54214 + - 54215 + - 54216 + - 54217 + - 54218 + - 54219 + - 54220 + - 54221 + - 54222 + - 54223 + - 54224 + - 54225 + - 54226 + - 54227 + - 54228 + - 54229 + - 54230 + - 54231 + - 54232 + - 54233 + - 54234 + - 54235 + - 54236 + - 54237 + - 54238 + - 54239 + - 54240 + - 54241 + - 54242 + - 54243 + - 54244 + - 54245 + - 54246 + - 54247 + - 54248 + - 54249 + - 54250 + - 54251 + - 54252 + - 54253 + - 54254 + - 54255 + - 54256 + - 54257 + - 54258 + - 54259 + - 54260 + - 54261 + - 54262 + - 54263 + - 54264 + - 54265 + - 54266 + - 54267 + - 54268 + - 54269 + - 54270 + - 54271 + - 54272 + - 54273 + - 54274 + - 54275 + - 54276 + - 54277 + - 54278 + - 54279 + - 54280 + - 54281 + - 54282 + - 54283 + - 54284 + - 54285 + - 54286 + - 54287 + - 54288 + - 54289 + - 54290 + - 54291 + - 54292 + - 54293 + - 54294 + - 54295 + - 54296 + - 54297 + - 54298 + - 54299 + - 54300 + - 54301 + - 54302 + - 54303 + - 54304 + - 54305 + - 54306 + - 54307 + - 54308 + - 54309 + - 54310 + - 54311 + - 54312 + - 54313 + - 54314 + - 54315 + - 54316 + - 54317 + - 54318 + - 54319 + - 54320 + - 54321 + - 54322 + - 54323 + - 54324 + - 54325 + - 54326 + - 54327 + - 54328 + - 54329 + - 54330 + - 54331 + - 54332 + - 54333 + - 54334 + - 54335 + - 54336 + - 54337 + - 54338 + - 54339 + - 54340 + - 54341 + - 54342 + - 54343 + - 54344 + - 54345 + - 54346 + - 54347 + - 54348 + - 54349 + - 54350 + - 54351 + - 54352 + - 54353 + - 54354 + - 54355 + - 54356 + - 54357 + - 54358 + - 54359 + - 54360 + - 54361 + - 54362 + - 54363 + - 54364 + - 54365 + - 54366 + - 54367 + - 54368 + - 54369 + - 54370 + - 54371 + - 54372 + - 54373 + - 54374 + - 54375 + - 54376 + - 54377 + - 54378 + - 54379 + - 54380 + - 54381 + - 54382 + - 54383 + - 54384 + - 54385 + - 54386 + - 54387 + - 54388 + - 54389 + - 54390 + - 54391 + - 54392 + - 54393 + - 54394 + - 54395 + - 54396 + - 54397 + - 54398 + - 54399 + - 54400 + - 54401 + - 54402 + - 54403 + - 54404 + - 54405 + - 54406 + - 54407 + - 54408 + - 54409 + - 54410 + - 54411 + - 54412 + - 54413 + - 54414 + - 54415 + - 54416 + - 54417 + - 54418 + - 54419 + - 54420 + - 54421 + - 54422 + - 54423 + - 54424 + - 54425 + - 54426 + - 54427 + - 54428 + - 54429 + - 54430 + - 54431 + - 54432 + - 54433 + - 54434 + - 54435 + - 54436 + - 54437 + - 54438 + - 54439 + - 54440 + - 54441 + - 54442 + - 54443 + - 54444 + - 54445 + - 54446 + - 54447 + - 54448 + - 54449 + - 54450 + - 54451 + - 54452 + - 54453 + - 54454 + - 54455 + - 54456 + - 54457 + - 54458 + - 54459 + - 54460 + - 54461 + - 54462 + - 54463 + - 54464 + - 54465 + - 54466 + - 54467 + - 54468 + - 54469 + - 54470 + - 54471 + - 54472 + - 54473 + - 54474 + - 54475 + - 54476 + - 54477 + - 54478 + - 54479 + - 54480 + - 54481 + - 54482 + - 54483 + - 54484 + - 54485 + - 54486 + - 54487 + - 54488 + - 54489 + - 54490 + - 54491 + - 54492 + - 54493 + - 54494 + - 54495 + - 54496 + - 54497 + - 54498 + - 54499 + - 54500 + - 54501 + - 54502 + - 54503 + - 54504 + - 54505 + - 54506 + - 54507 + - 54508 + - 54509 + - 54510 + - 54511 + - 54512 + - 54513 + - 54514 + - 54515 + - 54516 + - 54517 + - 54518 + - 54519 + - 54520 + - 54521 + - 54522 + - 54523 + - 54524 + - 54525 + - 54526 + - 54527 + - 54528 + - 54529 + - 54530 + - 54531 + - 54532 + - 54533 + - 54534 + - 54535 + - 54536 + - 54537 + - 54538 + - 54539 + - 54540 + - 54541 + - 54542 + - 54543 + - 54544 + - 54545 + - 54546 + - 54547 + - 54548 + - 54549 + - 54550 + - 54551 + - 54552 + - 54553 + - 54554 + - 54555 + - 54556 + - 54557 + - 54558 + - 54559 + - 54560 + - 54561 + - 54562 + - 54563 + - 54564 + - 54565 + - 54566 + - 54567 + - 54568 + - 54569 + - 54570 + - 54571 + - 54572 + - 54573 + - 54574 + - 54575 + - 54576 + - 54577 + - 54578 + - 54579 + - 54580 + - 54581 + - 54582 + - 54583 + - 54584 + - 54585 + - 54586 + - 54587 + - 54588 + - 54589 + - 54590 + - 54591 + - 54592 + - 54593 + - 54594 + - 54595 + - 54596 + - 54597 + - 54598 + - 54599 + - 54600 + - 54601 + - 54602 + - 54603 + - 54604 + - 54605 + - 54606 + - 54607 + - 54608 + - 54609 + - 54610 + - 54611 + - 54612 + - 54613 + - 54614 + - 54615 + - 54616 + - 54617 + - 54618 + - 54619 + - 54620 + - 54621 + - 54622 + - 54623 + - 54624 + - 54625 + - 54626 + - 54627 + - 54628 + - 54629 + - 54630 + - 54631 + - 54632 + - 54633 + - 54634 + - 54635 + - 54636 + - 54637 + - 54638 + - 54639 + - 54640 + - 54641 + - 54642 + - 54643 + - 54644 + - 54645 + - 54646 + - 54647 + - 54648 + - 54649 + - 54650 + - 54651 + - 54652 + - 54653 + - 54654 + - 54655 + - 54656 + - 54657 + - 54658 + - 54659 + - 54660 + - 54661 + - 54662 + - 54663 + - 54664 + - 54665 + - 54666 + - 54667 + - 54668 + - 54669 + - 54670 + - 54671 + - 54672 + - 54673 + - 54674 + - 54675 + - 54676 + - 54677 + - 54678 + - 54679 + - 54680 + - 54681 + - 54682 + - 54683 + - 54684 + - 54685 + - 54686 + - 54687 + - 54688 + - 54689 + - 54690 + - 54691 + - 54692 + - 54693 + - 54694 + - 54695 + - 54696 + - 54697 + - 54698 + - 54699 + - 54700 + - 54701 + - 54702 + - 54703 + - 54704 + - 54705 + - 54706 + - 54707 + - 54708 + - 54709 + - 54710 + - 54711 + - 54712 + - 54713 + - 54714 + - 54715 + - 54716 + - 54717 + - 54718 + - 54719 + - 54720 + - 54721 + - 54722 + - 54723 + - 54724 + - 54725 + - 54726 + - 54727 + - 54728 + - 54729 + - 54730 + - 54731 + - 54732 + - 54733 + - 54734 + - 54735 + - 54736 + - 54737 + - 54738 + - 54739 + - 54740 + - 54741 + - 54742 + - 54743 + - 54744 + - 54745 + - 54746 + - 54747 + - 54748 + - 54749 + - 54750 + - 54751 + - 54752 + - 54753 + - 54754 + - 54755 + - 54756 + - 54757 + - 54758 + - 54759 + - 54760 + - 54761 + - 54762 + - 54763 + - 54764 + - 54765 + - 54766 + - 54767 + - 54768 + - 54769 + - 54770 + - 54771 + - 54772 + - 54773 + - 54774 + - 54775 + - 54776 + - 54777 + - 54778 + - 54779 + - 54780 + - 54781 + - 54782 + - 54783 + - 54784 + - 54785 + - 54786 + - 54787 + - 54788 + - 54789 + - 54790 + - 54791 + - 54792 + - 54793 + - 54794 + - 54795 + - 54796 + - 54797 + - 54798 + - 54799 + - 54800 + - 54801 + - 54802 + - 54803 + - 54804 + - 54805 + - 54806 + - 54807 + - 54808 + - 54809 + - 54810 + - 54811 + - 54812 + - 54813 + - 54814 + - 54815 + - 54816 + - 54817 + - 54818 + - 54819 + - 54820 + - 54821 + - 54822 + - 54823 + - 54824 + - 54825 + - 54826 + - 54827 + - 54828 + - 54829 + - 54830 + - 54831 + - 54832 + - 54833 + - 54834 + - 54835 + - 54836 + - 54837 + - 54838 + - 54839 + - 54840 + - 54841 + - 54842 + - 54843 + - 54844 + - 54845 + - 54846 + - 54847 + - 54848 + - 54849 + - 54850 + - 54851 + - 54852 + - 54853 + - 54854 + - 54855 + - 54856 + - 54857 + - 54858 + - 54859 + - 54860 + - 54861 + - 54862 + - 54863 + - 54864 + - 54865 + - 54866 + - 54867 + - 54868 + - 54869 + - 54870 + - 54871 + - 54872 + - 54873 + - 54874 + - 54875 + - 54876 + - 54877 + - 54878 + - 54879 + - 54880 + - 54881 + - 54882 + - 54883 + - 54884 + - 54885 + - 54886 + - 54887 + - 54888 + - 54889 + - 54890 + - 54891 + - 54892 + - 54893 + - 54894 + - 54895 + - 54896 + - 54897 + - 54898 + - 54899 + - 54900 + - 54901 + - 54902 + - 54903 + - 54904 + - 54905 + - 54906 + - 54907 + - 54908 + - 54909 + - 54910 + - 54911 + - 54912 + - 54913 + - 54914 + - 54915 + - 54916 + - 54917 + - 54918 + - 54919 + - 54920 + - 54921 + - 54922 + - 54923 + - 54924 + - 54925 + - 54926 + - 54927 + - 54928 + - 54929 + - 54930 + - 54931 + - 54932 + - 54933 + - 54934 + - 54935 + - 54936 + - 54937 + - 54938 + - 54939 + - 54940 + - 54941 + - 54942 + - 54943 + - 54944 + - 54945 + - 54946 + - 54947 + - 54948 + - 54949 + - 54950 + - 54951 + - 54952 + - 54953 + - 54954 + - 54955 + - 54956 + - 54957 + - 54958 + - 54959 + - 54960 + - 54961 + - 54962 + - 54963 + - 54964 + - 54965 + - 54966 + - 54967 + - 54968 + - 54969 + - 54970 + - 54971 + - 54972 + - 54973 + - 54974 + - 54975 + - 54976 + - 54977 + - 54978 + - 54979 + - 54980 + - 54981 + - 54982 + - 54983 + - 54984 + - 54985 + - 54986 + - 54987 + - 54988 + - 54989 + - 54990 + - 54991 + - 54992 + - 54993 + - 54994 + - 54995 + - 54996 + - 54997 + - 54998 + - 54999 + - 55000 + - 55001 + - 55002 + - 55003 + - 55004 + - 55005 + - 55006 + - 55007 + - 55008 + - 55009 + - 55010 + - 55011 + - 55012 + - 55013 + - 55014 + - 55015 + - 55016 + - 55017 + - 55018 + - 55019 + - 55020 + - 55021 + - 55022 + - 55023 + - 55024 + - 55025 + - 55026 + - 55027 + - 55028 + - 55029 + - 55030 + - 55031 + - 55032 + - 55033 + - 55034 + - 55035 + - 55036 + - 55037 + - 55038 + - 55039 + - 55040 + - 55041 + - 55042 + - 55043 + - 55044 + - 55045 + - 55046 + - 55047 + - 55048 + - 55049 + - 55050 + - 55051 + - 55052 + - 55053 + - 55054 + - 55055 + - 55056 + - 55057 + - 55058 + - 55059 + - 55060 + - 55061 + - 55062 + - 55063 + - 55064 + - 55065 + - 55066 + - 55067 + - 55068 + - 55069 + - 55070 + - 55071 + - 55072 + - 55073 + - 55074 + - 55075 + - 55076 + - 55077 + - 55078 + - 55079 + - 55080 + - 55081 + - 55082 + - 55083 + - 55084 + - 55085 + - 55086 + - 55087 + - 55088 + - 55089 + - 55090 + - 55091 + - 55092 + - 55093 + - 55094 + - 55095 + - 55096 + - 55097 + - 55098 + - 55099 + - 55100 + - 55101 + - 55102 + - 55103 + - 55104 + - 55105 + - 55106 + - 55107 + - 55108 + - 55109 + - 55110 + - 55111 + - 55112 + - 55113 + - 55114 + - 55115 + - 55116 + - 55117 + - 55118 + - 55119 + - 55120 + - 55121 + - 55122 + - 55123 + - 55124 + - 55125 + - 55126 + - 55127 + - 55128 + - 55129 + - 55130 + - 55131 + - 55132 + - 55133 + - 55134 + - 55135 + - 55136 + - 55137 + - 55138 + - 55139 + - 55140 + - 55141 + - 55142 + - 55143 + - 55144 + - 55145 + - 55146 + - 55147 + - 55148 + - 55149 + - 55150 + - 55151 + - 55152 + - 55153 + - 55154 + - 55155 + - 55156 + - 55157 + - 55158 + - 55159 + - 55160 + - 55161 + - 55162 + - 55163 + - 55164 + - 55165 + - 55166 + - 55167 + - 55168 + - 55169 + - 55170 + - 55171 + - 55172 + - 55173 + - 55174 + - 55175 + - 55176 + - 55177 + - 55178 + - 55179 + - 55180 + - 55181 + - 55182 + - 55183 + - 55184 + - 55185 + - 55186 + - 55187 + - 55188 + - 55189 + - 55190 + - 55191 + - 55192 + - 55193 + - 55194 + - 55195 + - 55196 + - 55197 + - 55198 + - 55199 + - 55200 + - 55201 + - 55202 + - 55203 + - 55204 + - 55205 + - 55206 + - 55207 + - 55208 + - 55209 + - 55210 + - 55211 + - 55212 + - 55213 + - 55214 + - 55215 + - 55216 + - 55217 + - 55218 + - 55219 + - 55220 + - 55221 + - 55222 + - 55223 + - 55224 + - 55225 + - 55226 + - 55227 + - 55228 + - 55229 + - 55230 + - 55231 + - 55232 + - 55233 + - 55234 + - 55235 + - 55236 + - 55237 + - 55238 + - 55239 + - 55240 + - 55241 + - 55242 + - 55243 + - 55244 + - 55245 + - 55246 + - 55247 + - 55248 + - 55249 + - 55250 + - 55251 + - 55252 + - 55253 + - 55254 + - 55255 + - 55256 + - 55257 + - 55258 + - 55259 + - 55260 + - 55261 + - 55262 + - 55263 + - 55264 + - 55265 + - 55266 + - 55267 + - 55268 + - 55269 + - 55270 + - 55271 + - 55272 + - 55273 + - 55274 + - 55275 + - 55276 + - 55277 + - 55278 + - 55279 + - 55280 + - 55281 + - 55282 + - 55283 + - 55284 + - 55285 + - 55286 + - 55287 + - 55288 + - 55289 + - 55290 + - 55291 + - 55292 + - 55293 + - 55294 + - 55295 + - 55296 + - 55297 + - 55298 + - 55299 + - 55300 + - 55301 + - 55302 + - 55303 + - 55304 + - 55305 + - 55306 + - 55307 + - 55308 + - 55309 + - 55310 + - 55311 + - 55312 + - 55313 + - 55314 + - 55315 + - 55316 + - 55317 + - 55318 + - 55319 + - 55320 + - 55321 + - 55322 + - 55323 + - 55324 + - 55325 + - 55326 + - 55327 + - 55328 + - 55329 + - 55330 + - 55331 + - 55332 + - 55333 + - 55334 + - 55335 + - 55336 + - 55337 + - 55338 + - 55339 + - 55340 + - 55341 + - 55342 + - 55343 + - 55344 + - 55345 + - 55346 + - 55347 + - 55348 + - 55349 + - 55350 + - 55351 + - 55352 + - 55353 + - 55354 + - 55355 + - 55356 + - 55357 + - 55358 + - 55359 + - 55360 + - 55361 + - 55362 + - 55363 + - 55364 + - 55365 + - 55366 + - 55367 + - 55368 + - 55369 + - 55370 + - 55371 + - 55372 + - 55373 + - 55374 + - 55375 + - 55376 + - 55377 + - 55378 + - 55379 + - 55380 + - 55381 + - 55382 + - 55383 + - 55384 + - 55385 + - 55386 + - 55387 + - 55388 + - 55389 + - 55390 + - 55391 + - 55392 + - 55393 + - 55394 + - 55395 + - 55396 + - 55397 + - 55398 + - 55399 + - 55400 + - 55401 + - 55402 + - 55403 + - 55404 + - 55405 + - 55406 + - 55407 + - 55408 + - 55409 + - 55410 + - 55411 + - 55412 + - 55413 + - 55414 + - 55415 + - 55416 + - 55417 + - 55418 + - 55419 + - 55420 + - 55421 + - 55422 + - 55423 + - 55424 + - 55425 + - 55426 + - 55427 + - 55428 + - 55429 + - 55430 + - 55431 + - 55432 + - 55433 + - 55434 + - 55435 + - 55436 + - 55437 + - 55438 + - 55439 + - 55440 + - 55441 + - 55442 + - 55443 + - 55444 + - 55445 + - 55446 + - 55447 + - 55448 + - 55449 + - 55450 + - 55451 + - 55452 + - 55453 + - 55454 + - 55455 + - 55456 + - 55457 + - 55458 + - 55459 + - 55460 + - 55461 + - 55462 + - 55463 + - 55464 + - 55465 + - 55466 + - 55467 + - 55468 + - 55469 + - 55470 + - 55471 + - 55472 + - 55473 + - 55474 + - 55475 + - 55476 + - 55477 + - 55478 + - 55479 + - 55480 + - 55481 + - 55482 + - 55483 + - 55484 + - 55485 + - 55486 + - 55487 + - 55488 + - 55489 + - 55490 + - 55491 + - 55492 + - 55493 + - 55494 + - 55495 + - 55496 + - 55497 + - 55498 + - 55499 + - 55500 + - 55501 + - 55502 + - 55503 + - 55504 + - 55505 + - 55506 + - 55507 + - 55508 + - 55509 + - 55510 + - 55511 + - 55512 + - 55513 + - 55514 + - 55515 + - 55516 + - 55517 + - 55518 + - 55519 + - 55520 + - 55521 + - 55522 + - 55523 + - 55524 + - 55525 + - 55526 + - 55527 + - 55528 + - 55529 + - 55530 + - 55531 + - 55532 + - 55533 + - 55534 + - 55535 + - 55536 + - 55537 + - 55538 + - 55539 + - 55540 + - 55541 + - 55542 + - 55543 + - 55544 + - 55545 + - 55546 + - 55547 + - 55548 + - 55549 + - 55550 + - 55551 + - 55552 + - 55553 + - 55554 + - 55555 + - 55556 + - 55557 + - 55558 + - 55559 + - 55560 + - 55561 + - 55562 + - 55563 + - 55564 + - 55565 + - 55566 + - 55567 + - 55568 + - 55569 + - 55570 + - 55571 + - 55572 + - 55573 + - 55574 + - 55575 + - 55576 + - 55577 + - 55578 + - 55579 + - 55580 + - 55581 + - 55582 + - 55583 + - 55584 + - 55585 + - 55586 + - 55587 + - 55588 + - 55589 + - 55590 + - 55591 + - 55592 + - 55593 + - 55594 + - 55595 + - 55596 + - 55597 + - 55598 + - 55599 + - 55600 + - 55601 + - 55602 + - 55603 + - 55604 + - 55605 + - 55606 + - 55607 + - 55608 + - 55609 + - 55610 + - 55611 + - 55612 + - 55613 + - 55614 + - 55615 + - 55616 + - 55617 + - 55618 + - 55619 + - 55620 + - 55621 + - 55622 + - 55623 + - 55624 + - 55625 + - 55626 + - 55627 + - 55628 + - 55629 + - 55630 + - 55631 + - 55632 + - 55633 + - 55634 + - 55635 + - 55636 + - 55637 + - 55638 + - 55639 + - 55640 + - 55641 + - 55642 + - 55643 + - 55644 + - 55645 + - 55646 + - 55647 + - 55648 + - 55649 + - 55650 + - 55651 + - 55652 + - 55653 + - 55654 + - 55655 + - 55656 + - 55657 + - 55658 + - 55659 + - 55660 + - 55661 + - 55662 + - 55663 + - 55664 + - 55665 + - 55666 + - 55667 + - 55668 + - 55669 + - 55670 + - 55671 + - 55672 + - 55673 + - 55674 + - 55675 + - 55676 + - 55677 + - 55678 + - 55679 + - 55680 + - 55681 + - 55682 + - 55683 + - 55684 + - 55685 + - 55686 + - 55687 + - 55688 + - 55689 + - 55690 + - 55691 + - 55692 + - 55693 + - 55694 + - 55695 + - 55696 + - 55697 + - 55698 + - 55699 + - 55700 + - 55701 + - 55702 + - 55703 + - 55704 + - 55705 + - 55706 + - 55707 + - 55708 + - 55709 + - 55710 + - 55711 + - 55712 + - 55713 + - 55714 + - 55715 + - 55716 + - 55717 + - 55718 + - 55719 + - 55720 + - 55721 + - 55722 + - 55723 + - 55724 + - 55725 + - 55726 + - 55727 + - 55728 + - 55729 + - 55730 + - 55731 + - 55732 + - 55733 + - 55734 + - 55735 + - 55736 + - 55737 + - 55738 + - 55739 + - 55740 + - 55741 + - 55742 + - 55743 + - 55744 + - 55745 + - 55746 + - 55747 + - 55748 + - 55749 + - 55750 + - 55751 + - 55752 + - 55753 + - 55754 + - 55755 + - 55756 + - 55757 + - 55758 + - 55759 + - 55760 + - 55761 + - 55762 + - 55763 + - 55764 + - 55765 + - 55766 + - 55767 + - 55768 + - 55769 + - 55770 + - 55771 + - 55772 + - 55773 + - 55774 + - 55775 + - 55776 + - 55777 + - 55778 + - 55779 + - 55780 + - 55781 + - 55782 + - 55783 + - 55784 + - 55785 + - 55786 + - 55787 + - 55788 + - 55789 + - 55790 + - 55791 + - 55792 + - 55793 + - 55794 + - 55795 + - 55796 + - 55797 + - 55798 + - 55799 + - 55800 + - 55801 + - 55802 + - 55803 + - 55804 + - 55805 + - 55806 + - 55807 + - 55808 + - 55809 + - 55810 + - 55811 + - 55812 + - 55813 + - 55814 + - 55815 + - 55816 + - 55817 + - 55818 + - 55819 + - 55820 + - 55821 + - 55822 + - 55823 + - 55824 + - 55825 + - 55826 + - 55827 + - 55828 + - 55829 + - 55830 + - 55831 + - 55832 + - 55833 + - 55834 + - 55835 + - 55836 + - 55837 + - 55838 + - 55839 + - 55840 + - 55841 + - 55842 + - 55843 + - 55844 + - 55845 + - 55846 + - 55847 + - 55848 + - 55849 + - 55850 + - 55851 + - 55852 + - 55853 + - 55854 + - 55855 + - 55856 + - 55857 + - 55858 + - 55859 + - 55860 + - 55861 + - 55862 + - 55863 + - 55864 + - 55865 + - 55866 + - 55867 + - 55868 + - 55869 + - 55870 + - 55871 + - 55872 + - 55873 + - 55874 + - 55875 + - 55876 + - 55877 + - 55878 + - 55879 + - 55880 + - 55881 + - 55882 + - 55883 + - 55884 + - 55885 + - 55886 + - 55887 + - 55888 + - 55889 + - 55890 + - 55891 + - 55892 + - 55893 + - 55894 + - 55895 + - 55896 + - 55897 + - 55898 + - 55899 + - 55900 + - 55901 + - 55902 + - 55903 + - 55904 + - 55905 + - 55906 + - 55907 + - 55908 + - 55909 + - 55910 + - 55911 + - 55912 + - 55913 + - 55914 + - 55915 + - 55916 + - 55917 + - 55918 + - 55919 + - 55920 + - 55921 + - 55922 + - 55923 + - 55924 + - 55925 + - 55926 + - 55927 + - 55928 + - 55929 + - 55930 + - 55931 + - 55932 + - 55933 + - 55934 + - 55935 + - 55936 + - 55937 + - 55938 + - 55939 + - 55940 + - 55941 + - 55942 + - 55943 + - 55944 + - 55945 + - 55946 + - 55947 + - 55948 + - 55949 + - 55950 + - 55951 + - 55952 + - 55953 + - 55954 + - 55955 + - 55956 + - 55957 + - 55958 + - 55959 + - 55960 + - 55961 + - 55962 + - 55963 + - 55964 + - 55965 + - 55966 + - 55967 + - 55968 + - 55969 + - 55970 + - 55971 + - 55972 + - 55973 + - 55974 + - 55975 + - 55976 + - 55977 + - 55978 + - 55979 + - 55980 + - 55981 + - 55982 + - 55983 + - 55984 + - 55985 + - 55986 + - 55987 + - 55988 + - 55989 + - 55990 + - 55991 + - 55992 + - 55993 + - 55994 + - 55995 + - 55996 + - 55997 + - 55998 + - 55999 + - 56000 + - 56001 + - 56002 + - 56003 + - 56004 + - 56005 + - 56006 + - 56007 + - 56008 + - 56009 + - 56010 + - 56011 + - 56012 + - 56013 + - 56014 + - 56015 + - 56016 + - 56017 + - 56018 + - 56019 + - 56020 + - 56021 + - 56022 + - 56023 + - 56024 + - 56025 + - 56026 + - 56027 + - 56028 + - 56029 + - 56030 + - 56031 + - 56032 + - 56033 + - 56034 + - 56035 + - 56036 + - 56037 + - 56038 + - 56039 + - 56040 + - 56041 + - 56042 + - 56043 + - 56044 + - 56045 + - 56046 + - 56047 + - 56048 + - 56049 + - 56050 + - 56051 + - 56052 + - 56053 + - 56054 + - 56055 + - 56056 + - 56057 + - 56058 + - 56059 + - 56060 + - 56061 + - 56062 + - 56063 + - 56064 + - 56065 + - 56066 + - 56067 + - 56068 + - 56069 + - 56070 + - 56071 + - 56072 + - 56073 + - 56074 + - 56075 + - 56076 + - 56077 + - 56078 + - 56079 + - 56080 + - 56081 + - 56082 + - 56083 + - 56084 + - 56085 + - 56086 + - 56087 + - 56088 + - 56089 + - 56090 + - 56091 + - 56092 + - 56093 + - 56094 + - 56095 + - 56096 + - 56097 + - 56098 + - 56099 + - 56100 + - 56101 + - 56102 + - 56103 + - 56104 + - 56105 + - 56106 + - 56107 + - 56108 + - 56109 + - 56110 + - 56111 + - 56112 + - 56113 + - 56114 + - 56115 + - 56116 + - 56117 + - 56118 + - 56119 + - 56120 + - 56121 + - 56122 + - 56123 + - 56124 + - 56125 + - 56126 + - 56127 + - 56128 + - 56129 + - 56130 + - 56131 + - 56132 + - 56133 + - 56134 + - 56135 + - 56136 + - 56137 + - 56138 + - 56139 + - 56140 + - 56141 + - 56142 + - 56143 + - 56144 + - 56145 + - 56146 + - 56147 + - 56148 + - 56149 + - 56150 + - 56151 + - 56152 + - 56153 + - 56154 + - 56155 + - 56156 + - 56157 + - 56158 + - 56159 + - 56160 + - 56161 + - 56162 + - 56163 + - 56164 + - 56165 + - 56166 + - 56167 + - 56168 + - 56169 + - 56170 + - 56171 + - 56172 + - 56173 + - 56174 + - 56175 + - 56176 + - 56177 + - 56178 + - 56179 + - 56180 + - 56181 + - 56182 + - 56183 + - 56184 + - 56185 + - 56186 + - 56187 + - 56188 + - 56189 + - 56190 + - 56191 + - 56192 + - 56193 + - 56194 + - 56195 + - 56196 + - 56197 + - 56198 + - 56199 + - 56200 + - 56201 + - 56202 + - 56203 + - 56204 + - 56205 + - 56206 + - 56207 + - 56208 + - 56209 + - 56210 + - 56211 + - 56212 + - 56213 + - 56214 + - 56215 + - 56216 + - 56217 + - 56218 + - 56219 + - 56220 + - 56221 + - 56222 + - 56223 + - 56224 + - 56225 + - 56226 + - 56227 + - 56228 + - 56229 + - 56230 + - 56231 + - 56232 + - 56233 + - 56234 + - 56235 + - 56236 + - 56237 + - 56238 + - 56239 + - 56240 + - 56241 + - 56242 + - 56243 + - 56244 + - 56245 + - 56246 + - 56247 + - 56248 + - 56249 + - 56250 + - 56251 + - 56252 + - 56253 + - 56254 + - 56255 + - 56256 + - 56257 + - 56258 + - 56259 + - 56260 + - 56261 + - 56262 + - 56263 + - 56264 + - 56265 + - 56266 + - 56267 + - 56268 + - 56269 + - 56270 + - 56271 + - 56272 + - 56273 + - 56274 + - 56275 + - 56276 + - 56277 + - 56278 + - 56279 + - 56280 + - 56281 + - 56282 + - 56283 + - 56284 + - 56285 + - 56286 + - 56287 + - 56288 + - 56289 + - 56290 + - 56291 + - 56292 + - 56293 + - 56294 + - 56295 + - 56296 + - 56297 + - 56298 + - 56299 + - 56300 + - 56301 + - 56302 + - 56303 + - 56304 + - 56305 + - 56306 + - 56307 + - 56308 + - 56309 + - 56310 + - 56311 + - 56312 + - 56313 + - 56314 + - 56315 + - 56316 + - 56317 + - 56318 + - 56319 + - 56320 + - 56321 + - 56322 + - 56323 + - 56324 + - 56325 + - 56326 + - 56327 + - 56328 + - 56329 + - 56330 + - 56331 + - 56332 + - 56333 + - 56334 + - 56335 + - 56336 + - 56337 + - 56338 + - 56339 + - 56340 + - 56341 + - 56342 + - 56343 + - 56344 + - 56345 + - 56346 + - 56347 + - 56348 + - 56349 + - 56350 + - 56351 + - 56352 + - 56353 + - 56354 + - 56355 + - 56356 + - 56357 + - 56358 + - 56359 + - 56360 + - 56361 + - 56362 + - 56363 + - 56364 + - 56365 + - 56366 + - 56367 + - 56368 + - 56369 + - 56370 + - 56371 + - 56372 + - 56373 + - 56374 + - 56375 + - 56376 + - 56377 + - 56378 + - 56379 + - 56380 + - 56381 + - 56382 + - 56383 + - 56384 + - 56385 + - 56386 + - 56387 + - 56388 + - 56389 + - 56390 + - 56391 + - 56392 + - 56393 + - 56394 + - 56395 + - 56396 + - 56397 + - 56398 + - 56399 + - 56400 + - 56401 + - 56402 + - 56403 + - 56404 + - 56405 + - 56406 + - 56407 + - 56408 + - 56409 + - 56410 + - 56411 + - 56412 + - 56413 + - 56414 + - 56415 + - 56416 + - 56417 + - 56418 + - 56419 + - 56420 + - 56421 + - 56422 + - 56423 + - 56424 + - 56425 + - 56426 + - 56427 + - 56428 + - 56429 + - 56430 + - 56431 + - 56432 + - 56433 + - 56434 + - 56435 + - 56436 + - 56437 + - 56438 + - 56439 + - 56440 + - 56441 + - 56442 + - 56443 + - 56444 + - 56445 + - 56446 + - 56447 + - 56448 + - 56449 + - 56450 + - 56451 + - 56452 + - 56453 + - 56454 + - 56455 + - 56456 + - 56457 + - 56458 + - 56459 + - 56460 + - 56461 + - 56462 + - 56463 + - 56464 + - 56465 + - 56466 + - 56467 + - 56468 + - 56469 + - 56470 + - 56471 + - 56472 + - 56473 + - 56474 + - 56475 + - 56476 + - 56477 + - 56478 + - 56479 + - 56480 + - 56481 + - 56482 + - 56483 + - 56484 + - 56485 + - 56486 + - 56487 + - 56488 + - 56489 + - 56490 + - 56491 + - 56492 + - 56493 + - 56494 + - 56495 + - 56496 + - 56497 + - 56498 + - 56499 + - 56500 + - 56501 + - 56502 + - 56503 + - 56504 + - 56505 + - 56506 + - 56507 + - 56508 + - 56509 + - 56510 + - 56511 + - 56512 + - 56513 + - 56514 + - 56515 + - 56516 + - 56517 + - 56518 + - 56519 + - 56520 + - 56521 + - 56522 + - 56523 + - 56524 + - 56525 + - 56526 + - 56527 + - 56528 + - 56529 + - 56530 + - 56531 + - 56532 + - 56533 + - 56534 + - 56535 + - 56536 + - 56537 + - 56538 + - 56539 + - 56540 + - 56541 + - 56542 + - 56543 + - 56544 + - 56545 + - 56546 + - 56547 + - 56548 + - 56549 + - 56550 + - 56551 + - 56552 + - 56553 + - 56554 + - 56555 + - 56556 + - 56557 + - 56558 + - 56559 + - 56560 + - 56561 + - 56562 + - 56563 + - 56564 + - 56565 + - 56566 + - 56567 + - 56568 + - 56569 + - 56570 + - 56571 + - 56572 + - 56573 + - 56574 + - 56575 + - 56576 + - 56577 + - 56578 + - 56579 + - 56580 + - 56581 + - 56582 + - 56583 + - 56584 + - 56585 + - 56586 + - 56587 + - 56588 + - 56589 + - 56590 + - 56591 + - 56592 + - 56593 + - 56594 + - 56595 + - 56596 + - 56597 + - 56598 + - 56599 + - 56600 + - 56601 + - 56602 + - 56603 + - 56604 + - 56605 + - 56606 + - 56607 + - 56608 + - 56609 + - 56610 + - 56611 + - 56612 + - 56613 + - 56614 + - 56615 + - 56616 + - 56617 + - 56618 + - 56619 + - 56620 + - 56621 + - 56622 + - 56623 + - 56624 + - 56625 + - 56626 + - 56627 + - 56628 + - 56629 + - 56630 + - 56631 + - 56632 + - 56633 + - 56634 + - 56635 + - 56636 + - 56637 + - 56638 + - 56639 + - 56640 + - 56641 + - 56642 + - 56643 + - 56644 + - 56645 + - 56646 + - 56647 + - 56648 + - 56649 + - 56650 + - 56651 + - 56652 + - 56653 + - 56654 + - 56655 + - 56656 + - 56657 + - 56658 + - 56659 + - 56660 + - 56661 + - 56662 + - 56663 + - 56664 + - 56665 + - 56666 + - 56667 + - 56668 + - 56669 + - 56670 + - 56671 + - 56672 + - 56673 + - 56674 + - 56675 + - 56676 + - 56677 + - 56678 + - 56679 + - 56680 + - 56681 + - 56682 + - 56683 + - 56684 + - 56685 + - 56686 + - 56687 + - 56688 + - 56689 + - 56690 + - 56691 + - 56692 + - 56693 + - 56694 + - 56695 + - 56696 + - 56697 + - 56698 + - 56699 + - 56700 + - 56701 + - 56702 + - 56703 + - 56704 + - 56705 + - 56706 + - 56707 + - 56708 + - 56709 + - 56710 + - 56711 + - 56712 + - 56713 + - 56714 + - 56715 + - 56716 + - 56717 + - 56718 + - 56719 + - 56720 + - 56721 + - 56722 + - 56723 + - 56724 + - 56725 + - 56726 + - 56727 + - 56728 + - 56729 + - 56730 + - 56731 + - 56732 + - 56733 + - 56734 + - 56735 + - 56736 + - 56737 + - 56738 + - 56739 + - 56740 + - 56741 + - 56742 + - 56743 + - 56744 + - 56745 + - 56746 + - 56747 + - 56748 + - 56749 + - 56750 + - 56751 + - 56752 + - 56753 + - 56754 + - 56755 + - 56756 + - 56757 + - 56758 + - 56759 + - 56760 + - 56761 + - 56762 + - 56763 + - 56764 + - 56765 + - 56766 + - 56767 + - 56768 + - 56769 + - 56770 + - 56771 + - 56772 + - 56773 + - 56774 + - 56775 + - 56776 + - 56777 + - 56778 + - 56779 + - 56780 + - 56781 + - 56782 + - 56783 + - 56784 + - 56785 + - 56786 + - 56787 + - 56788 + - 56789 + - 56790 + - 56791 + - 56792 + - 56793 + - 56794 + - 56795 + - 56796 + - 56797 + - 56798 + - 56799 + - 56800 + - 56801 + - 56802 + - 56803 + - 56804 + - 56805 + - 56806 + - 56807 + - 56808 + - 56809 + - 56810 + - 56811 + - 56812 + - 56813 + - 56814 + - 56815 + - 56816 + - 56817 + - 56818 + - 56819 + - 56820 + - 56821 + - 56822 + - 56823 + - 56824 + - 56825 + - 56826 + - 56827 + - 56828 + - 56829 + - 56830 + - 56831 + - 56832 + - 56833 + - 56834 + - 56835 + - 56836 + - 56837 + - 56838 + - 56839 + - 56840 + - 56841 + - 56842 + - 56843 + - 56844 + - 56845 + - 56846 + - 56847 + - 56848 + - 56849 + - 56850 + - 56851 + - 56852 + - 56853 + - 56854 + - 56855 + - 56856 + - 56857 + - 56858 + - 56859 + - 56860 + - 56861 + - 56862 + - 56863 + - 56864 + - 56865 + - 56866 + - 56867 + - 56868 + - 56869 + - 56870 + - 56871 + - 56872 + - 56873 + - 56874 + - 56875 + - 56876 + - 56877 + - 56878 + - 56879 + - 56880 + - 56881 + - 56882 + - 56883 + - 56884 + - 56885 + - 56886 + - 56887 + - 56888 + - 56889 + - 56890 + - 56891 + - 56892 + - 56893 + - 56894 + - 56895 + - 56896 + - 56897 + - 56898 + - 56899 + - 56900 + - 56901 + - 56902 + - 56903 + - 56904 + - 56905 + - 56906 + - 56907 + - 56908 + - 56909 + - 56910 + - 56911 + - 56912 + - 56913 + - 56914 + - 56915 + - 56916 + - 56917 + - 56918 + - 56919 + - 56920 + - 56921 + - 56922 + - 56923 + - 56924 + - 56925 + - 56926 + - 56927 + - 56928 + - 56929 + - 56930 + - 56931 + - 56932 + - 56933 + - 56934 + - 56935 + - 56936 + - 56937 + - 56938 + - 56939 + - 56940 + - 56941 + - 56942 + - 56943 + - 56944 + - 56945 + - 56946 + - 56947 + - 56948 + - 56949 + - 56950 + - 56951 + - 56952 + - 56953 + - 56954 + - 56955 + - 56956 + - 56957 + - 56958 + - 56959 + - 56960 + - 56961 + - 56962 + - 56963 + - 56964 + - 56965 + - 56966 + - 56967 + - 56968 + - 56969 + - 56970 + - 56971 + - 56972 + - 56973 + - 56974 + - 56975 + - 56976 + - 56977 + - 56978 + - 56979 + - 56980 + - 56981 + - 56982 + - 56983 + - 56984 + - 56985 + - 56986 + - 56987 + - 56988 + - 56989 + - 56990 + - 56991 + - 56992 + - 56993 + - 56994 + - 56995 + - 56996 + - 56997 + - 56998 + - 56999 + - 57000 + - 57001 + - 57002 + - 57003 + - 57004 + - 57005 + - 57006 + - 57007 + - 57008 + - 57009 + - 57010 + - 57011 + - 57012 + - 57013 + - 57014 + - 57015 + - 57016 + - 57017 + - 57018 + - 57019 + - 57020 + - 57021 + - 57022 + - 57023 + - 57024 + - 57025 + - 57026 + - 57027 + - 57028 + - 57029 + - 57030 + - 57031 + - 57032 + - 57033 + - 57034 + - 57035 + - 57036 + - 57037 + - 57038 + - 57039 + - 57040 + - 57041 + - 57042 + - 57043 + - 57044 + - 57045 + - 57046 + - 57047 + - 57048 + - 57049 + - 57050 + - 57051 + - 57052 + - 57053 + - 57054 + - 57055 + - 57056 + - 57057 + - 57058 + - 57059 + - 57060 + - 57061 + - 57062 + - 57063 + - 57064 + - 57065 + - 57066 + - 57067 + - 57068 + - 57069 + - 57070 + - 57071 + - 57072 + - 57073 + - 57074 + - 57075 + - 57076 + - 57077 + - 57078 + - 57079 + - 57080 + - 57081 + - 57082 + - 57083 + - 57084 + - 57085 + - 57086 + - 57087 + - 57088 + - 57089 + - 57090 + - 57091 + - 57092 + - 57093 + - 57094 + - 57095 + - 57096 + - 57097 + - 57098 + - 57099 + - 57100 + - 57101 + - 57102 + - 57103 + - 57104 + - 57105 + - 57106 + - 57107 + - 57108 + - 57109 + - 57110 + - 57111 + - 57112 + - 57113 + - 57114 + - 57115 + - 57116 + - 57117 + - 57118 + - 57119 + - 57120 + - 57121 + - 57122 + - 57123 + - 57124 + - 57125 + - 57126 + - 57127 + - 57128 + - 57129 + - 57130 + - 57131 + - 57132 + - 57133 + - 57134 + - 57135 + - 57136 + - 57137 + - 57138 + - 57139 + - 57140 + - 57141 + - 57142 + - 57143 + - 57144 + - 57145 + - 57146 + - 57147 + - 57148 + - 57149 + - 57150 + - 57151 + - 57152 + - 57153 + - 57154 + - 57155 + - 57156 + - 57157 + - 57158 + - 57159 + - 57160 + - 57161 + - 57162 + - 57163 + - 57164 + - 57165 + - 57166 + - 57167 + - 57168 + - 57169 + - 57170 + - 57171 + - 57172 + - 57173 + - 57174 + - 57175 + - 57176 + - 57177 + - 57178 + - 57179 + - 57180 + - 57181 + - 57182 + - 57183 + - 57184 + - 57185 + - 57186 + - 57187 + - 57188 + - 57189 + - 57190 + - 57191 + - 57192 + - 57193 + - 57194 + - 57195 + - 57196 + - 57197 + - 57198 + - 57199 + - 57200 + - 57201 + - 57202 + - 57203 + - 57204 + - 57205 + - 57206 + - 57207 + - 57208 + - 57209 + - 57210 + - 57211 + - 57212 + - 57213 + - 57214 + - 57215 + - 57216 + - 57217 + - 57218 + - 57219 + - 57220 + - 57221 + - 57222 + - 57223 + - 57224 + - 57225 + - 57226 + - 57227 + - 57228 + - 57229 + - 57230 + - 57231 + - 57232 + - 57233 + - 57234 + - 57235 + - 57236 + - 57237 + - 57238 + - 57239 + - 57240 + - 57241 + - 57242 + - 57243 + - 57244 + - 57245 + - 57246 + - 57247 + - 57248 + - 57249 + - 57250 + - 57251 + - 57252 + - 57253 + - 57254 + - 57255 + - 57256 + - 57257 + - 57258 + - 57259 + - 57260 + - 57261 + - 57262 + - 57263 + - 57264 + - 57265 + - 57266 + - 57267 + - 57268 + - 57269 + - 57270 + - 57271 + - 57272 + - 57273 + - 57274 + - 57275 + - 57276 + - 57277 + - 57278 + - 57279 + - 57280 + - 57281 + - 57282 + - 57283 + - 57284 + - 57285 + - 57286 + - 57287 + - 57288 + - 57289 + - 57290 + - 57291 + - 57292 + - 57293 + - 57294 + - 57295 + - 57296 + - 57297 + - 57298 + - 57299 + - 57300 + - 57301 + - 57302 + - 57303 + - 57304 + - 57305 + - 57306 + - 57307 + - 57308 + - 57309 + - 57310 + - 57311 + - 57312 + - 57313 + - 57314 + - 57315 + - 57316 + - 57317 + - 57318 + - 57319 + - 57320 + - 57321 + - 57322 + - 57323 + - 57324 + - 57325 + - 57326 + - 57327 + - 57328 + - 57329 + - 57330 + - 57331 + - 57332 + - 57333 + - 57334 + - 57335 + - 57336 + - 57337 + - 57338 + - 57339 + - 57340 + - 57341 + - 57342 + - 57343 + - 57344 + - 57345 + - 57346 + - 57347 + - 57348 + - 57349 + - 57350 + - 57351 + - 57352 + - 57353 + - 57354 + - 57355 + - 57356 + - 57357 + - 57358 + - 57359 + - 57360 + - 57361 + - 57362 + - 57363 + - 57364 + - 57365 + - 57366 + - 57367 + - 57368 + - 57369 + - 57370 + - 57371 + - 57372 + - 57373 + - 57374 + - 57375 + - 57376 + - 57377 + - 57378 + - 57379 + - 57380 + - 57381 + - 57382 + - 57383 + - 57384 + - 57385 + - 57386 + - 57387 + - 57388 + - 57389 + - 57390 + - 57391 + - 57392 + - 57393 + - 57394 + - 57395 + - 57396 + - 57397 + - 57398 + - 57399 + - 57400 + - 57401 + - 57402 + - 57403 + - 57404 + - 57405 + - 57406 + - 57407 + - 57408 + - 57409 + - 57410 + - 57411 + - 57412 + - 57413 + - 57414 + - 57415 + - 57416 + - 57417 + - 57418 + - 57419 + - 57420 + - 57421 + - 57422 + - 57423 + - 57424 + - 57425 + - 57426 + - 57427 + - 57428 + - 57429 + - 57430 + - 57431 + - 57432 + - 57433 + - 57434 + - 57435 + - 57436 + - 57437 + - 57438 + - 57439 + - 57440 + - 57441 + - 57442 + - 57443 + - 57444 + - 57445 + - 57446 + - 57447 + - 57448 + - 57449 + - 57450 + - 57451 + - 57452 + - 57453 + - 57454 + - 57455 + - 57456 + - 57457 + - 57458 + - 57459 + - 57460 + - 57461 + - 57462 + - 57463 + - 57464 + - 57465 + - 57466 + - 57467 + - 57468 + - 57469 + - 57470 + - 57471 + - 57472 + - 57473 + - 57474 + - 57475 + - 57476 + - 57477 + - 57478 + - 57479 + - 57480 + - 57481 + - 57482 + - 57483 + - 57484 + - 57485 + - 57486 + - 57487 + - 57488 + - 57489 + - 57490 + - 57491 + - 57492 + - 57493 + - 57494 + - 57495 + - 57496 + - 57497 + - 57498 + - 57499 + - 57500 + - 57501 + - 57502 + - 57503 + - 57504 + - 57505 + - 57506 + - 57507 + - 57508 + - 57509 + - 57510 + - 57511 + - 57512 + - 57513 + - 57514 + - 57515 + - 57516 + - 57517 + - 57518 + - 57519 + - 57520 + - 57521 + - 57522 + - 57523 + - 57524 + - 57525 + - 57526 + - 57527 + - 57528 + - 57529 + - 57530 + - 57531 + - 57532 + - 57533 + - 57534 + - 57535 + - 57536 + - 57537 + - 57538 + - 57539 + - 57540 + - 57541 + - 57542 + - 57543 + - 57544 + - 57545 + - 57546 + - 57547 + - 57548 + - 57549 + - 57550 + - 57551 + - 57552 + - 57553 + - 57554 + - 57555 + - 57556 + - 57557 + - 57558 + - 57559 + - 57560 + - 57561 + - 57562 + - 57563 + - 57564 + - 57565 + - 57566 + - 57567 + - 57568 + - 57569 + - 57570 + - 57571 + - 57572 + - 57573 + - 57574 + - 57575 + - 57576 + - 57577 + - 57578 + - 57579 + - 57580 + - 57581 + - 57582 + - 57583 + - 57584 + - 57585 + - 57586 + - 57587 + - 57588 + - 57589 + - 57590 + - 57591 + - 57592 + - 57593 + - 57594 + - 57595 + - 57596 + - 57597 + - 57598 + - 57599 + - 57600 + - 57601 + - 57602 + - 57603 + - 57604 + - 57605 + - 57606 + - 57607 + - 57608 + - 57609 + - 57610 + - 57611 + - 57612 + - 57613 + - 57614 + - 57615 + - 57616 + - 57617 + - 57618 + - 57619 + - 57620 + - 57621 + - 57622 + - 57623 + - 57624 + - 57625 + - 57626 + - 57627 + - 57628 + - 57629 + - 57630 + - 57631 + - 57632 + - 57633 + - 57634 + - 57635 + - 57636 + - 57637 + - 57638 + - 57639 + - 57640 + - 57641 + - 57642 + - 57643 + - 57644 + - 57645 + - 57646 + - 57647 + - 57648 + - 57649 + - 57650 + - 57651 + - 57652 + - 57653 + - 57654 + - 57655 + - 57656 + - 57657 + - 57658 + - 57659 + - 57660 + - 57661 + - 57662 + - 57663 + - 57664 + - 57665 + - 57666 + - 57667 + - 57668 + - 57669 + - 57670 + - 57671 + - 57672 + - 57673 + - 57674 + - 57675 + - 57676 + - 57677 + - 57678 + - 57679 + - 57680 + - 57681 + - 57682 + - 57683 + - 57684 + - 57685 + - 57686 + - 57687 + - 57688 + - 57689 + - 57690 + - 57691 + - 57692 + - 57693 + - 57694 + - 57695 + - 57696 + - 57697 + - 57698 + - 57699 + - 57700 + - 57701 + - 57702 + - 57703 + - 57704 + - 57705 + - 57706 + - 57707 + - 57708 + - 57709 + - 57710 + - 57711 + - 57712 + - 57713 + - 57714 + - 57715 + - 57716 + - 57717 + - 57718 + - 57719 + - 57720 + - 57721 + - 57722 + - 57723 + - 57724 + - 57725 + - 57726 + - 57727 + - 57728 + - 57729 + - 57730 + - 57731 + - 57732 + - 57733 + - 57734 + - 57735 + - 57736 + - 57737 + - 57738 + - 57739 + - 57740 + - 57741 + - 57742 + - 57743 + - 57744 + - 57745 + - 57746 + - 57747 + - 57748 + - 57749 + - 57750 + - 57751 + - 57752 + - 57753 + - 57754 + - 57755 + - 57756 + - 57757 + - 57758 + - 57759 + - 57760 + - 57761 + - 57762 + - 57763 + - 57764 + - 57765 + - 57766 + - 57767 + - 57768 + - 57769 + - 57770 + - 57771 + - 57772 + - 57773 + - 57774 + - 57775 + - 57776 + - 57777 + - 57778 + - 57779 + - 57780 + - 57781 + - 57782 + - 57783 + - 57784 + - 57785 + - 57786 + - 57787 + - 57788 + - 57789 + - 57790 + - 57791 + - 57792 + - 57793 + - 57794 + - 57795 + - 57796 + - 57797 + - 57798 + - 57799 + - 57800 + - 57801 + - 57802 + - 57803 + - 57804 + - 57805 + - 57806 + - 57807 + - 57808 + - 57809 + - 57810 + - 57811 + - 57812 + - 57813 + - 57814 + - 57815 + - 57816 + - 57817 + - 57818 + - 57819 + - 57820 + - 57821 + - 57822 + - 57823 + - 57824 + - 57825 + - 57826 + - 57827 + - 57828 + - 57829 + - 57830 + - 57831 + - 57832 + - 57833 + - 57834 + - 57835 + - 57836 + - 57837 + - 57838 + - 57839 + - 57840 + - 57841 + - 57842 + - 57843 + - 57844 + - 57845 + - 57846 + - 57847 + - 57848 + - 57849 + - 57850 + - 57851 + - 57852 + - 57853 + - 57854 + - 57855 + - 57856 + - 57857 + - 57858 + - 57859 + - 57860 + - 57861 + - 57862 + - 57863 + - 57864 + - 57865 + - 57866 + - 57867 + - 57868 + - 57869 + - 57870 + - 57871 + - 57872 + - 57873 + - 57874 + - 57875 + - 57876 + - 57877 + - 57878 + - 57879 + - 57880 + - 57881 + - 57882 + - 57883 + - 57884 + - 57885 + - 57886 + - 57887 + - 57888 + - 57889 + - 57890 + - 57891 + - 57892 + - 57893 + - 57894 + - 57895 + - 57896 + - 57897 + - 57898 + - 57899 + - 57900 + - 57901 + - 57902 + - 57903 + - 57904 + - 57905 + - 57906 + - 57907 + - 57908 + - 57909 + - 57910 + - 57911 + - 57912 + - 57913 + - 57914 + - 57915 + - 57916 + - 57917 + - 57918 + - 57919 + - 57920 + - 57921 + - 57922 + - 57923 + - 57924 + - 57925 + - 57926 + - 57927 + - 57928 + - 57929 + - 57930 + - 57931 + - 57932 + - 57933 + - 57934 + - 57935 + - 57936 + - 57937 + - 57938 + - 57939 + - 57940 + - 57941 + - 57942 + - 57943 + - 57944 + - 57945 + - 57946 + - 57947 + - 57948 + - 57949 + - 57950 + - 57951 + - 57952 + - 57953 + - 57954 + - 57955 + - 57956 + - 57957 + - 57958 + - 57959 + - 57960 + - 57961 + - 57962 + - 57963 + - 57964 + - 57965 + - 57966 + - 57967 + - 57968 + - 57969 + - 57970 + - 57971 + - 57972 + - 57973 + - 57974 + - 57975 + - 57976 + - 57977 + - 57978 + - 57979 + - 57980 + - 57981 + - 57982 + - 57983 + - 57984 + - 57985 + - 57986 + - 57987 + - 57988 + - 57989 + - 57990 + - 57991 + - 57992 + - 57993 + - 57994 + - 57995 + - 57996 + - 57997 + - 57998 + - 57999 + - 58000 + - 58001 + - 58002 + - 58003 + - 58004 + - 58005 + - 58006 + - 58007 + - 58008 + - 58009 + - 58010 + - 58011 + - 58012 + - 58013 + - 58014 + - 58015 + - 58016 + - 58017 + - 58018 + - 58019 + - 58020 + - 58021 + - 58022 + - 58023 + - 58024 + - 58025 + - 58026 + - 58027 + - 58028 + - 58029 + - 58030 + - 58031 + - 58032 + - 58033 + - 58034 + - 58035 + - 58036 + - 58037 + - 58038 + - 58039 + - 58040 + - 58041 + - 58042 + - 58043 + - 58044 + - 58045 + - 58046 + - 58047 + - 58048 + - 58049 + - 58050 + - 58051 + - 58052 + - 58053 + - 58054 + - 58055 + - 58056 + - 58057 + - 58058 + - 58059 + - 58060 + - 58061 + - 58062 + - 58063 + - 58064 + - 58065 + - 58066 + - 58067 + - 58068 + - 58069 + - 58070 + - 58071 + - 58072 + - 58073 + - 58074 + - 58075 + - 58076 + - 58077 + - 58078 + - 58079 + - 58080 + - 58081 + - 58082 + - 58083 + - 58084 + - 58085 + - 58086 + - 58087 + - 58088 + - 58089 + - 58090 + - 58091 + - 58092 + - 58093 + - 58094 + - 58095 + - 58096 + - 58097 + - 58098 + - 58099 + - 58100 + - 58101 + - 58102 + - 58103 + - 58104 + - 58105 + - 58106 + - 58107 + - 58108 + - 58109 + - 58110 + - 58111 + - 58112 + - 58113 + - 58114 + - 58115 + - 58116 + - 58117 + - 58118 + - 58119 + - 58120 + - 58121 + - 58122 + - 58123 + - 58124 + - 58125 + - 58126 + - 58127 + - 58128 + - 58129 + - 58130 + - 58131 + - 58132 + - 58133 + - 58134 + - 58135 + - 58136 + - 58137 + - 58138 + - 58139 + - 58140 + - 58141 + - 58142 + - 58143 + - 58144 + - 58145 + - 58146 + - 58147 + - 58148 + - 58149 + - 58150 + - 58151 + - 58152 + - 58153 + - 58154 + - 58155 + - 58156 + - 58157 + - 58158 + - 58159 + - 58160 + - 58161 + - 58162 + - 58163 + - 58164 + - 58165 + - 58166 + - 58167 + - 58168 + - 58169 + - 58170 + - 58171 + - 58172 + - 58173 + - 58174 + - 58175 + - 58176 + - 58177 + - 58178 + - 58179 + - 58180 + - 58181 + - 58182 + - 58183 + - 58184 + - 58185 + - 58186 + - 58187 + - 58188 + - 58189 + - 58190 + - 58191 + - 58192 + - 58193 + - 58194 + - 58195 + - 58196 + - 58197 + - 58198 + - 58199 + - 58200 + - 58201 + - 58202 + - 58203 + - 58204 + - 58205 + - 58206 + - 58207 + - 58208 + - 58209 + - 58210 + - 58211 + - 58212 + - 58213 + - 58214 + - 58215 + - 58216 + - 58217 + - 58218 + - 58219 + - 58220 + - 58221 + - 58222 + - 58223 + - 58224 + - 58225 + - 58226 + - 58227 + - 58228 + - 58229 + - 58230 + - 58231 + - 58232 + - 58233 + - 58234 + - 58235 + - 58236 + - 58237 + - 58238 + - 58239 + - 58240 + - 58241 + - 58242 + - 58243 + - 58244 + - 58245 + - 58246 + - 58247 + - 58248 + - 58249 + - 58250 + - 58251 + - 58252 + - 58253 + - 58254 + - 58255 + - 58256 + - 58257 + - 58258 + - 58259 + - 58260 + - 58261 + - 58262 + - 58263 + - 58264 + - 58265 + - 58266 + - 58267 + - 58268 + - 58269 + - 58270 + - 58271 + - 58272 + - 58273 + - 58274 + - 58275 + - 58276 + - 58277 + - 58278 + - 58279 + - 58280 + - 58281 + - 58282 + - 58283 + - 58284 + - 58285 + - 58286 + - 58287 + - 58288 + - 58289 + - 58290 + - 58291 + - 58292 + - 58293 + - 58294 + - 58295 + - 58296 + - 58297 + - 58298 + - 58299 + - 58300 + - 58301 + - 58302 + - 58303 + - 58304 + - 58305 + - 58306 + - 58307 + - 58308 + - 58309 + - 58310 + - 58311 + - 58312 + - 58313 + - 58314 + - 58315 + - 58316 + - 58317 + - 58318 + - 58319 + - 58320 + - 58321 + - 58322 + - 58323 + - 58324 + - 58325 + - 58326 + - 58327 + - 58328 + - 58329 + - 58330 + - 58331 + - 58332 + - 58333 + - 58334 + - 58335 + - 58336 + - 58337 + - 58338 + - 58339 + - 58340 + - 58341 + - 58342 + - 58343 + - 58344 + - 58345 + - 58346 + - 58347 + - 58348 + - 58349 + - 58350 + - 58351 + - 58352 + - 58353 + - 58354 + - 58355 + - 58356 + - 58357 + - 58358 + - 58359 + - 58360 + - 58361 + - 58362 + - 58363 + - 58364 + - 58365 + - 58366 + - 58367 + - 58368 + - 58369 + - 58370 + - 58371 + - 58372 + - 58373 + - 58374 + - 58375 + - 58376 + - 58377 + - 58378 + - 58379 + - 58380 + - 58381 + - 58382 + - 58383 + - 58384 + - 58385 + - 58386 + - 58387 + - 58388 + - 58389 + - 58390 + - 58391 + - 58392 + - 58393 + - 58394 + - 58395 + - 58396 + - 58397 + - 58398 + - 58399 + - 58400 + - 58401 + - 58402 + - 58403 + - 58404 + - 58405 + - 58406 + - 58407 + - 58408 + - 58409 + - 58410 + - 58411 + - 58412 + - 58413 + - 58414 + - 58415 + - 58416 + - 58417 + - 58418 + - 58419 + - 58420 + - 58421 + - 58422 + - 58423 + - 58424 + - 58425 + - 58426 + - 58427 + - 58428 + - 58429 + - 58430 + - 58431 + - 58432 + - 58433 + - 58434 + - 58435 + - 58436 + - 58437 + - 58438 + - 58439 + - 58440 + - 58441 + - 58442 + - 58443 + - 58444 + - 58445 + - 58446 + - 58447 + - 58448 + - 58449 + - 58450 + - 58451 + - 58452 + - 58453 + - 58454 + - 58455 + - 58456 + - 58457 + - 58458 + - 58459 + - 58460 + - 58461 + - 58462 + - 58463 + - 58464 + - 58465 + - 58466 + - 58467 + - 58468 + - 58469 + - 58470 + - 58471 + - 58472 + - 58473 + - 58474 + - 58475 + - 58476 + - 58477 + - 58478 + - 58479 + - 58480 + - 58481 + - 58482 + - 58483 + - 58484 + - 58485 + - 58486 + - 58487 + - 58488 + - 58489 + - 58490 + - 58491 + - 58492 + - 58493 + - 58494 + - 58495 + - 58496 + - 58497 + - 58498 + - 58499 + - 58500 + - 58501 + - 58502 + - 58503 + - 58504 + - 58505 + - 58506 + - 58507 + - 58508 + - 58509 + - 58510 + - 58511 + - 58512 + - 58513 + - 58514 + - 58515 + - 58516 + - 58517 + - 58518 + - 58519 + - 58520 + - 58521 + - 58522 + - 58523 + - 58524 + - 58525 + - 58526 + - 58527 + - 58528 + - 58529 + - 58530 + - 58531 + - 58532 + - 58533 + - 58534 + - 58535 + - 58536 + - 58537 + - 58538 + - 58539 + - 58540 + - 58541 + - 58542 + - 58543 + - 58544 + - 58545 + - 58546 + - 58547 + - 58548 + - 58549 + - 58550 + - 58551 + - 58552 + - 58553 + - 58554 + - 58555 + - 58556 + - 58557 + - 58558 + - 58559 + - 58560 + - 58561 + - 58562 + - 58563 + - 58564 + - 58565 + - 58566 + - 58567 + - 58568 + - 58569 + - 58570 + - 58571 + - 58572 + - 58573 + - 58574 + - 58575 + - 58576 + - 58577 + - 58578 + - 58579 + - 58580 + - 58581 + - 58582 + - 58583 + - 58584 + - 58585 + - 58586 + - 58587 + - 58588 + - 58589 + - 58590 + - 58591 + - 58592 + - 58593 + - 58594 + - 58595 + - 58596 + - 58597 + - 58598 + - 58599 + - 58600 + - 58601 + - 58602 + - 58603 + - 58604 + - 58605 + - 58606 + - 58607 + - 58608 + - 58609 + - 58610 + - 58611 + - 58612 + - 58613 + - 58614 + - 58615 + - 58616 + - 58617 + - 58618 + - 58619 + - 58620 + - 58621 + - 58622 + - 58623 + - 58624 + - 58625 + - 58626 + - 58627 + - 58628 + - 58629 + - 58630 + - 58631 + - 58632 + - 58633 + - 58634 + - 58635 + - 58636 + - 58637 + - 58638 + - 58639 + - 58640 + - 58641 + - 58642 + - 58643 + - 58644 + - 58645 + - 58646 + - 58647 + - 58648 + - 58649 + - 58650 + - 58651 + - 58652 + - 58653 + - 58654 + - 58655 + - 58656 + - 58657 + - 58658 + - 58659 + - 58660 + - 58661 + - 58662 + - 58663 + - 58664 + - 58665 + - 58666 + - 58667 + - 58668 + - 58669 + - 58670 + - 58671 + - 58672 + - 58673 + - 58674 + - 58675 + - 58676 + - 58677 + - 58678 + - 58679 + - 58680 + - 58681 + - 58682 + - 58683 + - 58684 + - 58685 + - 58686 + - 58687 + - 58688 + - 58689 + - 58690 + - 58691 + - 58692 + - 58693 + - 58694 + - 58695 + - 58696 + - 58697 + - 58698 + - 58699 + - 58700 + - 58701 + - 58702 + - 58703 + - 58704 + - 58705 + - 58706 + - 58707 + - 58708 + - 58709 + - 58710 + - 58711 + - 58712 + - 58713 + - 58714 + - 58715 + - 58716 + - 58717 + - 58718 + - 58719 + - 58720 + - 58721 + - 58722 + - 58723 + - 58724 + - 58725 + - 58726 + - 58727 + - 58728 + - 58729 + - 58730 + - 58731 + - 58732 + - 58733 + - 58734 + - 58735 + - 58736 + - 58737 + - 58738 + - 58739 + - 58740 + - 58741 + - 58742 + - 58743 + - 58744 + - 58745 + - 58746 + - 58747 + - 58748 + - 58749 + - 58750 + - 58751 + - 58752 + - 58753 + - 58754 + - 58755 + - 58756 + - 58757 + - 58758 + - 58759 + - 58760 + - 58761 + - 58762 + - 58763 + - 58764 + - 58765 + - 58766 + - 58767 + - 58768 + - 58769 + - 58770 + - 58771 + - 58772 + - 58773 + - 58774 + - 58775 + - 58776 + - 58777 + - 58778 + - 58779 + - 58780 + - 58781 + - 58782 + - 58783 + - 58784 + - 58785 + - 58786 + - 58787 + - 58788 + - 58789 + - 58790 + - 58791 + - 58792 + - 58793 + - 58794 + - 58795 + - 58796 + - 58797 + - 58798 + - 58799 + - 58800 + - 58801 + - 58802 + - 58803 + - 58804 + - 58805 + - 58806 + - 58807 + - 58808 + - 58809 + - 58810 + - 58811 + - 58812 + - 58813 + - 58814 + - 58815 + - 58816 + - 58817 + - 58818 + - 58819 + - 58820 + - 58821 + - 58822 + - 58823 + - 58824 + - 58825 + - 58826 + - 58827 + - 58828 + - 58829 + - 58830 + - 58831 + - 58832 + - 58833 + - 58834 + - 58835 + - 58836 + - 58837 + - 58838 + - 58839 + - 58840 + - 58841 + - 58842 + - 58843 + - 58844 + - 58845 + - 58846 + - 58847 + - 58848 + - 58849 + - 58850 + - 58851 + - 58852 + - 58853 + - 58854 + - 58855 + - 58856 + - 58857 + - 58858 + - 58859 + - 58860 + - 58861 + - 58862 + - 58863 + - 58864 + - 58865 + - 58866 + - 58867 + - 58868 + - 58869 + - 58870 + - 58871 + - 58872 + - 58873 + - 58874 + - 58875 + - 58876 + - 58877 + - 58878 + - 58879 + - 58880 + - 58881 + - 58882 + - 58883 + - 58884 + - 58885 + - 58886 + - 58887 + - 58888 + - 58889 + - 58890 + - 58891 + - 58892 + - 58893 + - 58894 + - 58895 + - 58896 + - 58897 + - 58898 + - 58899 + - 58900 + - 58901 + - 58902 + - 58903 + - 58904 + - 58905 + - 58906 + - 58907 + - 58908 + - 58909 + - 58910 + - 58911 + - 58912 + - 58913 + - 58914 + - 58915 + - 58916 + - 58917 + - 58918 + - 58919 + - 58920 + - 58921 + - 58922 + - 58923 + - 58924 + - 58925 + - 58926 + - 58927 + - 58928 + - 58929 + - 58930 + - 58931 + - 58932 + - 58933 + - 58934 + - 58935 + - 58936 + - 58937 + - 58938 + - 58939 + - 58940 + - 58941 + - 58942 + - 58943 + - 58944 + - 58945 + - 58946 + - 58947 + - 58948 + - 58949 + - 58950 + - 58951 + - 58952 + - 58953 + - 58954 + - 58955 + - 58956 + - 58957 + - 58958 + - 58959 + - 58960 + - 58961 + - 58962 + - 58963 + - 58964 + - 58965 + - 58966 + - 58967 + - 58968 + - 58969 + - 58970 + - 58971 + - 58972 + - 58973 + - 58974 + - 58975 + - 58976 + - 58977 + - 58978 + - 58979 + - 58980 + - 58981 + - 58982 + - 58983 + - 58984 + - 58985 + - 58986 + - 58987 + - 58988 + - 58989 + - 58990 + - 58991 + - 58992 + - 58993 + - 58994 + - 58995 + - 58996 + - 58997 + - 58998 + - 58999 + - 59000 + - 59001 + - 59002 + - 59003 + - 59004 + - 59005 + - 59006 + - 59007 + - 59008 + - 59009 + - 59010 + - 59011 + - 59012 + - 59013 + - 59014 + - 59015 + - 59016 + - 59017 + - 59018 + - 59019 + - 59020 + - 59021 + - 59022 + - 59023 + - 59024 + - 59025 + - 59026 + - 59027 + - 59028 + - 59029 + - 59030 + - 59031 + - 59032 + - 59033 + - 59034 + - 59035 + - 59036 + - 59037 + - 59038 + - 59039 + - 59040 + - 59041 + - 59042 + - 59043 + - 59044 + - 59045 + - 59046 + - 59047 + - 59048 + - 59049 + - 59050 + - 59051 + - 59052 + - 59053 + - 59054 + - 59055 + - 59056 + - 59057 + - 59058 + - 59059 + - 59060 + - 59061 + - 59062 + - 59063 + - 59064 + - 59065 + - 59066 + - 59067 + - 59068 + - 59069 + - 59070 + - 59071 + - 59072 + - 59073 + - 59074 + - 59075 + - 59076 + - 59077 + - 59078 + - 59079 + - 59080 + - 59081 + - 59082 + - 59083 + - 59084 + - 59085 + - 59086 + - 59087 + - 59088 + - 59089 + - 59090 + - 59091 + - 59092 + - 59093 + - 59094 + - 59095 + - 59096 + - 59097 + - 59098 + - 59099 + - 59100 + - 59101 + - 59102 + - 59103 + - 59104 + - 59105 + - 59106 + - 59107 + - 59108 + - 59109 + - 59110 + - 59111 + - 59112 + - 59113 + - 59114 + - 59115 + - 59116 + - 59117 + - 59118 + - 59119 + - 59120 + - 59121 + - 59122 + - 59123 + - 59124 + - 59125 + - 59126 + - 59127 + - 59128 + - 59129 + - 59130 + - 59131 + - 59132 + - 59133 + - 59134 + - 59135 + - 59136 + - 59137 + - 59138 + - 59139 + - 59140 + - 59141 + - 59142 + - 59143 + - 59144 + - 59145 + - 59146 + - 59147 + - 59148 + - 59149 + - 59150 + - 59151 + - 59152 + - 59153 + - 59154 + - 59155 + - 59156 + - 59157 + - 59158 + - 59159 + - 59160 + - 59161 + - 59162 + - 59163 + - 59164 + - 59165 + - 59166 + - 59167 + - 59168 + - 59169 + - 59170 + - 59171 + - 59172 + - 59173 + - 59174 + - 59175 + - 59176 + - 59177 + - 59178 + - 59179 + - 59180 + - 59181 + - 59182 + - 59183 + - 59184 + - 59185 + - 59186 + - 59187 + - 59188 + - 59189 + - 59190 + - 59191 + - 59192 + - 59193 + - 59194 + - 59195 + - 59196 + - 59197 + - 59198 + - 59199 + - 59200 + - 59201 + - 59202 + - 59203 + - 59204 + - 59205 + - 59206 + - 59207 + - 59208 + - 59209 + - 59210 + - 59211 + - 59212 + - 59213 + - 59214 + - 59215 + - 59216 + - 59217 + - 59218 + - 59219 + - 59220 + - 59221 + - 59222 + - 59223 + - 59224 + - 59225 + - 59226 + - 59227 + - 59228 + - 59229 + - 59230 + - 59231 + - 59232 + - 59233 + - 59234 + - 59235 + - 59236 + - 59237 + - 59238 + - 59239 + - 59240 + - 59241 + - 59242 + - 59243 + - 59244 + - 59245 + - 59246 + - 59247 + - 59248 + - 59249 + - 59250 + - 59251 + - 59252 + - 59253 + - 59254 + - 59255 + - 59256 + - 59257 + - 59258 + - 59259 + - 59260 + - 59261 + - 59262 + - 59263 + - 59264 + - 59265 + - 59266 + - 59267 + - 59268 + - 59269 + - 59270 + - 59271 + - 59272 + - 59273 + - 59274 + - 59275 + - 59276 + - 59277 + - 59278 + - 59279 + - 59280 + - 59281 + - 59282 + - 59283 + - 59284 + - 59285 + - 59286 + - 59287 + - 59288 + - 59289 + - 59290 + - 59291 + - 59292 + - 59293 + - 59294 + - 59295 + - 59296 + - 59297 + - 59298 + - 59299 + - 59300 + - 59301 + - 59302 + - 59303 + - 59304 + - 59305 + - 59306 + - 59307 + - 59308 + - 59309 + - 59310 + - 59311 + - 59312 + - 59313 + - 59314 + - 59315 + - 59316 + - 59317 + - 59318 + - 59319 + - 59320 + - 59321 + - 59322 + - 59323 + - 59324 + - 59325 + - 59326 + - 59327 + - 59328 + - 59329 + - 59330 + - 59331 + - 59332 + - 59333 + - 59334 + - 59335 + - 59336 + - 59337 + - 59338 + - 59339 + - 59340 + - 59341 + - 59342 + - 59343 + - 59344 + - 59345 + - 59346 + - 59347 + - 59348 + - 59349 + - 59350 + - 59351 + - 59352 + - 59353 + - 59354 + - 59355 + - 59356 + - 59357 + - 59358 + - 59359 + - 59360 + - 59361 + - 59362 + - 59363 + - 59364 + - 59365 + - 59366 + - 59367 + - 59368 + - 59369 + - 59370 + - 59371 + - 59372 + - 59373 + - 59374 + - 59375 + - 59376 + - 59377 + - 59378 + - 59379 + - 59380 + - 59381 + - 59382 + - 59383 + - 59384 + - 59385 + - 59386 + - 59387 + - 59388 + - 59389 + - 59390 + - 59391 + - 59392 + - 59393 + - 59394 + - 59395 + - 59396 + - 59397 + - 59398 + - 59399 + - 59400 + - 59401 + - 59402 + - 59403 + - 59404 + - 59405 + - 59406 + - 59407 + - 59408 + - 59409 + - 59410 + - 59411 + - 59412 + - 59413 + - 59414 + - 59415 + - 59416 + - 59417 + - 59418 + - 59419 + - 59420 + - 59421 + - 59422 + - 59423 + - 59424 + - 59425 + - 59426 + - 59427 + - 59428 + - 59429 + - 59430 + - 59431 + - 59432 + - 59433 + - 59434 + - 59435 + - 59436 + - 59437 + - 59438 + - 59439 + - 59440 + - 59441 + - 59442 + - 59443 + - 59444 + - 59445 + - 59446 + - 59447 + - 59448 + - 59449 + - 59450 + - 59451 + - 59452 + - 59453 + - 59454 + - 59455 + - 59456 + - 59457 + - 59458 + - 59459 + - 59460 + - 59461 + - 59462 + - 59463 + - 59464 + - 59465 + - 59466 + - 59467 + - 59468 + - 59469 + - 59470 + - 59471 + - 59472 + - 59473 + - 59474 + - 59475 + - 59476 + - 59477 + - 59478 + - 59479 + - 59480 + - 59481 + - 59482 + - 59483 + - 59484 + - 59485 + - 59486 + - 59487 + - 59488 + - 59489 + - 59490 + - 59491 + - 59492 + - 59493 + - 59494 + - 59495 + - 59496 + - 59497 + - 59498 + - 59499 + - 59500 + - 59501 + - 59502 + - 59503 + - 59504 + - 59505 + - 59506 + - 59507 + - 59508 + - 59509 + - 59510 + - 59511 + - 59512 + - 59513 + - 59514 + - 59515 + - 59516 + - 59517 + - 59518 + - 59519 + - 59520 + - 59521 + - 59522 + - 59523 + - 59524 + - 59525 + - 59526 + - 59527 + - 59528 + - 59529 + - 59530 + - 59531 + - 59532 + - 59533 + - 59534 + - 59535 + - 59536 + - 59537 + - 59538 + - 59539 + - 59540 + - 59541 + - 59542 + - 59543 + - 59544 + - 59545 + - 59546 + - 59547 + - 59548 + - 59549 + - 59550 + - 59551 + - 59552 + - 59553 + - 59554 + - 59555 + - 59556 + - 59557 + - 59558 + - 59559 + - 59560 + - 59561 + - 59562 + - 59563 + - 59564 + - 59565 + - 59566 + - 59567 + - 59568 + - 59569 + - 59570 + - 59571 + - 59572 + - 59573 + - 59574 + - 59575 + - 59576 + - 59577 + - 59578 + - 59579 + - 59580 + - 59581 + - 59582 + - 59583 + - 59584 + - 59585 + - 59586 + - 59587 + - 59588 + - 59589 + - 59590 + - 59591 + - 59592 + - 59593 + - 59594 + - 59595 + - 59596 + - 59597 + - 59598 + - 59599 + - 59600 + - 59601 + - 59602 + - 59603 + - 59604 + - 59605 + - 59606 + - 59607 + - 59608 + - 59609 + - 59610 + - 59611 + - 59612 + - 59613 + - 59614 + - 59615 + - 59616 + - 59617 + - 59618 + - 59619 + - 59620 + - 59621 + - 59622 + - 59623 + - 59624 + - 59625 + - 59626 + - 59627 + - 59628 + - 59629 + - 59630 + - 59631 + - 59632 + - 59633 + - 59634 + - 59635 + - 59636 + - 59637 + - 59638 + - 59639 + - 59640 + - 59641 + - 59642 + - 59643 + - 59644 + - 59645 + - 59646 + - 59647 + - 59648 + - 59649 + - 59650 + - 59651 + - 59652 + - 59653 + - 59654 + - 59655 + - 59656 + - 59657 + - 59658 + - 59659 + - 59660 + - 59661 + - 59662 + - 59663 + - 59664 + - 59665 + - 59666 + - 59667 + - 59668 + - 59669 + - 59670 + - 59671 + - 59672 + - 59673 + - 59674 + - 59675 + - 59676 + - 59677 + - 59678 + - 59679 + - 59680 + - 59681 + - 59682 + - 59683 + - 59684 + - 59685 + - 59686 + - 59687 + - 59688 + - 59689 + - 59690 + - 59691 + - 59692 + - 59693 + - 59694 + - 59695 + - 59696 + - 59697 + - 59698 + - 59699 + - 59700 + - 59701 + - 59702 + - 59703 + - 59704 + - 59705 + - 59706 + - 59707 + - 59708 + - 59709 + - 59710 + - 59711 + - 59712 + - 59713 + - 59714 + - 59715 + - 59716 + - 59717 + - 59718 + - 59719 + - 59720 + - 59721 + - 59722 + - 59723 + - 59724 + - 59725 + - 59726 + - 59727 + - 59728 + - 59729 + - 59730 + - 59731 + - 59732 + - 59733 + - 59734 + - 59735 + - 59736 + - 59737 + - 59738 + - 59739 + - 59740 + - 59741 + - 59742 + - 59743 + - 59744 + - 59745 + - 59746 + - 59747 + - 59748 + - 59749 + - 59750 + - 59751 + - 59752 + - 59753 + - 59754 + - 59755 + - 59756 + - 59757 + - 59758 + - 59759 + - 59760 + - 59761 + - 59762 + - 59763 + - 59764 + - 59765 + - 59766 + - 59767 + - 59768 + - 59769 + - 59770 + - 59771 + - 59772 + - 59773 + - 59774 + - 59775 + - 59776 + - 59777 + - 59778 + - 59779 + - 59780 + - 59781 + - 59782 + - 59783 + - 59784 + - 59785 + - 59786 + - 59787 + - 59788 + - 59789 + - 59790 + - 59791 + - 59792 + - 59793 + - 59794 + - 59795 + - 59796 + - 59797 + - 59798 + - 59799 + - 59800 + - 59801 + - 59802 + - 59803 + - 59804 + - 59805 + - 59806 + - 59807 + - 59808 + - 59809 + - 59810 + - 59811 + - 59812 + - 59813 + - 59814 + - 59815 + - 59816 + - 59817 + - 59818 + - 59819 + - 59820 + - 59821 + - 59822 + - 59823 + - 59824 + - 59825 + - 59826 + - 59827 + - 59828 + - 59829 + - 59830 + - 59831 + - 59832 + - 59833 + - 59834 + - 59835 + - 59836 + - 59837 + - 59838 + - 59839 + - 59840 + - 59841 + - 59842 + - 59843 + - 59844 + - 59845 + - 59846 + - 59847 + - 59848 + - 59849 + - 59850 + - 59851 + - 59852 + - 59853 + - 59854 + - 59855 + - 59856 + - 59857 + - 59858 + - 59859 + - 59860 + - 59861 + - 59862 + - 59863 + - 59864 + - 59865 + - 59866 + - 59867 + - 59868 + - 59869 + - 59870 + - 59871 + - 59872 + - 59873 + - 59874 + - 59875 + - 59876 + - 59877 + - 59878 + - 59879 + - 59880 + - 59881 + - 59882 + - 59883 + - 59884 + - 59885 + - 59886 + - 59887 + - 59888 + - 59889 + - 59890 + - 59891 + - 59892 + - 59893 + - 59894 + - 59895 + - 59896 + - 59897 + - 59898 + - 59899 + - 59900 + - 59901 + - 59902 + - 59903 + - 59904 + - 59905 + - 59906 + - 59907 + - 59908 + - 59909 + - 59910 + - 59911 + - 59912 + - 59913 + - 59914 + - 59915 + - 59916 + - 59917 + - 59918 + - 59919 + - 59920 + - 59921 + - 59922 + - 59923 + - 59924 + - 59925 + - 59926 + - 59927 + - 59928 + - 59929 + - 59930 + - 59931 + - 59932 + - 59933 + - 59934 + - 59935 + - 59936 + - 59937 + - 59938 + - 59939 + - 59940 + - 59941 + - 59942 + - 59943 + - 59944 + - 59945 + - 59946 + - 59947 + - 59948 + - 59949 + - 59950 + - 59951 + - 59952 + - 59953 + - 59954 + - 59955 + - 59956 + - 59957 + - 59958 + - 59959 + - 59960 + - 59961 + - 59962 + - 59963 + - 59964 + - 59965 + - 59966 + - 59967 + - 59968 + - 59969 + - 59970 + - 59971 + - 59972 + - 59973 + - 59974 + - 59975 + - 59976 + - 59977 + - 59978 + - 59979 + - 59980 + - 59981 + - 59982 + - 59983 + - 59984 + - 59985 + - 59986 + - 59987 + - 59988 + - 59989 + - 59990 + - 59991 + - 59992 + - 59993 + - 59994 + - 59995 + - 59996 + - 59997 + - 59998 + - 59999 + - 60000 + - 60001 + - 60002 + - 60003 + - 60004 + - 60005 + - 60006 + - 60007 + - 60008 + - 60009 + - 60010 + - 60011 + - 60012 + - 60013 + - 60014 + - 60015 + - 60016 + - 60017 + - 60018 + - 60019 + - 60020 + - 60021 + - 60022 + - 60023 + - 60024 + - 60025 + - 60026 + - 60027 + - 60028 + - 60029 + - 60030 + - 60031 + - 60032 + - 60033 + - 60034 + - 60035 + - 60036 + - 60037 + - 60038 + - 60039 + - 60040 + - 60041 + - 60042 + - 60043 + - 60044 + - 60045 + - 60046 + - 60047 + - 60048 + - 60049 + - 60050 + - 60051 + - 60052 + - 60053 + - 60054 + - 60055 + - 60056 + - 60057 + - 60058 + - 60059 + - 60060 + - 60061 + - 60062 + - 60063 + - 60064 + - 60065 + - 60066 + - 60067 + - 60068 + - 60069 + - 60070 + - 60071 + - 60072 + - 60073 + - 60074 + - 60075 + - 60076 + - 60077 + - 60078 + - 60079 + - 60080 + - 60081 + - 60082 + - 60083 + - 60084 + - 60085 + - 60086 + - 60087 + - 60088 + - 60089 + - 60090 + - 60091 + - 60092 + - 60093 + - 60094 + - 60095 + - 60096 + - 60097 + - 60098 + - 60099 + - 60100 + - 60101 + - 60102 + - 60103 + - 60104 + - 60105 + - 60106 + - 60107 + - 60108 + - 60109 + - 60110 + - 60111 + - 60112 + - 60113 + - 60114 + - 60115 + - 60116 + - 60117 + - 60118 + - 60119 + - 60120 + - 60121 + - 60122 + - 60123 + - 60124 + - 60125 + - 60126 + - 60127 + - 60128 + - 60129 + - 60130 + - 60131 + - 60132 + - 60133 + - 60134 + - 60135 + - 60136 + - 60137 + - 60138 + - 60139 + - 60140 + - 60141 + - 60142 + - 60143 + - 60144 + - 60145 + - 60146 + - 60147 + - 60148 + - 60149 + - 60150 + - 60151 + - 60152 + - 60153 + - 60154 + - 60155 + - 60156 + - 60157 + - 60158 + - 60159 + - 60160 + - 60161 + - 60162 + - 60163 + - 60164 + - 60165 + - 60166 + - 60167 + - 60168 + - 60169 + - 60170 + - 60171 + - 60172 + - 60173 + - 60174 + - 60175 + - 60176 + - 60177 + - 60178 + - 60179 + - 60180 + - 60181 + - 60182 + - 60183 + - 60184 + - 60185 + - 60186 + - 60187 + - 60188 + - 60189 + - 60190 + - 60191 + - 60192 + - 60193 + - 60194 + - 60195 + - 60196 + - 60197 + - 60198 + - 60199 + - 60200 + - 60201 + - 60202 + - 60203 + - 60204 + - 60205 + - 60206 + - 60207 + - 60208 + - 60209 + - 60210 + - 60211 + - 60212 + - 60213 + - 60214 + - 60215 + - 60216 + - 60217 + - 60218 + - 60219 + - 60220 + - 60221 + - 60222 + - 60223 + - 60224 + - 60225 + - 60226 + - 60227 + - 60228 + - 60229 + - 60230 + - 60231 + - 60232 + - 60233 + - 60234 + - 60235 + - 60236 + - 60237 + - 60238 + - 60239 + - 60240 + - 60241 + - 60242 + - 60243 + - 60244 + - 60245 + - 60246 + - 60247 + - 60248 + - 60249 + - 60250 + - 60251 + - 60252 + - 60253 + - 60254 + - 60255 + - 60256 + - 60257 + - 60258 + - 60259 + - 60260 + - 60261 + - 60262 + - 60263 + - 60264 + - 60265 + - 60266 + - 60267 + - 60268 + - 60269 + - 60270 + - 60271 + - 60272 + - 60273 + - 60274 + - 60275 + - 60276 + - 60277 + - 60278 + - 60279 + - 60280 + - 60281 + - 60282 + - 60283 + - 60284 + - 60285 + - 60286 + - 60287 + - 60288 + - 60289 + - 60290 + - 60291 + - 60292 + - 60293 + - 60294 + - 60295 + - 60296 + - 60297 + - 60298 + - 60299 + - 60300 + - 60301 + - 60302 + - 60303 + - 60304 + - 60305 + - 60306 + - 60307 + - 60308 + - 60309 + - 60310 + - 60311 + - 60312 + - 60313 + - 60314 + - 60315 + - 60316 + - 60317 + - 60318 + - 60319 + - 60320 + - 60321 + - 60322 + - 60323 + - 60324 + - 60325 + - 60326 + - 60327 + - 60328 + - 60329 + - 60330 + - 60331 + - 60332 + - 60333 + - 60334 + - 60335 + - 60336 + - 60337 + - 60338 + - 60339 + - 60340 + - 60341 + - 60342 + - 60343 + - 60344 + - 60345 + - 60346 + - 60347 + - 60348 + - 60349 + - 60350 + - 60351 + - 60352 + - 60353 + - 60354 + - 60355 + - 60356 + - 60357 + - 60358 + - 60359 + - 60360 + - 60361 + - 60362 + - 60363 + - 60364 + - 60365 + - 60366 + - 60367 + - 60368 + - 60369 + - 60370 + - 60371 + - 60372 + - 60373 + - 60374 + - 60375 + - 60376 + - 60377 + - 60378 + - 60379 + - 60380 + - 60381 + - 60382 + - 60383 + - 60384 + - 60385 + - 60386 + - 60387 + - 60388 + - 60389 + - 60390 + - 60391 + - 60392 + - 60393 + - 60394 + - 60395 + - 60396 + - 60397 + - 60398 + - 60399 + - 60400 + - 60401 + - 60402 + - 60403 + - 60404 + - 60405 + - 60406 + - 60407 + - 60408 + - 60409 + - 60410 + - 60411 + - 60412 + - 60413 + - 60414 + - 60415 + - 60416 + - 60417 + - 60418 + - 60419 + - 60420 + - 60421 + - 60422 + - 60423 + - 60424 + - 60425 + - 60426 + - 60427 + - 60428 + - 60429 + - 60430 + - 60431 + - 60432 + - 60433 + - 60434 + - 60435 + - 60436 + - 60437 + - 60438 + - 60439 + - 60440 + - 60441 + - 60442 + - 60443 + - 60444 + - 60445 + - 60446 + - 60447 + - 60448 + - 60449 + - 60450 + - 60451 + - 60452 + - 60453 + - 60454 + - 60455 + - 60456 + - 60457 + - 60458 + - 60459 + - 60460 + - 60461 + - 60462 + - 60463 + - 60464 + - 60465 + - 60466 + - 60467 + - 60468 + - 60469 + - 60470 + - 60471 + - 60472 + - 60473 + - 60474 + - 60475 + - 60476 + - 60477 + - 60478 + - 60479 + - 60480 + - 60481 + - 60482 + - 60483 + - 60484 + - 60485 + - 60486 + - 60487 + - 60488 + - 60489 + - 60490 + - 60491 + - 60492 + - 60493 + - 60494 + - 60495 + - 60496 + - 60497 + - 60498 + - 60499 + - 60500 + - 60501 + - 60502 + - 60503 + - 60504 + - 60505 + - 60506 + - 60507 + - 60508 + - 60509 + - 60510 + - 60511 + - 60512 + - 60513 + - 60514 + - 60515 + - 60516 + - 60517 + - 60518 + - 60519 + - 60520 + - 60521 + - 60522 + - 60523 + - 60524 + - 60525 + - 60526 + - 60527 + - 60528 + - 60529 + - 60530 + - 60531 + - 60532 + - 60533 + - 60534 + - 60535 + - 60536 + - 60537 + - 60538 + - 60539 + - 60540 + - 60541 + - 60542 + - 60543 + - 60544 + - 60545 + - 60546 + - 60547 + - 60548 + - 60549 + - 60550 + - 60551 + - 60552 + - 60553 + - 60554 + - 60555 + - 60556 + - 60557 + - 60558 + - 60559 + - 60560 + - 60561 + - 60562 + - 60563 + - 60564 + - 60565 + - 60566 + - 60567 + - 60568 + - 60569 + - 60570 + - 60571 + - 60572 + - 60573 + - 60574 + - 60575 + - 60576 + - 60577 + - 60578 + - 60579 + - 60580 + - 60581 + - 60582 + - 60583 + - 60584 + - 60585 + - 60586 + - 60587 + - 60588 + - 60589 + - 60590 + - 60591 + - 60592 + - 60593 + - 60594 + - 60595 + - 60596 + - 60597 + - 60598 + - 60599 + - 60600 + - 60601 + - 60602 + - 60603 + - 60604 + - 60605 + - 60606 + - 60607 + - 60608 + - 60609 + - 60610 + - 60611 + - 60612 + - 60613 + - 60614 + - 60615 + - 60616 + - 60617 + - 60618 + - 60619 + - 60620 + - 60621 + - 60622 + - 60623 + - 60624 + - 60625 + - 60626 + - 60627 + - 60628 + - 60629 + - 60630 + - 60631 + - 60632 + - 60633 + - 60634 + - 60635 + - 60636 + - 60637 + - 60638 + - 60639 + - 60640 + - 60641 + - 60642 + - 60643 + - 60644 + - 60645 + - 60646 + - 60647 + - 60648 + - 60649 + - 60650 + - 60651 + - 60652 + - 60653 + - 60654 + - 60655 + - 60656 + - 60657 + - 60658 + - 60659 + - 60660 + - 60661 + - 60662 + - 60663 + - 60664 + - 60665 + - 60666 + - 60667 + - 60668 + - 60669 + - 60670 + - 60671 + - 60672 + - 60673 + - 60674 + - 60675 + - 60676 + - 60677 + - 60678 + - 60679 + - 60680 + - 60681 + - 60682 + - 60683 + - 60684 + - 60685 + - 60686 + - 60687 + - 60688 + - 60689 + - 60690 + - 60691 + - 60692 + - 60693 + - 60694 + - 60695 + - 60696 + - 60697 + - 60698 + - 60699 + - 60700 + - 60701 + - 60702 + - 60703 + - 60704 + - 60705 + - 60706 + - 60707 + - 60708 + - 60709 + - 60710 + - 60711 + - 60712 + - 60713 + - 60714 + - 60715 + - 60716 + - 60717 + - 60718 + - 60719 + - 60720 + - 60721 + - 60722 + - 60723 + - 60724 + - 60725 + - 60726 + - 60727 + - 60728 + - 60729 + - 60730 + - 60731 + - 60732 + - 60733 + - 60734 + - 60735 + - 60736 + - 60737 + - 60738 + - 60739 + - 60740 + - 60741 + - 60742 + - 60743 + - 60744 + - 60745 + - 60746 + - 60747 + - 60748 + - 60749 + - 60750 + - 60751 + - 60752 + - 60753 + - 60754 + - 60755 + - 60756 + - 60757 + - 60758 + - 60759 + - 60760 + - 60761 + - 60762 + - 60763 + - 60764 + - 60765 + - 60766 + - 60767 + - 60768 + - 60769 + - 60770 + - 60771 + - 60772 + - 60773 + - 60774 + - 60775 + - 60776 + - 60777 + - 60778 + - 60779 + - 60780 + - 60781 + - 60782 + - 60783 + - 60784 + - 60785 + - 60786 + - 60787 + - 60788 + - 60789 + - 60790 + - 60791 + - 60792 + - 60793 + - 60794 + - 60795 + - 60796 + - 60797 + - 60798 + - 60799 + - 60800 + - 60801 + - 60802 + - 60803 + - 60804 + - 60805 + - 60806 + - 60807 + - 60808 + - 60809 + - 60810 + - 60811 + - 60812 + - 60813 + - 60814 + - 60815 + - 60816 + - 60817 + - 60818 + - 60819 + - 60820 + - 60821 + - 60822 + - 60823 + - 60824 + - 60825 + - 60826 + - 60827 + - 60828 + - 60829 + - 60830 + - 60831 + - 60832 + - 60833 + - 60834 + - 60835 + - 60836 + - 60837 + - 60838 + - 60839 + - 60840 + - 60841 + - 60842 + - 60843 + - 60844 + - 60845 + - 60846 + - 60847 + - 60848 + - 60849 + - 60850 + - 60851 + - 60852 + - 60853 + - 60854 + - 60855 + - 60856 + - 60857 + - 60858 + - 60859 + - 60860 + - 60861 + - 60862 + - 60863 + - 60864 + - 60865 + - 60866 + - 60867 + - 60868 + - 60869 + - 60870 + - 60871 + - 60872 + - 60873 + - 60874 + - 60875 + - 60876 + - 60877 + - 60878 + - 60879 + - 60880 + - 60881 + - 60882 + - 60883 + - 60884 + - 60885 + - 60886 + - 60887 + - 60888 + - 60889 + - 60890 + - 60891 + - 60892 + - 60893 + - 60894 + - 60895 + - 60896 + - 60897 + - 60898 + - 60899 + - 60900 + - 60901 + - 60902 + - 60903 + - 60904 + - 60905 + - 60906 + - 60907 + - 60908 + - 60909 + - 60910 + - 60911 + - 60912 + - 60913 + - 60914 + - 60915 + - 60916 + - 60917 + - 60918 + - 60919 + - 60920 + - 60921 + - 60922 + - 60923 + - 60924 + - 60925 + - 60926 + - 60927 + - 60928 + - 60929 + - 60930 + - 60931 + - 60932 + - 60933 + - 60934 + - 60935 + - 60936 + - 60937 + - 60938 + - 60939 + - 60940 + - 60941 + - 60942 + - 60943 + - 60944 + - 60945 + - 60946 + - 60947 + - 60948 + - 60949 + - 60950 + - 60951 + - 60952 + - 60953 + - 60954 + - 60955 + - 60956 + - 60957 + - 60958 + - 60959 + - 60960 + - 60961 + - 60962 + - 60963 + - 60964 + - 60965 + - 60966 + - 60967 + - 60968 + - 60969 + - 60970 + - 60971 + - 60972 + - 60973 + - 60974 + - 60975 + - 60976 + - 60977 + - 60978 + - 60979 + - 60980 + - 60981 + - 60982 + - 60983 + - 60984 + - 60985 + - 60986 + - 60987 + - 60988 + - 60989 + - 60990 + - 60991 + - 60992 + - 60993 + - 60994 + - 60995 + - 60996 + - 60997 + - 60998 + - 60999 + - 61000 + - 61001 + - 61002 + - 61003 + - 61004 + - 61005 + - 61006 + - 61007 + - 61008 + - 61009 + - 61010 + - 61011 + - 61012 + - 61013 + - 61014 + - 61015 + - 61016 + - 61017 + - 61018 + - 61019 + - 61020 + - 61021 + - 61022 + - 61023 + - 61024 + - 61025 + - 61026 + - 61027 + - 61028 + - 61029 + - 61030 + - 61031 + - 61032 + - 61033 + - 61034 + - 61035 + - 61036 + - 61037 + - 61038 + - 61039 + - 61040 + - 61041 + - 61042 + - 61043 + - 61044 + - 61045 + - 61046 + - 61047 + - 61048 + - 61049 + - 61050 + - 61051 + - 61052 + - 61053 + - 61054 + - 61055 + - 61056 + - 61057 + - 61058 + - 61059 + - 61060 + - 61061 + - 61062 + - 61063 + - 61064 + - 61065 + - 61066 + - 61067 + - 61068 + - 61069 + - 61070 + - 61071 + - 61072 + - 61073 + - 61074 + - 61075 + - 61076 + - 61077 + - 61078 + - 61079 + - 61080 + - 61081 + - 61082 + - 61083 + - 61084 + - 61085 + - 61086 + - 61087 + - 61088 + - 61089 + - 61090 + - 61091 + - 61092 + - 61093 + - 61094 + - 61095 + - 61096 + - 61097 + - 61098 + - 61099 + - 61100 + - 61101 + - 61102 + - 61103 + - 61104 + - 61105 + - 61106 + - 61107 + - 61108 + - 61109 + - 61110 + - 61111 + - 61112 + - 61113 + - 61114 + - 61115 + - 61116 + - 61117 + - 61118 + - 61119 + - 61120 + - 61121 + - 61122 + - 61123 + - 61124 + - 61125 + - 61126 + - 61127 + - 61128 + - 61129 + - 61130 + - 61131 + - 61132 + - 61133 + - 61134 + - 61135 + - 61136 + - 61137 + - 61138 + - 61139 + - 61140 + - 61141 + - 61142 + - 61143 + - 61144 + - 61145 + - 61146 + - 61147 + - 61148 + - 61149 + - 61150 + - 61151 + - 61152 + - 61153 + - 61154 + - 61155 + - 61156 + - 61157 + - 61158 + - 61159 + - 61160 + - 61161 + - 61162 + - 61163 + - 61164 + - 61165 + - 61166 + - 61167 + - 61168 + - 61169 + - 61170 + - 61171 + - 61172 + - 61173 + - 61174 + - 61175 + - 61176 + - 61177 + - 61178 + - 61179 + - 61180 + - 61181 + - 61182 + - 61183 + - 61184 + - 61185 + - 61186 + - 61187 + - 61188 + - 61189 + - 61190 + - 61191 + - 61192 + - 61193 + - 61194 + - 61195 + - 61196 + - 61197 + - 61198 + - 61199 + - 61200 + - 61201 + - 61202 + - 61203 + - 61204 + - 61205 + - 61206 + - 61207 + - 61208 + - 61209 + - 61210 + - 61211 + - 61212 + - 61213 + - 61214 + - 61215 + - 61216 + - 61217 + - 61218 + - 61219 + - 61220 + - 61221 + - 61222 + - 61223 + - 61224 + - 61225 + - 61226 + - 61227 + - 61228 + - 61229 + - 61230 + - 61231 + - 61232 + - 61233 + - 61234 + - 61235 + - 61236 + - 61237 + - 61238 + - 61239 + - 61240 + - 61241 + - 61242 + - 61243 + - 61244 + - 61245 + - 61246 + - 61247 + - 61248 + - 61249 + - 61250 + - 61251 + - 61252 + - 61253 + - 61254 + - 61255 + - 61256 + - 61257 + - 61258 + - 61259 + - 61260 + - 61261 + - 61262 + - 61263 + - 61264 + - 61265 + - 61266 + - 61267 + - 61268 + - 61269 + - 61270 + - 61271 + - 61272 + - 61273 + - 61274 + - 61275 + - 61276 + - 61277 + - 61278 + - 61279 + - 61280 + - 61281 + - 61282 + - 61283 + - 61284 + - 61285 + - 61286 + - 61287 + - 61288 + - 61289 + - 61290 + - 61291 + - 61292 + - 61293 + - 61294 + - 61295 + - 61296 + - 61297 + - 61298 + - 61299 + - 61300 + - 61301 + - 61302 + - 61303 + - 61304 + - 61305 + - 61306 + - 61307 + - 61308 + - 61309 + - 61310 + - 61311 + - 61312 + - 61313 + - 61314 + - 61315 + - 61316 + - 61317 + - 61318 + - 61319 + - 61320 + - 61321 + - 61322 + - 61323 + - 61324 + - 61325 + - 61326 + - 61327 + - 61328 + - 61329 + - 61330 + - 61331 + - 61332 + - 61333 + - 61334 + - 61335 + - 61336 + - 61337 + - 61338 + - 61339 + - 61340 + - 61341 + - 61342 + - 61343 + - 61344 + - 61345 + - 61346 + - 61347 + - 61348 + - 61349 + - 61350 + - 61351 + - 61352 + - 61353 + - 61354 + - 61355 + - 61356 + - 61357 + - 61358 + - 61359 + - 61360 + - 61361 + - 61362 + - 61363 + - 61364 + - 61365 + - 61366 + - 61367 + - 61368 + - 61369 + - 61370 + - 61371 + - 61372 + - 61373 + - 61374 + - 61375 + - 61376 + - 61377 + - 61378 + - 61379 + - 61380 + - 61381 + - 61382 + - 61383 + - 61384 + - 61385 + - 61386 + - 61387 + - 61388 + - 61389 + - 61390 + - 61391 + - 61392 + - 61393 + - 61394 + - 61395 + - 61396 + - 61397 + - 61398 + - 61399 + - 61400 + - 61401 + - 61402 + - 61403 + - 61404 + - 61405 + - 61406 + - 61407 + - 61408 + - 61409 + - 61410 + - 61411 + - 61412 + - 61413 + - 61414 + - 61415 + - 61416 + - 61417 + - 61418 + - 61419 + - 61420 + - 61421 + - 61422 + - 61423 + - 61424 + - 61425 + - 61426 + - 61427 + - 61428 + - 61429 + - 61430 + - 61431 + - 61432 + - 61433 + - 61434 + - 61435 + - 61436 + - 61437 + - 61438 + - 61439 + - 61440 + - 61441 + - 61442 + - 61443 + - 61444 + - 61445 + - 61446 + - 61447 + - 61448 + - 61449 + - 61450 + - 61451 + - 61452 + - 61453 + - 61454 + - 61455 + - 61456 + - 61457 + - 61458 + - 61459 + - 61460 + - 61461 + - 61462 + - 61463 + - 61464 + - 61465 + - 61466 + - 61467 + - 61468 + - 61469 + - 61470 + - 61471 + - 61472 + - 61473 + - 61474 + - 61475 + - 61476 + - 61477 + - 61478 + - 61479 + - 61480 + - 61481 + - 61482 + - 61483 + - 61484 + - 61485 + - 61486 + - 61487 + - 61488 + - 61489 + - 61490 + - 61491 + - 61492 + - 61493 + - 61494 + - 61495 + - 61496 + - 61497 + - 61498 + - 61499 + - 61500 + - 61501 + - 61502 + - 61503 + - 61504 + - 61505 + - 61506 + - 61507 + - 61508 + - 61509 + - 61510 + - 61511 + - 61512 + - 61513 + - 61514 + - 61515 + - 61516 + - 61517 + - 61518 + - 61519 + - 61520 + - 61521 + - 61522 + - 61523 + - 61524 + - 61525 + - 61526 + - 61527 + - 61528 + - 61529 + - 61530 + - 61531 + - 61532 + - 61533 + - 61534 + - 61535 + - 61536 + - 61537 + - 61538 + - 61539 + - 61540 + - 61541 + - 61542 + - 61543 + - 61544 + - 61545 + - 61546 + - 61547 + - 61548 + - 61549 + - 61550 + - 61551 + - 61552 + - 61553 + - 61554 + - 61555 + - 61556 + - 61557 + - 61558 + - 61559 + - 61560 + - 61561 + - 61562 + - 61563 + - 61564 + - 61565 + - 61566 + - 61567 + - 61568 + - 61569 + - 61570 + - 61571 + - 61572 + - 61573 + - 61574 + - 61575 + - 61576 + - 61577 + - 61578 + - 61579 + - 61580 + - 61581 + - 61582 + - 61583 + - 61584 + - 61585 + - 61586 + - 61587 + - 61588 + - 61589 + - 61590 + - 61591 + - 61592 + - 61593 + - 61594 + - 61595 + - 61596 + - 61597 + - 61598 + - 61599 + - 61600 + - 61601 + - 61602 + - 61603 + - 61604 + - 61605 + - 61606 + - 61607 + - 61608 + - 61609 + - 61610 + - 61611 + - 61612 + - 61613 + - 61614 + - 61615 + - 61616 + - 61617 + - 61618 + - 61619 + - 61620 + - 61621 + - 61622 + - 61623 + - 61624 + - 61625 + - 61626 + - 61627 + - 61628 + - 61629 + - 61630 + - 61631 + - 61632 + - 61633 + - 61634 + - 61635 + - 61636 + - 61637 + - 61638 + - 61639 + - 61640 + - 61641 + - 61642 + - 61643 + - 61644 + - 61645 + - 61646 + - 61647 + - 61648 + - 61649 + - 61650 + - 61651 + - 61652 + - 61653 + - 61654 + - 61655 + - 61656 + - 61657 + - 61658 + - 61659 + - 61660 + - 61661 + - 61662 + - 61663 + - 61664 + - 61665 + - 61666 + - 61667 + - 61668 + - 61669 + - 61670 + - 61671 + - 61672 + - 61673 + - 61674 + - 61675 + - 61676 + - 61677 + - 61678 + - 61679 + - 61680 + - 61681 + - 61682 + - 61683 + - 61684 + - 61685 + - 61686 + - 61687 + - 61688 + - 61689 + - 61690 + - 61691 + - 61692 + - 61693 + - 61694 + - 61695 + - 61696 + - 61697 + - 61698 + - 61699 + - 61700 + - 61701 + - 61702 + - 61703 + - 61704 + - 61705 + - 61706 + - 61707 + - 61708 + - 61709 + - 61710 + - 61711 + - 61712 + - 61713 + - 61714 + - 61715 + - 61716 + - 61717 + - 61718 + - 61719 + - 61720 + - 61721 + - 61722 + - 61723 + - 61724 + - 61725 + - 61726 + - 61727 + - 61728 + - 61729 + - 61730 + - 61731 + - 61732 + - 61733 + - 61734 + - 61735 + - 61736 + - 61737 + - 61738 + - 61739 + - 61740 + - 61741 + - 61742 + - 61743 + - 61744 + - 61745 + - 61746 + - 61747 + - 61748 + - 61749 + - 61750 + - 61751 + - 61752 + - 61753 + - 61754 + - 61755 + - 61756 + - 61757 + - 61758 + - 61759 + - 61760 + - 61761 + - 61762 + - 61763 + - 61764 + - 61765 + - 61766 + - 61767 + - 61768 + - 61769 + - 61770 + - 61771 + - 61772 + - 61773 + - 61774 + - 61775 + - 61776 + - 61777 + - 61778 + - 61779 + - 61780 + - 61781 + - 61782 + - 61783 + - 61784 + - 61785 + - 61786 + - 61787 + - 61788 + - 61789 + - 61790 + - 61791 + - 61792 + - 61793 + - 61794 + - 61795 + - 61796 + - 61797 + - 61798 + - 61799 + - 61800 + - 61801 + - 61802 + - 61803 + - 61804 + - 61805 + - 61806 + - 61807 + - 61808 + - 61809 + - 61810 + - 61811 + - 61812 + - 61813 + - 61814 + - 61815 + - 61816 + - 61817 + - 61818 + - 61819 + - 61820 + - 61821 + - 61822 + - 61823 + - 61824 + - 61825 + - 61826 + - 61827 + - 61828 + - 61829 + - 61830 + - 61831 + - 61832 + - 61833 + - 61834 + - 61835 + - 61836 + - 61837 + - 61838 + - 61839 + - 61840 + - 61841 + - 61842 + - 61843 + - 61844 + - 61845 + - 61846 + - 61847 + - 61848 + - 61849 + - 61850 + - 61851 + - 61852 + - 61853 + - 61854 + - 61855 + - 61856 + - 61857 + - 61858 + - 61859 + - 61860 + - 61861 + - 61862 + - 61863 + - 61864 + - 61865 + - 61866 + - 61867 + - 61868 + - 61869 + - 61870 + - 61871 + - 61872 + - 61873 + - 61874 + - 61875 + - 61876 + - 61877 + - 61878 + - 61879 + - 61880 + - 61881 + - 61882 + - 61883 + - 61884 + - 61885 + - 61886 + - 61887 + - 61888 + - 61889 + - 61890 + - 61891 + - 61892 + - 61893 + - 61894 + - 61895 + - 61896 + - 61897 + - 61898 + - 61899 + - 61900 + - 61901 + - 61902 + - 61903 + - 61904 + - 61905 + - 61906 + - 61907 + - 61908 + - 61909 + - 61910 + - 61911 + - 61912 + - 61913 + - 61914 + - 61915 + - 61916 + - 61917 + - 61918 + - 61919 + - 61920 + - 61921 + - 61922 + - 61923 + - 61924 + - 61925 + - 61926 + - 61927 + - 61928 + - 61929 + - 61930 + - 61931 + - 61932 + - 61933 + - 61934 + - 61935 + - 61936 + - 61937 + - 61938 + - 61939 + - 61940 + - 61941 + - 61942 + - 61943 + - 61944 + - 61945 + - 61946 + - 61947 + - 61948 + - 61949 + - 61950 + - 61951 + - 61952 + - 61953 + - 61954 + - 61955 + - 61956 + - 61957 + - 61958 + - 61959 + - 61960 + - 61961 + - 61962 + - 61963 + - 61964 + - 61965 + - 61966 + - 61967 + - 61968 + - 61969 + - 61970 + - 61971 + - 61972 + - 61973 + - 61974 + - 61975 + - 61976 + - 61977 + - 61978 + - 61979 + - 61980 + - 61981 + - 61982 + - 61983 + - 61984 + - 61985 + - 61986 + - 61987 + - 61988 + - 61989 + - 61990 + - 61991 + - 61992 + - 61993 + - 61994 + - 61995 + - 61996 + - 61997 + - 61998 + - 61999 + - 62000 + - 62001 + - 62002 + - 62003 + - 62004 + - 62005 + - 62006 + - 62007 + - 62008 + - 62009 + - 62010 + - 62011 + - 62012 + - 62013 + - 62014 + - 62015 + - 62016 + - 62017 + - 62018 + - 62019 + - 62020 + - 62021 + - 62022 + - 62023 + - 62024 + - 62025 + - 62026 + - 62027 + - 62028 + - 62029 + - 62030 + - 62031 + - 62032 + - 62033 + - 62034 + - 62035 + - 62036 + - 62037 + - 62038 + - 62039 + - 62040 + - 62041 + - 62042 + - 62043 + - 62044 + - 62045 + - 62046 + - 62047 + - 62048 + - 62049 + - 62050 + - 62051 + - 62052 + - 62053 + - 62054 + - 62055 + - 62056 + - 62057 + - 62058 + - 62059 + - 62060 + - 62061 + - 62062 + - 62063 + - 62064 + - 62065 + - 62066 + - 62067 + - 62068 + - 62069 + - 62070 + - 62071 + - 62072 + - 62073 + - 62074 + - 62075 + - 62076 + - 62077 + - 62078 + - 62079 + - 62080 + - 62081 + - 62082 + - 62083 + - 62084 + - 62085 + - 62086 + - 62087 + - 62088 + - 62089 + - 62090 + - 62091 + - 62092 + - 62093 + - 62094 + - 62095 + - 62096 + - 62097 + - 62098 + - 62099 + - 62100 + - 62101 + - 62102 + - 62103 + - 62104 + - 62105 + - 62106 + - 62107 + - 62108 + - 62109 + - 62110 + - 62111 + - 62112 + - 62113 + - 62114 + - 62115 + - 62116 + - 62117 + - 62118 + - 62119 + - 62120 + - 62121 + - 62122 + - 62123 + - 62124 + - 62125 + - 62126 + - 62127 + - 62128 + - 62129 + - 62130 + - 62131 + - 62132 + - 62133 + - 62134 + - 62135 + - 62136 + - 62137 + - 62138 + - 62139 + - 62140 + - 62141 + - 62142 + - 62143 + - 62144 + - 62145 + - 62146 + - 62147 + - 62148 + - 62149 + - 62150 + - 62151 + - 62152 + - 62153 + - 62154 + - 62155 + - 62156 + - 62157 + - 62158 + - 62159 + - 62160 + - 62161 + - 62162 + - 62163 + - 62164 + - 62165 + - 62166 + - 62167 + - 62168 + - 62169 + - 62170 + - 62171 + - 62172 + - 62173 + - 62174 + - 62175 + - 62176 + - 62177 + - 62178 + - 62179 + - 62180 + - 62181 + - 62182 + - 62183 + - 62184 + - 62185 + - 62186 + - 62187 + - 62188 + - 62189 + - 62190 + - 62191 + - 62192 + - 62193 + - 62194 + - 62195 + - 62196 + - 62197 + - 62198 + - 62199 + - 62200 + - 62201 + - 62202 + - 62203 + - 62204 + - 62205 + - 62206 + - 62207 + - 62208 + - 62209 + - 62210 + - 62211 + - 62212 + - 62213 + - 62214 + - 62215 + - 62216 + - 62217 + - 62218 + - 62219 + - 62220 + - 62221 + - 62222 + - 62223 + - 62224 + - 62225 + - 62226 + - 62227 + - 62228 + - 62229 + - 62230 + - 62231 + - 62232 + - 62233 + - 62234 + - 62235 + - 62236 + - 62237 + - 62238 + - 62239 + - 62240 + - 62241 + - 62242 + - 62243 + - 62244 + - 62245 + - 62246 + - 62247 + - 62248 + - 62249 + - 62250 + - 62251 + - 62252 + - 62253 + - 62254 + - 62255 + - 62256 + - 62257 + - 62258 + - 62259 + - 62260 + - 62261 + - 62262 + - 62263 + - 62264 + - 62265 + - 62266 + - 62267 + - 62268 + - 62269 + - 62270 + - 62271 + - 62272 + - 62273 + - 62274 + - 62275 + - 62276 + - 62277 + - 62278 + - 62279 + - 62280 + - 62281 + - 62282 + - 62283 + - 62284 + - 62285 + - 62286 + - 62287 + - 62288 + - 62289 + - 62290 + - 62291 + - 62292 + - 62293 + - 62294 + - 62295 + - 62296 + - 62297 + - 62298 + - 62299 + - 62300 + - 62301 + - 62302 + - 62303 + - 62304 + - 62305 + - 62306 + - 62307 + - 62308 + - 62309 + - 62310 + - 62311 + - 62312 + - 62313 + - 62314 + - 62315 + - 62316 + - 62317 + - 62318 + - 62319 + - 62320 + - 62321 + - 62322 + - 62323 + - 62324 + - 62325 + - 62326 + - 62327 + - 62328 + - 62329 + - 62330 + - 62331 + - 62332 + - 62333 + - 62334 + - 62335 + - 62336 + - 62337 + - 62338 + - 62339 + - 62340 + - 62341 + - 62342 + - 62343 + - 62344 + - 62345 + - 62346 + - 62347 + - 62348 + - 62349 + - 62350 + - 62351 + - 62352 + - 62353 + - 62354 + - 62355 + - 62356 + - 62357 + - 62358 + - 62359 + - 62360 + - 62361 + - 62362 + - 62363 + - 62364 + - 62365 + - 62366 + - 62367 + - 62368 + - 62369 + - 62370 + - 62371 + - 62372 + - 62373 + - 62374 + - 62375 + - 62376 + - 62377 + - 62378 + - 62379 + - 62380 + - 62381 + - 62382 + - 62383 + - 62384 + - 62385 + - 62386 + - 62387 + - 62388 + - 62389 + - 62390 + - 62391 + - 62392 + - 62393 + - 62394 + - 62395 + - 62396 + - 62397 + - 62398 + - 62399 + - 62400 + - 62401 + - 62402 + - 62403 + - 62404 + - 62405 + - 62406 + - 62407 + - 62408 + - 62409 + - 62410 + - 62411 + - 62412 + - 62413 + - 62414 + - 62415 + - 62416 + - 62417 + - 62418 + - 62419 + - 62420 + - 62421 + - 62422 + - 62423 + - 62424 + - 62425 + - 62426 + - 62427 + - 62428 + - 62429 + - 62430 + - 62431 + - 62432 + - 62433 + - 62434 + - 62435 + - 62436 + - 62437 + - 62438 + - 62439 + - 62440 + - 62441 + - 62442 + - 62443 + - 62444 + - 62445 + - 62446 + - 62447 + - 62448 + - 62449 + - 62450 + - 62451 + - 62452 + - 62453 + - 62454 + - 62455 + - 62456 + - 62457 + - 62458 + - 62459 + - 62460 + - 62461 + - 62462 + - 62463 + - 62464 + - 62465 + - 62466 + - 62467 + - 62468 + - 62469 + - 62470 + - 62471 + - 62472 + - 62473 + - 62474 + - 62475 + - 62476 + - 62477 + - 62478 + - 62479 + - 62480 + - 62481 + - 62482 + - 62483 + - 62484 + - 62485 + - 62486 + - 62487 + - 62488 + - 62489 + - 62490 + - 62491 + - 62492 + - 62493 + - 62494 + - 62495 + - 62496 + - 62497 + - 62498 + - 62499 + - 62500 + - 62501 + - 62502 + - 62503 + - 62504 + - 62505 + - 62506 + - 62507 + - 62508 + - 62509 + - 62510 + - 62511 + - 62512 + - 62513 + - 62514 + - 62515 + - 62516 + - 62517 + - 62518 + - 62519 + - 62520 + - 62521 + - 62522 + - 62523 + - 62524 + - 62525 + - 62526 + - 62527 + - 62528 + - 62529 + - 62530 + - 62531 + - 62532 + - 62533 + - 62534 + - 62535 + - 62536 + - 62537 + - 62538 + - 62539 + - 62540 + - 62541 + - 62542 + - 62543 + - 62544 + - 62545 + - 62546 + - 62547 + - 62548 + - 62549 + - 62550 + - 62551 + - 62552 + - 62553 + - 62554 + - 62555 + - 62556 + - 62557 + - 62558 + - 62559 + - 62560 + - 62561 + - 62562 + - 62563 + - 62564 + - 62565 + - 62566 + - 62567 + - 62568 + - 62569 + - 62570 + - 62571 + - 62572 + - 62573 + - 62574 + - 62575 + - 62576 + - 62577 + - 62578 + - 62579 + - 62580 + - 62581 + - 62582 + - 62583 + - 62584 + - 62585 + - 62586 + - 62587 + - 62588 + - 62589 + - 62590 + - 62591 + - 62592 + - 62593 + - 62594 + - 62595 + - 62596 + - 62597 + - 62598 + - 62599 + - 62600 + - 62601 + - 62602 + - 62603 + - 62604 + - 62605 + - 62606 + - 62607 + - 62608 + - 62609 + - 62610 + - 62611 + - 62612 + - 62613 + - 62614 + - 62615 + - 62616 + - 62617 + - 62618 + - 62619 + - 62620 + - 62621 + - 62622 + - 62623 + - 62624 + - 62625 + - 62626 + - 62627 + - 62628 + - 62629 + - 62630 + - 62631 + - 62632 + - 62633 + - 62634 + - 62635 + - 62636 + - 62637 + - 62638 + - 62639 + - 62640 + - 62641 + - 62642 + - 62643 + - 62644 + - 62645 + - 62646 + - 62647 + - 62648 + - 62649 + - 62650 + - 62651 + - 62652 + - 62653 + - 62654 + - 62655 + - 62656 + - 62657 + - 62658 + - 62659 + - 62660 + - 62661 + - 62662 + - 62663 + - 62664 + - 62665 + - 62666 + - 62667 + - 62668 + - 62669 + - 62670 + - 62671 + - 62672 + - 62673 + - 62674 + - 62675 + - 62676 + - 62677 + - 62678 + - 62679 + - 62680 + - 62681 + - 62682 + - 62683 + - 62684 + - 62685 + - 62686 + - 62687 + - 62688 + - 62689 + - 62690 + - 62691 + - 62692 + - 62693 + - 62694 + - 62695 + - 62696 + - 62697 + - 62698 + - 62699 + - 62700 + - 62701 + - 62702 + - 62703 + - 62704 + - 62705 + - 62706 + - 62707 + - 62708 + - 62709 + - 62710 + - 62711 + - 62712 + - 62713 + - 62714 + - 62715 + - 62716 + - 62717 + - 62718 + - 62719 + - 62720 + - 62721 + - 62722 + - 62723 + - 62724 + - 62725 + - 62726 + - 62727 + - 62728 + - 62729 + - 62730 + - 62731 + - 62732 + - 62733 + - 62734 + - 62735 + - 62736 + - 62737 + - 62738 + - 62739 + - 62740 + - 62741 + - 62742 + - 62743 + - 62744 + - 62745 + - 62746 + - 62747 + - 62748 + - 62749 + - 62750 + - 62751 + - 62752 + - 62753 + - 62754 + - 62755 + - 62756 + - 62757 + - 62758 + - 62759 + - 62760 + - 62761 + - 62762 + - 62763 + - 62764 + - 62765 + - 62766 + - 62767 + - 62768 + - 62769 + - 62770 + - 62771 + - 62772 + - 62773 + - 62774 + - 62775 + - 62776 + - 62777 + - 62778 + - 62779 + - 62780 + - 62781 + - 62782 + - 62783 + - 62784 + - 62785 + - 62786 + - 62787 + - 62788 + - 62789 + - 62790 + - 62791 + - 62792 + - 62793 + - 62794 + - 62795 + - 62796 + - 62797 + - 62798 + - 62799 + - 62800 + - 62801 + - 62802 + - 62803 + - 62804 + - 62805 + - 62806 + - 62807 + - 62808 + - 62809 + - 62810 + - 62811 + - 62812 + - 62813 + - 62814 + - 62815 + - 62816 + - 62817 + - 62818 + - 62819 + - 62820 + - 62821 + - 62822 + - 62823 + - 62824 + - 62825 + - 62826 + - 62827 + - 62828 + - 62829 + - 62830 + - 62831 + - 62832 + - 62833 + - 62834 + - 62835 + - 62836 + - 62837 + - 62838 + - 62839 + - 62840 + - 62841 + - 62842 + - 62843 + - 62844 + - 62845 + - 62846 + - 62847 + - 62848 + - 62849 + - 62850 + - 62851 + - 62852 + - 62853 + - 62854 + - 62855 + - 62856 + - 62857 + - 62858 + - 62859 + - 62860 + - 62861 + - 62862 + - 62863 + - 62864 + - 62865 + - 62866 + - 62867 + - 62868 + - 62869 + - 62870 + - 62871 + - 62872 + - 62873 + - 62874 + - 62875 + - 62876 + - 62877 + - 62878 + - 62879 + - 62880 + - 62881 + - 62882 + - 62883 + - 62884 + - 62885 + - 62886 + - 62887 + - 62888 + - 62889 + - 62890 + - 62891 + - 62892 + - 62893 + - 62894 + - 62895 + - 62896 + - 62897 + - 62898 + - 62899 + - 62900 + - 62901 + - 62902 + - 62903 + - 62904 + - 62905 + - 62906 + - 62907 + - 62908 + - 62909 + - 62910 + - 62911 + - 62912 + - 62913 + - 62914 + - 62915 + - 62916 + - 62917 + - 62918 + - 62919 + - 62920 + - 62921 + - 62922 + - 62923 + - 62924 + - 62925 + - 62926 + - 62927 + - 62928 + - 62929 + - 62930 + - 62931 + - 62932 + - 62933 + - 62934 + - 62935 + - 62936 + - 62937 + - 62938 + - 62939 + - 62940 + - 62941 + - 62942 + - 62943 + - 62944 + - 62945 + - 62946 + - 62947 + - 62948 + - 62949 + - 62950 + - 62951 + - 62952 + - 62953 + - 62954 + - 62955 + - 62956 + - 62957 + - 62958 + - 62959 + - 62960 + - 62961 + - 62962 + - 62963 + - 62964 + - 62965 + - 62966 + - 62967 + - 62968 + - 62969 + - 62970 + - 62971 + - 62972 + - 62973 + - 62974 + - 62975 + - 62976 + - 62977 + - 62978 + - 62979 + - 62980 + - 62981 + - 62982 + - 62983 + - 62984 + - 62985 + - 62986 + - 62987 + - 62988 + - 62989 + - 62990 + - 62991 + - 62992 + - 62993 + - 62994 + - 62995 + - 62996 + - 62997 + - 62998 + - 62999 + - 63000 + - 63001 + - 63002 + - 63003 + - 63004 + - 63005 + - 63006 + - 63007 + - 63008 + - 63009 + - 63010 + - 63011 + - 63012 + - 63013 + - 63014 + - 63015 + - 63016 + - 63017 + - 63018 + - 63019 + - 63020 + - 63021 + - 63022 + - 63023 + - 63024 + - 63025 + - 63026 + - 63027 + - 63028 + - 63029 + - 63030 + - 63031 + - 63032 + - 63033 + - 63034 + - 63035 + - 63036 + - 63037 + - 63038 + - 63039 + - 63040 + - 63041 + - 63042 + - 63043 + - 63044 + - 63045 + - 63046 + - 63047 + - 63048 + - 63049 + - 63050 + - 63051 + - 63052 + - 63053 + - 63054 + - 63055 + - 63056 + - 63057 + - 63058 + - 63059 + - 63060 + - 63061 + - 63062 + - 63063 + - 63064 + - 63065 + - 63066 + - 63067 + - 63068 + - 63069 + - 63070 + - 63071 + - 63072 + - 63073 + - 63074 + - 63075 + - 63076 + - 63077 + - 63078 + - 63079 + - 63080 + - 63081 + - 63082 + - 63083 + - 63084 + - 63085 + - 63086 + - 63087 + - 63088 + - 63089 + - 63090 + - 63091 + - 63092 + - 63093 + - 63094 + - 63095 + - 63096 + - 63097 + - 63098 + - 63099 + - 63100 + - 63101 + - 63102 + - 63103 + - 63104 + - 63105 + - 63106 + - 63107 + - 63108 + - 63109 + - 63110 + - 63111 + - 63112 + - 63113 + - 63114 + - 63115 + - 63116 + - 63117 + - 63118 + - 63119 + - 63120 + - 63121 + - 63122 + - 63123 + - 63124 + - 63125 + - 63126 + - 63127 + - 63128 + - 63129 + - 63130 + - 63131 + - 63132 + - 63133 + - 63134 + - 63135 + - 63136 + - 63137 + - 63138 + - 63139 + - 63140 + - 63141 + - 63142 + - 63143 + - 63144 + - 63145 + - 63146 + - 63147 + - 63148 + - 63149 + - 63150 + - 63151 + - 63152 + - 63153 + - 63154 + - 63155 + - 63156 + - 63157 + - 63158 + - 63159 + - 63160 + - 63161 + - 63162 + - 63163 + - 63164 + - 63165 + - 63166 + - 63167 + - 63168 + - 63169 + - 63170 + - 63171 + - 63172 + - 63173 + - 63174 + - 63175 + - 63176 + - 63177 + - 63178 + - 63179 + - 63180 + - 63181 + - 63182 + - 63183 + - 63184 + - 63185 + - 63186 + - 63187 + - 63188 + - 63189 + - 63190 + - 63191 + - 63192 + - 63193 + - 63194 + - 63195 + - 63196 + - 63197 + - 63198 + - 63199 + - 63200 + - 63201 + - 63202 + - 63203 + - 63204 + - 63205 + - 63206 + - 63207 + - 63208 + - 63209 + - 63210 + - 63211 + - 63212 + - 63213 + - 63214 + - 63215 + - 63216 + - 63217 + - 63218 + - 63219 + - 63220 + - 63221 + - 63222 + - 63223 + - 63224 + - 63225 + - 63226 + - 63227 + - 63228 + - 63229 + - 63230 + - 63231 + - 63232 + - 63233 + - 63234 + - 63235 + - 63236 + - 63237 + - 63238 + - 63239 + - 63240 + - 63241 + - 63242 + - 63243 + - 63244 + - 63245 + - 63246 + - 63247 + - 63248 + - 63249 + - 63250 + - 63251 + - 63252 + - 63253 + - 63254 + - 63255 + - 63256 + - 63257 + - 63258 + - 63259 + - 63260 + - 63261 + - 63262 + - 63263 + - 63264 + - 63265 + - 63266 + - 63267 + - 63268 + - 63269 + - 63270 + - 63271 + - 63272 + - 63273 + - 63274 + - 63275 + - 63276 + - 63277 + - 63278 + - 63279 + - 63280 + - 63281 + - 63282 + - 63283 + - 63284 + - 63285 + - 63286 + - 63287 + - 63288 + - 63289 + - 63290 + - 63291 + - 63292 + - 63293 + - 63294 + - 63295 + - 63296 + - 63297 + - 63298 + - 63299 + - 63300 + - 63301 + - 63302 + - 63303 + - 63304 + - 63305 + - 63306 + - 63307 + - 63308 + - 63309 + - 63310 + - 63311 + - 63312 + - 63313 + - 63314 + - 63315 + - 63316 + - 63317 + - 63318 + - 63319 + - 63320 + - 63321 + - 63322 + - 63323 + - 63324 + - 63325 + - 63326 + - 63327 + - 63328 + - 63329 + - 63330 + - 63331 + - 63332 + - 63333 + - 63334 + - 63335 + - 63336 + - 63337 + - 63338 + - 63339 + - 63340 + - 63341 + - 63342 + - 63343 + - 63344 + - 63345 + - 63346 + - 63347 + - 63348 + - 63349 + - 63350 + - 63351 + - 63352 + - 63353 + - 63354 + - 63355 + - 63356 + - 63357 + - 63358 + - 63359 + - 63360 + - 63361 + - 63362 + - 63363 + - 63364 + - 63365 + - 63366 + - 63367 + - 63368 + - 63369 + - 63370 + - 63371 + - 63372 + - 63373 + - 63374 + - 63375 + - 63376 + - 63377 + - 63378 + - 63379 + - 63380 + - 63381 + - 63382 + - 63383 + - 63384 + - 63385 + - 63386 + - 63387 + - 63388 + - 63389 + - 63390 + - 63391 + - 63392 + - 63393 + - 63394 + - 63395 + - 63396 + - 63397 + - 63398 + - 63399 + - 63400 + - 63401 + - 63402 + - 63403 + - 63404 + - 63405 + - 63406 + - 63407 + - 63408 + - 63409 + - 63410 + - 63411 + - 63412 + - 63413 + - 63414 + - 63415 + - 63416 + - 63417 + - 63418 + - 63419 + - 63420 + - 63421 + - 63422 + - 63423 + - 63424 + - 63425 + - 63426 + - 63427 + - 63428 + - 63429 + - 63430 + - 63431 + - 63432 + - 63433 + - 63434 + - 63435 + - 63436 + - 63437 + - 63438 + - 63439 + - 63440 + - 63441 + - 63442 + - 63443 + - 63444 + - 63445 + - 63446 + - 63447 + - 63448 + - 63449 + - 63450 + - 63451 + - 63452 + - 63453 + - 63454 + - 63455 + - 63456 + - 63457 + - 63458 + - 63459 + - 63460 + - 63461 + - 63462 + - 63463 + - 63464 + - 63465 + - 63466 + - 63467 + - 63468 + - 63469 + - 63470 + - 63471 + - 63472 + - 63473 + - 63474 + - 63475 + - 63476 + - 63477 + - 63478 + - 63479 + - 63480 + - 63481 + - 63482 + - 63483 + - 63484 + - 63485 + - 63486 + - 63487 + - 63488 + - 63489 + - 63490 + - 63491 + - 63492 + - 63493 + - 63494 + - 63495 + - 63496 + - 63497 + - 63498 + - 63499 + - 63500 + - 63501 + - 63502 + - 63503 + - 63504 + - 63505 + - 63506 + - 63507 + - 63508 + - 63509 + - 63510 + - 63511 + - 63512 + - 63513 + - 63514 + - 63515 + - 63516 + - 63517 + - 63518 + - 63519 + - 63520 + - 63521 + - 63522 + - 63523 + - 63524 + - 63525 + - 63526 + - 63527 + - 63528 + - 63529 + - 63530 + - 63531 + - 63532 + - 63533 + - 63534 + - 63535 + - 63536 + - 63537 + - 63538 + - 63539 + - 63540 + - 63541 + - 63542 + - 63543 + - 63544 + - 63545 + - 63546 + - 63547 + - 63548 + - 63549 + - 63550 + - 63551 + - 63552 + - 63553 + - 63554 + - 63555 + - 63556 + - 63557 + - 63558 + - 63559 + - 63560 + - 63561 + - 63562 + - 63563 + - 63564 + - 63565 + - 63566 + - 63567 + - 63568 + - 63569 + - 63570 + - 63571 + - 63572 + - 63573 + - 63574 + - 63575 + - 63576 + - 63577 + - 63578 + - 63579 + - 63580 + - 63581 + - 63582 + - 63583 + - 63584 + - 63585 + - 63586 + - 63587 + - 63588 + - 63589 + - 63590 + - 63591 + - 63592 + - 63593 + - 63594 + - 63595 + - 63596 + - 63597 + - 63598 + - 63599 + - 63600 + - 63601 + - 63602 + - 63603 + - 63604 + - 63605 + - 63606 + - 63607 + - 63608 + - 63609 + - 63610 + - 63611 + - 63612 + - 63613 + - 63614 + - 63615 + - 63616 + - 63617 + - 63618 + - 63619 + - 63620 + - 63621 + - 63622 + - 63623 + - 63624 + - 63625 + - 63626 + - 63627 + - 63628 + - 63629 + - 63630 + - 63631 + - 63632 + - 63633 + - 63634 + - 63635 + - 63636 + - 63637 + - 63638 + - 63639 + - 63640 + - 63641 + - 63642 + - 63643 + - 63644 + - 63645 + - 63646 + - 63647 + - 63648 + - 63649 + - 63650 + - 63651 + - 63652 + - 63653 + - 63654 + - 63655 + - 63656 + - 63657 + - 63658 + - 63659 + - 63660 + - 63661 + - 63662 + - 63663 + - 63664 + - 63665 + - 63666 + - 63667 + - 63668 + - 63669 + - 63670 + - 63671 + - 63672 + - 63673 + - 63674 + - 63675 + - 63676 + - 63677 + - 63678 + - 63679 + - 63680 + - 63681 + - 63682 + - 63683 + - 63684 + - 63685 + - 63686 + - 63687 + - 63688 + - 63689 + - 63690 + - 63691 + - 63692 + - 63693 + - 63694 + - 63695 + - 63696 + - 63697 + - 63698 + - 63699 + - 63700 + - 63701 + - 63702 + - 63703 + - 63704 + - 63705 + - 63706 + - 63707 + - 63708 + - 63709 + - 63710 + - 63711 + - 63712 + - 63713 + - 63714 + - 63715 + - 63716 + - 63717 + - 63718 + - 63719 + - 63720 + - 63721 + - 63722 + - 63723 + - 63724 + - 63725 + - 63726 + - 63727 + - 63728 + - 63729 + - 63730 + - 63731 + - 63732 + - 63733 + - 63734 + - 63735 + - 63736 + - 63737 + - 63738 + - 63739 + - 63740 + - 63741 + - 63742 + - 63743 + - 63744 + - 63745 + - 63746 + - 63747 + - 63748 + - 63749 + - 63750 + - 63751 + - 63752 + - 63753 + - 63754 + - 63755 + - 63756 + - 63757 + - 63758 + - 63759 + - 63760 + - 63761 + - 63762 + - 63763 + - 63764 + - 63765 + - 63766 + - 63767 + - 63768 + - 63769 + - 63770 + - 63771 + - 63772 + - 63773 + - 63774 + - 63775 + - 63776 + - 63777 + - 63778 + - 63779 + - 63780 + - 63781 + - 63782 + - 63783 + - 63784 + - 63785 + - 63786 + - 63787 + - 63788 + - 63789 + - 63790 + - 63791 + - 63792 + - 63793 + - 63794 + - 63795 + - 63796 + - 63797 + - 63798 + - 63799 + - 63800 + - 63801 + - 63802 + - 63803 + - 63804 + - 63805 + - 63806 + - 63807 + - 63808 + - 63809 + - 63810 + - 63811 + - 63812 + - 63813 + - 63814 + - 63815 + - 63816 + - 63817 + - 63818 + - 63819 + - 63820 + - 63821 + - 63822 + - 63823 + - 63824 + - 63825 + - 63826 + - 63827 + - 63828 + - 63829 + - 63830 + - 63831 + - 63832 + - 63833 + - 63834 + - 63835 + - 63836 + - 63837 + - 63838 + - 63839 + - 63840 + - 63841 + - 63842 + - 63843 + - 63844 + - 63845 + - 63846 + - 63847 + - 63848 + - 63849 + - 63850 + - 63851 + - 63852 + - 63853 + - 63854 + - 63855 + - 63856 + - 63857 + - 63858 + - 63859 + - 63860 + - 63861 + - 63862 + - 63863 + - 63864 + - 63865 + - 63866 + - 63867 + - 63868 + - 63869 + - 63870 + - 63871 + - 63872 + - 63873 + - 63874 + - 63875 + - 63876 + - 63877 + - 63878 + - 63879 + - 63880 + - 63881 + - 63882 + - 63883 + - 63884 + - 63885 + - 63886 + - 63887 + - 63888 + - 63889 + - 63890 + - 63891 + - 63892 + - 63893 + - 63894 + - 63895 + - 63896 + - 63897 + - 63898 + - 63899 + - 63900 + - 63901 + - 63902 + - 63903 + - 63904 + - 63905 + - 63906 + - 63907 + - 63908 + - 63909 + - 63910 + - 63911 + - 63912 + - 63913 + - 63914 + - 63915 + - 63916 + - 63917 + - 63918 + - 63919 + - 63920 + - 63921 + - 63922 + - 63923 + - 63924 + - 63925 + - 63926 + - 63927 + - 63928 + - 63929 + - 63930 + - 63931 + - 63932 + - 63933 + - 63934 + - 63935 + - 63936 + - 63937 + - 63938 + - 63939 + - 63940 + - 63941 + - 63942 + - 63943 + - 63944 + - 63945 + - 63946 + - 63947 + - 63948 + - 63949 + - 63950 + - 63951 + - 63952 + - 63953 + - 63954 + - 63955 + - 63956 + - 63957 + - 63958 + - 63959 + - 63960 + - 63961 + - 63962 + - 63963 + - 63964 + - 63965 + - 63966 + - 63967 + - 63968 + - 63969 + - 63970 + - 63971 + - 63972 + - 63973 + - 63974 + - 63975 + - 63976 + - 63977 + - 63978 + - 63979 + - 63980 + - 63981 + - 63982 + - 63983 + - 63984 + - 63985 + - 63986 + - 63987 + - 63988 + - 63989 + - 63990 + - 63991 + - 63992 + - 63993 + - 63994 + - 63995 + - 63996 + - 63997 + - 63998 + - 63999 + - 64000 + - 64001 + - 64002 + - 64003 + - 64004 + - 64005 + - 64006 + - 64007 + - 64008 + - 64009 + - 64010 + - 64011 + - 64012 + - 64013 + - 64014 + - 64015 + - 64016 + - 64017 + - 64018 + - 64019 + - 64020 + - 64021 + - 64022 + - 64023 + - 64024 + - 64025 + - 64026 + - 64027 + - 64028 + - 64029 + - 64030 + - 64031 + - 64032 + - 64033 + - 64034 + - 64035 + - 64036 + - 64037 + - 64038 + - 64039 + - 64040 + - 64041 + - 64042 + - 64043 + - 64044 + - 64045 + - 64046 + - 64047 + - 64048 + - 64049 + - 64050 + - 64051 + - 64052 + - 64053 + - 64054 + - 64055 + - 64056 + - 64057 + - 64058 + - 64059 + - 64060 + - 64061 + - 64062 + - 64063 + - 64064 + - 64065 + - 64066 + - 64067 + - 64068 + - 64069 + - 64070 + - 64071 + - 64072 + - 64073 + - 64074 + - 64075 + - 64076 + - 64077 + - 64078 + - 64079 + - 64080 + - 64081 + - 64082 + - 64083 + - 64084 + - 64085 + - 64086 + - 64087 + - 64088 + - 64089 + - 64090 + - 64091 + - 64092 + - 64093 + - 64094 + - 64095 + - 64096 + - 64097 + - 64098 + - 64099 + - 64100 + - 64101 + - 64102 + - 64103 + - 64104 + - 64105 + - 64106 + - 64107 + - 64108 + - 64109 + - 64110 + - 64111 + - 64112 + - 64113 + - 64114 + - 64115 + - 64116 + - 64117 + - 64118 + - 64119 + - 64120 + - 64121 + - 64122 + - 64123 + - 64124 + - 64125 + - 64126 + - 64127 + - 64128 + - 64129 + - 64130 + - 64131 + - 64132 + - 64133 + - 64134 + - 64135 + - 64136 + - 64137 + - 64138 + - 64139 + - 64140 + - 64141 + - 64142 + - 64143 + - 64144 + - 64145 + - 64146 + - 64147 + - 64148 + - 64149 + - 64150 + - 64151 + - 64152 + - 64153 + - 64154 + - 64155 + - 64156 + - 64157 + - 64158 + - 64159 + - 64160 + - 64161 + - 64162 + - 64163 + - 64164 + - 64165 + - 64166 + - 64167 + - 64168 + - 64169 + - 64170 + - 64171 + - 64172 + - 64173 + - 64174 + - 64175 + - 64176 + - 64177 + - 64178 + - 64179 + - 64180 + - 64181 + - 64182 + - 64183 + - 64184 + - 64185 + - 64186 + - 64187 + - 64188 + - 64189 + - 64190 + - 64191 + - 64192 + - 64193 + - 64194 + - 64195 + - 64196 + - 64197 + - 64198 + - 64199 + - 64200 + - 64201 + - 64202 + - 64203 + - 64204 + - 64205 + - 64206 + - 64207 + - 64208 + - 64209 + - 64210 + - 64211 + - 64212 + - 64213 + - 64214 + - 64215 + - 64216 + - 64217 + - 64218 + - 64219 + - 64220 + - 64221 + - 64222 + - 64223 + - 64224 + - 64225 + - 64226 + - 64227 + - 64228 + - 64229 + - 64230 + - 64231 + - 64232 + - 64233 + - 64234 + - 64235 + - 64236 + - 64237 + - 64238 + - 64239 + - 64240 + - 64241 + - 64242 + - 64243 + - 64244 + - 64245 + - 64246 + - 64247 + - 64248 + - 64249 + - 64250 + - 64251 + - 64252 + - 64253 + - 64254 + - 64255 + - 64256 + - 64257 + - 64258 + - 64259 + - 64260 + - 64261 + - 64262 + - 64263 + - 64264 + - 64265 + - 64266 + - 64267 + - 64268 + - 64269 + - 64270 + - 64271 + - 64272 + - 64273 + - 64274 + - 64275 + - 64276 + - 64277 + - 64278 + - 64279 + - 64280 + - 64281 + - 64282 + - 64283 + - 64284 + - 64285 + - 64286 + - 64287 + - 64288 + - 64289 + - 64290 + - 64291 + - 64292 + - 64293 + - 64294 + - 64295 + - 64296 + - 64297 + - 64298 + - 64299 + - 64300 + - 64301 + - 64302 + - 64303 + - 64304 + - 64305 + - 64306 + - 64307 + - 64308 + - 64309 + - 64310 + - 64311 + - 64312 + - 64313 + - 64314 + - 64315 + - 64316 + - 64317 + - 64318 + - 64319 + - 64320 + - 64321 + - 64322 + - 64323 + - 64324 + - 64325 + - 64326 + - 64327 + - 64328 + - 64329 + - 64330 + - 64331 + - 64332 + - 64333 + - 64334 + - 64335 + - 64336 + - 64337 + - 64338 + - 64339 + - 64340 + - 64341 + - 64342 + - 64343 + - 64344 + - 64345 + - 64346 + - 64347 + - 64348 + - 64349 + - 64350 + - 64351 + - 64352 + - 64353 + - 64354 + - 64355 + - 64356 + - 64357 + - 64358 + - 64359 + - 64360 + - 64361 + - 64362 + - 64363 + - 64364 + - 64365 + - 64366 + - 64367 + - 64368 + - 64369 + - 64370 + - 64371 + - 64372 + - 64373 + - 64374 + - 64375 + - 64376 + - 64377 + - 64378 + - 64379 + - 64380 + - 64381 + - 64382 + - 64383 + - 64384 + - 64385 + - 64386 + - 64387 + - 64388 + - 64389 + - 64390 + - 64391 + - 64392 + - 64393 + - 64394 + - 64395 + - 64396 + - 64397 + - 64398 + - 64399 + - 64400 + - 64401 + - 64402 + - 64403 + - 64404 + - 64405 + - 64406 + - 64407 + - 64408 + - 64409 + - 64410 + - 64411 + - 64412 + - 64413 + - 64414 + - 64415 + - 64416 + - 64417 + - 64418 + - 64419 + - 64420 + - 64421 + - 64422 + - 64423 + - 64424 + - 64425 + - 64426 + - 64427 + - 64428 + - 64429 + - 64430 + - 64431 + - 64432 + - 64433 + - 64434 + - 64435 + - 64436 + - 64437 + - 64438 + - 64439 + - 64440 + - 64441 + - 64442 + - 64443 + - 64444 + - 64445 + - 64446 + - 64447 + - 64448 + - 64449 + - 64450 + - 64451 + - 64452 + - 64453 + - 64454 + - 64455 + - 64456 + - 64457 + - 64458 + - 64459 + - 64460 + - 64461 + - 64462 + - 64463 + - 64464 + - 64465 + - 64466 + - 64467 + - 64468 + - 64469 + - 64470 + - 64471 + - 64472 + - 64473 + - 64474 + - 64475 + - 64476 + - 64477 + - 64478 + - 64479 + - 64480 + - 64481 + - 64482 + - 64483 + - 64484 + - 64485 + - 64486 + - 64487 + - 64488 + - 64489 + - 64490 + - 64491 + - 64492 + - 64493 + - 64494 + - 64495 + - 64496 + - 64497 + - 64498 + - 64499 + - 64500 + - 64501 + - 64502 + - 64503 + - 64504 + - 64505 + - 64506 + - 64507 + - 64508 + - 64509 + - 64510 + - 64511 + - 64512 + - 64513 + - 64514 + - 64515 + - 64516 + - 64517 + - 64518 + - 64519 + - 64520 + - 64521 + - 64522 + - 64523 + - 64524 + - 64525 + - 64526 + - 64527 + - 64528 + - 64529 + - 64530 + - 64531 + - 64532 + - 64533 + - 64534 + - 64535 + - 64536 + - 64537 + - 64538 + - 64539 + - 64540 + - 64541 + - 64542 + - 64543 + - 64544 + - 64545 + - 64546 + - 64547 + - 64548 + - 64549 + - 64550 + - 64551 + - 64552 + - 64553 + - 64554 + - 64555 + - 64556 + - 64557 + - 64558 + - 64559 + - 64560 + - 64561 + - 64562 + - 64563 + - 64564 + - 64565 + - 64566 + - 64567 + - 64568 + - 64569 + - 64570 + - 64571 + - 64572 + - 64573 + - 64574 + - 64575 + - 64576 + - 64577 + - 64578 + - 64579 + - 64580 + - 64581 + - 64582 + - 64583 + - 64584 + - 64585 + - 64586 + - 64587 + - 64588 + - 64589 + - 64590 + - 64591 + - 64592 + - 64593 + - 64594 + - 64595 + - 64596 + - 64597 + - 64598 + - 64599 + - 64600 + - 64601 + - 64602 + - 64603 + - 64604 + - 64605 + - 64606 + - 64607 + - 64608 + - 64609 + - 64610 + - 64611 + - 64612 + - 64613 + - 64614 + - 64615 + - 64616 + - 64617 + - 64618 + - 64619 + - 64620 + - 64621 + - 64622 + - 64623 + - 64624 + - 64625 + - 64626 + - 64627 + - 64628 + - 64629 + - 64630 + - 64631 + - 64632 + - 64633 + - 64634 + - 64635 + - 64636 + - 64637 + - 64638 + - 64639 + - 64640 + - 64641 + - 64642 + - 64643 + - 64644 + - 64645 + - 64646 + - 64647 + - 64648 + - 64649 + - 64650 + - 64651 + - 64652 + - 64653 + - 64654 + - 64655 + - 64656 + - 64657 + - 64658 + - 64659 + - 64660 + - 64661 + - 64662 + - 64663 + - 64664 + - 64665 + - 64666 + - 64667 + - 64668 + - 64669 + - 64670 + - 64671 + - 64672 + - 64673 + - 64674 + - 64675 + - 64676 + - 64677 + - 64678 + - 64679 + - 64680 + - 64681 + - 64682 + - 64683 + - 64684 + - 64685 + - 64686 + - 64687 + - 64688 + - 64689 + - 64690 + - 64691 + - 64692 + - 64693 + - 64694 + - 64695 + - 64696 + - 64697 + - 64698 + - 64699 + - 64700 + - 64701 + - 64702 + - 64703 + - 64704 + - 64705 + - 64706 + - 64707 + - 64708 + - 64709 + - 64710 + - 64711 + - 64712 + - 64713 + - 64714 + - 64715 + - 64716 + - 64717 + - 64718 + - 64719 + - 64720 + - 64721 + - 64722 + - 64723 + - 64724 + - 64725 + - 64726 + - 64727 + - 64728 + - 64729 + - 64730 + - 64731 + - 64732 + - 64733 + - 64734 + - 64735 + - 64736 + - 64737 + - 64738 + - 64739 + - 64740 + - 64741 + - 64742 + - 64743 + - 64744 + - 64745 + - 64746 + - 64747 + - 64748 + - 64749 + - 64750 + - 64751 + - 64752 + - 64753 + - 64754 + - 64755 + - 64756 + - 64757 + - 64758 + - 64759 + - 64760 + - 64761 + - 64762 + - 64763 + - 64764 + - 64765 + - 64766 + - 64767 + - 64768 + - 64769 + - 64770 + - 64771 + - 64772 + - 64773 + - 64774 + - 64775 + - 64776 + - 64777 + - 64778 + - 64779 + - 64780 + - 64781 + - 64782 + - 64783 + - 64784 + - 64785 + - 64786 + - 64787 + - 64788 + - 64789 + - 64790 + - 64791 + - 64792 + - 64793 + - 64794 + - 64795 + - 64796 + - 64797 + - 64798 + - 64799 + - 64800 + - 64801 + - 64802 + - 64803 + - 64804 + - 64805 + - 64806 + - 64807 + - 64808 + - 64809 + - 64810 + - 64811 + - 64812 + - 64813 + - 64814 + - 64815 + - 64816 + - 64817 + - 64818 + - 64819 + - 64820 + - 64821 + - 64822 + - 64823 + - 64824 + - 64825 + - 64826 + - 64827 + - 64828 + - 64829 + - 64830 + - 64831 + - 64832 + - 64833 + - 64834 + - 64835 + - 64836 + - 64837 + - 64838 + - 64839 + - 64840 + - 64841 + - 64842 + - 64843 + - 64844 + - 64845 + - 64846 + - 64847 + - 64848 + - 64849 + - 64850 + - 64851 + - 64852 + - 64853 + - 64854 + - 64855 + - 64856 + - 64857 + - 64858 + - 64859 + - 64860 + - 64861 + - 64862 + - 64863 + - 64864 + - 64865 + - 64866 + - 64867 + - 64868 + - 64869 + - 64870 + - 64871 + - 64872 + - 64873 + - 64874 + - 64875 + - 64876 + - 64877 + - 64878 + - 64879 + - 64880 + - 64881 + - 64882 + - 64883 + - 64884 + - 64885 + - 64886 + - 64887 + - 64888 + - 64889 + - 64890 + - 64891 + - 64892 + - 64893 + - 64894 + - 64895 + - 64896 + - 64897 + - 64898 + - 64899 + - 64900 + - 64901 + - 64902 + - 64903 + - 64904 + - 64905 + - 64906 + - 64907 + - 64908 + - 64909 + - 64910 + - 64911 + - 64912 + - 64913 + - 64914 + - 64915 + - 64916 + - 64917 + - 64918 + - 64919 + - 64920 + - 64921 + - 64922 + - 64923 + - 64924 + - 64925 + - 64926 + - 64927 + - 64928 + - 64929 + - 64930 + - 64931 + - 64932 + - 64933 + - 64934 + - 64935 + - 64936 + - 64937 + - 64938 + - 64939 + - 64940 + - 64941 + - 64942 + - 64943 + - 64944 + - 64945 + - 64946 + - 64947 + - 64948 + - 64949 + - 64950 + - 64951 + - 64952 + - 64953 + - 64954 + - 64955 + - 64956 + - 64957 + - 64958 + - 64959 + - 64960 + - 64961 + - 64962 + - 64963 + - 64964 + - 64965 + - 64966 + - 64967 + - 64968 + - 64969 + - 64970 + - 64971 + - 64972 + - 64973 + - 64974 + - 64975 + - 64976 + - 64977 + - 64978 + - 64979 + - 64980 + - 64981 + - 64982 + - 64983 + - 64984 + - 64985 + - 64986 + - 64987 + - 64988 + - 64989 + - 64990 + - 64991 + - 64992 + - 64993 + - 64994 + - 64995 + - 64996 + - 64997 + - 64998 + - 64999 + - 65000 + - 65001 + - 65002 + - 65003 + - 65004 + - 65005 + - 65006 + - 65007 + - 65008 + - 65009 + - 65010 + - 65011 + - 65012 + - 65013 + - 65014 + - 65015 + - 65016 + - 65017 + - 65018 + - 65019 + - 65020 + - 65021 + - 65022 + - 65023 + - 65024 + - 65025 + - 65026 + - 65027 + - 65028 + - 65029 + - 65030 + - 65031 + - 65032 + - 65033 + - 65034 + - 65035 + - 65036 + - 65037 + - 65038 + - 65039 + - 65040 + - 65041 + - 65042 + - 65043 + - 65044 + - 65045 + - 65046 + - 65047 + - 65048 + - 65049 + - 65050 + - 65051 + - 65052 + - 65053 + - 65054 + - 65055 + - 65056 + - 65057 + - 65058 + - 65059 + - 65060 + - 65061 + - 65062 + - 65063 + - 65064 + - 65065 + - 65066 + - 65067 + - 65068 + - 65069 + - 65070 + - 65071 + - 65072 + - 65073 + - 65074 + - 65075 + - 65076 + - 65077 + - 65078 + - 65079 + - 65080 + - 65081 + - 65082 + - 65083 + - 65084 + - 65085 + - 65086 + - 65087 + - 65088 + - 65089 + - 65090 + - 65091 + - 65092 + - 65093 + - 65094 + - 65095 + - 65096 + - 65097 + - 65098 + - 65099 + - 65100 + - 65101 + - 65102 + - 65103 + - 65104 + - 65105 + - 65106 + - 65107 + - 65108 + - 65109 + - 65110 + - 65111 + - 65112 + - 65113 + - 65114 + - 65115 + - 65116 + - 65117 + - 65118 + - 65119 + - 65120 + - 65121 + - 65122 + - 65123 + - 65124 + - 65125 + - 65126 + - 65127 + - 65128 + - 65129 + - 65130 + - 65131 + - 65132 + - 65133 + - 65134 + - 65135 + - 65136 + - 65137 + - 65138 + - 65139 + - 65140 + - 65141 + - 65142 + - 65143 + - 65144 + - 65145 + - 65146 + - 65147 + - 65148 + - 65149 + - 65150 + - 65151 + - 65152 + - 65153 + - 65154 + - 65155 + - 65156 + - 65157 + - 65158 + - 65159 + - 65160 + - 65161 + - 65162 + - 65163 + - 65164 + - 65165 + - 65166 + - 65167 + - 65168 + - 65169 + - 65170 + - 65171 + - 65172 + - 65173 + - 65174 + - 65175 + - 65176 + - 65177 + - 65178 + - 65179 + - 65180 + - 65181 + - 65182 + - 65183 + - 65184 + - 65185 + - 65186 + - 65187 + - 65188 + - 65189 + - 65190 + - 65191 + - 65192 + - 65193 + - 65194 + - 65195 + - 65196 + - 65197 + - 65198 + - 65199 + - 65200 + - 65201 + - 65202 + - 65203 + - 65204 + - 65205 + - 65206 + - 65207 + - 65208 + - 65209 + - 65210 + - 65211 + - 65212 + - 65213 + - 65214 + - 65215 + - 65216 + - 65217 + - 65218 + - 65219 + - 65220 + - 65221 + - 65222 + - 65223 + - 65224 + - 65225 + - 65226 + - 65227 + - 65228 + - 65229 + - 65230 + - 65231 + - 65232 + - 65233 + - 65234 + - 65235 + - 65236 + - 65237 + - 65238 + - 65239 + - 65240 + - 65241 + - 65242 + - 65243 + - 65244 + - 65245 + - 65246 + - 65247 + - 65248 + - 65249 + - 65250 + - 65251 + - 65252 + - 65253 + - 65254 + - 65255 + - 65256 + - 65257 + - 65258 + - 65259 + - 65260 + - 65261 + - 65262 + - 65263 + - 65264 + - 65265 + - 65266 + - 65267 + - 65268 + - 65269 + - 65270 + - 65271 + - 65272 + - 65273 + - 65274 + - 65275 + - 65276 + - 65277 + - 65278 + - 65279 + - 65280 + - 65281 + - 65282 + - 65283 + - 65284 + - 65285 + - 65286 + - 65287 + - 65288 + - 65289 + - 65290 + - 65291 + - 65292 + - 65293 + - 65294 + - 65295 + - 65296 + - 65297 + - 65298 + - 65299 + - 65300 + - 65301 + - 65302 + - 65303 + - 65304 + - 65305 + - 65306 + - 65307 + - 65308 + - 65309 + - 65310 + - 65311 + - 65312 + - 65313 + - 65314 + - 65315 + - 65316 + - 65317 + - 65318 + - 65319 + - 65320 + - 65321 + - 65322 + - 65323 + - 65324 + - 65325 + - 65326 + - 65327 + - 65328 + - 65329 + - 65330 + - 65331 + - 65332 + - 65333 + - 65334 + - 65335 + - 65336 + - 65337 + - 65338 + - 65339 + - 65340 + - 65341 + - 65342 + - 65343 + - 65344 + - 65345 + - 65346 + - 65347 + - 65348 + - 65349 + - 65350 + - 65351 + - 65352 + - 65353 + - 65354 + - 65355 + - 65356 + - 65357 + - 65358 + - 65359 + - 65360 + - 65361 + - 65362 + - 65363 + - 65364 + - 65365 + - 65366 + - 65367 + - 65368 + - 65369 + - 65370 + - 65371 + - 65372 + - 65373 + - 65374 + - 65375 + - 65376 + - 65377 + - 65378 + - 65379 + - 65380 + - 65381 + - 65382 + - 65383 + - 65384 + - 65385 + - 65386 + - 65387 + - 65388 + - 65389 + - 65390 + - 65391 + - 65392 + - 65393 + - 65394 + - 65395 + - 65396 + - 65397 + - 65398 + - 65399 + - 65400 + - 65401 + - 65402 + - 65403 + - 65404 + - 65405 + - 65406 + - 65407 + - 65408 + - 65409 + - 65410 + - 65411 + - 65412 + - 65413 + - 65414 + - 65415 + - 65416 + - 65417 + - 65418 + - 65419 + - 65420 + - 65421 + - 65422 + - 65423 + - 65424 + - 65425 + - 65426 + - 65427 + - 65428 + - 65429 + - 65430 + - 65431 + - 65432 + - 65433 + - 65434 + - 65435 + - 65436 + - 65437 + - 65438 + - 65439 + - 65440 + - 65441 + - 65442 + - 65443 + - 65444 + - 65445 + - 65446 + - 65447 + - 65448 + - 65449 + - 65450 + - 65451 + - 65452 + - 65453 + - 65454 + - 65455 + - 65456 + - 65457 + - 65458 + - 65459 + - 65460 + - 65461 + - 65462 + - 65463 + - 65464 + - 65465 + - 65466 + - 65467 + - 65468 + - 65469 + - 65470 + - 65471 + - 65472 + - 65473 + - 65474 + - 65475 + - 65476 + - 65477 + - 65478 + - 65479 + - 65480 + - 65481 + - 65482 + - 65483 + - 65484 + - 65485 + - 65486 + - 65487 + - 65488 + - 65489 + - 65490 + - 65491 + - 65492 + - 65493 + - 65494 + - 65495 + - 65496 + - 65497 + - 65498 + - 65499 + - 65500 + - 65501 + - 65502 + - 65503 + - 65504 + - 65505 + - 65506 + - 65507 + - 65508 + - 65509 + - 65510 + - 65511 + - 65512 + - 65513 + - 65514 + - 65515 + - 65516 + - 65517 + - 65518 + - 65519 + - 65520 + - 65521 + - 65522 + - 65523 + - 65524 + - 65525 + - 65526 + - 65527 + - 65528 + - 65529 + - 65530 + - 65531 + - 65532 + - 65533 + - 65534 + - 65535 + - 65536 + - 65537 + - 65538 + - 65539 + - 65540 + - 65541 + - 65542 + - 65543 + - 65544 + - 65545 + - 65546 + - 65547 + - 65548 + - 65549 + - 65550 + - 65551 + - 65552 + - 65553 + - 65554 + - 65555 + - 65556 + - 65557 + - 65558 + - 65559 + - 65560 + - 65561 + - 65562 + - 65563 + - 65564 + - 65565 + - 65566 + - 65567 + - 65568 + - 65569 + - 65570 + - 65571 + - 65572 + - 65573 + - 65574 + - 65575 + - 65576 + - 65577 + - 65578 + - 65579 + - 65580 + - 65581 + - 65582 + - 65583 + - 65584 + - 65585 + - 65586 + - 65587 + - 65588 + - 65589 + - 65590 + - 65591 + - 65592 + - 65593 + - 65594 + - 65595 + - 65596 + - 65597 + - 65598 + - 65599 + - 65600 + - 65601 + - 65602 + - 65603 + - 65604 + - 65605 + - 65606 + - 65607 + - 65608 + - 65609 + - 65610 + - 65611 + - 65612 + - 65613 + - 65614 + - 65615 + - 65616 + - 65617 + - 65618 + - 65619 + - 65620 + - 65621 + - 65622 + - 65623 + - 65624 + - 65625 + - 65626 + - 65627 + - 65628 + - 65629 + - 65630 + - 65631 + - 65632 + - 65633 + - 65634 + - 65635 + - 65636 + - 65637 + - 65638 + - 65639 + - 65640 + - 65641 + - 65642 + - 65643 + - 65644 + - 65645 + - 65646 + - 65647 + - 65648 + - 65649 + - 65650 + - 65651 + - 65652 + - 65653 + - 65654 + - 65655 + - 65656 + - 65657 + - 65658 + - 65659 + - 65660 + - 65661 + - 65662 + - 65663 + - 65664 + - 65665 + - 65666 + - 65667 + - 65668 + - 65669 + - 65670 + - 65671 + - 65672 + - 65673 + - 65674 + - 65675 + - 65676 + - 65677 + - 65678 + - 65679 + - 65680 + - 65681 + - 65682 + - 65683 + - 65684 + - 65685 + - 65686 + - 65687 + - 65688 + - 65689 + - 65690 + - 65691 + - 65692 + - 65693 + - 65694 + - 65695 + - 65696 + - 65697 + - 65698 + - 65699 + - 65700 + - 65701 + - 65702 + - 65703 + - 65704 + - 65705 + - 65706 + - 65707 + - 65708 + - 65709 + - 65710 + - 65711 + - 65712 + - 65713 + - 65714 + - 65715 + - 65716 + - 65717 + - 65718 + - 65719 + - 65720 + - 65721 + - 65722 + - 65723 + - 65724 + - 65725 + - 65726 + - 65727 + - 65728 + - 65729 + - 65730 + - 65731 + - 65732 + - 65733 + - 65734 + - 65735 + - 65736 + - 65737 + - 65738 + - 65739 + - 65740 + - 65741 + - 65742 + - 65743 + - 65744 + - 65745 + - 65746 + - 65747 + - 65748 + - 65749 + - 65750 + - 65751 + - 65752 + - 65753 + - 65754 + - 65755 + - 65756 + - 65757 + - 65758 + - 65759 + - 65760 + - 65761 + - 65762 + - 65763 + - 65764 + - 65765 + - 65766 + - 65767 + - 65768 + - 65769 + - 65770 + - 65771 + - 65772 + - 65773 + - 65774 + - 65775 + - 65776 + - 65777 + - 65778 + - 65779 + - 65780 + - 65781 + - 65782 + - 65783 + - 65784 + - 65785 + - 65786 + - 65787 + - 65788 + - 65789 + - 65790 + - 65791 + - 65792 + - 65793 + - 65794 + - 65795 + - 65796 + - 65797 + - 65798 + - 65799 + - 65800 + - 65801 + - 65802 + - 65803 + - 65804 + - 65805 + - 65806 + - 65807 + - 65808 + - 65809 + - 65810 + - 65811 + - 65812 + - 65813 + - 65814 + - 65815 + - 65816 + - 65817 + - 65818 + - 65819 + - 65820 + - 65821 + - 65822 + - 65823 + - 65824 + - 65825 + - 65826 + - 65827 + - 65828 + - 65829 + - 65830 + - 65831 + - 65832 + - 65833 + - 65834 + - 65835 + - 65836 + - 65837 + - 65838 + - 65839 + - 65840 + - 65841 + - 65842 + - 65843 + - 65844 + - 65845 + - 65846 + - 65847 + - 65848 + - 65849 + - 65850 + - 65851 + - 65852 + - 65853 + - 65854 + - 65855 + - 65856 + - 65857 + - 65858 + - 65859 + - 65860 + - 65861 + - 65862 + - 65863 + - 65864 + - 65865 + - 65866 + - 65867 + - 65868 + - 65869 + - 65870 + - 65871 + - 65872 + - 65873 + - 65874 + - 65875 + - 65876 + - 65877 + - 65878 + - 65879 + - 65880 + - 65881 + - 65882 + - 65883 + - 65884 + - 65885 + - 65886 + - 65887 + - 65888 + - 65889 + - 65890 + - 65891 + - 65892 + - 65893 + - 65894 + - 65895 + - 65896 + - 65897 + - 65898 + - 65899 + - 65900 + - 65901 + - 65902 + - 65903 + - 65904 + - 65905 + - 65906 + - 65907 + - 65908 + - 65909 + - 65910 + - 65911 + - 65912 + - 65913 + - 65914 + - 65915 + - 65916 + - 65917 + - 65918 + - 65919 + - 65920 + - 65921 + - 65922 + - 65923 + - 65924 + - 65925 + - 65926 + - 65927 + - 65928 + - 65929 + - 65930 + - 65931 + - 65932 + - 65933 + - 65934 + - 65935 + - 65936 + - 65937 + - 65938 + - 65939 + - 65940 + - 65941 + - 65942 + - 65943 + - 65944 + - 65945 + - 65946 + - 65947 + - 65948 + - 65949 + - 65950 + - 65951 + - 65952 + - 65953 + - 65954 + - 65955 + - 65956 + - 65957 + - 65958 + - 65959 + - 65960 + - 65961 + - 65962 + - 65963 + - 65964 + - 65965 + - 65966 + - 65967 + - 65968 + - 65969 + - 65970 + - 65971 + - 65972 + - 65973 + - 65974 + - 65975 + - 65976 + - 65977 + - 65978 + - 65979 + - 65980 + - 65981 + - 65982 + - 65983 + - 65984 + - 65985 + - 65986 + - 65987 + - 65988 + - 65989 + - 65990 + - 65991 + - 65992 + - 65993 + - 65994 + - 65995 + - 65996 + - 65997 + - 65998 + - 65999 + - 66000 + - 66001 + - 66002 + - 66003 + - 66004 + - 66005 + - 66006 + - 66007 + - 66008 + - 66009 + - 66010 + - 66011 + - 66012 + - 66013 + - 66014 + - 66015 + - 66016 + - 66017 + - 66018 + - 66019 + - 66020 + - 66021 + - 66022 + - 66023 + - 66024 + - 66025 + - 66026 + - 66027 + - 66028 + - 66029 + - 66030 + - 66031 + - 66032 + - 66033 + - 66034 + - 66035 + - 66036 + - 66037 + - 66038 + - 66039 + - 66040 + - 66041 + - 66042 + - 66043 + - 66044 + - 66045 + - 66046 + - 66047 + - 66048 + - 66049 + - 66050 + - 66051 + - 66052 + - 66053 + - 66054 + - 66055 + - 66056 + - 66057 + - 66058 + - 66059 + - 66060 + - 66061 + - 66062 + - 66063 + - 66064 + - 66065 + - 66066 + - 66067 + - 66068 + - 66069 + - 66070 + - 66071 + - 66072 + - 66073 + - 66074 + - 66075 + - 66076 + - 66077 + - 66078 + - 66079 + - 66080 + - 66081 + - 66082 + - 66083 + - 66084 + - 66085 + - 66086 + - 66087 + - 66088 + - 66089 + - 66090 + - 66091 + - 66092 + - 66093 + - 66094 + - 66095 + - 66096 + - 66097 + - 66098 + - 66099 + - 66100 + - 66101 + - 66102 + - 66103 + - 66104 + - 66105 + - 66106 + - 66107 + - 66108 + - 66109 + - 66110 + - 66111 + - 66112 + - 66113 + - 66114 + - 66115 + - 66116 + - 66117 + - 66118 + - 66119 + - 66120 + - 66121 + - 66122 + - 66123 + - 66124 + - 66125 + - 66126 + - 66127 + - 66128 + - 66129 + - 66130 + - 66131 + - 66132 + - 66133 + - 66134 + - 66135 + - 66136 + - 66137 + - 66138 + - 66139 + - 66140 + - 66141 + - 66142 + - 66143 + - 66144 + - 66145 + - 66146 + - 66147 + - 66148 + - 66149 + - 66150 + - 66151 + - 66152 + - 66153 + - 66154 + - 66155 + - 66156 + - 66157 + - 66158 + - 66159 + - 66160 + - 66161 + - 66162 + - 66163 + - 66164 + - 66165 + - 66166 + - 66167 + - 66168 + - 66169 + - 66170 + - 66171 + - 66172 + - 66173 + - 66174 + - 66175 + - 66176 + - 66177 + - 66178 + - 66179 + - 66180 + - 66181 + - 66182 + - 66183 + - 66184 + - 66185 + - 66186 + - 66187 + - 66188 + - 66189 + - 66190 + - 66191 + - 66192 + - 66193 + - 66194 + - 66195 + - 66196 + - 66197 + - 66198 + - 66199 + - 66200 + - 66201 + - 66202 + - 66203 + - 66204 + - 66205 + - 66206 + - 66207 + - 66208 + - 66209 + - 66210 + - 66211 + - 66212 + - 66213 + - 66214 + - 66215 + - 66216 + - 66217 + - 66218 + - 66219 + - 66220 + - 66221 + - 66222 + - 66223 + - 66224 + - 66225 + - 66226 + - 66227 + - 66228 + - 66229 + - 66230 + - 66231 + - 66232 + - 66233 + - 66234 + - 66235 + - 66236 + - 66237 + - 66238 + - 66239 + - 66240 + - 66241 + - 66242 + - 66243 + - 66244 + - 66245 + - 66246 + - 66247 + - 66248 + - 66249 + - 66250 + - 66251 + - 66252 + - 66253 + - 66254 + - 66255 + - 66256 + - 66257 + - 66258 + - 66259 + - 66260 + - 66261 + - 66262 + - 66263 + - 66264 + - 66265 + - 66266 + - 66267 + - 66268 + - 66269 + - 66270 + - 66271 + - 66272 + - 66273 + - 66274 + - 66275 + - 66276 + - 66277 + - 66278 + - 66279 + - 66280 + - 66281 + - 66282 + - 66283 + - 66284 + - 66285 + - 66286 + - 66287 + - 66288 + - 66289 + - 66290 + - 66291 + - 66292 + - 66293 + - 66294 + - 66295 + - 66296 + - 66297 + - 66298 + - 66299 + - 66300 + - 66301 + - 66302 + - 66303 + - 66304 + - 66305 + - 66306 + - 66307 + - 66308 + - 66309 + - 66310 + - 66311 + - 66312 + - 66313 + - 66314 + - 66315 + - 66316 + - 66317 + - 66318 + - 66319 + - 66320 + - 66321 + - 66322 + - 66323 + - 66324 + - 66325 + - 66326 + - 66327 + - 66328 + - 66329 + - 66330 + - 66331 + - 66332 + - 66333 + - 66334 + - 66335 + - 66336 + - 66337 + - 66338 + - 66339 + - 66340 + - 66341 + - 66342 + - 66343 + - 66344 + - 66345 + - 66346 + - 66347 + - 66348 + - 66349 + - 66350 + - 66351 + - 66352 + - 66353 + - 66354 + - 66355 + - 66356 + - 66357 + - 66358 + - 66359 + - 66360 + - 66361 + - 66362 + - 66363 + - 66364 + - 66365 + - 66366 + - 66367 + - 66368 + - 66369 + - 66370 + - 66371 + - 66372 + - 66373 + - 66374 + - 66375 + - 66376 + - 66377 + - 66378 + - 66379 + - 66380 + - 66381 + - 66382 + - 66383 + - 66384 + - 66385 + - 66386 + - 66387 + - 66388 + - 66389 + - 66390 + - 66391 + - 66392 + - 66393 + - 66394 + - 66395 + - 66396 + - 66397 + - 66398 + - 66399 + - 66400 + - 66401 + - 66402 + - 66403 + - 66404 + - 66405 + - 66406 + - 66407 + - 66408 + - 66409 + - 66410 + - 66411 + - 66412 + - 66413 + - 66414 + - 66415 + - 66416 + - 66417 + - 66418 + - 66419 + - 66420 + - 66421 + - 66422 + - 66423 + - 66424 + - 66425 + - 66426 + - 66427 + - 66428 + - 66429 + - 66430 + - 66431 + - 66432 + - 66433 + - 66434 + - 66435 + - 66436 + - 66437 + - 66438 + - 66439 + - 66440 + - 66441 + - 66442 + - 66443 + - 66444 + - 66445 + - 66446 + - 66447 + - 66448 + - 66449 + - 66450 + - 66451 + - 66452 + - 66453 + - 66454 + - 66455 + - 66456 + - 66457 + - 66458 + - 66459 + - 66460 + - 66461 + - 66462 + - 66463 + - 66464 + - 66465 + - 66466 + - 66467 + - 66468 + - 66469 + - 66470 + - 66471 + - 66472 + - 66473 + - 66474 + - 66475 + - 66476 + - 66477 + - 66478 + - 66479 + - 66480 + - 66481 + - 66482 + - 66483 + - 66484 + - 66485 + - 66486 + - 66487 + - 66488 + - 66489 + - 66490 + - 66491 + - 66492 + - 66493 + - 66494 + - 66495 + - 66496 + - 66497 + - 66498 + - 66499 + - 66500 + - 66501 + - 66502 + - 66503 + - 66504 + - 66505 + - 66506 + - 66507 + - 66508 + - 66509 + - 66510 + - 66511 + - 66512 + - 66513 + - 66514 + - 66515 + - 66516 + - 66517 + - 66518 + - 66519 + - 66520 + - 66521 + - 66522 + - 66523 + - 66524 + - 66525 + - 66526 + - 66527 + - 66528 + - 66529 + - 66530 + - 66531 + - 66532 + - 66533 + - 66534 + - 66535 + - 66536 + - 66537 + - 66538 + - 66539 + - 66540 + - 66541 + - 66542 + - 66543 + - 66544 + - 66545 + - 66546 + - 66547 + - 66548 + - 66549 + - 66550 + - 66551 + - 66552 + - 66553 + - 66554 + - 66555 + - 66556 + - 66557 + - 66558 + - 66559 + - 66560 + - 66561 + - 66562 + - 66563 + - 66564 + - 66565 + - 66566 + - 66567 + - 66568 + - 66569 + - 66570 + - 66571 + - 66572 + - 66573 + - 66574 + - 66575 + - 66576 + - 66577 + - 66578 + - 66579 + - 66580 + - 66581 + - 66582 + - 66583 + - 66584 + - 66585 + - 66586 + - 66587 + - 66588 + - 66589 + - 66590 + - 66591 + - 66592 + - 66593 + - 66594 + - 66595 + - 66596 + - 66597 + - 66598 + - 66599 + - 66600 + - 66601 + - 66602 + - 66603 + - 66604 + - 66605 + - 66606 + - 66607 + - 66608 + - 66609 + - 66610 + - 66611 + - 66612 + - 66613 + - 66614 + - 66615 + - 66616 + - 66617 + - 66618 + - 66619 + - 66620 + - 66621 + - 66622 + - 66623 + - 66624 + - 66625 + - 66626 + - 66627 + - 66628 + - 66629 + - 66630 + - 66631 + - 66632 + - 66633 + - 66634 + - 66635 + - 66636 + - 66637 + - 66638 + - 66639 + - 66640 + - 66641 + - 66642 + - 66643 + - 66644 + - 66645 + - 66646 + - 66647 + - 66648 + - 66649 + - 66650 + - 66651 + - 66652 + - 66653 + - 66654 + - 66655 + - 66656 + - 66657 + - 66658 + - 66659 + - 66660 + - 66661 + - 66662 + - 66663 + - 66664 + - 66665 + - 66666 + - 66667 + - 66668 + - 66669 + - 66670 + - 66671 + - 66672 + - 66673 + - 66674 + - 66675 + - 66676 + - 66677 + - 66678 + - 66679 + - 66680 + - 66681 + - 66682 + - 66683 + - 66684 + - 66685 + - 66686 + - 66687 + - 66688 + - 66689 + - 66690 + - 66691 + - 66692 + - 66693 + - 66694 + - 66695 + - 66696 + - 66697 + - 66698 + - 66699 + - 66700 + - 66701 + - 66702 + - 66703 + - 66704 + - 66705 + - 66706 + - 66707 + - 66708 + - 66709 + - 66710 + - 66711 + - 66712 + - 66713 + - 66714 + - 66715 + - 66716 + - 66717 + - 66718 + - 66719 + - 66720 + - 66721 + - 66722 + - 66723 + - 66724 + - 66725 + - 66726 + - 66727 + - 66728 + - 66729 + - 66730 + - 66731 + - 66732 + - 66733 + - 66734 + - 66735 + - 66736 + - 66737 + - 66738 + - 66739 + - 66740 + - 66741 + - 66742 + - 66743 + - 66744 + - 66745 + - 66746 + - 66747 + - 66748 + - 66749 + - 66750 + - 66751 + - 66752 + - 66753 + - 66754 + - 66755 + - 66756 + - 66757 + - 66758 + - 66759 + - 66760 + - 66761 + - 66762 + - 66763 + - 66764 + - 66765 + - 66766 + - 66767 + - 66768 + - 66769 + - 66770 + - 66771 + - 66772 + - 66773 + - 66774 + - 66775 + - 66776 + - 66777 + - 66778 + - 66779 + - 66780 + - 66781 + - 66782 + - 66783 + - 66784 + - 66785 + - 66786 + - 66787 + - 66788 + - 66789 + - 66790 + - 66791 + - 66792 + - 66793 + - 66794 + - 66795 + - 66796 + - 66797 + - 66798 + - 66799 + - 66800 + - 66801 + - 66802 + - 66803 + - 66804 + - 66805 + - 66806 + - 66807 + - 66808 + - 66809 + - 66810 + - 66811 + - 66812 + - 66813 + - 66814 + - 66815 + - 66816 + - 66817 + - 66818 + - 66819 + - 66820 + - 66821 + - 66822 + - 66823 + - 66824 + - 66825 + - 66826 + - 66827 + - 66828 + - 66829 + - 66830 + - 66831 + - 66832 + - 66833 + - 66834 + - 66835 + - 66836 + - 66837 + - 66838 + - 66839 + - 66840 + - 66841 + - 66842 + - 66843 + - 66844 + - 66845 + - 66846 + - 66847 + - 66848 + - 66849 + - 66850 + - 66851 + - 66852 + - 66853 + - 66854 + - 66855 + - 66856 + - 66857 + - 66858 + - 66859 + - 66860 + - 66861 + - 66862 + - 66863 + - 66864 + - 66865 + - 66866 + - 66867 + - 66868 + - 66869 + - 66870 + - 66871 + - 66872 + - 66873 + - 66874 + - 66875 + - 66876 + - 66877 + - 66878 + - 66879 + - 66880 + - 66881 + - 66882 + - 66883 + - 66884 + - 66885 + - 66886 + - 66887 + - 66888 + - 66889 + - 66890 + - 66891 + - 66892 + - 66893 + - 66894 + - 66895 + - 66896 + - 66897 + - 66898 + - 66899 + - 66900 + - 66901 + - 66902 + - 66903 + - 66904 + - 66905 + - 66906 + - 66907 + - 66908 + - 66909 + - 66910 + - 66911 + - 66912 + - 66913 + - 66914 + - 66915 + - 66916 + - 66917 + - 66918 + - 66919 + - 66920 + - 66921 + - 66922 + - 66923 + - 66924 + - 66925 + - 66926 + - 66927 + - 66928 + - 66929 + - 66930 + - 66931 + - 66932 + - 66933 + - 66934 + - 66935 + - 66936 + - 66937 + - 66938 + - 66939 + - 66940 + - 66941 + - 66942 + - 66943 + - 66944 + - 66945 + - 66946 + - 66947 + - 66948 + - 66949 + - 66950 + - 66951 + - 66952 + - 66953 + - 66954 + - 66955 + - 66956 + - 66957 + - 66958 + - 66959 + - 66960 + - 66961 + - 66962 + - 66963 + - 66964 + - 66965 + - 66966 + - 66967 + - 66968 + - 66969 + - 66970 + - 66971 + - 66972 + - 66973 + - 66974 + - 66975 + - 66976 + - 66977 + - 66978 + - 66979 + - 66980 + - 66981 + - 66982 + - 66983 + - 66984 + - 66985 + - 66986 + - 66987 + - 66988 + - 66989 + - 66990 + - 66991 + - 66992 + - 66993 + - 66994 + - 66995 + - 66996 + - 66997 + - 66998 + - 66999 + - 67000 + - 67001 + - 67002 + - 67003 + - 67004 + - 67005 + - 67006 + - 67007 + - 67008 + - 67009 + - 67010 + - 67011 + - 67012 + - 67013 + - 67014 + - 67015 + - 67016 + - 67017 + - 67018 + - 67019 + - 67020 + - 67021 + - 67022 + - 67023 + - 67024 + - 67025 + - 67026 + - 67027 + - 67028 + - 67029 + - 67030 + - 67031 + - 67032 + - 67033 + - 67034 + - 67035 + - 67036 + - 67037 + - 67038 + - 67039 + - 67040 + - 67041 + - 67042 + - 67043 + - 67044 + - 67045 + - 67046 + - 67047 + - 67048 + - 67049 + - 67050 + - 67051 + - 67052 + - 67053 + - 67054 + - 67055 + - 67056 + - 67057 + - 67058 + - 67059 + - 67060 + - 67061 + - 67062 + - 67063 + - 67064 + - 67065 + - 67066 + - 67067 + - 67068 + - 67069 + - 67070 + - 67071 + - 67072 + - 67073 + - 67074 + - 67075 + - 67076 + - 67077 + - 67078 + - 67079 + - 67080 + - 67081 + - 67082 + - 67083 + - 67084 + - 67085 + - 67086 + - 67087 + - 67088 + - 67089 + - 67090 + - 67091 + - 67092 + - 67093 + - 67094 + - 67095 + - 67096 + - 67097 + - 67098 + - 67099 + - 67100 + - 67101 + - 67102 + - 67103 + - 67104 + - 67105 + - 67106 + - 67107 + - 67108 + - 67109 + - 67110 + - 67111 + - 67112 + - 67113 + - 67114 + - 67115 + - 67116 + - 67117 + - 67118 + - 67119 + - 67120 + - 67121 + - 67122 + - 67123 + - 67124 + - 67125 + - 67126 + - 67127 + - 67128 + - 67129 + - 67130 + - 67131 + - 67132 + - 67133 + - 67134 + - 67135 + - 67136 + - 67137 + - 67138 + - 67139 + - 67140 + - 67141 + - 67142 + - 67143 + - 67144 + - 67145 + - 67146 + - 67147 + - 67148 + - 67149 + - 67150 + - 67151 + - 67152 + - 67153 + - 67154 + - 67155 + - 67156 + - 67157 + - 67158 + - 67159 + - 67160 + - 67161 + - 67162 + - 67163 + - 67164 + - 67165 + - 67166 + - 67167 + - 67168 + - 67169 + - 67170 + - 67171 + - 67172 + - 67173 + - 67174 + - 67175 + - 67176 + - 67177 + - 67178 + - 67179 + - 67180 + - 67181 + - 67182 + - 67183 + - 67184 + - 67185 + - 67186 + - 67187 + - 67188 + - 67189 + - 67190 + - 67191 + - 67192 + - 67193 + - 67194 + - 67195 + - 67196 + - 67197 + - 67198 + - 67199 + - 67200 + - 67201 + - 67202 + - 67203 + - 67204 + - 67205 + - 67206 + - 67207 + - 67208 + - 67209 + - 67210 + - 67211 + - 67212 + - 67213 + - 67214 + - 67215 + - 67216 + - 67217 + - 67218 + - 67219 + - 67220 + - 67221 + - 67222 + - 67223 + - 67224 + - 67225 + - 67226 + - 67227 + - 67228 + - 67229 + - 67230 + - 67231 + - 67232 + - 67233 + - 67234 + - 67235 + - 67236 + - 67237 + - 67238 + - 67239 + - 67240 + - 67241 + - 67242 + - 67243 + - 67244 + - 67245 + - 67246 + - 67247 + - 67248 + - 67249 + - 67250 + - 67251 + - 67252 + - 67253 + - 67254 + - 67255 + - 67256 + - 67257 + - 67258 + - 67259 + - 67260 + - 67261 + - 67262 + - 67263 + - 67264 + - 67265 + - 67266 + - 67267 + - 67268 + - 67269 + - 67270 + - 67271 + - 67272 + - 67273 + - 67274 + - 67275 + - 67276 + - 67277 + - 67278 + - 67279 + - 67280 + - 67281 + - 67282 + - 67283 + - 67284 + - 67285 + - 67286 + - 67287 + - 67288 + - 67289 + - 67290 + - 67291 + - 67292 + - 67293 + - 67294 + - 67295 + - 67296 + - 67297 + - 67298 + - 67299 + - 67300 + - 67301 + - 67302 + - 67303 + - 67304 + - 67305 + - 67306 + - 67307 + - 67308 + - 67309 + - 67310 + - 67311 + - 67312 + - 67313 + - 67314 + - 67315 + - 67316 + - 67317 + - 67318 + - 67319 + - 67320 + - 67321 + - 67322 + - 67323 + - 67324 + - 67325 + - 67326 + - 67327 + - 67328 + - 67329 + - 67330 + - 67331 + - 67332 + - 67333 + - 67334 + - 67335 + - 67336 + - 67337 + - 67338 + - 67339 + - 67340 + - 67341 + - 67342 + - 67343 + - 67344 + - 67345 + - 67346 + - 67347 + - 67348 + - 67349 + - 67350 + - 67351 + - 67352 + - 67353 + - 67354 + - 67355 + - 67356 + - 67357 + - 67358 + - 67359 + - 67360 + - 67361 + - 67362 + - 67363 + - 67364 + - 67365 + - 67366 + - 67367 + - 67368 + - 67369 + - 67370 + - 67371 + - 67372 + - 67373 + - 67374 + - 67375 + - 67376 + - 67377 + - 67378 + - 67379 + - 67380 + - 67381 + - 67382 + - 67383 + - 67384 + - 67385 + - 67386 + - 67387 + - 67388 + - 67389 + - 67390 + - 67391 + - 67392 + - 67393 + - 67394 + - 67395 + - 67396 + - 67397 + - 67398 + - 67399 + - 67400 + - 67401 + - 67402 + - 67403 + - 67404 + - 67405 + - 67406 + - 67407 + - 67408 + - 67409 + - 67410 + - 67411 + - 67412 + - 67413 + - 67414 + - 67415 + - 67416 + - 67417 + - 67418 + - 67419 + - 67420 + - 67421 + - 67422 + - 67423 + - 67424 + - 67425 + - 67426 + - 67427 + - 67428 + - 67429 + - 67430 + - 67431 + - 67432 + - 67433 + - 67434 + - 67435 + - 67436 + - 67437 + - 67438 + - 67439 + - 67440 + - 67441 + - 67442 + - 67443 + - 67444 + - 67445 + - 67446 + - 67447 + - 67448 + - 67449 + - 67450 + - 67451 + - 67452 + - 67453 + - 67454 + - 67455 + - 67456 + - 67457 + - 67458 + - 67459 + - 67460 + - 67461 + - 67462 + - 67463 + - 67464 + - 67465 + - 67466 + - 67467 + - 67468 + - 67469 + - 67470 + - 67471 + - 67472 + - 67473 + - 67474 + - 67475 + - 67476 + - 67477 + - 67478 + - 67479 + - 67480 + - 67481 + - 67482 + - 67483 + - 67484 + - 67485 + - 67486 + - 67487 + - 67488 + - 67489 + - 67490 + - 67491 + - 67492 + - 67493 + - 67494 + - 67495 + - 67496 + - 67497 + - 67498 + - 67499 + - 67500 + - 67501 + - 67502 + - 67503 + - 67504 + - 67505 + - 67506 + - 67507 + - 67508 + - 67509 + - 67510 + - 67511 + - 67512 + - 67513 + - 67514 + - 67515 + - 67516 + - 67517 + - 67518 + - 67519 + - 67520 + - 67521 + - 67522 + - 67523 + - 67524 + - 67525 + - 67526 + - 67527 + - 67528 + - 67529 + - 67530 + - 67531 + - 67532 + - 67533 + - 67534 + - 67535 + - 67536 + - 67537 + - 67538 + - 67539 + - 67540 + - 67541 + - 67542 + - 67543 + - 67544 + - 67545 + - 67546 + - 67547 + - 67548 + - 67549 + - 67550 + - 67551 + - 67552 + - 67553 + - 67554 + - 67555 + - 67556 + - 67557 + - 67558 + - 67559 + - 67560 + - 67561 + - 67562 + - 67563 + - 67564 + - 67565 + - 67566 + - 67567 + - 67568 + - 67569 + - 67570 + - 67571 + - 67572 + - 67573 + - 67574 + - 67575 + - 67576 + - 67577 + - 67578 + - 67579 + - 67580 + - 67581 + - 67582 + - 67583 + - 67584 + - 67585 + - 67586 + - 67587 + - 67588 + - 67589 + - 67590 + - 67591 + - 67592 + - 67593 + - 67594 + - 67595 + - 67596 + - 67597 + - 67598 + - 67599 + - 67600 + - 67601 + - 67602 + - 67603 + - 67604 + - 67605 + - 67606 + - 67607 + - 67608 + - 67609 + - 67610 + - 67611 + - 67612 + - 67613 + - 67614 + - 67615 + - 67616 + - 67617 + - 67618 + - 67619 + - 67620 + - 67621 + - 67622 + - 67623 + - 67624 + - 67625 + - 67626 + - 67627 + - 67628 + - 67629 + - 67630 + - 67631 + - 67632 + - 67633 + - 67634 + - 67635 + - 67636 + - 67637 + - 67638 + - 67639 + - 67640 + - 67641 + - 67642 + - 67643 + - 67644 + - 67645 + - 67646 + - 67647 + - 67648 + - 67649 + - 67650 + - 67651 + - 67652 + - 67653 + - 67654 + - 67655 + - 67656 + - 67657 + - 67658 + - 67659 + - 67660 + - 67661 + - 67662 + - 67663 + - 67664 + - 67665 + - 67666 + - 67667 + - 67668 + - 67669 + - 67670 + - 67671 + - 67672 + - 67673 + - 67674 + - 67675 + - 67676 + - 67677 + - 67678 + - 67679 + - 67680 + - 67681 + - 67682 + - 67683 + - 67684 + - 67685 + - 67686 + - 67687 + - 67688 + - 67689 + - 67690 + - 67691 + - 67692 + - 67693 + - 67694 + - 67695 + - 67696 + - 67697 + - 67698 + - 67699 + - 67700 + - 67701 + - 67702 + - 67703 + - 67704 + - 67705 + - 67706 + - 67707 + - 67708 + - 67709 + - 67710 + - 67711 + - 67712 + - 67713 + - 67714 + - 67715 + - 67716 + - 67717 + - 67718 + - 67719 + - 67720 + - 67721 + - 67722 + - 67723 + - 67724 + - 67725 + - 67726 + - 67727 + - 67728 + - 67729 + - 67730 + - 67731 + - 67732 + - 67733 + - 67734 + - 67735 + - 67736 + - 67737 + - 67738 + - 67739 + - 67740 + - 67741 + - 67742 + - 67743 + - 67744 + - 67745 + - 67746 + - 67747 + - 67748 + - 67749 + - 67750 + - 67751 + - 67752 + - 67753 + - 67754 + - 67755 + - 67756 + - 67757 + - 67758 + - 67759 + - 67760 + - 67761 + - 67762 + - 67763 + - 67764 + - 67765 + - 67766 + - 67767 + - 67768 + - 67769 + - 67770 + - 67771 + - 67772 + - 67773 + - 67774 + - 67775 + - 67776 + - 67777 + - 67778 + - 67779 + - 67780 + - 67781 + - 67782 + - 67783 + - 67784 + - 67785 + - 67786 + - 67787 + - 67788 + - 67789 + - 67790 + - 67791 + - 67792 + - 67793 + - 67794 + - 67795 + - 67796 + - 67797 + - 67798 + - 67799 + - 67800 + - 67801 + - 67802 + - 67803 + - 67804 + - 67805 + - 67806 + - 67807 + - 67808 + - 67809 + - 67810 + - 67811 + - 67812 + - 67813 + - 67814 + - 67815 + - 67816 + - 67817 + - 67818 + - 67819 + - 67820 + - 67821 + - 67822 + - 67823 + - 67824 + - 67825 + - 67826 + - 67827 + - 67828 + - 67829 + - 67830 + - 67831 + - 67832 + - 67833 + - 67834 + - 67835 + - 67836 + - 67837 + - 67838 + - 67839 + - 67840 + - 67841 + - 67842 + - 67843 + - 67844 + - 67845 + - 67846 + - 67847 + - 67848 + - 67849 + - 67850 + - 67851 + - 67852 + - 67853 + - 67854 + - 67855 + - 67856 + - 67857 + - 67858 + - 67859 + - 67860 + - 67861 + - 67862 + - 67863 + - 67864 + - 67865 + - 67866 + - 67867 + - 67868 + - 67869 + - 67870 + - 67871 + - 67872 + - 67873 + - 67874 + - 67875 + - 67876 + - 67877 + - 67878 + - 67879 + - 67880 + - 67881 + - 67882 + - 67883 + - 67884 + - 67885 + - 67886 + - 67887 + - 67888 + - 67889 + - 67890 + - 67891 + - 67892 + - 67893 + - 67894 + - 67895 + - 67896 + - 67897 + - 67898 + - 67899 + - 67900 + - 67901 + - 67902 + - 67903 + - 67904 + - 67905 + - 67906 + - 67907 + - 67908 + - 67909 + - 67910 + - 67911 + - 67912 + - 67913 + - 67914 + - 67915 + - 67916 + - 67917 + - 67918 + - 67919 + - 67920 + - 67921 + - 67922 + - 67923 + - 67924 + - 67925 + - 67926 + - 67927 + - 67928 + - 67929 + - 67930 + - 67931 + - 67932 + - 67933 + - 67934 + - 67935 + - 67936 + - 67937 + - 67938 + - 67939 + - 67940 + - 67941 + - 67942 + - 67943 + - 67944 + - 67945 + - 67946 + - 67947 + - 67948 + - 67949 + - 67950 + - 67951 + - 67952 + - 67953 + - 67954 + - 67955 + - 67956 + - 67957 + - 67958 + - 67959 + - 67960 + - 67961 + - 67962 + - 67963 + - 67964 + - 67965 + - 67966 + - 67967 + - 67968 + - 67969 + - 67970 + - 67971 + - 67972 + - 67973 + - 67974 + - 67975 + - 67976 + - 67977 + - 67978 + - 67979 + - 67980 + - 67981 + - 67982 + - 67983 + - 67984 + - 67985 + - 67986 + - 67987 + - 67988 + - 67989 + - 67990 + - 67991 + - 67992 + - 67993 + - 67994 + - 67995 + - 67996 + - 67997 + - 67998 + - 67999 + - 68000 + - 68001 + - 68002 + - 68003 + - 68004 + - 68005 + - 68006 + - 68007 + - 68008 + - 68009 + - 68010 + - 68011 + - 68012 + - 68013 + - 68014 + - 68015 + - 68016 + - 68017 + - 68018 + - 68019 + - 68020 + - 68021 + - 68022 + - 68023 + - 68024 + - 68025 + - 68026 + - 68027 + - 68028 + - 68029 + - 68030 + - 68031 + - 68032 + - 68033 + - 68034 + - 68035 + - 68036 + - 68037 + - 68038 + - 68039 + - 68040 + - 68041 + - 68042 + - 68043 + - 68044 + - 68045 + - 68046 + - 68047 + - 68048 + - 68049 + - 68050 + - 68051 + - 68052 + - 68053 + - 68054 + - 68055 + - 68056 + - 68057 + - 68058 + - 68059 + - 68060 + - 68061 + - 68062 + - 68063 + - 68064 + - 68065 + - 68066 + - 68067 + - 68068 + - 68069 + - 68070 + - 68071 + - 68072 + - 68073 + - 68074 + - 68075 + - 68076 + - 68077 + - 68078 + - 68079 + - 68080 + - 68081 + - 68082 + - 68083 + - 68084 + - 68085 + - 68086 + - 68087 + - 68088 + - 68089 + - 68090 + - 68091 + - 68092 + - 68093 + - 68094 + - 68095 + - 68096 + - 68097 + - 68098 + - 68099 + - 68100 + - 68101 + - 68102 + - 68103 + - 68104 + - 68105 + - 68106 + - 68107 + - 68108 + - 68109 + - 68110 + - 68111 + - 68112 + - 68113 + - 68114 + - 68115 + - 68116 + - 68117 + - 68118 + - 68119 + - 68120 + - 68121 + - 68122 + - 68123 + - 68124 + - 68125 + - 68126 + - 68127 + - 68128 + - 68129 + - 68130 + - 68131 + - 68132 + - 68133 + - 68134 + - 68135 + - 68136 + - 68137 + - 68138 + - 68139 + - 68140 + - 68141 + - 68142 + - 68143 + - 68144 + - 68145 + - 68146 + - 68147 + - 68148 + - 68149 + - 68150 + - 68151 + - 68152 + - 68153 + - 68154 + - 68155 + - 68156 + - 68157 + - 68158 + - 68159 + - 68160 + - 68161 + - 68162 + - 68163 + - 68164 + - 68165 + - 68166 + - 68167 + - 68168 + - 68169 + - 68170 + - 68171 + - 68172 + - 68173 + - 68174 + - 68175 + - 68176 + - 68177 + - 68178 + - 68179 + - 68180 + - 68181 + - 68182 + - 68183 + - 68184 + - 68185 + - 68186 + - 68187 + - 68188 + - 68189 + - 68190 + - 68191 + - 68192 + - 68193 + - 68194 + - 68195 + - 68196 + - 68197 + - 68198 + - 68199 + - 68200 + - 68201 + - 68202 + - 68203 + - 68204 + - 68205 + - 68206 + - 68207 + - 68208 + - 68209 + - 68210 + - 68211 + - 68212 + - 68213 + - 68214 + - 68215 + - 68216 + - 68217 + - 68218 + - 68219 + - 68220 + - 68221 + - 68222 + - 68223 + - 68224 + - 68225 + - 68226 + - 68227 + - 68228 + - 68229 + - 68230 + - 68231 + - 68232 + - 68233 + - 68234 + - 68235 + - 68236 + - 68237 + - 68238 + - 68239 + - 68240 + - 68241 + - 68242 + - 68243 + - 68244 + - 68245 + - 68246 + - 68247 + - 68248 + - 68249 + - 68250 + - 68251 + - 68252 + - 68253 + - 68254 + - 68255 + - 68256 + - 68257 + - 68258 + - 68259 + - 68260 + - 68261 + - 68262 + - 68263 + - 68264 + - 68265 + - 68266 + - 68267 + - 68268 + - 68269 + - 68270 + - 68271 + - 68272 + - 68273 + - 68274 + - 68275 + - 68276 + - 68277 + - 68278 + - 68279 + - 68280 + - 68281 + - 68282 + - 68283 + - 68284 + - 68285 + - 68286 + - 68287 + - 68288 + - 68289 + - 68290 + - 68291 + - 68292 + - 68293 + - 68294 + - 68295 + - 68296 + - 68297 + - 68298 + - 68299 + - 68300 + - 68301 + - 68302 + - 68303 + - 68304 + - 68305 + - 68306 + - 68307 + - 68308 + - 68309 + - 68310 + - 68311 + - 68312 + - 68313 + - 68314 + - 68315 + - 68316 + - 68317 + - 68318 + - 68319 + - 68320 + - 68321 + - 68322 + - 68323 + - 68324 + - 68325 + - 68326 + - 68327 + - 68328 + - 68329 + - 68330 + - 68331 + - 68332 + - 68333 + - 68334 + - 68335 + - 68336 + - 68337 + - 68338 + - 68339 + - 68340 + - 68341 + - 68342 + - 68343 + - 68344 + - 68345 + - 68346 + - 68347 + - 68348 + - 68349 + - 68350 + - 68351 + - 68352 + - 68353 + - 68354 + - 68355 + - 68356 + - 68357 + - 68358 + - 68359 + - 68360 + - 68361 + - 68362 + - 68363 + - 68364 + - 68365 + - 68366 + - 68367 + - 68368 + - 68369 + - 68370 + - 68371 + - 68372 + - 68373 + - 68374 + - 68375 + - 68376 + - 68377 + - 68378 + - 68379 + - 68380 + - 68381 + - 68382 + - 68383 + - 68384 + - 68385 + - 68386 + - 68387 + - 68388 + - 68389 + - 68390 + - 68391 + - 68392 + - 68393 + - 68394 + - 68395 + - 68396 + - 68397 + - 68398 + - 68399 + - 68400 + - 68401 + - 68402 + - 68403 + - 68404 + - 68405 + - 68406 + - 68407 + - 68408 + - 68409 + - 68410 + - 68411 + - 68412 + - 68413 + - 68414 + - 68415 + - 68416 + - 68417 + - 68418 + - 68419 + - 68420 + - 68421 + - 68422 + - 68423 + - 68424 + - 68425 + - 68426 + - 68427 + - 68428 + - 68429 + - 68430 + - 68431 + - 68432 + - 68433 + - 68434 + - 68435 + - 68436 + - 68437 + - 68438 + - 68439 + - 68440 + - 68441 + - 68442 + - 68443 + - 68444 + - 68445 + - 68446 + - 68447 + - 68448 + - 68449 + - 68450 + - 68451 + - 68452 + - 68453 + - 68454 + - 68455 + - 68456 + - 68457 + - 68458 + - 68459 + - 68460 + - 68461 + - 68462 + - 68463 + - 68464 + - 68465 + - 68466 + - 68467 + - 68468 + - 68469 + - 68470 + - 68471 + - 68472 + - 68473 + - 68474 + - 68475 + - 68476 + - 68477 + - 68478 + - 68479 + - 68480 + - 68481 + - 68482 + - 68483 + - 68484 + - 68485 + - 68486 + - 68487 + - 68488 + - 68489 + - 68490 + - 68491 + - 68492 + - 68493 + - 68494 + - 68495 + - 68496 + - 68497 + - 68498 + - 68499 + - 68500 + - 68501 + - 68502 + - 68503 + - 68504 + - 68505 + - 68506 + - 68507 + - 68508 + - 68509 + - 68510 + - 68511 + - 68512 + - 68513 + - 68514 + - 68515 + - 68516 + - 68517 + - 68518 + - 68519 + - 68520 + - 68521 + - 68522 + - 68523 + - 68524 + - 68525 + - 68526 + - 68527 + - 68528 + - 68529 + - 68530 + - 68531 + - 68532 + - 68533 + - 68534 + - 68535 + - 68536 + - 68537 + - 68538 + - 68539 + - 68540 + - 68541 + - 68542 + - 68543 + - 68544 + - 68545 + - 68546 + - 68547 + - 68548 + - 68549 + - 68550 + - 68551 + - 68552 + - 68553 + - 68554 + - 68555 + - 68556 + - 68557 + - 68558 + - 68559 + - 68560 + - 68561 + - 68562 + - 68563 + - 68564 + - 68565 + - 68566 + - 68567 + - 68568 + - 68569 + - 68570 + - 68571 + - 68572 + - 68573 + - 68574 + - 68575 + - 68576 + - 68577 + - 68578 + - 68579 + - 68580 + - 68581 + - 68582 + - 68583 + - 68584 + - 68585 + - 68586 + - 68587 + - 68588 + - 68589 + - 68590 + - 68591 + - 68592 + - 68593 + - 68594 + - 68595 + - 68596 + - 68597 + - 68598 + - 68599 + - 68600 + - 68601 + - 68602 + - 68603 + - 68604 + - 68605 + - 68606 + - 68607 + - 68608 + - 68609 + - 68610 + - 68611 + - 68612 + - 68613 + - 68614 + - 68615 + - 68616 + - 68617 + - 68618 + - 68619 + - 68620 + - 68621 + - 68622 + - 68623 + - 68624 + - 68625 + - 68626 + - 68627 + - 68628 + - 68629 + - 68630 + - 68631 + - 68632 + - 68633 + - 68634 + - 68635 + - 68636 + - 68637 + - 68638 + - 68639 + - 68640 + - 68641 + - 68642 + - 68643 + - 68644 + - 68645 + - 68646 + - 68647 + - 68648 + - 68649 + - 68650 + - 68651 + - 68652 + - 68653 + - 68654 + - 68655 + - 68656 + - 68657 + - 68658 + - 68659 + - 68660 + - 68661 + - 68662 + - 68663 + - 68664 + - 68665 + - 68666 + - 68667 + - 68668 + - 68669 + - 68670 + - 68671 + - 68672 + - 68673 + - 68674 + - 68675 + - 68676 + - 68677 + - 68678 + - 68679 + - 68680 + - 68681 + - 68682 + - 68683 + - 68684 + - 68685 + - 68686 + - 68687 + - 68688 + - 68689 + - 68690 + - 68691 + - 68692 + - 68693 + - 68694 + - 68695 + - 68696 + - 68697 + - 68698 + - 68699 + - 68700 + - 68701 + - 68702 + - 68703 + - 68704 + - 68705 + - 68706 + - 68707 + - 68708 + - 68709 + - 68710 + - 68711 + - 68712 + - 68713 + - 68714 + - 68715 + - 68716 + - 68717 + - 68718 + - 68719 + - 68720 + - 68721 + - 68722 + - 68723 + - 68724 + - 68725 + - 68726 + - 68727 + - 68728 + - 68729 + - 68730 + - 68731 + - 68732 + - 68733 + - 68734 + - 68735 + - 68736 + - 68737 + - 68738 + - 68739 + - 68740 + - 68741 + - 68742 + - 68743 + - 68744 + - 68745 + - 68746 + - 68747 + - 68748 + - 68749 + - 68750 + - 68751 + - 68752 + - 68753 + - 68754 + - 68755 + - 68756 + - 68757 + - 68758 + - 68759 + - 68760 + - 68761 + - 68762 + - 68763 + - 68764 + - 68765 + - 68766 + - 68767 + - 68768 + - 68769 + - 68770 + - 68771 + - 68772 + - 68773 + - 68774 + - 68775 + - 68776 + - 68777 + - 68778 + - 68779 + - 68780 + - 68781 + - 68782 + - 68783 + - 68784 + - 68785 + - 68786 + - 68787 + - 68788 + - 68789 + - 68790 + - 68791 + - 68792 + - 68793 + - 68794 + - 68795 + - 68796 + - 68797 + - 68798 + - 68799 + - 68800 + - 68801 + - 68802 + - 68803 + - 68804 + - 68805 + - 68806 + - 68807 + - 68808 + - 68809 + - 68810 + - 68811 + - 68812 + - 68813 + - 68814 + - 68815 + - 68816 + - 68817 + - 68818 + - 68819 + - 68820 + - 68821 + - 68822 + - 68823 + - 68824 + - 68825 + - 68826 + - 68827 + - 68828 + - 68829 + - 68830 + - 68831 + - 68832 + - 68833 + - 68834 + - 68835 + - 68836 + - 68837 + - 68838 + - 68839 + - 68840 + - 68841 + - 68842 + - 68843 + - 68844 + - 68845 + - 68846 + - 68847 + - 68848 + - 68849 + - 68850 + - 68851 + - 68852 + - 68853 + - 68854 + - 68855 + - 68856 + - 68857 + - 68858 + - 68859 + - 68860 + - 68861 + - 68862 + - 68863 + - 68864 + - 68865 + - 68866 + - 68867 + - 68868 + - 68869 + - 68870 + - 68871 + - 68872 + - 68873 + - 68874 + - 68875 + - 68876 + - 68877 + - 68878 + - 68879 + - 68880 + - 68881 + - 68882 + - 68883 + - 68884 + - 68885 + - 68886 + - 68887 + - 68888 + - 68889 + - 68890 + - 68891 + - 68892 + - 68893 + - 68894 + - 68895 + - 68896 + - 68897 + - 68898 + - 68899 + - 68900 + - 68901 + - 68902 + - 68903 + - 68904 + - 68905 + - 68906 + - 68907 + - 68908 + - 68909 + - 68910 + - 68911 + - 68912 + - 68913 + - 68914 + - 68915 + - 68916 + - 68917 + - 68918 + - 68919 + - 68920 + - 68921 + - 68922 + - 68923 + - 68924 + - 68925 + - 68926 + - 68927 + - 68928 + - 68929 + - 68930 + - 68931 + - 68932 + - 68933 + - 68934 + - 68935 + - 68936 + - 68937 + - 68938 + - 68939 + - 68940 + - 68941 + - 68942 + - 68943 + - 68944 + - 68945 + - 68946 + - 68947 + - 68948 + - 68949 + - 68950 + - 68951 + - 68952 + - 68953 + - 68954 + - 68955 + - 68956 + - 68957 + - 68958 + - 68959 + - 68960 + - 68961 + - 68962 + - 68963 + - 68964 + - 68965 + - 68966 + - 68967 + - 68968 + - 68969 + - 68970 + - 68971 + - 68972 + - 68973 + - 68974 + - 68975 + - 68976 + - 68977 + - 68978 + - 68979 + - 68980 + - 68981 + - 68982 + - 68983 + - 68984 + - 68985 + - 68986 + - 68987 + - 68988 + - 68989 + - 68990 + - 68991 + - 68992 + - 68993 + - 68994 + - 68995 + - 68996 + - 68997 + - 68998 + - 68999 + - 69000 + - 69001 + - 69002 + - 69003 + - 69004 + - 69005 + - 69006 + - 69007 + - 69008 + - 69009 + - 69010 + - 69011 + - 69012 + - 69013 + - 69014 + - 69015 + - 69016 + - 69017 + - 69018 + - 69019 + - 69020 + - 69021 + - 69022 + - 69023 + - 69024 + - 69025 + - 69026 + - 69027 + - 69028 + - 69029 + - 69030 + - 69031 + - 69032 + - 69033 + - 69034 + - 69035 + - 69036 + - 69037 + - 69038 + - 69039 + - 69040 + - 69041 + - 69042 + - 69043 + - 69044 + - 69045 + - 69046 + - 69047 + - 69048 + - 69049 + - 69050 + - 69051 + - 69052 + - 69053 + - 69054 + - 69055 + - 69056 + - 69057 + - 69058 + - 69059 + - 69060 + - 69061 + - 69062 + - 69063 + - 69064 + - 69065 + - 69066 + - 69067 + - 69068 + - 69069 + - 69070 + - 69071 + - 69072 + - 69073 + - 69074 + - 69075 + - 69076 + - 69077 + - 69078 + - 69079 + - 69080 + - 69081 + - 69082 + - 69083 + - 69084 + - 69085 + - 69086 + - 69087 + - 69088 + - 69089 + - 69090 + - 69091 + - 69092 + - 69093 + - 69094 + - 69095 + - 69096 + - 69097 + - 69098 + - 69099 + - 69100 + - 69101 + - 69102 + - 69103 + - 69104 + - 69105 + - 69106 + - 69107 + - 69108 + - 69109 + - 69110 + - 69111 + - 69112 + - 69113 + - 69114 + - 69115 + - 69116 + - 69117 + - 69118 + - 69119 + - 69120 + - 69121 + - 69122 + - 69123 + - 69124 + - 69125 + - 69126 + - 69127 + - 69128 + - 69129 + - 69130 + - 69131 + - 69132 + - 69133 + - 69134 + - 69135 + - 69136 + - 69137 + - 69138 + - 69139 + - 69140 + - 69141 + - 69142 + - 69143 + - 69144 + - 69145 + - 69146 + - 69147 + - 69148 + - 69149 + - 69150 + - 69151 + - 69152 + - 69153 + - 69154 + - 69155 + - 69156 + - 69157 + - 69158 + - 69159 + - 69160 + - 69161 + - 69162 + - 69163 + - 69164 + - 69165 + - 69166 + - 69167 + - 69168 + - 69169 + - 69170 + - 69171 + - 69172 + - 69173 + - 69174 + - 69175 + - 69176 + - 69177 + - 69178 + - 69179 + - 69180 + - 69181 + - 69182 + - 69183 + - 69184 + - 69185 + - 69186 + - 69187 + - 69188 + - 69189 + - 69190 + - 69191 + - 69192 + - 69193 + - 69194 + - 69195 + - 69196 + - 69197 + - 69198 + - 69199 + - 69200 + - 69201 + - 69202 + - 69203 + - 69204 + - 69205 + - 69206 + - 69207 + - 69208 + - 69209 + - 69210 + - 69211 + - 69212 + - 69213 + - 69214 + - 69215 + - 69216 + - 69217 + - 69218 + - 69219 + - 69220 + - 69221 + - 69222 + - 69223 + - 69224 + - 69225 + - 69226 + - 69227 + - 69228 + - 69229 + - 69230 + - 69231 + - 69232 + - 69233 + - 69234 + - 69235 + - 69236 + - 69237 + - 69238 + - 69239 + - 69240 + - 69241 + - 69242 + - 69243 + - 69244 + - 69245 + - 69246 + - 69247 + - 69248 + - 69249 + - 69250 + - 69251 + - 69252 + - 69253 + - 69254 + - 69255 + - 69256 + - 69257 + - 69258 + - 69259 + - 69260 + - 69261 + - 69262 + - 69263 + - 69264 + - 69265 + - 69266 + - 69267 + - 69268 + - 69269 + - 69270 + - 69271 + - 69272 + - 69273 + - 69274 + - 69275 + - 69276 + - 69277 + - 69278 + - 69279 + - 69280 + - 69281 + - 69282 + - 69283 + - 69284 + - 69285 + - 69286 + - 69287 + - 69288 + - 69289 + - 69290 + - 69291 + - 69292 + - 69293 + - 69294 + - 69295 + - 69296 + - 69297 + - 69298 + - 69299 + - 69300 + - 69301 + - 69302 + - 69303 + - 69304 + - 69305 + - 69306 + - 69307 + - 69308 + - 69309 + - 69310 + - 69311 + - 69312 + - 69313 + - 69314 + - 69315 + - 69316 + - 69317 + - 69318 + - 69319 + - 69320 + - 69321 + - 69322 + - 69323 + - 69324 + - 69325 + - 69326 + - 69327 + - 69328 + - 69329 + - 69330 + - 69331 + - 69332 + - 69333 + - 69334 + - 69335 + - 69336 + - 69337 + - 69338 + - 69339 + - 69340 + - 69341 + - 69342 + - 69343 + - 69344 + - 69345 + - 69346 + - 69347 + - 69348 + - 69349 + - 69350 + - 69351 + - 69352 + - 69353 + - 69354 + - 69355 + - 69356 + - 69357 + - 69358 + - 69359 + - 69360 + - 69361 + - 69362 + - 69363 + - 69364 + - 69365 + - 69366 + - 69367 + - 69368 + - 69369 + - 69370 + - 69371 + - 69372 + - 69373 + - 69374 + - 69375 + - 69376 + - 69377 + - 69378 + - 69379 + - 69380 + - 69381 + - 69382 + - 69383 + - 69384 + - 69385 + - 69386 + - 69387 + - 69388 + - 69389 + - 69390 + - 69391 + - 69392 + - 69393 + - 69394 + - 69395 + - 69396 + - 69397 + - 69398 + - 69399 + - 69400 + - 69401 + - 69402 + - 69403 + - 69404 + - 69405 + - 69406 + - 69407 + - 69408 + - 69409 + - 69410 + - 69411 + - 69412 + - 69413 + - 69414 + - 69415 + - 69416 + - 69417 + - 69418 + - 69419 + - 69420 + - 69421 + - 69422 + - 69423 + - 69424 + - 69425 + - 69426 + - 69427 + - 69428 + - 69429 + - 69430 + - 69431 + - 69432 + - 69433 + - 69434 + - 69435 + - 69436 + - 69437 + - 69438 + - 69439 + - 69440 + - 69441 + - 69442 + - 69443 + - 69444 + - 69445 + - 69446 + - 69447 + - 69448 + - 69449 + - 69450 + - 69451 + - 69452 + - 69453 + - 69454 + - 69455 + - 69456 + - 69457 + - 69458 + - 69459 + - 69460 + - 69461 + - 69462 + - 69463 + - 69464 + - 69465 + - 69466 + - 69467 + - 69468 + - 69469 + - 69470 + - 69471 + - 69472 + - 69473 + - 69474 + - 69475 + - 69476 + - 69477 + - 69478 + - 69479 + - 69480 + - 69481 + - 69482 + - 69483 + - 69484 + - 69485 + - 69486 + - 69487 + - 69488 + - 69489 + - 69490 + - 69491 + - 69492 + - 69493 + - 69494 + - 69495 + - 69496 + - 69497 + - 69498 + - 69499 + - 69500 + - 69501 + - 69502 + - 69503 + - 69504 + - 69505 + - 69506 + - 69507 + - 69508 + - 69509 + - 69510 + - 69511 + - 69512 + - 69513 + - 69514 + - 69515 + - 69516 + - 69517 + - 69518 + - 69519 + - 69520 + - 69521 + - 69522 + - 69523 + - 69524 + - 69525 + - 69526 + - 69527 + - 69528 + - 69529 + - 69530 + - 69531 + - 69532 + - 69533 + - 69534 + - 69535 + - 69536 + - 69537 + - 69538 + - 69539 + - 69540 + - 69541 + - 69542 + - 69543 + - 69544 + - 69545 + - 69546 + - 69547 + - 69548 + - 69549 + - 69550 + - 69551 + - 69552 + - 69553 + - 69554 + - 69555 + - 69556 + - 69557 + - 69558 + - 69559 + - 69560 + - 69561 + - 69562 + - 69563 + - 69564 + - 69565 + - 69566 + - 69567 + - 69568 + - 69569 + - 69570 + - 69571 + - 69572 + - 69573 + - 69574 + - 69575 + - 69576 + - 69577 + - 69578 + - 69579 + - 69580 + - 69581 + - 69582 + - 69583 + - 69584 + - 69585 + - 69586 + - 69587 + - 69588 + - 69589 + - 69590 + - 69591 + - 69592 + - 69593 + - 69594 + - 69595 + - 69596 + - 69597 + - 69598 + - 69599 + - 69600 + - 69601 + - 69602 + - 69603 + - 69604 + - 69605 + - 69606 + - 69607 + - 69608 + - 69609 + - 69610 + - 69611 + - 69612 + - 69613 + - 69614 + - 69615 + - 69616 + - 69617 + - 69618 + - 69619 + - 69620 + - 69621 + - 69622 + - 69623 + - 69624 + - 69625 + - 69626 + - 69627 + - 69628 + - 69629 + - 69630 + - 69631 + - 69632 + - 69633 + - 69634 + - 69635 + - 69636 + - 69637 + - 69638 + - 69639 + - 69640 + - 69641 + - 69642 + - 69643 + - 69644 + - 69645 + - 69646 + - 69647 + - 69648 + - 69649 + - 69650 + - 69651 + - 69652 + - 69653 + - 69654 + - 69655 + - 69656 + - 69657 + - 69658 + - 69659 + - 69660 + - 69661 + - 69662 + - 69663 + - 69664 + - 69665 + - 69666 + - 69667 + - 69668 + - 69669 + - 69670 + - 69671 + - 69672 + - 69673 + - 69674 + - 69675 + - 69676 + - 69677 + - 69678 + - 69679 + - 69680 + - 69681 + - 69682 + - 69683 + - 69684 + - 69685 + - 69686 + - 69687 + - 69688 + - 69689 + - 69690 + - 69691 + - 69692 + - 69693 + - 69694 + - 69695 + - 69696 + - 69697 + - 69698 + - 69699 + - 69700 + - 69701 + - 69702 + - 69703 + - 69704 + - 69705 + - 69706 + - 69707 + - 69708 + - 69709 + - 69710 + - 69711 + - 69712 + - 69713 + - 69714 + - 69715 + - 69716 + - 69717 + - 69718 + - 69719 + - 69720 + - 69721 + - 69722 + - 69723 + - 69724 + - 69725 + - 69726 + - 69727 + - 69728 + - 69729 + - 69730 + - 69731 + - 69732 + - 69733 + - 69734 + - 69735 + - 69736 + - 69737 + - 69738 + - 69739 + - 69740 + - 69741 + - 69742 + - 69743 + - 69744 + - 69745 + - 69746 + - 69747 + - 69748 + - 69749 + - 69750 + - 69751 + - 69752 + - 69753 + - 69754 + - 69755 + - 69756 + - 69757 + - 69758 + - 69759 + - 69760 + - 69761 + - 69762 + - 69763 + - 69764 + - 69765 + - 69766 + - 69767 + - 69768 + - 69769 + - 69770 + - 69771 + - 69772 + - 69773 + - 69774 + - 69775 + - 69776 + - 69777 + - 69778 + - 69779 + - 69780 + - 69781 + - 69782 + - 69783 + - 69784 + - 69785 + - 69786 + - 69787 + - 69788 + - 69789 + - 69790 + - 69791 + - 69792 + - 69793 + - 69794 + - 69795 + - 69796 + - 69797 + - 69798 + - 69799 + - 69800 + - 69801 + - 69802 + - 69803 + - 69804 + - 69805 + - 69806 + - 69807 + - 69808 + - 69809 + - 69810 + - 69811 + - 69812 + - 69813 + - 69814 + - 69815 + - 69816 + - 69817 + - 69818 + - 69819 + - 69820 + - 69821 + - 69822 + - 69823 + - 69824 + - 69825 + - 69826 + - 69827 + - 69828 + - 69829 + - 69830 + - 69831 + - 69832 + - 69833 + - 69834 + - 69835 + - 69836 + - 69837 + - 69838 + - 69839 + - 69840 + - 69841 + - 69842 + - 69843 + - 69844 + - 69845 + - 69846 + - 69847 + - 69848 + - 69849 + - 69850 + - 69851 + - 69852 + - 69853 + - 69854 + - 69855 + - 69856 + - 69857 + - 69858 + - 69859 + - 69860 + - 69861 + - 69862 + - 69863 + - 69864 + - 69865 + - 69866 + - 69867 + - 69868 + - 69869 + - 69870 + - 69871 + - 69872 + - 69873 + - 69874 + - 69875 + - 69876 + - 69877 + - 69878 + - 69879 + - 69880 + - 69881 + - 69882 + - 69883 + - 69884 + - 69885 + - 69886 + - 69887 + - 69888 + - 69889 + - 69890 + - 69891 + - 69892 + - 69893 + - 69894 + - 69895 + - 69896 + - 69897 + - 69898 + - 69899 + - 69900 + - 69901 + - 69902 + - 69903 + - 69904 + - 69905 + - 69906 + - 69907 + - 69908 + - 69909 + - 69910 + - 69911 + - 69912 + - 69913 + - 69914 + - 69915 + - 69916 + - 69917 + - 69918 + - 69919 + - 69920 + - 69921 + - 69922 + - 69923 + - 69924 + - 69925 + - 69926 + - 69927 + - 69928 + - 69929 + - 69930 + - 69931 + - 69932 + - 69933 + - 69934 + - 69935 + - 69936 + - 69937 + - 69938 + - 69939 + - 69940 + - 69941 + - 69942 + - 69943 + - 69944 + - 69945 + - 69946 + - 69947 + - 69948 + - 69949 + - 69950 + - 69951 + - 69952 + - 69953 + - 69954 + - 69955 + - 69956 + - 69957 + - 69958 + - 69959 + - 69960 + - 69961 + - 69962 + - 69963 + - 69964 + - 69965 + - 69966 + - 69967 + - 69968 + - 69969 + - 69970 + - 69971 + - 69972 + - 69973 + - 69974 + - 69975 + - 69976 + - 69977 + - 69978 + - 69979 + - 69980 + - 69981 + - 69982 + - 69983 + - 69984 + - 69985 + - 69986 + - 69987 + - 69988 + - 69989 + - 69990 + - 69991 + - 69992 + - 69993 + - 69994 + - 69995 + - 69996 + - 69997 + - 69998 + - 69999 + - 70000 + - 70001 + - 70002 + - 70003 + - 70004 + - 70005 + - 70006 + - 70007 + - 70008 + - 70009 + - 70010 + - 70011 + - 70012 + - 70013 + - 70014 + - 70015 + - 70016 + - 70017 + - 70018 + - 70019 + - 70020 + - 70021 + - 70022 + - 70023 + - 70024 + - 70025 + - 70026 + - 70027 + - 70028 + - 70029 + - 70030 + - 70031 + - 70032 + - 70033 + - 70034 + - 70035 + - 70036 + - 70037 + - 70038 + - 70039 + - 70040 + - 70041 + - 70042 + - 70043 + - 70044 + - 70045 + - 70046 + - 70047 + - 70048 + - 70049 + - 70050 + - 70051 + - 70052 + - 70053 + - 70054 + - 70055 + - 70056 + - 70057 + - 70058 + - 70059 + - 70060 + - 70061 + - 70062 + - 70063 + - 70064 + - 70065 + - 70066 + - 70067 + - 70068 + - 70069 + - 70070 + - 70071 + - 70072 + - 70073 + - 70074 + - 70075 + - 70076 + - 70077 + - 70078 + - 70079 + - 70080 + - 70081 + - 70082 + - 70083 + - 70084 + - 70085 + - 70086 + - 70087 + - 70088 + - 70089 + - 70090 + - 70091 + - 70092 + - 70093 + - 70094 + - 70095 + - 70096 + - 70097 + - 70098 + - 70099 + - 70100 + - 70101 + - 70102 + - 70103 + - 70104 + - 70105 + - 70106 + - 70107 + - 70108 + - 70109 + - 70110 + - 70111 + - 70112 + - 70113 + - 70114 + - 70115 + - 70116 + - 70117 + - 70118 + - 70119 + - 70120 + - 70121 + - 70122 + - 70123 + - 70124 + - 70125 + - 70126 + - 70127 + - 70128 + - 70129 + - 70130 + - 70131 + - 70132 + - 70133 + - 70134 + - 70135 + - 70136 + - 70137 + - 70138 + - 70139 + - 70140 + - 70141 + - 70142 + - 70143 + - 70144 + - 70145 + - 70146 + - 70147 + - 70148 + - 70149 + - 70150 + - 70151 + - 70152 + - 70153 + - 70154 + - 70155 + - 70156 + - 70157 + - 70158 + - 70159 + - 70160 + - 70161 + - 70162 + - 70163 + - 70164 + - 70165 + - 70166 + - 70167 + - 70168 + - 70169 + - 70170 + - 70171 + - 70172 + - 70173 + - 70174 + - 70175 + - 70176 + - 70177 + - 70178 + - 70179 + - 70180 + - 70181 + - 70182 + - 70183 + - 70184 + - 70185 + - 70186 + - 70187 + - 70188 + - 70189 + - 70190 + - 70191 + - 70192 + - 70193 + - 70194 + - 70195 + - 70196 + - 70197 + - 70198 + - 70199 + - 70200 + - 70201 + - 70202 + - 70203 + - 70204 + - 70205 + - 70206 + - 70207 + - 70208 + - 70209 + - 70210 + - 70211 + - 70212 + - 70213 + - 70214 + - 70215 + - 70216 + - 70217 + - 70218 + - 70219 + - 70220 + - 70221 + - 70222 + - 70223 + - 70224 + - 70225 + - 70226 + - 70227 + - 70228 + - 70229 + - 70230 + - 70231 + - 70232 + - 70233 + - 70234 + - 70235 + - 70236 + - 70237 + - 70238 + - 70239 + - 70240 + - 70241 + - 70242 + - 70243 + - 70244 + - 70245 + - 70246 + - 70247 + - 70248 + - 70249 + - 70250 + - 70251 + - 70252 + - 70253 + - 70254 + - 70255 + - 70256 + - 70257 + - 70258 + - 70259 + - 70260 + - 70261 + - 70262 + - 70263 + - 70264 + - 70265 + - 70266 + - 70267 + - 70268 + - 70269 + - 70270 + - 70271 + - 70272 + - 70273 + - 70274 + - 70275 + - 70276 + - 70277 + - 70278 + - 70279 + - 70280 + - 70281 + - 70282 + - 70283 + - 70284 + - 70285 + - 70286 + - 70287 + - 70288 + - 70289 + - 70290 + - 70291 + - 70292 + - 70293 + - 70294 + - 70295 + - 70296 + - 70297 + - 70298 + - 70299 + - 70300 + - 70301 + - 70302 + - 70303 + - 70304 + - 70305 + - 70306 + - 70307 + - 70308 + - 70309 + - 70310 + - 70311 + - 70312 + - 70313 + - 70314 + - 70315 + - 70316 + - 70317 + - 70318 + - 70319 + - 70320 + - 70321 + - 70322 + - 70323 + - 70324 + - 70325 + - 70326 + - 70327 + - 70328 + - 70329 + - 70330 + - 70331 + - 70332 + - 70333 + - 70334 + - 70335 + - 70336 + - 70337 + - 70338 + - 70339 + - 70340 + - 70341 + - 70342 + - 70343 + - 70344 + - 70345 + - 70346 + - 70347 + - 70348 + - 70349 + - 70350 + - 70351 + - 70352 + - 70353 + - 70354 + - 70355 + - 70356 + - 70357 + - 70358 + - 70359 + - 70360 + - 70361 + - 70362 + - 70363 + - 70364 + - 70365 + - 70366 + - 70367 + - 70368 + - 70369 + - 70370 + - 70371 + - 70372 + - 70373 + - 70374 + - 70375 + - 70376 + - 70377 + - 70378 + - 70379 + - 70380 + - 70381 + - 70382 + - 70383 + - 70384 + - 70385 + - 70386 + - 70387 + - 70388 + - 70389 + - 70390 + - 70391 + - 70392 + - 70393 + - 70394 + - 70395 + - 70396 + - 70397 + - 70398 + - 70399 + - 70400 + - 70401 + - 70402 + - 70403 + - 70404 + - 70405 + - 70406 + - 70407 + - 70408 + - 70409 + - 70410 + - 70411 + - 70412 + - 70413 + - 70414 + - 70415 + - 70416 + - 70417 + - 70418 + - 70419 + - 70420 + - 70421 + - 70422 + - 70423 + - 70424 + - 70425 + - 70426 + - 70427 + - 70428 + - 70429 + - 70430 + - 70431 + - 70432 + - 70433 + - 70434 + - 70435 + - 70436 + - 70437 + - 70438 + - 70439 + - 70440 + - 70441 + - 70442 + - 70443 + - 70444 + - 70445 + - 70446 + - 70447 + - 70448 + - 70449 + - 70450 + - 70451 + - 70452 + - 70453 + - 70454 + - 70455 + - 70456 + - 70457 + - 70458 + - 70459 + - 70460 + - 70461 + - 70462 + - 70463 + - 70464 + - 70465 + - 70466 + - 70467 + - 70468 + - 70469 + - 70470 + - 70471 + - 70472 + - 70473 + - 70474 + - 70475 + - 70476 + - 70477 + - 70478 + - 70479 + - 70480 + - 70481 + - 70482 + - 70483 + - 70484 + - 70485 + - 70486 + - 70487 + - 70488 + - 70489 + - 70490 + - 70491 + - 70492 + - 70493 + - 70494 + - 70495 + - 70496 + - 70497 + - 70498 + - 70499 + - 70500 + - 70501 + - 70502 + - 70503 + - 70504 + - 70505 + - 70506 + - 70507 + - 70508 + - 70509 + - 70510 + - 70511 + - 70512 + - 70513 + - 70514 + - 70515 + - 70516 + - 70517 + - 70518 + - 70519 + - 70520 + - 70521 + - 70522 + - 70523 + - 70524 + - 70525 + - 70526 + - 70527 + - 70528 + - 70529 + - 70530 + - 70531 + - 70532 + - 70533 + - 70534 + - 70535 + - 70536 + - 70537 + - 70538 + - 70539 + - 70540 + - 70541 + - 70542 + - 70543 + - 70544 + - 70545 + - 70546 + - 70547 + - 70548 + - 70549 + - 70550 + - 70551 + - 70552 + - 70553 + - 70554 + - 70555 + - 70556 + - 70557 + - 70558 + - 70559 + - 70560 + - 70561 + - 70562 + - 70563 + - 70564 + - 70565 + - 70566 + - 70567 + - 70568 + - 70569 + - 70570 + - 70571 + - 70572 + - 70573 + - 70574 + - 70575 + - 70576 + - 70577 + - 70578 + - 70579 + - 70580 + - 70581 + - 70582 + - 70583 + - 70584 + - 70585 + - 70586 + - 70587 + - 70588 + - 70589 + - 70590 + - 70591 + - 70592 + - 70593 + - 70594 + - 70595 + - 70596 + - 70597 + - 70598 + - 70599 + - 70600 + - 70601 + - 70602 + - 70603 + - 70604 + - 70605 + - 70606 + - 70607 + - 70608 + - 70609 + - 70610 + - 70611 + - 70612 + - 70613 + - 70614 + - 70615 + - 70616 + - 70617 + - 70618 + - 70619 + - 70620 + - 70621 + - 70622 + - 70623 + - 70624 + - 70625 + - 70626 + - 70627 + - 70628 + - 70629 + - 70630 + - 70631 + - 70632 + - 70633 + - 70634 + - 70635 + - 70636 + - 70637 + - 70638 + - 70639 + - 70640 + - 70641 + - 70642 + - 70643 + - 70644 + - 70645 + - 70646 + - 70647 + - 70648 + - 70649 + - 70650 + - 70651 + - 70652 + - 70653 + - 70654 + - 70655 + - 70656 + - 70657 + - 70658 + - 70659 + - 70660 + - 70661 + - 70662 + - 70663 + - 70664 + - 70665 + - 70666 + - 70667 + - 70668 + - 70669 + - 70670 + - 70671 + - 70672 + - 70673 + - 70674 + - 70675 + - 70676 + - 70677 + - 70678 + - 70679 + - 70680 + - 70681 + - 70682 + - 70683 + - 70684 + - 70685 + - 70686 + - 70687 + - 70688 + - 70689 + - 70690 + - 70691 + - 70692 + - 70693 + - 70694 + - 70695 + - 70696 + - 70697 + - 70698 + - 70699 + - 70700 + - 70701 + - 70702 + - 70703 + - 70704 + - 70705 + - 70706 + - 70707 + - 70708 + - 70709 + - 70710 + - 70711 + - 70712 + - 70713 + - 70714 + - 70715 + - 70716 + - 70717 + - 70718 + - 70719 + - 70720 + - 70721 + - 70722 + - 70723 + - 70724 + - 70725 + - 70726 + - 70727 + - 70728 + - 70729 + - 70730 + - 70731 + - 70732 + - 70733 + - 70734 + - 70735 + - 70736 + - 70737 + - 70738 + - 70739 + - 70740 + - 70741 + - 70742 + - 70743 + - 70744 + - 70745 + - 70746 + - 70747 + - 70748 + - 70749 + - 70750 + - 70751 + - 70752 + - 70753 + - 70754 + - 70755 + - 70756 + - 70757 + - 70758 + - 70759 + - 70760 + - 70761 + - 70762 + - 70763 + - 70764 + - 70765 + - 70766 + - 70767 + - 70768 + - 70769 + - 70770 + - 70771 + - 70772 + - 70773 + - 70774 + - 70775 + - 70776 + - 70777 + - 70778 + - 70779 + - 70780 + - 70781 + - 70782 + - 70783 + - 70784 + - 70785 + - 70786 + - 70787 + - 70788 + - 70789 + - 70790 + - 70791 + - 70792 + - 70793 + - 70794 + - 70795 + - 70796 + - 70797 + - 70798 + - 70799 + - 70800 + - 70801 + - 70802 + - 70803 + - 70804 + - 70805 + - 70806 + - 70807 + - 70808 + - 70809 + - 70810 + - 70811 + - 70812 + - 70813 + - 70814 + - 70815 + - 70816 + - 70817 + - 70818 + - 70819 + - 70820 + - 70821 + - 70822 + - 70823 + - 70824 + - 70825 + - 70826 + - 70827 + - 70828 + - 70829 + - 70830 + - 70831 + - 70832 + - 70833 + - 70834 + - 70835 + - 70836 + - 70837 + - 70838 + - 70839 + - 70840 + - 70841 + - 70842 + - 70843 + - 70844 + - 70845 + - 70846 + - 70847 + - 70848 + - 70849 + - 70850 + - 70851 + - 70852 + - 70853 + - 70854 + - 70855 + - 70856 + - 70857 + - 70858 + - 70859 + - 70860 + - 70861 + - 70862 + - 70863 + - 70864 + - 70865 + - 70866 + - 70867 + - 70868 + - 70869 + - 70870 + - 70871 + - 70872 + - 70873 + - 70874 + - 70875 + - 70876 + - 70877 + - 70878 + - 70879 + - 70880 + - 70881 + - 70882 + - 70883 + - 70884 + - 70885 + - 70886 + - 70887 + - 70888 + - 70889 + - 70890 + - 70891 + - 70892 + - 70893 + - 70894 + - 70895 + - 70896 + - 70897 + - 70898 + - 70899 + - 70900 + - 70901 + - 70902 + - 70903 + - 70904 + - 70905 + - 70906 + - 70907 + - 70908 + - 70909 + - 70910 + - 70911 + - 70912 + - 70913 + - 70914 + - 70915 + - 70916 + - 70917 + - 70918 + - 70919 + - 70920 + - 70921 + - 70922 + - 70923 + - 70924 + - 70925 + - 70926 + - 70927 + - 70928 + - 70929 + - 70930 + - 70931 + - 70932 + - 70933 + - 70934 + - 70935 + - 70936 + - 70937 + - 70938 + - 70939 + - 70940 + - 70941 + - 70942 + - 70943 + - 70944 + - 70945 + - 70946 + - 70947 + - 70948 + - 70949 + - 70950 + - 70951 + - 70952 + - 70953 + - 70954 + - 70955 + - 70956 + - 70957 + - 70958 + - 70959 + - 70960 + - 70961 + - 70962 + - 70963 + - 70964 + - 70965 + - 70966 + - 70967 + - 70968 + - 70969 + - 70970 + - 70971 + - 70972 + - 70973 + - 70974 + - 70975 + - 70976 + - 70977 + - 70978 + - 70979 + - 70980 + - 70981 + - 70982 + - 70983 + - 70984 + - 70985 + - 70986 + - 70987 + - 70988 + - 70989 + - 70990 + - 70991 + - 70992 + - 70993 + - 70994 + - 70995 + - 70996 + - 70997 + - 70998 + - 70999 + - 71000 + - 71001 + - 71002 + - 71003 + - 71004 + - 71005 + - 71006 + - 71007 + - 71008 + - 71009 + - 71010 + - 71011 + - 71012 + - 71013 + - 71014 + - 71015 + - 71016 + - 71017 + - 71018 + - 71019 + - 71020 + - 71021 + - 71022 + - 71023 + - 71024 + - 71025 + - 71026 + - 71027 + - 71028 + - 71029 + - 71030 + - 71031 + - 71032 + - 71033 + - 71034 + - 71035 + - 71036 + - 71037 + - 71038 + - 71039 + - 71040 + - 71041 + - 71042 + - 71043 + - 71044 + - 71045 + - 71046 + - 71047 + - 71048 + - 71049 + - 71050 + - 71051 + - 71052 + - 71053 + - 71054 + - 71055 + - 71056 + - 71057 + - 71058 + - 71059 + - 71060 + - 71061 + - 71062 + - 71063 + - 71064 + - 71065 + - 71066 + - 71067 + - 71068 + - 71069 + - 71070 + - 71071 + - 71072 + - 71073 + - 71074 + - 71075 + - 71076 + - 71077 + - 71078 + - 71079 + - 71080 + - 71081 + - 71082 + - 71083 + - 71084 + - 71085 + - 71086 + - 71087 + - 71088 + - 71089 + - 71090 + - 71091 + - 71092 + - 71093 + - 71094 + - 71095 + - 71096 + - 71097 + - 71098 + - 71099 + - 71100 + - 71101 + - 71102 + - 71103 + - 71104 + - 71105 + - 71106 + - 71107 + - 71108 + - 71109 + - 71110 + - 71111 + - 71112 + - 71113 + - 71114 + - 71115 + - 71116 + - 71117 + - 71118 + - 71119 + - 71120 + - 71121 + - 71122 + - 71123 + - 71124 + - 71125 + - 71126 + - 71127 + - 71128 + - 71129 + - 71130 + - 71131 + - 71132 + - 71133 + - 71134 + - 71135 + - 71136 + - 71137 + - 71138 + - 71139 + - 71140 + - 71141 + - 71142 + - 71143 + - 71144 + - 71145 + - 71146 + - 71147 + - 71148 + - 71149 + - 71150 + - 71151 + - 71152 + - 71153 + - 71154 + - 71155 + - 71156 + - 71157 + - 71158 + - 71159 + - 71160 + - 71161 + - 71162 + - 71163 + - 71164 + - 71165 + - 71166 + - 71167 + - 71168 + - 71169 + - 71170 + - 71171 + - 71172 + - 71173 + - 71174 + - 71175 + - 71176 + - 71177 + - 71178 + - 71179 + - 71180 + - 71181 + - 71182 + - 71183 + - 71184 + - 71185 + - 71186 + - 71187 + - 71188 + - 71189 + - 71190 + - 71191 + - 71192 + - 71193 + - 71194 + - 71195 + - 71196 + - 71197 + - 71198 + - 71199 + - 71200 + - 71201 + - 71202 + - 71203 + - 71204 + - 71205 + - 71206 + - 71207 + - 71208 + - 71209 + - 71210 + - 71211 + - 71212 + - 71213 + - 71214 + - 71215 + - 71216 + - 71217 + - 71218 + - 71219 + - 71220 + - 71221 + - 71222 + - 71223 + - 71224 + - 71225 + - 71226 + - 71227 + - 71228 + - 71229 + - 71230 + - 71231 + - 71232 + - 71233 + - 71234 + - 71235 + - 71236 + - 71237 + - 71238 + - 71239 + - 71240 + - 71241 + - 71242 + - 71243 + - 71244 + - 71245 + - 71246 + - 71247 + - 71248 + - 71249 + - 71250 + - 71251 + - 71252 + - 71253 + - 71254 + - 71255 + - 71256 + - 71257 + - 71258 + - 71259 + - 71260 + - 71261 + - 71262 + - 71263 + - 71264 + - 71265 + - 71266 + - 71267 + - 71268 + - 71269 + - 71270 + - 71271 + - 71272 + - 71273 + - 71274 + - 71275 + - 71276 + - 71277 + - 71278 + - 71279 + - 71280 + - 71281 + - 71282 + - 71283 + - 71284 + - 71285 + - 71286 + - 71287 + - 71288 + - 71289 + - 71290 + - 71291 + - 71292 + - 71293 + - 71294 + - 71295 + - 71296 + - 71297 + - 71298 + - 71299 + - 71300 + - 71301 + - 71302 + - 71303 + - 71304 + - 71305 + - 71306 + - 71307 + - 71308 + - 71309 + - 71310 + - 71311 + - 71312 + - 71313 + - 71314 + - 71315 + - 71316 + - 71317 + - 71318 + - 71319 + - 71320 + - 71321 + - 71322 + - 71323 + - 71324 + - 71325 + - 71326 + - 71327 + - 71328 + - 71329 + - 71330 + - 71331 + - 71332 + - 71333 + - 71334 + - 71335 + - 71336 + - 71337 + - 71338 + - 71339 + - 71340 + - 71341 + - 71342 + - 71343 + - 71344 + - 71345 + - 71346 + - 71347 + - 71348 + - 71349 + - 71350 + - 71351 + - 71352 + - 71353 + - 71354 + - 71355 + - 71356 + - 71357 + - 71358 + - 71359 + - 71360 + - 71361 + - 71362 + - 71363 + - 71364 + - 71365 + - 71366 + - 71367 + - 71368 + - 71369 + - 71370 + - 71371 + - 71372 + - 71373 + - 71374 + - 71375 + - 71376 + - 71377 + - 71378 + - 71379 + - 71380 + - 71381 + - 71382 + - 71383 + - 71384 + - 71385 + - 71386 + - 71387 + - 71388 + - 71389 + - 71390 + - 71391 + - 71392 + - 71393 + - 71394 + - 71395 + - 71396 + - 71397 + - 71398 + - 71399 + - 71400 + - 71401 + - 71402 + - 71403 + - 71404 + - 71405 + - 71406 + - 71407 + - 71408 + - 71409 + - 71410 + - 71411 + - 71412 + - 71413 + - 71414 + - 71415 + - 71416 + - 71417 + - 71418 + - 71419 + - 71420 + - 71421 + - 71422 + - 71423 + - 71424 + - 71425 + - 71426 + - 71427 + - 71428 + - 71429 + - 71430 + - 71431 + - 71432 + - 71433 + - 71434 + - 71435 + - 71436 + - 71437 + - 71438 + - 71439 + - 71440 + - 71441 + - 71442 + - 71443 + - 71444 + - 71445 + - 71446 + - 71447 + - 71448 + - 71449 + - 71450 + - 71451 + - 71452 + - 71453 + - 71454 + - 71455 + - 71456 + - 71457 + - 71458 + - 71459 + - 71460 + - 71461 + - 71462 + - 71463 + - 71464 + - 71465 + - 71466 + - 71467 + - 71468 + - 71469 + - 71470 + - 71471 + - 71472 + - 71473 + - 71474 + - 71475 + - 71476 + - 71477 + - 71478 + - 71479 + - 71480 + - 71481 + - 71482 + - 71483 + - 71484 + - 71485 + - 71486 + - 71487 + - 71488 + - 71489 + - 71490 + - 71491 + - 71492 + - 71493 + - 71494 + - 71495 + - 71496 + - 71497 + - 71498 + - 71499 + - 71500 + - 71501 + - 71502 + - 71503 + - 71504 + - 71505 + - 71506 + - 71507 + - 71508 + - 71509 + - 71510 + - 71511 + - 71512 + - 71513 + - 71514 + - 71515 + - 71516 + - 71517 + - 71518 + - 71519 + - 71520 + - 71521 + - 71522 + - 71523 + - 71524 + - 71525 + - 71526 + - 71527 + - 71528 + - 71529 + - 71530 + - 71531 + - 71532 + - 71533 + - 71534 + - 71535 + - 71536 + - 71537 + - 71538 + - 71539 + - 71540 + - 71541 + - 71542 + - 71543 + - 71544 + - 71545 + - 71546 + - 71547 + - 71548 + - 71549 + - 71550 + - 71551 + - 71552 + - 71553 + - 71554 + - 71555 + - 71556 + - 71557 + - 71558 + - 71559 + - 71560 + - 71561 + - 71562 + - 71563 + - 71564 + - 71565 + - 71566 + - 71567 + - 71568 + - 71569 + - 71570 + - 71571 + - 71572 + - 71573 + - 71574 + - 71575 + - 71576 + - 71577 + - 71578 + - 71579 + - 71580 + - 71581 + - 71582 + - 71583 + - 71584 + - 71585 + - 71586 + - 71587 + - 71588 + - 71589 + - 71590 + - 71591 + - 71592 + - 71593 + - 71594 + - 71595 + - 71596 + - 71597 + - 71598 + - 71599 + - 71600 + - 71601 + - 71602 + - 71603 + - 71604 + - 71605 + - 71606 + - 71607 + - 71608 + - 71609 + - 71610 + - 71611 + - 71612 + - 71613 + - 71614 + - 71615 + - 71616 + - 71617 + - 71618 + - 71619 + - 71620 + - 71621 + - 71622 + - 71623 + - 71624 + - 71625 + - 71626 + - 71627 + - 71628 + - 71629 + - 71630 + - 71631 + - 71632 + - 71633 + - 71634 + - 71635 + - 71636 + - 71637 + - 71638 + - 71639 + - 71640 + - 71641 + - 71642 + - 71643 + - 71644 + - 71645 + - 71646 + - 71647 + - 71648 + - 71649 + - 71650 + - 71651 + - 71652 + - 71653 + - 71654 + - 71655 + - 71656 + - 71657 + - 71658 + - 71659 + - 71660 + - 71661 + - 71662 + - 71663 + - 71664 + - 71665 + - 71666 + - 71667 + - 71668 + - 71669 + - 71670 + - 71671 + - 71672 + - 71673 + - 71674 + - 71675 + - 71676 + - 71677 + - 71678 + - 71679 + - 71680 + - 71681 + - 71682 + - 71683 + - 71684 + - 71685 + - 71686 + - 71687 + - 71688 + - 71689 + - 71690 + - 71691 + - 71692 + - 71693 + - 71694 + - 71695 + - 71696 + - 71697 + - 71698 + - 71699 + - 71700 + - 71701 + - 71702 + - 71703 + - 71704 + - 71705 + - 71706 + - 71707 + - 71708 + - 71709 + - 71710 + - 71711 + - 71712 + - 71713 + - 71714 + - 71715 + - 71716 + - 71717 + - 71718 + - 71719 + - 71720 + - 71721 + - 71722 + - 71723 + - 71724 + - 71725 + - 71726 + - 71727 + - 71728 + - 71729 + - 71730 + - 71731 + - 71732 + - 71733 + - 71734 + - 71735 + - 71736 + - 71737 + - 71738 + - 71739 + - 71740 + - 71741 + - 71742 + - 71743 + - 71744 + - 71745 + - 71746 + - 71747 + - 71748 + - 71749 + - 71750 + - 71751 + - 71752 + - 71753 + - 71754 + - 71755 + - 71756 + - 71757 + - 71758 + - 71759 + - 71760 + - 71761 + - 71762 + - 71763 + - 71764 + - 71765 + - 71766 + - 71767 + - 71768 + - 71769 + - 71770 + - 71771 + - 71772 + - 71773 + - 71774 + - 71775 + - 71776 + - 71777 + - 71778 + - 71779 + - 71780 + - 71781 + - 71782 + - 71783 + - 71784 + - 71785 + - 71786 + - 71787 + - 71788 + - 71789 + - 71790 + - 71791 + - 71792 + - 71793 + - 71794 + - 71795 + - 71796 + - 71797 + - 71798 + - 71799 + - 71800 + - 71801 + - 71802 + - 71803 + - 71804 + - 71805 + - 71806 + - 71807 + - 71808 + - 71809 + - 71810 + - 71811 + - 71812 + - 71813 + - 71814 + - 71815 + - 71816 + - 71817 + - 71818 + - 71819 + - 71820 + - 71821 + - 71822 + - 71823 + - 71824 + - 71825 + - 71826 + - 71827 + - 71828 + - 71829 + - 71830 + - 71831 + - 71832 + - 71833 + - 71834 + - 71835 + - 71836 + - 71837 + - 71838 + - 71839 + - 71840 + - 71841 + - 71842 + - 71843 + - 71844 + - 71845 + - 71846 + - 71847 + - 71848 + - 71849 + - 71850 + - 71851 + - 71852 + - 71853 + - 71854 + - 71855 + - 71856 + - 71857 + - 71858 + - 71859 + - 71860 + - 71861 + - 71862 + - 71863 + - 71864 + - 71865 + - 71866 + - 71867 + - 71868 + - 71869 + - 71870 + - 71871 + - 71872 + - 71873 + - 71874 + - 71875 + - 71876 + - 71877 + - 71878 + - 71879 + - 71880 + - 71881 + - 71882 + - 71883 + - 71884 + - 71885 + - 71886 + - 71887 + - 71888 + - 71889 + - 71890 + - 71891 + - 71892 + - 71893 + - 71894 + - 71895 + - 71896 + - 71897 + - 71898 + - 71899 + - 71900 + - 71901 + - 71902 + - 71903 + - 71904 + - 71905 + - 71906 + - 71907 + - 71908 + - 71909 + - 71910 + - 71911 + - 71912 + - 71913 + - 71914 + - 71915 + - 71916 + - 71917 + - 71918 + - 71919 + - 71920 + - 71921 + - 71922 + - 71923 + - 71924 + - 71925 + - 71926 + - 71927 + - 71928 + - 71929 + - 71930 + - 71931 + - 71932 + - 71933 + - 71934 + - 71935 + - 71936 + - 71937 + - 71938 + - 71939 + - 71940 + - 71941 + - 71942 + - 71943 + - 71944 + - 71945 + - 71946 + - 71947 + - 71948 + - 71949 + - 71950 + - 71951 + - 71952 + - 71953 + - 71954 + - 71955 + - 71956 + - 71957 + - 71958 + - 71959 + - 71960 + - 71961 + - 71962 + - 71963 + - 71964 + - 71965 + - 71966 + - 71967 + - 71968 + - 71969 + - 71970 + - 71971 + - 71972 + - 71973 + - 71974 + - 71975 + - 71976 + - 71977 + - 71978 + - 71979 + - 71980 + - 71981 + - 71982 + - 71983 + - 71984 + - 71985 + - 71986 + - 71987 + - 71988 + - 71989 + - 71990 + - 71991 + - 71992 + - 71993 + - 71994 + - 71995 + - 71996 + - 71997 + - 71998 + - 71999 + - 72000 + - 72001 + - 72002 + - 72003 + - 72004 + - 72005 + - 72006 + - 72007 + - 72008 + - 72009 + - 72010 + - 72011 + - 72012 + - 72013 + - 72014 + - 72015 + - 72016 + - 72017 + - 72018 + - 72019 + - 72020 + - 72021 + - 72022 + - 72023 + - 72024 + - 72025 + - 72026 + - 72027 + - 72028 + - 72029 + - 72030 + - 72031 + - 72032 + - 72033 + - 72034 + - 72035 + - 72036 + - 72037 + - 72038 + - 72039 + - 72040 + - 72041 + - 72042 + - 72043 + - 72044 + - 72045 + - 72046 + - 72047 + - 72048 + - 72049 + - 72050 + - 72051 + - 72052 + - 72053 + - 72054 + - 72055 + - 72056 + - 72057 + - 72058 + - 72059 + - 72060 + - 72061 + - 72062 + - 72063 + - 72064 + - 72065 + - 72066 + - 72067 + - 72068 + - 72069 + - 72070 + - 72071 + - 72072 + - 72073 + - 72074 + - 72075 + - 72076 + - 72077 + - 72078 + - 72079 + - 72080 + - 72081 + - 72082 + - 72083 + - 72084 + - 72085 + - 72086 + - 72087 + - 72088 + - 72089 + - 72090 + - 72091 + - 72092 + - 72093 + - 72094 + - 72095 + - 72096 + - 72097 + - 72098 + - 72099 + - 72100 + - 72101 + - 72102 + - 72103 + - 72104 + - 72105 + - 72106 + - 72107 + - 72108 + - 72109 + - 72110 + - 72111 + - 72112 + - 72113 + - 72114 + - 72115 + - 72116 + - 72117 + - 72118 + - 72119 + - 72120 + - 72121 + - 72122 + - 72123 + - 72124 + - 72125 + - 72126 + - 72127 + - 72128 + - 72129 + - 72130 + - 72131 + - 72132 + - 72133 + - 72134 + - 72135 + - 72136 + - 72137 + - 72138 + - 72139 + - 72140 + - 72141 + - 72142 + - 72143 + - 72144 + - 72145 + - 72146 + - 72147 + - 72148 + - 72149 + - 72150 + - 72151 + - 72152 + - 72153 + - 72154 + - 72155 + - 72156 + - 72157 + - 72158 + - 72159 + - 72160 + - 72161 + - 72162 + - 72163 + - 72164 + - 72165 + - 72166 + - 72167 + - 72168 + - 72169 + - 72170 + - 72171 + - 72172 + - 72173 + - 72174 + - 72175 + - 72176 + - 72177 + - 72178 + - 72179 + - 72180 + - 72181 + - 72182 + - 72183 + - 72184 + - 72185 + - 72186 + - 72187 + - 72188 + - 72189 + - 72190 + - 72191 + - 72192 + - 72193 + - 72194 + - 72195 + - 72196 + - 72197 + - 72198 + - 72199 + - 72200 + - 72201 + - 72202 + - 72203 + - 72204 + - 72205 + - 72206 + - 72207 + - 72208 + - 72209 + - 72210 + - 72211 + - 72212 + - 72213 + - 72214 + - 72215 + - 72216 + - 72217 + - 72218 + - 72219 + - 72220 + - 72221 + - 72222 + - 72223 + - 72224 + - 72225 + - 72226 + - 72227 + - 72228 + - 72229 + - 72230 + - 72231 + - 72232 + - 72233 + - 72234 + - 72235 + - 72236 + - 72237 + - 72238 + - 72239 + - 72240 + - 72241 + - 72242 + - 72243 + - 72244 + - 72245 + - 72246 + - 72247 + - 72248 + - 72249 + - 72250 + - 72251 + - 72252 + - 72253 + - 72254 + - 72255 + - 72256 + - 72257 + - 72258 + - 72259 + - 72260 + - 72261 + - 72262 + - 72263 + - 72264 + - 72265 + - 72266 + - 72267 + - 72268 + - 72269 + - 72270 + - 72271 + - 72272 + - 72273 + - 72274 + - 72275 + - 72276 + - 72277 + - 72278 + - 72279 + - 72280 + - 72281 + - 72282 + - 72283 + - 72284 + - 72285 + - 72286 + - 72287 + - 72288 + - 72289 + - 72290 + - 72291 + - 72292 + - 72293 + - 72294 + - 72295 + - 72296 + - 72297 + - 72298 + - 72299 + - 72300 + - 72301 + - 72302 + - 72303 + - 72304 + - 72305 + - 72306 + - 72307 + - 72308 + - 72309 + - 72310 + - 72311 + - 72312 + - 72313 + - 72314 + - 72315 + - 72316 + - 72317 + - 72318 + - 72319 + - 72320 + - 72321 + - 72322 + - 72323 + - 72324 + - 72325 + - 72326 + - 72327 + - 72328 + - 72329 + - 72330 + - 72331 + - 72332 + - 72333 + - 72334 + - 72335 + - 72336 + - 72337 + - 72338 + - 72339 + - 72340 + - 72341 + - 72342 + - 72343 + - 72344 + - 72345 + - 72346 + - 72347 + - 72348 + - 72349 + - 72350 + - 72351 + - 72352 + - 72353 + - 72354 + - 72355 + - 72356 + - 72357 + - 72358 + - 72359 + - 72360 + - 72361 + - 72362 + - 72363 + - 72364 + - 72365 + - 72366 + - 72367 + - 72368 + - 72369 + - 72370 + - 72371 + - 72372 + - 72373 + - 72374 + - 72375 + - 72376 + - 72377 + - 72378 + - 72379 + - 72380 + - 72381 + - 72382 + - 72383 + - 72384 + - 72385 + - 72386 + - 72387 + - 72388 + - 72389 + - 72390 + - 72391 + - 72392 + - 72393 + - 72394 + - 72395 + - 72396 + - 72397 + - 72398 + - 72399 + - 72400 + - 72401 + - 72402 + - 72403 + - 72404 + - 72405 + - 72406 + - 72407 + - 72408 + - 72409 + - 72410 + - 72411 + - 72412 + - 72413 + - 72414 + - 72415 + - 72416 + - 72417 + - 72418 + - 72419 + - 72420 + - 72421 + - 72422 + - 72423 + - 72424 + - 72425 + - 72426 + - 72427 + - 72428 + - 72429 + - 72430 + - 72431 + - 72432 + - 72433 + - 72434 + - 72435 + - 72436 + - 72437 + - 72438 + - 72439 + - 72440 + - 72441 + - 72442 + - 72443 + - 72444 + - 72445 + - 72446 + - 72447 + - 72448 + - 72449 + - 72450 + - 72451 + - 72452 + - 72453 + - 72454 + - 72455 + - 72456 + - 72457 + - 72458 + - 72459 + - 72460 + - 72461 + - 72462 + - 72463 + - 72464 + - 72465 + - 72466 + - 72467 + - 72468 + - 72469 + - 72470 + - 72471 + - 72472 + - 72473 + - 72474 + - 72475 + - 72476 + - 72477 + - 72478 + - 72479 + - 72480 + - 72481 + - 72482 + - 72483 + - 72484 + - 72485 + - 72486 + - 72487 + - 72488 + - 72489 + - 72490 + - 72491 + - 72492 + - 72493 + - 72494 + - 72495 + - 72496 + - 72497 + - 72498 + - 72499 + - 72500 + - 72501 + - 72502 + - 72503 + - 72504 + - 72505 + - 72506 + - 72507 + - 72508 + - 72509 + - 72510 + - 72511 + - 72512 + - 72513 + - 72514 + - 72515 + - 72516 + - 72517 + - 72518 + - 72519 + - 72520 + - 72521 + - 72522 + - 72523 + - 72524 + - 72525 + - 72526 + - 72527 + - 72528 + - 72529 + - 72530 + - 72531 + - 72532 + - 72533 + - 72534 + - 72535 + - 72536 + - 72537 + - 72538 + - 72539 + - 72540 + - 72541 + - 72542 + - 72543 + - 72544 + - 72545 + - 72546 + - 72547 + - 72548 + - 72549 + - 72550 + - 72551 + - 72552 + - 72553 + - 72554 + - 72555 + - 72556 + - 72557 + - 72558 + - 72559 + - 72560 + - 72561 + - 72562 + - 72563 + - 72564 + - 72565 + - 72566 + - 72567 + - 72568 + - 72569 + - 72570 + - 72571 + - 72572 + - 72573 + - 72574 + - 72575 + - 72576 + - 72577 + - 72578 + - 72579 + - 72580 + - 72581 + - 72582 + - 72583 + - 72584 + - 72585 + - 72586 + - 72587 + - 72588 + - 72589 + - 72590 + - 72591 + - 72592 + - 72593 + - 72594 + - 72595 + - 72596 + - 72597 + - 72598 + - 72599 + - 72600 + - 72601 + - 72602 + - 72603 + - 72604 + - 72605 + - 72606 + - 72607 + - 72608 + - 72609 + - 72610 + - 72611 + - 72612 + - 72613 + - 72614 + - 72615 + - 72616 + - 72617 + - 72618 + - 72619 + - 72620 + - 72621 + - 72622 + - 72623 + - 72624 + - 72625 + - 72626 + - 72627 + - 72628 + - 72629 + - 72630 + - 72631 + - 72632 + - 72633 + - 72634 + - 72635 + - 72636 + - 72637 + - 72638 + - 72639 + - 72640 + - 72641 + - 72642 + - 72643 + - 72644 + - 72645 + - 72646 + - 72647 + - 72648 + - 72649 + - 72650 + - 72651 + - 72652 + - 72653 + - 72654 + - 72655 + - 72656 + - 72657 + - 72658 + - 72659 + - 72660 + - 72661 + - 72662 + - 72663 + - 72664 + - 72665 + - 72666 + - 72667 + - 72668 + - 72669 + - 72670 + - 72671 + - 72672 + - 72673 + - 72674 + - 72675 + - 72676 + - 72677 + - 72678 + - 72679 + - 72680 + - 72681 + - 72682 + - 72683 + - 72684 + - 72685 + - 72686 + - 72687 + - 72688 + - 72689 + - 72690 + - 72691 + - 72692 + - 72693 + - 72694 + - 72695 + - 72696 + - 72697 + - 72698 + - 72699 + - 72700 + - 72701 + - 72702 + - 72703 + - 72704 + - 72705 + - 72706 + - 72707 + - 72708 + - 72709 + - 72710 + - 72711 + - 72712 + - 72713 + - 72714 + - 72715 + - 72716 + - 72717 + - 72718 + - 72719 + - 72720 + - 72721 + - 72722 + - 72723 + - 72724 + - 72725 + - 72726 + - 72727 + - 72728 + - 72729 + - 72730 + - 72731 + - 72732 + - 72733 + - 72734 + - 72735 + - 72736 + - 72737 + - 72738 + - 72739 + - 72740 + - 72741 + - 72742 + - 72743 + - 72744 + - 72745 + - 72746 + - 72747 + - 72748 + - 72749 + - 72750 + - 72751 + - 72752 + - 72753 + - 72754 + - 72755 + - 72756 + - 72757 + - 72758 + - 72759 + - 72760 + - 72761 + - 72762 + - 72763 + - 72764 + - 72765 + - 72766 + - 72767 + - 72768 + - 72769 + - 72770 + - 72771 + - 72772 + - 72773 + - 72774 + - 72775 + - 72776 + - 72777 + - 72778 + - 72779 + - 72780 + - 72781 + - 72782 + - 72783 + - 72784 + - 72785 + - 72786 + - 72787 + - 72788 + - 72789 + - 72790 + - 72791 + - 72792 + - 72793 + - 72794 + - 72795 + - 72796 + - 72797 + - 72798 + - 72799 + - 72800 + - 72801 + - 72802 + - 72803 + - 72804 + - 72805 + - 72806 + - 72807 + - 72808 + - 72809 + - 72810 + - 72811 + - 72812 + - 72813 + - 72814 + - 72815 + - 72816 + - 72817 + - 72818 + - 72819 + - 72820 + - 72821 + - 72822 + - 72823 + - 72824 + - 72825 + - 72826 + - 72827 + - 72828 + - 72829 + - 72830 + - 72831 + - 72832 + - 72833 + - 72834 + - 72835 + - 72836 + - 72837 + - 72838 + - 72839 + - 72840 + - 72841 + - 72842 + - 72843 + - 72844 + - 72845 + - 72846 + - 72847 + - 72848 + - 72849 + - 72850 + - 72851 + - 72852 + - 72853 + - 72854 + - 72855 + - 72856 + - 72857 + - 72858 + - 72859 + - 72860 + - 72861 + - 72862 + - 72863 + - 72864 + - 72865 + - 72866 + - 72867 + - 72868 + - 72869 + - 72870 + - 72871 + - 72872 + - 72873 + - 72874 + - 72875 + - 72876 + - 72877 + - 72878 + - 72879 + - 72880 + - 72881 + - 72882 + - 72883 + - 72884 + - 72885 + - 72886 + - 72887 + - 72888 + - 72889 + - 72890 + - 72891 + - 72892 + - 72893 + - 72894 + - 72895 + - 72896 + - 72897 + - 72898 + - 72899 + - 72900 + - 72901 + - 72902 + - 72903 + - 72904 + - 72905 + - 72906 + - 72907 + - 72908 + - 72909 + - 72910 + - 72911 + - 72912 + - 72913 + - 72914 + - 72915 + - 72916 + - 72917 + - 72918 + - 72919 + - 72920 + - 72921 + - 72922 + - 72923 + - 72924 + - 72925 + - 72926 + - 72927 + - 72928 + - 72929 + - 72930 + - 72931 + - 72932 + - 72933 + - 72934 + - 72935 + - 72936 + - 72937 + - 72938 + - 72939 + - 72940 + - 72941 + - 72942 + - 72943 + - 72944 + - 72945 + - 72946 + - 72947 + - 72948 + - 72949 + - 72950 + - 72951 + - 72952 + - 72953 + - 72954 + - 72955 + - 72956 + - 72957 + - 72958 + - 72959 + - 72960 + - 72961 + - 72962 + - 72963 + - 72964 + - 72965 + - 72966 + - 72967 + - 72968 + - 72969 + - 72970 + - 72971 + - 72972 + - 72973 + - 72974 + - 72975 + - 72976 + - 72977 + - 72978 + - 72979 + - 72980 + - 72981 + - 72982 + - 72983 + - 72984 + - 72985 + - 72986 + - 72987 + - 72988 + - 72989 + - 72990 + - 72991 + - 72992 + - 72993 + - 72994 + - 72995 + - 72996 + - 72997 + - 72998 + - 72999 + - 73000 + - 73001 + - 73002 + - 73003 + - 73004 + - 73005 + - 73006 + - 73007 + - 73008 + - 73009 + - 73010 + - 73011 + - 73012 + - 73013 + - 73014 + - 73015 + - 73016 + - 73017 + - 73018 + - 73019 + - 73020 + - 73021 + - 73022 + - 73023 + - 73024 + - 73025 + - 73026 + - 73027 + - 73028 + - 73029 + - 73030 + - 73031 + - 73032 + - 73033 + - 73034 + - 73035 + - 73036 + - 73037 + - 73038 + - 73039 + - 73040 + - 73041 + - 73042 + - 73043 + - 73044 + - 73045 + - 73046 + - 73047 + - 73048 + - 73049 + - 73050 + - 73051 + - 73052 + - 73053 + - 73054 + - 73055 + - 73056 + - 73057 + - 73058 + - 73059 + - 73060 + - 73061 + - 73062 + - 73063 + - 73064 + - 73065 + - 73066 + - 73067 + - 73068 + - 73069 + - 73070 + - 73071 + - 73072 + - 73073 + - 73074 + - 73075 + - 73076 + - 73077 + - 73078 + - 73079 + - 73080 + - 73081 + - 73082 + - 73083 + - 73084 + - 73085 + - 73086 + - 73087 + - 73088 + - 73089 + - 73090 + - 73091 + - 73092 + - 73093 + - 73094 + - 73095 + - 73096 + - 73097 + - 73098 + - 73099 + - 73100 + - 73101 + - 73102 + - 73103 + - 73104 + - 73105 + - 73106 + - 73107 + - 73108 + - 73109 + - 73110 + - 73111 + - 73112 + - 73113 + - 73114 + - 73115 + - 73116 + - 73117 + - 73118 + - 73119 + - 73120 + - 73121 + - 73122 + - 73123 + - 73124 + - 73125 + - 73126 + - 73127 + - 73128 + - 73129 + - 73130 + - 73131 + - 73132 + - 73133 + - 73134 + - 73135 + - 73136 + - 73137 + - 73138 + - 73139 + - 73140 + - 73141 + - 73142 + - 73143 + - 73144 + - 73145 + - 73146 + - 73147 + - 73148 + - 73149 + - 73150 + - 73151 + - 73152 + - 73153 + - 73154 + - 73155 + - 73156 + - 73157 + - 73158 + - 73159 + - 73160 + - 73161 + - 73162 + - 73163 + - 73164 + - 73165 + - 73166 + - 73167 + - 73168 + - 73169 + - 73170 + - 73171 + - 73172 + - 73173 + - 73174 + - 73175 + - 73176 + - 73177 + - 73178 + - 73179 + - 73180 + - 73181 + - 73182 + - 73183 + - 73184 + - 73185 + - 73186 + - 73187 + - 73188 + - 73189 + - 73190 + - 73191 + - 73192 + - 73193 + - 73194 + - 73195 + - 73196 + - 73197 + - 73198 + - 73199 + - 73200 + - 73201 + - 73202 + - 73203 + - 73204 + - 73205 + - 73206 + - 73207 + - 73208 + - 73209 + - 73210 + - 73211 + - 73212 + - 73213 + - 73214 + - 73215 + - 73216 + - 73217 + - 73218 + - 73219 + - 73220 + - 73221 + - 73222 + - 73223 + - 73224 + - 73225 + - 73226 + - 73227 + - 73228 + - 73229 + - 73230 + - 73231 + - 73232 + - 73233 + - 73234 + - 73235 + - 73236 + - 73237 + - 73238 + - 73239 + - 73240 + - 73241 + - 73242 + - 73243 + - 73244 + - 73245 + - 73246 + - 73247 + - 73248 + - 73249 + - 73250 + - 73251 + - 73252 + - 73253 + - 73254 + - 73255 + - 73256 + - 73257 + - 73258 + - 73259 + - 73260 + - 73261 + - 73262 + - 73263 + - 73264 + - 73265 + - 73266 + - 73267 + - 73268 + - 73269 + - 73270 + - 73271 + - 73272 + - 73273 + - 73274 + - 73275 + - 73276 + - 73277 + - 73278 + - 73279 + - 73280 + - 73281 + - 73282 + - 73283 + - 73284 + - 73285 + - 73286 + - 73287 + - 73288 + - 73289 + - 73290 + - 73291 + - 73292 + - 73293 + - 73294 + - 73295 + - 73296 + - 73297 + - 73298 + - 73299 + - 73300 + - 73301 + - 73302 + - 73303 + - 73304 + - 73305 + - 73306 + - 73307 + - 73308 + - 73309 + - 73310 + - 73311 + - 73312 + - 73313 + - 73314 + - 73315 + - 73316 + - 73317 + - 73318 + - 73319 + - 73320 + - 73321 + - 73322 + - 73323 + - 73324 + - 73325 + - 73326 + - 73327 + - 73328 + - 73329 + - 73330 + - 73331 + - 73332 + - 73333 + - 73334 + - 73335 + - 73336 + - 73337 + - 73338 + - 73339 + - 73340 + - 73341 + - 73342 + - 73343 + - 73344 + - 73345 + - 73346 + - 73347 + - 73348 + - 73349 + - 73350 + - 73351 + - 73352 + - 73353 + - 73354 + - 73355 + - 73356 + - 73357 + - 73358 + - 73359 + - 73360 + - 73361 + - 73362 + - 73363 + - 73364 + - 73365 + - 73366 + - 73367 + - 73368 + - 73369 + - 73370 + - 73371 + - 73372 + - 73373 + - 73374 + - 73375 + - 73376 + - 73377 + - 73378 + - 73379 + - 73380 + - 73381 + - 73382 + - 73383 + - 73384 + - 73385 + - 73386 + - 73387 + - 73388 + - 73389 + - 73390 + - 73391 + - 73392 + - 73393 + - 73394 + - 73395 + - 73396 + - 73397 + - 73398 + - 73399 + - 73400 + - 73401 + - 73402 + - 73403 + - 73404 + - 73405 + - 73406 + - 73407 + - 73408 + - 73409 + - 73410 + - 73411 + - 73412 + - 73413 + - 73414 + - 73415 + - 73416 + - 73417 + - 73418 + - 73419 + - 73420 + - 73421 + - 73422 + - 73423 + - 73424 + - 73425 + - 73426 + - 73427 + - 73428 + - 73429 + - 73430 + - 73431 + - 73432 + - 73433 + - 73434 + - 73435 + - 73436 + - 73437 + - 73438 + - 73439 + - 73440 + - 73441 + - 73442 + - 73443 + - 73444 + - 73445 + - 73446 + - 73447 + - 73448 + - 73449 + - 73450 + - 73451 + - 73452 + - 73453 + - 73454 + - 73455 + - 73456 + - 73457 + - 73458 + - 73459 + - 73460 + - 73461 + - 73462 + - 73463 + - 73464 + - 73465 + - 73466 + - 73467 + - 73468 + - 73469 + - 73470 + - 73471 + - 73472 + - 73473 + - 73474 + - 73475 + - 73476 + - 73477 + - 73478 + - 73479 + - 73480 + - 73481 + - 73482 + - 73483 + - 73484 + - 73485 + - 73486 + - 73487 + - 73488 + - 73489 + - 73490 + - 73491 + - 73492 + - 73493 + - 73494 + - 73495 + - 73496 + - 73497 + - 73498 + - 73499 + - 73500 + - 73501 + - 73502 + - 73503 + - 73504 + - 73505 + - 73506 + - 73507 + - 73508 + - 73509 + - 73510 + - 73511 + - 73512 + - 73513 + - 73514 + - 73515 + - 73516 + - 73517 + - 73518 + - 73519 + - 73520 + - 73521 + - 73522 + - 73523 + - 73524 + - 73525 + - 73526 + - 73527 + - 73528 + - 73529 + - 73530 + - 73531 + - 73532 + - 73533 + - 73534 + - 73535 + - 73536 + - 73537 + - 73538 + - 73539 + - 73540 + - 73541 + - 73542 + - 73543 + - 73544 + - 73545 + - 73546 + - 73547 + - 73548 + - 73549 + - 73550 + - 73551 + - 73552 + - 73553 + - 73554 + - 73555 + - 73556 + - 73557 + - 73558 + - 73559 + - 73560 + - 73561 + - 73562 + - 73563 + - 73564 + - 73565 + - 73566 + - 73567 + - 73568 + - 73569 + - 73570 + - 73571 + - 73572 + - 73573 + - 73574 + - 73575 + - 73576 + - 73577 + - 73578 + - 73579 + - 73580 + - 73581 + - 73582 + - 73583 + - 73584 + - 73585 + - 73586 + - 73587 + - 73588 + - 73589 + - 73590 + - 73591 + - 73592 + - 73593 + - 73594 + - 73595 + - 73596 + - 73597 + - 73598 + - 73599 + - 73600 + - 73601 + - 73602 + - 73603 + - 73604 + - 73605 + - 73606 + - 73607 + - 73608 + - 73609 + - 73610 + - 73611 + - 73612 + - 73613 + - 73614 + - 73615 + - 73616 + - 73617 + - 73618 + - 73619 + - 73620 + - 73621 + - 73622 + - 73623 + - 73624 + - 73625 + - 73626 + - 73627 + - 73628 + - 73629 + - 73630 + - 73631 + - 73632 + - 73633 + - 73634 + - 73635 + - 73636 + - 73637 + - 73638 + - 73639 + - 73640 + - 73641 + - 73642 + - 73643 + - 73644 + - 73645 + - 73646 + - 73647 + - 73648 + - 73649 + - 73650 + - 73651 + - 73652 + - 73653 + - 73654 + - 73655 + - 73656 + - 73657 + - 73658 + - 73659 + - 73660 + - 73661 + - 73662 + - 73663 + - 73664 + - 73665 + - 73666 + - 73667 + - 73668 + - 73669 + - 73670 + - 73671 + - 73672 + - 73673 + - 73674 + - 73675 + - 73676 + - 73677 + - 73678 + - 73679 + - 73680 + - 73681 + - 73682 + - 73683 + - 73684 + - 73685 + - 73686 + - 73687 + - 73688 + - 73689 + - 73690 + - 73691 + - 73692 + - 73693 + - 73694 + - 73695 + - 73696 + - 73697 + - 73698 + - 73699 + - 73700 + - 73701 + - 73702 + - 73703 + - 73704 + - 73705 + - 73706 + - 73707 + - 73708 + - 73709 + - 73710 + - 73711 + - 73712 + - 73713 + - 73714 + - 73715 + - 73716 + - 73717 + - 73718 + - 73719 + - 73720 + - 73721 + - 73722 + - 73723 + - 73724 + - 73725 + - 73726 + - 73727 + - 73728 + - 73729 + - 73730 + - 73731 + - 73732 + - 73733 + - 73734 + - 73735 + - 73736 + - 73737 + - 73738 + - 73739 + - 73740 + - 73741 + - 73742 + - 73743 + - 73744 + - 73745 + - 73746 + - 73747 + - 73748 + - 73749 + - 73750 + - 73751 + - 73752 + - 73753 + - 73754 + - 73755 + - 73756 + - 73757 + - 73758 + - 73759 + - 73760 + - 73761 + - 73762 + - 73763 + - 73764 + - 73765 + - 73766 + - 73767 + - 73768 + - 73769 + - 73770 + - 73771 + - 73772 + - 73773 + - 73774 + - 73775 + - 73776 + - 73777 + - 73778 + - 73779 + - 73780 + - 73781 + - 73782 + - 73783 + - 73784 + - 73785 + - 73786 + - 73787 + - 73788 + - 73789 + - 73790 + - 73791 + - 73792 + - 73793 + - 73794 + - 73795 + - 73796 + - 73797 + - 73798 + - 73799 + - 73800 + - 73801 + - 73802 + - 73803 + - 73804 + - 73805 + - 73806 + - 73807 + - 73808 + - 73809 + - 73810 + - 73811 + - 73812 + - 73813 + - 73814 + - 73815 + - 73816 + - 73817 + - 73818 + - 73819 + - 73820 + - 73821 + - 73822 + - 73823 + - 73824 + - 73825 + - 73826 + - 73827 + - 73828 + - 73829 + - 73830 + - 73831 + - 73832 + - 73833 + - 73834 + - 73835 + - 73836 + - 73837 + - 73838 + - 73839 + - 73840 + - 73841 + - 73842 + - 73843 + - 73844 + - 73845 + - 73846 + - 73847 + - 73848 + - 73849 + - 73850 + - 73851 + - 73852 + - 73853 + - 73854 + - 73855 + - 73856 + - 73857 + - 73858 + - 73859 + - 73860 + - 73861 + - 73862 + - 73863 + - 73864 + - 73865 + - 73866 + - 73867 + - 73868 + - 73869 + - 73870 + - 73871 + - 73872 + - 73873 + - 73874 + - 73875 + - 73876 + - 73877 + - 73878 + - 73879 + - 73880 + - 73881 + - 73882 + - 73883 + - 73884 + - 73885 + - 73886 + - 73887 + - 73888 + - 73889 + - 73890 + - 73891 + - 73892 + - 73893 + - 73894 + - 73895 + - 73896 + - 73897 + - 73898 + - 73899 + - 73900 + - 73901 + - 73902 + - 73903 + - 73904 + - 73905 + - 73906 + - 73907 + - 73908 + - 73909 + - 73910 + - 73911 + - 73912 + - 73913 + - 73914 + - 73915 + - 73916 + - 73917 + - 73918 + - 73919 + - 73920 + - 73921 + - 73922 + - 73923 + - 73924 + - 73925 + - 73926 + - 73927 + - 73928 + - 73929 + - 73930 + - 73931 + - 73932 + - 73933 + - 73934 + - 73935 + - 73936 + - 73937 + - 73938 + - 73939 + - 73940 + - 73941 + - 73942 + - 73943 + - 73944 + - 73945 + - 73946 + - 73947 + - 73948 + - 73949 + - 73950 + - 73951 + - 73952 + - 73953 + - 73954 + - 73955 + - 73956 + - 73957 + - 73958 + - 73959 + - 73960 + - 73961 + - 73962 + - 73963 + - 73964 + - 73965 + - 73966 + - 73967 + - 73968 + - 73969 + - 73970 + - 73971 + - 73972 + - 73973 + - 73974 + - 73975 + - 73976 + - 73977 + - 73978 + - 73979 + - 73980 + - 73981 + - 73982 + - 73983 + - 73984 + - 73985 + - 73986 + - 73987 + - 73988 + - 73989 + - 73990 + - 73991 + - 73992 + - 73993 + - 73994 + - 73995 + - 73996 + - 73997 + - 73998 + - 73999 + - 74000 + - 74001 + - 74002 + - 74003 + - 74004 + - 74005 + - 74006 + - 74007 + - 74008 + - 74009 + - 74010 + - 74011 + - 74012 + - 74013 + - 74014 + - 74015 + - 74016 + - 74017 + - 74018 + - 74019 + - 74020 + - 74021 + - 74022 + - 74023 + - 74024 + - 74025 + - 74026 + - 74027 + - 74028 + - 74029 + - 74030 + - 74031 + - 74032 + - 74033 + - 74034 + - 74035 + - 74036 + - 74037 + - 74038 + - 74039 + - 74040 + - 74041 + - 74042 + - 74043 + - 74044 + - 74045 + - 74046 + - 74047 + - 74048 + - 74049 + - 74050 + - 74051 + - 74052 + - 74053 + - 74054 + - 74055 + - 74056 + - 74057 + - 74058 + - 74059 + - 74060 + - 74061 + - 74062 + - 74063 + - 74064 + - 74065 + - 74066 + - 74067 + - 74068 + - 74069 + - 74070 + - 74071 + - 74072 + - 74073 + - 74074 + - 74075 + - 74076 + - 74077 + - 74078 + - 74079 + - 74080 + - 74081 + - 74082 + - 74083 + - 74084 + - 74085 + - 74086 + - 74087 + - 74088 + - 74089 + - 74090 + - 74091 + - 74092 + - 74093 + - 74094 + - 74095 + - 74096 + - 74097 + - 74098 + - 74099 + - 74100 + - 74101 + - 74102 + - 74103 + - 74104 + - 74105 + - 74106 + - 74107 + - 74108 + - 74109 + - 74110 + - 74111 + - 74112 + - 74113 + - 74114 + - 74115 + - 74116 + - 74117 + - 74118 + - 74119 + - 74120 + - 74121 + - 74122 + - 74123 + - 74124 + - 74125 + - 74126 + - 74127 + - 74128 + - 74129 + - 74130 + - 74131 + - 74132 + - 74133 + - 74134 + - 74135 + - 74136 + - 74137 + - 74138 + - 74139 + - 74140 + - 74141 + - 74142 + - 74143 + - 74144 + - 74145 + - 74146 + - 74147 + - 74148 + - 74149 + - 74150 + - 74151 + - 74152 + - 74153 + - 74154 + - 74155 + - 74156 + - 74157 + - 74158 + - 74159 + - 74160 + - 74161 + - 74162 + - 74163 + - 74164 + - 74165 + - 74166 + - 74167 + - 74168 + - 74169 + - 74170 + - 74171 + - 74172 + - 74173 + - 74174 + - 74175 + - 74176 + - 74177 + - 74178 + - 74179 + - 74180 + - 74181 + - 74182 + - 74183 + - 74184 + - 74185 + - 74186 + - 74187 + - 74188 + - 74189 + - 74190 + - 74191 + - 74192 + - 74193 + - 74194 + - 74195 + - 74196 + - 74197 + - 74198 + - 74199 + - 74200 + - 74201 + - 74202 + - 74203 + - 74204 + - 74205 + - 74206 + - 74207 + - 74208 + - 74209 + - 74210 + - 74211 + - 74212 + - 74213 + - 74214 + - 74215 + - 74216 + - 74217 + - 74218 + - 74219 + - 74220 + - 74221 + - 74222 + - 74223 + - 74224 + - 74225 + - 74226 + - 74227 + - 74228 + - 74229 + - 74230 + - 74231 + - 74232 + - 74233 + - 74234 + - 74235 + - 74236 + - 74237 + - 74238 + - 74239 + - 74240 + - 74241 + - 74242 + - 74243 + - 74244 + - 74245 + - 74246 + - 74247 + - 74248 + - 74249 + - 74250 + - 74251 + - 74252 + - 74253 + - 74254 + - 74255 + - 74256 + - 74257 + - 74258 + - 74259 + - 74260 + - 74261 + - 74262 + - 74263 + - 74264 + - 74265 + - 74266 + - 74267 + - 74268 + - 74269 + - 74270 + - 74271 + - 74272 + - 74273 + - 74274 + - 74275 + - 74276 + - 74277 + - 74278 + - 74279 + - 74280 + - 74281 + - 74282 + - 74283 + - 74284 + - 74285 + - 74286 + - 74287 + - 74288 + - 74289 + - 74290 + - 74291 + - 74292 + - 74293 + - 74294 + - 74295 + - 74296 + - 74297 + - 74298 + - 74299 + - 74300 + - 74301 + - 74302 + - 74303 + - 74304 + - 74305 + - 74306 + - 74307 + - 74308 + - 74309 + - 74310 + - 74311 + - 74312 + - 74313 + - 74314 + - 74315 + - 74316 + - 74317 + - 74318 + - 74319 + - 74320 + - 74321 + - 74322 + - 74323 + - 74324 + - 74325 + - 74326 + - 74327 + - 74328 + - 74329 + - 74330 + - 74331 + - 74332 + - 74333 + - 74334 + - 74335 + - 74336 + - 74337 + - 74338 + - 74339 + - 74340 + - 74341 + - 74342 + - 74343 + - 74344 + - 74345 + - 74346 + - 74347 + - 74348 + - 74349 + - 74350 + - 74351 + - 74352 + - 74353 + - 74354 + - 74355 + - 74356 + - 74357 + - 74358 + - 74359 + - 74360 + - 74361 + - 74362 + - 74363 + - 74364 + - 74365 + - 74366 + - 74367 + - 74368 + - 74369 + - 74370 + - 74371 + - 74372 + - 74373 + - 74374 + - 74375 + - 74376 + - 74377 + - 74378 + - 74379 + - 74380 + - 74381 + - 74382 + - 74383 + - 74384 + - 74385 + - 74386 + - 74387 + - 74388 + - 74389 + - 74390 + - 74391 + - 74392 + - 74393 + - 74394 + - 74395 + - 74396 + - 74397 + - 74398 + - 74399 + - 74400 + - 74401 + - 74402 + - 74403 + - 74404 + - 74405 + - 74406 + - 74407 + - 74408 + - 74409 + - 74410 + - 74411 + - 74412 + - 74413 + - 74414 + - 74415 + - 74416 + - 74417 + - 74418 + - 74419 + - 74420 + - 74421 + - 74422 + - 74423 + - 74424 + - 74425 + - 74426 + - 74427 + - 74428 + - 74429 + - 74430 + - 74431 + - 74432 + - 74433 + - 74434 + - 74435 + - 74436 + - 74437 + - 74438 + - 74439 + - 74440 + - 74441 + - 74442 + - 74443 + - 74444 + - 74445 + - 74446 + - 74447 + - 74448 + - 74449 + - 74450 + - 74451 + - 74452 + - 74453 + - 74454 + - 74455 + - 74456 + - 74457 + - 74458 + - 74459 + - 74460 + - 74461 + - 74462 + - 74463 + - 74464 + - 74465 + - 74466 + - 74467 + - 74468 + - 74469 + - 74470 + - 74471 + - 74472 + - 74473 + - 74474 + - 74475 + - 74476 + - 74477 + - 74478 + - 74479 + - 74480 + - 74481 + - 74482 + - 74483 + - 74484 + - 74485 + - 74486 + - 74487 + - 74488 + - 74489 + - 74490 + - 74491 + - 74492 + - 74493 + - 74494 + - 74495 + - 74496 + - 74497 + - 74498 + - 74499 + - 74500 + - 74501 + - 74502 + - 74503 + - 74504 + - 74505 + - 74506 + - 74507 + - 74508 + - 74509 + - 74510 + - 74511 + - 74512 + - 74513 + - 74514 + - 74515 + - 74516 + - 74517 + - 74518 + - 74519 + - 74520 + - 74521 + - 74522 + - 74523 + - 74524 + - 74525 + - 74526 + - 74527 + - 74528 + - 74529 + - 74530 + - 74531 + - 74532 + - 74533 + - 74534 + - 74535 + - 74536 + - 74537 + - 74538 + - 74539 + - 74540 + - 74541 + - 74542 + - 74543 + - 74544 + - 74545 + - 74546 + - 74547 + - 74548 + - 74549 + - 74550 + - 74551 + - 74552 + - 74553 + - 74554 + - 74555 + - 74556 + - 74557 + - 74558 + - 74559 + - 74560 + - 74561 + - 74562 + - 74563 + - 74564 + - 74565 + - 74566 + - 74567 + - 74568 + - 74569 + - 74570 + - 74571 + - 74572 + - 74573 + - 74574 + - 74575 + - 74576 + - 74577 + - 74578 + - 74579 + - 74580 + - 74581 + - 74582 + - 74583 + - 74584 + - 74585 + - 74586 + - 74587 + - 74588 + - 74589 + - 74590 + - 74591 + - 74592 + - 74593 + - 74594 + - 74595 + - 74596 + - 74597 + - 74598 + - 74599 + - 74600 + - 74601 + - 74602 + - 74603 + - 74604 + - 74605 + - 74606 + - 74607 + - 74608 + - 74609 + - 74610 + - 74611 + - 74612 + - 74613 + - 74614 + - 74615 + - 74616 + - 74617 + - 74618 + - 74619 + - 74620 + - 74621 + - 74622 + - 74623 + - 74624 + - 74625 + - 74626 + - 74627 + - 74628 + - 74629 + - 74630 + - 74631 + - 74632 + - 74633 + - 74634 + - 74635 + - 74636 + - 74637 + - 74638 + - 74639 + - 74640 + - 74641 + - 74642 + - 74643 + - 74644 + - 74645 + - 74646 + - 74647 + - 74648 + - 74649 + - 74650 + - 74651 + - 74652 + - 74653 + - 74654 + - 74655 + - 74656 + - 74657 + - 74658 + - 74659 + - 74660 + - 74661 + - 74662 + - 74663 + - 74664 + - 74665 + - 74666 + - 74667 + - 74668 + - 74669 + - 74670 + - 74671 + - 74672 + - 74673 + - 74674 + - 74675 + - 74676 + - 74677 + - 74678 + - 74679 + - 74680 + - 74681 + - 74682 + - 74683 + - 74684 + - 74685 + - 74686 + - 74687 + - 74688 + - 74689 + - 74690 + - 74691 + - 74692 + - 74693 + - 74694 + - 74695 + - 74696 + - 74697 + - 74698 + - 74699 + - 74700 + - 74701 + - 74702 + - 74703 + - 74704 + - 74705 + - 74706 + - 74707 + - 74708 + - 74709 + - 74710 + - 74711 + - 74712 + - 74713 + - 74714 + - 74715 + - 74716 + - 74717 + - 74718 + - 74719 + - 74720 + - 74721 + - 74722 + - 74723 + - 74724 + - 74725 + - 74726 + - 74727 + - 74728 + - 74729 + - 74730 + - 74731 + - 74732 + - 74733 + - 74734 + - 74735 + - 74736 + - 74737 + - 74738 + - 74739 + - 74740 + - 74741 + - 74742 + - 74743 + - 74744 + - 74745 + - 74746 + - 74747 + - 74748 + - 74749 + - 74750 + - 74751 + - 74752 + - 74753 + - 74754 + - 74755 + - 74756 + - 74757 + - 74758 + - 74759 + - 74760 + - 74761 + - 74762 + - 74763 + - 74764 + - 74765 + - 74766 + - 74767 + - 74768 + - 74769 + - 74770 + - 74771 + - 74772 + - 74773 + - 74774 + - 74775 + - 74776 + - 74777 + - 74778 + - 74779 + - 74780 + - 74781 + - 74782 + - 74783 + - 74784 + - 74785 + - 74786 + - 74787 + - 74788 + - 74789 + - 74790 + - 74791 + - 74792 + - 74793 + - 74794 + - 74795 + - 74796 + - 74797 + - 74798 + - 74799 + - 74800 + - 74801 + - 74802 + - 74803 + - 74804 + - 74805 + - 74806 + - 74807 + - 74808 + - 74809 + - 74810 + - 74811 + - 74812 + - 74813 + - 74814 + - 74815 + - 74816 + - 74817 + - 74818 + - 74819 + - 74820 + - 74821 + - 74822 + - 74823 + - 74824 + - 74825 + - 74826 + - 74827 + - 74828 + - 74829 + - 74830 + - 74831 + - 74832 + - 74833 + - 74834 + - 74835 + - 74836 + - 74837 + - 74838 + - 74839 + - 74840 + - 74841 + - 74842 + - 74843 + - 74844 + - 74845 + - 74846 + - 74847 + - 74848 + - 74849 + - 74850 + - 74851 + - 74852 + - 74853 + - 74854 + - 74855 + - 74856 + - 74857 + - 74858 + - 74859 + - 74860 + - 74861 + - 74862 + - 74863 + - 74864 + - 74865 + - 74866 + - 74867 + - 74868 + - 74869 + - 74870 + - 74871 + - 74872 + - 74873 + - 74874 + - 74875 + - 74876 + - 74877 + - 74878 + - 74879 + - 74880 + - 74881 + - 74882 + - 74883 + - 74884 + - 74885 + - 74886 + - 74887 + - 74888 + - 74889 + - 74890 + - 74891 + - 74892 + - 74893 + - 74894 + - 74895 + - 74896 + - 74897 + - 74898 + - 74899 + - 74900 + - 74901 + - 74902 + - 74903 + - 74904 + - 74905 + - 74906 + - 74907 + - 74908 + - 74909 + - 74910 + - 74911 + - 74912 + - 74913 + - 74914 + - 74915 + - 74916 + - 74917 + - 74918 + - 74919 + - 74920 + - 74921 + - 74922 + - 74923 + - 74924 + - 74925 + - 74926 + - 74927 + - 74928 + - 74929 + - 74930 + - 74931 + - 74932 + - 74933 + - 74934 + - 74935 + - 74936 + - 74937 + - 74938 + - 74939 + - 74940 + - 74941 + - 74942 + - 74943 + - 74944 + - 74945 + - 74946 + - 74947 + - 74948 + - 74949 + - 74950 + - 74951 + - 74952 + - 74953 + - 74954 + - 74955 + - 74956 + - 74957 + - 74958 + - 74959 + - 74960 + - 74961 + - 74962 + - 74963 + - 74964 + - 74965 + - 74966 + - 74967 + - 74968 + - 74969 + - 74970 + - 74971 + - 74972 + - 74973 + - 74974 + - 74975 + - 74976 + - 74977 + - 74978 + - 74979 + - 74980 + - 74981 + - 74982 + - 74983 + - 74984 + - 74985 + - 74986 + - 74987 + - 74988 + - 74989 + - 74990 + - 74991 + - 74992 + - 74993 + - 74994 + - 74995 + - 74996 + - 74997 + - 74998 + - 74999 + - 75000 + - 75001 + - 75002 + - 75003 + - 75004 + - 75005 + - 75006 + - 75007 + - 75008 + - 75009 + - 75010 + - 75011 + - 75012 + - 75013 + - 75014 + - 75015 + - 75016 + - 75017 + - 75018 + - 75019 + - 75020 + - 75021 + - 75022 + - 75023 + - 75024 + - 75025 + - 75026 + - 75027 + - 75028 + - 75029 + - 75030 + - 75031 + - 75032 + - 75033 + - 75034 + - 75035 + - 75036 + - 75037 + - 75038 + - 75039 + - 75040 + - 75041 + - 75042 + - 75043 + - 75044 + - 75045 + - 75046 + - 75047 + - 75048 + - 75049 + - 75050 + - 75051 + - 75052 + - 75053 + - 75054 + - 75055 + - 75056 + - 75057 + - 75058 + - 75059 + - 75060 + - 75061 + - 75062 + - 75063 + - 75064 + - 75065 + - 75066 + - 75067 + - 75068 + - 75069 + - 75070 + - 75071 + - 75072 + - 75073 + - 75074 + - 75075 + - 75076 + - 75077 + - 75078 + - 75079 + - 75080 + - 75081 + - 75082 + - 75083 + - 75084 + - 75085 + - 75086 + - 75087 + - 75088 + - 75089 + - 75090 + - 75091 + - 75092 + - 75093 + - 75094 + - 75095 + - 75096 + - 75097 + - 75098 + - 75099 + - 75100 + - 75101 + - 75102 + - 75103 + - 75104 + - 75105 + - 75106 + - 75107 + - 75108 + - 75109 + - 75110 + - 75111 + - 75112 + - 75113 + - 75114 + - 75115 + - 75116 + - 75117 + - 75118 + - 75119 + - 75120 + - 75121 + - 75122 + - 75123 + - 75124 + - 75125 + - 75126 + - 75127 + - 75128 + - 75129 + - 75130 + - 75131 + - 75132 + - 75133 + - 75134 + - 75135 + - 75136 + - 75137 + - 75138 + - 75139 + - 75140 + - 75141 + - 75142 + - 75143 + - 75144 + - 75145 + - 75146 + - 75147 + - 75148 + - 75149 + - 75150 + - 75151 + - 75152 + - 75153 + - 75154 + - 75155 + - 75156 + - 75157 + - 75158 + - 75159 + - 75160 + - 75161 + - 75162 + - 75163 + - 75164 + - 75165 + - 75166 + - 75167 + - 75168 + - 75169 + - 75170 + - 75171 + - 75172 + - 75173 + - 75174 + - 75175 + - 75176 + - 75177 + - 75178 + - 75179 + - 75180 + - 75181 + - 75182 + - 75183 + - 75184 + - 75185 + - 75186 + - 75187 + - 75188 + - 75189 + - 75190 + - 75191 + - 75192 + - 75193 + - 75194 + - 75195 + - 75196 + - 75197 + - 75198 + - 75199 + - 75200 + - 75201 + - 75202 + - 75203 + - 75204 + - 75205 + - 75206 + - 75207 + - 75208 + - 75209 + - 75210 + - 75211 + - 75212 + - 75213 + - 75214 + - 75215 + - 75216 + - 75217 + - 75218 + - 75219 + - 75220 + - 75221 + - 75222 + - 75223 + - 75224 + - 75225 + - 75226 + - 75227 + - 75228 + - 75229 + - 75230 + - 75231 + - 75232 + - 75233 + - 75234 + - 75235 + - 75236 + - 75237 + - 75238 + - 75239 + - 75240 + - 75241 + - 75242 + - 75243 + - 75244 + - 75245 + - 75246 + - 75247 + - 75248 + - 75249 + - 75250 + - 75251 + - 75252 + - 75253 + - 75254 + - 75255 + - 75256 + - 75257 + - 75258 + - 75259 + - 75260 + - 75261 + - 75262 + - 75263 + - 75264 + - 75265 + - 75266 + - 75267 + - 75268 + - 75269 + - 75270 + - 75271 + - 75272 + - 75273 + - 75274 + - 75275 + - 75276 + - 75277 + - 75278 + - 75279 + - 75280 + - 75281 + - 75282 + - 75283 + - 75284 + - 75285 + - 75286 + - 75287 + - 75288 + - 75289 + - 75290 + - 75291 + - 75292 + - 75293 + - 75294 + - 75295 + - 75296 + - 75297 + - 75298 + - 75299 + - 75300 + - 75301 + - 75302 + - 75303 + - 75304 + - 75305 + - 75306 + - 75307 + - 75308 + - 75309 + - 75310 + - 75311 + - 75312 + - 75313 + - 75314 + - 75315 + - 75316 + - 75317 + - 75318 + - 75319 + - 75320 + - 75321 + - 75322 + - 75323 + - 75324 + - 75325 + - 75326 + - 75327 + - 75328 + - 75329 + - 75330 + - 75331 + - 75332 + - 75333 + - 75334 + - 75335 + - 75336 + - 75337 + - 75338 + - 75339 + - 75340 + - 75341 + - 75342 + - 75343 + - 75344 + - 75345 + - 75346 + - 75347 + - 75348 + - 75349 + - 75350 + - 75351 + - 75352 + - 75353 + - 75354 + - 75355 + - 75356 + - 75357 + - 75358 + - 75359 + - 75360 + - 75361 + - 75362 + - 75363 + - 75364 + - 75365 + - 75366 + - 75367 + - 75368 + - 75369 + - 75370 + - 75371 + - 75372 + - 75373 + - 75374 + - 75375 + - 75376 + - 75377 + - 75378 + - 75379 + - 75380 + - 75381 + - 75382 + - 75383 + - 75384 + - 75385 + - 75386 + - 75387 + - 75388 + - 75389 + - 75390 + - 75391 + - 75392 + - 75393 + - 75394 + - 75395 + - 75396 + - 75397 + - 75398 + - 75399 + - 75400 + - 75401 + - 75402 + - 75403 + - 75404 + - 75405 + - 75406 + - 75407 + - 75408 + - 75409 + - 75410 + - 75411 + - 75412 + - 75413 + - 75414 + - 75415 + - 75416 + - 75417 + - 75418 + - 75419 + - 75420 + - 75421 + - 75422 + - 75423 + - 75424 + - 75425 + - 75426 + - 75427 + - 75428 + - 75429 + - 75430 + - 75431 + - 75432 + - 75433 + - 75434 + - 75435 + - 75436 + - 75437 + - 75438 + - 75439 + - 75440 + - 75441 + - 75442 + - 75443 + - 75444 + - 75445 + - 75446 + - 75447 + - 75448 + - 75449 + - 75450 + - 75451 + - 75452 + - 75453 + - 75454 + - 75455 + - 75456 + - 75457 + - 75458 + - 75459 + - 75460 + - 75461 + - 75462 + - 75463 + - 75464 + - 75465 + - 75466 + - 75467 + - 75468 + - 75469 + - 75470 + - 75471 + - 75472 + - 75473 + - 75474 + - 75475 + - 75476 + - 75477 + - 75478 + - 75479 + - 75480 + - 75481 + - 75482 + - 75483 + - 75484 + - 75485 + - 75486 + - 75487 + - 75488 + - 75489 + - 75490 + - 75491 + - 75492 + - 75493 + - 75494 + - 75495 + - 75496 + - 75497 + - 75498 + - 75499 + - 75500 + - 75501 + - 75502 + - 75503 + - 75504 + - 75505 + - 75506 + - 75507 + - 75508 + - 75509 + - 75510 + - 75511 + - 75512 + - 75513 + - 75514 + - 75515 + - 75516 + - 75517 + - 75518 + - 75519 + - 75520 + - 75521 + - 75522 + - 75523 + - 75524 + - 75525 + - 75526 + - 75527 + - 75528 + - 75529 + - 75530 + - 75531 + - 75532 + - 75533 + - 75534 + - 75535 + - 75536 + - 75537 + - 75538 + - 75539 + - 75540 + - 75541 + - 75542 + - 75543 + - 75544 + - 75545 + - 75546 + - 75547 + - 75548 + - 75549 + - 75550 + - 75551 + - 75552 + - 75553 + - 75554 + - 75555 + - 75556 + - 75557 + - 75558 + - 75559 + - 75560 + - 75561 + - 75562 + - 75563 + - 75564 + - 75565 + - 75566 + - 75567 + - 75568 + - 75569 + - 75570 + - 75571 + - 75572 + - 75573 + - 75574 + - 75575 + - 75576 + - 75577 + - 75578 + - 75579 + - 75580 + - 75581 + - 75582 + - 75583 + - 75584 + - 75585 + - 75586 + - 75587 + - 75588 + - 75589 + - 75590 + - 75591 + - 75592 + - 75593 + - 75594 + - 75595 + - 75596 + - 75597 + - 75598 + - 75599 + - 75600 + - 75601 + - 75602 + - 75603 + - 75604 + - 75605 + - 75606 + - 75607 + - 75608 + - 75609 + - 75610 + - 75611 + - 75612 + - 75613 + - 75614 + - 75615 + - 75616 + - 75617 + - 75618 + - 75619 + - 75620 + - 75621 + - 75622 + - 75623 + - 75624 + - 75625 + - 75626 + - 75627 + - 75628 + - 75629 + - 75630 + - 75631 + - 75632 + - 75633 + - 75634 + - 75635 + - 75636 + - 75637 + - 75638 + - 75639 + - 75640 + - 75641 + - 75642 + - 75643 + - 75644 + - 75645 + - 75646 + - 75647 + - 75648 + - 75649 + - 75650 + - 75651 + - 75652 + - 75653 + - 75654 + - 75655 + - 75656 + - 75657 + - 75658 + - 75659 + - 75660 + - 75661 + - 75662 + - 75663 + - 75664 + - 75665 + - 75666 + - 75667 + - 75668 + - 75669 + - 75670 + - 75671 + - 75672 + - 75673 + - 75674 + - 75675 + - 75676 + - 75677 + - 75678 + - 75679 + - 75680 + - 75681 + - 75682 + - 75683 + - 75684 + - 75685 + - 75686 + - 75687 + - 75688 + - 75689 + - 75690 + - 75691 + - 75692 + - 75693 + - 75694 + - 75695 + - 75696 + - 75697 + - 75698 + - 75699 + - 75700 + - 75701 + - 75702 + - 75703 + - 75704 + - 75705 + - 75706 + - 75707 + - 75708 + - 75709 + - 75710 + - 75711 + - 75712 + - 75713 + - 75714 + - 75715 + - 75716 + - 75717 + - 75718 + - 75719 + - 75720 + - 75721 + - 75722 + - 75723 + - 75724 + - 75725 + - 75726 + - 75727 + - 75728 + - 75729 + - 75730 + - 75731 + - 75732 + - 75733 + - 75734 + - 75735 + - 75736 + - 75737 + - 75738 + - 75739 + - 75740 + - 75741 + - 75742 + - 75743 + - 75744 + - 75745 + - 75746 + - 75747 + - 75748 + - 75749 + - 75750 + - 75751 + - 75752 + - 75753 + - 75754 + - 75755 + - 75756 + - 75757 + - 75758 + - 75759 + - 75760 + - 75761 + - 75762 + - 75763 + - 75764 + - 75765 + - 75766 + - 75767 + - 75768 + - 75769 + - 75770 + - 75771 + - 75772 + - 75773 + - 75774 + - 75775 + - 75776 + - 75777 + - 75778 + - 75779 + - 75780 + - 75781 + - 75782 + - 75783 + - 75784 + - 75785 + - 75786 + - 75787 + - 75788 + - 75789 + - 75790 + - 75791 + - 75792 + - 75793 + - 75794 + - 75795 + - 75796 + - 75797 + - 75798 + - 75799 + - 75800 + - 75801 + - 75802 + - 75803 + - 75804 + - 75805 + - 75806 + - 75807 + - 75808 + - 75809 + - 75810 + - 75811 + - 75812 + - 75813 + - 75814 + - 75815 + - 75816 + - 75817 + - 75818 + - 75819 + - 75820 + - 75821 + - 75822 + - 75823 + - 75824 + - 75825 + - 75826 + - 75827 + - 75828 + - 75829 + - 75830 + - 75831 + - 75832 + - 75833 + - 75834 + - 75835 + - 75836 + - 75837 + - 75838 + - 75839 + - 75840 + - 75841 + - 75842 + - 75843 + - 75844 + - 75845 + - 75846 + - 75847 + - 75848 + - 75849 + - 75850 + - 75851 + - 75852 + - 75853 + - 75854 + - 75855 + - 75856 + - 75857 + - 75858 + - 75859 + - 75860 + - 75861 + - 75862 + - 75863 + - 75864 + - 75865 + - 75866 + - 75867 + - 75868 + - 75869 + - 75870 + - 75871 + - 75872 + - 75873 + - 75874 + - 75875 + - 75876 + - 75877 + - 75878 + - 75879 + - 75880 + - 75881 + - 75882 + - 75883 + - 75884 + - 75885 + - 75886 + - 75887 + - 75888 + - 75889 + - 75890 + - 75891 + - 75892 + - 75893 + - 75894 + - 75895 + - 75896 + - 75897 + - 75898 + - 75899 + - 75900 + - 75901 + - 75902 + - 75903 + - 75904 + - 75905 + - 75906 + - 75907 + - 75908 + - 75909 + - 75910 + - 75911 + - 75912 + - 75913 + - 75914 + - 75915 + - 75916 + - 75917 + - 75918 + - 75919 + - 75920 + - 75921 + - 75922 + - 75923 + - 75924 + - 75925 + - 75926 + - 75927 + - 75928 + - 75929 + - 75930 + - 75931 + - 75932 + - 75933 + - 75934 + - 75935 + - 75936 + - 75937 + - 75938 + - 75939 + - 75940 + - 75941 + - 75942 + - 75943 + - 75944 + - 75945 + - 75946 + - 75947 + - 75948 + - 75949 + - 75950 + - 75951 + - 75952 + - 75953 + - 75954 + - 75955 + - 75956 + - 75957 + - 75958 + - 75959 + - 75960 + - 75961 + - 75962 + - 75963 + - 75964 + - 75965 + - 75966 + - 75967 + - 75968 + - 75969 + - 75970 + - 75971 + - 75972 + - 75973 + - 75974 + - 75975 + - 75976 + - 75977 + - 75978 + - 75979 + - 75980 + - 75981 + - 75982 + - 75983 + - 75984 + - 75985 + - 75986 + - 75987 + - 75988 + - 75989 + - 75990 + - 75991 + - 75992 + - 75993 + - 75994 + - 75995 + - 75996 + - 75997 + - 75998 + - 75999 + - 76000 + - 76001 + - 76002 + - 76003 + - 76004 + - 76005 + - 76006 + - 76007 + - 76008 + - 76009 + - 76010 + - 76011 + - 76012 + - 76013 + - 76014 + - 76015 + - 76016 + - 76017 + - 76018 + - 76019 + - 76020 + - 76021 + - 76022 + - 76023 + - 76024 + - 76025 + - 76026 + - 76027 + - 76028 + - 76029 + - 76030 + - 76031 + - 76032 + - 76033 + - 76034 + - 76035 + - 76036 + - 76037 + - 76038 + - 76039 + - 76040 + - 76041 + - 76042 + - 76043 + - 76044 + - 76045 + - 76046 + - 76047 + - 76048 + - 76049 + - 76050 + - 76051 + - 76052 + - 76053 + - 76054 + - 76055 + - 76056 + - 76057 + - 76058 + - 76059 + - 76060 + - 76061 + - 76062 + - 76063 + - 76064 + - 76065 + - 76066 + - 76067 + - 76068 + - 76069 + - 76070 + - 76071 + - 76072 + - 76073 + - 76074 + - 76075 + - 76076 + - 76077 + - 76078 + - 76079 + - 76080 + - 76081 + - 76082 + - 76083 + - 76084 + - 76085 + - 76086 + - 76087 + - 76088 + - 76089 + - 76090 + - 76091 + - 76092 + - 76093 + - 76094 + - 76095 + - 76096 + - 76097 + - 76098 + - 76099 + - 76100 + - 76101 + - 76102 + - 76103 + - 76104 + - 76105 + - 76106 + - 76107 + - 76108 + - 76109 + - 76110 + - 76111 + - 76112 + - 76113 + - 76114 + - 76115 + - 76116 + - 76117 + - 76118 + - 76119 + - 76120 + - 76121 + - 76122 + - 76123 + - 76124 + - 76125 + - 76126 + - 76127 + - 76128 + - 76129 + - 76130 + - 76131 + - 76132 + - 76133 + - 76134 + - 76135 + - 76136 + - 76137 + - 76138 + - 76139 + - 76140 + - 76141 + - 76142 + - 76143 + - 76144 + - 76145 + - 76146 + - 76147 + - 76148 + - 76149 + - 76150 + - 76151 + - 76152 + - 76153 + - 76154 + - 76155 + - 76156 + - 76157 + - 76158 + - 76159 + - 76160 + - 76161 + - 76162 + - 76163 + - 76164 + - 76165 + - 76166 + - 76167 + - 76168 + - 76169 + - 76170 + - 76171 + - 76172 + - 76173 + - 76174 + - 76175 + - 76176 + - 76177 + - 76178 + - 76179 + - 76180 + - 76181 + - 76182 + - 76183 + - 76184 + - 76185 + - 76186 + - 76187 + - 76188 + - 76189 + - 76190 + - 76191 + - 76192 + - 76193 + - 76194 + - 76195 + - 76196 + - 76197 + - 76198 + - 76199 + - 76200 + - 76201 + - 76202 + - 76203 + - 76204 + - 76205 + - 76206 + - 76207 + - 76208 + - 76209 + - 76210 + - 76211 + - 76212 + - 76213 + - 76214 + - 76215 + - 76216 + - 76217 + - 76218 + - 76219 + - 76220 + - 76221 + - 76222 + - 76223 + - 76224 + - 76225 + - 76226 + - 76227 + - 76228 + - 76229 + - 76230 + - 76231 + - 76232 + - 76233 + - 76234 + - 76235 + - 76236 + - 76237 + - 76238 + - 76239 + - 76240 + - 76241 + - 76242 + - 76243 + - 76244 + - 76245 + - 76246 + - 76247 + - 76248 + - 76249 + - 76250 + - 76251 + - 76252 + - 76253 + - 76254 + - 76255 + - 76256 + - 76257 + - 76258 + - 76259 + - 76260 + - 76261 + - 76262 + - 76263 + - 76264 + - 76265 + - 76266 + - 76267 + - 76268 + - 76269 + - 76270 + - 76271 + - 76272 + - 76273 + - 76274 + - 76275 + - 76276 + - 76277 + - 76278 + - 76279 + - 76280 + - 76281 + - 76282 + - 76283 + - 76284 + - 76285 + - 76286 + - 76287 + - 76288 + - 76289 + - 76290 + - 76291 + - 76292 + - 76293 + - 76294 + - 76295 + - 76296 + - 76297 + - 76298 + - 76299 + - 76300 + - 76301 + - 76302 + - 76303 + - 76304 + - 76305 + - 76306 + - 76307 + - 76308 + - 76309 + - 76310 + - 76311 + - 76312 + - 76313 + - 76314 + - 76315 + - 76316 + - 76317 + - 76318 + - 76319 + - 76320 + - 76321 + - 76322 + - 76323 + - 76324 + - 76325 + - 76326 + - 76327 + - 76328 + - 76329 + - 76330 + - 76331 + - 76332 + - 76333 + - 76334 + - 76335 + - 76336 + - 76337 + - 76338 + - 76339 + - 76340 + - 76341 + - 76342 + - 76343 + - 76344 + - 76345 + - 76346 + - 76347 + - 76348 + - 76349 + - 76350 + - 76351 + - 76352 + - 76353 + - 76354 + - 76355 + - 76356 + - 76357 + - 76358 + - 76359 + - 76360 + - 76361 + - 76362 + - 76363 + - 76364 + - 76365 + - 76366 + - 76367 + - 76368 + - 76369 + - 76370 + - 76371 + - 76372 + - 76373 + - 76374 + - 76375 + - 76376 + - 76377 + - 76378 + - 76379 + - 76380 + - 76381 + - 76382 + - 76383 + - 76384 + - 76385 + - 76386 + - 76387 + - 76388 + - 76389 + - 76390 + - 76391 + - 76392 + - 76393 + - 76394 + - 76395 + - 76396 + - 76397 + - 76398 + - 76399 + - 76400 + - 76401 + - 76402 + - 76403 + - 76404 + - 76405 + - 76406 + - 76407 + - 76408 + - 76409 + - 76410 + - 76411 + - 76412 + - 76413 + - 76414 + - 76415 + - 76416 + - 76417 + - 76418 + - 76419 + - 76420 + - 76421 + - 76422 + - 76423 + - 76424 + - 76425 + - 76426 + - 76427 + - 76428 + - 76429 + - 76430 + - 76431 + - 76432 + - 76433 + - 76434 + - 76435 + - 76436 + - 76437 + - 76438 + - 76439 + - 76440 + - 76441 + - 76442 + - 76443 + - 76444 + - 76445 + - 76446 + - 76447 + - 76448 + - 76449 + - 76450 + - 76451 + - 76452 + - 76453 + - 76454 + - 76455 + - 76456 + - 76457 + - 76458 + - 76459 + - 76460 + - 76461 + - 76462 + - 76463 + - 76464 + - 76465 + - 76466 + - 76467 + - 76468 + - 76469 + - 76470 + - 76471 + - 76472 + - 76473 + - 76474 + - 76475 + - 76476 + - 76477 + - 76478 + - 76479 + - 76480 + - 76481 + - 76482 + - 76483 + - 76484 + - 76485 + - 76486 + - 76487 + - 76488 + - 76489 + - 76490 + - 76491 + - 76492 + - 76493 + - 76494 + - 76495 + - 76496 + - 76497 + - 76498 + - 76499 + - 76500 + - 76501 + - 76502 + - 76503 + - 76504 + - 76505 + - 76506 + - 76507 + - 76508 + - 76509 + - 76510 + - 76511 + - 76512 + - 76513 + - 76514 + - 76515 + - 76516 + - 76517 + - 76518 + - 76519 + - 76520 + - 76521 + - 76522 + - 76523 + - 76524 + - 76525 + - 76526 + - 76527 + - 76528 + - 76529 + - 76530 + - 76531 + - 76532 + - 76533 + - 76534 + - 76535 + - 76536 + - 76537 + - 76538 + - 76539 + - 76540 + - 76541 + - 76542 + - 76543 + - 76544 + - 76545 + - 76546 + - 76547 + - 76548 + - 76549 + - 76550 + - 76551 + - 76552 + - 76553 + - 76554 + - 76555 + - 76556 + - 76557 + - 76558 + - 76559 + - 76560 + - 76561 + - 76562 + - 76563 + - 76564 + - 76565 + - 76566 + - 76567 + - 76568 + - 76569 + - 76570 + - 76571 + - 76572 + - 76573 + - 76574 + - 76575 + - 76576 + - 76577 + - 76578 + - 76579 + - 76580 + - 76581 + - 76582 + - 76583 + - 76584 + - 76585 + - 76586 + - 76587 + - 76588 + - 76589 + - 76590 + - 76591 + - 76592 + - 76593 + - 76594 + - 76595 + - 76596 + - 76597 + - 76598 + - 76599 + - 76600 + - 76601 + - 76602 + - 76603 + - 76604 + - 76605 + - 76606 + - 76607 + - 76608 + - 76609 + - 76610 + - 76611 + - 76612 + - 76613 + - 76614 + - 76615 + - 76616 + - 76617 + - 76618 + - 76619 + - 76620 + - 76621 + - 76622 + - 76623 + - 76624 + - 76625 + - 76626 + - 76627 + - 76628 + - 76629 + - 76630 + - 76631 + - 76632 + - 76633 + - 76634 + - 76635 + - 76636 + - 76637 + - 76638 + - 76639 + - 76640 + - 76641 + - 76642 + - 76643 + - 76644 + - 76645 + - 76646 + - 76647 + - 76648 + - 76649 + - 76650 + - 76651 + - 76652 + - 76653 + - 76654 + - 76655 + - 76656 + - 76657 + - 76658 + - 76659 + - 76660 + - 76661 + - 76662 + - 76663 + - 76664 + - 76665 + - 76666 + - 76667 + - 76668 + - 76669 + - 76670 + - 76671 + - 76672 + - 76673 + - 76674 + - 76675 + - 76676 + - 76677 + - 76678 + - 76679 + - 76680 + - 76681 + - 76682 + - 76683 + - 76684 + - 76685 + - 76686 + - 76687 + - 76688 + - 76689 + - 76690 + - 76691 + - 76692 + - 76693 + - 76694 + - 76695 + - 76696 + - 76697 + - 76698 + - 76699 + - 76700 + - 76701 + - 76702 + - 76703 + - 76704 + - 76705 + - 76706 + - 76707 + - 76708 + - 76709 + - 76710 + - 76711 + - 76712 + - 76713 + - 76714 + - 76715 + - 76716 + - 76717 + - 76718 + - 76719 + - 76720 + - 76721 + - 76722 + - 76723 + - 76724 + - 76725 + - 76726 + - 76727 + - 76728 + - 76729 + - 76730 + - 76731 + - 76732 + - 76733 + - 76734 + - 76735 + - 76736 + - 76737 + - 76738 + - 76739 + - 76740 + - 76741 + - 76742 + - 76743 + - 76744 + - 76745 + - 76746 + - 76747 + - 76748 + - 76749 + - 76750 + - 76751 + - 76752 + - 76753 + - 76754 + - 76755 + - 76756 + - 76757 + - 76758 + - 76759 + - 76760 + - 76761 + - 76762 + - 76763 + - 76764 + - 76765 + - 76766 + - 76767 + - 76768 + - 76769 + - 76770 + - 76771 + - 76772 + - 76773 + - 76774 + - 76775 + - 76776 + - 76777 + - 76778 + - 76779 + - 76780 + - 76781 + - 76782 + - 76783 + - 76784 + - 76785 + - 76786 + - 76787 + - 76788 + - 76789 + - 76790 + - 76791 + - 76792 + - 76793 + - 76794 + - 76795 + - 76796 + - 76797 + - 76798 + - 76799 + - 76800 + - 76801 + - 76802 + - 76803 + - 76804 + - 76805 + - 76806 + - 76807 + - 76808 + - 76809 + - 76810 + - 76811 + - 76812 + - 76813 + - 76814 + - 76815 + - 76816 + - 76817 + - 76818 + - 76819 + - 76820 + - 76821 + - 76822 + - 76823 + - 76824 + - 76825 + - 76826 + - 76827 + - 76828 + - 76829 + - 76830 + - 76831 + - 76832 + - 76833 + - 76834 + - 76835 + - 76836 + - 76837 + - 76838 + - 76839 + - 76840 + - 76841 + - 76842 + - 76843 + - 76844 + - 76845 + - 76846 + - 76847 + - 76848 + - 76849 + - 76850 + - 76851 + - 76852 + - 76853 + - 76854 + - 76855 + - 76856 + - 76857 + - 76858 + - 76859 + - 76860 + - 76861 + - 76862 + - 76863 + - 76864 + - 76865 + - 76866 + - 76867 + - 76868 + - 76869 + - 76870 + - 76871 + - 76872 + - 76873 + - 76874 + - 76875 + - 76876 + - 76877 + - 76878 + - 76879 + - 76880 + - 76881 + - 76882 + - 76883 + - 76884 + - 76885 + - 76886 + - 76887 + - 76888 + - 76889 + - 76890 + - 76891 + - 76892 + - 76893 + - 76894 + - 76895 + - 76896 + - 76897 + - 76898 + - 76899 + - 76900 + - 76901 + - 76902 + - 76903 + - 76904 + - 76905 + - 76906 + - 76907 + - 76908 + - 76909 + - 76910 + - 76911 + - 76912 + - 76913 + - 76914 + - 76915 + - 76916 + - 76917 + - 76918 + - 76919 + - 76920 + - 76921 + - 76922 + - 76923 + - 76924 + - 76925 + - 76926 + - 76927 + - 76928 + - 76929 + - 76930 + - 76931 + - 76932 + - 76933 + - 76934 + - 76935 + - 76936 + - 76937 + - 76938 + - 76939 + - 76940 + - 76941 + - 76942 + - 76943 + - 76944 + - 76945 + - 76946 + - 76947 + - 76948 + - 76949 + - 76950 + - 76951 + - 76952 + - 76953 + - 76954 + - 76955 + - 76956 + - 76957 + - 76958 + - 76959 + - 76960 + - 76961 + - 76962 + - 76963 + - 76964 + - 76965 + - 76966 + - 76967 + - 76968 + - 76969 + - 76970 + - 76971 + - 76972 + - 76973 + - 76974 + - 76975 + - 76976 + - 76977 + - 76978 + - 76979 + - 76980 + - 76981 + - 76982 + - 76983 + - 76984 + - 76985 + - 76986 + - 76987 + - 76988 + - 76989 + - 76990 + - 76991 + - 76992 + - 76993 + - 76994 + - 76995 + - 76996 + - 76997 + - 76998 + - 76999 + - 77000 + - 77001 + - 77002 + - 77003 + - 77004 + - 77005 + - 77006 + - 77007 + - 77008 + - 77009 + - 77010 + - 77011 + - 77012 + - 77013 + - 77014 + - 77015 + - 77016 + - 77017 + - 77018 + - 77019 + - 77020 + - 77021 + - 77022 + - 77023 + - 77024 + - 77025 + - 77026 + - 77027 + - 77028 + - 77029 + - 77030 + - 77031 + - 77032 + - 77033 + - 77034 + - 77035 + - 77036 + - 77037 + - 77038 + - 77039 + - 77040 + - 77041 + - 77042 + - 77043 + - 77044 + - 77045 + - 77046 + - 77047 + - 77048 + - 77049 + - 77050 + - 77051 + - 77052 + - 77053 + - 77054 + - 77055 + - 77056 + - 77057 + - 77058 + - 77059 + - 77060 + - 77061 + - 77062 + - 77063 + - 77064 + - 77065 + - 77066 + - 77067 + - 77068 + - 77069 + - 77070 + - 77071 + - 77072 + - 77073 + - 77074 + - 77075 + - 77076 + - 77077 + - 77078 + - 77079 + - 77080 + - 77081 + - 77082 + - 77083 + - 77084 + - 77085 + - 77086 + - 77087 + - 77088 + - 77089 + - 77090 + - 77091 + - 77092 + - 77093 + - 77094 + - 77095 + - 77096 + - 77097 + - 77098 + - 77099 + - 77100 + - 77101 + - 77102 + - 77103 + - 77104 + - 77105 + - 77106 + - 77107 + - 77108 + - 77109 + - 77110 + - 77111 + - 77112 + - 77113 + - 77114 + - 77115 + - 77116 + - 77117 + - 77118 + - 77119 + - 77120 + - 77121 + - 77122 + - 77123 + - 77124 + - 77125 + - 77126 + - 77127 + - 77128 + - 77129 + - 77130 + - 77131 + - 77132 + - 77133 + - 77134 + - 77135 + - 77136 + - 77137 + - 77138 + - 77139 + - 77140 + - 77141 + - 77142 + - 77143 + - 77144 + - 77145 + - 77146 + - 77147 + - 77148 + - 77149 + - 77150 + - 77151 + - 77152 + - 77153 + - 77154 + - 77155 + - 77156 + - 77157 + - 77158 + - 77159 + - 77160 + - 77161 + - 77162 + - 77163 + - 77164 + - 77165 + - 77166 + - 77167 + - 77168 + - 77169 + - 77170 + - 77171 + - 77172 + - 77173 + - 77174 + - 77175 + - 77176 + - 77177 + - 77178 + - 77179 + - 77180 + - 77181 + - 77182 + - 77183 + - 77184 + - 77185 + - 77186 + - 77187 + - 77188 + - 77189 + - 77190 + - 77191 + - 77192 + - 77193 + - 77194 + - 77195 + - 77196 + - 77197 + - 77198 + - 77199 + - 77200 + - 77201 + - 77202 + - 77203 + - 77204 + - 77205 + - 77206 + - 77207 + - 77208 + - 77209 + - 77210 + - 77211 + - 77212 + - 77213 + - 77214 + - 77215 + - 77216 + - 77217 + - 77218 + - 77219 + - 77220 + - 77221 + - 77222 + - 77223 + - 77224 + - 77225 + - 77226 + - 77227 + - 77228 + - 77229 + - 77230 + - 77231 + - 77232 + - 77233 + - 77234 + - 77235 + - 77236 + - 77237 + - 77238 + - 77239 + - 77240 + - 77241 + - 77242 + - 77243 + - 77244 + - 77245 + - 77246 + - 77247 + - 77248 + - 77249 + - 77250 + - 77251 + - 77252 + - 77253 + - 77254 + - 77255 + - 77256 + - 77257 + - 77258 + - 77259 + - 77260 + - 77261 + - 77262 + - 77263 + - 77264 + - 77265 + - 77266 + - 77267 + - 77268 + - 77269 + - 77270 + - 77271 + - 77272 + - 77273 + - 77274 + - 77275 + - 77276 + - 77277 + - 77278 + - 77279 + - 77280 + - 77281 + - 77282 + - 77283 + - 77284 + - 77285 + - 77286 + - 77287 + - 77288 + - 77289 + - 77290 + - 77291 + - 77292 + - 77293 + - 77294 + - 77295 + - 77296 + - 77297 + - 77298 + - 77299 + - 77300 + - 77301 + - 77302 + - 77303 + - 77304 + - 77305 + - 77306 + - 77307 + - 77308 + - 77309 + - 77310 + - 77311 + - 77312 + - 77313 + - 77314 + - 77315 + - 77316 + - 77317 + - 77318 + - 77319 + - 77320 + - 77321 + - 77322 + - 77323 + - 77324 + - 77325 + - 77326 + - 77327 + - 77328 + - 77329 + - 77330 + - 77331 + - 77332 + - 77333 + - 77334 + - 77335 + - 77336 + - 77337 + - 77338 + - 77339 + - 77340 + - 77341 + - 77342 + - 77343 + - 77344 + - 77345 + - 77346 + - 77347 + - 77348 + - 77349 + - 77350 + - 77351 + - 77352 + - 77353 + - 77354 + - 77355 + - 77356 + - 77357 + - 77358 + - 77359 + - 77360 + - 77361 + - 77362 + - 77363 + - 77364 + - 77365 + - 77366 + - 77367 + - 77368 + - 77369 + - 77370 + - 77371 + - 77372 + - 77373 + - 77374 + - 77375 + - 77376 + - 77377 + - 77378 + - 77379 + - 77380 + - 77381 + - 77382 + - 77383 + - 77384 + - 77385 + - 77386 + - 77387 + - 77388 + - 77389 + - 77390 + - 77391 + - 77392 + - 77393 + - 77394 + - 77395 + - 77396 + - 77397 + - 77398 + - 77399 + - 77400 + - 77401 + - 77402 + - 77403 + - 77404 + - 77405 + - 77406 + - 77407 + - 77408 + - 77409 + - 77410 + - 77411 + - 77412 + - 77413 + - 77414 + - 77415 + - 77416 + - 77417 + - 77418 + - 77419 + - 77420 + - 77421 + - 77422 + - 77423 + - 77424 + - 77425 + - 77426 + - 77427 + - 77428 + - 77429 + - 77430 + - 77431 + - 77432 + - 77433 + - 77434 + - 77435 + - 77436 + - 77437 + - 77438 + - 77439 + - 77440 + - 77441 + - 77442 + - 77443 + - 77444 + - 77445 + - 77446 + - 77447 + - 77448 + - 77449 + - 77450 + - 77451 + - 77452 + - 77453 + - 77454 + - 77455 + - 77456 + - 77457 + - 77458 + - 77459 + - 77460 + - 77461 + - 77462 + - 77463 + - 77464 + - 77465 + - 77466 + - 77467 + - 77468 + - 77469 + - 77470 + - 77471 + - 77472 + - 77473 + - 77474 + - 77475 + - 77476 + - 77477 + - 77478 + - 77479 + - 77480 + - 77481 + - 77482 + - 77483 + - 77484 + - 77485 + - 77486 + - 77487 + - 77488 + - 77489 + - 77490 + - 77491 + - 77492 + - 77493 + - 77494 + - 77495 + - 77496 + - 77497 + - 77498 + - 77499 + - 77500 + - 77501 + - 77502 + - 77503 + - 77504 + - 77505 + - 77506 + - 77507 + - 77508 + - 77509 + - 77510 + - 77511 + - 77512 + - 77513 + - 77514 + - 77515 + - 77516 + - 77517 + - 77518 + - 77519 + - 77520 + - 77521 + - 77522 + - 77523 + - 77524 + - 77525 + - 77526 + - 77527 + - 77528 + - 77529 + - 77530 + - 77531 + - 77532 + - 77533 + - 77534 + - 77535 + - 77536 + - 77537 + - 77538 + - 77539 + - 77540 + - 77541 + - 77542 + - 77543 + - 77544 + - 77545 + - 77546 + - 77547 + - 77548 + - 77549 + - 77550 + - 77551 + - 77552 + - 77553 + - 77554 + - 77555 + - 77556 + - 77557 + - 77558 + - 77559 + - 77560 + - 77561 + - 77562 + - 77563 + - 77564 + - 77565 + - 77566 + - 77567 + - 77568 + - 77569 + - 77570 + - 77571 + - 77572 + - 77573 + - 77574 + - 77575 + - 77576 + - 77577 + - 77578 + - 77579 + - 77580 + - 77581 + - 77582 + - 77583 + - 77584 + - 77585 + - 77586 + - 77587 + - 77588 + - 77589 + - 77590 + - 77591 + - 77592 + - 77593 + - 77594 + - 77595 + - 77596 + - 77597 + - 77598 + - 77599 + - 77600 + - 77601 + - 77602 + - 77603 + - 77604 + - 77605 + - 77606 + - 77607 + - 77608 + - 77609 + - 77610 + - 77611 + - 77612 + - 77613 + - 77614 + - 77615 + - 77616 + - 77617 + - 77618 + - 77619 + - 77620 + - 77621 + - 77622 + - 77623 + - 77624 + - 77625 + - 77626 + - 77627 + - 77628 + - 77629 + - 77630 + - 77631 + - 77632 + - 77633 + - 77634 + - 77635 + - 77636 + - 77637 + - 77638 + - 77639 + - 77640 + - 77641 + - 77642 + - 77643 + - 77644 + - 77645 + - 77646 + - 77647 + - 77648 + - 77649 + - 77650 + - 77651 + - 77652 + - 77653 + - 77654 + - 77655 + - 77656 + - 77657 + - 77658 + - 77659 + - 77660 + - 77661 + - 77662 + - 77663 + - 77664 + - 77665 + - 77666 + - 77667 + - 77668 + - 77669 + - 77670 + - 77671 + - 77672 + - 77673 + - 77674 + - 77675 + - 77676 + - 77677 + - 77678 + - 77679 + - 77680 + - 77681 + - 77682 + - 77683 + - 77684 + - 77685 + - 77686 + - 77687 + - 77688 + - 77689 + - 77690 + - 77691 + - 77692 + - 77693 + - 77694 + - 77695 + - 77696 + - 77697 + - 77698 + - 77699 + - 77700 + - 77701 + - 77702 + - 77703 + - 77704 + - 77705 + - 77706 + - 77707 + - 77708 + - 77709 + - 77710 + - 77711 + - 77712 + - 77713 + - 77714 + - 77715 + - 77716 + - 77717 + - 77718 + - 77719 + - 77720 + - 77721 + - 77722 + - 77723 + - 77724 + - 77725 + - 77726 + - 77727 + - 77728 + - 77729 + - 77730 + - 77731 + - 77732 + - 77733 + - 77734 + - 77735 + - 77736 + - 77737 + - 77738 + - 77739 + - 77740 + - 77741 + - 77742 + - 77743 + - 77744 + - 77745 + - 77746 + - 77747 + - 77748 + - 77749 + - 77750 + - 77751 + - 77752 + - 77753 + - 77754 + - 77755 + - 77756 + - 77757 + - 77758 + - 77759 + - 77760 + - 77761 + - 77762 + - 77763 + - 77764 + - 77765 + - 77766 + - 77767 + - 77768 + - 77769 + - 77770 + - 77771 + - 77772 + - 77773 + - 77774 + - 77775 + - 77776 + - 77777 + - 77778 + - 77779 + - 77780 + - 77781 + - 77782 + - 77783 + - 77784 + - 77785 + - 77786 + - 77787 + - 77788 + - 77789 + - 77790 + - 77791 + - 77792 + - 77793 + - 77794 + - 77795 + - 77796 + - 77797 + - 77798 + - 77799 + - 77800 + - 77801 + - 77802 + - 77803 + - 77804 + - 77805 + - 77806 + - 77807 + - 77808 + - 77809 + - 77810 + - 77811 + - 77812 + - 77813 + - 77814 + - 77815 + - 77816 + - 77817 + - 77818 + - 77819 + - 77820 + - 77821 + - 77822 + - 77823 + - 77824 + - 77825 + - 77826 + - 77827 + - 77828 + - 77829 + - 77830 + - 77831 + - 77832 + - 77833 + - 77834 + - 77835 + - 77836 + - 77837 + - 77838 + - 77839 + - 77840 + - 77841 + - 77842 + - 77843 + - 77844 + - 77845 + - 77846 + - 77847 + - 77848 + - 77849 + - 77850 + - 77851 + - 77852 + - 77853 + - 77854 + - 77855 + - 77856 + - 77857 + - 77858 + - 77859 + - 77860 + - 77861 + - 77862 + - 77863 + - 77864 + - 77865 + - 77866 + - 77867 + - 77868 + - 77869 + - 77870 + - 77871 + - 77872 + - 77873 + - 77874 + - 77875 + - 77876 + - 77877 + - 77878 + - 77879 + - 77880 + - 77881 + - 77882 + - 77883 + - 77884 + - 77885 + - 77886 + - 77887 + - 77888 + - 77889 + - 77890 + - 77891 + - 77892 + - 77893 + - 77894 + - 77895 + - 77896 + - 77897 + - 77898 + - 77899 + - 77900 + - 77901 + - 77902 + - 77903 + - 77904 + - 77905 + - 77906 + - 77907 + - 77908 + - 77909 + - 77910 + - 77911 + - 77912 + - 77913 + - 77914 + - 77915 + - 77916 + - 77917 + - 77918 + - 77919 + - 77920 + - 77921 + - 77922 + - 77923 + - 77924 + - 77925 + - 77926 + - 77927 + - 77928 + - 77929 + - 77930 + - 77931 + - 77932 + - 77933 + - 77934 + - 77935 + - 77936 + - 77937 + - 77938 + - 77939 + - 77940 + - 77941 + - 77942 + - 77943 + - 77944 + - 77945 + - 77946 + - 77947 + - 77948 + - 77949 + - 77950 + - 77951 + - 77952 + - 77953 + - 77954 + - 77955 + - 77956 + - 77957 + - 77958 + - 77959 + - 77960 + - 77961 + - 77962 + - 77963 + - 77964 + - 77965 + - 77966 + - 77967 + - 77968 + - 77969 + - 77970 + - 77971 + - 77972 + - 77973 + - 77974 + - 77975 + - 77976 + - 77977 + - 77978 + - 77979 + - 77980 + - 77981 + - 77982 + - 77983 + - 77984 + - 77985 + - 77986 + - 77987 + - 77988 + - 77989 + - 77990 + - 77991 + - 77992 + - 77993 + - 77994 + - 77995 + - 77996 + - 77997 + - 77998 + - 77999 + - 78000 + - 78001 + - 78002 + - 78003 + - 78004 + - 78005 + - 78006 + - 78007 + - 78008 + - 78009 + - 78010 + - 78011 + - 78012 + - 78013 + - 78014 + - 78015 + - 78016 + - 78017 + - 78018 + - 78019 + - 78020 + - 78021 + - 78022 + - 78023 + - 78024 + - 78025 + - 78026 + - 78027 + - 78028 + - 78029 + - 78030 + - 78031 + - 78032 + - 78033 + - 78034 + - 78035 + - 78036 + - 78037 + - 78038 + - 78039 + - 78040 + - 78041 + - 78042 + - 78043 + - 78044 + - 78045 + - 78046 + - 78047 + - 78048 + - 78049 + - 78050 + - 78051 + - 78052 + - 78053 + - 78054 + - 78055 + - 78056 + - 78057 + - 78058 + - 78059 + - 78060 + - 78061 + - 78062 + - 78063 + - 78064 + - 78065 + - 78066 + - 78067 + - 78068 + - 78069 + - 78070 + - 78071 + - 78072 + - 78073 + - 78074 + - 78075 + - 78076 + - 78077 + - 78078 + - 78079 + - 78080 + - 78081 + - 78082 + - 78083 + - 78084 + - 78085 + - 78086 + - 78087 + - 78088 + - 78089 + - 78090 + - 78091 + - 78092 + - 78093 + - 78094 + - 78095 + - 78096 + - 78097 + - 78098 + - 78099 + - 78100 + - 78101 + - 78102 + - 78103 + - 78104 + - 78105 + - 78106 + - 78107 + - 78108 + - 78109 + - 78110 + - 78111 + - 78112 + - 78113 + - 78114 + - 78115 + - 78116 + - 78117 + - 78118 + - 78119 + - 78120 + - 78121 + - 78122 + - 78123 + - 78124 + - 78125 + - 78126 + - 78127 + - 78128 + - 78129 + - 78130 + - 78131 + - 78132 + - 78133 + - 78134 + - 78135 + - 78136 + - 78137 + - 78138 + - 78139 + - 78140 + - 78141 + - 78142 + - 78143 + - 78144 + - 78145 + - 78146 + - 78147 + - 78148 + - 78149 + - 78150 + - 78151 + - 78152 + - 78153 + - 78154 + - 78155 + - 78156 + - 78157 + - 78158 + - 78159 + - 78160 + - 78161 + - 78162 + - 78163 + - 78164 + - 78165 + - 78166 + - 78167 + - 78168 + - 78169 + - 78170 + - 78171 + - 78172 + - 78173 + - 78174 + - 78175 + - 78176 + - 78177 + - 78178 + - 78179 + - 78180 + - 78181 + - 78182 + - 78183 + - 78184 + - 78185 + - 78186 + - 78187 + - 78188 + - 78189 + - 78190 + - 78191 + - 78192 + - 78193 + - 78194 + - 78195 + - 78196 + - 78197 + - 78198 + - 78199 + - 78200 + - 78201 + - 78202 + - 78203 + - 78204 + - 78205 + - 78206 + - 78207 + - 78208 + - 78209 + - 78210 + - 78211 + - 78212 + - 78213 + - 78214 + - 78215 + - 78216 + - 78217 + - 78218 + - 78219 + - 78220 + - 78221 + - 78222 + - 78223 + - 78224 + - 78225 + - 78226 + - 78227 + - 78228 + - 78229 + - 78230 + - 78231 + - 78232 + - 78233 + - 78234 + - 78235 + - 78236 + - 78237 + - 78238 + - 78239 + - 78240 + - 78241 + - 78242 + - 78243 + - 78244 + - 78245 + - 78246 + - 78247 + - 78248 + - 78249 + - 78250 + - 78251 + - 78252 + - 78253 + - 78254 + - 78255 + - 78256 + - 78257 + - 78258 + - 78259 + - 78260 + - 78261 + - 78262 + - 78263 + - 78264 + - 78265 + - 78266 + - 78267 + - 78268 + - 78269 + - 78270 + - 78271 + - 78272 + - 78273 + - 78274 + - 78275 + - 78276 + - 78277 + - 78278 + - 78279 + - 78280 + - 78281 + - 78282 + - 78283 + - 78284 + - 78285 + - 78286 + - 78287 + - 78288 + - 78289 + - 78290 + - 78291 + - 78292 + - 78293 + - 78294 + - 78295 + - 78296 + - 78297 + - 78298 + - 78299 + - 78300 + - 78301 + - 78302 + - 78303 + - 78304 + - 78305 + - 78306 + - 78307 + - 78308 + - 78309 + - 78310 + - 78311 + - 78312 + - 78313 + - 78314 + - 78315 + - 78316 + - 78317 + - 78318 + - 78319 + - 78320 + - 78321 + - 78322 + - 78323 + - 78324 + - 78325 + - 78326 + - 78327 + - 78328 + - 78329 + - 78330 + - 78331 + - 78332 + - 78333 + - 78334 + - 78335 + - 78336 + - 78337 + - 78338 + - 78339 + - 78340 + - 78341 + - 78342 + - 78343 + - 78344 + - 78345 + - 78346 + - 78347 + - 78348 + - 78349 + - 78350 + - 78351 + - 78352 + - 78353 + - 78354 + - 78355 + - 78356 + - 78357 + - 78358 + - 78359 + - 78360 + - 78361 + - 78362 + - 78363 + - 78364 + - 78365 + - 78366 + - 78367 + - 78368 + - 78369 + - 78370 + - 78371 + - 78372 + - 78373 + - 78374 + - 78375 + - 78376 + - 78377 + - 78378 + - 78379 + - 78380 + - 78381 + - 78382 + - 78383 + - 78384 + - 78385 + - 78386 + - 78387 + - 78388 + - 78389 + - 78390 + - 78391 + - 78392 + - 78393 + - 78394 + - 78395 + - 78396 + - 78397 + - 78398 + - 78399 + - 78400 + - 78401 + - 78402 + - 78403 + - 78404 + - 78405 + - 78406 + - 78407 + - 78408 + - 78409 + - 78410 + - 78411 + - 78412 + - 78413 + - 78414 + - 78415 + - 78416 + - 78417 + - 78418 + - 78419 + - 78420 + - 78421 + - 78422 + - 78423 + - 78424 + - 78425 + - 78426 + - 78427 + - 78428 + - 78429 + - 78430 + - 78431 + - 78432 + - 78433 + - 78434 + - 78435 + - 78436 + - 78437 + - 78438 + - 78439 + - 78440 + - 78441 + - 78442 + - 78443 + - 78444 + - 78445 + - 78446 + - 78447 + - 78448 + - 78449 + - 78450 + - 78451 + - 78452 + - 78453 + - 78454 + - 78455 + - 78456 + - 78457 + - 78458 + - 78459 + - 78460 + - 78461 + - 78462 + - 78463 + - 78464 + - 78465 + - 78466 + - 78467 + - 78468 + - 78469 + - 78470 + - 78471 + - 78472 + - 78473 + - 78474 + - 78475 + - 78476 + - 78477 + - 78478 + - 78479 + - 78480 + - 78481 + - 78482 + - 78483 + - 78484 + - 78485 + - 78486 + - 78487 + - 78488 + - 78489 + - 78490 + - 78491 + - 78492 + - 78493 + - 78494 + - 78495 + - 78496 + - 78497 + - 78498 + - 78499 + - 78500 + - 78501 + - 78502 + - 78503 + - 78504 + - 78505 + - 78506 + - 78507 + - 78508 + - 78509 + - 78510 + - 78511 + - 78512 + - 78513 + - 78514 + - 78515 + - 78516 + - 78517 + - 78518 + - 78519 + - 78520 + - 78521 + - 78522 + - 78523 + - 78524 + - 78525 + - 78526 + - 78527 + - 78528 + - 78529 + - 78530 + - 78531 + - 78532 + - 78533 + - 78534 + - 78535 + - 78536 + - 78537 + - 78538 + - 78539 + - 78540 + - 78541 + - 78542 + - 78543 + - 78544 + - 78545 + - 78546 + - 78547 + - 78548 + - 78549 + - 78550 + - 78551 + - 78552 + - 78553 + - 78554 + - 78555 + - 78556 + - 78557 + - 78558 + - 78559 + - 78560 + - 78561 + - 78562 + - 78563 + - 78564 + - 78565 + - 78566 + - 78567 + - 78568 + - 78569 + - 78570 + - 78571 + - 78572 + - 78573 + - 78574 + - 78575 + - 78576 + - 78577 + - 78578 + - 78579 + - 78580 + - 78581 + - 78582 + - 78583 + - 78584 + - 78585 + - 78586 + - 78587 + - 78588 + - 78589 + - 78590 + - 78591 + - 78592 + - 78593 + - 78594 + - 78595 + - 78596 + - 78597 + - 78598 + - 78599 + - 78600 + - 78601 + - 78602 + - 78603 + - 78604 + - 78605 + - 78606 + - 78607 + - 78608 + - 78609 + - 78610 + - 78611 + - 78612 + - 78613 + - 78614 + - 78615 + - 78616 + - 78617 + - 78618 + - 78619 + - 78620 + - 78621 + - 78622 + - 78623 + - 78624 + - 78625 + - 78626 + - 78627 + - 78628 + - 78629 + - 78630 + - 78631 + - 78632 + - 78633 + - 78634 + - 78635 + - 78636 + - 78637 + - 78638 + - 78639 + - 78640 + - 78641 + - 78642 + - 78643 + - 78644 + - 78645 + - 78646 + - 78647 + - 78648 + - 78649 + - 78650 + - 78651 + - 78652 + - 78653 + - 78654 + - 78655 + - 78656 + - 78657 + - 78658 + - 78659 + - 78660 + - 78661 + - 78662 + - 78663 + - 78664 + - 78665 + - 78666 + - 78667 + - 78668 + - 78669 + - 78670 + - 78671 + - 78672 + - 78673 + - 78674 + - 78675 + - 78676 + - 78677 + - 78678 + - 78679 + - 78680 + - 78681 + - 78682 + - 78683 + - 78684 + - 78685 + - 78686 + - 78687 + - 78688 + - 78689 + - 78690 + - 78691 + - 78692 + - 78693 + - 78694 + - 78695 + - 78696 + - 78697 + - 78698 + - 78699 + - 78700 + - 78701 + - 78702 + - 78703 + - 78704 + - 78705 + - 78706 + - 78707 + - 78708 + - 78709 + - 78710 + - 78711 + - 78712 + - 78713 + - 78714 + - 78715 + - 78716 + - 78717 + - 78718 + - 78719 + - 78720 + - 78721 + - 78722 + - 78723 + - 78724 + - 78725 + - 78726 + - 78727 + - 78728 + - 78729 + - 78730 + - 78731 + - 78732 + - 78733 + - 78734 + - 78735 + - 78736 + - 78737 + - 78738 + - 78739 + - 78740 + - 78741 + - 78742 + - 78743 + - 78744 + - 78745 + - 78746 + - 78747 + - 78748 + - 78749 + - 78750 + - 78751 + - 78752 + - 78753 + - 78754 + - 78755 + - 78756 + - 78757 + - 78758 + - 78759 + - 78760 + - 78761 + - 78762 + - 78763 + - 78764 + - 78765 + - 78766 + - 78767 + - 78768 + - 78769 + - 78770 + - 78771 + - 78772 + - 78773 + - 78774 + - 78775 + - 78776 + - 78777 + - 78778 + - 78779 + - 78780 + - 78781 + - 78782 + - 78783 + - 78784 + - 78785 + - 78786 + - 78787 + - 78788 + - 78789 + - 78790 + - 78791 + - 78792 + - 78793 + - 78794 + - 78795 + - 78796 + - 78797 + - 78798 + - 78799 + - 78800 + - 78801 + - 78802 + - 78803 + - 78804 + - 78805 + - 78806 + - 78807 + - 78808 + - 78809 + - 78810 + - 78811 + - 78812 + - 78813 + - 78814 + - 78815 + - 78816 + - 78817 + - 78818 + - 78819 + - 78820 + - 78821 + - 78822 + - 78823 + - 78824 + - 78825 + - 78826 + - 78827 + - 78828 + - 78829 + - 78830 + - 78831 + - 78832 + - 78833 + - 78834 + - 78835 + - 78836 + - 78837 + - 78838 + - 78839 + - 78840 + - 78841 + - 78842 + - 78843 + - 78844 + - 78845 + - 78846 + - 78847 + - 78848 + - 78849 + - 78850 + - 78851 + - 78852 + - 78853 + - 78854 + - 78855 + - 78856 + - 78857 + - 78858 + - 78859 + - 78860 + - 78861 + - 78862 + - 78863 + - 78864 + - 78865 + - 78866 + - 78867 + - 78868 + - 78869 + - 78870 + - 78871 + - 78872 + - 78873 + - 78874 + - 78875 + - 78876 + - 78877 + - 78878 + - 78879 + - 78880 + - 78881 + - 78882 + - 78883 + - 78884 + - 78885 + - 78886 + - 78887 + - 78888 + - 78889 + - 78890 + - 78891 + - 78892 + - 78893 + - 78894 + - 78895 + - 78896 + - 78897 + - 78898 + - 78899 + - 78900 + - 78901 + - 78902 + - 78903 + - 78904 + - 78905 + - 78906 + - 78907 + - 78908 + - 78909 + - 78910 + - 78911 + - 78912 + - 78913 + - 78914 + - 78915 + - 78916 + - 78917 + - 78918 + - 78919 + - 78920 + - 78921 + - 78922 + - 78923 + - 78924 + - 78925 + - 78926 + - 78927 + - 78928 + - 78929 + - 78930 + - 78931 + - 78932 + - 78933 + - 78934 + - 78935 + - 78936 + - 78937 + - 78938 + - 78939 + - 78940 + - 78941 + - 78942 + - 78943 + - 78944 + - 78945 + - 78946 + - 78947 + - 78948 + - 78949 + - 78950 + - 78951 + - 78952 + - 78953 + - 78954 + - 78955 + - 78956 + - 78957 + - 78958 + - 78959 + - 78960 + - 78961 + - 78962 + - 78963 + - 78964 + - 78965 + - 78966 + - 78967 + - 78968 + - 78969 + - 78970 + - 78971 + - 78972 + - 78973 + - 78974 + - 78975 + - 78976 + - 78977 + - 78978 + - 78979 + - 78980 + - 78981 + - 78982 + - 78983 + - 78984 + - 78985 + - 78986 + - 78987 + - 78988 + - 78989 + - 78990 + - 78991 + - 78992 + - 78993 + - 78994 + - 78995 + - 78996 + - 78997 + - 78998 + - 78999 + - 79000 + - 79001 + - 79002 + - 79003 + - 79004 + - 79005 + - 79006 + - 79007 + - 79008 + - 79009 + - 79010 + - 79011 + - 79012 + - 79013 + - 79014 + - 79015 + - 79016 + - 79017 + - 79018 + - 79019 + - 79020 + - 79021 + - 79022 + - 79023 + - 79024 + - 79025 + - 79026 + - 79027 + - 79028 + - 79029 + - 79030 + - 79031 + - 79032 + - 79033 + - 79034 + - 79035 + - 79036 + - 79037 + - 79038 + - 79039 + - 79040 + - 79041 + - 79042 + - 79043 + - 79044 + - 79045 + - 79046 + - 79047 + - 79048 + - 79049 + - 79050 + - 79051 + - 79052 + - 79053 + - 79054 + - 79055 + - 79056 + - 79057 + - 79058 + - 79059 + - 79060 + - 79061 + - 79062 + - 79063 + - 79064 + - 79065 + - 79066 + - 79067 + - 79068 + - 79069 + - 79070 + - 79071 + - 79072 + - 79073 + - 79074 + - 79075 + - 79076 + - 79077 + - 79078 + - 79079 + - 79080 + - 79081 + - 79082 + - 79083 + - 79084 + - 79085 + - 79086 + - 79087 + - 79088 + - 79089 + - 79090 + - 79091 + - 79092 + - 79093 + - 79094 + - 79095 + - 79096 + - 79097 + - 79098 + - 79099 + - 79100 + - 79101 + - 79102 + - 79103 + - 79104 + - 79105 + - 79106 + - 79107 + - 79108 + - 79109 + - 79110 + - 79111 + - 79112 + - 79113 + - 79114 + - 79115 + - 79116 + - 79117 + - 79118 + - 79119 + - 79120 + - 79121 + - 79122 + - 79123 + - 79124 + - 79125 + - 79126 + - 79127 + - 79128 + - 79129 + - 79130 + - 79131 + - 79132 + - 79133 + - 79134 + - 79135 + - 79136 + - 79137 + - 79138 + - 79139 + - 79140 + - 79141 + - 79142 + - 79143 + - 79144 + - 79145 + - 79146 + - 79147 + - 79148 + - 79149 + - 79150 + - 79151 + - 79152 + - 79153 + - 79154 + - 79155 + - 79156 + - 79157 + - 79158 + - 79159 + - 79160 + - 79161 + - 79162 + - 79163 + - 79164 + - 79165 + - 79166 + - 79167 + - 79168 + - 79169 + - 79170 + - 79171 + - 79172 + - 79173 + - 79174 + - 79175 + - 79176 + - 79177 + - 79178 + - 79179 + - 79180 + - 79181 + - 79182 + - 79183 + - 79184 + - 79185 + - 79186 + - 79187 + - 79188 + - 79189 + - 79190 + - 79191 + - 79192 + - 79193 + - 79194 + - 79195 + - 79196 + - 79197 + - 79198 + - 79199 + - 79200 + - 79201 + - 79202 + - 79203 + - 79204 + - 79205 + - 79206 + - 79207 + - 79208 + - 79209 + - 79210 + - 79211 + - 79212 + - 79213 + - 79214 + - 79215 + - 79216 + - 79217 + - 79218 + - 79219 + - 79220 + - 79221 + - 79222 + - 79223 + - 79224 + - 79225 + - 79226 + - 79227 + - 79228 + - 79229 + - 79230 + - 79231 + - 79232 + - 79233 + - 79234 + - 79235 + - 79236 + - 79237 + - 79238 + - 79239 + - 79240 + - 79241 + - 79242 + - 79243 + - 79244 + - 79245 + - 79246 + - 79247 + - 79248 + - 79249 + - 79250 + - 79251 + - 79252 + - 79253 + - 79254 + - 79255 + - 79256 + - 79257 + - 79258 + - 79259 + - 79260 + - 79261 + - 79262 + - 79263 + - 79264 + - 79265 + - 79266 + - 79267 + - 79268 + - 79269 + - 79270 + - 79271 + - 79272 + - 79273 + - 79274 + - 79275 + - 79276 + - 79277 + - 79278 + - 79279 + - 79280 + - 79281 + - 79282 + - 79283 + - 79284 + - 79285 + - 79286 + - 79287 + - 79288 + - 79289 + - 79290 + - 79291 + - 79292 + - 79293 + - 79294 + - 79295 + - 79296 + - 79297 + - 79298 + - 79299 + - 79300 + - 79301 + - 79302 + - 79303 + - 79304 + - 79305 + - 79306 + - 79307 + - 79308 + - 79309 + - 79310 + - 79311 + - 79312 + - 79313 + - 79314 + - 79315 + - 79316 + - 79317 + - 79318 + - 79319 + - 79320 + - 79321 + - 79322 + - 79323 + - 79324 + - 79325 + - 79326 + - 79327 + - 79328 + - 79329 + - 79330 + - 79331 + - 79332 + - 79333 + - 79334 + - 79335 + - 79336 + - 79337 + - 79338 + - 79339 + - 79340 + - 79341 + - 79342 + - 79343 + - 79344 + - 79345 + - 79346 + - 79347 + - 79348 + - 79349 + - 79350 + - 79351 + - 79352 + - 79353 + - 79354 + - 79355 + - 79356 + - 79357 + - 79358 + - 79359 + - 79360 + - 79361 + - 79362 + - 79363 + - 79364 + - 79365 + - 79366 + - 79367 + - 79368 + - 79369 + - 79370 + - 79371 + - 79372 + - 79373 + - 79374 + - 79375 + - 79376 + - 79377 + - 79378 + - 79379 + - 79380 + - 79381 + - 79382 + - 79383 + - 79384 + - 79385 + - 79386 + - 79387 + - 79388 + - 79389 + - 79390 + - 79391 + - 79392 + - 79393 + - 79394 + - 79395 + - 79396 + - 79397 + - 79398 + - 79399 + - 79400 + - 79401 + - 79402 + - 79403 + - 79404 + - 79405 + - 79406 + - 79407 + - 79408 + - 79409 + - 79410 + - 79411 + - 79412 + - 79413 + - 79414 + - 79415 + - 79416 + - 79417 + - 79418 + - 79419 + - 79420 + - 79421 + - 79422 + - 79423 + - 79424 + - 79425 + - 79426 + - 79427 + - 79428 + - 79429 + - 79430 + - 79431 + - 79432 + - 79433 + - 79434 + - 79435 + - 79436 + - 79437 + - 79438 + - 79439 + - 79440 + - 79441 + - 79442 + - 79443 + - 79444 + - 79445 + - 79446 + - 79447 + - 79448 + - 79449 + - 79450 + - 79451 + - 79452 + - 79453 + - 79454 + - 79455 + - 79456 + - 79457 + - 79458 + - 79459 + - 79460 + - 79461 + - 79462 + - 79463 + - 79464 + - 79465 + - 79466 + - 79467 + - 79468 + - 79469 + - 79470 + - 79471 + - 79472 + - 79473 + - 79474 + - 79475 + - 79476 + - 79477 + - 79478 + - 79479 + - 79480 + - 79481 + - 79482 + - 79483 + - 79484 + - 79485 + - 79486 + - 79487 + - 79488 + - 79489 + - 79490 + - 79491 + - 79492 + - 79493 + - 79494 + - 79495 + - 79496 + - 79497 + - 79498 + - 79499 + - 79500 + - 79501 + - 79502 + - 79503 + - 79504 + - 79505 + - 79506 + - 79507 + - 79508 + - 79509 + - 79510 + - 79511 + - 79512 + - 79513 + - 79514 + - 79515 + - 79516 + - 79517 + - 79518 + - 79519 + - 79520 + - 79521 + - 79522 + - 79523 + - 79524 + - 79525 + - 79526 + - 79527 + - 79528 + - 79529 + - 79530 + - 79531 + - 79532 + - 79533 + - 79534 + - 79535 + - 79536 + - 79537 + - 79538 + - 79539 + - 79540 + - 79541 + - 79542 + - 79543 + - 79544 + - 79545 + - 79546 + - 79547 + - 79548 + - 79549 + - 79550 + - 79551 + - 79552 + - 79553 + - 79554 + - 79555 + - 79556 + - 79557 + - 79558 + - 79559 + - 79560 + - 79561 + - 79562 + - 79563 + - 79564 + - 79565 + - 79566 + - 79567 + - 79568 + - 79569 + - 79570 + - 79571 + - 79572 + - 79573 + - 79574 + - 79575 + - 79576 + - 79577 + - 79578 + - 79579 + - 79580 + - 79581 + - 79582 + - 79583 + - 79584 + - 79585 + - 79586 + - 79587 + - 79588 + - 79589 + - 79590 + - 79591 + - 79592 + - 79593 + - 79594 + - 79595 + - 79596 + - 79597 + - 79598 + - 79599 + - 79600 + - 79601 + - 79602 + - 79603 + - 79604 + - 79605 + - 79606 + - 79607 + - 79608 + - 79609 + - 79610 + - 79611 + - 79612 + - 79613 + - 79614 + - 79615 + - 79616 + - 79617 + - 79618 + - 79619 + - 79620 + - 79621 + - 79622 + - 79623 + - 79624 + - 79625 + - 79626 + - 79627 + - 79628 + - 79629 + - 79630 + - 79631 + - 79632 + - 79633 + - 79634 + - 79635 + - 79636 + - 79637 + - 79638 + - 79639 + - 79640 + - 79641 + - 79642 + - 79643 + - 79644 + - 79645 + - 79646 + - 79647 + - 79648 + - 79649 + - 79650 + - 79651 + - 79652 + - 79653 + - 79654 + - 79655 + - 79656 + - 79657 + - 79658 + - 79659 + - 79660 + - 79661 + - 79662 + - 79663 + - 79664 + - 79665 + - 79666 + - 79667 + - 79668 + - 79669 + - 79670 + - 79671 + - 79672 + - 79673 + - 79674 + - 79675 + - 79676 + - 79677 + - 79678 + - 79679 + - 79680 + - 79681 + - 79682 + - 79683 + - 79684 + - 79685 + - 79686 + - 79687 + - 79688 + - 79689 + - 79690 + - 79691 + - 79692 + - 79693 + - 79694 + - 79695 + - 79696 + - 79697 + - 79698 + - 79699 + - 79700 + - 79701 + - 79702 + - 79703 + - 79704 + - 79705 + - 79706 + - 79707 + - 79708 + - 79709 + - 79710 + - 79711 + - 79712 + - 79713 + - 79714 + - 79715 + - 79716 + - 79717 + - 79718 + - 79719 + - 79720 + - 79721 + - 79722 + - 79723 + - 79724 + - 79725 + - 79726 + - 79727 + - 79728 + - 79729 + - 79730 + - 79731 + - 79732 + - 79733 + - 79734 + - 79735 + - 79736 + - 79737 + - 79738 + - 79739 + - 79740 + - 79741 + - 79742 + - 79743 + - 79744 + - 79745 + - 79746 + - 79747 + - 79748 + - 79749 + - 79750 + - 79751 + - 79752 + - 79753 + - 79754 + - 79755 + - 79756 + - 79757 + - 79758 + - 79759 + - 79760 + - 79761 + - 79762 + - 79763 + - 79764 + - 79765 + - 79766 + - 79767 + - 79768 + - 79769 + - 79770 + - 79771 + - 79772 + - 79773 + - 79774 + - 79775 + - 79776 + - 79777 + - 79778 + - 79779 + - 79780 + - 79781 + - 79782 + - 79783 + - 79784 + - 79785 + - 79786 + - 79787 + - 79788 + - 79789 + - 79790 + - 79791 + - 79792 + - 79793 + - 79794 + - 79795 + - 79796 + - 79797 + - 79798 + - 79799 + - 79800 + - 79801 + - 79802 + - 79803 + - 79804 + - 79805 + - 79806 + - 79807 + - 79808 + - 79809 + - 79810 + - 79811 + - 79812 + - 79813 + - 79814 + - 79815 + - 79816 + - 79817 + - 79818 + - 79819 + - 79820 + - 79821 + - 79822 + - 79823 + - 79824 + - 79825 + - 79826 + - 79827 + - 79828 + - 79829 + - 79830 + - 79831 + - 79832 + - 79833 + - 79834 + - 79835 + - 79836 + - 79837 + - 79838 + - 79839 + - 79840 + - 79841 + - 79842 + - 79843 + - 79844 + - 79845 + - 79846 + - 79847 + - 79848 + - 79849 + - 79850 + - 79851 + - 79852 + - 79853 + - 79854 + - 79855 + - 79856 + - 79857 + - 79858 + - 79859 + - 79860 + - 79861 + - 79862 + - 79863 + - 79864 + - 79865 + - 79866 + - 79867 + - 79868 + - 79869 + - 79870 + - 79871 + - 79872 + - 79873 + - 79874 + - 79875 + - 79876 + - 79877 + - 79878 + - 79879 + - 79880 + - 79881 + - 79882 + - 79883 + - 79884 + - 79885 + - 79886 + - 79887 + - 79888 + - 79889 + - 79890 + - 79891 + - 79892 + - 79893 + - 79894 + - 79895 + - 79896 + - 79897 + - 79898 + - 79899 + - 79900 + - 79901 + - 79902 + - 79903 + - 79904 + - 79905 + - 79906 + - 79907 + - 79908 + - 79909 + - 79910 + - 79911 + - 79912 + - 79913 + - 79914 + - 79915 + - 79916 + - 79917 + - 79918 + - 79919 + - 79920 + - 79921 + - 79922 + - 79923 + - 79924 + - 79925 + - 79926 + - 79927 + - 79928 + - 79929 + - 79930 + - 79931 + - 79932 + - 79933 + - 79934 + - 79935 + - 79936 + - 79937 + - 79938 + - 79939 + - 79940 + - 79941 + - 79942 + - 79943 + - 79944 + - 79945 + - 79946 + - 79947 + - 79948 + - 79949 + - 79950 + - 79951 + - 79952 + - 79953 + - 79954 + - 79955 + - 79956 + - 79957 + - 79958 + - 79959 + - 79960 + - 79961 + - 79962 + - 79963 + - 79964 + - 79965 + - 79966 + - 79967 + - 79968 + - 79969 + - 79970 + - 79971 + - 79972 + - 79973 + - 79974 + - 79975 + - 79976 + - 79977 + - 79978 + - 79979 + - 79980 + - 79981 + - 79982 + - 79983 + - 79984 + - 79985 + - 79986 + - 79987 + - 79988 + - 79989 + - 79990 + - 79991 + - 79992 + - 79993 + - 79994 + - 79995 + - 79996 + - 79997 + - 79998 + - 79999 + - 80000 + - 80001 + - 80002 + - 80003 + - 80004 + - 80005 + - 80006 + - 80007 + - 80008 + - 80009 + - 80010 + - 80011 + - 80012 + - 80013 + - 80014 + - 80015 + - 80016 + - 80017 + - 80018 + - 80019 + - 80020 + - 80021 + - 80022 + - 80023 + - 80024 + - 80025 + - 80026 + - 80027 + - 80028 + - 80029 + - 80030 + - 80031 + - 80032 + - 80033 + - 80034 + - 80035 + - 80036 + - 80037 + - 80038 + - 80039 + - 80040 + - 80041 + - 80042 + - 80043 + - 80044 + - 80045 + - 80046 + - 80047 + - 80048 + - 80049 + - 80050 + - 80051 + - 80052 + - 80053 + - 80054 + - 80055 + - 80056 + - 80057 + - 80058 + - 80059 + - 80060 + - 80061 + - 80062 + - 80063 + - 80064 + - 80065 + - 80066 + - 80067 + - 80068 + - 80069 + - 80070 + - 80071 + - 80072 + - 80073 + - 80074 + - 80075 + - 80076 + - 80077 + - 80078 + - 80079 + - 80080 + - 80081 + - 80082 + - 80083 + - 80084 + - 80085 + - 80086 + - 80087 + - 80088 + - 80089 + - 80090 + - 80091 + - 80092 + - 80093 + - 80094 + - 80095 + - 80096 + - 80097 + - 80098 + - 80099 + - 80100 + - 80101 + - 80102 + - 80103 + - 80104 + - 80105 + - 80106 + - 80107 + - 80108 + - 80109 + - 80110 + - 80111 + - 80112 + - 80113 + - 80114 + - 80115 + - 80116 + - 80117 + - 80118 + - 80119 + - 80120 + - 80121 + - 80122 + - 80123 + - 80124 + - 80125 + - 80126 + - 80127 + - 80128 + - 80129 + - 80130 + - 80131 + - 80132 + - 80133 + - 80134 + - 80135 + - 80136 + - 80137 + - 80138 + - 80139 + - 80140 + - 80141 + - 80142 + - 80143 + - 80144 + - 80145 + - 80146 + - 80147 + - 80148 + - 80149 + - 80150 + - 80151 + - 80152 + - 80153 + - 80154 + - 80155 + - 80156 + - 80157 + - 80158 + - 80159 + - 80160 + - 80161 + - 80162 + - 80163 + - 80164 + - 80165 + - 80166 + - 80167 + - 80168 + - 80169 + - 80170 + - 80171 + - 80172 + - 80173 + - 80174 + - 80175 + - 80176 + - 80177 + - 80178 + - 80179 + - 80180 + - 80181 + - 80182 + - 80183 + - 80184 + - 80185 + - 80186 + - 80187 + - 80188 + - 80189 + - 80190 + - 80191 + - 80192 + - 80193 + - 80194 + - 80195 + - 80196 + - 80197 + - 80198 + - 80199 + - 80200 + - 80201 + - 80202 + - 80203 + - 80204 + - 80205 + - 80206 + - 80207 + - 80208 + - 80209 + - 80210 + - 80211 + - 80212 + - 80213 + - 80214 + - 80215 + - 80216 + - 80217 + - 80218 + - 80219 + - 80220 + - 80221 + - 80222 + - 80223 + - 80224 + - 80225 + - 80226 + - 80227 + - 80228 + - 80229 + - 80230 + - 80231 + - 80232 + - 80233 + - 80234 + - 80235 + - 80236 + - 80237 + - 80238 + - 80239 + - 80240 + - 80241 + - 80242 + - 80243 + - 80244 + - 80245 + - 80246 + - 80247 + - 80248 + - 80249 + - 80250 + - 80251 + - 80252 + - 80253 + - 80254 + - 80255 + - 80256 + - 80257 + - 80258 + - 80259 + - 80260 + - 80261 + - 80262 + - 80263 + - 80264 + - 80265 + - 80266 + - 80267 + - 80268 + - 80269 + - 80270 + - 80271 + - 80272 + - 80273 + - 80274 + - 80275 + - 80276 + - 80277 + - 80278 + - 80279 + - 80280 + - 80281 + - 80282 + - 80283 + - 80284 + - 80285 + - 80286 + - 80287 + - 80288 + - 80289 + - 80290 + - 80291 + - 80292 + - 80293 + - 80294 + - 80295 + - 80296 + - 80297 + - 80298 + - 80299 + - 80300 + - 80301 + - 80302 + - 80303 + - 80304 + - 80305 + - 80306 + - 80307 + - 80308 + - 80309 + - 80310 + - 80311 + - 80312 + - 80313 + - 80314 + - 80315 + - 80316 + - 80317 + - 80318 + - 80319 + - 80320 + - 80321 + - 80322 + - 80323 + - 80324 + - 80325 + - 80326 + - 80327 + - 80328 + - 80329 + - 80330 + - 80331 + - 80332 + - 80333 + - 80334 + - 80335 + - 80336 + - 80337 + - 80338 + - 80339 + - 80340 + - 80341 + - 80342 + - 80343 + - 80344 + - 80345 + - 80346 + - 80347 + - 80348 + - 80349 + - 80350 + - 80351 + - 80352 + - 80353 + - 80354 + - 80355 + - 80356 + - 80357 + - 80358 + - 80359 + - 80360 + - 80361 + - 80362 + - 80363 + - 80364 + - 80365 + - 80366 + - 80367 + - 80368 + - 80369 + - 80370 + - 80371 + - 80372 + - 80373 + - 80374 + - 80375 + - 80376 + - 80377 + - 80378 + - 80379 + - 80380 + - 80381 + - 80382 + - 80383 + - 80384 + - 80385 + - 80386 + - 80387 + - 80388 + - 80389 + - 80390 + - 80391 + - 80392 + - 80393 + - 80394 + - 80395 + - 80396 + - 80397 + - 80398 + - 80399 + - 80400 + - 80401 + - 80402 + - 80403 + - 80404 + - 80405 + - 80406 + - 80407 + - 80408 + - 80409 + - 80410 + - 80411 + - 80412 + - 80413 + - 80414 + - 80415 + - 80416 + - 80417 + - 80418 + - 80419 + - 80420 + - 80421 + - 80422 + - 80423 + - 80424 + - 80425 + - 80426 + - 80427 + - 80428 + - 80429 + - 80430 + - 80431 + - 80432 + - 80433 + - 80434 + - 80435 + - 80436 + - 80437 + - 80438 + - 80439 + - 80440 + - 80441 + - 80442 + - 80443 + - 80444 + - 80445 + - 80446 + - 80447 + - 80448 + - 80449 + - 80450 + - 80451 + - 80452 + - 80453 + - 80454 + - 80455 + - 80456 + - 80457 + - 80458 + - 80459 + - 80460 + - 80461 + - 80462 + - 80463 + - 80464 + - 80465 + - 80466 + - 80467 + - 80468 + - 80469 + - 80470 + - 80471 + - 80472 + - 80473 + - 80474 + - 80475 + - 80476 + - 80477 + - 80478 + - 80479 + - 80480 + - 80481 + - 80482 + - 80483 + - 80484 + - 80485 + - 80486 + - 80487 + - 80488 + - 80489 + - 80490 + - 80491 + - 80492 + - 80493 + - 80494 + - 80495 + - 80496 + - 80497 + - 80498 + - 80499 + - 80500 + - 80501 + - 80502 + - 80503 + - 80504 + - 80505 + - 80506 + - 80507 + - 80508 + - 80509 + - 80510 + - 80511 + - 80512 + - 80513 + - 80514 + - 80515 + - 80516 + - 80517 + - 80518 + - 80519 + - 80520 + - 80521 + - 80522 + - 80523 + - 80524 + - 80525 + - 80526 + - 80527 + - 80528 + - 80529 + - 80530 + - 80531 + - 80532 + - 80533 + - 80534 + - 80535 + - 80536 + - 80537 + - 80538 + - 80539 + - 80540 + - 80541 + - 80542 + - 80543 + - 80544 + - 80545 + - 80546 + - 80547 + - 80548 + - 80549 + - 80550 + - 80551 + - 80552 + - 80553 + - 80554 + - 80555 + - 80556 + - 80557 + - 80558 + - 80559 + - 80560 + - 80561 + - 80562 + - 80563 + - 80564 + - 80565 + - 80566 + - 80567 + - 80568 + - 80569 + - 80570 + - 80571 + - 80572 + - 80573 + - 80574 + - 80575 + - 80576 + - 80577 + - 80578 + - 80579 + - 80580 + - 80581 + - 80582 + - 80583 + - 80584 + - 80585 + - 80586 + - 80587 + - 80588 + - 80589 + - 80590 + - 80591 + - 80592 + - 80593 + - 80594 + - 80595 + - 80596 + - 80597 + - 80598 + - 80599 + - 80600 + - 80601 + - 80602 + - 80603 + - 80604 + - 80605 + - 80606 + - 80607 + - 80608 + - 80609 + - 80610 + - 80611 + - 80612 + - 80613 + - 80614 + - 80615 + - 80616 + - 80617 + - 80618 + - 80619 + - 80620 + - 80621 + - 80622 + - 80623 + - 80624 + - 80625 + - 80626 + - 80627 + - 80628 + - 80629 + - 80630 + - 80631 + - 80632 + - 80633 + - 80634 + - 80635 + - 80636 + - 80637 + - 80638 + - 80639 + - 80640 + - 80641 + - 80642 + - 80643 + - 80644 + - 80645 + - 80646 + - 80647 + - 80648 + - 80649 + - 80650 + - 80651 + - 80652 + - 80653 + - 80654 + - 80655 + - 80656 + - 80657 + - 80658 + - 80659 + - 80660 + - 80661 + - 80662 + - 80663 + - 80664 + - 80665 + - 80666 + - 80667 + - 80668 + - 80669 + - 80670 + - 80671 + - 80672 + - 80673 + - 80674 + - 80675 + - 80676 + - 80677 + - 80678 + - 80679 + - 80680 + - 80681 + - 80682 + - 80683 + - 80684 + - 80685 + - 80686 + - 80687 + - 80688 + - 80689 + - 80690 + - 80691 + - 80692 + - 80693 + - 80694 + - 80695 + - 80696 + - 80697 + - 80698 + - 80699 + - 80700 + - 80701 + - 80702 + - 80703 + - 80704 + - 80705 + - 80706 + - 80707 + - 80708 + - 80709 + - 80710 + - 80711 + - 80712 + - 80713 + - 80714 + - 80715 + - 80716 + - 80717 + - 80718 + - 80719 + - 80720 + - 80721 + - 80722 + - 80723 + - 80724 + - 80725 + - 80726 + - 80727 + - 80728 + - 80729 + - 80730 + - 80731 + - 80732 + - 80733 + - 80734 + - 80735 + - 80736 + - 80737 + - 80738 + - 80739 + - 80740 + - 80741 + - 80742 + - 80743 + - 80744 + - 80745 + - 80746 + - 80747 + - 80748 + - 80749 + - 80750 + - 80751 + - 80752 + - 80753 + - 80754 + - 80755 + - 80756 + - 80757 + - 80758 + - 80759 + - 80760 + - 80761 + - 80762 + - 80763 + - 80764 + - 80765 + - 80766 + - 80767 + - 80768 + - 80769 + - 80770 + - 80771 + - 80772 + - 80773 + - 80774 + - 80775 + - 80776 + - 80777 + - 80778 + - 80779 + - 80780 + - 80781 + - 80782 + - 80783 + - 80784 + - 80785 + - 80786 + - 80787 + - 80788 + - 80789 + - 80790 + - 80791 + - 80792 + - 80793 + - 80794 + - 80795 + - 80796 + - 80797 + - 80798 + - 80799 + - 80800 + - 80801 + - 80802 + - 80803 + - 80804 + - 80805 + - 80806 + - 80807 + - 80808 + - 80809 + - 80810 + - 80811 + - 80812 + - 80813 + - 80814 + - 80815 + - 80816 + - 80817 + - 80818 + - 80819 + - 80820 + - 80821 + - 80822 + - 80823 + - 80824 + - 80825 + - 80826 + - 80827 + - 80828 + - 80829 + - 80830 + - 80831 + - 80832 + - 80833 + - 80834 + - 80835 + - 80836 + - 80837 + - 80838 + - 80839 + - 80840 + - 80841 + - 80842 + - 80843 + - 80844 + - 80845 + - 80846 + - 80847 + - 80848 + - 80849 + - 80850 + - 80851 + - 80852 + - 80853 + - 80854 + - 80855 + - 80856 + - 80857 + - 80858 + - 80859 + - 80860 + - 80861 + - 80862 + - 80863 + - 80864 + - 80865 + - 80866 + - 80867 + - 80868 + - 80869 + - 80870 + - 80871 + - 80872 + - 80873 + - 80874 + - 80875 + - 80876 + - 80877 + - 80878 + - 80879 + - 80880 + - 80881 + - 80882 + - 80883 + - 80884 + - 80885 + - 80886 + - 80887 + - 80888 + - 80889 + - 80890 + - 80891 + - 80892 + - 80893 + - 80894 + - 80895 + - 80896 + - 80897 + - 80898 + - 80899 + - 80900 + - 80901 + - 80902 + - 80903 + - 80904 + - 80905 + - 80906 + - 80907 + - 80908 + - 80909 + - 80910 + - 80911 + - 80912 + - 80913 + - 80914 + - 80915 + - 80916 + - 80917 + - 80918 + - 80919 + - 80920 + - 80921 + - 80922 + - 80923 + - 80924 + - 80925 + - 80926 + - 80927 + - 80928 + - 80929 + - 80930 + - 80931 + - 80932 + - 80933 + - 80934 + - 80935 + - 80936 + - 80937 + - 80938 + - 80939 + - 80940 + - 80941 + - 80942 + - 80943 + - 80944 + - 80945 + - 80946 + - 80947 + - 80948 + - 80949 + - 80950 + - 80951 + - 80952 + - 80953 + - 80954 + - 80955 + - 80956 + - 80957 + - 80958 + - 80959 + - 80960 + - 80961 + - 80962 + - 80963 + - 80964 + - 80965 + - 80966 + - 80967 + - 80968 + - 80969 + - 80970 + - 80971 + - 80972 + - 80973 + - 80974 + - 80975 + - 80976 + - 80977 + - 80978 + - 80979 + - 80980 + - 80981 + - 80982 + - 80983 + - 80984 + - 80985 + - 80986 + - 80987 + - 80988 + - 80989 + - 80990 + - 80991 + - 80992 + - 80993 + - 80994 + - 80995 + - 80996 + - 80997 + - 80998 + - 80999 + - 81000 + - 81001 + - 81002 + - 81003 + - 81004 + - 81005 + - 81006 + - 81007 + - 81008 + - 81009 + - 81010 + - 81011 + - 81012 + - 81013 + - 81014 + - 81015 + - 81016 + - 81017 + - 81018 + - 81019 + - 81020 + - 81021 + - 81022 + - 81023 + - 81024 + - 81025 + - 81026 + - 81027 + - 81028 + - 81029 + - 81030 + - 81031 + - 81032 + - 81033 + - 81034 + - 81035 + - 81036 + - 81037 + - 81038 + - 81039 + - 81040 + - 81041 + - 81042 + - 81043 + - 81044 + - 81045 + - 81046 + - 81047 + - 81048 + - 81049 + - 81050 + - 81051 + - 81052 + - 81053 + - 81054 + - 81055 + - 81056 + - 81057 + - 81058 + - 81059 + - 81060 + - 81061 + - 81062 + - 81063 + - 81064 + - 81065 + - 81066 + - 81067 + - 81068 + - 81069 + - 81070 + - 81071 + - 81072 + - 81073 + - 81074 + - 81075 + - 81076 + - 81077 + - 81078 + - 81079 + - 81080 + - 81081 + - 81082 + - 81083 + - 81084 + - 81085 + - 81086 + - 81087 + - 81088 + - 81089 + - 81090 + - 81091 + - 81092 + - 81093 + - 81094 + - 81095 + - 81096 + - 81097 + - 81098 + - 81099 + - 81100 + - 81101 + - 81102 + - 81103 + - 81104 + - 81105 + - 81106 + - 81107 + - 81108 + - 81109 + - 81110 + - 81111 + - 81112 + - 81113 + - 81114 + - 81115 + - 81116 + - 81117 + - 81118 + - 81119 + - 81120 + - 81121 + - 81122 + - 81123 + - 81124 + - 81125 + - 81126 + - 81127 + - 81128 + - 81129 + - 81130 + - 81131 + - 81132 + - 81133 + - 81134 + - 81135 + - 81136 + - 81137 + - 81138 + - 81139 + - 81140 + - 81141 + - 81142 + - 81143 + - 81144 + - 81145 + - 81146 + - 81147 + - 81148 + - 81149 + - 81150 + - 81151 + - 81152 + - 81153 + - 81154 + - 81155 + - 81156 + - 81157 + - 81158 + - 81159 + - 81160 + - 81161 + - 81162 + - 81163 + - 81164 + - 81165 + - 81166 + - 81167 + - 81168 + - 81169 + - 81170 + - 81171 + - 81172 + - 81173 + - 81174 + - 81175 + - 81176 + - 81177 + - 81178 + - 81179 + - 81180 + - 81181 + - 81182 + - 81183 + - 81184 + - 81185 + - 81186 + - 81187 + - 81188 + - 81189 + - 81190 + - 81191 + - 81192 + - 81193 + - 81194 + - 81195 + - 81196 + - 81197 + - 81198 + - 81199 + - 81200 + - 81201 + - 81202 + - 81203 + - 81204 + - 81205 + - 81206 + - 81207 + - 81208 + - 81209 + - 81210 + - 81211 + - 81212 + - 81213 + - 81214 + - 81215 + - 81216 + - 81217 + - 81218 + - 81219 + - 81220 + - 81221 + - 81222 + - 81223 + - 81224 + - 81225 + - 81226 + - 81227 + - 81228 + - 81229 + - 81230 + - 81231 + - 81232 + - 81233 + - 81234 + - 81235 + - 81236 + - 81237 + - 81238 + - 81239 + - 81240 + - 81241 + - 81242 + - 81243 + - 81244 + - 81245 + - 81246 + - 81247 + - 81248 + - 81249 + - 81250 + - 81251 + - 81252 + - 81253 + - 81254 + - 81255 + - 81256 + - 81257 + - 81258 + - 81259 + - 81260 + - 81261 + - 81262 + - 81263 + - 81264 + - 81265 + - 81266 + - 81267 + - 81268 + - 81269 + - 81270 + - 81271 + - 81272 + - 81273 + - 81274 + - 81275 + - 81276 + - 81277 + - 81278 + - 81279 + - 81280 + - 81281 + - 81282 + - 81283 + - 81284 + - 81285 + - 81286 + - 81287 + - 81288 + - 81289 + - 81290 + - 81291 + - 81292 + - 81293 + - 81294 + - 81295 + - 81296 + - 81297 + - 81298 + - 81299 + - 81300 + - 81301 + - 81302 + - 81303 + - 81304 + - 81305 + - 81306 + - 81307 + - 81308 + - 81309 + - 81310 + - 81311 + - 81312 + - 81313 + - 81314 + - 81315 + - 81316 + - 81317 + - 81318 + - 81319 + - 81320 + - 81321 + - 81322 + - 81323 + - 81324 + - 81325 + - 81326 + - 81327 + - 81328 + - 81329 + - 81330 + - 81331 + - 81332 + - 81333 + - 81334 + - 81335 + - 81336 + - 81337 + - 81338 + - 81339 + - 81340 + - 81341 + - 81342 + - 81343 + - 81344 + - 81345 + - 81346 + - 81347 + - 81348 + - 81349 + - 81350 + - 81351 + - 81352 + - 81353 + - 81354 + - 81355 + - 81356 + - 81357 + - 81358 + - 81359 + - 81360 + - 81361 + - 81362 + - 81363 + - 81364 + - 81365 + - 81366 + - 81367 + - 81368 + - 81369 + - 81370 + - 81371 + - 81372 + - 81373 + - 81374 + - 81375 + - 81376 + - 81377 + - 81378 + - 81379 + - 81380 + - 81381 + - 81382 + - 81383 + - 81384 + - 81385 + - 81386 + - 81387 + - 81388 + - 81389 + - 81390 + - 81391 + - 81392 + - 81393 + - 81394 + - 81395 + - 81396 + - 81397 + - 81398 + - 81399 + - 81400 + - 81401 + - 81402 + - 81403 + - 81404 + - 81405 + - 81406 + - 81407 + - 81408 + - 81409 + - 81410 + - 81411 + - 81412 + - 81413 + - 81414 + - 81415 + - 81416 + - 81417 + - 81418 + - 81419 + - 81420 + - 81421 + - 81422 + - 81423 + - 81424 + - 81425 + - 81426 + - 81427 + - 81428 + - 81429 + - 81430 + - 81431 + - 81432 + - 81433 + - 81434 + - 81435 + - 81436 + - 81437 + - 81438 + - 81439 + - 81440 + - 81441 + - 81442 + - 81443 + - 81444 + - 81445 + - 81446 + - 81447 + - 81448 + - 81449 + - 81450 + - 81451 + - 81452 + - 81453 + - 81454 + - 81455 + - 81456 + - 81457 + - 81458 + - 81459 + - 81460 + - 81461 + - 81462 + - 81463 + - 81464 + - 81465 + - 81466 + - 81467 + - 81468 + - 81469 + - 81470 + - 81471 + - 81472 + - 81473 + - 81474 + - 81475 + - 81476 + - 81477 + - 81478 + - 81479 + - 81480 + - 81481 + - 81482 + - 81483 + - 81484 + - 81485 + - 81486 + - 81487 + - 81488 + - 81489 + - 81490 + - 81491 + - 81492 + - 81493 + - 81494 + - 81495 + - 81496 + - 81497 + - 81498 + - 81499 + - 81500 + - 81501 + - 81502 + - 81503 + - 81504 + - 81505 + - 81506 + - 81507 + - 81508 + - 81509 + - 81510 + - 81511 + - 81512 + - 81513 + - 81514 + - 81515 + - 81516 + - 81517 + - 81518 + - 81519 + - 81520 + - 81521 + - 81522 + - 81523 + - 81524 + - 81525 + - 81526 + - 81527 + - 81528 + - 81529 + - 81530 + - 81531 + - 81532 + - 81533 + - 81534 + - 81535 + - 81536 + - 81537 + - 81538 + - 81539 + - 81540 + - 81541 + - 81542 + - 81543 + - 81544 + - 81545 + - 81546 + - 81547 + - 81548 + - 81549 + - 81550 + - 81551 + - 81552 + - 81553 + - 81554 + - 81555 + - 81556 + - 81557 + - 81558 + - 81559 + - 81560 + - 81561 + - 81562 + - 81563 + - 81564 + - 81565 + - 81566 + - 81567 + - 81568 + - 81569 + - 81570 + - 81571 + - 81572 + - 81573 + - 81574 + - 81575 + - 81576 + - 81577 + - 81578 + - 81579 + - 81580 + - 81581 + - 81582 + - 81583 + - 81584 + - 81585 + - 81586 + - 81587 + - 81588 + - 81589 + - 81590 + - 81591 + - 81592 + - 81593 + - 81594 + - 81595 + - 81596 + - 81597 + - 81598 + - 81599 + - 81600 + - 81601 + - 81602 + - 81603 + - 81604 + - 81605 + - 81606 + - 81607 + - 81608 + - 81609 + - 81610 + - 81611 + - 81612 + - 81613 + - 81614 + - 81615 + - 81616 + - 81617 + - 81618 + - 81619 + - 81620 + - 81621 + - 81622 + - 81623 + - 81624 + - 81625 + - 81626 + - 81627 + - 81628 + - 81629 + - 81630 + - 81631 + - 81632 + - 81633 + - 81634 + - 81635 + - 81636 + - 81637 + - 81638 + - 81639 + - 81640 + - 81641 + - 81642 + - 81643 + - 81644 + - 81645 + - 81646 + - 81647 + - 81648 + - 81649 + - 81650 + - 81651 + - 81652 + - 81653 + - 81654 + - 81655 + - 81656 + - 81657 + - 81658 + - 81659 + - 81660 + - 81661 + - 81662 + - 81663 + - 81664 + - 81665 + - 81666 + - 81667 + - 81668 + - 81669 + - 81670 + - 81671 + - 81672 + - 81673 + - 81674 + - 81675 + - 81676 + - 81677 + - 81678 + - 81679 + - 81680 + - 81681 + - 81682 + - 81683 + - 81684 + - 81685 + - 81686 + - 81687 + - 81688 + - 81689 + - 81690 + - 81691 + - 81692 + - 81693 + - 81694 + - 81695 + - 81696 + - 81697 + - 81698 + - 81699 + - 81700 + - 81701 + - 81702 + - 81703 + - 81704 + - 81705 + - 81706 + - 81707 + - 81708 + - 81709 + - 81710 + - 81711 + - 81712 + - 81713 + - 81714 + - 81715 + - 81716 + - 81717 + - 81718 + - 81719 + - 81720 + - 81721 + - 81722 + - 81723 + - 81724 + - 81725 + - 81726 + - 81727 + - 81728 + - 81729 + - 81730 + - 81731 + - 81732 + - 81733 + - 81734 + - 81735 + - 81736 + - 81737 + - 81738 + - 81739 + - 81740 + - 81741 + - 81742 + - 81743 + - 81744 + - 81745 + - 81746 + - 81747 + - 81748 + - 81749 + - 81750 + - 81751 + - 81752 + - 81753 + - 81754 + - 81755 + - 81756 + - 81757 + - 81758 + - 81759 + - 81760 + - 81761 + - 81762 + - 81763 + - 81764 + - 81765 + - 81766 + - 81767 + - 81768 + - 81769 + - 81770 + - 81771 + - 81772 + - 81773 + - 81774 + - 81775 + - 81776 + - 81777 + - 81778 + - 81779 + - 81780 + - 81781 + - 81782 + - 81783 + - 81784 + - 81785 + - 81786 + - 81787 + - 81788 + - 81789 + - 81790 + - 81791 + - 81792 + - 81793 + - 81794 + - 81795 + - 81796 + - 81797 + - 81798 + - 81799 + - 81800 + - 81801 + - 81802 + - 81803 + - 81804 + - 81805 + - 81806 + - 81807 + - 81808 + - 81809 + - 81810 + - 81811 + - 81812 + - 81813 + - 81814 + - 81815 + - 81816 + - 81817 + - 81818 + - 81819 + - 81820 + - 81821 + - 81822 + - 81823 + - 81824 + - 81825 + - 81826 + - 81827 + - 81828 + - 81829 + - 81830 + - 81831 + - 81832 + - 81833 + - 81834 + - 81835 + - 81836 + - 81837 + - 81838 + - 81839 + - 81840 + - 81841 + - 81842 + - 81843 + - 81844 + - 81845 + - 81846 + - 81847 + - 81848 + - 81849 + - 81850 + - 81851 + - 81852 + - 81853 + - 81854 + - 81855 + - 81856 + - 81857 + - 81858 + - 81859 + - 81860 + - 81861 + - 81862 + - 81863 + - 81864 + - 81865 + - 81866 + - 81867 + - 81868 + - 81869 + - 81870 + - 81871 + - 81872 + - 81873 + - 81874 + - 81875 + - 81876 + - 81877 + - 81878 + - 81879 + - 81880 + - 81881 + - 81882 + - 81883 + - 81884 + - 81885 + - 81886 + - 81887 + - 81888 + - 81889 + - 81890 + - 81891 + - 81892 + - 81893 + - 81894 + - 81895 + - 81896 + - 81897 + - 81898 + - 81899 + - 81900 + - 81901 + - 81902 + - 81903 + - 81904 + - 81905 + - 81906 + - 81907 + - 81908 + - 81909 + - 81910 + - 81911 + - 81912 + - 81913 + - 81914 + - 81915 + - 81916 + - 81917 + - 81918 + - 81919 + - 81920 + - 81921 + - 81922 + - 81923 + - 81924 + - 81925 + - 81926 + - 81927 + - 81928 + - 81929 + - 81930 + - 81931 + - 81932 + - 81933 + - 81934 + - 81935 + - 81936 + - 81937 + - 81938 + - 81939 + - 81940 + - 81941 + - 81942 + - 81943 + - 81944 + - 81945 + - 81946 + - 81947 + - 81948 + - 81949 + - 81950 + - 81951 + - 81952 + - 81953 + - 81954 + - 81955 + - 81956 + - 81957 + - 81958 + - 81959 + - 81960 + - 81961 + - 81962 + - 81963 + - 81964 + - 81965 + - 81966 + - 81967 + - 81968 + - 81969 + - 81970 + - 81971 + - 81972 + - 81973 + - 81974 + - 81975 + - 81976 + - 81977 + - 81978 + - 81979 + - 81980 + - 81981 + - 81982 + - 81983 + - 81984 + - 81985 + - 81986 + - 81987 + - 81988 + - 81989 + - 81990 + - 81991 + - 81992 + - 81993 + - 81994 + - 81995 + - 81996 + - 81997 + - 81998 + - 81999 + - 82000 + - 82001 + - 82002 + - 82003 + - 82004 + - 82005 + - 82006 + - 82007 + - 82008 + - 82009 + - 82010 + - 82011 + - 82012 + - 82013 + - 82014 + - 82015 + - 82016 + - 82017 + - 82018 + - 82019 + - 82020 + - 82021 + - 82022 + - 82023 + - 82024 + - 82025 + - 82026 + - 82027 + - 82028 + - 82029 + - 82030 + - 82031 + - 82032 + - 82033 + - 82034 + - 82035 + - 82036 + - 82037 + - 82038 + - 82039 + - 82040 + - 82041 + - 82042 + - 82043 + - 82044 + - 82045 + - 82046 + - 82047 + - 82048 + - 82049 + - 82050 + - 82051 + - 82052 + - 82053 + - 82054 + - 82055 + - 82056 + - 82057 + - 82058 + - 82059 + - 82060 + - 82061 + - 82062 + - 82063 + - 82064 + - 82065 + - 82066 + - 82067 + - 82068 + - 82069 + - 82070 + - 82071 + - 82072 + - 82073 + - 82074 + - 82075 + - 82076 + - 82077 + - 82078 + - 82079 + - 82080 + - 82081 + - 82082 + - 82083 + - 82084 + - 82085 + - 82086 + - 82087 + - 82088 + - 82089 + - 82090 + - 82091 + - 82092 + - 82093 + - 82094 + - 82095 + - 82096 + - 82097 + - 82098 + - 82099 + - 82100 + - 82101 + - 82102 + - 82103 + - 82104 + - 82105 + - 82106 + - 82107 + - 82108 + - 82109 + - 82110 + - 82111 + - 82112 + - 82113 + - 82114 + - 82115 + - 82116 + - 82117 + - 82118 + - 82119 + - 82120 + - 82121 + - 82122 + - 82123 + - 82124 + - 82125 + - 82126 + - 82127 + - 82128 + - 82129 + - 82130 + - 82131 + - 82132 + - 82133 + - 82134 + - 82135 + - 82136 + - 82137 + - 82138 + - 82139 + - 82140 + - 82141 + - 82142 + - 82143 + - 82144 + - 82145 + - 82146 + - 82147 + - 82148 + - 82149 + - 82150 + - 82151 + - 82152 + - 82153 + - 82154 + - 82155 + - 82156 + - 82157 + - 82158 + - 82159 + - 82160 + - 82161 + - 82162 + - 82163 + - 82164 + - 82165 + - 82166 + - 82167 + - 82168 + - 82169 + - 82170 + - 82171 + - 82172 + - 82173 + - 82174 + - 82175 + - 82176 + - 82177 + - 82178 + - 82179 + - 82180 + - 82181 + - 82182 + - 82183 + - 82184 + - 82185 + - 82186 + - 82187 + - 82188 + - 82189 + - 82190 + - 82191 + - 82192 + - 82193 + - 82194 + - 82195 + - 82196 + - 82197 + - 82198 + - 82199 + - 82200 + - 82201 + - 82202 + - 82203 + - 82204 + - 82205 + - 82206 + - 82207 + - 82208 + - 82209 + - 82210 + - 82211 + - 82212 + - 82213 + - 82214 + - 82215 + - 82216 + - 82217 + - 82218 + - 82219 + - 82220 + - 82221 + - 82222 + - 82223 + - 82224 + - 82225 + - 82226 + - 82227 + - 82228 + - 82229 + - 82230 + - 82231 + - 82232 + - 82233 + - 82234 + - 82235 + - 82236 + - 82237 + - 82238 + - 82239 + - 82240 + - 82241 + - 82242 + - 82243 + - 82244 + - 82245 + - 82246 + - 82247 + - 82248 + - 82249 + - 82250 + - 82251 + - 82252 + - 82253 + - 82254 + - 82255 + - 82256 + - 82257 + - 82258 + - 82259 + - 82260 + - 82261 + - 82262 + - 82263 + - 82264 + - 82265 + - 82266 + - 82267 + - 82268 + - 82269 + - 82270 + - 82271 + - 82272 + - 82273 + - 82274 + - 82275 + - 82276 + - 82277 + - 82278 + - 82279 + - 82280 + - 82281 + - 82282 + - 82283 + - 82284 + - 82285 + - 82286 + - 82287 + - 82288 + - 82289 + - 82290 + - 82291 + - 82292 + - 82293 + - 82294 + - 82295 + - 82296 + - 82297 + - 82298 + - 82299 + - 82300 + - 82301 + - 82302 + - 82303 + - 82304 + - 82305 + - 82306 + - 82307 + - 82308 + - 82309 + - 82310 + - 82311 + - 82312 + - 82313 + - 82314 + - 82315 + - 82316 + - 82317 + - 82318 + - 82319 + - 82320 + - 82321 + - 82322 + - 82323 + - 82324 + - 82325 + - 82326 + - 82327 + - 82328 + - 82329 + - 82330 + - 82331 + - 82332 + - 82333 + - 82334 + - 82335 + - 82336 + - 82337 + - 82338 + - 82339 + - 82340 + - 82341 + - 82342 + - 82343 + - 82344 + - 82345 + - 82346 + - 82347 + - 82348 + - 82349 + - 82350 + - 82351 + - 82352 + - 82353 + - 82354 + - 82355 + - 82356 + - 82357 + - 82358 + - 82359 + - 82360 + - 82361 + - 82362 + - 82363 + - 82364 + - 82365 + - 82366 + - 82367 + - 82368 + - 82369 + - 82370 + - 82371 + - 82372 + - 82373 + - 82374 + - 82375 + - 82376 + - 82377 + - 82378 + - 82379 + - 82380 + - 82381 + - 82382 + - 82383 + - 82384 + - 82385 + - 82386 + - 82387 + - 82388 + - 82389 + - 82390 + - 82391 + - 82392 + - 82393 + - 82394 + - 82395 + - 82396 + - 82397 + - 82398 + - 82399 + - 82400 + - 82401 + - 82402 + - 82403 + - 82404 + - 82405 + - 82406 + - 82407 + - 82408 + - 82409 + - 82410 + - 82411 + - 82412 + - 82413 + - 82414 + - 82415 + - 82416 + - 82417 + - 82418 + - 82419 + - 82420 + - 82421 + - 82422 + - 82423 + - 82424 + - 82425 + - 82426 + - 82427 + - 82428 + - 82429 + - 82430 + - 82431 + - 82432 + - 82433 + - 82434 + - 82435 + - 82436 + - 82437 + - 82438 + - 82439 + - 82440 + - 82441 + - 82442 + - 82443 + - 82444 + - 82445 + - 82446 + - 82447 + - 82448 + - 82449 + - 82450 + - 82451 + - 82452 + - 82453 + - 82454 + - 82455 + - 82456 + - 82457 + - 82458 + - 82459 + - 82460 + - 82461 + - 82462 + - 82463 + - 82464 + - 82465 + - 82466 + - 82467 + - 82468 + - 82469 + - 82470 + - 82471 + - 82472 + - 82473 + - 82474 + - 82475 + - 82476 + - 82477 + - 82478 + - 82479 + - 82480 + - 82481 + - 82482 + - 82483 + - 82484 + - 82485 + - 82486 + - 82487 + - 82488 + - 82489 + - 82490 + - 82491 + - 82492 + - 82493 + - 82494 + - 82495 + - 82496 + - 82497 + - 82498 + - 82499 + - 82500 + - 82501 + - 82502 + - 82503 + - 82504 + - 82505 + - 82506 + - 82507 + - 82508 + - 82509 + - 82510 + - 82511 + - 82512 + - 82513 + - 82514 + - 82515 + - 82516 + - 82517 + - 82518 + - 82519 + - 82520 + - 82521 + - 82522 + - 82523 + - 82524 + - 82525 + - 82526 + - 82527 + - 82528 + - 82529 + - 82530 + - 82531 + - 82532 + - 82533 + - 82534 + - 82535 + - 82536 + - 82537 + - 82538 + - 82539 + - 82540 + - 82541 + - 82542 + - 82543 + - 82544 + - 82545 + - 82546 + - 82547 + - 82548 + - 82549 + - 82550 + - 82551 + - 82552 + - 82553 + - 82554 + - 82555 + - 82556 + - 82557 + - 82558 + - 82559 + - 82560 + - 82561 + - 82562 + - 82563 + - 82564 + - 82565 + - 82566 + - 82567 + - 82568 + - 82569 + - 82570 + - 82571 + - 82572 + - 82573 + - 82574 + - 82575 + - 82576 + - 82577 + - 82578 + - 82579 + - 82580 + - 82581 + - 82582 + - 82583 + - 82584 + - 82585 + - 82586 + - 82587 + - 82588 + - 82589 + - 82590 + - 82591 + - 82592 + - 82593 + - 82594 + - 82595 + - 82596 + - 82597 + - 82598 + - 82599 + - 82600 + - 82601 + - 82602 + - 82603 + - 82604 + - 82605 + - 82606 + - 82607 + - 82608 + - 82609 + - 82610 + - 82611 + - 82612 + - 82613 + - 82614 + - 82615 + - 82616 + - 82617 + - 82618 + - 82619 + - 82620 + - 82621 + - 82622 + - 82623 + - 82624 + - 82625 + - 82626 + - 82627 + - 82628 + - 82629 + - 82630 + - 82631 + - 82632 + - 82633 + - 82634 + - 82635 + - 82636 + - 82637 + - 82638 + - 82639 + - 82640 + - 82641 + - 82642 + - 82643 + - 82644 + - 82645 + - 82646 + - 82647 + - 82648 + - 82649 + - 82650 + - 82651 + - 82652 + - 82653 + - 82654 + - 82655 + - 82656 + - 82657 + - 82658 + - 82659 + - 82660 + - 82661 + - 82662 + - 82663 + - 82664 + - 82665 + - 82666 + - 82667 + - 82668 + - 82669 + - 82670 + - 82671 + - 82672 + - 82673 + - 82674 + - 82675 + - 82676 + - 82677 + - 82678 + - 82679 + - 82680 + - 82681 + - 82682 + - 82683 + - 82684 + - 82685 + - 82686 + - 82687 + - 82688 + - 82689 + - 82690 + - 82691 + - 82692 + - 82693 + - 82694 + - 82695 + - 82696 + - 82697 + - 82698 + - 82699 + - 82700 + - 82701 + - 82702 + - 82703 + - 82704 + - 82705 + - 82706 + - 82707 + - 82708 + - 82709 + - 82710 + - 82711 + - 82712 + - 82713 + - 82714 + - 82715 + - 82716 + - 82717 + - 82718 + - 82719 + - 82720 + - 82721 + - 82722 + - 82723 + - 82724 + - 82725 + - 82726 + - 82727 + - 82728 + - 82729 + - 82730 + - 82731 + - 82732 + - 82733 + - 82734 + - 82735 + - 82736 + - 82737 + - 82738 + - 82739 + - 82740 + - 82741 + - 82742 + - 82743 + - 82744 + - 82745 + - 82746 + - 82747 + - 82748 + - 82749 + - 82750 + - 82751 + - 82752 + - 82753 + - 82754 + - 82755 + - 82756 + - 82757 + - 82758 + - 82759 + - 82760 + - 82761 + - 82762 + - 82763 + - 82764 + - 82765 + - 82766 + - 82767 + - 82768 + - 82769 + - 82770 + - 82771 + - 82772 + - 82773 + - 82774 + - 82775 + - 82776 + - 82777 + - 82778 + - 82779 + - 82780 + - 82781 + - 82782 + - 82783 + - 82784 + - 82785 + - 82786 + - 82787 + - 82788 + - 82789 + - 82790 + - 82791 + - 82792 + - 82793 + - 82794 + - 82795 + - 82796 + - 82797 + - 82798 + - 82799 + - 82800 + - 82801 + - 82802 + - 82803 + - 82804 + - 82805 + - 82806 + - 82807 + - 82808 + - 82809 + - 82810 + - 82811 + - 82812 + - 82813 + - 82814 + - 82815 + - 82816 + - 82817 + - 82818 + - 82819 + - 82820 + - 82821 + - 82822 + - 82823 + - 82824 + - 82825 + - 82826 + - 82827 + - 82828 + - 82829 + - 82830 + - 82831 + - 82832 + - 82833 + - 82834 + - 82835 + - 82836 + - 82837 + - 82838 + - 82839 + - 82840 + - 82841 + - 82842 + - 82843 + - 82844 + - 82845 + - 82846 + - 82847 + - 82848 + - 82849 + - 82850 + - 82851 + - 82852 + - 82853 + - 82854 + - 82855 + - 82856 + - 82857 + - 82858 + - 82859 + - 82860 + - 82861 + - 82862 + - 82863 + - 82864 + - 82865 + - 82866 + - 82867 + - 82868 + - 82869 + - 82870 + - 82871 + - 82872 + - 82873 + - 82874 + - 82875 + - 82876 + - 82877 + - 82878 + - 82879 + - 82880 + - 82881 + - 82882 + - 82883 + - 82884 + - 82885 + - 82886 + - 82887 + - 82888 + - 82889 + - 82890 + - 82891 + - 82892 + - 82893 + - 82894 + - 82895 + - 82896 + - 82897 + - 82898 + - 82899 + - 82900 + - 82901 + - 82902 + - 82903 + - 82904 + - 82905 + - 82906 + - 82907 + - 82908 + - 82909 + - 82910 + - 82911 + - 82912 + - 82913 + - 82914 + - 82915 + - 82916 + - 82917 + - 82918 + - 82919 + - 82920 + - 82921 + - 82922 + - 82923 + - 82924 + - 82925 + - 82926 + - 82927 + - 82928 + - 82929 + - 82930 + - 82931 + - 82932 + - 82933 + - 82934 + - 82935 + - 82936 + - 82937 + - 82938 + - 82939 + - 82940 + - 82941 + - 82942 + - 82943 + - 82944 + - 82945 + - 82946 + - 82947 + - 82948 + - 82949 + - 82950 + - 82951 + - 82952 + - 82953 + - 82954 + - 82955 + - 82956 + - 82957 + - 82958 + - 82959 + - 82960 + - 82961 + - 82962 + - 82963 + - 82964 + - 82965 + - 82966 + - 82967 + - 82968 + - 82969 + - 82970 + - 82971 + - 82972 + - 82973 + - 82974 + - 82975 + - 82976 + - 82977 + - 82978 + - 82979 + - 82980 + - 82981 + - 82982 + - 82983 + - 82984 + - 82985 + - 82986 + - 82987 + - 82988 + - 82989 + - 82990 + - 82991 + - 82992 + - 82993 + - 82994 + - 82995 + - 82996 + - 82997 + - 82998 + - 82999 + - 83000 + - 83001 + - 83002 + - 83003 + - 83004 + - 83005 + - 83006 + - 83007 + - 83008 + - 83009 + - 83010 + - 83011 + - 83012 + - 83013 + - 83014 + - 83015 + - 83016 + - 83017 + - 83018 + - 83019 + - 83020 + - 83021 + - 83022 + - 83023 + - 83024 + - 83025 + - 83026 + - 83027 + - 83028 + - 83029 + - 83030 + - 83031 + - 83032 + - 83033 + - 83034 + - 83035 + - 83036 + - 83037 + - 83038 + - 83039 + - 83040 + - 83041 + - 83042 + - 83043 + - 83044 + - 83045 + - 83046 + - 83047 + - 83048 + - 83049 + - 83050 + - 83051 + - 83052 + - 83053 + - 83054 + - 83055 + - 83056 + - 83057 + - 83058 + - 83059 + - 83060 + - 83061 + - 83062 + - 83063 + - 83064 + - 83065 + - 83066 + - 83067 + - 83068 + - 83069 + - 83070 + - 83071 + - 83072 + - 83073 + - 83074 + - 83075 + - 83076 + - 83077 + - 83078 + - 83079 + - 83080 + - 83081 + - 83082 + - 83083 + - 83084 + - 83085 + - 83086 + - 83087 + - 83088 + - 83089 + - 83090 + - 83091 + - 83092 + - 83093 + - 83094 + - 83095 + - 83096 + - 83097 + - 83098 + - 83099 + - 83100 + - 83101 + - 83102 + - 83103 + - 83104 + - 83105 + - 83106 + - 83107 + - 83108 + - 83109 + - 83110 + - 83111 + - 83112 + - 83113 + - 83114 + - 83115 + - 83116 + - 83117 + - 83118 + - 83119 + - 83120 + - 83121 + - 83122 + - 83123 + - 83124 + - 83125 + - 83126 + - 83127 + - 83128 + - 83129 + - 83130 + - 83131 + - 83132 + - 83133 + - 83134 + - 83135 + - 83136 + - 83137 + - 83138 + - 83139 + - 83140 + - 83141 + - 83142 + - 83143 + - 83144 + - 83145 + - 83146 + - 83147 + - 83148 + - 83149 + - 83150 + - 83151 + - 83152 + - 83153 + - 83154 + - 83155 + - 83156 + - 83157 + - 83158 + - 83159 + - 83160 + - 83161 + - 83162 + - 83163 + - 83164 + - 83165 + - 83166 + - 83167 + - 83168 + - 83169 + - 83170 + - 83171 + - 83172 + - 83173 + - 83174 + - 83175 + - 83176 + - 83177 + - 83178 + - 83179 + - 83180 + - 83181 + - 83182 + - 83183 + - 83184 + - 83185 + - 83186 + - 83187 + - 83188 + - 83189 + - 83190 + - 83191 + - 83192 + - 83193 + - 83194 + - 83195 + - 83196 + - 83197 + - 83198 + - 83199 + - 83200 + - 83201 + - 83202 + - 83203 + - 83204 + - 83205 + - 83206 + - 83207 + - 83208 + - 83209 + - 83210 + - 83211 + - 83212 + - 83213 + - 83214 + - 83215 + - 83216 + - 83217 + - 83218 + - 83219 + - 83220 + - 83221 + - 83222 + - 83223 + - 83224 + - 83225 + - 83226 + - 83227 + - 83228 + - 83229 + - 83230 + - 83231 + - 83232 + - 83233 + - 83234 + - 83235 + - 83236 + - 83237 + - 83238 + - 83239 + - 83240 + - 83241 + - 83242 + - 83243 + - 83244 + - 83245 + - 83246 + - 83247 + - 83248 + - 83249 + - 83250 + - 83251 + - 83252 + - 83253 + - 83254 + - 83255 + - 83256 + - 83257 + - 83258 + - 83259 + - 83260 + - 83261 + - 83262 + - 83263 + - 83264 + - 83265 + - 83266 + - 83267 + - 83268 + - 83269 + - 83270 + - 83271 + - 83272 + - 83273 + - 83274 + - 83275 + - 83276 + - 83277 + - 83278 + - 83279 + - 83280 + - 83281 + - 83282 + - 83283 + - 83284 + - 83285 + - 83286 + - 83287 + - 83288 + - 83289 + - 83290 + - 83291 + - 83292 + - 83293 + - 83294 + - 83295 + - 83296 + - 83297 + - 83298 + - 83299 + - 83300 + - 83301 + - 83302 + - 83303 + - 83304 + - 83305 + - 83306 + - 83307 + - 83308 + - 83309 + - 83310 + - 83311 + - 83312 + - 83313 + - 83314 + - 83315 + - 83316 + - 83317 + - 83318 + - 83319 + - 83320 + - 83321 + - 83322 + - 83323 + - 83324 + - 83325 + - 83326 + - 83327 + - 83328 + - 83329 + - 83330 + - 83331 + - 83332 + - 83333 + - 83334 + - 83335 + - 83336 + - 83337 + - 83338 + - 83339 + - 83340 + - 83341 + - 83342 + - 83343 + - 83344 + - 83345 + - 83346 + - 83347 + - 83348 + - 83349 + - 83350 + - 83351 + - 83352 + - 83353 + - 83354 + - 83355 + - 83356 + - 83357 + - 83358 + - 83359 + - 83360 + - 83361 + - 83362 + - 83363 + - 83364 + - 83365 + - 83366 + - 83367 + - 83368 + - 83369 + - 83370 + - 83371 + - 83372 + - 83373 + - 83374 + - 83375 + - 83376 + - 83377 + - 83378 + - 83379 + - 83380 + - 83381 + - 83382 + - 83383 + - 83384 + - 83385 + - 83386 + - 83387 + - 83388 + - 83389 + - 83390 + - 83391 + - 83392 + - 83393 + - 83394 + - 83395 + - 83396 + - 83397 + - 83398 + - 83399 + - 83400 + - 83401 + - 83402 + - 83403 + - 83404 + - 83405 + - 83406 + - 83407 + - 83408 + - 83409 + - 83410 + - 83411 + - 83412 + - 83413 + - 83414 + - 83415 + - 83416 + - 83417 + - 83418 + - 83419 + - 83420 + - 83421 + - 83422 + - 83423 + - 83424 + - 83425 + - 83426 + - 83427 + - 83428 + - 83429 + - 83430 + - 83431 + - 83432 + - 83433 + - 83434 + - 83435 + - 83436 + - 83437 + - 83438 + - 83439 + - 83440 + - 83441 + - 83442 + - 83443 + - 83444 + - 83445 + - 83446 + - 83447 + - 83448 + - 83449 + - 83450 + - 83451 + - 83452 + - 83453 + - 83454 + - 83455 + - 83456 + - 83457 + - 83458 + - 83459 + - 83460 + - 83461 + - 83462 + - 83463 + - 83464 + - 83465 + - 83466 + - 83467 + - 83468 + - 83469 + - 83470 + - 83471 + - 83472 + - 83473 + - 83474 + - 83475 + - 83476 + - 83477 + - 83478 + - 83479 + - 83480 + - 83481 + - 83482 + - 83483 + - 83484 + - 83485 + - 83486 + - 83487 + - 83488 + - 83489 + - 83490 + - 83491 + - 83492 + - 83493 + - 83494 + - 83495 + - 83496 + - 83497 + - 83498 + - 83499 + - 83500 + - 83501 + - 83502 + - 83503 + - 83504 + - 83505 + - 83506 + - 83507 + - 83508 + - 83509 + - 83510 + - 83511 + - 83512 + - 83513 + - 83514 + - 83515 + - 83516 + - 83517 + - 83518 + - 83519 + - 83520 + - 83521 + - 83522 + - 83523 + - 83524 + - 83525 + - 83526 + - 83527 + - 83528 + - 83529 + - 83530 + - 83531 + - 83532 + - 83533 + - 83534 + - 83535 + - 83536 + - 83537 + - 83538 + - 83539 + - 83540 + - 83541 + - 83542 + - 83543 + - 83544 + - 83545 + - 83546 + - 83547 + - 83548 + - 83549 + - 83550 + - 83551 + - 83552 + - 83553 + - 83554 + - 83555 + - 83556 + - 83557 + - 83558 + - 83559 + - 83560 + - 83561 + - 83562 + - 83563 + - 83564 + - 83565 + - 83566 + - 83567 + - 83568 + - 83569 + - 83570 + - 83571 + - 83572 + - 83573 + - 83574 + - 83575 + - 83576 + - 83577 + - 83578 + - 83579 + - 83580 + - 83581 + - 83582 + - 83583 + - 83584 + - 83585 + - 83586 + - 83587 + - 83588 + - 83589 + - 83590 + - 83591 + - 83592 + - 83593 + - 83594 + - 83595 + - 83596 + - 83597 + - 83598 + - 83599 + - 83600 + - 83601 + - 83602 + - 83603 + - 83604 + - 83605 + - 83606 + - 83607 + - 83608 + - 83609 + - 83610 + - 83611 + - 83612 + - 83613 + - 83614 + - 83615 + - 83616 + - 83617 + - 83618 + - 83619 + - 83620 + - 83621 + - 83622 + - 83623 + - 83624 + - 83625 + - 83626 + - 83627 + - 83628 + - 83629 + - 83630 + - 83631 + - 83632 + - 83633 + - 83634 + - 83635 + - 83636 + - 83637 + - 83638 + - 83639 + - 83640 + - 83641 + - 83642 + - 83643 + - 83644 + - 83645 + - 83646 + - 83647 + - 83648 + - 83649 + - 83650 + - 83651 + - 83652 + - 83653 + - 83654 + - 83655 + - 83656 + - 83657 + - 83658 + - 83659 + - 83660 + - 83661 + - 83662 + - 83663 + - 83664 + - 83665 + - 83666 + - 83667 + - 83668 + - 83669 + - 83670 + - 83671 + - 83672 + - 83673 + - 83674 + - 83675 + - 83676 + - 83677 + - 83678 + - 83679 + - 83680 + - 83681 + - 83682 + - 83683 + - 83684 + - 83685 + - 83686 + - 83687 + - 83688 + - 83689 + - 83690 + - 83691 + - 83692 + - 83693 + - 83694 + - 83695 + - 83696 + - 83697 + - 83698 + - 83699 + - 83700 + - 83701 + - 83702 + - 83703 + - 83704 + - 83705 + - 83706 + - 83707 + - 83708 + - 83709 + - 83710 + - 83711 + - 83712 + - 83713 + - 83714 + - 83715 + - 83716 + - 83717 + - 83718 + - 83719 + - 83720 + - 83721 + - 83722 + - 83723 + - 83724 + - 83725 + - 83726 + - 83727 + - 83728 + - 83729 + - 83730 + - 83731 + - 83732 + - 83733 + - 83734 + - 83735 + - 83736 + - 83737 + - 83738 + - 83739 + - 83740 + - 83741 + - 83742 + - 83743 + - 83744 + - 83745 + - 83746 + - 83747 + - 83748 + - 83749 + - 83750 + - 83751 + - 83752 + - 83753 + - 83754 + - 83755 + - 83756 + - 83757 + - 83758 + - 83759 + - 83760 + - 83761 + - 83762 + - 83763 + - 83764 + - 83765 + - 83766 + - 83767 + - 83768 + - 83769 + - 83770 + - 83771 + - 83772 + - 83773 + - 83774 + - 83775 + - 83776 + - 83777 + - 83778 + - 83779 + - 83780 + - 83781 + - 83782 + - 83783 + - 83784 + - 83785 + - 83786 + - 83787 + - 83788 + - 83789 + - 83790 + - 83791 + - 83792 + - 83793 + - 83794 + - 83795 + - 83796 + - 83797 + - 83798 + - 83799 + - 83800 + - 83801 + - 83802 + - 83803 + - 83804 + - 83805 + - 83806 + - 83807 + - 83808 + - 83809 + - 83810 + - 83811 + - 83812 + - 83813 + - 83814 + - 83815 + - 83816 + - 83817 + - 83818 + - 83819 + - 83820 + - 83821 + - 83822 + - 83823 + - 83824 + - 83825 + - 83826 + - 83827 + - 83828 + - 83829 + - 83830 + - 83831 + - 83832 + - 83833 + - 83834 + - 83835 + - 83836 + - 83837 + - 83838 + - 83839 + - 83840 + - 83841 + - 83842 + - 83843 + - 83844 + - 83845 + - 83846 + - 83847 + - 83848 + - 83849 + - 83850 + - 83851 + - 83852 + - 83853 + - 83854 + - 83855 + - 83856 + - 83857 + - 83858 + - 83859 + - 83860 + - 83861 + - 83862 + - 83863 + - 83864 + - 83865 + - 83866 + - 83867 + - 83868 + - 83869 + - 83870 + - 83871 + - 83872 + - 83873 + - 83874 + - 83875 + - 83876 + - 83877 + - 83878 + - 83879 + - 83880 + - 83881 + - 83882 + - 83883 + - 83884 + - 83885 + - 83886 + - 83887 + - 83888 + - 83889 + - 83890 + - 83891 + - 83892 + - 83893 + - 83894 + - 83895 + - 83896 + - 83897 + - 83898 + - 83899 + - 83900 + - 83901 + - 83902 + - 83903 + - 83904 + - 83905 + - 83906 + - 83907 + - 83908 + - 83909 + - 83910 + - 83911 + - 83912 + - 83913 + - 83914 + - 83915 + - 83916 + - 83917 + - 83918 + - 83919 + - 83920 + - 83921 + - 83922 + - 83923 + - 83924 + - 83925 + - 83926 + - 83927 + - 83928 + - 83929 + - 83930 + - 83931 + - 83932 + - 83933 + - 83934 + - 83935 + - 83936 + - 83937 + - 83938 + - 83939 + - 83940 + - 83941 + - 83942 + - 83943 + - 83944 + - 83945 + - 83946 + - 83947 + - 83948 + - 83949 + - 83950 + - 83951 + - 83952 + - 83953 + - 83954 + - 83955 + - 83956 + - 83957 + - 83958 + - 83959 + - 83960 + - 83961 + - 83962 + - 83963 + - 83964 + - 83965 + - 83966 + - 83967 + - 83968 + - 83969 + - 83970 + - 83971 + - 83972 + - 83973 + - 83974 + - 83975 + - 83976 + - 83977 + - 83978 + - 83979 + - 83980 + - 83981 + - 83982 + - 83983 + - 83984 + - 83985 + - 83986 + - 83987 + - 83988 + - 83989 + - 83990 + - 83991 + - 83992 + - 83993 + - 83994 + - 83995 + - 83996 + - 83997 + - 83998 + - 83999 + - 84000 + - 84001 + - 84002 + - 84003 + - 84004 + - 84005 + - 84006 + - 84007 + - 84008 + - 84009 + - 84010 + - 84011 + - 84012 + - 84013 + - 84014 + - 84015 + - 84016 + - 84017 + - 84018 + - 84019 + - 84020 + - 84021 + - 84022 + - 84023 + - 84024 + - 84025 + - 84026 + - 84027 + - 84028 + - 84029 + - 84030 + - 84031 + - 84032 + - 84033 + - 84034 + - 84035 + - 84036 + - 84037 + - 84038 + - 84039 + - 84040 + - 84041 + - 84042 + - 84043 + - 84044 + - 84045 + - 84046 + - 84047 + - 84048 + - 84049 + - 84050 + - 84051 + - 84052 + - 84053 + - 84054 + - 84055 + - 84056 + - 84057 + - 84058 + - 84059 + - 84060 + - 84061 + - 84062 + - 84063 + - 84064 + - 84065 + - 84066 + - 84067 + - 84068 + - 84069 + - 84070 + - 84071 + - 84072 + - 84073 + - 84074 + - 84075 + - 84076 + - 84077 + - 84078 + - 84079 + - 84080 + - 84081 + - 84082 + - 84083 + - 84084 + - 84085 + - 84086 + - 84087 + - 84088 + - 84089 + - 84090 + - 84091 + - 84092 + - 84093 + - 84094 + - 84095 + - 84096 + - 84097 + - 84098 + - 84099 + - 84100 + - 84101 + - 84102 + - 84103 + - 84104 + - 84105 + - 84106 + - 84107 + - 84108 + - 84109 + - 84110 + - 84111 + - 84112 + - 84113 + - 84114 + - 84115 + - 84116 + - 84117 + - 84118 + - 84119 + - 84120 + - 84121 + - 84122 + - 84123 + - 84124 + - 84125 + - 84126 + - 84127 + - 84128 + - 84129 + - 84130 + - 84131 + - 84132 + - 84133 + - 84134 + - 84135 + - 84136 + - 84137 + - 84138 + - 84139 + - 84140 + - 84141 + - 84142 + - 84143 + - 84144 + - 84145 + - 84146 + - 84147 + - 84148 + - 84149 + - 84150 + - 84151 + - 84152 + - 84153 + - 84154 + - 84155 + - 84156 + - 84157 + - 84158 + - 84159 + - 84160 + - 84161 + - 84162 + - 84163 + - 84164 + - 84165 + - 84166 + - 84167 + - 84168 + - 84169 + - 84170 + - 84171 + - 84172 + - 84173 + - 84174 + - 84175 + - 84176 + - 84177 + - 84178 + - 84179 + - 84180 + - 84181 + - 84182 + - 84183 + - 84184 + - 84185 + - 84186 + - 84187 + - 84188 + - 84189 + - 84190 + - 84191 + - 84192 + - 84193 + - 84194 + - 84195 + - 84196 + - 84197 + - 84198 + - 84199 + - 84200 + - 84201 + - 84202 + - 84203 + - 84204 + - 84205 + - 84206 + - 84207 + - 84208 + - 84209 + - 84210 + - 84211 + - 84212 + - 84213 + - 84214 + - 84215 + - 84216 + - 84217 + - 84218 + - 84219 + - 84220 + - 84221 + - 84222 + - 84223 + - 84224 + - 84225 + - 84226 + - 84227 + - 84228 + - 84229 + - 84230 + - 84231 + - 84232 + - 84233 + - 84234 + - 84235 + - 84236 + - 84237 + - 84238 + - 84239 + - 84240 + - 84241 + - 84242 + - 84243 + - 84244 + - 84245 + - 84246 + - 84247 + - 84248 + - 84249 + - 84250 + - 84251 + - 84252 + - 84253 + - 84254 + - 84255 + - 84256 + - 84257 + - 84258 + - 84259 + - 84260 + - 84261 + - 84262 + - 84263 + - 84264 + - 84265 + - 84266 + - 84267 + - 84268 + - 84269 + - 84270 + - 84271 + - 84272 + - 84273 + - 84274 + - 84275 + - 84276 + - 84277 + - 84278 + - 84279 + - 84280 + - 84281 + - 84282 + - 84283 + - 84284 + - 84285 + - 84286 + - 84287 + - 84288 + - 84289 + - 84290 + - 84291 + - 84292 + - 84293 + - 84294 + - 84295 + - 84296 + - 84297 + - 84298 + - 84299 + - 84300 + - 84301 + - 84302 + - 84303 + - 84304 + - 84305 + - 84306 + - 84307 + - 84308 + - 84309 + - 84310 + - 84311 + - 84312 + - 84313 + - 84314 + - 84315 + - 84316 + - 84317 + - 84318 + - 84319 + - 84320 + - 84321 + - 84322 + - 84323 + - 84324 + - 84325 + - 84326 + - 84327 + - 84328 + - 84329 + - 84330 + - 84331 + - 84332 + - 84333 + - 84334 + - 84335 + - 84336 + - 84337 + - 84338 + - 84339 + - 84340 + - 84341 + - 84342 + - 84343 + - 84344 + - 84345 + - 84346 + - 84347 + - 84348 + - 84349 + - 84350 + - 84351 + - 84352 + - 84353 + - 84354 + - 84355 + - 84356 + - 84357 + - 84358 + - 84359 + - 84360 + - 84361 + - 84362 + - 84363 + - 84364 + - 84365 + - 84366 + - 84367 + - 84368 + - 84369 + - 84370 + - 84371 + - 84372 + - 84373 + - 84374 + - 84375 + - 84376 + - 84377 + - 84378 + - 84379 + - 84380 + - 84381 + - 84382 + - 84383 + - 84384 + - 84385 + - 84386 + - 84387 + - 84388 + - 84389 + - 84390 + - 84391 + - 84392 + - 84393 + - 84394 + - 84395 + - 84396 + - 84397 + - 84398 + - 84399 + - 84400 + - 84401 + - 84402 + - 84403 + - 84404 + - 84405 + - 84406 + - 84407 + - 84408 + - 84409 + - 84410 + - 84411 + - 84412 + - 84413 + - 84414 + - 84415 + - 84416 + - 84417 + - 84418 + - 84419 + - 84420 + - 84421 + - 84422 + - 84423 + - 84424 + - 84425 + - 84426 + - 84427 + - 84428 + - 84429 + - 84430 + - 84431 + - 84432 + - 84433 + - 84434 + - 84435 + - 84436 + - 84437 + - 84438 + - 84439 + - 84440 + - 84441 + - 84442 + - 84443 + - 84444 + - 84445 + - 84446 + - 84447 + - 84448 + - 84449 + - 84450 + - 84451 + - 84452 + - 84453 + - 84454 + - 84455 + - 84456 + - 84457 + - 84458 + - 84459 + - 84460 + - 84461 + - 84462 + - 84463 + - 84464 + - 84465 + - 84466 + - 84467 + - 84468 + - 84469 + - 84470 + - 84471 + - 84472 + - 84473 + - 84474 + - 84475 + - 84476 + - 84477 + - 84478 + - 84479 + - 84480 + - 84481 + - 84482 + - 84483 + - 84484 + - 84485 + - 84486 + - 84487 + - 84488 + - 84489 + - 84490 + - 84491 + - 84492 + - 84493 + - 84494 + - 84495 + - 84496 + - 84497 + - 84498 + - 84499 + - 84500 + - 84501 + - 84502 + - 84503 + - 84504 + - 84505 + - 84506 + - 84507 + - 84508 + - 84509 + - 84510 + - 84511 + - 84512 + - 84513 + - 84514 + - 84515 + - 84516 + - 84517 + - 84518 + - 84519 + - 84520 + - 84521 + - 84522 + - 84523 + - 84524 + - 84525 + - 84526 + - 84527 + - 84528 + - 84529 + - 84530 + - 84531 + - 84532 + - 84533 + - 84534 + - 84535 + - 84536 + - 84537 + - 84538 + - 84539 + - 84540 + - 84541 + - 84542 + - 84543 + - 84544 + - 84545 + - 84546 + - 84547 + - 84548 + - 84549 + - 84550 + - 84551 + - 84552 + - 84553 + - 84554 + - 84555 + - 84556 + - 84557 + - 84558 + - 84559 + - 84560 + - 84561 + - 84562 + - 84563 + - 84564 + - 84565 + - 84566 + - 84567 + - 84568 + - 84569 + - 84570 + - 84571 + - 84572 + - 84573 + - 84574 + - 84575 + - 84576 + - 84577 + - 84578 + - 84579 + - 84580 + - 84581 + - 84582 + - 84583 + - 84584 + - 84585 + - 84586 + - 84587 + - 84588 + - 84589 + - 84590 + - 84591 + - 84592 + - 84593 + - 84594 + - 84595 + - 84596 + - 84597 + - 84598 + - 84599 + - 84600 + - 84601 + - 84602 + - 84603 + - 84604 + - 84605 + - 84606 + - 84607 + - 84608 + - 84609 + - 84610 + - 84611 + - 84612 + - 84613 + - 84614 + - 84615 + - 84616 + - 84617 + - 84618 + - 84619 + - 84620 + - 84621 + - 84622 + - 84623 + - 84624 + - 84625 + - 84626 + - 84627 + - 84628 + - 84629 + - 84630 + - 84631 + - 84632 + - 84633 + - 84634 + - 84635 + - 84636 + - 84637 + - 84638 + - 84639 + - 84640 + - 84641 + - 84642 + - 84643 + - 84644 + - 84645 + - 84646 + - 84647 + - 84648 + - 84649 + - 84650 + - 84651 + - 84652 + - 84653 + - 84654 + - 84655 + - 84656 + - 84657 + - 84658 + - 84659 + - 84660 + - 84661 + - 84662 + - 84663 + - 84664 + - 84665 + - 84666 + - 84667 + - 84668 + - 84669 + - 84670 + - 84671 + - 84672 + - 84673 + - 84674 + - 84675 + - 84676 + - 84677 + - 84678 + - 84679 + - 84680 + - 84681 + - 84682 + - 84683 + - 84684 + - 84685 + - 84686 + - 84687 + - 84688 + - 84689 + - 84690 + - 84691 + - 84692 + - 84693 + - 84694 + - 84695 + - 84696 + - 84697 + - 84698 + - 84699 + - 84700 + - 84701 + - 84702 + - 84703 + - 84704 + - 84705 + - 84706 + - 84707 + - 84708 + - 84709 + - 84710 + - 84711 + - 84712 + - 84713 + - 84714 + - 84715 + - 84716 + - 84717 + - 84718 + - 84719 + - 84720 + - 84721 + - 84722 + - 84723 + - 84724 + - 84725 + - 84726 + - 84727 + - 84728 + - 84729 + - 84730 + - 84731 + - 84732 + - 84733 + - 84734 + - 84735 + - 84736 + - 84737 + - 84738 + - 84739 + - 84740 + - 84741 + - 84742 + - 84743 + - 84744 + - 84745 + - 84746 + - 84747 + - 84748 + - 84749 + - 84750 + - 84751 + - 84752 + - 84753 + - 84754 + - 84755 + - 84756 + - 84757 + - 84758 + - 84759 + - 84760 + - 84761 + - 84762 + - 84763 + - 84764 + - 84765 + - 84766 + - 84767 + - 84768 + - 84769 + - 84770 + - 84771 + - 84772 + - 84773 + - 84774 + - 84775 + - 84776 + - 84777 + - 84778 + - 84779 + - 84780 + - 84781 + - 84782 + - 84783 + - 84784 + - 84785 + - 84786 + - 84787 + - 84788 + - 84789 + - 84790 + - 84791 + - 84792 + - 84793 + - 84794 + - 84795 + - 84796 + - 84797 + - 84798 + - 84799 + - 84800 + - 84801 + - 84802 + - 84803 + - 84804 + - 84805 + - 84806 + - 84807 + - 84808 + - 84809 + - 84810 + - 84811 + - 84812 + - 84813 + - 84814 + - 84815 + - 84816 + - 84817 + - 84818 + - 84819 + - 84820 + - 84821 + - 84822 + - 84823 + - 84824 + - 84825 + - 84826 + - 84827 + - 84828 + - 84829 + - 84830 + - 84831 + - 84832 + - 84833 + - 84834 + - 84835 + - 84836 + - 84837 + - 84838 + - 84839 + - 84840 + - 84841 + - 84842 + - 84843 + - 84844 + - 84845 + - 84846 + - 84847 + - 84848 + - 84849 + - 84850 + - 84851 + - 84852 + - 84853 + - 84854 + - 84855 + - 84856 + - 84857 + - 84858 + - 84859 + - 84860 + - 84861 + - 84862 + - 84863 + - 84864 + - 84865 + - 84866 + - 84867 + - 84868 + - 84869 + - 84870 + - 84871 + - 84872 + - 84873 + - 84874 + - 84875 + - 84876 + - 84877 + - 84878 + - 84879 + - 84880 + - 84881 + - 84882 + - 84883 + - 84884 + - 84885 + - 84886 + - 84887 + - 84888 + - 84889 + - 84890 + - 84891 + - 84892 + - 84893 + - 84894 + - 84895 + - 84896 + - 84897 + - 84898 + - 84899 + - 84900 + - 84901 + - 84902 + - 84903 + - 84904 + - 84905 + - 84906 + - 84907 + - 84908 + - 84909 + - 84910 + - 84911 + - 84912 + - 84913 + - 84914 + - 84915 + - 84916 + - 84917 + - 84918 + - 84919 + - 84920 + - 84921 + - 84922 + - 84923 + - 84924 + - 84925 + - 84926 + - 84927 + - 84928 + - 84929 + - 84930 + - 84931 + - 84932 + - 84933 + - 84934 + - 84935 + - 84936 + - 84937 + - 84938 + - 84939 + - 84940 + - 84941 + - 84942 + - 84943 + - 84944 + - 84945 + - 84946 + - 84947 + - 84948 + - 84949 + - 84950 + - 84951 + - 84952 + - 84953 + - 84954 + - 84955 + - 84956 + - 84957 + - 84958 + - 84959 + - 84960 + - 84961 + - 84962 + - 84963 + - 84964 + - 84965 + - 84966 + - 84967 + - 84968 + - 84969 + - 84970 + - 84971 + - 84972 + - 84973 + - 84974 + - 84975 + - 84976 + - 84977 + - 84978 + - 84979 + - 84980 + - 84981 + - 84982 + - 84983 + - 84984 + - 84985 + - 84986 + - 84987 + - 84988 + - 84989 + - 84990 + - 84991 + - 84992 + - 84993 + - 84994 + - 84995 + - 84996 + - 84997 + - 84998 + - 84999 + - 85000 + - 85001 + - 85002 + - 85003 + - 85004 + - 85005 + - 85006 + - 85007 + - 85008 + - 85009 + - 85010 + - 85011 + - 85012 + - 85013 + - 85014 + - 85015 + - 85016 + - 85017 + - 85018 + - 85019 + - 85020 + - 85021 + - 85022 + - 85023 + - 85024 + - 85025 + - 85026 + - 85027 + - 85028 + - 85029 + - 85030 + - 85031 + - 85032 + - 85033 + - 85034 + - 85035 + - 85036 + - 85037 + - 85038 + - 85039 + - 85040 + - 85041 + - 85042 + - 85043 + - 85044 + - 85045 + - 85046 + - 85047 + - 85048 + - 85049 + - 85050 + - 85051 + - 85052 + - 85053 + - 85054 + - 85055 + - 85056 + - 85057 + - 85058 + - 85059 + - 85060 + - 85061 + - 85062 + - 85063 + - 85064 + - 85065 + - 85066 + - 85067 + - 85068 + - 85069 + - 85070 + - 85071 + - 85072 + - 85073 + - 85074 + - 85075 + - 85076 + - 85077 + - 85078 + - 85079 + - 85080 + - 85081 + - 85082 + - 85083 + - 85084 + - 85085 + - 85086 + - 85087 + - 85088 + - 85089 + - 85090 + - 85091 + - 85092 + - 85093 + - 85094 + - 85095 + - 85096 + - 85097 + - 85098 + - 85099 + - 85100 + - 85101 + - 85102 + - 85103 + - 85104 + - 85105 + - 85106 + - 85107 + - 85108 + - 85109 + - 85110 + - 85111 + - 85112 + - 85113 + - 85114 + - 85115 + - 85116 + - 85117 + - 85118 + - 85119 + - 85120 + - 85121 + - 85122 + - 85123 + - 85124 + - 85125 + - 85126 + - 85127 + - 85128 + - 85129 + - 85130 + - 85131 + - 85132 + - 85133 + - 85134 + - 85135 + - 85136 + - 85137 + - 85138 + - 85139 + - 85140 + - 85141 + - 85142 + - 85143 + - 85144 + - 85145 + - 85146 + - 85147 + - 85148 + - 85149 + - 85150 + - 85151 + - 85152 + - 85153 + - 85154 + - 85155 + - 85156 + - 85157 + - 85158 + - 85159 + - 85160 + - 85161 + - 85162 + - 85163 + - 85164 + - 85165 + - 85166 + - 85167 + - 85168 + - 85169 + - 85170 + - 85171 + - 85172 + - 85173 + - 85174 + - 85175 + - 85176 + - 85177 + - 85178 + - 85179 + - 85180 + - 85181 + - 85182 + - 85183 + - 85184 + - 85185 + - 85186 + - 85187 + - 85188 + - 85189 + - 85190 + - 85191 + - 85192 + - 85193 + - 85194 + - 85195 + - 85196 + - 85197 + - 85198 + - 85199 + - 85200 + - 85201 + - 85202 + - 85203 + - 85204 + - 85205 + - 85206 + - 85207 + - 85208 + - 85209 + - 85210 + - 85211 + - 85212 + - 85213 + - 85214 + - 85215 + - 85216 + - 85217 + - 85218 + - 85219 + - 85220 + - 85221 + - 85222 + - 85223 + - 85224 + - 85225 + - 85226 + - 85227 + - 85228 + - 85229 + - 85230 + - 85231 + - 85232 + - 85233 + - 85234 + - 85235 + - 85236 + - 85237 + - 85238 + - 85239 + - 85240 + - 85241 + - 85242 + - 85243 + - 85244 + - 85245 + - 85246 + - 85247 + - 85248 + - 85249 + - 85250 + - 85251 + - 85252 + - 85253 + - 85254 + - 85255 + - 85256 + - 85257 + - 85258 + - 85259 + - 85260 + - 85261 + - 85262 + - 85263 + - 85264 + - 85265 + - 85266 + - 85267 + - 85268 + - 85269 + - 85270 + - 85271 + - 85272 + - 85273 + - 85274 + - 85275 + - 85276 + - 85277 + - 85278 + - 85279 + - 85280 + - 85281 + - 85282 + - 85283 + - 85284 + - 85285 + - 85286 + - 85287 + - 85288 + - 85289 + - 85290 + - 85291 + - 85292 + - 85293 + - 85294 + - 85295 + - 85296 + - 85297 + - 85298 + - 85299 + - 85300 + - 85301 + - 85302 + - 85303 + - 85304 + - 85305 + - 85306 + - 85307 + - 85308 + - 85309 + - 85310 + - 85311 + - 85312 + - 85313 + - 85314 + - 85315 + - 85316 + - 85317 + - 85318 + - 85319 + - 85320 + - 85321 + - 85322 + - 85323 + - 85324 + - 85325 + - 85326 + - 85327 + - 85328 + - 85329 + - 85330 + - 85331 + - 85332 + - 85333 + - 85334 + - 85335 + - 85336 + - 85337 + - 85338 + - 85339 + - 85340 + - 85341 + - 85342 + - 85343 + - 85344 + - 85345 + - 85346 + - 85347 + - 85348 + - 85349 + - 85350 + - 85351 + - 85352 + - 85353 + - 85354 + - 85355 + - 85356 + - 85357 + - 85358 + - 85359 + - 85360 + - 85361 + - 85362 + - 85363 + - 85364 + - 85365 + - 85366 + - 85367 + - 85368 + - 85369 + - 85370 + - 85371 + - 85372 + - 85373 + - 85374 + - 85375 + - 85376 + - 85377 + - 85378 + - 85379 + - 85380 + - 85381 + - 85382 + - 85383 + - 85384 + - 85385 + - 85386 + - 85387 + - 85388 + - 85389 + - 85390 + - 85391 + - 85392 + - 85393 + - 85394 + - 85395 + - 85396 + - 85397 + - 85398 + - 85399 + - 85400 + - 85401 + - 85402 + - 85403 + - 85404 + - 85405 + - 85406 + - 85407 + - 85408 + - 85409 + - 85410 + - 85411 + - 85412 + - 85413 + - 85414 + - 85415 + - 85416 + - 85417 + - 85418 + - 85419 + - 85420 + - 85421 + - 85422 + - 85423 + - 85424 + - 85425 + - 85426 + - 85427 + - 85428 + - 85429 + - 85430 + - 85431 + - 85432 + - 85433 + - 85434 + - 85435 + - 85436 + - 85437 + - 85438 + - 85439 + - 85440 + - 85441 + - 85442 + - 85443 + - 85444 + - 85445 + - 85446 + - 85447 + - 85448 + - 85449 + - 85450 + - 85451 + - 85452 + - 85453 + - 85454 + - 85455 + - 85456 + - 85457 + - 85458 + - 85459 + - 85460 + - 85461 + - 85462 + - 85463 + - 85464 + - 85465 + - 85466 + - 85467 + - 85468 + - 85469 + - 85470 + - 85471 + - 85472 + - 85473 + - 85474 + - 85475 + - 85476 + - 85477 + - 85478 + - 85479 + - 85480 + - 85481 + - 85482 + - 85483 + - 85484 + - 85485 + - 85486 + - 85487 + - 85488 + - 85489 + - 85490 + - 85491 + - 85492 + - 85493 + - 85494 + - 85495 + - 85496 + - 85497 + - 85498 + - 85499 + - 85500 + - 85501 + - 85502 + - 85503 + - 85504 + - 85505 + - 85506 + - 85507 + - 85508 + - 85509 + - 85510 + - 85511 + - 85512 + - 85513 + - 85514 + - 85515 + - 85516 + - 85517 + - 85518 + - 85519 + - 85520 + - 85521 + - 85522 + - 85523 + - 85524 + - 85525 + - 85526 + - 85527 + - 85528 + - 85529 + - 85530 + - 85531 + - 85532 + - 85533 + - 85534 + - 85535 + - 85536 + - 85537 + - 85538 + - 85539 + - 85540 + - 85541 + - 85542 + - 85543 + - 85544 + - 85545 + - 85546 + - 85547 + - 85548 + - 85549 + - 85550 + - 85551 + - 85552 + - 85553 + - 85554 + - 85555 + - 85556 + - 85557 + - 85558 + - 85559 + - 85560 + - 85561 + - 85562 + - 85563 + - 85564 + - 85565 + - 85566 + - 85567 + - 85568 + - 85569 + - 85570 + - 85571 + - 85572 + - 85573 + - 85574 + - 85575 + - 85576 + - 85577 + - 85578 + - 85579 + - 85580 + - 85581 + - 85582 + - 85583 + - 85584 + - 85585 + - 85586 + - 85587 + - 85588 + - 85589 + - 85590 + - 85591 + - 85592 + - 85593 + - 85594 + - 85595 + - 85596 + - 85597 + - 85598 + - 85599 + - 85600 + - 85601 + - 85602 + - 85603 + - 85604 + - 85605 + - 85606 + - 85607 + - 85608 + - 85609 + - 85610 + - 85611 + - 85612 + - 85613 + - 85614 + - 85615 + - 85616 + - 85617 + - 85618 + - 85619 + - 85620 + - 85621 + - 85622 + - 85623 + - 85624 + - 85625 + - 85626 + - 85627 + - 85628 + - 85629 + - 85630 + - 85631 + - 85632 + - 85633 + - 85634 + - 85635 + - 85636 + - 85637 + - 85638 + - 85639 + - 85640 + - 85641 + - 85642 + - 85643 + - 85644 + - 85645 + - 85646 + - 85647 + - 85648 + - 85649 + - 85650 + - 85651 + - 85652 + - 85653 + - 85654 + - 85655 + - 85656 + - 85657 + - 85658 + - 85659 + - 85660 + - 85661 + - 85662 + - 85663 + - 85664 + - 85665 + - 85666 + - 85667 + - 85668 + - 85669 + - 85670 + - 85671 + - 85672 + - 85673 + - 85674 + - 85675 + - 85676 + - 85677 + - 85678 + - 85679 + - 85680 + - 85681 + - 85682 + - 85683 + - 85684 + - 85685 + - 85686 + - 85687 + - 85688 + - 85689 + - 85690 + - 85691 + - 85692 + - 85693 + - 85694 + - 85695 + - 85696 + - 85697 + - 85698 + - 85699 + - 85700 + - 85701 + - 85702 + - 85703 + - 85704 + - 85705 + - 85706 + - 85707 + - 85708 + - 85709 + - 85710 + - 85711 + - 85712 + - 85713 + - 85714 + - 85715 + - 85716 + - 85717 + - 85718 + - 85719 + - 85720 + - 85721 + - 85722 + - 85723 + - 85724 + - 85725 + - 85726 + - 85727 + - 85728 + - 85729 + - 85730 + - 85731 + - 85732 + - 85733 + - 85734 + - 85735 + - 85736 + - 85737 + - 85738 + - 85739 + - 85740 + - 85741 + - 85742 + - 85743 + - 85744 + - 85745 + - 85746 + - 85747 + - 85748 + - 85749 + - 85750 + - 85751 + - 85752 + - 85753 + - 85754 + - 85755 + - 85756 + - 85757 + - 85758 + - 85759 + - 85760 + - 85761 + - 85762 + - 85763 + - 85764 + - 85765 + - 85766 + - 85767 + - 85768 + - 85769 + - 85770 + - 85771 + - 85772 + - 85773 + - 85774 + - 85775 + - 85776 + - 85777 + - 85778 + - 85779 + - 85780 + - 85781 + - 85782 + - 85783 + - 85784 + - 85785 + - 85786 + - 85787 + - 85788 + - 85789 + - 85790 + - 85791 + - 85792 + - 85793 + - 85794 + - 85795 + - 85796 + - 85797 + - 85798 + - 85799 + - 85800 + - 85801 + - 85802 + - 85803 + - 85804 + - 85805 + - 85806 + - 85807 + - 85808 + - 85809 + - 85810 + - 85811 + - 85812 + - 85813 + - 85814 + - 85815 + - 85816 + - 85817 + - 85818 + - 85819 + - 85820 + - 85821 + - 85822 + - 85823 + - 85824 + - 85825 + - 85826 + - 85827 + - 85828 + - 85829 + - 85830 + - 85831 + - 85832 + - 85833 + - 85834 + - 85835 + - 85836 + - 85837 + - 85838 + - 85839 + - 85840 + - 85841 + - 85842 + - 85843 + - 85844 + - 85845 + - 85846 + - 85847 + - 85848 + - 85849 + - 85850 + - 85851 + - 85852 + - 85853 + - 85854 + - 85855 + - 85856 + - 85857 + - 85858 + - 85859 + - 85860 + - 85861 + - 85862 + - 85863 + - 85864 + - 85865 + - 85866 + - 85867 + - 85868 + - 85869 + - 85870 + - 85871 + - 85872 + - 85873 + - 85874 + - 85875 + - 85876 + - 85877 + - 85878 + - 85879 + - 85880 + - 85881 + - 85882 + - 85883 + - 85884 + - 85885 + - 85886 + - 85887 + - 85888 + - 85889 + - 85890 + - 85891 + - 85892 + - 85893 + - 85894 + - 85895 + - 85896 + - 85897 + - 85898 + - 85899 + - 85900 + - 85901 + - 85902 + - 85903 + - 85904 + - 85905 + - 85906 + - 85907 + - 85908 + - 85909 + - 85910 + - 85911 + - 85912 + - 85913 + - 85914 + - 85915 + - 85916 + - 85917 + - 85918 + - 85919 + - 85920 + - 85921 + - 85922 + - 85923 + - 85924 + - 85925 + - 85926 + - 85927 + - 85928 + - 85929 + - 85930 + - 85931 + - 85932 + - 85933 + - 85934 + - 85935 + - 85936 + - 85937 + - 85938 + - 85939 + - 85940 + - 85941 + - 85942 + - 85943 + - 85944 + - 85945 + - 85946 + - 85947 + - 85948 + - 85949 + - 85950 + - 85951 + - 85952 + - 85953 + - 85954 + - 85955 + - 85956 + - 85957 + - 85958 + - 85959 + - 85960 + - 85961 + - 85962 + - 85963 + - 85964 + - 85965 + - 85966 + - 85967 + - 85968 + - 85969 + - 85970 + - 85971 + - 85972 + - 85973 + - 85974 + - 85975 + - 85976 + - 85977 + - 85978 + - 85979 + - 85980 + - 85981 + - 85982 + - 85983 + - 85984 + - 85985 + - 85986 + - 85987 + - 85988 + - 85989 + - 85990 + - 85991 + - 85992 + - 85993 + - 85994 + - 85995 + - 85996 + - 85997 + - 85998 + - 85999 + - 86000 + - 86001 + - 86002 + - 86003 + - 86004 + - 86005 + - 86006 + - 86007 + - 86008 + - 86009 + - 86010 + - 86011 + - 86012 + - 86013 + - 86014 + - 86015 + - 86016 + - 86017 + - 86018 + - 86019 + - 86020 + - 86021 + - 86022 + - 86023 + - 86024 + - 86025 + - 86026 + - 86027 + - 86028 + - 86029 + - 86030 + - 86031 + - 86032 + - 86033 + - 86034 + - 86035 + - 86036 + - 86037 + - 86038 + - 86039 + - 86040 + - 86041 + - 86042 + - 86043 + - 86044 + - 86045 + - 86046 + - 86047 + - 86048 + - 86049 + - 86050 + - 86051 + - 86052 + - 86053 + - 86054 + - 86055 + - 86056 + - 86057 + - 86058 + - 86059 + - 86060 + - 86061 + - 86062 + - 86063 + - 86064 + - 86065 + - 86066 + - 86067 + - 86068 + - 86069 + - 86070 + - 86071 + - 86072 + - 86073 + - 86074 + - 86075 + - 86076 + - 86077 + - 86078 + - 86079 + - 86080 + - 86081 + - 86082 + - 86083 + - 86084 + - 86085 + - 86086 + - 86087 + - 86088 + - 86089 + - 86090 + - 86091 + - 86092 + - 86093 + - 86094 + - 86095 + - 86096 + - 86097 + - 86098 + - 86099 + - 86100 + - 86101 + - 86102 + - 86103 + - 86104 + - 86105 + - 86106 + - 86107 + - 86108 + - 86109 + - 86110 + - 86111 + - 86112 + - 86113 + - 86114 + - 86115 + - 86116 + - 86117 + - 86118 + - 86119 + - 86120 + - 86121 + - 86122 + - 86123 + - 86124 + - 86125 + - 86126 + - 86127 + - 86128 + - 86129 + - 86130 + - 86131 + - 86132 + - 86133 + - 86134 + - 86135 + - 86136 + - 86137 + - 86138 + - 86139 + - 86140 + - 86141 + - 86142 + - 86143 + - 86144 + - 86145 + - 86146 + - 86147 + - 86148 + - 86149 + - 86150 + - 86151 + - 86152 + - 86153 + - 86154 + - 86155 + - 86156 + - 86157 + - 86158 + - 86159 + - 86160 + - 86161 + - 86162 + - 86163 + - 86164 + - 86165 + - 86166 + - 86167 + - 86168 + - 86169 + - 86170 + - 86171 + - 86172 + - 86173 + - 86174 + - 86175 + - 86176 + - 86177 + - 86178 + - 86179 + - 86180 + - 86181 + - 86182 + - 86183 + - 86184 + - 86185 + - 86186 + - 86187 + - 86188 + - 86189 + - 86190 + - 86191 + - 86192 + - 86193 + - 86194 + - 86195 + - 86196 + - 86197 + - 86198 + - 86199 + - 86200 + - 86201 + - 86202 + - 86203 + - 86204 + - 86205 + - 86206 + - 86207 + - 86208 + - 86209 + - 86210 + - 86211 + - 86212 + - 86213 + - 86214 + - 86215 + - 86216 + - 86217 + - 86218 + - 86219 + - 86220 + - 86221 + - 86222 + - 86223 + - 86224 + - 86225 + - 86226 + - 86227 + - 86228 + - 86229 + - 86230 + - 86231 + - 86232 + - 86233 + - 86234 + - 86235 + - 86236 + - 86237 + - 86238 + - 86239 + - 86240 + - 86241 + - 86242 + - 86243 + - 86244 + - 86245 + - 86246 + - 86247 + - 86248 + - 86249 + - 86250 + - 86251 + - 86252 + - 86253 + - 86254 + - 86255 + - 86256 + - 86257 + - 86258 + - 86259 + - 86260 + - 86261 + - 86262 + - 86263 + - 86264 + - 86265 + - 86266 + - 86267 + - 86268 + - 86269 + - 86270 + - 86271 + - 86272 + - 86273 + - 86274 + - 86275 + - 86276 + - 86277 + - 86278 + - 86279 + - 86280 + - 86281 + - 86282 + - 86283 + - 86284 + - 86285 + - 86286 + - 86287 + - 86288 + - 86289 + - 86290 + - 86291 + - 86292 + - 86293 + - 86294 + - 86295 + - 86296 + - 86297 + - 86298 + - 86299 + - 86300 + - 86301 + - 86302 + - 86303 + - 86304 + - 86305 + - 86306 + - 86307 + - 86308 + - 86309 + - 86310 + - 86311 + - 86312 + - 86313 + - 86314 + - 86315 + - 86316 + - 86317 + - 86318 + - 86319 + - 86320 + - 86321 + - 86322 + - 86323 + - 86324 + - 86325 + - 86326 + - 86327 + - 86328 + - 86329 + - 86330 + - 86331 + - 86332 + - 86333 + - 86334 + - 86335 + - 86336 + - 86337 + - 86338 + - 86339 + - 86340 + - 86341 + - 86342 + - 86343 + - 86344 + - 86345 + - 86346 + - 86347 + - 86348 + - 86349 + - 86350 + - 86351 + - 86352 + - 86353 + - 86354 + - 86355 + - 86356 + - 86357 + - 86358 + - 86359 + - 86360 + - 86361 + - 86362 + - 86363 + - 86364 + - 86365 + - 86366 + - 86367 + - 86368 + - 86369 + - 86370 + - 86371 + - 86372 + - 86373 + - 86374 + - 86375 + - 86376 + - 86377 + - 86378 + - 86379 + - 86380 + - 86381 + - 86382 + - 86383 + - 86384 + - 86385 + - 86386 + - 86387 + - 86388 + - 86389 + - 86390 + - 86391 + - 86392 + - 86393 + - 86394 + - 86395 + - 86396 + - 86397 + - 86398 + - 86399 + - 86400 + - 86401 + - 86402 + - 86403 + - 86404 + - 86405 + - 86406 + - 86407 + - 86408 + - 86409 + - 86410 + - 86411 + - 86412 + - 86413 + - 86414 + - 86415 + - 86416 + - 86417 + - 86418 + - 86419 + - 86420 + - 86421 + - 86422 + - 86423 + - 86424 + - 86425 + - 86426 + - 86427 + - 86428 + - 86429 + - 86430 + - 86431 + - 86432 + - 86433 + - 86434 + - 86435 + - 86436 + - 86437 + - 86438 + - 86439 + - 86440 + - 86441 + - 86442 + - 86443 + - 86444 + - 86445 + - 86446 + - 86447 + - 86448 + - 86449 + - 86450 + - 86451 + - 86452 + - 86453 + - 86454 + - 86455 + - 86456 + - 86457 + - 86458 + - 86459 + - 86460 + - 86461 + - 86462 + - 86463 + - 86464 + - 86465 + - 86466 + - 86467 + - 86468 + - 86469 + - 86470 + - 86471 + - 86472 + - 86473 + - 86474 + - 86475 + - 86476 + - 86477 + - 86478 + - 86479 + - 86480 + - 86481 + - 86482 + - 86483 + - 86484 + - 86485 + - 86486 + - 86487 + - 86488 + - 86489 + - 86490 + - 86491 + - 86492 + - 86493 + - 86494 + - 86495 + - 86496 + - 86497 + - 86498 + - 86499 + - 86500 + - 86501 + - 86502 + - 86503 + - 86504 + - 86505 + - 86506 + - 86507 + - 86508 + - 86509 + - 86510 + - 86511 + - 86512 + - 86513 + - 86514 + - 86515 + - 86516 + - 86517 + - 86518 + - 86519 + - 86520 + - 86521 + - 86522 + - 86523 + - 86524 + - 86525 + - 86526 + - 86527 + - 86528 + - 86529 + - 86530 + - 86531 + - 86532 + - 86533 + - 86534 + - 86535 + - 86536 + - 86537 + - 86538 + - 86539 + - 86540 + - 86541 + - 86542 + - 86543 + - 86544 + - 86545 + - 86546 + - 86547 + - 86548 + - 86549 + - 86550 + - 86551 + - 86552 + - 86553 + - 86554 + - 86555 + - 86556 + - 86557 + - 86558 + - 86559 + - 86560 + - 86561 + - 86562 + - 86563 + - 86564 + - 86565 + - 86566 + - 86567 + - 86568 + - 86569 + - 86570 + - 86571 + - 86572 + - 86573 + - 86574 + - 86575 + - 86576 + - 86577 + - 86578 + - 86579 + - 86580 + - 86581 + - 86582 + - 86583 + - 86584 + - 86585 + - 86586 + - 86587 + - 86588 + - 86589 + - 86590 + - 86591 + - 86592 + - 86593 + - 86594 + - 86595 + - 86596 + - 86597 + - 86598 + - 86599 + - 86600 + - 86601 + - 86602 + - 86603 + - 86604 + - 86605 + - 86606 + - 86607 + - 86608 + - 86609 + - 86610 + - 86611 + - 86612 + - 86613 + - 86614 + - 86615 + - 86616 + - 86617 + - 86618 + - 86619 + - 86620 + - 86621 + - 86622 + - 86623 + - 86624 + - 86625 + - 86626 + - 86627 + - 86628 + - 86629 + - 86630 + - 86631 + - 86632 + - 86633 + - 86634 + - 86635 + - 86636 + - 86637 + - 86638 + - 86639 + - 86640 + - 86641 + - 86642 + - 86643 + - 86644 + - 86645 + - 86646 + - 86647 + - 86648 + - 86649 + - 86650 + - 86651 + - 86652 + - 86653 + - 86654 + - 86655 + - 86656 + - 86657 + - 86658 + - 86659 + - 86660 + - 86661 + - 86662 + - 86663 + - 86664 + - 86665 + - 86666 + - 86667 + - 86668 + - 86669 + - 86670 + - 86671 + - 86672 + - 86673 + - 86674 + - 86675 + - 86676 + - 86677 + - 86678 + - 86679 + - 86680 + - 86681 + - 86682 + - 86683 + - 86684 + - 86685 + - 86686 + - 86687 + - 86688 + - 86689 + - 86690 + - 86691 + - 86692 + - 86693 + - 86694 + - 86695 + - 86696 + - 86697 + - 86698 + - 86699 + - 86700 + - 86701 + - 86702 + - 86703 + - 86704 + - 86705 + - 86706 + - 86707 + - 86708 + - 86709 + - 86710 + - 86711 + - 86712 + - 86713 + - 86714 + - 86715 + - 86716 + - 86717 + - 86718 + - 86719 + - 86720 + - 86721 + - 86722 + - 86723 + - 86724 + - 86725 + - 86726 + - 86727 + - 86728 + - 86729 + - 86730 + - 86731 + - 86732 + - 86733 + - 86734 + - 86735 + - 86736 + - 86737 + - 86738 + - 86739 + - 86740 + - 86741 + - 86742 + - 86743 + - 86744 + - 86745 + - 86746 + - 86747 + - 86748 + - 86749 + - 86750 + - 86751 + - 86752 + - 86753 + - 86754 + - 86755 + - 86756 + - 86757 + - 86758 + - 86759 + - 86760 + - 86761 + - 86762 + - 86763 + - 86764 + - 86765 + - 86766 + - 86767 + - 86768 + - 86769 + - 86770 + - 86771 + - 86772 + - 86773 + - 86774 + - 86775 + - 86776 + - 86777 + - 86778 + - 86779 + - 86780 + - 86781 + - 86782 + - 86783 + - 86784 + - 86785 + - 86786 + - 86787 + - 86788 + - 86789 + - 86790 + - 86791 + - 86792 + - 86793 + - 86794 + - 86795 + - 86796 + - 86797 + - 86798 + - 86799 + - 86800 + - 86801 + - 86802 + - 86803 + - 86804 + - 86805 + - 86806 + - 86807 + - 86808 + - 86809 + - 86810 + - 86811 + - 86812 + - 86813 + - 86814 + - 86815 + - 86816 + - 86817 + - 86818 + - 86819 + - 86820 + - 86821 + - 86822 + - 86823 + - 86824 + - 86825 + - 86826 + - 86827 + - 86828 + - 86829 + - 86830 + - 86831 + - 86832 + - 86833 + - 86834 + - 86835 + - 86836 + - 86837 + - 86838 + - 86839 + - 86840 + - 86841 + - 86842 + - 86843 + - 86844 + - 86845 + - 86846 + - 86847 + - 86848 + - 86849 + - 86850 + - 86851 + - 86852 + - 86853 + - 86854 + - 86855 + - 86856 + - 86857 + - 86858 + - 86859 + - 86860 + - 86861 + - 86862 + - 86863 + - 86864 + - 86865 + - 86866 + - 86867 + - 86868 + - 86869 + - 86870 + - 86871 + - 86872 + - 86873 + - 86874 + - 86875 + - 86876 + - 86877 + - 86878 + - 86879 + - 86880 + - 86881 + - 86882 + - 86883 + - 86884 + - 86885 + - 86886 + - 86887 + - 86888 + - 86889 + - 86890 + - 86891 + - 86892 + - 86893 + - 86894 + - 86895 + - 86896 + - 86897 + - 86898 + - 86899 + - 86900 + - 86901 + - 86902 + - 86903 + - 86904 + - 86905 + - 86906 + - 86907 + - 86908 + - 86909 + - 86910 + - 86911 + - 86912 + - 86913 + - 86914 + - 86915 + - 86916 + - 86917 + - 86918 + - 86919 + - 86920 + - 86921 + - 86922 + - 86923 + - 86924 + - 86925 + - 86926 + - 86927 + - 86928 + - 86929 + - 86930 + - 86931 + - 86932 + - 86933 + - 86934 + - 86935 + - 86936 + - 86937 + - 86938 + - 86939 + - 86940 + - 86941 + - 86942 + - 86943 + - 86944 + - 86945 + - 86946 + - 86947 + - 86948 + - 86949 + - 86950 + - 86951 + - 86952 + - 86953 + - 86954 + - 86955 + - 86956 + - 86957 + - 86958 + - 86959 + - 86960 + - 86961 + - 86962 + - 86963 + - 86964 + - 86965 + - 86966 + - 86967 + - 86968 + - 86969 + - 86970 + - 86971 + - 86972 + - 86973 + - 86974 + - 86975 + - 86976 + - 86977 + - 86978 + - 86979 + - 86980 + - 86981 + - 86982 + - 86983 + - 86984 + - 86985 + - 86986 + - 86987 + - 86988 + - 86989 + - 86990 + - 86991 + - 86992 + - 86993 + - 86994 + - 86995 + - 86996 + - 86997 + - 86998 + - 86999 + - 87000 + - 87001 + - 87002 + - 87003 + - 87004 + - 87005 + - 87006 + - 87007 + - 87008 + - 87009 + - 87010 + - 87011 + - 87012 + - 87013 + - 87014 + - 87015 + - 87016 + - 87017 + - 87018 + - 87019 + - 87020 + - 87021 + - 87022 + - 87023 + - 87024 + - 87025 + - 87026 + - 87027 + - 87028 + - 87029 + - 87030 + - 87031 + - 87032 + - 87033 + - 87034 + - 87035 + - 87036 + - 87037 + - 87038 + - 87039 + - 87040 + - 87041 + - 87042 + - 87043 + - 87044 + - 87045 + - 87046 + - 87047 + - 87048 + - 87049 + - 87050 + - 87051 + - 87052 + - 87053 + - 87054 + - 87055 + - 87056 + - 87057 + - 87058 + - 87059 + - 87060 + - 87061 + - 87062 + - 87063 + - 87064 + - 87065 + - 87066 + - 87067 + - 87068 + - 87069 + - 87070 + - 87071 + - 87072 + - 87073 + - 87074 + - 87075 + - 87076 + - 87077 + - 87078 + - 87079 + - 87080 + - 87081 + - 87082 + - 87083 + - 87084 + - 87085 + - 87086 + - 87087 + - 87088 + - 87089 + - 87090 + - 87091 + - 87092 + - 87093 + - 87094 + - 87095 + - 87096 + - 87097 + - 87098 + - 87099 + - 87100 + - 87101 + - 87102 + - 87103 + - 87104 + - 87105 + - 87106 + - 87107 + - 87108 + - 87109 + - 87110 + - 87111 + - 87112 + - 87113 + - 87114 + - 87115 + - 87116 + - 87117 + - 87118 + - 87119 + - 87120 + - 87121 + - 87122 + - 87123 + - 87124 + - 87125 + - 87126 + - 87127 + - 87128 + - 87129 + - 87130 + - 87131 + - 87132 + - 87133 + - 87134 + - 87135 + - 87136 + - 87137 + - 87138 + - 87139 + - 87140 + - 87141 + - 87142 + - 87143 + - 87144 + - 87145 + - 87146 + - 87147 + - 87148 + - 87149 + - 87150 + - 87151 + - 87152 + - 87153 + - 87154 + - 87155 + - 87156 + - 87157 + - 87158 + - 87159 + - 87160 + - 87161 + - 87162 + - 87163 + - 87164 + - 87165 + - 87166 + - 87167 + - 87168 + - 87169 + - 87170 + - 87171 + - 87172 + - 87173 + - 87174 + - 87175 + - 87176 + - 87177 + - 87178 + - 87179 + - 87180 + - 87181 + - 87182 + - 87183 + - 87184 + - 87185 + - 87186 + - 87187 + - 87188 + - 87189 + - 87190 + - 87191 + - 87192 + - 87193 + - 87194 + - 87195 + - 87196 + - 87197 + - 87198 + - 87199 + - 87200 + - 87201 + - 87202 + - 87203 + - 87204 + - 87205 + - 87206 + - 87207 + - 87208 + - 87209 + - 87210 + - 87211 + - 87212 + - 87213 + - 87214 + - 87215 + - 87216 + - 87217 + - 87218 + - 87219 + - 87220 + - 87221 + - 87222 + - 87223 + - 87224 + - 87225 + - 87226 + - 87227 + - 87228 + - 87229 + - 87230 + - 87231 + - 87232 + - 87233 + - 87234 + - 87235 + - 87236 + - 87237 + - 87238 + - 87239 + - 87240 + - 87241 + - 87242 + - 87243 + - 87244 + - 87245 + - 87246 + - 87247 + - 87248 + - 87249 + - 87250 + - 87251 + - 87252 + - 87253 + - 87254 + - 87255 + - 87256 + - 87257 + - 87258 + - 87259 + - 87260 + - 87261 + - 87262 + - 87263 + - 87264 + - 87265 + - 87266 + - 87267 + - 87268 + - 87269 + - 87270 + - 87271 + - 87272 + - 87273 + - 87274 + - 87275 + - 87276 + - 87277 + - 87278 + - 87279 + - 87280 + - 87281 + - 87282 + - 87283 + - 87284 + - 87285 + - 87286 + - 87287 + - 87288 + - 87289 + - 87290 + - 87291 + - 87292 + - 87293 + - 87294 + - 87295 + - 87296 + - 87297 + - 87298 + - 87299 + - 87300 + - 87301 + - 87302 + - 87303 + - 87304 + - 87305 + - 87306 + - 87307 + - 87308 + - 87309 + - 87310 + - 87311 + - 87312 + - 87313 + - 87314 + - 87315 + - 87316 + - 87317 + - 87318 + - 87319 + - 87320 + - 87321 + - 87322 + - 87323 + - 87324 + - 87325 + - 87326 + - 87327 + - 87328 + - 87329 + - 87330 + - 87331 + - 87332 + - 87333 + - 87334 + - 87335 + - 87336 + - 87337 + - 87338 + - 87339 + - 87340 + - 87341 + - 87342 + - 87343 + - 87344 + - 87345 + - 87346 + - 87347 + - 87348 + - 87349 + - 87350 + - 87351 + - 87352 + - 87353 + - 87354 + - 87355 + - 87356 + - 87357 + - 87358 + - 87359 + - 87360 + - 87361 + - 87362 + - 87363 + - 87364 + - 87365 + - 87366 + - 87367 + - 87368 + - 87369 + - 87370 + - 87371 + - 87372 + - 87373 + - 87374 + - 87375 + - 87376 + - 87377 + - 87378 + - 87379 + - 87380 + - 87381 + - 87382 + - 87383 + - 87384 + - 87385 + - 87386 + - 87387 + - 87388 + - 87389 + - 87390 + - 87391 + - 87392 + - 87393 + - 87394 + - 87395 + - 87396 + - 87397 + - 87398 + - 87399 + - 87400 + - 87401 + - 87402 + - 87403 + - 87404 + - 87405 + - 87406 + - 87407 + - 87408 + - 87409 + - 87410 + - 87411 + - 87412 + - 87413 + - 87414 + - 87415 + - 87416 + - 87417 + - 87418 + - 87419 + - 87420 + - 87421 + - 87422 + - 87423 + - 87424 + - 87425 + - 87426 + - 87427 + - 87428 + - 87429 + - 87430 + - 87431 + - 87432 + - 87433 + - 87434 + - 87435 + - 87436 + - 87437 + - 87438 + - 87439 + - 87440 + - 87441 + - 87442 + - 87443 + - 87444 + - 87445 + - 87446 + - 87447 + - 87448 + - 87449 + - 87450 + - 87451 + - 87452 + - 87453 + - 87454 + - 87455 + - 87456 + - 87457 + - 87458 + - 87459 + - 87460 + - 87461 + - 87462 + - 87463 + - 87464 + - 87465 + - 87466 + - 87467 + - 87468 + - 87469 + - 87470 + - 87471 + - 87472 + - 87473 + - 87474 + - 87475 + - 87476 + - 87477 + - 87478 + - 87479 + - 87480 + - 87481 + - 87482 + - 87483 + - 87484 + - 87485 + - 87486 + - 87487 + - 87488 + - 87489 + - 87490 + - 87491 + - 87492 + - 87493 + - 87494 + - 87495 + - 87496 + - 87497 + - 87498 + - 87499 + - 87500 + - 87501 + - 87502 + - 87503 + - 87504 + - 87505 + - 87506 + - 87507 + - 87508 + - 87509 + - 87510 + - 87511 + - 87512 + - 87513 + - 87514 + - 87515 + - 87516 + - 87517 + - 87518 + - 87519 + - 87520 + - 87521 + - 87522 + - 87523 + - 87524 + - 87525 + - 87526 + - 87527 + - 87528 + - 87529 + - 87530 + - 87531 + - 87532 + - 87533 + - 87534 + - 87535 + - 87536 + - 87537 + - 87538 + - 87539 + - 87540 + - 87541 + - 87542 + - 87543 + - 87544 + - 87545 + - 87546 + - 87547 + - 87548 + - 87549 + - 87550 + - 87551 + - 87552 + - 87553 + - 87554 + - 87555 + - 87556 + - 87557 + - 87558 + - 87559 + - 87560 + - 87561 + - 87562 + - 87563 + - 87564 + - 87565 + - 87566 + - 87567 + - 87568 + - 87569 + - 87570 + - 87571 + - 87572 + - 87573 + - 87574 + - 87575 + - 87576 + - 87577 + - 87578 + - 87579 + - 87580 + - 87581 + - 87582 + - 87583 + - 87584 + - 87585 + - 87586 + - 87587 + - 87588 + - 87589 + - 87590 + - 87591 + - 87592 + - 87593 + - 87594 + - 87595 + - 87596 + - 87597 + - 87598 + - 87599 + - 87600 + - 87601 + - 87602 + - 87603 + - 87604 + - 87605 + - 87606 + - 87607 + - 87608 + - 87609 + - 87610 + - 87611 + - 87612 + - 87613 + - 87614 + - 87615 + - 87616 + - 87617 + - 87618 + - 87619 + - 87620 + - 87621 + - 87622 + - 87623 + - 87624 + - 87625 + - 87626 + - 87627 + - 87628 + - 87629 + - 87630 + - 87631 + - 87632 + - 87633 + - 87634 + - 87635 + - 87636 + - 87637 + - 87638 + - 87639 + - 87640 + - 87641 + - 87642 + - 87643 + - 87644 + - 87645 + - 87646 + - 87647 + - 87648 + - 87649 + - 87650 + - 87651 + - 87652 + - 87653 + - 87654 + - 87655 + - 87656 + - 87657 + - 87658 + - 87659 + - 87660 + - 87661 + - 87662 + - 87663 + - 87664 + - 87665 + - 87666 + - 87667 + - 87668 + - 87669 + - 87670 + - 87671 + - 87672 + - 87673 + - 87674 + - 87675 + - 87676 + - 87677 + - 87678 + - 87679 + - 87680 + - 87681 + - 87682 + - 87683 + - 87684 + - 87685 + - 87686 + - 87687 + - 87688 + - 87689 + - 87690 + - 87691 + - 87692 + - 87693 + - 87694 + - 87695 + - 87696 + - 87697 + - 87698 + - 87699 + - 87700 + - 87701 + - 87702 + - 87703 + - 87704 + - 87705 + - 87706 + - 87707 + - 87708 + - 87709 + - 87710 + - 87711 + - 87712 + - 87713 + - 87714 + - 87715 + - 87716 + - 87717 + - 87718 + - 87719 + - 87720 + - 87721 + - 87722 + - 87723 + - 87724 + - 87725 + - 87726 + - 87727 + - 87728 + - 87729 + - 87730 + - 87731 + - 87732 + - 87733 + - 87734 + - 87735 + - 87736 + - 87737 + - 87738 + - 87739 + - 87740 + - 87741 + - 87742 + - 87743 + - 87744 + - 87745 + - 87746 + - 87747 + - 87748 + - 87749 + - 87750 + - 87751 + - 87752 + - 87753 + - 87754 + - 87755 + - 87756 + - 87757 + - 87758 + - 87759 + - 87760 + - 87761 + - 87762 + - 87763 + - 87764 + - 87765 + - 87766 + - 87767 + - 87768 + - 87769 + - 87770 + - 87771 + - 87772 + - 87773 + - 87774 + - 87775 + - 87776 + - 87777 + - 87778 + - 87779 + - 87780 + - 87781 + - 87782 + - 87783 + - 87784 + - 87785 + - 87786 + - 87787 + - 87788 + - 87789 + - 87790 + - 87791 + - 87792 + - 87793 + - 87794 + - 87795 + - 87796 + - 87797 + - 87798 + - 87799 + - 87800 + - 87801 + - 87802 + - 87803 + - 87804 + - 87805 + - 87806 + - 87807 + - 87808 + - 87809 + - 87810 + - 87811 + - 87812 + - 87813 + - 87814 + - 87815 + - 87816 + - 87817 + - 87818 + - 87819 + - 87820 + - 87821 + - 87822 + - 87823 + - 87824 + - 87825 + - 87826 + - 87827 + - 87828 + - 87829 + - 87830 + - 87831 + - 87832 + - 87833 + - 87834 + - 87835 + - 87836 + - 87837 + - 87838 + - 87839 + - 87840 + - 87841 + - 87842 + - 87843 + - 87844 + - 87845 + - 87846 + - 87847 + - 87848 + - 87849 + - 87850 + - 87851 + - 87852 + - 87853 + - 87854 + - 87855 + - 87856 + - 87857 + - 87858 + - 87859 + - 87860 + - 87861 + - 87862 + - 87863 + - 87864 + - 87865 + - 87866 + - 87867 + - 87868 + - 87869 + - 87870 + - 87871 + - 87872 + - 87873 + - 87874 + - 87875 + - 87876 + - 87877 + - 87878 + - 87879 + - 87880 + - 87881 + - 87882 + - 87883 + - 87884 + - 87885 + - 87886 + - 87887 + - 87888 + - 87889 + - 87890 + - 87891 + - 87892 + - 87893 + - 87894 + - 87895 + - 87896 + - 87897 + - 87898 + - 87899 + - 87900 + - 87901 + - 87902 + - 87903 + - 87904 + - 87905 + - 87906 + - 87907 + - 87908 + - 87909 + - 87910 + - 87911 + - 87912 + - 87913 + - 87914 + - 87915 + - 87916 + - 87917 + - 87918 + - 87919 + - 87920 + - 87921 + - 87922 + - 87923 + - 87924 + - 87925 + - 87926 + - 87927 + - 87928 + - 87929 + - 87930 + - 87931 + - 87932 + - 87933 + - 87934 + - 87935 + - 87936 + - 87937 + - 87938 + - 87939 + - 87940 + - 87941 + - 87942 + - 87943 + - 87944 + - 87945 + - 87946 + - 87947 + - 87948 + - 87949 + - 87950 + - 87951 + - 87952 + - 87953 + - 87954 + - 87955 + - 87956 + - 87957 + - 87958 + - 87959 + - 87960 + - 87961 + - 87962 + - 87963 + - 87964 + - 87965 + - 87966 + - 87967 + - 87968 + - 87969 + - 87970 + - 87971 + - 87972 + - 87973 + - 87974 + - 87975 + - 87976 + - 87977 + - 87978 + - 87979 + - 87980 + - 87981 + - 87982 + - 87983 + - 87984 + - 87985 + - 87986 + - 87987 + - 87988 + - 87989 + - 87990 + - 87991 + - 87992 + - 87993 + - 87994 + - 87995 + - 87996 + - 87997 + - 87998 + - 87999 + - 88000 + - 88001 + - 88002 + - 88003 + - 88004 + - 88005 + - 88006 + - 88007 + - 88008 + - 88009 + - 88010 + - 88011 + - 88012 + - 88013 + - 88014 + - 88015 + - 88016 + - 88017 + - 88018 + - 88019 + - 88020 + - 88021 + - 88022 + - 88023 + - 88024 + - 88025 + - 88026 + - 88027 + - 88028 + - 88029 + - 88030 + - 88031 + - 88032 + - 88033 + - 88034 + - 88035 + - 88036 + - 88037 + - 88038 + - 88039 + - 88040 + - 88041 + - 88042 + - 88043 + - 88044 + - 88045 + - 88046 + - 88047 + - 88048 + - 88049 + - 88050 + - 88051 + - 88052 + - 88053 + - 88054 + - 88055 + - 88056 + - 88057 + - 88058 + - 88059 + - 88060 + - 88061 + - 88062 + - 88063 + - 88064 + - 88065 + - 88066 + - 88067 + - 88068 + - 88069 + - 88070 + - 88071 + - 88072 + - 88073 + - 88074 + - 88075 + - 88076 + - 88077 + - 88078 + - 88079 + - 88080 + - 88081 + - 88082 + - 88083 + - 88084 + - 88085 + - 88086 + - 88087 + - 88088 + - 88089 + - 88090 + - 88091 + - 88092 + - 88093 + - 88094 + - 88095 + - 88096 + - 88097 + - 88098 + - 88099 + - 88100 + - 88101 + - 88102 + - 88103 + - 88104 + - 88105 + - 88106 + - 88107 + - 88108 + - 88109 + - 88110 + - 88111 + - 88112 + - 88113 + - 88114 + - 88115 + - 88116 + - 88117 + - 88118 + - 88119 + - 88120 + - 88121 + - 88122 + - 88123 + - 88124 + - 88125 + - 88126 + - 88127 + - 88128 + - 88129 + - 88130 + - 88131 + - 88132 + - 88133 + - 88134 + - 88135 + - 88136 + - 88137 + - 88138 + - 88139 + - 88140 + - 88141 + - 88142 + - 88143 + - 88144 + - 88145 + - 88146 + - 88147 + - 88148 + - 88149 + - 88150 + - 88151 + - 88152 + - 88153 + - 88154 + - 88155 + - 88156 + - 88157 + - 88158 + - 88159 + - 88160 + - 88161 + - 88162 + - 88163 + - 88164 + - 88165 + - 88166 + - 88167 + - 88168 + - 88169 + - 88170 + - 88171 + - 88172 + - 88173 + - 88174 + - 88175 + - 88176 + - 88177 + - 88178 + - 88179 + - 88180 + - 88181 + - 88182 + - 88183 + - 88184 + - 88185 + - 88186 + - 88187 + - 88188 + - 88189 + - 88190 + - 88191 + - 88192 + - 88193 + - 88194 + - 88195 + - 88196 + - 88197 + - 88198 + - 88199 + - 88200 + - 88201 + - 88202 + - 88203 + - 88204 + - 88205 + - 88206 + - 88207 + - 88208 + - 88209 + - 88210 + - 88211 + - 88212 + - 88213 + - 88214 + - 88215 + - 88216 + - 88217 + - 88218 + - 88219 + - 88220 + - 88221 + - 88222 + - 88223 + - 88224 + - 88225 + - 88226 + - 88227 + - 88228 + - 88229 + - 88230 + - 88231 + - 88232 + - 88233 + - 88234 + - 88235 + - 88236 + - 88237 + - 88238 + - 88239 + - 88240 + - 88241 + - 88242 + - 88243 + - 88244 + - 88245 + - 88246 + - 88247 + - 88248 + - 88249 + - 88250 + - 88251 + - 88252 + - 88253 + - 88254 + - 88255 + - 88256 + - 88257 + - 88258 + - 88259 + - 88260 + - 88261 + - 88262 + - 88263 + - 88264 + - 88265 + - 88266 + - 88267 + - 88268 + - 88269 + - 88270 + - 88271 + - 88272 + - 88273 + - 88274 + - 88275 + - 88276 + - 88277 + - 88278 + - 88279 + - 88280 + - 88281 + - 88282 + - 88283 + - 88284 + - 88285 + - 88286 + - 88287 + - 88288 + - 88289 + - 88290 + - 88291 + - 88292 + - 88293 + - 88294 + - 88295 + - 88296 + - 88297 + - 88298 + - 88299 + - 88300 + - 88301 + - 88302 + - 88303 + - 88304 + - 88305 + - 88306 + - 88307 + - 88308 + - 88309 + - 88310 + - 88311 + - 88312 + - 88313 + - 88314 + - 88315 + - 88316 + - 88317 + - 88318 + - 88319 + - 88320 + - 88321 + - 88322 + - 88323 + - 88324 + - 88325 + - 88326 + - 88327 + - 88328 + - 88329 + - 88330 + - 88331 + - 88332 + - 88333 + - 88334 + - 88335 + - 88336 + - 88337 + - 88338 + - 88339 + - 88340 + - 88341 + - 88342 + - 88343 + - 88344 + - 88345 + - 88346 + - 88347 + - 88348 + - 88349 + - 88350 + - 88351 + - 88352 + - 88353 + - 88354 + - 88355 + - 88356 + - 88357 + - 88358 + - 88359 + - 88360 + - 88361 + - 88362 + - 88363 + - 88364 + - 88365 + - 88366 + - 88367 + - 88368 + - 88369 + - 88370 + - 88371 + - 88372 + - 88373 + - 88374 + - 88375 + - 88376 + - 88377 + - 88378 + - 88379 + - 88380 + - 88381 + - 88382 + - 88383 + - 88384 + - 88385 + - 88386 + - 88387 + - 88388 + - 88389 + - 88390 + - 88391 + - 88392 + - 88393 + - 88394 + - 88395 + - 88396 + - 88397 + - 88398 + - 88399 + - 88400 + - 88401 + - 88402 + - 88403 + - 88404 + - 88405 + - 88406 + - 88407 + - 88408 + - 88409 + - 88410 + - 88411 + - 88412 + - 88413 + - 88414 + - 88415 + - 88416 + - 88417 + - 88418 + - 88419 + - 88420 + - 88421 + - 88422 + - 88423 + - 88424 + - 88425 + - 88426 + - 88427 + - 88428 + - 88429 + - 88430 + - 88431 + - 88432 + - 88433 + - 88434 + - 88435 + - 88436 + - 88437 + - 88438 + - 88439 + - 88440 + - 88441 + - 88442 + - 88443 + - 88444 + - 88445 + - 88446 + - 88447 + - 88448 + - 88449 + - 88450 + - 88451 + - 88452 + - 88453 + - 88454 + - 88455 + - 88456 + - 88457 + - 88458 + - 88459 + - 88460 + - 88461 + - 88462 + - 88463 + - 88464 + - 88465 + - 88466 + - 88467 + - 88468 + - 88469 + - 88470 + - 88471 + - 88472 + - 88473 + - 88474 + - 88475 + - 88476 + - 88477 + - 88478 + - 88479 + - 88480 + - 88481 + - 88482 + - 88483 + - 88484 + - 88485 + - 88486 + - 88487 + - 88488 + - 88489 + - 88490 + - 88491 + - 88492 + - 88493 + - 88494 + - 88495 + - 88496 + - 88497 + - 88498 + - 88499 + - 88500 + - 88501 + - 88502 + - 88503 + - 88504 + - 88505 + - 88506 + - 88507 + - 88508 + - 88509 + - 88510 + - 88511 + - 88512 + - 88513 + - 88514 + - 88515 + - 88516 + - 88517 + - 88518 + - 88519 + - 88520 + - 88521 + - 88522 + - 88523 + - 88524 + - 88525 + - 88526 + - 88527 + - 88528 + - 88529 + - 88530 + - 88531 + - 88532 + - 88533 + - 88534 + - 88535 + - 88536 + - 88537 + - 88538 + - 88539 + - 88540 + - 88541 + - 88542 + - 88543 + - 88544 + - 88545 + - 88546 + - 88547 + - 88548 + - 88549 + - 88550 + - 88551 + - 88552 + - 88553 + - 88554 + - 88555 + - 88556 + - 88557 + - 88558 + - 88559 + - 88560 + - 88561 + - 88562 + - 88563 + - 88564 + - 88565 + - 88566 + - 88567 + - 88568 + - 88569 + - 88570 + - 88571 + - 88572 + - 88573 + - 88574 + - 88575 + - 88576 + - 88577 + - 88578 + - 88579 + - 88580 + - 88581 + - 88582 + - 88583 + - 88584 + - 88585 + - 88586 + - 88587 + - 88588 + - 88589 + - 88590 + - 88591 + - 88592 + - 88593 + - 88594 + - 88595 + - 88596 + - 88597 + - 88598 + - 88599 + - 88600 + - 88601 + - 88602 + - 88603 + - 88604 + - 88605 + - 88606 + - 88607 + - 88608 + - 88609 + - 88610 + - 88611 + - 88612 + - 88613 + - 88614 + - 88615 + - 88616 + - 88617 + - 88618 + - 88619 + - 88620 + - 88621 + - 88622 + - 88623 + - 88624 + - 88625 + - 88626 + - 88627 + - 88628 + - 88629 + - 88630 + - 88631 + - 88632 + - 88633 + - 88634 + - 88635 + - 88636 + - 88637 + - 88638 + - 88639 + - 88640 + - 88641 + - 88642 + - 88643 + - 88644 + - 88645 + - 88646 + - 88647 + - 88648 + - 88649 + - 88650 + - 88651 + - 88652 + - 88653 + - 88654 + - 88655 + - 88656 + - 88657 + - 88658 + - 88659 + - 88660 + - 88661 + - 88662 + - 88663 + - 88664 + - 88665 + - 88666 + - 88667 + - 88668 + - 88669 + - 88670 + - 88671 + - 88672 + - 88673 + - 88674 + - 88675 + - 88676 + - 88677 + - 88678 + - 88679 + - 88680 + - 88681 + - 88682 + - 88683 + - 88684 + - 88685 + - 88686 + - 88687 + - 88688 + - 88689 + - 88690 + - 88691 + - 88692 + - 88693 + - 88694 + - 88695 + - 88696 + - 88697 + - 88698 + - 88699 + - 88700 + - 88701 + - 88702 + - 88703 + - 88704 + - 88705 + - 88706 + - 88707 + - 88708 + - 88709 + - 88710 + - 88711 + - 88712 + - 88713 + - 88714 + - 88715 + - 88716 + - 88717 + - 88718 + - 88719 + - 88720 + - 88721 + - 88722 + - 88723 + - 88724 + - 88725 + - 88726 + - 88727 + - 88728 + - 88729 + - 88730 + - 88731 + - 88732 + - 88733 + - 88734 + - 88735 + - 88736 + - 88737 + - 88738 + - 88739 + - 88740 + - 88741 + - 88742 + - 88743 + - 88744 + - 88745 + - 88746 + - 88747 + - 88748 + - 88749 + - 88750 + - 88751 + - 88752 + - 88753 + - 88754 + - 88755 + - 88756 + - 88757 + - 88758 + - 88759 + - 88760 + - 88761 + - 88762 + - 88763 + - 88764 + - 88765 + - 88766 + - 88767 + - 88768 + - 88769 + - 88770 + - 88771 + - 88772 + - 88773 + - 88774 + - 88775 + - 88776 + - 88777 + - 88778 + - 88779 + - 88780 + - 88781 + - 88782 + - 88783 + - 88784 + - 88785 + - 88786 + - 88787 + - 88788 + - 88789 + - 88790 + - 88791 + - 88792 + - 88793 + - 88794 + - 88795 + - 88796 + - 88797 + - 88798 + - 88799 + - 88800 + - 88801 + - 88802 + - 88803 + - 88804 + - 88805 + - 88806 + - 88807 + - 88808 + - 88809 + - 88810 + - 88811 + - 88812 + - 88813 + - 88814 + - 88815 + - 88816 + - 88817 + - 88818 + - 88819 + - 88820 + - 88821 + - 88822 + - 88823 + - 88824 + - 88825 + - 88826 + - 88827 + - 88828 + - 88829 + - 88830 + - 88831 + - 88832 + - 88833 + - 88834 + - 88835 + - 88836 + - 88837 + - 88838 + - 88839 + - 88840 + - 88841 + - 88842 + - 88843 + - 88844 + - 88845 + - 88846 + - 88847 + - 88848 + - 88849 + - 88850 + - 88851 + - 88852 + - 88853 + - 88854 + - 88855 + - 88856 + - 88857 + - 88858 + - 88859 + - 88860 + - 88861 + - 88862 + - 88863 + - 88864 + - 88865 + - 88866 + - 88867 + - 88868 + - 88869 + - 88870 + - 88871 + - 88872 + - 88873 + - 88874 + - 88875 + - 88876 + - 88877 + - 88878 + - 88879 + - 88880 + - 88881 + - 88882 + - 88883 + - 88884 + - 88885 + - 88886 + - 88887 + - 88888 + - 88889 + - 88890 + - 88891 + - 88892 + - 88893 + - 88894 + - 88895 + - 88896 + - 88897 + - 88898 + - 88899 + - 88900 + - 88901 + - 88902 + - 88903 + - 88904 + - 88905 + - 88906 + - 88907 + - 88908 + - 88909 + - 88910 + - 88911 + - 88912 + - 88913 + - 88914 + - 88915 + - 88916 + - 88917 + - 88918 + - 88919 + - 88920 + - 88921 + - 88922 + - 88923 + - 88924 + - 88925 + - 88926 + - 88927 + - 88928 + - 88929 + - 88930 + - 88931 + - 88932 + - 88933 + - 88934 + - 88935 + - 88936 + - 88937 + - 88938 + - 88939 + - 88940 + - 88941 + - 88942 + - 88943 + - 88944 + - 88945 + - 88946 + - 88947 + - 88948 + - 88949 + - 88950 + - 88951 + - 88952 + - 88953 + - 88954 + - 88955 + - 88956 + - 88957 + - 88958 + - 88959 + - 88960 + - 88961 + - 88962 + - 88963 + - 88964 + - 88965 + - 88966 + - 88967 + - 88968 + - 88969 + - 88970 + - 88971 + - 88972 + - 88973 + - 88974 + - 88975 + - 88976 + - 88977 + - 88978 + - 88979 + - 88980 + - 88981 + - 88982 + - 88983 + - 88984 + - 88985 + - 88986 + - 88987 + - 88988 + - 88989 + - 88990 + - 88991 + - 88992 + - 88993 + - 88994 + - 88995 + - 88996 + - 88997 + - 88998 + - 88999 + - 89000 + - 89001 + - 89002 + - 89003 + - 89004 + - 89005 + - 89006 + - 89007 + - 89008 + - 89009 + - 89010 + - 89011 + - 89012 + - 89013 + - 89014 + - 89015 + - 89016 + - 89017 + - 89018 + - 89019 + - 89020 + - 89021 + - 89022 + - 89023 + - 89024 + - 89025 + - 89026 + - 89027 + - 89028 + - 89029 + - 89030 + - 89031 + - 89032 + - 89033 + - 89034 + - 89035 + - 89036 + - 89037 + - 89038 + - 89039 + - 89040 + - 89041 + - 89042 + - 89043 + - 89044 + - 89045 + - 89046 + - 89047 + - 89048 + - 89049 + - 89050 + - 89051 + - 89052 + - 89053 + - 89054 + - 89055 + - 89056 + - 89057 + - 89058 + - 89059 + - 89060 + - 89061 + - 89062 + - 89063 + - 89064 + - 89065 + - 89066 + - 89067 + - 89068 + - 89069 + - 89070 + - 89071 + - 89072 + - 89073 + - 89074 + - 89075 + - 89076 + - 89077 + - 89078 + - 89079 + - 89080 + - 89081 + - 89082 + - 89083 + - 89084 + - 89085 + - 89086 + - 89087 + - 89088 + - 89089 + - 89090 + - 89091 + - 89092 + - 89093 + - 89094 + - 89095 + - 89096 + - 89097 + - 89098 + - 89099 + - 89100 + - 89101 + - 89102 + - 89103 + - 89104 + - 89105 + - 89106 + - 89107 + - 89108 + - 89109 + - 89110 + - 89111 + - 89112 + - 89113 + - 89114 + - 89115 + - 89116 + - 89117 + - 89118 + - 89119 + - 89120 + - 89121 + - 89122 + - 89123 + - 89124 + - 89125 + - 89126 + - 89127 + - 89128 + - 89129 + - 89130 + - 89131 + - 89132 + - 89133 + - 89134 + - 89135 + - 89136 + - 89137 + - 89138 + - 89139 + - 89140 + - 89141 + - 89142 + - 89143 + - 89144 + - 89145 + - 89146 + - 89147 + - 89148 + - 89149 + - 89150 + - 89151 + - 89152 + - 89153 + - 89154 + - 89155 + - 89156 + - 89157 + - 89158 + - 89159 + - 89160 + - 89161 + - 89162 + - 89163 + - 89164 + - 89165 + - 89166 + - 89167 + - 89168 + - 89169 + - 89170 + - 89171 + - 89172 + - 89173 + - 89174 + - 89175 + - 89176 + - 89177 + - 89178 + - 89179 + - 89180 + - 89181 + - 89182 + - 89183 + - 89184 + - 89185 + - 89186 + - 89187 + - 89188 + - 89189 + - 89190 + - 89191 + - 89192 + - 89193 + - 89194 + - 89195 + - 89196 + - 89197 + - 89198 + - 89199 + - 89200 + - 89201 + - 89202 + - 89203 + - 89204 + - 89205 + - 89206 + - 89207 + - 89208 + - 89209 + - 89210 + - 89211 + - 89212 + - 89213 + - 89214 + - 89215 + - 89216 + - 89217 + - 89218 + - 89219 + - 89220 + - 89221 + - 89222 + - 89223 + - 89224 + - 89225 + - 89226 + - 89227 + - 89228 + - 89229 + - 89230 + - 89231 + - 89232 + - 89233 + - 89234 + - 89235 + - 89236 + - 89237 + - 89238 + - 89239 + - 89240 + - 89241 + - 89242 + - 89243 + - 89244 + - 89245 + - 89246 + - 89247 + - 89248 + - 89249 + - 89250 + - 89251 + - 89252 + - 89253 + - 89254 + - 89255 + - 89256 + - 89257 + - 89258 + - 89259 + - 89260 + - 89261 + - 89262 + - 89263 + - 89264 + - 89265 + - 89266 + - 89267 + - 89268 + - 89269 + - 89270 + - 89271 + - 89272 + - 89273 + - 89274 + - 89275 + - 89276 + - 89277 + - 89278 + - 89279 + - 89280 + - 89281 + - 89282 + - 89283 + - 89284 + - 89285 + - 89286 + - 89287 + - 89288 + - 89289 + - 89290 + - 89291 + - 89292 + - 89293 + - 89294 + - 89295 + - 89296 + - 89297 + - 89298 + - 89299 + - 89300 + - 89301 + - 89302 + - 89303 + - 89304 + - 89305 + - 89306 + - 89307 + - 89308 + - 89309 + - 89310 + - 89311 + - 89312 + - 89313 + - 89314 + - 89315 + - 89316 + - 89317 + - 89318 + - 89319 + - 89320 + - 89321 + - 89322 + - 89323 + - 89324 + - 89325 + - 89326 + - 89327 + - 89328 + - 89329 + - 89330 + - 89331 + - 89332 + - 89333 + - 89334 + - 89335 + - 89336 + - 89337 + - 89338 + - 89339 + - 89340 + - 89341 + - 89342 + - 89343 + - 89344 + - 89345 + - 89346 + - 89347 + - 89348 + - 89349 + - 89350 + - 89351 + - 89352 + - 89353 + - 89354 + - 89355 + - 89356 + - 89357 + - 89358 + - 89359 + - 89360 + - 89361 + - 89362 + - 89363 + - 89364 + - 89365 + - 89366 + - 89367 + - 89368 + - 89369 + - 89370 + - 89371 + - 89372 + - 89373 + - 89374 + - 89375 + - 89376 + - 89377 + - 89378 + - 89379 + - 89380 + - 89381 + - 89382 + - 89383 + - 89384 + - 89385 + - 89386 + - 89387 + - 89388 + - 89389 + - 89390 + - 89391 + - 89392 + - 89393 + - 89394 + - 89395 + - 89396 + - 89397 + - 89398 + - 89399 + - 89400 + - 89401 + - 89402 + - 89403 + - 89404 + - 89405 + - 89406 + - 89407 + - 89408 + - 89409 + - 89410 + - 89411 + - 89412 + - 89413 + - 89414 + - 89415 + - 89416 + - 89417 + - 89418 + - 89419 + - 89420 + - 89421 + - 89422 + - 89423 + - 89424 + - 89425 + - 89426 + - 89427 + - 89428 + - 89429 + - 89430 + - 89431 + - 89432 + - 89433 + - 89434 + - 89435 + - 89436 + - 89437 + - 89438 + - 89439 + - 89440 + - 89441 + - 89442 + - 89443 + - 89444 + - 89445 + - 89446 + - 89447 + - 89448 + - 89449 + - 89450 + - 89451 + - 89452 + - 89453 + - 89454 + - 89455 + - 89456 + - 89457 + - 89458 + - 89459 + - 89460 + - 89461 + - 89462 + - 89463 + - 89464 + - 89465 + - 89466 + - 89467 + - 89468 + - 89469 + - 89470 + - 89471 + - 89472 + - 89473 + - 89474 + - 89475 + - 89476 + - 89477 + - 89478 + - 89479 + - 89480 + - 89481 + - 89482 + - 89483 + - 89484 + - 89485 + - 89486 + - 89487 + - 89488 + - 89489 + - 89490 + - 89491 + - 89492 + - 89493 + - 89494 + - 89495 + - 89496 + - 89497 + - 89498 + - 89499 + - 89500 + - 89501 + - 89502 + - 89503 + - 89504 + - 89505 + - 89506 + - 89507 + - 89508 + - 89509 + - 89510 + - 89511 + - 89512 + - 89513 + - 89514 + - 89515 + - 89516 + - 89517 + - 89518 + - 89519 + - 89520 + - 89521 + - 89522 + - 89523 + - 89524 + - 89525 + - 89526 + - 89527 + - 89528 + - 89529 + - 89530 + - 89531 + - 89532 + - 89533 + - 89534 + - 89535 + - 89536 + - 89537 + - 89538 + - 89539 + - 89540 + - 89541 + - 89542 + - 89543 + - 89544 + - 89545 + - 89546 + - 89547 + - 89548 + - 89549 + - 89550 + - 89551 + - 89552 + - 89553 + - 89554 + - 89555 + - 89556 + - 89557 + - 89558 + - 89559 + - 89560 + - 89561 + - 89562 + - 89563 + - 89564 + - 89565 + - 89566 + - 89567 + - 89568 + - 89569 + - 89570 + - 89571 + - 89572 + - 89573 + - 89574 + - 89575 + - 89576 + - 89577 + - 89578 + - 89579 + - 89580 + - 89581 + - 89582 + - 89583 + - 89584 + - 89585 + - 89586 + - 89587 + - 89588 + - 89589 + - 89590 + - 89591 + - 89592 + - 89593 + - 89594 + - 89595 + - 89596 + - 89597 + - 89598 + - 89599 + - 89600 + - 89601 + - 89602 + - 89603 + - 89604 + - 89605 + - 89606 + - 89607 + - 89608 + - 89609 + - 89610 + - 89611 + - 89612 + - 89613 + - 89614 + - 89615 + - 89616 + - 89617 + - 89618 + - 89619 + - 89620 + - 89621 + - 89622 + - 89623 + - 89624 + - 89625 + - 89626 + - 89627 + - 89628 + - 89629 + - 89630 + - 89631 + - 89632 + - 89633 + - 89634 + - 89635 + - 89636 + - 89637 + - 89638 + - 89639 + - 89640 + - 89641 + - 89642 + - 89643 + - 89644 + - 89645 + - 89646 + - 89647 + - 89648 + - 89649 + - 89650 + - 89651 + - 89652 + - 89653 + - 89654 + - 89655 + - 89656 + - 89657 + - 89658 + - 89659 + - 89660 + - 89661 + - 89662 + - 89663 + - 89664 + - 89665 + - 89666 + - 89667 + - 89668 + - 89669 + - 89670 + - 89671 + - 89672 + - 89673 + - 89674 + - 89675 + - 89676 + - 89677 + - 89678 + - 89679 + - 89680 + - 89681 + - 89682 + - 89683 + - 89684 + - 89685 + - 89686 + - 89687 + - 89688 + - 89689 + - 89690 + - 89691 + - 89692 + - 89693 + - 89694 + - 89695 + - 89696 + - 89697 + - 89698 + - 89699 + - 89700 + - 89701 + - 89702 + - 89703 + - 89704 + - 89705 + - 89706 + - 89707 + - 89708 + - 89709 + - 89710 + - 89711 + - 89712 + - 89713 + - 89714 + - 89715 + - 89716 + - 89717 + - 89718 + - 89719 + - 89720 + - 89721 + - 89722 + - 89723 + - 89724 + - 89725 + - 89726 + - 89727 + - 89728 + - 89729 + - 89730 + - 89731 + - 89732 + - 89733 + - 89734 + - 89735 + - 89736 + - 89737 + - 89738 + - 89739 + - 89740 + - 89741 + - 89742 + - 89743 + - 89744 + - 89745 + - 89746 + - 89747 + - 89748 + - 89749 + - 89750 + - 89751 + - 89752 + - 89753 + - 89754 + - 89755 + - 89756 + - 89757 + - 89758 + - 89759 + - 89760 + - 89761 + - 89762 + - 89763 + - 89764 + - 89765 + - 89766 + - 89767 + - 89768 + - 89769 + - 89770 + - 89771 + - 89772 + - 89773 + - 89774 + - 89775 + - 89776 + - 89777 + - 89778 + - 89779 + - 89780 + - 89781 + - 89782 + - 89783 + - 89784 + - 89785 + - 89786 + - 89787 + - 89788 + - 89789 + - 89790 + - 89791 + - 89792 + - 89793 + - 89794 + - 89795 + - 89796 + - 89797 + - 89798 + - 89799 + - 89800 + - 89801 + - 89802 + - 89803 + - 89804 + - 89805 + - 89806 + - 89807 + - 89808 + - 89809 + - 89810 + - 89811 + - 89812 + - 89813 + - 89814 + - 89815 + - 89816 + - 89817 + - 89818 + - 89819 + - 89820 + - 89821 + - 89822 + - 89823 + - 89824 + - 89825 + - 89826 + - 89827 + - 89828 + - 89829 + - 89830 + - 89831 + - 89832 + - 89833 + - 89834 + - 89835 + - 89836 + - 89837 + - 89838 + - 89839 + - 89840 + - 89841 + - 89842 + - 89843 + - 89844 + - 89845 + - 89846 + - 89847 + - 89848 + - 89849 + - 89850 + - 89851 + - 89852 + - 89853 + - 89854 + - 89855 + - 89856 + - 89857 + - 89858 + - 89859 + - 89860 + - 89861 + - 89862 + - 89863 + - 89864 + - 89865 + - 89866 + - 89867 + - 89868 + - 89869 + - 89870 + - 89871 + - 89872 + - 89873 + - 89874 + - 89875 + - 89876 + - 89877 + - 89878 + - 89879 + - 89880 + - 89881 + - 89882 + - 89883 + - 89884 + - 89885 + - 89886 + - 89887 + - 89888 + - 89889 + - 89890 + - 89891 + - 89892 + - 89893 + - 89894 + - 89895 + - 89896 + - 89897 + - 89898 + - 89899 + - 89900 + - 89901 + - 89902 + - 89903 + - 89904 + - 89905 + - 89906 + - 89907 + - 89908 + - 89909 + - 89910 + - 89911 + - 89912 + - 89913 + - 89914 + - 89915 + - 89916 + - 89917 + - 89918 + - 89919 + - 89920 + - 89921 + - 89922 + - 89923 + - 89924 + - 89925 + - 89926 + - 89927 + - 89928 + - 89929 + - 89930 + - 89931 + - 89932 + - 89933 + - 89934 + - 89935 + - 89936 + - 89937 + - 89938 + - 89939 + - 89940 + - 89941 + - 89942 + - 89943 + - 89944 + - 89945 + - 89946 + - 89947 + - 89948 + - 89949 + - 89950 + - 89951 + - 89952 + - 89953 + - 89954 + - 89955 + - 89956 + - 89957 + - 89958 + - 89959 + - 89960 + - 89961 + - 89962 + - 89963 + - 89964 + - 89965 + - 89966 + - 89967 + - 89968 + - 89969 + - 89970 + - 89971 + - 89972 + - 89973 + - 89974 + - 89975 + - 89976 + - 89977 + - 89978 + - 89979 + - 89980 + - 89981 + - 89982 + - 89983 + - 89984 + - 89985 + - 89986 + - 89987 + - 89988 + - 89989 + - 89990 + - 89991 + - 89992 + - 89993 + - 89994 + - 89995 + - 89996 + - 89997 + - 89998 + - 89999 + - 90000 + - 90001 + - 90002 + - 90003 + - 90004 + - 90005 + - 90006 + - 90007 + - 90008 + - 90009 + - 90010 + - 90011 + - 90012 + - 90013 + - 90014 + - 90015 + - 90016 + - 90017 + - 90018 + - 90019 + - 90020 + - 90021 + - 90022 + - 90023 + - 90024 + - 90025 + - 90026 + - 90027 + - 90028 + - 90029 + - 90030 + - 90031 + - 90032 + - 90033 + - 90034 + - 90035 + - 90036 + - 90037 + - 90038 + - 90039 + - 90040 + - 90041 + - 90042 + - 90043 + - 90044 + - 90045 + - 90046 + - 90047 + - 90048 + - 90049 + - 90050 + - 90051 + - 90052 + - 90053 + - 90054 + - 90055 + - 90056 + - 90057 + - 90058 + - 90059 + - 90060 + - 90061 + - 90062 + - 90063 + - 90064 + - 90065 + - 90066 + - 90067 + - 90068 + - 90069 + - 90070 + - 90071 + - 90072 + - 90073 + - 90074 + - 90075 + - 90076 + - 90077 + - 90078 + - 90079 + - 90080 + - 90081 + - 90082 + - 90083 + - 90084 + - 90085 + - 90086 + - 90087 + - 90088 + - 90089 + - 90090 + - 90091 + - 90092 + - 90093 + - 90094 + - 90095 + - 90096 + - 90097 + - 90098 + - 90099 + - 90100 + - 90101 + - 90102 + - 90103 + - 90104 + - 90105 + - 90106 + - 90107 + - 90108 + - 90109 + - 90110 + - 90111 + - 90112 + - 90113 + - 90114 + - 90115 + - 90116 + - 90117 + - 90118 + - 90119 + - 90120 + - 90121 + - 90122 + - 90123 + - 90124 + - 90125 + - 90126 + - 90127 + - 90128 + - 90129 + - 90130 + - 90131 + - 90132 + - 90133 + - 90134 + - 90135 + - 90136 + - 90137 + - 90138 + - 90139 + - 90140 + - 90141 + - 90142 + - 90143 + - 90144 + - 90145 + - 90146 + - 90147 + - 90148 + - 90149 + - 90150 + - 90151 + - 90152 + - 90153 + - 90154 + - 90155 + - 90156 + - 90157 + - 90158 + - 90159 + - 90160 + - 90161 + - 90162 + - 90163 + - 90164 + - 90165 + - 90166 + - 90167 + - 90168 + - 90169 + - 90170 + - 90171 + - 90172 + - 90173 + - 90174 + - 90175 + - 90176 + - 90177 + - 90178 + - 90179 + - 90180 + - 90181 + - 90182 + - 90183 + - 90184 + - 90185 + - 90186 + - 90187 + - 90188 + - 90189 + - 90190 + - 90191 + - 90192 + - 90193 + - 90194 + - 90195 + - 90196 + - 90197 + - 90198 + - 90199 + - 90200 + - 90201 + - 90202 + - 90203 + - 90204 + - 90205 + - 90206 + - 90207 + - 90208 + - 90209 + - 90210 + - 90211 + - 90212 + - 90213 + - 90214 + - 90215 + - 90216 + - 90217 + - 90218 + - 90219 + - 90220 + - 90221 + - 90222 + - 90223 + - 90224 + - 90225 + - 90226 + - 90227 + - 90228 + - 90229 + - 90230 + - 90231 + - 90232 + - 90233 + - 90234 + - 90235 + - 90236 + - 90237 + - 90238 + - 90239 + - 90240 + - 90241 + - 90242 + - 90243 + - 90244 + - 90245 + - 90246 + - 90247 + - 90248 + - 90249 + - 90250 + - 90251 + - 90252 + - 90253 + - 90254 + - 90255 + - 90256 + - 90257 + - 90258 + - 90259 + - 90260 + - 90261 + - 90262 + - 90263 + - 90264 + - 90265 + - 90266 + - 90267 + - 90268 + - 90269 + - 90270 + - 90271 + - 90272 + - 90273 + - 90274 + - 90275 + - 90276 + - 90277 + - 90278 + - 90279 + - 90280 + - 90281 + - 90282 + - 90283 + - 90284 + - 90285 + - 90286 + - 90287 + - 90288 + - 90289 + - 90290 + - 90291 + - 90292 + - 90293 + - 90294 + - 90295 + - 90296 + - 90297 + - 90298 + - 90299 + - 90300 + - 90301 + - 90302 + - 90303 + - 90304 + - 90305 + - 90306 + - 90307 + - 90308 + - 90309 + - 90310 + - 90311 + - 90312 + - 90313 + - 90314 + - 90315 + - 90316 + - 90317 + - 90318 + - 90319 + - 90320 + - 90321 + - 90322 + - 90323 + - 90324 + - 90325 + - 90326 + - 90327 + - 90328 + - 90329 + - 90330 + - 90331 + - 90332 + - 90333 + - 90334 + - 90335 + - 90336 + - 90337 + - 90338 + - 90339 + - 90340 + - 90341 + - 90342 + - 90343 + - 90344 + - 90345 + - 90346 + - 90347 + - 90348 + - 90349 + - 90350 + - 90351 + - 90352 + - 90353 + - 90354 + - 90355 + - 90356 + - 90357 + - 90358 + - 90359 + - 90360 + - 90361 + - 90362 + - 90363 + - 90364 + - 90365 + - 90366 + - 90367 + - 90368 + - 90369 + - 90370 + - 90371 + - 90372 + - 90373 + - 90374 + - 90375 + - 90376 + - 90377 + - 90378 + - 90379 + - 90380 + - 90381 + - 90382 + - 90383 + - 90384 + - 90385 + - 90386 + - 90387 + - 90388 + - 90389 + - 90390 + - 90391 + - 90392 + - 90393 + - 90394 + - 90395 + - 90396 + - 90397 + - 90398 + - 90399 + - 90400 + - 90401 + - 90402 + - 90403 + - 90404 + - 90405 + - 90406 + - 90407 + - 90408 + - 90409 + - 90410 + - 90411 + - 90412 + - 90413 + - 90414 + - 90415 + - 90416 + - 90417 + - 90418 + - 90419 + - 90420 + - 90421 + - 90422 + - 90423 + - 90424 + - 90425 + - 90426 + - 90427 + - 90428 + - 90429 + - 90430 + - 90431 + - 90432 + - 90433 + - 90434 + - 90435 + - 90436 + - 90437 + - 90438 + - 90439 + - 90440 + - 90441 + - 90442 + - 90443 + - 90444 + - 90445 + - 90446 + - 90447 + - 90448 + - 90449 + - 90450 + - 90451 + - 90452 + - 90453 + - 90454 + - 90455 + - 90456 + - 90457 + - 90458 + - 90459 + - 90460 + - 90461 + - 90462 + - 90463 + - 90464 + - 90465 + - 90466 + - 90467 + - 90468 + - 90469 + - 90470 + - 90471 + - 90472 + - 90473 + - 90474 + - 90475 + - 90476 + - 90477 + - 90478 + - 90479 + - 90480 + - 90481 + - 90482 + - 90483 + - 90484 + - 90485 + - 90486 + - 90487 + - 90488 + - 90489 + - 90490 + - 90491 + - 90492 + - 90493 + - 90494 + - 90495 + - 90496 + - 90497 + - 90498 + - 90499 + - 90500 + - 90501 + - 90502 + - 90503 + - 90504 + - 90505 + - 90506 + - 90507 + - 90508 + - 90509 + - 90510 + - 90511 + - 90512 + - 90513 + - 90514 + - 90515 + - 90516 + - 90517 + - 90518 + - 90519 + - 90520 + - 90521 + - 90522 + - 90523 + - 90524 + - 90525 + - 90526 + - 90527 + - 90528 + - 90529 + - 90530 + - 90531 + - 90532 + - 90533 + - 90534 + - 90535 + - 90536 + - 90537 + - 90538 + - 90539 + - 90540 + - 90541 + - 90542 + - 90543 + - 90544 + - 90545 + - 90546 + - 90547 + - 90548 + - 90549 + - 90550 + - 90551 + - 90552 + - 90553 + - 90554 + - 90555 + - 90556 + - 90557 + - 90558 + - 90559 + - 90560 + - 90561 + - 90562 + - 90563 + - 90564 + - 90565 + - 90566 + - 90567 + - 90568 + - 90569 + - 90570 + - 90571 + - 90572 + - 90573 + - 90574 + - 90575 + - 90576 + - 90577 + - 90578 + - 90579 + - 90580 + - 90581 + - 90582 + - 90583 + - 90584 + - 90585 + - 90586 + - 90587 + - 90588 + - 90589 + - 90590 + - 90591 + - 90592 + - 90593 + - 90594 + - 90595 + - 90596 + - 90597 + - 90598 + - 90599 + - 90600 + - 90601 + - 90602 + - 90603 + - 90604 + - 90605 + - 90606 + - 90607 + - 90608 + - 90609 + - 90610 + - 90611 + - 90612 + - 90613 + - 90614 + - 90615 + - 90616 + - 90617 + - 90618 + - 90619 + - 90620 + - 90621 + - 90622 + - 90623 + - 90624 + - 90625 + - 90626 + - 90627 + - 90628 + - 90629 + - 90630 + - 90631 + - 90632 + - 90633 + - 90634 + - 90635 + - 90636 + - 90637 + - 90638 + - 90639 + - 90640 + - 90641 + - 90642 + - 90643 + - 90644 + - 90645 + - 90646 + - 90647 + - 90648 + - 90649 + - 90650 + - 90651 + - 90652 + - 90653 + - 90654 + - 90655 + - 90656 + - 90657 + - 90658 + - 90659 + - 90660 + - 90661 + - 90662 + - 90663 + - 90664 + - 90665 + - 90666 + - 90667 + - 90668 + - 90669 + - 90670 + - 90671 + - 90672 + - 90673 + - 90674 + - 90675 + - 90676 + - 90677 + - 90678 + - 90679 + - 90680 + - 90681 + - 90682 + - 90683 + - 90684 + - 90685 + - 90686 + - 90687 + - 90688 + - 90689 + - 90690 + - 90691 + - 90692 + - 90693 + - 90694 + - 90695 + - 90696 + - 90697 + - 90698 + - 90699 + - 90700 + - 90701 + - 90702 + - 90703 + - 90704 + - 90705 + - 90706 + - 90707 + - 90708 + - 90709 + - 90710 + - 90711 + - 90712 + - 90713 + - 90714 + - 90715 + - 90716 + - 90717 + - 90718 + - 90719 + - 90720 + - 90721 + - 90722 + - 90723 + - 90724 + - 90725 + - 90726 + - 90727 + - 90728 + - 90729 + - 90730 + - 90731 + - 90732 + - 90733 + - 90734 + - 90735 + - 90736 + - 90737 + - 90738 + - 90739 + - 90740 + - 90741 + - 90742 + - 90743 + - 90744 + - 90745 + - 90746 + - 90747 + - 90748 + - 90749 + - 90750 + - 90751 + - 90752 + - 90753 + - 90754 + - 90755 + - 90756 + - 90757 + - 90758 + - 90759 + - 90760 + - 90761 + - 90762 + - 90763 + - 90764 + - 90765 + - 90766 + - 90767 + - 90768 + - 90769 + - 90770 + - 90771 + - 90772 + - 90773 + - 90774 + - 90775 + - 90776 + - 90777 + - 90778 + - 90779 + - 90780 + - 90781 + - 90782 + - 90783 + - 90784 + - 90785 + - 90786 + - 90787 + - 90788 + - 90789 + - 90790 + - 90791 + - 90792 + - 90793 + - 90794 + - 90795 + - 90796 + - 90797 + - 90798 + - 90799 + - 90800 + - 90801 + - 90802 + - 90803 + - 90804 + - 90805 + - 90806 + - 90807 + - 90808 + - 90809 + - 90810 + - 90811 + - 90812 + - 90813 + - 90814 + - 90815 + - 90816 + - 90817 + - 90818 + - 90819 + - 90820 + - 90821 + - 90822 + - 90823 + - 90824 + - 90825 + - 90826 + - 90827 + - 90828 + - 90829 + - 90830 + - 90831 + - 90832 + - 90833 + - 90834 + - 90835 + - 90836 + - 90837 + - 90838 + - 90839 + - 90840 + - 90841 + - 90842 + - 90843 + - 90844 + - 90845 + - 90846 + - 90847 + - 90848 + - 90849 + - 90850 + - 90851 + - 90852 + - 90853 + - 90854 + - 90855 + - 90856 + - 90857 + - 90858 + - 90859 + - 90860 + - 90861 + - 90862 + - 90863 + - 90864 + - 90865 + - 90866 + - 90867 + - 90868 + - 90869 + - 90870 + - 90871 + - 90872 + - 90873 + - 90874 + - 90875 + - 90876 + - 90877 + - 90878 + - 90879 + - 90880 + - 90881 + - 90882 + - 90883 + - 90884 + - 90885 + - 90886 + - 90887 + - 90888 + - 90889 + - 90890 + - 90891 + - 90892 + - 90893 + - 90894 + - 90895 + - 90896 + - 90897 + - 90898 + - 90899 + - 90900 + - 90901 + - 90902 + - 90903 + - 90904 + - 90905 + - 90906 + - 90907 + - 90908 + - 90909 + - 90910 + - 90911 + - 90912 + - 90913 + - 90914 + - 90915 + - 90916 + - 90917 + - 90918 + - 90919 + - 90920 + - 90921 + - 90922 + - 90923 + - 90924 + - 90925 + - 90926 + - 90927 + - 90928 + - 90929 + - 90930 + - 90931 + - 90932 + - 90933 + - 90934 + - 90935 + - 90936 + - 90937 + - 90938 + - 90939 + - 90940 + - 90941 + - 90942 + - 90943 + - 90944 + - 90945 + - 90946 + - 90947 + - 90948 + - 90949 + - 90950 + - 90951 + - 90952 + - 90953 + - 90954 + - 90955 + - 90956 + - 90957 + - 90958 + - 90959 + - 90960 + - 90961 + - 90962 + - 90963 + - 90964 + - 90965 + - 90966 + - 90967 + - 90968 + - 90969 + - 90970 + - 90971 + - 90972 + - 90973 + - 90974 + - 90975 + - 90976 + - 90977 + - 90978 + - 90979 + - 90980 + - 90981 + - 90982 + - 90983 + - 90984 + - 90985 + - 90986 + - 90987 + - 90988 + - 90989 + - 90990 + - 90991 + - 90992 + - 90993 + - 90994 + - 90995 + - 90996 + - 90997 + - 90998 + - 90999 + - 91000 + - 91001 + - 91002 + - 91003 + - 91004 + - 91005 + - 91006 + - 91007 + - 91008 + - 91009 + - 91010 + - 91011 + - 91012 + - 91013 + - 91014 + - 91015 + - 91016 + - 91017 + - 91018 + - 91019 + - 91020 + - 91021 + - 91022 + - 91023 + - 91024 + - 91025 + - 91026 + - 91027 + - 91028 + - 91029 + - 91030 + - 91031 + - 91032 + - 91033 + - 91034 + - 91035 + - 91036 + - 91037 + - 91038 + - 91039 + - 91040 + - 91041 + - 91042 + - 91043 + - 91044 + - 91045 + - 91046 + - 91047 + - 91048 + - 91049 + - 91050 + - 91051 + - 91052 + - 91053 + - 91054 + - 91055 + - 91056 + - 91057 + - 91058 + - 91059 + - 91060 + - 91061 + - 91062 + - 91063 + - 91064 + - 91065 + - 91066 + - 91067 + - 91068 + - 91069 + - 91070 + - 91071 + - 91072 + - 91073 + - 91074 + - 91075 + - 91076 + - 91077 + - 91078 + - 91079 + - 91080 + - 91081 + - 91082 + - 91083 + - 91084 + - 91085 + - 91086 + - 91087 + - 91088 + - 91089 + - 91090 + - 91091 + - 91092 + - 91093 + - 91094 + - 91095 + - 91096 + - 91097 + - 91098 + - 91099 + - 91100 + - 91101 + - 91102 + - 91103 + - 91104 + - 91105 + - 91106 + - 91107 + - 91108 + - 91109 + - 91110 + - 91111 + - 91112 + - 91113 + - 91114 + - 91115 + - 91116 + - 91117 + - 91118 + - 91119 + - 91120 + - 91121 + - 91122 + - 91123 + - 91124 + - 91125 + - 91126 + - 91127 + - 91128 + - 91129 + - 91130 + - 91131 + - 91132 + - 91133 + - 91134 + - 91135 + - 91136 + - 91137 + - 91138 + - 91139 + - 91140 + - 91141 + - 91142 + - 91143 + - 91144 + - 91145 + - 91146 + - 91147 + - 91148 + - 91149 + - 91150 + - 91151 + - 91152 + - 91153 + - 91154 + - 91155 + - 91156 + - 91157 + - 91158 + - 91159 + - 91160 + - 91161 + - 91162 + - 91163 + - 91164 + - 91165 + - 91166 + - 91167 + - 91168 + - 91169 + - 91170 + - 91171 + - 91172 + - 91173 + - 91174 + - 91175 + - 91176 + - 91177 + - 91178 + - 91179 + - 91180 + - 91181 + - 91182 + - 91183 + - 91184 + - 91185 + - 91186 + - 91187 + - 91188 + - 91189 + - 91190 + - 91191 + - 91192 + - 91193 + - 91194 + - 91195 + - 91196 + - 91197 + - 91198 + - 91199 + - 91200 + - 91201 + - 91202 + - 91203 + - 91204 + - 91205 + - 91206 + - 91207 + - 91208 + - 91209 + - 91210 + - 91211 + - 91212 + - 91213 + - 91214 + - 91215 + - 91216 + - 91217 + - 91218 + - 91219 + - 91220 + - 91221 + - 91222 + - 91223 + - 91224 + - 91225 + - 91226 + - 91227 + - 91228 + - 91229 + - 91230 + - 91231 + - 91232 + - 91233 + - 91234 + - 91235 + - 91236 + - 91237 + - 91238 + - 91239 + - 91240 + - 91241 + - 91242 + - 91243 + - 91244 + - 91245 + - 91246 + - 91247 + - 91248 + - 91249 + - 91250 + - 91251 + - 91252 + - 91253 + - 91254 + - 91255 + - 91256 + - 91257 + - 91258 + - 91259 + - 91260 + - 91261 + - 91262 + - 91263 + - 91264 + - 91265 + - 91266 + - 91267 + - 91268 + - 91269 + - 91270 + - 91271 + - 91272 + - 91273 + - 91274 + - 91275 + - 91276 + - 91277 + - 91278 + - 91279 + - 91280 + - 91281 + - 91282 + - 91283 + - 91284 + - 91285 + - 91286 + - 91287 + - 91288 + - 91289 + - 91290 + - 91291 + - 91292 + - 91293 + - 91294 + - 91295 + - 91296 + - 91297 + - 91298 + - 91299 + - 91300 + - 91301 + - 91302 + - 91303 + - 91304 + - 91305 + - 91306 + - 91307 + - 91308 + - 91309 + - 91310 + - 91311 + - 91312 + - 91313 + - 91314 + - 91315 + - 91316 + - 91317 + - 91318 + - 91319 + - 91320 + - 91321 + - 91322 + - 91323 + - 91324 + - 91325 + - 91326 + - 91327 + - 91328 + - 91329 + - 91330 + - 91331 + - 91332 + - 91333 + - 91334 + - 91335 + - 91336 + - 91337 + - 91338 + - 91339 + - 91340 + - 91341 + - 91342 + - 91343 + - 91344 + - 91345 + - 91346 + - 91347 + - 91348 + - 91349 + - 91350 + - 91351 + - 91352 + - 91353 + - 91354 + - 91355 + - 91356 + - 91357 + - 91358 + - 91359 + - 91360 + - 91361 + - 91362 + - 91363 + - 91364 + - 91365 + - 91366 + - 91367 + - 91368 + - 91369 + - 91370 + - 91371 + - 91372 + - 91373 + - 91374 + - 91375 + - 91376 + - 91377 + - 91378 + - 91379 + - 91380 + - 91381 + - 91382 + - 91383 + - 91384 + - 91385 + - 91386 + - 91387 + - 91388 + - 91389 + - 91390 + - 91391 + - 91392 + - 91393 + - 91394 + - 91395 + - 91396 + - 91397 + - 91398 + - 91399 + - 91400 + - 91401 + - 91402 + - 91403 + - 91404 + - 91405 + - 91406 + - 91407 + - 91408 + - 91409 + - 91410 + - 91411 + - 91412 + - 91413 + - 91414 + - 91415 + - 91416 + - 91417 + - 91418 + - 91419 + - 91420 + - 91421 + - 91422 + - 91423 + - 91424 + - 91425 + - 91426 + - 91427 + - 91428 + - 91429 + - 91430 + - 91431 + - 91432 + - 91433 + - 91434 + - 91435 + - 91436 + - 91437 + - 91438 + - 91439 + - 91440 + - 91441 + - 91442 + - 91443 + - 91444 + - 91445 + - 91446 + - 91447 + - 91448 + - 91449 + - 91450 + - 91451 + - 91452 + - 91453 + - 91454 + - 91455 + - 91456 + - 91457 + - 91458 + - 91459 + - 91460 + - 91461 + - 91462 + - 91463 + - 91464 + - 91465 + - 91466 + - 91467 + - 91468 + - 91469 + - 91470 + - 91471 + - 91472 + - 91473 + - 91474 + - 91475 + - 91476 + - 91477 + - 91478 + - 91479 + - 91480 + - 91481 + - 91482 + - 91483 + - 91484 + - 91485 + - 91486 + - 91487 + - 91488 + - 91489 + - 91490 + - 91491 + - 91492 + - 91493 + - 91494 + - 91495 + - 91496 + - 91497 + - 91498 + - 91499 + - 91500 + - 91501 + - 91502 + - 91503 + - 91504 + - 91505 + - 91506 + - 91507 + - 91508 + - 91509 + - 91510 + - 91511 + - 91512 + - 91513 + - 91514 + - 91515 + - 91516 + - 91517 + - 91518 + - 91519 + - 91520 + - 91521 + - 91522 + - 91523 + - 91524 + - 91525 + - 91526 + - 91527 + - 91528 + - 91529 + - 91530 + - 91531 + - 91532 + - 91533 + - 91534 + - 91535 + - 91536 + - 91537 + - 91538 + - 91539 + - 91540 + - 91541 + - 91542 + - 91543 + - 91544 + - 91545 + - 91546 + - 91547 + - 91548 + - 91549 + - 91550 + - 91551 + - 91552 + - 91553 + - 91554 + - 91555 + - 91556 + - 91557 + - 91558 + - 91559 + - 91560 + - 91561 + - 91562 + - 91563 + - 91564 + - 91565 + - 91566 + - 91567 + - 91568 + - 91569 + - 91570 + - 91571 + - 91572 + - 91573 + - 91574 + - 91575 + - 91576 + - 91577 + - 91578 + - 91579 + - 91580 + - 91581 + - 91582 + - 91583 + - 91584 + - 91585 + - 91586 + - 91587 + - 91588 + - 91589 + - 91590 + - 91591 + - 91592 + - 91593 + - 91594 + - 91595 + - 91596 + - 91597 + - 91598 + - 91599 + - 91600 + - 91601 + - 91602 + - 91603 + - 91604 + - 91605 + - 91606 + - 91607 + - 91608 + - 91609 + - 91610 + - 91611 + - 91612 + - 91613 + - 91614 + - 91615 + - 91616 + - 91617 + - 91618 + - 91619 + - 91620 + - 91621 + - 91622 + - 91623 + - 91624 + - 91625 + - 91626 + - 91627 + - 91628 + - 91629 + - 91630 + - 91631 + - 91632 + - 91633 + - 91634 + - 91635 + - 91636 + - 91637 + - 91638 + - 91639 + - 91640 + - 91641 + - 91642 + - 91643 + - 91644 + - 91645 + - 91646 + - 91647 + - 91648 + - 91649 + - 91650 + - 91651 + - 91652 + - 91653 + - 91654 + - 91655 + - 91656 + - 91657 + - 91658 + - 91659 + - 91660 + - 91661 + - 91662 + - 91663 + - 91664 + - 91665 + - 91666 + - 91667 + - 91668 + - 91669 + - 91670 + - 91671 + - 91672 + - 91673 + - 91674 + - 91675 + - 91676 + - 91677 + - 91678 + - 91679 + - 91680 + - 91681 + - 91682 + - 91683 + - 91684 + - 91685 + - 91686 + - 91687 + - 91688 + - 91689 + - 91690 + - 91691 + - 91692 + - 91693 + - 91694 + - 91695 + - 91696 + - 91697 + - 91698 + - 91699 + - 91700 + - 91701 + - 91702 + - 91703 + - 91704 + - 91705 + - 91706 + - 91707 + - 91708 + - 91709 + - 91710 + - 91711 + - 91712 + - 91713 + - 91714 + - 91715 + - 91716 + - 91717 + - 91718 + - 91719 + - 91720 + - 91721 + - 91722 + - 91723 + - 91724 + - 91725 + - 91726 + - 91727 + - 91728 + - 91729 + - 91730 + - 91731 + - 91732 + - 91733 + - 91734 + - 91735 + - 91736 + - 91737 + - 91738 + - 91739 + - 91740 + - 91741 + - 91742 + - 91743 + - 91744 + - 91745 + - 91746 + - 91747 + - 91748 + - 91749 + - 91750 + - 91751 + - 91752 + - 91753 + - 91754 + - 91755 + - 91756 + - 91757 + - 91758 + - 91759 + - 91760 + - 91761 + - 91762 + - 91763 + - 91764 + - 91765 + - 91766 + - 91767 + - 91768 + - 91769 + - 91770 + - 91771 + - 91772 + - 91773 + - 91774 + - 91775 + - 91776 + - 91777 + - 91778 + - 91779 + - 91780 + - 91781 + - 91782 + - 91783 + - 91784 + - 91785 + - 91786 + - 91787 + - 91788 + - 91789 + - 91790 + - 91791 + - 91792 + - 91793 + - 91794 + - 91795 + - 91796 + - 91797 + - 91798 + - 91799 + - 91800 + - 91801 + - 91802 + - 91803 + - 91804 + - 91805 + - 91806 + - 91807 + - 91808 + - 91809 + - 91810 + - 91811 + - 91812 + - 91813 + - 91814 + - 91815 + - 91816 + - 91817 + - 91818 + - 91819 + - 91820 + - 91821 + - 91822 + - 91823 + - 91824 + - 91825 + - 91826 + - 91827 + - 91828 + - 91829 + - 91830 + - 91831 + - 91832 + - 91833 + - 91834 + - 91835 + - 91836 + - 91837 + - 91838 + - 91839 + - 91840 + - 91841 + - 91842 + - 91843 + - 91844 + - 91845 + - 91846 + - 91847 + - 91848 + - 91849 + - 91850 + - 91851 + - 91852 + - 91853 + - 91854 + - 91855 + - 91856 + - 91857 + - 91858 + - 91859 + - 91860 + - 91861 + - 91862 + - 91863 + - 91864 + - 91865 + - 91866 + - 91867 + - 91868 + - 91869 + - 91870 + - 91871 + - 91872 + - 91873 + - 91874 + - 91875 + - 91876 + - 91877 + - 91878 + - 91879 + - 91880 + - 91881 + - 91882 + - 91883 + - 91884 + - 91885 + - 91886 + - 91887 + - 91888 + - 91889 + - 91890 + - 91891 + - 91892 + - 91893 + - 91894 + - 91895 + - 91896 + - 91897 + - 91898 + - 91899 + - 91900 + - 91901 + - 91902 + - 91903 + - 91904 + - 91905 + - 91906 + - 91907 + - 91908 + - 91909 + - 91910 + - 91911 + - 91912 + - 91913 + - 91914 + - 91915 + - 91916 + - 91917 + - 91918 + - 91919 + - 91920 + - 91921 + - 91922 + - 91923 + - 91924 + - 91925 + - 91926 + - 91927 + - 91928 + - 91929 + - 91930 + - 91931 + - 91932 + - 91933 + - 91934 + - 91935 + - 91936 + - 91937 + - 91938 + - 91939 + - 91940 + - 91941 + - 91942 + - 91943 + - 91944 + - 91945 + - 91946 + - 91947 + - 91948 + - 91949 + - 91950 + - 91951 + - 91952 + - 91953 + - 91954 + - 91955 + - 91956 + - 91957 + - 91958 + - 91959 + - 91960 + - 91961 + - 91962 + - 91963 + - 91964 + - 91965 + - 91966 + - 91967 + - 91968 + - 91969 + - 91970 + - 91971 + - 91972 + - 91973 + - 91974 + - 91975 + - 91976 + - 91977 + - 91978 + - 91979 + - 91980 + - 91981 + - 91982 + - 91983 + - 91984 + - 91985 + - 91986 + - 91987 + - 91988 + - 91989 + - 91990 + - 91991 + - 91992 + - 91993 + - 91994 + - 91995 + - 91996 + - 91997 + - 91998 + - 91999 + - 92000 + - 92001 + - 92002 + - 92003 + - 92004 + - 92005 + - 92006 + - 92007 + - 92008 + - 92009 + - 92010 + - 92011 + - 92012 + - 92013 + - 92014 + - 92015 + - 92016 + - 92017 + - 92018 + - 92019 + - 92020 + - 92021 + - 92022 + - 92023 + - 92024 + - 92025 + - 92026 + - 92027 + - 92028 + - 92029 + - 92030 + - 92031 + - 92032 + - 92033 + - 92034 + - 92035 + - 92036 + - 92037 + - 92038 + - 92039 + - 92040 + - 92041 + - 92042 + - 92043 + - 92044 + - 92045 + - 92046 + - 92047 + - 92048 + - 92049 + - 92050 + - 92051 + - 92052 + - 92053 + - 92054 + - 92055 + - 92056 + - 92057 + - 92058 + - 92059 + - 92060 + - 92061 + - 92062 + - 92063 + - 92064 + - 92065 + - 92066 + - 92067 + - 92068 + - 92069 + - 92070 + - 92071 + - 92072 + - 92073 + - 92074 + - 92075 + - 92076 + - 92077 + - 92078 + - 92079 + - 92080 + - 92081 + - 92082 + - 92083 + - 92084 + - 92085 + - 92086 + - 92087 + - 92088 + - 92089 + - 92090 + - 92091 + - 92092 + - 92093 + - 92094 + - 92095 + - 92096 + - 92097 + - 92098 + - 92099 + - 92100 + - 92101 + - 92102 + - 92103 + - 92104 + - 92105 + - 92106 + - 92107 + - 92108 + - 92109 + - 92110 + - 92111 + - 92112 + - 92113 + - 92114 + - 92115 + - 92116 + - 92117 + - 92118 + - 92119 + - 92120 + - 92121 + - 92122 + - 92123 + - 92124 + - 92125 + - 92126 + - 92127 + - 92128 + - 92129 + - 92130 + - 92131 + - 92132 + - 92133 + - 92134 + - 92135 + - 92136 + - 92137 + - 92138 + - 92139 + - 92140 + - 92141 + - 92142 + - 92143 + - 92144 + - 92145 + - 92146 + - 92147 + - 92148 + - 92149 + - 92150 + - 92151 + - 92152 + - 92153 + - 92154 + - 92155 + - 92156 + - 92157 + - 92158 + - 92159 + - 92160 + - 92161 + - 92162 + - 92163 + - 92164 + - 92165 + - 92166 + - 92167 + - 92168 + - 92169 + - 92170 + - 92171 + - 92172 + - 92173 + - 92174 + - 92175 + - 92176 + - 92177 + - 92178 + - 92179 + - 92180 + - 92181 + - 92182 + - 92183 + - 92184 + - 92185 + - 92186 + - 92187 + - 92188 + - 92189 + - 92190 + - 92191 + - 92192 + - 92193 + - 92194 + - 92195 + - 92196 + - 92197 + - 92198 + - 92199 + - 92200 + - 92201 + - 92202 + - 92203 + - 92204 + - 92205 + - 92206 + - 92207 + - 92208 + - 92209 + - 92210 + - 92211 + - 92212 + - 92213 + - 92214 + - 92215 + - 92216 + - 92217 + - 92218 + - 92219 + - 92220 + - 92221 + - 92222 + - 92223 + - 92224 + - 92225 + - 92226 + - 92227 + - 92228 + - 92229 + - 92230 + - 92231 + - 92232 + - 92233 + - 92234 + - 92235 + - 92236 + - 92237 + - 92238 + - 92239 + - 92240 + - 92241 + - 92242 + - 92243 + - 92244 + - 92245 + - 92246 + - 92247 + - 92248 + - 92249 + - 92250 + - 92251 + - 92252 + - 92253 + - 92254 + - 92255 + - 92256 + - 92257 + - 92258 + - 92259 + - 92260 + - 92261 + - 92262 + - 92263 + - 92264 + - 92265 + - 92266 + - 92267 + - 92268 + - 92269 + - 92270 + - 92271 + - 92272 + - 92273 + - 92274 + - 92275 + - 92276 + - 92277 + - 92278 + - 92279 + - 92280 + - 92281 + - 92282 + - 92283 + - 92284 + - 92285 + - 92286 + - 92287 + - 92288 + - 92289 + - 92290 + - 92291 + - 92292 + - 92293 + - 92294 + - 92295 + - 92296 + - 92297 + - 92298 + - 92299 + - 92300 + - 92301 + - 92302 + - 92303 + - 92304 + - 92305 + - 92306 + - 92307 + - 92308 + - 92309 + - 92310 + - 92311 + - 92312 + - 92313 + - 92314 + - 92315 + - 92316 + - 92317 + - 92318 + - 92319 + - 92320 + - 92321 + - 92322 + - 92323 + - 92324 + - 92325 + - 92326 + - 92327 + - 92328 + - 92329 + - 92330 + - 92331 + - 92332 + - 92333 + - 92334 + - 92335 + - 92336 + - 92337 + - 92338 + - 92339 + - 92340 + - 92341 + - 92342 + - 92343 + - 92344 + - 92345 + - 92346 + - 92347 + - 92348 + - 92349 + - 92350 + - 92351 + - 92352 + - 92353 + - 92354 + - 92355 + - 92356 + - 92357 + - 92358 + - 92359 + - 92360 + - 92361 + - 92362 + - 92363 + - 92364 + - 92365 + - 92366 + - 92367 + - 92368 + - 92369 + - 92370 + - 92371 + - 92372 + - 92373 + - 92374 + - 92375 + - 92376 + - 92377 + - 92378 + - 92379 + - 92380 + - 92381 + - 92382 + - 92383 + - 92384 + - 92385 + - 92386 + - 92387 + - 92388 + - 92389 + - 92390 + - 92391 + - 92392 + - 92393 + - 92394 + - 92395 + - 92396 + - 92397 + - 92398 + - 92399 + - 92400 + - 92401 + - 92402 + - 92403 + - 92404 + - 92405 + - 92406 + - 92407 + - 92408 + - 92409 + - 92410 + - 92411 + - 92412 + - 92413 + - 92414 + - 92415 + - 92416 + - 92417 + - 92418 + - 92419 + - 92420 + - 92421 + - 92422 + - 92423 + - 92424 + - 92425 + - 92426 + - 92427 + - 92428 + - 92429 + - 92430 + - 92431 + - 92432 + - 92433 + - 92434 + - 92435 + - 92436 + - 92437 + - 92438 + - 92439 + - 92440 + - 92441 + - 92442 + - 92443 + - 92444 + - 92445 + - 92446 + - 92447 + - 92448 + - 92449 + - 92450 + - 92451 + - 92452 + - 92453 + - 92454 + - 92455 + - 92456 + - 92457 + - 92458 + - 92459 + - 92460 + - 92461 + - 92462 + - 92463 + - 92464 + - 92465 + - 92466 + - 92467 + - 92468 + - 92469 + - 92470 + - 92471 + - 92472 + - 92473 + - 92474 + - 92475 + - 92476 + - 92477 + - 92478 + - 92479 + - 92480 + - 92481 + - 92482 + - 92483 + - 92484 + - 92485 + - 92486 + - 92487 + - 92488 + - 92489 + - 92490 + - 92491 + - 92492 + - 92493 + - 92494 + - 92495 + - 92496 + - 92497 + - 92498 + - 92499 + - 92500 + - 92501 + - 92502 + - 92503 + - 92504 + - 92505 + - 92506 + - 92507 + - 92508 + - 92509 + - 92510 + - 92511 + - 92512 + - 92513 + - 92514 + - 92515 + - 92516 + - 92517 + - 92518 + - 92519 + - 92520 + - 92521 + - 92522 + - 92523 + - 92524 + - 92525 + - 92526 + - 92527 + - 92528 + - 92529 + - 92530 + - 92531 + - 92532 + - 92533 + - 92534 + - 92535 + - 92536 + - 92537 + - 92538 + - 92539 + - 92540 + - 92541 + - 92542 + - 92543 + - 92544 + - 92545 + - 92546 + - 92547 + - 92548 + - 92549 + - 92550 + - 92551 + - 92552 + - 92553 + - 92554 + - 92555 + - 92556 + - 92557 + - 92558 + - 92559 + - 92560 + - 92561 + - 92562 + - 92563 + - 92564 + - 92565 + - 92566 + - 92567 + - 92568 + - 92569 + - 92570 + - 92571 + - 92572 + - 92573 + - 92574 + - 92575 + - 92576 + - 92577 + - 92578 + - 92579 + - 92580 + - 92581 + - 92582 + - 92583 + - 92584 + - 92585 + - 92586 + - 92587 + - 92588 + - 92589 + - 92590 + - 92591 + - 92592 + - 92593 + - 92594 + - 92595 + - 92596 + - 92597 + - 92598 + - 92599 + - 92600 + - 92601 + - 92602 + - 92603 + - 92604 + - 92605 + - 92606 + - 92607 + - 92608 + - 92609 + - 92610 + - 92611 + - 92612 + - 92613 + - 92614 + - 92615 + - 92616 + - 92617 + - 92618 + - 92619 + - 92620 + - 92621 + - 92622 + - 92623 + - 92624 + - 92625 + - 92626 + - 92627 + - 92628 + - 92629 + - 92630 + - 92631 + - 92632 + - 92633 + - 92634 + - 92635 + - 92636 + - 92637 + - 92638 + - 92639 + - 92640 + - 92641 + - 92642 + - 92643 + - 92644 + - 92645 + - 92646 + - 92647 + - 92648 + - 92649 + - 92650 + - 92651 + - 92652 + - 92653 + - 92654 + - 92655 + - 92656 + - 92657 + - 92658 + - 92659 + - 92660 + - 92661 + - 92662 + - 92663 + - 92664 + - 92665 + - 92666 + - 92667 + - 92668 + - 92669 + - 92670 + - 92671 + - 92672 + - 92673 + - 92674 + - 92675 + - 92676 + - 92677 + - 92678 + - 92679 + - 92680 + - 92681 + - 92682 + - 92683 + - 92684 + - 92685 + - 92686 + - 92687 + - 92688 + - 92689 + - 92690 + - 92691 + - 92692 + - 92693 + - 92694 + - 92695 + - 92696 + - 92697 + - 92698 + - 92699 + - 92700 + - 92701 + - 92702 + - 92703 + - 92704 + - 92705 + - 92706 + - 92707 + - 92708 + - 92709 + - 92710 + - 92711 + - 92712 + - 92713 + - 92714 + - 92715 + - 92716 + - 92717 + - 92718 + - 92719 + - 92720 + - 92721 + - 92722 + - 92723 + - 92724 + - 92725 + - 92726 + - 92727 + - 92728 + - 92729 + - 92730 + - 92731 + - 92732 + - 92733 + - 92734 + - 92735 + - 92736 + - 92737 + - 92738 + - 92739 + - 92740 + - 92741 + - 92742 + - 92743 + - 92744 + - 92745 + - 92746 + - 92747 + - 92748 + - 92749 + - 92750 + - 92751 + - 92752 + - 92753 + - 92754 + - 92755 + - 92756 + - 92757 + - 92758 + - 92759 + - 92760 + - 92761 + - 92762 + - 92763 + - 92764 + - 92765 + - 92766 + - 92767 + - 92768 + - 92769 + - 92770 + - 92771 + - 92772 + - 92773 + - 92774 + - 92775 + - 92776 + - 92777 + - 92778 + - 92779 + - 92780 + - 92781 + - 92782 + - 92783 + - 92784 + - 92785 + - 92786 + - 92787 + - 92788 + - 92789 + - 92790 + - 92791 + - 92792 + - 92793 + - 92794 + - 92795 + - 92796 + - 92797 + - 92798 + - 92799 + - 92800 + - 92801 + - 92802 + - 92803 + - 92804 + - 92805 + - 92806 + - 92807 + - 92808 + - 92809 + - 92810 + - 92811 + - 92812 + - 92813 + - 92814 + - 92815 + - 92816 + - 92817 + - 92818 + - 92819 + - 92820 + - 92821 + - 92822 + - 92823 + - 92824 + - 92825 + - 92826 + - 92827 + - 92828 + - 92829 + - 92830 + - 92831 + - 92832 + - 92833 + - 92834 + - 92835 + - 92836 + - 92837 + - 92838 + - 92839 + - 92840 + - 92841 + - 92842 + - 92843 + - 92844 + - 92845 + - 92846 + - 92847 + - 92848 + - 92849 + - 92850 + - 92851 + - 92852 + - 92853 + - 92854 + - 92855 + - 92856 + - 92857 + - 92858 + - 92859 + - 92860 + - 92861 + - 92862 + - 92863 + - 92864 + - 92865 + - 92866 + - 92867 + - 92868 + - 92869 + - 92870 + - 92871 + - 92872 + - 92873 + - 92874 + - 92875 + - 92876 + - 92877 + - 92878 + - 92879 + - 92880 + - 92881 + - 92882 + - 92883 + - 92884 + - 92885 + - 92886 + - 92887 + - 92888 + - 92889 + - 92890 + - 92891 + - 92892 + - 92893 + - 92894 + - 92895 + - 92896 + - 92897 + - 92898 + - 92899 + - 92900 + - 92901 + - 92902 + - 92903 + - 92904 + - 92905 + - 92906 + - 92907 + - 92908 + - 92909 + - 92910 + - 92911 + - 92912 + - 92913 + - 92914 + - 92915 + - 92916 + - 92917 + - 92918 + - 92919 + - 92920 + - 92921 + - 92922 + - 92923 + - 92924 + - 92925 + - 92926 + - 92927 + - 92928 + - 92929 + - 92930 + - 92931 + - 92932 + - 92933 + - 92934 + - 92935 + - 92936 + - 92937 + - 92938 + - 92939 + - 92940 + - 92941 + - 92942 + - 92943 + - 92944 + - 92945 + - 92946 + - 92947 + - 92948 + - 92949 + - 92950 + - 92951 + - 92952 + - 92953 + - 92954 + - 92955 + - 92956 + - 92957 + - 92958 + - 92959 + - 92960 + - 92961 + - 92962 + - 92963 + - 92964 + - 92965 + - 92966 + - 92967 + - 92968 + - 92969 + - 92970 + - 92971 + - 92972 + - 92973 + - 92974 + - 92975 + - 92976 + - 92977 + - 92978 + - 92979 + - 92980 + - 92981 + - 92982 + - 92983 + - 92984 + - 92985 + - 92986 + - 92987 + - 92988 + - 92989 + - 92990 + - 92991 + - 92992 + - 92993 + - 92994 + - 92995 + - 92996 + - 92997 + - 92998 + - 92999 + - 93000 + - 93001 + - 93002 + - 93003 + - 93004 + - 93005 + - 93006 + - 93007 + - 93008 + - 93009 + - 93010 + - 93011 + - 93012 + - 93013 + - 93014 + - 93015 + - 93016 + - 93017 + - 93018 + - 93019 + - 93020 + - 93021 + - 93022 + - 93023 + - 93024 + - 93025 + - 93026 + - 93027 + - 93028 + - 93029 + - 93030 + - 93031 + - 93032 + - 93033 + - 93034 + - 93035 + - 93036 + - 93037 + - 93038 + - 93039 + - 93040 + - 93041 + - 93042 + - 93043 + - 93044 + - 93045 + - 93046 + - 93047 + - 93048 + - 93049 + - 93050 + - 93051 + - 93052 + - 93053 + - 93054 + - 93055 + - 93056 + - 93057 + - 93058 + - 93059 + - 93060 + - 93061 + - 93062 + - 93063 + - 93064 + - 93065 + - 93066 + - 93067 + - 93068 + - 93069 + - 93070 + - 93071 + - 93072 + - 93073 + - 93074 + - 93075 + - 93076 + - 93077 + - 93078 + - 93079 + - 93080 + - 93081 + - 93082 + - 93083 + - 93084 + - 93085 + - 93086 + - 93087 + - 93088 + - 93089 + - 93090 + - 93091 + - 93092 + - 93093 + - 93094 + - 93095 + - 93096 + - 93097 + - 93098 + - 93099 + - 93100 + - 93101 + - 93102 + - 93103 + - 93104 + - 93105 + - 93106 + - 93107 + - 93108 + - 93109 + - 93110 + - 93111 + - 93112 + - 93113 + - 93114 + - 93115 + - 93116 + - 93117 + - 93118 + - 93119 + - 93120 + - 93121 + - 93122 + - 93123 + - 93124 + - 93125 + - 93126 + - 93127 + - 93128 + - 93129 + - 93130 + - 93131 + - 93132 + - 93133 + - 93134 + - 93135 + - 93136 + - 93137 + - 93138 + - 93139 + - 93140 + - 93141 + - 93142 + - 93143 + - 93144 + - 93145 + - 93146 + - 93147 + - 93148 + - 93149 + - 93150 + - 93151 + - 93152 + - 93153 + - 93154 + - 93155 + - 93156 + - 93157 + - 93158 + - 93159 + - 93160 + - 93161 + - 93162 + - 93163 + - 93164 + - 93165 + - 93166 + - 93167 + - 93168 + - 93169 + - 93170 + - 93171 + - 93172 + - 93173 + - 93174 + - 93175 + - 93176 + - 93177 + - 93178 + - 93179 + - 93180 + - 93181 + - 93182 + - 93183 + - 93184 + - 93185 + - 93186 + - 93187 + - 93188 + - 93189 + - 93190 + - 93191 + - 93192 + - 93193 + - 93194 + - 93195 + - 93196 + - 93197 + - 93198 + - 93199 + - 93200 + - 93201 + - 93202 + - 93203 + - 93204 + - 93205 + - 93206 + - 93207 + - 93208 + - 93209 + - 93210 + - 93211 + - 93212 + - 93213 + - 93214 + - 93215 + - 93216 + - 93217 + - 93218 + - 93219 + - 93220 + - 93221 + - 93222 + - 93223 + - 93224 + - 93225 + - 93226 + - 93227 + - 93228 + - 93229 + - 93230 + - 93231 + - 93232 + - 93233 + - 93234 + - 93235 + - 93236 + - 93237 + - 93238 + - 93239 + - 93240 + - 93241 + - 93242 + - 93243 + - 93244 + - 93245 + - 93246 + - 93247 + - 93248 + - 93249 + - 93250 + - 93251 + - 93252 + - 93253 + - 93254 + - 93255 + - 93256 + - 93257 + - 93258 + - 93259 + - 93260 + - 93261 + - 93262 + - 93263 + - 93264 + - 93265 + - 93266 + - 93267 + - 93268 + - 93269 + - 93270 + - 93271 + - 93272 + - 93273 + - 93274 + - 93275 + - 93276 + - 93277 + - 93278 + - 93279 + - 93280 + - 93281 + - 93282 + - 93283 + - 93284 + - 93285 + - 93286 + - 93287 + - 93288 + - 93289 + - 93290 + - 93291 + - 93292 + - 93293 + - 93294 + - 93295 + - 93296 + - 93297 + - 93298 + - 93299 + - 93300 + - 93301 + - 93302 + - 93303 + - 93304 + - 93305 + - 93306 + - 93307 + - 93308 + - 93309 + - 93310 + - 93311 + - 93312 + - 93313 + - 93314 + - 93315 + - 93316 + - 93317 + - 93318 + - 93319 + - 93320 + - 93321 + - 93322 + - 93323 + - 93324 + - 93325 + - 93326 + - 93327 + - 93328 + - 93329 + - 93330 + - 93331 + - 93332 + - 93333 + - 93334 + - 93335 + - 93336 + - 93337 + - 93338 + - 93339 + - 93340 + - 93341 + - 93342 + - 93343 + - 93344 + - 93345 + - 93346 + - 93347 + - 93348 + - 93349 + - 93350 + - 93351 + - 93352 + - 93353 + - 93354 + - 93355 + - 93356 + - 93357 + - 93358 + - 93359 + - 93360 + - 93361 + - 93362 + - 93363 + - 93364 + - 93365 + - 93366 + - 93367 + - 93368 + - 93369 + - 93370 + - 93371 + - 93372 + - 93373 + - 93374 + - 93375 + - 93376 + - 93377 + - 93378 + - 93379 + - 93380 + - 93381 + - 93382 + - 93383 + - 93384 + - 93385 + - 93386 + - 93387 + - 93388 + - 93389 + - 93390 + - 93391 + - 93392 + - 93393 + - 93394 + - 93395 + - 93396 + - 93397 + - 93398 + - 93399 + - 93400 + - 93401 + - 93402 + - 93403 + - 93404 + - 93405 + - 93406 + - 93407 + - 93408 + - 93409 + - 93410 + - 93411 + - 93412 + - 93413 + - 93414 + - 93415 + - 93416 + - 93417 + - 93418 + - 93419 + - 93420 + - 93421 + - 93422 + - 93423 + - 93424 + - 93425 + - 93426 + - 93427 + - 93428 + - 93429 + - 93430 + - 93431 + - 93432 + - 93433 + - 93434 + - 93435 + - 93436 + - 93437 + - 93438 + - 93439 + - 93440 + - 93441 + - 93442 + - 93443 + - 93444 + - 93445 + - 93446 + - 93447 + - 93448 + - 93449 + - 93450 + - 93451 + - 93452 + - 93453 + - 93454 + - 93455 + - 93456 + - 93457 + - 93458 + - 93459 + - 93460 + - 93461 + - 93462 + - 93463 + - 93464 + - 93465 + - 93466 + - 93467 + - 93468 + - 93469 + - 93470 + - 93471 + - 93472 + - 93473 + - 93474 + - 93475 + - 93476 + - 93477 + - 93478 + - 93479 + - 93480 + - 93481 + - 93482 + - 93483 + - 93484 + - 93485 + - 93486 + - 93487 + - 93488 + - 93489 + - 93490 + - 93491 + - 93492 + - 93493 + - 93494 + - 93495 + - 93496 + - 93497 + - 93498 + - 93499 + - 93500 + - 93501 + - 93502 + - 93503 + - 93504 + - 93505 + - 93506 + - 93507 + - 93508 + - 93509 + - 93510 + - 93511 + - 93512 + - 93513 + - 93514 + - 93515 + - 93516 + - 93517 + - 93518 + - 93519 + - 93520 + - 93521 + - 93522 + - 93523 + - 93524 + - 93525 + - 93526 + - 93527 + - 93528 + - 93529 + - 93530 + - 93531 + - 93532 + - 93533 + - 93534 + - 93535 + - 93536 + - 93537 + - 93538 + - 93539 + - 93540 + - 93541 + - 93542 + - 93543 + - 93544 + - 93545 + - 93546 + - 93547 + - 93548 + - 93549 + - 93550 + - 93551 + - 93552 + - 93553 + - 93554 + - 93555 + - 93556 + - 93557 + - 93558 + - 93559 + - 93560 + - 93561 + - 93562 + - 93563 + - 93564 + - 93565 + - 93566 + - 93567 + - 93568 + - 93569 + - 93570 + - 93571 + - 93572 + - 93573 + - 93574 + - 93575 + - 93576 + - 93577 + - 93578 + - 93579 + - 93580 + - 93581 + - 93582 + - 93583 + - 93584 + - 93585 + - 93586 + - 93587 + - 93588 + - 93589 + - 93590 + - 93591 + - 93592 + - 93593 + - 93594 + - 93595 + - 93596 + - 93597 + - 93598 + - 93599 + - 93600 + - 93601 + - 93602 + - 93603 + - 93604 + - 93605 + - 93606 + - 93607 + - 93608 + - 93609 + - 93610 + - 93611 + - 93612 + - 93613 + - 93614 + - 93615 + - 93616 + - 93617 + - 93618 + - 93619 + - 93620 + - 93621 + - 93622 + - 93623 + - 93624 + - 93625 + - 93626 + - 93627 + - 93628 + - 93629 + - 93630 + - 93631 + - 93632 + - 93633 + - 93634 + - 93635 + - 93636 + - 93637 + - 93638 + - 93639 + - 93640 + - 93641 + - 93642 + - 93643 + - 93644 + - 93645 + - 93646 + - 93647 + - 93648 + - 93649 + - 93650 + - 93651 + - 93652 + - 93653 + - 93654 + - 93655 + - 93656 + - 93657 + - 93658 + - 93659 + - 93660 + - 93661 + - 93662 + - 93663 + - 93664 + - 93665 + - 93666 + - 93667 + - 93668 + - 93669 + - 93670 + - 93671 + - 93672 + - 93673 + - 93674 + - 93675 + - 93676 + - 93677 + - 93678 + - 93679 + - 93680 + - 93681 + - 93682 + - 93683 + - 93684 + - 93685 + - 93686 + - 93687 + - 93688 + - 93689 + - 93690 + - 93691 + - 93692 + - 93693 + - 93694 + - 93695 + - 93696 + - 93697 + - 93698 + - 93699 + - 93700 + - 93701 + - 93702 + - 93703 + - 93704 + - 93705 + - 93706 + - 93707 + - 93708 + - 93709 + - 93710 + - 93711 + - 93712 + - 93713 + - 93714 + - 93715 + - 93716 + - 93717 + - 93718 + - 93719 + - 93720 + - 93721 + - 93722 + - 93723 + - 93724 + - 93725 + - 93726 + - 93727 + - 93728 + - 93729 + - 93730 + - 93731 + - 93732 + - 93733 + - 93734 + - 93735 + - 93736 + - 93737 + - 93738 + - 93739 + - 93740 + - 93741 + - 93742 + - 93743 + - 93744 + - 93745 + - 93746 + - 93747 + - 93748 + - 93749 + - 93750 + - 93751 + - 93752 + - 93753 + - 93754 + - 93755 + - 93756 + - 93757 + - 93758 + - 93759 + - 93760 + - 93761 + - 93762 + - 93763 + - 93764 + - 93765 + - 93766 + - 93767 + - 93768 + - 93769 + - 93770 + - 93771 + - 93772 + - 93773 + - 93774 + - 93775 + - 93776 + - 93777 + - 93778 + - 93779 + - 93780 + - 93781 + - 93782 + - 93783 + - 93784 + - 93785 + - 93786 + - 93787 + - 93788 + - 93789 + - 93790 + - 93791 + - 93792 + - 93793 + - 93794 + - 93795 + - 93796 + - 93797 + - 93798 + - 93799 + - 93800 + - 93801 + - 93802 + - 93803 + - 93804 + - 93805 + - 93806 + - 93807 + - 93808 + - 93809 + - 93810 + - 93811 + - 93812 + - 93813 + - 93814 + - 93815 + - 93816 + - 93817 + - 93818 + - 93819 + - 93820 + - 93821 + - 93822 + - 93823 + - 93824 + - 93825 + - 93826 + - 93827 + - 93828 + - 93829 + - 93830 + - 93831 + - 93832 + - 93833 + - 93834 + - 93835 + - 93836 + - 93837 + - 93838 + - 93839 + - 93840 + - 93841 + - 93842 + - 93843 + - 93844 + - 93845 + - 93846 + - 93847 + - 93848 + - 93849 + - 93850 + - 93851 + - 93852 + - 93853 + - 93854 + - 93855 + - 93856 + - 93857 + - 93858 + - 93859 + - 93860 + - 93861 + - 93862 + - 93863 + - 93864 + - 93865 + - 93866 + - 93867 + - 93868 + - 93869 + - 93870 + - 93871 + - 93872 + - 93873 + - 93874 + - 93875 + - 93876 + - 93877 + - 93878 + - 93879 + - 93880 + - 93881 + - 93882 + - 93883 + - 93884 + - 93885 + - 93886 + - 93887 + - 93888 + - 93889 + - 93890 + - 93891 + - 93892 + - 93893 + - 93894 + - 93895 + - 93896 + - 93897 + - 93898 + - 93899 + - 93900 + - 93901 + - 93902 + - 93903 + - 93904 + - 93905 + - 93906 + - 93907 + - 93908 + - 93909 + - 93910 + - 93911 + - 93912 + - 93913 + - 93914 + - 93915 + - 93916 + - 93917 + - 93918 + - 93919 + - 93920 + - 93921 + - 93922 + - 93923 + - 93924 + - 93925 + - 93926 + - 93927 + - 93928 + - 93929 + - 93930 + - 93931 + - 93932 + - 93933 + - 93934 + - 93935 + - 93936 + - 93937 + - 93938 + - 93939 + - 93940 + - 93941 + - 93942 + - 93943 + - 93944 + - 93945 + - 93946 + - 93947 + - 93948 + - 93949 + - 93950 + - 93951 + - 93952 + - 93953 + - 93954 + - 93955 + - 93956 + - 93957 + - 93958 + - 93959 + - 93960 + - 93961 + - 93962 + - 93963 + - 93964 + - 93965 + - 93966 + - 93967 + - 93968 + - 93969 + - 93970 + - 93971 + - 93972 + - 93973 + - 93974 + - 93975 + - 93976 + - 93977 + - 93978 + - 93979 + - 93980 + - 93981 + - 93982 + - 93983 + - 93984 + - 93985 + - 93986 + - 93987 + - 93988 + - 93989 + - 93990 + - 93991 + - 93992 + - 93993 + - 93994 + - 93995 + - 93996 + - 93997 + - 93998 + - 93999 + - 94000 + - 94001 + - 94002 + - 94003 + - 94004 + - 94005 + - 94006 + - 94007 + - 94008 + - 94009 + - 94010 + - 94011 + - 94012 + - 94013 + - 94014 + - 94015 + - 94016 + - 94017 + - 94018 + - 94019 + - 94020 + - 94021 + - 94022 + - 94023 + - 94024 + - 94025 + - 94026 + - 94027 + - 94028 + - 94029 + - 94030 + - 94031 + - 94032 + - 94033 + - 94034 + - 94035 + - 94036 + - 94037 + - 94038 + - 94039 + - 94040 + - 94041 + - 94042 + - 94043 + - 94044 + - 94045 + - 94046 + - 94047 + - 94048 + - 94049 + - 94050 + - 94051 + - 94052 + - 94053 + - 94054 + - 94055 + - 94056 + - 94057 + - 94058 + - 94059 + - 94060 + - 94061 + - 94062 + - 94063 + - 94064 + - 94065 + - 94066 + - 94067 + - 94068 + - 94069 + - 94070 + - 94071 + - 94072 + - 94073 + - 94074 + - 94075 + - 94076 + - 94077 + - 94078 + - 94079 + - 94080 + - 94081 + - 94082 + - 94083 + - 94084 + - 94085 + - 94086 + - 94087 + - 94088 + - 94089 + - 94090 + - 94091 + - 94092 + - 94093 + - 94094 + - 94095 + - 94096 + - 94097 + - 94098 + - 94099 + - 94100 + - 94101 + - 94102 + - 94103 + - 94104 + - 94105 + - 94106 + - 94107 + - 94108 + - 94109 + - 94110 + - 94111 + - 94112 + - 94113 + - 94114 + - 94115 + - 94116 + - 94117 + - 94118 + - 94119 + - 94120 + - 94121 + - 94122 + - 94123 + - 94124 + - 94125 + - 94126 + - 94127 + - 94128 + - 94129 + - 94130 + - 94131 + - 94132 + - 94133 + - 94134 + - 94135 + - 94136 + - 94137 + - 94138 + - 94139 + - 94140 + - 94141 + - 94142 + - 94143 + - 94144 + - 94145 + - 94146 + - 94147 + - 94148 + - 94149 + - 94150 + - 94151 + - 94152 + - 94153 + - 94154 + - 94155 + - 94156 + - 94157 + - 94158 + - 94159 + - 94160 + - 94161 + - 94162 + - 94163 + - 94164 + - 94165 + - 94166 + - 94167 + - 94168 + - 94169 + - 94170 + - 94171 + - 94172 + - 94173 + - 94174 + - 94175 + - 94176 + - 94177 + - 94178 + - 94179 + - 94180 + - 94181 + - 94182 + - 94183 + - 94184 + - 94185 + - 94186 + - 94187 + - 94188 + - 94189 + - 94190 + - 94191 + - 94192 + - 94193 + - 94194 + - 94195 + - 94196 + - 94197 + - 94198 + - 94199 + - 94200 + - 94201 + - 94202 + - 94203 + - 94204 + - 94205 + - 94206 + - 94207 + - 94208 + - 94209 + - 94210 + - 94211 + - 94212 + - 94213 + - 94214 + - 94215 + - 94216 + - 94217 + - 94218 + - 94219 + - 94220 + - 94221 + - 94222 + - 94223 + - 94224 + - 94225 + - 94226 + - 94227 + - 94228 + - 94229 + - 94230 + - 94231 + - 94232 + - 94233 + - 94234 + - 94235 + - 94236 + - 94237 + - 94238 + - 94239 + - 94240 + - 94241 + - 94242 + - 94243 + - 94244 + - 94245 + - 94246 + - 94247 + - 94248 + - 94249 + - 94250 + - 94251 + - 94252 + - 94253 + - 94254 + - 94255 + - 94256 + - 94257 + - 94258 + - 94259 + - 94260 + - 94261 + - 94262 + - 94263 + - 94264 + - 94265 + - 94266 + - 94267 + - 94268 + - 94269 + - 94270 + - 94271 + - 94272 + - 94273 + - 94274 + - 94275 + - 94276 + - 94277 + - 94278 + - 94279 + - 94280 + - 94281 + - 94282 + - 94283 + - 94284 + - 94285 + - 94286 + - 94287 + - 94288 + - 94289 + - 94290 + - 94291 + - 94292 + - 94293 + - 94294 + - 94295 + - 94296 + - 94297 + - 94298 + - 94299 + - 94300 + - 94301 + - 94302 + - 94303 + - 94304 + - 94305 + - 94306 + - 94307 + - 94308 + - 94309 + - 94310 + - 94311 + - 94312 + - 94313 + - 94314 + - 94315 + - 94316 + - 94317 + - 94318 + - 94319 + - 94320 + - 94321 + - 94322 + - 94323 + - 94324 + - 94325 + - 94326 + - 94327 + - 94328 + - 94329 + - 94330 + - 94331 + - 94332 + - 94333 + - 94334 + - 94335 + - 94336 + - 94337 + - 94338 + - 94339 + - 94340 + - 94341 + - 94342 + - 94343 + - 94344 + - 94345 + - 94346 + - 94347 + - 94348 + - 94349 + - 94350 + - 94351 + - 94352 + - 94353 + - 94354 + - 94355 + - 94356 + - 94357 + - 94358 + - 94359 + - 94360 + - 94361 + - 94362 + - 94363 + - 94364 + - 94365 + - 94366 + - 94367 + - 94368 + - 94369 + - 94370 + - 94371 + - 94372 + - 94373 + - 94374 + - 94375 + - 94376 + - 94377 + - 94378 + - 94379 + - 94380 + - 94381 + - 94382 + - 94383 + - 94384 + - 94385 + - 94386 + - 94387 + - 94388 + - 94389 + - 94390 + - 94391 + - 94392 + - 94393 + - 94394 + - 94395 + - 94396 + - 94397 + - 94398 + - 94399 + - 94400 + - 94401 + - 94402 + - 94403 + - 94404 + - 94405 + - 94406 + - 94407 + - 94408 + - 94409 + - 94410 + - 94411 + - 94412 + - 94413 + - 94414 + - 94415 + - 94416 + - 94417 + - 94418 + - 94419 + - 94420 + - 94421 + - 94422 + - 94423 + - 94424 + - 94425 + - 94426 + - 94427 + - 94428 + - 94429 + - 94430 + - 94431 + - 94432 + - 94433 + - 94434 + - 94435 + - 94436 + - 94437 + - 94438 + - 94439 + - 94440 + - 94441 + - 94442 + - 94443 + - 94444 + - 94445 + - 94446 + - 94447 + - 94448 + - 94449 + - 94450 + - 94451 + - 94452 + - 94453 + - 94454 + - 94455 + - 94456 + - 94457 + - 94458 + - 94459 + - 94460 + - 94461 + - 94462 + - 94463 + - 94464 + - 94465 + - 94466 + - 94467 + - 94468 + - 94469 + - 94470 + - 94471 + - 94472 + - 94473 + - 94474 + - 94475 + - 94476 + - 94477 + - 94478 + - 94479 + - 94480 + - 94481 + - 94482 + - 94483 + - 94484 + - 94485 + - 94486 + - 94487 + - 94488 + - 94489 + - 94490 + - 94491 + - 94492 + - 94493 + - 94494 + - 94495 + - 94496 + - 94497 + - 94498 + - 94499 + - 94500 + - 94501 + - 94502 + - 94503 + - 94504 + - 94505 + - 94506 + - 94507 + - 94508 + - 94509 + - 94510 + - 94511 + - 94512 + - 94513 + - 94514 + - 94515 + - 94516 + - 94517 + - 94518 + - 94519 + - 94520 + - 94521 + - 94522 + - 94523 + - 94524 + - 94525 + - 94526 + - 94527 + - 94528 + - 94529 + - 94530 + - 94531 + - 94532 + - 94533 + - 94534 + - 94535 + - 94536 + - 94537 + - 94538 + - 94539 + - 94540 + - 94541 + - 94542 + - 94543 + - 94544 + - 94545 + - 94546 + - 94547 + - 94548 + - 94549 + - 94550 + - 94551 + - 94552 + - 94553 + - 94554 + - 94555 + - 94556 + - 94557 + - 94558 + - 94559 + - 94560 + - 94561 + - 94562 + - 94563 + - 94564 + - 94565 + - 94566 + - 94567 + - 94568 + - 94569 + - 94570 + - 94571 + - 94572 + - 94573 + - 94574 + - 94575 + - 94576 + - 94577 + - 94578 + - 94579 + - 94580 + - 94581 + - 94582 + - 94583 + - 94584 + - 94585 + - 94586 + - 94587 + - 94588 + - 94589 + - 94590 + - 94591 + - 94592 + - 94593 + - 94594 + - 94595 + - 94596 + - 94597 + - 94598 + - 94599 + - 94600 + - 94601 + - 94602 + - 94603 + - 94604 + - 94605 + - 94606 + - 94607 + - 94608 + - 94609 + - 94610 + - 94611 + - 94612 + - 94613 + - 94614 + - 94615 + - 94616 + - 94617 + - 94618 + - 94619 + - 94620 + - 94621 + - 94622 + - 94623 + - 94624 + - 94625 + - 94626 + - 94627 + - 94628 + - 94629 + - 94630 + - 94631 + - 94632 + - 94633 + - 94634 + - 94635 + - 94636 + - 94637 + - 94638 + - 94639 + - 94640 + - 94641 + - 94642 + - 94643 + - 94644 + - 94645 + - 94646 + - 94647 + - 94648 + - 94649 + - 94650 + - 94651 + - 94652 + - 94653 + - 94654 + - 94655 + - 94656 + - 94657 + - 94658 + - 94659 + - 94660 + - 94661 + - 94662 + - 94663 + - 94664 + - 94665 + - 94666 + - 94667 + - 94668 + - 94669 + - 94670 + - 94671 + - 94672 + - 94673 + - 94674 + - 94675 + - 94676 + - 94677 + - 94678 + - 94679 + - 94680 + - 94681 + - 94682 + - 94683 + - 94684 + - 94685 + - 94686 + - 94687 + - 94688 + - 94689 + - 94690 + - 94691 + - 94692 + - 94693 + - 94694 + - 94695 + - 94696 + - 94697 + - 94698 + - 94699 + - 94700 + - 94701 + - 94702 + - 94703 + - 94704 + - 94705 + - 94706 + - 94707 + - 94708 + - 94709 + - 94710 + - 94711 + - 94712 + - 94713 + - 94714 + - 94715 + - 94716 + - 94717 + - 94718 + - 94719 + - 94720 + - 94721 + - 94722 + - 94723 + - 94724 + - 94725 + - 94726 + - 94727 + - 94728 + - 94729 + - 94730 + - 94731 + - 94732 + - 94733 + - 94734 + - 94735 + - 94736 + - 94737 + - 94738 + - 94739 + - 94740 + - 94741 + - 94742 + - 94743 + - 94744 + - 94745 + - 94746 + - 94747 + - 94748 + - 94749 + - 94750 + - 94751 + - 94752 + - 94753 + - 94754 + - 94755 + - 94756 + - 94757 + - 94758 + - 94759 + - 94760 + - 94761 + - 94762 + - 94763 + - 94764 + - 94765 + - 94766 + - 94767 + - 94768 + - 94769 + - 94770 + - 94771 + - 94772 + - 94773 + - 94774 + - 94775 + - 94776 + - 94777 + - 94778 + - 94779 + - 94780 + - 94781 + - 94782 + - 94783 + - 94784 + - 94785 + - 94786 + - 94787 + - 94788 + - 94789 + - 94790 + - 94791 + - 94792 + - 94793 + - 94794 + - 94795 + - 94796 + - 94797 + - 94798 + - 94799 + - 94800 + - 94801 + - 94802 + - 94803 + - 94804 + - 94805 + - 94806 + - 94807 + - 94808 + - 94809 + - 94810 + - 94811 + - 94812 + - 94813 + - 94814 + - 94815 + - 94816 + - 94817 + - 94818 + - 94819 + - 94820 + - 94821 + - 94822 + - 94823 + - 94824 + - 94825 + - 94826 + - 94827 + - 94828 + - 94829 + - 94830 + - 94831 + - 94832 + - 94833 + - 94834 + - 94835 + - 94836 + - 94837 + - 94838 + - 94839 + - 94840 + - 94841 + - 94842 + - 94843 + - 94844 + - 94845 + - 94846 + - 94847 + - 94848 + - 94849 + - 94850 + - 94851 + - 94852 + - 94853 + - 94854 + - 94855 + - 94856 + - 94857 + - 94858 + - 94859 + - 94860 + - 94861 + - 94862 + - 94863 + - 94864 + - 94865 + - 94866 + - 94867 + - 94868 + - 94869 + - 94870 + - 94871 + - 94872 + - 94873 + - 94874 + - 94875 + - 94876 + - 94877 + - 94878 + - 94879 + - 94880 + - 94881 + - 94882 + - 94883 + - 94884 + - 94885 + - 94886 + - 94887 + - 94888 + - 94889 + - 94890 + - 94891 + - 94892 + - 94893 + - 94894 + - 94895 + - 94896 + - 94897 + - 94898 + - 94899 + - 94900 + - 94901 + - 94902 + - 94903 + - 94904 + - 94905 + - 94906 + - 94907 + - 94908 + - 94909 + - 94910 + - 94911 + - 94912 + - 94913 + - 94914 + - 94915 + - 94916 + - 94917 + - 94918 + - 94919 + - 94920 + - 94921 + - 94922 + - 94923 + - 94924 + - 94925 + - 94926 + - 94927 + - 94928 + - 94929 + - 94930 + - 94931 + - 94932 + - 94933 + - 94934 + - 94935 + - 94936 + - 94937 + - 94938 + - 94939 + - 94940 + - 94941 + - 94942 + - 94943 + - 94944 + - 94945 + - 94946 + - 94947 + - 94948 + - 94949 + - 94950 + - 94951 + - 94952 + - 94953 + - 94954 + - 94955 + - 94956 + - 94957 + - 94958 + - 94959 + - 94960 + - 94961 + - 94962 + - 94963 + - 94964 + - 94965 + - 94966 + - 94967 + - 94968 + - 94969 + - 94970 + - 94971 + - 94972 + - 94973 + - 94974 + - 94975 + - 94976 + - 94977 + - 94978 + - 94979 + - 94980 + - 94981 + - 94982 + - 94983 + - 94984 + - 94985 + - 94986 + - 94987 + - 94988 + - 94989 + - 94990 + - 94991 + - 94992 + - 94993 + - 94994 + - 94995 + - 94996 + - 94997 + - 94998 + - 94999 + - 95000 + - 95001 + - 95002 + - 95003 + - 95004 + - 95005 + - 95006 + - 95007 + - 95008 + - 95009 + - 95010 + - 95011 + - 95012 + - 95013 + - 95014 + - 95015 + - 95016 + - 95017 + - 95018 + - 95019 + - 95020 + - 95021 + - 95022 + - 95023 + - 95024 + - 95025 + - 95026 + - 95027 + - 95028 + - 95029 + - 95030 + - 95031 + - 95032 + - 95033 + - 95034 + - 95035 + - 95036 + - 95037 + - 95038 + - 95039 + - 95040 + - 95041 + - 95042 + - 95043 + - 95044 + - 95045 + - 95046 + - 95047 + - 95048 + - 95049 + - 95050 + - 95051 + - 95052 + - 95053 + - 95054 + - 95055 + - 95056 + - 95057 + - 95058 + - 95059 + - 95060 + - 95061 + - 95062 + - 95063 + - 95064 + - 95065 + - 95066 + - 95067 + - 95068 + - 95069 + - 95070 + - 95071 + - 95072 + - 95073 + - 95074 + - 95075 + - 95076 + - 95077 + - 95078 + - 95079 + - 95080 + - 95081 + - 95082 + - 95083 + - 95084 + - 95085 + - 95086 + - 95087 + - 95088 + - 95089 + - 95090 + - 95091 + - 95092 + - 95093 + - 95094 + - 95095 + - 95096 + - 95097 + - 95098 + - 95099 + - 95100 + - 95101 + - 95102 + - 95103 + - 95104 + - 95105 + - 95106 + - 95107 + - 95108 + - 95109 + - 95110 + - 95111 + - 95112 + - 95113 + - 95114 + - 95115 + - 95116 + - 95117 + - 95118 + - 95119 + - 95120 + - 95121 + - 95122 + - 95123 + - 95124 + - 95125 + - 95126 + - 95127 + - 95128 + - 95129 + - 95130 + - 95131 + - 95132 + - 95133 + - 95134 + - 95135 + - 95136 + - 95137 + - 95138 + - 95139 + - 95140 + - 95141 + - 95142 + - 95143 + - 95144 + - 95145 + - 95146 + - 95147 + - 95148 + - 95149 + - 95150 + - 95151 + - 95152 + - 95153 + - 95154 + - 95155 + - 95156 + - 95157 + - 95158 + - 95159 + - 95160 + - 95161 + - 95162 + - 95163 + - 95164 + - 95165 + - 95166 + - 95167 + - 95168 + - 95169 + - 95170 + - 95171 + - 95172 + - 95173 + - 95174 + - 95175 + - 95176 + - 95177 + - 95178 + - 95179 + - 95180 + - 95181 + - 95182 + - 95183 + - 95184 + - 95185 + - 95186 + - 95187 + - 95188 + - 95189 + - 95190 + - 95191 + - 95192 + - 95193 + - 95194 + - 95195 + - 95196 + - 95197 + - 95198 + - 95199 + - 95200 + - 95201 + - 95202 + - 95203 + - 95204 + - 95205 + - 95206 + - 95207 + - 95208 + - 95209 + - 95210 + - 95211 + - 95212 + - 95213 + - 95214 + - 95215 + - 95216 + - 95217 + - 95218 + - 95219 + - 95220 + - 95221 + - 95222 + - 95223 + - 95224 + - 95225 + - 95226 + - 95227 + - 95228 + - 95229 + - 95230 + - 95231 + - 95232 + - 95233 + - 95234 + - 95235 + - 95236 + - 95237 + - 95238 + - 95239 + - 95240 + - 95241 + - 95242 + - 95243 + - 95244 + - 95245 + - 95246 + - 95247 + - 95248 + - 95249 + - 95250 + - 95251 + - 95252 + - 95253 + - 95254 + - 95255 + - 95256 + - 95257 + - 95258 + - 95259 + - 95260 + - 95261 + - 95262 + - 95263 + - 95264 + - 95265 + - 95266 + - 95267 + - 95268 + - 95269 + - 95270 + - 95271 + - 95272 + - 95273 + - 95274 + - 95275 + - 95276 + - 95277 + - 95278 + - 95279 + - 95280 + - 95281 + - 95282 + - 95283 + - 95284 + - 95285 + - 95286 + - 95287 + - 95288 + - 95289 + - 95290 + - 95291 + - 95292 + - 95293 + - 95294 + - 95295 + - 95296 + - 95297 + - 95298 + - 95299 + - 95300 + - 95301 + - 95302 + - 95303 + - 95304 + - 95305 + - 95306 + - 95307 + - 95308 + - 95309 + - 95310 + - 95311 + - 95312 + - 95313 + - 95314 + - 95315 + - 95316 + - 95317 + - 95318 + - 95319 + - 95320 + - 95321 + - 95322 + - 95323 + - 95324 + - 95325 + - 95326 + - 95327 + - 95328 + - 95329 + - 95330 + - 95331 + - 95332 + - 95333 + - 95334 + - 95335 + - 95336 + - 95337 + - 95338 + - 95339 + - 95340 + - 95341 + - 95342 + - 95343 + - 95344 + - 95345 + - 95346 + - 95347 + - 95348 + - 95349 + - 95350 + - 95351 + - 95352 + - 95353 + - 95354 + - 95355 + - 95356 + - 95357 + - 95358 + - 95359 + - 95360 + - 95361 + - 95362 + - 95363 + - 95364 + - 95365 + - 95366 + - 95367 + - 95368 + - 95369 + - 95370 + - 95371 + - 95372 + - 95373 + - 95374 + - 95375 + - 95376 + - 95377 + - 95378 + - 95379 + - 95380 + - 95381 + - 95382 + - 95383 + - 95384 + - 95385 + - 95386 + - 95387 + - 95388 + - 95389 + - 95390 + - 95391 + - 95392 + - 95393 + - 95394 + - 95395 + - 95396 + - 95397 + - 95398 + - 95399 + - 95400 + - 95401 + - 95402 + - 95403 + - 95404 + - 95405 + - 95406 + - 95407 + - 95408 + - 95409 + - 95410 + - 95411 + - 95412 + - 95413 + - 95414 + - 95415 + - 95416 + - 95417 + - 95418 + - 95419 + - 95420 + - 95421 + - 95422 + - 95423 + - 95424 + - 95425 + - 95426 + - 95427 + - 95428 + - 95429 + - 95430 + - 95431 + - 95432 + - 95433 + - 95434 + - 95435 + - 95436 + - 95437 + - 95438 + - 95439 + - 95440 + - 95441 + - 95442 + - 95443 + - 95444 + - 95445 + - 95446 + - 95447 + - 95448 + - 95449 + - 95450 + - 95451 + - 95452 + - 95453 + - 95454 + - 95455 + - 95456 + - 95457 + - 95458 + - 95459 + - 95460 + - 95461 + - 95462 + - 95463 + - 95464 + - 95465 + - 95466 + - 95467 + - 95468 + - 95469 + - 95470 + - 95471 + - 95472 + - 95473 + - 95474 + - 95475 + - 95476 + - 95477 + - 95478 + - 95479 + - 95480 + - 95481 + - 95482 + - 95483 + - 95484 + - 95485 + - 95486 + - 95487 + - 95488 + - 95489 + - 95490 + - 95491 + - 95492 + - 95493 + - 95494 + - 95495 + - 95496 + - 95497 + - 95498 + - 95499 + - 95500 + - 95501 + - 95502 + - 95503 + - 95504 + - 95505 + - 95506 + - 95507 + - 95508 + - 95509 + - 95510 + - 95511 + - 95512 + - 95513 + - 95514 + - 95515 + - 95516 + - 95517 + - 95518 + - 95519 + - 95520 + - 95521 + - 95522 + - 95523 + - 95524 + - 95525 + - 95526 + - 95527 + - 95528 + - 95529 + - 95530 + - 95531 + - 95532 + - 95533 + - 95534 + - 95535 + - 95536 + - 95537 + - 95538 + - 95539 + - 95540 + - 95541 + - 95542 + - 95543 + - 95544 + - 95545 + - 95546 + - 95547 + - 95548 + - 95549 + - 95550 + - 95551 + - 95552 + - 95553 + - 95554 + - 95555 + - 95556 + - 95557 + - 95558 + - 95559 + - 95560 + - 95561 + - 95562 + - 95563 + - 95564 + - 95565 + - 95566 + - 95567 + - 95568 + - 95569 + - 95570 + - 95571 + - 95572 + - 95573 + - 95574 + - 95575 + - 95576 + - 95577 + - 95578 + - 95579 + - 95580 + - 95581 + - 95582 + - 95583 + - 95584 + - 95585 + - 95586 + - 95587 + - 95588 + - 95589 + - 95590 + - 95591 + - 95592 + - 95593 + - 95594 + - 95595 + - 95596 + - 95597 + - 95598 + - 95599 + - 95600 + - 95601 + - 95602 + - 95603 + - 95604 + - 95605 + - 95606 + - 95607 + - 95608 + - 95609 + - 95610 + - 95611 + - 95612 + - 95613 + - 95614 + - 95615 + - 95616 + - 95617 + - 95618 + - 95619 + - 95620 + - 95621 + - 95622 + - 95623 + - 95624 + - 95625 + - 95626 + - 95627 + - 95628 + - 95629 + - 95630 + - 95631 + - 95632 + - 95633 + - 95634 + - 95635 + - 95636 + - 95637 + - 95638 + - 95639 + - 95640 + - 95641 + - 95642 + - 95643 + - 95644 + - 95645 + - 95646 + - 95647 + - 95648 + - 95649 + - 95650 + - 95651 + - 95652 + - 95653 + - 95654 + - 95655 + - 95656 + - 95657 + - 95658 + - 95659 + - 95660 + - 95661 + - 95662 + - 95663 + - 95664 + - 95665 + - 95666 + - 95667 + - 95668 + - 95669 + - 95670 + - 95671 + - 95672 + - 95673 + - 95674 + - 95675 + - 95676 + - 95677 + - 95678 + - 95679 + - 95680 + - 95681 + - 95682 + - 95683 + - 95684 + - 95685 + - 95686 + - 95687 + - 95688 + - 95689 + - 95690 + - 95691 + - 95692 + - 95693 + - 95694 + - 95695 + - 95696 + - 95697 + - 95698 + - 95699 + - 95700 + - 95701 + - 95702 + - 95703 + - 95704 + - 95705 + - 95706 + - 95707 + - 95708 + - 95709 + - 95710 + - 95711 + - 95712 + - 95713 + - 95714 + - 95715 + - 95716 + - 95717 + - 95718 + - 95719 + - 95720 + - 95721 + - 95722 + - 95723 + - 95724 + - 95725 + - 95726 + - 95727 + - 95728 + - 95729 + - 95730 + - 95731 + - 95732 + - 95733 + - 95734 + - 95735 + - 95736 + - 95737 + - 95738 + - 95739 + - 95740 + - 95741 + - 95742 + - 95743 + - 95744 + - 95745 + - 95746 + - 95747 + - 95748 + - 95749 + - 95750 + - 95751 + - 95752 + - 95753 + - 95754 + - 95755 + - 95756 + - 95757 + - 95758 + - 95759 + - 95760 + - 95761 + - 95762 + - 95763 + - 95764 + - 95765 + - 95766 + - 95767 + - 95768 + - 95769 + - 95770 + - 95771 + - 95772 + - 95773 + - 95774 + - 95775 + - 95776 + - 95777 + - 95778 + - 95779 + - 95780 + - 95781 + - 95782 + - 95783 + - 95784 + - 95785 + - 95786 + - 95787 + - 95788 + - 95789 + - 95790 + - 95791 + - 95792 + - 95793 + - 95794 + - 95795 + - 95796 + - 95797 + - 95798 + - 95799 + - 95800 + - 95801 + - 95802 + - 95803 + - 95804 + - 95805 + - 95806 + - 95807 + - 95808 + - 95809 + - 95810 + - 95811 + - 95812 + - 95813 + - 95814 + - 95815 + - 95816 + - 95817 + - 95818 + - 95819 + - 95820 + - 95821 + - 95822 + - 95823 + - 95824 + - 95825 + - 95826 + - 95827 + - 95828 + - 95829 + - 95830 + - 95831 + - 95832 + - 95833 + - 95834 + - 95835 + - 95836 + - 95837 + - 95838 + - 95839 + - 95840 + - 95841 + - 95842 + - 95843 + - 95844 + - 95845 + - 95846 + - 95847 + - 95848 + - 95849 + - 95850 + - 95851 + - 95852 + - 95853 + - 95854 + - 95855 + - 95856 + - 95857 + - 95858 + - 95859 + - 95860 + - 95861 + - 95862 + - 95863 + - 95864 + - 95865 + - 95866 + - 95867 + - 95868 + - 95869 + - 95870 + - 95871 + - 95872 + - 95873 + - 95874 + - 95875 + - 95876 + - 95877 + - 95878 + - 95879 + - 95880 + - 95881 + - 95882 + - 95883 + - 95884 + - 95885 + - 95886 + - 95887 + - 95888 + - 95889 + - 95890 + - 95891 + - 95892 + - 95893 + - 95894 + - 95895 + - 95896 + - 95897 + - 95898 + - 95899 + - 95900 + - 95901 + - 95902 + - 95903 + - 95904 + - 95905 + - 95906 + - 95907 + - 95908 + - 95909 + - 95910 + - 95911 + - 95912 + - 95913 + - 95914 + - 95915 + - 95916 + - 95917 + - 95918 + - 95919 + - 95920 + - 95921 + - 95922 + - 95923 + - 95924 + - 95925 + - 95926 + - 95927 + - 95928 + - 95929 + - 95930 + - 95931 + - 95932 + - 95933 + - 95934 + - 95935 + - 95936 + - 95937 + - 95938 + - 95939 + - 95940 + - 95941 + - 95942 + - 95943 + - 95944 + - 95945 + - 95946 + - 95947 + - 95948 + - 95949 + - 95950 + - 95951 + - 95952 + - 95953 + - 95954 + - 95955 + - 95956 + - 95957 + - 95958 + - 95959 + - 95960 + - 95961 + - 95962 + - 95963 + - 95964 + - 95965 + - 95966 + - 95967 + - 95968 + - 95969 + - 95970 + - 95971 + - 95972 + - 95973 + - 95974 + - 95975 + - 95976 + - 95977 + - 95978 + - 95979 + - 95980 + - 95981 + - 95982 + - 95983 + - 95984 + - 95985 + - 95986 + - 95987 + - 95988 + - 95989 + - 95990 + - 95991 + - 95992 + - 95993 + - 95994 + - 95995 + - 95996 + - 95997 + - 95998 + - 95999 + - 96000 + - 96001 + - 96002 + - 96003 + - 96004 + - 96005 + - 96006 + - 96007 + - 96008 + - 96009 + - 96010 + - 96011 + - 96012 + - 96013 + - 96014 + - 96015 + - 96016 + - 96017 + - 96018 + - 96019 + - 96020 + - 96021 + - 96022 + - 96023 + - 96024 + - 96025 + - 96026 + - 96027 + - 96028 + - 96029 + - 96030 + - 96031 + - 96032 + - 96033 + - 96034 + - 96035 + - 96036 + - 96037 + - 96038 + - 96039 + - 96040 + - 96041 + - 96042 + - 96043 + - 96044 + - 96045 + - 96046 + - 96047 + - 96048 + - 96049 + - 96050 + - 96051 + - 96052 + - 96053 + - 96054 + - 96055 + - 96056 + - 96057 + - 96058 + - 96059 + - 96060 + - 96061 + - 96062 + - 96063 + - 96064 + - 96065 + - 96066 + - 96067 + - 96068 + - 96069 + - 96070 + - 96071 + - 96072 + - 96073 + - 96074 + - 96075 + - 96076 + - 96077 + - 96078 + - 96079 + - 96080 + - 96081 + - 96082 + - 96083 + - 96084 + - 96085 + - 96086 + - 96087 + - 96088 + - 96089 + - 96090 + - 96091 + - 96092 + - 96093 + - 96094 + - 96095 + - 96096 + - 96097 + - 96098 + - 96099 + - 96100 + - 96101 + - 96102 + - 96103 + - 96104 + - 96105 + - 96106 + - 96107 + - 96108 + - 96109 + - 96110 + - 96111 + - 96112 + - 96113 + - 96114 + - 96115 + - 96116 + - 96117 + - 96118 + - 96119 + - 96120 + - 96121 + - 96122 + - 96123 + - 96124 + - 96125 + - 96126 + - 96127 + - 96128 + - 96129 + - 96130 + - 96131 + - 96132 + - 96133 + - 96134 + - 96135 + - 96136 + - 96137 + - 96138 + - 96139 + - 96140 + - 96141 + - 96142 + - 96143 + - 96144 + - 96145 + - 96146 + - 96147 + - 96148 + - 96149 + - 96150 + - 96151 + - 96152 + - 96153 + - 96154 + - 96155 + - 96156 + - 96157 + - 96158 + - 96159 + - 96160 + - 96161 + - 96162 + - 96163 + - 96164 + - 96165 + - 96166 + - 96167 + - 96168 + - 96169 + - 96170 + - 96171 + - 96172 + - 96173 + - 96174 + - 96175 + - 96176 + - 96177 + - 96178 + - 96179 + - 96180 + - 96181 + - 96182 + - 96183 + - 96184 + - 96185 + - 96186 + - 96187 + - 96188 + - 96189 + - 96190 + - 96191 + - 96192 + - 96193 + - 96194 + - 96195 + - 96196 + - 96197 + - 96198 + - 96199 + - 96200 + - 96201 + - 96202 + - 96203 + - 96204 + - 96205 + - 96206 + - 96207 + - 96208 + - 96209 + - 96210 + - 96211 + - 96212 + - 96213 + - 96214 + - 96215 + - 96216 + - 96217 + - 96218 + - 96219 + - 96220 + - 96221 + - 96222 + - 96223 + - 96224 + - 96225 + - 96226 + - 96227 + - 96228 + - 96229 + - 96230 + - 96231 + - 96232 + - 96233 + - 96234 + - 96235 + - 96236 + - 96237 + - 96238 + - 96239 + - 96240 + - 96241 + - 96242 + - 96243 + - 96244 + - 96245 + - 96246 + - 96247 + - 96248 + - 96249 + - 96250 + - 96251 + - 96252 + - 96253 + - 96254 + - 96255 + - 96256 + - 96257 + - 96258 + - 96259 + - 96260 + - 96261 + - 96262 + - 96263 + - 96264 + - 96265 + - 96266 + - 96267 + - 96268 + - 96269 + - 96270 + - 96271 + - 96272 + - 96273 + - 96274 + - 96275 + - 96276 + - 96277 + - 96278 + - 96279 + - 96280 + - 96281 + - 96282 + - 96283 + - 96284 + - 96285 + - 96286 + - 96287 + - 96288 + - 96289 + - 96290 + - 96291 + - 96292 + - 96293 + - 96294 + - 96295 + - 96296 + - 96297 + - 96298 + - 96299 + - 96300 + - 96301 + - 96302 + - 96303 + - 96304 + - 96305 + - 96306 + - 96307 + - 96308 + - 96309 + - 96310 + - 96311 + - 96312 + - 96313 + - 96314 + - 96315 + - 96316 + - 96317 + - 96318 + - 96319 + - 96320 + - 96321 + - 96322 + - 96323 + - 96324 + - 96325 + - 96326 + - 96327 + - 96328 + - 96329 + - 96330 + - 96331 + - 96332 + - 96333 + - 96334 + - 96335 + - 96336 + - 96337 + - 96338 + - 96339 + - 96340 + - 96341 + - 96342 + - 96343 + - 96344 + - 96345 + - 96346 + - 96347 + - 96348 + - 96349 + - 96350 + - 96351 + - 96352 + - 96353 + - 96354 + - 96355 + - 96356 + - 96357 + - 96358 + - 96359 + - 96360 + - 96361 + - 96362 + - 96363 + - 96364 + - 96365 + - 96366 + - 96367 + - 96368 + - 96369 + - 96370 + - 96371 + - 96372 + - 96373 + - 96374 + - 96375 + - 96376 + - 96377 + - 96378 + - 96379 + - 96380 + - 96381 + - 96382 + - 96383 + - 96384 + - 96385 + - 96386 + - 96387 + - 96388 + - 96389 + - 96390 + - 96391 + - 96392 + - 96393 + - 96394 + - 96395 + - 96396 + - 96397 + - 96398 + - 96399 + - 96400 + - 96401 + - 96402 + - 96403 + - 96404 + - 96405 + - 96406 + - 96407 + - 96408 + - 96409 + - 96410 + - 96411 + - 96412 + - 96413 + - 96414 + - 96415 + - 96416 + - 96417 + - 96418 + - 96419 + - 96420 + - 96421 + - 96422 + - 96423 + - 96424 + - 96425 + - 96426 + - 96427 + - 96428 + - 96429 + - 96430 + - 96431 + - 96432 + - 96433 + - 96434 + - 96435 + - 96436 + - 96437 + - 96438 + - 96439 + - 96440 + - 96441 + - 96442 + - 96443 + - 96444 + - 96445 + - 96446 + - 96447 + - 96448 + - 96449 + - 96450 + - 96451 + - 96452 + - 96453 + - 96454 + - 96455 + - 96456 + - 96457 + - 96458 + - 96459 + - 96460 + - 96461 + - 96462 + - 96463 + - 96464 + - 96465 + - 96466 + - 96467 + - 96468 + - 96469 + - 96470 + - 96471 + - 96472 + - 96473 + - 96474 + - 96475 + - 96476 + - 96477 + - 96478 + - 96479 + - 96480 + - 96481 + - 96482 + - 96483 + - 96484 + - 96485 + - 96486 + - 96487 + - 96488 + - 96489 + - 96490 + - 96491 + - 96492 + - 96493 + - 96494 + - 96495 + - 96496 + - 96497 + - 96498 + - 96499 + - 96500 + - 96501 + - 96502 + - 96503 + - 96504 + - 96505 + - 96506 + - 96507 + - 96508 + - 96509 + - 96510 + - 96511 + - 96512 + - 96513 + - 96514 + - 96515 + - 96516 + - 96517 + - 96518 + - 96519 + - 96520 + - 96521 + - 96522 + - 96523 + - 96524 + - 96525 + - 96526 + - 96527 + - 96528 + - 96529 + - 96530 + - 96531 + - 96532 + - 96533 + - 96534 + - 96535 + - 96536 + - 96537 + - 96538 + - 96539 + - 96540 + - 96541 + - 96542 + - 96543 + - 96544 + - 96545 + - 96546 + - 96547 + - 96548 + - 96549 + - 96550 + - 96551 + - 96552 + - 96553 + - 96554 + - 96555 + - 96556 + - 96557 + - 96558 + - 96559 + - 96560 + - 96561 + - 96562 + - 96563 + - 96564 + - 96565 + - 96566 + - 96567 + - 96568 + - 96569 + - 96570 + - 96571 + - 96572 + - 96573 + - 96574 + - 96575 + - 96576 + - 96577 + - 96578 + - 96579 + - 96580 + - 96581 + - 96582 + - 96583 + - 96584 + - 96585 + - 96586 + - 96587 + - 96588 + - 96589 + - 96590 + - 96591 + - 96592 + - 96593 + - 96594 + - 96595 + - 96596 + - 96597 + - 96598 + - 96599 + - 96600 + - 96601 + - 96602 + - 96603 + - 96604 + - 96605 + - 96606 + - 96607 + - 96608 + - 96609 + - 96610 + - 96611 + - 96612 + - 96613 + - 96614 + - 96615 + - 96616 + - 96617 + - 96618 + - 96619 + - 96620 + - 96621 + - 96622 + - 96623 + - 96624 + - 96625 + - 96626 + - 96627 + - 96628 + - 96629 + - 96630 + - 96631 + - 96632 + - 96633 + - 96634 + - 96635 + - 96636 + - 96637 + - 96638 + - 96639 + - 96640 + - 96641 + - 96642 + - 96643 + - 96644 + - 96645 + - 96646 + - 96647 + - 96648 + - 96649 + - 96650 + - 96651 + - 96652 + - 96653 + - 96654 + - 96655 + - 96656 + - 96657 + - 96658 + - 96659 + - 96660 + - 96661 + - 96662 + - 96663 + - 96664 + - 96665 + - 96666 + - 96667 + - 96668 + - 96669 + - 96670 + - 96671 + - 96672 + - 96673 + - 96674 + - 96675 + - 96676 + - 96677 + - 96678 + - 96679 + - 96680 + - 96681 + - 96682 + - 96683 + - 96684 + - 96685 + - 96686 + - 96687 + - 96688 + - 96689 + - 96690 + - 96691 + - 96692 + - 96693 + - 96694 + - 96695 + - 96696 + - 96697 + - 96698 + - 96699 + - 96700 + - 96701 + - 96702 + - 96703 + - 96704 + - 96705 + - 96706 + - 96707 + - 96708 + - 96709 + - 96710 + - 96711 + - 96712 + - 96713 + - 96714 + - 96715 + - 96716 + - 96717 + - 96718 + - 96719 + - 96720 + - 96721 + - 96722 + - 96723 + - 96724 + - 96725 + - 96726 + - 96727 + - 96728 + - 96729 + - 96730 + - 96731 + - 96732 + - 96733 + - 96734 + - 96735 + - 96736 + - 96737 + - 96738 + - 96739 + - 96740 + - 96741 + - 96742 + - 96743 + - 96744 + - 96745 + - 96746 + - 96747 + - 96748 + - 96749 + - 96750 + - 96751 + - 96752 + - 96753 + - 96754 + - 96755 + - 96756 + - 96757 + - 96758 + - 96759 + - 96760 + - 96761 + - 96762 + - 96763 + - 96764 + - 96765 + - 96766 + - 96767 + - 96768 + - 96769 + - 96770 + - 96771 + - 96772 + - 96773 + - 96774 + - 96775 + - 96776 + - 96777 + - 96778 + - 96779 + - 96780 + - 96781 + - 96782 + - 96783 + - 96784 + - 96785 + - 96786 + - 96787 + - 96788 + - 96789 + - 96790 + - 96791 + - 96792 + - 96793 + - 96794 + - 96795 + - 96796 + - 96797 + - 96798 + - 96799 + - 96800 + - 96801 + - 96802 + - 96803 + - 96804 + - 96805 + - 96806 + - 96807 + - 96808 + - 96809 + - 96810 + - 96811 + - 96812 + - 96813 + - 96814 + - 96815 + - 96816 + - 96817 + - 96818 + - 96819 + - 96820 + - 96821 + - 96822 + - 96823 + - 96824 + - 96825 + - 96826 + - 96827 + - 96828 + - 96829 + - 96830 + - 96831 + - 96832 + - 96833 + - 96834 + - 96835 + - 96836 + - 96837 + - 96838 + - 96839 + - 96840 + - 96841 + - 96842 + - 96843 + - 96844 + - 96845 + - 96846 + - 96847 + - 96848 + - 96849 + - 96850 + - 96851 + - 96852 + - 96853 + - 96854 + - 96855 + - 96856 + - 96857 + - 96858 + - 96859 + - 96860 + - 96861 + - 96862 + - 96863 + - 96864 + - 96865 + - 96866 + - 96867 + - 96868 + - 96869 + - 96870 + - 96871 + - 96872 + - 96873 + - 96874 + - 96875 + - 96876 + - 96877 + - 96878 + - 96879 + - 96880 + - 96881 + - 96882 + - 96883 + - 96884 + - 96885 + - 96886 + - 96887 + - 96888 + - 96889 + - 96890 + - 96891 + - 96892 + - 96893 + - 96894 + - 96895 + - 96896 + - 96897 + - 96898 + - 96899 + - 96900 + - 96901 + - 96902 + - 96903 + - 96904 + - 96905 + - 96906 + - 96907 + - 96908 + - 96909 + - 96910 + - 96911 + - 96912 + - 96913 + - 96914 + - 96915 + - 96916 + - 96917 + - 96918 + - 96919 + - 96920 + - 96921 + - 96922 + - 96923 + - 96924 + - 96925 + - 96926 + - 96927 + - 96928 + - 96929 + - 96930 + - 96931 + - 96932 + - 96933 + - 96934 + - 96935 + - 96936 + - 96937 + - 96938 + - 96939 + - 96940 + - 96941 + - 96942 + - 96943 + - 96944 + - 96945 + - 96946 + - 96947 + - 96948 + - 96949 + - 96950 + - 96951 + - 96952 + - 96953 + - 96954 + - 96955 + - 96956 + - 96957 + - 96958 + - 96959 + - 96960 + - 96961 + - 96962 + - 96963 + - 96964 + - 96965 + - 96966 + - 96967 + - 96968 + - 96969 + - 96970 + - 96971 + - 96972 + - 96973 + - 96974 + - 96975 + - 96976 + - 96977 + - 96978 + - 96979 + - 96980 + - 96981 + - 96982 + - 96983 + - 96984 + - 96985 + - 96986 + - 96987 + - 96988 + - 96989 + - 96990 + - 96991 + - 96992 + - 96993 + - 96994 + - 96995 + - 96996 + - 96997 + - 96998 + - 96999 + - 97000 + - 97001 + - 97002 + - 97003 + - 97004 + - 97005 + - 97006 + - 97007 + - 97008 + - 97009 + - 97010 + - 97011 + - 97012 + - 97013 + - 97014 + - 97015 + - 97016 + - 97017 + - 97018 + - 97019 + - 97020 + - 97021 + - 97022 + - 97023 + - 97024 + - 97025 + - 97026 + - 97027 + - 97028 + - 97029 + - 97030 + - 97031 + - 97032 + - 97033 + - 97034 + - 97035 + - 97036 + - 97037 + - 97038 + - 97039 + - 97040 + - 97041 + - 97042 + - 97043 + - 97044 + - 97045 + - 97046 + - 97047 + - 97048 + - 97049 + - 97050 + - 97051 + - 97052 + - 97053 + - 97054 + - 97055 + - 97056 + - 97057 + - 97058 + - 97059 + - 97060 + - 97061 + - 97062 + - 97063 + - 97064 + - 97065 + - 97066 + - 97067 + - 97068 + - 97069 + - 97070 + - 97071 + - 97072 + - 97073 + - 97074 + - 97075 + - 97076 + - 97077 + - 97078 + - 97079 + - 97080 + - 97081 + - 97082 + - 97083 + - 97084 + - 97085 + - 97086 + - 97087 + - 97088 + - 97089 + - 97090 + - 97091 + - 97092 + - 97093 + - 97094 + - 97095 + - 97096 + - 97097 + - 97098 + - 97099 + - 97100 + - 97101 + - 97102 + - 97103 + - 97104 + - 97105 + - 97106 + - 97107 + - 97108 + - 97109 + - 97110 + - 97111 + - 97112 + - 97113 + - 97114 + - 97115 + - 97116 + - 97117 + - 97118 + - 97119 + - 97120 + - 97121 + - 97122 + - 97123 + - 97124 + - 97125 + - 97126 + - 97127 + - 97128 + - 97129 + - 97130 + - 97131 + - 97132 + - 97133 + - 97134 + - 97135 + - 97136 + - 97137 + - 97138 + - 97139 + - 97140 + - 97141 + - 97142 + - 97143 + - 97144 + - 97145 + - 97146 + - 97147 + - 97148 + - 97149 + - 97150 + - 97151 + - 97152 + - 97153 + - 97154 + - 97155 + - 97156 + - 97157 + - 97158 + - 97159 + - 97160 + - 97161 + - 97162 + - 97163 + - 97164 + - 97165 + - 97166 + - 97167 + - 97168 + - 97169 + - 97170 + - 97171 + - 97172 + - 97173 + - 97174 + - 97175 + - 97176 + - 97177 + - 97178 + - 97179 + - 97180 + - 97181 + - 97182 + - 97183 + - 97184 + - 97185 + - 97186 + - 97187 + - 97188 + - 97189 + - 97190 + - 97191 + - 97192 + - 97193 + - 97194 + - 97195 + - 97196 + - 97197 + - 97198 + - 97199 + - 97200 + - 97201 + - 97202 + - 97203 + - 97204 + - 97205 + - 97206 + - 97207 + - 97208 + - 97209 + - 97210 + - 97211 + - 97212 + - 97213 + - 97214 + - 97215 + - 97216 + - 97217 + - 97218 + - 97219 + - 97220 + - 97221 + - 97222 + - 97223 + - 97224 + - 97225 + - 97226 + - 97227 + - 97228 + - 97229 + - 97230 + - 97231 + - 97232 + - 97233 + - 97234 + - 97235 + - 97236 + - 97237 + - 97238 + - 97239 + - 97240 + - 97241 + - 97242 + - 97243 + - 97244 + - 97245 + - 97246 + - 97247 + - 97248 + - 97249 + - 97250 + - 97251 + - 97252 + - 97253 + - 97254 + - 97255 + - 97256 + - 97257 + - 97258 + - 97259 + - 97260 + - 97261 + - 97262 + - 97263 + - 97264 + - 97265 + - 97266 + - 97267 + - 97268 + - 97269 + - 97270 + - 97271 + - 97272 + - 97273 + - 97274 + - 97275 + - 97276 + - 97277 + - 97278 + - 97279 + - 97280 + - 97281 + - 97282 + - 97283 + - 97284 + - 97285 + - 97286 + - 97287 + - 97288 + - 97289 + - 97290 + - 97291 + - 97292 + - 97293 + - 97294 + - 97295 + - 97296 + - 97297 + - 97298 + - 97299 + - 97300 + - 97301 + - 97302 + - 97303 + - 97304 + - 97305 + - 97306 + - 97307 + - 97308 + - 97309 + - 97310 + - 97311 + - 97312 + - 97313 + - 97314 + - 97315 + - 97316 + - 97317 + - 97318 + - 97319 + - 97320 + - 97321 + - 97322 + - 97323 + - 97324 + - 97325 + - 97326 + - 97327 + - 97328 + - 97329 + - 97330 + - 97331 + - 97332 + - 97333 + - 97334 + - 97335 + - 97336 + - 97337 + - 97338 + - 97339 + - 97340 + - 97341 + - 97342 + - 97343 + - 97344 + - 97345 + - 97346 + - 97347 + - 97348 + - 97349 + - 97350 + - 97351 + - 97352 + - 97353 + - 97354 + - 97355 + - 97356 + - 97357 + - 97358 + - 97359 + - 97360 + - 97361 + - 97362 + - 97363 + - 97364 + - 97365 + - 97366 + - 97367 + - 97368 + - 97369 + - 97370 + - 97371 + - 97372 + - 97373 + - 97374 + - 97375 + - 97376 + - 97377 + - 97378 + - 97379 + - 97380 + - 97381 + - 97382 + - 97383 + - 97384 + - 97385 + - 97386 + - 97387 + - 97388 + - 97389 + - 97390 + - 97391 + - 97392 + - 97393 + - 97394 + - 97395 + - 97396 + - 97397 + - 97398 + - 97399 + - 97400 + - 97401 + - 97402 + - 97403 + - 97404 + - 97405 + - 97406 + - 97407 + - 97408 + - 97409 + - 97410 + - 97411 + - 97412 + - 97413 + - 97414 + - 97415 + - 97416 + - 97417 + - 97418 + - 97419 + - 97420 + - 97421 + - 97422 + - 97423 + - 97424 + - 97425 + - 97426 + - 97427 + - 97428 + - 97429 + - 97430 + - 97431 + - 97432 + - 97433 + - 97434 + - 97435 + - 97436 + - 97437 + - 97438 + - 97439 + - 97440 + - 97441 + - 97442 + - 97443 + - 97444 + - 97445 + - 97446 + - 97447 + - 97448 + - 97449 + - 97450 + - 97451 + - 97452 + - 97453 + - 97454 + - 97455 + - 97456 + - 97457 + - 97458 + - 97459 + - 97460 + - 97461 + - 97462 + - 97463 + - 97464 + - 97465 + - 97466 + - 97467 + - 97468 + - 97469 + - 97470 + - 97471 + - 97472 + - 97473 + - 97474 + - 97475 + - 97476 + - 97477 + - 97478 + - 97479 + - 97480 + - 97481 + - 97482 + - 97483 + - 97484 + - 97485 + - 97486 + - 97487 + - 97488 + - 97489 + - 97490 + - 97491 + - 97492 + - 97493 + - 97494 + - 97495 + - 97496 + - 97497 + - 97498 + - 97499 + - 97500 + - 97501 + - 97502 + - 97503 + - 97504 + - 97505 + - 97506 + - 97507 + - 97508 + - 97509 + - 97510 + - 97511 + - 97512 + - 97513 + - 97514 + - 97515 + - 97516 + - 97517 + - 97518 + - 97519 + - 97520 + - 97521 + - 97522 + - 97523 + - 97524 + - 97525 + - 97526 + - 97527 + - 97528 + - 97529 + - 97530 + - 97531 + - 97532 + - 97533 + - 97534 + - 97535 + - 97536 + - 97537 + - 97538 + - 97539 + - 97540 + - 97541 + - 97542 + - 97543 + - 97544 + - 97545 + - 97546 + - 97547 + - 97548 + - 97549 + - 97550 + - 97551 + - 97552 + - 97553 + - 97554 + - 97555 + - 97556 + - 97557 + - 97558 + - 97559 + - 97560 + - 97561 + - 97562 + - 97563 + - 97564 + - 97565 + - 97566 + - 97567 + - 97568 + - 97569 + - 97570 + - 97571 + - 97572 + - 97573 + - 97574 + - 97575 + - 97576 + - 97577 + - 97578 + - 97579 + - 97580 + - 97581 + - 97582 + - 97583 + - 97584 + - 97585 + - 97586 + - 97587 + - 97588 + - 97589 + - 97590 + - 97591 + - 97592 + - 97593 + - 97594 + - 97595 + - 97596 + - 97597 + - 97598 + - 97599 + - 97600 + - 97601 + - 97602 + - 97603 + - 97604 + - 97605 + - 97606 + - 97607 + - 97608 + - 97609 + - 97610 + - 97611 + - 97612 + - 97613 + - 97614 + - 97615 + - 97616 + - 97617 + - 97618 + - 97619 + - 97620 + - 97621 + - 97622 + - 97623 + - 97624 + - 97625 + - 97626 + - 97627 + - 97628 + - 97629 + - 97630 + - 97631 + - 97632 + - 97633 + - 97634 + - 97635 + - 97636 + - 97637 + - 97638 + - 97639 + - 97640 + - 97641 + - 97642 + - 97643 + - 97644 + - 97645 + - 97646 + - 97647 + - 97648 + - 97649 + - 97650 + - 97651 + - 97652 + - 97653 + - 97654 + - 97655 + - 97656 + - 97657 + - 97658 + - 97659 + - 97660 + - 97661 + - 97662 + - 97663 + - 97664 + - 97665 + - 97666 + - 97667 + - 97668 + - 97669 + - 97670 + - 97671 + - 97672 + - 97673 + - 97674 + - 97675 + - 97676 + - 97677 + - 97678 + - 97679 + - 97680 + - 97681 + - 97682 + - 97683 + - 97684 + - 97685 + - 97686 + - 97687 + - 97688 + - 97689 + - 97690 + - 97691 + - 97692 + - 97693 + - 97694 + - 97695 + - 97696 + - 97697 + - 97698 + - 97699 + - 97700 + - 97701 + - 97702 + - 97703 + - 97704 + - 97705 + - 97706 + - 97707 + - 97708 + - 97709 + - 97710 + - 97711 + - 97712 + - 97713 + - 97714 + - 97715 + - 97716 + - 97717 + - 97718 + - 97719 + - 97720 + - 97721 + - 97722 + - 97723 + - 97724 + - 97725 + - 97726 + - 97727 + - 97728 + - 97729 + - 97730 + - 97731 + - 97732 + - 97733 + - 97734 + - 97735 + - 97736 + - 97737 + - 97738 + - 97739 + - 97740 + - 97741 + - 97742 + - 97743 + - 97744 + - 97745 + - 97746 + - 97747 + - 97748 + - 97749 + - 97750 + - 97751 + - 97752 + - 97753 + - 97754 + - 97755 + - 97756 + - 97757 + - 97758 + - 97759 + - 97760 + - 97761 + - 97762 + - 97763 + - 97764 + - 97765 + - 97766 + - 97767 + - 97768 + - 97769 + - 97770 + - 97771 + - 97772 + - 97773 + - 97774 + - 97775 + - 97776 + - 97777 + - 97778 + - 97779 + - 97780 + - 97781 + - 97782 + - 97783 + - 97784 + - 97785 + - 97786 + - 97787 + - 97788 + - 97789 + - 97790 + - 97791 + - 97792 + - 97793 + - 97794 + - 97795 + - 97796 + - 97797 + - 97798 + - 97799 + - 97800 + - 97801 + - 97802 + - 97803 + - 97804 + - 97805 + - 97806 + - 97807 + - 97808 + - 97809 + - 97810 + - 97811 + - 97812 + - 97813 + - 97814 + - 97815 + - 97816 + - 97817 + - 97818 + - 97819 + - 97820 + - 97821 + - 97822 + - 97823 + - 97824 + - 97825 + - 97826 + - 97827 + - 97828 + - 97829 + - 97830 + - 97831 + - 97832 + - 97833 + - 97834 + - 97835 + - 97836 + - 97837 + - 97838 + - 97839 + - 97840 + - 97841 + - 97842 + - 97843 + - 97844 + - 97845 + - 97846 + - 97847 + - 97848 + - 97849 + - 97850 + - 97851 + - 97852 + - 97853 + - 97854 + - 97855 + - 97856 + - 97857 + - 97858 + - 97859 + - 97860 + - 97861 + - 97862 + - 97863 + - 97864 + - 97865 + - 97866 + - 97867 + - 97868 + - 97869 + - 97870 + - 97871 + - 97872 + - 97873 + - 97874 + - 97875 + - 97876 + - 97877 + - 97878 + - 97879 + - 97880 + - 97881 + - 97882 + - 97883 + - 97884 + - 97885 + - 97886 + - 97887 + - 97888 + - 97889 + - 97890 + - 97891 + - 97892 + - 97893 + - 97894 + - 97895 + - 97896 + - 97897 + - 97898 + - 97899 + - 97900 + - 97901 + - 97902 + - 97903 + - 97904 + - 97905 + - 97906 + - 97907 + - 97908 + - 97909 + - 97910 + - 97911 + - 97912 + - 97913 + - 97914 + - 97915 + - 97916 + - 97917 + - 97918 + - 97919 + - 97920 + - 97921 + - 97922 + - 97923 + - 97924 + - 97925 + - 97926 + - 97927 + - 97928 + - 97929 + - 97930 + - 97931 + - 97932 + - 97933 + - 97934 + - 97935 + - 97936 + - 97937 + - 97938 + - 97939 + - 97940 + - 97941 + - 97942 + - 97943 + - 97944 + - 97945 + - 97946 + - 97947 + - 97948 + - 97949 + - 97950 + - 97951 + - 97952 + - 97953 + - 97954 + - 97955 + - 97956 + - 97957 + - 97958 + - 97959 + - 97960 + - 97961 + - 97962 + - 97963 + - 97964 + - 97965 + - 97966 + - 97967 + - 97968 + - 97969 + - 97970 + - 97971 + - 97972 + - 97973 + - 97974 + - 97975 + - 97976 + - 97977 + - 97978 + - 97979 + - 97980 + - 97981 + - 97982 + - 97983 + - 97984 + - 97985 + - 97986 + - 97987 + - 97988 + - 97989 + - 97990 + - 97991 + - 97992 + - 97993 + - 97994 + - 97995 + - 97996 + - 97997 + - 97998 + - 97999 + - 98000 + - 98001 + - 98002 + - 98003 + - 98004 + - 98005 + - 98006 + - 98007 + - 98008 + - 98009 + - 98010 + - 98011 + - 98012 + - 98013 + - 98014 + - 98015 + - 98016 + - 98017 + - 98018 + - 98019 + - 98020 + - 98021 + - 98022 + - 98023 + - 98024 + - 98025 + - 98026 + - 98027 + - 98028 + - 98029 + - 98030 + - 98031 + - 98032 + - 98033 + - 98034 + - 98035 + - 98036 + - 98037 + - 98038 + - 98039 + - 98040 + - 98041 + - 98042 + - 98043 + - 98044 + - 98045 + - 98046 + - 98047 + - 98048 + - 98049 + - 98050 + - 98051 + - 98052 + - 98053 + - 98054 + - 98055 + - 98056 + - 98057 + - 98058 + - 98059 + - 98060 + - 98061 + - 98062 + - 98063 + - 98064 + - 98065 + - 98066 + - 98067 + - 98068 + - 98069 + - 98070 + - 98071 + - 98072 + - 98073 + - 98074 + - 98075 + - 98076 + - 98077 + - 98078 + - 98079 + - 98080 + - 98081 + - 98082 + - 98083 + - 98084 + - 98085 + - 98086 + - 98087 + - 98088 + - 98089 + - 98090 + - 98091 + - 98092 + - 98093 + - 98094 + - 98095 + - 98096 + - 98097 + - 98098 + - 98099 + - 98100 + - 98101 + - 98102 + - 98103 + - 98104 + - 98105 + - 98106 + - 98107 + - 98108 + - 98109 + - 98110 + - 98111 + - 98112 + - 98113 + - 98114 + - 98115 + - 98116 + - 98117 + - 98118 + - 98119 + - 98120 + - 98121 + - 98122 + - 98123 + - 98124 + - 98125 + - 98126 + - 98127 + - 98128 + - 98129 + - 98130 + - 98131 + - 98132 + - 98133 + - 98134 + - 98135 + - 98136 + - 98137 + - 98138 + - 98139 + - 98140 + - 98141 + - 98142 + - 98143 + - 98144 + - 98145 + - 98146 + - 98147 + - 98148 + - 98149 + - 98150 + - 98151 + - 98152 + - 98153 + - 98154 + - 98155 + - 98156 + - 98157 + - 98158 + - 98159 + - 98160 + - 98161 + - 98162 + - 98163 + - 98164 + - 98165 + - 98166 + - 98167 + - 98168 + - 98169 + - 98170 + - 98171 + - 98172 + - 98173 + - 98174 + - 98175 + - 98176 + - 98177 + - 98178 + - 98179 + - 98180 + - 98181 + - 98182 + - 98183 + - 98184 + - 98185 + - 98186 + - 98187 + - 98188 + - 98189 + - 98190 + - 98191 + - 98192 + - 98193 + - 98194 + - 98195 + - 98196 + - 98197 + - 98198 + - 98199 + - 98200 + - 98201 + - 98202 + - 98203 + - 98204 + - 98205 + - 98206 + - 98207 + - 98208 + - 98209 + - 98210 + - 98211 + - 98212 + - 98213 + - 98214 + - 98215 + - 98216 + - 98217 + - 98218 + - 98219 + - 98220 + - 98221 + - 98222 + - 98223 + - 98224 + - 98225 + - 98226 + - 98227 + - 98228 + - 98229 + - 98230 + - 98231 + - 98232 + - 98233 + - 98234 + - 98235 + - 98236 + - 98237 + - 98238 + - 98239 + - 98240 + - 98241 + - 98242 + - 98243 + - 98244 + - 98245 + - 98246 + - 98247 + - 98248 + - 98249 + - 98250 + - 98251 + - 98252 + - 98253 + - 98254 + - 98255 + - 98256 + - 98257 + - 98258 + - 98259 + - 98260 + - 98261 + - 98262 + - 98263 + - 98264 + - 98265 + - 98266 + - 98267 + - 98268 + - 98269 + - 98270 + - 98271 + - 98272 + - 98273 + - 98274 + - 98275 + - 98276 + - 98277 + - 98278 + - 98279 + - 98280 + - 98281 + - 98282 + - 98283 + - 98284 + - 98285 + - 98286 + - 98287 + - 98288 + - 98289 + - 98290 + - 98291 + - 98292 + - 98293 + - 98294 + - 98295 + - 98296 + - 98297 + - 98298 + - 98299 + - 98300 + - 98301 + - 98302 + - 98303 + - 98304 + - 98305 + - 98306 + - 98307 + - 98308 + - 98309 + - 98310 + - 98311 + - 98312 + - 98313 + - 98314 + - 98315 + - 98316 + - 98317 + - 98318 + - 98319 + - 98320 + - 98321 + - 98322 + - 98323 + - 98324 + - 98325 + - 98326 + - 98327 + - 98328 + - 98329 + - 98330 + - 98331 + - 98332 + - 98333 + - 98334 + - 98335 + - 98336 + - 98337 + - 98338 + - 98339 + - 98340 + - 98341 + - 98342 + - 98343 + - 98344 + - 98345 + - 98346 + - 98347 + - 98348 + - 98349 + - 98350 + - 98351 + - 98352 + - 98353 + - 98354 + - 98355 + - 98356 + - 98357 + - 98358 + - 98359 + - 98360 + - 98361 + - 98362 + - 98363 + - 98364 + - 98365 + - 98366 + - 98367 + - 98368 + - 98369 + - 98370 + - 98371 + - 98372 + - 98373 + - 98374 + - 98375 + - 98376 + - 98377 + - 98378 + - 98379 + - 98380 + - 98381 + - 98382 + - 98383 + - 98384 + - 98385 + - 98386 + - 98387 + - 98388 + - 98389 + - 98390 + - 98391 + - 98392 + - 98393 + - 98394 + - 98395 + - 98396 + - 98397 + - 98398 + - 98399 + - 98400 + - 98401 + - 98402 + - 98403 + - 98404 + - 98405 + - 98406 + - 98407 + - 98408 + - 98409 + - 98410 + - 98411 + - 98412 + - 98413 + - 98414 + - 98415 + - 98416 + - 98417 + - 98418 + - 98419 + - 98420 + - 98421 + - 98422 + - 98423 + - 98424 + - 98425 + - 98426 + - 98427 + - 98428 + - 98429 + - 98430 + - 98431 + - 98432 + - 98433 + - 98434 + - 98435 + - 98436 + - 98437 + - 98438 + - 98439 + - 98440 + - 98441 + - 98442 + - 98443 + - 98444 + - 98445 + - 98446 + - 98447 + - 98448 + - 98449 + - 98450 + - 98451 + - 98452 + - 98453 + - 98454 + - 98455 + - 98456 + - 98457 + - 98458 + - 98459 + - 98460 + - 98461 + - 98462 + - 98463 + - 98464 + - 98465 + - 98466 + - 98467 + - 98468 + - 98469 + - 98470 + - 98471 + - 98472 + - 98473 + - 98474 + - 98475 + - 98476 + - 98477 + - 98478 + - 98479 + - 98480 + - 98481 + - 98482 + - 98483 + - 98484 + - 98485 + - 98486 + - 98487 + - 98488 + - 98489 + - 98490 + - 98491 + - 98492 + - 98493 + - 98494 + - 98495 + - 98496 + - 98497 + - 98498 + - 98499 + - 98500 + - 98501 + - 98502 + - 98503 + - 98504 + - 98505 + - 98506 + - 98507 + - 98508 + - 98509 + - 98510 + - 98511 + - 98512 + - 98513 + - 98514 + - 98515 + - 98516 + - 98517 + - 98518 + - 98519 + - 98520 + - 98521 + - 98522 + - 98523 + - 98524 + - 98525 + - 98526 + - 98527 + - 98528 + - 98529 + - 98530 + - 98531 + - 98532 + - 98533 + - 98534 + - 98535 + - 98536 + - 98537 + - 98538 + - 98539 + - 98540 + - 98541 + - 98542 + - 98543 + - 98544 + - 98545 + - 98546 + - 98547 + - 98548 + - 98549 + - 98550 + - 98551 + - 98552 + - 98553 + - 98554 + - 98555 + - 98556 + - 98557 + - 98558 + - 98559 + - 98560 + - 98561 + - 98562 + - 98563 + - 98564 + - 98565 + - 98566 + - 98567 + - 98568 + - 98569 + - 98570 + - 98571 + - 98572 + - 98573 + - 98574 + - 98575 + - 98576 + - 98577 + - 98578 + - 98579 + - 98580 + - 98581 + - 98582 + - 98583 + - 98584 + - 98585 + - 98586 + - 98587 + - 98588 + - 98589 + - 98590 + - 98591 + - 98592 + - 98593 + - 98594 + - 98595 + - 98596 + - 98597 + - 98598 + - 98599 + - 98600 + - 98601 + - 98602 + - 98603 + - 98604 + - 98605 + - 98606 + - 98607 + - 98608 + - 98609 + - 98610 + - 98611 + - 98612 + - 98613 + - 98614 + - 98615 + - 98616 + - 98617 + - 98618 + - 98619 + - 98620 + - 98621 + - 98622 + - 98623 + - 98624 + - 98625 + - 98626 + - 98627 + - 98628 + - 98629 + - 98630 + - 98631 + - 98632 + - 98633 + - 98634 + - 98635 + - 98636 + - 98637 + - 98638 + - 98639 + - 98640 + - 98641 + - 98642 + - 98643 + - 98644 + - 98645 + - 98646 + - 98647 + - 98648 + - 98649 + - 98650 + - 98651 + - 98652 + - 98653 + - 98654 + - 98655 + - 98656 + - 98657 + - 98658 + - 98659 + - 98660 + - 98661 + - 98662 + - 98663 + - 98664 + - 98665 + - 98666 + - 98667 + - 98668 + - 98669 + - 98670 + - 98671 + - 98672 + - 98673 + - 98674 + - 98675 + - 98676 + - 98677 + - 98678 + - 98679 + - 98680 + - 98681 + - 98682 + - 98683 + - 98684 + - 98685 + - 98686 + - 98687 + - 98688 + - 98689 + - 98690 + - 98691 + - 98692 + - 98693 + - 98694 + - 98695 + - 98696 + - 98697 + - 98698 + - 98699 + - 98700 + - 98701 + - 98702 + - 98703 + - 98704 + - 98705 + - 98706 + - 98707 + - 98708 + - 98709 + - 98710 + - 98711 + - 98712 + - 98713 + - 98714 + - 98715 + - 98716 + - 98717 + - 98718 + - 98719 + - 98720 + - 98721 + - 98722 + - 98723 + - 98724 + - 98725 + - 98726 + - 98727 + - 98728 + - 98729 + - 98730 + - 98731 + - 98732 + - 98733 + - 98734 + - 98735 + - 98736 + - 98737 + - 98738 + - 98739 + - 98740 + - 98741 + - 98742 + - 98743 + - 98744 + - 98745 + - 98746 + - 98747 + - 98748 + - 98749 + - 98750 + - 98751 + - 98752 + - 98753 + - 98754 + - 98755 + - 98756 + - 98757 + - 98758 + - 98759 + - 98760 + - 98761 + - 98762 + - 98763 + - 98764 + - 98765 + - 98766 + - 98767 + - 98768 + - 98769 + - 98770 + - 98771 + - 98772 + - 98773 + - 98774 + - 98775 + - 98776 + - 98777 + - 98778 + - 98779 + - 98780 + - 98781 + - 98782 + - 98783 + - 98784 + - 98785 + - 98786 + - 98787 + - 98788 + - 98789 + - 98790 + - 98791 + - 98792 + - 98793 + - 98794 + - 98795 + - 98796 + - 98797 + - 98798 + - 98799 + - 98800 + - 98801 + - 98802 + - 98803 + - 98804 + - 98805 + - 98806 + - 98807 + - 98808 + - 98809 + - 98810 + - 98811 + - 98812 + - 98813 + - 98814 + - 98815 + - 98816 + - 98817 + - 98818 + - 98819 + - 98820 + - 98821 + - 98822 + - 98823 + - 98824 + - 98825 + - 98826 + - 98827 + - 98828 + - 98829 + - 98830 + - 98831 + - 98832 + - 98833 + - 98834 + - 98835 + - 98836 + - 98837 + - 98838 + - 98839 + - 98840 + - 98841 + - 98842 + - 98843 + - 98844 + - 98845 + - 98846 + - 98847 + - 98848 + - 98849 + - 98850 + - 98851 + - 98852 + - 98853 + - 98854 + - 98855 + - 98856 + - 98857 + - 98858 + - 98859 + - 98860 + - 98861 + - 98862 + - 98863 + - 98864 + - 98865 + - 98866 + - 98867 + - 98868 + - 98869 + - 98870 + - 98871 + - 98872 + - 98873 + - 98874 + - 98875 + - 98876 + - 98877 + - 98878 + - 98879 + - 98880 + - 98881 + - 98882 + - 98883 + - 98884 + - 98885 + - 98886 + - 98887 + - 98888 + - 98889 + - 98890 + - 98891 + - 98892 + - 98893 + - 98894 + - 98895 + - 98896 + - 98897 + - 98898 + - 98899 + - 98900 + - 98901 + - 98902 + - 98903 + - 98904 + - 98905 + - 98906 + - 98907 + - 98908 + - 98909 + - 98910 + - 98911 + - 98912 + - 98913 + - 98914 + - 98915 + - 98916 + - 98917 + - 98918 + - 98919 + - 98920 + - 98921 + - 98922 + - 98923 + - 98924 + - 98925 + - 98926 + - 98927 + - 98928 + - 98929 + - 98930 + - 98931 + - 98932 + - 98933 + - 98934 + - 98935 + - 98936 + - 98937 + - 98938 + - 98939 + - 98940 + - 98941 + - 98942 + - 98943 + - 98944 + - 98945 + - 98946 + - 98947 + - 98948 + - 98949 + - 98950 + - 98951 + - 98952 + - 98953 + - 98954 + - 98955 + - 98956 + - 98957 + - 98958 + - 98959 + - 98960 + - 98961 + - 98962 + - 98963 + - 98964 + - 98965 + - 98966 + - 98967 + - 98968 + - 98969 + - 98970 + - 98971 + - 98972 + - 98973 + - 98974 + - 98975 + - 98976 + - 98977 + - 98978 + - 98979 + - 98980 + - 98981 + - 98982 + - 98983 + - 98984 + - 98985 + - 98986 + - 98987 + - 98988 + - 98989 + - 98990 + - 98991 + - 98992 + - 98993 + - 98994 + - 98995 + - 98996 + - 98997 + - 98998 + - 98999 + - 99000 + - 99001 + - 99002 + - 99003 + - 99004 + - 99005 + - 99006 + - 99007 + - 99008 + - 99009 + - 99010 + - 99011 + - 99012 + - 99013 + - 99014 + - 99015 + - 99016 + - 99017 + - 99018 + - 99019 + - 99020 + - 99021 + - 99022 + - 99023 + - 99024 + - 99025 + - 99026 + - 99027 + - 99028 + - 99029 + - 99030 + - 99031 + - 99032 + - 99033 + - 99034 + - 99035 + - 99036 + - 99037 + - 99038 + - 99039 + - 99040 + - 99041 + - 99042 + - 99043 + - 99044 + - 99045 + - 99046 + - 99047 + - 99048 + - 99049 + - 99050 + - 99051 + - 99052 + - 99053 + - 99054 + - 99055 + - 99056 + - 99057 + - 99058 + - 99059 + - 99060 + - 99061 + - 99062 + - 99063 + - 99064 + - 99065 + - 99066 + - 99067 + - 99068 + - 99069 + - 99070 + - 99071 + - 99072 + - 99073 + - 99074 + - 99075 + - 99076 + - 99077 + - 99078 + - 99079 + - 99080 + - 99081 + - 99082 + - 99083 + - 99084 + - 99085 + - 99086 + - 99087 + - 99088 + - 99089 + - 99090 + - 99091 + - 99092 + - 99093 + - 99094 + - 99095 + - 99096 + - 99097 + - 99098 + - 99099 + - 99100 + - 99101 + - 99102 + - 99103 + - 99104 + - 99105 + - 99106 + - 99107 + - 99108 + - 99109 + - 99110 + - 99111 + - 99112 + - 99113 + - 99114 + - 99115 + - 99116 + - 99117 + - 99118 + - 99119 + - 99120 + - 99121 + - 99122 + - 99123 + - 99124 + - 99125 + - 99126 + - 99127 + - 99128 + - 99129 + - 99130 + - 99131 + - 99132 + - 99133 + - 99134 + - 99135 + - 99136 + - 99137 + - 99138 + - 99139 + - 99140 + - 99141 + - 99142 + - 99143 + - 99144 + - 99145 + - 99146 + - 99147 + - 99148 + - 99149 + - 99150 + - 99151 + - 99152 + - 99153 + - 99154 + - 99155 + - 99156 + - 99157 + - 99158 + - 99159 + - 99160 + - 99161 + - 99162 + - 99163 + - 99164 + - 99165 + - 99166 + - 99167 + - 99168 + - 99169 + - 99170 + - 99171 + - 99172 + - 99173 + - 99174 + - 99175 + - 99176 + - 99177 + - 99178 + - 99179 + - 99180 + - 99181 + - 99182 + - 99183 + - 99184 + - 99185 + - 99186 + - 99187 + - 99188 + - 99189 + - 99190 + - 99191 + - 99192 + - 99193 + - 99194 + - 99195 + - 99196 + - 99197 + - 99198 + - 99199 + - 99200 + - 99201 + - 99202 + - 99203 + - 99204 + - 99205 + - 99206 + - 99207 + - 99208 + - 99209 + - 99210 + - 99211 + - 99212 + - 99213 + - 99214 + - 99215 + - 99216 + - 99217 + - 99218 + - 99219 + - 99220 + - 99221 + - 99222 + - 99223 + - 99224 + - 99225 + - 99226 + - 99227 + - 99228 + - 99229 + - 99230 + - 99231 + - 99232 + - 99233 + - 99234 + - 99235 + - 99236 + - 99237 + - 99238 + - 99239 + - 99240 + - 99241 + - 99242 + - 99243 + - 99244 + - 99245 + - 99246 + - 99247 + - 99248 + - 99249 + - 99250 + - 99251 + - 99252 + - 99253 + - 99254 + - 99255 + - 99256 + - 99257 + - 99258 + - 99259 + - 99260 + - 99261 + - 99262 + - 99263 + - 99264 + - 99265 + - 99266 + - 99267 + - 99268 + - 99269 + - 99270 + - 99271 + - 99272 + - 99273 + - 99274 + - 99275 + - 99276 + - 99277 + - 99278 + - 99279 + - 99280 + - 99281 + - 99282 + - 99283 + - 99284 + - 99285 + - 99286 + - 99287 + - 99288 + - 99289 + - 99290 + - 99291 + - 99292 + - 99293 + - 99294 + - 99295 + - 99296 + - 99297 + - 99298 + - 99299 + - 99300 + - 99301 + - 99302 + - 99303 + - 99304 + - 99305 + - 99306 + - 99307 + - 99308 + - 99309 + - 99310 + - 99311 + - 99312 + - 99313 + - 99314 + - 99315 + - 99316 + - 99317 + - 99318 + - 99319 + - 99320 + - 99321 + - 99322 + - 99323 + - 99324 + - 99325 + - 99326 + - 99327 + - 99328 + - 99329 + - 99330 + - 99331 + - 99332 + - 99333 + - 99334 + - 99335 + - 99336 + - 99337 + - 99338 + - 99339 + - 99340 + - 99341 + - 99342 + - 99343 + - 99344 + - 99345 + - 99346 + - 99347 + - 99348 + - 99349 + - 99350 + - 99351 + - 99352 + - 99353 + - 99354 + - 99355 + - 99356 + - 99357 + - 99358 + - 99359 + - 99360 + - 99361 + - 99362 + - 99363 + - 99364 + - 99365 + - 99366 + - 99367 + - 99368 + - 99369 + - 99370 + - 99371 + - 99372 + - 99373 + - 99374 + - 99375 + - 99376 + - 99377 + - 99378 + - 99379 + - 99380 + - 99381 + - 99382 + - 99383 + - 99384 + - 99385 + - 99386 + - 99387 + - 99388 + - 99389 + - 99390 + - 99391 + - 99392 + - 99393 + - 99394 + - 99395 + - 99396 + - 99397 + - 99398 + - 99399 + - 99400 + - 99401 + - 99402 + - 99403 + - 99404 + - 99405 + - 99406 + - 99407 + - 99408 + - 99409 + - 99410 + - 99411 + - 99412 + - 99413 + - 99414 + - 99415 + - 99416 + - 99417 + - 99418 + - 99419 + - 99420 + - 99421 + - 99422 + - 99423 + - 99424 + - 99425 + - 99426 + - 99427 + - 99428 + - 99429 + - 99430 + - 99431 + - 99432 + - 99433 + - 99434 + - 99435 + - 99436 + - 99437 + - 99438 + - 99439 + - 99440 + - 99441 + - 99442 + - 99443 + - 99444 + - 99445 + - 99446 + - 99447 + - 99448 + - 99449 + - 99450 + - 99451 + - 99452 + - 99453 + - 99454 + - 99455 + - 99456 + - 99457 + - 99458 + - 99459 + - 99460 + - 99461 + - 99462 + - 99463 + - 99464 + - 99465 + - 99466 + - 99467 + - 99468 + - 99469 + - 99470 + - 99471 + - 99472 + - 99473 + - 99474 + - 99475 + - 99476 + - 99477 + - 99478 + - 99479 + - 99480 + - 99481 + - 99482 + - 99483 + - 99484 + - 99485 + - 99486 + - 99487 + - 99488 + - 99489 + - 99490 + - 99491 + - 99492 + - 99493 + - 99494 + - 99495 + - 99496 + - 99497 + - 99498 + - 99499 + - 99500 + - 99501 + - 99502 + - 99503 + - 99504 + - 99505 + - 99506 + - 99507 + - 99508 + - 99509 + - 99510 + - 99511 + - 99512 + - 99513 + - 99514 + - 99515 + - 99516 + - 99517 + - 99518 + - 99519 + - 99520 + - 99521 + - 99522 + - 99523 + - 99524 + - 99525 + - 99526 + - 99527 + - 99528 + - 99529 + - 99530 + - 99531 + - 99532 + - 99533 + - 99534 + - 99535 + - 99536 + - 99537 + - 99538 + - 99539 + - 99540 + - 99541 + - 99542 + - 99543 + - 99544 + - 99545 + - 99546 + - 99547 + - 99548 + - 99549 + - 99550 + - 99551 + - 99552 + - 99553 + - 99554 + - 99555 + - 99556 + - 99557 + - 99558 + - 99559 + - 99560 + - 99561 + - 99562 + - 99563 + - 99564 + - 99565 + - 99566 + - 99567 + - 99568 + - 99569 + - 99570 + - 99571 + - 99572 + - 99573 + - 99574 + - 99575 + - 99576 + - 99577 + - 99578 + - 99579 + - 99580 + - 99581 + - 99582 + - 99583 + - 99584 + - 99585 + - 99586 + - 99587 + - 99588 + - 99589 + - 99590 + - 99591 + - 99592 + - 99593 + - 99594 + - 99595 + - 99596 + - 99597 + - 99598 + - 99599 + - 99600 + - 99601 + - 99602 + - 99603 + - 99604 + - 99605 + - 99606 + - 99607 + - 99608 + - 99609 + - 99610 + - 99611 + - 99612 + - 99613 + - 99614 + - 99615 + - 99616 + - 99617 + - 99618 + - 99619 + - 99620 + - 99621 + - 99622 + - 99623 + - 99624 + - 99625 + - 99626 + - 99627 + - 99628 + - 99629 + - 99630 + - 99631 + - 99632 + - 99633 + - 99634 + - 99635 + - 99636 + - 99637 + - 99638 + - 99639 + - 99640 + - 99641 + - 99642 + - 99643 + - 99644 + - 99645 + - 99646 + - 99647 + - 99648 + - 99649 + - 99650 + - 99651 + - 99652 + - 99653 + - 99654 + - 99655 + - 99656 + - 99657 + - 99658 + - 99659 + - 99660 + - 99661 + - 99662 + - 99663 + - 99664 + - 99665 + - 99666 + - 99667 + - 99668 + - 99669 + - 99670 + - 99671 + - 99672 + - 99673 + - 99674 + - 99675 + - 99676 + - 99677 + - 99678 + - 99679 + - 99680 + - 99681 + - 99682 + - 99683 + - 99684 + - 99685 + - 99686 + - 99687 + - 99688 + - 99689 + - 99690 + - 99691 + - 99692 + - 99693 + - 99694 + - 99695 + - 99696 + - 99697 + - 99698 + - 99699 + - 99700 + - 99701 + - 99702 + - 99703 + - 99704 + - 99705 + - 99706 + - 99707 + - 99708 + - 99709 + - 99710 + - 99711 + - 99712 + - 99713 + - 99714 + - 99715 + - 99716 + - 99717 + - 99718 + - 99719 + - 99720 + - 99721 + - 99722 + - 99723 + - 99724 + - 99725 + - 99726 + - 99727 + - 99728 + - 99729 + - 99730 + - 99731 + - 99732 + - 99733 + - 99734 + - 99735 + - 99736 + - 99737 + - 99738 + - 99739 + - 99740 + - 99741 + - 99742 + - 99743 + - 99744 + - 99745 + - 99746 + - 99747 + - 99748 + - 99749 + - 99750 + - 99751 + - 99752 + - 99753 + - 99754 + - 99755 + - 99756 + - 99757 + - 99758 + - 99759 + - 99760 + - 99761 + - 99762 + - 99763 + - 99764 + - 99765 + - 99766 + - 99767 + - 99768 + - 99769 + - 99770 + - 99771 + - 99772 + - 99773 + - 99774 + - 99775 + - 99776 + - 99777 + - 99778 + - 99779 + - 99780 + - 99781 + - 99782 + - 99783 + - 99784 + - 99785 + - 99786 + - 99787 + - 99788 + - 99789 + - 99790 + - 99791 + - 99792 + - 99793 + - 99794 + - 99795 + - 99796 + - 99797 + - 99798 + - 99799 + - 99800 + - 99801 + - 99802 + - 99803 + - 99804 + - 99805 + - 99806 + - 99807 + - 99808 + - 99809 + - 99810 + - 99811 + - 99812 + - 99813 + - 99814 + - 99815 + - 99816 + - 99817 + - 99818 + - 99819 + - 99820 + - 99821 + - 99822 + - 99823 + - 99824 + - 99825 + - 99826 + - 99827 + - 99828 + - 99829 + - 99830 + - 99831 + - 99832 + - 99833 + - 99834 + - 99835 + - 99836 + - 99837 + - 99838 + - 99839 + - 99840 + - 99841 + - 99842 + - 99843 + - 99844 + - 99845 + - 99846 + - 99847 + - 99848 + - 99849 + - 99850 + - 99851 + - 99852 + - 99853 + - 99854 + - 99855 + - 99856 + - 99857 + - 99858 + - 99859 + - 99860 + - 99861 + - 99862 + - 99863 + - 99864 + - 99865 + - 99866 + - 99867 + - 99868 + - 99869 + - 99870 + - 99871 + - 99872 + - 99873 + - 99874 + - 99875 + - 99876 + - 99877 + - 99878 + - 99879 + - 99880 + - 99881 + - 99882 + - 99883 + - 99884 + - 99885 + - 99886 + - 99887 + - 99888 + - 99889 + - 99890 + - 99891 + - 99892 + - 99893 + - 99894 + - 99895 + - 99896 + - 99897 + - 99898 + - 99899 + - 99900 + - 99901 + - 99902 + - 99903 + - 99904 + - 99905 + - 99906 + - 99907 + - 99908 + - 99909 + - 99910 + - 99911 + - 99912 + - 99913 + - 99914 + - 99915 + - 99916 + - 99917 + - 99918 + - 99919 + - 99920 + - 99921 + - 99922 + - 99923 + - 99924 + - 99925 + - 99926 + - 99927 + - 99928 + - 99929 + - 99930 + - 99931 + - 99932 + - 99933 + - 99934 + - 99935 + - 99936 + - 99937 + - 99938 + - 99939 + - 99940 + - 99941 + - 99942 + - 99943 + - 99944 + - 99945 + - 99946 + - 99947 + - 99948 + - 99949 + - 99950 + - 99951 + - 99952 + - 99953 + - 99954 + - 99955 + - 99956 + - 99957 + - 99958 + - 99959 + - 99960 + - 99961 + - 99962 + - 99963 + - 99964 + - 99965 + - 99966 + - 99967 + - 99968 + - 99969 + - 99970 + - 99971 + - 99972 + - 99973 + - 99974 + - 99975 + - 99976 + - 99977 + - 99978 + - 99979 + - 99980 + - 99981 + - 99982 + - 99983 + - 99984 + - 99985 + - 99986 + - 99987 + - 99988 + - 99989 + - 99990 + - 99991 + - 99992 + - 99993 + - 99994 + - 99995 + - 99996 + - 99997 + - 99998 + - 99999 + out: ghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhgebxsmfxoethugrbkszfkortuutrokfzskbrguhteoxfmsxbeghhg diff --git a/tests/501-1000/848. shifting-letters/sol.cpp b/tests/501-1000/848. shifting-letters/sol.cpp new file mode 100644 index 00000000..8f914a37 --- /dev/null +++ b/tests/501-1000/848. shifting-letters/sol.cpp @@ -0,0 +1,21 @@ +class Solution { +public: + string shiftingLetters(string s, vector& shifts) { + int n = shifts.size(); + vector l(n); + int z = 0; + for (int i = n - 1; i >= 0; --i) { + z = (z + shifts[i]) % 26; + l[i] = z; + } + vector p(n); + for (int i = 0; i < n; i++) { + p[i] = s[i] - 'a'; + } + string k; + for (int i = 0; i < n; i++) { + k += (char)(((p[i] + l[i]) % 26) + 'a'); + } + return k; + } +}; diff --git a/tests/501-1000/848. shifting-letters/sol.cs b/tests/501-1000/848. shifting-letters/sol.cs new file mode 100644 index 00000000..77d8a9b0 --- /dev/null +++ b/tests/501-1000/848. shifting-letters/sol.cs @@ -0,0 +1,20 @@ +public class Solution { + public string ShiftingLetters(string s, int[] shifts) { + int n = shifts.Length; + int[] l = new int[n]; + int z = 0; + for (int i = n - 1; i >= 0; i--) { + z = (z + shifts[i]) % 26; + l[i] = z; + } + int[] p = new int[n]; + for (int i = 0; i < n; i++) { + p[i] = s[i] - 'a'; + } + char[] result = new char[n]; + for (int i = 0; i < n; i++) { + result[i] = (char)(((p[i] + l[i]) % 26) + 'a'); + } + return new string(result); + } +} diff --git a/tests/501-1000/848. shifting-letters/sol.dart b/tests/501-1000/848. shifting-letters/sol.dart new file mode 100644 index 00000000..e450ca40 --- /dev/null +++ b/tests/501-1000/848. shifting-letters/sol.dart @@ -0,0 +1,17 @@ +class Solution { + String shiftingLetters(String s, List shifts) { + int n = shifts.length; + List l = List.filled(n, 0); + int z = shifts.reduce((a, b) => a + b); + l[0] = z; + for (int i = 1; i < n; i++) { + l[i] = l[i - 1] - shifts[i - 1]; + } + List p = s.codeUnits.map((c) => c - 97).toList(); + StringBuffer k = StringBuffer(); + for (int i = 0; i < n; i++) { + k.writeCharCode((p[i] + l[i]) % 26 + 97); + } + return k.toString(); + } +} diff --git a/tests/501-1000/848. shifting-letters/sol.go b/tests/501-1000/848. shifting-letters/sol.go new file mode 100644 index 00000000..2bd81a38 --- /dev/null +++ b/tests/501-1000/848. shifting-letters/sol.go @@ -0,0 +1,21 @@ +func shiftingLetters(s string, shifts []int) string { + n := len(shifts) + l := make([]int, n) + z := 0 + for _, v := range shifts { + z += v + } + l[0] = z + for i := 1; i < n; i++ { + l[i] = l[i-1] - shifts[i-1] + } + p := make([]int, n) + for i, c := range s { + p[i] = int(c - 'a') + } + k := make([]byte, n) + for i := 0; i < n; i++ { + k[i] = byte((p[i]+l[i])%26 + 97) + } + return string(k) +} diff --git a/tests/501-1000/848. shifting-letters/sol.java b/tests/501-1000/848. shifting-letters/sol.java new file mode 100644 index 00000000..aa4295dc --- /dev/null +++ b/tests/501-1000/848. shifting-letters/sol.java @@ -0,0 +1,22 @@ +class Solution { + public String shiftingLetters(String s, int[] shifts) { + int n = shifts.length; + int[] l = new int[n]; + int z = 0; + for (int shift : shifts) { + z = (z + shift) % 26; + } + l[0] = z; + for (int i = 1; i < n; i++) { + l[i] = (l[i - 1] - shifts[i - 1]) % 26; + if (l[i] < 0) l[i] += 26; + } + StringBuilder k = new StringBuilder(); + for (int i = 0; i < n; i++) { + int original = s.charAt(i) - 'a'; + int shifted = (original + l[i]) % 26; + k.append((char)(shifted + 'a')); + } + return k.toString(); + } +} diff --git a/tests/501-1000/848. shifting-letters/sol.kt b/tests/501-1000/848. shifting-letters/sol.kt new file mode 100644 index 00000000..6cc15c74 --- /dev/null +++ b/tests/501-1000/848. shifting-letters/sol.kt @@ -0,0 +1,17 @@ +class Solution { + fun shiftingLetters(s: String, shifts: IntArray): String { + val n = shifts.size + val l = IntArray(n) + var z = 0 + for (i in n - 1 downTo 0) { + z = (z + shifts[i]) % 26 + l[i] = z + } + val p = s.map { it.code - 97 } + val k = StringBuilder() + for (i in 0 until n) { + k.append(((p[i] + l[i]) % 26 + 97).toChar()) + } + return k.toString() + } +} diff --git a/tests/501-1000/848. shifting-letters/sol.py b/tests/501-1000/848. shifting-letters/sol.py new file mode 100644 index 00000000..6f0cf73d --- /dev/null +++ b/tests/501-1000/848. shifting-letters/sol.py @@ -0,0 +1,14 @@ +class Solution(object): + def shiftingLetters(self, s, shifts): + l = [] + z = sum(shifts) + l.append(z) + for i in range(1, len(shifts)): + l.append(l[-1] - shifts[i - 1]) + p = [] + for i in range(len(s)): + p.append(ord(s[i]) - 97) + k = "" + for i in range(len(p)): + k = k + chr(((p[i] + l[i]) % 26) + 97) + return k diff --git a/tests/501-1000/848. shifting-letters/sol.py2 b/tests/501-1000/848. shifting-letters/sol.py2 new file mode 100644 index 00000000..0cffb392 --- /dev/null +++ b/tests/501-1000/848. shifting-letters/sol.py2 @@ -0,0 +1,14 @@ +class Solution(object): + def shiftingLetters(self, s, shifts): + l=[] + z=sum(shifts) + l.append(z) + for i in range(1,len(shifts)): + l.append(l[-1]-shifts[i-1]) + p=[] + for i in range(len(s)): + p.append(ord(s[i])-97) + k="" + for i in range(len(p)): + k=k+chr(((p[i]+l[i])%26)+97) + return k diff --git a/tests/501-1000/848. shifting-letters/sol.rb b/tests/501-1000/848. shifting-letters/sol.rb new file mode 100644 index 00000000..6d1ae4b2 --- /dev/null +++ b/tests/501-1000/848. shifting-letters/sol.rb @@ -0,0 +1,17 @@ +# @param {String} s +# @param {Integer[]} shifts +# @return {String} +def shifting_letters(s, shifts) + l = [] + z = shifts.sum + l << z + (1...shifts.length).each do |i| + l << l[-1] - shifts[i - 1] + end + p = s.chars.map { |c| c.ord - 97 } + k = "" + (0...p.length).each do |i| + k += ((p[i] + l[i]) % 26 + 97).chr + end + k +end diff --git a/tests/501-1000/848. shifting-letters/sol.rs b/tests/501-1000/848. shifting-letters/sol.rs new file mode 100644 index 00000000..b9136d3f --- /dev/null +++ b/tests/501-1000/848. shifting-letters/sol.rs @@ -0,0 +1,18 @@ +impl Solution { + pub fn shifting_letters(s: String, shifts: Vec) -> String { + let n = shifts.len(); + let mut l = vec![0i32; n]; + let mut z = 0i32; + for i in (0..n).rev() { + z = (z + shifts[i]) % 26; + l[i] = z; + } + let p: Vec = s.chars().map(|c| c as i32 - 97).collect(); + let mut k = String::new(); + for i in 0..n { + let ch = ((p[i] + l[i]) % 26 + 97) as u8 as char; + k.push(ch); + } + k + } +} diff --git a/tests/501-1000/848. shifting-letters/sol.swift b/tests/501-1000/848. shifting-letters/sol.swift new file mode 100644 index 00000000..76b169bc --- /dev/null +++ b/tests/501-1000/848. shifting-letters/sol.swift @@ -0,0 +1,17 @@ +class Solution { + func shiftingLetters(_ s: String, _ shifts: [Int]) -> String { + let n = shifts.count + var l = [Int](repeating: 0, count: n) + let z = shifts.reduce(0, +) + l[0] = z + for i in 1.. a + b, 0); + l[0] = z; + for (let i = 1; i < n; i++) { + l[i] = l[i - 1] - shifts[i - 1]; + } + const p = s.split("").map((c) => c.charCodeAt(0) - 97); + let k = ""; + for (let i = 0; i < n; i++) { + k += String.fromCharCode(((p[i] + l[i]) % 26) + 97); + } + return k; +} diff --git a/tests/501-1000/849. maximize-distance-to-closest-person/manifest.yaml b/tests/501-1000/849. maximize-distance-to-closest-person/manifest.yaml new file mode 100644 index 00000000..2277e6ef --- /dev/null +++ b/tests/501-1000/849. maximize-distance-to-closest-person/manifest.yaml @@ -0,0 +1,974 @@ +entry: + id: 849 + title: maximize-distance-to-closest-person + params: + seats: + type: array + items: + type: int + call: + cpp: Solution().maxDistToClosest({seats}) + rust: Solution::max_dist_to_closest({seats}) + python3: Solution().maxDistToClosest({seats}) + python2: Solution().maxDistToClosest({seats}) + ruby: max_dist_to_closest({seats}) + java: new Solution().maxDistToClosest({seats}) + csharp: new Solution().MaxDistToClosest({seats}) + kotlin: Solution().maxDistToClosest({seats}) + go: maxDistToClosest({seats}) + dart: Solution().maxDistToClosest({seats}) + swift: Solution().maxDistToClosest({seats}) + typescript: maxDistToClosest({seats}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().maxDistToClosest(seats, {result}) + checker: "class Checker:\n def maxDistToClosest(self, seats, result):\n parts = \"\".join(str(x) for x in seats).split(\"1\")\n lengths = [len(x) for x in parts]\n expected = max(lengths[0], (max(lengths) + 1) // 2, lengths[-1])\n return result == expected\n" +seed: 849 +tests: + - name: example-1 + in: + seats: + - 1 + - 0 + - 0 + - 0 + - 1 + - 0 + - 1 + out: 2 + - name: example-2 + in: + seats: + - 1 + - 0 + - 0 + - 0 + out: 3 + - name: example-3 + in: + seats: + - 0 + - 1 + out: 1 + - name: left-edge + in: + seats: + - 0 + - 0 + - 0 + - 0 + - 1 + out: 4 + - name: right-edge + in: + seats: + - 1 + - 0 + - 0 + - 0 + - 0 + out: 4 + - name: single-middle-gap + in: + seats: + - 1 + - 0 + - 1 + out: 1 + - name: two-middle-gap + in: + seats: + - 1 + - 0 + - 0 + - 1 + out: 1 + - name: three-middle-gap + in: + seats: + - 1 + - 0 + - 0 + - 0 + - 1 + out: 2 + - name: alternating-start-1 + in: + seats: + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + out: 1 + - name: alternating-start-0 + in: + seats: + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + out: 1 + - name: long-middle-gap + in: + seats: + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + out: 3 + - name: leading-and-middle + in: + seats: + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 1 + out: 2 + - name: trailing-and-middle + in: + seats: + - 1 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + out: 2 + - name: all-but-one-left + in: + seats: + - 1 + - 1 + - 1 + - 0 + - 1 + - 1 + out: 1 + - name: all-but-one-right + in: + seats: + - 1 + - 1 + - 0 + - 1 + - 1 + - 1 + out: 1 + - name: double-blocks + in: + seats: + - 1 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 1 + out: 2 + - name: two-people-ends + in: + seats: + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + out: 3 + - name: single-person-left + in: + seats: + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + out: 9 + - name: single-person-right + in: + seats: + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + out: 9 + - name: single-person-center + in: + seats: + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + out: 4 + - name: dense-left-empty-right + in: + seats: + - 1 + - 1 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + out: 4 + - name: dense-right-empty-left + in: + seats: + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 1 + - 1 + out: 4 + - name: tiny-four + in: + seats: + - 0 + - 1 + - 0 + - 0 + out: 2 + - name: tiny-five + in: + seats: + - 0 + - 0 + - 1 + - 0 + - 0 + out: 2 + - name: clustered-ones + in: + seats: + - 1 + - 1 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 1 + out: 2 + - name: clustered-zeros + in: + seats: + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 1 + out: 3 + - name: mixed-ten + in: + seats: + - 0 + - 1 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 1 + out: 2 + - name: mixed-twelve + in: + seats: + - 1 + - 0 + - 0 + - 1 + - 0 + - 1 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + out: 2 + - name: long-20-ends + in: + seats: + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + out: 9 + - name: long-20-left + in: + seats: + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + out: 19 + - name: long-20-right + in: + seats: + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + out: 19 + - name: long-50-center + in: + seats: + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + out: 25 + - name: long-100-periodic + in: + seats: + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + out: 19 + - name: long-200-sparse + in: + seats: + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + out: 94 + - name: long-200-dense-ends + in: + seats: + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + out: 100 diff --git a/tests/501-1000/849. maximize-distance-to-closest-person/sol.cpp b/tests/501-1000/849. maximize-distance-to-closest-person/sol.cpp new file mode 100644 index 00000000..824cefba --- /dev/null +++ b/tests/501-1000/849. maximize-distance-to-closest-person/sol.cpp @@ -0,0 +1,18 @@ +class Solution { +public: + int maxDistToClosest(vector& seats) { + string s; + for (int x : seats) s += to_string(x); + vector lens; + size_t pos = 0; + string token; + while ((pos = s.find('1')) != string::npos) { + token = s.substr(0, pos); + lens.push_back(token.length()); + s.erase(0, pos + 1); + } + lens.push_back(s.length()); + int maxVal = *max_element(lens.begin(), lens.end()); + return max({lens[0], (maxVal + 1) / 2, lens.back()}); + } +}; diff --git a/tests/501-1000/849. maximize-distance-to-closest-person/sol.cs b/tests/501-1000/849. maximize-distance-to-closest-person/sol.cs new file mode 100644 index 00000000..a6b866e9 --- /dev/null +++ b/tests/501-1000/849. maximize-distance-to-closest-person/sol.cs @@ -0,0 +1,9 @@ +public class Solution { + public int MaxDistToClosest(int[] seats) { + string s = string.Join("", seats); + string[] parts = s.Split('1'); + int maxVal = 0; + foreach (string p in parts) maxVal = Math.Max(maxVal, p.Length); + return Math.Max(Math.Max(parts[0].Length, (maxVal + 1) / 2), parts[parts.Length - 1].Length); + } +} diff --git a/tests/501-1000/849. maximize-distance-to-closest-person/sol.dart b/tests/501-1000/849. maximize-distance-to-closest-person/sol.dart new file mode 100644 index 00000000..6076f4ad --- /dev/null +++ b/tests/501-1000/849. maximize-distance-to-closest-person/sol.dart @@ -0,0 +1,8 @@ +class Solution { + int maxDistToClosest(List seats) { + String s = seats.join(); + List parts = s.split('1'); + int maxVal = parts.map((p) => p.length).reduce((a, b) => a > b ? a : b); + return [parts.first.length, (maxVal + 1) ~/ 2, parts.last.length].reduce((a, b) => a > b ? a : b); + } +} diff --git a/tests/501-1000/849. maximize-distance-to-closest-person/sol.go b/tests/501-1000/849. maximize-distance-to-closest-person/sol.go new file mode 100644 index 00000000..1e0226ac --- /dev/null +++ b/tests/501-1000/849. maximize-distance-to-closest-person/sol.go @@ -0,0 +1,23 @@ +func maxDistToClosest(seats []int) int { + sb := "" + for _, s := range seats { + sb += string(rune('0' + s)) + } + parts := strings.Split(sb, "1") + maxVal := 0 + for _, p := range parts { + if len(p) > maxVal { + maxVal = len(p) + } + } + first := len(parts[0]) + last := len(parts[len(parts)-1]) + mid := (maxVal + 1) / 2 + if first > mid { + mid = first + } + if last > mid { + mid = last + } + return mid +} diff --git a/tests/501-1000/849. maximize-distance-to-closest-person/sol.java b/tests/501-1000/849. maximize-distance-to-closest-person/sol.java new file mode 100644 index 00000000..7ddeb693 --- /dev/null +++ b/tests/501-1000/849. maximize-distance-to-closest-person/sol.java @@ -0,0 +1,13 @@ +class Solution { + public int maxDistToClosest(int[] seats) { + int previous = -1; + int best = 0; + for (int i = 0; i < seats.length; i++) { + if (seats[i] == 1) { + best = Math.max(best, previous == -1 ? i : (i - previous) / 2); + previous = i; + } + } + return Math.max(best, seats.length - 1 - previous); + } +} diff --git a/tests/501-1000/849. maximize-distance-to-closest-person/sol.kt b/tests/501-1000/849. maximize-distance-to-closest-person/sol.kt new file mode 100644 index 00000000..71133c51 --- /dev/null +++ b/tests/501-1000/849. maximize-distance-to-closest-person/sol.kt @@ -0,0 +1,8 @@ +class Solution { + fun maxDistToClosest(seats: IntArray): Int { + val s = seats.joinToString("") + val parts = s.split("1") + val max = parts.maxOfOrNull { it.length } ?: 0 + return maxOf(parts.first().length, (max + 1) / 2, parts.last().length) + } +} diff --git a/tests/501-1000/849. maximize-distance-to-closest-person/sol.py b/tests/501-1000/849. maximize-distance-to-closest-person/sol.py new file mode 100644 index 00000000..3be91910 --- /dev/null +++ b/tests/501-1000/849. maximize-distance-to-closest-person/sol.py @@ -0,0 +1,4 @@ +class Solution: + def maxDistToClosest(self, seats: List[int]) -> int: + l = [len(y) for y in "".join([str(x) for x in seats]).split("1")] + return max(l[0], (max(l) + 1) // 2, l[-1]) diff --git a/tests/501-1000/849. maximize-distance-to-closest-person/sol.py2 b/tests/501-1000/849. maximize-distance-to-closest-person/sol.py2 new file mode 100644 index 00000000..3621405a --- /dev/null +++ b/tests/501-1000/849. maximize-distance-to-closest-person/sol.py2 @@ -0,0 +1,8 @@ +class Solution(object): + def maxDistToClosest(self, seats): + """ + :type seats: List[int] + :rtype: int + """ + l = [len(y) for y in ''.join([str(x) for x in seats]).split('1')] + return max(l[0], (max(l)+1)//2, l[-1]) diff --git a/tests/501-1000/849. maximize-distance-to-closest-person/sol.rb b/tests/501-1000/849. maximize-distance-to-closest-person/sol.rb new file mode 100644 index 00000000..c908553f --- /dev/null +++ b/tests/501-1000/849. maximize-distance-to-closest-person/sol.rb @@ -0,0 +1,12 @@ +# @param {Integer[]} seats +# @return {Integer} +def max_dist_to_closest(seats) + previous = -1 + best = 0 + seats.each_with_index do |seat, index| + next unless seat == 1 + best = [best, previous == -1 ? index : (index - previous) / 2].max + previous = index + end + [best, seats.length - 1 - previous].max +end diff --git a/tests/501-1000/849. maximize-distance-to-closest-person/sol.rs b/tests/501-1000/849. maximize-distance-to-closest-person/sol.rs new file mode 100644 index 00000000..b0a9bd42 --- /dev/null +++ b/tests/501-1000/849. maximize-distance-to-closest-person/sol.rs @@ -0,0 +1,11 @@ +impl Solution { + pub fn max_dist_to_closest(seats: Vec) -> i32 { + let s: String = seats.iter().map(|&x| if x == 1 { '1' } else { '0' }).collect(); + let parts: Vec<&str> = s.split('1').collect(); + let max_val = parts.iter().map(|p| p.len()).max().unwrap_or(0); + let first = parts[0].len(); + let last = parts[parts.len() - 1].len(); + let mid = (max_val + 1) / 2; + std::cmp::max(std::cmp::max(first, mid), last) as i32 + } +} diff --git a/tests/501-1000/849. maximize-distance-to-closest-person/sol.swift b/tests/501-1000/849. maximize-distance-to-closest-person/sol.swift new file mode 100644 index 00000000..7ad20bd3 --- /dev/null +++ b/tests/501-1000/849. maximize-distance-to-closest-person/sol.swift @@ -0,0 +1,11 @@ +class Solution { + func maxDistToClosest(_ seats: [Int]) -> Int { + var previous = -1 + var best = 0 + for (index, seat) in seats.enumerated() where seat == 1 { + best = max(best, previous == -1 ? index : (index - previous) / 2) + previous = index + } + return max(best, seats.count - 1 - previous) + } +} diff --git a/tests/501-1000/849. maximize-distance-to-closest-person/sol.ts b/tests/501-1000/849. maximize-distance-to-closest-person/sol.ts new file mode 100644 index 00000000..b66864cf --- /dev/null +++ b/tests/501-1000/849. maximize-distance-to-closest-person/sol.ts @@ -0,0 +1,10 @@ +function maxDistToClosest(seats: number[]): number { + const s = seats.join(""); + const parts = s.split("1"); + const maxVal = Math.max(...parts.map((p) => p.length)); + return Math.max( + parts[0].length, + Math.floor((maxVal + 1) / 2), + parts[parts.length - 1].length, + ); +} diff --git a/tests/501-1000/850. rectangle-area-ii/manifest.yaml b/tests/501-1000/850. rectangle-area-ii/manifest.yaml new file mode 100644 index 00000000..d2613054 --- /dev/null +++ b/tests/501-1000/850. rectangle-area-ii/manifest.yaml @@ -0,0 +1,283 @@ +entry: + id: 850 + title: rectangle-area-ii + params: + rectangles: + type: array + items: + type: array + items: + type: int + call: + cpp: Solution().rectangleArea({rectangles}) + rust: Solution::rectangle_area({rectangles}) + python3: Solution().rectangleArea({rectangles}) + python2: Solution().rectangleArea({rectangles}) + ruby: rectangle_area({rectangles}) + java: new Solution().rectangleArea({rectangles}) + csharp: new Solution().RectangleArea({rectangles}) + kotlin: Solution().rectangleArea({rectangles}) + go: rectangleArea({rectangles}) + dart: Solution().rectangleArea({rectangles}) + swift: Solution().rectangleArea({rectangles}) + typescript: rectangleArea({rectangles}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().ok({result}) + checker: | + class Checker: + def ok(self, result): + return True +seed: 850 +tests: + - name: example-one + in: + rectangles: + - [0, 0, 2, 2] + - [1, 0, 2, 3] + - [1, 0, 3, 1] + out: 6 + - name: example-two + in: + rectangles: + - [0, 0, 1000000000, 1000000000] + out: 49 + - name: unit-square + in: + rectangles: + - [0, 0, 1, 1] + out: 1 + - name: horizontal-strip-pair + in: + rectangles: + - [0, 0, 4, 1] + - [1, 0, 3, 1] + out: 4 + - name: vertical-strip-pair + in: + rectangles: + - [0, 0, 1, 4] + - [0, 1, 1, 3] + out: 4 + - name: disjoint-two + in: + rectangles: + - [0, 0, 2, 2] + - [3, 0, 5, 2] + out: 8 + - name: touching-edge + in: + rectangles: + - [0, 0, 2, 2] + - [2, 0, 4, 2] + out: 8 + - name: touching-corner + in: + rectangles: + - [0, 0, 2, 2] + - [2, 2, 4, 4] + out: 8 + - name: full-containment + in: + rectangles: + - [0, 0, 5, 5] + - [1, 1, 2, 2] + out: 25 + - name: nested-three + in: + rectangles: + - [0, 0, 10, 10] + - [2, 2, 8, 8] + - [4, 4, 6, 6] + out: 100 + - name: partial-overlap + in: + rectangles: + - [0, 0, 3, 3] + - [2, 2, 5, 5] + out: 17 + - name: overlap-chain + in: + rectangles: + - [0, 0, 2, 4] + - [1, 1, 3, 5] + - [2, 2, 4, 6] + out: 18 + - name: staircase + in: + rectangles: + - [0, 0, 2, 2] + - [1, 1, 3, 3] + - [2, 2, 4, 4] + out: 10 + - name: strip-union + in: + rectangles: + - [0, 0, 1, 4] + - [1, 0, 2, 4] + - [2, 0, 3, 4] + out: 12 + - name: wide-overlap + in: + rectangles: + - [0, 0, 6, 2] + - [2, 1, 8, 3] + - [4, 0, 10, 2] + out: 26 + - name: tall-overlap + in: + rectangles: + - [0, 0, 2, 6] + - [1, 2, 3, 8] + - [0, 4, 2, 10] + out: 26 + - name: corner-grid + in: + rectangles: + - [0, 0, 2, 2] + - [2, 0, 4, 2] + - [0, 2, 2, 4] + - [2, 2, 4, 4] + out: 16 + - name: cross-center + in: + rectangles: + - [1, 0, 3, 4] + - [0, 1, 4, 3] + out: 12 + - name: three-way-overlap + in: + rectangles: + - [0, 0, 4, 4] + - [1, 1, 5, 5] + - [2, 2, 6, 6] + out: 30 + - name: shared-strip + in: + rectangles: + - [0, 0, 5, 5] + - [1, 0, 4, 5] + - [2, 0, 3, 5] + out: 25 + - name: disjoint-triple + in: + rectangles: + - [0, 0, 1, 1] + - [2, 2, 3, 3] + - [4, 4, 5, 5] + out: 3 + - name: aligned-stack + in: + rectangles: + - [0, 0, 3, 1] + - [0, 1, 3, 2] + - [0, 2, 3, 3] + out: 9 + - name: thin-overlap + in: + rectangles: + - [0, 0, 5, 1] + - [4, 0, 9, 1] + - [8, 0, 13, 1] + out: 13 + - name: large-single + in: + rectangles: + - [0, 0, 1000000000, 1000000000] + out: 49 + - name: large-nested + in: + rectangles: + - [0, 0, 1000000000, 1000000000] + - [1, 1, 999999999, 999999999] + out: 49 + - name: large-disjoint + in: + rectangles: + - [0, 0, 500000000, 1000000000] + - [500000000, 0, 1000000000, 1000000000] + out: 49 + - name: large-partial + in: + rectangles: + - [0, 0, 1000000000, 500000000] + - [500000000, 250000000, 1000000000, 1000000000] + out: 750000042 + - name: large-cross + in: + rectangles: + - [0, 0, 1000000000, 1] + - [0, 0, 1, 1000000000] + out: 999999992 + - name: three-small-offset + in: + rectangles: + - [0, 0, 2, 3] + - [1, 1, 4, 2] + - [3, 0, 5, 4] + out: 15 + - name: nested-left + in: + rectangles: + - [0, 0, 8, 8] + - [0, 0, 4, 4] + - [0, 0, 2, 2] + out: 64 + - name: nested-right + in: + rectangles: + - [0, 0, 8, 8] + - [4, 4, 8, 8] + - [6, 6, 8, 8] + out: 64 + - name: overlap-fan + in: + rectangles: + - [0, 0, 2, 5] + - [1, 0, 3, 5] + - [2, 0, 4, 5] + - [3, 0, 5, 5] + out: 25 + - name: tiny-lattice + in: + rectangles: + - [0, 0, 1, 2] + - [1, 0, 2, 1] + - [1, 1, 2, 2] + - [2, 0, 3, 2] + out: 6 + - name: asymmetric-overlap + in: + rectangles: + - [0, 0, 4, 6] + - [1, 2, 5, 4] + - [3, 1, 6, 5] + out: 32 + - name: far-apart-four + in: + rectangles: + - [0, 0, 1, 3] + - [2, 0, 3, 3] + - [4, 0, 5, 3] + - [6, 0, 7, 3] + out: 12 + - name: overlapping-columns + in: + rectangles: + - [0, 0, 2, 4] + - [1, 0, 3, 4] + - [2, 0, 4, 4] + out: 16 + - name: box-with-hole-overlap + in: + rectangles: + - [0, 0, 6, 6] + - [1, 1, 5, 5] + - [2, 2, 4, 4] + - [3, 0, 6, 3] + out: 36 diff --git a/tests/501-1000/850. rectangle-area-ii/sol.cpp b/tests/501-1000/850. rectangle-area-ii/sol.cpp new file mode 100644 index 00000000..185754a7 --- /dev/null +++ b/tests/501-1000/850. rectangle-area-ii/sol.cpp @@ -0,0 +1,41 @@ +class Solution { +public: + int rectangleArea(vector>& rectangles) { + const int MOD = 1e9 + 7; + const int OPEN = 0, CLOSE = 1; + + vector> events; + for (auto& r : rectangles) { + int x1 = r[0], y1 = r[1], x2 = r[2], y2 = r[3]; + events.emplace_back(y1, OPEN, x1, x2); + events.emplace_back(y2, CLOSE, x1, x2); + } + sort(events.begin(), events.end()); + + long long res = 0; + int cur_y = get<0>(events[0]); + vector> active; + + for (auto& [y, typ, x1, x2] : events) { + long long q = 0; + int cur = -1; + sort(active.begin(), active.end()); + for (auto& [ax1, ax2] : active) { + q += max(0, ax2 - max(cur, ax1)); + cur = max(cur, ax2); + } + + res = (res + q * (y - cur_y)) % MOD; + cur_y = y; + + if (typ == OPEN) { + active.emplace_back(x1, x2); + } else { + auto it = find(active.begin(), active.end(), make_pair(x1, x2)); + if (it != active.end()) active.erase(it); + } + } + + return (int)res; + } +}; diff --git a/tests/501-1000/850. rectangle-area-ii/sol.cs b/tests/501-1000/850. rectangle-area-ii/sol.cs new file mode 100644 index 00000000..4089d570 --- /dev/null +++ b/tests/501-1000/850. rectangle-area-ii/sol.cs @@ -0,0 +1,40 @@ +public class Solution { + public int RectangleArea(int[][] rectangles) { + const int MOD = 1000000007; + const int OPEN = 0; + const int CLOSE = 1; + + var events = new List<(int y, int typ, int x1, int x2)>(); + foreach (var r in rectangles) { + int x1 = r[0], y1 = r[1], x2 = r[2], y2 = r[3]; + events.Add((y1, OPEN, x1, x2)); + events.Add((y2, CLOSE, x1, x2)); + } + events.Sort((a, b) => a.y.CompareTo(b.y)); + + long res = 0; + int curY = events[0].y; + var active = new List<(int x1, int x2)>(); + + foreach (var (y, typ, x1, x2) in events) { + long q = 0; + int cur = -1; + active.Sort((a, b) => a.x1.CompareTo(b.x1)); + foreach (var (ax1, ax2) in active) { + q += Math.Max(0, ax2 - Math.Max(cur, ax1)); + cur = Math.Max(cur, ax2); + } + + res = (res + q * (y - curY)) % MOD; + curY = y; + + if (typ == OPEN) { + active.Add((x1, x2)); + } else { + active.Remove((x1, x2)); + } + } + + return (int)res; + } +} diff --git a/tests/501-1000/850. rectangle-area-ii/sol.dart b/tests/501-1000/850. rectangle-area-ii/sol.dart new file mode 100644 index 00000000..fa51e1a1 --- /dev/null +++ b/tests/501-1000/850. rectangle-area-ii/sol.dart @@ -0,0 +1,43 @@ +class Solution { + int rectangleArea(List> rectangles) { + const int OPEN = 0; + const int CLOSE = 1; + const int MOD = 1000000007; + + List> events = []; + for (var r in rectangles) { + int x1 = r[0], y1 = r[1], x2 = r[2], y2 = r[3]; + events.add([y1, OPEN, x1, x2]); + events.add([y2, CLOSE, x1, x2]); + } + events.sort((a, b) => a[0].compareTo(b[0])); + + int res = 0; + int curY = events[0][0]; + List> active = []; + + for (var e in events) { + int y = e[0], typ = e[1], x1 = e[2], x2 = e[3]; + + int q = 0; + int cur = -1; + active.sort((a, b) => a[0].compareTo(b[0])); + for (var seg in active) { + q += max(0, seg[1] - max(cur, seg[0])); + cur = max(cur, seg[1]); + } + + res = (res + q * (y - curY)) % MOD; + curY = y; + + if (typ == OPEN) { + active.add([x1, x2]); + } else { + final index = active.indexWhere((seg) => seg[0] == x1 && seg[1] == x2); + if (index >= 0) active.removeAt(index); + } + } + + return res; + } +} diff --git a/tests/501-1000/850. rectangle-area-ii/sol.go b/tests/501-1000/850. rectangle-area-ii/sol.go new file mode 100644 index 00000000..e0cee25a --- /dev/null +++ b/tests/501-1000/850. rectangle-area-ii/sol.go @@ -0,0 +1,62 @@ +func rectangleArea(rectangles [][]int) int { + const MOD = 1000000007 + const OPEN = 0 + const CLOSE = 1 + + type Event struct { + y, typ, x1, x2 int + } + + var events []Event + for _, r := range rectangles { + x1, y1, x2, y2 := r[0], r[1], r[2], r[3] + events = append(events, Event{y1, OPEN, x1, x2}) + events = append(events, Event{y2, CLOSE, x1, x2}) + } + sort.Slice(events, func(i, j int) bool { + return events[i].y < events[j].y + }) + + res := 0 + curY := events[0].y + type Segment struct{ x1, x2 int } + var active []Segment + + for _, e := range events { + y, typ, x1, x2 := e.y, e.typ, e.x1, e.x2 + + q := 0 + cur := -1 + sort.Slice(active, func(i, j int) bool { + return active[i].x1 < active[j].x1 + }) + for _, seg := range active { + if seg.x2 > cur { + if seg.x1 > cur { + q += seg.x2 - seg.x1 + } else { + q += seg.x2 - cur + } + if seg.x2 > cur { + cur = seg.x2 + } + } + } + + res = (res + q*(y-curY)) % MOD + curY = y + + if typ == OPEN { + active = append(active, Segment{x1, x2}) + } else { + for i, seg := range active { + if seg.x1 == x1 && seg.x2 == x2 { + active = append(active[:i], active[i+1:]...) + break + } + } + } + } + + return res +} diff --git a/tests/501-1000/850. rectangle-area-ii/sol.java b/tests/501-1000/850. rectangle-area-ii/sol.java new file mode 100644 index 00000000..7f22aaec --- /dev/null +++ b/tests/501-1000/850. rectangle-area-ii/sol.java @@ -0,0 +1,46 @@ +class Solution { + public int rectangleArea(int[][] rectangles) { + final int OPEN = 0, CLOSE = 1; + int MOD = (int)1e9 + 7; + List events = new ArrayList<>(); + for (int[] r : rectangles) { + int x1 = r[0], y1 = r[1], x2 = r[2], y2 = r[3]; + events.add(new int[]{y1, OPEN, x1, x2}); + events.add(new int[]{y2, CLOSE, x1, x2}); + } + events.sort((a, b) -> Integer.compare(a[0], b[0])); + + long res = 0; + int cur_y = events.get(0)[0]; + List active = new ArrayList<>(); + + for (int[] event : events) { + int y = event[0], typ = event[1], x1 = event[2], x2 = event[3]; + + long q = 0; + int cur = -1; + active.sort((a, b) -> Integer.compare(a[0], b[0])); + for (int[] seg : active) { + q += Math.max(0, seg[1] - Math.max(cur, seg[0])); + cur = Math.max(cur, seg[1]); + } + + res = (res + q * (y - cur_y)) % MOD; + cur_y = y; + + if (typ == OPEN) { + active.add(new int[]{x1, x2}); + } else { + for (int i = 0; i < active.size(); i++) { + int[] seg = active.get(i); + if (seg[0] == x1 && seg[1] == x2) { + active.remove(i); + break; + } + } + } + } + + return (int)res; + } +} diff --git a/tests/501-1000/850. rectangle-area-ii/sol.kt b/tests/501-1000/850. rectangle-area-ii/sol.kt new file mode 100644 index 00000000..90cfa2ed --- /dev/null +++ b/tests/501-1000/850. rectangle-area-ii/sol.kt @@ -0,0 +1,42 @@ +class Solution { + fun rectangleArea(rectangles: Array): Int { + val MOD = 1000000007 + val OPEN = 0 + val CLOSE = 1 + + val events = mutableListOf>>() + for (r in rectangles) { + val (x1, y1, x2, y2) = r + events.add(Triple(y1, OPEN, Pair(x1, x2))) + events.add(Triple(y2, CLOSE, Pair(x1, x2))) + } + events.sortBy { it.first } + + var res = 0L + var curY = events[0].first + val active = mutableListOf>() + + for ((y, typ, pair) in events) { + val (x1, x2) = pair + + var q = 0L + var cur = -1 + active.sortBy { it.first } + for ((ax1, ax2) in active) { + q += maxOf(0, ax2 - maxOf(cur, ax1)) + cur = maxOf(cur, ax2) + } + + res = (res + q * (y - curY)) % MOD + curY = y + + if (typ == OPEN) { + active.add(Pair(x1, x2)) + } else { + active.remove(Pair(x1, x2)) + } + } + + return res.toInt() + } +} diff --git a/tests/501-1000/850. rectangle-area-ii/sol.py b/tests/501-1000/850. rectangle-area-ii/sol.py new file mode 100644 index 00000000..0eb939ab --- /dev/null +++ b/tests/501-1000/850. rectangle-area-ii/sol.py @@ -0,0 +1,18 @@ +class Solution: + def rectangleArea(self, rectangles: List[List[int]]) -> int: + OPEN, CLOSE = 0, 1 + events = sorted( + (*p, x1, x2) + for x1, y1, x2, y2 in rectangles + for p in ((y1, OPEN), (y2, CLOSE)) + ) + res, cur_y, active = 0, events[0][0], SortedList() + for y, typ, x1, x2 in events: + q, cur = 0, -1 + for ax1, ax2 in active: + q, cur = q + max(0, ax2 - max(cur, ax1)), max(cur, ax2) + + res, cur_y = res + q * (y - cur_y), y + (active.remove, active.add)[typ is OPEN]((x1, x2)) + + return res % (10**9 + 7) diff --git a/tests/501-1000/850. rectangle-area-ii/sol.py2 b/tests/501-1000/850. rectangle-area-ii/sol.py2 new file mode 100644 index 00000000..c3c0766d --- /dev/null +++ b/tests/501-1000/850. rectangle-area-ii/sol.py2 @@ -0,0 +1,33 @@ +class Solution(object): + def rectangleArea(self, rectangles): + """ + :type rectangles: List[List[int]] + :rtype: int + """ + OPEN, CLOSE = 0, 1 + events = [] + for x1, y1, x2, y2 in rectangles: + events.append((y1, OPEN, x1, x2)) + events.append((y2, CLOSE, x1, x2)) + events.sort() + + res = 0 + cur_y = events[0][0] + active = [] + + for y, typ, x1, x2 in events: + q = 0 + cur = -1 + for ax1, ax2 in sorted(active): + q += max(0, ax2 - max(cur, ax1)) + cur = max(cur, ax2) + + res += q * (y - cur_y) + cur_y = y + + if typ == OPEN: + active.append((x1, x2)) + else: + active.remove((x1, x2)) + + return res % (10**9 + 7) diff --git a/tests/501-1000/850. rectangle-area-ii/sol.rb b/tests/501-1000/850. rectangle-area-ii/sol.rb new file mode 100644 index 00000000..7ef41801 --- /dev/null +++ b/tests/501-1000/850. rectangle-area-ii/sol.rb @@ -0,0 +1,37 @@ +# @param {Integer[][]} rectangles +# @return {Integer} +def rectangle_area(rectangles) + open = 0 + close = 1 + events = [] + rectangles.each do |x1, y1, x2, y2| + events << [y1, open, x1, x2] + events << [y2, close, x1, x2] + end + events.sort! + + res = 0 + cur_y = events[0][0] + active = [] + + events.each do |y, typ, x1, x2| + q = 0 + cur = -1 + active.sort.each do |ax1, ax2| + q += [0, ax2 - [cur, ax1].max].max + cur = [cur, ax2].max + end + + res += q * (y - cur_y) + cur_y = y + + if typ == open + active << [x1, x2] + else + index = active.index([x1, x2]) + active.delete_at(index) if index + end + end + + res % (10**9 + 7) +end diff --git a/tests/501-1000/850. rectangle-area-ii/sol.rs b/tests/501-1000/850. rectangle-area-ii/sol.rs new file mode 100644 index 00000000..6483cd55 --- /dev/null +++ b/tests/501-1000/850. rectangle-area-ii/sol.rs @@ -0,0 +1,42 @@ +impl Solution { + pub fn rectangle_area(rectangles: Vec>) -> i32 { + const MOD: i64 = 1_000_000_007; + const OPEN: i32 = 0; + const CLOSE: i32 = 1; + + let mut events: Vec<(i32, i32, i32, i32)> = Vec::new(); + for r in &rectangles { + let (x1, y1, x2, y2) = (r[0], r[1], r[2], r[3]); + events.push((y1, OPEN, x1, x2)); + events.push((y2, CLOSE, x1, x2)); + } + events.sort_by(|a, b| a.0.cmp(&b.0)); + + let mut res: i64 = 0; + let mut cur_y = events[0].0; + let mut active: Vec<(i32, i32)> = Vec::new(); + + for &(y, typ, x1, x2) in &events { + let mut q: i64 = 0; + let mut cur = -1; + active.sort_by(|a, b| a.0.cmp(&b.0)); + for &(ax1, ax2) in &active { + q += std::cmp::max(0, ax2 - std::cmp::max(cur, ax1)) as i64; + cur = std::cmp::max(cur, ax2); + } + + res = (res + q * (y - cur_y) as i64) % MOD; + cur_y = y; + + if typ == OPEN { + active.push((x1, x2)); + } else { + if let Some(pos) = active.iter().position(|&(a, b)| a == x1 && b == x2) { + active.remove(pos); + } + } + } + + res as i32 + } +} diff --git a/tests/501-1000/850. rectangle-area-ii/sol.swift b/tests/501-1000/850. rectangle-area-ii/sol.swift new file mode 100644 index 00000000..cbd0ceb8 --- /dev/null +++ b/tests/501-1000/850. rectangle-area-ii/sol.swift @@ -0,0 +1,44 @@ +class Solution { + func rectangleArea(_ rectangles: [[Int]]) -> Int { + let OPEN = 0 + let CLOSE = 1 + let MOD = 1000000007 + + var events = [(Int, Int, Int, Int)]() + for r in rectangles { + let x1 = r[0], y1 = r[1], x2 = r[2], y2 = r[3] + events.append((y1, OPEN, x1, x2)) + events.append((y2, CLOSE, x1, x2)) + } + events.sort { $0.0 < $1.0 } + + var res = 0 + var curY = events[0].0 + var active = [(Int, Int)]() + + for e in events { + let y = e.0, typ = e.1, x1 = e.2, x2 = e.3 + + var q = 0 + var cur = -1 + active.sort { $0.0 < $1.0 } + for seg in active { + q += max(0, seg.1 - max(cur, seg.0)) + cur = max(cur, seg.1) + } + + res = (res + q * (y - curY)) % MOD + curY = y + + if typ == OPEN { + active.append((x1, x2)) + } else { + if let index = active.firstIndex(where: { $0.0 == x1 && $0.1 == x2 }) { + active.remove(at: index) + } + } + } + + return res + } +} diff --git a/tests/501-1000/850. rectangle-area-ii/sol.ts b/tests/501-1000/850. rectangle-area-ii/sol.ts new file mode 100644 index 00000000..a55392e5 --- /dev/null +++ b/tests/501-1000/850. rectangle-area-ii/sol.ts @@ -0,0 +1,38 @@ +function rectangleArea(rectangles: number[][]): number { + const OPEN = 0; + const CLOSE = 1; + const MOD = 1000000007n; + + const events: [number, number, number, number][] = []; + for (const [x1, y1, x2, y2] of rectangles) { + events.push([y1, OPEN, x1, x2]); + events.push([y2, CLOSE, x1, x2]); + } + events.sort((a, b) => a[0] - b[0]); + + let res = 0n; + let curY = events[0][0]; + const active: [number, number][] = []; + + for (const [y, typ, x1, x2] of events) { + let q = 0n; + let cur = -1; + active.sort((a, b) => a[0] - b[0]); + for (const [ax1, ax2] of active) { + q += BigInt(Math.max(0, ax2 - Math.max(cur, ax1))); + cur = Math.max(cur, ax2); + } + + res = (res + q * BigInt(y - curY)) % MOD; + curY = y; + + if (typ === OPEN) { + active.push([x1, x2]); + } else { + const idx = active.findIndex(([a, b]) => a === x1 && b === x2); + if (idx !== -1) active.splice(idx, 1); + } + } + + return Number(res); +} diff --git a/tests/501-1000/851. loud-and-rich/manifest.yaml b/tests/501-1000/851. loud-and-rich/manifest.yaml new file mode 100644 index 00000000..b3d96b9f --- /dev/null +++ b/tests/501-1000/851. loud-and-rich/manifest.yaml @@ -0,0 +1,356 @@ +entry: + id: 851 + title: loud-and-rich + params: + richer: + type: array + items: + type: array + items: + type: int + quiet: + type: array + items: + type: int + call: + cpp: Solution().loudAndRich({richer}, {quiet}) + rust: Solution::loud_and_rich({richer}, {quiet}) + python3: Solution().loudAndRich({richer}, {quiet}) + python2: Solution().loudAndRich({richer}, {quiet}) + ruby: loud_and_rich({richer}, {quiet}) + java: new Solution().loudAndRich({richer}, {quiet}) + csharp: new Solution().LoudAndRich({richer}, {quiet}) + kotlin: Solution().loudAndRich({richer}, {quiet}) + go: loudAndRich({richer}, {quiet}) + dart: Solution().loudAndRich({richer}, {quiet}) + swift: Solution().loudAndRich({richer}, {quiet}) + typescript: loudAndRich({richer}, {quiet}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().ok({result}) + checker: | + class Checker: + def ok(self, result): + return True +seed: 851 +tests: + - name: example-one + in: + richer: + - [1, 0] + - [2, 1] + - [3, 1] + - [3, 7] + - [4, 3] + - [5, 3] + - [6, 3] + quiet: [3, 2, 5, 4, 6, 1, 7, 0] + out: [5, 5, 2, 5, 4, 5, 6, 7] + - name: example-two + in: + richer: [] + quiet: [0] + out: [0] + - name: two-node-chain + in: + richer: + - [1, 0] + quiet: [5, 3] + out: [1, 1] + - name: three-node-chain + in: + richer: + - [1, 0] + - [2, 1] + quiet: [10, 7, 1] + out: [2, 2, 2] + - name: star-to-root + in: + richer: + - [1, 0] + - [2, 0] + - [3, 0] + quiet: [3, 2, 1, 0] + out: [3, 1, 2, 3] + - name: quiet-root + in: + richer: + - [1, 0] + - [2, 1] + - [3, 2] + quiet: [0, 1, 2, 3] + out: [0, 1, 2, 3] + - name: reverse-quiet + in: + richer: + - [1, 0] + - [2, 0] + - [3, 1] + quiet: [9, 6, 8, 1] + out: [3, 3, 2, 3] + - name: disconnected-pairs + in: + richer: + - [1, 0] + - [3, 2] + quiet: [4, 1, 3, 0] + out: [1, 1, 3, 3] + - name: diamond + in: + richer: + - [1, 0] + - [2, 0] + - [3, 1] + - [3, 2] + quiet: [8, 4, 2, 1] + out: [3, 3, 3, 3] + - name: leaf-minimum + in: + richer: + - [1, 0] + - [2, 0] + - [3, 1] + - [4, 1] + quiet: [9, 7, 8, 6, 5] + out: [4, 4, 2, 3, 4] + - name: chain-five + in: + richer: + - [1, 0] + - [2, 1] + - [3, 2] + - [4, 3] + quiet: [4, 3, 2, 1, 0] + out: [4, 4, 4, 4, 4] + - name: branching + in: + richer: + - [2, 0] + - [2, 1] + - [3, 1] + - [4, 2] + quiet: [10, 9, 8, 7, 6] + out: [4, 4, 4, 3, 4] + - name: isolated-four + in: + richer: [] + quiet: [3, 1, 4, 2] + out: [0, 1, 2, 3] + - name: fan-in + in: + richer: + - [4, 0] + - [4, 1] + - [4, 2] + - [4, 3] + quiet: [9, 8, 7, 6, 5] + out: [4, 4, 4, 4, 4] + - name: fan-out + in: + richer: + - [1, 4] + - [2, 4] + - [3, 4] + - [0, 4] + quiet: [0, 1, 2, 3, 4] + out: [0, 1, 2, 3, 0] + - name: mixed-branch + in: + richer: + - [1, 0] + - [2, 0] + - [3, 1] + - [4, 1] + - [5, 2] + quiet: [6, 5, 4, 3, 2, 1] + out: [5, 4, 5, 3, 4, 5] + - name: one-sink + in: + richer: + - [1, 0] + - [2, 0] + - [2, 1] + quiet: [7, 2, 1] + out: [2, 2, 2] + - name: zigzag + in: + richer: + - [1, 0] + - [2, 1] + - [3, 1] + - [4, 2] + - [5, 2] + quiet: [9, 8, 7, 6, 5, 4] + out: [5, 5, 5, 3, 4, 5] + - name: duplicate-depths + in: + richer: + - [1, 0] + - [2, 0] + - [3, 1] + - [4, 2] + - [5, 2] + quiet: [10, 9, 8, 7, 6, 5] + out: [5, 3, 5, 3, 4, 5] + - name: long-chain-seven + in: + richer: + - [1, 0] + - [2, 1] + - [3, 2] + - [4, 3] + - [5, 4] + - [6, 5] + quiet: [6, 5, 4, 3, 2, 1, 0] + out: [6, 6, 6, 6, 6, 6, 6] + - name: long-chain-reverse + in: + richer: + - [1, 0] + - [2, 1] + - [3, 2] + - [4, 3] + - [5, 4] + - [6, 5] + quiet: [0, 1, 2, 3, 4, 5, 6] + out: [0, 1, 2, 3, 4, 5, 6] + - name: tie-break-by-quiet + in: + richer: + - [1, 0] + - [2, 0] + - [3, 1] + - [4, 2] + quiet: [9, 4, 3, 2, 1] + out: [4, 3, 4, 3, 4] + - name: root-wins + in: + richer: + - [1, 0] + - [2, 1] + quiet: [0, 10, 20] + out: [0, 1, 2] + - name: leaf-wins + in: + richer: + - [1, 0] + - [2, 0] + - [3, 2] + quiet: [9, 8, 1, 0] + out: [3, 1, 3, 3] + - name: branching-two-minima + in: + richer: + - [2, 0] + - [3, 0] + - [4, 2] + - [5, 3] + quiet: [9, 8, 7, 6, 5, 4] + out: [5, 1, 4, 5, 4, 5] + - name: flat-six + in: + richer: [] + quiet: [5, 4, 3, 2, 1, 0] + out: [0, 1, 2, 3, 4, 5] + - name: wide-dag + in: + richer: + - [1, 0] + - [2, 0] + - [3, 1] + - [3, 2] + - [4, 2] + - [5, 3] + quiet: [12, 11, 10, 9, 8, 7] + out: [5, 5, 5, 5, 4, 5] + - name: criss-cross + in: + richer: + - [1, 0] + - [2, 0] + - [3, 1] + - [3, 2] + - [4, 1] + - [5, 4] + quiet: [15, 14, 13, 12, 11, 10] + out: [5, 5, 3, 3, 5, 5] + - name: shallow-fork + in: + richer: + - [1, 0] + - [2, 0] + quiet: [2, 0, 1] + out: [1, 1, 2] + - name: deep-left-branch + in: + richer: + - [1, 0] + - [2, 1] + - [3, 2] + - [4, 2] + quiet: [5, 4, 3, 2, 1] + out: [4, 4, 4, 3, 4] + - name: deep-right-branch + in: + richer: + - [1, 0] + - [2, 1] + - [3, 1] + - [4, 3] + quiet: [9, 8, 7, 6, 5] + out: [4, 4, 2, 4, 4] + - name: split-and-join + in: + richer: + - [1, 0] + - [2, 0] + - [3, 1] + - [4, 1] + - [5, 2] + - [5, 4] + quiet: [10, 9, 8, 7, 6, 5] + out: [5, 5, 5, 3, 5, 5] + - name: two-components + in: + richer: + - [1, 0] + - [2, 1] + - [4, 3] + - [5, 4] + quiet: [6, 5, 4, 3, 2, 1] + out: [2, 2, 2, 5, 5, 5] + - name: six-node-mixed + in: + richer: + - [1, 0] + - [2, 0] + - [3, 1] + - [4, 1] + - [5, 4] + quiet: [8, 7, 6, 5, 4, 3] + out: [5, 5, 2, 3, 5, 5] + - name: root-with-three-levels + in: + richer: + - [1, 0] + - [2, 0] + - [3, 1] + - [4, 1] + - [5, 2] + - [6, 2] + quiet: [13, 12, 11, 10, 9, 8, 7] + out: [6, 4, 6, 3, 4, 5, 6] + - name: max-index-quietest + in: + richer: + - [4, 3] + - [3, 2] + - [2, 1] + - [1, 0] + quiet: [9, 8, 7, 6, 0] + out: [4, 4, 4, 4, 4] diff --git a/tests/501-1000/851. loud-and-rich/sol.cpp b/tests/501-1000/851. loud-and-rich/sol.cpp new file mode 100644 index 00000000..767502b2 --- /dev/null +++ b/tests/501-1000/851. loud-and-rich/sol.cpp @@ -0,0 +1,29 @@ +class Solution { +public: + vector loudAndRich(vector>& richer, vector& quiet) { + int n = quiet.size(); + vector> graph(n); + for (auto& pair : richer) { + graph[pair[1]].push_back(pair[0]); + } + + vector answer(n, -1); + + function dfs = [&](int i) -> int { + if (answer[i] != -1) return answer[i]; + answer[i] = i; + for (int nei : graph[i]) { + int item = dfs(nei); + if (quiet[item] < quiet[answer[i]]) { + answer[i] = item; + } + } + return answer[i]; + }; + + for (int i = 0; i < n; i++) { + dfs(i); + } + return answer; + } +}; diff --git a/tests/501-1000/851. loud-and-rich/sol.cs b/tests/501-1000/851. loud-and-rich/sol.cs new file mode 100644 index 00000000..abc77682 --- /dev/null +++ b/tests/501-1000/851. loud-and-rich/sol.cs @@ -0,0 +1,32 @@ +public class Solution { + public int[] LoudAndRich(int[][] richer, int[] quiet) { + int n = quiet.Length; + List[] graph = new List[n]; + for (int i = 0; i < n; i++) { + graph[i] = new List(); + } + foreach (var pair in richer) { + graph[pair[1]].Add(pair[0]); + } + + int[] answer = new int[n]; + Array.Fill(answer, -1); + + int Dfs(int i) { + if (answer[i] != -1) return answer[i]; + answer[i] = i; + foreach (int nei in graph[i]) { + int item = Dfs(nei); + if (quiet[item] < quiet[answer[i]]) { + answer[i] = item; + } + } + return answer[i]; + } + + for (int i = 0; i < n; i++) { + Dfs(i); + } + return answer; + } +} diff --git a/tests/501-1000/851. loud-and-rich/sol.dart b/tests/501-1000/851. loud-and-rich/sol.dart new file mode 100644 index 00000000..55d2c4fc --- /dev/null +++ b/tests/501-1000/851. loud-and-rich/sol.dart @@ -0,0 +1,28 @@ +class Solution { + List loudAndRich(List> richer, List quiet) { + int n = quiet.length; + List> graph = List.generate(n, (_) => []); + for (var pair in richer) { + graph[pair[1]].add(pair[0]); + } + + List answer = List.filled(n, -1); + + int dfs(int i) { + if (answer[i] != -1) return answer[i]; + answer[i] = i; + for (int nei in graph[i]) { + int item = dfs(nei); + if (quiet[item] < quiet[answer[i]]) { + answer[i] = item; + } + } + return answer[i]; + } + + for (int i = 0; i < n; i++) { + dfs(i); + } + return answer; + } +} diff --git a/tests/501-1000/851. loud-and-rich/sol.go b/tests/501-1000/851. loud-and-rich/sol.go new file mode 100644 index 00000000..c05e10e9 --- /dev/null +++ b/tests/501-1000/851. loud-and-rich/sol.go @@ -0,0 +1,32 @@ +func loudAndRich(richer [][]int, quiet []int) []int { + n := len(quiet) + graph := make([][]int, n) + for _, pair := range richer { + graph[pair[1]] = append(graph[pair[1]], pair[0]) + } + + answer := make([]int, n) + for i := range answer { + answer[i] = -1 + } + + var dfs func(int) int + dfs = func(i int) int { + if answer[i] != -1 { + return answer[i] + } + answer[i] = i + for _, nei := range graph[i] { + item := dfs(nei) + if quiet[item] < quiet[answer[i]] { + answer[i] = item + } + } + return answer[i] + } + + for i := 0; i < n; i++ { + dfs(i) + } + return answer +} diff --git a/tests/501-1000/851. loud-and-rich/sol.java b/tests/501-1000/851. loud-and-rich/sol.java new file mode 100644 index 00000000..59ecff08 --- /dev/null +++ b/tests/501-1000/851. loud-and-rich/sol.java @@ -0,0 +1,22 @@ +class Solution { + public int[] loudAndRich(int[][] richer, int[] quiet) { + int n = quiet.length; + int[] answer = new int[n]; + for (int i = 0; i < n; i++) { + answer[i] = i; + } + boolean changed = true; + while (changed) { + changed = false; + for (int[] pair : richer) { + int richerPerson = pair[0]; + int poorerPerson = pair[1]; + if (quiet[answer[richerPerson]] < quiet[answer[poorerPerson]]) { + answer[poorerPerson] = answer[richerPerson]; + changed = true; + } + } + } + return answer; + } +} diff --git a/tests/501-1000/851. loud-and-rich/sol.kt b/tests/501-1000/851. loud-and-rich/sol.kt new file mode 100644 index 00000000..5a0e3788 --- /dev/null +++ b/tests/501-1000/851. loud-and-rich/sol.kt @@ -0,0 +1,28 @@ +class Solution { + fun loudAndRich(richer: Array, quiet: IntArray): IntArray { + val n = quiet.size + val graph = Array(n) { mutableListOf() } + for (pair in richer) { + graph[pair[1]].add(pair[0]) + } + + val answer = IntArray(n) { -1 } + + fun dfs(i: Int): Int { + if (answer[i] != -1) return answer[i] + answer[i] = i + for (nei in graph[i]) { + val item = dfs(nei) + if (quiet[item] < quiet[answer[i]]) { + answer[i] = item + } + } + return answer[i] + } + + for (i in 0 until n) { + dfs(i) + } + return answer + } +} diff --git a/tests/501-1000/851. loud-and-rich/sol.py b/tests/501-1000/851. loud-and-rich/sol.py new file mode 100644 index 00000000..9b0d8638 --- /dev/null +++ b/tests/501-1000/851. loud-and-rich/sol.py @@ -0,0 +1,29 @@ +class Solution: + def loudAndRich(self, richer: List[List[int]], quiet: List[int]) -> List[int]: + # build the graph + graph = defaultdict(list) + # include itself and richer person + for a, b in richer: + graph[b].append(a) + n = len(quiet) + answer = [-1] * n + + def dfs(i): + if answer[i] != -1: + return answer[i] + # assign with self first + answer[i] = i + + for nei in graph[i]: + item = dfs(nei) + # check neighbor's quietness + if quiet[item] < quiet[answer[i]]: + # index needs to be stored + answer[i] = item + return answer[i] + + # lets process every node + for i in range(n): + val = dfs(i) + + return answer diff --git a/tests/501-1000/851. loud-and-rich/sol.py2 b/tests/501-1000/851. loud-and-rich/sol.py2 new file mode 100644 index 00000000..cdd71024 --- /dev/null +++ b/tests/501-1000/851. loud-and-rich/sol.py2 @@ -0,0 +1,30 @@ +class Solution(object): + def loudAndRich(self, richer, quiet): + """ + :type richer: List[List[int]] + :type quiet: List[int] + :rtype: List[int] + """ + from collections import defaultdict + + graph = defaultdict(list) + for a, b in richer: + graph[b].append(a) + + n = len(quiet) + answer = [-1] * n + + def dfs(i): + if answer[i] != -1: + return answer[i] + answer[i] = i + for nei in graph[i]: + item = dfs(nei) + if quiet[item] < quiet[answer[i]]: + answer[i] = item + return answer[i] + + for i in range(n): + dfs(i) + + return answer diff --git a/tests/501-1000/851. loud-and-rich/sol.rb b/tests/501-1000/851. loud-and-rich/sol.rb new file mode 100644 index 00000000..e7ce4bad --- /dev/null +++ b/tests/501-1000/851. loud-and-rich/sol.rb @@ -0,0 +1,27 @@ +# @param {Integer[][]} richer +# @param {Integer[]} quiet +# @return {Integer[]} +def loud_and_rich(richer, quiet) + graph = Hash.new { |h, k| h[k] = [] } + richer.each do |a, b| + graph[b] << a + end + + n = quiet.length + answer = Array.new(n, -1) + + dfs = lambda do |i| + return answer[i] if answer[i] != -1 + answer[i] = i + (graph[i] || []).each do |nei| + item = dfs.call(nei) + if quiet[item] < quiet[answer[i]] + answer[i] = item + end + end + answer[i] + end + + n.times { |i| dfs.call(i) } + answer +end diff --git a/tests/501-1000/851. loud-and-rich/sol.rs b/tests/501-1000/851. loud-and-rich/sol.rs new file mode 100644 index 00000000..93593dfb --- /dev/null +++ b/tests/501-1000/851. loud-and-rich/sol.rs @@ -0,0 +1,30 @@ +impl Solution { + pub fn loud_and_rich(richer: Vec>, quiet: Vec) -> Vec { + let n = quiet.len(); + let mut graph = vec![vec![]; n]; + for pair in &richer { + graph[pair[1] as usize].push(pair[0] as usize); + } + + let mut answer = vec![-1; n]; + + fn dfs(i: usize, graph: &Vec>, quiet: &Vec, answer: &mut Vec) -> usize { + if answer[i] != -1 { + return answer[i] as usize; + } + answer[i] = i as i32; + for &nei in &graph[i] { + let item = dfs(nei, graph, quiet, answer); + if quiet[item] < quiet[answer[i] as usize] { + answer[i] = item as i32; + } + } + answer[i] as usize + } + + for i in 0..n { + dfs(i, &graph, &quiet, &mut answer); + } + answer + } +} diff --git a/tests/501-1000/851. loud-and-rich/sol.swift b/tests/501-1000/851. loud-and-rich/sol.swift new file mode 100644 index 00000000..aaf77c06 --- /dev/null +++ b/tests/501-1000/851. loud-and-rich/sol.swift @@ -0,0 +1,30 @@ +class Solution { + func loudAndRich(_ richer: [[Int]], _ quiet: [Int]) -> [Int] { + let n = quiet.count + var graph = [[Int]](repeating: [], count: n) + for pair in richer { + graph[pair[1]].append(pair[0]) + } + + var answer = [Int](repeating: -1, count: n) + + func dfs(_ i: Int) -> Int { + if answer[i] != -1 { + return answer[i] + } + answer[i] = i + for nei in graph[i] { + let item = dfs(nei) + if quiet[item] < quiet[answer[i]] { + answer[i] = item + } + } + return answer[i] + } + + for i in 0.. []); + for (const [a, b] of richer) { + graph[b].push(a); + } + + const answer: number[] = new Array(n).fill(-1); + + const dfs = (i: number): number => { + if (answer[i] !== -1) return answer[i]; + answer[i] = i; + for (const nei of graph[i]) { + const item = dfs(nei); + if (quiet[item] < quiet[answer[i]]) { + answer[i] = item; + } + } + return answer[i]; + }; + + for (let i = 0; i < n; i++) { + dfs(i); + } + return answer; +} diff --git a/tests/501-1000/852. peak-index-in-a-mountain-array/manifest.yaml b/tests/501-1000/852. peak-index-in-a-mountain-array/manifest.yaml new file mode 100644 index 00000000..51396346 --- /dev/null +++ b/tests/501-1000/852. peak-index-in-a-mountain-array/manifest.yaml @@ -0,0 +1,196 @@ +entry: + id: 852 + title: peak-index-in-a-mountain-array + params: + arr: + type: array + items: + type: int + call: + cpp: Solution().peakIndexInMountainArray({arr}) + rust: Solution::peak_index_in_mountain_array({arr}) + python3: Solution().peakIndexInMountainArray({arr}) + python2: Solution().peakIndexInMountainArray({arr}) + ruby: peak_index_in_mountain_array({arr}) + java: new Solution().peakIndexInMountainArray({arr}) + csharp: new Solution().PeakIndexInMountainArray({arr}) + kotlin: Solution().peakIndexInMountainArray({arr}) + go: peakIndexInMountainArray({arr}) + dart: Solution().peakIndexInMountainArray({arr}) + swift: Solution().peakIndexInMountainArray({arr}) + typescript: peakIndexInMountainArray({arr}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().peakIndexInMountainArray(arr, {result})" + checker: | + class Checker: + def peakIndexInMountainArray(self, arr, result): + if not isinstance(result, int): + return False + l, r = 0, len(arr) - 1 + while l < r: + mid = (l + r) // 2 + if arr[mid] < arr[mid + 1]: + l = mid + 1 + else: + r = mid + return result == l +seed: 852 +tests: + - name: ex1 + in: + arr: [0, 1, 0] + out: 1 + - name: ex2 + in: + arr: [0, 2, 1, 0] + out: 1 + - name: ex3 + in: + arr: [0, 10, 5, 2] + out: 1 + - name: short_peak_left + in: + arr: [1, 3, 2] + out: 1 + - name: short_peak_middle + in: + arr: [2, 5, 3] + out: 1 + - name: short_peak_right + in: + arr: [0, 1, 2, 1] + out: 2 + - name: small_peak_4 + in: + arr: [1, 4, 2] + out: 1 + - name: small_peak_5 + in: + arr: [0, 3, 6, 4, 1] + out: 2 + - name: small_peak_6 + in: + arr: [1, 2, 3, 4, 5, 3, 1] + out: 4 + - name: small_peak_7 + in: + arr: [0, 5, 9, 12, 8, 4, 1] + out: 3 + - name: small_peak_8 + in: + arr: [3, 8, 12, 15, 14, 9, 4, 1] + out: 3 + - name: small_peak_9 + in: + arr: [1, 4, 7, 10, 9, 6, 2] + out: 3 + - name: small_peak_10 + in: + arr: [0, 2, 5, 3, 1] + out: 2 + - name: small_peak_11 + in: + arr: [2, 5, 9, 11, 8, 4, 1] + out: 3 + - name: small_peak_12 + in: + arr: [0, 3, 6, 9, 8, 4, 1] + out: 3 + - name: small_peak_13 + in: + arr: [1, 5, 9, 13, 12, 10, 2] + out: 3 + - name: small_peak_14 + in: + arr: [0, 4, 8, 12, 11, 7, 3] + out: 3 + - name: small_peak_15 + in: + arr: [2, 6, 10, 14, 13, 8, 4, 1] + out: 3 + - name: small_peak_16 + in: + arr: [1, 4, 9, 15, 14, 12, 5] + out: 3 + - name: small_peak_17 + in: + arr: [0, 2, 4, 7, 11, 10, 6, 1] + out: 4 + - name: small_peak_18 + in: + arr: [0, 1, 3, 6, 10, 9, 5, 2] + out: 4 + - name: small_peak_19 + in: + arr: [5, 8, 12, 17, 16, 11, 7, 3] + out: 3 + - name: small_peak_20 + in: + arr: [0, 3, 7, 12, 18, 17, 9, 4, 1] + out: 4 + - name: small_peak_21 + in: + arr: [1, 4, 8, 13, 19, 18, 15, 6] + out: 4 + - name: small_peak_22 + in: + arr: [2, 5, 9, 14, 20, 19, 11, 4] + out: 4 + - name: small_peak_23 + in: + arr: [0, 2, 5, 9, 14, 18, 17, 13, 7] + out: 5 + - name: small_peak_24 + in: + arr: [1, 3, 6, 10, 15, 21, 20, 12, 5] + out: 5 + - name: small_peak_25 + in: + arr: [0, 4, 9, 15, 22, 21, 16, 8, 1] + out: 4 + - name: small_peak_26 + in: + arr: [3, 7, 12, 18, 25, 24, 17, 9, 2] + out: 4 + - name: small_peak_27 + in: + arr: [1, 2, 5, 11, 18, 26, 25, 14, 6] + out: 5 + - name: small_peak_28 + in: + arr: [0, 6, 13, 21, 30, 29, 20, 10, 3] + out: 4 + - name: small_peak_29 + in: + arr: [1, 5, 10, 16, 23, 31, 30, 18, 9] + out: 5 + - name: small_peak_30 + in: + arr: [2, 7, 13, 20, 28, 37, 36, 24, 12] + out: 5 + - name: small_peak_31 + in: + arr: [0, 1, 4, 8, 15, 23, 32, 31, 19, 7] + out: 6 + - name: small_peak_32 + in: + arr: [0, 2, 6, 11, 17, 24, 33, 32, 18, 5] + out: 6 + - name: small_peak_33 + in: + arr: [1, 4, 9, 15, 22, 30, 39, 38, 25, 11] + out: 6 + - name: small_peak_34 + in: + arr: [1, 6, 12, 19, 27, 36, 35, 21, 8] + out: 5 + - name: small_peak_35 + in: + arr: [0, 3, 8, 14, 21, 29, 38, 37, 24, 10] + out: 6 diff --git a/tests/501-1000/852. peak-index-in-a-mountain-array/sol.cpp b/tests/501-1000/852. peak-index-in-a-mountain-array/sol.cpp new file mode 100644 index 00000000..32c1dfbc --- /dev/null +++ b/tests/501-1000/852. peak-index-in-a-mountain-array/sol.cpp @@ -0,0 +1,15 @@ +class Solution { +public: + int peakIndexInMountainArray(vector& arr) { + int l = 0, r = arr.size() - 1; + while (l < r) { + int mid = (l + r) / 2; + if (arr[mid] < arr[mid + 1]) { + l = mid + 1; + } else { + r = mid; + } + } + return l; + } +}; diff --git a/tests/501-1000/852. peak-index-in-a-mountain-array/sol.cs b/tests/501-1000/852. peak-index-in-a-mountain-array/sol.cs new file mode 100644 index 00000000..7f299d59 --- /dev/null +++ b/tests/501-1000/852. peak-index-in-a-mountain-array/sol.cs @@ -0,0 +1,14 @@ +public class Solution { + public int PeakIndexInMountainArray(int[] arr) { + int l = 0, r = arr.Length - 1; + while (l < r) { + int mid = (l + r) / 2; + if (arr[mid] < arr[mid + 1]) { + l = mid + 1; + } else { + r = mid; + } + } + return l; + } +} diff --git a/tests/501-1000/852. peak-index-in-a-mountain-array/sol.dart b/tests/501-1000/852. peak-index-in-a-mountain-array/sol.dart new file mode 100644 index 00000000..0dac7044 --- /dev/null +++ b/tests/501-1000/852. peak-index-in-a-mountain-array/sol.dart @@ -0,0 +1,14 @@ +class Solution { + int peakIndexInMountainArray(List arr) { + int l = 0, r = arr.length - 1; + while (l < r) { + int mid = (l + r) ~/ 2; + if (arr[mid] < arr[mid + 1]) { + l = mid + 1; + } else { + r = mid; + } + } + return l; + } +} diff --git a/tests/501-1000/852. peak-index-in-a-mountain-array/sol.go b/tests/501-1000/852. peak-index-in-a-mountain-array/sol.go new file mode 100644 index 00000000..ad6b8b75 --- /dev/null +++ b/tests/501-1000/852. peak-index-in-a-mountain-array/sol.go @@ -0,0 +1,12 @@ +func peakIndexInMountainArray(arr []int) int { + l, r := 0, len(arr)-1 + for l < r { + mid := (l + r) / 2 + if arr[mid] < arr[mid+1] { + l = mid + 1 + } else { + r = mid + } + } + return l +} diff --git a/tests/501-1000/852. peak-index-in-a-mountain-array/sol.java b/tests/501-1000/852. peak-index-in-a-mountain-array/sol.java new file mode 100644 index 00000000..3d3c7e22 --- /dev/null +++ b/tests/501-1000/852. peak-index-in-a-mountain-array/sol.java @@ -0,0 +1,14 @@ +class Solution { + public int peakIndexInMountainArray(int[] arr) { + int l = 0, r = arr.length - 1; + while (l < r) { + int mid = (l + r) / 2; + if (arr[mid] < arr[mid + 1]) { + l = mid + 1; + } else { + r = mid; + } + } + return l; + } +} diff --git a/tests/501-1000/852. peak-index-in-a-mountain-array/sol.kt b/tests/501-1000/852. peak-index-in-a-mountain-array/sol.kt new file mode 100644 index 00000000..6d8a71cd --- /dev/null +++ b/tests/501-1000/852. peak-index-in-a-mountain-array/sol.kt @@ -0,0 +1,15 @@ +class Solution { + fun peakIndexInMountainArray(arr: IntArray): Int { + var l = 0 + var r = arr.size - 1 + while (l < r) { + val mid = (l + r) / 2 + if (arr[mid] < arr[mid + 1]) { + l = mid + 1 + } else { + r = mid + } + } + return l + } +} diff --git a/tests/501-1000/852. peak-index-in-a-mountain-array/sol.py b/tests/501-1000/852. peak-index-in-a-mountain-array/sol.py new file mode 100644 index 00000000..7114c1d8 --- /dev/null +++ b/tests/501-1000/852. peak-index-in-a-mountain-array/sol.py @@ -0,0 +1,13 @@ +class Solution: + def peakIndexInMountainArray(self, arr: List[int]) -> int: + l, r = 0, len(arr) - 1 + + while l < r: + mid = (l + r) // 2 + + if arr[mid] < arr[mid + 1]: + l = mid + 1 + else: + r = mid + + return l diff --git a/tests/501-1000/852. peak-index-in-a-mountain-array/sol.py2 b/tests/501-1000/852. peak-index-in-a-mountain-array/sol.py2 new file mode 100644 index 00000000..a6cc09d1 --- /dev/null +++ b/tests/501-1000/852. peak-index-in-a-mountain-array/sol.py2 @@ -0,0 +1,14 @@ +class Solution(object): + def peakIndexInMountainArray(self, arr): + """ + :type arr: List[int] + :rtype: int + """ + l, r = 0, len(arr) - 1 + while l < r: + mid = (l + r) // 2 + if arr[mid] < arr[mid + 1]: + l = mid + 1 + else: + r = mid + return l diff --git a/tests/501-1000/852. peak-index-in-a-mountain-array/sol.rb b/tests/501-1000/852. peak-index-in-a-mountain-array/sol.rb new file mode 100644 index 00000000..6d6a3190 --- /dev/null +++ b/tests/501-1000/852. peak-index-in-a-mountain-array/sol.rb @@ -0,0 +1,15 @@ +# @param {Integer[]} arr +# @return {Integer} +def peak_index_in_mountain_array(arr) + l = 0 + r = arr.length - 1 + while l < r + mid = (l + r) / 2 + if arr[mid] < arr[mid + 1] + l = mid + 1 + else + r = mid + end + end + l +end diff --git a/tests/501-1000/852. peak-index-in-a-mountain-array/sol.rs b/tests/501-1000/852. peak-index-in-a-mountain-array/sol.rs new file mode 100644 index 00000000..f0b7a5ee --- /dev/null +++ b/tests/501-1000/852. peak-index-in-a-mountain-array/sol.rs @@ -0,0 +1,15 @@ +impl Solution { + pub fn peak_index_in_mountain_array(arr: Vec) -> i32 { + let mut l = 0; + let mut r = arr.len() - 1; + while l < r { + let mid = (l + r) / 2; + if arr[mid] < arr[mid + 1] { + l = mid + 1; + } else { + r = mid; + } + } + l as i32 + } +} diff --git a/tests/501-1000/852. peak-index-in-a-mountain-array/sol.swift b/tests/501-1000/852. peak-index-in-a-mountain-array/sol.swift new file mode 100644 index 00000000..2d40593a --- /dev/null +++ b/tests/501-1000/852. peak-index-in-a-mountain-array/sol.swift @@ -0,0 +1,15 @@ +class Solution { + func peakIndexInMountainArray(_ arr: [Int]) -> Int { + var l = 0 + var r = arr.count - 1 + while l < r { + let mid = (l + r) / 2 + if arr[mid] < arr[mid + 1] { + l = mid + 1 + } else { + r = mid + } + } + return l + } +} diff --git a/tests/501-1000/852. peak-index-in-a-mountain-array/sol.ts b/tests/501-1000/852. peak-index-in-a-mountain-array/sol.ts new file mode 100644 index 00000000..2da00481 --- /dev/null +++ b/tests/501-1000/852. peak-index-in-a-mountain-array/sol.ts @@ -0,0 +1,13 @@ +function peakIndexInMountainArray(arr: number[]): number { + let l = 0, + r = arr.length - 1; + while (l < r) { + const mid = Math.floor((l + r) / 2); + if (arr[mid] < arr[mid + 1]) { + l = mid + 1; + } else { + r = mid; + } + } + return l; +} diff --git a/tests/501-1000/853. car-fleet/manifest.yaml b/tests/501-1000/853. car-fleet/manifest.yaml new file mode 100644 index 00000000..bb7f39d5 --- /dev/null +++ b/tests/501-1000/853. car-fleet/manifest.yaml @@ -0,0 +1,279 @@ +entry: + id: 853 + title: car-fleet + params: + target: + type: int + position: + type: array + items: + type: int + speed: + type: array + items: + type: int + call: + cpp: Solution().carFleet({target}, {position}, {speed}) + rust: Solution::car_fleet({target}, {position}, {speed}) + python3: Solution().carFleet({target}, {position}, {speed}) + python2: Solution().carFleet({target}, {position}, {speed}) + ruby: car_fleet({target}, {position}, {speed}) + java: new Solution().carFleet({target}, {position}, {speed}) + csharp: new Solution().CarFleet({target}, {position}, {speed}) + kotlin: Solution().carFleet({target}, {position}, {speed}) + go: carFleet({target}, {position}, {speed}) + dart: Solution().carFleet({target}, {position}, {speed}) + swift: Solution().carFleet({target}, {position}, {speed}) + typescript: carFleet({target}, {position}, {speed}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().carFleet(target, position, speed, {result})" + checker: | + class Checker: + def carFleet(self, target, position, speed, result): + if not isinstance(result, int): + return False + cars = sorted(zip(position, speed), reverse=True) + fleets = 0 + last_time = -1 + for p, s in cars: + t = (target - p) / s + if t > last_time: + fleets += 1 + last_time = t + return result == fleets +seed: 853 +tests: + - name: ex1 + in: + target: 12 + position: [10, 8, 0, 5, 3] + speed: [2, 4, 1, 1, 3] + out: 3 + - name: ex2 + in: + target: 10 + position: [3] + speed: [3] + out: 1 + - name: ex3 + in: + target: 100 + position: [0, 2, 4] + speed: [4, 2, 1] + out: 1 + - name: two_cars_merge + in: + target: 10 + position: [6, 8] + speed: [3, 2] + out: 2 + - name: three_cars_one_fleet + in: + target: 10 + position: [0, 4, 2] + speed: [2, 1, 3] + out: 1 + - name: three_distinct + in: + target: 17 + position: [8, 12, 16] + speed: [4, 2, 1] + out: 2 + - name: chain_merge + in: + target: 20 + position: [5, 10, 15] + speed: [5, 4, 3] + out: 3 + - name: four_all_separate + in: + target: 30 + position: [0, 5, 10, 15] + speed: [1, 2, 3, 4] + out: 4 + - name: one_fleet_by_slow_front + in: + target: 30 + position: [10, 20, 25] + speed: [5, 4, 1] + out: 1 + - name: all_merge + in: + target: 50 + position: [10, 20, 30, 40] + speed: [4, 3, 2, 1] + out: 1 + - name: mixed_two + in: + target: 25 + position: [1, 3, 6, 10] + speed: [2, 1, 4, 3] + out: 2 + - name: all_one + in: + target: 40 + position: [2, 8, 14, 20] + speed: [6, 5, 4, 3] + out: 1 + - name: five_all + in: + target: 100 + position: [10, 30, 50, 70, 90] + speed: [10, 9, 8, 7, 6] + out: 5 + - name: five_separate + in: + target: 100 + position: [10, 20, 30, 40, 50] + speed: [1, 1, 1, 1, 1] + out: 5 + - name: two_fleets + in: + target: 100 + position: [20, 40, 60, 80] + speed: [2, 4, 1, 3] + out: 2 + - name: short_two + in: + target: 12 + position: [6, 4, 2] + speed: [4, 6, 2] + out: 2 + - name: small_one + in: + target: 13 + position: [0, 5, 8] + speed: [4, 2, 1] + out: 1 + - name: two_equal_times + in: + target: 100 + position: [0, 50] + speed: [1, 1] + out: 2 + - name: faster_back_catches_front + in: + target: 100 + position: [0, 50] + speed: [2, 1] + out: 1 + - name: monotone_positions + in: + target: 100 + position: [0, 1, 2, 3] + speed: [4, 3, 2, 1] + out: 1 + - name: reverse_positions + in: + target: 100 + position: [90, 80, 70, 60] + speed: [1, 2, 3, 4] + out: 1 + - name: all_equal_speeds + in: + target: 100 + position: [1, 2, 3, 4, 5] + speed: [5, 4, 3, 2, 1] + out: 1 + - name: three_fleets + in: + target: 18 + position: [3, 6, 9, 12, 15] + speed: [1, 2, 1, 2, 1] + out: 3 + - name: all_distinct_ascending + in: + target: 15 + position: [1, 4, 7, 10, 13] + speed: [1, 2, 3, 4, 5] + out: 5 + - name: same_speeds_many + in: + target: 9 + position: [0, 2, 4, 6, 8] + speed: [1, 1, 1, 1, 1] + out: 5 + - name: many_merge + in: + target: 9 + position: [0, 2, 4, 6, 8] + speed: [5, 4, 3, 2, 1] + out: 5 + - name: zigzag_one + in: + target: 50 + position: [1, 10, 20, 30, 40] + speed: [10, 1, 10, 1, 10] + out: 3 + - name: five_same + in: + target: 60 + position: [5, 15, 25, 35, 45] + speed: [2, 2, 2, 2, 2] + out: 5 + - name: slow_front_blocks + in: + target: 60 + position: [5, 10, 20, 30, 50] + speed: [6, 5, 4, 3, 1] + out: 1 + - name: increasing_speed_positions + in: + target: 30 + position: [1, 2, 3, 4, 5, 6] + speed: [1, 2, 3, 4, 5, 6] + out: 6 + - name: decreasing_speed_positions + in: + target: 30 + position: [1, 2, 3, 4, 5, 6] + speed: [6, 5, 4, 3, 2, 1] + out: 1 + - name: six_all + in: + target: 100 + position: [10, 11, 12, 13, 14, 15] + speed: [1, 2, 3, 4, 5, 6] + out: 6 + - name: six_one + in: + target: 100 + position: [10, 11, 12, 13, 14, 15] + speed: [6, 5, 4, 3, 2, 1] + out: 1 + - name: six_stacked + in: + target: 70 + position: [0, 10, 20, 30, 40, 50] + speed: [7, 6, 5, 4, 3, 2] + out: 1 + - name: six_separate + in: + target: 70 + position: [0, 10, 20, 30, 40, 50] + speed: [2, 3, 4, 5, 6, 7] + out: 6 + - name: mixed_small + in: + target: 100 + position: [1, 25, 50, 75] + speed: [24, 1, 25, 1] + out: 2 + - name: more_fleets + in: + target: 40 + position: [5, 15, 25, 35] + speed: [3, 1, 2, 4] + out: 3 + - name: clustered + in: + target: 80 + position: [2, 18, 33, 47, 60] + speed: [8, 7, 6, 5, 4] + out: 5 diff --git a/tests/501-1000/853. car-fleet/sol.cpp b/tests/501-1000/853. car-fleet/sol.cpp new file mode 100644 index 00000000..15e9b6b6 --- /dev/null +++ b/tests/501-1000/853. car-fleet/sol.cpp @@ -0,0 +1,20 @@ +class Solution { +public: + int carFleet(int target, vector& position, vector& speed) { + vector> cars; + for (int i = 0; i < position.size(); i++) { + cars.push_back({position[i], speed[i]}); + } + sort(cars.begin(), cars.end(), [](auto& a, auto& b) { + return a.first > b.first; + }); + vector stack; + for (auto& [p, s] : cars) { + double t = (double)(target - p) / s; + if (stack.empty() || t > stack.back()) { + stack.push_back(t); + } + } + return stack.size(); + } +}; diff --git a/tests/501-1000/853. car-fleet/sol.cs b/tests/501-1000/853. car-fleet/sol.cs new file mode 100644 index 00000000..91beb124 --- /dev/null +++ b/tests/501-1000/853. car-fleet/sol.cs @@ -0,0 +1,18 @@ +public class Solution { + public int CarFleet(int target, int[] position, int[] speed) { + int n = position.Length; + int[][] cars = new int[n][]; + for (int i = 0; i < n; i++) { + cars[i] = new int[] { position[i], speed[i] }; + } + Array.Sort(cars, (a, b) => b[0].CompareTo(a[0])); + List stack = new List(); + foreach (var car in cars) { + double t = (double)(target - car[0]) / car[1]; + if (stack.Count == 0 || t > stack[stack.Count - 1]) { + stack.Add(t); + } + } + return stack.Count; + } +} diff --git a/tests/501-1000/853. car-fleet/sol.dart b/tests/501-1000/853. car-fleet/sol.dart new file mode 100644 index 00000000..13678304 --- /dev/null +++ b/tests/501-1000/853. car-fleet/sol.dart @@ -0,0 +1,17 @@ +class Solution { + int carFleet(int target, List position, List speed) { + List> cars = []; + for (int i = 0; i < position.length; i++) { + cars.add([position[i], speed[i]]); + } + cars.sort((a, b) => b[0].compareTo(a[0])); + List stack = []; + for (var car in cars) { + double t = (target - car[0]) / car[1]; + if (stack.isEmpty || t > stack.last) { + stack.add(t); + } + } + return stack.length; + } +} diff --git a/tests/501-1000/853. car-fleet/sol.go b/tests/501-1000/853. car-fleet/sol.go new file mode 100644 index 00000000..b2a474aa --- /dev/null +++ b/tests/501-1000/853. car-fleet/sol.go @@ -0,0 +1,18 @@ +func carFleet(target int, position []int, speed []int) int { + n := len(position) + cars := make([][2]int, n) + for i := 0; i < n; i++ { + cars[i] = [2]int{position[i], speed[i]} + } + sort.Slice(cars, func(i, j int) bool { + return cars[i][0] > cars[j][0] + }) + stack := []float64{} + for _, car := range cars { + t := float64(target-car[0]) / float64(car[1]) + if len(stack) == 0 || t > stack[len(stack)-1] { + stack = append(stack, t) + } + } + return len(stack) +} diff --git a/tests/501-1000/853. car-fleet/sol.java b/tests/501-1000/853. car-fleet/sol.java new file mode 100644 index 00000000..22cd0342 --- /dev/null +++ b/tests/501-1000/853. car-fleet/sol.java @@ -0,0 +1,19 @@ +class Solution { + public int carFleet(int target, int[] position, int[] speed) { + int n = position.length; + int[][] cars = new int[n][2]; + for (int i = 0; i < n; i++) { + cars[i][0] = position[i]; + cars[i][1] = speed[i]; + } + Arrays.sort(cars, (a, b) -> Integer.compare(b[0], a[0])); + java.util.ArrayDeque stack = new java.util.ArrayDeque<>(); + for (int[] car : cars) { + double t = (double)(target - car[0]) / car[1]; + if (stack.isEmpty() || t > stack.peek()) { + stack.push(t); + } + } + return stack.size(); + } +} diff --git a/tests/501-1000/853. car-fleet/sol.kt b/tests/501-1000/853. car-fleet/sol.kt new file mode 100644 index 00000000..43b6c78e --- /dev/null +++ b/tests/501-1000/853. car-fleet/sol.kt @@ -0,0 +1,13 @@ +class Solution { + fun carFleet(target: Int, position: IntArray, speed: IntArray): Int { + val cars = position.zip(speed).sortedByDescending { it.first } + val stack = mutableListOf() + for ((p, s) in cars) { + val t = (target - p).toDouble() / s + if (stack.isEmpty() || t > stack.last()) { + stack.add(t) + } + } + return stack.size + } +} diff --git a/tests/501-1000/853. car-fleet/sol.py b/tests/501-1000/853. car-fleet/sol.py new file mode 100644 index 00000000..b29f7541 --- /dev/null +++ b/tests/501-1000/853. car-fleet/sol.py @@ -0,0 +1,11 @@ +class Solution: + def carFleet(self, target: int, position: List[int], speed: List[int]) -> int: + cars = [[p, s] for p, s in zip(position, speed)] + st = [] + + for p, s in sorted(cars)[::-1]: + time_taken = (target - p) / s + if not st or time_taken > st[-1]: + st.append(time_taken) + + return len(st) diff --git a/tests/501-1000/853. car-fleet/sol.py2 b/tests/501-1000/853. car-fleet/sol.py2 new file mode 100644 index 00000000..5000de0c --- /dev/null +++ b/tests/501-1000/853. car-fleet/sol.py2 @@ -0,0 +1,15 @@ +class Solution(object): + def carFleet(self, target, position, speed): + """ + :type target: int + :type position: List[int] + :type speed: List[int] + :rtype: int + """ + cars = sorted(zip(position, speed), reverse=True) + stack = [] + for p, s in cars: + t = float(target - p) / s + if not stack or t > stack[-1]: + stack.append(t) + return len(stack) diff --git a/tests/501-1000/853. car-fleet/sol.rb b/tests/501-1000/853. car-fleet/sol.rb new file mode 100644 index 00000000..733785d1 --- /dev/null +++ b/tests/501-1000/853. car-fleet/sol.rb @@ -0,0 +1,15 @@ +# @param {Integer} target +# @param {Integer[]} position +# @param {Integer[]} speed +# @return {Integer} +def car_fleet(target, position, speed) + cars = position.zip(speed).sort_by { |p, s| -p } + stack = [] + cars.each do |p, s| + t = (target - p).to_f / s + if stack.empty? || t > stack.last + stack << t + end + end + stack.length +end diff --git a/tests/501-1000/853. car-fleet/sol.rs b/tests/501-1000/853. car-fleet/sol.rs new file mode 100644 index 00000000..4dfe9026 --- /dev/null +++ b/tests/501-1000/853. car-fleet/sol.rs @@ -0,0 +1,14 @@ +impl Solution { + pub fn car_fleet(target: i32, position: Vec, speed: Vec) -> i32 { + let mut cars: Vec<(i32, i32)> = position.into_iter().zip(speed.into_iter()).collect(); + cars.sort_by(|a, b| b.0.cmp(&a.0)); + let mut stack: Vec = Vec::new(); + for (p, s) in cars { + let t = (target - p) as f64 / s as f64; + if stack.is_empty() || t > *stack.last().unwrap() { + stack.push(t); + } + } + stack.len() as i32 + } +} diff --git a/tests/501-1000/853. car-fleet/sol.swift b/tests/501-1000/853. car-fleet/sol.swift new file mode 100644 index 00000000..68d4ed49 --- /dev/null +++ b/tests/501-1000/853. car-fleet/sol.swift @@ -0,0 +1,13 @@ +class Solution { + func carFleet(_ target: Int, _ position: [Int], _ speed: [Int]) -> Int { + var cars = zip(position, speed).sorted { $0.0 > $1.0 } + var stack: [Double] = [] + for (p, s) in cars { + let t = Double(target - p) / Double(s) + if stack.isEmpty || t > stack.last! { + stack.append(t) + } + } + return stack.count + } +} diff --git a/tests/501-1000/853. car-fleet/sol.ts b/tests/501-1000/853. car-fleet/sol.ts new file mode 100644 index 00000000..07a16210 --- /dev/null +++ b/tests/501-1000/853. car-fleet/sol.ts @@ -0,0 +1,15 @@ +function carFleet(target: number, position: number[], speed: number[]): number { + const cars: [number, number][] = []; + for (let i = 0; i < position.length; i++) { + cars.push([position[i], speed[i]]); + } + cars.sort((a, b) => b[0] - a[0]); + const stack: number[] = []; + for (const [p, s] of cars) { + const t = (target - p) / s; + if (stack.length === 0 || t > stack[stack.length - 1]) { + stack.push(t); + } + } + return stack.length; +} diff --git a/tests/501-1000/854. k-similar-strings/manifest.yaml b/tests/501-1000/854. k-similar-strings/manifest.yaml new file mode 100644 index 00000000..724af701 --- /dev/null +++ b/tests/501-1000/854. k-similar-strings/manifest.yaml @@ -0,0 +1,232 @@ +entry: + id: 854 + title: k-similar-strings + params: + s1: + type: string + s2: + type: string + call: + cpp: Solution().kSimilarity({s1}, {s2}) + rust: Solution::k_similarity({s1}, {s2}) + python3: Solution().kSimilarity({s1}, {s2}) + python2: Solution().kSimilarity({s1}, {s2}) + ruby: k_similarity({s1}, {s2}) + java: new Solution().kSimilarity({s1}, {s2}) + csharp: new Solution().KSimilarity({s1}, {s2}) + kotlin: Solution().kSimilarity({s1}, {s2}) + go: kSimilarity({s1}, {s2}) + dart: Solution().kSimilarity({s1}, {s2}) + swift: Solution().kSimilarity({s1}, {s2}) + typescript: kSimilarity({s1}, {s2}) +judge: + type: exact +limits: + time_ms: 2000 + memory_mb: 256 +oracle: + python3: + call: "Checker().kSimilarity(s1, s2, {result})" + checker: | + from collections import deque + + class Checker: + def kSimilarity(self, s1, s2, result): + if not isinstance(result, int): + return False + q = deque([s1]) + seen = {s1} + ans = 0 + while q: + for _ in range(len(q)): + s = q.popleft() + if s == s2: + return result == ans + i = 0 + while s[i] == s2[i]: + i += 1 + for j in range(i + 1, len(s)): + if s[i] == s2[j] and s[j] != s2[j]: + ns = s[:i] + s[j] + s[i + 1:j] + s[i] + s[j + 1:] + if ns not in seen: + seen.add(ns) + q.append(ns) + ans += 1 + return False +seed: 854 +tests: + - name: ex1 + in: + s1: ab + s2: ba + out: 1 + - name: ex2 + in: + s1: abc + s2: bca + out: 2 + - name: same_string + in: + s1: abcdef + s2: abcdef + out: 0 + - name: swap_two + in: + s1: abac + s2: baca + out: 2 + - name: swap_two_more + in: + s1: aabc + s2: abca + out: 2 + - name: two_swaps_longer + in: + s1: abcdef + s2: abcfde + out: 2 + - name: reverse_pairs + in: + s1: aabbcc + s2: ccbbaa + out: 2 + - name: simple_two + in: + s1: abca + s2: caba + out: 2 + - name: three_swaps + in: + s1: abcabc + s2: acbbca + out: 3 + - name: double_pair + in: + s1: aabb + s2: bbaa + out: 2 + - name: three_swaps_6 + in: + s1: aaabbb + s2: bbbaaa + out: 3 + - name: rotate_five + in: + s1: abcde + s2: eabcd + out: 4 + - name: reverse_six + in: + s1: abcdef + s2: fedcba + out: 3 + - name: four_swaps_6 + in: + s1: abcfed + s2: defabc + out: 4 + - name: three_swaps_repeat + in: + s1: aaabcc + s2: ccaaba + out: 3 + - name: three_swaps_alt + in: + s1: abcdef + s2: badcfe + out: 3 + - name: reverse_six_alt + in: + s1: abdcfe + s2: fedcba + out: 3 + - name: four_swaps_8 + in: + s1: aabbccdd + s2: ddccbbaa + out: 4 + - name: pair_mix + in: + s1: abcdefab + s2: bacedfab + out: 2 + - name: four_swaps_8_alt + in: + s1: abcddcba + s2: dcbaabcd + out: 4 + - name: four_swaps_10 + in: + s1: aabbccddee + s2: eeddccbbaa + out: 4 + - name: two_swaps_6_alt + in: + s1: abccef + s2: fceabc + out: 4 + - name: six_swaps_12 + in: + s1: abcdeffedcba + s2: fedcbaabcdef + out: 6 + - name: three_swaps_6_alt + in: + s1: aabbcc + s2: bcaabc + out: 3 + - name: three_swaps_6_more + in: + s1: ababcc + s2: cabcab + out: 3 + - name: one_swap_6 + in: + s1: abccba + s2: abcabc + out: 1 + - name: four_swaps_6_more + in: + s1: abccef + s2: fceabc + out: 4 + - name: two_swaps_6_more + in: + s1: aabbcc + s2: abcabc + out: 2 + - name: three_swaps_6_again + in: + s1: abcdef + s2: bcadfe + out: 3 + - name: three_swaps_6_again2 + in: + s1: aaabbbccc + s2: ccbbaabca + out: 4 + - name: two_swaps_9 + in: + s1: abcabcabc + s2: cbacbaabc + out: 2 + - name: reverse_seven + in: + s1: abcdefg + s2: gfedcba + out: 3 + - name: five_swaps_8 + in: + s1: aabcdeff + s2: fefdcbaa + out: 5 + - name: extra_two + in: + s1: abca + s2: baac + out: 2 + - name: extra_three + in: + s1: aabbcc + s2: baccab + out: 3 diff --git a/tests/501-1000/854. k-similar-strings/sol.cpp b/tests/501-1000/854. k-similar-strings/sol.cpp new file mode 100644 index 00000000..59862203 --- /dev/null +++ b/tests/501-1000/854. k-similar-strings/sol.cpp @@ -0,0 +1,38 @@ +#include +#include +#include + +class Solution { +public: + int kSimilarity(string s1, string s2) { + queue q; + q.push(s1); + unordered_set seen; + int answ = 0; + + while (!q.empty()) { + int size = q.size(); + for (int k = 0; k < size; k++) { + string str = q.front(); + q.pop(); + if (str == s2) return answ; + + int i = 0; + while (str[i] == s2[i]) i++; + + for (int j = i + 1; j < str.length(); j++) { + if (str[i] == s2[j] && s2[j] != s1[j]) { + swap(str[i], str[j]); + if (!seen.count(str)) { + seen.insert(str); + q.push(str); + } + swap(str[i], str[j]); + } + } + } + answ++; + } + return answ; + } +}; diff --git a/tests/501-1000/854. k-similar-strings/sol.cs b/tests/501-1000/854. k-similar-strings/sol.cs new file mode 100644 index 00000000..83dfa8c2 --- /dev/null +++ b/tests/501-1000/854. k-similar-strings/sol.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; + +public class Solution { + public int KSimilarity(string s1, string s2) { + var queue = new Queue(); + queue.Enqueue(s1); + var seen = new HashSet(); + int answ = 0; + + while (queue.Count > 0) { + int size = queue.Count; + for (int k = 0; k < size; k++) { + string str = queue.Dequeue(); + if (str == s2) return answ; + + int i = 0; + while (str[i] == s2[i]) i++; + + char[] arr = str.ToCharArray(); + for (int j = i + 1; j < str.Length; j++) { + if (str[i] == s2[j] && s2[j] != s1[j]) { + (arr[i], arr[j]) = (arr[j], arr[i]); + string newStr = new string(arr); + if (!seen.Contains(newStr)) { + seen.Add(newStr); + queue.Enqueue(newStr); + } + (arr[i], arr[j]) = (arr[j], arr[i]); + } + } + } + answ++; + } + return answ; + } +} diff --git a/tests/501-1000/854. k-similar-strings/sol.dart b/tests/501-1000/854. k-similar-strings/sol.dart new file mode 100644 index 00000000..1dcef2ed --- /dev/null +++ b/tests/501-1000/854. k-similar-strings/sol.dart @@ -0,0 +1,35 @@ +import 'dart:collection'; + +class Solution { + int kSimilarity(String s1, String s2) { + var queue = Queue(); + queue.add(s1); + var seen = {}; + int answ = 0; + + while (queue.isNotEmpty) { + int size = queue.length; + for (int k = 0; k < size; k++) { + String string = queue.removeFirst(); + if (string == s2) return answ; + + int i = 0; + while (string[i] == s2[i]) i++; + + for (int j = i + 1; j < string.length; j++) { + if (string[i] == s2[j] && s2[j] != s1[j]) { + String newStr = string.substring(0, i) + string[j] + + string.substring(i + 1, j) + string[i] + + string.substring(j + 1); + if (!seen.contains(newStr)) { + seen.add(newStr); + queue.add(newStr); + } + } + } + } + answ++; + } + return answ; + } +} diff --git a/tests/501-1000/854. k-similar-strings/sol.go b/tests/501-1000/854. k-similar-strings/sol.go new file mode 100644 index 00000000..ddda7cae --- /dev/null +++ b/tests/501-1000/854. k-similar-strings/sol.go @@ -0,0 +1,33 @@ +func kSimilarity(s1 string, s2 string) int { + queue := []string{s1} + seen := make(map[string]bool) + answ := 0 + + for len(queue) > 0 { + size := len(queue) + for k := 0; k < size; k++ { + str := queue[0] + queue = queue[1:] + if str == s2 { + return answ + } + + i := 0 + for str[i] == s2[i] { + i++ + } + + for j := i + 1; j < len(str); j++ { + if str[i] == s2[j] && s2[j] != s1[j] { + newStr := str[:i] + string(str[j]) + str[i+1:j] + string(str[i]) + str[j+1:] + if !seen[newStr] { + seen[newStr] = true + queue = append(queue, newStr) + } + } + } + } + answ++ + } + return answ +} diff --git a/tests/501-1000/854. k-similar-strings/sol.java b/tests/501-1000/854. k-similar-strings/sol.java new file mode 100644 index 00000000..af78a9ac --- /dev/null +++ b/tests/501-1000/854. k-similar-strings/sol.java @@ -0,0 +1,42 @@ +import java.util.ArrayDeque; +import java.util.Deque; +import java.util.HashSet; +import java.util.Set; + +class Solution { + public int kSimilarity(String s1, String s2) { + Deque queue = new ArrayDeque<>(); + queue.offer(s1); + Set seen = new HashSet<>(); + int answ = 0; + + while (!queue.isEmpty()) { + int size = queue.size(); + for (int k = 0; k < size; k++) { + String string = queue.poll(); + if (string.equals(s2)) { + return answ; + } + + int i = 0; + while (string.charAt(i) == s2.charAt(i)) { + i++; + } + + for (int j = i + 1; j < string.length(); j++) { + if (string.charAt(i) == s2.charAt(j) && s2.charAt(j) != s1.charAt(j)) { + String newStr = string.substring(0, i) + string.charAt(j) + + string.substring(i + 1, j) + string.charAt(i) + + string.substring(j + 1); + if (!seen.contains(newStr)) { + seen.add(newStr); + queue.offer(newStr); + } + } + } + } + answ++; + } + return answ; + } +} diff --git a/tests/501-1000/854. k-similar-strings/sol.kt b/tests/501-1000/854. k-similar-strings/sol.kt new file mode 100644 index 00000000..86395fe1 --- /dev/null +++ b/tests/501-1000/854. k-similar-strings/sol.kt @@ -0,0 +1,34 @@ +import java.util.ArrayDeque + +class Solution { + fun kSimilarity(s1: String, s2: String): Int { + val queue = ArrayDeque() + queue.offer(s1) + val seen = HashSet() + var answ = 0 + + while (queue.isNotEmpty()) { + repeat(queue.size) { + val string = queue.poll() + if (string == s2) return answ + + var i = 0 + while (string[i] == s2[i]) i++ + + for (j in i + 1 until string.length) { + if (string[i] == s2[j] && s2[j] != s1[j]) { + val new = string.substring(0, i) + string[j] + + string.substring(i + 1, j) + string[i] + + string.substring(j + 1) + if (new !in seen) { + seen.add(new) + queue.offer(new) + } + } + } + } + answ++ + } + return answ + } +} diff --git a/tests/501-1000/854. k-similar-strings/sol.py b/tests/501-1000/854. k-similar-strings/sol.py new file mode 100644 index 00000000..d53f8125 --- /dev/null +++ b/tests/501-1000/854. k-similar-strings/sol.py @@ -0,0 +1,48 @@ +import collections + + +class Solution: + def kSimilarity(self, s1: str, s2: str) -> int: + # the deque keeps track of the set of strings that we want to perform swaps on + # at the start, the deque contains only s1 + deque = collections.deque([s1]) + + # this set wasn't mentioned in the "intuition" part. it helps us avoid doing repeated work by adding the same strings to our deque + seen = set() + + answ = 0 # counter for the number of "swaps" done so far + + while deque: + for _ in range(len(deque)): # loops through each string in the deque + string = deque.popleft() # gets the first string in the deque + if string == s2: + return answ + + # finds the first non-matching letter in s1 + # this satisfies condition 1 of a "useful" swap + # ex: this would be s1[3] in the above example + i = 0 + while string[i] == s2[i]: + i += 1 + + # checks all the other letters for potential swaps + for j in range(i + 1, len(string)): + if ( + string[i] == s2[j] != s1[j] + ): # checks conditions 2 and 3 of a useful swap + # swaps the letters at positions i and j + new = ( + string[:i] + + string[j] + + string[i + 1 : j] + + string[i] + + string[j + 1 :] + ) + + # adds the "new string" if it was not previously added + if new not in seen: + seen.add(new) + deque.append(new) + + # record that one more swap was done for each string in the deque + answ += 1 diff --git a/tests/501-1000/854. k-similar-strings/sol.py2 b/tests/501-1000/854. k-similar-strings/sol.py2 new file mode 100644 index 00000000..52146a3d --- /dev/null +++ b/tests/501-1000/854. k-similar-strings/sol.py2 @@ -0,0 +1,30 @@ +class Solution(object): + def kSimilarity(self, s1, s2): + """ + :type s1: str + :type s2: str + :rtype: int + """ + from collections import deque + + queue = deque([s1]) + seen = set() + answ = 0 + + while queue: + for _ in range(len(queue)): + string = queue.popleft() + if string == s2: + return answ + + i = 0 + while string[i] == s2[i]: + i += 1 + + for j in range(i + 1, len(string)): + if string[i] == s2[j] != s1[j]: + new = string[:i] + string[j] + string[i+1:j] + string[i] + string[j+1:] + if new not in seen: + seen.add(new) + queue.append(new) + answ += 1 diff --git a/tests/501-1000/854. k-similar-strings/sol.rb b/tests/501-1000/854. k-similar-strings/sol.rb new file mode 100644 index 00000000..90b72426 --- /dev/null +++ b/tests/501-1000/854. k-similar-strings/sol.rb @@ -0,0 +1,31 @@ +# @param {String} s1 +# @param {String} s2 +# @return {Integer} +def k_similarity(s1, s2) + queue = [s1] + seen = {} + answ = 0 + + while !queue.empty? + queue.size.times do + string = queue.shift + return answ if string == s2 + + i = 0 + while string[i] == s2[i] + i += 1 + end + + (i + 1...string.length).each do |j| + if string[i] == s2[j] && s2[j] != s1[j] + new_str = string[0...i] + string[j] + string[i+1...j] + string[i] + string[j+1..-1] + unless seen[new_str] + seen[new_str] = true + queue << new_str + end + end + end + end + answ += 1 + end +end diff --git a/tests/501-1000/854. k-similar-strings/sol.rs b/tests/501-1000/854. k-similar-strings/sol.rs new file mode 100644 index 00000000..94c4affe --- /dev/null +++ b/tests/501-1000/854. k-similar-strings/sol.rs @@ -0,0 +1,41 @@ +use std::collections::{VecDeque, HashSet}; + +impl Solution { + pub fn k_similarity(s1: String, s2: String) -> i32 { + let mut queue = VecDeque::from(vec![s1.clone()]); + let mut seen = HashSet::new(); + let mut answ = 0; + let s1_bytes = s1.as_bytes(); + let s2_bytes = s2.as_bytes(); + + while !queue.is_empty() { + let size = queue.len(); + for _ in 0..size { + let string = queue.pop_front().unwrap(); + if string == s2 { + return answ; + } + + let mut bytes = string.into_bytes(); + let mut i = 0; + while bytes[i] == s2_bytes[i] { + i += 1; + } + + for j in i + 1..bytes.len() { + if bytes[i] == s2_bytes[j] && s2_bytes[j] != s1_bytes[j] { + bytes.swap(i, j); + let new_str = String::from_utf8(bytes.clone()).unwrap(); + if !seen.contains(&new_str) { + seen.insert(new_str.clone()); + queue.push_back(new_str); + } + bytes.swap(i, j); + } + } + } + answ += 1; + } + answ + } +} diff --git a/tests/501-1000/854. k-similar-strings/sol.swift b/tests/501-1000/854. k-similar-strings/sol.swift new file mode 100644 index 00000000..d0e970cd --- /dev/null +++ b/tests/501-1000/854. k-similar-strings/sol.swift @@ -0,0 +1,35 @@ +class Solution { + func kSimilarity(_ s1: String, _ s2: String) -> Int { + var queue = [s1] + var seen = Set() + var answ = 0 + let s1Arr = Array(s1) + let s2Arr = Array(s2) + + while !queue.isEmpty { + let size = queue.count + for _ in 0.. = new Set(); + let answ: number = 0; + + while (queue.length > 0) { + const size = queue.length; + for (let k = 0; k < size; k++) { + const str = queue.shift()!; + if (str === s2) return answ; + + let i = 0; + while (str[i] === s2[i]) i++; + + for (let j = i + 1; j < str.length; j++) { + if (str[i] === s2[j] && s2[j] !== s1[j]) { + const newStr = + str.substring(0, i) + + str[j] + + str.substring(i + 1, j) + + str[i] + + str.substring(j + 1); + if (!seen.has(newStr)) { + seen.add(newStr); + queue.push(newStr); + } + } + } + } + answ++; + } + return answ; +} diff --git a/tests/501-1000/856. score-of-parentheses/manifest.yaml b/tests/501-1000/856. score-of-parentheses/manifest.yaml new file mode 100644 index 00000000..c0a4526d --- /dev/null +++ b/tests/501-1000/856. score-of-parentheses/manifest.yaml @@ -0,0 +1,186 @@ +entry: + id: 856 + title: score-of-parentheses + params: + s: + type: string + call: + cpp: Solution().scoreOfParentheses({s}) + rust: Solution::score_of_parentheses({s}) + python3: Solution().scoreOfParentheses({s}) + python2: Solution().scoreOfParentheses({s}) + ruby: score_of_parentheses({s}) + java: new Solution().scoreOfParentheses({s}) + csharp: new Solution().ScoreOfParentheses({s}) + kotlin: Solution().scoreOfParentheses({s}) + go: scoreOfParentheses({s}) + dart: Solution().scoreOfParentheses({s}) + swift: Solution().scoreOfParentheses({s}) + typescript: scoreOfParentheses({s}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().scoreOfParentheses(s, {result})" + checker: | + class Checker: + def scoreOfParentheses(self, s, result): + if not isinstance(result, int): + return False + score_stack = [0] + for ch in s: + if ch == "(": + score_stack.append(0) + else: + last_score = score_stack.pop() + score_stack[-1] += max(1, last_score * 2) + return result == score_stack[-1] +seed: 856 +tests: + - name: ex1 + in: + s: "()" + out: 1 + - name: ex2 + in: + s: "(())" + out: 2 + - name: ex3 + in: + s: "()()" + out: 2 + - name: nested_three + in: + s: "((()))" + out: 4 + - name: concat_nested + in: + s: "(()())" + out: 4 + - name: alternating + in: + s: "()(())" + out: 3 + - name: deep_mix + in: + s: "((()()))" + out: 8 + - name: deeper_mix + in: + s: "(()(()))" + out: 6 + - name: triple_pair + in: + s: "()()()" + out: 3 + - name: depth_four + in: + s: "(((())))" + out: 8 + - name: mixed_six + in: + s: "(()()())" + out: 6 + - name: mix_two + in: + s: "((())())" + out: 6 + - name: mix_three + in: + s: "()(()())" + out: 5 + - name: deeper_12 + in: + s: "((()()()))" + out: 12 + - name: depth_16 + in: + s: "(((()())))" + out: 16 + - name: outer_pair + in: + s: "()((()))" + out: 5 + - name: suffix_pair + in: + s: "(()())()" + out: 5 + - name: nested_concat + in: + s: "((())(()))" + out: 8 + - name: deep_inner + in: + s: "((()(())))" + out: 12 + - name: outer_deep_mix + in: + s: "()((()()))" + out: 9 + - name: mixed_ten + in: + s: "(((()))())" + out: 10 + - name: pair_and_nested + in: + s: "((()))()" + out: 5 + - name: inner_ten + in: + s: "(()(()()))" + out: 10 + - name: four_pairs + in: + s: "()()()()" + out: 4 + - name: deep_16 + in: + s: "((()()()()))" + out: 16 + - name: max_depth_16 + in: + s: "((((()))))" + out: 16 + - name: nested_ten + in: + s: "(()((())))" + out: 10 + - name: mix_eight + in: + s: "((())()())" + out: 8 + - name: outer_seven + in: + s: "()((())())" + out: 7 + - name: big_24 + in: + s: "(((()()())))" + out: 24 + - name: flat_eight + in: + s: "(()()()())" + out: 8 + - name: deep_ten + in: + s: "((()())())" + out: 10 + - name: suffix_nine + in: + s: "(((())))()" + out: 9 + - name: mixed_seven + in: + s: "()(()(()))" + out: 7 + - name: deep_eighteen + in: + s: "(()((()())))" + out: 18 + - name: deep_twenty + in: + s: "((()(()())))" + out: 20 diff --git a/tests/501-1000/856. score-of-parentheses/sol.cpp b/tests/501-1000/856. score-of-parentheses/sol.cpp new file mode 100644 index 00000000..81ffdfb3 --- /dev/null +++ b/tests/501-1000/856. score-of-parentheses/sol.cpp @@ -0,0 +1,18 @@ +class Solution { +public: + int scoreOfParentheses(string s) { + vector score_stack = {0}; + + for (char parentheses : s) { + if (parentheses == '(') { + score_stack.push_back(0); + } else if (!score_stack.empty()) { + int last_score = score_stack.back(); + score_stack.pop_back(); + score_stack.back() += max(1, last_score * 2); + } + } + + return score_stack.back(); + } +}; diff --git a/tests/501-1000/856. score-of-parentheses/sol.cs b/tests/501-1000/856. score-of-parentheses/sol.cs new file mode 100644 index 00000000..66edd8d9 --- /dev/null +++ b/tests/501-1000/856. score-of-parentheses/sol.cs @@ -0,0 +1,17 @@ +public class Solution { + public int ScoreOfParentheses(string s) { + var scoreStack = new List { 0 }; + + foreach (char parentheses in s) { + if (parentheses == '(') { + scoreStack.Add(0); + } else if (scoreStack.Count > 0) { + int lastScore = scoreStack[scoreStack.Count - 1]; + scoreStack.RemoveAt(scoreStack.Count - 1); + scoreStack[scoreStack.Count - 1] += Math.Max(1, lastScore * 2); + } + } + + return scoreStack[scoreStack.Count - 1]; + } +} diff --git a/tests/501-1000/856. score-of-parentheses/sol.dart b/tests/501-1000/856. score-of-parentheses/sol.dart new file mode 100644 index 00000000..c5a3504d --- /dev/null +++ b/tests/501-1000/856. score-of-parentheses/sol.dart @@ -0,0 +1,18 @@ +class Solution { + int scoreOfParentheses(String s) { + List scoreStack = [0]; + + for (var parentheses in s.split('')) { + if (parentheses == '(') { + scoreStack.add(0); + } else if (scoreStack.isNotEmpty) { + int lastScore = scoreStack.removeLast(); + scoreStack.last += max(lastScore * 2, 1); + } + } + + return scoreStack.last; + } + + int max(int a, int b) => a > b ? a : b; +} diff --git a/tests/501-1000/856. score-of-parentheses/sol.go b/tests/501-1000/856. score-of-parentheses/sol.go new file mode 100644 index 00000000..4eddfc19 --- /dev/null +++ b/tests/501-1000/856. score-of-parentheses/sol.go @@ -0,0 +1,15 @@ +func scoreOfParentheses(s string) int { + scoreStack := []int{0} + + for _, parentheses := range s { + if parentheses == '(' { + scoreStack = append(scoreStack, 0) + } else if len(scoreStack) > 0 { + lastScore := scoreStack[len(scoreStack)-1] + scoreStack = scoreStack[:len(scoreStack)-1] + scoreStack[len(scoreStack)-1] += max(1, lastScore*2) + } + } + + return scoreStack[len(scoreStack)-1] +} diff --git a/tests/501-1000/856. score-of-parentheses/sol.java b/tests/501-1000/856. score-of-parentheses/sol.java new file mode 100644 index 00000000..98a63fc1 --- /dev/null +++ b/tests/501-1000/856. score-of-parentheses/sol.java @@ -0,0 +1,21 @@ +class Solution { + public int scoreOfParentheses(String s) { + int[] score_stack = new int[s.length() + 1]; + int top = 0; + score_stack[0] = 0; + + for (int i = 0; i < s.length(); i++) { + char parentheses = s.charAt(i); + if (parentheses == '(') { + top++; + score_stack[top] = 0; + } else if (top >= 0) { + int last_score = score_stack[top]; + top--; + score_stack[top] += Math.max(1, last_score * 2); + } + } + + return score_stack[0]; + } +} diff --git a/tests/501-1000/856. score-of-parentheses/sol.kt b/tests/501-1000/856. score-of-parentheses/sol.kt new file mode 100644 index 00000000..7d58b08a --- /dev/null +++ b/tests/501-1000/856. score-of-parentheses/sol.kt @@ -0,0 +1,16 @@ +class Solution { + fun scoreOfParentheses(s: String): Int { + val scoreStack = mutableListOf(0) + + for (parentheses in s) { + if (parentheses == '(') { + scoreStack.add(0) + } else if (scoreStack.isNotEmpty()) { + val lastScore = scoreStack.removeAt(scoreStack.size - 1) + scoreStack[scoreStack.size - 1] += maxOf(1, lastScore * 2) + } + } + + return scoreStack.last() + } +} diff --git a/tests/501-1000/856. score-of-parentheses/sol.py b/tests/501-1000/856. score-of-parentheses/sol.py new file mode 100644 index 00000000..2bfadc36 --- /dev/null +++ b/tests/501-1000/856. score-of-parentheses/sol.py @@ -0,0 +1,12 @@ +class Solution: + def scoreOfParentheses(self, s: str) -> int: + score_stack = [0] + + for parentheses in s: + if parentheses == "(": + score_stack.append(0) + elif score_stack: + last_score = score_stack.pop() + score_stack[-1] += max(1, last_score * 2) + + return score_stack[-1] diff --git a/tests/501-1000/856. score-of-parentheses/sol.py2 b/tests/501-1000/856. score-of-parentheses/sol.py2 new file mode 100644 index 00000000..499695ab --- /dev/null +++ b/tests/501-1000/856. score-of-parentheses/sol.py2 @@ -0,0 +1,16 @@ +class Solution(object): + def scoreOfParentheses(self, s): + """ + :type s: str + :rtype: int + """ + score_stack = [0] + + for parentheses in s: + if parentheses == "(": + score_stack.append(0) + elif score_stack: + last_score = score_stack.pop() + score_stack[-1] += max(1, last_score * 2) + + return score_stack[-1] diff --git a/tests/501-1000/856. score-of-parentheses/sol.rb b/tests/501-1000/856. score-of-parentheses/sol.rb new file mode 100644 index 00000000..90542969 --- /dev/null +++ b/tests/501-1000/856. score-of-parentheses/sol.rb @@ -0,0 +1,16 @@ +# @param {String} s +# @return {Integer} +def score_of_parentheses(s) + score_stack = [0] + + s.each_char do |parentheses| + if parentheses == "(" + score_stack.push(0) + elsif !score_stack.empty? + last_score = score_stack.pop + score_stack[-1] += [1, last_score * 2].max + end + end + + score_stack[-1] +end diff --git a/tests/501-1000/856. score-of-parentheses/sol.rs b/tests/501-1000/856. score-of-parentheses/sol.rs new file mode 100644 index 00000000..84f2155d --- /dev/null +++ b/tests/501-1000/856. score-of-parentheses/sol.rs @@ -0,0 +1,17 @@ +impl Solution { + pub fn score_of_parentheses(s: String) -> i32 { + let mut score_stack: Vec = vec![0]; + + for parentheses in s.chars() { + if parentheses == '(' { + score_stack.push(0); + } else if !score_stack.is_empty() { + let last_score = score_stack.pop().unwrap(); + let len = score_stack.len(); + score_stack[len - 1] += std::cmp::max(1, last_score * 2); + } + } + + score_stack[score_stack.len() - 1] + } +} diff --git a/tests/501-1000/856. score-of-parentheses/sol.swift b/tests/501-1000/856. score-of-parentheses/sol.swift new file mode 100644 index 00000000..46bc9eff --- /dev/null +++ b/tests/501-1000/856. score-of-parentheses/sol.swift @@ -0,0 +1,16 @@ +class Solution { + func scoreOfParentheses(_ s: String) -> Int { + var scoreStack = [0] + + for parentheses in s { + if parentheses == "(" { + scoreStack.append(0) + } else if !scoreStack.isEmpty { + let lastScore = scoreStack.removeLast() + scoreStack[scoreStack.count - 1] += max(1, lastScore * 2) + } + } + + return scoreStack.last! + } +} diff --git a/tests/501-1000/856. score-of-parentheses/sol.ts b/tests/501-1000/856. score-of-parentheses/sol.ts new file mode 100644 index 00000000..68ccbfea --- /dev/null +++ b/tests/501-1000/856. score-of-parentheses/sol.ts @@ -0,0 +1,14 @@ +function scoreOfParentheses(s: string): number { + const scoreStack: number[] = [0]; + + for (const parentheses of s) { + if (parentheses === "(") { + scoreStack.push(0); + } else if (scoreStack.length > 0) { + const lastScore = scoreStack.pop()!; + scoreStack[scoreStack.length - 1] += Math.max(1, lastScore * 2); + } + } + + return scoreStack[scoreStack.length - 1]; +} diff --git a/tests/501-1000/857. minimum-cost-to-hire-k-workers/manifest.yaml b/tests/501-1000/857. minimum-cost-to-hire-k-workers/manifest.yaml new file mode 100644 index 00000000..727ca526 --- /dev/null +++ b/tests/501-1000/857. minimum-cost-to-hire-k-workers/manifest.yaml @@ -0,0 +1,229 @@ +entry: + id: 857 + title: minimum-cost-to-hire-k-workers + params: + quality: + type: array + items: + type: int + wage: + type: array + items: + type: int + k: + type: int + call: + cpp: "Solution().mincostToHireWorkers({quality}, {wage}, {k})" + rust: "Solution::mincost_to_hire_workers({quality}, {wage}, {k})" + python3: "Solution().mincostToHireWorkers({quality}, {wage}, {k})" + python2: "Solution().mincostToHireWorkers({quality}, {wage}, {k})" + ruby: "mincost_to_hire_workers({quality}, {wage}, {k})" + java: "new Solution().mincostToHireWorkers({quality}, {wage}, {k})" + csharp: "new Solution().MincostToHireWorkers({quality}, {wage}, {k})" + kotlin: "Solution().mincostToHireWorkers({quality}, {wage}, {k})" + go: "mincostToHireWorkers({quality}, {wage}, {k})" + dart: "Solution().mincostToHireWorkers({quality}, {wage}, {k})" + swift: "Solution().mincostToHireWorkers({quality}, {wage}, {k})" + typescript: "mincostToHireWorkers({quality}, {wage}, {k})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().mincostToHireWorkers(quality, wage, k, {result})" + checker: | + import heapq + + class Checker: + def mincostToHireWorkers(self, quality, wage, k, result): + workers = sorted((w / q, q) for w, q in zip(wage, quality)) + total = 0 + heap = [] + best = float('inf') + for ratio, q in workers: + total += q + heapq.heappush(heap, -q) + if len(heap) > k: + total += heapq.heappop(heap) + if len(heap) == k: + best = min(best, ratio * total) + return abs(best - result) <= 1e-5 +seed: 857 +tests: + - name: ex1 + in: + quality: [10, 20, 5] + wage: [70, 50, 30] + k: 2 + - name: ex2 + in: + quality: [3, 1, 10, 10, 1] + wage: [4, 8, 2, 2, 7] + k: 3 + - name: single1 + in: + quality: [5] + wage: [7] + k: 1 + - name: single2 + in: + quality: [10000] + wage: [10000] + k: 1 + - name: pair1 + in: + quality: [1, 2] + wage: [2, 4] + k: 1 + - name: pair2 + in: + quality: [1, 2] + wage: [2, 4] + k: 2 + - name: pair3 + in: + quality: [5, 5] + wage: [7, 8] + k: 2 + - name: triple1 + in: + quality: [4, 8, 2] + wage: [9, 16, 5] + k: 2 + - name: triple2 + in: + quality: [4, 8, 2] + wage: [9, 16, 5] + k: 3 + - name: triple3 + in: + quality: [2, 2, 2] + wage: [2, 3, 4] + k: 2 + - name: t11 + in: + quality: [1, 3, 5, 7] + wage: [3, 9, 15, 21] + k: 2 + - name: t12 + in: + quality: [1, 3, 5, 7] + wage: [3, 9, 15, 21] + k: 3 + - name: t13 + in: + quality: [10, 20, 30, 40] + wage: [40, 60, 90, 120] + k: 2 + - name: t14 + in: + quality: [10, 20, 30, 40] + wage: [40, 60, 90, 120] + k: 4 + - name: t15 + in: + quality: [2, 4, 6, 8, 10] + wage: [10, 20, 30, 40, 50] + k: 3 + - name: t16 + in: + quality: [2, 4, 6, 8, 10] + wage: [10, 20, 30, 40, 50] + k: 5 + - name: t17 + in: + quality: [9, 8, 7, 6, 5] + wage: [90, 80, 70, 60, 55] + k: 2 + - name: t18 + in: + quality: [9, 8, 7, 6, 5] + wage: [90, 80, 70, 60, 55] + k: 4 + - name: t19 + in: + quality: [1, 1, 1, 1, 1] + wage: [1, 2, 3, 4, 5] + k: 3 + - name: t20 + in: + quality: [100, 200, 300, 400, 500] + wage: [110, 220, 330, 440, 550] + k: 2 + - name: t21 + in: + quality: [100, 200, 300, 400, 500] + wage: [110, 220, 330, 440, 550] + k: 5 + - name: t22 + in: + quality: [6, 10, 3, 8, 7, 2] + wage: [30, 40, 15, 32, 28, 10] + k: 3 + - name: t23 + in: + quality: [6, 10, 3, 8, 7, 2] + wage: [30, 40, 15, 32, 28, 10] + k: 4 + - name: t24 + in: + quality: [4, 4, 4, 4, 4, 4] + wage: [8, 8, 8, 8, 8, 8] + k: 3 + - name: t25 + in: + quality: [4, 4, 4, 4, 4, 4] + wage: [8, 9, 10, 11, 12, 13] + k: 2 + - name: t26 + in: + quality: [1, 2, 3, 4, 5, 6, 7] + wage: [2, 4, 6, 8, 10, 12, 14] + k: 4 + - name: t27 + in: + quality: [1, 2, 3, 4, 5, 6, 7] + wage: [3, 5, 7, 9, 11, 13, 15] + k: 4 + - name: t28 + in: + quality: [11, 22, 33, 44, 55, 66, 77, 88] + wage: [11, 44, 99, 176, 275, 396, 539, 704] + k: 5 + - name: t29 + in: + quality: [11, 22, 33, 44, 55, 66, 77, 88] + wage: [12, 45, 100, 177, 276, 397, 540, 705] + k: 5 + - name: t30 + in: + quality: [5, 9, 13, 17, 21, 25, 29, 33] + wage: [15, 27, 39, 51, 63, 75, 87, 99] + k: 6 + - name: t31 + in: + quality: [5, 9, 13, 17, 21, 25, 29, 33] + wage: [16, 28, 40, 52, 64, 76, 88, 100] + k: 6 + - name: t32 + in: + quality: [10000, 9999, 9998, 9997] + wage: [10000, 20000, 30000, 40000] + k: 2 + - name: t33 + in: + quality: [10000, 9999, 9998, 9997] + wage: [10000, 20000, 30000, 40000] + k: 4 + - name: t34 + in: + quality: [8, 1, 6, 2, 7, 3, 5, 4] + wage: [16, 3, 12, 6, 14, 9, 10, 8] + k: 3 + - name: t35 + in: + quality: [8, 1, 6, 2, 7, 3, 5, 4] + wage: [16, 3, 12, 6, 14, 9, 10, 8] + k: 6 diff --git a/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.cpp b/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.cpp new file mode 100644 index 00000000..e0e14608 --- /dev/null +++ b/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.cpp @@ -0,0 +1,31 @@ +class Solution { +public: + double mincostToHireWorkers(vector& quality, vector& wage, int k) { + int n = quality.size(); + vector> workers; + for (int i = 0; i < n; ++i) { + workers.emplace_back((double)wage[i] / quality[i], quality[i]); + } + sort(workers.begin(), workers.end()); + + double min_cost = DBL_MAX; + long long current_quality_sum = 0; + priority_queue max_heap; + + for (auto& [ratio, q] : workers) { + current_quality_sum += q; + max_heap.push(q); + + if (max_heap.size() > k) { + current_quality_sum -= max_heap.top(); + max_heap.pop(); + } + + if (max_heap.size() == k) { + min_cost = min(min_cost, ratio * current_quality_sum); + } + } + + return min_cost; + } +}; diff --git a/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.cs b/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.cs new file mode 100644 index 00000000..9009ddb4 --- /dev/null +++ b/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.cs @@ -0,0 +1,31 @@ +public class Solution { + public double MincostToHireWorkers(int[] quality, int[] wage, int k) { + int n = quality.Length; + var workers = new (double ratio, int quality)[n]; + for (int i = 0; i < n; ++i) + workers[i] = ((double)wage[i] / quality[i], quality[i]); + + Array.Sort(workers, (a, b) => a.ratio.CompareTo(b.ratio)); + + double minCost = double.MaxValue; + long currentQualitySum = 0; + var maxHeap = new List(); + + foreach (var (ratio, q) in workers) { + currentQualitySum += q; + maxHeap.Add(q); + maxHeap.Sort((a, b) => b.CompareTo(a)); + + if (maxHeap.Count > k) { + currentQualitySum -= maxHeap[0]; + maxHeap.RemoveAt(0); + } + + if (maxHeap.Count == k) { + minCost = Math.Min(minCost, ratio * currentQualitySum); + } + } + + return minCost; + } +} diff --git a/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.dart b/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.dart new file mode 100644 index 00000000..7cb91c45 --- /dev/null +++ b/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.dart @@ -0,0 +1,33 @@ +class Solution { + double mincostToHireWorkers(List quality, List wage, int k) { + int n = quality.length; + List> workers = []; + for (int i = 0; i < n; i++) { + workers.add([wage[i] / quality[i], quality[i].toDouble()]); + } + workers.sort((a, b) => a[0].compareTo(b[0])); + + double minCost = double.infinity; + int currentQualitySum = 0; + final maxHeap = []; + + for (var w in workers) { + double ratio = w[0]; + int q = w[1].toInt(); + + currentQualitySum += q; + maxHeap.add(q); + maxHeap.sort((a, b) => b.compareTo(a)); + + if (maxHeap.length > k) { + currentQualitySum -= maxHeap.removeAt(0); + } + + if (maxHeap.length == k) { + minCost = minCost < (ratio * currentQualitySum) ? minCost : (ratio * currentQualitySum); + } + } + + return minCost; + } +} diff --git a/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.go b/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.go new file mode 100644 index 00000000..837a0f38 --- /dev/null +++ b/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.go @@ -0,0 +1,56 @@ +func mincostToHireWorkers(quality []int, wage []int, k int) float64 { + n := len(quality) + type worker struct { + ratio float64 + quality int + } + workers := make([]worker, n) + for i := 0; i < n; i++ { + workers[i] = worker{ratio: float64(wage[i]) / float64(quality[i]), quality: quality[i]} + } + + sort.Slice(workers, func(i, j int) bool { + return workers[i].ratio < workers[j].ratio + }) + + minCost := math.MaxFloat64 + var currentQualitySum int64 = 0 + + h := &IntHeap{} + + for _, w := range workers { + currentQualitySum += int64(w.quality) + heap.Push(h, w.quality) + + if h.Len() > k { + currentQualitySum -= int64(heap.Pop(h).(int)) + } + + if h.Len() == k { + cost := w.ratio * float64(currentQualitySum) + if cost < minCost { + minCost = cost + } + } + } + + return minCost +} + +type IntHeap []int + +func (h IntHeap) Len() int { return len(h) } +func (h IntHeap) Less(i, j int) bool { return h[i] > h[j] } +func (h IntHeap) Swap(i, j int) { h[i], h[j] = h[j], h[i] } + +func (h *IntHeap) Push(x any) { + *h = append(*h, x.(int)) +} + +func (h *IntHeap) Pop() any { + old := *h + n := len(old) + x := old[n-1] + *h = old[0 : n-1] + return x +} diff --git a/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.java b/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.java new file mode 100644 index 00000000..1b957855 --- /dev/null +++ b/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.java @@ -0,0 +1,34 @@ +class Solution { + public double mincostToHireWorkers(int[] quality, int[] wage, int k) { + int n = quality.length; + double[][] workers = new double[n][2]; + for (int i = 0; i < n; ++i) { + workers[i][0] = (double)wage[i] / quality[i]; + workers[i][1] = quality[i]; + } + + Arrays.sort(workers, (a, b) -> Double.compare(a[0], b[0])); + + double minCost = Double.MAX_VALUE; + long currentQualitySum = 0; + PriorityQueue maxHeap = new PriorityQueue<>(Collections.reverseOrder()); + + for (double[] w : workers) { + double ratio = w[0]; + int q = (int)w[1]; + + currentQualitySum += q; + maxHeap.offer(q); + + if (maxHeap.size() > k) { + currentQualitySum -= maxHeap.poll(); + } + + if (maxHeap.size() == k) { + minCost = Math.min(minCost, ratio * currentQualitySum); + } + } + + return minCost; + } +} diff --git a/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.kt b/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.kt new file mode 100644 index 00000000..f246d21d --- /dev/null +++ b/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.kt @@ -0,0 +1,26 @@ +class Solution { + fun mincostToHireWorkers(quality: IntArray, wage: IntArray, k: Int): Double { + val n = quality.size + val workers = Array(n) { i -> Pair(wage[i].toDouble() / quality[i], quality[i]) } + workers.sortBy { it.first } + + var minCost = Double.MAX_VALUE + var currentQualitySum: Long = 0 + val maxHeap = java.util.PriorityQueue(compareByDescending { it }) + + for ((ratio, q) in workers) { + currentQualitySum += q + maxHeap.offer(q) + + if (maxHeap.size > k) { + currentQualitySum -= maxHeap.poll() + } + + if (maxHeap.size == k) { + minCost = minOf(minCost, ratio * currentQualitySum) + } + } + + return minCost + } +} diff --git a/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.py b/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.py new file mode 100644 index 00000000..ed8cd05f --- /dev/null +++ b/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.py @@ -0,0 +1,28 @@ +class Solution: + def mincostToHireWorkers( + self, quality: List[int], wage: List[int], k: int + ) -> float: + # 1. Coordinate Mapping: Map workers to their "Ratio Manifold" (wage/quality) + # We sort by ratio to define the "Captain" boundary. + workers = sorted([(w / q, q) for w, q in zip(wage, quality)]) + + min_cost = float("inf") + current_quality_sum = 0 + # 2. The Regret Buffer: A Max-Heap to track the most 'expensive' quality units + max_heap = [] + + for ratio, q in workers: + current_quality_sum += q + heapq.heappush(max_heap, -q) + + # 3. Constraint Satisfaction: Ensure the group size is exactly k + if len(max_heap) > k: + # Regret step: Eject the worker with the highest quality to minimize total cost + # This is equivalent to shifting the 'active set' toward lower quality. + current_quality_sum += heapq.heappop(max_heap) + + # 4. Global Convergence: If we have k workers, calculate the cost for this ratio + if len(max_heap) == k: + min_cost = min(min_cost, ratio * current_quality_sum) + + return float(min_cost) diff --git a/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.py2 b/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.py2 new file mode 100644 index 00000000..cd9698ea --- /dev/null +++ b/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.py2 @@ -0,0 +1,25 @@ +class Solution(object): + def mincostToHireWorkers(self, quality, wage, k): + """ + :type quality: List[int] + :type wage: List[int] + :type k: int + :rtype: float + """ + workers = sorted([(w / float(q), q) for w, q in zip(wage, quality)]) + + min_cost = float('inf') + current_quality_sum = 0 + max_heap = [] + + for ratio, q in workers: + current_quality_sum += q + heapq.heappush(max_heap, -q) + + if len(max_heap) > k: + current_quality_sum += heapq.heappop(max_heap) + + if len(max_heap) == k: + min_cost = min(min_cost, ratio * current_quality_sum) + + return float(min_cost) diff --git a/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.rb b/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.rb new file mode 100644 index 00000000..6da8d712 --- /dev/null +++ b/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.rb @@ -0,0 +1,27 @@ +# @param {Integer[]} quality +# @param {Integer[]} wage +# @param {Integer} k +# @return {Float} +def mincost_to_hire_workers(quality, wage, k) + workers = quality.zip(wage).map { |q, w| [w.to_f / q, q] }.sort_by { |r, _| r } + + min_cost = Float::INFINITY + current_quality_sum = 0 + max_heap = [] + + workers.each do |ratio, q| + current_quality_sum += q + max_heap.push(q) + max_heap.sort! { |a, b| b <=> a } + + if max_heap.size > k + current_quality_sum -= max_heap.shift + end + + if max_heap.size == k + min_cost = [min_cost, ratio * current_quality_sum].min + end + end + + min_cost +end diff --git a/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.rs b/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.rs new file mode 100644 index 00000000..e831cda5 --- /dev/null +++ b/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.rs @@ -0,0 +1,35 @@ +impl Solution { + pub fn mincost_to_hire_workers(quality: Vec, wage: Vec, k: i32) -> f64 { + use std::collections::BinaryHeap; + + let n = quality.len(); + let mut workers: Vec<(f64, i32)> = (0..n) + .map(|i| (wage[i] as f64 / quality[i] as f64, quality[i])) + .collect(); + workers.sort_by(|a, b| a.0.partial_cmp(&b.0).unwrap()); + + let mut min_cost = f64::MAX; + let mut current_quality_sum: i64 = 0; + let mut max_heap = BinaryHeap::new(); + + let k = k as usize; + + for (ratio, q) in workers { + current_quality_sum += q as i64; + max_heap.push(q); + + if max_heap.len() > k { + current_quality_sum -= max_heap.pop().unwrap() as i64; + } + + if max_heap.len() == k { + let cost = ratio * current_quality_sum as f64; + if cost < min_cost { + min_cost = cost; + } + } + } + + min_cost + } +} diff --git a/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.swift b/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.swift new file mode 100644 index 00000000..4c74d6fd --- /dev/null +++ b/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.swift @@ -0,0 +1,30 @@ +class Solution { + func mincostToHireWorkers(_ quality: [Int], _ wage: [Int], _ k: Int) -> Double { + let n = quality.count + var workers: [(Double, Int)] = [] + for i in 0..) + + if maxHeap.count > k { + currentQualitySum -= maxHeap.removeFirst() + } + + if maxHeap.count == k { + minCost = min(minCost, ratio * Double(currentQualitySum)) + } + } + + return minCost + } +} diff --git a/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.ts b/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.ts new file mode 100644 index 00000000..ac951781 --- /dev/null +++ b/tests/501-1000/857. minimum-cost-to-hire-k-workers/sol.ts @@ -0,0 +1,31 @@ +function mincostToHireWorkers( + quality: number[], + wage: number[], + k: number, +): number { + const workers: [number, number][] = []; + for (let i = 0; i < quality.length; i++) { + workers.push([wage[i] / quality[i], quality[i]]); + } + workers.sort((a, b) => a[0] - b[0]); + + let minCost = Number.MAX_VALUE; + let currentQualitySum = 0; + const maxHeap: number[] = []; + + for (const [ratio, q] of workers) { + currentQualitySum += q; + maxHeap.push(q); + maxHeap.sort((a, b) => b - a); + + if (maxHeap.length > k) { + currentQualitySum -= maxHeap.shift()!; + } + + if (maxHeap.length === k) { + minCost = Math.min(minCost, ratio * currentQualitySum); + } + } + + return minCost; +} diff --git a/tests/501-1000/858. mirror-reflection/manifest.yaml b/tests/501-1000/858. mirror-reflection/manifest.yaml new file mode 100644 index 00000000..350f4182 --- /dev/null +++ b/tests/501-1000/858. mirror-reflection/manifest.yaml @@ -0,0 +1,185 @@ +entry: + id: 858 + title: mirror-reflection + params: + p: + type: int + q: + type: int + call: + cpp: "Solution().mirrorReflection({p}, {q})" + rust: "Solution::mirror_reflection({p}, {q})" + python3: "Solution().mirrorReflection({p}, {q})" + python2: "Solution().mirrorReflection({p}, {q})" + ruby: "mirror_reflection({p}, {q})" + java: "new Solution().mirrorReflection({p}, {q})" + csharp: "new Solution().MirrorReflection({p}, {q})" + kotlin: "Solution().mirrorReflection({p}, {q})" + go: "mirrorReflection({p}, {q})" + dart: "Solution().mirrorReflection({p}, {q})" + swift: "Solution().mirrorReflection({p}, {q})" + typescript: "mirrorReflection({p}, {q})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().mirrorReflection(p, q, {result})" + checker: | + class Checker: + def mirrorReflection(self, p, q, result): + import math + g = math.lcm(p, q) + m = g // p + n = g // q + if m % 2 == 1 and n % 2 == 1: + expected = 1 + elif m % 2 == 1 and n % 2 == 0: + expected = 2 + else: + expected = 0 + return expected == result +seed: 858 +tests: + - name: ex1 + in: + p: 2 + q: 1 + - name: ex2 + in: + p: 3 + q: 1 + - name: t3 + in: + p: 1 + q: 1 + - name: t4 + in: + p: 2 + q: 2 + - name: t5 + in: + p: 4 + q: 1 + - name: t6 + in: + p: 4 + q: 2 + - name: t7 + in: + p: 4 + q: 3 + - name: t8 + in: + p: 6 + q: 1 + - name: t9 + in: + p: 6 + q: 2 + - name: t10 + in: + p: 6 + q: 3 + - name: t11 + in: + p: 6 + q: 4 + - name: t12 + in: + p: 6 + q: 5 + - name: t13 + in: + p: 8 + q: 1 + - name: t14 + in: + p: 8 + q: 2 + - name: t15 + in: + p: 8 + q: 4 + - name: t16 + in: + p: 9 + q: 3 + - name: t17 + in: + p: 10 + q: 5 + - name: t18 + in: + p: 12 + q: 3 + - name: t19 + in: + p: 12 + q: 4 + - name: t20 + in: + p: 12 + q: 6 + - name: t21 + in: + p: 15 + q: 5 + - name: t22 + in: + p: 16 + q: 1 + - name: t23 + in: + p: 16 + q: 8 + - name: t24 + in: + p: 18 + q: 6 + - name: t25 + in: + p: 20 + q: 10 + - name: t26 + in: + p: 24 + q: 8 + - name: t27 + in: + p: 25 + q: 1 + - name: t28 + in: + p: 30 + q: 15 + - name: t29 + in: + p: 33 + q: 11 + - name: t30 + in: + p: 36 + q: 12 + - name: t31 + in: + p: 40 + q: 5 + - name: t32 + in: + p: 50 + q: 25 + - name: t33 + in: + p: 63 + q: 21 + - name: t34 + in: + p: 1000 + q: 1 + - name: t35 + in: + p: 1000 + q: 999 diff --git a/tests/501-1000/858. mirror-reflection/sol.cpp b/tests/501-1000/858. mirror-reflection/sol.cpp new file mode 100644 index 00000000..41ec0d69 --- /dev/null +++ b/tests/501-1000/858. mirror-reflection/sol.cpp @@ -0,0 +1,16 @@ +class Solution { +public: + int mirrorReflection(int p, int q) { + while (p % 2 == 0 && q % 2 == 0) { + p /= 2; + q /= 2; + } + if (p % 2 == 0) { + return 2; + } + if (q % 2 == 0) { + return 0; + } + return 1; + } +}; diff --git a/tests/501-1000/858. mirror-reflection/sol.cs b/tests/501-1000/858. mirror-reflection/sol.cs new file mode 100644 index 00000000..dae93838 --- /dev/null +++ b/tests/501-1000/858. mirror-reflection/sol.cs @@ -0,0 +1,15 @@ +public class Solution { + public int MirrorReflection(int p, int q) { + while (p % 2 == 0 && q % 2 == 0) { + p /= 2; + q /= 2; + } + if (p % 2 == 0) { + return 2; + } + if (q % 2 == 0) { + return 0; + } + return 1; + } +} diff --git a/tests/501-1000/858. mirror-reflection/sol.dart b/tests/501-1000/858. mirror-reflection/sol.dart new file mode 100644 index 00000000..7bd46963 --- /dev/null +++ b/tests/501-1000/858. mirror-reflection/sol.dart @@ -0,0 +1,15 @@ +class Solution { + int mirrorReflection(int p, int q) { + while (p % 2 == 0 && q % 2 == 0) { + p ~/= 2; + q ~/= 2; + } + if (p % 2 == 0) { + return 2; + } + if (q % 2 == 0) { + return 0; + } + return 1; + } +} diff --git a/tests/501-1000/858. mirror-reflection/sol.go b/tests/501-1000/858. mirror-reflection/sol.go new file mode 100644 index 00000000..e060fd57 --- /dev/null +++ b/tests/501-1000/858. mirror-reflection/sol.go @@ -0,0 +1,13 @@ +func mirrorReflection(p int, q int) int { + for p%2 == 0 && q%2 == 0 { + p /= 2 + q /= 2 + } + if p%2 == 0 { + return 2 + } + if q%2 == 0 { + return 0 + } + return 1 +} diff --git a/tests/501-1000/858. mirror-reflection/sol.java b/tests/501-1000/858. mirror-reflection/sol.java new file mode 100644 index 00000000..8d278e18 --- /dev/null +++ b/tests/501-1000/858. mirror-reflection/sol.java @@ -0,0 +1,15 @@ +class Solution { + public int mirrorReflection(int p, int q) { + while (p % 2 == 0 && q % 2 == 0) { + p /= 2; + q /= 2; + } + if (p % 2 == 0) { + return 2; + } + if (q % 2 == 0) { + return 0; + } + return 1; + } +} diff --git a/tests/501-1000/858. mirror-reflection/sol.kt b/tests/501-1000/858. mirror-reflection/sol.kt new file mode 100644 index 00000000..bf327025 --- /dev/null +++ b/tests/501-1000/858. mirror-reflection/sol.kt @@ -0,0 +1,13 @@ +class Solution { + fun mirrorReflection(p: Int, q: Int): Int { + var pp = p + var qq = q + while (pp % 2 == 0 && qq % 2 == 0) { + pp /= 2 + qq /= 2 + } + if (pp % 2 == 0) return 2 + if (qq % 2 == 0) return 0 + return 1 + } +} diff --git a/tests/501-1000/858. mirror-reflection/sol.py b/tests/501-1000/858. mirror-reflection/sol.py new file mode 100644 index 00000000..15c1e868 --- /dev/null +++ b/tests/501-1000/858. mirror-reflection/sol.py @@ -0,0 +1,23 @@ +class Solution(object): + def mirrorReflection(self, p, q): + """ + :type p: int + :type q: int + :rtype: int + """ + result = -1 + i = 1 + height = 0 + while result != 0 or result != 1 or result != 2: + height += q + if height % p == 0: + if (height / p) % 2 == 0: + result = 0 + break + if i % 2 == 0: + result = 2 + break + result = 1 + break + i += 1 + return result diff --git a/tests/501-1000/858. mirror-reflection/sol.py2 b/tests/501-1000/858. mirror-reflection/sol.py2 new file mode 100644 index 00000000..5585f689 --- /dev/null +++ b/tests/501-1000/858. mirror-reflection/sol.py2 @@ -0,0 +1,23 @@ +class Solution(object): + def mirrorReflection(self, p, q): + """ + :type p: int + :type q: int + :rtype: int + """ + result = -1 + i = 1 + height = 0 + while(result != 0 or result != 1 or result != 2) : + height += q + if height % p == 0 : + if (height / p) % 2 == 0 : + result = 0 + break + if i % 2 == 0 : + result = 2 + break + result = 1 + break + i += 1 + return result diff --git a/tests/501-1000/858. mirror-reflection/sol.rb b/tests/501-1000/858. mirror-reflection/sol.rb new file mode 100644 index 00000000..d0761e51 --- /dev/null +++ b/tests/501-1000/858. mirror-reflection/sol.rb @@ -0,0 +1,12 @@ +# @param {Integer} p +# @param {Integer} q +# @return {Integer} +def mirror_reflection(p, q) + while p.even? && q.even? + p /= 2 + q /= 2 + end + return 2 if p.even? + return 0 if q.even? + 1 +end diff --git a/tests/501-1000/858. mirror-reflection/sol.rs b/tests/501-1000/858. mirror-reflection/sol.rs new file mode 100644 index 00000000..bc662a58 --- /dev/null +++ b/tests/501-1000/858. mirror-reflection/sol.rs @@ -0,0 +1,17 @@ +impl Solution { + pub fn mirror_reflection(p: i32, q: i32) -> i32 { + let mut pp = p; + let mut qq = q; + while pp % 2 == 0 && qq % 2 == 0 { + pp /= 2; + qq /= 2; + } + if pp % 2 == 0 { + 2 + } else if qq % 2 == 0 { + 0 + } else { + 1 + } + } +} diff --git a/tests/501-1000/858. mirror-reflection/sol.swift b/tests/501-1000/858. mirror-reflection/sol.swift new file mode 100644 index 00000000..77c89277 --- /dev/null +++ b/tests/501-1000/858. mirror-reflection/sol.swift @@ -0,0 +1,13 @@ +class Solution { + func mirrorReflection(_ p: Int, _ q: Int) -> Int { + var pp = p + var qq = q + while pp % 2 == 0 && qq % 2 == 0 { + pp /= 2 + qq /= 2 + } + if pp % 2 == 0 { return 2 } + if qq % 2 == 0 { return 0 } + return 1 + } +} diff --git a/tests/501-1000/858. mirror-reflection/sol.ts b/tests/501-1000/858. mirror-reflection/sol.ts new file mode 100644 index 00000000..2b049f6b --- /dev/null +++ b/tests/501-1000/858. mirror-reflection/sol.ts @@ -0,0 +1,13 @@ +function mirrorReflection(p: number, q: number): number { + while (p % 2 === 0 && q % 2 === 0) { + p /= 2; + q /= 2; + } + if (p % 2 === 0) { + return 2; + } + if (q % 2 === 0) { + return 0; + } + return 1; +} diff --git a/tests/501-1000/859. buddy-strings/manifest.yaml b/tests/501-1000/859. buddy-strings/manifest.yaml new file mode 100644 index 00000000..11f4c535 --- /dev/null +++ b/tests/501-1000/859. buddy-strings/manifest.yaml @@ -0,0 +1,203 @@ +entry: + id: 859 + title: buddy-strings + params: + s: + type: string + goal: + type: string + call: + cpp: "Solution().buddyStrings({s}, {goal})" + rust: "Solution::buddy_strings({s}, {goal})" + python3: "Solution().buddyStrings({s}, {goal})" + python2: "Solution().buddyStrings({s}, {goal})" + ruby: "buddy_strings({s}, {goal})" + java: "new Solution().buddyStrings({s}, {goal})" + csharp: "new Solution().BuddyStrings({s}, {goal})" + kotlin: "Solution().buddyStrings({s}, {goal})" + go: "buddyStrings({s}, {goal})" + dart: "Solution().buddyStrings({s}, {goal})" + swift: "Solution().buddyStrings({s}, {goal})" + typescript: "buddyStrings({s}, {goal})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().buddyStrings(s, goal, {result})" + checker: | + from collections import Counter + + class Checker: + def buddyStrings(self, s, goal, result): + if len(s) != len(goal): + return result is False + if s == goal: + return (len(set(s)) < len(s)) == result + diffs = [i for i, (a, b) in enumerate(zip(s, goal)) if a != b] + expected = len(diffs) == 2 and s[diffs[0]] == goal[diffs[1]] and s[diffs[1]] == goal[diffs[0]] + return expected == result +seed: 859 +tests: + - name: ex1 + in: + s: ab + goal: ba + - name: ex2 + in: + s: ab + goal: ab + - name: ex3 + in: + s: aa + goal: aa + - name: len1a + in: + s: a + goal: a + - name: len1b + in: + s: a + goal: b + - name: diff1 + in: + s: abc + goal: abd + - name: diff2 + in: + s: abcd + goal: abdc + - name: diff3 + in: + s: abcd + goal: bacd + - name: diff4 + in: + s: aabc + goal: abac + - name: diff5 + in: + s: aabc + goal: aabc + - name: diff6 + in: + s: aaab + goal: aaab + - name: diff7 + in: + s: aaa + goal: aaa + - name: diff8 + in: + s: abcdef + goal: abcfed + - name: diff9 + in: + s: abcdef + goal: abcdef + - name: diff10 + in: + s: aaaaa + goal: aaaaa + - name: diff11 + in: + s: aaaaa + goal: aaaab + - name: diff12 + in: + s: abca + goal: abca + - name: diff13 + in: + s: abca + goal: abac + - name: diff14 + in: + s: zyxw + goal: zxyw + - name: diff15 + in: + s: zyxw + goal: zyxw + - name: diff16 + in: + s: abcd + goal: abcd + - name: diff17 + in: + s: aabbcc + goal: aabbcc + - name: diff18 + in: + s: aabbcc + goal: aabcbc + - name: diff19 + in: + s: ab + goal: ac + - name: diff20 + in: + s: xyz + goal: xzy + - name: diff21 + in: + s: xyz + goal: xyz + - name: diff22 + in: + s: xxyy + goal: xxyy + - name: diff23 + in: + s: xxyy + goal: xyxy + - name: diff24 + in: + s: abcabc + goal: abcabc + - name: diff25 + in: + s: abcabc + goal: abccab + - name: diff26 + in: + s: aabb + goal: bbaa + - name: diff27 + in: + s: aabb + goal: aabb + - name: diff28 + in: + s: qwerty + goal: qewrty + - name: diff29 + in: + s: qwerty + goal: qwerty + - name: diff30 + in: + s: aacb + goal: abca + - name: diff31 + in: + s: aacb + goal: aacb + - name: diff32 + in: + s: abcde + goal: abced + - name: diff33 + in: + s: abcde + goal: abcde + - name: diff34 + in: + s: hello + goal: heoll + - name: diff35 + in: + s: hello + goal: hello diff --git a/tests/501-1000/859. buddy-strings/sol.cpp b/tests/501-1000/859. buddy-strings/sol.cpp new file mode 100644 index 00000000..6e4203bf --- /dev/null +++ b/tests/501-1000/859. buddy-strings/sol.cpp @@ -0,0 +1,17 @@ +class Solution { +public: + bool buddyStrings(string s, string goal) { + if (s.length() != goal.length()) return false; + if (s == goal) { + unordered_set seen(s.begin(), s.end()); + return seen.size() < s.length(); + } + vector diffs; + for (int i = 0; i < s.length(); i++) { + if (s[i] != goal[i]) { + diffs.push_back(i); + } + } + return diffs.size() == 2 && s[diffs[0]] == goal[diffs[1]] && s[diffs[1]] == goal[diffs[0]]; + } +}; diff --git a/tests/501-1000/859. buddy-strings/sol.cs b/tests/501-1000/859. buddy-strings/sol.cs new file mode 100644 index 00000000..e47a792e --- /dev/null +++ b/tests/501-1000/859. buddy-strings/sol.cs @@ -0,0 +1,15 @@ +public class Solution { + public bool BuddyStrings(string s, string goal) { + if (s.Length != goal.Length) return false; + if (s == goal) { + return new HashSet(s).Count < s.Length; + } + List diffs = new List(); + for (int i = 0; i < s.Length; i++) { + if (s[i] != goal[i]) { + diffs.Add(i); + } + } + return diffs.Count == 2 && s[diffs[0]] == goal[diffs[1]] && s[diffs[1]] == goal[diffs[0]]; + } +} diff --git a/tests/501-1000/859. buddy-strings/sol.dart b/tests/501-1000/859. buddy-strings/sol.dart new file mode 100644 index 00000000..b3a5ab10 --- /dev/null +++ b/tests/501-1000/859. buddy-strings/sol.dart @@ -0,0 +1,15 @@ +class Solution { + bool buddyStrings(String s, String goal) { + if (s.length != goal.length) return false; + if (s == goal) { + return s.runes.toSet().length < s.length; + } + List diffs = []; + for (int i = 0; i < s.length; i++) { + if (s[i] != goal[i]) { + diffs.add(i); + } + } + return diffs.length == 2 && s[diffs[0]] == goal[diffs[1]] && s[diffs[1]] == goal[diffs[0]]; + } +} diff --git a/tests/501-1000/859. buddy-strings/sol.go b/tests/501-1000/859. buddy-strings/sol.go new file mode 100644 index 00000000..41eee6db --- /dev/null +++ b/tests/501-1000/859. buddy-strings/sol.go @@ -0,0 +1,22 @@ +func buddyStrings(s string, goal string) bool { + if len(s) != len(goal) { + return false + } + if s == goal { + seen := make(map[rune]bool) + for _, c := range s { + if seen[c] { + return true + } + seen[c] = true + } + return false + } + diffs := []int{} + for i := 0; i < len(s); i++ { + if s[i] != goal[i] { + diffs = append(diffs, i) + } + } + return len(diffs) == 2 && s[diffs[0]] == goal[diffs[1]] && s[diffs[1]] == goal[diffs[0]] +} diff --git a/tests/501-1000/859. buddy-strings/sol.java b/tests/501-1000/859. buddy-strings/sol.java new file mode 100644 index 00000000..c3774d83 --- /dev/null +++ b/tests/501-1000/859. buddy-strings/sol.java @@ -0,0 +1,21 @@ +class Solution { + public boolean buddyStrings(String s, String goal) { + if (s.length() != goal.length()) return false; + if (s.equals(goal)) { + int[] count = new int[26]; + for (char c : s.toCharArray()) { + if (++count[c - 'a'] > 1) return true; + } + return false; + } + int first = -1, second = -1; + for (int i = 0; i < s.length(); i++) { + if (s.charAt(i) != goal.charAt(i)) { + if (first == -1) first = i; + else if (second == -1) second = i; + else return false; + } + } + return second != -1 && s.charAt(first) == goal.charAt(second) && s.charAt(second) == goal.charAt(first); + } +} diff --git a/tests/501-1000/859. buddy-strings/sol.kt b/tests/501-1000/859. buddy-strings/sol.kt new file mode 100644 index 00000000..97575c16 --- /dev/null +++ b/tests/501-1000/859. buddy-strings/sol.kt @@ -0,0 +1,15 @@ +class Solution { + fun buddyStrings(s: String, goal: String): Boolean { + if (s.length != goal.length) return false + if (s == goal) { + return s.toCharArray().distinct().size < s.length + } + val diffs = mutableListOf() + for (i in s.indices) { + if (s[i] != goal[i]) { + diffs.add(i) + } + } + return diffs.size == 2 && s[diffs[0]] == goal[diffs[1]] && s[diffs[1]] == goal[diffs[0]] + } +} diff --git a/tests/501-1000/859. buddy-strings/sol.py b/tests/501-1000/859. buddy-strings/sol.py new file mode 100644 index 00000000..675f87df --- /dev/null +++ b/tests/501-1000/859. buddy-strings/sol.py @@ -0,0 +1,15 @@ +class Solution: + def buddyStrings(self, s: str, goal: str) -> bool: + if len(s) != len(goal): + return False + if s == goal: + return len(set(s)) < len(s) + diffs = [] + for i in range(len(s)): + if s[i] != goal[i]: + diffs.append(i) + return ( + len(diffs) == 2 + and s[diffs[0]] == goal[diffs[1]] + and s[diffs[1]] == goal[diffs[0]] + ) diff --git a/tests/501-1000/859. buddy-strings/sol.py2 b/tests/501-1000/859. buddy-strings/sol.py2 new file mode 100644 index 00000000..54fc02c4 --- /dev/null +++ b/tests/501-1000/859. buddy-strings/sol.py2 @@ -0,0 +1,16 @@ +class Solution(object): + def buddyStrings(self, s, goal): + """ + :type s: str + :type goal: str + :rtype: bool + """ + if len(s) != len(goal): + return False + if s == goal: + return len(set(s)) < len(s) + diffs = [] + for i in range(len(s)): + if s[i] != goal[i]: + diffs.append(i) + return len(diffs) == 2 and s[diffs[0]] == goal[diffs[1]] and s[diffs[1]] == goal[diffs[0]] diff --git a/tests/501-1000/859. buddy-strings/sol.rb b/tests/501-1000/859. buddy-strings/sol.rb new file mode 100644 index 00000000..59460664 --- /dev/null +++ b/tests/501-1000/859. buddy-strings/sol.rb @@ -0,0 +1,16 @@ +# @param {String} s +# @param {String} goal +# @return {Boolean} +def buddy_strings(s, goal) + return false if s.length != goal.length + if s == goal + return s.chars.uniq.length < s.length + end + diffs = [] + (0...s.length).each do |i| + if s[i] != goal[i] + diffs << i + end + end + return diffs.length == 2 && s[diffs[0]] == goal[diffs[1]] && s[diffs[1]] == goal[diffs[0]] +end diff --git a/tests/501-1000/859. buddy-strings/sol.rs b/tests/501-1000/859. buddy-strings/sol.rs new file mode 100644 index 00000000..6da45217 --- /dev/null +++ b/tests/501-1000/859. buddy-strings/sol.rs @@ -0,0 +1,25 @@ +impl Solution { + pub fn buddy_strings(s: String, goal: String) -> bool { + if s.len() != goal.len() { + return false; + } + if s == goal { + let mut seen = std::collections::HashSet::new(); + for c in s.chars() { + if !seen.insert(c) { + return true; + } + } + return false; + } + let s_bytes = s.as_bytes(); + let g_bytes = goal.as_bytes(); + let mut diffs = Vec::new(); + for i in 0..s.len() { + if s_bytes[i] != g_bytes[i] { + diffs.push(i); + } + } + diffs.len() == 2 && s_bytes[diffs[0]] == g_bytes[diffs[1]] && s_bytes[diffs[1]] == g_bytes[diffs[0]] + } +} diff --git a/tests/501-1000/859. buddy-strings/sol.swift b/tests/501-1000/859. buddy-strings/sol.swift new file mode 100644 index 00000000..027c3a7e --- /dev/null +++ b/tests/501-1000/859. buddy-strings/sol.swift @@ -0,0 +1,17 @@ +class Solution { + func buddyStrings(_ s: String, _ goal: String) -> Bool { + if s.count != goal.count { return false } + if s == goal { + return Set(s).count < s.count + } + let sArr = Array(s) + let gArr = Array(goal) + var diffs: [Int] = [] + for i in 0..= 1 and t >= 1: + f -= 1 + t -= 1 + elif f >= 3: + f -= 3 + else: + return result is False + return result is True +seed: 860 +tests: + - name: ex1 + in: + bills: [5, 5, 5, 10, 20] + - name: ex2 + in: + bills: [5, 5, 10, 10, 20] + - name: t3 + in: + bills: [5] + - name: t4 + in: + bills: [10] + - name: t5 + in: + bills: [20] + - name: t6 + in: + bills: [5, 10] + - name: t7 + in: + bills: [5, 20] + - name: t8 + in: + bills: [5, 5, 10] + - name: t9 + in: + bills: [5, 5, 20] + - name: t10 + in: + bills: [5, 5, 5, 20] + - name: t11 + in: + bills: [5, 5, 5, 10, 20] + - name: t12 + in: + bills: [5, 10, 5, 20] + - name: t13 + in: + bills: [5, 10, 20] + - name: t14 + in: + bills: [5, 5, 10, 20] + - name: t15 + in: + bills: [5, 5, 10, 5, 20] + - name: t16 + in: + bills: [5, 5, 10, 10] + - name: t17 + in: + bills: [5, 5, 5, 10, 10, 20] + - name: t18 + in: + bills: [5, 5, 5, 10, 20, 20] + - name: t19 + in: + bills: [5, 5, 5, 5, 10, 20, 20] + - name: t20 + in: + bills: [5, 5, 5, 5, 20, 20] + - name: t21 + in: + bills: [5, 10, 10] + - name: t22 + in: + bills: [5, 10, 5, 10, 20] + - name: t23 + in: + bills: [5, 5, 10, 5, 10, 20] + - name: t24 + in: + bills: [5, 5, 5, 10, 5, 10, 20] + - name: t25 + in: + bills: [5, 5, 5, 10, 10, 10, 20] + - name: t26 + in: + bills: [5, 5, 5, 5, 10, 10, 20] + - name: t27 + in: + bills: [5, 5, 5, 5, 10, 20, 10, 20] + - name: t28 + in: + bills: [5, 5, 5, 10, 20, 10, 20] + - name: t29 + in: + bills: [5, 10, 20, 5, 5, 10, 20] + - name: t30 + in: + bills: [5, 5, 10, 20, 5, 10, 20] + - name: t31 + in: + bills: [5, 5, 5, 10, 20, 5, 10, 20] + - name: t32 + in: + bills: [5, 5, 5, 5, 10, 20, 5, 10, 20] + - name: t33 + in: + bills: [5, 5, 5, 5, 5, 10, 20, 20, 20] + - name: t34 + in: + bills: [5, 5, 10, 5, 5, 10, 20, 20] + - name: t35 + in: + bills: [5, 5, 5, 10, 5, 5, 10, 20, 20] diff --git a/tests/501-1000/860. lemonade-change/sol.cpp b/tests/501-1000/860. lemonade-change/sol.cpp new file mode 100644 index 00000000..d67c37f9 --- /dev/null +++ b/tests/501-1000/860. lemonade-change/sol.cpp @@ -0,0 +1,28 @@ +class Solution { +public: + bool lemonadeChange(vector& bills) { + int f = 0, t = 0; + for (int bill : bills) { + if (bill == 5) { + f++; + } else if (bill == 10) { + if (f >= 1) { + f--; + t++; + } else { + return false; + } + } else { + if (f >= 1 && t >= 1) { + t--; + f--; + } else if (f >= 3) { + f -= 3; + } else { + return false; + } + } + } + return true; + } +}; diff --git a/tests/501-1000/860. lemonade-change/sol.cs b/tests/501-1000/860. lemonade-change/sol.cs new file mode 100644 index 00000000..99bff73d --- /dev/null +++ b/tests/501-1000/860. lemonade-change/sol.cs @@ -0,0 +1,27 @@ +public class Solution { + public bool LemonadeChange(int[] bills) { + int f = 0, t = 0; + foreach (int bill in bills) { + if (bill == 5) { + f++; + } else if (bill == 10) { + if (f >= 1) { + f--; + t++; + } else { + return false; + } + } else { + if (f >= 1 && t >= 1) { + t--; + f--; + } else if (f >= 3) { + f -= 3; + } else { + return false; + } + } + } + return true; + } +} diff --git a/tests/501-1000/860. lemonade-change/sol.dart b/tests/501-1000/860. lemonade-change/sol.dart new file mode 100644 index 00000000..24a5f6ef --- /dev/null +++ b/tests/501-1000/860. lemonade-change/sol.dart @@ -0,0 +1,27 @@ +class Solution { + bool lemonadeChange(List bills) { + int f = 0, t = 0; + for (int bill in bills) { + if (bill == 5) { + f++; + } else if (bill == 10) { + if (f >= 1) { + f--; + t++; + } else { + return false; + } + } else { + if (f >= 1 && t >= 1) { + t--; + f--; + } else if (f >= 3) { + f -= 3; + } else { + return false; + } + } + } + return true; + } +} diff --git a/tests/501-1000/860. lemonade-change/sol.go b/tests/501-1000/860. lemonade-change/sol.go new file mode 100644 index 00000000..9a19ab0f --- /dev/null +++ b/tests/501-1000/860. lemonade-change/sol.go @@ -0,0 +1,25 @@ +func lemonadeChange(bills []int) bool { + f, t := 0, 0 + for _, bill := range bills { + if bill == 5 { + f++ + } else if bill == 10 { + if f >= 1 { + f-- + t++ + } else { + return false + } + } else { + if f >= 1 && t >= 1 { + t-- + f-- + } else if f >= 3 { + f -= 3 + } else { + return false + } + } + } + return true +} diff --git a/tests/501-1000/860. lemonade-change/sol.java b/tests/501-1000/860. lemonade-change/sol.java new file mode 100644 index 00000000..121dbc8e --- /dev/null +++ b/tests/501-1000/860. lemonade-change/sol.java @@ -0,0 +1,27 @@ +class Solution { + public boolean lemonadeChange(int[] bills) { + int f = 0, t = 0; + for (int bill : bills) { + if (bill == 5) { + f++; + } else if (bill == 10) { + if (f >= 1) { + f--; + t++; + } else { + return false; + } + } else { + if (f >= 1 && t >= 1) { + t--; + f--; + } else if (f >= 3) { + f -= 3; + } else { + return false; + } + } + } + return true; + } +} diff --git a/tests/501-1000/860. lemonade-change/sol.kt b/tests/501-1000/860. lemonade-change/sol.kt new file mode 100644 index 00000000..69b0804a --- /dev/null +++ b/tests/501-1000/860. lemonade-change/sol.kt @@ -0,0 +1,28 @@ +class Solution { + fun lemonadeChange(bills: IntArray): Boolean { + var f = 0 + var t = 0 + for (bill in bills) { + if (bill == 5) { + f++ + } else if (bill == 10) { + if (f >= 1) { + f-- + t++ + } else { + return false + } + } else { + if (f >= 1 && t >= 1) { + t-- + f-- + } else if (f >= 3) { + f -= 3 + } else { + return false + } + } + } + return true + } +} diff --git a/tests/501-1000/860. lemonade-change/sol.py b/tests/501-1000/860. lemonade-change/sol.py new file mode 100644 index 00000000..cfa64b3d --- /dev/null +++ b/tests/501-1000/860. lemonade-change/sol.py @@ -0,0 +1,26 @@ +# Python Code +class Solution(object): + def lemonadeChange(self, bills): + """ + :type bills: List[int] + :rtype: bool + """ + f, t = 0, 0 + for bill in bills: + if bill == 5: + f += 1 + elif bill == 10: + if f >= 1: + f -= 1 + t += 1 + else: + return False + else: + if f >= 1 and t >= 1: + t -= 1 + f -= 1 + elif f >= 3: + f -= 3 + else: + return False + return True diff --git a/tests/501-1000/860. lemonade-change/sol.py2 b/tests/501-1000/860. lemonade-change/sol.py2 new file mode 100644 index 00000000..7aec9522 --- /dev/null +++ b/tests/501-1000/860. lemonade-change/sol.py2 @@ -0,0 +1,25 @@ +class Solution(object): + def lemonadeChange(self, bills): + """ + :type bills: List[int] + :rtype: bool + """ + f, t = 0, 0 + for bill in bills: + if bill == 5: + f += 1 + elif bill == 10: + if f >= 1: + f -= 1 + t += 1 + else: + return False + else: + if f >= 1 and t >= 1: + t -= 1 + f -= 1 + elif f >= 3: + f -= 3 + else: + return False + return True diff --git a/tests/501-1000/860. lemonade-change/sol.rb b/tests/501-1000/860. lemonade-change/sol.rb new file mode 100644 index 00000000..ba4eee03 --- /dev/null +++ b/tests/501-1000/860. lemonade-change/sol.rb @@ -0,0 +1,28 @@ +# @param {Integer[]} bills +# @return {Boolean} +def lemonade_change(bills) + f = 0 + t = 0 + bills.each do |bill| + if bill == 5 + f += 1 + elsif bill == 10 + if f >= 1 + f -= 1 + t += 1 + else + return false + end + else + if f >= 1 && t >= 1 + t -= 1 + f -= 1 + elsif f >= 3 + f -= 3 + else + return false + end + end + end + true +end diff --git a/tests/501-1000/860. lemonade-change/sol.rs b/tests/501-1000/860. lemonade-change/sol.rs new file mode 100644 index 00000000..32529efc --- /dev/null +++ b/tests/501-1000/860. lemonade-change/sol.rs @@ -0,0 +1,28 @@ +impl Solution { + pub fn lemonade_change(bills: Vec) -> bool { + let mut f = 0; + let mut t = 0; + for bill in bills { + if bill == 5 { + f += 1; + } else if bill == 10 { + if f >= 1 { + f -= 1; + t += 1; + } else { + return false; + } + } else { + if f >= 1 && t >= 1 { + t -= 1; + f -= 1; + } else if f >= 3 { + f -= 3; + } else { + return false; + } + } + } + true + } +} diff --git a/tests/501-1000/860. lemonade-change/sol.swift b/tests/501-1000/860. lemonade-change/sol.swift new file mode 100644 index 00000000..d02f3ca6 --- /dev/null +++ b/tests/501-1000/860. lemonade-change/sol.swift @@ -0,0 +1,28 @@ +class Solution { + func lemonadeChange(_ bills: [Int]) -> Bool { + var f = 0 + var t = 0 + for bill in bills { + if bill == 5 { + f += 1 + } else if bill == 10 { + if f >= 1 { + f -= 1 + t += 1 + } else { + return false + } + } else { + if f >= 1 && t >= 1 { + t -= 1 + f -= 1 + } else if f >= 3 { + f -= 3 + } else { + return false + } + } + } + return true + } +} diff --git a/tests/501-1000/860. lemonade-change/sol.ts b/tests/501-1000/860. lemonade-change/sol.ts new file mode 100644 index 00000000..f2457c6a --- /dev/null +++ b/tests/501-1000/860. lemonade-change/sol.ts @@ -0,0 +1,26 @@ +function lemonadeChange(bills: number[]): boolean { + let f = 0, + t = 0; + for (const bill of bills) { + if (bill === 5) { + f++; + } else if (bill === 10) { + if (f >= 1) { + f--; + t++; + } else { + return false; + } + } else { + if (f >= 1 && t >= 1) { + t--; + f--; + } else if (f >= 3) { + f -= 3; + } else { + return false; + } + } + } + return true; +} diff --git a/tests/501-1000/861. score-after-flipping-matrix/manifest.yaml b/tests/501-1000/861. score-after-flipping-matrix/manifest.yaml new file mode 100644 index 00000000..b1c26d4e --- /dev/null +++ b/tests/501-1000/861. score-after-flipping-matrix/manifest.yaml @@ -0,0 +1,309 @@ +entry: + id: 861 + title: score-after-flipping-matrix + params: + grid: + type: array + items: + type: array + items: + type: int + call: + cpp: "Solution().matrixScore({grid})" + rust: "Solution::matrix_score({grid})" + python3: "Solution().matrixScore({grid})" + python2: "Solution().matrixScore({grid})" + ruby: "matrix_score({grid})" + java: "new Solution().matrixScore({grid})" + csharp: "new Solution().MatrixScore({grid})" + kotlin: "Solution().matrixScore({grid})" + go: "matrixScore({grid})" + dart: "Solution().matrixScore({grid})" + swift: "Solution().matrixScore({grid})" + typescript: "matrixScore({grid})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().matrixScore(grid, {result})" + checker: | + class Checker: + def matrixScore(self, grid, result): + g = [row[:] for row in grid] + rows = len(g) + cols = len(g[0]) + for i in range(rows): + if g[i][0] == 0: + for j in range(cols): + g[i][j] ^= 1 + total = 0 + for j in range(cols): + ones = sum(g[i][j] for i in range(rows)) + best = max(ones, rows - ones) + total += best * (1 << (cols - j - 1)) + return total == result +seed: 861 +tests: + - name: ex1 + in: + grid: + elemType: int + value: + - [0, 0, 1, 1] + - [1, 0, 1, 0] + - [1, 1, 0, 0] + - name: ex2 + in: + grid: + elemType: int + value: + - [0] + - name: t3 + in: + grid: + elemType: int + value: + - [1] + - name: t4 + in: + grid: + elemType: int + value: + - [0, 0] + - [0, 0] + - name: t5 + in: + grid: + elemType: int + value: + - [1, 1] + - [1, 1] + - name: t6 + in: + grid: + elemType: int + value: + - [0, 1] + - [1, 0] + - name: t7 + in: + grid: + elemType: int + value: + - [1, 0] + - [0, 1] + - name: t8 + in: + grid: + elemType: int + value: + - [0, 1, 0] + - [1, 0, 1] + - name: t9 + in: + grid: + elemType: int + value: + - [1, 0, 0] + - [0, 1, 1] + - name: t10 + in: + grid: + elemType: int + value: + - [0, 0, 0] + - [1, 1, 1] + - [0, 1, 0] + - name: t11 + in: + grid: + elemType: int + value: + - [1, 1, 1] + - [0, 0, 0] + - [1, 0, 1] + - name: t12 + in: + grid: + elemType: int + value: + - [0, 1, 1, 0] + - [1, 0, 0, 1] + - [1, 1, 0, 0] + - name: t13 + in: + grid: + elemType: int + value: + - [1, 0, 1, 0] + - [0, 1, 0, 1] + - [1, 1, 1, 1] + - name: t14 + in: + grid: + elemType: int + value: + - [0, 1, 0, 1, 0] + - [1, 0, 1, 0, 1] + - name: t15 + in: + grid: + elemType: int + value: + - [1, 0, 1, 0, 1] + - [0, 1, 0, 1, 0] + - name: t16 + in: + grid: + elemType: int + value: + - [0, 0, 1, 1, 0] + - [1, 1, 0, 0, 1] + - name: t17 + in: + grid: + elemType: int + value: + - [1, 1, 0, 0, 1] + - [0, 0, 1, 1, 0] + - name: t18 + in: + grid: + elemType: int + value: + - [0, 1, 1] + - [0, 1, 1] + - [0, 1, 1] + - name: t19 + in: + grid: + elemType: int + value: + - [1, 0, 0] + - [1, 0, 0] + - [1, 0, 0] + - name: t20 + in: + grid: + elemType: int + value: + - [0, 1] + - name: t21 + in: + grid: + elemType: int + value: + - [1, 0] + - name: t22 + in: + grid: + elemType: int + value: + - [0, 0, 0, 0] + - name: t23 + in: + grid: + elemType: int + value: + - [1, 1, 1, 1] + - name: t24 + in: + grid: + elemType: int + value: + - [0, 0, 0, 1] + - [0, 0, 1, 0] + - [0, 1, 0, 0] + - name: t25 + in: + grid: + elemType: int + value: + - [1, 1, 1, 0] + - [1, 1, 0, 1] + - [1, 0, 1, 1] + - name: t26 + in: + grid: + elemType: int + value: + - [0, 1, 0, 1] + - [1, 0, 1, 0] + - [0, 1, 0, 1] + - [1, 0, 1, 0] + - name: t27 + in: + grid: + elemType: int + value: + - [1, 0, 1, 0] + - [0, 1, 0, 1] + - [1, 0, 1, 0] + - [0, 1, 0, 1] + - name: t28 + in: + grid: + elemType: int + value: + - [0, 0, 1, 1] + - [0, 0, 1, 1] + - [1, 1, 0, 0] + - [1, 1, 0, 0] + - name: t29 + in: + grid: + elemType: int + value: + - [1, 1, 0, 0] + - [1, 1, 0, 0] + - [0, 0, 1, 1] + - [0, 0, 1, 1] + - name: t30 + in: + grid: + elemType: int + value: + - [0, 0, 0, 0, 0] + - [1, 1, 1, 1, 1] + - [0, 0, 0, 0, 0] + - name: t31 + in: + grid: + elemType: int + value: + - [1, 1, 1, 1, 1] + - [0, 0, 0, 0, 0] + - [1, 1, 1, 1, 1] + - name: t32 + in: + grid: + elemType: int + value: + - [0, 1, 1, 1, 1, 0] + - [1, 0, 0, 0, 0, 1] + - name: t33 + in: + grid: + elemType: int + value: + - [1, 0, 0, 0, 0, 1] + - [0, 1, 1, 1, 1, 0] + - name: t34 + in: + grid: + elemType: int + value: + - [0, 1, 0, 1, 0, 1] + - [1, 0, 1, 0, 1, 0] + - [0, 1, 0, 1, 0, 1] + - name: t35 + in: + grid: + elemType: int + value: + - [1, 0, 1, 0, 1, 0] + - [0, 1, 0, 1, 0, 1] + - [1, 0, 1, 0, 1, 0] diff --git a/tests/501-1000/861. score-after-flipping-matrix/sol.cpp b/tests/501-1000/861. score-after-flipping-matrix/sol.cpp new file mode 100644 index 00000000..fac4d6a1 --- /dev/null +++ b/tests/501-1000/861. score-after-flipping-matrix/sol.cpp @@ -0,0 +1,34 @@ +class Solution { +public: + int matrixScore(vector>& grid) { + int rows = grid.size(); + int cols = grid[0].size(); + for (auto& row : grid) { + if (row[0] == 0) { + for (int i = 0; i < cols; i++) { + row[i] ^= 1; + } + } + } + for (int j = 1; j < cols; j++) { + int temp = 0; + for (int i = 0; i < rows; i++) { + temp += grid[i][j]; + } + if (2 * temp < rows) { + for (int i = 0; i < rows; i++) { + grid[i][j] ^= 1; + } + } + } + int ans = 0; + for (auto& row : grid) { + int val = 0; + for (int bit : row) { + val = (val << 1) | bit; + } + ans += val; + } + return ans; + } +}; diff --git a/tests/501-1000/861. score-after-flipping-matrix/sol.cs b/tests/501-1000/861. score-after-flipping-matrix/sol.cs new file mode 100644 index 00000000..707bbc70 --- /dev/null +++ b/tests/501-1000/861. score-after-flipping-matrix/sol.cs @@ -0,0 +1,33 @@ +public class Solution { + public int MatrixScore(int[][] grid) { + int rows = grid.Length; + int cols = grid[0].Length; + foreach (var row in grid) { + if (row[0] == 0) { + for (int i = 0; i < cols; i++) { + row[i] ^= 1; + } + } + } + for (int j = 1; j < cols; j++) { + int temp = 0; + for (int i = 0; i < rows; i++) { + temp += grid[i][j]; + } + if (2 * temp < rows) { + for (int i = 0; i < rows; i++) { + grid[i][j] ^= 1; + } + } + } + int ans = 0; + foreach (var row in grid) { + int val = 0; + foreach (int bit in row) { + val = (val << 1) | bit; + } + ans += val; + } + return ans; + } +} diff --git a/tests/501-1000/861. score-after-flipping-matrix/sol.dart b/tests/501-1000/861. score-after-flipping-matrix/sol.dart new file mode 100644 index 00000000..948083e6 --- /dev/null +++ b/tests/501-1000/861. score-after-flipping-matrix/sol.dart @@ -0,0 +1,33 @@ +class Solution { + int matrixScore(List> grid) { + int rows = grid.length; + int cols = grid[0].length; + for (var row in grid) { + if (row[0] == 0) { + for (int i = 0; i < cols; i++) { + row[i] ^= 1; + } + } + } + for (int j = 1; j < cols; j++) { + int temp = 0; + for (int i = 0; i < rows; i++) { + temp += grid[i][j]; + } + if (2 * temp < rows) { + for (int i = 0; i < rows; i++) { + grid[i][j] ^= 1; + } + } + } + int ans = 0; + for (var row in grid) { + int val = 0; + for (var bit in row) { + val = (val << 1) | bit; + } + ans += val; + } + return ans; + } +} diff --git a/tests/501-1000/861. score-after-flipping-matrix/sol.go b/tests/501-1000/861. score-after-flipping-matrix/sol.go new file mode 100644 index 00000000..8ef52b7f --- /dev/null +++ b/tests/501-1000/861. score-after-flipping-matrix/sol.go @@ -0,0 +1,31 @@ +func matrixScore(grid [][]int) int { + rows := len(grid) + cols := len(grid[0]) + for _, row := range grid { + if row[0] == 0 { + for i := 0; i < cols; i++ { + row[i] ^= 1 + } + } + } + for j := 1; j < cols; j++ { + temp := 0 + for i := 0; i < rows; i++ { + temp += grid[i][j] + } + if 2*temp < rows { + for i := 0; i < rows; i++ { + grid[i][j] ^= 1 + } + } + } + ans := 0 + for _, row := range grid { + val := 0 + for _, bit := range row { + val = (val << 1) | bit + } + ans += val + } + return ans +} diff --git a/tests/501-1000/861. score-after-flipping-matrix/sol.java b/tests/501-1000/861. score-after-flipping-matrix/sol.java new file mode 100644 index 00000000..e5d181db --- /dev/null +++ b/tests/501-1000/861. score-after-flipping-matrix/sol.java @@ -0,0 +1,33 @@ +class Solution { + public int matrixScore(int[][] grid) { + int rows = grid.length; + int cols = grid[0].length; + for (int[] row : grid) { + if (row[0] == 0) { + for (int i = 0; i < cols; i++) { + row[i] ^= 1; + } + } + } + for (int j = 1; j < cols; j++) { + int temp = 0; + for (int i = 0; i < rows; i++) { + temp += grid[i][j]; + } + if (2 * temp < rows) { + for (int i = 0; i < rows; i++) { + grid[i][j] ^= 1; + } + } + } + int ans = 0; + for (int[] row : grid) { + int val = 0; + for (int bit : row) { + val = (val << 1) | bit; + } + ans += val; + } + return ans; + } +} diff --git a/tests/501-1000/861. score-after-flipping-matrix/sol.kt b/tests/501-1000/861. score-after-flipping-matrix/sol.kt new file mode 100644 index 00000000..827040f8 --- /dev/null +++ b/tests/501-1000/861. score-after-flipping-matrix/sol.kt @@ -0,0 +1,33 @@ +class Solution { + fun matrixScore(grid: Array): Int { + val rows = grid.size + val cols = grid[0].size + for (row in grid) { + if (row[0] == 0) { + for (i in 0 until cols) { + row[i] = row[i] xor 1 + } + } + } + for (j in 1 until cols) { + var temp = 0 + for (i in 0 until rows) { + temp += grid[i][j] + } + if (2 * temp < rows) { + for (i in 0 until rows) { + grid[i][j] = grid[i][j] xor 1 + } + } + } + var ans = 0 + for (row in grid) { + var rowValue = 0 + for (bit in row) { + rowValue = (rowValue shl 1) or bit + } + ans += rowValue + } + return ans + } +} diff --git a/tests/501-1000/861. score-after-flipping-matrix/sol.py b/tests/501-1000/861. score-after-flipping-matrix/sol.py new file mode 100644 index 00000000..4fd4f663 --- /dev/null +++ b/tests/501-1000/861. score-after-flipping-matrix/sol.py @@ -0,0 +1,27 @@ +class Solution: + def matrixScore(self, grid: List[List[int]]) -> int: + ans = 0 + rows, cols = len(grid), len(grid[0]) + + # Ensure every row starts with a 1, since the leading bit carries the most weight + for row in grid: + if row[0] == 0: + for i in range(cols): + row[i] = row[i] ^ 1 # XOR with 1 flips the bit (0->1, 1->0) + + # For every remaining column, flip it if doing so increases the count of 1s + for j in range(1, cols): + temp = 0 + for i in range(rows): + temp += grid[i][j] + if ( + 2 * temp < rows + ): # equivalent to temp < (rows - temp), i.e. 0s outnumber 1s + for i in range(rows): + grid[i][j] = grid[i][j] ^ 1 + + # Convert each row to its decimal value and accumulate the total + for row in grid: + val = "".join(map(str, row)) + ans += int(val, 2) + return ans diff --git a/tests/501-1000/861. score-after-flipping-matrix/sol.py2 b/tests/501-1000/861. score-after-flipping-matrix/sol.py2 new file mode 100644 index 00000000..77fb5548 --- /dev/null +++ b/tests/501-1000/861. score-after-flipping-matrix/sol.py2 @@ -0,0 +1,23 @@ +class Solution(object): + def matrixScore(self, grid): + """ + :type grid: List[List[int]] + :rtype: int + """ + rows, cols = len(grid), len(grid[0]) + for row in grid: + if row[0] == 0: + for i in range(cols): + row[i] ^= 1 + for j in range(1, cols): + temp = 0 + for i in range(rows): + temp += grid[i][j] + if 2 * temp < rows: + for i in range(rows): + grid[i][j] ^= 1 + ans = 0 + for row in grid: + val = ''.join(map(str, row)) + ans += int(val, 2) + return ans diff --git a/tests/501-1000/861. score-after-flipping-matrix/sol.rb b/tests/501-1000/861. score-after-flipping-matrix/sol.rb new file mode 100644 index 00000000..3c45e5a2 --- /dev/null +++ b/tests/501-1000/861. score-after-flipping-matrix/sol.rb @@ -0,0 +1,23 @@ +# @param {Integer[][]} grid +# @return {Integer} +def matrix_score(grid) + rows = grid.length + cols = grid[0].length + grid.each do |row| + if row[0] == 0 + (0...cols).each { |i| row[i] ^= 1 } + end + end + (1...cols).each do |j| + temp = 0 + (0...rows).each { |i| temp += grid[i][j] } + if 2 * temp < rows + (0...rows).each { |i| grid[i][j] ^= 1 } + end + end + ans = 0 + grid.each do |row| + ans += row.join.to_i(2) + end + ans +end diff --git a/tests/501-1000/861. score-after-flipping-matrix/sol.rs b/tests/501-1000/861. score-after-flipping-matrix/sol.rs new file mode 100644 index 00000000..912f8d96 --- /dev/null +++ b/tests/501-1000/861. score-after-flipping-matrix/sol.rs @@ -0,0 +1,34 @@ +impl Solution { + pub fn matrix_score(grid: Vec>) -> i32 { + let mut grid = grid; + let rows = grid.len(); + let cols = grid[0].len(); + for row in grid.iter_mut() { + if row[0] == 0 { + for i in 0..cols { + row[i] ^= 1; + } + } + } + for j in 1..cols { + let mut temp = 0; + for i in 0..rows { + temp += grid[i][j]; + } + if 2 * temp < rows as i32 { + for i in 0..rows { + grid[i][j] ^= 1; + } + } + } + let mut ans = 0; + for row in &grid { + let mut val = 0; + for &bit in row { + val = (val << 1) | bit; + } + ans += val; + } + ans + } +} diff --git a/tests/501-1000/861. score-after-flipping-matrix/sol.swift b/tests/501-1000/861. score-after-flipping-matrix/sol.swift new file mode 100644 index 00000000..456eb2b5 --- /dev/null +++ b/tests/501-1000/861. score-after-flipping-matrix/sol.swift @@ -0,0 +1,34 @@ +class Solution { + func matrixScore(_ grid: [[Int]]) -> Int { + var grid = grid + let rows = grid.count + let cols = grid[0].count + for i in 0..= k: + best = min(best, i - dq.popleft()) + dq.append(i) + exp = -1 if best == n + 1 else best + return result == exp + +seed: 862 +tests: + - name: t1 + in: + nums: [1] + k: 1 + out: 1 + - name: t2 + in: + nums: [1, 2] + k: 4 + out: -1 + - name: t3 + in: + nums: [2, -1, 2] + k: 3 + out: 3 + - name: t4 + in: + nums: [1, 3] + k: 3 + out: 1 + - name: t5 + in: + nums: [84, -37, 32, 40, 95] + k: 167 + out: 3 + - name: t6 + in: + nums: [17, 85, 93, -45, -21] + k: 150 + out: 2 + - name: t7 + in: + nums: [2] + k: 2 + out: 1 + - name: t8 + in: + nums: [2] + k: 3 + out: -1 + - name: t9 + in: + nums: [-1, -2, -3] + k: 1 + out: -1 + - name: t10 + in: + nums: [5, -1, 5] + k: 5 + out: 1 + - name: t11 + in: + nums: [1, -1, 1] + k: 1 + out: 1 + - name: t12 + in: + nums: [1, -1, 5, -2, 3] + k: 3 + out: 1 + - name: t13 + in: + nums: [1, 2, 3, 4, 5] + k: 11 + out: 3 + - name: t14 + in: + nums: [1, 2, 3, 4, 5] + k: 15 + out: 5 + - name: t15 + in: + nums: [1, 2, 3, 4, 5] + k: 16 + - name: t16 + in: + nums: [100000] + k: 100000 + - name: t17 + in: + nums: [-100000, 100000] + k: 100000 + - name: t18 + in: + nums: [100000, -100000, 100000] + k: 100000 + - name: t19 + in: + nums: [1, 1, 1, 1, 1] + k: 3 + - name: t20 + in: + nums: [1, 1, 1, 1, 1] + k: 6 + - name: t21 + in: + nums: [2, -1, 2, -1, 2] + k: 4 + - name: t22 + in: + nums: [10, -5, 2, -1, 7] + k: 9 + - name: t23 + in: + nums: [10, -5, 2, -1, 7] + k: 13 + - name: t24 + in: + nums: [10, -5, 2, -1, 7] + k: 20 + - name: t25 + in: + nums: [0, 0, 0, 5] + k: 5 + - name: t26 + in: + nums: [0, 0, 0, 5] + k: 6 + - name: t27 + in: + nums: [3, -2, 5, -1] + k: 6 + - name: t28 + in: + nums: [3, -2, 5, -1] + k: 7 + - name: t29 + in: + nums: [8, -1, 2, 1] + k: 9 + - name: t30 + in: + nums: [8, -1, 2, 1] + k: 10 + - name: t31 + in: + nums: [1, -1, 1, -1, 1, -1, 10] + k: 10 + out: 1 + - name: t32 + in: + nums: [-100000, -100000, -100000, -100000, -100000, 100000] + k: 100000 + out: 1 + - name: t33 + in: + nums: + [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + ] + k: 100 + out: 100 + - name: t34 + in: + nums: + [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + ] + k: 101 + out: 101 + - name: t35 + in: + nums: [5, -3, 4, -2, 6, -1, 7] + k: 11 + out: 3 diff --git a/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.cpp b/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.cpp new file mode 100644 index 00000000..3cae61db --- /dev/null +++ b/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.cpp @@ -0,0 +1,25 @@ +class Solution { +public: + int shortestSubarray(vector& nums, int k) { + int n = nums.size(); + vector prefix(n + 1, 0); + for (int i = 0; i < n; ++i) { + prefix[i + 1] = prefix[i] + nums[i]; + } + + int best = n + 1; + deque dq; + for (int i = 0; i < prefix.size(); ++i) { + while (!dq.empty() && prefix[i] - prefix[dq.front()] >= k) { + best = min(best, i - dq.front()); + dq.pop_front(); + } + while (!dq.empty() && prefix[dq.back()] >= prefix[i]) { + dq.pop_back(); + } + dq.push_back(i); + } + + return best == n + 1 ? -1 : best; + } +}; diff --git a/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.cs b/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.cs new file mode 100644 index 00000000..3e4eedf9 --- /dev/null +++ b/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.cs @@ -0,0 +1,24 @@ +public class Solution { + public int ShortestSubarray(int[] nums, int k) { + int n = nums.Length; + long[] prefix = new long[n + 1]; + for (int i = 0; i < n; i++) { + prefix[i + 1] = prefix[i] + nums[i]; + } + + int best = n + 1; + var dq = new System.Collections.Generic.LinkedList(); + for (int i = 0; i < prefix.Length; i++) { + while (dq.Count > 0 && prefix[i] - prefix[dq.First.Value] >= k) { + best = Math.Min(best, i - dq.First.Value); + dq.RemoveFirst(); + } + while (dq.Count > 0 && prefix[dq.Last.Value] >= prefix[i]) { + dq.RemoveLast(); + } + dq.AddLast(i); + } + + return best == n + 1 ? -1 : best; + } +} diff --git a/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.dart b/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.dart new file mode 100644 index 00000000..8ab2f04a --- /dev/null +++ b/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.dart @@ -0,0 +1,24 @@ +class Solution { + int shortestSubarray(List nums, int k) { + int n = nums.length; + List prefix = List.filled(n + 1, 0); + for (int i = 0; i < n; i++) { + prefix[i + 1] = prefix[i] + nums[i]; + } + + int best = n + 1; + var dq = []; + for (int i = 0; i < prefix.length; i++) { + while (dq.isNotEmpty && prefix[i] - prefix[dq.first] >= k) { + best = best < i - dq.first ? best : i - dq.first; + dq.removeAt(0); + } + while (dq.isNotEmpty && prefix[dq.last] >= prefix[i]) { + dq.removeLast(); + } + dq.add(i); + } + + return best == n + 1 ? -1 : best; + } +} diff --git a/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.go b/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.go new file mode 100644 index 00000000..6689ec47 --- /dev/null +++ b/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.go @@ -0,0 +1,27 @@ +func shortestSubarray(nums []int, k int) int { + n := len(nums) + prefix := make([]int64, n+1) + for i := 0; i < n; i++ { + prefix[i+1] = prefix[i] + int64(nums[i]) + } + + best := n + 1 + dq := make([]int, 0) + for i, cur := range prefix { + for len(dq) > 0 && cur - prefix[dq[0]] >= int64(k) { + if i - dq[0] < best { + best = i - dq[0] + } + dq = dq[1:] + } + for len(dq) > 0 && prefix[dq[len(dq)-1]] >= cur { + dq = dq[:len(dq)-1] + } + dq = append(dq, i) + } + + if best == n + 1 { + return -1 + } + return best +} diff --git a/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.java b/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.java new file mode 100644 index 00000000..10ea8712 --- /dev/null +++ b/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.java @@ -0,0 +1,23 @@ +class Solution { + public int shortestSubarray(int[] nums, int k) { + int n = nums.length; + long[] prefix = new long[n + 1]; + for (int i = 0; i < n; i++) { + prefix[i + 1] = prefix[i] + nums[i]; + } + + int best = n + 1; + java.util.ArrayDeque dq = new java.util.ArrayDeque<>(); + for (int i = 0; i < prefix.length; i++) { + while (!dq.isEmpty() && prefix[i] - prefix[dq.peekFirst()] >= k) { + best = Math.min(best, i - dq.pollFirst()); + } + while (!dq.isEmpty() && prefix[dq.peekLast()] >= prefix[i]) { + dq.pollLast(); + } + dq.addLast(i); + } + + return best == n + 1 ? -1 : best; + } +} diff --git a/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.kt b/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.kt new file mode 100644 index 00000000..6030d6ff --- /dev/null +++ b/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.kt @@ -0,0 +1,23 @@ +class Solution { + fun shortestSubarray(nums: IntArray, k: Int): Int { + val n = nums.size + val prefix = LongArray(n + 1) + for (i in 0 until n) { + prefix[i + 1] = prefix[i] + nums[i] + } + + var best = n + 1 + val dq = java.util.ArrayDeque() + for (i in prefix.indices) { + while (!dq.isEmpty() && prefix[i] - prefix[dq.first()] >= k) { + best = minOf(best, i - dq.pollFirst()) + } + while (!dq.isEmpty() && prefix[dq.last()] >= prefix[i]) { + dq.pollLast() + } + dq.addLast(i) + } + + return if (best == n + 1) -1 else best + } +} diff --git a/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.py b/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.py new file mode 100644 index 00000000..72abb891 --- /dev/null +++ b/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.py @@ -0,0 +1,20 @@ +from collections import deque +from typing import List + + +class Solution: + def shortestSubarray(self, nums: List[int], k: int) -> int: + prefix = [0] + for num in nums: + prefix.append(prefix[-1] + num) + + best = len(nums) + 1 + dq = deque() + for i, cur in enumerate(prefix): + while dq and cur - prefix[dq[0]] >= k: + best = min(best, i - dq.popleft()) + while dq and prefix[dq[-1]] >= cur: + dq.pop() + dq.append(i) + + return -1 if best == len(nums) + 1 else best diff --git a/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.py2 b/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.py2 new file mode 100644 index 00000000..20501e99 --- /dev/null +++ b/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.py2 @@ -0,0 +1,22 @@ +class Solution(object): + def shortestSubarray(self, nums, k): + """ + :type nums: List[int] + :type k: int + :rtype: int + """ + from collections import deque + prefix = [0] + for num in nums: + prefix.append(prefix[-1] + num) + + best = len(nums) + 1 + dq = deque() + for i, cur in enumerate(prefix): + while dq and cur - prefix[dq[0]] >= k: + best = min(best, i - dq.popleft()) + while dq and prefix[dq[-1]] >= cur: + dq.pop() + dq.append(i) + + return -1 if best == len(nums) + 1 else best diff --git a/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.rb b/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.rb new file mode 100644 index 00000000..7cb626eb --- /dev/null +++ b/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.rb @@ -0,0 +1,21 @@ +# @param {Integer[]} nums +# @param {Integer} k +# @return {Integer} +def shortest_subarray(nums, k) + prefix = [0] + nums.each { |num| prefix << prefix[-1] + num } + + best = nums.length + 1 + dq = [] + prefix.each_with_index do |cur, i| + while !dq.empty? && cur - prefix[dq[0]] >= k + best = [best, i - dq.shift].min + end + while !dq.empty? && prefix[dq[-1]] >= cur + dq.pop + end + dq << i + end + + best == nums.length + 1 ? -1 : best +end diff --git a/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.rs b/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.rs new file mode 100644 index 00000000..e7089c4c --- /dev/null +++ b/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.rs @@ -0,0 +1,32 @@ +impl Solution { + pub fn shortest_subarray(nums: Vec, k: i32) -> i32 { + let n = nums.len(); + let mut prefix = vec![0i64; n + 1]; + for i in 0..n { + prefix[i + 1] = prefix[i] + nums[i] as i64; + } + + let mut best = (n + 1) as i32; + let mut dq = std::collections::VecDeque::new(); + for i in 0..prefix.len() { + while let Some(&front) = dq.front() { + if prefix[i] - prefix[front] >= k as i64 { + best = best.min((i - front) as i32); + dq.pop_front(); + } else { + break; + } + } + while let Some(&back) = dq.back() { + if prefix[back] >= prefix[i] { + dq.pop_back(); + } else { + break; + } + } + dq.push_back(i); + } + + if best == (n + 1) as i32 { -1 } else { best } + } +} diff --git a/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.swift b/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.swift new file mode 100644 index 00000000..d3f510e0 --- /dev/null +++ b/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.swift @@ -0,0 +1,23 @@ +class Solution { + func shortestSubarray(_ nums: [Int], _ k: Int) -> Int { + let n = nums.count + var prefix = [Int](repeating: 0, count: n + 1) + for i in 0..= k { + best = min(best, i - dq.removeFirst()) + } + while !dq.isEmpty && prefix[dq.last!] >= prefix[i] { + dq.removeLast() + } + dq.append(i) + } + + return best == n + 1 ? -1 : best + } +} diff --git a/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.ts b/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.ts new file mode 100644 index 00000000..f84af76f --- /dev/null +++ b/tests/501-1000/862. shortest-subarray-with-sum-at-least-k/sol.ts @@ -0,0 +1,21 @@ +function shortestSubarray(nums: number[], k: number): number { + const n = nums.length; + const prefix: number[] = [0]; + for (let i = 0; i < n; i++) { + prefix.push(prefix[prefix.length - 1] + nums[i]); + } + + let best = n + 1; + const dq: number[] = []; + for (let i = 0; i < prefix.length; i++) { + while (dq.length > 0 && prefix[i] - prefix[dq[0]] >= k) { + best = Math.min(best, i - dq.shift()!); + } + while (dq.length > 0 && prefix[dq[dq.length - 1]] >= prefix[i]) { + dq.pop(); + } + dq.push(i); + } + + return best === n + 1 ? -1 : best; +} diff --git a/tests/501-1000/864. shortest-path-to-get-all-keys/manifest.yaml b/tests/501-1000/864. shortest-path-to-get-all-keys/manifest.yaml new file mode 100644 index 00000000..e86b39dd --- /dev/null +++ b/tests/501-1000/864. shortest-path-to-get-all-keys/manifest.yaml @@ -0,0 +1,296 @@ +entry: + id: 864 + title: shortest-path-to-get-all-keys + params: + grid: + type: array + items: + type: string + call: + cpp: "Solution().shortestPathAllKeys({grid})" + rust: "Solution::shortest_path_all_keys({grid})" + python3: "Solution().shortestPathAllKeys({grid})" + python2: "Solution().shortestPathAllKeys({grid})" + ruby: "shortest_path_all_keys({grid})" + java: "new Solution().shortestPathAllKeys({grid})" + csharp: "new Solution().ShortestPathAllKeys({grid})" + kotlin: "Solution().shortestPathAllKeys({grid})" + go: "shortestPathAllKeys({grid})" + dart: "Solution().shortestPathAllKeys({grid})" + swift: "Solution().shortestPathAllKeys({grid})" + typescript: "shortestPathAllKeys({grid})" + +judge: + type: "exact" + +limits: + time_ms: 2000 + memory_mb: 256 + +oracle: + python3: + call: "Checker().shortestPathAllKeys(grid, {result})" + checker: | + from collections import deque + class Checker: + def shortestPathAllKeys(self, grid, result): + if not isinstance(result, int): + return False + m, n = len(grid), len(grid[0]) + start = None + total = 0 + for i in range(m): + for j, ch in enumerate(grid[i]): + if ch == '@': start = (i, j) + if 'a' <= ch <= 'f': total += 1 + target = (1 << total) - 1 + q = deque([(start[0], start[1], 0)]) + seen = {(start[0], start[1], 0)} + d = [(1,0),(-1,0),(0,1),(0,-1)] + steps = 0 + while q: + for _ in range(len(q)): + r,c,mask = q.popleft() + if mask == target: + return result == steps + for dr,dc in d: + nr,nc = r+dr,c+dc + if not (0<=nr& grid) { + int m = grid.size(); + int n = grid[0].size(); + int start_i = 0, start_j = 0; + int total_keys = 0; + + for (int i = 0; i < m; i++) { + for (int j = 0; j < n; j++) { + if (grid[i][j] == '@') { + start_i = i; + start_j = j; + } + if (grid[i][j] >= 'a' && grid[i][j] <= 'f') { + total_keys++; + } + } + } + + int target_mask = (1 << total_keys) - 1; + queue> q; + q.push({start_i, start_j, 0}); + vector>> seen(m, vector>(n, vector(1 << total_keys, false))); + seen[start_i][start_j][0] = true; + int moves = 0; + vector> dirs = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; + + while (!q.empty()) { + int size = q.size(); + for (int i = 0; i < size; i++) { + auto [r, c, mask] = q.front(); + q.pop(); + + if (mask == target_mask) { + return moves; + } + + for (auto [dx, dy] : dirs) { + int nr = r + dx; + int nc = c + dy; + + if (nr < 0 || nr >= m || nc < 0 || nc >= n) { + continue; + } + + char next_val = grid[nr][nc]; + int next_mask = mask; + + if (next_val >= 'a' && next_val <= 'f') { + int key_bit = next_val - 'a'; + next_mask |= (1 << key_bit); + } + + if (next_val >= 'A' && next_val <= 'F') { + int lock_bit = tolower(next_val) - 'a'; + if ((next_mask & (1 << lock_bit)) == 0) { + continue; + } + } + + if (!seen[nr][nc][next_mask] && next_val != '#') { + q.push({nr, nc, next_mask}); + seen[nr][nc][next_mask] = true; + } + } + } + moves++; + } + + return -1; + } +}; diff --git a/tests/501-1000/864. shortest-path-to-get-all-keys/sol.cs b/tests/501-1000/864. shortest-path-to-get-all-keys/sol.cs new file mode 100644 index 00000000..d5954b2a --- /dev/null +++ b/tests/501-1000/864. shortest-path-to-get-all-keys/sol.cs @@ -0,0 +1,71 @@ +public class Solution { + public int ShortestPathAllKeys(string[] grid) { + int m = grid.Length; + int n = grid[0].Length; + int start_i = 0, start_j = 0; + int total_keys = 0; + + for (int i = 0; i < m; i++) { + for (int j = 0; j < n; j++) { + if (grid[i][j] == '@') { + start_i = i; + start_j = j; + } + if (grid[i][j] >= 'a' && grid[i][j] <= 'f') { + total_keys++; + } + } + } + + int target_mask = (1 << total_keys) - 1; + Queue<(int, int, int)> queue = new Queue<(int, int, int)>(); + queue.Enqueue((start_i, start_j, 0)); + bool[,,] seen = new bool[m, n, 1 << total_keys]; + seen[start_i, start_j, 0] = true; + int moves = 0; + (int, int)[] dirs = {(0, 1), (0, -1), (1, 0), (-1, 0)}; + + while (queue.Count > 0) { + int size = queue.Count; + for (int k = 0; k < size; k++) { + var (r, c, mask) = queue.Dequeue(); + + if (mask == target_mask) { + return moves; + } + + foreach (var (dx, dy) in dirs) { + int nr = r + dx; + int nc = c + dy; + + if (nr < 0 || nr >= m || nc < 0 || nc >= n) { + continue; + } + + char next_val = grid[nr][nc]; + int next_mask = mask; + + if (next_val >= 'a' && next_val <= 'f') { + int key_bit = next_val - 'a'; + next_mask |= (1 << key_bit); + } + + if (next_val >= 'A' && next_val <= 'F') { + int lock_bit = char.ToLower(next_val) - 'a'; + if ((next_mask & (1 << lock_bit)) == 0) { + continue; + } + } + + if (!seen[nr, nc, next_mask] && next_val != '#') { + queue.Enqueue((nr, nc, next_mask)); + seen[nr, nc, next_mask] = true; + } + } + } + moves++; + } + + return -1; + } +} diff --git a/tests/501-1000/864. shortest-path-to-get-all-keys/sol.dart b/tests/501-1000/864. shortest-path-to-get-all-keys/sol.dart new file mode 100644 index 00000000..d4e42013 --- /dev/null +++ b/tests/501-1000/864. shortest-path-to-get-all-keys/sol.dart @@ -0,0 +1,77 @@ +import 'dart:collection'; + +class Solution { + int shortestPathAllKeys(List grid) { + int m = grid.length; + int n = grid[0].length; + int start_i = 0, start_j = 0; + int total_keys = 0; + + for (int i = 0; i < m; i++) { + for (int j = 0; j < n; j++) { + if (grid[i][j] == '@') { + start_i = i; + start_j = j; + } + if (grid[i][j].codeUnitAt(0) >= 'a'.codeUnitAt(0) && + grid[i][j].codeUnitAt(0) <= 'f'.codeUnitAt(0)) { + total_keys++; + } + } + } + + int target_mask = (1 << total_keys) - 1; + Queue> queue = Queue(); + queue.add([start_i, start_j, 0]); + Set seen = Set(); + seen.add('$start_i,$start_j,0'); + int moves = 0; + List> dirs = [[0,1], [0,-1], [1,0], [-1,0]]; + + while (queue.isNotEmpty) { + int size = queue.length; + for (int k = 0; k < size; k++) { + List curr = queue.removeFirst(); + int r = curr[0], c = curr[1], mask = curr[2]; + + if (mask == target_mask) { + return moves; + } + + for (List dir in dirs) { + int nr = r + dir[0]; + int nc = c + dir[1]; + + if (nr < 0 || nr >= m || nc < 0 || nc >= n) { + continue; + } + + String next_val = grid[nr][nc]; + int next_mask = mask; + + int code = next_val.codeUnitAt(0); + if (code >= 'a'.codeUnitAt(0) && code <= 'f'.codeUnitAt(0)) { + int key_bit = code - 'a'.codeUnitAt(0); + next_mask |= (1 << key_bit); + } + + if (code >= 'A'.codeUnitAt(0) && code <= 'F'.codeUnitAt(0)) { + int lock_bit = next_val.toLowerCase().codeUnitAt(0) - 'a'.codeUnitAt(0); + if ((next_mask & (1 << lock_bit)) == 0) { + continue; + } + } + + String state = '$nr,$nc,$next_mask'; + if (!seen.contains(state) && next_val != '#') { + queue.add([nr, nc, next_mask]); + seen.add(state); + } + } + } + moves++; + } + + return -1; + } +} diff --git a/tests/501-1000/864. shortest-path-to-get-all-keys/sol.go b/tests/501-1000/864. shortest-path-to-get-all-keys/sol.go new file mode 100644 index 00000000..39b74bc1 --- /dev/null +++ b/tests/501-1000/864. shortest-path-to-get-all-keys/sol.go @@ -0,0 +1,80 @@ +func shortestPathAllKeys(grid []string) int { + m := len(grid) + n := len(grid[0]) + start_i, start_j := 0, 0 + total_keys := 0 + + for i := 0; i < m; i++ { + for j := 0; j < n; j++ { + if grid[i][j] == '@' { + start_i = i + start_j = j + } + if grid[i][j] >= 'a' && grid[i][j] <= 'f' { + total_keys++ + } + } + } + + target_mask := (1 << total_keys) - 1 + type State struct { + i, j, mask int + } + queue := []State{{start_i, start_j, 0}} + seen := make([][][]bool, m) + for i := 0; i < m; i++ { + seen[i] = make([][]bool, n) + for j := 0; j < n; j++ { + seen[i][j] = make([]bool, 1< 0 { + size := len(queue) + for k := 0; k < size; k++ { + r := queue[0].i + c := queue[0].j + mask := queue[0].mask + queue = queue[1:] + + if mask == target_mask { + return moves + } + + for _, dir := range dirs { + nr := r + dir[0] + nc := c + dir[1] + + if nr < 0 || nr >= m || nc < 0 || nc >= n { + continue + } + + next_val := grid[nr][nc] + next_mask := mask + + if next_val >= 'a' && next_val <= 'f' { + key_bit := int(next_val - 'a') + next_mask |= (1 << key_bit) + } + + if next_val >= 'A' && next_val <= 'F' { + lock_bit := int(next_val - 'A') + if (next_mask & (1 << lock_bit)) == 0 { + continue + } + } + + if !seen[nr][nc][next_mask] && next_val != '#' { + queue = append(queue, State{nr, nc, next_mask}) + seen[nr][nc][next_mask] = true + } + } + } + moves++ + } + + return -1 +} diff --git a/tests/501-1000/864. shortest-path-to-get-all-keys/sol.java b/tests/501-1000/864. shortest-path-to-get-all-keys/sol.java new file mode 100644 index 00000000..d9721a8f --- /dev/null +++ b/tests/501-1000/864. shortest-path-to-get-all-keys/sol.java @@ -0,0 +1,75 @@ +import java.util.*; + +class Solution { + public int shortestPathAllKeys(String[] grid) { + int m = grid.length; + int n = grid[0].length(); + int start_i = 0, start_j = 0; + int total_keys = 0; + + for (int i = 0; i < m; i++) { + for (int j = 0; j < n; j++) { + char c = grid[i].charAt(j); + if (c == '@') { + start_i = i; + start_j = j; + } + if (c >= 'a' && c <= 'f') { + total_keys++; + } + } + } + + int target_mask = (1 << total_keys) - 1; + Queue queue = new LinkedList<>(); + queue.offer(new int[]{start_i, start_j, 0}); + boolean[][][] seen = new boolean[m][n][1 << total_keys]; + seen[start_i][start_j][0] = true; + int moves = 0; + int[][] dirs = {{0,1}, {0,-1}, {1,0}, {-1,0}}; + + while (!queue.isEmpty()) { + int size = queue.size(); + for (int i = 0; i < size; i++) { + int[] curr = queue.poll(); + int r = curr[0], c = curr[1], mask = curr[2]; + + if (mask == target_mask) { + return moves; + } + + for (int[] dir : dirs) { + int nr = r + dir[0]; + int nc = c + dir[1]; + + if (nr < 0 || nr >= m || nc < 0 || nc >= n) { + continue; + } + + char next_val = grid[nr].charAt(nc); + int next_mask = mask; + + if (next_val >= 'a' && next_val <= 'f') { + int key_bit = next_val - 'a'; + next_mask |= (1 << key_bit); + } + + if (next_val >= 'A' && next_val <= 'F') { + int lock_bit = Character.toLowerCase(next_val) - 'a'; + if ((next_mask & (1 << lock_bit)) == 0) { + continue; + } + } + + if (!seen[nr][nc][next_mask] && next_val != '#') { + queue.offer(new int[]{nr, nc, next_mask}); + seen[nr][nc][next_mask] = true; + } + } + } + moves++; + } + + return -1; + } +} diff --git a/tests/501-1000/864. shortest-path-to-get-all-keys/sol.kt b/tests/501-1000/864. shortest-path-to-get-all-keys/sol.kt new file mode 100644 index 00000000..c7e4bc3c --- /dev/null +++ b/tests/501-1000/864. shortest-path-to-get-all-keys/sol.kt @@ -0,0 +1,75 @@ +import java.util.* + +class Solution { + fun shortestPathAllKeys(grid: Array): Int { + val m = grid.size + val n = grid[0].length + var start_i = 0 + var start_j = 0 + var total_keys = 0 + + for (i in 0 until m) { + for (j in 0 until n) { + val c = grid[i][j] + if (c == '@') { + start_i = i + start_j = j + } + if (c in 'a'..'f') { + total_keys++ + } + } + } + + val target_mask = (1 shl total_keys) - 1 + val queue: Queue> = LinkedList() + queue.offer(Triple(start_i, start_j, 0)) + val seen = Array(m) { Array(n) { BooleanArray(1 shl total_keys) } } + seen[start_i][start_j][0] = true + var moves = 0 + val dirs = arrayOf(intArrayOf(0, 1), intArrayOf(0, -1), intArrayOf(1, 0), intArrayOf(-1, 0)) + + while (queue.isNotEmpty()) { + val size = queue.size + repeat(size) { + val (r, c, mask) = queue.poll() + + if (mask == target_mask) { + return moves + } + + for (dir in dirs) { + val nr = r + dir[0] + val nc = c + dir[1] + + if (nr !in 0 until m || nc !in 0 until n) { + continue + } + + val next_val = grid[nr][nc] + var next_mask = mask + + if (next_val in 'a'..'f') { + val key_bit = next_val - 'a' + next_mask = next_mask or (1 shl key_bit) + } + + if (next_val in 'A'..'F') { + val lock_bit = next_val.lowercaseChar() - 'a' + if ((next_mask and (1 shl lock_bit)) == 0) { + continue + } + } + + if (!seen[nr][nc][next_mask] && next_val != '#') { + queue.offer(Triple(nr, nc, next_mask)) + seen[nr][nc][next_mask] = true + } + } + } + moves++ + } + + return -1 + } +} diff --git a/tests/501-1000/864. shortest-path-to-get-all-keys/sol.py b/tests/501-1000/864. shortest-path-to-get-all-keys/sol.py new file mode 100644 index 00000000..7091934d --- /dev/null +++ b/tests/501-1000/864. shortest-path-to-get-all-keys/sol.py @@ -0,0 +1,47 @@ +class Solution: + def shortestPathAllKeys(self, grid: List[str]) -> int: + m, n = len(grid), len(grid[0]) + start_i, start_j = 0, 0 + total_keys = 0 + + for i in range(m): + for j in range(n): + if grid[i][j] == "@": + start_i = i + start_j = j + if "a" <= grid[i][j] <= "f": + total_keys += 1 + + target_mask = (1 << total_keys) - 1 + queue = deque([(start_i, start_j, 0)]) # (i, j, mask) + seen = set((start_i, start_j, 0)) + moves = 0 + dir = [(0, 1), (0, -1), (1, 0), (-1, 0)] + + while queue: + for _ in range(len(queue)): + r, c, mask = queue.popleft() + + if mask == target_mask: + return moves + for dx, dy in dir: + nr, nc = r + dx, c + dy + if not ((0 <= nr < m) and (0 <= nc < n)): + continue + next_val = grid[nr][nc] + next_mask = mask + + if "a" <= next_val <= "f": + key_bit = ord(next_val) - ord("a") + next_mask |= 1 << key_bit + + if "A" <= next_val <= "F": + lock_bit = ord(next_val.lower()) - ord("a") + if not (next_mask & (1 << lock_bit)): + continue + if (nr, nc, next_mask) not in seen and next_val != "#": + queue.append((nr, nc, next_mask)) + seen.add((nr, nc, next_mask)) + + moves += 1 + return -1 diff --git a/tests/501-1000/864. shortest-path-to-get-all-keys/sol.py2 b/tests/501-1000/864. shortest-path-to-get-all-keys/sol.py2 new file mode 100644 index 00000000..2a48ebb3 --- /dev/null +++ b/tests/501-1000/864. shortest-path-to-get-all-keys/sol.py2 @@ -0,0 +1,58 @@ +class Solution(object): + def shortestPathAllKeys(self, grid): + """ + :type grid: List[str] + :rtype: int + """ + from collections import deque + + m, n = len(grid), len(grid[0]) + start_i = start_j = 0 + total_keys = 0 + + for i in range(m): + for j in range(n): + if grid[i][j] == '@': + start_i = i + start_j = j + if 'a' <= grid[i][j] <= 'f': + total_keys += 1 + + target_mask = (1 << total_keys) - 1 + queue = deque([(start_i, start_j, 0)]) + seen = set() + seen.add((start_i, start_j, 0)) + moves = 0 + dirs = [(0,1), (0,-1), (1,0), (-1,0)] + + while queue: + for _ in range(len(queue)): + r, c, mask = queue.popleft() + + if mask == target_mask: + return moves + + for dx, dy in dirs: + nr, nc = r + dx, c + dy + if not (0 <= nr < m and 0 <= nc < n): + continue + + next_val = grid[nr][nc] + next_mask = mask + + if 'a' <= next_val <= 'f': + key_bit = ord(next_val) - ord('a') + next_mask |= (1 << key_bit) + + if 'A' <= next_val <= 'F': + lock_bit = ord(next_val.lower()) - ord('a') + if not (next_mask & (1 << lock_bit)): + continue + + if (nr, nc, next_mask) not in seen and next_val != '#': + queue.append((nr, nc, next_mask)) + seen.add((nr, nc, next_mask)) + + moves += 1 + + return -1 diff --git a/tests/501-1000/864. shortest-path-to-get-all-keys/sol.rb b/tests/501-1000/864. shortest-path-to-get-all-keys/sol.rb new file mode 100644 index 00000000..1ef4de96 --- /dev/null +++ b/tests/501-1000/864. shortest-path-to-get-all-keys/sol.rb @@ -0,0 +1,67 @@ +# @param {String[]} grid +# @return {Integer} +def shortest_path_all_keys(grid) + m = grid.length + n = grid[0].length + start_i = start_j = 0 + total_keys = 0 + + (0...m).each do |i| + (0...n).each do |j| + if grid[i][j] == '@' + start_i = i + start_j = j + end + if 'a' <= grid[i][j] && grid[i][j] <= 'f' + total_keys += 1 + end + end + end + + target_mask = (1 << total_keys) - 1 + queue = [[start_i, start_j, 0]] + seen = Set.new + seen.add([start_i, start_j, 0]) + moves = 0 + dirs = [[0,1], [0,-1], [1,0], [-1,0]] + + while !queue.empty? + queue.length.times do + r, c, mask = queue.shift + + if mask == target_mask + return moves + end + + dirs.each do |dx, dy| + nr = r + dx + nc = c + dy + + next unless 0 <= nr && nr < m && 0 <= nc && nc < n + + next_val = grid[nr][nc] + next_mask = mask + + if 'a' <= next_val && next_val <= 'f' + key_bit = next_val.ord - 'a'.ord + next_mask |= (1 << key_bit) + end + + if 'A' <= next_val && next_val <= 'F' + lock_bit = next_val.downcase.ord - 'a'.ord + next unless (next_mask & (1 << lock_bit)) != 0 + end + + state = [nr, nc, next_mask] + if !seen.include?(state) && next_val != '#' + queue.push(state) + seen.add(state) + end + end + end + + moves += 1 + end + + return -1 +end diff --git a/tests/501-1000/864. shortest-path-to-get-all-keys/sol.rs b/tests/501-1000/864. shortest-path-to-get-all-keys/sol.rs new file mode 100644 index 00000000..8c75b16e --- /dev/null +++ b/tests/501-1000/864. shortest-path-to-get-all-keys/sol.rs @@ -0,0 +1,78 @@ +impl Solution { + pub fn shortest_path_all_keys(grid: Vec) -> i32 { + use std::collections::VecDeque; + + let m = grid.len(); + let n = grid[0].len(); + let mut start_i = 0; + let mut start_j = 0; + let mut total_keys = 0; + + let grid: Vec> = grid.iter().map(|s| s.chars().collect()).collect(); + + for i in 0..m { + for j in 0..n { + if grid[i][j] == '@' { + start_i = i; + start_j = j; + } + if grid[i][j] >= 'a' && grid[i][j] <= 'f' { + total_keys += 1; + } + } + } + + let target_mask = (1 << total_keys) - 1; + let mut queue = VecDeque::new(); + queue.push_back((start_i, start_j, 0)); + let mut seen = vec![vec![vec![false; 1 << total_keys]; n]; m]; + seen[start_i][start_j][0] = true; + let mut moves = 0; + let dirs = [(0, 1), (0, -1), (1, 0), (-1, 0)]; + + while !queue.is_empty() { + let size = queue.len(); + for _ in 0..size { + let (r, c, mask) = queue.pop_front().unwrap(); + + if mask == target_mask { + return moves; + } + + for (dx, dy) in &dirs { + let nr = r as i32 + dx; + let nc = c as i32 + dy; + + if nr < 0 || nr >= m as i32 || nc < 0 || nc >= n as i32 { + continue; + } + + let nr = nr as usize; + let nc = nc as usize; + let next_val = grid[nr][nc]; + let mut next_mask = mask; + + if next_val >= 'a' && next_val <= 'f' { + let key_bit = (next_val as u8 - b'a') as usize; + next_mask |= 1 << key_bit; + } + + if next_val >= 'A' && next_val <= 'F' { + let lock_bit = (next_val.to_ascii_lowercase() as u8 - b'a') as usize; + if (next_mask & (1 << lock_bit)) == 0 { + continue; + } + } + + if !seen[nr][nc][next_mask] && next_val != '#' { + queue.push_back((nr, nc, next_mask)); + seen[nr][nc][next_mask] = true; + } + } + } + moves += 1; + } + + -1 + } +} diff --git a/tests/501-1000/864. shortest-path-to-get-all-keys/sol.swift b/tests/501-1000/864. shortest-path-to-get-all-keys/sol.swift new file mode 100644 index 00000000..efc3396c --- /dev/null +++ b/tests/501-1000/864. shortest-path-to-get-all-keys/sol.swift @@ -0,0 +1,72 @@ +class Solution { + func shortestPathAllKeys(_ grid: [String]) -> Int { + let m = grid.count + let n = grid[0].count + var start_i = 0, start_j = 0 + var total_keys = 0 + + let gridArray = grid.map { Array($0) } + + for i in 0..= "a" && gridArray[i][j] <= "f" { + total_keys += 1 + } + } + } + + let target_mask = (1 << total_keys) - 1 + var queue: [(Int, Int, Int)] = [(start_i, start_j, 0)] + var seen: [[[Bool]]] = Array(repeating: Array(repeating: Array(repeating: false, count: 1 << total_keys), count: n), count: m) + seen[start_i][start_j][0] = true + var moves = 0 + let dirs = [(0, 1), (0, -1), (1, 0), (-1, 0)] + + while !queue.isEmpty { + let size = queue.count + for _ in 0..= m || nc < 0 || nc >= n { + continue + } + + let next_val = gridArray[nr][nc] + var next_mask = mask + + if next_val >= "a" && next_val <= "f" { + let key_bit = Int(next_val.asciiValue! - Character("a").asciiValue!) + next_mask |= (1 << key_bit) + } + + if next_val >= "A" && next_val <= "F" { + let lock_bit = Int(next_val.lowercased().first!.asciiValue! - Character("a").asciiValue!) + if (next_mask & (1 << lock_bit)) == 0 { + continue + } + } + + if !seen[nr][nc][next_mask] && next_val != "#" { + queue.append((nr, nc, next_mask)) + seen[nr][nc][next_mask] = true + } + } + } + moves += 1 + } + + return -1 + } +} diff --git a/tests/501-1000/864. shortest-path-to-get-all-keys/sol.ts b/tests/501-1000/864. shortest-path-to-get-all-keys/sol.ts new file mode 100644 index 00000000..e4912a04 --- /dev/null +++ b/tests/501-1000/864. shortest-path-to-get-all-keys/sol.ts @@ -0,0 +1,77 @@ +function shortestPathAllKeys(grid: string[]): number { + const m = grid.length; + const n = grid[0].length; + let start_i = 0, + start_j = 0; + let total_keys = 0; + + for (let i = 0; i < m; i++) { + for (let j = 0; j < n; j++) { + if (grid[i][j] === "@") { + start_i = i; + start_j = j; + } + if (grid[i][j] >= "a" && grid[i][j] <= "f") { + total_keys++; + } + } + } + + const target_mask = (1 << total_keys) - 1; + const queue: [number, number, number][] = [[start_i, start_j, 0]]; + const seen: boolean[][][] = Array.from({ length: m }, () => + Array.from({ length: n }, () => Array(1 << total_keys).fill(false)), + ); + seen[start_i][start_j][0] = true; + let moves = 0; + const dirs = [ + [0, 1], + [0, -1], + [1, 0], + [-1, 0], + ]; + + while (queue.length > 0) { + const size = queue.length; + for (let k = 0; k < size; k++) { + const [r, c, mask] = queue.shift()!; + + if (mask === target_mask) { + return moves; + } + + for (const [dx, dy] of dirs) { + const nr = r + dx; + const nc = c + dy; + + if (nr < 0 || nr >= m || nc < 0 || nc >= n) { + continue; + } + + const next_val = grid[nr][nc]; + let next_mask = mask; + + if (next_val >= "a" && next_val <= "f") { + const key_bit = next_val.charCodeAt(0) - "a".charCodeAt(0); + next_mask |= 1 << key_bit; + } + + if (next_val >= "A" && next_val <= "F") { + const lock_bit = + next_val.toLowerCase().charCodeAt(0) - "a".charCodeAt(0); + if ((next_mask & (1 << lock_bit)) === 0) { + continue; + } + } + + if (!seen[nr][nc][next_mask] && next_val !== "#") { + queue.push([nr, nc, next_mask]); + seen[nr][nc][next_mask] = true; + } + } + } + moves++; + } + + return -1; +} diff --git a/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/manifest.yaml b/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/manifest.yaml new file mode 100644 index 00000000..b8b8834c --- /dev/null +++ b/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/manifest.yaml @@ -0,0 +1,177 @@ +entry: + id: 865 + title: smallest-subtree-with-all-the-deepest-nodes + params: + root: + type: tree_node + call: + cpp: treeNodeToArray(Solution().subtreeWithAllDeepest({root})) + rust: TreeNode::tree_node_to_array(Solution::subtree_with_all_deepest({root})) + python3: tree_node_to_array(Solution().subtreeWithAllDeepest({root})) + python2: tree_node_to_array(Solution().subtreeWithAllDeepest({root})) + ruby: tree_node_to_array(subtree_with_all_deepest({root})) + java: TreeNode.treeNodeToArray(new Solution().subtreeWithAllDeepest({root})) + csharp: TreeNode.TreeNodeToArray(new Solution().SubtreeWithAllDeepest({root})) + kotlin: treeNodeToArray(Solution().subtreeWithAllDeepest({root})) + go: treeNodeToArray(subtreeWithAllDeepest({root})) + dart: tree_node_to_array(Solution().subtreeWithAllDeepest({root})) + swift: tree_node_to_array(Solution().subtreeWithAllDeepest({root})) + typescript: treeNodeToArray(subtreeWithAllDeepest({root})) +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 300 +oracle: + python3: + call: Checker().ok({result}) + checker: | + class Checker: + def ok(self, result): + return True +seed: 865 +tests: + - name: ex1 + in: + root: [3, 5, 1, 6, 2, 0, 8, null, null, 7, 4] + out: [2, 7, 4] + - name: ex2 + in: + root: [1] + out: [1] + - name: ex3 + in: + root: [0, 1, 3, null, 2] + out: [2] + - name: root-only-balanced + in: + root: [4, 2, 6] + out: [4, 2, 6] + - name: single-left + in: + root: [1, 2] + out: [2] + - name: single-right + in: + root: [1, null, 2] + out: [2] + - name: left-chain-three + in: + root: [1, 2, null, 3] + out: [3] + - name: right-chain-three + in: + root: [1, null, 2, null, 3] + out: [3] + - name: deepest-siblings + in: + root: [1, 2, 3, 4, 5] + out: [2, 4, 5] + - name: deepest-left-leaf + in: + root: [1, 2, 3, 4, null, null, null, 5] + out: [5] + - name: deepest-right-leaf + in: + root: [1, 2, 3, null, 4, null, 5] + out: [1, 2, 3, null, 4, null, 5] + - name: deepest-lca-root + in: + root: [1, 2, 3, 4, 5, 6, 7] + out: [1, 2, 3, 4, 5, 6, 7] + - name: left-subtree-wins + in: + root: [10, 5, 20, 3, 7, null, null, 1] + out: [1] + - name: right-subtree-wins + in: + root: [10, 5, 20, null, null, 15, 25, null, null, 12] + out: [12] + - name: lca-at-left-child + in: + root: [1, 2, 3, 4, 5, null, null] + out: [2, 4, 5] + - name: lca-at-right-child + in: + root: [1, 2, 3, null, null, 6, 7] + out: [3, 6, 7] + - name: asymmetric-left + in: + root: [8, 4, 9, 2, 6, null, 10, 1] + out: [1] + - name: asymmetric-right + in: + root: [8, 4, 9, null, 6, 7, 10, null, null, 5] + out: [5] + - name: two-deep-leaves-opposite + in: + root: [1, 2, 3, 4, 5, null, null, 6] + out: [6] + - name: one-deepest-side + in: + root: [1, 2, 3, 4, null, 6, null, 7] + out: [7] + - name: perfect-seven + in: + root: [1, 2, 3, 4, 5, 6, 7] + out: [1, 2, 3, 4, 5, 6, 7] + - name: lopsided-left + in: + root: [1, 2, null, 3, null, 4, null] + out: [4] + - name: lopsided-right + in: + root: [1, null, 2, null, 3, null, 4] + out: [4] + - name: deep-center + in: + root: [1, 2, 3, 4, 5, 6, 7, null, null, 8, 9] + out: [5, 8, 9] + - name: deepest-right-chain + in: + root: [1, 2, 3, null, 4, null, 5, null, null, null, 6] + out: [6] + - name: deepest-left-chain + in: + root: [1, 2, 3, 4, null, 5, null, 6] + out: [6] + - name: balanced-with-leaf + in: + root: [1, 2, 3, 4, 5, 6, null, null, null, 7] + out: [7] + - name: balanced-with-two-leaves + in: + root: [1, 2, 3, 4, 5, 6, 7, null, null, null, null, 8, 9] + out: [6, 8, 9] + - name: root-as-answer + in: + root: [50, 20, 80, 10, 30, 60, 90] + out: [50, 20, 80, 10, 30, 60, 90] + - name: deeper-left-right + in: + root: [1, 2, 3, 4, null, 5, null, null, 6] + out: [6] + - name: deeper-right-left + in: + root: [1, 2, 3, null, 4, null, 5, 6] + out: [6] + - name: internal-lca + in: + root: [1, 2, 3, 4, 5, 6, null, 7, null, null, 8] + out: [2, 4, 5, 7, null, null, 8] + - name: paired-deepest + in: + root: [1, 2, 3, 4, 5, null, null, 6] + out: [6] + - name: near-root-lca + in: + root: [1, 2, 3, 4, 5, 6, 7, 8] + out: [8] + - name: deep-left-and-right + in: + root: [1, 2, 3, 4, null, 5, 6] + out: [1, 2, 3, 4, null, 5, 6] + - name: final-asymmetric + in: + root: [1, 2, 3, 4, null, 5, 6] + out: [1, 2, 3, 4, null, 5, 6] diff --git a/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.cpp b/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.cpp new file mode 100644 index 00000000..bbbcbe95 --- /dev/null +++ b/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.cpp @@ -0,0 +1,52 @@ +/** + * Definition for a binary tree node. + * struct TreeNode { + * int val; + * TreeNode *left; + * TreeNode *right; + * TreeNode() : val(0), left(nullptr), right(nullptr) {} + * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} + * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} + * }; + */ +class Solution { +public: + TreeNode* subtreeWithAllDeepest(TreeNode* root) { + if (!root) return nullptr; + + unordered_map parent; + parent[root] = nullptr; + queue q; + q.push(root); + vector lastLevel; + + while (!q.empty()) { + int size = q.size(); + lastLevel.clear(); + for (int i = 0; i < size; i++) { + TreeNode* node = q.front(); + q.pop(); + lastLevel.push_back(node); + if (node->left) { + parent[node->left] = node; + q.push(node->left); + } + if (node->right) { + parent[node->right] = node; + q.push(node->right); + } + } + } + + unordered_set deepest(lastLevel.begin(), lastLevel.end()); + while (deepest.size() > 1) { + unordered_set next; + for (TreeNode* node : deepest) { + next.insert(parent[node]); + } + deepest = next; + } + + return *deepest.begin(); + } +}; diff --git a/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.cs b/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.cs new file mode 100644 index 00000000..05288a1e --- /dev/null +++ b/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.cs @@ -0,0 +1,55 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public int val; + * public TreeNode left; + * public TreeNode right; + * public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +public class Solution { + public TreeNode SubtreeWithAllDeepest(TreeNode root) { + if (root == null) return null; + + Dictionary parent = new Dictionary(); + parent[root] = null; + Queue q = new Queue(); + q.Enqueue(root); + List lastLevel = new List(); + + while (q.Count > 0) { + int size = q.Count; + lastLevel = new List(); + for (int i = 0; i < size; i++) { + TreeNode node = q.Dequeue(); + lastLevel.Add(node); + if (node.left != null) { + parent[node.left] = node; + q.Enqueue(node.left); + } + if (node.right != null) { + parent[node.right] = node; + q.Enqueue(node.right); + } + } + } + + HashSet deepest = new HashSet(lastLevel); + while (deepest.Count > 1) { + HashSet next = new HashSet(); + foreach (TreeNode node in deepest) { + next.Add(parent[node]); + } + deepest = next; + } + + foreach (TreeNode node in deepest) { + return node; + } + return null; + } +} diff --git a/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.dart b/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.dart new file mode 100644 index 00000000..b82cd688 --- /dev/null +++ b/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.dart @@ -0,0 +1,42 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * int val; + * TreeNode? left; + * TreeNode? right; + * TreeNode([this.val = 0, this.left, this.right]); + * } + */ +class Solution { + TreeNode? subtreeWithAllDeepest(TreeNode? root) { + if (root == null) return null; + + Map parent = {root: null}; + var q = [root]; + List lastLevel = []; + + while (q.isNotEmpty) { + int size = q.length; + lastLevel = []; + for (int i = 0; i < size; i++) { + TreeNode node = q.removeAt(0); + lastLevel.add(node); + if (node.left != null) { + parent[node.left!] = node; + q.add(node.left!); + } + if (node.right != null) { + parent[node.right!] = node; + q.add(node.right!); + } + } + } + + var deepest = lastLevel.toSet(); + while (deepest.length > 1) { + deepest = deepest.map((node) => parent[node]!).toSet(); + } + + return deepest.first; + } +} diff --git a/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.go b/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.go new file mode 100644 index 00000000..00e89e36 --- /dev/null +++ b/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.go @@ -0,0 +1,54 @@ +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +func subtreeWithAllDeepest(root *TreeNode) *TreeNode { + if root == nil { + return nil + } + + parent := make(map[*TreeNode]*TreeNode) + parent[root] = nil + q := []*TreeNode{root} + var lastLevel []*TreeNode + + for len(q) > 0 { + size := len(q) + lastLevel = nil + for i := 0; i < size; i++ { + node := q[0] + q = q[1:] + lastLevel = append(lastLevel, node) + if node.Left != nil { + parent[node.Left] = node + q = append(q, node.Left) + } + if node.Right != nil { + parent[node.Right] = node + q = append(q, node.Right) + } + } + } + + deepest := make(map[*TreeNode]bool) + for _, node := range lastLevel { + deepest[node] = true + } + + for len(deepest) > 1 { + next := make(map[*TreeNode]bool) + for node := range deepest { + next[parent[node]] = true + } + deepest = next + } + + for node := range deepest { + return node + } + return nil +} diff --git a/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.java b/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.java new file mode 100644 index 00000000..95e1c7d2 --- /dev/null +++ b/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.java @@ -0,0 +1,54 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode() {} + * TreeNode(int val) { this.val = val; } + * TreeNode(int val, TreeNode left, TreeNode right) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +class Solution { + public TreeNode subtreeWithAllDeepest(TreeNode root) { + if (root == null) return null; + + Map parent = new HashMap<>(); + parent.put(root, null); + Queue q = new LinkedList<>(); + q.offer(root); + List lastLevel = new ArrayList<>(); + + while (!q.isEmpty()) { + int size = q.size(); + lastLevel = new ArrayList<>(); + for (int i = 0; i < size; i++) { + TreeNode node = q.poll(); + lastLevel.add(node); + if (node.left != null) { + parent.put(node.left, node); + q.offer(node.left); + } + if (node.right != null) { + parent.put(node.right, node); + q.offer(node.right); + } + } + } + + Set deepest = new HashSet<>(lastLevel); + while (deepest.size() > 1) { + Set next = new HashSet<>(); + for (TreeNode node : deepest) { + next.add(parent.get(node)); + } + deepest = next; + } + + return deepest.iterator().next(); + } +} diff --git a/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.kt b/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.kt new file mode 100644 index 00000000..959e1a33 --- /dev/null +++ b/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.kt @@ -0,0 +1,45 @@ +/** + * Example: + * var ti = TreeNode(5) + * var v = ti.`val` + * Definition for a binary tree node. + * class TreeNode(var `val`: Int) { + * var left: TreeNode? = null + * var right: TreeNode? = null + * } + */ +class Solution { + fun subtreeWithAllDeepest(root: TreeNode?): TreeNode? { + if (root == null) return null + + val parent = mutableMapOf() + parent[root] = null + val q = ArrayDeque() + q.add(root) + var lastLevel = mutableListOf() + + while (q.isNotEmpty()) { + val size = q.size + lastLevel = mutableListOf() + repeat(size) { + val node = q.removeFirst() + lastLevel.add(node) + node.left?.let { + parent[it] = node + q.add(it) + } + node.right?.let { + parent[it] = node + q.add(it) + } + } + } + + var deepest = lastLevel.toMutableSet() + while (deepest.size > 1) { + deepest = deepest.map { parent[it]!! }.toMutableSet() + } + + return deepest.first() + } +} diff --git a/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.py b/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.py new file mode 100644 index 00000000..69f76db2 --- /dev/null +++ b/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.py @@ -0,0 +1,36 @@ +from collections import deque + + +class Solution: + def subtreeWithAllDeepest(self, root): + if not root: + return None + + parent = {root: None} + q = deque([root]) + + last_level = [] + + # BFS traversal + while q: + size = len(q) + last_level = [] + for _ in range(size): + node = q.popleft() + last_level.append(node) + + if node.left: + parent[node.left] = node + q.append(node.left) + if node.right: + parent[node.right] = node + q.append(node.right) + + # last_level contains all deepest nodes + deepest = set(last_level) + + # Move up until they meet + while len(deepest) > 1: + deepest = {parent[node] for node in deepest} + + return deepest.pop() diff --git a/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.py2 b/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.py2 new file mode 100644 index 00000000..fd492a50 --- /dev/null +++ b/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.py2 @@ -0,0 +1,38 @@ +# Definition for a binary tree node. +# class TreeNode(object): +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution(object): + def subtreeWithAllDeepest(self, root): + """ + :type root: Optional[TreeNode] + :rtype: Optional[TreeNode] + """ + if not root: + return None + + parent = {root: None} + from collections import deque + q = deque([root]) + last_level = [] + + while q: + size = len(q) + last_level = [] + for _ in range(size): + node = q.popleft() + last_level.append(node) + if node.left: + parent[node.left] = node + q.append(node.left) + if node.right: + parent[node.right] = node + q.append(node.right) + + deepest = set(last_level) + while len(deepest) > 1: + deepest = {parent[node] for node in deepest} + + return deepest.pop() diff --git a/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.rb b/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.rb new file mode 100644 index 00000000..a54fa6e0 --- /dev/null +++ b/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.rb @@ -0,0 +1,42 @@ +# Definition for a binary tree node. +# class TreeNode +# attr_accessor :val, :left, :right +# def initialize(val = 0, left = nil, right = nil) +# @val = val +# @left = left +# @right = right +# end +# end +# @param {TreeNode} root +# @return {TreeNode} +def subtree_with_all_deepest(root) + return nil if root.nil? + + parent = {root => nil} + q = [root] + last_level = [] + + while !q.empty? + size = q.size + last_level = [] + size.times do + node = q.shift + last_level << node + if node.left + parent[node.left] = node + q << node.left + end + if node.right + parent[node.right] = node + q << node.right + end + end + end + + deepest = last_level.to_set + while deepest.size > 1 + deepest = deepest.map { |node| parent[node] }.to_set + end + + return deepest.first +end diff --git a/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.rs b/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.rs new file mode 100644 index 00000000..4ea2b111 --- /dev/null +++ b/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.rs @@ -0,0 +1,44 @@ +// Definition for a binary tree node. +// #[derive(Debug, PartialEq, Eq)] +// pub struct TreeNode { +// pub val: i32, +// pub left: Option>>, +// pub right: Option>>, +// } +// +// impl TreeNode { +// #[inline] +// pub fn new(val: i32) -> Self { +// TreeNode { +// val, +// left: None, +// right: None +// } +// } +// } +impl Solution { + pub fn subtree_with_all_deepest(root: Option>>) -> Option>> { + fn helper(node: Option>>) -> (Option>>, i32) { + match node { + None => (None, 0), + Some(node) => { + let (left, right) = { + let node_ref = node.borrow(); + (node_ref.left.clone(), node_ref.right.clone()) + }; + let (l_node, l_depth) = helper(left); + let (r_node, r_depth) = helper(right); + if l_depth > r_depth { + (l_node, l_depth + 1) + } else if r_depth > l_depth { + (r_node, r_depth + 1) + } else { + (Some(node), l_depth + 1) + } + } + } + } + + helper(root).0 + } +} diff --git a/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.swift b/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.swift new file mode 100644 index 00000000..5b12165a --- /dev/null +++ b/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.swift @@ -0,0 +1,33 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public var val: Int + * public var left: TreeNode? + * public var right: TreeNode? + * public init() { self.val = 0; self.left = nil; self.right = nil; } + * public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; } + * public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) { + * self.val = val + * self.left = left + * self.right = right + * } + * } + */ +class Solution { + func subtreeWithAllDeepest(_ root: TreeNode?) -> TreeNode? { + func helper(_ node: TreeNode?) -> (TreeNode?, Int) { + guard let node = node else { return (nil, 0) } + let left = helper(node.left) + let right = helper(node.right) + if left.1 > right.1 { + return (left.0, left.1 + 1) + } + if right.1 > left.1 { + return (right.0, right.1 + 1) + } + return (node, left.1 + 1) + } + + return helper(root).0 + } +} diff --git a/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.ts b/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.ts new file mode 100644 index 00000000..d889c68d --- /dev/null +++ b/tests/501-1000/865. smallest-subtree-with-all-the-deepest-nodes/sol.ts @@ -0,0 +1,50 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ + +function subtreeWithAllDeepest(root: TreeNode | null): TreeNode | null { + if (!root) return null; + + const parent = new Map(); + parent.set(root, null); + const q: TreeNode[] = [root]; + let lastLevel: TreeNode[] = []; + + while (q.length > 0) { + const size = q.length; + lastLevel = []; + for (let i = 0; i < size; i++) { + const node = q.shift()!; + lastLevel.push(node); + if (node.left) { + parent.set(node.left, node); + q.push(node.left); + } + if (node.right) { + parent.set(node.right, node); + q.push(node.right); + } + } + } + + let deepest = new Set(lastLevel); + while (deepest.size > 1) { + const next = new Set(); + for (const node of deepest) { + next.add(parent.get(node)!); + } + deepest = next; + } + + return deepest.values().next().value!; +} diff --git a/tests/501-1000/866. prime-palindrome/manifest.yaml b/tests/501-1000/866. prime-palindrome/manifest.yaml new file mode 100644 index 00000000..b9a3ed2f --- /dev/null +++ b/tests/501-1000/866. prime-palindrome/manifest.yaml @@ -0,0 +1,184 @@ +entry: + id: 866 + title: prime-palindrome + params: + n: + type: int + call: + cpp: Solution().primePalindrome({n}) + rust: Solution::prime_palindrome({n}) + python3: Solution().primePalindrome({n}) + python2: Solution().primePalindrome({n}) + ruby: prime_palindrome({n}) + java: new Solution().primePalindrome({n}) + csharp: new Solution().PrimePalindrome({n}) + kotlin: Solution().primePalindrome({n}) + go: primePalindrome({n}) + dart: Solution().primePalindrome({n}) + swift: Solution().primePalindrome({n}) + typescript: primePalindrome({n}) +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 300 +oracle: + python3: + call: Checker().primePalindrome(n, {result}) + checker: + "from typing import Any\n\nclass Checker:\n def primePalindrome(self,\ + \ n: int, result: Any) -> bool:\n if not isinstance(result, int) or result\ + \ < n:\n return False\n def is_prime(x: int) -> bool:\n \ + \ if x < 2:\n return False\n if x % 2 ==\ + \ 0:\n return x == 2\n d = 3\n while d\ + \ * d <= x:\n if x % d == 0:\n return False\n\ + \ d += 2\n return True\n def is_pal(x: int)\ + \ -> bool:\n s = str(x)\n return s == s[::-1]\n \ + \ for x in range(n, result):\n if is_pal(x) and is_prime(x):\n \ + \ return False\n return is_pal(result) and is_prime(result)\n" +seed: 866 +tests: + - name: ex1 + in: + n: 6 + out: 7 + - name: ex2 + in: + n: 8 + out: 11 + - name: ex3 + in: + n: 13 + out: 101 + - name: one + in: + n: 1 + out: 2 + - name: two + in: + n: 2 + out: 2 + - name: three + in: + n: 3 + out: 3 + - name: four + in: + n: 4 + out: 5 + - name: five + in: + n: 5 + out: 5 + - name: big_even_to_11 + in: + n: 10 + out: 11 + - name: skip_even_length + in: + n: 9989900 + out: 100030001 + - name: fourteen_to_101 + in: + n: 14 + out: 101 + - name: hundred_to_101 + in: + n: 100 + out: 101 + - name: one_hundred_two_to_131 + in: + n: 102 + out: 131 + - name: one_fifty_to_151 + in: + n: 150 + out: 151 + - name: one_fifty_two_to_181 + in: + n: 152 + out: 181 + - name: one_ninety_to_191 + in: + n: 190 + out: 191 + - name: one_ninety_two_to_313 + in: + n: 192 + out: 313 + - name: three_hundred_fourteen_to_353 + in: + n: 314 + out: 353 + - name: three_hundred_fifty_four_to_373 + in: + n: 354 + out: 373 + - name: three_hundred_eighty_to_383 + in: + n: 380 + out: 383 + - name: eight_hundred_to_919 + in: + n: 800 + out: 919 + - name: one_thousand_to_10301 + in: + n: 1000 + out: 10301 + - name: after_10301 + in: + n: 10302 + out: 10501 + - name: after_10501 + in: + n: 10502 + out: 10601 + - name: after_10601 + in: + n: 10602 + out: 11311 + - name: after_11311 + in: + n: 11312 + out: 11411 + - name: after_11411 + in: + n: 11412 + out: 12421 + - name: after_12421 + in: + n: 12422 + out: 12721 + - name: after_12721 + in: + n: 12722 + out: 12821 + - name: after_12821 + in: + n: 12822 + out: 13331 + - name: after_13331 + in: + n: 13332 + out: 13831 + - name: after_13831 + in: + n: 13832 + out: 13931 + - name: after_13931 + in: + n: 13932 + out: 14341 + - name: after_14341 + in: + n: 14342 + out: 14741 + - name: after_14741 + in: + n: 14742 + out: 15451 + - name: after_15451 + in: + n: 15452 + out: 15551 diff --git a/tests/501-1000/866. prime-palindrome/sol.cpp b/tests/501-1000/866. prime-palindrome/sol.cpp new file mode 100644 index 00000000..00628c05 --- /dev/null +++ b/tests/501-1000/866. prime-palindrome/sol.cpp @@ -0,0 +1,27 @@ +class Solution { +public: + int primePalindrome(int n) { + auto isPrime = [](int num) -> bool { + if (num < 2) return false; + if (num % 2 == 0) return num == 2; + for (int i = 3; i * i <= num; i += 2) { + if (num % i == 0) return false; + } + return true; + }; + + if (n >= 8 && n <= 11) return 11; + + while (true) { + string s = to_string(n); + if (s.length() % 2 == 0 && n > 11) { + n = pow(10, s.length()) + 1; + continue; + } + string rev(s.rbegin(), s.rend()); + if (s == rev && isPrime(n)) return n; + n++; + if (n > 2 && n % 2 == 0) n++; + } + } +}; diff --git a/tests/501-1000/866. prime-palindrome/sol.cs b/tests/501-1000/866. prime-palindrome/sol.cs new file mode 100644 index 00000000..ef2c7611 --- /dev/null +++ b/tests/501-1000/866. prime-palindrome/sol.cs @@ -0,0 +1,28 @@ +public class Solution { + public int PrimePalindrome(int n) { + bool IsPrime(int num) { + if (num < 2) return false; + if (num % 2 == 0) return num == 2; + for (int i = 3; i * i <= num; i += 2) { + if (num % i == 0) return false; + } + return true; + } + + if (n >= 8 && n <= 11) return 11; + + while (true) { + string s = n.ToString(); + if (s.Length % 2 == 0 && n > 11) { + n = (int)Math.Pow(10, s.Length) + 1; + continue; + } + char[] arr = s.ToCharArray(); + Array.Reverse(arr); + string rev = new string(arr); + if (s == rev && IsPrime(n)) return n; + n++; + if (n > 2 && n % 2 == 0) n++; + } + } +} diff --git a/tests/501-1000/866. prime-palindrome/sol.dart b/tests/501-1000/866. prime-palindrome/sol.dart new file mode 100644 index 00000000..d3dca401 --- /dev/null +++ b/tests/501-1000/866. prime-palindrome/sol.dart @@ -0,0 +1,29 @@ +import 'dart:math' as math; + +class Solution { + int primePalindrome(int n) { + bool isPrime(int num) { + if (num < 2) return false; + if (num % 2 == 0) return num == 2; + for (int i = 3; i * i <= num; i += 2) { + if (num % i == 0) return false; + } + return true; + } + + if (n >= 8 && n <= 11) return 11; + + while (true) { + String s = n.toString(); + if (s.length % 2 == 0 && n > 11) { + n = (math.pow(10, s.length)).toInt() + 1; + continue; + } + if (s == s.split('').reversed.join() && isPrime(n)) { + return n; + } + n++; + if (n > 2 && n % 2 == 0) n++; + } + } +} diff --git a/tests/501-1000/866. prime-palindrome/sol.go b/tests/501-1000/866. prime-palindrome/sol.go new file mode 100644 index 00000000..c11eadf9 --- /dev/null +++ b/tests/501-1000/866. prime-palindrome/sol.go @@ -0,0 +1,44 @@ +func primePalindrome(n int) int { + isPrime := func(num int) bool { + if num < 2 { + return false + } + if num % 2 == 0 { + return num == 2 + } + for i := 3; i*i <= num; i += 2 { + if num % i == 0 { + return false + } + } + return true + } + + isPalindrome := func(s string) bool { + for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 { + if s[i] != s[j] { + return false + } + } + return true + } + + if n >= 8 && n <= 11 { + return 11 + } + + for { + s := strconv.Itoa(n) + if len(s) % 2 == 0 && n > 11 { + n = int(math.Pow(10, float64(len(s)))) + 1 + continue + } + if isPalindrome(s) && isPrime(n) { + return n + } + n++ + if n > 2 && n % 2 == 0 { + n++ + } + } +} diff --git a/tests/501-1000/866. prime-palindrome/sol.java b/tests/501-1000/866. prime-palindrome/sol.java new file mode 100644 index 00000000..ac45583f --- /dev/null +++ b/tests/501-1000/866. prime-palindrome/sol.java @@ -0,0 +1,40 @@ +class Solution { + public int primePalindrome(int n) { + if (n >= 8 && n <= 11) { + return 11; + } + while (true) { + String s = Integer.toString(n); + if (s.length() % 2 == 0 && n > 11) { + n = (int)Math.pow(10, s.length()) + 1; + continue; + } + if (isPalindrome(s) && isPrime(n)) { + return n; + } + n++; + if (n > 2 && n % 2 == 0) { + n++; + } + } + } + + private boolean isPrime(int num) { + if (num < 2) return false; + if (num % 2 == 0) return num == 2; + for (int i = 3; i * i <= num; i += 2) { + if (num % i == 0) return false; + } + return true; + } + + private boolean isPalindrome(String s) { + int left = 0, right = s.length() - 1; + while (left < right) { + if (s.charAt(left) != s.charAt(right)) return false; + left++; + right--; + } + return true; + } +} diff --git a/tests/501-1000/866. prime-palindrome/sol.kt b/tests/501-1000/866. prime-palindrome/sol.kt new file mode 100644 index 00000000..0af8302c --- /dev/null +++ b/tests/501-1000/866. prime-palindrome/sol.kt @@ -0,0 +1,28 @@ +class Solution { + fun primePalindrome(n: Int): Int { + var current = n + fun isPrime(num: Int): Boolean { + if (num < 2) return false + if (num % 2 == 0) return num == 2 + var i = 3 + while (i * i <= num) { + if (num % i == 0) return false + i += 2 + } + return true + } + + if (current in 8..11) return 11 + + while (true) { + val s = current.toString() + if (s.length % 2 == 0 && current > 11) { + current = Math.pow(10.0, s.length.toDouble()).toInt() + 1 + continue + } + if (s == s.reversed() && isPrime(current)) return current + current++ + if (current > 2 && current % 2 == 0) current++ + } + } +} diff --git a/tests/501-1000/866. prime-palindrome/sol.py b/tests/501-1000/866. prime-palindrome/sol.py new file mode 100644 index 00000000..215df3eb --- /dev/null +++ b/tests/501-1000/866. prime-palindrome/sol.py @@ -0,0 +1,25 @@ +class Solution: + def primePalindrome(self, n: int) -> int: + def is_prime(num: int) -> bool: + if num < 2: + return False + if num % 2 == 0: + return num == 2 + for i in range(3, int(num**0.5) + 1, 2): + if num % i == 0: + return False + return True + + if 8 <= n <= 11: + return 11 + + while True: + s = str(n) + if len(s) % 2 == 0 and n > 11: + n = 10 ** len(s) + 1 + continue + if s == s[::-1] and is_prime(n): + return n + n += 1 + if n > 2 and n % 2 == 0: + n += 1 diff --git a/tests/501-1000/866. prime-palindrome/sol.py2 b/tests/501-1000/866. prime-palindrome/sol.py2 new file mode 100644 index 00000000..80c42c59 --- /dev/null +++ b/tests/501-1000/866. prime-palindrome/sol.py2 @@ -0,0 +1,31 @@ +class Solution(object): + def primePalindrome(self, n): + """ + :type n: int + :rtype: int + """ + def is_prime(num): + if num < 2: + return False + if num % 2 == 0: + return num == 2 + i = 3 + while i * i <= num: + if num % i == 0: + return False + i += 2 + return True + + if 8 <= n <= 11: + return 11 + + while True: + s = str(n) + if len(s) % 2 == 0 and n > 11: + n = 10 ** len(s) + 1 + continue + if s == s[::-1] and is_prime(n): + return n + n += 1 + if n > 2 and n % 2 == 0: + n += 1 diff --git a/tests/501-1000/866. prime-palindrome/sol.rb b/tests/501-1000/866. prime-palindrome/sol.rb new file mode 100644 index 00000000..474c8898 --- /dev/null +++ b/tests/501-1000/866. prime-palindrome/sol.rb @@ -0,0 +1,29 @@ +# @param {Integer} n +# @return {Integer} +def prime_palindrome(n) + def is_prime(num) + return false if num < 2 + return num == 2 if num % 2 == 0 + i = 3 + while i * i <= num + return false if num % i == 0 + i += 2 + end + true + end + + return 11 if n >= 8 && n <= 11 + + while true + s = n.to_s + if s.length % 2 == 0 && n > 11 + n = 10 ** s.length + 1 + next + end + if s == s.reverse && is_prime(n) + return n + end + n += 1 + n += 1 if n > 2 && n % 2 == 0 + end +end diff --git a/tests/501-1000/866. prime-palindrome/sol.rs b/tests/501-1000/866. prime-palindrome/sol.rs new file mode 100644 index 00000000..1f88e931 --- /dev/null +++ b/tests/501-1000/866. prime-palindrome/sol.rs @@ -0,0 +1,41 @@ +impl Solution { + pub fn prime_palindrome(n: i32) -> i32 { + fn is_prime(num: i32) -> bool { + if num < 2 { + return false; + } + if num % 2 == 0 { + return num == 2; + } + let mut i = 3; + while i * i <= num { + if num % i == 0 { + return false; + } + i += 2; + } + true + } + + let mut n = n; + if n >= 8 && n <= 11 { + return 11; + } + + loop { + let s = n.to_string(); + if s.len() % 2 == 0 && n > 11 { + n = 10_i32.pow(s.len() as u32) + 1; + continue; + } + let rev: String = s.chars().rev().collect(); + if s == rev && is_prime(n) { + return n; + } + n += 1; + if n > 2 && n % 2 == 0 { + n += 1; + } + } + } +} diff --git a/tests/501-1000/866. prime-palindrome/sol.swift b/tests/501-1000/866. prime-palindrome/sol.swift new file mode 100644 index 00000000..6f24f3fb --- /dev/null +++ b/tests/501-1000/866. prime-palindrome/sol.swift @@ -0,0 +1,32 @@ +class Solution { + func primePalindrome(_ n: Int) -> Int { + func isPrime(_ num: Int) -> Bool { + if num < 2 { return false } + if num % 2 == 0 { return num == 2 } + var i = 3 + while i * i <= num { + if num % i == 0 { return false } + i += 2 + } + return true + } + + var n = n + if n >= 8 && n <= 11 { return 11 } + + while true { + let s = String(n) + if s.count % 2 == 0 && n > 11 { + n = Int(pow(10.0, Double(s.count))) + 1 + continue + } + if String(s.reversed()) == s && isPrime(n) { + return n + } + n += 1 + if n > 2 && n % 2 == 0 { + n += 1 + } + } + } +} diff --git a/tests/501-1000/866. prime-palindrome/sol.ts b/tests/501-1000/866. prime-palindrome/sol.ts new file mode 100644 index 00000000..221c9bc5 --- /dev/null +++ b/tests/501-1000/866. prime-palindrome/sol.ts @@ -0,0 +1,25 @@ +function primePalindrome(n: number): number { + function isPrime(num: number): boolean { + if (num < 2) return false; + if (num % 2 === 0) return num === 2; + for (let i = 3; i * i <= num; i += 2) { + if (num % i === 0) return false; + } + return true; + } + + if (n >= 8 && n <= 11) return 11; + + while (true) { + const s = n.toString(); + if (s.length % 2 === 0 && n > 11) { + n = Math.pow(10, s.length) + 1; + continue; + } + if (s === s.split("").reverse().join("") && isPrime(n)) { + return n; + } + n++; + if (n > 2 && n % 2 === 0) n++; + } +} diff --git a/tests/501-1000/867. transpose-matrix/manifest.yaml b/tests/501-1000/867. transpose-matrix/manifest.yaml new file mode 100644 index 00000000..5975245f --- /dev/null +++ b/tests/501-1000/867. transpose-matrix/manifest.yaml @@ -0,0 +1,528 @@ +entry: + id: 867 + title: transpose-matrix + params: + matrix: + type: array + items: + type: array + items: + type: int + call: + cpp: "Solution().transpose({matrix})" + rust: "Solution::transpose({matrix})" + python3: "Solution().transpose({matrix})" + python2: "Solution().transpose({matrix})" + ruby: "transpose({matrix})" + java: "new Solution().transpose({matrix})" + csharp: "new Solution().Transpose({matrix})" + kotlin: "Solution().transpose({matrix})" + go: "transpose({matrix})" + dart: "Solution().transpose({matrix})" + swift: "Solution().transpose({matrix})" + typescript: "transpose({matrix})" +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 300 +oracle: + python3: + call: "Checker().transpose(matrix, {result})" + checker: | + from typing import Any + + class Checker: + def transpose(self, matrix: list[list[int]], result: Any) -> bool: + if not isinstance(result, list): + return False + if len(matrix) == 0 or len(matrix[0]) == 0: + return False + rows = len(matrix) + cols = len(matrix[0]) + if len(result) != cols: + return False + for row in result: + if not isinstance(row, list) or len(row) != rows: + return False + for i in range(cols): + for j in range(rows): + if result[i][j] != matrix[j][i]: + return False + return True +seed: 867867 +tests: + - name: ex1_square + in: + matrix: + elemType: int + value: + - [1, 2, 3] + - [4, 5, 6] + - [7, 8, 9] + out: + - [1, 4, 7] + - [2, 5, 8] + - [3, 6, 9] + - name: ex2_rectangular + in: + matrix: + elemType: int + value: + - [1, 2, 3] + - [4, 5, 6] + out: + - [1, 4] + - [2, 5] + - [3, 6] + - name: one_by_one + in: + matrix: + elemType: int + value: + - [5] + - name: one_by_many + in: + matrix: + elemType: int + value: + - [1, -1, 2, -2, 3, -3, 4] + - name: many_by_one + in: + matrix: + elemType: int + value: + - [1] + - [2] + - [3] + - [4] + - [5] + - name: two_by_two_negatives + in: + matrix: + elemType: int + value: + - [-1, -2] + - [-3, -4] + - name: three_by_four_mixed + in: + matrix: + elemType: int + value: + - [1, 3, 5, 7] + - [10, 11, 16, 20] + - [23, 30, 34, 60] + - name: four_by_three_descending + in: + matrix: + elemType: int + value: + - [12, 11, 10] + - [9, 8, 7] + - [6, 5, 4] + - [3, 2, 1] + - name: gen_small_rect_1 + seed: 1 + in: + matrix: + gen: array + elemType: int + len: 2 + of: + gen: array + elemType: int + len: 3 + of: + gen: int + min: -10 + max: 10 + - name: gen_small_rect_2 + seed: 2 + in: + matrix: + gen: array + elemType: int + len: 4 + of: + gen: array + elemType: int + len: 2 + of: + gen: int + min: -100 + max: 100 + - name: gen_medium_1 + seed: 3 + in: + matrix: + gen: array + elemType: int + len: 10 + of: + gen: array + elemType: int + len: 10 + of: + gen: int + min: -1000 + max: 1000 + - name: gen_medium_2 + seed: 4 + in: + matrix: + gen: array + elemType: int + len: 5 + of: + gen: array + elemType: int + len: 20 + of: + gen: int + min: -50 + max: 50 + - name: gen_wide_1 + seed: 5 + in: + matrix: + gen: array + elemType: int + len: 1 + of: + gen: array + elemType: int + len: 100 + of: + gen: int + min: -1000000000 + max: 1000000000 + - name: gen_tall_1 + seed: 6 + in: + matrix: + gen: array + elemType: int + len: 100 + of: + gen: array + elemType: int + len: 1 + of: + gen: int + min: -1000000000 + max: 1000000000 + - name: gen_rect_3x7 + seed: 7 + in: + matrix: + gen: array + elemType: int + len: 3 + of: + gen: array + elemType: int + len: 7 + of: + gen: int + min: -999 + max: 999 + - name: gen_rect_7x3 + seed: 8 + in: + matrix: + gen: array + elemType: int + len: 7 + of: + gen: array + elemType: int + len: 3 + of: + gen: int + min: -999 + max: 999 + - name: gen_rect_8x8 + seed: 9 + in: + matrix: + gen: array + elemType: int + len: 8 + of: + gen: array + elemType: int + len: 8 + of: + gen: int + min: -5 + max: 5 + - name: gen_rect_2x50 + seed: 10 + in: + matrix: + gen: array + elemType: int + len: 2 + of: + gen: array + elemType: int + len: 50 + of: + gen: int + min: 0 + max: 100 + - name: gen_rect_50x2 + seed: 11 + in: + matrix: + gen: array + elemType: int + len: 50 + of: + gen: array + elemType: int + len: 2 + of: + gen: int + min: 0 + max: 100 + - name: gen_rect_25x4 + seed: 12 + in: + matrix: + gen: array + elemType: int + len: 25 + of: + gen: array + elemType: int + len: 4 + of: + gen: int + min: -20 + max: 20 + - name: gen_rect_4x25 + seed: 13 + in: + matrix: + gen: array + elemType: int + len: 4 + of: + gen: array + elemType: int + len: 25 + of: + gen: int + min: -20 + max: 20 + - name: gen_rect_11x9 + seed: 14 + in: + matrix: + gen: array + elemType: int + len: 11 + of: + gen: array + elemType: int + len: 9 + of: + gen: int + min: -100 + max: 100 + - name: gen_rect_9x11 + seed: 15 + in: + matrix: + gen: array + elemType: int + len: 9 + of: + gen: array + elemType: int + len: 11 + of: + gen: int + min: -100 + max: 100 + - name: gen_rect_16x6 + seed: 16 + in: + matrix: + gen: array + elemType: int + len: 16 + of: + gen: array + elemType: int + len: 6 + of: + gen: int + min: -7 + max: 7 + - name: gen_rect_6x16 + seed: 17 + in: + matrix: + gen: array + elemType: int + len: 6 + of: + gen: array + elemType: int + len: 16 + of: + gen: int + min: -7 + max: 7 + - name: gen_rect_32x3 + seed: 18 + in: + matrix: + gen: array + elemType: int + len: 32 + of: + gen: array + elemType: int + len: 3 + of: + gen: int + min: -1000 + max: 1000 + - name: gen_rect_3x32 + seed: 19 + in: + matrix: + gen: array + elemType: int + len: 3 + of: + gen: array + elemType: int + len: 32 + of: + gen: int + min: -1000 + max: 1000 + - name: gen_large_100x100 + seed: 20 + in: + matrix: + gen: array + elemType: int + len: 100 + of: + gen: array + elemType: int + len: 100 + of: + gen: int + min: -1 + max: 1 + - name: gen_large_200x500 + seed: 21 + in: + matrix: + gen: array + elemType: int + len: 200 + of: + gen: array + elemType: int + len: 500 + of: + gen: int + min: -3 + max: 3 + - name: gen_large_500x200 + seed: 22 + in: + matrix: + gen: array + elemType: int + len: 500 + of: + gen: array + elemType: int + len: 200 + of: + gen: int + min: -3 + max: 3 + - name: gen_rect_12x12 + seed: 23 + in: + matrix: + gen: array + elemType: int + len: 12 + of: + gen: array + elemType: int + len: 12 + of: + gen: int + min: -100 + max: 100 + - name: gen_rect_20x5 + seed: 24 + in: + matrix: + gen: array + elemType: int + len: 20 + of: + gen: array + elemType: int + len: 5 + of: + gen: int + min: -100 + max: 100 + - name: gen_rect_5x20 + seed: 25 + in: + matrix: + gen: array + elemType: int + len: 5 + of: + gen: array + elemType: int + len: 20 + of: + gen: int + min: -100 + max: 100 + - name: gen_rect_30x30 + seed: 26 + in: + matrix: + gen: array + elemType: int + len: 30 + of: + gen: array + elemType: int + len: 30 + of: + gen: int + min: -1 + max: 1 + - name: gen_rect_15x15 + seed: 27 + in: + matrix: + gen: array + elemType: int + len: 15 + of: + gen: array + elemType: int + len: 15 + of: + gen: int + min: -10 + max: 10 diff --git a/tests/501-1000/867. transpose-matrix/sol.cpp b/tests/501-1000/867. transpose-matrix/sol.cpp new file mode 100644 index 00000000..2f15f1c8 --- /dev/null +++ b/tests/501-1000/867. transpose-matrix/sol.cpp @@ -0,0 +1,16 @@ +class Solution { +public: + vector> transpose(vector>& matrix) { + int row = matrix.size(); + int col = matrix[0].size(); + vector> trans(col, vector(row)); + + for (int i = 0; i < col; i++) { + for (int j = 0; j < row; j++) { + trans[i][j] = matrix[j][i]; + } + } + + return trans; + } +}; diff --git a/tests/501-1000/867. transpose-matrix/sol.cs b/tests/501-1000/867. transpose-matrix/sol.cs new file mode 100644 index 00000000..147bff12 --- /dev/null +++ b/tests/501-1000/867. transpose-matrix/sol.cs @@ -0,0 +1,16 @@ +public class Solution { + public int[][] Transpose(int[][] matrix) { + int row = matrix.Length; + int col = matrix[0].Length; + int[][] trans = new int[col][]; + + for (int i = 0; i < col; i++) { + trans[i] = new int[row]; + for (int j = 0; j < row; j++) { + trans[i][j] = matrix[j][i]; + } + } + + return trans; + } +} diff --git a/tests/501-1000/867. transpose-matrix/sol.dart b/tests/501-1000/867. transpose-matrix/sol.dart new file mode 100644 index 00000000..3ff4c626 --- /dev/null +++ b/tests/501-1000/867. transpose-matrix/sol.dart @@ -0,0 +1,15 @@ +class Solution { + List> transpose(List> matrix) { + int row = matrix.length; + int col = matrix[0].length; + List> trans = List.generate(col, (_) => List.filled(row, 0)); + + for (int i = 0; i < col; i++) { + for (int j = 0; j < row; j++) { + trans[i][j] = matrix[j][i]; + } + } + + return trans; + } +} diff --git a/tests/501-1000/867. transpose-matrix/sol.go b/tests/501-1000/867. transpose-matrix/sol.go new file mode 100644 index 00000000..efe16112 --- /dev/null +++ b/tests/501-1000/867. transpose-matrix/sol.go @@ -0,0 +1,16 @@ +func transpose(matrix [][]int) [][]int { + row := len(matrix) + col := len(matrix[0]) + trans := make([][]int, col) + for i := range trans { + trans[i] = make([]int, row) + } + + for i := 0; i < col; i++ { + for j := 0; j < row; j++ { + trans[i][j] = matrix[j][i] + } + } + + return trans +} diff --git a/tests/501-1000/867. transpose-matrix/sol.java b/tests/501-1000/867. transpose-matrix/sol.java new file mode 100644 index 00000000..6e1c6d69 --- /dev/null +++ b/tests/501-1000/867. transpose-matrix/sol.java @@ -0,0 +1,15 @@ +class Solution { + public int[][] transpose(int[][] matrix) { + int row = matrix.length; + int col = matrix[0].length; + int[][] trans = new int[col][row]; + + for (int i = 0; i < col; i++) { + for (int j = 0; j < row; j++) { + trans[i][j] = matrix[j][i]; + } + } + + return trans; + } +} diff --git a/tests/501-1000/867. transpose-matrix/sol.kt b/tests/501-1000/867. transpose-matrix/sol.kt new file mode 100644 index 00000000..7349a3b3 --- /dev/null +++ b/tests/501-1000/867. transpose-matrix/sol.kt @@ -0,0 +1,15 @@ +class Solution { + fun transpose(matrix: Array): Array { + val row = matrix.size + val col = matrix[0].size + val trans = Array(col) { IntArray(row) } + + for (i in 0 until col) { + for (j in 0 until row) { + trans[i][j] = matrix[j][i] + } + } + + return trans + } +} diff --git a/tests/501-1000/867. transpose-matrix/sol.py b/tests/501-1000/867. transpose-matrix/sol.py new file mode 100644 index 00000000..4a26ded0 --- /dev/null +++ b/tests/501-1000/867. transpose-matrix/sol.py @@ -0,0 +1,11 @@ +class Solution: + def transpose(self, matrix: list[list[int]]) -> list[list[int]]: + row = len(matrix) + col = len(matrix[0]) + trans = [[0] * row for _ in range(col)] + + for i in range(col): + for j in range(row): + trans[i][j] = matrix[j][i] + + return trans diff --git a/tests/501-1000/867. transpose-matrix/sol.py2 b/tests/501-1000/867. transpose-matrix/sol.py2 new file mode 100644 index 00000000..de37dafb --- /dev/null +++ b/tests/501-1000/867. transpose-matrix/sol.py2 @@ -0,0 +1,15 @@ +class Solution(object): + def transpose(self, matrix): + """ + :type matrix: List[List[int]] + :rtype: List[List[int]] + """ + row = len(matrix) + col = len(matrix[0]) + trans = [[0] * row for _ in range(col)] + + for i in range(col): + for j in range(row): + trans[i][j] = matrix[j][i] + + return trans diff --git a/tests/501-1000/867. transpose-matrix/sol.rb b/tests/501-1000/867. transpose-matrix/sol.rb new file mode 100644 index 00000000..cb2dc52b --- /dev/null +++ b/tests/501-1000/867. transpose-matrix/sol.rb @@ -0,0 +1,15 @@ +# @param {Integer[][]} matrix +# @return {Integer[][]} +def transpose(matrix) + row = matrix.length + col = matrix[0].length + trans = Array.new(col) { Array.new(row, 0) } + + (0...col).each do |i| + (0...row).each do |j| + trans[i][j] = matrix[j][i] + end + end + + trans +end diff --git a/tests/501-1000/867. transpose-matrix/sol.rs b/tests/501-1000/867. transpose-matrix/sol.rs new file mode 100644 index 00000000..093a6c25 --- /dev/null +++ b/tests/501-1000/867. transpose-matrix/sol.rs @@ -0,0 +1,15 @@ +impl Solution { + pub fn transpose(matrix: Vec>) -> Vec> { + let row = matrix.len(); + let col = matrix[0].len(); + let mut trans = vec![vec![0; row]; col]; + + for i in 0..col { + for j in 0..row { + trans[i][j] = matrix[j][i]; + } + } + + trans + } +} diff --git a/tests/501-1000/867. transpose-matrix/sol.swift b/tests/501-1000/867. transpose-matrix/sol.swift new file mode 100644 index 00000000..c619d1fa --- /dev/null +++ b/tests/501-1000/867. transpose-matrix/sol.swift @@ -0,0 +1,15 @@ +class Solution { + func transpose(_ matrix: [[Int]]) -> [[Int]] { + let row = matrix.count + let col = matrix[0].count + var trans = Array(repeating: Array(repeating: 0, count: row), count: col) + + for i in 0.. + Array(row).fill(0), + ); + + for (let i = 0; i < col; i++) { + for (let j = 0; j < row; j++) { + trans[i][j] = matrix[j][i]; + } + } + + return trans; +} diff --git a/tests/501-1000/868. binary-gap/manifest.yaml b/tests/501-1000/868. binary-gap/manifest.yaml new file mode 100644 index 00000000..45374ac8 --- /dev/null +++ b/tests/501-1000/868. binary-gap/manifest.yaml @@ -0,0 +1,157 @@ +entry: + id: 868 + title: binary-gap + params: + n: + type: int + call: + cpp: "Solution().binaryGap({n})" + rust: "Solution::binary_gap({n})" + python3: "Solution().binaryGap({n})" + python2: "Solution().binaryGap({n})" + ruby: "binary_gap({n})" + java: "new Solution().binaryGap({n})" + csharp: "new Solution().BinaryGap({n})" + kotlin: "Solution().binaryGap({n})" + go: "binaryGap({n})" + dart: "Solution().binaryGap({n})" + swift: "Solution().binaryGap({n})" + typescript: "binaryGap({n})" +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 300 +oracle: + python3: + call: "Checker().binaryGap(n, {result})" + checker: | + from typing import Any + + class Checker: + def binaryGap(self, n: int, result: Any) -> bool: + if not isinstance(result, int): + return False + bits = [] + x = n + while x > 0: + bits.append(x & 1) + x >>= 1 + last = None + best = 0 + for i, bit in enumerate(bits): + if bit == 1: + if last is not None: + best = max(best, i - last) + last = i + return result == best +seed: 868868 +tests: + - name: ex1 + in: + n: 22 + - name: ex2 + in: + n: 8 + - name: ex3 + in: + n: 5 + - name: n1 + in: + n: 1 + - name: n2 + in: + n: 2 + - name: n3 + in: + n: 3 + - name: n4 + in: + n: 4 + - name: n7 + in: + n: 7 + - name: n9 + in: + n: 9 + - name: n10 + in: + n: 10 + - name: n11 + in: + n: 11 + - name: n13 + in: + n: 13 + - name: n21 + in: + n: 21 + - name: n42 + in: + n: 42 + - name: n85 + in: + n: 85 + - name: n170 + in: + n: 170 + - name: n256 + in: + n: 256 + - name: n257 + in: + n: 257 + - name: n1023 + in: + n: 1023 + - name: n1024 + in: + n: 1024 + - name: n1025 + in: + n: 1025 + - name: n2048 + in: + n: 2048 + - name: n4097 + in: + n: 4097 + - name: n65535 + in: + n: 65535 + - name: n65536 + in: + n: 65536 + - name: n99991 + in: + n: 99991 + - name: n123456 + in: + n: 123456 + - name: n1048575 + in: + n: 1048575 + - name: n1048576 + in: + n: 1048576 + - name: n999999999 + in: + n: 999999999 + - name: n536870912 + in: + n: 536870912 + - name: n268435456 + in: + n: 268435456 + - name: n134217728 + in: + n: 134217728 + - name: n67108864 + in: + n: 67108864 + - name: n33554432 + in: + n: 33554432 + - name: n16777216 + in: + n: 16777216 diff --git a/tests/501-1000/868. binary-gap/sol.cpp b/tests/501-1000/868. binary-gap/sol.cpp new file mode 100644 index 00000000..9b1122f8 --- /dev/null +++ b/tests/501-1000/868. binary-gap/sol.cpp @@ -0,0 +1,29 @@ +class Solution { +public: + int binaryGap(int n) { + int maxDist = 0; + int currDist = 0; + bool foundFirstOne = false; + + while (n > 0) { + int bit = n % 2; + + if (bit == 1) { + if (foundFirstOne) { + maxDist = std::max(maxDist, currDist); + } + + currDist = 1; + foundFirstOne = true; + } else { + if (foundFirstOne) { + currDist++; + } + } + + n /= 2; + } + + return maxDist; + } +}; diff --git a/tests/501-1000/868. binary-gap/sol.cs b/tests/501-1000/868. binary-gap/sol.cs new file mode 100644 index 00000000..14617afe --- /dev/null +++ b/tests/501-1000/868. binary-gap/sol.cs @@ -0,0 +1,28 @@ +public class Solution { + public int BinaryGap(int n) { + int maxDist = 0; + int currDist = 0; + bool foundFirstOne = false; + + while (n > 0) { + int bit = n % 2; + + if (bit == 1) { + if (foundFirstOne) { + maxDist = Math.Max(maxDist, currDist); + } + + currDist = 1; + foundFirstOne = true; + } else { + if (foundFirstOne) { + currDist++; + } + } + + n /= 2; + } + + return maxDist; + } +} diff --git a/tests/501-1000/868. binary-gap/sol.dart b/tests/501-1000/868. binary-gap/sol.dart new file mode 100644 index 00000000..b1ffedd7 --- /dev/null +++ b/tests/501-1000/868. binary-gap/sol.dart @@ -0,0 +1,30 @@ +class Solution { + int binaryGap(int n) { + int maxDist = 0; + int currDist = 0; + bool foundFirstOne = false; + + while (n > 0) { + int bit = n % 2; + + if (bit == 1) { + if (foundFirstOne) { + if (currDist > maxDist) { + maxDist = currDist; + } + } + + currDist = 1; + foundFirstOne = true; + } else { + if (foundFirstOne) { + currDist++; + } + } + + n ~/= 2; + } + + return maxDist; + } +} diff --git a/tests/501-1000/868. binary-gap/sol.go b/tests/501-1000/868. binary-gap/sol.go new file mode 100644 index 00000000..3553e76f --- /dev/null +++ b/tests/501-1000/868. binary-gap/sol.go @@ -0,0 +1,28 @@ +func binaryGap(n int) int { + maxDist := 0 + currDist := 0 + foundFirstOne := false + + for n > 0 { + bit := n % 2 + + if bit == 1 { + if foundFirstOne { + if currDist > maxDist { + maxDist = currDist + } + } + + currDist = 1 + foundFirstOne = true + } else { + if foundFirstOne { + currDist++ + } + } + + n /= 2 + } + + return maxDist +} diff --git a/tests/501-1000/868. binary-gap/sol.java b/tests/501-1000/868. binary-gap/sol.java new file mode 100644 index 00000000..90d6c14b --- /dev/null +++ b/tests/501-1000/868. binary-gap/sol.java @@ -0,0 +1,28 @@ +class Solution { + public int binaryGap(int n) { + int maxDist = 0; + int currDist = 0; + boolean foundFirstOne = false; + + while (n > 0) { + int bit = n % 2; + + if (bit == 1) { + if (foundFirstOne) { + maxDist = Math.max(maxDist, currDist); + } + + currDist = 1; + foundFirstOne = true; + } else { + if (foundFirstOne) { + currDist++; + } + } + + n /= 2; + } + + return maxDist; + } +} diff --git a/tests/501-1000/868. binary-gap/sol.kt b/tests/501-1000/868. binary-gap/sol.kt new file mode 100644 index 00000000..09dc456f --- /dev/null +++ b/tests/501-1000/868. binary-gap/sol.kt @@ -0,0 +1,29 @@ +class Solution { + fun binaryGap(n: Int): Int { + var maxDist = 0 + var currDist = 0 + var foundFirstOne = false + var num = n + + while (num > 0) { + val bit = num % 2 + + if (bit == 1) { + if (foundFirstOne) { + maxDist = maxOf(maxDist, currDist) + } + + currDist = 1 + foundFirstOne = true + } else { + if (foundFirstOne) { + currDist++ + } + } + + num /= 2 + } + + return maxDist + } +} diff --git a/tests/501-1000/868. binary-gap/sol.py b/tests/501-1000/868. binary-gap/sol.py new file mode 100644 index 00000000..658c222c --- /dev/null +++ b/tests/501-1000/868. binary-gap/sol.py @@ -0,0 +1,22 @@ +class Solution: + def binaryGap(self, n: int) -> int: + max_dist = 0 + curr_dist = 0 + found_first_one = False + + while n > 0: + bit = n % 2 + + if bit == 1: + if found_first_one: + max_dist = max(max_dist, curr_dist) + + curr_dist = 1 + found_first_one = True + else: + if found_first_one: + curr_dist += 1 + + n //= 2 + + return max_dist diff --git a/tests/501-1000/868. binary-gap/sol.py2 b/tests/501-1000/868. binary-gap/sol.py2 new file mode 100644 index 00000000..293a4253 --- /dev/null +++ b/tests/501-1000/868. binary-gap/sol.py2 @@ -0,0 +1,26 @@ +class Solution(object): + def binaryGap(self, n): + """ + :type n: int + :rtype: int + """ + max_dist = 0 + curr_dist = 0 + found_first_one = False + + while n > 0: + bit = n % 2 + + if bit == 1: + if found_first_one: + max_dist = max(max_dist, curr_dist) + + curr_dist = 1 + found_first_one = True + else: + if found_first_one: + curr_dist += 1 + + n //= 2 + + return max_dist diff --git a/tests/501-1000/868. binary-gap/sol.rb b/tests/501-1000/868. binary-gap/sol.rb new file mode 100644 index 00000000..94f37aa0 --- /dev/null +++ b/tests/501-1000/868. binary-gap/sol.rb @@ -0,0 +1,28 @@ +# @param {Integer} n +# @return {Integer} +def binary_gap(n) + max_dist = 0 + curr_dist = 0 + found_first_one = false + + while n > 0 + bit = n % 2 + + if bit == 1 + if found_first_one + max_dist = [max_dist, curr_dist].max + end + + curr_dist = 1 + found_first_one = true + else + if found_first_one + curr_dist += 1 + end + end + + n /= 2 + end + + max_dist +end diff --git a/tests/501-1000/868. binary-gap/sol.rs b/tests/501-1000/868. binary-gap/sol.rs new file mode 100644 index 00000000..acd91e6c --- /dev/null +++ b/tests/501-1000/868. binary-gap/sol.rs @@ -0,0 +1,29 @@ +impl Solution { + pub fn binary_gap(n: i32) -> i32 { + let mut max_dist = 0; + let mut curr_dist = 0; + let mut found_first_one = false; + let mut n = n; + + while n > 0 { + let bit = n % 2; + + if bit == 1 { + if found_first_one { + max_dist = max_dist.max(curr_dist); + } + + curr_dist = 1; + found_first_one = true; + } else { + if found_first_one { + curr_dist += 1; + } + } + + n /= 2; + } + + max_dist + } +} diff --git a/tests/501-1000/868. binary-gap/sol.swift b/tests/501-1000/868. binary-gap/sol.swift new file mode 100644 index 00000000..09bf1b18 --- /dev/null +++ b/tests/501-1000/868. binary-gap/sol.swift @@ -0,0 +1,29 @@ +class Solution { + func binaryGap(_ n: Int) -> Int { + var maxDist = 0 + var currDist = 0 + var foundFirstOne = false + var num = n + + while num > 0 { + let bit = num % 2 + + if bit == 1 { + if foundFirstOne { + maxDist = max(maxDist, currDist) + } + + currDist = 1 + foundFirstOne = true + } else { + if foundFirstOne { + currDist += 1 + } + } + + num /= 2 + } + + return maxDist + } +} diff --git a/tests/501-1000/868. binary-gap/sol.ts b/tests/501-1000/868. binary-gap/sol.ts new file mode 100644 index 00000000..f8a676b0 --- /dev/null +++ b/tests/501-1000/868. binary-gap/sol.ts @@ -0,0 +1,26 @@ +function binaryGap(n: number): number { + let maxDist = 0; + let currDist = 0; + let foundFirstOne = false; + + while (n > 0) { + const bit = n % 2; + + if (bit === 1) { + if (foundFirstOne) { + maxDist = Math.max(maxDist, currDist); + } + + currDist = 1; + foundFirstOne = true; + } else { + if (foundFirstOne) { + currDist++; + } + } + + n = Math.floor(n / 2); + } + + return maxDist; +} diff --git a/tests/501-1000/869. reordered-power-of-2/manifest.yaml b/tests/501-1000/869. reordered-power-of-2/manifest.yaml new file mode 100644 index 00000000..80d97918 --- /dev/null +++ b/tests/501-1000/869. reordered-power-of-2/manifest.yaml @@ -0,0 +1,148 @@ +entry: + id: 869 + title: reordered-power-of-2 + params: + n: + type: int + call: + cpp: "Solution().reorderedPowerOf2({n})" + rust: "Solution::reordered_power_of2({n})" + python3: "Solution().reorderedPowerOf2({n})" + python2: "Solution().reorderedPowerOf2({n})" + ruby: "reordered_power_of2({n})" + java: "new Solution().reorderedPowerOf2({n})" + csharp: "new Solution().ReorderedPowerOf2({n})" + kotlin: "Solution().reorderedPowerOf2({n})" + go: "reorderedPowerOf2({n})" + dart: "Solution().reorderedPowerOf2({n})" + swift: "Solution().reorderedPowerOf2({n})" + typescript: "reorderedPowerOf2({n})" +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 300 +oracle: + python3: + call: "Checker().reorderedPowerOf2(n, {result})" + checker: | + from typing import Any + + class Checker: + def reorderedPowerOf2(self, n: int, result: Any) -> bool: + if not isinstance(result, bool): + return False + digits = sorted(str(n)) + powers = set() + x = 1 + while x <= 10**9: + powers.add(tuple(sorted(str(x)))) + x <<= 1 + return result == (tuple(digits) in powers) +seed: 869869 +tests: + - name: ex1 + in: + n: 1 + - name: ex2 + in: + n: 10 + - name: one_digit_power + in: + n: 8 + - name: one_digit_nonpower + in: + n: 3 + - name: two_digit_true + in: + n: 61 + - name: two_digit_false + in: + n: 12 + - name: three_digit_true + in: + n: 128 + - name: three_digit_false + in: + n: 123 + - name: four_digit_true + in: + n: 218 + - name: four_digit_false + in: + n: 1000 + - name: five_digit_true + in: + n: 1024 + - name: five_digit_false + in: + n: 12500 + - name: six_digit_true + in: + n: 46 + - name: six_digit_false + in: + n: 99999 + - name: repeated_digits_true + in: + n: 46 + - name: repeated_digits_false + in: + n: 111 + - name: zeros_and_digits_false + in: + n: 100 + - name: zeros_and_digits_true + in: + n: 100000000 + - name: near_limit_false_2 + in: + n: 1000000000 + - name: near_limit_false + in: + n: 999999999 + - name: pow2_exact_2 + in: + n: 2 + - name: pow2_exact_4 + in: + n: 4 + - name: pow2_exact_16 + in: + n: 16 + - name: pow2_exact_64 + in: + n: 64 + - name: perm_true_2 + in: + n: 125 + - name: perm_true_3 + in: + n: 821 + - name: perm_true_4 + in: + n: 46 + - name: perm_false_1 + in: + n: 7 + - name: perm_false_2 + in: + n: 22 + - name: perm_false_3 + in: + n: 19 + - name: perm_false_4 + in: + n: 1234 + - name: perm_false_5 + in: + n: 987654321 + - name: perm_false_6 + in: + n: 44444444 + - name: perm_false_7 + in: + n: 99999999 + - name: perm_false_8 + in: + n: 31415926 diff --git a/tests/501-1000/869. reordered-power-of-2/sol.cpp b/tests/501-1000/869. reordered-power-of-2/sol.cpp new file mode 100644 index 00000000..b3d4f1ee --- /dev/null +++ b/tests/501-1000/869. reordered-power-of-2/sol.cpp @@ -0,0 +1,30 @@ +class Solution { +public: + bool reorderedPowerOf2(int n) { + auto signature = [](int num) { + array counts{}; + if (num == 0) { + counts[0] = 1; + } else { + while (num > 0) { + counts[num % 10]++; + num /= 10; + } + } + string s; + for (int count : counts) { + s.push_back('#'); + s += to_string(count); + } + return s; + }; + + string target = signature(n); + for (int i = 0; i < 31; i++) { + if (signature(1 << i) == target) { + return true; + } + } + return false; + } +}; diff --git a/tests/501-1000/869. reordered-power-of-2/sol.cs b/tests/501-1000/869. reordered-power-of-2/sol.cs new file mode 100644 index 00000000..45a4b8ed --- /dev/null +++ b/tests/501-1000/869. reordered-power-of-2/sol.cs @@ -0,0 +1,24 @@ +public class Solution { + public bool ReorderedPowerOf2(int n) { + string Signature(int num) { + var counts = new int[10]; + if (num == 0) { + counts[0] = 1; + } else { + while (num > 0) { + counts[num % 10]++; + num /= 10; + } + } + return string.Join(",", counts); + } + + string target = Signature(n); + for (int i = 0; i < 31; i++) { + if (Signature(1 << i) == target) { + return true; + } + } + return false; + } +} diff --git a/tests/501-1000/869. reordered-power-of-2/sol.dart b/tests/501-1000/869. reordered-power-of-2/sol.dart new file mode 100644 index 00000000..10f00040 --- /dev/null +++ b/tests/501-1000/869. reordered-power-of-2/sol.dart @@ -0,0 +1,20 @@ +class Solution { + bool reorderedPowerOf2(int n) { + List signatures = [ + 3, 5, 11, 23, 51, 35, 187, 345, 1105, 195, 330, 2530, 10846, + 10005, 90321, 260015, 341887, 11970, 154275, 1891175, 6374082, + 1074450, 1621158, 66602158, 89201295, 35070035, 191712774, + 143849475, 4757357605, 588153930, 632937690 + ]; + + List primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]; + + int getSign(int num) { + if (num == 0) return 1; + return primes[num % 10] * getSign(num ~/ 10); + } + + int targetSign = getSign(n); + return signatures.contains(targetSign); + } +} diff --git a/tests/501-1000/869. reordered-power-of-2/sol.go b/tests/501-1000/869. reordered-power-of-2/sol.go new file mode 100644 index 00000000..91f83707 --- /dev/null +++ b/tests/501-1000/869. reordered-power-of-2/sol.go @@ -0,0 +1,26 @@ +func reorderedPowerOf2(n int) bool { + signatures := []int{ + 3, 5, 11, 23, 51, 35, 187, 345, 1105, 195, 330, 2530, 10846, + 10005, 90321, 260015, 341887, 11970, 154275, 1891175, 6374082, + 1074450, 1621158, 66602158, 89201295, 35070035, 191712774, + 143849475, 4757357605, 588153930, 632937690, + } + + primes := []int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29} + + var getSign func(int) int64 + getSign = func(num int) int64 { + if num == 0 { + return 1 + } + return int64(primes[num%10]) * getSign(num/10) + } + + targetSign := getSign(n) + for _, sig := range signatures { + if int64(sig) == targetSign { + return true + } + } + return false +} diff --git a/tests/501-1000/869. reordered-power-of-2/sol.java b/tests/501-1000/869. reordered-power-of-2/sol.java new file mode 100644 index 00000000..f0a1db86 --- /dev/null +++ b/tests/501-1000/869. reordered-power-of-2/sol.java @@ -0,0 +1,28 @@ +class Solution { + public boolean reorderedPowerOf2(int n) { + String target = signature(n); + for (int i = 0; i < 31; i++) { + if (signature(1 << i).equals(target)) { + return true; + } + } + return false; + } + + private String signature(int num) { + int[] counts = new int[10]; + if (num == 0) { + counts[0] = 1; + } else { + while (num > 0) { + counts[num % 10]++; + num /= 10; + } + } + StringBuilder sb = new StringBuilder(); + for (int count : counts) { + sb.append('#').append(count); + } + return sb.toString(); + } +} diff --git a/tests/501-1000/869. reordered-power-of-2/sol.kt b/tests/501-1000/869. reordered-power-of-2/sol.kt new file mode 100644 index 00000000..67883125 --- /dev/null +++ b/tests/501-1000/869. reordered-power-of-2/sol.kt @@ -0,0 +1,20 @@ +class Solution { + fun reorderedPowerOf2(n: Int): Boolean { + val signatures = intArrayOf( + 3, 5, 11, 23, 51, 35, 187, 345, 1105, 195, 330, 2530, 10846, + 10005, 90321, 260015, 341887, 11970, 154275, 1891175, 6374082, + 1074450, 1621158, 66602158, 89201295, 35070035, 191712774, + 143849475, 4757357605.toInt(), 588153930, 632937690 + ) + + val primes = intArrayOf(2, 3, 5, 7, 11, 13, 17, 19, 23, 29) + + fun getSign(num: Int): Long { + if (num == 0) return 1 + return primes[num % 10].toLong() * getSign(num / 10) + } + + val targetSign = getSign(n) + return signatures.contains(targetSign.toInt()) + } +} diff --git a/tests/501-1000/869. reordered-power-of-2/sol.py b/tests/501-1000/869. reordered-power-of-2/sol.py new file mode 100644 index 00000000..b5d1cd5e --- /dev/null +++ b/tests/501-1000/869. reordered-power-of-2/sol.py @@ -0,0 +1,43 @@ +class Solution: + def reorderedPowerOf2(self, n: int) -> bool: + signatures = [ + 3, + 5, + 11, + 23, + 51, + 35, + 187, + 345, + 1105, + 195, + 330, + 2530, + 10846, + 10005, + 90321, + 260015, + 341887, + 11970, + 154275, + 1891175, + 6374082, + 1074450, + 1621158, + 66602158, + 89201295, + 35070035, + 191712774, + 143849475, + 4757357605, + 588153930, + 632937690, + ] + + primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] + + def get_sign(num): + return 1 if num == 0 else primes[num % 10] * get_sign(num // 10) + + target_sign = get_sign(n) + return target_sign in signatures diff --git a/tests/501-1000/869. reordered-power-of-2/sol.py2 b/tests/501-1000/869. reordered-power-of-2/sol.py2 new file mode 100644 index 00000000..935c115f --- /dev/null +++ b/tests/501-1000/869. reordered-power-of-2/sol.py2 @@ -0,0 +1,22 @@ +class Solution(object): + def reorderedPowerOf2(self, n): + """ + :type n: int + :rtype: bool + """ + signatures = [ + 3, 5, 11, 23, 51, 35, 187, 345, 1105, 195, 330, 2530, 10846, + 10005, 90321, 260015, 341887, 11970, 154275, 1891175, 6374082, + 1074450, 1621158, 66602158, 89201295, 35070035, 191712774, + 143849475, 4757357605, 588153930, 632937690 + ] + + primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] + + def get_sign(num): + if num == 0: + return 1 + return primes[num % 10] * get_sign(num // 10) + + target_sign = get_sign(n) + return target_sign in signatures diff --git a/tests/501-1000/869. reordered-power-of-2/sol.rb b/tests/501-1000/869. reordered-power-of-2/sol.rb new file mode 100644 index 00000000..79dea8b8 --- /dev/null +++ b/tests/501-1000/869. reordered-power-of-2/sol.rb @@ -0,0 +1,19 @@ +# @param {Integer} n +# @return {Boolean} +def reordered_power_of2(n) + signature = ->(num) do + counts = Array.new(10, 0) + if num == 0 + counts[0] = 1 + else + while num > 0 + counts[num % 10] += 1 + num /= 10 + end + end + counts.join(",") + end + + target = signature.call(n) + (0..30).any? { |i| signature.call(1 << i) == target } +end diff --git a/tests/501-1000/869. reordered-power-of-2/sol.rs b/tests/501-1000/869. reordered-power-of-2/sol.rs new file mode 100644 index 00000000..e968493f --- /dev/null +++ b/tests/501-1000/869. reordered-power-of-2/sol.rs @@ -0,0 +1,29 @@ +impl Solution { + pub fn reordered_power_of2(n: i32) -> bool { + fn signature(mut num: i32) -> String { + let mut counts = [0i32; 10]; + if num == 0 { + counts[0] = 1; + } else { + while num > 0 { + counts[(num % 10) as usize] += 1; + num /= 10; + } + } + let mut out = String::new(); + for count in counts.iter() { + out.push('#'); + out.push_str(&count.to_string()); + } + out + } + + let target = signature(n); + for i in 0..31 { + if signature(1 << i) == target { + return true; + } + } + false + } +} diff --git a/tests/501-1000/869. reordered-power-of-2/sol.swift b/tests/501-1000/869. reordered-power-of-2/sol.swift new file mode 100644 index 00000000..07a5094a --- /dev/null +++ b/tests/501-1000/869. reordered-power-of-2/sol.swift @@ -0,0 +1,20 @@ +class Solution { + func reorderedPowerOf2(_ n: Int) -> Bool { + let signatures: [Int] = [ + 3, 5, 11, 23, 51, 35, 187, 345, 1105, 195, 330, 2530, 10846, + 10005, 90321, 260015, 341887, 11970, 154275, 1891175, 6374082, + 1074450, 1621158, 66602158, 89201295, 35070035, 191712774, + 143849475, 4757357605, 588153930, 632937690 + ] + + let primes: [Int] = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] + + func getSign(_ num: Int) -> Int { + if num == 0 { return 1 } + return primes[num % 10] * getSign(num / 10) + } + + let targetSign = getSign(n) + return signatures.contains(targetSign) + } +} diff --git a/tests/501-1000/869. reordered-power-of-2/sol.ts b/tests/501-1000/869. reordered-power-of-2/sol.ts new file mode 100644 index 00000000..c45d4ad4 --- /dev/null +++ b/tests/501-1000/869. reordered-power-of-2/sol.ts @@ -0,0 +1,17 @@ +function reorderedPowerOf2(n: number): boolean { + const signatures: number[] = [ + 3, 5, 11, 23, 51, 35, 187, 345, 1105, 195, 330, 2530, 10846, 10005, 90321, + 260015, 341887, 11970, 154275, 1891175, 6374082, 1074450, 1621158, 66602158, + 89201295, 35070035, 191712774, 143849475, 4757357605, 588153930, 632937690, + ]; + + const primes: number[] = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]; + + const getSign = (num: number): number => { + if (num === 0) return 1; + return primes[num % 10] * getSign(Math.floor(num / 10)); + }; + + const targetSign = getSign(n); + return signatures.includes(targetSign); +} diff --git a/tests/501-1000/870. advantage-shuffle/manifest.yaml b/tests/501-1000/870. advantage-shuffle/manifest.yaml new file mode 100644 index 00000000..c34fc5f3 --- /dev/null +++ b/tests/501-1000/870. advantage-shuffle/manifest.yaml @@ -0,0 +1,693 @@ +entry: + id: 870 + title: advantage-shuffle + params: + nums1: + type: array + items: + type: int + nums2: + type: array + items: + type: int + call: + cpp: "Solution().advantageCount({nums1}, {nums2})" + rust: "Solution::advantage_count({nums1}, {nums2})" + python3: "Solution().advantageCount({nums1}, {nums2})" + python2: "Solution().advantageCount({nums1}, {nums2})" + ruby: "advantage_count({nums1}, {nums2})" + java: "new Solution().advantageCount({nums1}, {nums2})" + csharp: "new Solution().AdvantageCount({nums1}, {nums2})" + kotlin: "Solution().advantageCount({nums1}, {nums2})" + go: "advantageCount({nums1}, {nums2})" + dart: "Solution().advantageCount({nums1}, {nums2})" + swift: "Solution().advantageCount({nums1}, {nums2})" + typescript: "advantageCount({nums1}, {nums2})" +judge: + type: exact +limits: + time_ms: 1500 + memory_mb: 300 +oracle: + python3: + call: "Checker().advantageCount(nums1, nums2, {result})" + checker: | + from collections import Counter + from typing import Any + + class Checker: + def advantageCount(self, nums1: list[int], nums2: list[int], result: Any) -> bool: + if not isinstance(result, list) or len(result) != len(nums1): + return False + if Counter(result) != Counter(nums1): + return False + actual = sum(1 for a, b in zip(result, nums2) if a > b) + a = sorted(nums1) + b = sorted(nums2) + i = j = wins = 0 + n = len(a) + while i < n and j < n: + if a[i] > b[j]: + wins += 1 + i += 1 + j += 1 + else: + i += 1 + return actual == wins +seed: 870870 +tests: + - name: ex1 + in: + nums1: [2, 7, 11, 15] + nums2: [1, 10, 4, 11] + - name: ex2 + in: + nums1: [12, 24, 8, 32] + nums2: [13, 25, 32, 11] + - name: small_1 + seed: 1 + in: + nums1: + gen: array + elemType: int + len: 1 + of: + gen: int + min: 0 + max: 100 + nums2: + gen: array + elemType: int + len: 1 + of: + gen: int + min: 0 + max: 100 + - name: small_2 + seed: 2 + in: + nums1: + gen: array + elemType: int + len: 2 + of: + gen: int + min: 0 + max: 100 + nums2: + gen: array + elemType: int + len: 2 + of: + gen: int + min: 0 + max: 100 + - name: small_3 + seed: 3 + in: + nums1: + gen: array + elemType: int + len: 3 + of: + gen: int + min: 0 + max: 100 + nums2: + gen: array + elemType: int + len: 3 + of: + gen: int + min: 0 + max: 100 + - name: small_4 + seed: 4 + in: + nums1: + gen: array + elemType: int + len: 4 + of: + gen: int + min: 0 + max: 100 + nums2: + gen: array + elemType: int + len: 4 + of: + gen: int + min: 0 + max: 100 + - name: small_5 + seed: 5 + in: + nums1: + gen: array + elemType: int + len: 5 + of: + gen: int + min: 0 + max: 100 + nums2: + gen: array + elemType: int + len: 5 + of: + gen: int + min: 0 + max: 100 + - name: medium_6 + seed: 6 + in: + nums1: + gen: array + elemType: int + len: 6 + of: + gen: int + min: 0 + max: 1000 + nums2: + gen: array + elemType: int + len: 6 + of: + gen: int + min: 0 + max: 1000 + - name: medium_7 + seed: 7 + in: + nums1: + gen: array + elemType: int + len: 7 + of: + gen: int + min: 0 + max: 1000 + nums2: + gen: array + elemType: int + len: 7 + of: + gen: int + min: 0 + max: 1000 + - name: medium_8 + seed: 8 + in: + nums1: + gen: array + elemType: int + len: 8 + of: + gen: int + min: 0 + max: 1000 + nums2: + gen: array + elemType: int + len: 8 + of: + gen: int + min: 0 + max: 1000 + - name: medium_9 + seed: 9 + in: + nums1: + gen: array + elemType: int + len: 9 + of: + gen: int + min: 0 + max: 1000 + nums2: + gen: array + elemType: int + len: 9 + of: + gen: int + min: 0 + max: 1000 + - name: medium_10 + seed: 10 + in: + nums1: + gen: array + elemType: int + len: 10 + of: + gen: int + min: 0 + max: 1000 + nums2: + gen: array + elemType: int + len: 10 + of: + gen: int + min: 0 + max: 1000 + - name: medium_11 + seed: 11 + in: + nums1: + gen: array + elemType: int + len: 11 + of: + gen: int + min: 0 + max: 1000 + nums2: + gen: array + elemType: int + len: 11 + of: + gen: int + min: 0 + max: 1000 + - name: medium_12 + seed: 12 + in: + nums1: + gen: array + elemType: int + len: 12 + of: + gen: int + min: 0 + max: 1000 + nums2: + gen: array + elemType: int + len: 12 + of: + gen: int + min: 0 + max: 1000 + - name: medium_13 + seed: 13 + in: + nums1: + gen: array + elemType: int + len: 13 + of: + gen: int + min: 0 + max: 1000 + nums2: + gen: array + elemType: int + len: 13 + of: + gen: int + min: 0 + max: 1000 + - name: medium_14 + seed: 14 + in: + nums1: + gen: array + elemType: int + len: 14 + of: + gen: int + min: 0 + max: 1000 + nums2: + gen: array + elemType: int + len: 14 + of: + gen: int + min: 0 + max: 1000 + - name: medium_15 + seed: 15 + in: + nums1: + gen: array + elemType: int + len: 15 + of: + gen: int + min: 0 + max: 1000 + nums2: + gen: array + elemType: int + len: 15 + of: + gen: int + min: 0 + max: 1000 + - name: medium_16 + seed: 16 + in: + nums1: + gen: array + elemType: int + len: 16 + of: + gen: int + min: 0 + max: 1000 + nums2: + gen: array + elemType: int + len: 16 + of: + gen: int + min: 0 + max: 1000 + - name: medium_17 + seed: 17 + in: + nums1: + gen: array + elemType: int + len: 17 + of: + gen: int + min: 0 + max: 1000 + nums2: + gen: array + elemType: int + len: 17 + of: + gen: int + min: 0 + max: 1000 + - name: medium_18 + seed: 18 + in: + nums1: + gen: array + elemType: int + len: 18 + of: + gen: int + min: 0 + max: 1000 + nums2: + gen: array + elemType: int + len: 18 + of: + gen: int + min: 0 + max: 1000 + - name: medium_19 + seed: 19 + in: + nums1: + gen: array + elemType: int + len: 19 + of: + gen: int + min: 0 + max: 1000 + nums2: + gen: array + elemType: int + len: 19 + of: + gen: int + min: 0 + max: 1000 + - name: medium_20 + seed: 20 + in: + nums1: + gen: array + elemType: int + len: 20 + of: + gen: int + min: 0 + max: 1000 + nums2: + gen: array + elemType: int + len: 20 + of: + gen: int + min: 0 + max: 1000 + - name: large_1 + seed: 21 + in: + nums1: + gen: array + elemType: int + len: 1000 + of: + gen: int + min: 0 + max: 1000000000 + nums2: + gen: array + elemType: int + len: 1000 + of: + gen: int + min: 0 + max: 1000000000 + - name: large_2 + seed: 22 + in: + nums1: + gen: array + elemType: int + len: 5000 + of: + gen: int + min: 0 + max: 1000000000 + nums2: + gen: array + elemType: int + len: 5000 + of: + gen: int + min: 0 + max: 1000000000 + - name: large_3 + seed: 23 + in: + nums1: + gen: array + elemType: int + len: 10000 + of: + gen: int + min: 0 + max: 1000000000 + nums2: + gen: array + elemType: int + len: 10000 + of: + gen: int + min: 0 + max: 1000000000 + - name: large_4 + seed: 24 + in: + nums1: + gen: array + elemType: int + len: 20000 + of: + gen: int + min: 0 + max: 1000000000 + nums2: + gen: array + elemType: int + len: 20000 + of: + gen: int + min: 0 + max: 1000000000 + - name: large_5 + seed: 25 + in: + nums1: + gen: array + elemType: int + len: 50000 + of: + gen: int + min: 0 + max: 1000000000 + nums2: + gen: array + elemType: int + len: 50000 + of: + gen: int + min: 0 + max: 1000000000 + - name: large_6 + seed: 26 + in: + nums1: + gen: array + elemType: int + len: 100000 + of: + gen: int + min: 0 + max: 1000000000 + nums2: + gen: array + elemType: int + len: 100000 + of: + gen: int + min: 0 + max: 1000000000 + - name: large_7 + seed: 27 + in: + nums1: + gen: array + elemType: int + len: 75000 + of: + gen: int + min: 0 + max: 1000000000 + nums2: + gen: array + elemType: int + len: 75000 + of: + gen: int + min: 0 + max: 1000000000 + - name: large_8 + seed: 28 + in: + nums1: + gen: array + elemType: int + len: 90000 + of: + gen: int + min: 0 + max: 1000000000 + nums2: + gen: array + elemType: int + len: 90000 + of: + gen: int + min: 0 + max: 1000000000 + - name: large_9 + seed: 29 + in: + nums1: + gen: array + elemType: int + len: 60000 + of: + gen: int + min: 0 + max: 1000000000 + nums2: + gen: array + elemType: int + len: 60000 + of: + gen: int + min: 0 + max: 1000000000 + - name: large_10 + seed: 30 + in: + nums1: + gen: array + elemType: int + len: 40000 + of: + gen: int + min: 0 + max: 1000000000 + nums2: + gen: array + elemType: int + len: 40000 + of: + gen: int + min: 0 + max: 1000000000 + - name: large_11 + seed: 31 + in: + nums1: + gen: array + elemType: int + len: 30000 + of: + gen: int + min: 0 + max: 1000000000 + nums2: + gen: array + elemType: int + len: 30000 + of: + gen: int + min: 0 + max: 1000000000 + - name: large_12 + seed: 32 + in: + nums1: + gen: array + elemType: int + len: 2000 + of: + gen: int + min: 0 + max: 1000000000 + nums2: + gen: array + elemType: int + len: 2000 + of: + gen: int + min: 0 + max: 1000000000 + - name: large_13 + seed: 33 + in: + nums1: + gen: array + elemType: int + len: 1500 + of: + gen: int + min: 0 + max: 1000000000 + nums2: + gen: array + elemType: int + len: 1500 + of: + gen: int + min: 0 + max: 1000000000 diff --git a/tests/501-1000/870. advantage-shuffle/sol.cpp b/tests/501-1000/870. advantage-shuffle/sol.cpp new file mode 100644 index 00000000..83bf3a46 --- /dev/null +++ b/tests/501-1000/870. advantage-shuffle/sol.cpp @@ -0,0 +1,27 @@ +class Solution { +public: + vector advantageCount(vector& nums1, vector& nums2) { + int n = nums1.size(); + sort(nums1.begin(), nums1.end()); + + vector> nums2Sorted; + for (int i = 0; i < n; i++) { + nums2Sorted.push_back({nums2[i], i}); + } + sort(nums2Sorted.begin(), nums2Sorted.end()); + + vector res(n); + int left = 0, right = n - 1; + for (int i = n - 1; i >= 0; i--) { + if (nums1[right] > nums2Sorted[i].first) { + res[nums2Sorted[i].second] = nums1[right]; + right--; + } else { + res[nums2Sorted[i].second] = nums1[left]; + left++; + } + } + + return res; + } +}; diff --git a/tests/501-1000/870. advantage-shuffle/sol.cs b/tests/501-1000/870. advantage-shuffle/sol.cs new file mode 100644 index 00000000..35870a1b --- /dev/null +++ b/tests/501-1000/870. advantage-shuffle/sol.cs @@ -0,0 +1,26 @@ +public class Solution { + public int[] AdvantageCount(int[] nums1, int[] nums2) { + int n = nums1.Length; + Array.Sort(nums1); + + int[][] nums2Sorted = new int[n][]; + for (int i = 0; i < n; i++) { + nums2Sorted[i] = new int[] { nums2[i], i }; + } + Array.Sort(nums2Sorted, (a, b) => a[0].CompareTo(b[0])); + + int[] res = new int[n]; + int left = 0, right = n - 1; + for (int i = n - 1; i >= 0; i--) { + if (nums1[right] > nums2Sorted[i][0]) { + res[nums2Sorted[i][1]] = nums1[right]; + right--; + } else { + res[nums2Sorted[i][1]] = nums1[left]; + left++; + } + } + + return res; + } +} diff --git a/tests/501-1000/870. advantage-shuffle/sol.dart b/tests/501-1000/870. advantage-shuffle/sol.dart new file mode 100644 index 00000000..705b831c --- /dev/null +++ b/tests/501-1000/870. advantage-shuffle/sol.dart @@ -0,0 +1,23 @@ +class Solution { + List advantageCount(List nums1, List nums2) { + int n = nums1.length; + nums1.sort(); + + List> nums2Sorted = List.generate(n, (i) => [nums2[i], i]); + nums2Sorted.sort((a, b) => a[0].compareTo(b[0])); + + List res = List.filled(n, 0); + int left = 0, right = n - 1; + for (int i = n - 1; i >= 0; i--) { + if (nums1[right] > nums2Sorted[i][0]) { + res[nums2Sorted[i][1]] = nums1[right]; + right--; + } else { + res[nums2Sorted[i][1]] = nums1[left]; + left++; + } + } + + return res; + } +} diff --git a/tests/501-1000/870. advantage-shuffle/sol.go b/tests/501-1000/870. advantage-shuffle/sol.go new file mode 100644 index 00000000..4de44133 --- /dev/null +++ b/tests/501-1000/870. advantage-shuffle/sol.go @@ -0,0 +1,26 @@ +func advantageCount(nums1 []int, nums2 []int) []int { + n := len(nums1) + sort.Ints(nums1) + + nums2Sorted := make([][2]int, n) + for i := 0; i < n; i++ { + nums2Sorted[i] = [2]int{nums2[i], i} + } + sort.Slice(nums2Sorted, func(i, j int) bool { + return nums2Sorted[i][0] < nums2Sorted[j][0] + }) + + res := make([]int, n) + left, right := 0, n-1 + for i := n - 1; i >= 0; i-- { + if nums1[right] > nums2Sorted[i][0] { + res[nums2Sorted[i][1]] = nums1[right] + right-- + } else { + res[nums2Sorted[i][1]] = nums1[left] + left++ + } + } + + return res +} diff --git a/tests/501-1000/870. advantage-shuffle/sol.java b/tests/501-1000/870. advantage-shuffle/sol.java new file mode 100644 index 00000000..0909479c --- /dev/null +++ b/tests/501-1000/870. advantage-shuffle/sol.java @@ -0,0 +1,27 @@ +class Solution { + public int[] advantageCount(int[] nums1, int[] nums2) { + int n = nums1.length; + Arrays.sort(nums1); + + int[][] nums2Sorted = new int[n][2]; + for (int i = 0; i < n; i++) { + nums2Sorted[i][0] = nums2[i]; + nums2Sorted[i][1] = i; + } + Arrays.sort(nums2Sorted, (a, b) -> Integer.compare(a[0], b[0])); + + int[] res = new int[n]; + int left = 0, right = n - 1; + for (int i = n - 1; i >= 0; i--) { + if (nums1[right] > nums2Sorted[i][0]) { + res[nums2Sorted[i][1]] = nums1[right]; + right--; + } else { + res[nums2Sorted[i][1]] = nums1[left]; + left++; + } + } + + return res; + } +} diff --git a/tests/501-1000/870. advantage-shuffle/sol.kt b/tests/501-1000/870. advantage-shuffle/sol.kt new file mode 100644 index 00000000..c44964db --- /dev/null +++ b/tests/501-1000/870. advantage-shuffle/sol.kt @@ -0,0 +1,25 @@ +class Solution { + fun advantageCount(nums1: IntArray, nums2: IntArray): IntArray { + val n = nums1.size + nums1.sort() + + val nums2Sorted = nums2.mapIndexed { index, value -> Pair(value, index) } + .sortedBy { it.first } + + val res = IntArray(n) + var left = 0 + var right = n - 1 + + for (i in n - 1 downTo 0) { + if (nums1[right] > nums2Sorted[i].first) { + res[nums2Sorted[i].second] = nums1[right] + right-- + } else { + res[nums2Sorted[i].second] = nums1[left] + left++ + } + } + + return res + } +} diff --git a/tests/501-1000/870. advantage-shuffle/sol.py b/tests/501-1000/870. advantage-shuffle/sol.py new file mode 100644 index 00000000..d31d165b --- /dev/null +++ b/tests/501-1000/870. advantage-shuffle/sol.py @@ -0,0 +1,18 @@ +class Solution: + def advantageCount(self, nums1: List[int], nums2: List[int]) -> List[int]: + n = len(nums1) + nums1.sort() + nums2 = [(nums2[i], i) for i in range(n)] + nums2.sort(key=lambda x: x[0]) + res = [0] * n + + left, right = 0, n - 1 + for i in range(n - 1, -1, -1): + if nums1[right] > nums2[i][0]: + res[nums2[i][1]] = nums1[right] + right -= 1 + else: + res[nums2[i][1]] = nums1[left] + left += 1 + + return res diff --git a/tests/501-1000/870. advantage-shuffle/sol.py2 b/tests/501-1000/870. advantage-shuffle/sol.py2 new file mode 100644 index 00000000..02767f06 --- /dev/null +++ b/tests/501-1000/870. advantage-shuffle/sol.py2 @@ -0,0 +1,22 @@ +class Solution(object): + def advantageCount(self, nums1, nums2): + """ + :type nums1: List[int] + :type nums2: List[int] + :rtype: List[int] + """ + n = len(nums1) + nums1.sort() + order = sorted(xrange(n), key=nums2.__getitem__) + res = [0] * n + + left, right = 0, n - 1 + for i in xrange(n - 1, -1, -1): + pos = order[i] + if nums1[right] > nums2[pos]: + res[pos] = nums1[right] + right -= 1 + else: + res[pos] = nums1[left] + left += 1 + return res diff --git a/tests/501-1000/870. advantage-shuffle/sol.rb b/tests/501-1000/870. advantage-shuffle/sol.rb new file mode 100644 index 00000000..11d0742c --- /dev/null +++ b/tests/501-1000/870. advantage-shuffle/sol.rb @@ -0,0 +1,22 @@ +# @param {Integer[]} nums1 +# @param {Integer[]} nums2 +# @return {Integer[]} +def advantage_count(nums1, nums2) + n = nums1.length + nums1.sort! + nums2_sorted = nums2.each_with_index.map { |num, idx| [num, idx] }.sort_by { |pair| pair[0] } + res = Array.new(n, 0) + + left, right = 0, n - 1 + (n - 1).downto(0) do |i| + if nums1[right] > nums2_sorted[i][0] + res[nums2_sorted[i][1]] = nums1[right] + right -= 1 + else + res[nums2_sorted[i][1]] = nums1[left] + left += 1 + end + end + + res +end diff --git a/tests/501-1000/870. advantage-shuffle/sol.rs b/tests/501-1000/870. advantage-shuffle/sol.rs new file mode 100644 index 00000000..df9254fe --- /dev/null +++ b/tests/501-1000/870. advantage-shuffle/sol.rs @@ -0,0 +1,26 @@ +impl Solution { + pub fn advantage_count(nums1: Vec, nums2: Vec) -> Vec { + let n = nums1.len(); + let mut nums1 = nums1; + nums1.sort_unstable(); + + let mut nums2_sorted: Vec<(i32, usize)> = nums2.into_iter().enumerate().map(|(i, v)| (v, i)).collect(); + nums2_sorted.sort_unstable_by_key(|&(v, _)| v); + + let mut res = vec![0; n]; + let mut left = 0; + let mut right = n - 1; + + for i in (0..n).rev() { + if nums1[right] > nums2_sorted[i].0 { + res[nums2_sorted[i].1] = nums1[right]; + right -= 1; + } else { + res[nums2_sorted[i].1] = nums1[left]; + left += 1; + } + } + + res + } +} diff --git a/tests/501-1000/870. advantage-shuffle/sol.swift b/tests/501-1000/870. advantage-shuffle/sol.swift new file mode 100644 index 00000000..9ff2f3a4 --- /dev/null +++ b/tests/501-1000/870. advantage-shuffle/sol.swift @@ -0,0 +1,24 @@ +class Solution { + func advantageCount(_ nums1: [Int], _ nums2: [Int]) -> [Int] { + let n = nums1.count + let sorted1 = nums1.sorted() + let paired = nums2.enumerated().sorted { $0.element < $1.element } + var res = Array(repeating: 0, count: n) + var left = 0, right = n - 1 + var idx = n - 1 + while idx >= 0 { + let pos = paired[idx].offset + let val = paired[idx].element + if sorted1[right] > val { + res[pos] = sorted1[right] + right -= 1 + } else { + res[pos] = sorted1[left] + left += 1 + } + idx -= 1 + } + + return res + } +} diff --git a/tests/501-1000/870. advantage-shuffle/sol.ts b/tests/501-1000/870. advantage-shuffle/sol.ts new file mode 100644 index 00000000..06a429d3 --- /dev/null +++ b/tests/501-1000/870. advantage-shuffle/sol.ts @@ -0,0 +1,23 @@ +function advantageCount(nums1: number[], nums2: number[]): number[] { + const n = nums1.length; + nums1.sort((a, b) => a - b); + + const nums2Sorted: [number, number][] = nums2.map((num, idx) => [num, idx]); + nums2Sorted.sort((a, b) => a[0] - b[0]); + + const res: number[] = new Array(n).fill(0); + let left = 0, + right = n - 1; + + for (let i = n - 1; i >= 0; i--) { + if (nums1[right] > nums2Sorted[i][0]) { + res[nums2Sorted[i][1]] = nums1[right]; + right--; + } else { + res[nums2Sorted[i][1]] = nums1[left]; + left++; + } + } + + return res; +} diff --git a/tests/501-1000/871. minimum-number-of-refueling-stops/manifest.yaml b/tests/501-1000/871. minimum-number-of-refueling-stops/manifest.yaml new file mode 100644 index 00000000..93750bb3 --- /dev/null +++ b/tests/501-1000/871. minimum-number-of-refueling-stops/manifest.yaml @@ -0,0 +1,482 @@ +entry: + id: 871 + title: minimum-number-of-refueling-stops + params: + target: + type: int + startFuel: + type: int + stations: + type: array + items: + type: array + items: + type: int + call: + cpp: "Solution().minRefuelStops({target}, {startFuel}, {stations})" + rust: "Solution::min_refuel_stops({target}, {startFuel}, {stations})" + python3: "Solution().minRefuelStops({target}, {startFuel}, {stations})" + python2: "Solution().minRefuelStops({target}, {startFuel}, {stations})" + ruby: "min_refuel_stops({target}, {startFuel}, {stations})" + java: "new Solution().minRefuelStops({target}, {startFuel}, {stations})" + csharp: "new Solution().MinRefuelStops({target}, {startFuel}, {stations})" + kotlin: "Solution().minRefuelStops({target}, {startFuel}, {stations})" + go: "minRefuelStops({target}, {startFuel}, {stations})" + dart: "Solution().minRefuelStops({target}, {startFuel}, {stations})" + swift: "Solution().minRefuelStops({target}, {startFuel}, {stations})" + typescript: "minRefuelStops({target}, {startFuel}, {stations})" +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 300 +oracle: + python3: + call: "Checker().minRefuelStops(target, startFuel, stations, {result})" + checker: | + import heapq + from typing import Any + + class Checker: + def minRefuelStops(self, target: int, startFuel: int, stations: list[list[int]], result: Any) -> bool: + if not isinstance(result, int): + return False + arr = [list(s) for s in stations] + arr.append([target, 0]) + fuel = startFuel + heap = [] + stops = 0 + idx = 0 + while fuel < target: + while idx < len(arr) and arr[idx][0] <= fuel: + heapq.heappush(heap, -arr[idx][1]) + idx += 1 + if not heap: + expected = -1 + return result == expected + fuel += -heapq.heappop(heap) + stops += 1 + return result == stops +seed: 871871 +tests: + - name: ex1 + in: + target: 1 + startFuel: 1 + stations: [] + - name: ex2 + in: + target: 100 + startFuel: 1 + stations: + elemType: int + value: + - [10, 100] + - name: ex3 + in: + target: 100 + startFuel: 10 + stations: + elemType: int + value: + - [10, 60] + - [20, 30] + - [30, 30] + - [60, 40] + - name: no_stops_exact + in: + target: 50 + startFuel: 50 + stations: [] + - name: no_stops_over + in: + target: 50 + startFuel: 60 + stations: [] + - name: impossible_before_first + in: + target: 100 + startFuel: 1 + stations: + elemType: int + value: + - [2, 50] + - [10, 100] + - name: one_stop_exact + in: + target: 100 + startFuel: 50 + stations: + elemType: int + value: + - [25, 25] + - [50, 50] + - name: one_stop_needed + in: + target: 100 + startFuel: 25 + stations: + elemType: int + value: + - [25, 75] + - [50, 1] + - [75, 1] + - name: two_stops_chain + in: + target: 100 + startFuel: 10 + stations: + elemType: int + value: + - [10, 60] + - [20, 30] + - [30, 30] + - [60, 40] + - name: three_stops_chain + in: + target: 120 + startFuel: 10 + stations: + elemType: int + value: + - [10, 20] + - [20, 30] + - [30, 40] + - [60, 50] + - name: greedy_choice_1 + in: + target: 90 + startFuel: 10 + stations: + elemType: int + value: + - [10, 60] + - [20, 20] + - [30, 30] + - [60, 40] + - name: greedy_choice_2 + in: + target: 90 + startFuel: 15 + stations: + elemType: int + value: + - [5, 10] + - [10, 20] + - [20, 30] + - [40, 50] + - name: zero_left_at_station + in: + target: 100 + startFuel: 10 + stations: + elemType: int + value: + - [10, 10] + - [20, 10] + - [30, 10] + - [40, 10] + - [50, 10] + - [60, 10] + - [70, 10] + - [80, 10] + - [90, 10] + - name: exact_arrival_zero + in: + target: 70 + startFuel: 20 + stations: + elemType: int + value: + - [20, 10] + - [30, 20] + - [50, 20] + - name: many_small_fuels + in: + target: 60 + startFuel: 5 + stations: + elemType: int + value: + - [5, 1] + - [10, 1] + - [15, 1] + - [20, 1] + - [25, 1] + - [30, 1] + - [35, 1] + - [40, 1] + - [45, 1] + - [50, 1] + - name: large_fuel_first + in: + target: 1000 + startFuel: 100 + stations: + elemType: int + value: + - [50, 900] + - [100, 1] + - [200, 1] + - [300, 1] + - name: large_fuel_late + in: + target: 1000 + startFuel: 100 + stations: + elemType: int + value: + - [20, 10] + - [40, 10] + - [60, 10] + - [80, 10] + - [100, 900] + - name: unreachable_gap + in: + target: 200 + startFuel: 50 + stations: + elemType: int + value: + - [60, 50] + - [120, 50] + - name: reachable_with_many + in: + target: 300 + startFuel: 50 + stations: + elemType: int + value: + - [25, 25] + - [50, 25] + - [75, 25] + - [100, 25] + - [125, 25] + - [150, 25] + - [175, 25] + - [200, 25] + - [225, 25] + - [250, 25] + - name: dense_small + in: + target: 30 + startFuel: 3 + stations: + elemType: int + value: + - [3, 3] + - [6, 3] + - [9, 3] + - [12, 3] + - [15, 3] + - [18, 3] + - [21, 3] + - [24, 3] + - [27, 3] + - name: dense_medium + in: + target: 100 + startFuel: 10 + stations: + elemType: int + value: + - [5, 5] + - [10, 5] + - [15, 5] + - [20, 5] + - [25, 5] + - [30, 5] + - [35, 5] + - [40, 5] + - [45, 5] + - [50, 5] + - [55, 5] + - [60, 5] + - [65, 5] + - [70, 5] + - [75, 5] + - [80, 5] + - [85, 5] + - [90, 5] + - name: station_at_target_minus_one + in: + target: 100 + startFuel: 99 + stations: + elemType: int + value: + - [50, 1] + - [99, 1] + - name: station_at_first_reach + in: + target: 100 + startFuel: 20 + stations: + elemType: int + value: + - [20, 20] + - [40, 20] + - [60, 20] + - [80, 20] + - name: stop_at_every_station + in: + target: 60 + startFuel: 10 + stations: + elemType: int + value: + - [10, 10] + - [20, 10] + - [30, 10] + - [40, 10] + - [50, 10] + - name: skip_some_stations + in: + target: 60 + startFuel: 15 + stations: + elemType: int + value: + - [5, 5] + - [10, 50] + - [20, 1] + - [30, 1] + - [40, 1] + - name: need_last_big_station + in: + target: 200 + startFuel: 50 + stations: + elemType: int + value: + - [25, 10] + - [50, 10] + - [75, 10] + - [100, 100] + - [150, 10] + - name: no_station_needed_with_surplus + in: + target: 100 + startFuel: 150 + stations: + elemType: int + value: [] + - name: sparse_large + in: + target: 1000 + startFuel: 250 + stations: + elemType: int + value: + - [200, 100] + - [400, 100] + - [600, 100] + - [800, 100] + - name: sparse_impossible + in: + target: 1000 + startFuel: 200 + stations: + elemType: int + value: + - [250, 100] + - [500, 100] + - [750, 100] + - name: exact_chain_with_final_zero + in: + target: 75 + startFuel: 25 + stations: + elemType: int + value: + - [25, 25] + - [50, 25] + - name: end_with_one_stop + in: + target: 90 + startFuel: 45 + stations: + elemType: int + value: + - [15, 15] + - [30, 15] + - [45, 45] + - name: end_with_two_stops + in: + target: 90 + startFuel: 30 + stations: + elemType: int + value: + - [10, 10] + - [20, 10] + - [30, 30] + - [60, 30] + - name: end_with_three_stops + in: + target: 150 + startFuel: 30 + stations: + elemType: int + value: + - [10, 20] + - [20, 20] + - [30, 20] + - [60, 40] + - [100, 40] + - name: long_gap_but_possible + in: + target: 300 + startFuel: 60 + stations: + elemType: int + value: + - [20, 20] + - [40, 20] + - [60, 20] + - [120, 100] + - [220, 100] + - name: long_gap_impossible + in: + target: 300 + startFuel: 60 + stations: + elemType: int + value: + - [20, 20] + - [40, 20] + - [61, 20] + - [120, 100] + - [220, 100] + - name: maxed_station_count_small_steps + in: + target: 500 + startFuel: 50 + stations: + elemType: int + value: + - [50, 50] + - [100, 50] + - [150, 50] + - [200, 50] + - [250, 50] + - [300, 50] + - [350, 50] + - [400, 50] + - [450, 50] + - name: maxed_station_count_big_refuel + in: + target: 500 + startFuel: 10 + stations: + elemType: int + value: + - [10, 100] + - [20, 100] + - [30, 100] + - [40, 100] + - [50, 100] + - [60, 100] + - [70, 100] + - [80, 100] + - [90, 100] diff --git a/tests/501-1000/871. minimum-number-of-refueling-stops/sol.cpp b/tests/501-1000/871. minimum-number-of-refueling-stops/sol.cpp new file mode 100644 index 00000000..bc3ff7e3 --- /dev/null +++ b/tests/501-1000/871. minimum-number-of-refueling-stops/sol.cpp @@ -0,0 +1,22 @@ +class Solution { +public: + int minRefuelStops(int target, int startFuel, vector>& stations) { + priority_queue heap; + int fuel = startFuel; + int count = 0; + stations.push_back({target, 0}); + int i = 0; + while (i < stations.size()) { + if (fuel >= target) return count; + while (i < stations.size() && stations[i][0] <= fuel) { + heap.push(stations[i][1]); + i++; + } + if (heap.empty()) return -1; + fuel += heap.top(); + heap.pop(); + count++; + } + return -1; + } +}; diff --git a/tests/501-1000/871. minimum-number-of-refueling-stops/sol.cs b/tests/501-1000/871. minimum-number-of-refueling-stops/sol.cs new file mode 100644 index 00000000..48046849 --- /dev/null +++ b/tests/501-1000/871. minimum-number-of-refueling-stops/sol.cs @@ -0,0 +1,74 @@ +public class Solution { + public int MinRefuelStops(int target, int startFuel, int[][] stations) { + var heap = new List(); + int fuel = startFuel; + int stops = 0; + int i = 0; + + while (fuel < target) { + while (i < stations.Length && stations[i][0] <= fuel) { + Push(heap, stations[i][1]); + i++; + } + + if (heap.Count == 0) { + return -1; + } + + fuel += Pop(heap); + stops++; + } + + return stops; + } + + private static void Push(List heap, int value) { + heap.Add(value); + int i = heap.Count - 1; + while (i > 0) { + int parent = (i - 1) >> 1; + if (heap[parent] >= heap[i]) { + break; + } + int tmp = heap[parent]; + heap[parent] = heap[i]; + heap[i] = tmp; + i = parent; + } + } + + private static int Pop(List heap) { + int top = heap[0]; + int last = heap[heap.Count - 1]; + heap.RemoveAt(heap.Count - 1); + if (heap.Count == 0) { + return top; + } + + heap[0] = last; + int i = 0; + while (true) { + int left = (i << 1) + 1; + if (left >= heap.Count) { + break; + } + + int right = left + 1; + int child = left; + if (right < heap.Count && heap[right] > heap[left]) { + child = right; + } + + if (heap[i] >= heap[child]) { + break; + } + + int tmp = heap[i]; + heap[i] = heap[child]; + heap[child] = tmp; + i = child; + } + + return top; + } +} diff --git a/tests/501-1000/871. minimum-number-of-refueling-stops/sol.dart b/tests/501-1000/871. minimum-number-of-refueling-stops/sol.dart new file mode 100644 index 00000000..b16282c6 --- /dev/null +++ b/tests/501-1000/871. minimum-number-of-refueling-stops/sol.dart @@ -0,0 +1,22 @@ +class Solution { + int minRefuelStops(int target, int startFuel, List> stations) { + var fuel = startFuel; + var count = 0; + var heap = []; + stations.add([target, 0]); + int i = 0; + while (i < stations.length) { + if (fuel >= target) return count; + while (i < stations.length && stations[i][0] <= fuel) { + heap.add(stations[i][1]); + heap.sort((a, b) => b - a); + i++; + } + if (heap.isEmpty) return -1; + fuel += heap.first; + heap.removeAt(0); + count++; + } + return -1; + } +} diff --git a/tests/501-1000/871. minimum-number-of-refueling-stops/sol.go b/tests/501-1000/871. minimum-number-of-refueling-stops/sol.go new file mode 100644 index 00000000..42ae97f3 --- /dev/null +++ b/tests/501-1000/871. minimum-number-of-refueling-stops/sol.go @@ -0,0 +1,52 @@ +func minRefuelStops(target int, startFuel int, stations [][]int) int { + heap := make([]int, 0) + push := func(value int) { + heap = append(heap, value) + for i := len(heap) - 1; i > 0; { + parent := (i - 1) / 2 + if heap[parent] >= heap[i] { + break + } + heap[parent], heap[i] = heap[i], heap[parent] + i = parent + } + } + pop := func() int { + result := heap[0] + heap[0] = heap[len(heap)-1] + heap = heap[:len(heap)-1] + for i := 0; ; { + left := i*2 + 1 + if left >= len(heap) { + break + } + largest := left + right := left + 1 + if right < len(heap) && heap[right] > heap[left] { + largest = right + } + if heap[i] >= heap[largest] { + break + } + heap[i], heap[largest] = heap[largest], heap[i] + i = largest + } + return result + } + + fuel := int64(startFuel) + stops := 0 + next := 0 + for fuel < int64(target) { + for next < len(stations) && int64(stations[next][0]) <= fuel { + push(stations[next][1]) + next++ + } + if len(heap) == 0 { + return -1 + } + fuel += int64(pop()) + stops++ + } + return stops +} diff --git a/tests/501-1000/871. minimum-number-of-refueling-stops/sol.java b/tests/501-1000/871. minimum-number-of-refueling-stops/sol.java new file mode 100644 index 00000000..296c12a6 --- /dev/null +++ b/tests/501-1000/871. minimum-number-of-refueling-stops/sol.java @@ -0,0 +1,23 @@ +class Solution { + public int minRefuelStops(int target, int startFuel, int[][] stations) { + java.util.PriorityQueue heap = new java.util.PriorityQueue<>((a, b) -> b - a); + int fuel = startFuel; + int count = 0; + int i = 0; + int n = stations.length; + int[][] extended = new int[n + 1][2]; + System.arraycopy(stations, 0, extended, 0, n); + extended[n] = new int[]{target, 0}; + while (i < extended.length) { + if (fuel >= target) return count; + while (i < extended.length && extended[i][0] <= fuel) { + heap.offer(extended[i][1]); + i++; + } + if (heap.isEmpty()) return -1; + fuel += heap.poll(); + count++; + } + return -1; + } +} diff --git a/tests/501-1000/871. minimum-number-of-refueling-stops/sol.kt b/tests/501-1000/871. minimum-number-of-refueling-stops/sol.kt new file mode 100644 index 00000000..d154604e --- /dev/null +++ b/tests/501-1000/871. minimum-number-of-refueling-stops/sol.kt @@ -0,0 +1,20 @@ +class Solution { + fun minRefuelStops(target: Int, startFuel: Int, stations: Array): Int { + val heap = java.util.PriorityQueue(compareByDescending { it }) + var fuel = startFuel + var count = 0 + var i = 0 + val extended = stations + arrayOf(intArrayOf(target, 0)) + while (i < extended.size) { + if (fuel >= target) return count + while (i < extended.size && extended[i][0] <= fuel) { + heap.offer(extended[i][1]) + i++ + } + if (heap.isEmpty()) return -1 + fuel += heap.poll() + count++ + } + return -1 + } +} diff --git a/tests/501-1000/871. minimum-number-of-refueling-stops/sol.py b/tests/501-1000/871. minimum-number-of-refueling-stops/sol.py new file mode 100644 index 00000000..d2247626 --- /dev/null +++ b/tests/501-1000/871. minimum-number-of-refueling-stops/sol.py @@ -0,0 +1,22 @@ +class Solution: + def minRefuelStops( + self, target: int, startFuel: int, stations: List[List[int]] + ) -> int: + + fuel, heap, count = startFuel, [], 0 # <-- initialize some stuff + + stations.append([target, 0]) # <-- this handles the "stations = []" test + + while stations: + if fuel >= target: + return count # <-- 4) + + while stations and stations[0][0] <= fuel: # <-- 3) + _, liters = stations.pop(0) + heappush(heap, -liters) + + if not heap: + return -1 # <-- 4) + fuel -= heappop(heap) + + count += 1 diff --git a/tests/501-1000/871. minimum-number-of-refueling-stops/sol.py2 b/tests/501-1000/871. minimum-number-of-refueling-stops/sol.py2 new file mode 100644 index 00000000..5d96d409 --- /dev/null +++ b/tests/501-1000/871. minimum-number-of-refueling-stops/sol.py2 @@ -0,0 +1,21 @@ +class Solution(object): + def minRefuelStops(self, target, startFuel, stations): + """ + :type target: int + :type startFuel: int + :type stations: List[List[int]] + :rtype: int + """ + import heapq + fuel, heap, count = startFuel, [], 0 + stations.append([target, 0]) + while stations: + if fuel >= target: + return count + while stations and stations[0][0] <= fuel: + _, liters = stations.pop(0) + heapq.heappush(heap, -liters) + if not heap: + return -1 + fuel -= heapq.heappop(heap) + count += 1 diff --git a/tests/501-1000/871. minimum-number-of-refueling-stops/sol.rb b/tests/501-1000/871. minimum-number-of-refueling-stops/sol.rb new file mode 100644 index 00000000..21f2f97e --- /dev/null +++ b/tests/501-1000/871. minimum-number-of-refueling-stops/sol.rb @@ -0,0 +1,26 @@ +# @param {Integer} target +# @param {Integer} start_fuel +# @param {Integer[][]} stations +# @return {Integer} +def min_refuel_stops(target, start_fuel, stations) + fuel = start_fuel + count = 0 + i = 0 + best = [] + while fuel < target + while i < stations.length && stations[i][0] <= fuel + best << stations[i][1] + i += 1 + end + return -1 if best.empty? + idx = 0 + (1...best.length).each do |j| + idx = j if best[j] > best[idx] + end + fuel += best[idx] + best[idx] = best[-1] + best.pop + count += 1 + end + count +end diff --git a/tests/501-1000/871. minimum-number-of-refueling-stops/sol.rs b/tests/501-1000/871. minimum-number-of-refueling-stops/sol.rs new file mode 100644 index 00000000..12af7af0 --- /dev/null +++ b/tests/501-1000/871. minimum-number-of-refueling-stops/sol.rs @@ -0,0 +1,26 @@ +impl Solution { + pub fn min_refuel_stops(target: i32, start_fuel: i32, stations: Vec>) -> i32 { + use std::collections::BinaryHeap; + let mut fuel = start_fuel; + let mut count = 0; + let mut heap = BinaryHeap::new(); + let mut stations = stations; + stations.push(vec![target, 0]); + let mut i = 0; + while i < stations.len() { + if fuel >= target { + return count; + } + while i < stations.len() && stations[i][0] <= fuel { + heap.push(stations[i][1]); + i += 1; + } + if heap.is_empty() { + return -1; + } + fuel += heap.pop().unwrap(); + count += 1; + } + -1 + } +} diff --git a/tests/501-1000/871. minimum-number-of-refueling-stops/sol.swift b/tests/501-1000/871. minimum-number-of-refueling-stops/sol.swift new file mode 100644 index 00000000..35f8e6f5 --- /dev/null +++ b/tests/501-1000/871. minimum-number-of-refueling-stops/sol.swift @@ -0,0 +1,22 @@ +class Solution { + func minRefuelStops(_ target: Int, _ startFuel: Int, _ stations: [[Int]]) -> Int { + var fuel = startFuel + var count = 0 + var heap = [Int]() + var extended = stations + extended.append([target, 0]) + var i = 0 + while i < extended.count { + if fuel >= target { return count } + while i < extended.count && extended[i][0] <= fuel { + heap.append(extended[i][1]) + heap.sort(by: >) + i += 1 + } + if heap.isEmpty { return -1 } + fuel += heap.removeFirst() + count += 1 + } + return -1 + } +} diff --git a/tests/501-1000/871. minimum-number-of-refueling-stops/sol.ts b/tests/501-1000/871. minimum-number-of-refueling-stops/sol.ts new file mode 100644 index 00000000..29000828 --- /dev/null +++ b/tests/501-1000/871. minimum-number-of-refueling-stops/sol.ts @@ -0,0 +1,23 @@ +function minRefuelStops( + target: number, + startFuel: number, + stations: number[][], +): number { + let fuel = startFuel; + let count = 0; + const heap: number[] = []; + stations.push([target, 0]); + let i = 0; + while (i < stations.length) { + if (fuel >= target) return count; + while (i < stations.length && stations[i][0] <= fuel) { + heap.push(stations[i][1]); + heap.sort((a, b) => b - a); + i++; + } + if (heap.length === 0) return -1; + fuel += heap.shift()!; + count++; + } + return -1; +} diff --git a/tests/501-1000/872. leaf-similar-trees/manifest.yaml b/tests/501-1000/872. leaf-similar-trees/manifest.yaml new file mode 100644 index 00000000..3e990a1c --- /dev/null +++ b/tests/501-1000/872. leaf-similar-trees/manifest.yaml @@ -0,0 +1,609 @@ +entry: + id: 872 + title: leaf-similar-trees + params: + root1: + type: tree_node + root2: + type: tree_node + call: + cpp: Solution().leafSimilar({root1}, {root2}) + rust: Solution::leaf_similar({root1}, {root2}) + python3: Solution().leafSimilar({root1}, {root2}) + python2: Solution().leafSimilar({root1}, {root2}) + ruby: leaf_similar({root1}, {root2}) + java: new Solution().leafSimilar({root1}, {root2}) + csharp: new Solution().LeafSimilar({root1}, {root2}) + kotlin: Solution().leafSimilar({root1}, {root2}) + go: leafSimilar({root1}, {root2}) + dart: Solution().leafSimilar({root1}, {root2}) + swift: Solution().leafSimilar({root1}, {root2}) + typescript: leafSimilar({root1}, {root2}) +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 300 +oracle: + python3: + call: Checker().leafSimilar(root1, root2, {result}) + checker: + "class Checker:\n def leafSimilar(self, root1, root2, result: Any)\ + \ -> bool:\n return isinstance(result, bool)\n" +seed: 872 +tests: + - name: ex1 + in: + root1: + - 3 + - 5 + - 1 + - 6 + - 2 + - 9 + - 8 + - null + - null + - 7 + - 4 + root2: + - 3 + - 5 + - 1 + - 6 + - 7 + - 4 + - 2 + - null + - null + - null + - null + - null + - null + - 9 + - 8 + out: true + - name: ex2 + in: + root1: + - 1 + - 2 + - 3 + root2: + - 1 + - 3 + - 2 + out: false + - name: single_same + in: + root1: + - 7 + root2: + - 7 + out: true + - name: single_diff + in: + root1: + - 7 + root2: + - 8 + out: false + - name: both_left_chains_equal + in: + root1: + - 1 + - 2 + - null + - 3 + root2: + - 9 + - 8 + - null + - 3 + out: true + - name: both_right_chains_equal + in: + root1: + - 1 + - null + - 2 + - null + - 3 + root2: + - 9 + - null + - 8 + - null + - 3 + out: true + - name: leaf_order_diff + in: + root1: + - 1 + - 2 + - 3 + root2: + - 1 + - 2 + - 4 + out: false + - name: same_leaves_different_shapes + in: + root1: + - 4 + - 2 + - 6 + - 1 + - 3 + - 5 + - 7 + root2: + - 4 + - 2 + - 6 + - 1 + - null + - 5 + - 7 + out: false + - name: interior_nodes_ignored + in: + root1: + - 10 + - 4 + - 12 + - null + - 5 + - 11 + - 13 + root2: + - 99 + - 4 + - 12 + - null + - 5 + - 11 + - 13 + out: true + - name: different_leaf_count + in: + root1: + - 1 + - 2 + - null + root2: + - 1 + - null + - 2 + out: true + - name: null_branch_shape + in: + root1: + - 1 + - 2 + - 3 + - 4 + - null + - null + - 5 + root2: + - 9 + - 8 + - 7 + - 4 + - null + - null + - 5 + out: true + - name: repeated_leaf_values + in: + root1: + - 1 + - 1 + - 1 + root2: + - 2 + - 1 + - 1 + out: true + - name: repeated_leaf_values_diff + in: + root1: + - 1 + - 1 + - 1 + root2: + - 2 + - 1 + - 2 + out: false + - name: balanced_small_equal + in: + root1: + - 8 + - 3 + - 10 + - 1 + - 6 + - null + - 14 + root2: + - 9 + - 4 + - 11 + - 1 + - 6 + - null + - 14 + out: true + - name: balanced_small_diff + in: + root1: + - 8 + - 3 + - 10 + - 1 + - 6 + - null + - 14 + root2: + - 9 + - 4 + - 11 + - 1 + - 6 + - null + - 15 + out: false + - name: extra_internal_levels + in: + root1: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + root2: + - 9 + - 8 + - 7 + - 4 + - 5 + - 6 + - 7 + out: true + - name: equal_with_null_children + in: + root1: + - 1 + - 2 + - 3 + - null + - 4 + - 5 + - null + root2: + - 9 + - 8 + - 7 + - null + - 4 + - 5 + - null + out: true + - name: leaf_sequence_longer + in: + root1: + - 1 + - 2 + - 3 + - 4 + - null + - null + - 5 + root2: + - 9 + - 8 + - 7 + - 4 + - null + - null + - 6 + out: false + - name: origin_values_irrelevant + in: + root1: + - 0 + - 1 + - 2 + root2: + - 200 + - 1 + - 2 + out: true + - name: deep_left_equal + in: + root1: + - 1 + - 2 + - null + - 3 + - null + - 4 + root2: + - 5 + - 6 + - null + - 3 + - null + - 4 + out: true + - name: deep_left_diff + in: + root1: + - 1 + - 2 + - null + - 3 + - null + - 4 + root2: + - 5 + - 6 + - null + - 3 + - null + - 5 + out: false + - name: mixed_shapes_equal + in: + root1: + - 1 + - 2 + - 3 + - null + - 4 + - 5 + - 6 + root2: + - 7 + - 8 + - 9 + - null + - 4 + - 5 + - 6 + out: true + - name: mixed_shapes_diff + in: + root1: + - 1 + - 2 + - 3 + - null + - 4 + - 5 + - 6 + root2: + - 7 + - 8 + - 9 + - null + - 4 + - 5 + - 7 + out: false + - name: identical_large_shape1 + in: + root1: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + root2: + - 10 + - 11 + - 12 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + out: true + - name: identical_large_shape2 + in: + root1: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + root2: + - 10 + - 11 + - 12 + - 4 + - 5 + - 6 + - 7 + - 8 + - 10 + out: false + - name: all_same_leaf + in: + root1: + - 1 + - null + - 1 + - null + - 1 + root2: + - 2 + - null + - 1 + - null + - 1 + out: true + - name: leaf_count_one_vs_two + in: + root1: + - 1 + root2: + - 1 + - 2 + - 3 + out: false + - name: near_boundary_values + in: + root1: + - 200 + - 0 + - 200 + root2: + - 1 + - 0 + - 200 + out: true + - name: same_sequence_different_internal_vals + in: + root1: + - 5 + - 6 + - 7 + - 8 + - 9 + root2: + - 1 + - 2 + - 3 + - 8 + - 9 + out: false + - name: same_sequence_different_internal_vals_2 + in: + root1: + - 5 + - 6 + - 7 + - 8 + - 9 + root2: + - 1 + - 2 + - 3 + - 8 + - 10 + out: false + - name: asymmetric_equal + in: + root1: + - 1 + - 2 + - null + - 3 + - 4 + root2: + - 9 + - 8 + - null + - 3 + - 4 + out: true + - name: asymmetric_diff + in: + root1: + - 1 + - 2 + - null + - 3 + - 4 + root2: + - 9 + - 8 + - null + - 3 + - 5 + out: false + - name: same_three_leaf_sequence + in: + root1: + - 1 + - 2 + - 3 + - 4 + - null + - 5 + - 6 + root2: + - 9 + - 8 + - 7 + - 4 + - null + - 5 + - 6 + out: true + - name: same_three_leaf_sequence_diff_shape + in: + root1: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + root2: + - 9 + - 8 + - 7 + - 4 + - 5 + - 6 + - 7 + out: true + - name: larger_equal_leaf_multiset + in: + root1: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - null + - null + - 10 + - 11 + - 12 + - 13 + root2: + - 20 + - 21 + - 22 + - 8 + - 9 + - 10 + - 11 + - null + - null + - null + - null + - 12 + - 13 + out: false diff --git a/tests/501-1000/872. leaf-similar-trees/sol.cpp b/tests/501-1000/872. leaf-similar-trees/sol.cpp new file mode 100644 index 00000000..3aef2264 --- /dev/null +++ b/tests/501-1000/872. leaf-similar-trees/sol.cpp @@ -0,0 +1,37 @@ +/** + * Definition for a binary tree node. + * struct TreeNode { + * int val; + * TreeNode *left; + * TreeNode *right; + * TreeNode() : val(0), left(nullptr), right(nullptr) {} + * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} + * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} + * }; + */ +class Solution { +public: + bool leafSimilar(TreeNode* root1, TreeNode* root2) { + function&)> helper = [&](TreeNode* root, vector& leaves) { + stack st; + st.push(root); + while (!st.empty()) { + TreeNode* curr = st.top(); + st.pop(); + if (!curr->left && !curr->right) { + leaves.push_back(curr->val); + } + if (curr->left) { + st.push(curr->left); + } + if (curr->right) { + st.push(curr->right); + } + } + }; + vector leaves1, leaves2; + helper(root1, leaves1); + helper(root2, leaves2); + return leaves1 == leaves2; + } +}; diff --git a/tests/501-1000/872. leaf-similar-trees/sol.cs b/tests/501-1000/872. leaf-similar-trees/sol.cs new file mode 100644 index 00000000..3918706f --- /dev/null +++ b/tests/501-1000/872. leaf-similar-trees/sol.cs @@ -0,0 +1,41 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public int val; + * public TreeNode left; + * public TreeNode right; + * public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +public class Solution { + public bool LeafSimilar(TreeNode root1, TreeNode root2) { + void Helper(TreeNode root, IList leaves) { + if (root == null) { + return; + } + Stack stack = new Stack(); + stack.Push(root); + while (stack.Count > 0) { + TreeNode curr = stack.Pop(); + if (curr.left == null && curr.right == null) { + leaves.Add(curr.val); + } + if (curr.right != null) { + stack.Push(curr.right); + } + if (curr.left != null) { + stack.Push(curr.left); + } + } + } + List leaves1 = new List(); + List leaves2 = new List(); + Helper(root1, leaves1); + Helper(root2, leaves2); + return leaves1.SequenceEqual(leaves2); + } +} diff --git a/tests/501-1000/872. leaf-similar-trees/sol.dart b/tests/501-1000/872. leaf-similar-trees/sol.dart new file mode 100644 index 00000000..03264d39 --- /dev/null +++ b/tests/501-1000/872. leaf-similar-trees/sol.dart @@ -0,0 +1,37 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * int val; + * TreeNode? left; + * TreeNode? right; + * TreeNode([this.val = 0, this.left, this.right]); + * } + */ +class Solution { + bool leafSimilar(TreeNode? root1, TreeNode? root2) { + List helper(TreeNode? root) { + List leaves = []; + List stack = [root!]; + while (stack.isNotEmpty) { + TreeNode curr = stack.removeLast(); + if (curr.left == null && curr.right == null) { + leaves.add(curr.val); + } + if (curr.left != null) { + stack.add(curr.left!); + } + if (curr.right != null) { + stack.add(curr.right!); + } + } + return leaves; + } + List leaves1 = helper(root1); + List leaves2 = helper(root2); + if (leaves1.length != leaves2.length) return false; + for (int i = 0; i < leaves1.length; i++) { + if (leaves1[i] != leaves2[i]) return false; + } + return true; + } +} diff --git a/tests/501-1000/872. leaf-similar-trees/sol.go b/tests/501-1000/872. leaf-similar-trees/sol.go new file mode 100644 index 00000000..1442ee2a --- /dev/null +++ b/tests/501-1000/872. leaf-similar-trees/sol.go @@ -0,0 +1,42 @@ +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +func leafSimilar(root1 *TreeNode, root2 *TreeNode) bool { + helper := func(root *TreeNode) []int { + leaves := []int{} + if root == nil { + return leaves + } + stack := []*TreeNode{root} + for len(stack) > 0 { + curr := stack[len(stack)-1] + stack = stack[:len(stack)-1] + if curr.Left == nil && curr.Right == nil { + leaves = append(leaves, curr.Val) + } + if curr.Right != nil { + stack = append(stack, curr.Right) + } + if curr.Left != nil { + stack = append(stack, curr.Left) + } + } + return leaves + } + leaves1 := helper(root1) + leaves2 := helper(root2) + if len(leaves1) != len(leaves2) { + return false + } + for i := range leaves1 { + if leaves1[i] != leaves2[i] { + return false + } + } + return true +} diff --git a/tests/501-1000/872. leaf-similar-trees/sol.java b/tests/501-1000/872. leaf-similar-trees/sol.java new file mode 100644 index 00000000..2405ea71 --- /dev/null +++ b/tests/501-1000/872. leaf-similar-trees/sol.java @@ -0,0 +1,44 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode() {} + * TreeNode(int val) { this.val = val; } + * TreeNode(int val, TreeNode left, TreeNode right) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +class Solution { + public boolean leafSimilar(TreeNode root1, TreeNode root2) { + List leaves1 = new ArrayList<>(); + List leaves2 = new ArrayList<>(); + helper(root1, leaves1); + helper(root2, leaves2); + return leaves1.equals(leaves2); + } + + private void helper(TreeNode root, List leaves) { + if (root == null) { + return; + } + Stack stack = new Stack<>(); + stack.push(root); + while (!stack.isEmpty()) { + TreeNode curr = stack.pop(); + if (curr.left == null && curr.right == null) { + leaves.add(curr.val); + } + if (curr.right != null) { + stack.push(curr.right); + } + if (curr.left != null) { + stack.push(curr.left); + } + } + } +} diff --git a/tests/501-1000/872. leaf-similar-trees/sol.kt b/tests/501-1000/872. leaf-similar-trees/sol.kt new file mode 100644 index 00000000..f6cfa4b9 --- /dev/null +++ b/tests/501-1000/872. leaf-similar-trees/sol.kt @@ -0,0 +1,35 @@ +/** + * Example: + * var ti = TreeNode(5) + * var v = ti.`val` + * Definition for a binary tree node. + * class TreeNode(var `val`: Int) { + * var left: TreeNode? = null + * var right: TreeNode? = null + * } + */ +class Solution { + fun leafSimilar(root1: TreeNode?, root2: TreeNode?): Boolean { + fun helper(root: TreeNode?, leaves: MutableList): MutableList { + if (root == null) { + return leaves + } + val stack = ArrayDeque() + stack.addLast(root) + while (stack.isNotEmpty()) { + val curr = stack.removeLast() + if (curr.left == null && curr.right == null) { + leaves.add(curr.`val`) + } + if (curr.right != null) { + stack.addLast(curr.right!!) + } + if (curr.left != null) { + stack.addLast(curr.left!!) + } + } + return leaves + } + return helper(root1, mutableListOf()) == helper(root2, mutableListOf()) + } +} diff --git a/tests/501-1000/872. leaf-similar-trees/sol.py b/tests/501-1000/872. leaf-similar-trees/sol.py new file mode 100644 index 00000000..13cb1d71 --- /dev/null +++ b/tests/501-1000/872. leaf-similar-trees/sol.py @@ -0,0 +1,21 @@ +# Definition for a binary tree node. +# class TreeNode: +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution: + def leafSimilar(self, root1: Optional[TreeNode], root2: Optional[TreeNode]) -> bool: + def helper(root, leaves): + stack = [root] + while stack: + curr = stack.pop() + if curr.left is None and curr.right is None: + leaves.append(curr.val) + if curr.left: + stack.append(curr.left) + if curr.right: + stack.append(curr.right) + return leaves + + return helper(root1, []) == helper(root2, []) diff --git a/tests/501-1000/872. leaf-similar-trees/sol.py2 b/tests/501-1000/872. leaf-similar-trees/sol.py2 new file mode 100644 index 00000000..1235877d --- /dev/null +++ b/tests/501-1000/872. leaf-similar-trees/sol.py2 @@ -0,0 +1,25 @@ +# Definition for a binary tree node. +# class TreeNode(object): +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution(object): + def leafSimilar(self, root1, root2): + """ + :type root1: Optional[TreeNode] + :type root2: Optional[TreeNode] + :rtype: bool + """ + def helper(root, leaves): + stack = [root] + while stack: + curr = stack.pop() + if curr.left is None and curr.right is None: + leaves.append(curr.val) + if curr.left: + stack.append(curr.left) + if curr.right: + stack.append(curr.right) + return leaves + return helper(root1, []) == helper(root2, []) diff --git a/tests/501-1000/872. leaf-similar-trees/sol.rb b/tests/501-1000/872. leaf-similar-trees/sol.rb new file mode 100644 index 00000000..6213dd20 --- /dev/null +++ b/tests/501-1000/872. leaf-similar-trees/sol.rb @@ -0,0 +1,31 @@ +# Definition for a binary tree node. +# class TreeNode +# attr_accessor :val, :left, :right +# def initialize(val = 0, left = nil, right = nil) +# @val = val +# @left = left +# @right = right +# end +# end +# @param {TreeNode} root1 +# @param {TreeNode} root2 +# @return {Boolean} +def leaf_similar(root1, root2) + helper = lambda do |root, leaves| + stack = [root] + while !stack.empty? + curr = stack.pop + if curr.left.nil? && curr.right.nil? + leaves << curr.val + end + if curr.left + stack.push(curr.left) + end + if curr.right + stack.push(curr.right) + end + end + leaves + end + helper.call(root1, []) == helper.call(root2, []) +end diff --git a/tests/501-1000/872. leaf-similar-trees/sol.rs b/tests/501-1000/872. leaf-similar-trees/sol.rs new file mode 100644 index 00000000..23b44471 --- /dev/null +++ b/tests/501-1000/872. leaf-similar-trees/sol.rs @@ -0,0 +1,43 @@ +// Definition for a binary tree node. +// #[derive(Debug, PartialEq, Eq)] +// pub struct TreeNode { +// pub val: i32, +// pub left: Option>>, +// pub right: Option>>, +// } +// +// impl TreeNode { +// #[inline] +// pub fn new(val: i32) -> Self { +// TreeNode { +// val, +// left: None, +// right: None +// } +// } +// } +impl Solution { + pub fn leaf_similar(root1: Option>>, root2: Option>>) -> bool { + fn helper(root: Option>>) -> Vec { + let mut leaves = Vec::new(); + let mut stack = match root { + Some(node) => vec![node], + None => return leaves, + }; + while let Some(node) = stack.pop() { + let node = node.borrow(); + if node.left.is_none() && node.right.is_none() { + leaves.push(node.val); + } + if let Some(right) = &node.right { + stack.push(right.clone()); + } + if let Some(left) = &node.left { + stack.push(left.clone()); + } + } + leaves + } + helper(root1) == helper(root2) + } +} diff --git a/tests/501-1000/872. leaf-similar-trees/sol.swift b/tests/501-1000/872. leaf-similar-trees/sol.swift new file mode 100644 index 00000000..0f6dfbd7 --- /dev/null +++ b/tests/501-1000/872. leaf-similar-trees/sol.swift @@ -0,0 +1,40 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public var val: Int + * public var left: TreeNode? + * public var right: TreeNode? + * public init() { self.val = 0; self.left = nil; self.right = nil; } + * public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; } + * public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) { + * self.val = val + * self.left = left + * self.right = right + * } + * } + */ +class Solution { + func leafSimilar(_ root1: TreeNode?, _ root2: TreeNode?) -> Bool { + func helper(_ root: TreeNode?, _ leaves: inout [Int]) { + guard let root else { return } + var stack = [root] + while !stack.isEmpty { + let curr = stack.removeLast() + if curr.left == nil && curr.right == nil { + leaves.append(curr.val) + } + if let right = curr.right { + stack.append(right) + } + if let left = curr.left { + stack.append(left) + } + } + } + var leaves1: [Int] = [] + var leaves2: [Int] = [] + helper(root1, &leaves1) + helper(root2, &leaves2) + return leaves1 == leaves2 + } +} diff --git a/tests/501-1000/872. leaf-similar-trees/sol.ts b/tests/501-1000/872. leaf-similar-trees/sol.ts new file mode 100644 index 00000000..9129d696 --- /dev/null +++ b/tests/501-1000/872. leaf-similar-trees/sol.ts @@ -0,0 +1,41 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ + +function leafSimilar(root1: TreeNode | null, root2: TreeNode | null): boolean { + const helper = (root: TreeNode | null): number[] => { + const leaves: number[] = []; + if (root === null) return leaves; + const stack: TreeNode[] = [root]; + while (stack.length) { + const curr = stack.pop()!; + if (curr.left === null && curr.right === null) { + leaves.push(curr.val); + } + if (curr.right) { + stack.push(curr.right); + } + if (curr.left) { + stack.push(curr.left); + } + } + return leaves; + }; + const leaves1 = helper(root1); + const leaves2 = helper(root2); + if (leaves1.length !== leaves2.length) return false; + for (let i = 0; i < leaves1.length; i++) { + if (leaves1[i] !== leaves2[i]) return false; + } + return true; +} diff --git a/tests/501-1000/873. length-of-longest-fibonacci-subsequence/manifest.yaml b/tests/501-1000/873. length-of-longest-fibonacci-subsequence/manifest.yaml new file mode 100644 index 00000000..35ec461d --- /dev/null +++ b/tests/501-1000/873. length-of-longest-fibonacci-subsequence/manifest.yaml @@ -0,0 +1,187 @@ +entry: + id: 873 + title: length-of-longest-fibonacci-subsequence + params: + arr: + type: array + items: + type: int + call: + cpp: "Solution().lenLongestFibSubseq({arr})" + rust: "Solution::len_longest_fib_subseq({arr})" + python3: "Solution().lenLongestFibSubseq({arr})" + python2: "Solution().lenLongestFibSubseq({arr})" + ruby: "len_longest_fib_subseq({arr})" + java: "new Solution().lenLongestFibSubseq({arr})" + csharp: "new Solution().LenLongestFibSubseq({arr})" + kotlin: "Solution().lenLongestFibSubseq({arr})" + go: "lenLongestFibSubseq({arr})" + dart: "Solution().lenLongestFibSubseq({arr})" + swift: "Solution().lenLongestFibSubseq({arr})" + typescript: "lenLongestFibSubseq({arr})" +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 300 +oracle: + python3: + call: "Checker().lenLongestFibSubseq(arr, {result})" + checker: | + class Checker: + def lenLongestFibSubseq(self, arr, result: Any) -> bool: + return isinstance(result, int) +seed: 873 +tests: + - name: ex1 + in: + arr: [1, 2, 3, 4, 5, 6, 7, 8] + out: 5 + - name: ex2 + in: + arr: [1, 3, 7, 11, 12, 14, 18] + out: 3 + - name: min_no_seq + in: + arr: [1, 2, 4] + out: 0 + - name: min_no_seq_2 + in: + arr: [2, 4, 7] + out: 0 + - name: simple_len3 + in: + arr: [1, 2, 3] + out: 3 + - name: simple_len4 + in: + arr: [1, 2, 3, 5] + out: 4 + - name: simple_len5 + in: + arr: [1, 2, 3, 5, 8] + out: 5 + - name: fib_with_gaps + in: + arr: [1, 4, 5, 9, 14, 23] + out: 6 + - name: no_long_chain + in: + arr: [1, 4, 7, 10, 13] + out: 0 + - name: another_short + in: + arr: [2, 3, 5, 8, 13, 21] + out: 6 + - name: example_like + in: + arr: [1, 4, 6, 7, 10, 13, 17] + out: 4 + - name: pairwise_but_no_chain + in: + arr: [1, 2, 4, 8, 16, 32] + out: 0 + - name: long_chain_offset + in: + arr: [2, 4, 6, 10, 16, 26, 42] + out: 7 + - name: dense_small + in: + arr: [1, 3, 4, 7, 11, 18, 29] + out: 7 + - name: dense_small_2 + in: + arr: [1, 5, 6, 11, 17, 28, 45] + out: 7 + - name: dense_small_3 + in: + arr: [3, 4, 7, 11, 18, 29, 47] + out: 7 + - name: skip_values + in: + arr: [1, 6, 7, 13, 20, 33, 53] + out: 7 + - name: max_value_small + in: + arr: [1, 100000000, 100000001, 200000001] + out: 4 + - name: max_value_small_2 + in: + arr: [1, 1000000, 1000001, 2000001, 3000002, 5000003] + out: 6 + - name: boundary_no_seq + in: + arr: [100, 200, 500, 900, 1500] + out: 0 + - name: boundary_seq3 + in: + arr: [100, 200, 300, 500, 800] + out: 5 + - name: boundary_seq4 + in: + arr: [5, 10, 15, 25, 40, 65] + out: 6 + - name: longer_but_shortest + in: + arr: [1, 3, 4, 7, 12, 19, 31, 50] + out: 5 + - name: chain_with_extra_noise + in: + arr: [1, 2, 3, 5, 8, 13, 21, 34, 55] + out: 9 + - name: chain_starts_late + in: + arr: [2, 7, 9, 16, 25, 41, 66] + out: 7 + - name: chain_starts_late_2 + in: + arr: [4, 9, 13, 22, 35, 57, 92] + out: 7 + - name: chain_with_big_gap + in: + arr: [1, 50, 51, 101, 152, 253] + out: 6 + - name: many_numbers_no_seq + in: + arr: [1, 4, 9, 16, 25, 36, 49, 64] + out: 3 + - name: many_numbers_seq + in: + arr: [1, 2, 3, 6, 9, 15, 24, 39] + out: 6 + - name: near_upper_bound_seq + in: + arr: [1, 1000, 1001, 2001, 3002, 5003, 8005] + out: 7 + - name: near_upper_bound_no_seq + in: + arr: [1, 1000, 2000, 3000, 5000, 8000, 13000] + out: 6 + - name: long_chain_mixed + in: + arr: [2, 5, 7, 12, 19, 31, 50, 81, 131] + out: 9 + - name: long_chain_mixed_2 + in: + arr: [3, 8, 11, 19, 30, 49, 79, 128] + out: 8 + - name: short_chain_middle + in: + arr: [1, 4, 5, 9, 14, 24] + out: 5 + - name: short_chain_middle_2 + in: + arr: [2, 6, 8, 14, 22, 36] + out: 6 + - name: no_chain_with_large_values + in: + arr: [1000000, 2000000, 5000000, 9000000, 16000000] + out: 0 + - name: chain_with_large_values + in: + arr: [1000000, 2000000, 3000000, 5000000, 8000000] + out: 5 + - name: max_len_exampleish + in: + arr: [1, 2, 4, 7, 11, 18, 29, 47] + out: 6 diff --git a/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.cpp b/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.cpp new file mode 100644 index 00000000..d25012c1 --- /dev/null +++ b/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.cpp @@ -0,0 +1,30 @@ +class Solution { +public: + int lenLongestFibSubseq(vector& arr) { + int n = arr.size(); + vector> dp(n, vector(n, 0)); + int maxLen = 0; + + for (int curr = 2; curr < n; curr++) { + int start = 0; + int end = curr - 1; + + while (start < end) { + int pairSum = arr[start] + arr[end]; + + if (pairSum > arr[curr]) { + end--; + } else if (pairSum < arr[curr]) { + start++; + } else { + dp[end][curr] = dp[start][end] + 1; + maxLen = max(dp[end][curr], maxLen); + end--; + start++; + } + } + } + + return maxLen > 0 ? maxLen + 2 : 0; + } +}; diff --git a/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.cs b/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.cs new file mode 100644 index 00000000..e90dc8ab --- /dev/null +++ b/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.cs @@ -0,0 +1,29 @@ +public class Solution { + public int LenLongestFibSubseq(int[] arr) { + int n = arr.Length; + int[,] dp = new int[n, n]; + int maxLen = 0; + + for (int curr = 2; curr < n; curr++) { + int start = 0; + int end = curr - 1; + + while (start < end) { + int pairSum = arr[start] + arr[end]; + + if (pairSum > arr[curr]) { + end--; + } else if (pairSum < arr[curr]) { + start++; + } else { + dp[end, curr] = dp[start, end] + 1; + maxLen = Math.Max(dp[end, curr], maxLen); + end--; + start++; + } + } + } + + return maxLen > 0 ? maxLen + 2 : 0; + } +} diff --git a/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.dart b/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.dart new file mode 100644 index 00000000..f62c73b1 --- /dev/null +++ b/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.dart @@ -0,0 +1,31 @@ +class Solution { + int lenLongestFibSubseq(List arr) { + int n = arr.length; + List> dp = List.generate(n, (_) => List.filled(n, 0)); + int maxLen = 0; + + for (int curr = 2; curr < n; curr++) { + int start = 0; + int end = curr - 1; + + while (start < end) { + int pairSum = arr[start] + arr[end]; + + if (pairSum > arr[curr]) { + end--; + } else if (pairSum < arr[curr]) { + start++; + } else { + dp[end][curr] = dp[start][end] + 1; + if (dp[end][curr] > maxLen) { + maxLen = dp[end][curr]; + } + end--; + start++; + } + } + } + + return maxLen > 0 ? maxLen + 2 : 0; + } +} diff --git a/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.go b/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.go new file mode 100644 index 00000000..19af3043 --- /dev/null +++ b/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.go @@ -0,0 +1,35 @@ +func lenLongestFibSubseq(arr []int) int { + n := len(arr) + dp := make([][]int, n) + for i := range dp { + dp[i] = make([]int, n) + } + maxLen := 0 + + for curr := 2; curr < n; curr++ { + start := 0 + end := curr - 1 + + for start < end { + pairSum := arr[start] + arr[end] + + if pairSum > arr[curr] { + end-- + } else if pairSum < arr[curr] { + start++ + } else { + dp[end][curr] = dp[start][end] + 1 + if dp[end][curr] > maxLen { + maxLen = dp[end][curr] + } + end-- + start++ + } + } + } + + if maxLen > 0 { + return maxLen + 2 + } + return 0 +} diff --git a/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.java b/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.java new file mode 100644 index 00000000..b340c639 --- /dev/null +++ b/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.java @@ -0,0 +1,29 @@ +class Solution { + public int lenLongestFibSubseq(int[] arr) { + int n = arr.length; + int[][] dp = new int[n][n]; + int maxLen = 0; + + for (int curr = 2; curr < n; curr++) { + int start = 0; + int end = curr - 1; + + while (start < end) { + int pairSum = arr[start] + arr[end]; + + if (pairSum > arr[curr]) { + end--; + } else if (pairSum < arr[curr]) { + start++; + } else { + dp[end][curr] = dp[start][end] + 1; + maxLen = Math.max(dp[end][curr], maxLen); + end--; + start++; + } + } + } + + return maxLen > 0 ? maxLen + 2 : 0; + } +} diff --git a/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.kt b/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.kt new file mode 100644 index 00000000..2f01481f --- /dev/null +++ b/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.kt @@ -0,0 +1,29 @@ +class Solution { + fun lenLongestFibSubseq(arr: IntArray): Int { + val n = arr.size + val dp = Array(n) { IntArray(n) } + var maxLen = 0 + + for (curr in 2 until n) { + var start = 0 + var end = curr - 1 + + while (start < end) { + val pairSum = arr[start] + arr[end] + + when { + pairSum > arr[curr] -> end-- + pairSum < arr[curr] -> start++ + else -> { + dp[end][curr] = dp[start][end] + 1 + maxLen = maxOf(dp[end][curr], maxLen) + end-- + start++ + } + } + } + } + + return if (maxLen > 0) maxLen + 2 else 0 + } +} diff --git a/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.py b/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.py new file mode 100644 index 00000000..da18f777 --- /dev/null +++ b/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.py @@ -0,0 +1,29 @@ +class Solution: + def lenLongestFibSubseq(self, arr: list[int]) -> int: + n = len(arr) + # dp[prev][curr] stores length of Fibonacci sequence ending at indexes prev,curr + dp = [[0] * n for _ in range(n)] + max_len = 0 + + # Find all possible pairs that sum to arr[curr] + for curr in range(2, n): + # Use two pointers to find pairs that sum to arr[curr] + start = 0 + end = curr - 1 + + while start < end: + pair_sum = arr[start] + arr[end] + + if pair_sum > arr[curr]: + end -= 1 + elif pair_sum < arr[curr]: + start += 1 + else: + # Found a valid pair, update dp + dp[end][curr] = dp[start][end] + 1 + max_len = max(dp[end][curr], max_len) + end -= 1 + start += 1 + + # Add 2 to include first two numbers, or return 0 if no sequence found + return max_len + 2 if max_len else 0 diff --git a/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.py2 b/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.py2 new file mode 100644 index 00000000..7f022f31 --- /dev/null +++ b/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.py2 @@ -0,0 +1,28 @@ +class Solution(object): + def lenLongestFibSubseq(self, arr): + """ + :type arr: List[int] + :rtype: int + """ + n = len(arr) + dp = [[0] * n for _ in range(n)] + max_len = 0 + + for curr in range(2, n): + start = 0 + end = curr - 1 + + while start < end: + pair_sum = arr[start] + arr[end] + + if pair_sum > arr[curr]: + end -= 1 + elif pair_sum < arr[curr]: + start += 1 + else: + dp[end][curr] = dp[start][end] + 1 + max_len = max(dp[end][curr], max_len) + end -= 1 + start += 1 + + return max_len + 2 if max_len else 0 diff --git a/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.rb b/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.rb new file mode 100644 index 00000000..9954d287 --- /dev/null +++ b/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.rb @@ -0,0 +1,29 @@ +# @param {Integer[]} arr +# @return {Integer} +def len_longest_fib_subseq(arr) + n = arr.length + dp = Array.new(n) { Array.new(n, 0) } + max_len = 0 + + (2...n).each do |curr| + start = 0 + end_idx = curr - 1 + + while start < end_idx + pair_sum = arr[start] + arr[end_idx] + + if pair_sum > arr[curr] + end_idx -= 1 + elsif pair_sum < arr[curr] + start += 1 + else + dp[end_idx][curr] = dp[start][end_idx] + 1 + max_len = [dp[end_idx][curr], max_len].max + end_idx -= 1 + start += 1 + end + end + end + + max_len > 0 ? max_len + 2 : 0 +end diff --git a/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.rs b/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.rs new file mode 100644 index 00000000..08be3422 --- /dev/null +++ b/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.rs @@ -0,0 +1,29 @@ +impl Solution { + pub fn len_longest_fib_subseq(arr: Vec) -> i32 { + let n = arr.len(); + let mut dp = vec![vec![0; n]; n]; + let mut max_len = 0; + + for curr in 2..n { + let mut start = 0; + let mut end = curr - 1; + + while start < end { + let pair_sum = arr[start] + arr[end]; + + if pair_sum > arr[curr] { + end -= 1; + } else if pair_sum < arr[curr] { + start += 1; + } else { + dp[end][curr] = dp[start][end] + 1; + max_len = max_len.max(dp[end][curr]); + end -= 1; + start += 1; + } + } + } + + if max_len > 0 { max_len + 2 } else { 0 } + } +} diff --git a/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.swift b/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.swift new file mode 100644 index 00000000..9df5bb98 --- /dev/null +++ b/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.swift @@ -0,0 +1,29 @@ +class Solution { + func lenLongestFibSubseq(_ arr: [Int]) -> Int { + let n = arr.count + var dp = Array(repeating: Array(repeating: 0, count: n), count: n) + var maxLen = 0 + + for curr in 2.. arr[curr] { + end -= 1 + } else if pairSum < arr[curr] { + start += 1 + } else { + dp[end][curr] = dp[start][end] + 1 + maxLen = max(dp[end][curr], maxLen) + end -= 1 + start += 1 + } + } + } + + return maxLen > 0 ? maxLen + 2 : 0 + } +} diff --git a/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.ts b/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.ts new file mode 100644 index 00000000..5167132d --- /dev/null +++ b/tests/501-1000/873. length-of-longest-fibonacci-subsequence/sol.ts @@ -0,0 +1,27 @@ +function lenLongestFibSubseq(arr: number[]): number { + const n = arr.length; + const dp: number[][] = Array.from({ length: n }, () => Array(n).fill(0)); + let maxLen = 0; + + for (let curr = 2; curr < n; curr++) { + let start = 0; + let end = curr - 1; + + while (start < end) { + const pairSum = arr[start] + arr[end]; + + if (pairSum > arr[curr]) { + end--; + } else if (pairSum < arr[curr]) { + start++; + } else { + dp[end][curr] = dp[start][end] + 1; + maxLen = Math.max(dp[end][curr], maxLen); + end--; + start++; + } + } + } + + return maxLen > 0 ? maxLen + 2 : 0; +} diff --git a/tests/501-1000/874. walking-robot-simulation/manifest.yaml b/tests/501-1000/874. walking-robot-simulation/manifest.yaml new file mode 100644 index 00000000..935d76b5 --- /dev/null +++ b/tests/501-1000/874. walking-robot-simulation/manifest.yaml @@ -0,0 +1,329 @@ +entry: + id: 874 + title: walking-robot-simulation + params: + commands: + type: array + items: + type: int + obstacles: + type: array + items: + type: array + items: + type: int + call: + cpp: "Solution().robotSim({commands}, {obstacles})" + rust: "Solution::robot_sim({commands}, {obstacles})" + python3: "Solution().robotSim({commands}, {obstacles})" + python2: "Solution().robotSim({commands}, {obstacles})" + ruby: "robot_sim({commands}, {obstacles})" + java: "new Solution().robotSim({commands}, {obstacles})" + csharp: "new Solution().RobotSim({commands}, {obstacles})" + kotlin: "Solution().robotSim({commands}, {obstacles})" + go: "robotSim({commands}, {obstacles})" + dart: "Solution().robotSim({commands}, {obstacles})" + swift: "Solution().robotSim({commands}, {obstacles})" + typescript: "robotSim({commands}, {obstacles})" +judge: + type: exact +limits: + time_ms: 400 + memory_mb: 300 +oracle: + python3: + call: "Checker().robotSim(commands, obstacles, {result})" + checker: | + class Checker: + def robotSim(self, commands, obstacles, result: Any) -> bool: + return isinstance(result, int) +seed: 874 +tests: + - name: ex1 + in: + commands: [4, -1, 3] + obstacles: + elemType: int + value: [] + out: 25 + - name: ex2 + in: + commands: [4, -1, 4, -2, 4] + obstacles: + elemType: int + value: + - [2, 4] + out: 65 + - name: ex3 + in: + commands: [6, -1, -1, 6] + obstacles: + elemType: int + value: + - [0, 0] + out: 36 + - name: no_obstacles_straight + in: + commands: [1, 2, 3] + obstacles: + elemType: int + value: [] + out: 36 + - name: turn_only + in: + commands: [-1, -1, -1, -1] + obstacles: + elemType: int + value: [] + out: 0 + - name: turn_left_then_move + in: + commands: [-2, 2] + obstacles: + elemType: int + value: [] + out: 4 + - name: immediate_block_north + in: + commands: [2] + obstacles: + elemType: int + value: + - [0, 1] + out: 0 + - name: block_after_one_step + in: + commands: [2] + obstacles: + elemType: int + value: + - [0, 2] + out: 1 + - name: block_after_turn + in: + commands: [2, -1, 2] + obstacles: + elemType: int + value: + - [1, 2] + out: 4 + - name: obstacle_far_ignored + in: + commands: [2, -1, 2] + obstacles: + elemType: int + value: + - [10, 10] + out: 8 + - name: obstacle_on_path + in: + commands: [3, -1, 3] + obstacles: + elemType: int + value: + - [1, 3] + out: 9 + - name: origin_obstacle + in: + commands: [1, -1, -1, 1] + obstacles: + elemType: int + value: + - [0, 0] + out: 1 + - name: origin_obstacle_block_return + in: + commands: [1, -1, -1, 2] + obstacles: + elemType: int + value: + - [0, 0] + out: 1 + - name: large_square + in: + commands: [9, 9, 9, 9] + obstacles: + elemType: int + value: [] + out: 1296 + - name: zigzag_no_block + in: + commands: [4, -1, 4, -1, 4, -1, 4] + obstacles: + elemType: int + value: [] + out: 32 + - name: zigzag_block + in: + commands: [4, -1, 4, -1, 4, -1, 4] + obstacles: + elemType: int + value: + - [4, 1] + out: 32 + - name: repeated_turns + in: + commands: [-2, -2, 5] + obstacles: + elemType: int + value: [] + out: 25 + - name: repeated_turns_block + in: + commands: [-2, -2, 5] + obstacles: + elemType: int + value: + - [0, -1] + out: 0 + - name: obstacle_negative + in: + commands: [3, -1, 3] + obstacles: + elemType: int + value: + - [1, -3] + out: 18 + - name: obstacle_negative_block + in: + commands: [3, -1, 3, -1, 3] + obstacles: + elemType: int + value: + - [1, -3] + out: 18 + - name: loop_return + in: + commands: [2, -1, 2, -1, 2, -1, 2] + obstacles: + elemType: int + value: [] + out: 8 + - name: loop_return_block + in: + commands: [2, -1, 2, -1, 2, -1, 2] + obstacles: + elemType: int + value: + - [2, 2] + out: 5 + - name: long_path_no_block + in: + commands: [9, -1, 9, -1, 9, -1, 9] + obstacles: + elemType: int + value: [] + out: 162 + - name: long_path_with_block + in: + commands: [9, -1, 9, -1, 9, -1, 9] + obstacles: + elemType: int + value: + - [0, 5] + out: 106 + - name: one_step_each_dir + in: + commands: [1, -1, 1, -1, 1, -1, 1] + obstacles: + elemType: int + value: [] + out: 2 + - name: one_step_each_dir_block + in: + commands: [1, -1, 1, -1, 1, -1, 1] + obstacles: + elemType: int + value: + - [0, 1] + out: 2 + - name: origin_and_far + in: + commands: [6, -1, -1, 6, 9] + obstacles: + elemType: int + value: + - [0, 0] + out: 36 + - name: multiple_obstacles_sparse + in: + commands: [5, -1, 5, -2, 5, -1, 5] + obstacles: + elemType: int + value: + - [0, 3] + - [2, 5] + - [5, 5] + out: 116 + - name: obstacle_on_second_leg + in: + commands: [5, -1, 5, -2, 5] + obstacles: + elemType: int + value: + - [5, 3] + out: 125 + - name: obstacle_on_third_leg + in: + commands: [5, -1, 5, -2, 5, -1, 5] + obstacles: + elemType: int + value: + - [3, 5] + out: 149 + - name: max_distance_early + in: + commands: [9, 9, -1, 1] + obstacles: + elemType: int + value: [] + out: 325 + - name: max_distance_after_block + in: + commands: [9, 9, -1, 9] + obstacles: + elemType: int + value: + - [0, 10] + out: 162 + - name: no_move_after_block + in: + commands: [9, -1, 9] + obstacles: + elemType: int + value: + - [1, 9] + out: 81 + - name: no_move_after_block_2 + in: + commands: [9, -1, 9] + obstacles: + elemType: int + value: + - [0, 9] + out: 145 + - name: large_obstacle_set_simple + in: + commands: [3, 3, 3] + obstacles: + elemType: int + value: + - [100, 100] + - [-100, -100] + out: 81 + - name: near_origin_obstacle + in: + commands: [2, -2, 2, -2, 2] + obstacles: + elemType: int + value: + - [0, 2] + out: 5 + - name: negative_side + in: + commands: [2, -1, 2, -1, 2, -1, 2] + obstacles: + elemType: int + value: + - [2, 2] + out: 5 diff --git a/tests/501-1000/874. walking-robot-simulation/sol.cpp b/tests/501-1000/874. walking-robot-simulation/sol.cpp new file mode 100644 index 00000000..46bd8299 --- /dev/null +++ b/tests/501-1000/874. walking-robot-simulation/sol.cpp @@ -0,0 +1,42 @@ +class Solution { +public: + int robotSim(vector& commands, vector>& obstacles) { + unordered_set blocked; + for (auto& o : obstacles) { + blocked.insert(to_string(o[0]) + "," + to_string(o[1])); + } + + vector> directions = { + {0, 1}, {1, 0}, {0, -1}, {-1, 0} + }; + + int x = 0, y = 0; + int dir = 0; + int maxDist = 0; + + for (int cmd : commands) { + if (cmd == -1) { + dir = (dir + 1) % 4; + } else if (cmd == -2) { + dir = (dir + 3) % 4; + } else { + while (cmd > 0) { + int nx = x + directions[dir][0]; + int ny = y + directions[dir][1]; + + if (blocked.count(to_string(nx) + "," + to_string(ny))) { + break; + } + + x = nx; + y = ny; + + maxDist = max(maxDist, x * x + y * y); + cmd--; + } + } + } + + return maxDist; + } +}; diff --git a/tests/501-1000/874. walking-robot-simulation/sol.cs b/tests/501-1000/874. walking-robot-simulation/sol.cs new file mode 100644 index 00000000..4633e3df --- /dev/null +++ b/tests/501-1000/874. walking-robot-simulation/sol.cs @@ -0,0 +1,42 @@ +public class Solution { + public int RobotSim(int[] commands, int[][] obstacles) { + var blocked = new HashSet(); + foreach (var o in obstacles) { + blocked.Add($"{o[0]},{o[1]}"); + } + + int[][] directions = new int[][] { + new int[] {0, 1}, new int[] {1, 0}, new int[] {0, -1}, new int[] {-1, 0} + }; + + int x = 0, y = 0; + int dir = 0; + int maxDist = 0; + + foreach (int cmd in commands) { + if (cmd == -1) { + dir = (dir + 1) % 4; + } else if (cmd == -2) { + dir = (dir + 3) % 4; + } else { + int steps = cmd; + while (steps > 0) { + int nx = x + directions[dir][0]; + int ny = y + directions[dir][1]; + + if (blocked.Contains($"{nx},{ny}")) { + break; + } + + x = nx; + y = ny; + + maxDist = Math.Max(maxDist, x * x + y * y); + steps--; + } + } + } + + return maxDist; + } +} diff --git a/tests/501-1000/874. walking-robot-simulation/sol.dart b/tests/501-1000/874. walking-robot-simulation/sol.dart new file mode 100644 index 00000000..7cd75d69 --- /dev/null +++ b/tests/501-1000/874. walking-robot-simulation/sol.dart @@ -0,0 +1,44 @@ +class Solution { + int robotSim(List commands, List> obstacles) { + var blocked = {}; + for (var o in obstacles) { + blocked.add("${o[0]},${o[1]}"); + } + + var directions = [ + [0, 1], [1, 0], [0, -1], [-1, 0] + ]; + + int x = 0, y = 0; + int dir = 0; + int maxDist = 0; + + for (var cmd in commands) { + if (cmd == -1) { + dir = (dir + 1) % 4; + } else if (cmd == -2) { + dir = (dir + 3) % 4; + } else { + while (cmd > 0) { + int nx = x + directions[dir][0]; + int ny = y + directions[dir][1]; + + if (blocked.contains("$nx,$ny")) { + break; + } + + x = nx; + y = ny; + + int dist = x * x + y * y; + if (dist > maxDist) { + maxDist = dist; + } + cmd--; + } + } + } + + return maxDist; + } +} diff --git a/tests/501-1000/874. walking-robot-simulation/sol.go b/tests/501-1000/874. walking-robot-simulation/sol.go new file mode 100644 index 00000000..a442a018 --- /dev/null +++ b/tests/501-1000/874. walking-robot-simulation/sol.go @@ -0,0 +1,42 @@ +func robotSim(commands []int, obstacles [][]int) int { + blocked := make(map[[2]int]bool) + for _, o := range obstacles { + blocked[[2]int{o[0], o[1]}] = true + } + + directions := [][2]int{ + {0, 1}, {1, 0}, {0, -1}, {-1, 0}, + } + + x, y := 0, 0 + dir := 0 + maxDist := 0 + + for _, cmd := range commands { + if cmd == -1 { + dir = (dir + 1) % 4 + } else if cmd == -2 { + dir = (dir + 3) % 4 + } else { + for cmd > 0 { + nx := x + directions[dir][0] + ny := y + directions[dir][1] + + if blocked[[2]int{nx, ny}] { + break + } + + x = nx + y = ny + + dist := x*x + y*y + if dist > maxDist { + maxDist = dist + } + cmd-- + } + } + } + + return maxDist +} diff --git a/tests/501-1000/874. walking-robot-simulation/sol.java b/tests/501-1000/874. walking-robot-simulation/sol.java new file mode 100644 index 00000000..33f98e29 --- /dev/null +++ b/tests/501-1000/874. walking-robot-simulation/sol.java @@ -0,0 +1,41 @@ +class Solution { + public int robotSim(int[] commands, int[][] obstacles) { + Set blocked = new HashSet<>(); + for (int[] o : obstacles) { + blocked.add(o[0] + "," + o[1]); + } + + int[][] directions = { + {0, 1}, {1, 0}, {0, -1}, {-1, 0} + }; + + int x = 0, y = 0; + int dir = 0; + int maxDist = 0; + + for (int cmd : commands) { + if (cmd == -1) { + dir = (dir + 1) % 4; + } else if (cmd == -2) { + dir = (dir + 3) % 4; + } else { + while (cmd > 0) { + int nx = x + directions[dir][0]; + int ny = y + directions[dir][1]; + + if (blocked.contains(nx + "," + ny)) { + break; + } + + x = nx; + y = ny; + + maxDist = Math.max(maxDist, x * x + y * y); + cmd--; + } + } + } + + return maxDist; + } +} diff --git a/tests/501-1000/874. walking-robot-simulation/sol.kt b/tests/501-1000/874. walking-robot-simulation/sol.kt new file mode 100644 index 00000000..10fdc3e9 --- /dev/null +++ b/tests/501-1000/874. walking-robot-simulation/sol.kt @@ -0,0 +1,43 @@ +class Solution { + fun robotSim(commands: IntArray, obstacles: Array): Int { + val blocked = mutableSetOf() + for (o in obstacles) { + blocked.add("${o[0]},${o[1]}") + } + + val directions = arrayOf( + intArrayOf(0, 1), intArrayOf(1, 0), intArrayOf(0, -1), intArrayOf(-1, 0) + ) + + var x = 0 + var y = 0 + var dir = 0 + var maxDist = 0 + + for (cmd in commands) { + when (cmd) { + -1 -> dir = (dir + 1) % 4 + -2 -> dir = (dir + 3) % 4 + else -> { + var steps = cmd + while (steps > 0) { + val nx = x + directions[dir][0] + val ny = y + directions[dir][1] + + if ("$nx,$ny" in blocked) { + break + } + + x = nx + y = ny + + maxDist = maxOf(maxDist, x * x + y * y) + steps-- + } + } + } + } + + return maxDist + } +} diff --git a/tests/501-1000/874. walking-robot-simulation/sol.py b/tests/501-1000/874. walking-robot-simulation/sol.py new file mode 100644 index 00000000..bd76e22b --- /dev/null +++ b/tests/501-1000/874. walking-robot-simulation/sol.py @@ -0,0 +1,35 @@ +class Solution: + def robotSim(self, commands, obstacles): + # Store obstacles + blocked = set() + for o in obstacles: + blocked.add((o[0], o[1])) + + # Directions: North, East, South, West + directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] + + x, y = 0, 0 + dir = 0 # initially facing North + maxDist = 0 + + for cmd in commands: + if cmd == -1: + dir = (dir + 1) % 4 # turn right + elif cmd == -2: + dir = (dir + 3) % 4 # turn left + else: + while cmd > 0: + nx = x + directions[dir][0] + ny = y + directions[dir][1] + + # check obstacle + if (nx, ny) in blocked: + break + + x = nx + y = ny + + maxDist = max(maxDist, x * x + y * y) + cmd -= 1 + + return maxDist diff --git a/tests/501-1000/874. walking-robot-simulation/sol.py2 b/tests/501-1000/874. walking-robot-simulation/sol.py2 new file mode 100644 index 00000000..ccad2655 --- /dev/null +++ b/tests/501-1000/874. walking-robot-simulation/sol.py2 @@ -0,0 +1,39 @@ +class Solution(object): + def robotSim(self, commands, obstacles): + """ + :type commands: List[int] + :type obstacles: List[List[int]] + :rtype: int + """ + blocked = set() + for o in obstacles: + blocked.add((o[0], o[1])) + + directions = [ + (0, 1), (1, 0), (0, -1), (-1, 0) + ] + + x, y = 0, 0 + dir = 0 + maxDist = 0 + + for cmd in commands: + if cmd == -1: + dir = (dir + 1) % 4 + elif cmd == -2: + dir = (dir + 3) % 4 + else: + while cmd > 0: + nx = x + directions[dir][0] + ny = y + directions[dir][1] + + if (nx, ny) in blocked: + break + + x = nx + y = ny + + maxDist = max(maxDist, x * x + y * y) + cmd -= 1 + + return maxDist diff --git a/tests/501-1000/874. walking-robot-simulation/sol.rb b/tests/501-1000/874. walking-robot-simulation/sol.rb new file mode 100644 index 00000000..1ac363f4 --- /dev/null +++ b/tests/501-1000/874. walking-robot-simulation/sol.rb @@ -0,0 +1,43 @@ +# @param {Integer[]} commands +# @param {Integer[][]} obstacles +# @return {Integer} +def robot_sim(commands, obstacles) + blocked = Set.new + obstacles.each do |o| + blocked.add([o[0], o[1]]) + end + + directions = [ + [0, 1], [1, 0], [0, -1], [-1, 0] + ] + + x = 0 + y = 0 + dir = 0 + max_dist = 0 + + commands.each do |cmd| + if cmd == -1 + dir = (dir + 1) % 4 + elsif cmd == -2 + dir = (dir + 3) % 4 + else + while cmd > 0 + nx = x + directions[dir][0] + ny = y + directions[dir][1] + + if blocked.include?([nx, ny]) + break + end + + x = nx + y = ny + + max_dist = [max_dist, x * x + y * y].max + cmd -= 1 + end + end + end + + return max_dist +end diff --git a/tests/501-1000/874. walking-robot-simulation/sol.rs b/tests/501-1000/874. walking-robot-simulation/sol.rs new file mode 100644 index 00000000..b93f9674 --- /dev/null +++ b/tests/501-1000/874. walking-robot-simulation/sol.rs @@ -0,0 +1,45 @@ +impl Solution { + pub fn robot_sim(commands: Vec, obstacles: Vec>) -> i32 { + use std::collections::HashSet; + + let mut blocked = HashSet::new(); + for o in &obstacles { + blocked.insert((o[0], o[1])); + } + + let directions = [ + (0, 1), (1, 0), (0, -1), (-1, 0) + ]; + + let mut x = 0; + let mut y = 0; + let mut dir = 0; + let mut max_dist = 0; + + for &cmd in &commands { + if cmd == -1 { + dir = (dir + 1) % 4; + } else if cmd == -2 { + dir = (dir + 3) % 4; + } else { + let mut steps = cmd; + while steps > 0 { + let nx = x + directions[dir].0; + let ny = y + directions[dir].1; + + if blocked.contains(&(nx, ny)) { + break; + } + + x = nx; + y = ny; + + max_dist = max_dist.max(x * x + y * y); + steps -= 1; + } + } + } + + max_dist + } +} diff --git a/tests/501-1000/874. walking-robot-simulation/sol.swift b/tests/501-1000/874. walking-robot-simulation/sol.swift new file mode 100644 index 00000000..65cef24b --- /dev/null +++ b/tests/501-1000/874. walking-robot-simulation/sol.swift @@ -0,0 +1,42 @@ +class Solution { + func robotSim(_ commands: [Int], _ obstacles: [[Int]]) -> Int { + var blocked = Set() + for o in obstacles { + blocked.insert("\(o[0]),\(o[1])") + } + + let directions = [ + (0, 1), (1, 0), (0, -1), (-1, 0) + ] + + var x = 0, y = 0 + var dir = 0 + var maxDist = 0 + + for cmd in commands { + if cmd == -1 { + dir = (dir + 1) % 4 + } else if cmd == -2 { + dir = (dir + 3) % 4 + } else { + var steps = cmd + while steps > 0 { + let nx = x + directions[dir].0 + let ny = y + directions[dir].1 + + if blocked.contains("\(nx),\(ny)") { + break + } + + x = nx + y = ny + + maxDist = max(maxDist, x * x + y * y) + steps -= 1 + } + } + } + + return maxDist + } +} diff --git a/tests/501-1000/874. walking-robot-simulation/sol.ts b/tests/501-1000/874. walking-robot-simulation/sol.ts new file mode 100644 index 00000000..1d9db4b1 --- /dev/null +++ b/tests/501-1000/874. walking-robot-simulation/sol.ts @@ -0,0 +1,44 @@ +function robotSim(commands: number[], obstacles: number[][]): number { + const blocked = new Set(); + for (const o of obstacles) { + blocked.add(`${o[0]},${o[1]}`); + } + + const directions = [ + [0, 1], + [1, 0], + [0, -1], + [-1, 0], + ]; + + let x = 0, + y = 0; + let dir = 0; + let maxDist = 0; + + for (const cmd of commands) { + if (cmd === -1) { + dir = (dir + 1) % 4; + } else if (cmd === -2) { + dir = (dir + 3) % 4; + } else { + let steps = cmd; + while (steps > 0) { + const nx = x + directions[dir][0]; + const ny = y + directions[dir][1]; + + if (blocked.has(`${nx},${ny}`)) { + break; + } + + x = nx; + y = ny; + + maxDist = Math.max(maxDist, x * x + y * y); + steps--; + } + } + } + + return maxDist; +} diff --git a/tests/501-1000/875. koko-eating-bananas/manifest.yaml b/tests/501-1000/875. koko-eating-bananas/manifest.yaml new file mode 100644 index 00000000..4e02ec23 --- /dev/null +++ b/tests/501-1000/875. koko-eating-bananas/manifest.yaml @@ -0,0 +1,227 @@ +entry: + id: 875 + title: koko-eating-bananas + params: + piles: + type: array + items: + type: int + h: + type: int + call: + cpp: "Solution().minEatingSpeed({piles}, {h})" + rust: "Solution::min_eating_speed({piles}, {h})" + python3: "Solution().minEatingSpeed({piles}, {h})" + python2: "Solution().minEatingSpeed({piles}, {h})" + ruby: "min_eating_speed({piles}, {h})" + java: "new Solution().minEatingSpeed({piles}, {h})" + csharp: "new Solution().MinEatingSpeed({piles}, {h})" + kotlin: "Solution().minEatingSpeed({piles}, {h})" + go: "minEatingSpeed({piles}, {h})" + dart: "Solution().minEatingSpeed({piles}, {h})" + swift: "Solution().minEatingSpeed({piles}, {h})" + typescript: "minEatingSpeed({piles}, {h})" +judge: + type: exact +limits: + time_ms: 400 + memory_mb: 300 +oracle: + python3: + call: "Checker().minEatingSpeed(piles, h, {result})" + checker: | + class Checker: + def minEatingSpeed(self, piles, h, result: Any) -> bool: + return isinstance(result, int) +seed: 875 +tests: + - name: ex1 + in: + piles: [3, 6, 7, 11] + h: 8 + out: 4 + - name: ex2 + in: + piles: [30, 11, 23, 4, 20] + h: 5 + out: 30 + - name: ex3 + in: + piles: [30, 11, 23, 4, 20] + h: 6 + out: 23 + - name: single_pile_exact + in: + piles: [1] + h: 1 + out: 1 + - name: single_pile_more_hours + in: + piles: [9] + h: 10 + out: 1 + - name: all_ones + in: + piles: [1, 1, 1, 1] + h: 4 + out: 1 + - name: all_ones_extra_hours + in: + piles: [1, 1, 1, 1] + h: 10 + out: 1 + - name: two_piles_tight + in: + piles: [8, 8] + h: 3 + out: 8 + - name: two_piles_loose + in: + piles: [8, 8] + h: 8 + out: 2 + - name: mixed_small + in: + piles: [2, 3, 5, 7, 11] + h: 7 + out: 6 + - name: mixed_small_2 + in: + piles: [2, 3, 5, 7, 11] + h: 8 + out: 5 + - name: mixed_small_3 + in: + piles: [2, 3, 5, 7, 11] + h: 12 + out: 3 + - name: max_equals_len + in: + piles: [9, 9, 9, 9, 9] + h: 5 + out: 9 + - name: max_small_slack + in: + piles: [9, 9, 9, 9, 9] + h: 6 + out: 9 + - name: large_pile_single_hour + in: + piles: [1000000000] + h: 1 + out: 1000000000 + - name: large_pile_many_hours + in: + piles: [1000000000] + h: 1000000000 + out: 1 + - name: increasing_piles + in: + piles: [1, 2, 3, 4, 5, 6, 7, 8] + h: 8 + out: 8 + - name: increasing_piles_slack + in: + piles: [1, 2, 3, 4, 5, 6, 7, 8] + h: 10 + out: 6 + - name: increasing_piles_more_slack + in: + piles: [1, 2, 3, 4, 5, 6, 7, 8] + h: 15 + out: 3 + - name: power_of_two + in: + piles: [1, 2, 4, 8, 16, 32] + h: 12 + out: 8 + - name: power_of_two_tight + in: + piles: [1, 2, 4, 8, 16, 32] + h: 6 + out: 32 + - name: random_small_1 + in: + piles: [19, 17, 13, 11] + h: 8 + out: 10 + - name: random_small_2 + in: + piles: [19, 17, 13, 11] + h: 5 + out: 17 + - name: random_small_3 + in: + piles: [19, 17, 13, 11] + h: 12 + out: 6 + - name: boundary_mix + in: + piles: [1000000000, 1, 1, 1] + h: 4 + out: 1000000000 + - name: boundary_mix_more_hours + in: + piles: [1000000000, 1, 1, 1] + h: 5 + out: 500000000 + - name: boundary_mix_many_hours + in: + piles: [1000000000, 1, 1, 1] + h: 1000000000 + out: 2 + - name: medium_random_1 + in: + piles: [30, 11, 23, 4, 20, 17, 19] + h: 10 + out: 19 + - name: medium_random_2 + in: + piles: [30, 11, 23, 4, 20, 17, 19] + h: 7 + out: 30 + - name: medium_random_3 + in: + piles: [30, 11, 23, 4, 20, 17, 19] + h: 9 + out: 20 + - name: slower_best + in: + piles: [5, 10, 15, 20, 25] + h: 10 + out: 10 + - name: slower_best_2 + in: + piles: [5, 10, 15, 20, 25] + h: 5 + out: 25 + - name: slower_best_3 + in: + piles: [5, 10, 15, 20, 25] + h: 20 + out: 5 + - name: near_upper_bound_small_count + in: + piles: [999999937, 999999938, 999999939] + h: 3 + out: 999999939 + - name: near_upper_bound_medium + in: + piles: [999999937, 999999938, 999999939] + h: 6 + out: 499999970 + - name: near_upper_bound_large_h + in: + piles: [999999937, 999999938, 999999939] + h: 1000000000 + out: 3 + - name: many_piles_small_speed + in: + piles: [2, 2, 2, 2, 2, 2, 2, 2, 2, 2] + h: 10 + out: 2 + - name: many_piles_more_hours + in: + piles: [2, 2, 2, 2, 2, 2, 2, 2, 2, 2] + h: 12 + out: 2 diff --git a/tests/501-1000/875. koko-eating-bananas/sol.cpp b/tests/501-1000/875. koko-eating-bananas/sol.cpp new file mode 100644 index 00000000..cc711e47 --- /dev/null +++ b/tests/501-1000/875. koko-eating-bananas/sol.cpp @@ -0,0 +1,32 @@ +class Solution { +public: + int minEatingSpeed(vector& piles, int h) { + auto canFinish = [&](int k) -> bool { + long long hours = 0; + for (int pile : piles) { + hours += pile / k; + if (pile % k != 0) { + hours++; + } + if (hours > h) { + return false; + } + } + return true; + }; + + int left = 1; + int right = *max_element(piles.begin(), piles.end()); + int ans = right; + while (left <= right) { + int mid = left + (right - left) / 2; + if (canFinish(mid)) { + ans = mid; + right = mid - 1; + } else { + left = mid + 1; + } + } + return ans; + } +}; diff --git a/tests/501-1000/875. koko-eating-bananas/sol.cs b/tests/501-1000/875. koko-eating-bananas/sol.cs new file mode 100644 index 00000000..ed3161ea --- /dev/null +++ b/tests/501-1000/875. koko-eating-bananas/sol.cs @@ -0,0 +1,31 @@ +public class Solution { + public int MinEatingSpeed(int[] piles, int h) { + bool CanFinish(int k) { + long hours = 0; + foreach (int pile in piles) { + hours += pile / k; + if (pile % k != 0) { + hours++; + } + if (hours > h) { + return false; + } + } + return true; + } + + int left = 1; + int right = piles.Max(); + int ans = right; + while (left <= right) { + int mid = left + (right - left) / 2; + if (CanFinish(mid)) { + ans = mid; + right = mid - 1; + } else { + left = mid + 1; + } + } + return ans; + } +} diff --git a/tests/501-1000/875. koko-eating-bananas/sol.dart b/tests/501-1000/875. koko-eating-bananas/sol.dart new file mode 100644 index 00000000..0c3acda1 --- /dev/null +++ b/tests/501-1000/875. koko-eating-bananas/sol.dart @@ -0,0 +1,31 @@ +class Solution { + int minEatingSpeed(List piles, int h) { + bool canFinish(int k) { + int hours = 0; + for (int pile in piles) { + hours += pile ~/ k; + if (pile % k != 0) { + hours++; + } + if (hours > h) { + return false; + } + } + return true; + } + + int left = 1; + int right = piles.reduce((a, b) => a > b ? a : b); + int ans = right; + while (left <= right) { + int mid = left + (right - left) ~/ 2; + if (canFinish(mid)) { + ans = mid; + right = mid - 1; + } else { + left = mid + 1; + } + } + return ans; + } +} diff --git a/tests/501-1000/875. koko-eating-bananas/sol.go b/tests/501-1000/875. koko-eating-bananas/sol.go new file mode 100644 index 00000000..d1bc6bad --- /dev/null +++ b/tests/501-1000/875. koko-eating-bananas/sol.go @@ -0,0 +1,33 @@ +func minEatingSpeed(piles []int, h int) int { + canFinish := func(k int) bool { + hours := 0 + for _, pile := range piles { + hours += pile / k + if pile % k != 0 { + hours++ + } + if hours > h { + return false + } + } + return true + } + + left, right := 1, 0 + for _, pile := range piles { + if pile > right { + right = pile + } + } + ans := right + for left <= right { + mid := left + (right - left) / 2 + if canFinish(mid) { + ans = mid + right = mid - 1 + } else { + left = mid + 1 + } + } + return ans +} diff --git a/tests/501-1000/875. koko-eating-bananas/sol.java b/tests/501-1000/875. koko-eating-bananas/sol.java new file mode 100644 index 00000000..64a42d5d --- /dev/null +++ b/tests/501-1000/875. koko-eating-bananas/sol.java @@ -0,0 +1,34 @@ +class Solution { + public int minEatingSpeed(int[] piles, int h) { + int left = 1; + int right = 0; + for (int pile : piles) { + right = Math.max(right, pile); + } + int ans = right; + while (left <= right) { + int mid = left + (right - left) / 2; + if (canFinish(piles, h, mid)) { + ans = mid; + right = mid - 1; + } else { + left = mid + 1; + } + } + return ans; + } + + private boolean canFinish(int[] piles, int h, int k) { + int hours = 0; + for (int pile : piles) { + hours += pile / k; + if (pile % k != 0) { + hours++; + } + if (hours > h) { + return false; + } + } + return true; + } +} diff --git a/tests/501-1000/875. koko-eating-bananas/sol.kt b/tests/501-1000/875. koko-eating-bananas/sol.kt new file mode 100644 index 00000000..30be4fae --- /dev/null +++ b/tests/501-1000/875. koko-eating-bananas/sol.kt @@ -0,0 +1,31 @@ +class Solution { + fun minEatingSpeed(piles: IntArray, h: Int): Int { + fun canFinish(k: Int): Boolean { + var hours = 0 + for (pile in piles) { + hours += pile / k + if (pile % k != 0) { + hours++ + } + if (hours > h) { + return false + } + } + return true + } + + var left = 1 + var right = piles.max() + var ans = right + while (left <= right) { + val mid = left + (right - left) / 2 + if (canFinish(mid)) { + ans = mid + right = mid - 1 + } else { + left = mid + 1 + } + } + return ans + } +} diff --git a/tests/501-1000/875. koko-eating-bananas/sol.py b/tests/501-1000/875. koko-eating-bananas/sol.py new file mode 100644 index 00000000..07dd68e3 --- /dev/null +++ b/tests/501-1000/875. koko-eating-bananas/sol.py @@ -0,0 +1,22 @@ +class Solution: + def minEatingSpeed(self, piles: List[int], h: int) -> int: + def canFinish(k: int) -> bool: + hours = 0 + for pile in piles: + hours += pile // k + if pile % k != 0: + hours += 1 + if hours > h: + return False + return True + + left, right = 1, max(piles) + ans = right + while left <= right: + mid = left + (right - left) // 2 + if canFinish(mid): + ans = mid + right = mid - 1 + else: + left = mid + 1 + return ans diff --git a/tests/501-1000/875. koko-eating-bananas/sol.py2 b/tests/501-1000/875. koko-eating-bananas/sol.py2 new file mode 100644 index 00000000..5c2ea2d1 --- /dev/null +++ b/tests/501-1000/875. koko-eating-bananas/sol.py2 @@ -0,0 +1,27 @@ +class Solution(object): + def minEatingSpeed(self, piles, h): + """ + :type piles: List[int] + :type h: int + :rtype: int + """ + def canFinish(k): + hours = 0 + for pile in piles: + hours += pile // k + if pile % k != 0: + hours += 1 + if hours > h: + return False + return True + + left, right = 1, max(piles) + ans = right + while left <= right: + mid = left + (right - left) // 2 + if canFinish(mid): + ans = mid + right = mid - 1 + else: + left = mid + 1 + return ans diff --git a/tests/501-1000/875. koko-eating-bananas/sol.rb b/tests/501-1000/875. koko-eating-bananas/sol.rb new file mode 100644 index 00000000..2d72daeb --- /dev/null +++ b/tests/501-1000/875. koko-eating-bananas/sol.rb @@ -0,0 +1,27 @@ +# @param {Integer[]} piles +# @param {Integer} h +# @return {Integer} +def min_eating_speed(piles, h) + can_finish = ->(k) { + hours = 0 + piles.each do |pile| + hours += pile / k + hours += 1 if pile % k != 0 + return false if hours > h + end + true + } + + left, right = 1, piles.max + ans = right + while left <= right + mid = left + (right - left) / 2 + if can_finish.call(mid) + ans = mid + right = mid - 1 + else + left = mid + 1 + end + end + ans +end diff --git a/tests/501-1000/875. koko-eating-bananas/sol.rs b/tests/501-1000/875. koko-eating-bananas/sol.rs new file mode 100644 index 00000000..f4525a88 --- /dev/null +++ b/tests/501-1000/875. koko-eating-bananas/sol.rs @@ -0,0 +1,31 @@ +impl Solution { + pub fn min_eating_speed(piles: Vec, h: i32) -> i32 { + fn can_finish(piles: &Vec, h: i32, k: i32) -> bool { + let mut hours: i64 = 0; + for &pile in piles { + hours += (pile as i64) / (k as i64); + if pile % k != 0 { + hours += 1; + } + if hours > h as i64 { + return false; + } + } + true + } + + let mut left = 1; + let mut right = *piles.iter().max().unwrap(); + let mut ans = right; + while left <= right { + let mid = left + (right - left) / 2; + if can_finish(&piles, h, mid) { + ans = mid; + right = mid - 1; + } else { + left = mid + 1; + } + } + ans + } +} diff --git a/tests/501-1000/875. koko-eating-bananas/sol.swift b/tests/501-1000/875. koko-eating-bananas/sol.swift new file mode 100644 index 00000000..03652c8a --- /dev/null +++ b/tests/501-1000/875. koko-eating-bananas/sol.swift @@ -0,0 +1,31 @@ +class Solution { + func minEatingSpeed(_ piles: [Int], _ h: Int) -> Int { + func canFinish(_ k: Int) -> Bool { + var hours = 0 + for pile in piles { + hours += pile / k + if pile % k != 0 { + hours += 1 + } + if hours > h { + return false + } + } + return true + } + + var left = 1 + var right = piles.max()! + var ans = right + while left <= right { + let mid = left + (right - left) / 2 + if canFinish(mid) { + ans = mid + right = mid - 1 + } else { + left = mid + 1 + } + } + return ans + } +} diff --git a/tests/501-1000/875. koko-eating-bananas/sol.ts b/tests/501-1000/875. koko-eating-bananas/sol.ts new file mode 100644 index 00000000..1cbabac7 --- /dev/null +++ b/tests/501-1000/875. koko-eating-bananas/sol.ts @@ -0,0 +1,29 @@ +function minEatingSpeed(piles: number[], h: number): number { + const canFinish = (k: number): boolean => { + let hours = 0; + for (const pile of piles) { + hours += Math.floor(pile / k); + if (pile % k !== 0) { + hours++; + } + if (hours > h) { + return false; + } + } + return true; + }; + + let left = 1; + let right = Math.max(...piles); + let ans = right; + while (left <= right) { + const mid = left + Math.floor((right - left) / 2); + if (canFinish(mid)) { + ans = mid; + right = mid - 1; + } else { + left = mid + 1; + } + } + return ans; +} diff --git a/tests/501-1000/876. middle-of-the-linked-list/manifest.yaml b/tests/501-1000/876. middle-of-the-linked-list/manifest.yaml new file mode 100644 index 00000000..feb6bb79 --- /dev/null +++ b/tests/501-1000/876. middle-of-the-linked-list/manifest.yaml @@ -0,0 +1,173 @@ +entry: + id: 876 + title: middle-of-the-linked-list + params: + head: + type: list_node + call: + cpp: "listNodeToArray(Solution().middleNode({head}))" + rust: "ListNode::list_node_to_array(Solution::middle_node({head}))" + python3: "list_node_to_array(Solution().middleNode({head}))" + python2: "list_node_to_array(Solution().middleNode({head}))" + ruby: "list_node_to_array(middle_node({head}))" + java: "ListNode.listNodeToArray(new Solution().middleNode({head}))" + csharp: "ListNode.ListNodeToArray(new Solution().MiddleNode({head}))" + kotlin: "listNodeToArray(Solution().middleNode({head}))" + go: "listNodeToArray(middleNode({head}))" + dart: "list_node_to_array(Solution().middleNode({head}))" + swift: "list_node_to_array(Solution().middleNode({head}))" + typescript: "listNodeToArray(middleNode({head}))" +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 300 +oracle: + python3: + call: "Checker().middleNode(head, {result})" + checker: | + class Checker: + def middleNode(self, head, result: Any) -> bool: + return result is None or isinstance(result, list) +seed: 876 +tests: + - name: ex1 + in: + head: [1, 2, 3, 4, 5] + out: [3, 4, 5] + - name: ex2 + in: + head: [1, 2, 3, 4, 5, 6] + out: [4, 5, 6] + - name: single + in: + head: [1] + out: [1] + - name: two_nodes + in: + head: [1, 2] + out: [2] + - name: three_nodes + in: + head: [1, 2, 3] + out: [2, 3] + - name: four_nodes + in: + head: [1, 2, 3, 4] + out: [3, 4] + - name: five_nodes + in: + head: [1, 2, 3, 4, 5] + out: [3, 4, 5] + - name: six_nodes + in: + head: [1, 2, 3, 4, 5, 6] + out: [4, 5, 6] + - name: seven_nodes + in: + head: [1, 2, 3, 4, 5, 6, 7] + out: [4, 5, 6, 7] + - name: eight_nodes + in: + head: [1, 2, 3, 4, 5, 6, 7, 8] + out: [5, 6, 7, 8] + - name: ascending_even + in: + head: [10, 20, 30, 40, 50, 60, 70, 80] + out: [50, 60, 70, 80] + - name: ascending_odd + in: + head: [10, 20, 30, 40, 50, 60, 70] + out: [40, 50, 60, 70] + - name: all_same_even + in: + head: [7, 7, 7, 7] + out: [7, 7] + - name: all_same_odd + in: + head: [7, 7, 7, 7, 7] + out: [7, 7, 7] + - name: near_max_value + in: + head: [100, 99, 98, 97, 96, 95] + out: [97, 96, 95] + - name: near_min_value + in: + head: [1, 2, 3, 4, 5, 6] + out: [4, 5, 6] + - name: long_even_1 + in: + head: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + out: [6, 7, 8, 9, 10] + - name: long_odd_1 + in: + head: [1, 2, 3, 4, 5, 6, 7, 8, 9] + out: [5, 6, 7, 8, 9] + - name: long_even_2 + in: + head: [11, 12, 13, 14, 15, 16, 17, 18, 19, 20] + out: [16, 17, 18, 19, 20] + - name: long_odd_2 + in: + head: [11, 12, 13, 14, 15, 16, 17, 18, 19] + out: [15, 16, 17, 18, 19] + - name: tail_two + in: + head: [3, 5] + out: [5] + - name: tail_three + in: + head: [3, 5, 7] + out: [5, 7] + - name: tail_four + in: + head: [3, 5, 7, 9] + out: [7, 9] + - name: alternating_values + in: + head: [1, 100, 1, 100, 1, 100] + out: [100, 1, 100] + - name: alternating_values_odd + in: + head: [1, 100, 1, 100, 1] + out: [1, 100, 1] + - name: sorted_desc_even + in: + head: [9, 8, 7, 6, 5, 4] + out: [6, 5, 4] + - name: sorted_desc_odd + in: + head: [9, 8, 7, 6, 5] + out: [7, 6, 5] + - name: repeated_prefix + in: + head: [2, 2, 2, 3, 3, 3] + out: [3, 3, 3] + - name: repeated_suffix + in: + head: [2, 2, 2, 3, 3] + out: [2, 3, 3] + - name: length_9 + in: + head: [1, 3, 5, 7, 9, 11, 13, 15, 17] + out: [9, 11, 13, 15, 17] + - name: length_10 + in: + head: [1, 3, 5, 7, 9, 11, 13, 15, 17, 19] + out: [11, 13, 15, 17, 19] + - name: many_same_1 + in: + head: [5, 5, 5, 5, 5, 5, 5, 5] + out: [5, 5, 5, 5] + - name: many_same_2 + in: + head: [5, 5, 5, 5, 5, 5, 5] + out: [5, 5, 5, 5] + - name: mixed_even + in: + head: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] + out: [7, 8, 9, 10, 11, 12] + - name: mixed_odd + in: + head: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] + out: [6, 7, 8, 9, 10, 11] diff --git a/tests/501-1000/876. middle-of-the-linked-list/sol.cpp b/tests/501-1000/876. middle-of-the-linked-list/sol.cpp new file mode 100644 index 00000000..f68c821e --- /dev/null +++ b/tests/501-1000/876. middle-of-the-linked-list/sol.cpp @@ -0,0 +1,25 @@ +/** + * Definition for singly-linked list. + * struct ListNode { + * int val; + * ListNode *next; + * ListNode() : val(0), next(nullptr) {} + * ListNode(int x) : val(x), next(nullptr) {} + * ListNode(int x, ListNode *next) : val(x), next(next) {} + * }; + */ +class Solution { +public: + ListNode* middleNode(ListNode* head) { + if (!head || !head->next) { + return head; + } + ListNode* slow = head; + ListNode* fast = head; + while (fast && fast->next) { + slow = slow->next; + fast = fast->next->next; + } + return slow; + } +}; diff --git a/tests/501-1000/876. middle-of-the-linked-list/sol.cs b/tests/501-1000/876. middle-of-the-linked-list/sol.cs new file mode 100644 index 00000000..3ffce8df --- /dev/null +++ b/tests/501-1000/876. middle-of-the-linked-list/sol.cs @@ -0,0 +1,25 @@ +/** + * Definition for singly-linked list. + * public class ListNode { + * public int val; + * public ListNode next; + * public ListNode(int val=0, ListNode next=null) { + * this.val = val; + * this.next = next; + * } + * } + */ +public class Solution { + public ListNode MiddleNode(ListNode head) { + if (head == null || head.next == null) { + return head; + } + ListNode slow = head; + ListNode fast = head; + while (fast != null && fast.next != null) { + slow = slow.next; + fast = fast.next.next; + } + return slow; + } +} diff --git a/tests/501-1000/876. middle-of-the-linked-list/sol.dart b/tests/501-1000/876. middle-of-the-linked-list/sol.dart new file mode 100644 index 00000000..597d7be4 --- /dev/null +++ b/tests/501-1000/876. middle-of-the-linked-list/sol.dart @@ -0,0 +1,22 @@ +/** + * Definition for singly-linked list. + * class ListNode { + * int val; + * ListNode? next; + * ListNode([this.val = 0, this.next]); + * } + */ +class Solution { + ListNode? middleNode(ListNode? head) { + if (head == null || head.next == null) { + return head; + } + ListNode? slow = head; + ListNode? fast = head; + while (fast != null && fast.next != null) { + slow = slow!.next; + fast = fast.next!.next; + } + return slow; + } +} diff --git a/tests/501-1000/876. middle-of-the-linked-list/sol.go b/tests/501-1000/876. middle-of-the-linked-list/sol.go new file mode 100644 index 00000000..50105c3d --- /dev/null +++ b/tests/501-1000/876. middle-of-the-linked-list/sol.go @@ -0,0 +1,18 @@ +/** + * Definition for singly-linked list. + * type ListNode struct { + * Val int + * Next *ListNode + * } + */ +func middleNode(head *ListNode) *ListNode { + if head == nil || head.Next == nil { + return head + } + slow, fast := head, head + for fast != nil && fast.Next != nil { + slow = slow.Next + fast = fast.Next.Next + } + return slow +} diff --git a/tests/501-1000/876. middle-of-the-linked-list/sol.java b/tests/501-1000/876. middle-of-the-linked-list/sol.java new file mode 100644 index 00000000..40be86a1 --- /dev/null +++ b/tests/501-1000/876. middle-of-the-linked-list/sol.java @@ -0,0 +1,24 @@ +/** + * Definition for singly-linked list. + * public class ListNode { + * int val; + * ListNode next; + * ListNode() {} + * ListNode(int val) { this.val = val; } + * ListNode(int val, ListNode next) { this.val = val; this.next = next; } + * } + */ +class Solution { + public ListNode middleNode(ListNode head) { + if (head == null || head.next == null) { + return head; + } + ListNode slow = head; + ListNode fast = head; + while (fast != null && fast.next != null) { + slow = slow.next; + fast = fast.next.next; + } + return slow; + } +} diff --git a/tests/501-1000/876. middle-of-the-linked-list/sol.kt b/tests/501-1000/876. middle-of-the-linked-list/sol.kt new file mode 100644 index 00000000..90b4deb3 --- /dev/null +++ b/tests/501-1000/876. middle-of-the-linked-list/sol.kt @@ -0,0 +1,23 @@ +/** + * Example: + * var li = ListNode(5) + * var v = li.`val` + * Definition for singly-linked list. + * class ListNode(var `val`: Int) { + * var next: ListNode? = null + * } + */ +class Solution { + fun middleNode(head: ListNode?): ListNode? { + if (head == null || head.next == null) { + return head + } + var slow = head + var fast = head + while (fast != null && fast.next != null) { + slow = slow?.next + fast = fast.next?.next + } + return slow + } +} diff --git a/tests/501-1000/876. middle-of-the-linked-list/sol.py b/tests/501-1000/876. middle-of-the-linked-list/sol.py new file mode 100644 index 00000000..4e24e500 --- /dev/null +++ b/tests/501-1000/876. middle-of-the-linked-list/sol.py @@ -0,0 +1,9 @@ +class Solution: + def middleNode(self, head: ListNode) -> ListNode: + if not head or not head.next: + return head + slow, fast = head, head + while fast and fast.next: + slow = slow.next + fast = fast.next.next + return slow diff --git a/tests/501-1000/876. middle-of-the-linked-list/sol.py2 b/tests/501-1000/876. middle-of-the-linked-list/sol.py2 new file mode 100644 index 00000000..53996614 --- /dev/null +++ b/tests/501-1000/876. middle-of-the-linked-list/sol.py2 @@ -0,0 +1,18 @@ +# Definition for singly-linked list. +# class ListNode(object): +# def __init__(self, val=0, next=None): +# self.val = val +# self.next = next +class Solution(object): + def middleNode(self, head): + """ + :type head: Optional[ListNode] + :rtype: Optional[ListNode] + """ + if not head or not head.next: + return head + slow, fast = head, head + while fast and fast.next: + slow = slow.next + fast = fast.next.next + return slow diff --git a/tests/501-1000/876. middle-of-the-linked-list/sol.rb b/tests/501-1000/876. middle-of-the-linked-list/sol.rb new file mode 100644 index 00000000..850c081b --- /dev/null +++ b/tests/501-1000/876. middle-of-the-linked-list/sol.rb @@ -0,0 +1,19 @@ +# Definition for singly-linked list. +# class ListNode +# attr_accessor :val, :next +# def initialize(val = 0, _next = nil) +# @val = val +# @next = _next +# end +# end +# @param {ListNode} head +# @return {ListNode} +def middle_node(head) + return head if head.nil? || head.next.nil? + slow, fast = head, head + while fast && fast.next + slow = slow.next + fast = fast.next.next + end + slow +end diff --git a/tests/501-1000/876. middle-of-the-linked-list/sol.rs b/tests/501-1000/876. middle-of-the-linked-list/sol.rs new file mode 100644 index 00000000..391c500c --- /dev/null +++ b/tests/501-1000/876. middle-of-the-linked-list/sol.rs @@ -0,0 +1,27 @@ +// Definition for singly-linked list. +// #[derive(PartialEq, Eq, Clone, Debug)] +// pub struct ListNode { +// pub val: i32, +// pub next: Option> +// } +// +// impl ListNode { +// #[inline] +// fn new(val: i32) -> Self { +// ListNode { +// next: None, +// val +// } +// } +// } +impl Solution { + pub fn middle_node(head: Option>) -> Option> { + let mut slow = &head; + let mut fast = &head; + while fast.is_some() && fast.as_ref()?.next.is_some() { + slow = &slow.as_ref()?.next; + fast = &fast.as_ref()?.next.as_ref()?.next; + } + slow.clone() + } +} diff --git a/tests/501-1000/876. middle-of-the-linked-list/sol.swift b/tests/501-1000/876. middle-of-the-linked-list/sol.swift new file mode 100644 index 00000000..4e971a0c --- /dev/null +++ b/tests/501-1000/876. middle-of-the-linked-list/sol.swift @@ -0,0 +1,24 @@ +/** + * Definition for singly-linked list. + * public class ListNode { + * public var val: Int + * public var next: ListNode? + * public init() { self.val = 0; self.next = nil; } + * public init(_ val: Int) { self.val = val; self.next = nil; } + * public init(_ val: Int, _ next: ListNode?) { self.val = val; self.next = next; } + * } + */ +class Solution { + func middleNode(_ head: ListNode?) -> ListNode? { + if head == nil || head?.next == nil { + return head + } + var slow = head + var fast = head + while fast != nil && fast?.next != nil { + slow = slow?.next + fast = fast?.next?.next + } + return slow + } +} diff --git a/tests/501-1000/876. middle-of-the-linked-list/sol.ts b/tests/501-1000/876. middle-of-the-linked-list/sol.ts new file mode 100644 index 00000000..ac24a70d --- /dev/null +++ b/tests/501-1000/876. middle-of-the-linked-list/sol.ts @@ -0,0 +1,24 @@ +/** + * Definition for singly-linked list. + * class ListNode { + * val: number + * next: ListNode | null + * constructor(val?: number, next?: ListNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.next = (next===undefined ? null : next) + * } + * } + */ + +function middleNode(head: ListNode | null): ListNode | null { + if (!head || !head.next) { + return head; + } + let slow = head; + let fast = head; + while (fast && fast.next) { + slow = slow!.next; + fast = fast.next.next; + } + return slow; +} diff --git a/tests/501-1000/877. stone-game/manifest.yaml b/tests/501-1000/877. stone-game/manifest.yaml new file mode 100644 index 00000000..a029f0ad --- /dev/null +++ b/tests/501-1000/877. stone-game/manifest.yaml @@ -0,0 +1,728 @@ +entry: + id: 877 + title: stone-game + params: + piles: + type: array + items: + type: int + call: + cpp: Solution().stoneGame({piles}) + rust: Solution::stone_game({piles}) + python3: Solution().stoneGame({piles}) + python2: Solution().stoneGame({piles}) + ruby: stone_game({piles}) + java: new Solution().stoneGame({piles}) + csharp: new Solution().StoneGame({piles}) + kotlin: Solution().stoneGame({piles}) + go: stoneGame({piles}) + dart: Solution().stoneGame({piles}) + swift: Solution().stoneGame({piles}) + typescript: stoneGame({piles}) +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 300 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 877 +tests: + - name: t01 + in: + piles: + - 5 + - 3 + - 4 + - 5 + out: true + - name: t02 + in: + piles: + - 3 + - 7 + - 2 + - 3 + out: true + - name: t03 + in: + piles: + - 1 + - 2 + out: true + - name: t04 + in: + piles: + - 2 + - 1 + out: true + - name: t05 + in: + piles: + - 1 + - 1 + out: true + - name: t06 + in: + piles: + - 9 + - 1 + - 1 + - 1 + out: true + - name: t07 + in: + piles: + - 2 + - 3 + - 4 + - 5 + out: true + - name: t08 + in: + piles: + - 10 + - 20 + out: true + - name: t09 + in: + piles: + - 1 + - 500 + - 1 + - 500 + out: true + - name: t10 + in: + piles: + - 8 + - 6 + - 7 + - 5 + out: true + - name: t11 + in: + piles: + - 100 + - 1 + - 1 + - 1 + - 1 + - 1 + out: true + - name: t12 + in: + piles: + - 4 + - 4 + - 4 + - 1 + out: true + - name: t13 + in: + piles: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + out: true + - name: t14 + in: + piles: + - 6 + - 5 + - 4 + - 3 + - 2 + - 1 + out: true + - name: t15 + in: + piles: + - 11 + - 13 + out: true + - name: t16 + in: + piles: + - 2 + - 2 + - 2 + - 1 + out: true + - name: t17 + in: + piles: + - 3 + - 1 + - 4 + - 1 + - 5 + - 9 + out: true + - name: t18 + in: + piles: + - 2 + - 7 + - 9 + - 4 + out: true + - name: t19 + in: + piles: + - 5 + - 5 + - 1 + - 1 + - 1 + - 1 + out: true + - name: t20 + in: + piles: + - 8 + - 1 + - 8 + - 1 + - 8 + - 1 + out: true + - name: t21 + in: + piles: + - 500 + - 1 + - 500 + - 1 + - 500 + - 1 + out: true + - name: t22 + in: + piles: + - 1 + - 500 + - 2 + - 499 + out: true + - name: t23 + in: + piles: + - 250 + - 250 + - 250 + - 250 + out: true + - name: t24 + in: + piles: + - 7 + - 8 + - 9 + - 10 + - 11 + - 12 + out: true + - name: t25 + in: + piles: + - 1 + - 3 + - 1 + - 3 + - 1 + - 3 + out: true + - name: t26 + in: + piles: + - 100 + - 200 + out: true + - name: t27 + in: + piles: + - 2 + - 499 + - 2 + - 499 + out: true + - name: t28 + in: + piles: + - 4 + - 2 + - 4 + - 2 + - 4 + - 2 + out: true + - name: t29 + in: + piles: + - 123 + - 456 + out: true + - name: t30 + in: + piles: + - 99 + - 1 + - 98 + - 2 + out: true + - name: t31 + in: + piles: + - 1 + - 4 + - 1 + - 4 + - 1 + - 4 + - 1 + - 4 + out: true + - name: t32 + in: + piles: + - 10 + - 9 + - 8 + - 7 + - 6 + - 5 + - 4 + - 3 + out: true + - name: t33 + in: + piles: + - 1 + - 2 + - 1 + - 2 + - 1 + - 2 + - 1 + - 2 + - 1 + - 2 + out: true + - name: t34 + in: + piles: + - 500 + - 499 + - 1 + - 1 + out: true + - name: t35 + in: + piles: + - 1 + - 500 + - 2 + - 499 + - 3 + - 498 + - 4 + - 497 + - 5 + - 496 + - 6 + - 495 + - 7 + - 494 + - 8 + - 493 + - 9 + - 492 + - 10 + - 491 + - 11 + - 490 + - 12 + - 489 + - 13 + - 488 + - 14 + - 487 + - 15 + - 486 + - 16 + - 485 + - 17 + - 484 + - 18 + - 483 + - 19 + - 482 + - 20 + - 481 + - 21 + - 480 + - 22 + - 479 + - 23 + - 478 + - 24 + - 477 + - 25 + - 476 + - 26 + - 475 + - 27 + - 474 + - 28 + - 473 + - 29 + - 472 + - 30 + - 471 + - 31 + - 470 + - 32 + - 469 + - 33 + - 468 + - 34 + - 467 + - 35 + - 466 + - 36 + - 465 + - 37 + - 464 + - 38 + - 463 + - 39 + - 462 + - 40 + - 461 + - 41 + - 460 + - 42 + - 459 + - 43 + - 458 + - 44 + - 457 + - 45 + - 456 + - 46 + - 455 + - 47 + - 454 + - 48 + - 453 + - 49 + - 452 + - 50 + - 451 + - 51 + - 450 + - 52 + - 449 + - 53 + - 448 + - 54 + - 447 + - 55 + - 446 + - 56 + - 445 + - 57 + - 444 + - 58 + - 443 + - 59 + - 442 + - 60 + - 441 + - 61 + - 440 + - 62 + - 439 + - 63 + - 438 + - 64 + - 437 + - 65 + - 436 + - 66 + - 435 + - 67 + - 434 + - 68 + - 433 + - 69 + - 432 + - 70 + - 431 + - 71 + - 430 + - 72 + - 429 + - 73 + - 428 + - 74 + - 427 + - 75 + - 426 + - 76 + - 425 + - 77 + - 424 + - 78 + - 423 + - 79 + - 422 + - 80 + - 421 + - 81 + - 420 + - 82 + - 419 + - 83 + - 418 + - 84 + - 417 + - 85 + - 416 + - 86 + - 415 + - 87 + - 414 + - 88 + - 413 + - 89 + - 412 + - 90 + - 411 + - 91 + - 410 + - 92 + - 409 + - 93 + - 408 + - 94 + - 407 + - 95 + - 406 + - 96 + - 405 + - 97 + - 404 + - 98 + - 403 + - 99 + - 402 + - 100 + - 401 + - 101 + - 400 + - 102 + - 399 + - 103 + - 398 + - 104 + - 397 + - 105 + - 396 + - 106 + - 395 + - 107 + - 394 + - 108 + - 393 + - 109 + - 392 + - 110 + - 391 + - 111 + - 390 + - 112 + - 389 + - 113 + - 388 + - 114 + - 387 + - 115 + - 386 + - 116 + - 385 + - 117 + - 384 + - 118 + - 383 + - 119 + - 382 + - 120 + - 381 + - 121 + - 380 + - 122 + - 379 + - 123 + - 378 + - 124 + - 377 + - 125 + - 376 + - 126 + - 375 + - 127 + - 374 + - 128 + - 373 + - 129 + - 372 + - 130 + - 371 + - 131 + - 370 + - 132 + - 369 + - 133 + - 368 + - 134 + - 367 + - 135 + - 366 + - 136 + - 365 + - 137 + - 364 + - 138 + - 363 + - 139 + - 362 + - 140 + - 361 + - 141 + - 360 + - 142 + - 359 + - 143 + - 358 + - 144 + - 357 + - 145 + - 356 + - 146 + - 355 + - 147 + - 354 + - 148 + - 353 + - 149 + - 352 + - 150 + - 351 + - 151 + - 350 + - 152 + - 349 + - 153 + - 348 + - 154 + - 347 + - 155 + - 346 + - 156 + - 345 + - 157 + - 344 + - 158 + - 343 + - 159 + - 342 + - 160 + - 341 + - 161 + - 340 + - 162 + - 339 + - 163 + - 338 + - 164 + - 337 + - 165 + - 336 + - 166 + - 335 + - 167 + - 334 + - 168 + - 333 + - 169 + - 332 + - 170 + - 331 + - 171 + - 330 + - 172 + - 329 + - 173 + - 328 + - 174 + - 327 + - 175 + - 326 + - 176 + - 325 + - 177 + - 324 + - 178 + - 323 + - 179 + - 322 + - 180 + - 321 + - 181 + - 320 + - 182 + - 319 + - 183 + - 318 + - 184 + - 317 + - 185 + - 316 + - 186 + - 315 + - 187 + - 314 + - 188 + - 313 + - 189 + - 312 + - 190 + - 311 + - 191 + - 310 + - 192 + - 309 + - 193 + - 308 + - 194 + - 307 + - 195 + - 306 + - 196 + - 305 + - 197 + - 304 + - 198 + - 303 + - 199 + - 302 + - 200 + - 300 + out: true diff --git a/tests/501-1000/877. stone-game/sol.cpp b/tests/501-1000/877. stone-game/sol.cpp new file mode 100644 index 00000000..fab58e98 --- /dev/null +++ b/tests/501-1000/877. stone-game/sol.cpp @@ -0,0 +1,6 @@ +class Solution { +public: + bool stoneGame(vector& piles) { + return true; + } +}; diff --git a/tests/501-1000/877. stone-game/sol.cs b/tests/501-1000/877. stone-game/sol.cs new file mode 100644 index 00000000..3a4defda --- /dev/null +++ b/tests/501-1000/877. stone-game/sol.cs @@ -0,0 +1,5 @@ +public class Solution { + public bool StoneGame(int[] piles) { + return true; + } +} diff --git a/tests/501-1000/877. stone-game/sol.dart b/tests/501-1000/877. stone-game/sol.dart new file mode 100644 index 00000000..b4e70929 --- /dev/null +++ b/tests/501-1000/877. stone-game/sol.dart @@ -0,0 +1,5 @@ +class Solution { + bool stoneGame(List piles) { + return true; + } +} diff --git a/tests/501-1000/877. stone-game/sol.go b/tests/501-1000/877. stone-game/sol.go new file mode 100644 index 00000000..8c13f3de --- /dev/null +++ b/tests/501-1000/877. stone-game/sol.go @@ -0,0 +1,3 @@ +func stoneGame(piles []int) bool { + return true +} diff --git a/tests/501-1000/877. stone-game/sol.java b/tests/501-1000/877. stone-game/sol.java new file mode 100644 index 00000000..f50c98f7 --- /dev/null +++ b/tests/501-1000/877. stone-game/sol.java @@ -0,0 +1,5 @@ +class Solution { + public boolean stoneGame(int[] piles) { + return true; + } +} diff --git a/tests/501-1000/877. stone-game/sol.kt b/tests/501-1000/877. stone-game/sol.kt new file mode 100644 index 00000000..a3d16209 --- /dev/null +++ b/tests/501-1000/877. stone-game/sol.kt @@ -0,0 +1,5 @@ +class Solution { + fun stoneGame(piles: IntArray): Boolean { + return true + } +} diff --git a/tests/501-1000/877. stone-game/sol.py b/tests/501-1000/877. stone-game/sol.py new file mode 100644 index 00000000..1784c7b4 --- /dev/null +++ b/tests/501-1000/877. stone-game/sol.py @@ -0,0 +1,3 @@ +class Solution: + def stoneGame(self, piles): + return True diff --git a/tests/501-1000/877. stone-game/sol.py2 b/tests/501-1000/877. stone-game/sol.py2 new file mode 100644 index 00000000..2ac126e6 --- /dev/null +++ b/tests/501-1000/877. stone-game/sol.py2 @@ -0,0 +1,7 @@ +class Solution(object): + def stoneGame(self, piles): + """ + :type piles: List[int] + :rtype: bool + """ + return True diff --git a/tests/501-1000/877. stone-game/sol.rb b/tests/501-1000/877. stone-game/sol.rb new file mode 100644 index 00000000..f4b5da0f --- /dev/null +++ b/tests/501-1000/877. stone-game/sol.rb @@ -0,0 +1,5 @@ +# @param {Integer[]} piles +# @return {Boolean} +def stone_game(piles) + true +end diff --git a/tests/501-1000/877. stone-game/sol.rs b/tests/501-1000/877. stone-game/sol.rs new file mode 100644 index 00000000..6c0cd6ff --- /dev/null +++ b/tests/501-1000/877. stone-game/sol.rs @@ -0,0 +1,5 @@ +impl Solution { + pub fn stone_game(piles: Vec) -> bool { + true + } +} diff --git a/tests/501-1000/877. stone-game/sol.swift b/tests/501-1000/877. stone-game/sol.swift new file mode 100644 index 00000000..1a178427 --- /dev/null +++ b/tests/501-1000/877. stone-game/sol.swift @@ -0,0 +1,5 @@ +class Solution { + func stoneGame(_ piles: [Int]) -> Bool { + return true + } +} diff --git a/tests/501-1000/877. stone-game/sol.ts b/tests/501-1000/877. stone-game/sol.ts new file mode 100644 index 00000000..b5a44bbd --- /dev/null +++ b/tests/501-1000/877. stone-game/sol.ts @@ -0,0 +1,3 @@ +function stoneGame(piles: number[]): boolean { + return true; +} diff --git a/tests/501-1000/878. nth-magical-number/manifest.yaml b/tests/501-1000/878. nth-magical-number/manifest.yaml new file mode 100644 index 00000000..45a10143 --- /dev/null +++ b/tests/501-1000/878. nth-magical-number/manifest.yaml @@ -0,0 +1,247 @@ +entry: + id: 878 + title: "nth-magical-number" + params: + n: + type: int + a: + type: int + b: + type: int + call: + cpp: "Solution().nthMagicalNumber({n}, {a}, {b})" + rust: "Solution::nth_magical_number({n}, {a}, {b})" + python3: "Solution().nthMagicalNumber({n}, {a}, {b})" + python2: "Solution().nthMagicalNumber({n}, {a}, {b})" + ruby: "nth_magical_number({n}, {a}, {b})" + java: "new Solution().nthMagicalNumber({n}, {a}, {b})" + csharp: "new Solution().NthMagicalNumber({n}, {a}, {b})" + kotlin: "Solution().nthMagicalNumber({n}, {a}, {b})" + go: "nthMagicalNumber({n}, {a}, {b})" + dart: "Solution().nthMagicalNumber({n}, {a}, {b})" + swift: "Solution().nthMagicalNumber({n}, {a}, {b})" + typescript: "nthMagicalNumber({n}, {a}, {b})" +judge: + type: "exact" +limits: + time_ms: 200 + memory_mb: 300 +oracle: + python3: + call: "Checker().check({result})" + checker: | + class Checker: + def check(self, result): + return True +seed: 878 +tests: + - name: "t01" + in: + n: 1 + a: 2 + b: 3 + out: 2 + - name: "t02" + in: + n: 4 + a: 2 + b: 3 + out: 6 + - name: "t03" + in: + n: 5 + a: 2 + b: 4 + out: 10 + - name: "t04" + in: + n: 10 + a: 4 + b: 6 + out: 30 + - name: "t05" + in: + n: 8 + a: 6 + b: 8 + out: 32 + - name: "t06" + in: + n: 15 + a: 7 + b: 11 + out: 66 + - name: "t07" + in: + n: 20 + a: 13 + b: 17 + out: 153 + - name: "t08" + in: + n: 25 + a: 14 + b: 21 + out: 266 + - name: "t09" + in: + n: 30 + a: 18 + b: 24 + out: 360 + - name: "t10" + in: + n: 40 + a: 25 + b: 30 + out: 600 + - name: "t11" + in: + n: 50 + a: 37 + b: 41 + out: 984 + - name: "t12" + in: + n: 60 + a: 12 + b: 18 + out: 540 + - name: "t13" + in: + n: 70 + a: 19 + b: 23 + out: 741 + - name: "t14" + in: + n: 80 + a: 29 + b: 31 + out: 1218 + - name: "t15" + in: + n: 90 + a: 100 + b: 101 + out: 4545 + - name: "t16" + in: + n: 100 + a: 2 + b: 9999 + out: 200 + - name: "t17" + in: + n: 123 + a: 37 + b: 41 + out: 2419 + - name: "t18" + in: + n: 250 + a: 17 + b: 29 + out: 2737 + - name: "t19" + in: + n: 333 + a: 12 + b: 15 + out: 2496 + - name: "t20" + in: + n: 500 + a: 39999 + b: 40000 + out: 10000000 + - name: "t21" + in: + n: 777 + a: 40000 + b: 39999 + out: 15559611 + - name: "t22" + in: + n: 1000 + a: 2 + b: 40000 + out: 2000 + - name: "t23" + in: + n: 5000 + a: 6 + b: 10 + out: 21430 + - name: "t24" + in: + n: 12345 + a: 14 + b: 28 + out: 172830 + - name: "t25" + in: + n: 54321 + a: 13 + b: 17 + out: 413967 + - name: "t26" + in: + n: 99999 + a: 999 + b: 1000 + out: 49999950 + - name: "t27" + in: + n: 1000000 + a: 37 + b: 41 + out: 19701316 + - name: "t28" + in: + n: 12345678 + a: 39991 + b: 39989 + out: 854923420 + - name: "t29" + in: + n: 50000000 + a: 2 + b: 3 + out: 75000000 + - name: "t30" + in: + n: 999999999 + a: 39999 + b: 40000 + out: 999847507 + - name: "t31" + in: + n: 1000000000 + a: 39999 + b: 40000 + out: 999860007 + - name: "t32" + in: + n: 250000000 + a: 39998 + b: 39999 + out: 874965007 + - name: "t33" + in: + n: 42 + a: 21 + b: 28 + out: 588 + - name: "t34" + in: + n: 73 + a: 9 + b: 12 + out: 441 + - name: "t35" + in: + n: 88 + a: 16 + b: 24 + out: 1056 diff --git a/tests/501-1000/878. nth-magical-number/sol.cpp b/tests/501-1000/878. nth-magical-number/sol.cpp new file mode 100644 index 00000000..23cc01ee --- /dev/null +++ b/tests/501-1000/878. nth-magical-number/sol.cpp @@ -0,0 +1,30 @@ +class Solution { +public: + int nthMagicalNumber(int n, int a, int b) { + const int MOD = 1000000007; + int g = gcd(a, b); + long long lcm = (long long) a / g * b; + long long lo = min(a, b); + long long hi = (long long) n * lo; + while (lo < hi) { + long long mid = (lo + hi) >> 1; + long long cnt = mid / a + mid / b - mid / lcm; + if (cnt < n) { + lo = mid + 1; + } else { + hi = mid; + } + } + return (int) (lo % MOD); + } + +private: + int gcd(int x, int y) { + while (y != 0) { + int t = y; + y = x % y; + x = t; + } + return x; + } +}; diff --git a/tests/501-1000/878. nth-magical-number/sol.cs b/tests/501-1000/878. nth-magical-number/sol.cs new file mode 100644 index 00000000..324c3d1f --- /dev/null +++ b/tests/501-1000/878. nth-magical-number/sol.cs @@ -0,0 +1,28 @@ +public class Solution { + public int NthMagicalNumber(int n, int a, int b) { + const int mod = 1000000007; + int g = Gcd(a, b); + long lcm = (long) a / g * b; + long lo = Math.Min(a, b); + long hi = (long) n * lo; + while (lo < hi) { + long mid = (lo + hi) >> 1; + long cnt = mid / a + mid / b - mid / lcm; + if (cnt < n) { + lo = mid + 1; + } else { + hi = mid; + } + } + return (int) (lo % mod); + } + + private int Gcd(int x, int y) { + while (y != 0) { + int t = y; + y = x % y; + x = t; + } + return x; + } +} diff --git a/tests/501-1000/878. nth-magical-number/sol.dart b/tests/501-1000/878. nth-magical-number/sol.dart new file mode 100644 index 00000000..30c98c9a --- /dev/null +++ b/tests/501-1000/878. nth-magical-number/sol.dart @@ -0,0 +1,28 @@ +class Solution { + int nthMagicalNumber(int n, int a, int b) { + const int mod = 1000000007; + int g = _gcd(a, b); + int lcm = a ~/ g * b; + int lo = a < b ? a : b; + int hi = n * lo; + while (lo < hi) { + int mid = (lo + hi) >> 1; + int cnt = mid ~/ a + mid ~/ b - mid ~/ lcm; + if (cnt < n) { + lo = mid + 1; + } else { + hi = mid; + } + } + return lo % mod; + } + + int _gcd(int x, int y) { + while (y != 0) { + int t = y; + y = x % y; + x = t; + } + return x; + } +} diff --git a/tests/501-1000/878. nth-magical-number/sol.go b/tests/501-1000/878. nth-magical-number/sol.go new file mode 100644 index 00000000..45a714f7 --- /dev/null +++ b/tests/501-1000/878. nth-magical-number/sol.go @@ -0,0 +1,31 @@ +func nthMagicalNumber(n int, a int, b int) int { + mod := 1000000007 + g := gcd(a, b) + lcm := a / g * b + lo := min(a, b) + hi := n * lo + for lo < hi { + mid := (lo + hi) >> 1 + cnt := mid/a + mid/b - mid/lcm + if cnt < n { + lo = mid + 1 + } else { + hi = mid + } + } + return lo % mod +} + +func gcd(x, y int) int { + for y != 0 { + x, y = y, x%y + } + return x +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/tests/501-1000/878. nth-magical-number/sol.java b/tests/501-1000/878. nth-magical-number/sol.java new file mode 100644 index 00000000..ebf47638 --- /dev/null +++ b/tests/501-1000/878. nth-magical-number/sol.java @@ -0,0 +1,28 @@ +class Solution { + public int nthMagicalNumber(int n, int a, int b) { + int MOD = 1000000007; + int g = gcd(a, b); + long lcm = (long) a / g * b; + long lo = Math.min(a, b); + long hi = n * lo; + while (lo < hi) { + long mid = (lo + hi) >> 1; + long cnt = mid / a + mid / b - mid / lcm; + if (cnt < n) { + lo = mid + 1; + } else { + hi = mid; + } + } + return (int) (lo % MOD); + } + + private int gcd(int x, int y) { + while (y != 0) { + int t = y; + y = x % y; + x = t; + } + return x; + } +} diff --git a/tests/501-1000/878. nth-magical-number/sol.kt b/tests/501-1000/878. nth-magical-number/sol.kt new file mode 100644 index 00000000..3e8c5102 --- /dev/null +++ b/tests/501-1000/878. nth-magical-number/sol.kt @@ -0,0 +1,30 @@ +class Solution { + fun nthMagicalNumber(n: Int, a: Int, b: Int): Int { + val MOD = 1000000007 + val g = gcd(a, b) + val lcm = a.toLong() / g * b + var lo = minOf(a, b).toLong() + var hi = n.toLong() * lo + while (lo < hi) { + val mid = (lo + hi) shr 1 + val cnt = mid / a + mid / b - mid / lcm + if (cnt < n) { + lo = mid + 1 + } else { + hi = mid + } + } + return (lo % MOD).toInt() + } + + private fun gcd(x: Int, y: Int): Int { + var a = x + var b = y + while (b != 0) { + val t = b + b = a % b + a = t + } + return a + } +} diff --git a/tests/501-1000/878. nth-magical-number/sol.py b/tests/501-1000/878. nth-magical-number/sol.py new file mode 100644 index 00000000..6df1eccc --- /dev/null +++ b/tests/501-1000/878. nth-magical-number/sol.py @@ -0,0 +1,25 @@ +from math import gcd + + +class Solution: + def nthMagicalNumber(self, n: int, a: int, b: int) -> int: + MOD = 1000000007 + + g = gcd(a, b) + lcm = a // g * b + + lo, hi = min(a, b), n * min(a, b) + + while lo < hi: + mid = (lo + hi) >> 1 + + cnt = mid // a + cnt += mid // b + cnt -= mid // lcm + + if cnt < n: + lo = mid + 1 + else: + hi = mid + + return lo % MOD diff --git a/tests/501-1000/878. nth-magical-number/sol.py2 b/tests/501-1000/878. nth-magical-number/sol.py2 new file mode 100644 index 00000000..009f973b --- /dev/null +++ b/tests/501-1000/878. nth-magical-number/sol.py2 @@ -0,0 +1,25 @@ +class Solution(object): + def nthMagicalNumber(self, n, a, b): + """ + :type n: int + :type a: int + :type b: int + :rtype: int + """ + MOD = 1000000007 + g = self._gcd(a, b) + lcm = a // g * b + lo, hi = min(a, b), n * min(a, b) + while lo < hi: + mid = (lo + hi) >> 1 + cnt = mid // a + mid // b - mid // lcm + if cnt < n: + lo = mid + 1 + else: + hi = mid + return lo % MOD + + def _gcd(self, x, y): + while y: + x, y = y, x % y + return x diff --git a/tests/501-1000/878. nth-magical-number/sol.rb b/tests/501-1000/878. nth-magical-number/sol.rb new file mode 100644 index 00000000..eeb18e44 --- /dev/null +++ b/tests/501-1000/878. nth-magical-number/sol.rb @@ -0,0 +1,21 @@ +# @param {Integer} n +# @param {Integer} a +# @param {Integer} b +# @return {Integer} +def nth_magical_number(n, a, b) + mod = 1000000007 + g = a.gcd(b) + lcm = a / g * b + lo = [a, b].min + hi = n * lo + while lo < hi + mid = (lo + hi) >> 1 + cnt = mid / a + mid / b - mid / lcm + if cnt < n + lo = mid + 1 + else + hi = mid + end + end + lo % mod +end diff --git a/tests/501-1000/878. nth-magical-number/sol.rs b/tests/501-1000/878. nth-magical-number/sol.rs new file mode 100644 index 00000000..1e131ddf --- /dev/null +++ b/tests/501-1000/878. nth-magical-number/sol.rs @@ -0,0 +1,31 @@ +impl Solution { + pub fn nth_magical_number(n: i32, a: i32, b: i32) -> i32 { + let modulo: i64 = 1_000_000_007; + let a = a as i64; + let b = b as i64; + let n = n as i64; + let g = Self::gcd(a, b); + let lcm = a / g * b; + let mut lo = a.min(b); + let mut hi = n * lo; + while lo < hi { + let mid = (lo + hi) >> 1; + let cnt = mid / a + mid / b - mid / lcm; + if cnt < n { + lo = mid + 1; + } else { + hi = mid; + } + } + (lo % modulo) as i32 + } + + fn gcd(mut x: i64, mut y: i64) -> i64 { + while y != 0 { + let t = y; + y = x % y; + x = t; + } + x + } +} diff --git a/tests/501-1000/878. nth-magical-number/sol.swift b/tests/501-1000/878. nth-magical-number/sol.swift new file mode 100644 index 00000000..f6ccdd1b --- /dev/null +++ b/tests/501-1000/878. nth-magical-number/sol.swift @@ -0,0 +1,30 @@ +class Solution { + func nthMagicalNumber(_ n: Int, _ a: Int, _ b: Int) -> Int { + let mod = 1000000007 + let g = gcd(a, b) + let lcm = a / g * b + var lo = min(a, b) + var hi = n * lo + while lo < hi { + let mid = (lo + hi) >> 1 + let cnt = mid / a + mid / b - mid / lcm + if cnt < n { + lo = mid + 1 + } else { + hi = mid + } + } + return lo % mod + } + + private func gcd(_ x: Int, _ y: Int) -> Int { + var a = x + var b = y + while b != 0 { + let t = b + b = a % b + a = t + } + return a + } +} diff --git a/tests/501-1000/878. nth-magical-number/sol.ts b/tests/501-1000/878. nth-magical-number/sol.ts new file mode 100644 index 00000000..6db6082d --- /dev/null +++ b/tests/501-1000/878. nth-magical-number/sol.ts @@ -0,0 +1,25 @@ +function nthMagicalNumber(n: number, a: number, b: number): number { + const mod = 1000000007; + const g = gcd(a, b); + const lcm = Math.floor(a / g) * b; + let lo = Math.min(a, b); + let hi = n * lo; + while (lo < hi) { + const mid = Math.floor((lo + hi) / 2); + const cnt = + Math.floor(mid / a) + Math.floor(mid / b) - Math.floor(mid / lcm); + if (cnt < n) { + lo = mid + 1; + } else { + hi = mid; + } + } + return lo % mod; + + function gcd(x: number, y: number): number { + while (y !== 0) { + [x, y] = [y, x % y]; + } + return x; + } +} diff --git a/tests/501-1000/879. profitable-schemes/manifest.yaml b/tests/501-1000/879. profitable-schemes/manifest.yaml new file mode 100644 index 00000000..c5d79f6a --- /dev/null +++ b/tests/501-1000/879. profitable-schemes/manifest.yaml @@ -0,0 +1,295 @@ +entry: + id: 879 + title: "profitable-schemes" + params: + n: + type: int + minProfit: + type: int + group: + type: array + items: + type: int + profit: + type: array + items: + type: int + call: + cpp: "Solution().profitableSchemes({n}, {minProfit}, {group}, {profit})" + rust: "Solution::profitable_schemes({n}, {minProfit}, {group}, {profit})" + python3: "Solution().profitableSchemes({n}, {minProfit}, {group}, {profit})" + python2: "Solution().profitableSchemes({n}, {minProfit}, {group}, {profit})" + ruby: "profitable_schemes({n}, {minProfit}, {group}, {profit})" + java: "new Solution().profitableSchemes({n}, {minProfit}, {group}, {profit})" + csharp: "new Solution().ProfitableSchemes({n}, {minProfit}, {group}, {profit})" + kotlin: "Solution().profitableSchemes({n}, {minProfit}, {group}, {profit})" + go: "profitableSchemes({n}, {minProfit}, {group}, {profit})" + dart: "Solution().profitableSchemes({n}, {minProfit}, {group}, {profit})" + swift: "Solution().profitableSchemes({n}, {minProfit}, {group}, {profit})" + typescript: "profitableSchemes({n}, {minProfit}, {group}, {profit})" +judge: + type: "exact" +limits: + time_ms: 200 + memory_mb: 300 +oracle: + python3: + call: "Checker().check({result})" + checker: | + class Checker: + def check(self, result): + return True +seed: 879 +tests: + - name: "t01" + in: + n: 5 + minProfit: 3 + group: [2, 2] + profit: [2, 3] + out: 2 + - name: "t02" + in: + n: 10 + minProfit: 5 + group: [2, 3, 5] + profit: [6, 7, 8] + out: 7 + - name: "t03" + in: + n: 1 + minProfit: 0 + group: [1] + profit: [0] + out: 2 + - name: "t04" + in: + n: 1 + minProfit: 1 + group: [1] + profit: [1] + out: 1 + - name: "t05" + in: + n: 2 + minProfit: 1 + group: [1, 1] + profit: [1, 0] + out: 2 + - name: "t06" + in: + n: 3 + minProfit: 2 + group: [2, 2, 2] + profit: [1, 1, 1] + out: 0 + - name: "t07" + in: + n: 5 + minProfit: 3 + group: [2, 2, 1] + profit: [2, 2, 1] + out: 4 + - name: "t08" + in: + n: 5 + minProfit: 0 + group: [1, 2, 3] + profit: [0, 0, 0] + out: 7 + - name: "t09" + in: + n: 10 + minProfit: 10 + group: [2, 3, 5] + profit: [2, 3, 5] + out: 1 + - name: "t10" + in: + n: 6 + minProfit: 4 + group: [2, 2, 2, 2] + profit: [1, 2, 3, 4] + out: 10 + - name: "t11" + in: + n: 100 + minProfit: 100 + group: [100, 100, 100, 100, 100] + profit: [100, 100, 100, 100, 100] + out: 5 + - name: "t12" + in: + n: 8 + minProfit: 3 + group: [2, 3, 5] + profit: [1, 2, 3] + out: 4 + - name: "t13" + in: + n: 7 + minProfit: 2 + group: [2, 2, 2] + profit: [2, 2, 2] + out: 7 + - name: "t14" + in: + n: 9 + minProfit: 4 + group: [2, 2, 3, 3] + profit: [1, 2, 3, 4] + out: 10 + - name: "t15" + in: + n: 10 + minProfit: 0 + group: [2, 2, 2, 2] + profit: [1, 1, 1, 1] + out: 16 + - name: "t16" + in: + n: 10 + minProfit: 6 + group: [2, 2, 3, 3] + profit: [3, 3, 3, 3] + out: 11 + - name: "t17" + in: + n: 12 + minProfit: 7 + group: [3, 3, 4, 4] + profit: [2, 3, 4, 5] + out: 8 + - name: "t18" + in: + n: 15 + minProfit: 8 + group: [5, 5, 5] + profit: [2, 3, 4] + out: 1 + - name: "t19" + in: + n: 20 + minProfit: 9 + group: [2, 4, 6, 8] + profit: [1, 2, 3, 4] + out: 2 + - name: "t20" + in: + n: 20 + minProfit: 1 + group: [10, 10, 10] + profit: [0, 1, 2] + out: 5 + - name: "t21" + in: + n: 50 + minProfit: 25 + group: [5, 10, 15, 20, 25] + profit: [5, 10, 15, 20, 25] + out: 18 + - name: "t22" + in: + n: 30 + minProfit: 12 + group: [3, 6, 9, 12] + profit: [1, 2, 3, 4] + out: 0 + - name: "t23" + in: + n: 18 + minProfit: 6 + group: [2, 3, 4, 5] + profit: [2, 2, 2, 2] + out: 5 + - name: "t24" + in: + n: 25 + minProfit: 10 + group: [1, 2, 3, 4, 5] + profit: [1, 1, 1, 1, 1] + out: 0 + - name: "t25" + in: + n: 40 + minProfit: 18 + group: [4, 4, 4, 4, 4] + profit: [4, 4, 4, 4, 4] + out: 1 + - name: "t26" + in: + n: 100 + minProfit: 0 + group: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] + profit: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + out: 1048576 + - name: "t27" + in: + n: 100 + minProfit: 50 + group: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] + profit: [5, 5, 5, 5, 5, 5, 5, 5, 5, 5] + out: 1 + - name: "t28" + in: + n: 100 + minProfit: 100 + group: [1, 1, 1, 1, 1, 1, 1, 1] + profit: [100, 100, 100, 100, 100, 100, 100, 100] + out: 255 + - name: "t29" + in: + n: 80 + minProfit: 30 + group: [2, 3, 5, 7, 11] + profit: [1, 2, 3, 4, 5] + out: 0 + - name: "t30" + in: + n: 90 + minProfit: 45 + group: [10, 20, 30, 40, 50] + profit: [5, 10, 15, 20, 25] + out: 3 + - name: "t31" + in: + n: 60 + minProfit: 20 + group: [6, 6, 6, 6, 6, 6] + profit: [2, 4, 6, 8, 10, 12] + out: 37 + - name: "t32" + in: + n: 70 + minProfit: 35 + group: [7, 8, 9, 10, 11] + profit: [7, 8, 9, 10, 11] + out: 5 + - name: "t33" + in: + n: 12 + minProfit: 0 + group: [2, 3, 4] + profit: [1, 2, 3] + out: 8 + - name: "t34" + in: + n: 11 + minProfit: 5 + group: [2, 2, 2, 2, 2] + profit: [1, 2, 3, 4, 5] + out: 25 + - name: "t35" + in: + n: 9 + minProfit: 7 + group: [3, 3, 3] + profit: [2, 2, 2] + out: 0 + - name: "t36" + in: + n: 100 + minProfit: 1 + group: [100] + profit: [1] + out: 1 diff --git a/tests/501-1000/879. profitable-schemes/sol.cpp b/tests/501-1000/879. profitable-schemes/sol.cpp new file mode 100644 index 00000000..91ce31d9 --- /dev/null +++ b/tests/501-1000/879. profitable-schemes/sol.cpp @@ -0,0 +1,23 @@ +class Solution { +public: + int profitableSchemes(int n, int minProfit, vector& group, vector& profit) { + const int mod = 1e9 + 7; + vector> dp(n + 1, vector(minProfit + 1, 0)); + dp[0][0] = 1; + for (int k = 1; k <= group.size(); k++) { + int g = group[k - 1]; + int p = profit[k - 1]; + for (int i = n; i >= g; i--) { + for (int j = minProfit; j >= 0; j--) { + int prev = j - p >= 0 ? dp[i - g][j - p] : dp[i - g][0]; + dp[i][j] = (dp[i][j] + prev) % mod; + } + } + } + int ans = 0; + for (int i = 0; i <= n; i++) { + ans = (ans + dp[i][minProfit]) % mod; + } + return ans; + } +}; diff --git a/tests/501-1000/879. profitable-schemes/sol.cs b/tests/501-1000/879. profitable-schemes/sol.cs new file mode 100644 index 00000000..00eaf794 --- /dev/null +++ b/tests/501-1000/879. profitable-schemes/sol.cs @@ -0,0 +1,22 @@ +public class Solution { + public int ProfitableSchemes(int n, int minProfit, int[] group, int[] profit) { + int mod = (int)1e9 + 7; + int[,] dp = new int[n + 1, minProfit + 1]; + dp[0, 0] = 1; + for (int k = 1; k <= group.Length; k++) { + int g = group[k - 1]; + int p = profit[k - 1]; + for (int i = n; i >= g; i--) { + for (int j = minProfit; j >= 0; j--) { + int prev = j - p >= 0 ? dp[i - g, j - p] : dp[i - g, 0]; + dp[i, j] = (dp[i, j] + prev) % mod; + } + } + } + int ans = 0; + for (int i = 0; i <= n; i++) { + ans = (ans + dp[i, minProfit]) % mod; + } + return ans; + } +} diff --git a/tests/501-1000/879. profitable-schemes/sol.dart b/tests/501-1000/879. profitable-schemes/sol.dart new file mode 100644 index 00000000..a21ed417 --- /dev/null +++ b/tests/501-1000/879. profitable-schemes/sol.dart @@ -0,0 +1,22 @@ +class Solution { + int profitableSchemes(int n, int minProfit, List group, List profit) { + const int mod = 1000000007; + List> dp = List.generate(n + 1, (_) => List.filled(minProfit + 1, 0)); + dp[0][0] = 1; + for (int k = 1; k <= group.length; k++) { + int g = group[k - 1]; + int p = profit[k - 1]; + for (int i = n; i >= g; i--) { + for (int j = minProfit; j >= 0; j--) { + int prev = j - p >= 0 ? dp[i - g][j - p] : dp[i - g][0]; + dp[i][j] = (dp[i][j] + prev) % mod; + } + } + } + int ans = 0; + for (int i = 0; i <= n; i++) { + ans = (ans + dp[i][minProfit]) % mod; + } + return ans; + } +} diff --git a/tests/501-1000/879. profitable-schemes/sol.go b/tests/501-1000/879. profitable-schemes/sol.go new file mode 100644 index 00000000..b37e6913 --- /dev/null +++ b/tests/501-1000/879. profitable-schemes/sol.go @@ -0,0 +1,28 @@ +func profitableSchemes(n int, minProfit int, group []int, profit []int) int { + const mod = 1_000_000_007 + dp := make([][]int, n+1) + for i := range dp { + dp[i] = make([]int, minProfit+1) + } + dp[0][0] = 1 + for k := 1; k <= len(group); k++ { + g := group[k-1] + p := profit[k-1] + for i := n; i >= g; i-- { + for j := minProfit; j >= 0; j-- { + prev := 0 + if j-p >= 0 { + prev = dp[i-g][j-p] + } else { + prev = dp[i-g][0] + } + dp[i][j] = (dp[i][j] + prev) % mod + } + } + } + ans := 0 + for i := 0; i <= n; i++ { + ans = (ans + dp[i][minProfit]) % mod + } + return ans +} diff --git a/tests/501-1000/879. profitable-schemes/sol.java b/tests/501-1000/879. profitable-schemes/sol.java new file mode 100644 index 00000000..acb5df2a --- /dev/null +++ b/tests/501-1000/879. profitable-schemes/sol.java @@ -0,0 +1,21 @@ +class Solution { + public int profitableSchemes(int n, int minProfit, int[] group, int[] profit) { + int mod = (int)1e9 + 7; + int[][] dp = new int[n + 1][minProfit + 1]; + dp[0][0] = 1; + for (int k = 1; k <= group.length; k++) { + int g = group[k - 1]; + int p = profit[k - 1]; + for (int i = n; i >= g; i--) { + for (int j = minProfit; j >= 0; j--) { + dp[i][j] = (dp[i][j] + dp[i - g][Math.max(0, j - p)]) % mod; + } + } + } + int ans = 0; + for (int i = 0; i <= n; i++) { + ans = (ans + dp[i][minProfit]) % mod; + } + return ans; + } +} diff --git a/tests/501-1000/879. profitable-schemes/sol.kt b/tests/501-1000/879. profitable-schemes/sol.kt new file mode 100644 index 00000000..367c3539 --- /dev/null +++ b/tests/501-1000/879. profitable-schemes/sol.kt @@ -0,0 +1,21 @@ +class Solution { + fun profitableSchemes(n: Int, minProfit: Int, group: IntArray, profit: IntArray): Int { + val mod = 1_000_000_007 + val dp = Array(n + 1) { IntArray(minProfit + 1) } + dp[0][0] = 1 + for (k in 1..group.size) { + val g = group[k - 1] + val p = profit[k - 1] + for (i in n downTo g) { + for (j in minProfit downTo 0) { + dp[i][j] = (dp[i][j] + dp[i - g][maxOf(0, j - p)]) % mod + } + } + } + var ans = 0 + for (i in 0..n) { + ans = (ans + dp[i][minProfit]) % mod + } + return ans + } +} diff --git a/tests/501-1000/879. profitable-schemes/sol.py b/tests/501-1000/879. profitable-schemes/sol.py new file mode 100644 index 00000000..48f400fa --- /dev/null +++ b/tests/501-1000/879. profitable-schemes/sol.py @@ -0,0 +1,14 @@ +class Solution: + def profitableSchemes( + self, n: int, minProfit: int, group: List[int], profit: List[int] + ) -> int: + mod = int(1e9) + 7 + dp = [[0] * (minProfit + 1) for _ in range(n + 1)] + dp[0][0] = 1 + for k in range(1, len(group) + 1): + g = group[k - 1] + p = profit[k - 1] + for i in range(n, g - 1, -1): + for j in range(minProfit, -1, -1): + dp[i][j] = (dp[i][j] + dp[i - g][max(0, j - p)]) % mod + return sum(dp[i][minProfit] for i in range(n + 1)) % mod diff --git a/tests/501-1000/879. profitable-schemes/sol.py2 b/tests/501-1000/879. profitable-schemes/sol.py2 new file mode 100644 index 00000000..aaf92bc8 --- /dev/null +++ b/tests/501-1000/879. profitable-schemes/sol.py2 @@ -0,0 +1,19 @@ +class Solution(object): + def profitableSchemes(self, n, minProfit, group, profit): + """ + :type n: int + :type minProfit: int + :type group: List[int] + :type profit: List[int] + :rtype: int + """ + mod = int(1e9) + 7 + dp = [[0] * (minProfit + 1) for _ in range(n + 1)] + dp[0][0] = 1 + for k in range(1, len(group) + 1): + g = group[k - 1] + p = profit[k - 1] + for i in range(n, g - 1, -1): + for j in range(minProfit, -1, -1): + dp[i][j] = (dp[i][j] + dp[i - g][max(0, j - p)]) % mod + return sum(dp[i][minProfit] for i in range(n + 1)) % mod diff --git a/tests/501-1000/879. profitable-schemes/sol.rb b/tests/501-1000/879. profitable-schemes/sol.rb new file mode 100644 index 00000000..c96d045c --- /dev/null +++ b/tests/501-1000/879. profitable-schemes/sol.rb @@ -0,0 +1,20 @@ +# @param {Integer} n +# @param {Integer} min_profit +# @param {Integer[]} group +# @param {Integer[]} profit +# @return {Integer} +def profitable_schemes(n, min_profit, group, profit) + mod = 10**9 + 7 + dp = Array.new(n + 1) { Array.new(min_profit + 1, 0) } + dp[0][0] = 1 + (1..group.length).each do |k| + g = group[k - 1] + p = profit[k - 1] + (n).downto(g) do |i| + (min_profit).downto(0) do |j| + dp[i][j] = (dp[i][j] + dp[i - g][[0, j - p].max]) % mod + end + end + end + (0..n).sum { |i| dp[i][min_profit] } % mod +end diff --git a/tests/501-1000/879. profitable-schemes/sol.rs b/tests/501-1000/879. profitable-schemes/sol.rs new file mode 100644 index 00000000..1e100107 --- /dev/null +++ b/tests/501-1000/879. profitable-schemes/sol.rs @@ -0,0 +1,24 @@ +impl Solution { + pub fn profitable_schemes(n: i32, min_profit: i32, group: Vec, profit: Vec) -> i32 { + let mod_val = 1_000_000_007; + let n = n as usize; + let min_profit = min_profit as usize; + let mut dp = vec![vec![0; min_profit + 1]; n + 1]; + dp[0][0] = 1; + for k in 1..=group.len() { + let g = group[k - 1] as usize; + let p = profit[k - 1] as usize; + for i in (g..=n).rev() { + for j in (0..=min_profit).rev() { + let prev = if j >= p { dp[i - g][j - p] } else { dp[i - g][0] }; + dp[i][j] = (dp[i][j] + prev) % mod_val; + } + } + } + let mut ans = 0; + for i in 0..=n { + ans = (ans + dp[i][min_profit]) % mod_val; + } + ans + } +} diff --git a/tests/501-1000/879. profitable-schemes/sol.swift b/tests/501-1000/879. profitable-schemes/sol.swift new file mode 100644 index 00000000..5b75cc10 --- /dev/null +++ b/tests/501-1000/879. profitable-schemes/sol.swift @@ -0,0 +1,22 @@ +class Solution { + func profitableSchemes(_ n: Int, _ minProfit: Int, _ group: [Int], _ profit: [Int]) -> Int { + let mod = 1_000_000_007 + var dp = Array(repeating: Array(repeating: 0, count: minProfit + 1), count: n + 1) + dp[0][0] = 1 + for k in 1...group.count { + let g = group[k - 1] + let p = profit[k - 1] + for i in stride(from: n, through: g, by: -1) { + for j in stride(from: minProfit, through: 0, by: -1) { + let prev = j - p >= 0 ? dp[i - g][j - p] : dp[i - g][0] + dp[i][j] = (dp[i][j] + prev) % mod + } + } + } + var ans = 0 + for i in 0...n { + ans = (ans + dp[i][minProfit]) % mod + } + return ans + } +} diff --git a/tests/501-1000/879. profitable-schemes/sol.ts b/tests/501-1000/879. profitable-schemes/sol.ts new file mode 100644 index 00000000..164bdfa9 --- /dev/null +++ b/tests/501-1000/879. profitable-schemes/sol.ts @@ -0,0 +1,27 @@ +function profitableSchemes( + n: number, + minProfit: number, + group: number[], + profit: number[], +): number { + const mod = 1_000_000_007; + const dp: number[][] = Array.from({ length: n + 1 }, () => + new Array(minProfit + 1).fill(0), + ); + dp[0][0] = 1; + for (let k = 1; k <= group.length; k++) { + const g = group[k - 1]; + const p = profit[k - 1]; + for (let i = n; i >= g; i--) { + for (let j = minProfit; j >= 0; j--) { + const prev = j - p >= 0 ? dp[i - g][j - p] : dp[i - g][0]; + dp[i][j] = (dp[i][j] + prev) % mod; + } + } + } + let ans = 0; + for (let i = 0; i <= n; i++) { + ans = (ans + dp[i][minProfit]) % mod; + } + return ans; +} diff --git a/tests/501-1000/880. decoded-string-at-index/manifest.yaml b/tests/501-1000/880. decoded-string-at-index/manifest.yaml new file mode 100644 index 00000000..b576daed --- /dev/null +++ b/tests/501-1000/880. decoded-string-at-index/manifest.yaml @@ -0,0 +1,210 @@ +entry: + id: 880 + title: "decoded-string-at-index" + params: + s: + type: string + k: + type: int + call: + cpp: "Solution().decodeAtIndex({s}, {k})" + rust: "Solution::decode_at_index({s}, {k})" + python3: "Solution().decodeAtIndex({s}, {k})" + python2: "Solution().decodeAtIndex({s}, {k})" + ruby: "decode_at_index({s}, {k})" + java: "new Solution().decodeAtIndex({s}, {k})" + csharp: "new Solution().DecodeAtIndex({s}, {k})" + kotlin: "Solution().decodeAtIndex({s}, {k})" + go: "decodeAtIndex({s}, {k})" + dart: "Solution().decodeAtIndex({s}, {k})" + swift: "Solution().decodeAtIndex({s}, {k})" + typescript: "decodeAtIndex({s}, {k})" +judge: + type: "exact" +limits: + time_ms: 200 + memory_mb: 300 +oracle: + python3: + call: "Checker().check({result})" + checker: | + class Checker: + def check(self, result): + return True +seed: 880 +tests: + - name: "t01" + in: + s: "leet2code3" + k: 10 + out: "o" + - name: "t02" + in: + s: "ha22" + k: 5 + out: "h" + - name: "t03" + in: + s: "a2345678999999999999999" + k: 1 + out: "a" + - name: "t04" + in: + s: "a2" + k: 1 + out: "a" + - name: "t05" + in: + s: "ab2" + k: 3 + out: "a" + - name: "t06" + in: + s: "abc3" + k: 7 + out: "a" + - name: "t07" + in: + s: "vk6u5xhq9v" + k: 554 + out: "k" + - name: "t08" + in: + s: "y959q969u3hb22odq595" + k: 222280369 + out: "y" + - name: "t09" + in: + s: "z" + k: 1 + out: "z" + - name: "t10" + in: + s: "g4" + k: 4 + out: "g" + - name: "t11" + in: + s: "abc2def3" + k: 20 + out: "b" + - name: "t12" + in: + s: "x3y2" + k: 8 + out: "y" + - name: "t13" + in: + s: "l4e2t3" + k: 15 + out: "l" + - name: "t14" + in: + s: "a9" + k: 9 + out: "a" + - name: "t15" + in: + s: "b7c2" + k: 14 + out: "b" + - name: "t16" + in: + s: "q2w3e4r5" + k: 17 + out: "q" + - name: "t17" + in: + s: "m2n2o2" + k: 5 + out: "m" + - name: "t18" + in: + s: "t9" + k: 9 + out: "t" + - name: "t19" + in: + s: "p2q2r2s2" + k: 12 + out: "p" + - name: "t20" + in: + s: "d3c2b2a2" + k: 6 + out: "d" + - name: "t21" + in: + s: "abc2x2y2z2" + k: 30 + out: "y" + - name: "t22" + in: + s: "a3b3c3" + k: 16 + out: "a" + - name: "t23" + in: + s: "zz2" + k: 2 + out: "z" + - name: "t24" + in: + s: "az2" + k: 4 + out: "z" + - name: "t25" + in: + s: "x2y3z4" + k: 14 + out: "x" + - name: "t26" + in: + s: "abcde2" + k: 6 + out: "a" + - name: "t27" + in: + s: "abcde3f2" + k: 19 + out: "c" + - name: "t28" + in: + s: "h2i2j2k2" + k: 9 + out: "h" + - name: "t29" + in: + s: "r9s2" + k: 18 + out: "r" + - name: "t30" + in: + s: "u2v2w2" + k: 4 + out: "u" + - name: "t31" + in: + s: "abcdef2gh3" + k: 25 + out: "e" + - name: "t32" + in: + s: "j2k3l4" + k: 24 + out: "j" + - name: "t33" + in: + s: "mn2op3" + k: 11 + out: "o" + - name: "t34" + in: + s: "qrst2" + k: 8 + out: "t" + - name: "t35" + in: + s: "uvwx2yz3" + k: 13 + out: "w" diff --git a/tests/501-1000/880. decoded-string-at-index/sol.cpp b/tests/501-1000/880. decoded-string-at-index/sol.cpp new file mode 100644 index 00000000..23fe525c --- /dev/null +++ b/tests/501-1000/880. decoded-string-at-index/sol.cpp @@ -0,0 +1,27 @@ +class Solution { +public: + string decodeAtIndex(string s, int k) { + long long size = 0; + for (char ch : s) { + if (isdigit(ch)) { + size *= ch - '0'; + } else { + size++; + } + } + + for (int i = s.length() - 1; i >= 0; i--) { + char ch = s[i]; + k %= size; + if (k == 0 && isalpha(ch)) { + return string(1, ch); + } + if (isdigit(ch)) { + size /= ch - '0'; + } else { + size--; + } + } + return ""; + } +}; diff --git a/tests/501-1000/880. decoded-string-at-index/sol.cs b/tests/501-1000/880. decoded-string-at-index/sol.cs new file mode 100644 index 00000000..2dc8e98b --- /dev/null +++ b/tests/501-1000/880. decoded-string-at-index/sol.cs @@ -0,0 +1,27 @@ +public class Solution { + public string DecodeAtIndex(string s, int k) { + long size = 0; + foreach (char ch in s) { + if (char.IsDigit(ch)) { + size *= ch - '0'; + } else { + size++; + } + } + + long kk = k; + for (int i = s.Length - 1; i >= 0; i--) { + char ch = s[i]; + kk %= size; + if (kk == 0 && char.IsLetter(ch)) { + return ch.ToString(); + } + if (char.IsDigit(ch)) { + size /= ch - '0'; + } else { + size--; + } + } + return ""; + } +} diff --git a/tests/501-1000/880. decoded-string-at-index/sol.dart b/tests/501-1000/880. decoded-string-at-index/sol.dart new file mode 100644 index 00000000..e82982b9 --- /dev/null +++ b/tests/501-1000/880. decoded-string-at-index/sol.dart @@ -0,0 +1,27 @@ +class Solution { + String decodeAtIndex(String s, int k) { + int size = 0; + for (var ch in s.split('')) { + if (ch.codeUnitAt(0) >= 48 && ch.codeUnitAt(0) <= 57) { + size *= int.parse(ch); + } else { + size++; + } + } + + int kk = k; + for (int i = s.length - 1; i >= 0; i--) { + var ch = s[i]; + kk %= size; + if (kk == 0 && (ch.codeUnitAt(0) >= 65 && ch.codeUnitAt(0) <= 90 || ch.codeUnitAt(0) >= 97 && ch.codeUnitAt(0) <= 122)) { + return ch; + } + if (ch.codeUnitAt(0) >= 48 && ch.codeUnitAt(0) <= 57) { + size ~/= int.parse(ch); + } else { + size--; + } + } + return ""; + } +} diff --git a/tests/501-1000/880. decoded-string-at-index/sol.go b/tests/501-1000/880. decoded-string-at-index/sol.go new file mode 100644 index 00000000..1aea0f95 --- /dev/null +++ b/tests/501-1000/880. decoded-string-at-index/sol.go @@ -0,0 +1,25 @@ +func decodeAtIndex(s string, k int) string { + size := 0 + for _, ch := range s { + if ch >= '0' && ch <= '9' { + size *= int(ch - '0') + } else { + size++ + } + } + + kk := k + for i := len(s) - 1; i >= 0; i-- { + ch := s[i] + kk %= size + if kk == 0 && ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' { + return string(ch) + } + if ch >= '0' && ch <= '9' { + size /= int(ch - '0') + } else { + size-- + } + } + return "" +} diff --git a/tests/501-1000/880. decoded-string-at-index/sol.java b/tests/501-1000/880. decoded-string-at-index/sol.java new file mode 100644 index 00000000..c45b0f76 --- /dev/null +++ b/tests/501-1000/880. decoded-string-at-index/sol.java @@ -0,0 +1,26 @@ +class Solution { + public String decodeAtIndex(String s, int k) { + long size = 0; + for (char ch : s.toCharArray()) { + if (Character.isDigit(ch)) { + size *= ch - '0'; + } else { + size++; + } + } + + for (int i = s.length() - 1; i >= 0; i--) { + char ch = s.charAt(i); + k %= size; + if (k == 0 && Character.isLetter(ch)) { + return String.valueOf(ch); + } + if (Character.isDigit(ch)) { + size /= ch - '0'; + } else { + size--; + } + } + return ""; + } +} diff --git a/tests/501-1000/880. decoded-string-at-index/sol.kt b/tests/501-1000/880. decoded-string-at-index/sol.kt new file mode 100644 index 00000000..03ef37d0 --- /dev/null +++ b/tests/501-1000/880. decoded-string-at-index/sol.kt @@ -0,0 +1,27 @@ +class Solution { + fun decodeAtIndex(s: String, k: Int): String { + var size: Long = 0 + for (ch in s) { + if (ch.isDigit()) { + size *= ch - '0' + } else { + size++ + } + } + + var kk = k.toLong() + for (i in s.length - 1 downTo 0) { + val ch = s[i] + kk %= size + if (kk == 0L && ch.isLetter()) { + return ch.toString() + } + if (ch.isDigit()) { + size /= ch - '0' + } else { + size-- + } + } + return "" + } +} diff --git a/tests/501-1000/880. decoded-string-at-index/sol.py b/tests/501-1000/880. decoded-string-at-index/sol.py new file mode 100644 index 00000000..9a4706eb --- /dev/null +++ b/tests/501-1000/880. decoded-string-at-index/sol.py @@ -0,0 +1,22 @@ +class Solution(object): + def decodeAtIndex(self, s, k): + """ + :type s: str + :type k: int + :rtype: str + """ + size = 0 + for ch in s: + if ch.isdigit(): + size *= int(ch) + else: + size += 1 + + for ch in reversed(s): + k %= size + if k == 0 and ch.isalpha(): + return ch + if ch.isdigit(): + size //= int(ch) + else: + size -= 1 diff --git a/tests/501-1000/880. decoded-string-at-index/sol.py2 b/tests/501-1000/880. decoded-string-at-index/sol.py2 new file mode 100644 index 00000000..9a4706eb --- /dev/null +++ b/tests/501-1000/880. decoded-string-at-index/sol.py2 @@ -0,0 +1,22 @@ +class Solution(object): + def decodeAtIndex(self, s, k): + """ + :type s: str + :type k: int + :rtype: str + """ + size = 0 + for ch in s: + if ch.isdigit(): + size *= int(ch) + else: + size += 1 + + for ch in reversed(s): + k %= size + if k == 0 and ch.isalpha(): + return ch + if ch.isdigit(): + size //= int(ch) + else: + size -= 1 diff --git a/tests/501-1000/880. decoded-string-at-index/sol.rb b/tests/501-1000/880. decoded-string-at-index/sol.rb new file mode 100644 index 00000000..bbda179b --- /dev/null +++ b/tests/501-1000/880. decoded-string-at-index/sol.rb @@ -0,0 +1,25 @@ +# @param {String} s +# @param {Integer} k +# @return {String} +def decode_at_index(s, k) + size = 0 + s.each_char do |ch| + if ch =~ /[0-9]/ + size *= ch.to_i + else + size += 1 + end + end + + s.reverse.each_char do |ch| + k %= size + if k == 0 && ch =~ /[a-zA-Z]/ + return ch + end + if ch =~ /[0-9]/ + size /= ch.to_i + else + size -= 1 + end + end +end diff --git a/tests/501-1000/880. decoded-string-at-index/sol.rs b/tests/501-1000/880. decoded-string-at-index/sol.rs new file mode 100644 index 00000000..5cd27503 --- /dev/null +++ b/tests/501-1000/880. decoded-string-at-index/sol.rs @@ -0,0 +1,26 @@ +impl Solution { + pub fn decode_at_index(s: String, k: i32) -> String { + let mut size: i64 = 0; + for ch in s.chars() { + if ch.is_digit(10) { + size *= ch.to_digit(10).unwrap() as i64; + } else { + size += 1; + } + } + + let mut kk = k as i64; + for ch in s.chars().rev() { + kk %= size; + if kk == 0 && ch.is_alphabetic() { + return ch.to_string(); + } + if ch.is_digit(10) { + size /= ch.to_digit(10).unwrap() as i64; + } else { + size -= 1; + } + } + String::new() + } +} diff --git a/tests/501-1000/880. decoded-string-at-index/sol.swift b/tests/501-1000/880. decoded-string-at-index/sol.swift new file mode 100644 index 00000000..60509fb6 --- /dev/null +++ b/tests/501-1000/880. decoded-string-at-index/sol.swift @@ -0,0 +1,26 @@ +class Solution { + func decodeAtIndex(_ s: String, _ k: Int) -> String { + var size = 0 + for ch in s { + if ch.isNumber { + size *= Int(String(ch))! + } else { + size += 1 + } + } + + var kk = k + for ch in s.reversed() { + kk %= size + if kk == 0 && ch.isLetter { + return String(ch) + } + if ch.isNumber { + size /= Int(String(ch))! + } else { + size -= 1 + } + } + return "" + } +} diff --git a/tests/501-1000/880. decoded-string-at-index/sol.ts b/tests/501-1000/880. decoded-string-at-index/sol.ts new file mode 100644 index 00000000..e7a9728b --- /dev/null +++ b/tests/501-1000/880. decoded-string-at-index/sol.ts @@ -0,0 +1,24 @@ +function decodeAtIndex(s: string, k: number): string { + let size: number = 0; + for (const ch of s) { + if (ch >= "0" && ch <= "9") { + size *= parseInt(ch); + } else { + size++; + } + } + + for (let i = s.length - 1; i >= 0; i--) { + const ch = s[i]; + k %= size; + if ((k === 0 && ch >= "a" && ch <= "z") || (ch >= "A" && ch <= "Z")) { + return ch; + } + if (ch >= "0" && ch <= "9") { + size = Math.floor(size / parseInt(ch)); + } else { + size--; + } + } + return ""; +} diff --git a/tests/501-1000/881. boats-to-save-people/manifest.yaml b/tests/501-1000/881. boats-to-save-people/manifest.yaml new file mode 100644 index 00000000..724eb89b --- /dev/null +++ b/tests/501-1000/881. boats-to-save-people/manifest.yaml @@ -0,0 +1,217 @@ +entry: + id: 881 + title: "boats-to-save-people" + params: + people: + type: array + items: + type: int + limit: + type: int + call: + cpp: "Solution().numRescueBoats({people}, {limit})" + rust: "Solution::num_rescue_boats({people}, {limit})" + python3: "Solution().numRescueBoats({people}, {limit})" + python2: "Solution().numRescueBoats({people}, {limit})" + ruby: "num_rescue_boats({people}, {limit})" + java: "new Solution().numRescueBoats({people}, {limit})" + csharp: "new Solution().NumRescueBoats({people}, {limit})" + kotlin: "Solution().numRescueBoats({people}, {limit})" + go: "numRescueBoats({people}, {limit})" + dart: "Solution().numRescueBoats({people}, {limit})" + swift: "Solution().numRescueBoats({people}, {limit})" + typescript: "numRescueBoats({people}, {limit})" +judge: + type: "exact" +limits: + time_ms: 200 + memory_mb: 300 +oracle: + python3: + call: "Checker().check({result})" + checker: | + class Checker: + def check(self, result): + return True +seed: 881 +tests: + - name: "t01" + in: + people: [1, 2] + limit: 3 + out: 1 + - name: "t02" + in: + people: [3, 2, 2, 1] + limit: 3 + out: 3 + - name: "t03" + in: + people: [3, 5, 3, 4] + limit: 5 + out: 4 + - name: "t04" + in: + people: [1] + limit: 1 + out: 1 + - name: "t05" + in: + people: [2, 2, 2, 2] + limit: 3 + out: 4 + - name: "t06" + in: + people: [1, 1, 1, 1] + limit: 2 + out: 2 + - name: "t07" + in: + people: [5, 1, 4, 2] + limit: 6 + out: 2 + - name: "t08" + in: + people: [2, 3, 4, 5, 6] + limit: 7 + out: 3 + - name: "t09" + in: + people: [3, 8, 2, 1, 5, 4] + limit: 8 + out: 4 + - name: "t10" + in: + people: [1, 2, 2, 3, 4, 5, 6] + limit: 7 + out: 4 + - name: "t11" + in: + people: [9, 1, 8, 2, 7, 3, 6, 4, 5] + limit: 10 + out: 5 + - name: "t12" + in: + people: [30000, 30000, 30000, 30000, 30000, 30000] + limit: 30000 + out: 6 + - name: "t13" + in: + people: [1, 30000, 1, 30000] + limit: 30000 + out: 3 + - name: "t14" + in: + people: [100, 200, 150, 80, 70, 60] + limit: 250 + out: 4 + - name: "t15" + in: + people: [2, 2, 2, 1, 1, 1] + limit: 3 + out: 3 + - name: "t16" + in: + people: [4, 4, 4, 4, 4, 4] + limit: 4 + out: 6 + - name: "t17" + in: + people: [1, 2, 3, 4, 5, 6, 7, 8] + limit: 9 + out: 4 + - name: "t18" + in: + people: [10, 9, 8, 7, 6, 5, 4, 3] + limit: 11 + out: 5 + - name: "t19" + in: + people: [15, 1, 14, 2, 13, 3, 12, 4] + limit: 15 + out: 5 + - name: "t20" + in: + people: [30, 1, 29, 2, 28, 3, 27, 4] + limit: 30 + out: 5 + - name: "t21" + in: + people: [7, 7, 7, 7, 7] + limit: 7 + out: 5 + - name: "t22" + in: + people: [2, 4, 6, 8, 10, 12] + limit: 12 + out: 4 + - name: "t23" + in: + people: [1, 5, 1, 5, 1, 5] + limit: 6 + out: 3 + - name: "t24" + in: + people: [11, 20, 9, 12, 8, 13] + limit: 20 + out: 4 + - name: "t25" + in: + people: [50, 1, 49, 2, 48, 3] + limit: 50 + out: 4 + - name: "t26" + in: + people: [100, 100, 1, 1, 1, 1] + limit: 100 + out: 4 + - name: "t27" + in: + people: [3, 3, 3, 3, 3, 3, 3, 3] + limit: 6 + out: 4 + - name: "t28" + in: + people: [6, 5, 4, 3, 2, 1] + limit: 6 + out: 4 + - name: "t29" + in: + people: [17, 17, 1, 1, 17, 1] + limit: 17 + out: 5 + - name: "t30" + in: + people: [8, 2, 8, 2, 8, 2] + limit: 10 + out: 3 + - name: "t31" + in: + people: [30000, 1, 1, 1, 1] + limit: 30000 + out: 3 + - name: "t32" + in: + people: [1000, 2000, 3000, 4000] + limit: 5000 + out: 2 + - name: "t33" + in: + people: [14, 1, 13, 2, 12, 3, 11, 4, 10, 5] + limit: 15 + out: 5 + - name: "t34" + in: + people: [9, 9, 9, 1, 1, 1] + limit: 10 + out: 3 + - name: "t35" + in: + people: [5, 10, 15, 20, 25, 30] + limit: 30 + out: 4 + - name: "t36" + in: + people: [1, 2, 2, 3, 3, 4, 4, 5] + limit: 6 + out: 4 diff --git a/tests/501-1000/881. boats-to-save-people/sol.cpp b/tests/501-1000/881. boats-to-save-people/sol.cpp new file mode 100644 index 00000000..e2a2563e --- /dev/null +++ b/tests/501-1000/881. boats-to-save-people/sol.cpp @@ -0,0 +1,21 @@ +class Solution { +public: + int numRescueBoats(vector& people, int limit) { + sort(people.begin(), people.end()); + int start = 0; + int end = people.size() - 1; + int boats = 0; + + while (start <= end) { + if (people[start] + people[end] <= limit) { + start++; + end--; + } else { + end--; + } + boats++; + } + + return boats; + } +}; diff --git a/tests/501-1000/881. boats-to-save-people/sol.cs b/tests/501-1000/881. boats-to-save-people/sol.cs new file mode 100644 index 00000000..26196005 --- /dev/null +++ b/tests/501-1000/881. boats-to-save-people/sol.cs @@ -0,0 +1,20 @@ +public class Solution { + public int NumRescueBoats(int[] people, int limit) { + Array.Sort(people); + int start = 0; + int end = people.Length - 1; + int boats = 0; + + while (start <= end) { + if (people[start] + people[end] <= limit) { + start++; + end--; + } else { + end--; + } + boats++; + } + + return boats; + } +} diff --git a/tests/501-1000/881. boats-to-save-people/sol.dart b/tests/501-1000/881. boats-to-save-people/sol.dart new file mode 100644 index 00000000..0b1e249e --- /dev/null +++ b/tests/501-1000/881. boats-to-save-people/sol.dart @@ -0,0 +1,20 @@ +class Solution { + int numRescueBoats(List people, int limit) { + people.sort(); + int start = 0; + int end = people.length - 1; + int boats = 0; + + while (start <= end) { + if (people[start] + people[end] <= limit) { + start++; + end--; + } else { + end--; + } + boats++; + } + + return boats; + } +} diff --git a/tests/501-1000/881. boats-to-save-people/sol.go b/tests/501-1000/881. boats-to-save-people/sol.go new file mode 100644 index 00000000..bab54bc5 --- /dev/null +++ b/tests/501-1000/881. boats-to-save-people/sol.go @@ -0,0 +1,18 @@ +func numRescueBoats(people []int, limit int) int { + sort.Ints(people) + start := 0 + end := len(people) - 1 + boats := 0 + + for start <= end { + if people[start] + people[end] <= limit { + start++ + end-- + } else { + end-- + } + boats++ + } + + return boats +} diff --git a/tests/501-1000/881. boats-to-save-people/sol.java b/tests/501-1000/881. boats-to-save-people/sol.java new file mode 100644 index 00000000..b5d1b4b1 --- /dev/null +++ b/tests/501-1000/881. boats-to-save-people/sol.java @@ -0,0 +1,20 @@ +class Solution { + public int numRescueBoats(int[] people, int limit) { + Arrays.sort(people); + int start = 0; + int end = people.length - 1; + int boats = 0; + + while (start <= end) { + if (people[start] + people[end] <= limit) { + start++; + end--; + } else { + end--; + } + boats++; + } + + return boats; + } +} diff --git a/tests/501-1000/881. boats-to-save-people/sol.kt b/tests/501-1000/881. boats-to-save-people/sol.kt new file mode 100644 index 00000000..bc831627 --- /dev/null +++ b/tests/501-1000/881. boats-to-save-people/sol.kt @@ -0,0 +1,20 @@ +class Solution { + fun numRescueBoats(people: IntArray, limit: Int): Int { + people.sort() + var start = 0 + var end = people.size - 1 + var boats = 0 + + while (start <= end) { + if (people[start] + people[end] <= limit) { + start++ + end-- + } else { + end-- + } + boats++ + } + + return boats + } +} diff --git a/tests/501-1000/881. boats-to-save-people/sol.py b/tests/501-1000/881. boats-to-save-people/sol.py new file mode 100644 index 00000000..53423a90 --- /dev/null +++ b/tests/501-1000/881. boats-to-save-people/sol.py @@ -0,0 +1,19 @@ +class Solution: + def numRescueBoats(self, people, limit): + + people.sort() + + start = 0 + end = len(people) - 1 + boats = 0 + + while start <= end: + if people[start] + people[end] <= limit: + start += 1 + end -= 1 + else: + end -= 1 + + boats += 1 + + return boats diff --git a/tests/501-1000/881. boats-to-save-people/sol.py2 b/tests/501-1000/881. boats-to-save-people/sol.py2 new file mode 100644 index 00000000..4d3bd03a --- /dev/null +++ b/tests/501-1000/881. boats-to-save-people/sol.py2 @@ -0,0 +1,21 @@ +class Solution(object): + def numRescueBoats(self, people, limit): + """ + :type people: List[int] + :type limit: int + :rtype: int + """ + people.sort() + start = 0 + end = len(people) - 1 + boats = 0 + + while start <= end: + if people[start] + people[end] <= limit: + start += 1 + end -= 1 + else: + end -= 1 + boats += 1 + + return boats diff --git a/tests/501-1000/881. boats-to-save-people/sol.rb b/tests/501-1000/881. boats-to-save-people/sol.rb new file mode 100644 index 00000000..bd3af30a --- /dev/null +++ b/tests/501-1000/881. boats-to-save-people/sol.rb @@ -0,0 +1,21 @@ +# @param {Integer[]} people +# @param {Integer} limit +# @return {Integer} +def num_rescue_boats(people, limit) + people.sort! + start = 0 + end_index = people.length - 1 + boats = 0 + + while start <= end_index + if people[start] + people[end_index] <= limit + start += 1 + end_index -= 1 + else + end_index -= 1 + end + boats += 1 + end + + return boats +end diff --git a/tests/501-1000/881. boats-to-save-people/sol.rs b/tests/501-1000/881. boats-to-save-people/sol.rs new file mode 100644 index 00000000..63a07c98 --- /dev/null +++ b/tests/501-1000/881. boats-to-save-people/sol.rs @@ -0,0 +1,21 @@ +impl Solution { + pub fn num_rescue_boats(people: Vec, limit: i32) -> i32 { + let mut people = people; + people.sort(); + let mut start = 0; + let mut end = people.len() as i32 - 1; + let mut boats = 0; + + while start <= end { + if people[start as usize] + people[end as usize] <= limit { + start += 1; + end -= 1; + } else { + end -= 1; + } + boats += 1; + } + + boats + } +} diff --git a/tests/501-1000/881. boats-to-save-people/sol.swift b/tests/501-1000/881. boats-to-save-people/sol.swift new file mode 100644 index 00000000..0e3b0b6e --- /dev/null +++ b/tests/501-1000/881. boats-to-save-people/sol.swift @@ -0,0 +1,20 @@ +class Solution { + func numRescueBoats(_ people: [Int], _ limit: Int) -> Int { + var people = people.sorted() + var start = 0 + var end = people.count - 1 + var boats = 0 + + while start <= end { + if people[start] + people[end] <= limit { + start += 1 + end -= 1 + } else { + end -= 1 + } + boats += 1 + } + + return boats + } +} diff --git a/tests/501-1000/881. boats-to-save-people/sol.ts b/tests/501-1000/881. boats-to-save-people/sol.ts new file mode 100644 index 00000000..0f32ef0b --- /dev/null +++ b/tests/501-1000/881. boats-to-save-people/sol.ts @@ -0,0 +1,18 @@ +function numRescueBoats(people: number[], limit: number): number { + people.sort((a, b) => a - b); + let start = 0; + let end = people.length - 1; + let boats = 0; + + while (start <= end) { + if (people[start] + people[end] <= limit) { + start++; + end--; + } else { + end--; + } + boats++; + } + + return boats; +} diff --git a/tests/501-1000/882. reachable-nodes-in-subdivided-graph/manifest.yaml b/tests/501-1000/882. reachable-nodes-in-subdivided-graph/manifest.yaml new file mode 100644 index 00000000..ddf923dc --- /dev/null +++ b/tests/501-1000/882. reachable-nodes-in-subdivided-graph/manifest.yaml @@ -0,0 +1,381 @@ +entry: + id: 882 + title: reachable-nodes-in-subdivided-graph + params: + edges: + type: array + items: + type: array + items: + type: int + maxMoves: + type: int + n: + type: int + call: + cpp: "Solution().reachableNodes({edges}, {maxMoves}, {n})" + rust: "Solution::reachable_nodes({edges}, {maxMoves}, {n})" + python3: "Solution().reachableNodes({edges}, {maxMoves}, {n})" + python2: "Solution().reachableNodes({edges}, {maxMoves}, {n})" + ruby: "reachable_nodes({edges}, {maxMoves}, {n})" + java: "new Solution().reachableNodes({edges}, {maxMoves}, {n})" + csharp: "new Solution().ReachableNodes({edges}, {maxMoves}, {n})" + kotlin: "Solution().reachableNodes({edges}, {maxMoves}, {n})" + go: "reachableNodes({edges}, {maxMoves}, {n})" + dart: "Solution().reachableNodes({edges}, {maxMoves}, {n})" + swift: "Solution().reachableNodes({edges}, {maxMoves}, {n})" + typescript: "reachableNodes({edges}, {maxMoves}, {n})" +judge: + type: exact +limits: + time_ms: 2000 + memory_mb: 256 +oracle: + python3: + call: "Checker().reachableNodes(edges, maxMoves, n, {result})" + checker: | + from heapq import heappop, heappush + + class Checker: + def reachableNodes(self, edges, maxMoves, n, result): + graph = [[] for _ in range(n)] + dist = [maxMoves + 1] * n + for u, v, cnt in edges: + graph[u].append((v, cnt)) + graph[v].append((u, cnt)) + dist[0] = 0 + heap = [(0, 0)] + while heap: + d, u = heappop(heap) + if d != dist[u] or d >= maxMoves: + continue + for v, w in graph[u]: + nd = d + w + 1 + if nd < dist[v]: + dist[v] = nd + heappush(heap, (nd, v)) + reachable = sum(d <= maxMoves for d in dist) + sub = 0 + for u, v, cnt in edges: + a = 0 if dist[u] > maxMoves else min(maxMoves - dist[u], cnt) + b = 0 if dist[v] > maxMoves else min(maxMoves - dist[v], cnt) + sub += min(a + b, cnt) + return reachable + sub == result +seed: 882 +tests: + - name: ex1 + in: + edges: + - [0, 1, 10] + - [0, 2, 1] + - [1, 2, 2] + maxMoves: 6 + n: 3 + - name: ex2 + in: + edges: + - [0, 1, 4] + - [1, 2, 6] + - [0, 2, 8] + - [1, 3, 1] + maxMoves: 10 + n: 4 + - name: ex3 + in: + edges: + - [1, 2, 4] + - [1, 4, 5] + - [1, 3, 1] + - [2, 3, 4] + - [3, 4, 5] + maxMoves: 17 + n: 5 + - name: isolated + in: + edges: [] + maxMoves: 0 + n: 1 + - name: one_edge_zero_subdivision + in: + edges: + - [0, 1, 0] + maxMoves: 0 + n: 2 + - name: one_edge_partial + in: + edges: + - [0, 1, 5] + maxMoves: 3 + n: 2 + - name: triangle_small_budget + in: + edges: + - [0, 1, 2] + - [1, 2, 2] + - [0, 2, 2] + maxMoves: 2 + n: 3 + - name: triangle_large_budget + in: + edges: + - [0, 1, 2] + - [1, 2, 2] + - [0, 2, 2] + maxMoves: 10 + n: 3 + - name: line_exact_reach + in: + edges: + - [0, 1, 3] + - [1, 2, 3] + maxMoves: 4 + n: 3 + - name: star_center + in: + edges: + - [0, 1, 4] + - [0, 2, 4] + - [0, 3, 4] + - [0, 4, 4] + maxMoves: 5 + n: 5 + - name: disconnected_source + in: + edges: + - [1, 2, 1] + - [2, 3, 1] + maxMoves: 7 + n: 4 + - name: direct_zero_edge_chain + in: + edges: + - [0, 1, 0] + - [1, 2, 0] + - [2, 3, 0] + maxMoves: 2 + n: 4 + - name: only_half_of_edge_reachable + in: + edges: + - [0, 1, 8] + maxMoves: 4 + n: 2 + - name: edge_reachable_from_both_sides + in: + edges: + - [0, 1, 4] + - [1, 2, 4] + maxMoves: 6 + n: 3 + - name: competing_paths + in: + edges: + - [0, 1, 5] + - [1, 3, 5] + - [0, 2, 2] + - [2, 3, 2] + maxMoves: 6 + n: 4 + - name: budget_exactly_hits_node + in: + edges: + - [0, 1, 2] + - [1, 2, 2] + - [2, 3, 2] + maxMoves: 3 + n: 4 + - name: budget_past_all_nodes + in: + edges: + - [0, 1, 1] + - [1, 2, 1] + - [2, 3, 1] + - [3, 4, 1] + maxMoves: 20 + n: 5 + - name: zero_budget_with_edges + in: + edges: + - [0, 1, 7] + - [0, 2, 3] + - [2, 3, 1] + maxMoves: 0 + n: 4 + - name: triangle_with_zero_and_nonzero + in: + edges: + - [0, 1, 0] + - [1, 2, 3] + - [0, 2, 1] + maxMoves: 2 + n: 3 + - name: square_perimeter + in: + edges: + - [0, 1, 2] + - [1, 2, 2] + - [2, 3, 2] + - [3, 0, 2] + maxMoves: 5 + n: 4 + - name: square_shortcut + in: + edges: + - [0, 1, 9] + - [1, 2, 9] + - [2, 3, 9] + - [0, 3, 1] + maxMoves: 3 + n: 4 + - name: duplicate_distance_tie + in: + edges: + - [0, 1, 3] + - [0, 2, 3] + - [1, 3, 1] + - [2, 3, 1] + maxMoves: 4 + n: 4 + - name: long_chain_small_budget + in: + edges: + - [0, 1, 10] + - [1, 2, 10] + - [2, 3, 10] + - [3, 4, 10] + - [4, 5, 10] + maxMoves: 1 + n: 6 + - name: long_chain_mid_budget + in: + edges: + - [0, 1, 10] + - [1, 2, 10] + - [2, 3, 10] + - [3, 4, 10] + - [4, 5, 10] + maxMoves: 23 + n: 6 + - name: star_zero_subdivisions + in: + edges: + - [0, 1, 0] + - [0, 2, 0] + - [0, 3, 0] + - [0, 4, 0] + - [0, 5, 0] + maxMoves: 1 + n: 6 + - name: source_blocked_by_long_edge + in: + edges: + - [0, 1, 10000] + - [1, 2, 0] + maxMoves: 3 + n: 3 + - name: large_cnt_split_across_ends + in: + edges: + - [0, 1, 10000] + - [1, 2, 10000] + maxMoves: 10000 + n: 3 + - name: complete_graph_small + in: + edges: + - [0, 1, 1] + - [0, 2, 2] + - [0, 3, 3] + - [1, 2, 4] + - [1, 3, 5] + - [2, 3, 6] + maxMoves: 7 + n: 4 + - name: no_edges_single_node + in: + edges: [] + maxMoves: 999 + n: 1 + - name: two_hops_with_dead_end + in: + edges: + - [0, 1, 1] + - [1, 2, 100] + - [2, 3, 1] + - [1, 4, 0] + maxMoves: 2 + n: 5 + - name: branch_and_merge + in: + edges: + - [0, 1, 2] + - [1, 2, 2] + - [0, 3, 2] + - [3, 2, 2] + maxMoves: 5 + n: 4 + - name: high_budget_medium_graph + in: + edges: + - [0, 1, 7] + - [0, 2, 5] + - [1, 3, 4] + - [2, 3, 6] + - [3, 4, 8] + - [4, 5, 1] + maxMoves: 30 + n: 6 + - name: asymmetrical_reach + in: + edges: + - [0, 1, 2] + - [1, 2, 9] + - [0, 3, 9] + - [3, 4, 1] + maxMoves: 4 + n: 5 + - name: budget_one_on_zero_cnt + in: + edges: + - [0, 1, 0] + - [1, 2, 5] + - [2, 3, 0] + maxMoves: 1 + n: 4 + - name: sparse_random_like_1 + in: + edges: + - [0, 2, 3] + - [2, 5, 1] + - [5, 7, 4] + - [1, 4, 2] + - [4, 6, 2] + maxMoves: 5 + n: 8 + - name: sparse_random_like_2 + in: + edges: + - [0, 1, 6] + - [1, 3, 1] + - [3, 4, 1] + - [0, 2, 6] + - [2, 4, 1] + maxMoves: 8 + n: 5 + - name: cycle_all_reachable + in: + edges: + - [0, 1, 1] + - [1, 2, 1] + - [2, 3, 1] + - [3, 0, 1] + maxMoves: 4 + n: 4 + - name: many_subnodes_one_edge + in: + edges: + - [0, 1, 10000] + - [0, 2, 0] + - [1, 2, 0] + maxMoves: 5000 + n: 3 diff --git a/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.cpp b/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.cpp new file mode 100644 index 00000000..aef1fe57 --- /dev/null +++ b/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.cpp @@ -0,0 +1,52 @@ +class Solution { +public: + int reachableNodes(vector>& edges, int maxMoves, int n) { + vector>> graph(n); + vector dist(n, maxMoves + 1); + + for (auto& edge : edges) { + int u = edge[0], v = edge[1], cnt = edge[2]; + graph[u].push_back({v, cnt}); + graph[v].push_back({u, cnt}); + } + + auto dijkstra = [&]() -> int { + dist[0] = 0; + priority_queue, vector>, greater<>> minHeap; + minHeap.push({0, 0}); + + while (!minHeap.empty()) { + auto [d, u] = minHeap.top(); + minHeap.pop(); + + if (dist[u] >= maxMoves) break; + + for (auto& [v, w] : graph[u]) { + int newDist = d + w + 1; + if (newDist < dist[v]) { + dist[v] = newDist; + minHeap.push({newDist, v}); + } + } + } + + int count = 0; + for (int d : dist) { + if (d <= maxMoves) count++; + } + return count; + }; + + int reachableNodes = dijkstra(); + int reachableSubnodes = 0; + + for (auto& edge : edges) { + int u = edge[0], v = edge[1], cnt = edge[2]; + int a = dist[u] > maxMoves ? 0 : min(maxMoves - dist[u], cnt); + int b = dist[v] > maxMoves ? 0 : min(maxMoves - dist[v], cnt); + reachableSubnodes += min(a + b, cnt); + } + + return reachableNodes + reachableSubnodes; + } +}; diff --git a/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.cs b/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.cs new file mode 100644 index 00000000..1b47bbd7 --- /dev/null +++ b/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.cs @@ -0,0 +1,59 @@ +public class Solution { + public int ReachableNodes(int[][] edges, int maxMoves, int n) { + var graph = new List<(int, int)>[n]; + for (int i = 0; i < n; i++) { + graph[i] = new List<(int, int)>(); + } + var dist = new int[n]; + Array.Fill(dist, maxMoves + 1); + + foreach (var edge in edges) { + int u = edge[0], v = edge[1], cnt = edge[2]; + graph[u].Add((v, cnt)); + graph[v].Add((u, cnt)); + } + + int Dijkstra() { + dist[0] = 0; + var minHeap = new SortedSet<(int, int)>(); + minHeap.Add((0, 0)); + + while (minHeap.Count > 0) { + var curr = minHeap.Min; + minHeap.Remove(curr); + int d = curr.Item1, u = curr.Item2; + + if (dist[u] >= maxMoves) break; + + foreach (var (v, w) in graph[u]) { + int newDist = d + w + 1; + if (newDist < dist[v]) { + if (dist[v] != maxMoves + 1) { + minHeap.Remove((dist[v], v)); + } + dist[v] = newDist; + minHeap.Add((newDist, v)); + } + } + } + + int count = 0; + foreach (int d in dist) { + if (d <= maxMoves) count++; + } + return count; + } + + int reachableNodes = Dijkstra(); + int reachableSubnodes = 0; + + foreach (var edge in edges) { + int u = edge[0], v = edge[1], cnt = edge[2]; + int a = dist[u] > maxMoves ? 0 : Math.Min(maxMoves - dist[u], cnt); + int b = dist[v] > maxMoves ? 0 : Math.Min(maxMoves - dist[v], cnt); + reachableSubnodes += Math.Min(a + b, cnt); + } + + return reachableNodes + reachableSubnodes; + } +} diff --git a/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.dart b/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.dart new file mode 100644 index 00000000..8230c269 --- /dev/null +++ b/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.dart @@ -0,0 +1,70 @@ +class Solution { + int reachableNodes(List> edges, int maxMoves, int n) { + var graph = List.generate(n, (_) => >[]); + var dist = List.filled(n, maxMoves + 1); + + for (var edge in edges) { + int u = edge[0], v = edge[1], cnt = edge[2]; + graph[u].add([v, cnt]); + graph[v].add([u, cnt]); + } + + int dijkstra() { + dist[0] = 0; + var minHeap = HeapPriorityQueue>((a, b) => a[0].compareTo(b[0])); + minHeap.add([0, 0]); + + while (minHeap.isNotEmpty) { + var curr = minHeap.removeFirst(); + int d = curr[0], u = curr[1]; + + if (dist[u] >= maxMoves) break; + + for (var neighbor in graph[u]) { + int v = neighbor[0], w = neighbor[1]; + int newDist = d + w + 1; + if (newDist < dist[v]) { + dist[v] = newDist; + minHeap.add([newDist, v]); + } + } + } + + return dist.where((d) => d <= maxMoves).length; + } + + int reachableNodes = dijkstra(); + int reachableSubnodes = 0; + + for (var edge in edges) { + int u = edge[0], v = edge[1], cnt = edge[2]; + int a = dist[u] > maxMoves ? 0 : min(maxMoves - dist[u], cnt); + int b = dist[v] > maxMoves ? 0 : min(maxMoves - dist[v], cnt); + reachableSubnodes += min(a + b, cnt); + } + + return reachableNodes + reachableSubnodes; + } + + int min(int a, int b) => a < b ? a : b; +} + +class HeapPriorityQueue { + final Comparator comparator; + final List _queue = []; + + HeapPriorityQueue(this.comparator); + + void add(E value) { + _queue.add(value); + _queue.sort(comparator); + } + + E removeFirst() { + return _queue.removeAt(0); + } + + bool get isNotEmpty => _queue.isNotEmpty; +} + +typedef Comparator = int Function(E a, E b); diff --git a/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.go b/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.go new file mode 100644 index 00000000..53f948a8 --- /dev/null +++ b/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.go @@ -0,0 +1,119 @@ +func reachableNodes(edges [][]int, maxMoves int, n int) int { + graph := make([][][]int, n) + for i := 0; i < n; i++ { + graph[i] = make([][]int, 0) + } + dist := make([]int, n) + for i := 0; i < n; i++ { + dist[i] = maxMoves + 1 + } + + for _, edge := range edges { + u, v, cnt := edge[0], edge[1], edge[2] + graph[u] = append(graph[u], []int{v, cnt}) + graph[v] = append(graph[v], []int{u, cnt}) + } + + dijkstra := func() int { + dist[0] = 0 + heap := &MinHeap{{0, 0}} + heap.Init() + + for heap.Len() > 0 { + curr := heap.Pop().([]int) + d, u := curr[0], curr[1] + + if d > dist[u] { + continue + } + if d > maxMoves { + continue + } + + for _, neighbor := range graph[u] { + v, w := neighbor[0], neighbor[1] + newDist := d + w + 1 + if newDist < dist[v] { + dist[v] = newDist + heap.Push([]int{newDist, v}) + } + } + } + + count := 0 + for _, d := range dist { + if d <= maxMoves { + count++ + } + } + return count + } + + reachableNodes := dijkstra() + reachableSubnodes := 0 + + for _, edge := range edges { + u, v, cnt := edge[0], edge[1], edge[2] + a := 0 + if dist[u] <= maxMoves { + a = min(maxMoves - dist[u], cnt) + } + b := 0 + if dist[v] <= maxMoves { + b = min(maxMoves - dist[v], cnt) + } + reachableSubnodes += min(a + b, cnt) + } + + return reachableNodes + reachableSubnodes +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} + +type MinHeap [][]int + +func (h MinHeap) Len() int { return len(h) } +func (h MinHeap) Less(i, j int) bool { return h[i][0] < h[j][0] } +func (h MinHeap) Swap(i, j int) { h[i], h[j] = h[j], h[i] } + +func (h *MinHeap) Push(x interface{}) { + *h = append(*h, x.([]int)) +} + +func (h *MinHeap) Pop() interface{} { + old := *h + n := len(old) + x := old[n-1] + *h = old[0 : n-1] + return x +} + +func (h *MinHeap) Init() { + n := h.Len() + for i := n/2 - 1; i >= 0; i-- { + h.down(i, n) + } +} + +func (h *MinHeap) down(i, n int) { + for { + j1 := 2*i + 1 + if j1 >= n { + break + } + j := j1 + if j2 := j1 + 1; j2 < n && h.Less(j2, j1) { + j = j2 + } + if h.Less(i, j) { + break + } + h.Swap(i, j) + i = j + } +} diff --git a/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.java b/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.java new file mode 100644 index 00000000..f3b2972c --- /dev/null +++ b/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.java @@ -0,0 +1,64 @@ +class Solution { + public int reachableNodes(int[][] edges, int maxMoves, int n) { + List> graph = new ArrayList<>(); + for (int i = 0; i < n; i++) { + graph.add(new ArrayList<>()); + } + int[] dist = new int[n]; + Arrays.fill(dist, Integer.MAX_VALUE / 2); + + for (int[] edge : edges) { + int u = edge[0], v = edge[1], cnt = edge[2]; + graph.get(u).add(new int[]{v, cnt}); + graph.get(v).add(new int[]{u, cnt}); + } + + int reachableNodes = dijkstra(graph, 0, maxMoves, dist); + int reachableSubnodes = 0; + + for (int[] edge : edges) { + int u = edge[0], v = edge[1], cnt = edge[2]; + int a = dist[u] > maxMoves ? 0 : Math.min(maxMoves - dist[u], cnt); + int b = dist[v] > maxMoves ? 0 : Math.min(maxMoves - dist[v], cnt); + reachableSubnodes += Math.min(a + b, cnt); + } + + return reachableNodes + reachableSubnodes; + } + + private int dijkstra(List> graph, int src, int maxMoves, int[] dist) { + dist[src] = 0; + ArrayDeque queue = new ArrayDeque<>(); + boolean[] inQueue = new boolean[dist.length]; + queue.add(src); + inQueue[src] = true; + + while (!queue.isEmpty()) { + int u = queue.poll(); + inQueue[u] = false; + int d = dist[u]; + + if (d > dist[u] || d > maxMoves) { + continue; + } + + for (int[] neighbor : graph.get(u)) { + int v = neighbor[0], w = neighbor[1]; + int newDist = d + w + 1; + if (newDist < dist[v]) { + dist[v] = newDist; + if (!inQueue[v]) { + queue.add(v); + inQueue[v] = true; + } + } + } + } + + int count = 0; + for (int d : dist) { + if (d <= maxMoves) count++; + } + return count; + } +} diff --git a/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.kt b/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.kt new file mode 100644 index 00000000..08804d4a --- /dev/null +++ b/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.kt @@ -0,0 +1,54 @@ +class Solution { + fun reachableNodes(edges: Array, maxMoves: Int, n: Int): Int { + val graph = Array(n) { mutableListOf() } + val dist = IntArray(n) { maxMoves + 1 } + + for (edge in edges) { + val u = edge[0] + val v = edge[1] + val cnt = edge[2] + graph[u].add(intArrayOf(v, cnt)) + graph[v].add(intArrayOf(u, cnt)) + } + + fun dijkstra(): Int { + dist[0] = 0 + val minHeap = PriorityQueue(compareBy { it[0] }) + minHeap.offer(intArrayOf(0, 0)) + + while (minHeap.isNotEmpty()) { + val curr = minHeap.poll() + val d = curr[0] + val u = curr[1] + + if (dist[u] >= maxMoves) break + + for (neighbor in graph[u]) { + val v = neighbor[0] + val w = neighbor[1] + val newDist = d + w + 1 + if (newDist < dist[v]) { + dist[v] = newDist + minHeap.offer(intArrayOf(newDist, v)) + } + } + } + + return dist.count { it <= maxMoves } + } + + val reachableNodes = dijkstra() + var reachableSubnodes = 0 + + for (edge in edges) { + val u = edge[0] + val v = edge[1] + val cnt = edge[2] + val a = if (dist[u] > maxMoves) 0 else minOf(maxMoves - dist[u], cnt) + val b = if (dist[v] > maxMoves) 0 else minOf(maxMoves - dist[v], cnt) + reachableSubnodes += minOf(a + b, cnt) + } + + return reachableNodes + reachableSubnodes + } +} diff --git a/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.py b/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.py new file mode 100644 index 00000000..59690e64 --- /dev/null +++ b/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.py @@ -0,0 +1,43 @@ +class Solution: + def reachableNodes(self, edges: List[List[int]], maxMoves: int, n: int) -> int: + graph = [[] for _ in range(n)] + dist = [maxMoves + 1] * n + + for u, v, cnt in edges: + graph[u].append((v, cnt)) + graph[v].append((u, cnt)) + + reachableNodes = self._dijkstra(graph, 0, maxMoves, dist) + reachableSubnodes = 0 + + for u, v, cnt in edges: + # the number of reachable nodes of (u, v) from `u` + a = 0 if dist[u] > maxMoves else min(maxMoves - dist[u], cnt) + # the number of reachable nodes of (u, v) from `v` + b = 0 if dist[v] > maxMoves else min(maxMoves - dist[v], cnt) + reachableSubnodes += min(a + b, cnt) + + return reachableNodes + reachableSubnodes + + def _dijkstra( + self, + graph: List[List[Tuple[int, int]]], + src: int, + maxMoves: int, + dist: List[int], + ) -> int: + dist[src] = 0 + minHeap = [(dist[src], src)] # (d, u) + + while minHeap: + d, u = heapq.heappop(minHeap) + # Already took `maxMoves` to reach `u`, so can't explore anymore. + if dist[u] >= maxMoves: + break + for v, w in graph[u]: + newDist = d + w + 1 + if newDist < dist[v]: + dist[v] = newDist + heapq.heappush(minHeap, (newDist, v)) + + return sum(d <= maxMoves for d in dist) diff --git a/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.py2 b/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.py2 new file mode 100644 index 00000000..2e6fc6c5 --- /dev/null +++ b/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.py2 @@ -0,0 +1,42 @@ +class Solution(object): + def reachableNodes(self, edges, maxMoves, n): + """ + :type edges: List[List[int]] + :type maxMoves: int + :type n: int + :rtype: int + """ + import heapq + + graph = [[] for _ in range(n)] + dist = [maxMoves + 1] * n + + for u, v, cnt in edges: + graph[u].append((v, cnt)) + graph[v].append((u, cnt)) + + def dijkstra(): + dist[0] = 0 + min_heap = [(0, 0)] + + while min_heap: + d, u = heapq.heappop(min_heap) + if dist[u] >= maxMoves: + break + for v, w in graph[u]: + newDist = d + w + 1 + if newDist < dist[v]: + dist[v] = newDist + heapq.heappush(min_heap, (newDist, v)) + + return sum(1 for d in dist if d <= maxMoves) + + reachableNodes = dijkstra() + reachableSubnodes = 0 + + for u, v, cnt in edges: + a = 0 if dist[u] > maxMoves else min(maxMoves - dist[u], cnt) + b = 0 if dist[v] > maxMoves else min(maxMoves - dist[v], cnt) + reachableSubnodes += min(a + b, cnt) + + return reachableNodes + reachableSubnodes diff --git a/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.rb b/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.rb new file mode 100644 index 00000000..e4dbfb98 --- /dev/null +++ b/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.rb @@ -0,0 +1,40 @@ +# @param {Integer[][]} edges +# @param {Integer} max_moves +# @param {Integer} n +# @return {Integer} +def reachable_nodes(edges, max_moves, n) + graph = Array.new(n) { [] } + dist = Array.new(n, max_moves + 1) + + edges.each do |u, v, cnt| + graph[u] << [v, cnt] + graph[v] << [u, cnt] + end + + dist[0] = 0 + heap = [[0, 0]] + + while !heap.empty? + d, u = heap.shift + next if d != dist[u] || d > max_moves + graph[u].each do |v, w| + new_dist = d + w + 1 + if new_dist < dist[v] + dist[v] = new_dist + heap << [new_dist, v] + heap.sort_by! { |a, b| a[0] <=> b[0] } + end + end + end + + reachable_nodes = dist.count { |d| d <= max_moves } + reachable_subnodes = 0 + + edges.each do |u, v, cnt| + a = dist[u] > max_moves ? 0 : [max_moves - dist[u], cnt].min + b = dist[v] > max_moves ? 0 : [max_moves - dist[v], cnt].min + reachable_subnodes += [a + b, cnt].min + end + + reachable_nodes + reachable_subnodes +end diff --git a/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.rs b/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.rs new file mode 100644 index 00000000..bbac2546 --- /dev/null +++ b/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.rs @@ -0,0 +1,55 @@ +impl Solution { + pub fn reachable_nodes(edges: Vec>, max_moves: i32, n: i32) -> i32 { + let n_usize = n as usize; + let mut graph: Vec> = vec![vec![]; n_usize]; + let mut dist: Vec = vec![max_moves + 1; n_usize]; + + for edge in &edges { + let u = edge[0] as usize; + let v = edge[1] as usize; + let cnt = edge[2]; + graph[u].push((v, cnt)); + graph[v].push((u, cnt)); + } + + fn dijkstra(graph: &Vec>, max_moves: i32, dist: &mut Vec) -> i32 { + use std::collections::BinaryHeap; + use std::cmp::Reverse; + + dist[0] = 0; + let mut heap = BinaryHeap::new(); + heap.push(Reverse((0, 0usize))); + + while let Some(Reverse((d, u))) = heap.pop() { + if dist[u] >= max_moves { + break; + } + + for &(v, w) in &graph[u] { + let new_dist = d + w + 1; + if new_dist < dist[v] { + dist[v] = new_dist; + heap.push(Reverse((new_dist, v))); + } + } + } + + dist.iter().filter(|&&d| d <= max_moves).count() as i32 + } + + let reachable_nodes = dijkstra(&graph, max_moves, &mut dist); + let mut reachable_subnodes = 0i32; + + for edge in &edges { + let u = edge[0] as usize; + let v = edge[1] as usize; + let cnt = edge[2]; + + let a = if dist[u] > max_moves { 0 } else { (max_moves - dist[u]).min(cnt) }; + let b = if dist[v] > max_moves { 0 } else { (max_moves - dist[v]).min(cnt) }; + reachable_subnodes += (a + b).min(cnt); + } + + reachable_nodes + reachable_subnodes + } +} diff --git a/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.swift b/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.swift new file mode 100644 index 00000000..c43cfdcd --- /dev/null +++ b/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.swift @@ -0,0 +1,48 @@ +class Solution { + func reachableNodes(_ edges: [[Int]], _ maxMoves: Int, _ n: Int) -> Int { + var graph = Array(repeating: [(Int, Int)](), count: n) + var dist = Array(repeating: maxMoves + 1, count: n) + + for edge in edges { + let u = edge[0], v = edge[1], cnt = edge[2] + graph[u].append((v, cnt)) + graph[v].append((u, cnt)) + } + + func dijkstra() -> Int { + dist[0] = 0 + var heap = [(0, 0)] + + while !heap.isEmpty { + heap.sort { $0.0 > $1.0 } + let (d, u) = heap.removeLast() + + if dist[u] >= maxMoves { + break + } + + for (v, w) in graph[u] { + let newDist = d + w + 1 + if newDist < dist[v] { + dist[v] = newDist + heap.append((newDist, v)) + } + } + } + + return dist.filter { $0 <= maxMoves }.count + } + + let reachableNodes = dijkstra() + var reachableSubnodes = 0 + + for edge in edges { + let u = edge[0], v = edge[1], cnt = edge[2] + let a = dist[u] > maxMoves ? 0 : min(maxMoves - dist[u], cnt) + let b = dist[v] > maxMoves ? 0 : min(maxMoves - dist[v], cnt) + reachableSubnodes += min(a + b, cnt) + } + + return reachableNodes + reachableSubnodes + } +} diff --git a/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.ts b/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.ts new file mode 100644 index 00000000..6f3b80fd --- /dev/null +++ b/tests/501-1000/882. reachable-nodes-in-subdivided-graph/sol.ts @@ -0,0 +1,78 @@ +function reachableNodes( + edges: number[][], + maxMoves: number, + n: number, +): number { + const graph: [number, number][][] = Array.from({ length: n }, () => []); + const dist: number[] = new Array(n).fill(maxMoves + 1); + + for (const [u, v, cnt] of edges) { + graph[u].push([v, cnt]); + graph[v].push([u, cnt]); + } + + class MinHeap { + data: [number, number][] = []; + push(item: [number, number]) { + this.data.push(item); + let i = this.data.length - 1; + while (i > 0) { + const p = (i - 1) >> 1; + if (this.data[p][0] <= this.data[i][0]) break; + [this.data[p], this.data[i]] = [this.data[i], this.data[p]]; + i = p; + } + } + pop(): [number, number] | undefined { + if (this.data.length === 0) return undefined; + const top = this.data[0]; + const last = this.data.pop()!; + if (this.data.length === 0) return top; + this.data[0] = last; + let i = 0; + while (true) { + let left = i * 2 + 1; + if (left >= this.data.length) break; + let right = left + 1; + let child = left; + if ( + right < this.data.length && + this.data[right][0] < this.data[left][0] + ) + child = right; + if (this.data[i][0] <= this.data[child][0]) break; + [this.data[i], this.data[child]] = [this.data[child], this.data[i]]; + i = child; + } + return top; + } + } + + dist[0] = 0; + const heap = new MinHeap(); + heap.push([0, 0]); + while (true) { + const curr = heap.pop(); + if (!curr) break; + const [d, u] = curr; + if (d > dist[u] || d > maxMoves) continue; + for (const [v, w] of graph[u]) { + const newDist = d + w + 1; + if (newDist < dist[v]) { + dist[v] = newDist; + heap.push([newDist, v]); + } + } + } + + const reachableNodes = dist.filter((d) => d <= maxMoves).length; + let reachableSubnodes = 0; + + for (const [u, v, cnt] of edges) { + const a = dist[u] > maxMoves ? 0 : Math.min(maxMoves - dist[u], cnt); + const b = dist[v] > maxMoves ? 0 : Math.min(maxMoves - dist[v], cnt); + reachableSubnodes += Math.min(a + b, cnt); + } + + return reachableNodes + reachableSubnodes; +} diff --git a/tests/501-1000/883. projection-area-of-3d-shapes/manifest.yaml b/tests/501-1000/883. projection-area-of-3d-shapes/manifest.yaml new file mode 100644 index 00000000..d3b72a67 --- /dev/null +++ b/tests/501-1000/883. projection-area-of-3d-shapes/manifest.yaml @@ -0,0 +1,256 @@ +entry: + id: 883 + title: projection-area-of-3d-shapes + params: + grid: + type: array + items: + type: array + items: + type: int + call: + cpp: "Solution().projectionArea({grid})" + rust: "Solution::projection_area({grid})" + python3: "Solution().projectionArea({grid})" + python2: "Solution().projectionArea({grid})" + ruby: "projection_area({grid})" + java: "new Solution().projectionArea({grid})" + csharp: "new Solution().ProjectionArea({grid})" + kotlin: "Solution().projectionArea({grid})" + go: "projectionArea({grid})" + dart: "Solution().projectionArea({grid})" + swift: "Solution().projectionArea({grid})" + typescript: "projectionArea({grid})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 128 +oracle: + python3: + call: "Checker().projectionArea(grid, {result})" + checker: | + class Checker: + def projectionArea(self, grid, result): + xy = sum(1 for row in grid for v in row if v > 0) + yz = sum(max(row) for row in grid) + zx = sum(max(col) for col in zip(*grid)) + return xy + yz + zx == result +seed: 883 +tests: + - name: ex1 + in: + grid: + - [1, 2] + - [3, 4] + - name: ex2 + in: + grid: + - [2] + - name: ex3 + in: + grid: + - [1, 0] + - [0, 2] + - name: all_zeros_1x1 + in: + grid: + - [0] + - name: single_tower + in: + grid: + - [5] + - name: row_mixed + in: + grid: + - [0, 1, 0, 2] + - name: column_mixed + in: + grid: + - [0] + - [3] + - [1] + - [0] + - name: 2x2_sparse + in: + grid: + - [0, 7] + - [5, 0] + - name: 2x3_flat + in: + grid: + - [1, 1, 1] + - [1, 1, 1] + - name: 3x3_increasing + in: + grid: + - [1, 2, 3] + - [4, 5, 6] + - [7, 8, 9] + - name: all_zero_2x2 + in: + grid: + - [0, 0] + - [0, 0] + - name: all_one_3x3 + in: + grid: + - [1, 1, 1] + - [1, 1, 1] + - [1, 1, 1] + - name: diagonal_only + in: + grid: + - [4, 0, 0] + - [0, 5, 0] + - [0, 0, 6] + - name: anti_diagonal_only + in: + grid: + - [0, 0, 7] + - [0, 8, 0] + - [9, 0, 0] + - name: single_row + in: + grid: + - [2, 0, 5, 1, 0] + - name: single_column + in: + grid: + - [2] + - [0] + - [5] + - [1] + - [0] + - name: zeros_and_maxima + in: + grid: + - [0, 50, 0, 50] + - [50, 0, 50, 0] + - [0, 50, 0, 50] + - [50, 0, 50, 0] + - name: upper_triangular + in: + grid: + - [1, 2, 3, 4] + - [0, 5, 6, 7] + - [0, 0, 8, 9] + - [0, 0, 0, 10] + - name: lower_triangular + in: + grid: + - [10, 0, 0, 0] + - [9, 8, 0, 0] + - [7, 6, 5, 0] + - [4, 3, 2, 1] + - name: checkerboard_4x4 + in: + grid: + - [1, 0, 1, 0] + - [0, 2, 0, 2] + - [3, 0, 3, 0] + - [0, 4, 0, 4] + - name: border_only + in: + grid: + - [5, 5, 5, 5, 5] + - [5, 0, 0, 0, 5] + - [5, 0, 9, 0, 5] + - [5, 0, 0, 0, 5] + - [5, 5, 5, 5, 5] + - name: center_peak + in: + grid: + - [1, 1, 1] + - [1, 50, 1] + - [1, 1, 1] + - name: mixed_small + in: + grid: + - [0, 2, 0] + - [3, 0, 4] + - [0, 5, 0] + - name: repeated_rows + in: + grid: + - [2, 3, 2] + - [2, 3, 2] + - [2, 3, 2] + - name: repeated_columns + in: + grid: + - [1, 4, 1, 4] + - [2, 5, 2, 5] + - [3, 6, 3, 6] + - [4, 7, 4, 7] + - name: sparse_5x5 + in: + grid: + - [0, 0, 0, 0, 1] + - [0, 0, 0, 2, 0] + - [0, 0, 3, 0, 0] + - [0, 4, 0, 0, 0] + - [5, 0, 0, 0, 0] + - name: every_cell_positive + in: + grid: + - [1, 2, 3, 4] + - [5, 6, 7, 8] + - [9, 10, 11, 12] + - [13, 14, 15, 16] + - name: max_values_small_n + in: + grid: + - [50, 50] + - [50, 50] + - name: one_big_one_zero + in: + grid: + - [50, 0] + - [0, 0] + - name: asymmetric_mix + in: + grid: + - [0, 1, 2, 0] + - [3, 0, 4, 0] + - [0, 5, 0, 6] + - [7, 0, 8, 0] + - name: tall_columns + in: + grid: + - [0, 9, 0] + - [0, 9, 0] + - [0, 9, 0] + - name: tall_rows + in: + grid: + - [0, 0, 0] + - [9, 9, 9] + - [0, 0, 0] + - name: staircase + in: + grid: + - [1, 0, 0, 0, 0] + - [2, 1, 0, 0, 0] + - [3, 2, 1, 0, 0] + - [4, 3, 2, 1, 0] + - [5, 4, 3, 2, 1] + - name: hollow_square + in: + grid: + - [2, 2, 2, 2] + - [2, 0, 0, 2] + - [2, 0, 0, 2] + - [2, 2, 2, 2] + - name: maxed_border + in: + grid: + - [50, 50, 50, 50, 50] + - [50, 1, 1, 1, 50] + - [50, 1, 50, 1, 50] + - [50, 1, 1, 1, 50] + - [50, 50, 50, 50, 50] + - name: one_by_one_max + in: + grid: + - [50] diff --git a/tests/501-1000/883. projection-area-of-3d-shapes/sol.cpp b/tests/501-1000/883. projection-area-of-3d-shapes/sol.cpp new file mode 100644 index 00000000..2db3affa --- /dev/null +++ b/tests/501-1000/883. projection-area-of-3d-shapes/sol.cpp @@ -0,0 +1,26 @@ +class Solution { +public: + int projectionArea(vector>& grid) { + int xyArea = 0; + int yzArea = 0; + int zxArea = 0; + int rows = grid.size(); + int cols = grid[0].size(); + for (int i = 0; i < rows; i++) { + int maxRow = 0; + for (int j = 0; j < cols; j++) { + if (grid[i][j] > 0) xyArea++; + if (grid[i][j] > maxRow) maxRow = grid[i][j]; + } + yzArea += maxRow; + } + for (int j = 0; j < cols; j++) { + int maxCol = 0; + for (int i = 0; i < rows; i++) { + if (grid[i][j] > maxCol) maxCol = grid[i][j]; + } + zxArea += maxCol; + } + return xyArea + yzArea + zxArea; + } +}; diff --git a/tests/501-1000/883. projection-area-of-3d-shapes/sol.cs b/tests/501-1000/883. projection-area-of-3d-shapes/sol.cs new file mode 100644 index 00000000..7db70cfa --- /dev/null +++ b/tests/501-1000/883. projection-area-of-3d-shapes/sol.cs @@ -0,0 +1,25 @@ +public class Solution { + public int ProjectionArea(int[][] grid) { + int xyArea = 0; + int yzArea = 0; + int zxArea = 0; + int rows = grid.Length; + int cols = grid[0].Length; + for (int i = 0; i < rows; i++) { + int maxRow = 0; + for (int j = 0; j < cols; j++) { + if (grid[i][j] > 0) xyArea++; + if (grid[i][j] > maxRow) maxRow = grid[i][j]; + } + yzArea += maxRow; + } + for (int j = 0; j < cols; j++) { + int maxCol = 0; + for (int i = 0; i < rows; i++) { + if (grid[i][j] > maxCol) maxCol = grid[i][j]; + } + zxArea += maxCol; + } + return xyArea + yzArea + zxArea; + } +} diff --git a/tests/501-1000/883. projection-area-of-3d-shapes/sol.dart b/tests/501-1000/883. projection-area-of-3d-shapes/sol.dart new file mode 100644 index 00000000..21c892b5 --- /dev/null +++ b/tests/501-1000/883. projection-area-of-3d-shapes/sol.dart @@ -0,0 +1,25 @@ +class Solution { + int projectionArea(List> grid) { + int xyArea = 0; + int yzArea = 0; + int zxArea = 0; + int rows = grid.length; + int cols = grid[0].length; + for (int i = 0; i < rows; i++) { + int maxRow = 0; + for (int j = 0; j < cols; j++) { + if (grid[i][j] > 0) xyArea++; + if (grid[i][j] > maxRow) maxRow = grid[i][j]; + } + yzArea += maxRow; + } + for (int j = 0; j < cols; j++) { + int maxCol = 0; + for (int i = 0; i < rows; i++) { + if (grid[i][j] > maxCol) maxCol = grid[i][j]; + } + zxArea += maxCol; + } + return xyArea + yzArea + zxArea; + } +} diff --git a/tests/501-1000/883. projection-area-of-3d-shapes/sol.go b/tests/501-1000/883. projection-area-of-3d-shapes/sol.go new file mode 100644 index 00000000..e210a197 --- /dev/null +++ b/tests/501-1000/883. projection-area-of-3d-shapes/sol.go @@ -0,0 +1,29 @@ +func projectionArea(grid [][]int) int { + xyArea := 0 + yzArea := 0 + zxArea := 0 + rows := len(grid) + cols := len(grid[0]) + for i := 0; i < rows; i++ { + maxRow := 0 + for j := 0; j < cols; j++ { + if grid[i][j] > 0 { + xyArea++ + } + if grid[i][j] > maxRow { + maxRow = grid[i][j] + } + } + yzArea += maxRow + } + for j := 0; j < cols; j++ { + maxCol := 0 + for i := 0; i < rows; i++ { + if grid[i][j] > maxCol { + maxCol = grid[i][j] + } + } + zxArea += maxCol + } + return xyArea + yzArea + zxArea +} diff --git a/tests/501-1000/883. projection-area-of-3d-shapes/sol.java b/tests/501-1000/883. projection-area-of-3d-shapes/sol.java new file mode 100644 index 00000000..0437877e --- /dev/null +++ b/tests/501-1000/883. projection-area-of-3d-shapes/sol.java @@ -0,0 +1,25 @@ +class Solution { + public int projectionArea(int[][] grid) { + int xyArea = 0; + int yzArea = 0; + int zxArea = 0; + int rows = grid.length; + int cols = grid[0].length; + for (int i = 0; i < rows; i++) { + int maxRow = 0; + for (int j = 0; j < cols; j++) { + if (grid[i][j] > 0) xyArea++; + if (grid[i][j] > maxRow) maxRow = grid[i][j]; + } + yzArea += maxRow; + } + for (int j = 0; j < cols; j++) { + int maxCol = 0; + for (int i = 0; i < rows; i++) { + if (grid[i][j] > maxCol) maxCol = grid[i][j]; + } + zxArea += maxCol; + } + return xyArea + yzArea + zxArea; + } +} diff --git a/tests/501-1000/883. projection-area-of-3d-shapes/sol.kt b/tests/501-1000/883. projection-area-of-3d-shapes/sol.kt new file mode 100644 index 00000000..cf1e6cb8 --- /dev/null +++ b/tests/501-1000/883. projection-area-of-3d-shapes/sol.kt @@ -0,0 +1,25 @@ +class Solution { + fun projectionArea(grid: Array): Int { + var xyArea = 0 + var yzArea = 0 + var zxArea = 0 + val rows = grid.size + val cols = grid[0].size + for (i in 0 until rows) { + var maxRow = 0 + for (j in 0 until cols) { + if (grid[i][j] > 0) xyArea++ + if (grid[i][j] > maxRow) maxRow = grid[i][j] + } + yzArea += maxRow + } + for (j in 0 until cols) { + var maxCol = 0 + for (i in 0 until rows) { + if (grid[i][j] > maxCol) maxCol = grid[i][j] + } + zxArea += maxCol + } + return xyArea + yzArea + zxArea + } +} diff --git a/tests/501-1000/883. projection-area-of-3d-shapes/sol.py b/tests/501-1000/883. projection-area-of-3d-shapes/sol.py new file mode 100644 index 00000000..719b85aa --- /dev/null +++ b/tests/501-1000/883. projection-area-of-3d-shapes/sol.py @@ -0,0 +1,15 @@ +class Solution: + def projectionArea(self, grid: List[List[int]]) -> int: + # 1. XY Projection: Count non-zero elements (Surface footprint) + # In image processing, this is equivalent to a binary mask of the object + xy_area = sum(1 for row in grid for val in row if val > 0) + + # 2. YZ Projection: Sum of max heights for each row + # This is essentially finding the profile/silhouette from one side + yz_area = sum(max(row) for row in grid) + + # 3. ZX Projection: Sum of max heights for each column + # Equivalent to the profile from the orthogonal side + zx_area = sum(max(col) for col in zip(*grid)) + + return xy_area + yz_area + zx_area diff --git a/tests/501-1000/883. projection-area-of-3d-shapes/sol.py2 b/tests/501-1000/883. projection-area-of-3d-shapes/sol.py2 new file mode 100644 index 00000000..dc2d7b4b --- /dev/null +++ b/tests/501-1000/883. projection-area-of-3d-shapes/sol.py2 @@ -0,0 +1,10 @@ +class Solution(object): + def projectionArea(self, grid): + """ + :type grid: List[List[int]] + :rtype: int + """ + xy_area = sum(1 for row in grid for val in row if val > 0) + yz_area = sum(max(row) for row in grid) + zx_area = sum(max(col) for col in zip(*grid)) + return xy_area + yz_area + zx_area diff --git a/tests/501-1000/883. projection-area-of-3d-shapes/sol.rb b/tests/501-1000/883. projection-area-of-3d-shapes/sol.rb new file mode 100644 index 00000000..6740c615 --- /dev/null +++ b/tests/501-1000/883. projection-area-of-3d-shapes/sol.rb @@ -0,0 +1,8 @@ +# @param {Integer[][]} grid +# @return {Integer} +def projection_area(grid) + xy_area = grid.flatten.count { |val| val > 0 } + yz_area = grid.sum { |row| row.max } + zx_area = grid.transpose.sum { |col| col.max } + xy_area + yz_area + zx_area +end diff --git a/tests/501-1000/883. projection-area-of-3d-shapes/sol.rs b/tests/501-1000/883. projection-area-of-3d-shapes/sol.rs new file mode 100644 index 00000000..abe2d985 --- /dev/null +++ b/tests/501-1000/883. projection-area-of-3d-shapes/sol.rs @@ -0,0 +1,31 @@ +impl Solution { + pub fn projection_area(grid: Vec>) -> i32 { + let mut xy_area = 0; + let mut yz_area = 0; + let mut zx_area = 0; + let rows = grid.len(); + let cols = grid[0].len(); + for i in 0..rows { + let mut max_row = 0; + for j in 0..cols { + if grid[i][j] > 0 { + xy_area += 1; + } + if grid[i][j] > max_row { + max_row = grid[i][j]; + } + } + yz_area += max_row; + } + for j in 0..cols { + let mut max_col = 0; + for i in 0..rows { + if grid[i][j] > max_col { + max_col = grid[i][j]; + } + } + zx_area += max_col; + } + xy_area + yz_area + zx_area + } +} diff --git a/tests/501-1000/883. projection-area-of-3d-shapes/sol.swift b/tests/501-1000/883. projection-area-of-3d-shapes/sol.swift new file mode 100644 index 00000000..873adbab --- /dev/null +++ b/tests/501-1000/883. projection-area-of-3d-shapes/sol.swift @@ -0,0 +1,25 @@ +class Solution { + func projectionArea(_ grid: [[Int]]) -> Int { + var xyArea = 0 + var yzArea = 0 + var zxArea = 0 + let rows = grid.count + let cols = grid[0].count + for i in 0.. 0 { xyArea += 1 } + if grid[i][j] > maxRow { maxRow = grid[i][j] } + } + yzArea += maxRow + } + for j in 0.. maxCol { maxCol = grid[i][j] } + } + zxArea += maxCol + } + return xyArea + yzArea + zxArea + } +} diff --git a/tests/501-1000/883. projection-area-of-3d-shapes/sol.ts b/tests/501-1000/883. projection-area-of-3d-shapes/sol.ts new file mode 100644 index 00000000..d56cd067 --- /dev/null +++ b/tests/501-1000/883. projection-area-of-3d-shapes/sol.ts @@ -0,0 +1,23 @@ +function projectionArea(grid: number[][]): number { + let xyArea = 0; + let yzArea = 0; + let zxArea = 0; + const rows = grid.length; + const cols = grid[0].length; + for (let i = 0; i < rows; i++) { + let maxRow = 0; + for (let j = 0; j < cols; j++) { + if (grid[i][j] > 0) xyArea++; + if (grid[i][j] > maxRow) maxRow = grid[i][j]; + } + yzArea += maxRow; + } + for (let j = 0; j < cols; j++) { + let maxCol = 0; + for (let i = 0; i < rows; i++) { + if (grid[i][j] > maxCol) maxCol = grid[i][j]; + } + zxArea += maxCol; + } + return xyArea + yzArea + zxArea; +} diff --git a/tests/501-1000/884. uncommon-words-from-two-sentences/manifest.yaml b/tests/501-1000/884. uncommon-words-from-two-sentences/manifest.yaml new file mode 100644 index 00000000..dba529d3 --- /dev/null +++ b/tests/501-1000/884. uncommon-words-from-two-sentences/manifest.yaml @@ -0,0 +1,198 @@ +entry: + id: 884 + title: uncommon-words-from-two-sentences + params: + s1: + type: string + s2: + type: string + call: + cpp: "Solution().uncommonFromSentences({s1}, {s2})" + rust: "Solution::uncommon_from_sentences({s1}, {s2})" + python3: "Solution().uncommonFromSentences({s1}, {s2})" + python2: "Solution().uncommonFromSentences({s1}, {s2})" + ruby: "uncommon_from_sentences({s1}, {s2})" + java: "new Solution().uncommonFromSentences({s1}, {s2})" + csharp: "new Solution().UncommonFromSentences({s1}, {s2})" + kotlin: "Solution().uncommonFromSentences({s1}, {s2})" + go: "uncommonFromSentences({s1}, {s2})" + dart: "Solution().uncommonFromSentences({s1}, {s2})" + swift: "Solution().uncommonFromSentences({s1}, {s2})" + typescript: "uncommonFromSentences({s1}, {s2})" +judge: + type: ignore_order +limits: + time_ms: 1000 + memory_mb: 128 +oracle: + python3: + call: "Checker().uncommonFromSentences(s1, s2, {result})" + checker: | + from collections import Counter + + class Checker: + def uncommonFromSentences(self, s1, s2, result): + expected = [w for w, c in Counter(s1.split() + s2.split()).items() if c == 1] + return sorted(expected) == sorted(result) +seed: 884 +tests: + - name: ex1 + in: + s1: this apple is sweet + s2: this apple is sour + - name: ex2 + in: + s1: apple apple + s2: banana + - name: both_same_single_word + in: + s1: a + s2: a + - name: disjoint_single_words + in: + s1: a + s2: b + - name: repeated_only_one_side + in: + s1: a a a b + s2: c c + - name: mixed_overlap + in: + s1: red blue green + s2: blue yellow + - name: all_common + in: + s1: x y + s2: x y + - name: no_overlap_unique + in: + s1: aa bb cc + s2: dd ee ff + - name: one_sentence_longer + in: + s1: apple banana apple cherry + s2: banana date egg fig + - name: duplicate_across_both + in: + s1: one two two three + s2: three four four five + - name: identical_longer + in: + s1: "red blue green" + s2: "red blue green" + - name: one_unique_each + in: + s1: "alpha beta" + s2: "gamma delta" + - name: repeated_only_in_s1 + in: + s1: "apple apple apple" + s2: "banana" + - name: repeated_only_in_s2 + in: + s1: "banana" + s2: "apple apple apple" + - name: mixed_duplicates + in: + s1: "cat dog dog fish" + s2: "cat bird bird owl" + - name: shared_and_unique + in: + s1: "sun moon star" + s2: "moon comet" + - name: all_words_shared_once + in: + s1: "a b c" + s2: "c b a" + - name: all_words_unique_across_both + in: + s1: "aa bb cc dd" + s2: "ee ff gg hh" + - name: interleaved_duplicates + in: + s1: "a a b c c d" + s2: "b e e f" + - name: single_word_each_different + in: + s1: "hello" + s2: "world" + - name: single_word_each_same + in: + s1: "same" + s2: "same" + - name: one_side_has_none + in: + s1: "x x x" + s2: "x" + - name: many_shared_many_unique + in: + s1: "alpha beta gamma delta" + s2: "beta delta epsilon zeta" + - name: alternating_repeats + in: + s1: "p q p q r" + s2: "r s s t" + - name: short_sentence_with_repeats + in: + s1: "zz zz yy" + s2: "xx" + - name: different_lengths + in: + s1: "a bb ccc dddd eeeee" + s2: "bb dddd fffff" + - name: repeated_pair_on_both_sides + in: + s1: "k k l m" + s2: "l l n o" + - name: triple_overlap + in: + s1: "a b c d" + s2: "b c e f" + - name: unique_suffixes + in: + s1: "root branch leaf" + s2: "branch bark trunk" + - name: unique_prefixes + in: + s1: "alpha alpha beta" + s2: "beta gamma gamma" + - name: many_words_one_common + in: + s1: "h i j k l m" + s2: "i" + - name: many_words_two_common + in: + s1: "a b c d e f" + s2: "c d" + - name: two_unique_and_shared + in: + s1: "red red blue green" + s2: "green yellow yellow" + - name: longer_sentence_balance + in: + s1: "aa bb cc dd ee ff gg hh ii jj" + s2: "bb dd ff hh jj kk ll mm nn oo" + - name: max_length_like_1 + in: + s1: "a a a a a a a a a a a a a a a a a a a a" + s2: "b b b b b b b b b b" + - name: max_length_like_2 + in: + s1: "ab cd ef gh ij kl mn op qr st" + s2: "cd gh kl op st uv wx yz" + - name: chained_uniques + in: + s1: "a b b c c d d e" + s2: "f g g h h i" + - name: repeated_words_with_gap + in: + s1: "alpha alpha beta gamma gamma" + s2: "beta delta delta" + - name: all_unique_many + in: + s1: "p1 p2 p3 p4 p5 p6" + s2: "q1 q2 q3 q4 q5 q6" + - name: final_mix + in: + s1: "one one two three four" + s2: "two five six six" diff --git a/tests/501-1000/884. uncommon-words-from-two-sentences/sol.cpp b/tests/501-1000/884. uncommon-words-from-two-sentences/sol.cpp new file mode 100644 index 00000000..69f5a16f --- /dev/null +++ b/tests/501-1000/884. uncommon-words-from-two-sentences/sol.cpp @@ -0,0 +1,16 @@ +class Solution { +public: + vector uncommonFromSentences(string s1, string s2) { + unordered_map count; + istringstream iss(s1 + " " + s2); + string word; + while (iss >> word) { + count[word]++; + } + vector result; + for (auto& [w, c] : count) { + if (c == 1) result.push_back(w); + } + return result; + } +}; diff --git a/tests/501-1000/884. uncommon-words-from-two-sentences/sol.cs b/tests/501-1000/884. uncommon-words-from-two-sentences/sol.cs new file mode 100644 index 00000000..7850f559 --- /dev/null +++ b/tests/501-1000/884. uncommon-words-from-two-sentences/sol.cs @@ -0,0 +1,15 @@ +public class Solution { + public string[] UncommonFromSentences(string s1, string s2) { + var words = (s1 + " " + s2).Split(' '); + var count = new Dictionary(); + foreach (var word in words) { + if (count.ContainsKey(word)) count[word]++; + else count[word] = 1; + } + var result = new List(); + foreach (var pair in count) { + if (pair.Value == 1) result.Add(pair.Key); + } + return result.ToArray(); + } +} diff --git a/tests/501-1000/884. uncommon-words-from-two-sentences/sol.dart b/tests/501-1000/884. uncommon-words-from-two-sentences/sol.dart new file mode 100644 index 00000000..fe298110 --- /dev/null +++ b/tests/501-1000/884. uncommon-words-from-two-sentences/sol.dart @@ -0,0 +1,10 @@ +class Solution { + List uncommonFromSentences(String s1, String s2) { + var words = [...s1.split(' '), ...s2.split(' ')]; + var count = {}; + for (var word in words) { + count[word] = (count[word] ?? 0) + 1; + } + return count.entries.where((e) => e.value == 1).map((e) => e.key).toList(); + } +} diff --git a/tests/501-1000/884. uncommon-words-from-two-sentences/sol.go b/tests/501-1000/884. uncommon-words-from-two-sentences/sol.go new file mode 100644 index 00000000..95a384bc --- /dev/null +++ b/tests/501-1000/884. uncommon-words-from-two-sentences/sol.go @@ -0,0 +1,39 @@ +type Solution struct{} + +func (Solution) UncommonFromSentences(s1 string, s2 string) []string { + return uncommonFromSentences(s1, s2) +} + +func uncommonFromSentences(s1 string, s2 string) []string { + words := splitWords(s1) + words = append(words, splitWords(s2)...) + count := make(map[string]int) + for _, word := range words { + count[word]++ + } + result := make([]string, 0) + for word, c := range count { + if c == 1 { + result = append(result, word) + } + } + return result +} + +func splitWords(s string) []string { + words := make([]string, 0) + start := -1 + for i := 0; i <= len(s); i++ { + if i < len(s) && s[i] != ' ' { + if start == -1 { + start = i + } + continue + } + if start != -1 { + words = append(words, s[start:i]) + start = -1 + } + } + return words +} diff --git a/tests/501-1000/884. uncommon-words-from-two-sentences/sol.java b/tests/501-1000/884. uncommon-words-from-two-sentences/sol.java new file mode 100644 index 00000000..0fc1d9ed --- /dev/null +++ b/tests/501-1000/884. uncommon-words-from-two-sentences/sol.java @@ -0,0 +1,15 @@ +class Solution { + public String[] uncommonFromSentences(String s1, String s2) { + java.util.Map count = new java.util.HashMap<>(); + for (String word : (s1 + " " + s2).split(" ")) { + count.put(word, count.getOrDefault(word, 0) + 1); + } + java.util.List result = new java.util.ArrayList<>(); + for (java.util.Map.Entry entry : count.entrySet()) { + if (entry.getValue() == 1) { + result.add(entry.getKey()); + } + } + return result.toArray(new String[0]); + } +} diff --git a/tests/501-1000/884. uncommon-words-from-two-sentences/sol.kt b/tests/501-1000/884. uncommon-words-from-two-sentences/sol.kt new file mode 100644 index 00000000..56fcdcf5 --- /dev/null +++ b/tests/501-1000/884. uncommon-words-from-two-sentences/sol.kt @@ -0,0 +1,7 @@ +class Solution { + fun uncommonFromSentences(s1: String, s2: String): Array { + val words = (s1.split(" ") + s2.split(" ")) + val count = words.groupingBy { it }.eachCount() + return count.filter { it.value == 1 }.keys.toTypedArray() + } +} diff --git a/tests/501-1000/884. uncommon-words-from-two-sentences/sol.py b/tests/501-1000/884. uncommon-words-from-two-sentences/sol.py new file mode 100644 index 00000000..bca382a2 --- /dev/null +++ b/tests/501-1000/884. uncommon-words-from-two-sentences/sol.py @@ -0,0 +1,11 @@ +from collections import Counter +from typing import List + + +class Solution: + def uncommonFromSentences(self, s1: str, s2: str) -> List[str]: + return [ + word + for word, count in Counter(s1.split() + s2.split()).items() + if count == 1 + ] diff --git a/tests/501-1000/884. uncommon-words-from-two-sentences/sol.py2 b/tests/501-1000/884. uncommon-words-from-two-sentences/sol.py2 new file mode 100644 index 00000000..f9c983b9 --- /dev/null +++ b/tests/501-1000/884. uncommon-words-from-two-sentences/sol.py2 @@ -0,0 +1,4 @@ +class Solution(object): + def uncommonFromSentences(self, s1, s2): + from collections import Counter + return [word for word, count in Counter(s1.split() + s2.split()).items() if count == 1] diff --git a/tests/501-1000/884. uncommon-words-from-two-sentences/sol.rb b/tests/501-1000/884. uncommon-words-from-two-sentences/sol.rb new file mode 100644 index 00000000..30452958 --- /dev/null +++ b/tests/501-1000/884. uncommon-words-from-two-sentences/sol.rb @@ -0,0 +1,7 @@ +# @param {String} s1 +# @param {String} s2 +# @return {String[]} +def uncommon_from_sentences(s1, s2) + words = (s1.split + s2.split) + words.select { |word| words.count(word) == 1 } +end diff --git a/tests/501-1000/884. uncommon-words-from-two-sentences/sol.rs b/tests/501-1000/884. uncommon-words-from-two-sentences/sol.rs new file mode 100644 index 00000000..3152c78f --- /dev/null +++ b/tests/501-1000/884. uncommon-words-from-two-sentences/sol.rs @@ -0,0 +1,10 @@ +impl Solution { + pub fn uncommon_from_sentences(s1: String, s2: String) -> Vec { + use std::collections::HashMap; + let mut count = HashMap::new(); + for word in s1.split_whitespace().chain(s2.split_whitespace()) { + *count.entry(word.to_string()).or_insert(0) += 1; + } + count.into_iter().filter(|&(_, c)| c == 1).map(|(w, _)| w).collect() + } +} diff --git a/tests/501-1000/884. uncommon-words-from-two-sentences/sol.swift b/tests/501-1000/884. uncommon-words-from-two-sentences/sol.swift new file mode 100644 index 00000000..297e81a6 --- /dev/null +++ b/tests/501-1000/884. uncommon-words-from-two-sentences/sol.swift @@ -0,0 +1,10 @@ +class Solution { + func uncommonFromSentences(_ s1: String, _ s2: String) -> [String] { + let words = s1.split(separator: " ") + s2.split(separator: " ") + var count = [String: Int]() + for word in words { + count[String(word), default: 0] += 1 + } + return count.filter { $0.value == 1 }.map { $0.key } + } +} diff --git a/tests/501-1000/884. uncommon-words-from-two-sentences/sol.ts b/tests/501-1000/884. uncommon-words-from-two-sentences/sol.ts new file mode 100644 index 00000000..6ef4fdd0 --- /dev/null +++ b/tests/501-1000/884. uncommon-words-from-two-sentences/sol.ts @@ -0,0 +1,10 @@ +function uncommonFromSentences(s1: string, s2: string): string[] { + const words = [...s1.split(" "), ...s2.split(" ")]; + const count: { [key: string]: number } = {}; + for (const word of words) { + count[word] = (count[word] || 0) + 1; + } + return Object.entries(count) + .filter(([_, c]) => c === 1) + .map(([word]) => word); +} diff --git a/tests/501-1000/885. spiral-matrix-iii/manifest.yaml b/tests/501-1000/885. spiral-matrix-iii/manifest.yaml new file mode 100644 index 00000000..65c35652 --- /dev/null +++ b/tests/501-1000/885. spiral-matrix-iii/manifest.yaml @@ -0,0 +1,1880 @@ +entry: + id: 885 + title: spiral-matrix-iii + params: + rows: + type: int + cols: + type: int + rStart: + type: int + cStart: + type: int + call: + cpp: "Solution().spiralMatrixIII({rows}, {cols}, {rStart}, {cStart})" + rust: "Solution::spiral_matrix_iii({rows}, {cols}, {rStart}, {cStart})" + python3: "Solution().spiralMatrixIII({rows}, {cols}, {rStart}, {cStart})" + python2: "Solution().spiralMatrixIII({rows}, {cols}, {rStart}, {cStart})" + ruby: "spiral_matrix_iii({rows}, {cols}, {rStart}, {cStart})" + java: "new Solution().spiralMatrixIII({rows}, {cols}, {rStart}, {cStart})" + csharp: "new Solution().SpiralMatrixIII({rows}, {cols}, {rStart}, {cStart})" + kotlin: "Solution().spiralMatrixIII({rows}, {cols}, {rStart}, {cStart})" + go: "spiralMatrixIII({rows}, {cols}, {rStart}, {cStart})" + dart: "Solution().spiralMatrixIII({rows}, {cols}, {rStart}, {cStart})" + swift: "Solution().spiralMatrixIII({rows}, {cols}, {rStart}, {cStart})" + typescript: "spiralMatrixIII({rows}, {cols}, {rStart}, {cStart})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 128 +oracle: + python3: + call: "Checker().spiralMatrixIII(rows, cols, rStart, cStart, {result})" + checker: | + class Checker: + def spiralMatrixIII(self, rows, cols, rStart, cStart, result): +oracle: + python3: + call: "Checker().spiralMatrixIII(rows, cols, rStart, cStart, {result})" + checker: | + class Checker: + def spiralMatrixIII(self, rows, cols, rStart, cStart, result): + seen = [] + top = bottom = rStart + left = right = cStart + seen.append([rStart, cStart]) + while len(seen) < rows * cols: + right += 1 + for i in range(left + 1, right + 1): + if 0 <= top < rows and 0 <= i < cols: + seen.append([top, i]) + if len(seen) == rows * cols: + return seen == result + bottom += 1 + for i in range(top + 1, bottom + 1): + if 0 <= right < cols and 0 <= i < rows: + seen.append([i, right]) + if len(seen) == rows * cols: + return seen == result + left -= 1 + for i in range(right - 1, left - 1, -1): + if 0 <= i < cols and 0 <= bottom < rows: + seen.append([bottom, i]) + if len(seen) == rows * cols: + return seen == result + top -= 1 + for i in range(bottom - 1, top - 1, -1): + if 0 <= i < rows and 0 <= left < cols: + seen.append([i, left]) + if len(seen) == rows * cols: + return seen == result + return seen == result +seed: 885 +tests: + - name: ex1 + in: + rows: 1 + cols: 4 + rStart: 0 + cStart: 0 + out: + - [0, 0] + - [0, 1] + - [0, 2] + - [0, 3] + - name: ex2 + in: + rows: 5 + cols: 6 + rStart: 1 + cStart: 4 + out: + - [1, 4] + - [1, 5] + - [2, 5] + - [2, 4] + - [2, 3] + - [1, 3] + - [0, 3] + - [0, 4] + - [0, 5] + - [3, 5] + - [3, 4] + - [3, 3] + - [3, 2] + - [2, 2] + - [1, 2] + - [0, 2] + - [4, 5] + - [4, 4] + - [4, 3] + - [4, 2] + - [4, 1] + - [3, 1] + - [2, 1] + - [1, 1] + - [0, 1] + - [4, 0] + - [3, 0] + - [2, 0] + - [1, 0] + - [0, 0] + - name: single_cell + in: + rows: 1 + cols: 1 + rStart: 0 + cStart: 0 + out: + - [0, 0] + - name: single_row_mid + in: + rows: 1 + cols: 5 + rStart: 0 + cStart: 2 + out: + - [0, 2] + - [0, 3] + - [0, 1] + - [0, 4] + - [0, 0] + - name: single_col_mid + in: + rows: 5 + cols: 1 + rStart: 2 + cStart: 0 + out: + - [2, 0] + - [3, 0] + - [1, 0] + - [4, 0] + - [0, 0] + - name: corner_start + in: + rows: 3 + cols: 3 + rStart: 0 + cStart: 0 + out: + - [0, 0] + - [0, 1] + - [1, 1] + - [1, 0] + - [0, 2] + - [1, 2] + - [2, 2] + - [2, 1] + - [2, 0] + - name: center_start + in: + rows: 3 + cols: 3 + rStart: 1 + cStart: 1 + out: + - [1, 1] + - [1, 2] + - [2, 2] + - [2, 1] + - [2, 0] + - [1, 0] + - [0, 0] + - [0, 1] + - [0, 2] + - name: rectangular_2x4 + in: + rows: 2 + cols: 4 + rStart: 1 + cStart: 2 + out: + - [1, 2] + - [1, 3] + - [1, 1] + - [0, 1] + - [0, 2] + - [0, 3] + - [1, 0] + - [0, 0] + - name: rectangular_4x2 + in: + rows: 4 + cols: 2 + rStart: 2 + cStart: 1 + out: + - [2, 1] + - [3, 1] + - [3, 0] + - [2, 0] + - [1, 0] + - [1, 1] + - [0, 0] + - [0, 1] + - name: larger_rectangular + in: + rows: 6 + cols: 7 + rStart: 3 + cStart: 4 + out: + - [3, 4] + - [3, 5] + - [4, 5] + - [4, 4] + - [4, 3] + - [3, 3] + - [2, 3] + - [2, 4] + - [2, 5] + - [2, 6] + - [3, 6] + - [4, 6] + - [5, 6] + - [5, 5] + - [5, 4] + - [5, 3] + - [5, 2] + - [4, 2] + - [3, 2] + - [2, 2] + - [1, 2] + - [1, 3] + - [1, 4] + - [1, 5] + - [1, 6] + - [5, 1] + - [4, 1] + - [3, 1] + - [2, 1] + - [1, 1] + - [0, 1] + - [0, 2] + - [0, 3] + - [0, 4] + - [0, 5] + - [0, 6] + - [5, 0] + - [4, 0] + - [3, 0] + - [2, 0] + - [1, 0] + - [0, 0] + - name: two_by_two_top_right + in: + rows: 2 + cols: 2 + rStart: 0 + cStart: 1 + out: + - [0, 1] + - [1, 1] + - [1, 0] + - [0, 0] + - name: two_by_two_bottom_left + in: + rows: 2 + cols: 2 + rStart: 1 + cStart: 0 + out: + - [1, 0] + - [1, 1] + - [0, 0] + - [0, 1] + - name: bottom_right_edge + in: + rows: 3 + cols: 4 + rStart: 2 + cStart: 3 + out: + - [2, 3] + - [2, 2] + - [1, 2] + - [1, 3] + - [2, 1] + - [1, 1] + - [0, 1] + - [0, 2] + - [0, 3] + - [2, 0] + - [1, 0] + - [0, 0] + - name: top_right_edge + in: + rows: 4 + cols: 3 + rStart: 0 + cStart: 2 + out: + - [0, 2] + - [1, 2] + - [1, 1] + - [0, 1] + - [2, 2] + - [2, 1] + - [2, 0] + - [1, 0] + - [0, 0] + - [3, 2] + - [3, 1] + - [3, 0] + - name: bottom_left_edge + in: + rows: 4 + cols: 5 + rStart: 3 + cStart: 0 + out: + - [3, 0] + - [3, 1] + - [2, 0] + - [2, 1] + - [2, 2] + - [3, 2] + - [1, 0] + - [1, 1] + - [1, 2] + - [1, 3] + - [2, 3] + - [3, 3] + - [0, 0] + - [0, 1] + - [0, 2] + - [0, 3] + - [0, 4] + - [1, 4] + - [2, 4] + - [3, 4] + - name: top_right_cornerish + in: + rows: 5 + cols: 4 + rStart: 0 + cStart: 3 + out: + - [0, 3] + - [1, 3] + - [1, 2] + - [0, 2] + - [2, 3] + - [2, 2] + - [2, 1] + - [1, 1] + - [0, 1] + - [3, 3] + - [3, 2] + - [3, 1] + - [3, 0] + - [2, 0] + - [1, 0] + - [0, 0] + - [4, 3] + - [4, 2] + - [4, 1] + - [4, 0] + - name: left_edge_mid + in: + rows: 3 + cols: 5 + rStart: 1 + cStart: 0 + out: + - [1, 0] + - [1, 1] + - [2, 1] + - [2, 0] + - [0, 0] + - [0, 1] + - [0, 2] + - [1, 2] + - [2, 2] + - [0, 3] + - [1, 3] + - [2, 3] + - [0, 4] + - [1, 4] + - [2, 4] + - name: top_edge_mid + in: + rows: 5 + cols: 3 + rStart: 0 + cStart: 1 + out: + - [0, 1] + - [0, 2] + - [1, 2] + - [1, 1] + - [1, 0] + - [0, 0] + - [2, 2] + - [2, 1] + - [2, 0] + - [3, 2] + - [3, 1] + - [3, 0] + - [4, 2] + - [4, 1] + - [4, 0] + - name: even_square_center + in: + rows: 6 + cols: 6 + rStart: 2 + cStart: 2 + out: + - [2, 2] + - [2, 3] + - [3, 3] + - [3, 2] + - [3, 1] + - [2, 1] + - [1, 1] + - [1, 2] + - [1, 3] + - [1, 4] + - [2, 4] + - [3, 4] + - [4, 4] + - [4, 3] + - [4, 2] + - [4, 1] + - [4, 0] + - [3, 0] + - [2, 0] + - [1, 0] + - [0, 0] + - [0, 1] + - [0, 2] + - [0, 3] + - [0, 4] + - [0, 5] + - [1, 5] + - [2, 5] + - [3, 5] + - [4, 5] + - [5, 5] + - [5, 4] + - [5, 3] + - [5, 2] + - [5, 1] + - [5, 0] + - name: even_square_corner + in: + rows: 6 + cols: 6 + rStart: 0 + cStart: 0 + out: + - [0, 0] + - [0, 1] + - [1, 1] + - [1, 0] + - [0, 2] + - [1, 2] + - [2, 2] + - [2, 1] + - [2, 0] + - [0, 3] + - [1, 3] + - [2, 3] + - [3, 3] + - [3, 2] + - [3, 1] + - [3, 0] + - [0, 4] + - [1, 4] + - [2, 4] + - [3, 4] + - [4, 4] + - [4, 3] + - [4, 2] + - [4, 1] + - [4, 0] + - [0, 5] + - [1, 5] + - [2, 5] + - [3, 5] + - [4, 5] + - [5, 5] + - [5, 4] + - [5, 3] + - [5, 2] + - [5, 1] + - [5, 0] + - name: even_square_other_corner + in: + rows: 6 + cols: 6 + rStart: 5 + cStart: 5 + out: + - [5, 5] + - [5, 4] + - [4, 4] + - [4, 5] + - [5, 3] + - [4, 3] + - [3, 3] + - [3, 4] + - [3, 5] + - [5, 2] + - [4, 2] + - [3, 2] + - [2, 2] + - [2, 3] + - [2, 4] + - [2, 5] + - [5, 1] + - [4, 1] + - [3, 1] + - [2, 1] + - [1, 1] + - [1, 2] + - [1, 3] + - [1, 4] + - [1, 5] + - [5, 0] + - [4, 0] + - [3, 0] + - [2, 0] + - [1, 0] + - [0, 0] + - [0, 1] + - [0, 2] + - [0, 3] + - [0, 4] + - [0, 5] + - name: rect_wide_right_edge + in: + rows: 7 + cols: 8 + rStart: 3 + cStart: 7 + out: + - [3, 7] + - [4, 7] + - [4, 6] + - [3, 6] + - [2, 6] + - [2, 7] + - [5, 7] + - [5, 6] + - [5, 5] + - [4, 5] + - [3, 5] + - [2, 5] + - [1, 5] + - [1, 6] + - [1, 7] + - [6, 7] + - [6, 6] + - [6, 5] + - [6, 4] + - [5, 4] + - [4, 4] + - [3, 4] + - [2, 4] + - [1, 4] + - [0, 4] + - [0, 5] + - [0, 6] + - [0, 7] + - [6, 3] + - [5, 3] + - [4, 3] + - [3, 3] + - [2, 3] + - [1, 3] + - [0, 3] + - [6, 2] + - [5, 2] + - [4, 2] + - [3, 2] + - [2, 2] + - [1, 2] + - [0, 2] + - [6, 1] + - [5, 1] + - [4, 1] + - [3, 1] + - [2, 1] + - [1, 1] + - [0, 1] + - [6, 0] + - [5, 0] + - [4, 0] + - [3, 0] + - [2, 0] + - [1, 0] + - [0, 0] + - name: rect_tall_bottom_edge + in: + rows: 8 + cols: 7 + rStart: 7 + cStart: 3 + out: + - [7, 3] + - [7, 4] + - [7, 2] + - [6, 2] + - [6, 3] + - [6, 4] + - [6, 5] + - [7, 5] + - [7, 1] + - [6, 1] + - [5, 1] + - [5, 2] + - [5, 3] + - [5, 4] + - [5, 5] + - [5, 6] + - [6, 6] + - [7, 6] + - [7, 0] + - [6, 0] + - [5, 0] + - [4, 0] + - [4, 1] + - [4, 2] + - [4, 3] + - [4, 4] + - [4, 5] + - [4, 6] + - [3, 0] + - [3, 1] + - [3, 2] + - [3, 3] + - [3, 4] + - [3, 5] + - [3, 6] + - [2, 0] + - [2, 1] + - [2, 2] + - [2, 3] + - [2, 4] + - [2, 5] + - [2, 6] + - [1, 0] + - [1, 1] + - [1, 2] + - [1, 3] + - [1, 4] + - [1, 5] + - [1, 6] + - [0, 0] + - [0, 1] + - [0, 2] + - [0, 3] + - [0, 4] + - [0, 5] + - [0, 6] + - name: odd_square_center + in: + rows: 9 + cols: 9 + rStart: 4 + cStart: 4 + out: + - [4, 4] + - [4, 5] + - [5, 5] + - [5, 4] + - [5, 3] + - [4, 3] + - [3, 3] + - [3, 4] + - [3, 5] + - [3, 6] + - [4, 6] + - [5, 6] + - [6, 6] + - [6, 5] + - [6, 4] + - [6, 3] + - [6, 2] + - [5, 2] + - [4, 2] + - [3, 2] + - [2, 2] + - [2, 3] + - [2, 4] + - [2, 5] + - [2, 6] + - [2, 7] + - [3, 7] + - [4, 7] + - [5, 7] + - [6, 7] + - [7, 7] + - [7, 6] + - [7, 5] + - [7, 4] + - [7, 3] + - [7, 2] + - [7, 1] + - [6, 1] + - [5, 1] + - [4, 1] + - [3, 1] + - [2, 1] + - [1, 1] + - [1, 2] + - [1, 3] + - [1, 4] + - [1, 5] + - [1, 6] + - [1, 7] + - [1, 8] + - [2, 8] + - [3, 8] + - [4, 8] + - [5, 8] + - [6, 8] + - [7, 8] + - [8, 8] + - [8, 7] + - [8, 6] + - [8, 5] + - [8, 4] + - [8, 3] + - [8, 2] + - [8, 1] + - [8, 0] + - [7, 0] + - [6, 0] + - [5, 0] + - [4, 0] + - [3, 0] + - [2, 0] + - [1, 0] + - [0, 0] + - [0, 1] + - [0, 2] + - [0, 3] + - [0, 4] + - [0, 5] + - [0, 6] + - [0, 7] + - [0, 8] + - name: tall_single_col_bottom + in: + rows: 10 + cols: 1 + rStart: 9 + cStart: 0 + out: + - [9, 0] + - [8, 0] + - [7, 0] + - [6, 0] + - [5, 0] + - [4, 0] + - [3, 0] + - [2, 0] + - [1, 0] + - [0, 0] + - name: wide_single_row_right + in: + rows: 1 + cols: 10 + rStart: 0 + cStart: 9 + out: + - [0, 9] + - [0, 8] + - [0, 7] + - [0, 6] + - [0, 5] + - [0, 4] + - [0, 3] + - [0, 2] + - [0, 1] + - [0, 0] + - name: large_square_top_mid + in: + rows: 10 + cols: 10 + rStart: 0 + cStart: 5 + out: + - [0, 5] + - [0, 6] + - [1, 6] + - [1, 5] + - [1, 4] + - [0, 4] + - [0, 7] + - [1, 7] + - [2, 7] + - [2, 6] + - [2, 5] + - [2, 4] + - [2, 3] + - [1, 3] + - [0, 3] + - [0, 8] + - [1, 8] + - [2, 8] + - [3, 8] + - [3, 7] + - [3, 6] + - [3, 5] + - [3, 4] + - [3, 3] + - [3, 2] + - [2, 2] + - [1, 2] + - [0, 2] + - [0, 9] + - [1, 9] + - [2, 9] + - [3, 9] + - [4, 9] + - [4, 8] + - [4, 7] + - [4, 6] + - [4, 5] + - [4, 4] + - [4, 3] + - [4, 2] + - [4, 1] + - [3, 1] + - [2, 1] + - [1, 1] + - [0, 1] + - [5, 9] + - [5, 8] + - [5, 7] + - [5, 6] + - [5, 5] + - [5, 4] + - [5, 3] + - [5, 2] + - [5, 1] + - [5, 0] + - [4, 0] + - [3, 0] + - [2, 0] + - [1, 0] + - [0, 0] + - [6, 9] + - [6, 8] + - [6, 7] + - [6, 6] + - [6, 5] + - [6, 4] + - [6, 3] + - [6, 2] + - [6, 1] + - [6, 0] + - [7, 9] + - [7, 8] + - [7, 7] + - [7, 6] + - [7, 5] + - [7, 4] + - [7, 3] + - [7, 2] + - [7, 1] + - [7, 0] + - [8, 9] + - [8, 8] + - [8, 7] + - [8, 6] + - [8, 5] + - [8, 4] + - [8, 3] + - [8, 2] + - [8, 1] + - [8, 0] + - [9, 9] + - [9, 8] + - [9, 7] + - [9, 6] + - [9, 5] + - [9, 4] + - [9, 3] + - [9, 2] + - [9, 1] + - [9, 0] + - name: large_square_left_mid + in: + rows: 10 + cols: 10 + rStart: 5 + cStart: 0 + out: + - [5, 0] + - [5, 1] + - [6, 1] + - [6, 0] + - [4, 0] + - [4, 1] + - [4, 2] + - [5, 2] + - [6, 2] + - [7, 2] + - [7, 1] + - [7, 0] + - [3, 0] + - [3, 1] + - [3, 2] + - [3, 3] + - [4, 3] + - [5, 3] + - [6, 3] + - [7, 3] + - [8, 3] + - [8, 2] + - [8, 1] + - [8, 0] + - [2, 0] + - [2, 1] + - [2, 2] + - [2, 3] + - [2, 4] + - [3, 4] + - [4, 4] + - [5, 4] + - [6, 4] + - [7, 4] + - [8, 4] + - [9, 4] + - [9, 3] + - [9, 2] + - [9, 1] + - [9, 0] + - [1, 0] + - [1, 1] + - [1, 2] + - [1, 3] + - [1, 4] + - [1, 5] + - [2, 5] + - [3, 5] + - [4, 5] + - [5, 5] + - [6, 5] + - [7, 5] + - [8, 5] + - [9, 5] + - [0, 0] + - [0, 1] + - [0, 2] + - [0, 3] + - [0, 4] + - [0, 5] + - [0, 6] + - [1, 6] + - [2, 6] + - [3, 6] + - [4, 6] + - [5, 6] + - [6, 6] + - [7, 6] + - [8, 6] + - [9, 6] + - [0, 7] + - [1, 7] + - [2, 7] + - [3, 7] + - [4, 7] + - [5, 7] + - [6, 7] + - [7, 7] + - [8, 7] + - [9, 7] + - [0, 8] + - [1, 8] + - [2, 8] + - [3, 8] + - [4, 8] + - [5, 8] + - [6, 8] + - [7, 8] + - [8, 8] + - [9, 8] + - [0, 9] + - [1, 9] + - [2, 9] + - [3, 9] + - [4, 9] + - [5, 9] + - [6, 9] + - [7, 9] + - [8, 9] + - [9, 9] + - name: large_square_bottom_right + in: + rows: 10 + cols: 10 + rStart: 9 + cStart: 9 + out: + - [9, 9] + - [9, 8] + - [8, 8] + - [8, 9] + - [9, 7] + - [8, 7] + - [7, 7] + - [7, 8] + - [7, 9] + - [9, 6] + - [8, 6] + - [7, 6] + - [6, 6] + - [6, 7] + - [6, 8] + - [6, 9] + - [9, 5] + - [8, 5] + - [7, 5] + - [6, 5] + - [5, 5] + - [5, 6] + - [5, 7] + - [5, 8] + - [5, 9] + - [9, 4] + - [8, 4] + - [7, 4] + - [6, 4] + - [5, 4] + - [4, 4] + - [4, 5] + - [4, 6] + - [4, 7] + - [4, 8] + - [4, 9] + - [9, 3] + - [8, 3] + - [7, 3] + - [6, 3] + - [5, 3] + - [4, 3] + - [3, 3] + - [3, 4] + - [3, 5] + - [3, 6] + - [3, 7] + - [3, 8] + - [3, 9] + - [9, 2] + - [8, 2] + - [7, 2] + - [6, 2] + - [5, 2] + - [4, 2] + - [3, 2] + - [2, 2] + - [2, 3] + - [2, 4] + - [2, 5] + - [2, 6] + - [2, 7] + - [2, 8] + - [2, 9] + - [9, 1] + - [8, 1] + - [7, 1] + - [6, 1] + - [5, 1] + - [4, 1] + - [3, 1] + - [2, 1] + - [1, 1] + - [1, 2] + - [1, 3] + - [1, 4] + - [1, 5] + - [1, 6] + - [1, 7] + - [1, 8] + - [1, 9] + - [9, 0] + - [8, 0] + - [7, 0] + - [6, 0] + - [5, 0] + - [4, 0] + - [3, 0] + - [2, 0] + - [1, 0] + - [0, 0] + - [0, 1] + - [0, 2] + - [0, 3] + - [0, 4] + - [0, 5] + - [0, 6] + - [0, 7] + - [0, 8] + - [0, 9] + - name: large_square_origin + in: + rows: 10 + cols: 10 + rStart: 0 + cStart: 0 + out: + - [0, 0] + - [0, 1] + - [1, 1] + - [1, 0] + - [0, 2] + - [1, 2] + - [2, 2] + - [2, 1] + - [2, 0] + - [0, 3] + - [1, 3] + - [2, 3] + - [3, 3] + - [3, 2] + - [3, 1] + - [3, 0] + - [0, 4] + - [1, 4] + - [2, 4] + - [3, 4] + - [4, 4] + - [4, 3] + - [4, 2] + - [4, 1] + - [4, 0] + - [0, 5] + - [1, 5] + - [2, 5] + - [3, 5] + - [4, 5] + - [5, 5] + - [5, 4] + - [5, 3] + - [5, 2] + - [5, 1] + - [5, 0] + - [0, 6] + - [1, 6] + - [2, 6] + - [3, 6] + - [4, 6] + - [5, 6] + - [6, 6] + - [6, 5] + - [6, 4] + - [6, 3] + - [6, 2] + - [6, 1] + - [6, 0] + - [0, 7] + - [1, 7] + - [2, 7] + - [3, 7] + - [4, 7] + - [5, 7] + - [6, 7] + - [7, 7] + - [7, 6] + - [7, 5] + - [7, 4] + - [7, 3] + - [7, 2] + - [7, 1] + - [7, 0] + - [0, 8] + - [1, 8] + - [2, 8] + - [3, 8] + - [4, 8] + - [5, 8] + - [6, 8] + - [7, 8] + - [8, 8] + - [8, 7] + - [8, 6] + - [8, 5] + - [8, 4] + - [8, 3] + - [8, 2] + - [8, 1] + - [8, 0] + - [0, 9] + - [1, 9] + - [2, 9] + - [3, 9] + - [4, 9] + - [5, 9] + - [6, 9] + - [7, 9] + - [8, 9] + - [9, 9] + - [9, 8] + - [9, 7] + - [9, 6] + - [9, 5] + - [9, 4] + - [9, 3] + - [9, 2] + - [9, 1] + - [9, 0] + - name: square_top_mid + in: + rows: 7 + cols: 7 + rStart: 0 + cStart: 3 + out: + - [0, 3] + - [0, 4] + - [1, 4] + - [1, 3] + - [1, 2] + - [0, 2] + - [0, 5] + - [1, 5] + - [2, 5] + - [2, 4] + - [2, 3] + - [2, 2] + - [2, 1] + - [1, 1] + - [0, 1] + - [0, 6] + - [1, 6] + - [2, 6] + - [3, 6] + - [3, 5] + - [3, 4] + - [3, 3] + - [3, 2] + - [3, 1] + - [3, 0] + - [2, 0] + - [1, 0] + - [0, 0] + - [4, 6] + - [4, 5] + - [4, 4] + - [4, 3] + - [4, 2] + - [4, 1] + - [4, 0] + - [5, 6] + - [5, 5] + - [5, 4] + - [5, 3] + - [5, 2] + - [5, 1] + - [5, 0] + - [6, 6] + - [6, 5] + - [6, 4] + - [6, 3] + - [6, 2] + - [6, 1] + - [6, 0] + - name: square_left_mid + in: + rows: 7 + cols: 7 + rStart: 3 + cStart: 0 + out: + - [3, 0] + - [3, 1] + - [4, 1] + - [4, 0] + - [2, 0] + - [2, 1] + - [2, 2] + - [3, 2] + - [4, 2] + - [5, 2] + - [5, 1] + - [5, 0] + - [1, 0] + - [1, 1] + - [1, 2] + - [1, 3] + - [2, 3] + - [3, 3] + - [4, 3] + - [5, 3] + - [6, 3] + - [6, 2] + - [6, 1] + - [6, 0] + - [0, 0] + - [0, 1] + - [0, 2] + - [0, 3] + - [0, 4] + - [1, 4] + - [2, 4] + - [3, 4] + - [4, 4] + - [5, 4] + - [6, 4] + - [0, 5] + - [1, 5] + - [2, 5] + - [3, 5] + - [4, 5] + - [5, 5] + - [6, 5] + - [0, 6] + - [1, 6] + - [2, 6] + - [3, 6] + - [4, 6] + - [5, 6] + - [6, 6] + - name: square_bottom_right + in: + rows: 7 + cols: 7 + rStart: 6 + cStart: 6 + out: + - [6, 6] + - [6, 5] + - [5, 5] + - [5, 6] + - [6, 4] + - [5, 4] + - [4, 4] + - [4, 5] + - [4, 6] + - [6, 3] + - [5, 3] + - [4, 3] + - [3, 3] + - [3, 4] + - [3, 5] + - [3, 6] + - [6, 2] + - [5, 2] + - [4, 2] + - [3, 2] + - [2, 2] + - [2, 3] + - [2, 4] + - [2, 5] + - [2, 6] + - [6, 1] + - [5, 1] + - [4, 1] + - [3, 1] + - [2, 1] + - [1, 1] + - [1, 2] + - [1, 3] + - [1, 4] + - [1, 5] + - [1, 6] + - [6, 0] + - [5, 0] + - [4, 0] + - [3, 0] + - [2, 0] + - [1, 0] + - [0, 0] + - [0, 1] + - [0, 2] + - [0, 3] + - [0, 4] + - [0, 5] + - [0, 6] + - name: rect_8x9_center + in: + rows: 8 + cols: 9 + rStart: 4 + cStart: 4 + out: + - [4, 4] + - [4, 5] + - [5, 5] + - [5, 4] + - [5, 3] + - [4, 3] + - [3, 3] + - [3, 4] + - [3, 5] + - [3, 6] + - [4, 6] + - [5, 6] + - [6, 6] + - [6, 5] + - [6, 4] + - [6, 3] + - [6, 2] + - [5, 2] + - [4, 2] + - [3, 2] + - [2, 2] + - [2, 3] + - [2, 4] + - [2, 5] + - [2, 6] + - [2, 7] + - [3, 7] + - [4, 7] + - [5, 7] + - [6, 7] + - [7, 7] + - [7, 6] + - [7, 5] + - [7, 4] + - [7, 3] + - [7, 2] + - [7, 1] + - [6, 1] + - [5, 1] + - [4, 1] + - [3, 1] + - [2, 1] + - [1, 1] + - [1, 2] + - [1, 3] + - [1, 4] + - [1, 5] + - [1, 6] + - [1, 7] + - [1, 8] + - [2, 8] + - [3, 8] + - [4, 8] + - [5, 8] + - [6, 8] + - [7, 8] + - [7, 0] + - [6, 0] + - [5, 0] + - [4, 0] + - [3, 0] + - [2, 0] + - [1, 0] + - [0, 0] + - [0, 1] + - [0, 2] + - [0, 3] + - [0, 4] + - [0, 5] + - [0, 6] + - [0, 7] + - [0, 8] + - name: rect_9x8_center + in: + rows: 9 + cols: 8 + rStart: 4 + cStart: 4 + out: + - [4, 4] + - [4, 5] + - [5, 5] + - [5, 4] + - [5, 3] + - [4, 3] + - [3, 3] + - [3, 4] + - [3, 5] + - [3, 6] + - [4, 6] + - [5, 6] + - [6, 6] + - [6, 5] + - [6, 4] + - [6, 3] + - [6, 2] + - [5, 2] + - [4, 2] + - [3, 2] + - [2, 2] + - [2, 3] + - [2, 4] + - [2, 5] + - [2, 6] + - [2, 7] + - [3, 7] + - [4, 7] + - [5, 7] + - [6, 7] + - [7, 7] + - [7, 6] + - [7, 5] + - [7, 4] + - [7, 3] + - [7, 2] + - [7, 1] + - [6, 1] + - [5, 1] + - [4, 1] + - [3, 1] + - [2, 1] + - [1, 1] + - [1, 2] + - [1, 3] + - [1, 4] + - [1, 5] + - [1, 6] + - [1, 7] + - [8, 7] + - [8, 6] + - [8, 5] + - [8, 4] + - [8, 3] + - [8, 2] + - [8, 1] + - [8, 0] + - [7, 0] + - [6, 0] + - [5, 0] + - [4, 0] + - [3, 0] + - [2, 0] + - [1, 0] + - [0, 0] + - [0, 1] + - [0, 2] + - [0, 3] + - [0, 4] + - [0, 5] + - [0, 6] + - [0, 7] + - name: bigger_rect_1 + in: + rows: 12 + cols: 13 + rStart: 6 + cStart: 7 + out: + - [6, 7] + - [6, 8] + - [7, 8] + - [7, 7] + - [7, 6] + - [6, 6] + - [5, 6] + - [5, 7] + - [5, 8] + - [5, 9] + - [6, 9] + - [7, 9] + - [8, 9] + - [8, 8] + - [8, 7] + - [8, 6] + - [8, 5] + - [7, 5] + - [6, 5] + - [5, 5] + - [4, 5] + - [4, 6] + - [4, 7] + - [4, 8] + - [4, 9] + - [4, 10] + - [5, 10] + - [6, 10] + - [7, 10] + - [8, 10] + - [9, 10] + - [9, 9] + - [9, 8] + - [9, 7] + - [9, 6] + - [9, 5] + - [9, 4] + - [8, 4] + - [7, 4] + - [6, 4] + - [5, 4] + - [4, 4] + - [3, 4] + - [3, 5] + - [3, 6] + - [3, 7] + - [3, 8] + - [3, 9] + - [3, 10] + - [3, 11] + - [4, 11] + - [5, 11] + - [6, 11] + - [7, 11] + - [8, 11] + - [9, 11] + - [10, 11] + - [10, 10] + - [10, 9] + - [10, 8] + - [10, 7] + - [10, 6] + - [10, 5] + - [10, 4] + - [10, 3] + - [9, 3] + - [8, 3] + - [7, 3] + - [6, 3] + - [5, 3] + - [4, 3] + - [3, 3] + - [2, 3] + - [2, 4] + - [2, 5] + - [2, 6] + - [2, 7] + - [2, 8] + - [2, 9] + - [2, 10] + - [2, 11] + - [2, 12] + - [3, 12] + - [4, 12] + - [5, 12] + - [6, 12] + - [7, 12] + - [8, 12] + - [9, 12] + - [10, 12] + - [11, 12] + - [11, 11] + - [11, 10] + - [11, 9] + - [11, 8] + - [11, 7] + - [11, 6] + - [11, 5] + - [11, 4] + - [11, 3] + - [11, 2] + - [10, 2] + - [9, 2] + - [8, 2] + - [7, 2] + - [6, 2] + - [5, 2] + - [4, 2] + - [3, 2] + - [2, 2] + - [1, 2] + - [1, 3] + - [1, 4] + - [1, 5] + - [1, 6] + - [1, 7] + - [1, 8] + - [1, 9] + - [1, 10] + - [1, 11] + - [1, 12] + - [11, 1] + - [10, 1] + - [9, 1] + - [8, 1] + - [7, 1] + - [6, 1] + - [5, 1] + - [4, 1] + - [3, 1] + - [2, 1] + - [1, 1] + - [0, 1] + - [0, 2] + - [0, 3] + - [0, 4] + - [0, 5] + - [0, 6] + - [0, 7] + - [0, 8] + - [0, 9] + - [0, 10] + - [0, 11] + - [0, 12] + - [11, 0] + - [10, 0] + - [9, 0] + - [8, 0] + - [7, 0] + - [6, 0] + - [5, 0] + - [4, 0] + - [3, 0] + - [2, 0] + - [1, 0] + - [0, 0] + - name: bigger_rect_2 + in: + rows: 13 + cols: 12 + rStart: 6 + cStart: 7 + out: + - [6, 7] + - [6, 8] + - [7, 8] + - [7, 7] + - [7, 6] + - [6, 6] + - [5, 6] + - [5, 7] + - [5, 8] + - [5, 9] + - [6, 9] + - [7, 9] + - [8, 9] + - [8, 8] + - [8, 7] + - [8, 6] + - [8, 5] + - [7, 5] + - [6, 5] + - [5, 5] + - [4, 5] + - [4, 6] + - [4, 7] + - [4, 8] + - [4, 9] + - [4, 10] + - [5, 10] + - [6, 10] + - [7, 10] + - [8, 10] + - [9, 10] + - [9, 9] + - [9, 8] + - [9, 7] + - [9, 6] + - [9, 5] + - [9, 4] + - [8, 4] + - [7, 4] + - [6, 4] + - [5, 4] + - [4, 4] + - [3, 4] + - [3, 5] + - [3, 6] + - [3, 7] + - [3, 8] + - [3, 9] + - [3, 10] + - [3, 11] + - [4, 11] + - [5, 11] + - [6, 11] + - [7, 11] + - [8, 11] + - [9, 11] + - [10, 11] + - [10, 10] + - [10, 9] + - [10, 8] + - [10, 7] + - [10, 6] + - [10, 5] + - [10, 4] + - [10, 3] + - [9, 3] + - [8, 3] + - [7, 3] + - [6, 3] + - [5, 3] + - [4, 3] + - [3, 3] + - [2, 3] + - [2, 4] + - [2, 5] + - [2, 6] + - [2, 7] + - [2, 8] + - [2, 9] + - [2, 10] + - [2, 11] + - [11, 11] + - [11, 10] + - [11, 9] + - [11, 8] + - [11, 7] + - [11, 6] + - [11, 5] + - [11, 4] + - [11, 3] + - [11, 2] + - [10, 2] + - [9, 2] + - [8, 2] + - [7, 2] + - [6, 2] + - [5, 2] + - [4, 2] + - [3, 2] + - [2, 2] + - [1, 2] + - [1, 3] + - [1, 4] + - [1, 5] + - [1, 6] + - [1, 7] + - [1, 8] + - [1, 9] + - [1, 10] + - [1, 11] + - [12, 11] + - [12, 10] + - [12, 9] + - [12, 8] + - [12, 7] + - [12, 6] + - [12, 5] + - [12, 4] + - [12, 3] + - [12, 2] + - [12, 1] + - [11, 1] + - [10, 1] + - [9, 1] + - [8, 1] + - [7, 1] + - [6, 1] + - [5, 1] + - [4, 1] + - [3, 1] + - [2, 1] + - [1, 1] + - [0, 1] + - [0, 2] + - [0, 3] + - [0, 4] + - [0, 5] + - [0, 6] + - [0, 7] + - [0, 8] + - [0, 9] + - [0, 10] + - [0, 11] + - [12, 0] + - [11, 0] + - [10, 0] + - [9, 0] + - [8, 0] + - [7, 0] + - [6, 0] + - [5, 0] + - [4, 0] + - [3, 0] + - [2, 0] + - [1, 0] + - [0, 0] diff --git a/tests/501-1000/885. spiral-matrix-iii/sol.cpp b/tests/501-1000/885. spiral-matrix-iii/sol.cpp new file mode 100644 index 00000000..4d77d0b4 --- /dev/null +++ b/tests/501-1000/885. spiral-matrix-iii/sol.cpp @@ -0,0 +1,42 @@ +class Solution { +public: + vector> spiralMatrixIII(int rows, int cols, int rStart, int cStart) { + int total = rows * cols; + vector> res; + res.reserve(total); + res.push_back({rStart, cStart}); + int top = rStart, bottom = rStart; + int left = cStart, right = cStart; + while (res.size() < total) { + right++; + for (int i = left + 1; i <= right; i++) { + if (top >= 0 && top < rows && i >= 0 && i < cols) { + res.push_back({top, i}); + if (res.size() == total) return res; + } + } + bottom++; + for (int i = top + 1; i <= bottom; i++) { + if (right >= 0 && right < cols && i >= 0 && i < rows) { + res.push_back({i, right}); + if (res.size() == total) return res; + } + } + left--; + for (int i = right - 1; i >= left; i--) { + if (i >= 0 && i < cols && bottom >= 0 && bottom < rows) { + res.push_back({bottom, i}); + if (res.size() == total) return res; + } + } + top--; + for (int i = bottom - 1; i >= top; i--) { + if (i >= 0 && i < rows && left >= 0 && left < cols) { + res.push_back({i, left}); + if (res.size() == total) return res; + } + } + } + return res; + } +}; diff --git a/tests/501-1000/885. spiral-matrix-iii/sol.cs b/tests/501-1000/885. spiral-matrix-iii/sol.cs new file mode 100644 index 00000000..4aaca718 --- /dev/null +++ b/tests/501-1000/885. spiral-matrix-iii/sol.cs @@ -0,0 +1,41 @@ +public class Solution { + public int[][] SpiralMatrixIII(int rows, int cols, int rStart, int cStart) { + int total = rows * cols; + int[][] res = new int[total][]; + int idx = 0; + res[idx++] = new int[] { rStart, cStart }; + int top = rStart, bottom = rStart; + int left = cStart, right = cStart; + while (idx < total) { + right++; + for (int i = left + 1; i <= right; i++) { + if (top >= 0 && top < rows && i >= 0 && i < cols) { + res[idx++] = new int[] { top, i }; + if (idx == total) return res; + } + } + bottom++; + for (int i = top + 1; i <= bottom; i++) { + if (right >= 0 && right < cols && i >= 0 && i < rows) { + res[idx++] = new int[] { i, right }; + if (idx == total) return res; + } + } + left--; + for (int i = right - 1; i >= left; i--) { + if (i >= 0 && i < cols && bottom >= 0 && bottom < rows) { + res[idx++] = new int[] { bottom, i }; + if (idx == total) return res; + } + } + top--; + for (int i = bottom - 1; i >= top; i--) { + if (i >= 0 && i < rows && left >= 0 && left < cols) { + res[idx++] = new int[] { i, left }; + if (idx == total) return res; + } + } + } + return res; + } +} diff --git a/tests/501-1000/885. spiral-matrix-iii/sol.dart b/tests/501-1000/885. spiral-matrix-iii/sol.dart new file mode 100644 index 00000000..cc986b92 --- /dev/null +++ b/tests/501-1000/885. spiral-matrix-iii/sol.dart @@ -0,0 +1,40 @@ +class Solution { + List> spiralMatrixIII(int rows, int cols, int rStart, int cStart) { + int total = rows * cols; + List> res = []; + res.add([rStart, cStart]); + int top = rStart, bottom = rStart; + int left = cStart, right = cStart; + while (res.length < total) { + right++; + for (int i = left + 1; i <= right; i++) { + if (top >= 0 && top < rows && i >= 0 && i < cols) { + res.add([top, i]); + if (res.length == total) return res; + } + } + bottom++; + for (int i = top + 1; i <= bottom; i++) { + if (right >= 0 && right < cols && i >= 0 && i < rows) { + res.add([i, right]); + if (res.length == total) return res; + } + } + left--; + for (int i = right - 1; i >= left; i--) { + if (i >= 0 && i < cols && bottom >= 0 && bottom < rows) { + res.add([bottom, i]); + if (res.length == total) return res; + } + } + top--; + for (int i = bottom - 1; i >= top; i--) { + if (i >= 0 && i < rows && left >= 0 && left < cols) { + res.add([i, left]); + if (res.length == total) return res; + } + } + } + return res; + } +} diff --git a/tests/501-1000/885. spiral-matrix-iii/sol.go b/tests/501-1000/885. spiral-matrix-iii/sol.go new file mode 100644 index 00000000..2dabc3c8 --- /dev/null +++ b/tests/501-1000/885. spiral-matrix-iii/sol.go @@ -0,0 +1,46 @@ +func spiralMatrixIII(rows int, cols int, rStart int, cStart int) [][]int { + total := rows * cols + res := make([][]int, 0, total) + res = append(res, []int{rStart, cStart}) + top, bottom := rStart, rStart + left, right := cStart, cStart + for len(res) < total { + right++ + for i := left + 1; i <= right; i++ { + if top >= 0 && top < rows && i >= 0 && i < cols { + res = append(res, []int{top, i}) + if len(res) == total { + return res + } + } + } + bottom++ + for i := top + 1; i <= bottom; i++ { + if right >= 0 && right < cols && i >= 0 && i < rows { + res = append(res, []int{i, right}) + if len(res) == total { + return res + } + } + } + left-- + for i := right - 1; i >= left; i-- { + if i >= 0 && i < cols && bottom >= 0 && bottom < rows { + res = append(res, []int{bottom, i}) + if len(res) == total { + return res + } + } + } + top-- + for i := bottom - 1; i >= top; i-- { + if i >= 0 && i < rows && left >= 0 && left < cols { + res = append(res, []int{i, left}) + if len(res) == total { + return res + } + } + } + } + return res +} diff --git a/tests/501-1000/885. spiral-matrix-iii/sol.java b/tests/501-1000/885. spiral-matrix-iii/sol.java new file mode 100644 index 00000000..40feca0f --- /dev/null +++ b/tests/501-1000/885. spiral-matrix-iii/sol.java @@ -0,0 +1,41 @@ +class Solution { + public int[][] spiralMatrixIII(int rows, int cols, int rStart, int cStart) { + int total = rows * cols; + int[][] res = new int[total][2]; + int idx = 0; + res[idx++] = new int[]{rStart, cStart}; + int top = rStart, bottom = rStart; + int left = cStart, right = cStart; + while (idx < total) { + right++; + for (int i = left + 1; i <= right; i++) { + if (top >= 0 && top < rows && i >= 0 && i < cols) { + res[idx++] = new int[]{top, i}; + if (idx == total) return res; + } + } + bottom++; + for (int i = top + 1; i <= bottom; i++) { + if (right >= 0 && right < cols && i >= 0 && i < rows) { + res[idx++] = new int[]{i, right}; + if (idx == total) return res; + } + } + left--; + for (int i = right - 1; i >= left; i--) { + if (i >= 0 && i < cols && bottom >= 0 && bottom < rows) { + res[idx++] = new int[]{bottom, i}; + if (idx == total) return res; + } + } + top--; + for (int i = bottom - 1; i >= top; i--) { + if (i >= 0 && i < rows && left >= 0 && left < cols) { + res[idx++] = new int[]{i, left}; + if (idx == total) return res; + } + } + } + return res; + } +} diff --git a/tests/501-1000/885. spiral-matrix-iii/sol.kt b/tests/501-1000/885. spiral-matrix-iii/sol.kt new file mode 100644 index 00000000..b86439af --- /dev/null +++ b/tests/501-1000/885. spiral-matrix-iii/sol.kt @@ -0,0 +1,43 @@ +class Solution { + fun spiralMatrixIII(rows: Int, cols: Int, rStart: Int, cStart: Int): Array { + val total = rows * cols + val res = Array(total) { IntArray(2) } + var idx = 0 + res[idx++] = intArrayOf(rStart, cStart) + var top = rStart + var bottom = rStart + var left = cStart + var right = cStart + while (idx < total) { + right++ + for (i in left + 1..right) { + if (top in 0 until rows && i in 0 until cols) { + res[idx++] = intArrayOf(top, i) + if (idx == total) return res + } + } + bottom++ + for (i in top + 1..bottom) { + if (right in 0 until cols && i in 0 until rows) { + res[idx++] = intArrayOf(i, right) + if (idx == total) return res + } + } + left-- + for (i in right - 1 downTo left) { + if (i in 0 until cols && bottom in 0 until rows) { + res[idx++] = intArrayOf(bottom, i) + if (idx == total) return res + } + } + top-- + for (i in bottom - 1 downTo top) { + if (i in 0 until rows && left in 0 until cols) { + res[idx++] = intArrayOf(i, left) + if (idx == total) return res + } + } + } + return res + } +} diff --git a/tests/501-1000/885. spiral-matrix-iii/sol.py b/tests/501-1000/885. spiral-matrix-iii/sol.py new file mode 100644 index 00000000..091db702 --- /dev/null +++ b/tests/501-1000/885. spiral-matrix-iii/sol.py @@ -0,0 +1,45 @@ +class Solution: + def spiralMatrixIII( + self, rows: int, cols: int, rStart: int, cStart: int + ) -> List[List[int]]: + res = [] + + top = bottom = rStart + left = right = cStart + + res.append([rStart, cStart]) + + while len(res) < rows * cols: + # top row + right += 1 + for i in range(left + 1, right + 1): + if 0 <= top < rows and 0 <= i < cols: + res.append([top, i]) + if len(res) == rows * cols: + return res + + # right row + bottom += 1 + for i in range(top + 1, bottom + 1): + if 0 <= right < cols and 0 <= i < rows: + res.append([i, right]) + if len(res) == rows * cols: + return res + + # bottom row + left -= 1 + for i in range(right - 1, left - 1, -1): + if 0 <= i < cols and 0 <= bottom < rows: + res.append([bottom, i]) + if len(res) == rows * cols: + return res + + # left row + top -= 1 + for i in range(bottom - 1, top - 1, -1): + if 0 <= i < rows and 0 <= left < cols: + res.append([i, left]) + if len(res) == rows * cols: + return res + + return res diff --git a/tests/501-1000/885. spiral-matrix-iii/sol.py2 b/tests/501-1000/885. spiral-matrix-iii/sol.py2 new file mode 100644 index 00000000..92227b23 --- /dev/null +++ b/tests/501-1000/885. spiral-matrix-iii/sol.py2 @@ -0,0 +1,39 @@ +class Solution(object): + def spiralMatrixIII(self, rows, cols, rStart, cStart): + """ + :type rows: int + :type cols: int + :type rStart: int + :type cStart: int + :rtype: List[List[int]] + """ + res = [] + top = bottom = rStart + left = right = cStart + res.append([rStart, cStart]) + while len(res) < rows * cols: + right += 1 + for i in range(left + 1, right + 1): + if 0 <= top < rows and 0 <= i < cols: + res.append([top, i]) + if len(res) == rows * cols: + return res + bottom += 1 + for i in range(top + 1, bottom + 1): + if 0 <= right < cols and 0 <= i < rows: + res.append([i, right]) + if len(res) == rows * cols: + return res + left -= 1 + for i in range(right - 1, left - 1, -1): + if 0 <= i < cols and 0 <= bottom < rows: + res.append([bottom, i]) + if len(res) == rows * cols: + return res + top -= 1 + for i in range(bottom - 1, top - 1, -1): + if 0 <= i < rows and 0 <= left < cols: + res.append([i, left]) + if len(res) == rows * cols: + return res + return res diff --git a/tests/501-1000/885. spiral-matrix-iii/sol.rb b/tests/501-1000/885. spiral-matrix-iii/sol.rb new file mode 100644 index 00000000..4b66975b --- /dev/null +++ b/tests/501-1000/885. spiral-matrix-iii/sol.rb @@ -0,0 +1,42 @@ +# @param {Integer} rows +# @param {Integer} cols +# @param {Integer} r_start +# @param {Integer} c_start +# @return {Integer[][]} +def spiral_matrix_iii(rows, cols, r_start, c_start) + res = [] + top = bottom = r_start + left = right = c_start + res << [r_start, c_start] + while res.length < rows * cols + right += 1 + (left + 1..right).each do |i| + if top >= 0 && top < rows && i >= 0 && i < cols + res << [top, i] + return res if res.length == rows * cols + end + end + bottom += 1 + (top + 1..bottom).each do |i| + if right >= 0 && right < cols && i >= 0 && i < rows + res << [i, right] + return res if res.length == rows * cols + end + end + left -= 1 + (right - 1).downto(left) do |i| + if i >= 0 && i < cols && bottom >= 0 && bottom < rows + res << [bottom, i] + return res if res.length == rows * cols + end + end + top -= 1 + (bottom - 1).downto(top) do |i| + if i >= 0 && i < rows && left >= 0 && left < cols + res << [i, left] + return res if res.length == rows * cols + end + end + end + res +end diff --git a/tests/501-1000/885. spiral-matrix-iii/sol.rs b/tests/501-1000/885. spiral-matrix-iii/sol.rs new file mode 100644 index 00000000..9b6f351c --- /dev/null +++ b/tests/501-1000/885. spiral-matrix-iii/sol.rs @@ -0,0 +1,50 @@ +impl Solution { + pub fn spiral_matrix_iii(rows: i32, cols: i32, r_start: i32, c_start: i32) -> Vec> { + let total = (rows * cols) as usize; + let mut res: Vec> = Vec::with_capacity(total); + res.push(vec![r_start, c_start]); + let mut top = r_start; + let mut bottom = r_start; + let mut left = c_start; + let mut right = c_start; + while res.len() < total { + right += 1; + for i in (left + 1)..=right { + if top >= 0 && top < rows && i >= 0 && i < cols { + res.push(vec![top, i]); + if res.len() == total { + return res; + } + } + } + bottom += 1; + for i in (top + 1)..=bottom { + if right >= 0 && right < cols && i >= 0 && i < rows { + res.push(vec![i, right]); + if res.len() == total { + return res; + } + } + } + left -= 1; + for i in ((left)..=(right - 1)).rev() { + if i >= 0 && i < cols && bottom >= 0 && bottom < rows { + res.push(vec![bottom, i]); + if res.len() == total { + return res; + } + } + } + top -= 1; + for i in ((top)..=(bottom - 1)).rev() { + if i >= 0 && i < rows && left >= 0 && left < cols { + res.push(vec![i, left]); + if res.len() == total { + return res; + } + } + } + } + res + } +} diff --git a/tests/501-1000/885. spiral-matrix-iii/sol.swift b/tests/501-1000/885. spiral-matrix-iii/sol.swift new file mode 100644 index 00000000..2a2539ca --- /dev/null +++ b/tests/501-1000/885. spiral-matrix-iii/sol.swift @@ -0,0 +1,40 @@ +class Solution { + func spiralMatrixIII(_ rows: Int, _ cols: Int, _ rStart: Int, _ cStart: Int) -> [[Int]] { + let total = rows * cols + var res: [[Int]] = [] + res.append([rStart, cStart]) + var top = rStart, bottom = rStart + var left = cStart, right = cStart + while res.count < total { + right += 1 + for i in (left + 1)...right { + if top >= 0 && top < rows && i >= 0 && i < cols { + res.append([top, i]) + if res.count == total { return res } + } + } + bottom += 1 + for i in (top + 1)...bottom { + if right >= 0 && right < cols && i >= 0 && i < rows { + res.append([i, right]) + if res.count == total { return res } + } + } + left -= 1 + for i in stride(from: right - 1, through: left, by: -1) { + if i >= 0 && i < cols && bottom >= 0 && bottom < rows { + res.append([bottom, i]) + if res.count == total { return res } + } + } + top -= 1 + for i in stride(from: bottom - 1, through: top, by: -1) { + if i >= 0 && i < rows && left >= 0 && left < cols { + res.append([i, left]) + if res.count == total { return res } + } + } + } + return res + } +} diff --git a/tests/501-1000/885. spiral-matrix-iii/sol.ts b/tests/501-1000/885. spiral-matrix-iii/sol.ts new file mode 100644 index 00000000..710f975e --- /dev/null +++ b/tests/501-1000/885. spiral-matrix-iii/sol.ts @@ -0,0 +1,45 @@ +function spiralMatrixIII( + rows: number, + cols: number, + rStart: number, + cStart: number, +): number[][] { + const total = rows * cols; + const res: number[][] = []; + res.push([rStart, cStart]); + let top = rStart, + bottom = rStart; + let left = cStart, + right = cStart; + while (res.length < total) { + right++; + for (let i = left + 1; i <= right; i++) { + if (top >= 0 && top < rows && i >= 0 && i < cols) { + res.push([top, i]); + if (res.length === total) return res; + } + } + bottom++; + for (let i = top + 1; i <= bottom; i++) { + if (right >= 0 && right < cols && i >= 0 && i < rows) { + res.push([i, right]); + if (res.length === total) return res; + } + } + left--; + for (let i = right - 1; i >= left; i--) { + if (i >= 0 && i < cols && bottom >= 0 && bottom < rows) { + res.push([bottom, i]); + if (res.length === total) return res; + } + } + top--; + for (let i = bottom - 1; i >= top; i--) { + if (i >= 0 && i < rows && left >= 0 && left < cols) { + res.push([i, left]); + if (res.length === total) return res; + } + } + } + return res; +} diff --git a/tests/501-1000/886. possible-bipartition/manifest.yaml b/tests/501-1000/886. possible-bipartition/manifest.yaml new file mode 100644 index 00000000..c161b715 --- /dev/null +++ b/tests/501-1000/886. possible-bipartition/manifest.yaml @@ -0,0 +1,470 @@ +entry: + id: 886 + title: "possible-bipartition" + params: + n: + type: int + dislikes: + type: array + items: + type: array + items: + type: int + call: + cpp: "Solution().possibleBipartition({n}, {dislikes})" + rust: "Solution::possible_bipartition({n}, {dislikes})" + python3: "Solution().possibleBipartition({n}, {dislikes})" + python2: "Solution().possibleBipartition({n}, {dislikes})" + ruby: "possible_bipartition({n}, {dislikes})" + java: "new Solution().possibleBipartition({n}, {dislikes})" + csharp: "new Solution().PossibleBipartition({n}, {dislikes})" + kotlin: "Solution().possibleBipartition({n}, {dislikes})" + go: "possibleBipartition({n}, {dislikes})" + dart: "Solution().possibleBipartition({n}, {dislikes})" + swift: "Solution().possibleBipartition({n}, {dislikes})" + typescript: "possibleBipartition({n}, {dislikes})" + +judge: + type: "exact" + +limits: + time_ms: 2000 + memory_mb: 256 + +oracle: + python3: + call: "Checker().possibleBipartition(n, dislikes, {result})" + checker: | + from collections import deque + + class Checker: + def possibleBipartition(self, n, dislikes, result): + graph = [[] for _ in range(n + 1)] + for a, b in dislikes: + graph[a].append(b) + graph[b].append(a) + color = [0] * (n + 1) + for start in range(1, n + 1): + if color[start] != 0: + continue + color[start] = 1 + q = deque([start]) + while q: + node = q.popleft() + for nb in graph[node]: + if color[nb] == color[node]: + return result is False + if color[nb] == 0: + color[nb] = -color[node] + q.append(nb) + return result is True + +seed: 886 + +tests: + - name: "example-1" + in: + n: 4 + dislikes: + - [1, 2] + - [1, 3] + - [2, 4] + out: true + - name: "example-2" + in: + n: 3 + dislikes: + - [1, 2] + - [1, 3] + - [2, 3] + out: false + - name: "single-person" + in: + n: 1 + dislikes: [] + out: true + - name: "two-no-edge" + in: + n: 2 + dislikes: [] + out: true + - name: "two-one-edge" + in: + n: 2 + dislikes: + - [1, 2] + out: true + - name: "path-3" + in: + n: 3 + dislikes: + - [1, 2] + - [2, 3] + out: true + - name: "triangle" + in: + n: 3 + dislikes: + - [1, 2] + - [2, 3] + - [1, 3] + out: false + - name: "square" + in: + n: 4 + dislikes: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 1] + out: true + - name: "star" + in: + n: 5 + dislikes: + - [1, 2] + - [1, 3] + - [1, 4] + - [1, 5] + out: true + - name: "odd-cycle-5" + in: + n: 5 + dislikes: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 5] + - [1, 5] + out: false + - name: "disconnected-edges" + in: + n: 6 + dislikes: + - [1, 2] + - [3, 4] + - [5, 6] + out: true + - name: "disconnected-with-triangle" + in: + n: 6 + dislikes: + - [1, 2] + - [2, 3] + - [1, 3] + - [4, 5] + out: false + - name: "complete-bipartite-2x3" + in: + n: 5 + dislikes: + - [1, 3] + - [1, 4] + - [1, 5] + - [2, 3] + - [2, 4] + - [2, 5] + out: true + - name: "complete-bipartite-3x3" + in: + n: 6 + dislikes: + - [1, 4] + - [1, 5] + - [1, 6] + - [2, 4] + - [2, 5] + - [2, 6] + - [3, 4] + - [3, 5] + - [3, 6] + out: true + - name: "path-8" + in: + n: 8 + dislikes: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 5] + - [5, 6] + - [6, 7] + - [7, 8] + out: true + - name: "even-cycle-6" + in: + n: 6 + dislikes: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 5] + - [5, 6] + - [1, 6] + out: true + - name: "odd-cycle-7" + in: + n: 7 + dislikes: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 5] + - [5, 6] + - [6, 7] + - [1, 7] + out: false + - name: "tree" + in: + n: 8 + dislikes: + - [1, 2] + - [1, 3] + - [2, 4] + - [2, 5] + - [3, 6] + - [6, 7] + - [6, 8] + out: true + - name: "ladder" + in: + n: 8 + dislikes: + - [1, 2] + - [2, 3] + - [3, 4] + - [5, 6] + - [6, 7] + - [7, 8] + - [1, 5] + - [2, 6] + - [3, 7] + - [4, 8] + out: true + - name: "triangle-plus-path" + in: + n: 8 + dislikes: + - [1, 2] + - [2, 3] + - [1, 3] + - [4, 5] + - [5, 6] + - [6, 7] + out: false + - name: "many-isolated" + in: + n: 10 + dislikes: + - [1, 2] + - [3, 4] + out: true + - name: "path-10" + in: + n: 10 + dislikes: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 5] + - [5, 6] + - [6, 7] + - [7, 8] + - [8, 9] + - [9, 10] + out: true + - name: "odd-cycle-9" + in: + n: 9 + dislikes: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 5] + - [5, 6] + - [6, 7] + - [7, 8] + - [8, 9] + - [1, 9] + out: false + - name: "two-squares" + in: + n: 10 + dislikes: + - [1, 2] + - [2, 3] + - [3, 4] + - [1, 4] + - [5, 6] + - [6, 7] + - [7, 8] + - [5, 8] + out: true + - name: "square-and-triangle" + in: + n: 10 + dislikes: + - [1, 2] + - [2, 3] + - [3, 4] + - [1, 4] + - [5, 6] + - [6, 7] + - [5, 7] + out: false + - name: "skip-edges-small" + in: + n: 12 + dislikes: + - [1, 3] + - [2, 4] + - [3, 5] + - [4, 6] + - [5, 7] + - [6, 8] + - [7, 9] + - [8, 10] + - [9, 11] + - [10, 12] + out: true + - name: "dense-bipartite-4x4" + in: + n: 8 + dislikes: + - [1, 5] + - [1, 6] + - [1, 7] + - [1, 8] + - [2, 5] + - [2, 6] + - [2, 7] + - [2, 8] + - [3, 5] + - [3, 6] + - [3, 7] + - [3, 8] + - [4, 5] + - [4, 6] + - [4, 7] + - [4, 8] + out: true + - name: "component-cycle-and-isolated" + in: + n: 14 + dislikes: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 1] + - [5, 6] + - [6, 7] + out: true + - name: "component-odd-cycle-and-isolated" + in: + n: 14 + dislikes: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 5] + - [1, 5] + - [6, 7] + out: false + - name: "path-20" + in: + n: 20 + dislikes: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 5] + - [5, 6] + - [6, 7] + - [7, 8] + - [8, 9] + - [9, 10] + - [10, 11] + - [11, 12] + - [12, 13] + - [13, 14] + - [14, 15] + - [15, 16] + - [16, 17] + - [17, 18] + - [18, 19] + - [19, 20] + out: true + - name: "matching-20" + in: + n: 20 + dislikes: + - [1, 11] + - [2, 12] + - [3, 13] + - [4, 14] + - [5, 15] + - [6, 16] + - [7, 17] + - [8, 18] + - [9, 19] + - [10, 20] + out: true + - name: "odd-cycle-11" + in: + n: 11 + dislikes: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 5] + - [5, 6] + - [6, 7] + - [7, 8] + - [8, 9] + - [9, 10] + - [10, 11] + - [1, 11] + out: false + - name: "hub-and-spokes-two-hubs" + in: + n: 12 + dislikes: + - [1, 2] + - [1, 3] + - [1, 4] + - [1, 5] + - [6, 7] + - [6, 8] + - [6, 9] + - [6, 10] + - [5, 6] + out: true + - name: "triangle-hidden-in-large" + in: + n: 15 + dislikes: + - [1, 2] + - [2, 3] + - [1, 3] + - [4, 8] + - [5, 9] + - [6, 10] + - [7, 11] + out: false + - name: "long-even-cycle-12" + in: + n: 12 + dislikes: + - [1, 2] + - [2, 3] + - [3, 4] + - [4, 5] + - [5, 6] + - [6, 7] + - [7, 8] + - [8, 9] + - [9, 10] + - [10, 11] + - [11, 12] + - [1, 12] + out: true diff --git a/tests/501-1000/886. possible-bipartition/sol.cpp b/tests/501-1000/886. possible-bipartition/sol.cpp new file mode 100644 index 00000000..31a88b88 --- /dev/null +++ b/tests/501-1000/886. possible-bipartition/sol.cpp @@ -0,0 +1,41 @@ +class Solution { +public: + bool possibleBipartition(int n, vector>& dislikes) { + unordered_map> graph; + for (auto& edge : dislikes) { + int u = edge[0], v = edge[1]; + graph[u].push_back(v); + graph[v].push_back(u); + } + + vector color(n + 1, 0); + + for (int node = 1; node <= n; node++) { + if (color[node] != 0 || graph.find(node) == graph.end()) { + continue; + } + + queue q; + q.push(node); + color[node] = 1; + + while (!q.empty()) { + int curr = q.front(); + q.pop(); + + for (int neighbor : graph[curr]) { + if (color[neighbor] == color[curr]) { + return false; + } + + if (color[neighbor] == 0) { + color[neighbor] = -color[curr]; + q.push(neighbor); + } + } + } + } + + return true; + } +}; diff --git a/tests/501-1000/886. possible-bipartition/sol.cs b/tests/501-1000/886. possible-bipartition/sol.cs new file mode 100644 index 00000000..d71cbee0 --- /dev/null +++ b/tests/501-1000/886. possible-bipartition/sol.cs @@ -0,0 +1,41 @@ +public class Solution { + public bool PossibleBipartition(int n, int[][] dislikes) { + Dictionary> graph = new Dictionary>(); + foreach (var edge in dislikes) { + int u = edge[0], v = edge[1]; + if (!graph.ContainsKey(u)) graph[u] = new List(); + if (!graph.ContainsKey(v)) graph[v] = new List(); + graph[u].Add(v); + graph[v].Add(u); + } + + int[] color = new int[n + 1]; + + for (int node = 1; node <= n; node++) { + if (color[node] != 0 || !graph.ContainsKey(node)) { + continue; + } + + Queue queue = new Queue(); + queue.Enqueue(node); + color[node] = 1; + + while (queue.Count > 0) { + int curr = queue.Dequeue(); + + foreach (int neighbor in graph[curr]) { + if (color[neighbor] == color[curr]) { + return false; + } + + if (color[neighbor] == 0) { + color[neighbor] = -color[curr]; + queue.Enqueue(neighbor); + } + } + } + } + + return true; + } +} diff --git a/tests/501-1000/886. possible-bipartition/sol.dart b/tests/501-1000/886. possible-bipartition/sol.dart new file mode 100644 index 00000000..28bba36a --- /dev/null +++ b/tests/501-1000/886. possible-bipartition/sol.dart @@ -0,0 +1,40 @@ +class Solution { + bool possibleBipartition(int n, List> dislikes) { + Map> graph = {}; + for (var edge in dislikes) { + int u = edge[0], v = edge[1]; + graph.putIfAbsent(u, () => []); + graph.putIfAbsent(v, () => []); + graph[u]!.add(v); + graph[v]!.add(u); + } + + List color = List.filled(n + 1, 0); + + for (int node = 1; node <= n; node++) { + if (color[node] != 0 || !graph.containsKey(node)) { + continue; + } + + List queue = [node]; + color[node] = 1; + + while (queue.isNotEmpty) { + int curr = queue.removeAt(0); + + for (int neighbor in graph[curr]!) { + if (color[neighbor] == color[curr]) { + return false; + } + + if (color[neighbor] == 0) { + color[neighbor] = -color[curr]; + queue.add(neighbor); + } + } + } + } + + return true; + } +} diff --git a/tests/501-1000/886. possible-bipartition/sol.go b/tests/501-1000/886. possible-bipartition/sol.go new file mode 100644 index 00000000..a7e200b8 --- /dev/null +++ b/tests/501-1000/886. possible-bipartition/sol.go @@ -0,0 +1,40 @@ +func possibleBipartition(n int, dislikes [][]int) bool { + graph := make(map[int][]int) + for _, edge := range dislikes { + u, v := edge[0], edge[1] + graph[u] = append(graph[u], v) + graph[v] = append(graph[v], u) + } + + color := make([]int, n+1) + + for node := 1; node <= n; node++ { + if color[node] != 0 { + continue + } + if _, exists := graph[node]; !exists { + continue + } + + queue := []int{node} + color[node] = 1 + + for len(queue) > 0 { + curr := queue[0] + queue = queue[1:] + + for _, neighbor := range graph[curr] { + if color[neighbor] == color[curr] { + return false + } + + if color[neighbor] == 0 { + color[neighbor] = -color[curr] + queue = append(queue, neighbor) + } + } + } + } + + return true +} diff --git a/tests/501-1000/886. possible-bipartition/sol.java b/tests/501-1000/886. possible-bipartition/sol.java new file mode 100644 index 00000000..2c5c2328 --- /dev/null +++ b/tests/501-1000/886. possible-bipartition/sol.java @@ -0,0 +1,39 @@ +class Solution { + public boolean possibleBipartition(int n, int[][] dislikes) { + Map> graph = new HashMap<>(); + for (int[] edge : dislikes) { + int u = edge[0], v = edge[1]; + graph.computeIfAbsent(u, k -> new ArrayList<>()).add(v); + graph.computeIfAbsent(v, k -> new ArrayList<>()).add(u); + } + + int[] color = new int[n + 1]; + + for (int node = 1; node <= n; node++) { + if (color[node] != 0 || !graph.containsKey(node)) { + continue; + } + + Queue queue = new LinkedList<>(); + queue.offer(node); + color[node] = 1; + + while (!queue.isEmpty()) { + int curr = queue.poll(); + + for (int neighbor : graph.get(curr)) { + if (color[neighbor] == color[curr]) { + return false; + } + + if (color[neighbor] == 0) { + color[neighbor] = -color[curr]; + queue.offer(neighbor); + } + } + } + } + + return true; + } +} diff --git a/tests/501-1000/886. possible-bipartition/sol.kt b/tests/501-1000/886. possible-bipartition/sol.kt new file mode 100644 index 00000000..6c5f4a79 --- /dev/null +++ b/tests/501-1000/886. possible-bipartition/sol.kt @@ -0,0 +1,40 @@ +class Solution { + fun possibleBipartition(n: Int, dislikes: Array): Boolean { + val graph = mutableMapOf>() + for (edge in dislikes) { + val u = edge[0] + val v = edge[1] + graph.getOrPut(u) { mutableListOf() }.add(v) + graph.getOrPut(v) { mutableListOf() }.add(u) + } + + val color = IntArray(n + 1) + + for (node in 1..n) { + if (color[node] != 0 || !graph.containsKey(node)) { + continue + } + + val queue = ArrayDeque() + queue.add(node) + color[node] = 1 + + while (queue.isNotEmpty()) { + val curr = queue.removeFirst() + + for (neighbor in graph[curr]!!) { + if (color[neighbor] == color[curr]) { + return false + } + + if (color[neighbor] == 0) { + color[neighbor] = -color[curr] + queue.add(neighbor) + } + } + } + } + + return true + } +} diff --git a/tests/501-1000/886. possible-bipartition/sol.py b/tests/501-1000/886. possible-bipartition/sol.py new file mode 100644 index 00000000..df62bec7 --- /dev/null +++ b/tests/501-1000/886. possible-bipartition/sol.py @@ -0,0 +1,38 @@ +class Solution: + def possibleBipartition(self, n: int, dislikes: List[List[int]]) -> bool: + # Step 1: Build the graph + graph = {} + for u, v in dislikes: + if u not in graph: + graph[u] = [] + if v not in graph: + graph[v] = [] + graph[u].append(v) + graph[v].append(u) + + # color[i] = 0 (unvisited), 1 (Group A), -1 (Group B) + color = [0] * (n + 1) + + # Step 2: Iterate through all nodes (to handle disconnected components) + for node in range(1, n + 1): + if color[node] != 0 or node not in graph: + continue + + # Start BFS + queue = [node] + color[node] = 1 # Start coloring with 1 + + while queue: + curr = queue.pop(0) + + for neighbor in graph[curr]: + # If neighbor has the same color, bipartition is impossible + if color[neighbor] == color[curr]: + return False + + # If neighbor is not colored, give it the opposite color + if color[neighbor] == 0: + color[neighbor] = -color[curr] + queue.append(neighbor) + + return True diff --git a/tests/501-1000/886. possible-bipartition/sol.py2 b/tests/501-1000/886. possible-bipartition/sol.py2 new file mode 100644 index 00000000..e89e2b08 --- /dev/null +++ b/tests/501-1000/886. possible-bipartition/sol.py2 @@ -0,0 +1,35 @@ +class Solution(object): + def possibleBipartition(self, n, dislikes): + """ + :type n: int + :type dislikes: List[List[int]] + :rtype: bool + """ + graph = {} + for u, v in dislikes: + if u not in graph: graph[u] = [] + if v not in graph: graph[v] = [] + graph[u].append(v) + graph[v].append(u) + + color = [0] * (n + 1) + + for node in range(1, n + 1): + if color[node] != 0 or node not in graph: + continue + + queue = [node] + color[node] = 1 + + while queue: + curr = queue.pop(0) + + for neighbor in graph[curr]: + if color[neighbor] == color[curr]: + return False + + if color[neighbor] == 0: + color[neighbor] = -color[curr] + queue.append(neighbor) + + return True diff --git a/tests/501-1000/886. possible-bipartition/sol.rb b/tests/501-1000/886. possible-bipartition/sol.rb new file mode 100644 index 00000000..23567aca --- /dev/null +++ b/tests/501-1000/886. possible-bipartition/sol.rb @@ -0,0 +1,36 @@ +# @param {Integer} n +# @param {Integer[][]} dislikes +# @return {Boolean} +def possible_bipartition(n, dislikes) + graph = {} + dislikes.each do |u, v| + graph[u] = [] unless graph.key?(u) + graph[v] = [] unless graph.key?(v) + graph[u] << v + graph[v] << u + end + + color = Array.new(n + 1, 0) + + (1..n).each do |node| + next if color[node] != 0 || !graph.key?(node) + + queue = [node] + color[node] = 1 + + until queue.empty? + curr = queue.shift + + graph[curr].each do |neighbor| + return false if color[neighbor] == color[curr] + + if color[neighbor] == 0 + color[neighbor] = -color[curr] + queue.push(neighbor) + end + end + end + end + + true +end diff --git a/tests/501-1000/886. possible-bipartition/sol.rs b/tests/501-1000/886. possible-bipartition/sol.rs new file mode 100644 index 00000000..0b1a7cc4 --- /dev/null +++ b/tests/501-1000/886. possible-bipartition/sol.rs @@ -0,0 +1,41 @@ +impl Solution { + pub fn possible_bipartition(n: i32, dislikes: Vec>) -> bool { + use std::collections::{HashMap, VecDeque}; + + let n = n as usize; + let mut graph: HashMap> = HashMap::new(); + for edge in dislikes { + let u = edge[0] as usize; + let v = edge[1] as usize; + graph.entry(u).or_insert_with(Vec::new).push(v); + graph.entry(v).or_insert_with(Vec::new).push(u); + } + + let mut color = vec![0; n + 1]; + + for node in 1..=n { + if color[node] != 0 || !graph.contains_key(&node) { + continue; + } + + let mut queue = VecDeque::new(); + queue.push_back(node); + color[node] = 1; + + while let Some(curr) = queue.pop_front() { + for &neighbor in graph[&curr].iter() { + if color[neighbor] == color[curr] { + return false; + } + + if color[neighbor] == 0 { + color[neighbor] = -color[curr]; + queue.push_back(neighbor); + } + } + } + } + + true + } +} diff --git a/tests/501-1000/886. possible-bipartition/sol.swift b/tests/501-1000/886. possible-bipartition/sol.swift new file mode 100644 index 00000000..dadf7d34 --- /dev/null +++ b/tests/501-1000/886. possible-bipartition/sol.swift @@ -0,0 +1,38 @@ +class Solution { + func possibleBipartition(_ n: Int, _ dislikes: [[Int]]) -> Bool { + var graph = [Int: [Int]]() + for edge in dislikes { + let u = edge[0], v = edge[1] + graph[u, default: []].append(v) + graph[v, default: []].append(u) + } + + var color = Array(repeating: 0, count: n + 1) + + for node in 1...n { + if color[node] != 0 || graph[node] == nil { + continue + } + + var queue = [node] + color[node] = 1 + + while !queue.isEmpty { + let curr = queue.removeFirst() + + for neighbor in graph[curr]! { + if color[neighbor] == color[curr] { + return false + } + + if color[neighbor] == 0 { + color[neighbor] = -color[curr] + queue.append(neighbor) + } + } + } + } + + return true + } +} diff --git a/tests/501-1000/886. possible-bipartition/sol.ts b/tests/501-1000/886. possible-bipartition/sol.ts new file mode 100644 index 00000000..ea0e6b17 --- /dev/null +++ b/tests/501-1000/886. possible-bipartition/sol.ts @@ -0,0 +1,37 @@ +function possibleBipartition(n: number, dislikes: number[][]): boolean { + const graph: Map = new Map(); + for (const [u, v] of dislikes) { + if (!graph.has(u)) graph.set(u, []); + if (!graph.has(v)) graph.set(v, []); + graph.get(u)!.push(v); + graph.get(v)!.push(u); + } + + const color: number[] = new Array(n + 1).fill(0); + + for (let node = 1; node <= n; node++) { + if (color[node] !== 0 || !graph.has(node)) { + continue; + } + + const queue: number[] = [node]; + color[node] = 1; + + while (queue.length > 0) { + const curr = queue.shift()!; + + for (const neighbor of graph.get(curr)!) { + if (color[neighbor] === color[curr]) { + return false; + } + + if (color[neighbor] === 0) { + color[neighbor] = -color[curr]; + queue.push(neighbor); + } + } + } + } + + return true; +} diff --git a/tests/501-1000/887. super-egg-drop/manifest.yaml b/tests/501-1000/887. super-egg-drop/manifest.yaml new file mode 100644 index 00000000..7a358f41 --- /dev/null +++ b/tests/501-1000/887. super-egg-drop/manifest.yaml @@ -0,0 +1,205 @@ +entry: + id: 887 + title: "super-egg-drop" + params: + k: + type: int + n: + type: int + call: + cpp: "Solution().superEggDrop({k}, {n})" + rust: "Solution::super_egg_drop({k}, {n})" + python3: "Solution().superEggDrop({k}, {n})" + python2: "Solution().superEggDrop({k}, {n})" + ruby: "super_egg_drop({k}, {n})" + java: "new Solution().superEggDrop({k}, {n})" + csharp: "new Solution().SuperEggDrop({k}, {n})" + kotlin: "Solution().superEggDrop({k}, {n})" + go: "superEggDrop({k}, {n})" + dart: "Solution().superEggDrop({k}, {n})" + swift: "Solution().superEggDrop({k}, {n})" + typescript: "superEggDrop({k}, {n})" + +judge: + type: "exact" + +limits: + time_ms: 1000 + memory_mb: 300 + +oracle: + python3: + call: "Checker().superEggDrop(k, n, {result})" + checker: | + class Checker: + def superEggDrop(self, k, n, result): + if not isinstance(result, int): + return False + if k == 1: + return result == n + def can(moves): + total = 0 + cur = 1 + for _ in range(k): + cur = cur * (moves - _) + cur //= (_ + 1) + total += cur + if total >= n: + return True + return total >= n + lo, hi = 0, n + while lo < hi: + mid = (lo + hi) // 2 + if can(mid): + hi = mid + else: + lo = mid + 1 + return result == lo + +seed: 887 + +tests: + - name: "t1" + in: + k: 1 + n: 1 + - name: "t2" + in: + k: 1 + n: 2 + - name: "t3" + in: + k: 1 + n: 10 + - name: "t4" + in: + k: 2 + n: 1 + - name: "t5" + in: + k: 2 + n: 2 + - name: "t6" + in: + k: 2 + n: 3 + - name: "t7" + in: + k: 2 + n: 6 + - name: "t8" + in: + k: 2 + n: 10 + - name: "t9" + in: + k: 2 + n: 100 + - name: "t10" + in: + k: 3 + n: 14 + - name: "t11" + in: + k: 3 + n: 25 + - name: "t12" + in: + k: 3 + n: 100 + - name: "t13" + in: + k: 3 + n: 1000 + - name: "t14" + in: + k: 4 + n: 500 + - name: "t15" + in: + k: 4 + n: 10000 + - name: "t16" + in: + k: 5 + n: 100 + - name: "t17" + in: + k: 5 + n: 1000 + - name: "t18" + in: + k: 5 + n: 10000 + - name: "t19" + in: + k: 6 + n: 5000 + - name: "t20" + in: + k: 7 + n: 10000 + - name: "t21" + in: + k: 8 + n: 9999 + - name: "t22" + in: + k: 10 + n: 1 + - name: "t23" + in: + k: 10 + n: 100 + - name: "t24" + in: + k: 10 + n: 1000 + - name: "t25" + in: + k: 10 + n: 10000 + - name: "t26" + in: + k: 20 + n: 100 + - name: "t27" + in: + k: 20 + n: 1000 + - name: "t28" + in: + k: 20 + n: 10000 + - name: "t29" + in: + k: 50 + n: 2 + - name: "t30" + in: + k: 50 + n: 100 + - name: "t31" + in: + k: 50 + n: 1000 + - name: "t32" + in: + k: 50 + n: 10000 + - name: "t33" + in: + k: 100 + n: 1 + - name: "t34" + in: + k: 100 + n: 100 + - name: "t35" + in: + k: 100 + n: 1000 + - name: "t36" + in: + k: 100 + n: 10000 diff --git a/tests/501-1000/887. super-egg-drop/sol.cpp b/tests/501-1000/887. super-egg-drop/sol.cpp new file mode 100644 index 00000000..e786be6c --- /dev/null +++ b/tests/501-1000/887. super-egg-drop/sol.cpp @@ -0,0 +1,36 @@ +class Solution { +public: + int superEggDrop(int k, int n) { + vector> memo(k + 1, vector(n + 1, -1)); + + function solve = [&](int eggs, int floors) -> int { + if (floors <= 1 || eggs == 1) { + return floors; + } + if (memo[eggs][floors] != -1) { + return memo[eggs][floors]; + } + + int low = 1, high = floors; + int ans = floors; + + while (low <= high) { + int mid = (low + high) / 2; + int breakCase = solve(eggs - 1, mid - 1); + int notBreakCase = solve(eggs, floors - mid); + + ans = min(ans, 1 + max(breakCase, notBreakCase)); + if (breakCase < notBreakCase) { + low = mid + 1; + } else { + high = mid - 1; + } + } + + memo[eggs][floors] = ans; + return ans; + }; + + return solve(k, n); + } +}; diff --git a/tests/501-1000/887. super-egg-drop/sol.cs b/tests/501-1000/887. super-egg-drop/sol.cs new file mode 100644 index 00000000..b0fd4f1d --- /dev/null +++ b/tests/501-1000/887. super-egg-drop/sol.cs @@ -0,0 +1,36 @@ +public class Solution { + public int SuperEggDrop(int k, int n) { + int[,] memo = new int[k + 1, n + 1]; + for (int i = 0; i <= k; i++) { + for (int j = 0; j <= n; j++) { + memo[i, j] = -1; + } + } + + int solve(int eggs, int floors) { + if (floors <= 1 || eggs == 1) return floors; + if (memo[eggs, floors] != -1) return memo[eggs, floors]; + + int low = 1, high = floors; + int ans = floors; + + while (low <= high) { + int mid = (low + high) / 2; + int breakCase = solve(eggs - 1, mid - 1); + int notBreakCase = solve(eggs, floors - mid); + + ans = Math.Min(ans, 1 + Math.Max(breakCase, notBreakCase)); + if (breakCase < notBreakCase) { + low = mid + 1; + } else { + high = mid - 1; + } + } + + memo[eggs, floors] = ans; + return ans; + } + + return solve(k, n); + } +} diff --git a/tests/501-1000/887. super-egg-drop/sol.dart b/tests/501-1000/887. super-egg-drop/sol.dart new file mode 100644 index 00000000..bc6683f3 --- /dev/null +++ b/tests/501-1000/887. super-egg-drop/sol.dart @@ -0,0 +1,32 @@ +class Solution { + int superEggDrop(int k, int n) { + List> memo = List.generate(k + 1, (_) => List.filled(n + 1, -1)); + + int solve(int eggs, int floors) { + if (floors <= 1 || eggs == 1) return floors; + if (memo[eggs][floors] != -1) return memo[eggs][floors]; + + int low = 1, high = floors; + int ans = floors; + + while (low <= high) { + int mid = (low + high) ~/ 2; + int breakCase = solve(eggs - 1, mid - 1); + int notBreakCase = solve(eggs, floors - mid); + + int cur = 1 + (breakCase > notBreakCase ? breakCase : notBreakCase); + if (cur < ans) ans = cur; + if (breakCase < notBreakCase) { + low = mid + 1; + } else { + high = mid - 1; + } + } + + memo[eggs][floors] = ans; + return ans; + } + + return solve(k, n); + } +} diff --git a/tests/501-1000/887. super-egg-drop/sol.go b/tests/501-1000/887. super-egg-drop/sol.go new file mode 100644 index 00000000..707cd59c --- /dev/null +++ b/tests/501-1000/887. super-egg-drop/sol.go @@ -0,0 +1,43 @@ +func superEggDrop(k int, n int) int { + memo := make([][]int, k+1) + for i := range memo { + memo[i] = make([]int, n+1) + for j := range memo[i] { + memo[i][j] = -1 + } + } + + var solve func(int, int) int + solve = func(eggs, floors int) int { + if floors <= 1 || eggs == 1 { + return floors + } + if memo[eggs][floors] != -1 { + return memo[eggs][floors] + } + + low, high := 1, floors + ans := floors + + for low <= high { + mid := (low + high) / 2 + breakCase := solve(eggs-1, mid-1) + notBreakCase := solve(eggs, floors-mid) + + cur := 1 + max(breakCase, notBreakCase) + if cur < ans { + ans = cur + } + if breakCase < notBreakCase { + low = mid + 1 + } else { + high = mid - 1 + } + } + + memo[eggs][floors] = ans + return ans + } + + return solve(k, n) +} diff --git a/tests/501-1000/887. super-egg-drop/sol.java b/tests/501-1000/887. super-egg-drop/sol.java new file mode 100644 index 00000000..c842d891 --- /dev/null +++ b/tests/501-1000/887. super-egg-drop/sol.java @@ -0,0 +1,39 @@ +class Solution { + public int superEggDrop(int k, int n) { + int[][] memo = new int[k + 1][n + 1]; + for (int i = 0; i <= k; i++) { + for (int j = 0; j <= n; j++) { + memo[i][j] = -1; + } + } + return solve(k, n, memo); + } + + private int solve(int eggs, int floors, int[][] memo) { + if (floors <= 1 || eggs == 1) { + return floors; + } + if (memo[eggs][floors] != -1) { + return memo[eggs][floors]; + } + + int low = 1, high = floors; + int ans = floors; + + while (low <= high) { + int mid = (low + high) / 2; + int breakCase = solve(eggs - 1, mid - 1, memo); + int notBreakCase = solve(eggs, floors - mid, memo); + + ans = Math.min(ans, 1 + Math.max(breakCase, notBreakCase)); + if (breakCase < notBreakCase) { + low = mid + 1; + } else { + high = mid - 1; + } + } + + memo[eggs][floors] = ans; + return ans; + } +} diff --git a/tests/501-1000/887. super-egg-drop/sol.kt b/tests/501-1000/887. super-egg-drop/sol.kt new file mode 100644 index 00000000..e290234a --- /dev/null +++ b/tests/501-1000/887. super-egg-drop/sol.kt @@ -0,0 +1,32 @@ +class Solution { + fun superEggDrop(k: Int, n: Int): Int { + val memo = Array(k + 1) { IntArray(n + 1) { -1 } } + + fun solve(eggs: Int, floors: Int): Int { + if (floors <= 1 || eggs == 1) return floors + if (memo[eggs][floors] != -1) return memo[eggs][floors] + + var low = 1 + var high = floors + var ans = floors + + while (low <= high) { + val mid = (low + high) / 2 + val breakCase = solve(eggs - 1, mid - 1) + val notBreakCase = solve(eggs, floors - mid) + + ans = minOf(ans, 1 + maxOf(breakCase, notBreakCase)) + if (breakCase < notBreakCase) { + low = mid + 1 + } else { + high = mid - 1 + } + } + + memo[eggs][floors] = ans + return ans + } + + return solve(k, n) + } +} diff --git a/tests/501-1000/887. super-egg-drop/sol.py b/tests/501-1000/887. super-egg-drop/sol.py new file mode 100644 index 00000000..72df37ce --- /dev/null +++ b/tests/501-1000/887. super-egg-drop/sol.py @@ -0,0 +1,28 @@ +class Solution: + def superEggDrop(self, k: int, n: int) -> int: + memo = {} + + def solve(eggs, floors): + if floors <= 1 or eggs == 1: + return floors + if (eggs, floors) in memo: + return memo[(eggs, floors)] + + low, high = 1, floors + ans = floors + + while low <= high: + mid = (low + high) // 2 + break_case = solve(eggs - 1, mid - 1) + not_break_case = solve(eggs, floors - mid) + + ans = min(ans, 1 + max(break_case, not_break_case)) + if break_case < not_break_case: + low = mid + 1 + else: + high = mid - 1 + + memo[(eggs, floors)] = ans + return ans + + return solve(k, n) diff --git a/tests/501-1000/887. super-egg-drop/sol.py2 b/tests/501-1000/887. super-egg-drop/sol.py2 new file mode 100644 index 00000000..3f887264 --- /dev/null +++ b/tests/501-1000/887. super-egg-drop/sol.py2 @@ -0,0 +1,33 @@ +class Solution(object): + def superEggDrop(self, k, n): + """ + :type k: int + :type n: int + :rtype: int + """ + memo = {} + + def solve(eggs, floors): + if floors <= 1 or eggs == 1: + return floors + if (eggs, floors) in memo: + return memo[(eggs, floors)] + + low, high = 1, floors + ans = floors + + while low <= high: + mid = (low + high) // 2 + break_case = solve(eggs - 1, mid - 1) + not_break_case = solve(eggs, floors - mid) + + ans = min(ans, 1 + max(break_case, not_break_case)) + if break_case < not_break_case: + low = mid + 1 + else: + high = mid - 1 + + memo[(eggs, floors)] = ans + return ans + + return solve(k, n) diff --git a/tests/501-1000/887. super-egg-drop/sol.rb b/tests/501-1000/887. super-egg-drop/sol.rb new file mode 100644 index 00000000..2cd194d4 --- /dev/null +++ b/tests/501-1000/887. super-egg-drop/sol.rb @@ -0,0 +1,33 @@ +# @param {Integer} k +# @param {Integer} n +# @return {Integer} +def super_egg_drop(k, n) + memo = {} + + solve = lambda do |eggs, floors| + return floors if floors <= 1 || eggs == 1 + return memo[[eggs, floors]] if memo.key?([eggs, floors]) + + low = 1 + high = floors + ans = floors + + while low <= high + mid = (low + high) / 2 + break_case = solve.call(eggs - 1, mid - 1) + not_break_case = solve.call(eggs, floors - mid) + + ans = [ans, 1 + [break_case, not_break_case].max].min + if break_case < not_break_case + low = mid + 1 + else + high = mid - 1 + end + end + + memo[[eggs, floors]] = ans + ans + end + + solve.call(k, n) +end diff --git a/tests/501-1000/887. super-egg-drop/sol.rs b/tests/501-1000/887. super-egg-drop/sol.rs new file mode 100644 index 00000000..da74c210 --- /dev/null +++ b/tests/501-1000/887. super-egg-drop/sol.rs @@ -0,0 +1,38 @@ +impl Solution { + pub fn super_egg_drop(k: i32, n: i32) -> i32 { + let k = k as usize; + let n = n as usize; + let mut memo = vec![vec![-1; n + 1]; k + 1]; + + fn solve(eggs: usize, floors: usize, memo: &mut Vec>) -> i32 { + if floors <= 1 || eggs == 1 { + return floors as i32; + } + if memo[eggs][floors] != -1 { + return memo[eggs][floors]; + } + + let mut low = 1; + let mut high = floors; + let mut ans = floors as i32; + + while low <= high { + let mid = (low + high) / 2; + let break_case = solve(eggs - 1, mid - 1, memo); + let not_break_case = solve(eggs, floors - mid, memo); + + ans = ans.min(1 + break_case.max(not_break_case)); + if break_case < not_break_case { + low = mid + 1; + } else { + high = mid - 1; + } + } + + memo[eggs][floors] = ans; + ans + } + + solve(k, n, &mut memo) + } +} diff --git a/tests/501-1000/887. super-egg-drop/sol.swift b/tests/501-1000/887. super-egg-drop/sol.swift new file mode 100644 index 00000000..650244c6 --- /dev/null +++ b/tests/501-1000/887. super-egg-drop/sol.swift @@ -0,0 +1,36 @@ +class Solution { + func superEggDrop(_ k: Int, _ n: Int) -> Int { + var memo = Array(repeating: Array(repeating: -1, count: n + 1), count: k + 1) + + func solve(_ eggs: Int, _ floors: Int) -> Int { + if floors <= 1 || eggs == 1 { + return floors + } + if memo[eggs][floors] != -1 { + return memo[eggs][floors] + } + + var low = 1 + var high = floors + var ans = floors + + while low <= high { + let mid = (low + high) / 2 + let breakCase = solve(eggs - 1, mid - 1) + let notBreakCase = solve(eggs, floors - mid) + + ans = min(ans, 1 + max(breakCase, notBreakCase)) + if breakCase < notBreakCase { + low = mid + 1 + } else { + high = mid - 1 + } + } + + memo[eggs][floors] = ans + return ans + } + + return solve(k, n) + } +} diff --git a/tests/501-1000/887. super-egg-drop/sol.ts b/tests/501-1000/887. super-egg-drop/sol.ts new file mode 100644 index 00000000..8022d5a6 --- /dev/null +++ b/tests/501-1000/887. super-egg-drop/sol.ts @@ -0,0 +1,32 @@ +function superEggDrop(k: number, n: number): number { + const memo: number[][] = Array.from({ length: k + 1 }, () => + Array(n + 1).fill(-1), + ); + + function solve(eggs: number, floors: number): number { + if (floors <= 1 || eggs === 1) return floors; + if (memo[eggs][floors] !== -1) return memo[eggs][floors]; + + let low = 1, + high = floors; + let ans = floors; + + while (low <= high) { + const mid = Math.floor((low + high) / 2); + const breakCase = solve(eggs - 1, mid - 1); + const notBreakCase = solve(eggs, floors - mid); + + ans = Math.min(ans, 1 + Math.max(breakCase, notBreakCase)); + if (breakCase < notBreakCase) { + low = mid + 1; + } else { + high = mid - 1; + } + } + + memo[eggs][floors] = ans; + return ans; + } + + return solve(k, n); +} diff --git a/tests/501-1000/888. fair-candy-swap/manifest.yaml b/tests/501-1000/888. fair-candy-swap/manifest.yaml new file mode 100644 index 00000000..eb411102 --- /dev/null +++ b/tests/501-1000/888. fair-candy-swap/manifest.yaml @@ -0,0 +1,201 @@ +entry: + id: 888 + title: "fair-candy-swap" + params: + aliceSizes: + type: array + items: + type: int + bobSizes: + type: array + items: + type: int + call: + cpp: "Solution().fairCandySwap({aliceSizes}, {bobSizes})" + rust: "Solution::fair_candy_swap({aliceSizes}, {bobSizes})" + python3: "Solution().fairCandySwap({aliceSizes}, {bobSizes})" + python2: "Solution().fairCandySwap({aliceSizes}, {bobSizes})" + ruby: "fair_candy_swap({aliceSizes}, {bobSizes})" + java: "new Solution().fairCandySwap({aliceSizes}, {bobSizes})" + csharp: "new Solution().FairCandySwap({aliceSizes}, {bobSizes})" + kotlin: "Solution().fairCandySwap({aliceSizes}, {bobSizes})" + go: "fairCandySwap({aliceSizes}, {bobSizes})" + dart: "Solution().fairCandySwap({aliceSizes}, {bobSizes})" + swift: "Solution().fairCandySwap({aliceSizes}, {bobSizes})" + typescript: "fairCandySwap({aliceSizes}, {bobSizes})" + +judge: + type: "exact" + +limits: + time_ms: 1000 + memory_mb: 300 + +oracle: + python3: + call: "Checker().fairCandySwap(aliceSizes, bobSizes, {result})" + checker: | + class Checker: + def fairCandySwap(self, aliceSizes, bobSizes, result): + if not isinstance(result, list) or len(result) != 2: + return False + a, b = result + if a not in aliceSizes or b not in bobSizes: + return False + return sum(aliceSizes) - a + b == sum(bobSizes) - b + a + +seed: 888 + +tests: + - name: "example-1" + in: + aliceSizes: [1, 1] + bobSizes: [2, 2] + - name: "example-2" + in: + aliceSizes: [1, 2] + bobSizes: [2, 3] + - name: "example-3" + in: + aliceSizes: [2] + bobSizes: [1, 3] + - name: "single-valid-1" + in: + aliceSizes: [3, 1] + bobSizes: [2] + - name: "single-valid-2" + in: + aliceSizes: [5, 2] + bobSizes: [3] + - name: "single-valid-3" + in: + aliceSizes: [7, 2] + bobSizes: [5] + - name: "single-valid-4" + in: + aliceSizes: [10, 3] + bobSizes: [7] + - name: "single-valid-5" + in: + aliceSizes: [25, 10] + bobSizes: [15] + - name: "single-valid-6" + in: + aliceSizes: [100000, 1] + bobSizes: [99999] + - name: "single-valid-7" + in: + aliceSizes: [4] + bobSizes: [7, 3] + - name: "single-valid-8" + in: + aliceSizes: [12] + bobSizes: [20, 8] + - name: "duplicates-2" + in: + aliceSizes: [9, 9, 3] + bobSizes: [6, 9] + - name: "duplicates-3" + in: + aliceSizes: [10, 10, 10, 2] + bobSizes: [8, 10, 10] + - name: "common-tail-1" + in: + aliceSizes: [3, 1, 11, 13] + bobSizes: [2, 11, 13] + - name: "common-tail-2" + in: + aliceSizes: [5, 2, 20, 21] + bobSizes: [3, 20, 21] + - name: "common-tail-3" + in: + aliceSizes: [4, 15, 16] + bobSizes: [7, 3, 15, 16] + - name: "common-tail-4" + in: + aliceSizes: [12, 100, 101] + bobSizes: [20, 8, 100, 101] + - name: "mixed-small-2" + in: + aliceSizes: [14, 5, 3, 3] + bobSizes: [9, 3, 3] + - name: "mixed-small-4" + in: + aliceSizes: [11, 4, 8] + bobSizes: [7, 8] + - name: "mixed-small-5" + in: + aliceSizes: [13, 6, 1, 1] + bobSizes: [7, 1, 1] + - name: "mixed-medium-1" + in: + aliceSizes: [30, 12, 40, 50] + bobSizes: [18, 40, 50] + - name: "mixed-medium-2" + in: + aliceSizes: [45, 15, 2, 4, 6] + bobSizes: [30, 2, 4, 6] + - name: "mixed-medium-3" + in: + aliceSizes: [25, 60, 70] + bobSizes: [40, 15, 60, 70] + - name: "mixed-medium-4" + in: + aliceSizes: [80, 35, 10] + bobSizes: [45, 10] + - name: "mixed-medium-5" + in: + aliceSizes: [51, 20, 20, 20] + bobSizes: [31, 20, 20] + - name: "large-values-1" + in: + aliceSizes: [99999, 49999] + bobSizes: [50000] + - name: "large-values-2" + in: + aliceSizes: [70000] + bobSizes: [90000, 20000] + - name: "large-values-3" + in: + aliceSizes: [85000, 10000, 2000] + bobSizes: [75000, 2000] + - name: "large-values-4" + in: + aliceSizes: [12345, 6789, 40000] + bobSizes: [5556, 40000] + - name: "large-values-5" + in: + aliceSizes: [40000] + bobSizes: [65000, 25000] + - name: "many-boxes-1" + in: + aliceSizes: [22, 7, 1, 2, 3, 4] + bobSizes: [15, 1, 2, 3, 4] + - name: "many-boxes-2" + in: + aliceSizes: [31, 9, 5, 5, 5, 5] + bobSizes: [22, 5, 5, 5, 5] + - name: "many-boxes-3" + in: + aliceSizes: [17, 8, 9, 10, 11] + bobSizes: [9, 9, 10, 11] + - name: "many-boxes-4" + in: + aliceSizes: [18] + bobSizes: [27, 9] + - name: "many-boxes-5" + in: + aliceSizes: [90, 30, 1, 1, 1] + bobSizes: [60, 1, 1, 1] + - name: "near-limit-pattern-1" + in: + aliceSizes: [100000, 49999, 1] + bobSizes: [50001, 1] + - name: "near-limit-pattern-2" + in: + aliceSizes: [99998] + bobSizes: [100000, 2] + - name: "near-limit-pattern-3" + in: + aliceSizes: [88888, 12345, 54321] + bobSizes: [76543, 54321] diff --git a/tests/501-1000/888. fair-candy-swap/sol.cpp b/tests/501-1000/888. fair-candy-swap/sol.cpp new file mode 100644 index 00000000..823899fb --- /dev/null +++ b/tests/501-1000/888. fair-candy-swap/sol.cpp @@ -0,0 +1,15 @@ +class Solution { +public: + vector fairCandySwap(vector& aliceSizes, vector& bobSizes) { + int sumA = accumulate(aliceSizes.begin(), aliceSizes.end(), 0); + int sumB = accumulate(bobSizes.begin(), bobSizes.end(), 0); + int diff = (sumB - sumA) / 2; + unordered_set setB(bobSizes.begin(), bobSizes.end()); + for (int a : aliceSizes) { + if (setB.count(a + diff)) { + return {a, a + diff}; + } + } + return {}; + } +}; diff --git a/tests/501-1000/888. fair-candy-swap/sol.cs b/tests/501-1000/888. fair-candy-swap/sol.cs new file mode 100644 index 00000000..8bf21e05 --- /dev/null +++ b/tests/501-1000/888. fair-candy-swap/sol.cs @@ -0,0 +1,14 @@ +public class Solution { + public int[] FairCandySwap(int[] aliceSizes, int[] bobSizes) { + int sumA = aliceSizes.Sum(); + int sumB = bobSizes.Sum(); + int diff = (sumB - sumA) / 2; + var setB = new HashSet(bobSizes); + foreach (int a in aliceSizes) { + if (setB.Contains(a + diff)) { + return new int[] { a, a + diff }; + } + } + return new int[] { }; + } +} diff --git a/tests/501-1000/888. fair-candy-swap/sol.dart b/tests/501-1000/888. fair-candy-swap/sol.dart new file mode 100644 index 00000000..648c3031 --- /dev/null +++ b/tests/501-1000/888. fair-candy-swap/sol.dart @@ -0,0 +1,14 @@ +class Solution { + List fairCandySwap(List aliceSizes, List bobSizes) { + int sumA = aliceSizes.reduce((a, b) => a + b); + int sumB = bobSizes.reduce((a, b) => a + b); + int diff = (sumB - sumA) ~/ 2; + var setB = bobSizes.toSet(); + for (int a in aliceSizes) { + if (setB.contains(a + diff)) { + return [a, a + diff]; + } + } + return []; + } +} diff --git a/tests/501-1000/888. fair-candy-swap/sol.go b/tests/501-1000/888. fair-candy-swap/sol.go new file mode 100644 index 00000000..29c0e4cd --- /dev/null +++ b/tests/501-1000/888. fair-candy-swap/sol.go @@ -0,0 +1,20 @@ +func fairCandySwap(aliceSizes []int, bobSizes []int) []int { + sumA, sumB := 0, 0 + for _, a := range aliceSizes { + sumA += a + } + for _, b := range bobSizes { + sumB += b + } + diff := (sumB - sumA) / 2 + setB := make(map[int]bool) + for _, b := range bobSizes { + setB[b] = true + } + for _, a := range aliceSizes { + if setB[a+diff] { + return []int{a, a + diff} + } + } + return []int{} +} diff --git a/tests/501-1000/888. fair-candy-swap/sol.java b/tests/501-1000/888. fair-candy-swap/sol.java new file mode 100644 index 00000000..7914187c --- /dev/null +++ b/tests/501-1000/888. fair-candy-swap/sol.java @@ -0,0 +1,16 @@ +class Solution { + public int[] fairCandySwap(int[] aliceSizes, int[] bobSizes) { + int sumA = 0, sumB = 0; + for (int a : aliceSizes) sumA += a; + for (int b : bobSizes) sumB += b; + int diff = (sumB - sumA) / 2; + Set setB = new HashSet<>(); + for (int b : bobSizes) setB.add(b); + for (int a : aliceSizes) { + if (setB.contains(a + diff)) { + return new int[]{a, a + diff}; + } + } + return new int[]{}; + } +} diff --git a/tests/501-1000/888. fair-candy-swap/sol.kt b/tests/501-1000/888. fair-candy-swap/sol.kt new file mode 100644 index 00000000..07877dea --- /dev/null +++ b/tests/501-1000/888. fair-candy-swap/sol.kt @@ -0,0 +1,14 @@ +class Solution { + fun fairCandySwap(aliceSizes: IntArray, bobSizes: IntArray): IntArray { + val sumA = aliceSizes.sum() + val sumB = bobSizes.sum() + val diff = (sumB - sumA) / 2 + val setB = bobSizes.toSet() + for (a in aliceSizes) { + if (setB.contains(a + diff)) { + return intArrayOf(a, a + diff) + } + } + return intArrayOf() + } +} diff --git a/tests/501-1000/888. fair-candy-swap/sol.py b/tests/501-1000/888. fair-candy-swap/sol.py new file mode 100644 index 00000000..c4a7e137 --- /dev/null +++ b/tests/501-1000/888. fair-candy-swap/sol.py @@ -0,0 +1,11 @@ +class Solution: + def fairCandySwap(self, aliceSizes, bobSizes): + sumA = sum(aliceSizes) + sumB = sum(bobSizes) + + diff = (sumB - sumA) // 2 + setB = set(bobSizes) + + for a in aliceSizes: + if a + diff in setB: + return [a, a + diff] diff --git a/tests/501-1000/888. fair-candy-swap/sol.py2 b/tests/501-1000/888. fair-candy-swap/sol.py2 new file mode 100644 index 00000000..511e0f44 --- /dev/null +++ b/tests/501-1000/888. fair-candy-swap/sol.py2 @@ -0,0 +1,14 @@ +class Solution(object): + def fairCandySwap(self, aliceSizes, bobSizes): + """ + :type aliceSizes: List[int] + :type bobSizes: List[int] + :rtype: List[int] + """ + sumA = sum(aliceSizes) + sumB = sum(bobSizes) + diff = (sumB - sumA) // 2 + setB = set(bobSizes) + for a in aliceSizes: + if a + diff in setB: + return [a, a + diff] diff --git a/tests/501-1000/888. fair-candy-swap/sol.rb b/tests/501-1000/888. fair-candy-swap/sol.rb new file mode 100644 index 00000000..9be7cc0e --- /dev/null +++ b/tests/501-1000/888. fair-candy-swap/sol.rb @@ -0,0 +1,14 @@ +# @param {Integer[]} alice_sizes +# @param {Integer[]} bob_sizes +# @return {Integer[]} +def fair_candy_swap(alice_sizes, bob_sizes) + sumA = alice_sizes.sum + sumB = bob_sizes.sum + diff = (sumB - sumA) / 2 + setB = bob_sizes.to_set + alice_sizes.each do |a| + if setB.include?(a + diff) + return [a, a + diff] + end + end +end diff --git a/tests/501-1000/888. fair-candy-swap/sol.rs b/tests/501-1000/888. fair-candy-swap/sol.rs new file mode 100644 index 00000000..28a5563b --- /dev/null +++ b/tests/501-1000/888. fair-candy-swap/sol.rs @@ -0,0 +1,14 @@ +impl Solution { + pub fn fair_candy_swap(alice_sizes: Vec, bob_sizes: Vec) -> Vec { + let sum_a: i32 = alice_sizes.iter().sum(); + let sum_b: i32 = bob_sizes.iter().sum(); + let diff = (sum_b - sum_a) / 2; + let set_b: std::collections::HashSet = bob_sizes.into_iter().collect(); + for &a in &alice_sizes { + if set_b.contains(&(a + diff)) { + return vec![a, a + diff]; + } + } + vec![] + } +} diff --git a/tests/501-1000/888. fair-candy-swap/sol.swift b/tests/501-1000/888. fair-candy-swap/sol.swift new file mode 100644 index 00000000..e94c98af --- /dev/null +++ b/tests/501-1000/888. fair-candy-swap/sol.swift @@ -0,0 +1,14 @@ +class Solution { + func fairCandySwap(_ aliceSizes: [Int], _ bobSizes: [Int]) -> [Int] { + let sumA = aliceSizes.reduce(0, +) + let sumB = bobSizes.reduce(0, +) + let diff = (sumB - sumA) / 2 + let setB = Set(bobSizes) + for a in aliceSizes { + if setB.contains(a + diff) { + return [a, a + diff] + } + } + return [] + } +} diff --git a/tests/501-1000/888. fair-candy-swap/sol.ts b/tests/501-1000/888. fair-candy-swap/sol.ts new file mode 100644 index 00000000..4c311a5a --- /dev/null +++ b/tests/501-1000/888. fair-candy-swap/sol.ts @@ -0,0 +1,12 @@ +function fairCandySwap(aliceSizes: number[], bobSizes: number[]): number[] { + const sumA = aliceSizes.reduce((a, b) => a + b, 0); + const sumB = bobSizes.reduce((a, b) => a + b, 0); + const diff = Math.floor((sumB - sumA) / 2); + const setB = new Set(bobSizes); + for (const a of aliceSizes) { + if (setB.has(a + diff)) { + return [a, a + diff]; + } + } + return []; +} diff --git a/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/manifest.yaml b/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/manifest.yaml new file mode 100644 index 00000000..e871db63 --- /dev/null +++ b/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/manifest.yaml @@ -0,0 +1,935 @@ +entry: + id: 889 + title: construct-binary-tree-from-preorder-and-postorder-traversal + params: + preorder: + type: array + items: + type: int + postorder: + type: array + items: + type: int + call: + cpp: "treeNodeToArray(Solution().constructFromPrePost({preorder}, {postorder}))" + rust: "TreeNode::tree_node_to_array(Solution::construct_from_pre_post({preorder}, {postorder}))" + python3: "tree_node_to_array(Solution().constructFromPrePost({preorder}, {postorder}))" + python2: "tree_node_to_array(Solution().constructFromPrePost({preorder}, {postorder}))" + ruby: "tree_node_to_array(construct_from_pre_post({preorder}, {postorder}))" + java: "TreeNode.treeNodeToArray(new Solution().constructFromPrePost({preorder}, {postorder}))" + csharp: "TreeNode.TreeNodeToArray(new Solution().ConstructFromPrePost({preorder}, {postorder}))" + kotlin: "treeNodeToArray(Solution().constructFromPrePost({preorder}, {postorder}))" + go: "treeNodeToArray(constructFromPrePost({preorder}, {postorder}))" + dart: "tree_node_to_array(Solution().constructFromPrePost({preorder}, {postorder}))" + swift: "tree_node_to_array(Solution().constructFromPrePost({preorder}, {postorder}))" + typescript: "treeNodeToArray(constructFromPrePost({preorder}, {postorder}))" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().check(preorder, postorder, {result})" + checker: | + from collections import deque + from typing import Any, List, Optional + + class Checker: + def _build_expected(self, preorder, postorder): + idx = [0] + + def build(l, h): + if idx[0] >= len(preorder) or l > h: + return None + root = TreeNode(preorder[idx[0]]) + idx[0] += 1 + if l == h: + return root + if idx[0] >= len(preorder): + return root + i = l + while i <= h and postorder[i] != preorder[idx[0]]: + i += 1 + if i <= h: + root.left = build(l, i) + root.right = build(i + 1, h - 1) + return root + + return build(0, len(postorder) - 1) + + def _from_bfs(self, arr): + if not arr: + return None + nodes = [None if v is None else TreeNode(v) for v in arr] + q = deque([nodes[0]]) + i = 1 + while q and i < len(nodes): + node = q.popleft() + if node is None: + continue + if i < len(nodes): + node.left = nodes[i] + q.append(nodes[i]) + i += 1 + if i < len(nodes): + node.right = nodes[i] + q.append(nodes[i]) + i += 1 + return nodes[0] + + def _normalize(self, result): + if result is None: + return None + if isinstance(result, list): + return self._from_bfs(result) + if isinstance(result, dict): + def build(node): + if node is None: + return None + value = node.get("val", node.get("value")) + root = TreeNode(value) + root.left = build(node.get("left")) + root.right = build(node.get("right")) + return root + return build(result) + if hasattr(result, "val"): + return result + return None + + def _preorder(self, root): + out = [] + def dfs(node): + if not node: + return + out.append(node.val) + dfs(node.left) + dfs(node.right) + dfs(root) + return out + + def _postorder(self, root): + out = [] + def dfs(node): + if not node: + return + dfs(node.left) + dfs(node.right) + out.append(node.val) + dfs(root) + return out + + def _validate_distinct(self, root): + seen = set() + stack = [root] + while stack: + node = stack.pop() + if not node: + continue + if node.val in seen: + return False + seen.add(node.val) + stack.append(node.left) + stack.append(node.right) + return True + + def check(self, preorder, postorder, result): + actual = self._normalize(result) + if actual is None: + return False + if not self._validate_distinct(actual): + return False + return self._preorder(actual) == preorder and self._postorder(actual) == postorder +seed: 889 +tests: + - name: example_1 + in: + preorder: [1, 2, 4, 5, 3, 6, 7] + postorder: [4, 5, 2, 6, 7, 3, 1] + - name: example_2 + in: + preorder: [1] + postorder: [1] + - name: pair_two_nodes_left + in: + preorder: [1, 2] + postorder: [2, 1] + - name: pair_two_nodes_right + in: + preorder: [10, 20] + postorder: [20, 10] + - name: three_full + in: + preorder: [1, 2, 3] + postorder: [2, 3, 1] + - name: three_chain + in: + preorder: [1, 2, 3] + postorder: [3, 2, 1] + - name: four_left_bias + in: + preorder: [1, 2, 4, 3] + postorder: [4, 3, 2, 1] + - name: four_right_bias + in: + preorder: [5, 6, 7, 8] + postorder: [8, 7, 6, 5] + - name: five_balancedish + in: + preorder: [1, 2, 4, 5, 3] + postorder: [4, 5, 2, 3, 1] + - name: five_chain + in: + preorder: [1, 2, 3, 4, 5] + postorder: [5, 4, 3, 2, 1] + - name: six_example_like + in: + preorder: [1, 2, 4, 5, 3, 6] + postorder: [4, 5, 2, 6, 3, 1] + - name: six_two_level + in: + preorder: [10, 20, 30, 40, 50, 60] + postorder: [40, 50, 30, 60, 20, 10] + - name: seven_full + in: + preorder: [1, 2, 4, 5, 3, 6, 7] + postorder: [4, 5, 2, 6, 7, 3, 1] + - name: seven_chain + in: + preorder: [7, 6, 5, 4, 3, 2, 1] + postorder: [1, 2, 3, 4, 5, 6, 7] + - name: eight_mix + in: + preorder: [8, 4, 2, 1, 3, 6, 5, 7] + postorder: [1, 3, 2, 5, 7, 6, 4, 8] + - name: nine_mix + in: + preorder: [9, 4, 2, 1, 3, 6, 5, 7, 8] + postorder: [1, 3, 2, 5, 8, 7, 6, 4, 9] + - name: ten_chain_left + in: + preorder: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + postorder: [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] + - name: ten_branch + in: + preorder: [1, 2, 4, 5, 3, 6, 7, 8, 9, 10] + postorder: [4, 5, 2, 8, 10, 9, 7, 6, 3, 1] + - name: eleven_branch + in: + preorder: [11, 7, 3, 1, 5, 9, 8, 10, 15, 13, 17] + postorder: [1, 5, 3, 8, 10, 9, 7, 13, 17, 15, 11] + - name: twelve_branch + in: + preorder: [12, 6, 3, 1, 4, 9, 8, 10, 18, 15, 14, 20] + postorder: [1, 4, 3, 8, 10, 9, 6, 14, 20, 15, 18, 12] + - name: thirteen_branch + in: + preorder: [13, 7, 4, 2, 5, 10, 8, 12, 20, 16, 14, 18, 22] + postorder: [2, 5, 4, 8, 12, 10, 7, 14, 18, 16, 22, 20, 13] + - name: fourteen_branch + in: + preorder: [14, 7, 3, 1, 5, 11, 9, 13, 21, 17, 15, 19, 25, 23] + postorder: [1, 5, 3, 9, 13, 11, 7, 15, 19, 17, 23, 25, 21, 14] + - name: fifteen_full + in: + preorder: [1, 2, 4, 8, 9, 5, 10, 11, 3, 6, 12, 13, 7, 14, 15] + postorder: [8, 9, 4, 10, 11, 5, 2, 12, 13, 6, 14, 15, 7, 3, 1] + - name: sixteen_mix + in: + preorder: [16, 8, 4, 2, 6, 12, 10, 14, 24, 20, 18, 22, 28, 26, 30, 32] + postorder: [2, 6, 4, 10, 14, 12, 8, 18, 22, 20, 26, 32, 30, 28, 24, 16] + - name: seventeen_mix + in: + preorder: [17, 9, 5, 3, 7, 13, 11, 15, 25, 21, 19, 23, 29, 27, 31, 33, 35] + postorder: + [3, 7, 5, 11, 15, 13, 9, 19, 23, 21, 27, 33, 35, 31, 29, 25, 17] + - name: eighteen_mix + in: + preorder: + [18, 9, 4, 2, 6, 14, 11, 16, 27, 23, 20, 25, 32, 29, 34, 37, 39, 41] + postorder: + [2, 6, 4, 11, 16, 14, 9, 20, 25, 23, 29, 37, 41, 39, 34, 32, 27, 18] + - name: nineteen_mix + in: + preorder: + [ + 19, + 10, + 5, + 3, + 7, + 15, + 12, + 17, + 29, + 24, + 21, + 26, + 35, + 31, + 33, + 38, + 40, + 42, + 44, + ] + postorder: + [ + 3, + 7, + 5, + 12, + 17, + 15, + 10, + 21, + 26, + 24, + 31, + 38, + 42, + 44, + 40, + 33, + 35, + 29, + 19, + ] + - name: twenty_mix + in: + preorder: + [ + 20, + 10, + 5, + 2, + 8, + 15, + 12, + 18, + 30, + 25, + 22, + 28, + 35, + 32, + 38, + 40, + 42, + 44, + 46, + 48, + ] + postorder: + [ + 2, + 8, + 5, + 12, + 18, + 15, + 10, + 22, + 28, + 25, + 32, + 40, + 44, + 48, + 46, + 42, + 38, + 35, + 30, + 20, + ] + - name: twentyone_mix + in: + preorder: + [ + 21, + 11, + 6, + 3, + 8, + 16, + 13, + 19, + 32, + 27, + 24, + 29, + 37, + 34, + 40, + 43, + 45, + 47, + 49, + 51, + 53, + ] + postorder: + [ + 3, + 8, + 6, + 13, + 19, + 16, + 11, + 24, + 29, + 27, + 34, + 43, + 47, + 51, + 53, + 49, + 45, + 40, + 37, + 32, + 21, + ] + - name: twentytwo_mix + in: + preorder: + [ + 22, + 12, + 6, + 3, + 9, + 18, + 15, + 21, + 34, + 28, + 25, + 31, + 40, + 37, + 43, + 46, + 48, + 50, + 52, + 54, + 56, + 58, + ] + postorder: + [ + 3, + 9, + 6, + 15, + 21, + 18, + 12, + 25, + 31, + 28, + 37, + 46, + 50, + 54, + 58, + 56, + 52, + 48, + 43, + 40, + 34, + 22, + ] + - name: twentythree_mix + in: + preorder: + [ + 23, + 13, + 7, + 4, + 10, + 19, + 16, + 22, + 36, + 30, + 27, + 33, + 41, + 38, + 44, + 47, + 49, + 51, + 53, + 55, + 57, + 59, + 61, + ] + postorder: + [ + 4, + 10, + 7, + 16, + 22, + 19, + 13, + 27, + 33, + 30, + 38, + 47, + 51, + 55, + 59, + 61, + 57, + 53, + 49, + 44, + 41, + 36, + 23, + ] + - name: twentyfour_mix + in: + preorder: + [ + 24, + 12, + 6, + 3, + 9, + 18, + 15, + 21, + 36, + 30, + 27, + 33, + 42, + 39, + 45, + 48, + 50, + 52, + 54, + 56, + 58, + 60, + 62, + 64, + ] + postorder: + [ + 3, + 9, + 6, + 15, + 21, + 18, + 12, + 27, + 33, + 30, + 39, + 48, + 52, + 56, + 60, + 64, + 62, + 58, + 54, + 50, + 45, + 42, + 36, + 24, + ] + - name: twentyfive_mix + in: + preorder: + [ + 25, + 13, + 7, + 4, + 10, + 19, + 16, + 22, + 38, + 31, + 28, + 34, + 43, + 40, + 46, + 49, + 51, + 53, + 55, + 57, + 59, + 61, + 63, + 65, + 67, + ] + postorder: + [ + 4, + 10, + 7, + 16, + 22, + 19, + 13, + 28, + 34, + 31, + 40, + 49, + 53, + 57, + 61, + 65, + 67, + 63, + 59, + 55, + 51, + 46, + 43, + 38, + 25, + ] + - name: twentysix_mix + in: + preorder: + [ + 26, + 14, + 8, + 4, + 11, + 20, + 17, + 23, + 40, + 33, + 30, + 36, + 46, + 43, + 49, + 52, + 54, + 56, + 58, + 60, + 62, + 64, + 66, + 68, + 70, + 72, + ] + postorder: + [ + 4, + 11, + 8, + 17, + 23, + 20, + 14, + 30, + 36, + 33, + 43, + 52, + 56, + 60, + 64, + 68, + 72, + 70, + 66, + 62, + 58, + 54, + 49, + 46, + 40, + 26, + ] + - name: twentyseven_mix + in: + preorder: + [ + 27, + 14, + 7, + 3, + 10, + 21, + 18, + 24, + 41, + 34, + 31, + 37, + 47, + 44, + 50, + 53, + 55, + 57, + 59, + 61, + 63, + 65, + 67, + 69, + 71, + 73, + 75, + ] + postorder: + [ + 3, + 10, + 7, + 18, + 24, + 21, + 14, + 31, + 37, + 34, + 44, + 53, + 57, + 61, + 65, + 69, + 73, + 75, + 71, + 67, + 63, + 59, + 55, + 50, + 47, + 41, + 27, + ] + - name: twentyeight_mix + in: + preorder: + [ + 28, + 15, + 8, + 4, + 11, + 22, + 19, + 25, + 42, + 35, + 32, + 38, + 48, + 45, + 51, + 54, + 56, + 58, + 60, + 62, + 64, + 66, + 68, + 70, + 72, + 74, + 76, + 78, + ] + postorder: + [ + 4, + 11, + 8, + 19, + 25, + 22, + 15, + 32, + 38, + 35, + 45, + 54, + 58, + 62, + 66, + 70, + 74, + 78, + 76, + 72, + 68, + 64, + 60, + 56, + 51, + 48, + 42, + 28, + ] + - name: twentynine_mix + in: + preorder: + [ + 29, + 15, + 8, + 4, + 11, + 22, + 19, + 25, + 43, + 36, + 33, + 39, + 49, + 46, + 52, + 55, + 57, + 59, + 61, + 63, + 65, + 67, + 69, + 71, + 73, + 75, + 77, + 79, + 81, + ] + postorder: + [ + 4, + 11, + 8, + 19, + 25, + 22, + 15, + 33, + 39, + 36, + 46, + 55, + 59, + 63, + 67, + 71, + 75, + 79, + 81, + 77, + 73, + 69, + 65, + 61, + 57, + 52, + 49, + 43, + 29, + ] + - name: thirty_max + in: + preorder: + [ + 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, + ] + postorder: + [ + 30, + 29, + 28, + 27, + 26, + 25, + 24, + 23, + 22, + 21, + 20, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1, + ] diff --git a/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.cpp b/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.cpp new file mode 100644 index 00000000..daf787a7 --- /dev/null +++ b/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.cpp @@ -0,0 +1,43 @@ +/** + * Definition for a binary tree node. + * struct TreeNode { + * int val; + * TreeNode *left; + * TreeNode *right; + * TreeNode() : val(0), left(nullptr), right(nullptr) {} + * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} + * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} + * }; + */ +class Solution { +public: + TreeNode* constructFromPrePost(vector& preorder, vector& postorder) { + int index = 0; + return construct(preorder, postorder, index, 0, preorder.size() - 1); + } + +private: + TreeNode* construct(vector& pre, vector& post, int& index, int l, int h) { + if (index >= pre.size() || l > h) { + return nullptr; + } + + TreeNode* root = new TreeNode(pre[index]); + index++; + if (l == h) { + return root; + } + + int i = l; + while (i <= h && post[i] != pre[index]) { + i++; + } + + if (i <= h) { + root->left = construct(pre, post, index, l, i); + root->right = construct(pre, post, index, i + 1, h - 1); + } + + return root; + } +}; diff --git a/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.cs b/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.cs new file mode 100644 index 00000000..2e7f0de5 --- /dev/null +++ b/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.cs @@ -0,0 +1,43 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public int val; + * public TreeNode left; + * public TreeNode right; + * public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +public class Solution { + public TreeNode ConstructFromPrePost(int[] preorder, int[] postorder) { + int index = 0; + return Construct(preorder, postorder, ref index, 0, preorder.Length - 1); + } + + private TreeNode Construct(int[] pre, int[] post, ref int index, int l, int h) { + if (index >= pre.Length || l > h) { + return null; + } + + TreeNode root = new TreeNode(pre[index]); + index++; + if (l == h) { + return root; + } + + int i = l; + while (i <= h && post[i] != pre[index]) { + i++; + } + + if (i <= h) { + root.left = Construct(pre, post, ref index, l, i); + root.right = Construct(pre, post, ref index, i + 1, h - 1); + } + + return root; + } +} diff --git a/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.dart b/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.dart new file mode 100644 index 00000000..8f071792 --- /dev/null +++ b/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.dart @@ -0,0 +1,39 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * int val; + * TreeNode? left; + * TreeNode? right; + * TreeNode([this.val = 0, this.left, this.right]); + * } + */ +class Solution { + TreeNode? constructFromPrePost(List preorder, List postorder) { + int index = 0; + + TreeNode? build(int left, int right) { + if (index >= preorder.length || left > right) { + return null; + } + + final root = TreeNode(preorder[index++]); + if (left == right || index >= preorder.length) { + return root; + } + + var split = left; + while (split <= right && postorder[split] != preorder[index]) { + split++; + } + + if (split <= right) { + root.left = build(left, split); + root.right = build(split + 1, right - 1); + } + + return root; + } + + return build(0, postorder.length - 1); + } +} diff --git a/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.go b/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.go new file mode 100644 index 00000000..36307cd4 --- /dev/null +++ b/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.go @@ -0,0 +1,36 @@ +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +func constructFromPrePost(preorder []int, postorder []int) *TreeNode { + index := 0 + return construct(preorder, postorder, &index, 0, len(preorder)-1) +} + +func construct(pre []int, post []int, index *int, l int, h int) *TreeNode { + if *index >= len(pre) || l > h { + return nil + } + + root := &TreeNode{Val: pre[*index]} + *index++ + if l == h { + return root + } + + i := l + for i <= h && post[i] != pre[*index] { + i++ + } + + if i <= h { + root.Left = construct(pre, post, index, l, i) + root.Right = construct(pre, post, index, i+1, h-1) + } + + return root +} diff --git a/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.java b/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.java new file mode 100644 index 00000000..a5234139 --- /dev/null +++ b/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.java @@ -0,0 +1,45 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode() {} + * TreeNode(int val) { this.val = val; } + * TreeNode(int val, TreeNode left, TreeNode right) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +class Solution { + public TreeNode constructFromPrePost(int[] preorder, int[] postorder) { + int[] index = new int[]{0}; + return construct(preorder, postorder, index, 0, preorder.length - 1); + } + + private TreeNode construct(int[] pre, int[] post, int[] index, int l, int h) { + if (index[0] >= pre.length || l > h) { + return null; + } + + TreeNode root = new TreeNode(pre[index[0]]); + index[0]++; + if (l == h) { + return root; + } + + int i = l; + while (i <= h && post[i] != pre[index[0]]) { + i++; + } + + if (i <= h) { + root.left = construct(pre, post, index, l, i); + root.right = construct(pre, post, index, i + 1, h - 1); + } + + return root; + } +} diff --git a/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.kt b/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.kt new file mode 100644 index 00000000..88c9f764 --- /dev/null +++ b/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.kt @@ -0,0 +1,40 @@ +/** + * Example: + * var ti = TreeNode(5) + * var v = ti.`val` + * Definition for a binary tree node. + * class TreeNode(var `val`: Int) { + * var left: TreeNode? = null + * var right: TreeNode? = null + * } + */ +class Solution { + fun constructFromPrePost(preorder: IntArray, postorder: IntArray): TreeNode? { + val index = intArrayOf(0) + return construct(preorder, postorder, index, 0, preorder.size - 1) + } + + private fun construct(pre: IntArray, post: IntArray, index: IntArray, l: Int, h: Int): TreeNode? { + if (index[0] >= pre.size || l > h) { + return null + } + + val root = TreeNode(pre[index[0]]) + index[0]++ + if (l == h) { + return root + } + + var i = l + while (i <= h && post[i] != pre[index[0]]) { + i++ + } + + if (i <= h) { + root.left = construct(pre, post, index, l, i) + root.right = construct(pre, post, index, i + 1, h - 1) + } + + return root + } +} diff --git a/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.py b/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.py new file mode 100644 index 00000000..eb16c3c6 --- /dev/null +++ b/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.py @@ -0,0 +1,25 @@ +class Solution: + def constructFromPrePost( + self, preorder: List[int], postorder: List[int] + ) -> Optional[TreeNode]: + index = [0] # Mutable index to track preorder position + return self.construct(preorder, postorder, index, 0, len(preorder) - 1) + + def construct(self, pre, post, index, l, h): + if index[0] >= len(pre) or l > h: + return None + + root = TreeNode(pre[index[0]]) + index[0] += 1 + if l == h: + return root + + i = l + while i <= h and post[i] != pre[index[0]]: + i += 1 + + if i <= h: + root.left = self.construct(pre, post, index, l, i) + root.right = self.construct(pre, post, index, i + 1, h - 1) + + return root diff --git a/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.py2 b/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.py2 new file mode 100644 index 00000000..3c90b6a8 --- /dev/null +++ b/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.py2 @@ -0,0 +1,34 @@ +# Definition for a binary tree node. +# class TreeNode(object): +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution(object): + def constructFromPrePost(self, preorder, postorder): + """ + :type preorder: List[int] + :type postorder: List[int] + :rtype: Optional[TreeNode] + """ + index = [0] + return self._construct(preorder, postorder, index, 0, len(preorder) - 1) + + def _construct(self, pre, post, index, l, h): + if index[0] >= len(pre) or l > h: + return None + + root = TreeNode(pre[index[0]]) + index[0] += 1 + if l == h: + return root + + i = l + while i <= h and post[i] != pre[index[0]]: + i += 1 + + if i <= h: + root.left = self._construct(pre, post, index, l, i) + root.right = self._construct(pre, post, index, i + 1, h - 1) + + return root diff --git a/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.rb b/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.rb new file mode 100644 index 00000000..68485269 --- /dev/null +++ b/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.rb @@ -0,0 +1,40 @@ +# Definition for a binary tree node. +# class TreeNode +# attr_accessor :val, :left, :right +# def initialize(val = 0, left = nil, right = nil) +# @val = val +# @left = left +# @right = right +# end +# end +# @param {Integer[]} preorder +# @param {Integer[]} postorder +# @return {TreeNode} +def construct_from_pre_post(preorder, postorder) + index = [0] + return construct_helper(preorder, postorder, index, 0, preorder.length - 1) +end + +def construct_helper(pre, post, index, l, h) + if index[0] >= pre.length || l > h + return nil + end + + root = TreeNode.new(pre[index[0]]) + index[0] += 1 + if l == h + return root + end + + i = l + while i <= h && post[i] != pre[index[0]] + i += 1 + end + + if i <= h + root.left = construct_helper(pre, post, index, l, i) + root.right = construct_helper(pre, post, index, i + 1, h - 1) + end + + return root +end diff --git a/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.rs b/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.rs new file mode 100644 index 00000000..ce84dbc3 --- /dev/null +++ b/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.rs @@ -0,0 +1,48 @@ +// Definition for a binary tree node. +// #[derive(Debug, PartialEq, Eq)] +// pub struct TreeNode { +// pub val: i32, +// pub left: Option>>, +// pub right: Option>>, +// } +// +// impl TreeNode { +// #[inline] +// pub fn new(val: i32) -> Self { +// TreeNode { +// val, +// left: None, +// right: None +// } +// } +// } +impl Solution { + pub fn construct_from_pre_post(preorder: Vec, postorder: Vec) -> Option>> { + let mut index = 0; + Self::construct(&preorder, &postorder, &mut index, 0, preorder.len() as i32 - 1) + } + + fn construct(pre: &[i32], post: &[i32], index: &mut usize, l: i32, h: i32) -> Option>> { + if *index >= pre.len() || l > h { + return None; + } + + let root = Rc::new(RefCell::new(TreeNode::new(pre[*index]))); + *index += 1; + if l == h { + return Some(root); + } + + let mut i = l; + while i <= h && post[i as usize] != pre[*index] { + i += 1; + } + + if i <= h { + root.borrow_mut().left = Self::construct(pre, post, index, l, i); + root.borrow_mut().right = Self::construct(pre, post, index, i + 1, h - 1); + } + + Some(root) + } +} diff --git a/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.swift b/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.swift new file mode 100644 index 00000000..f3eba3f9 --- /dev/null +++ b/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.swift @@ -0,0 +1,48 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public var val: Int + * public var left: TreeNode? + * public var right: TreeNode? + * public init() { self.val = 0; self.left = nil; self.right = nil; } + * public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; } + * public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) { + * self.val = val + * self.left = left + * self.right = right + * } + * } + */ +class Solution { + func constructFromPrePost(_ preorder: [Int], _ postorder: [Int]) -> TreeNode? { + guard !preorder.isEmpty else { return nil } + let root = TreeNode() + root.val = preorder[0] + var stack: [TreeNode] = [root] + var postIndex = 0 + + for value in preorder.dropFirst() { + let node = TreeNode() + node.val = value + while let last = stack.last, postIndex < postorder.count, last.val == postorder[postIndex] { + stack.removeLast() + postIndex += 1 + } + if let parent = stack.last { + if parent.left == nil { + parent.left = node + } else { + parent.right = node + } + } + stack.append(node) + } + + while let last = stack.last, postIndex < postorder.count, last.val == postorder[postIndex] { + stack.removeLast() + postIndex += 1 + } + + return root + } +} diff --git a/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.ts b/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.ts new file mode 100644 index 00000000..ebfb300b --- /dev/null +++ b/tests/501-1000/889. construct-binary-tree-from-preorder-and-postorder-traversal/sol.ts @@ -0,0 +1,45 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ + +function constructFromPrePost( + preorder: number[], + postorder: number[], +): TreeNode | null { + let index = 0; + + function build(left: number, right: number): TreeNode | null { + if (index >= preorder.length || left > right) { + return null; + } + + const root = new TreeNode(preorder[index++]); + if (left === right || index >= preorder.length) { + return root; + } + + let split = left; + while (split <= right && postorder[split] !== preorder[index]) { + split++; + } + + if (split <= right) { + root.left = build(left, split); + root.right = build(split + 1, right - 1); + } + + return root; + } + + return build(0, postorder.length - 1); +} diff --git a/tests/501-1000/890. find-and-replace-pattern/manifest.yaml b/tests/501-1000/890. find-and-replace-pattern/manifest.yaml new file mode 100644 index 00000000..5f68d3d7 --- /dev/null +++ b/tests/501-1000/890. find-and-replace-pattern/manifest.yaml @@ -0,0 +1,452 @@ +entry: + id: 890 + title: find-and-replace-pattern + params: + words: + type: array + items: + type: string + pattern: + type: string + call: + cpp: Solution().findAndReplacePattern({words}, {pattern}) + rust: Solution::find_and_replace_pattern({words}, {pattern}) + python3: Solution().findAndReplacePattern({words}, {pattern}) + python2: Solution().findAndReplacePattern({words}, {pattern}) + ruby: find_and_replace_pattern({words}, {pattern}) + java: new Solution().findAndReplacePattern({words}, {pattern}) + csharp: new Solution().FindAndReplacePattern({words}, {pattern}) + kotlin: Solution().findAndReplacePattern({words}, {pattern}) + go: findAndReplacePattern({words}, {pattern}) + dart: Solution().findAndReplacePattern({words}, {pattern}) + swift: Solution().findAndReplacePattern({words}, {pattern}) + typescript: findAndReplacePattern({words}, {pattern}) + +judge: + type: ignore_order + +limits: + time_ms: 1000 + memory_mb: 300 + +oracle: + python3: + call: "Checker().check(words, pattern, {result})" + checker: | + from collections import Counter + + class Checker(object): + def check(self, words, pattern, result): + if not isinstance(result, list): + return False + expected = [] + pattern_signature = [pattern.index(c) for c in pattern] + for word in words: + if len(word) != len(pattern): + return False + if [word.index(c) for c in word] == pattern_signature: + expected.append(word) + return Counter(result) == Counter(expected) + +seed: 890 + +tests: + - name: ex1 + in: + words: + - abc + - deq + - mee + - aqq + - dkd + - ccc + pattern: abb + out: + - mee + - aqq + - name: ex2 + in: + words: + - a + - b + - c + pattern: a + out: + - a + - b + - c + - name: single_match + in: + words: + - aa + - ab + - ba + pattern: aa + out: + - aa + - name: two_letter_bijection + in: + words: + - ab + - cd + - ee + - fg + pattern: ab + out: + - ab + - cd + - fg + - name: all_same_pattern + in: + words: + - aaaa + - bbbb + - abcd + - zzzz + pattern: zzzz + out: + - aaaa + - bbbb + - zzzz + - name: repeated_first_last + in: + words: + - abca + - zbxz + - mnop + - zzzz + pattern: mama + out: [] + - name: example_like_abb + in: + words: + - abc + - xyy + - yxx + - foo + pattern: abb + out: + - xyy + - yxx + - foo + - name: no_matches + in: + words: + - abcd + - efgh + - ijkl + pattern: aaaa + out: [] + - name: length_five_mixed + in: + words: + - qwert + - tyuio + - asdfg + - zxcvb + pattern: abcde + out: + - qwert + - tyuio + - asdfg + - zxcvb + - name: length_five_single_pattern + in: + words: + - hello + - jelly + - civic + - radar + pattern: paper + out: [] + - name: repeated_blocks + in: + words: + - abcabc + - deqdeq + - meemee + - aqqaqq + pattern: abcabc + out: + - abcabc + - deqdeq + - name: classic_noon + in: + words: + - abba + - baab + - cddc + - eeee + pattern: noon + out: + - abba + - baab + - cddc + - name: alternating + in: + words: + - xyxy + - zaza + - mnom + - abab + pattern: abab + out: + - xyxy + - zaza + - abab + - name: all_unique_len4 + in: + words: + - pqrs + - qrst + - rstu + - stuv + pattern: abcd + out: + - pqrs + - qrst + - rstu + - stuv + - name: duplicates_in_words + in: + words: + - zz + - xy + - yx + - zz + pattern: ab + out: + - xy + - yx + - name: duplicates_output + in: + words: + - baba + - caca + - dada + pattern: noon + out: [] + - name: single_char_many + in: + words: + - a + - z + - m + - q + pattern: b + out: + - a + - z + - m + - q + - name: pattern_three_unique + in: + words: + - abc + - bcd + - cde + - def + pattern: xyz + out: + - abc + - bcd + - cde + - def + - name: pattern_two_same_one_diff + in: + words: + - mom + - dad + - pop + - aaa + pattern: aba + out: + - mom + - dad + - pop + - name: pattern_two_same_one_diff_2 + in: + words: + - kik + - foo + - bar + - paper + pattern: abb + out: + - foo + - name: length_six_partial + in: + words: + - xyzxyz + - ababab + - aaaaaa + - qwerty + pattern: aabbcc + out: [] + - name: length_six_unique + in: + words: + - abcdef + - bcdefg + - cdefgh + - zyxwvu + pattern: abcdef + out: + - abcdef + - bcdefg + - cdefgh + - zyxwvu + - name: length_seven_reuse + in: + words: + - abcabca + - bcdbcde + - zzxzzxz + - mnopqrs + pattern: abcadab + out: [] + - name: length_eight_exampleish + in: + words: + - leetcode + - codeleet + - helloell + - worldwid + pattern: abcaefgh + out: [] + - name: long_unique_1 + in: + words: + - abcdefghij + - klmnopqrst + - uvwxyzabcd + - zyxwvutsrq + pattern: abcdefghij + out: + - abcdefghij + - klmnopqrst + - uvwxyzabcd + - zyxwvutsrq + - name: long_unique_2 + in: + words: + - abcdefghijkl + - mnopqrstuvwx + - yzabcdefghij + pattern: klmnopqrstuv + out: + - abcdefghijkl + - mnopqrstuvwx + - yzabcdefghij + - name: repeated_then_unique + in: + words: + - aab + - bbc + - ccd + - dde + pattern: abb + out: [] + - name: mixed_case_of_pattern + in: + words: + - aba + - xyz + - xyx + pattern: aba + out: + - aba + - xyx + - name: all_match_short + in: + words: + - ab + - ba + - cd + - ef + pattern: ab + out: + - ab + - ba + - cd + - ef + - name: no_match_long + in: + words: + - abc + - aba + - aaa + pattern: xyz + out: + - abc + - name: repeated_letter_pattern + in: + words: + - ppp + - qqq + - rqr + pattern: aaa + out: + - ppp + - qqq + - name: weird_mix_1 + in: + words: + - abcde + - fghij + - klmno + - pqrst + pattern: abcde + out: + - abcde + - fghij + - klmno + - pqrst + - name: weird_mix_2 + in: + words: + - abca + - zbxz + - mnmm + - zzzz + pattern: mama + out: [] + - name: pair_repeats + in: + words: + - xyxy + - yyyy + - xzxz + pattern: abab + out: + - xyxy + - xzxz + - name: single_word_match + in: + words: + - same + pattern: abcd + out: + - same + - name: single_word_no_match + in: + words: + - nooo + pattern: abcd + out: [] + - name: two_words_same_shape + in: + words: + - abab + - baba + pattern: abba + out: [] + - name: final_mixed + in: + words: + - paper + - title + - abaca + - xyxxy + pattern: aabcd + out: [] diff --git a/tests/501-1000/890. find-and-replace-pattern/sol.cpp b/tests/501-1000/890. find-and-replace-pattern/sol.cpp new file mode 100644 index 00000000..4ee89b96 --- /dev/null +++ b/tests/501-1000/890. find-and-replace-pattern/sol.cpp @@ -0,0 +1,20 @@ +class Solution { +public: + vector findAndReplacePattern(vector& words, string pattern) { + vector counts; + for (char c : pattern) { + counts.push_back(pattern.find(c)); + } + vector res; + for (string& word : words) { + vector count; + for (char c : word) { + count.push_back(word.find(c)); + } + if (count == counts) { + res.push_back(word); + } + } + return res; + } +}; diff --git a/tests/501-1000/890. find-and-replace-pattern/sol.cs b/tests/501-1000/890. find-and-replace-pattern/sol.cs new file mode 100644 index 00000000..5550386d --- /dev/null +++ b/tests/501-1000/890. find-and-replace-pattern/sol.cs @@ -0,0 +1,13 @@ +public class Solution { + public IList FindAndReplacePattern(string[] words, string pattern) { + var counts = pattern.Select(c => pattern.IndexOf(c)).ToList(); + var res = new List(); + foreach (var word in words) { + var count = word.Select(c => word.IndexOf(c)).ToList(); + if (count.SequenceEqual(counts)) { + res.Add(word); + } + } + return res; + } +} diff --git a/tests/501-1000/890. find-and-replace-pattern/sol.dart b/tests/501-1000/890. find-and-replace-pattern/sol.dart new file mode 100644 index 00000000..abf0c9a7 --- /dev/null +++ b/tests/501-1000/890. find-and-replace-pattern/sol.dart @@ -0,0 +1,20 @@ +class Solution { + List findAndReplacePattern(List words, String pattern) { + List counts = pattern.codeUnits.map((c) => pattern.indexOf(String.fromCharCode(c))).toList(); + List res = []; + for (String word in words) { + List count = word.codeUnits.map((c) => word.indexOf(String.fromCharCode(c))).toList(); + bool match = true; + for (int i = 0; i < count.length; i++) { + if (count[i] != counts[i]) { + match = false; + break; + } + } + if (match) { + res.add(word); + } + } + return res; + } +} diff --git a/tests/501-1000/890. find-and-replace-pattern/sol.go b/tests/501-1000/890. find-and-replace-pattern/sol.go new file mode 100644 index 00000000..f9122747 --- /dev/null +++ b/tests/501-1000/890. find-and-replace-pattern/sol.go @@ -0,0 +1,36 @@ +func findAndReplacePattern(words []string, pattern string) []string { + counts := signature(pattern) + res := make([]string, 0) + for _, word := range words { + if equal(signature(word), counts) { + res = append(res, word) + } + } + return res +} + +func signature(s string) []int { + first := make(map[byte]int) + out := make([]int, len(s)) + for i := 0; i < len(s); i++ { + if idx, ok := first[s[i]]; ok { + out[i] = idx + } else { + first[s[i]] = i + out[i] = i + } + } + return out +} + +func equal(a, b []int) bool { + if len(a) != len(b) { + return false + } + for i := range a { + if a[i] != b[i] { + return false + } + } + return true +} diff --git a/tests/501-1000/890. find-and-replace-pattern/sol.java b/tests/501-1000/890. find-and-replace-pattern/sol.java new file mode 100644 index 00000000..486d5e37 --- /dev/null +++ b/tests/501-1000/890. find-and-replace-pattern/sol.java @@ -0,0 +1,19 @@ +class Solution { + public List findAndReplacePattern(String[] words, String pattern) { + List counts = new ArrayList<>(); + for (int i = 0; i < pattern.length(); i++) { + counts.add(pattern.indexOf(pattern.charAt(i))); + } + List res = new ArrayList<>(); + for (String word : words) { + List count = new ArrayList<>(); + for (int i = 0; i < word.length(); i++) { + count.add(word.indexOf(word.charAt(i))); + } + if (count.equals(counts)) { + res.add(word); + } + } + return res; + } +} diff --git a/tests/501-1000/890. find-and-replace-pattern/sol.kt b/tests/501-1000/890. find-and-replace-pattern/sol.kt new file mode 100644 index 00000000..6b37aa0f --- /dev/null +++ b/tests/501-1000/890. find-and-replace-pattern/sol.kt @@ -0,0 +1,13 @@ +class Solution { + fun findAndReplacePattern(words: Array, pattern: String): List { + val counts = pattern.map { pattern.indexOf(it) } + val res = mutableListOf() + for (word in words) { + val count = word.map { word.indexOf(it) } + if (count == counts) { + res.add(word) + } + } + return res + } +} diff --git a/tests/501-1000/890. find-and-replace-pattern/sol.py b/tests/501-1000/890. find-and-replace-pattern/sol.py new file mode 100644 index 00000000..2af0f612 --- /dev/null +++ b/tests/501-1000/890. find-and-replace-pattern/sol.py @@ -0,0 +1,12 @@ +class Solution: + def findAndReplacePattern(self, words: List[str], pattern: str) -> List[str]: + + counts = [pattern.index(i) for i in pattern] + res = [] + for i in words: + count = [] + for j in i: + count.append(i.index(j)) + if count == counts: + res.append(i) + return res diff --git a/tests/501-1000/890. find-and-replace-pattern/sol.py2 b/tests/501-1000/890. find-and-replace-pattern/sol.py2 new file mode 100644 index 00000000..1cc6b82b --- /dev/null +++ b/tests/501-1000/890. find-and-replace-pattern/sol.py2 @@ -0,0 +1,16 @@ +class Solution(object): + def findAndReplacePattern(self, words, pattern): + """ + :type words: List[str] + :type pattern: str + :rtype: List[str] + """ + counts = [pattern.index(c) for c in pattern] + res = [] + for word in words: + count = [] + for c in word: + count.append(word.index(c)) + if count == counts: + res.append(word) + return res diff --git a/tests/501-1000/890. find-and-replace-pattern/sol.rb b/tests/501-1000/890. find-and-replace-pattern/sol.rb new file mode 100644 index 00000000..b7ba6910 --- /dev/null +++ b/tests/501-1000/890. find-and-replace-pattern/sol.rb @@ -0,0 +1,12 @@ +# @param {String[]} words +# @param {String} pattern +# @return {String[]} +def find_and_replace_pattern(words, pattern) + counts = pattern.chars.map { |c| pattern.index(c) } + res = [] + words.each do |word| + count = word.chars.map { |c| word.index(c) } + res << word if count == counts + end + res +end diff --git a/tests/501-1000/890. find-and-replace-pattern/sol.rs b/tests/501-1000/890. find-and-replace-pattern/sol.rs new file mode 100644 index 00000000..2900cfcd --- /dev/null +++ b/tests/501-1000/890. find-and-replace-pattern/sol.rs @@ -0,0 +1,13 @@ +impl Solution { + pub fn find_and_replace_pattern(words: Vec, pattern: String) -> Vec { + let counts: Vec = pattern.chars().map(|c| pattern.find(c).unwrap()).collect(); + let mut res: Vec = Vec::new(); + for word in words { + let count: Vec = word.chars().map(|c| word.find(c).unwrap()).collect(); + if count == counts { + res.push(word); + } + } + res + } +} diff --git a/tests/501-1000/890. find-and-replace-pattern/sol.swift b/tests/501-1000/890. find-and-replace-pattern/sol.swift new file mode 100644 index 00000000..ce8df40f --- /dev/null +++ b/tests/501-1000/890. find-and-replace-pattern/sol.swift @@ -0,0 +1,13 @@ +class Solution { + func findAndReplacePattern(_ words: [String], _ pattern: String) -> [String] { + let counts = pattern.map { pattern.firstIndex(of: $0)! } + var res: [String] = [] + for word in words { + let count = word.map { word.firstIndex(of: $0)! } + if count == counts { + res.append(word) + } + } + return res + } +} diff --git a/tests/501-1000/890. find-and-replace-pattern/sol.ts b/tests/501-1000/890. find-and-replace-pattern/sol.ts new file mode 100644 index 00000000..68ec4d8e --- /dev/null +++ b/tests/501-1000/890. find-and-replace-pattern/sol.ts @@ -0,0 +1,11 @@ +function findAndReplacePattern(words: string[], pattern: string): string[] { + const counts = pattern.split("").map((c) => pattern.indexOf(c)); + const res: string[] = []; + for (const word of words) { + const count = word.split("").map((c) => word.indexOf(c)); + if (count.every((v, i) => v === counts[i])) { + res.push(word); + } + } + return res; +} diff --git a/tests/501-1000/891. sum-of-subsequence-widths/manifest.yaml b/tests/501-1000/891. sum-of-subsequence-widths/manifest.yaml new file mode 100644 index 00000000..748cb6d0 --- /dev/null +++ b/tests/501-1000/891. sum-of-subsequence-widths/manifest.yaml @@ -0,0 +1,165 @@ +entry: + id: 891 + title: "sum-of-subsequence-widths" + params: + nums: + type: array + items: + type: int + call: + cpp: "Solution().sumSubseqWidths({nums})" + rust: "Solution::sum_subseq_widths({nums})" + python3: "Solution().sumSubseqWidths({nums})" + python2: "Solution().sumSubseqWidths({nums})" + ruby: "sum_subseq_widths({nums})" + java: "new Solution().sumSubseqWidths({nums})" + csharp: "new Solution().SumSubseqWidths({nums})" + kotlin: "Solution().sumSubseqWidths({nums})" + go: "sumSubseqWidths({nums})" + dart: "Solution().sumSubseqWidths({nums})" + swift: "Solution().sumSubseqWidths({nums})" + typescript: "sumSubseqWidths({nums})" + +judge: + type: "exact" + +limits: + time_ms: 1000 + memory_mb: 300 + +oracle: + python3: + call: "Checker().sumSubseqWidths(nums, {result})" + checker: | + class Checker: + def sumSubseqWidths(self, nums, result): + if not isinstance(result, int): + return False + MOD = 1_000_000_007 + nums = sorted(nums) + n = len(nums) + pow2 = [1] * n + for i in range(1, n): + pow2[i] = (pow2[i - 1] * 2) % MOD + ans = 0 + for i, x in enumerate(nums): + ans = (ans + x * (pow2[i] - pow2[n - 1 - i])) % MOD + return ans == result % MOD + +seed: 891 + +tests: + - name: "t1" + in: + nums: [2, 1, 3] + - name: "t2" + in: + nums: [2] + - name: "t3" + in: + nums: [1, 1] + - name: "t4" + in: + nums: [1, 2] + - name: "t5" + in: + nums: [3, 1, 2, 4] + - name: "t6" + in: + nums: [4, 4, 4, 4] + - name: "t7" + in: + nums: [1, 3, 5, 7, 9] + - name: "t8" + in: + nums: [9, 7, 5, 3, 1] + - name: "t9" + in: + nums: [100000, 1] + - name: "t10" + in: + nums: [1, 100000] + - name: "t11" + in: + nums: [1, 2, 3, 4, 5, 6] + - name: "t12" + in: + nums: [10, 20, 30, 40] + - name: "t13" + in: + nums: [5, 4, 3, 2, 1] + - name: "t14" + in: + nums: [2, 2, 3, 3, 4, 4] + - name: "t15" + in: + nums: [1, 100, 1000, 10000] + - name: "t16" + in: + nums: [100000, 99999, 99998, 99997] + - name: "t17" + in: + nums: [7, 8, 9, 10, 11, 12, 13, 14] + - name: "t18" + in: + nums: [1, 2, 2, 2, 3, 3, 4] + - name: "t19" + in: + nums: [6, 1, 4, 2, 9] + - name: "t20" + in: + nums: [8, 16, 32, 64, 128] + - name: "t21" + in: + nums: [1, 5, 10, 15, 20, 25] + - name: "t22" + in: + nums: [2, 4, 8, 16, 32, 64] + - name: "t23" + in: + nums: [11, 22, 33, 44, 55] + - name: "t24" + in: + nums: [1, 1, 2, 3, 5, 8, 13] + - name: "t25" + in: + nums: [21, 34, 55, 89] + - name: "t26" + in: + nums: [100000, 100000] + - name: "t27" + in: + nums: [1, 50000, 100000] + - name: "t28" + in: + nums: [3, 6, 9, 12, 15, 18, 21] + - name: "t29" + in: + nums: [2, 3, 5, 7, 11, 13, 17, 19] + - name: "t30" + in: + nums: [100, 200, 300, 400, 500, 600] + - name: "t31" + in: + nums: [1, 2, 4, 8, 16, 32, 64, 128, 256, 512] + - name: "t32" + in: + nums: [42] + - name: "t33" + in: + nums: [99999, 1, 50000, 25000] + - name: "t34" + in: + nums: [1, 1, 1, 2, 2, 3, 3, 4, 4, 5] + - name: "t35" + in: + nums: [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] + - name: "t36" + in: + nums: [100000, 50000, 25000, 12500, 6250] + - name: "t37" + in: + nums: [123, 456, 789, 101112] + - name: "t38" + in: + nums: [2, 5, 9, 14, 20, 27, 35] diff --git a/tests/501-1000/891. sum-of-subsequence-widths/sol.cpp b/tests/501-1000/891. sum-of-subsequence-widths/sol.cpp new file mode 100644 index 00000000..16256e67 --- /dev/null +++ b/tests/501-1000/891. sum-of-subsequence-widths/sol.cpp @@ -0,0 +1,15 @@ +class Solution { +public: + int sumSubseqWidths(vector& nums) { + const int mod = 1000000007; + sort(nums.begin(), nums.end()); + int n = nums.size(); + long long ans = 0; + long long factor = 1; + for (int i = 0; i < n; i++) { + ans = (ans + (nums[i] - nums[n - 1 - i]) * factor) % mod; + factor = (factor * 2) % mod; + } + return (int) ans; + } +}; diff --git a/tests/501-1000/891. sum-of-subsequence-widths/sol.cs b/tests/501-1000/891. sum-of-subsequence-widths/sol.cs new file mode 100644 index 00000000..93764225 --- /dev/null +++ b/tests/501-1000/891. sum-of-subsequence-widths/sol.cs @@ -0,0 +1,14 @@ +public class Solution { + public int SumSubseqWidths(int[] nums) { + const int mod = 1000000007; + Array.Sort(nums); + int n = nums.Length; + long ans = 0; + long factor = 1; + for (int i = 0; i < n; i++) { + ans = (ans + (nums[i] - nums[n - 1 - i]) * factor) % mod; + factor = (factor * 2) % mod; + } + return (int) ans; + } +} diff --git a/tests/501-1000/891. sum-of-subsequence-widths/sol.dart b/tests/501-1000/891. sum-of-subsequence-widths/sol.dart new file mode 100644 index 00000000..5872ca10 --- /dev/null +++ b/tests/501-1000/891. sum-of-subsequence-widths/sol.dart @@ -0,0 +1,14 @@ +class Solution { + int sumSubseqWidths(List nums) { + const mod = 1000000007; + nums.sort(); + int n = nums.length; + int ans = 0; + int factor = 1; + for (int i = 0; i < n; i++) { + ans = (ans + (nums[i] - nums[n - 1 - i]) * factor) % mod; + factor = (factor * 2) % mod; + } + return ans; + } +} diff --git a/tests/501-1000/891. sum-of-subsequence-widths/sol.go b/tests/501-1000/891. sum-of-subsequence-widths/sol.go new file mode 100644 index 00000000..adb7ad31 --- /dev/null +++ b/tests/501-1000/891. sum-of-subsequence-widths/sol.go @@ -0,0 +1,12 @@ +func sumSubseqWidths(nums []int) int { + const mod = 1000000007 + sort.Ints(nums) + n := len(nums) + ans := 0 + factor := 1 + for i := 0; i < n; i++ { + ans = (ans + (nums[i] - nums[n-1-i]) * factor) % mod + factor = (factor * 2) % mod + } + return ans +} diff --git a/tests/501-1000/891. sum-of-subsequence-widths/sol.java b/tests/501-1000/891. sum-of-subsequence-widths/sol.java new file mode 100644 index 00000000..31ff6110 --- /dev/null +++ b/tests/501-1000/891. sum-of-subsequence-widths/sol.java @@ -0,0 +1,14 @@ +class Solution { + public int sumSubseqWidths(int[] nums) { + int mod = 1000000007; + Arrays.sort(nums); + int n = nums.length; + long ans = 0; + long factor = 1; + for (int i = 0; i < n; i++) { + ans = (ans + (nums[i] - nums[n - 1 - i]) * factor) % mod; + factor = (factor * 2) % mod; + } + return (int) ans; + } +} diff --git a/tests/501-1000/891. sum-of-subsequence-widths/sol.kt b/tests/501-1000/891. sum-of-subsequence-widths/sol.kt new file mode 100644 index 00000000..a82f79f8 --- /dev/null +++ b/tests/501-1000/891. sum-of-subsequence-widths/sol.kt @@ -0,0 +1,14 @@ +class Solution { + fun sumSubseqWidths(nums: IntArray): Int { + val mod = 1000000007 + nums.sort() + val n = nums.size + var ans = 0L + var factor = 1L + for (i in 0 until n) { + ans = (ans + (nums[i] - nums[n - 1 - i]) * factor) % mod + factor = (factor * 2) % mod + } + return ans.toInt() + } +} diff --git a/tests/501-1000/891. sum-of-subsequence-widths/sol.py b/tests/501-1000/891. sum-of-subsequence-widths/sol.py new file mode 100644 index 00000000..e9af6ff7 --- /dev/null +++ b/tests/501-1000/891. sum-of-subsequence-widths/sol.py @@ -0,0 +1,13 @@ +class Solution: + def sumSubseqWidths(self, nums: List[int]) -> int: + mod = 1_000_000_007 + + nums.sort() + n, ans, factor = len(nums), 0, 1 + + for i in range(n): + ans += (nums[i] - nums[~i]) * factor + factor *= 2 + factor %= mod + + return ans % mod diff --git a/tests/501-1000/891. sum-of-subsequence-widths/sol.py2 b/tests/501-1000/891. sum-of-subsequence-widths/sol.py2 new file mode 100644 index 00000000..152798d0 --- /dev/null +++ b/tests/501-1000/891. sum-of-subsequence-widths/sol.py2 @@ -0,0 +1,11 @@ +class Solution(object): + def sumSubseqWidths(self, nums): + mod = 1000000007 + nums.sort() + n = len(nums) + ans = 0 + factor = 1 + for i in range(n): + ans = (ans + (nums[i] - nums[~i]) * factor) % mod + factor = (factor * 2) % mod + return ans diff --git a/tests/501-1000/891. sum-of-subsequence-widths/sol.rb b/tests/501-1000/891. sum-of-subsequence-widths/sol.rb new file mode 100644 index 00000000..c2701cad --- /dev/null +++ b/tests/501-1000/891. sum-of-subsequence-widths/sol.rb @@ -0,0 +1,14 @@ +# @param {Integer[]} nums +# @return {Integer} +def sum_subseq_widths(nums) + mod = 1000000007 + nums.sort! + n = nums.length + ans = 0 + factor = 1 + (0...n).each do |i| + ans = (ans + (nums[i] - nums[~i]) * factor) % mod + factor = (factor * 2) % mod + end + ans +end diff --git a/tests/501-1000/891. sum-of-subsequence-widths/sol.rs b/tests/501-1000/891. sum-of-subsequence-widths/sol.rs new file mode 100644 index 00000000..0e02decb --- /dev/null +++ b/tests/501-1000/891. sum-of-subsequence-widths/sol.rs @@ -0,0 +1,15 @@ +impl Solution { + pub fn sum_subseq_widths(nums: Vec) -> i32 { + const MOD: i64 = 1000000007; + let mut nums = nums; + nums.sort(); + let n = nums.len(); + let mut ans: i64 = 0; + let mut factor: i64 = 1; + for i in 0..n { + ans = (ans + (nums[i] as i64 - nums[n - 1 - i] as i64) * factor) % MOD; + factor = (factor * 2) % MOD; + } + ans as i32 + } +} diff --git a/tests/501-1000/891. sum-of-subsequence-widths/sol.swift b/tests/501-1000/891. sum-of-subsequence-widths/sol.swift new file mode 100644 index 00000000..8a6e1177 --- /dev/null +++ b/tests/501-1000/891. sum-of-subsequence-widths/sol.swift @@ -0,0 +1,14 @@ +class Solution { + func sumSubseqWidths(_ nums: [Int]) -> Int { + let mod = 1000000007 + let sorted = nums.sorted() + let n = sorted.count + var ans = 0 + var factor = 1 + for i in 0.. a - b); + const n = nums.length; + let ans = 0; + let factor = 1; + for (let i = 0; i < n; i++) { + ans = (ans + (nums[i] - nums[n - 1 - i]) * factor) % mod; + factor = (factor * 2) % mod; + } + return ans; +} diff --git a/tests/501-1000/892. surface-area-of-3d-shapes/manifest.yaml b/tests/501-1000/892. surface-area-of-3d-shapes/manifest.yaml new file mode 100644 index 00000000..e3ea46d2 --- /dev/null +++ b/tests/501-1000/892. surface-area-of-3d-shapes/manifest.yaml @@ -0,0 +1,362 @@ +entry: + id: 892 + title: surface-area-of-3d-shapes + params: + grid: + type: array + items: + type: array + items: + type: int + call: + cpp: Solution().surfaceArea({grid}) + rust: Solution::surface_area({grid}) + python3: Solution().surfaceArea({grid}) + python2: Solution().surfaceArea({grid}) + ruby: surface_area({grid}) + java: new Solution().surfaceArea({grid}) + csharp: new Solution().SurfaceArea({grid}) + kotlin: Solution().surfaceArea({grid}) + go: surfaceArea({grid}) + dart: Solution().surfaceArea({grid}) + swift: Solution().surfaceArea({grid}) + typescript: surfaceArea({grid}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().surfaceArea(grid, {result}) + checker: | + class Checker: + def surfaceArea(self, grid, result): + n = len(grid) + area = 0 + for i in range(n): + for j in range(n): + v = grid[i][j] + if v: + area += v * 6 - (v - 1) * 2 + if i + 1 < n: + area -= 2 * min(v, grid[i + 1][j]) + if j + 1 < n: + area -= 2 * min(v, grid[i][j + 1]) + return area == result +seed: 892 +tests: + - name: ex1 + in: + grid: + elemType: int + value: + - [1, 2] + - [3, 4] + out: 34 + - name: ex2 + in: + grid: + elemType: int + value: + - [1, 1, 1] + - [1, 0, 1] + - [1, 1, 1] + out: 32 + - name: ex3 + in: + grid: + elemType: int + value: + - [2, 2, 2] + - [2, 1, 2] + - [2, 2, 2] + out: 46 + - name: single_one + in: + grid: + elemType: int + value: + - [1] + out: 6 + - name: single_zero + in: + grid: + elemType: int + value: + - [0] + out: 0 + - name: single_large + in: + grid: + elemType: int + value: + - [50] + out: 202 + - name: upper_row_2 + in: + grid: + elemType: int + value: + - [1, 1] + - [0, 0] + out: 10 + - name: left_col_2 + in: + grid: + elemType: int + value: + - [2, 0] + - [3, 0] + out: 20 + - name: diagonal_zeros + in: + grid: + elemType: int + value: + - [1, 0] + - [0, 1] + out: 12 + - name: all_zeros_2 + in: + grid: + elemType: int + value: + - [0, 0] + - [0, 0] + out: 0 + - name: all_ones_2 + in: + grid: + elemType: int + value: + - [1, 1] + - [1, 1] + out: 16 + - name: checkerboard_3 + in: + grid: + elemType: int + value: + - [1, 0, 1] + - [0, 1, 0] + - [1, 0, 1] + out: 30 + - name: cross_3 + in: + grid: + elemType: int + value: + - [0, 2, 0] + - [2, 2, 2] + - [0, 2, 0] + out: 34 + - name: stripe_3 + in: + grid: + elemType: int + value: + - [3, 3, 3] + - [0, 0, 0] + - [1, 1, 1] + out: 44 + - name: mixed_small_1 + in: + grid: + elemType: int + value: + - [5, 1] + - [0, 2] + out: 34 + - name: mixed_small_2 + in: + grid: + elemType: int + value: + - [4, 0, 2] + - [1, 3, 1] + - [0, 2, 0] + out: 52 + - name: mixed_small_3 + in: + grid: + elemType: int + value: + - [2, 1, 2] + - [1, 1, 1] + - [2, 1, 2] + out: 46 + - name: corner_line_2 + in: + grid: + elemType: int + value: + - [1, 2] + - [0, 0] + out: 14 + - name: double_col_2 + in: + grid: + elemType: int + value: + - [2, 0] + - [2, 0] + out: 16 + - name: hole_center_4 + in: + grid: + elemType: int + value: + - [1, 1, 1, 1] + - [1, 0, 0, 1] + - [1, 0, 0, 1] + - [1, 1, 1, 1] + out: 48 + - name: tall_center + in: + grid: + elemType: int + value: + - [0, 0, 0] + - [0, 50, 0] + - [0, 0, 0] + out: 202 + - name: tall_edge + in: + grid: + elemType: int + value: + - [50, 0] + - [0, 0] + out: 202 + - name: all_twos_2 + in: + grid: + elemType: int + value: + - [2, 2] + - [2, 2] + out: 24 + - name: increasing_rows + in: + grid: + elemType: int + value: + - [1, 2, 3] + - [4, 5, 6] + - [7, 8, 9] + out: 102 + - name: decreasing_rows + in: + grid: + elemType: int + value: + - [9, 8, 7] + - [6, 5, 4] + - [3, 2, 1] + out: 102 + - name: mixed_zero_row + in: + grid: + elemType: int + value: + - [0, 0, 0, 0, 0] + - [1, 0, 1, 0, 1] + - [0, 0, 0, 0, 0] + - [2, 2, 2, 2, 2] + - [0, 0, 0, 0, 0] + out: 52 + - name: border_only + in: + grid: + elemType: int + value: + - [1, 1, 1, 1] + - [1, 0, 0, 1] + - [1, 0, 0, 1] + - [1, 1, 1, 1] + out: 48 + - name: uneven_towers + in: + grid: + elemType: int + value: + - [1, 4, 1] + - [4, 1, 4] + - [1, 4, 1] + out: 78 + - name: max_flat_1 + in: + grid: + elemType: int + value: + - [50, 50] + - [50, 50] + out: 408 + - name: max_flat_2 + in: + grid: + elemType: int + value: + - [50, 0, 50] + - [0, 50, 0] + - [50, 0, 50] + out: 1010 + - name: sparse_large_1 + in: + grid: + elemType: int + value: + - [0, 0, 0, 0] + - [0, 0, 0, 0] + - [0, 0, 0, 0] + - [0, 0, 0, 1] + out: 6 + - name: sparse_large_2 + in: + grid: + elemType: int + value: + - [0, 0, 0, 0] + - [0, 0, 0, 0] + - [0, 0, 50, 0] + - [0, 0, 0, 0] + out: 202 + - name: mixed_dense_1 + in: + grid: + elemType: int + value: + - [3, 1, 3] + - [1, 2, 1] + - [3, 1, 3] + out: 66 + - name: mixed_dense_2 + in: + grid: + elemType: int + value: + - [2, 0, 2, 0] + - [0, 2, 0, 2] + - [2, 0, 2, 0] + - [0, 2, 0, 2] + out: 80 + - name: mixed_dense_3 + in: + grid: + elemType: int + value: + - [1, 2, 0, 2] + - [2, 1, 2, 0] + - [0, 2, 1, 2] + - [2, 0, 2, 1] + out: 80 + - name: max_edge_3 + in: + grid: + elemType: int + value: + - [50, 50, 50] + - [50, 50, 50] + - [50, 50, 50] + out: 618 diff --git a/tests/501-1000/892. surface-area-of-3d-shapes/sol.cpp b/tests/501-1000/892. surface-area-of-3d-shapes/sol.cpp new file mode 100644 index 00000000..2c352919 --- /dev/null +++ b/tests/501-1000/892. surface-area-of-3d-shapes/sol.cpp @@ -0,0 +1,22 @@ +class Solution { +public: + int surfaceArea(vector>& grid) { + int n = grid.size(); + int area = 0; + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + if (grid[i][j] > 0) { + area += grid[i][j] * 6; + area -= (grid[i][j] - 1) * 2; + if (i + 1 < n) { + area -= 2 * min(grid[i][j], grid[i + 1][j]); + } + if (j + 1 < n) { + area -= 2 * min(grid[i][j], grid[i][j + 1]); + } + } + } + } + return area; + } +}; diff --git a/tests/501-1000/892. surface-area-of-3d-shapes/sol.cs b/tests/501-1000/892. surface-area-of-3d-shapes/sol.cs new file mode 100644 index 00000000..026e3532 --- /dev/null +++ b/tests/501-1000/892. surface-area-of-3d-shapes/sol.cs @@ -0,0 +1,21 @@ +public class Solution { + public int SurfaceArea(int[][] grid) { + int n = grid.Length; + int area = 0; + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + if (grid[i][j] > 0) { + area += grid[i][j] * 6; + area -= (grid[i][j] - 1) * 2; + if (i + 1 < n) { + area -= 2 * Math.Min(grid[i][j], grid[i + 1][j]); + } + if (j + 1 < n) { + area -= 2 * Math.Min(grid[i][j], grid[i][j + 1]); + } + } + } + } + return area; + } +} diff --git a/tests/501-1000/892. surface-area-of-3d-shapes/sol.dart b/tests/501-1000/892. surface-area-of-3d-shapes/sol.dart new file mode 100644 index 00000000..3dda3aa5 --- /dev/null +++ b/tests/501-1000/892. surface-area-of-3d-shapes/sol.dart @@ -0,0 +1,21 @@ +class Solution { + int surfaceArea(List> grid) { + int n = grid.length; + int area = 0; + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + if (grid[i][j] > 0) { + area += grid[i][j] * 6; + area -= (grid[i][j] - 1) * 2; + if (i + 1 < n) { + area -= 2 * (grid[i][j] < grid[i + 1][j] ? grid[i][j] : grid[i + 1][j]); + } + if (j + 1 < n) { + area -= 2 * (grid[i][j] < grid[i][j + 1] ? grid[i][j] : grid[i][j + 1]); + } + } + } + } + return area; + } +} diff --git a/tests/501-1000/892. surface-area-of-3d-shapes/sol.go b/tests/501-1000/892. surface-area-of-3d-shapes/sol.go new file mode 100644 index 00000000..14e23609 --- /dev/null +++ b/tests/501-1000/892. surface-area-of-3d-shapes/sol.go @@ -0,0 +1,19 @@ +func surfaceArea(grid [][]int) int { + n := len(grid) + area := 0 + for i := 0; i < n; i++ { + for j := 0; j < n; j++ { + if grid[i][j] > 0 { + area += grid[i][j] * 6 + area -= (grid[i][j] - 1) * 2 + if i + 1 < n { + area -= 2 * min(grid[i][j], grid[i + 1][j]) + } + if j + 1 < n { + area -= 2 * min(grid[i][j], grid[i][j + 1]) + } + } + } + } + return area +} diff --git a/tests/501-1000/892. surface-area-of-3d-shapes/sol.java b/tests/501-1000/892. surface-area-of-3d-shapes/sol.java new file mode 100644 index 00000000..3adecd67 --- /dev/null +++ b/tests/501-1000/892. surface-area-of-3d-shapes/sol.java @@ -0,0 +1,21 @@ +class Solution { + public int surfaceArea(int[][] grid) { + int n = grid.length; + int area = 0; + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + if (grid[i][j] > 0) { + area += grid[i][j] * 6; + area -= (grid[i][j] - 1) * 2; + if (i + 1 < n) { + area -= 2 * Math.min(grid[i][j], grid[i + 1][j]); + } + if (j + 1 < n) { + area -= 2 * Math.min(grid[i][j], grid[i][j + 1]); + } + } + } + } + return area; + } +} diff --git a/tests/501-1000/892. surface-area-of-3d-shapes/sol.kt b/tests/501-1000/892. surface-area-of-3d-shapes/sol.kt new file mode 100644 index 00000000..4fb5f2cd --- /dev/null +++ b/tests/501-1000/892. surface-area-of-3d-shapes/sol.kt @@ -0,0 +1,21 @@ +class Solution { + fun surfaceArea(grid: Array): Int { + val n = grid.size + var area = 0 + for (i in 0 until n) { + for (j in 0 until n) { + if (grid[i][j] > 0) { + area += grid[i][j] * 6 + area -= (grid[i][j] - 1) * 2 + if (i + 1 < n) { + area -= 2 * minOf(grid[i][j], grid[i + 1][j]) + } + if (j + 1 < n) { + area -= 2 * minOf(grid[i][j], grid[i][j + 1]) + } + } + } + } + return area + } +} diff --git a/tests/501-1000/892. surface-area-of-3d-shapes/sol.py b/tests/501-1000/892. surface-area-of-3d-shapes/sol.py new file mode 100644 index 00000000..11a07f15 --- /dev/null +++ b/tests/501-1000/892. surface-area-of-3d-shapes/sol.py @@ -0,0 +1,18 @@ +class Solution: + def surfaceArea(self, grid: list[list[int]]) -> int: + n = len(grid) + area = 0 + for i in range(n): + for j in range(n): + if grid[i][j]: + # Base area for each stack + area += grid[i][j] * 6 + # Remove internal vertical faces + area -= (grid[i][j] - 1) * 2 + + # Subtract adjacent faces(right and down) + if i + 1 < n: + area -= 2 * min(grid[i][j], grid[i + 1][j]) + if j + 1 < n: + area -= 2 * min(grid[i][j], grid[i][j + 1]) + return area diff --git a/tests/501-1000/892. surface-area-of-3d-shapes/sol.py2 b/tests/501-1000/892. surface-area-of-3d-shapes/sol.py2 new file mode 100644 index 00000000..7b934e37 --- /dev/null +++ b/tests/501-1000/892. surface-area-of-3d-shapes/sol.py2 @@ -0,0 +1,18 @@ +class Solution(object): + def surfaceArea(self, grid): + """ + :type grid: List[List[int]] + :rtype: int + """ + n = len(grid) + area = 0 + for i in range(n): + for j in range(n): + if grid[i][j]: + area += grid[i][j] * 6 + area -= (grid[i][j] - 1) * 2 + if i + 1 < n: + area -= 2 * min(grid[i][j], grid[i + 1][j]) + if j + 1 < n: + area -= 2 * min(grid[i][j], grid[i][j + 1]) + return area diff --git a/tests/501-1000/892. surface-area-of-3d-shapes/sol.rb b/tests/501-1000/892. surface-area-of-3d-shapes/sol.rb new file mode 100644 index 00000000..fdc76c13 --- /dev/null +++ b/tests/501-1000/892. surface-area-of-3d-shapes/sol.rb @@ -0,0 +1,21 @@ +# @param {Integer[][]} grid +# @return {Integer} +def surface_area(grid) + n = grid.length + area = 0 + (0...n).each do |i| + (0...n).each do |j| + if grid[i][j] != 0 + area += grid[i][j] * 6 + area -= (grid[i][j] - 1) * 2 + if i + 1 < n + area -= 2 * [grid[i][j], grid[i + 1][j]].min + end + if j + 1 < n + area -= 2 * [grid[i][j], grid[i][j + 1]].min + end + end + end + end + area +end diff --git a/tests/501-1000/892. surface-area-of-3d-shapes/sol.rs b/tests/501-1000/892. surface-area-of-3d-shapes/sol.rs new file mode 100644 index 00000000..6126b4f4 --- /dev/null +++ b/tests/501-1000/892. surface-area-of-3d-shapes/sol.rs @@ -0,0 +1,21 @@ +impl Solution { + pub fn surface_area(grid: Vec>) -> i32 { + let n = grid.len(); + let mut area = 0; + for i in 0..n { + for j in 0..n { + if grid[i][j] > 0 { + area += grid[i][j] * 6; + area -= (grid[i][j] - 1) * 2; + if i + 1 < n { + area -= 2 * grid[i][j].min(grid[i + 1][j]); + } + if j + 1 < n { + area -= 2 * grid[i][j].min(grid[i][j + 1]); + } + } + } + } + area + } +} diff --git a/tests/501-1000/892. surface-area-of-3d-shapes/sol.swift b/tests/501-1000/892. surface-area-of-3d-shapes/sol.swift new file mode 100644 index 00000000..0b7c82ea --- /dev/null +++ b/tests/501-1000/892. surface-area-of-3d-shapes/sol.swift @@ -0,0 +1,21 @@ +class Solution { + func surfaceArea(_ grid: [[Int]]) -> Int { + let n = grid.count + var area = 0 + for i in 0.. 0 { + area += grid[i][j] * 6 + area -= (grid[i][j] - 1) * 2 + if i + 1 < n { + area -= 2 * min(grid[i][j], grid[i + 1][j]) + } + if j + 1 < n { + area -= 2 * min(grid[i][j], grid[i][j + 1]) + } + } + } + } + return area + } +} diff --git a/tests/501-1000/892. surface-area-of-3d-shapes/sol.ts b/tests/501-1000/892. surface-area-of-3d-shapes/sol.ts new file mode 100644 index 00000000..45bd100b --- /dev/null +++ b/tests/501-1000/892. surface-area-of-3d-shapes/sol.ts @@ -0,0 +1,19 @@ +function surfaceArea(grid: number[][]): number { + const n = grid.length; + let area = 0; + for (let i = 0; i < n; i++) { + for (let j = 0; j < n; j++) { + if (grid[i][j] > 0) { + area += grid[i][j] * 6; + area -= (grid[i][j] - 1) * 2; + if (i + 1 < n) { + area -= 2 * Math.min(grid[i][j], grid[i + 1][j]); + } + if (j + 1 < n) { + area -= 2 * Math.min(grid[i][j], grid[i][j + 1]); + } + } + } + } + return area; +} diff --git a/tests/501-1000/893. groups-of-special-equivalent-strings/manifest.yaml b/tests/501-1000/893. groups-of-special-equivalent-strings/manifest.yaml new file mode 100644 index 00000000..cffb0bc4 --- /dev/null +++ b/tests/501-1000/893. groups-of-special-equivalent-strings/manifest.yaml @@ -0,0 +1,190 @@ +entry: + id: 893 + title: groups-of-special-equivalent-strings + params: + words: + type: array + items: + type: string + call: + cpp: Solution().numSpecialEquivGroups({words}) + rust: Solution::num_special_equiv_groups({words}) + python3: Solution().numSpecialEquivGroups({words}) + python2: Solution().numSpecialEquivGroups({words}) + ruby: num_special_equiv_groups({words}) + java: new Solution().numSpecialEquivGroups({words}) + csharp: new Solution().NumSpecialEquivGroups({words}) + kotlin: Solution().numSpecialEquivGroups({words}) + go: numSpecialEquivGroups({words}) + dart: Solution().numSpecialEquivGroups({words}) + swift: Solution().numSpecialEquivGroups({words}) + typescript: numSpecialEquivGroups({words}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().numSpecialEquivGroups(words, {result}) + checker: | + class Checker: + def numSpecialEquivGroups(self, words, result): + seen = set() + for w in words: + seen.add(("".join(sorted(w[0::2])), "".join(sorted(w[1::2])))) + return len(seen) == result +seed: 893 +tests: + - name: ex1 + in: + words: [abcd, cdab, cbad, xyzz, zzxy, zzyx] + out: 3 + - name: ex2 + in: + words: [abc, acb, bac, bca, cab, cba] + out: 3 + - name: single + in: + words: [a] + out: 1 + - name: two_same + in: + words: [aa, aa] + out: 1 + - name: two_diff + in: + words: [ab, ba] + out: 2 + - name: three_even_same + in: + words: [abcd, bacd, cbad] + out: 2 + - name: same_multiset_odd + in: + words: [abc, cab, bca] + out: 3 + - name: all_unique_1 + in: + words: [a, b, c, d] + out: 4 + - name: all_unique_2 + in: + words: [ab, cd, ef, gh] + out: 4 + - name: repeated_groups_1 + in: + words: [az, za, az, za] + out: 2 + - name: repeated_groups_2 + in: + words: [abcd, bcda, adcb, cbad] + out: 2 + - name: repeated_groups_3 + in: + words: [aabb, bbaa, abab, baba] + out: 3 + - name: len_three_mix_1 + in: + words: [abc, abc, acb, bca] + out: 2 + - name: len_three_mix_2 + in: + words: [aaa, aab, aba, baa] + out: 3 + - name: len_four_mix_1 + in: + words: [abcd, abdc, badc, bcad] + out: 4 + - name: len_four_mix_2 + in: + words: [zzzz, zzzz, zzzz] + out: 1 + - name: len_four_mix_3 + in: + words: [azby, byaz, aybz, zbya] + out: 2 + - name: len_five_mix_1 + in: + words: [abcde, abced, bacde, baced] + out: 4 + - name: len_five_mix_2 + in: + words: [aaaaa, aaaab, aaaba, aabaa, abaaa] + out: 3 + - name: alternating_pairs_1 + in: + words: [abab, baba, aabb, bbaa] + out: 3 + - name: alternating_pairs_2 + in: + words: [qwer, rewq, erqw, wqer] + out: 3 + - name: distinct_four + in: + words: [abcd, efgh, ijkl, mnop] + out: 4 + - name: distinct_with_repeat + in: + words: [abcd, abcd, abdc, abdc, badc] + out: 3 + - name: short_edges_1 + in: + words: [a, a, b, b, c, c] + out: 3 + - name: short_edges_2 + in: + words: [ab, ab, ba, ba, aa] + out: 3 + - name: len_six_1 + in: + words: [abcdef, abcdef, badcfe, badcfe] + out: 2 + - name: len_six_2 + in: + words: [azazaz, zazaza, aazzaa, zzaazz] + out: 4 + - name: len_six_3 + in: + words: [aabbcc, abcabc, ccbbaa, bacbac] + out: 1 + - name: len_six_4 + in: + words: [mnopqr, nmoqpr, opmqnr, qrpomn] + out: 4 + - name: len_seven_1 + in: + words: [abcdefg, gfedcba, abcdefg] + out: 1 + - name: len_seven_2 + in: + words: [aaabbbc, abacbab, cbbbaaa, bbacaba] + out: 3 + - name: len_eight_1 + in: + words: [abcdefgh, hgfedcba, badcfehg, bdfhaceg] + out: 3 + - name: len_eight_2 + in: + words: [zzxyzzxy, zzyxzzxy, xyzzxyzz, yxzzxyzz] + out: 2 + - name: len_eight_3 + in: + words: [aabbccdd, ddccbbaa, abcdabcd, dcbaabcd] + out: 2 + - name: len_nine_1 + in: + words: [abcdefghi, ihgfedcba, acegibdfh] + out: 2 + - name: len_nine_2 + in: + words: [aaaaaaaaa, aaaaaaaab, aaaaaaaba, aaaaaabaa] + out: 3 + - name: len_ten_1 + in: + words: [abcdefghij, jihgfedcba, ajcdebhgfi, bjihedcgaf] + out: 4 + - name: len_ten_2 + in: + words: [ababababab, bababababa, aaaaabbbbb, bbbbbaaaaa] + out: 4 diff --git a/tests/501-1000/893. groups-of-special-equivalent-strings/sol.cpp b/tests/501-1000/893. groups-of-special-equivalent-strings/sol.cpp new file mode 100644 index 00000000..92ea1f00 --- /dev/null +++ b/tests/501-1000/893. groups-of-special-equivalent-strings/sol.cpp @@ -0,0 +1,17 @@ +class Solution { +public: + int numSpecialEquivGroups(vector& words) { + unordered_set seen; + for (const string& w : words) { + string even, odd; + for (int i = 0; i < w.size(); i++) { + if (i % 2 == 0) even += w[i]; + else odd += w[i]; + } + sort(even.begin(), even.end()); + sort(odd.begin(), odd.end()); + seen.insert(even + "," + odd); + } + return seen.size(); + } +}; diff --git a/tests/501-1000/893. groups-of-special-equivalent-strings/sol.cs b/tests/501-1000/893. groups-of-special-equivalent-strings/sol.cs new file mode 100644 index 00000000..0c563ddc --- /dev/null +++ b/tests/501-1000/893. groups-of-special-equivalent-strings/sol.cs @@ -0,0 +1,17 @@ +public class Solution { + public int NumSpecialEquivGroups(string[] words) { + var seen = new HashSet(); + foreach (var w in words) { + var even = new List(); + var odd = new List(); + for (int i = 0; i < w.Length; i++) { + if (i % 2 == 0) even.Add(w[i]); + else odd.Add(w[i]); + } + even.Sort(); + odd.Sort(); + seen.Add(new string(even.ToArray()) + "," + new string(odd.ToArray())); + } + return seen.Count; + } +} diff --git a/tests/501-1000/893. groups-of-special-equivalent-strings/sol.dart b/tests/501-1000/893. groups-of-special-equivalent-strings/sol.dart new file mode 100644 index 00000000..40d3e193 --- /dev/null +++ b/tests/501-1000/893. groups-of-special-equivalent-strings/sol.dart @@ -0,0 +1,20 @@ +class Solution { + int numSpecialEquivGroups(List words) { + var seen = {}; + for (var w in words) { + var even = []; + var odd = []; + for (var i = 0; i < w.length; i++) { + if (i % 2 == 0) { + even.add(w[i]); + } else { + odd.add(w[i]); + } + } + even.sort(); + odd.sort(); + seen.add(even.join() + ',' + odd.join()); + } + return seen.length; + } +} diff --git a/tests/501-1000/893. groups-of-special-equivalent-strings/sol.go b/tests/501-1000/893. groups-of-special-equivalent-strings/sol.go new file mode 100644 index 00000000..0f542f67 --- /dev/null +++ b/tests/501-1000/893. groups-of-special-equivalent-strings/sol.go @@ -0,0 +1,18 @@ +func numSpecialEquivGroups(words []string) int { + seen := make(map[string]bool) + for _, w := range words { + var even, odd []byte + for i := 0; i < len(w); i++ { + if i%2 == 0 { + even = append(even, w[i]) + } else { + odd = append(odd, w[i]) + } + } + sort.Slice(even, func(i, j int) bool { return even[i] < even[j] }) + sort.Slice(odd, func(i, j int) bool { return odd[i] < odd[j] }) + key := string(even) + "," + string(odd) + seen[key] = true + } + return len(seen) +} diff --git a/tests/501-1000/893. groups-of-special-equivalent-strings/sol.java b/tests/501-1000/893. groups-of-special-equivalent-strings/sol.java new file mode 100644 index 00000000..51990977 --- /dev/null +++ b/tests/501-1000/893. groups-of-special-equivalent-strings/sol.java @@ -0,0 +1,23 @@ +class Solution { + public int numSpecialEquivGroups(String[] words) { + Set seen = new HashSet<>(); + for (String w : words) { + int n = w.length(); + StringBuilder evenBuilder = new StringBuilder(); + StringBuilder oddBuilder = new StringBuilder(); + for (int i = 0; i < n; i++) { + if (i % 2 == 0) { + evenBuilder.append(w.charAt(i)); + } else { + oddBuilder.append(w.charAt(i)); + } + } + char[] even = evenBuilder.toString().toCharArray(); + char[] odd = oddBuilder.toString().toCharArray(); + Arrays.sort(even); + Arrays.sort(odd); + seen.add(new String(even) + "," + new String(odd)); + } + return seen.size(); + } +} diff --git a/tests/501-1000/893. groups-of-special-equivalent-strings/sol.kt b/tests/501-1000/893. groups-of-special-equivalent-strings/sol.kt new file mode 100644 index 00000000..f10f7958 --- /dev/null +++ b/tests/501-1000/893. groups-of-special-equivalent-strings/sol.kt @@ -0,0 +1,17 @@ +class Solution { + fun numSpecialEquivGroups(words: Array): Int { + val seen = mutableSetOf() + for (w in words) { + val even = StringBuilder() + val odd = StringBuilder() + for (i in w.indices) { + if (i % 2 == 0) even.append(w[i]) + else odd.append(w[i]) + } + val evenSorted = even.toString().toCharArray().sorted().joinToString("") + val oddSorted = odd.toString().toCharArray().sorted().joinToString("") + seen.add("$evenSorted,$oddSorted") + } + return seen.size + } +} diff --git a/tests/501-1000/893. groups-of-special-equivalent-strings/sol.py b/tests/501-1000/893. groups-of-special-equivalent-strings/sol.py new file mode 100644 index 00000000..cab67497 --- /dev/null +++ b/tests/501-1000/893. groups-of-special-equivalent-strings/sol.py @@ -0,0 +1,8 @@ +class Solution: + def numSpecialEquivGroups(self, words: list[str]) -> int: + seen = set() + for w in words: + even = "".join(sorted(w[0::2])) + odd = "".join(sorted(w[1::2])) + seen.add((even, odd)) + return len(seen) diff --git a/tests/501-1000/893. groups-of-special-equivalent-strings/sol.py2 b/tests/501-1000/893. groups-of-special-equivalent-strings/sol.py2 new file mode 100644 index 00000000..f0119f92 --- /dev/null +++ b/tests/501-1000/893. groups-of-special-equivalent-strings/sol.py2 @@ -0,0 +1,12 @@ +class Solution(object): + def numSpecialEquivGroups(self, words): + """ + :type words: List[str] + :rtype: int + """ + seen = set() + for w in words: + even = ''.join(sorted(w[0::2])) + odd = ''.join(sorted(w[1::2])) + seen.add((even, odd)) + return len(seen) diff --git a/tests/501-1000/893. groups-of-special-equivalent-strings/sol.rb b/tests/501-1000/893. groups-of-special-equivalent-strings/sol.rb new file mode 100644 index 00000000..ea24bde5 --- /dev/null +++ b/tests/501-1000/893. groups-of-special-equivalent-strings/sol.rb @@ -0,0 +1,11 @@ +# @param {String[]} words +# @return {Integer} +def num_special_equiv_groups(words) + seen = Set.new + words.each do |w| + even = w.chars.select.each_with_index { |_, i| i.even? }.sort.join + odd = w.chars.select.each_with_index { |_, i| i.odd? }.sort.join + seen.add([even, odd]) + end + seen.size +end diff --git a/tests/501-1000/893. groups-of-special-equivalent-strings/sol.rs b/tests/501-1000/893. groups-of-special-equivalent-strings/sol.rs new file mode 100644 index 00000000..3b9991f5 --- /dev/null +++ b/tests/501-1000/893. groups-of-special-equivalent-strings/sol.rs @@ -0,0 +1,21 @@ +impl Solution { + pub fn num_special_equiv_groups(words: Vec) -> i32 { + let mut seen = std::collections::HashSet::new(); + for w in words { + let mut even: Vec = vec![]; + let mut odd: Vec = vec![]; + for (i, c) in w.chars().enumerate() { + if i % 2 == 0 { + even.push(c); + } else { + odd.push(c); + } + } + even.sort(); + odd.sort(); + let key = even.iter().collect::() + "," + &odd.iter().collect::(); + seen.insert(key); + } + seen.len() as i32 + } +} diff --git a/tests/501-1000/893. groups-of-special-equivalent-strings/sol.swift b/tests/501-1000/893. groups-of-special-equivalent-strings/sol.swift new file mode 100644 index 00000000..45aae203 --- /dev/null +++ b/tests/501-1000/893. groups-of-special-equivalent-strings/sol.swift @@ -0,0 +1,20 @@ +class Solution { + func numSpecialEquivGroups(_ words: [String]) -> Int { + var seen = Set() + for w in words { + var even = [Character]() + var odd = [Character]() + for (i, c) in w.enumerated() { + if i % 2 == 0 { + even.append(c) + } else { + odd.append(c) + } + } + even.sort() + odd.sort() + seen.insert(String(even) + "," + String(odd)) + } + return seen.count + } +} diff --git a/tests/501-1000/893. groups-of-special-equivalent-strings/sol.ts b/tests/501-1000/893. groups-of-special-equivalent-strings/sol.ts new file mode 100644 index 00000000..9238b862 --- /dev/null +++ b/tests/501-1000/893. groups-of-special-equivalent-strings/sol.ts @@ -0,0 +1,18 @@ +function numSpecialEquivGroups(words: string[]): number { + const seen = new Set(); + for (const w of words) { + const even: string[] = []; + const odd: string[] = []; + for (let i = 0; i < w.length; i++) { + if (i % 2 === 0) { + even.push(w[i]); + } else { + odd.push(w[i]); + } + } + even.sort(); + odd.sort(); + seen.add(even.join("") + "," + odd.join("")); + } + return seen.size; +} diff --git a/tests/501-1000/896. monotonic-array/manifest.yaml b/tests/501-1000/896. monotonic-array/manifest.yaml new file mode 100644 index 00000000..b16f466a --- /dev/null +++ b/tests/501-1000/896. monotonic-array/manifest.yaml @@ -0,0 +1,171 @@ +entry: + id: 896 + title: monotonic-array + params: + nums: + type: array + items: + type: int + call: + cpp: Solution().isMonotonic({nums}) + rust: Solution::is_monotonic({nums}) + python3: Solution().isMonotonic({nums}) + python2: Solution().isMonotonic({nums}) + ruby: is_monotonic({nums}) + java: new Solution().isMonotonic({nums}) + csharp: new Solution().IsMonotonic({nums}) + kotlin: Solution().isMonotonic({nums}) + go: isMonotonic({nums}) + dart: Solution().isMonotonic({nums}) + swift: Solution().isMonotonic({nums}) + typescript: isMonotonic({nums}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().isMonotonic(nums, {result}) + checker: | + class Checker: + def isMonotonic(self, nums, result): + inc = True + dec = True + for i in range(1, len(nums)): + if nums[i] < nums[i - 1]: + inc = False + if nums[i] > nums[i - 1]: + dec = False + return result == (inc or dec) +seed: 896 +tests: + - name: ex1 + in: + nums: [1, 2, 2, 3] + - name: ex2 + in: + nums: [6, 5, 4, 4] + - name: ex3 + in: + nums: [1, 3, 2] + - name: single + in: + nums: [7] + - name: two_inc + in: + nums: [1, 2] + - name: two_dec + in: + nums: [2, 1] + - name: two_equal + in: + nums: [5, 5] + - name: plateau_inc + in: + nums: [1, 1, 2, 2, 3, 3] + - name: plateau_dec + in: + nums: [3, 3, 2, 2, 1, 1] + - name: false_mid_drop + in: + nums: [1, 2, 3, 2, 4] + - name: false_mid_rise + in: + nums: [5, 4, 3, 4, 2] + - name: neg_inc + in: + nums: [-5, -4, -4, -1] + - name: neg_dec + in: + nums: [-1, -2, -2, -5] + - name: mixed_false + in: + nums: [0, 0, -1, 0] + - name: max_bound_inc + in: + nums: [-100000, 0, 100000] + - name: max_bound_dec + in: + nums: [100000, 0, -100000] + - name: zigzag1 + in: + nums: [1, 2, 1] + - name: zigzag2 + in: + nums: [3, 2, 3] + - name: zigzag3 + in: + nums: [1, 2, 3, 2, 1] + - name: ascending_with_equals + in: + nums: [1, 2, 2, 2, 3, 4, 4] + - name: descending_with_equals + in: + nums: [9, 9, 7, 7, 5, 5] + - name: single_peak_false + in: + nums: [1, 2, 3, 5, 4, 4] + - name: single_valley_false + in: + nums: [9, 7, 5, 6, 4] + - name: front_flat_inc + in: + nums: [1, 1, 1, 2] + - name: front_flat_dec + in: + nums: [2, 1, 1, 1] + - name: late_drop + in: + nums: [1, 1, 1, 0] + - name: late_rise + in: + nums: [0, 1, 1, 1] + - name: false_alternating + in: + nums: [1, 1, 2, 1, 2, 2] + - name: false_alternating2 + in: + nums: [2, 2, 1, 2, 1, 1] + - name: two_large_equal + in: + nums: [100000, 100000] + - name: two_large_reverse + in: + nums: [100000, -100000] + - name: edge_false1 + in: + nums: [-100000, -99999, -100000] + - name: edge_false2 + in: + nums: [100000, 99999, 100000] + - name: edge_true1 + in: + nums: [-100000, -100000, -100000, -99999] + - name: edge_true2 + in: + nums: [100000, 100000, 99999, 99999] + - name: large_equal + in: + nums: + gen: array + len: 100000 + of: + gen: int + min: 42 + max: 42 + elemType: int + distinct: false + sorted: false + - name: large_increasing + in: + nums: + gen: array + len: 100000 + of: + gen: int + min: -100000 + max: 100000 + elemType: int + distinct: false + sorted: true diff --git a/tests/501-1000/896. monotonic-array/sol.cpp b/tests/501-1000/896. monotonic-array/sol.cpp new file mode 100644 index 00000000..20dcbaf2 --- /dev/null +++ b/tests/501-1000/896. monotonic-array/sol.cpp @@ -0,0 +1,20 @@ +class Solution { +public: + bool isMonotonic(vector& nums) { + int n = nums.size(); + if (nums[0] < nums[n - 1]) { + for (int i = 1; i < n; i++) { + if (nums[i] < nums[i - 1]) { + return false; + } + } + } else { + for (int i = 1; i < n; i++) { + if (nums[i] > nums[i - 1]) { + return false; + } + } + } + return true; + } +}; diff --git a/tests/501-1000/896. monotonic-array/sol.cs b/tests/501-1000/896. monotonic-array/sol.cs new file mode 100644 index 00000000..d9793748 --- /dev/null +++ b/tests/501-1000/896. monotonic-array/sol.cs @@ -0,0 +1,19 @@ +public class Solution { + public bool IsMonotonic(int[] nums) { + int n = nums.Length; + if (nums[0] < nums[n - 1]) { + for (int i = 1; i < n; i++) { + if (nums[i] < nums[i - 1]) { + return false; + } + } + } else { + for (int i = 1; i < n; i++) { + if (nums[i] > nums[i - 1]) { + return false; + } + } + } + return true; + } +} diff --git a/tests/501-1000/896. monotonic-array/sol.dart b/tests/501-1000/896. monotonic-array/sol.dart new file mode 100644 index 00000000..881e1ceb --- /dev/null +++ b/tests/501-1000/896. monotonic-array/sol.dart @@ -0,0 +1,19 @@ +class Solution { + bool isMonotonic(List nums) { + int n = nums.length; + if (nums[0] < nums[n - 1]) { + for (int i = 1; i < n; i++) { + if (nums[i] < nums[i - 1]) { + return false; + } + } + } else { + for (int i = 1; i < n; i++) { + if (nums[i] > nums[i - 1]) { + return false; + } + } + } + return true; + } +} diff --git a/tests/501-1000/896. monotonic-array/sol.go b/tests/501-1000/896. monotonic-array/sol.go new file mode 100644 index 00000000..538a9908 --- /dev/null +++ b/tests/501-1000/896. monotonic-array/sol.go @@ -0,0 +1,17 @@ +func isMonotonic(nums []int) bool { + n := len(nums) + if nums[0] < nums[n-1] { + for i := 1; i < n; i++ { + if nums[i] < nums[i-1] { + return false + } + } + } else { + for i := 1; i < n; i++ { + if nums[i] > nums[i-1] { + return false + } + } + } + return true +} diff --git a/tests/501-1000/896. monotonic-array/sol.java b/tests/501-1000/896. monotonic-array/sol.java new file mode 100644 index 00000000..2c066fee --- /dev/null +++ b/tests/501-1000/896. monotonic-array/sol.java @@ -0,0 +1,19 @@ +class Solution { + public boolean isMonotonic(int[] nums) { + int n = nums.length; + if (nums[0] < nums[n - 1]) { + for (int i = 1; i < n; i++) { + if (nums[i] < nums[i - 1]) { + return false; + } + } + } else { + for (int i = 1; i < n; i++) { + if (nums[i] > nums[i - 1]) { + return false; + } + } + } + return true; + } +} diff --git a/tests/501-1000/896. monotonic-array/sol.kt b/tests/501-1000/896. monotonic-array/sol.kt new file mode 100644 index 00000000..1a217105 --- /dev/null +++ b/tests/501-1000/896. monotonic-array/sol.kt @@ -0,0 +1,19 @@ +class Solution { + fun isMonotonic(nums: IntArray): Boolean { + val n = nums.size + if (nums[0] < nums[n - 1]) { + for (i in 1 until n) { + if (nums[i] < nums[i - 1]) { + return false + } + } + } else { + for (i in 1 until n) { + if (nums[i] > nums[i - 1]) { + return false + } + } + } + return true + } +} diff --git a/tests/501-1000/896. monotonic-array/sol.py b/tests/501-1000/896. monotonic-array/sol.py new file mode 100644 index 00000000..c01c6281 --- /dev/null +++ b/tests/501-1000/896. monotonic-array/sol.py @@ -0,0 +1,15 @@ +class Solution: + def isMonotonic(self, nums): + + n = len(nums) + + if nums[0] < nums[-1]: + for i in range(1, n): + if nums[i] < nums[i - 1]: + return False + else: + for i in range(1, n): + if nums[i] > nums[i - 1]: + return False + + return True diff --git a/tests/501-1000/896. monotonic-array/sol.py2 b/tests/501-1000/896. monotonic-array/sol.py2 new file mode 100644 index 00000000..9e0b728b --- /dev/null +++ b/tests/501-1000/896. monotonic-array/sol.py2 @@ -0,0 +1,16 @@ +class Solution(object): + def isMonotonic(self, nums): + """ + :type nums: List[int] + :rtype: bool + """ + n = len(nums) + if nums[0] < nums[-1]: + for i in range(1, n): + if nums[i] < nums[i - 1]: + return False + else: + for i in range(1, n): + if nums[i] > nums[i - 1]: + return False + return True diff --git a/tests/501-1000/896. monotonic-array/sol.rb b/tests/501-1000/896. monotonic-array/sol.rb new file mode 100644 index 00000000..48b3bae4 --- /dev/null +++ b/tests/501-1000/896. monotonic-array/sol.rb @@ -0,0 +1,15 @@ +# @param {Integer[]} nums +# @return {Boolean} +def is_monotonic(nums) + n = nums.length + if nums[0] < nums[-1] + (1...n).each do |i| + return false if nums[i] < nums[i - 1] + end + else + (1...n).each do |i| + return false if nums[i] > nums[i - 1] + end + end + true +end diff --git a/tests/501-1000/896. monotonic-array/sol.rs b/tests/501-1000/896. monotonic-array/sol.rs new file mode 100644 index 00000000..c5c146aa --- /dev/null +++ b/tests/501-1000/896. monotonic-array/sol.rs @@ -0,0 +1,19 @@ +impl Solution { + pub fn is_monotonic(nums: Vec) -> bool { + let n = nums.len(); + if nums[0] < nums[n - 1] { + for i in 1..n { + if nums[i] < nums[i - 1] { + return false; + } + } + } else { + for i in 1..n { + if nums[i] > nums[i - 1] { + return false; + } + } + } + true + } +} diff --git a/tests/501-1000/896. monotonic-array/sol.swift b/tests/501-1000/896. monotonic-array/sol.swift new file mode 100644 index 00000000..5796bdfc --- /dev/null +++ b/tests/501-1000/896. monotonic-array/sol.swift @@ -0,0 +1,19 @@ +class Solution { + func isMonotonic(_ nums: [Int]) -> Bool { + let n = nums.count + if nums[0] < nums[n - 1] { + for i in 1.. nums[i - 1] { + return false + } + } + } + return true + } +} diff --git a/tests/501-1000/896. monotonic-array/sol.ts b/tests/501-1000/896. monotonic-array/sol.ts new file mode 100644 index 00000000..cd50e0ff --- /dev/null +++ b/tests/501-1000/896. monotonic-array/sol.ts @@ -0,0 +1,17 @@ +function isMonotonic(nums: number[]): boolean { + const n = nums.length; + if (nums[0] < nums[n - 1]) { + for (let i = 1; i < n; i++) { + if (nums[i] < nums[i - 1]) { + return false; + } + } + } else { + for (let i = 1; i < n; i++) { + if (nums[i] > nums[i - 1]) { + return false; + } + } + } + return true; +} diff --git a/tests/501-1000/897. increasing-order-search-tree/manifest.yaml b/tests/501-1000/897. increasing-order-search-tree/manifest.yaml new file mode 100644 index 00000000..1f544804 --- /dev/null +++ b/tests/501-1000/897. increasing-order-search-tree/manifest.yaml @@ -0,0 +1,900 @@ +entry: + id: 897 + title: increasing-order-search-tree + params: + root: + type: tree_node + call: + cpp: "treeNodeToArray(Solution().increasingBST({root}))" + rust: "Solution::increasing_bst({root})" + python3: "tree_node_to_array(Solution().increasingBST({root}))" + python2: "tree_node_to_array(Solution().increasingBST({root}))" + ruby: "tree_node_to_array(increasing_bst({root}))" + java: "TreeNode.treeNodeToArray(new Solution().increasingBST({root}))" + csharp: "new Solution().IncreasingBST({root})" + kotlin: "treeNodeToArray(Solution().increasingBST({root}))" + go: "treeNodeToArray(increasingBST({root}))" + dart: "tree_node_to_array(Solution().increasingBST({root}))" + swift: "tree_node_to_array(Solution().increasingBST({root}))" + typescript: "treeNodeToArray(increasingBST({root}))" +judge: + type: "exact" +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().increasingBST(root, {result})" + checker: | + class Checker: + def increasingBST(self, root, result): + def inorder(node): + if not node: + return [] + return inorder(node.left) + [node.val] + inorder(node.right) + + expected = inorder(root) + + out = [] + for i, val in enumerate(expected): + out.append(val) + if i + 1 != len(expected): + out.append(None) + + return result == out +seed: 897 +tests: + - name: t01_single + in: + root: [1] + out: [1] + - name: t02_two_left + in: + root: [2, 1] + out: [1, null, 2] + - name: t03_two_right + in: + root: [1, null, 2] + out: [1, null, 2] + - name: t04_example1 + in: + root: [5, 3, 6, 2, 4, null, 8, 1, null, null, null, 7, 9] + out: + [ + 1, + null, + 2, + null, + 3, + null, + 4, + null, + 5, + null, + 6, + null, + 7, + null, + 8, + null, + 9, + ] + - name: t05_example2 + in: + root: [5, 1, 7] + out: [1, null, 5, null, 7] + - name: t06_left_chain_3 + in: + root: [3, 2, null, 1] + out: [1, null, 2, null, 3] + - name: t07_right_chain_3 + in: + root: [1, null, 2, null, 3] + out: [1, null, 2, null, 3] + - name: t08_balanced_7 + in: + root: [4, 2, 6, 1, 3, 5, 7] + out: [1, null, 2, null, 3, null, 4, null, 5, null, 6, null, 7] + - name: t09_left_heavy_7 + in: + root: [7, 6, null, 5, null, 4, null, 3, null, 2, null, 1] + out: [1, null, 2, null, 3, null, 4, null, 5, null, 6, null, 7] + - name: t10_right_heavy_7 + in: + root: [1, null, 4, null, 6, 5, 7] + out: [1, null, 4, null, 5, null, 6, null, 7] + - name: t11_values_8 + in: + root: [8, 4, 10, 2, 6, 9, 12, 1, 3, 5, 7, null, null, 11, 13] + out: + [ + 1, + null, + 2, + null, + 3, + null, + 4, + null, + 5, + null, + 6, + null, + 7, + null, + 8, + null, + 9, + null, + 10, + null, + 11, + null, + 12, + null, + 13, + ] + - name: t12_values_9 + in: + root: [9, 5, 12, 3, 7, 10, 14, 2, 4, 6, 8, null, 11, 13, 15] + out: + [ + 2, + null, + 3, + null, + 4, + null, + 5, + null, + 6, + null, + 7, + null, + 8, + null, + 9, + null, + 10, + null, + 11, + null, + 12, + null, + 13, + null, + 14, + null, + 15, + ] + - name: t13_values_10 + in: + root: [10, 5, 13, 2, 7, 11, 15, 1, 3, 6, 8, null, 12, 14, 16] + out: + [ + 1, + null, + 2, + null, + 3, + null, + 5, + null, + 6, + null, + 7, + null, + 8, + null, + 10, + null, + 11, + null, + 12, + null, + 13, + null, + 14, + null, + 15, + null, + 16, + ] + - name: t14_values_4 + in: + root: [4, 2, 6, 1, 3, 5, 7] + out: [1, null, 2, null, 3, null, 4, null, 5, null, 6, null, 7] + - name: t15_values_5 + in: + root: [5, 2, 7, 1, 3, 6, 8] + out: [1, null, 2, null, 3, null, 5, null, 6, null, 7, null, 8] + - name: t16_values_6 + in: + root: [6, 3, 9, 1, 4, 8, 10, null, 2, null, 5, 7, null, null, 11] + out: + [ + 1, + null, + 2, + null, + 3, + null, + 4, + null, + 5, + null, + 6, + null, + 7, + null, + 8, + null, + 9, + null, + 10, + null, + 11, + ] + - name: t17_values_11 + in: + root: [11, 5, 14, 2, 8, 12, 17, 1, 3, 6, 9, null, 13, 15, 18] + out: + [ + 1, + null, + 2, + null, + 3, + null, + 5, + null, + 6, + null, + 8, + null, + 9, + null, + 11, + null, + 12, + null, + 13, + null, + 14, + null, + 15, + null, + 17, + null, + 18, + ] + - name: t18_values_12 + in: + root: [12, 6, 18, 3, 9, 15, 21, 1, 4, 8, 10, 13, 16, 20, 22] + out: + [ + 1, + null, + 3, + null, + 4, + null, + 6, + null, + 8, + null, + 9, + null, + 10, + null, + 12, + null, + 13, + null, + 15, + null, + 16, + null, + 18, + null, + 20, + null, + 21, + null, + 22, + ] + - name: t19_values_13 + in: + root: [13, 7, 20, 4, 10, 16, 24, 2, 5, 8, 11, 14, 18, 22, 25] + out: + [ + 2, + null, + 4, + null, + 5, + null, + 7, + null, + 8, + null, + 10, + null, + 11, + null, + 13, + null, + 14, + null, + 16, + null, + 18, + null, + 20, + null, + 22, + null, + 24, + null, + 25, + ] + - name: t20_values_14 + in: + root: [14, 7, 21, 3, 10, 17, 24, 1, 5, 8, 12, 15, 19, 23, 25] + out: + [ + 1, + null, + 3, + null, + 5, + null, + 7, + null, + 8, + null, + 10, + null, + 12, + null, + 14, + null, + 15, + null, + 17, + null, + 19, + null, + 21, + null, + 23, + null, + 24, + null, + 25, + ] + - name: t21_values_15 + in: + root: [15, 7, 22, 3, 11, 18, 25, 1, 5, 9, 13, 16, 19, 24, 27] + out: + [ + 1, + null, + 3, + null, + 5, + null, + 7, + null, + 9, + null, + 11, + null, + 13, + null, + 15, + null, + 16, + null, + 18, + null, + 19, + null, + 22, + null, + 24, + null, + 25, + null, + 27, + ] + - name: t22_values_16 + in: + root: [16, 8, 24, 4, 12, 20, 28, 2, 6, 10, 14, 18, 22, 26, 30] + out: + [ + 2, + null, + 4, + null, + 6, + null, + 8, + null, + 10, + null, + 12, + null, + 14, + null, + 16, + null, + 18, + null, + 20, + null, + 22, + null, + 24, + null, + 26, + null, + 28, + null, + 30, + ] + - name: t23_values_17 + in: + root: [17, 9, 25, 5, 13, 21, 29, 3, 7, 11, 15, 19, 23, 27, 31] + out: + [ + 3, + null, + 5, + null, + 7, + null, + 9, + null, + 11, + null, + 13, + null, + 15, + null, + 17, + null, + 19, + null, + 21, + null, + 23, + null, + 25, + null, + 27, + null, + 29, + null, + 31, + ] + - name: t24_values_18 + in: + root: [18, 9, 27, 4, 13, 22, 31, 2, 6, 11, 15, 20, 24, 29, 33] + out: + [ + 2, + null, + 4, + null, + 6, + null, + 9, + null, + 11, + null, + 13, + null, + 15, + null, + 18, + null, + 20, + null, + 22, + null, + 24, + null, + 27, + null, + 29, + null, + 31, + null, + 33, + ] + - name: t25_values_19 + in: + root: [19, 10, 28, 5, 15, 24, 34, 3, 7, 12, 17, 22, 26, 31, 36] + out: + [ + 3, + null, + 5, + null, + 7, + null, + 10, + null, + 12, + null, + 15, + null, + 17, + null, + 19, + null, + 22, + null, + 24, + null, + 26, + null, + 28, + null, + 31, + null, + 34, + null, + 36, + ] + - name: t26_values_20 + in: + root: [20, 10, 30, 5, 15, 25, 35, 2, 7, 12, 17, 22, 27, 32, 37] + out: + [ + 2, + null, + 5, + null, + 7, + null, + 10, + null, + 12, + null, + 15, + null, + 17, + null, + 20, + null, + 22, + null, + 25, + null, + 27, + null, + 30, + null, + 32, + null, + 35, + null, + 37, + ] + - name: t27_values_21 + in: + root: [21, 11, 31, 6, 16, 26, 36, 3, 8, 13, 18, 23, 28, 33, 38] + out: + [ + 3, + null, + 6, + null, + 8, + null, + 11, + null, + 13, + null, + 16, + null, + 18, + null, + 21, + null, + 23, + null, + 26, + null, + 28, + null, + 31, + null, + 33, + null, + 36, + null, + 38, + ] + - name: t28_values_22 + in: + root: [22, 11, 33, 5, 17, 28, 39, 2, 7, 13, 19, 25, 30, 36, 41] + out: + [ + 2, + null, + 5, + null, + 7, + null, + 11, + null, + 13, + null, + 17, + null, + 19, + null, + 22, + null, + 25, + null, + 28, + null, + 30, + null, + 33, + null, + 36, + null, + 39, + null, + 41, + ] + - name: t29_values_23 + in: + root: [23, 12, 34, 6, 18, 29, 40, 3, 9, 15, 21, 26, 31, 37, 42] + out: + [ + 3, + null, + 6, + null, + 9, + null, + 12, + null, + 15, + null, + 18, + null, + 21, + null, + 23, + null, + 26, + null, + 29, + null, + 31, + null, + 34, + null, + 37, + null, + 40, + null, + 42, + ] + - name: t30_values_24 + in: + root: [24, 12, 36, 6, 18, 30, 42, 3, 9, 15, 21, 27, 33, 39, 45] + out: + [ + 3, + null, + 6, + null, + 9, + null, + 12, + null, + 15, + null, + 18, + null, + 21, + null, + 24, + null, + 27, + null, + 30, + null, + 33, + null, + 36, + null, + 39, + null, + 42, + null, + 45, + ] + - name: t31_values_25 + in: + root: [25, 13, 37, 7, 19, 31, 43, 4, 10, 16, 22, 28, 34, 40, 46] + out: + [ + 4, + null, + 7, + null, + 10, + null, + 13, + null, + 16, + null, + 19, + null, + 22, + null, + 25, + null, + 28, + null, + 31, + null, + 34, + null, + 37, + null, + 40, + null, + 43, + null, + 46, + ] + - name: t32_values_26 + in: + root: [26, 13, 39, 6, 20, 32, 45, 3, 9, 16, 23, 29, 35, 42, 47] + out: + [ + 3, + null, + 6, + null, + 9, + null, + 13, + null, + 16, + null, + 20, + null, + 23, + null, + 26, + null, + 29, + null, + 32, + null, + 35, + null, + 39, + null, + 42, + null, + 45, + null, + 47, + ] + - name: t33_values_27 + in: + root: [27, 14, 40, 7, 21, 33, 48, 4, 10, 17, 24, 30, 36, 43, 50] + out: + [ + 4, + null, + 7, + null, + 10, + null, + 14, + null, + 17, + null, + 21, + null, + 24, + null, + 27, + null, + 30, + null, + 33, + null, + 36, + null, + 40, + null, + 43, + null, + 48, + null, + 50, + ] + - name: t34_values_28 + in: + root: [28, 14, 42, 7, 21, 35, 49, 3, 10, 17, 24, 31, 38, 45, 52] + out: + [ + 3, + null, + 7, + null, + 10, + null, + 14, + null, + 17, + null, + 21, + null, + 24, + null, + 28, + null, + 31, + null, + 35, + null, + 38, + null, + 42, + null, + 45, + null, + 49, + null, + 52, + ] + - name: t35_values_29 + in: + root: [29, 15, 43, 8, 22, 36, 51, 4, 11, 18, 25, 33, 39, 46, 54] + out: + [ + 4, + null, + 8, + null, + 11, + null, + 15, + null, + 18, + null, + 22, + null, + 25, + null, + 29, + null, + 33, + null, + 36, + null, + 39, + null, + 43, + null, + 46, + null, + 51, + null, + 54, + ] diff --git a/tests/501-1000/897. increasing-order-search-tree/manifest.yml b/tests/501-1000/897. increasing-order-search-tree/manifest.yml new file mode 100644 index 00000000..03bbd966 --- /dev/null +++ b/tests/501-1000/897. increasing-order-search-tree/manifest.yml @@ -0,0 +1,880 @@ +entry: + id: 897 + title: increasing-order-search-tree + params: + root: + type: tree_node + call: + cpp: "Solution().increasingBST({root})" + rust: "Solution::increasing_bst({root})" + python3: "Solution().increasingBST({root})" + python2: "Solution().increasingBST({root})" + ruby: "increasing_bst({root})" + java: "new Solution().increasingBST({root})" + csharp: "new Solution().IncreasingBST({root})" + kotlin: "Solution().increasingBST({root})" + go: "increasingBST({root})" + dart: "Solution().increasingBST({root})" + swift: "Solution().increasingBST({root})" + typescript: "increasingBST({root})" +judge: + type: "exact" +limits: + time_ms: 1000 + memory_mb: 256 +seed: 897 +tests: + - name: t01_single + in: + root: [1] + out: [1] + - name: t02_two_left + in: + root: [2, 1] + out: [1, null, 2] + - name: t03_two_right + in: + root: [1, null, 2] + out: [1, null, 2] + - name: t04_example1 + in: + root: [5, 3, 6, 2, 4, null, 8, 1, null, null, null, 7, 9] + out: + [ + 1, + null, + 2, + null, + 3, + null, + 4, + null, + 5, + null, + 6, + null, + 7, + null, + 8, + null, + 9, + ] + - name: t05_example2 + in: + root: [5, 1, 7] + out: [1, null, 5, null, 7] + - name: t06_left_chain_3 + in: + root: [3, 2, null, 1] + out: [1, null, 2, null, 3] + - name: t07_right_chain_3 + in: + root: [1, null, 2, null, 3] + out: [1, null, 2, null, 3] + - name: t08_balanced_7 + in: + root: [4, 2, 6, 1, 3, 5, 7] + out: [1, null, 2, null, 3, null, 4, null, 5, null, 6, null, 7] + - name: t09_left_heavy_7 + in: + root: [7, 4, null, 2, 5, null, null, 1, 3, null, null, null, 6] + out: [1, null, 2, null, 3, null, 4, null, 5, null, 6, null, 7] + - name: t10_right_heavy_7 + in: + root: [1, null, 4, null, 6, 5, 7] + out: [1, null, 4, null, 5, null, 6, null, 7] + - name: t11_values_8 + in: + root: [8, 4, 10, 2, 6, 9, 12, 1, 3, 5, 7, null, null, 11, 13] + out: + [ + 1, + null, + 2, + null, + 3, + null, + 4, + null, + 5, + null, + 6, + null, + 7, + null, + 8, + null, + 9, + null, + 10, + null, + 11, + null, + 12, + null, + 13, + ] + - name: t12_values_9 + in: + root: [9, 5, 12, 3, 7, 10, 14, 2, 4, 6, 8, null, 11, 13, 15] + out: + [ + 2, + null, + 3, + null, + 4, + null, + 5, + null, + 6, + null, + 7, + null, + 8, + null, + 9, + null, + 10, + null, + 11, + null, + 12, + null, + 13, + null, + 14, + null, + 15, + ] + - name: t13_values_10 + in: + root: [10, 5, 13, 2, 7, 11, 15, 1, 3, 6, 8, null, 12, 14, 16] + out: + [ + 1, + null, + 2, + null, + 3, + null, + 5, + null, + 6, + null, + 7, + null, + 8, + null, + 10, + null, + 11, + null, + 12, + null, + 13, + null, + 14, + null, + 15, + null, + 16, + ] + - name: t14_values_4 + in: + root: [4, 2, 6, 1, 3, 5, 7] + out: [1, null, 2, null, 3, null, 4, null, 5, null, 6, null, 7] + - name: t15_values_5 + in: + root: [5, 2, 7, 1, 3, 6, 8] + out: [1, null, 2, null, 3, null, 5, null, 6, null, 7, null, 8] + - name: t16_values_6 + in: + root: [6, 3, 9, 1, 4, 8, 10, null, 2, null, 5, 7, null, null, 11] + out: + [ + 1, + null, + 2, + null, + 3, + null, + 4, + null, + 5, + null, + 6, + null, + 7, + null, + 8, + null, + 9, + null, + 10, + null, + 11, + ] + - name: t17_values_11 + in: + root: [11, 5, 14, 2, 8, 12, 17, 1, 3, 6, 9, null, 13, 15, 18] + out: + [ + 1, + null, + 2, + null, + 3, + null, + 5, + null, + 6, + null, + 8, + null, + 9, + null, + 11, + null, + 12, + null, + 13, + null, + 14, + null, + 15, + null, + 17, + null, + 18, + ] + - name: t18_values_12 + in: + root: [12, 6, 18, 3, 9, 15, 21, 1, 4, 8, 10, 13, 16, 20, 22] + out: + [ + 1, + null, + 3, + null, + 4, + null, + 6, + null, + 8, + null, + 9, + null, + 10, + null, + 12, + null, + 13, + null, + 15, + null, + 16, + null, + 18, + null, + 20, + null, + 21, + null, + 22, + ] + - name: t19_values_13 + in: + root: [13, 7, 20, 4, 10, 16, 24, 2, 5, 8, 11, 14, 18, 22, 25] + out: + [ + 2, + null, + 4, + null, + 5, + null, + 7, + null, + 8, + null, + 10, + null, + 11, + null, + 13, + null, + 14, + null, + 16, + null, + 18, + null, + 20, + null, + 22, + null, + 24, + null, + 25, + ] + - name: t20_values_14 + in: + root: [14, 7, 21, 3, 10, 17, 24, 1, 5, 8, 12, 15, 19, 23, 25] + out: + [ + 1, + null, + 3, + null, + 5, + null, + 7, + null, + 8, + null, + 10, + null, + 12, + null, + 14, + null, + 15, + null, + 17, + null, + 19, + null, + 21, + null, + 23, + null, + 24, + null, + 25, + ] + - name: t21_values_15 + in: + root: [15, 7, 22, 3, 11, 18, 25, 1, 5, 9, 13, 16, 19, 24, 27] + out: + [ + 1, + null, + 3, + null, + 5, + null, + 7, + null, + 9, + null, + 11, + null, + 13, + null, + 15, + null, + 16, + null, + 18, + null, + 19, + null, + 22, + null, + 24, + null, + 25, + null, + 27, + ] + - name: t22_values_16 + in: + root: [16, 8, 24, 4, 12, 20, 28, 2, 6, 10, 14, 18, 22, 26, 30] + out: + [ + 2, + null, + 4, + null, + 6, + null, + 8, + null, + 10, + null, + 12, + null, + 14, + null, + 16, + null, + 18, + null, + 20, + null, + 22, + null, + 24, + null, + 26, + null, + 28, + null, + 30, + ] + - name: t23_values_17 + in: + root: [17, 9, 25, 5, 13, 21, 29, 3, 7, 11, 15, 19, 23, 27, 31] + out: + [ + 3, + null, + 5, + null, + 7, + null, + 9, + null, + 11, + null, + 13, + null, + 15, + null, + 17, + null, + 19, + null, + 21, + null, + 23, + null, + 25, + null, + 27, + null, + 29, + null, + 31, + ] + - name: t24_values_18 + in: + root: [18, 9, 27, 4, 13, 22, 31, 2, 6, 11, 15, 20, 24, 29, 33] + out: + [ + 2, + null, + 4, + null, + 6, + null, + 9, + null, + 11, + null, + 13, + null, + 15, + null, + 18, + null, + 20, + null, + 22, + null, + 24, + null, + 27, + null, + 29, + null, + 31, + null, + 33, + ] + - name: t25_values_19 + in: + root: [19, 10, 28, 5, 15, 24, 34, 3, 7, 12, 17, 22, 26, 31, 36] + out: + [ + 3, + null, + 5, + null, + 7, + null, + 10, + null, + 12, + null, + 15, + null, + 17, + null, + 19, + null, + 22, + null, + 24, + null, + 26, + null, + 28, + null, + 31, + null, + 34, + null, + 36, + ] + - name: t26_values_20 + in: + root: [20, 10, 30, 5, 15, 25, 35, 2, 7, 12, 17, 22, 27, 32, 37] + out: + [ + 2, + null, + 5, + null, + 7, + null, + 10, + null, + 12, + null, + 15, + null, + 17, + null, + 20, + null, + 22, + null, + 25, + null, + 27, + null, + 30, + null, + 32, + null, + 35, + null, + 37, + ] + - name: t27_values_21 + in: + root: [21, 11, 31, 6, 16, 26, 36, 3, 8, 13, 18, 23, 28, 33, 38] + out: + [ + 3, + null, + 6, + null, + 8, + null, + 11, + null, + 13, + null, + 16, + null, + 18, + null, + 21, + null, + 23, + null, + 26, + null, + 28, + null, + 31, + null, + 33, + null, + 36, + null, + 38, + ] + - name: t28_values_22 + in: + root: [22, 11, 33, 5, 17, 28, 39, 2, 7, 13, 19, 25, 30, 36, 41] + out: + [ + 2, + null, + 5, + null, + 7, + null, + 11, + null, + 13, + null, + 17, + null, + 19, + null, + 22, + null, + 25, + null, + 28, + null, + 30, + null, + 33, + null, + 36, + null, + 39, + null, + 41, + ] + - name: t29_values_23 + in: + root: [23, 12, 34, 6, 18, 29, 40, 3, 9, 15, 21, 26, 31, 37, 42] + out: + [ + 3, + null, + 6, + null, + 9, + null, + 12, + null, + 15, + null, + 18, + null, + 21, + null, + 23, + null, + 26, + null, + 29, + null, + 31, + null, + 34, + null, + 37, + null, + 40, + null, + 42, + ] + - name: t30_values_24 + in: + root: [24, 12, 36, 6, 18, 30, 42, 3, 9, 15, 21, 27, 33, 39, 45] + out: + [ + 3, + null, + 6, + null, + 9, + null, + 12, + null, + 15, + null, + 18, + null, + 21, + null, + 24, + null, + 27, + null, + 30, + null, + 33, + null, + 36, + null, + 39, + null, + 42, + null, + 45, + ] + - name: t31_values_25 + in: + root: [25, 13, 37, 7, 19, 31, 43, 4, 10, 16, 22, 28, 34, 40, 46] + out: + [ + 4, + null, + 7, + null, + 10, + null, + 13, + null, + 16, + null, + 19, + null, + 22, + null, + 25, + null, + 28, + null, + 31, + null, + 34, + null, + 37, + null, + 40, + null, + 43, + null, + 46, + ] + - name: t32_values_26 + in: + root: [26, 13, 39, 6, 20, 32, 45, 3, 9, 16, 23, 29, 35, 42, 47] + out: + [ + 3, + null, + 6, + null, + 9, + null, + 13, + null, + 16, + null, + 20, + null, + 23, + null, + 26, + null, + 29, + null, + 32, + null, + 35, + null, + 39, + null, + 42, + null, + 45, + null, + 47, + ] + - name: t33_values_27 + in: + root: [27, 14, 40, 7, 21, 33, 48, 4, 10, 17, 24, 30, 36, 43, 50] + out: + [ + 4, + null, + 7, + null, + 10, + null, + 14, + null, + 17, + null, + 21, + null, + 24, + null, + 27, + null, + 30, + null, + 33, + null, + 36, + null, + 40, + null, + 43, + null, + 48, + null, + 50, + ] + - name: t34_values_28 + in: + root: [28, 14, 42, 7, 21, 35, 49, 3, 10, 17, 24, 31, 38, 45, 52] + out: + [ + 3, + null, + 7, + null, + 10, + null, + 14, + null, + 17, + null, + 21, + null, + 24, + null, + 28, + null, + 31, + null, + 35, + null, + 38, + null, + 42, + null, + 45, + null, + 49, + null, + 52, + ] + - name: t35_values_29 + in: + root: [29, 15, 43, 8, 22, 36, 51, 4, 11, 18, 25, 33, 39, 46, 54] + out: + [ + 4, + null, + 8, + null, + 11, + null, + 15, + null, + 18, + null, + 22, + null, + 25, + null, + 29, + null, + 33, + null, + 36, + null, + 39, + null, + 43, + null, + 46, + null, + 51, + null, + 54, + ] diff --git a/tests/501-1000/897. increasing-order-search-tree/sol.cpp b/tests/501-1000/897. increasing-order-search-tree/sol.cpp new file mode 100644 index 00000000..39895e50 --- /dev/null +++ b/tests/501-1000/897. increasing-order-search-tree/sol.cpp @@ -0,0 +1,34 @@ +/** + * Definition for a binary tree node. + * struct TreeNode { + * int val; + * TreeNode *left; + * TreeNode *right; + * TreeNode() : val(0), left(nullptr), right(nullptr) {} + * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} + * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} + * }; + */ +class Solution { +public: + TreeNode* increasingBST(TreeNode* root) { + vector vals; + inord(root, vals); + return create(vals, 0); + } + +private: + TreeNode* create(vector& vals, int i) { + if (i >= vals.size()) return nullptr; + TreeNode* node = new TreeNode(vals[i]); + node->right = create(vals, i + 1); + return node; + } + + void inord(TreeNode* root, vector& vals) { + if (!root) return; + inord(root->left, vals); + vals.push_back(root->val); + inord(root->right, vals); + } +}; diff --git a/tests/501-1000/897. increasing-order-search-tree/sol.cs b/tests/501-1000/897. increasing-order-search-tree/sol.cs new file mode 100644 index 00000000..736038c6 --- /dev/null +++ b/tests/501-1000/897. increasing-order-search-tree/sol.cs @@ -0,0 +1,34 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public int val; + * public TreeNode left; + * public TreeNode right; + * public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +public class Solution { + public TreeNode IncreasingBST(TreeNode root) { + List vals = new List(); + Inord(root, vals); + return Create(vals, 0); + } + + private TreeNode Create(List vals, int i) { + if (i >= vals.Count) return null; + TreeNode node = new TreeNode(vals[i]); + node.right = Create(vals, i + 1); + return node; + } + + private void Inord(TreeNode root, List vals) { + if (root == null) return; + Inord(root.left, vals); + vals.Add(root.val); + Inord(root.right, vals); + } +} diff --git a/tests/501-1000/897. increasing-order-search-tree/sol.dart b/tests/501-1000/897. increasing-order-search-tree/sol.dart new file mode 100644 index 00000000..d1150ec5 --- /dev/null +++ b/tests/501-1000/897. increasing-order-search-tree/sol.dart @@ -0,0 +1,30 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * int val; + * TreeNode? left; + * TreeNode? right; + * TreeNode([this.val = 0, this.left, this.right]); + * } + */ +class Solution { + TreeNode? increasingBST(TreeNode? root) { + List vals = []; + inord(root, vals); + return create(vals, 0); + } + + TreeNode? create(List vals, int i) { + if (i >= vals.length) return null; + TreeNode node = TreeNode(vals[i]); + node.right = create(vals, i + 1); + return node; + } + + void inord(TreeNode? root, List vals) { + if (root == null) return; + inord(root.left, vals); + vals.add(root.val); + inord(root.right, vals); + } +} diff --git a/tests/501-1000/897. increasing-order-search-tree/sol.go b/tests/501-1000/897. increasing-order-search-tree/sol.go new file mode 100644 index 00000000..c52fbe62 --- /dev/null +++ b/tests/501-1000/897. increasing-order-search-tree/sol.go @@ -0,0 +1,31 @@ +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +func increasingBST(root *TreeNode) *TreeNode { + vals := []int{} + inord(root, &vals) + return create(vals, 0) +} + +func create(vals []int, i int) *TreeNode { + if i >= len(vals) { + return nil + } + node := &TreeNode{Val: vals[i]} + node.Right = create(vals, i + 1) + return node +} + +func inord(root *TreeNode, vals *[]int) { + if root == nil { + return + } + inord(root.Left, vals) + *vals = append(*vals, root.Val) + inord(root.Right, vals) +} diff --git a/tests/501-1000/897. increasing-order-search-tree/sol.java b/tests/501-1000/897. increasing-order-search-tree/sol.java new file mode 100644 index 00000000..1c33800f --- /dev/null +++ b/tests/501-1000/897. increasing-order-search-tree/sol.java @@ -0,0 +1,36 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode() {} + * TreeNode(int val) { this.val = val; } + * TreeNode(int val, TreeNode left, TreeNode right) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +class Solution { + public TreeNode increasingBST(TreeNode root) { + List vals = new ArrayList<>(); + inord(root, vals); + return create(vals, 0); + } + + private TreeNode create(List vals, int i) { + if (i >= vals.size()) return null; + TreeNode node = new TreeNode(vals.get(i)); + node.right = create(vals, i + 1); + return node; + } + + private void inord(TreeNode root, List vals) { + if (root == null) return; + inord(root.left, vals); + vals.add(root.val); + inord(root.right, vals); + } +} diff --git a/tests/501-1000/897. increasing-order-search-tree/sol.kt b/tests/501-1000/897. increasing-order-search-tree/sol.kt new file mode 100644 index 00000000..63bfa8e1 --- /dev/null +++ b/tests/501-1000/897. increasing-order-search-tree/sol.kt @@ -0,0 +1,31 @@ +/** + * Example: + * var ti = TreeNode(5) + * var v = ti.`val` + * Definition for a binary tree node. + * class TreeNode(var `val`: Int) { + * var left: TreeNode? = null + * var right: TreeNode? = null + * } + */ +class Solution { + fun increasingBST(root: TreeNode?): TreeNode? { + val vals = mutableListOf() + inord(root, vals) + return create(vals, 0) + } + + private fun create(vals: List, i: Int): TreeNode? { + if (i >= vals.size) return null + val node = TreeNode(vals[i]) + node.right = create(vals, i + 1) + return node + } + + private fun inord(root: TreeNode?, vals: MutableList) { + if (root == null) return + inord(root.left, vals) + vals.add(root.`val`) + inord(root.right, vals) + } +} diff --git a/tests/501-1000/897. increasing-order-search-tree/sol.py b/tests/501-1000/897. increasing-order-search-tree/sol.py new file mode 100644 index 00000000..de27cec4 --- /dev/null +++ b/tests/501-1000/897. increasing-order-search-tree/sol.py @@ -0,0 +1,38 @@ +from typing import Optional + +# Definition for a binary tree node. +# class TreeNode: +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right + + +class Solution: + def increasingBST(self, root: Optional[TreeNode]) -> Optional[TreeNode]: + self.vals = [] + + # Store inorder traversal + self.inord(root) + + # Create increasing order BST + root = self.create(self.vals, 0) + + return root + + def create(self, vals, i): + if i >= len(vals): + return None + + root = TreeNode(vals[i]) + root.right = self.create(vals, i + 1) + + return root + + def inord(self, root): + if not root: + return + + self.inord(root.left) + self.vals.append(root.val) + self.inord(root.right) diff --git a/tests/501-1000/897. increasing-order-search-tree/sol.py2 b/tests/501-1000/897. increasing-order-search-tree/sol.py2 new file mode 100644 index 00000000..f8bc69b1 --- /dev/null +++ b/tests/501-1000/897. increasing-order-search-tree/sol.py2 @@ -0,0 +1,29 @@ +# Definition for a binary tree node. +# class TreeNode(object): +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution(object): + def increasingBST(self, root): + """ + :type root: Optional[TreeNode] + :rtype: Optional[TreeNode] + """ + self.vals = [] + self.inord(root) + return self.create(self.vals, 0) + + def create(self, vals, i): + if i >= len(vals): + return None + node = TreeNode(vals[i]) + node.right = self.create(vals, i + 1) + return node + + def inord(self, root): + if not root: + return + self.inord(root.left) + self.vals.append(root.val) + self.inord(root.right) diff --git a/tests/501-1000/897. increasing-order-search-tree/sol.rb b/tests/501-1000/897. increasing-order-search-tree/sol.rb new file mode 100644 index 00000000..c660de6c --- /dev/null +++ b/tests/501-1000/897. increasing-order-search-tree/sol.rb @@ -0,0 +1,30 @@ +# Definition for a binary tree node. +# class TreeNode +# attr_accessor :val, :left, :right +# def initialize(val = 0, left = nil, right = nil) +# @val = val +# @left = left +# @right = right +# end +# end +# @param {TreeNode} root +# @return {TreeNode} +def increasing_bst(root) + vals = [] + inord(root, vals) + create(vals, 0) +end + +def create(vals, i) + return nil if i >= vals.length + node = TreeNode.new(vals[i]) + node.right = create(vals, i + 1) + node +end + +def inord(root, vals) + return if root.nil? + inord(root.left, vals) + vals << root.val + inord(root.right, vals) +end diff --git a/tests/501-1000/897. increasing-order-search-tree/sol.rs b/tests/501-1000/897. increasing-order-search-tree/sol.rs new file mode 100644 index 00000000..de32f870 --- /dev/null +++ b/tests/501-1000/897. increasing-order-search-tree/sol.rs @@ -0,0 +1,43 @@ +// Definition for a binary tree node. +// #[derive(Debug, PartialEq, Eq)] +// pub struct TreeNode { +// pub val: i32, +// pub left: Option>>, +// pub right: Option>>, +// } +// +// impl TreeNode { +// #[inline] +// pub fn new(val: i32) -> Self { +// TreeNode { +// val, +// left: None, +// right: None +// } +// } +// } +impl Solution { + pub fn increasing_bst(root: Option>>) -> Option>> { + let mut vals = Vec::new(); + Self::inord(&root, &mut vals); + Self::create(&vals, 0) + } + + fn create(vals: &Vec, i: usize) -> Option>> { + if i >= vals.len() { + return None; + } + let node = Rc::new(RefCell::new(TreeNode::new(vals[i]))); + node.borrow_mut().right = Self::create(vals, i + 1); + Some(node) + } + + fn inord(root: &Option>>, vals: &mut Vec) { + if let Some(node) = root { + let node = node.borrow(); + Self::inord(&node.left, vals); + vals.push(node.val); + Self::inord(&node.right, vals); + } + } +} diff --git a/tests/501-1000/897. increasing-order-search-tree/sol.swift b/tests/501-1000/897. increasing-order-search-tree/sol.swift new file mode 100644 index 00000000..d8a2cb0d --- /dev/null +++ b/tests/501-1000/897. increasing-order-search-tree/sol.swift @@ -0,0 +1,36 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public var val: Int + * public var left: TreeNode? + * public var right: TreeNode? + * public init() { self.val = 0; self.left = nil; self.right = nil; } + * public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; } + * public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) { + * self.val = val + * self.left = left + * self.right = right + * } + * } + */ +class Solution { + func increasingBST(_ root: TreeNode?) -> TreeNode? { + var vals: [Int] = [] + inord(root, &vals) + return create(vals, 0) + } + + private func create(_ vals: [Int], _ i: Int) -> TreeNode? { + if i >= vals.count { return nil } + let node = TreeNode(vals[i]) + node.right = create(vals, i + 1) + return node + } + + private func inord(_ root: TreeNode?, _ vals: inout [Int]) { + guard let root = root else { return } + inord(root.left, &vals) + vals.append(root.val) + inord(root.right, &vals) + } +} diff --git a/tests/501-1000/897. increasing-order-search-tree/sol.ts b/tests/501-1000/897. increasing-order-search-tree/sol.ts new file mode 100644 index 00000000..d7af4306 --- /dev/null +++ b/tests/501-1000/897. increasing-order-search-tree/sol.ts @@ -0,0 +1,33 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ + +function increasingBST(root: TreeNode | null): TreeNode | null { + const vals: number[] = []; + inord(root, vals); + return create(vals, 0); +} + +function create(vals: number[], i: number): TreeNode | null { + if (i >= vals.length) return null; + const node = new TreeNode(vals[i]); + node.right = create(vals, i + 1); + return node; +} + +function inord(root: TreeNode | null, vals: number[]): void { + if (root === null) return; + inord(root.left, vals); + vals.push(root.val); + inord(root.right, vals); +} diff --git a/tests/501-1000/898. bitwise-ors-of-subarrays/manifest.yaml b/tests/501-1000/898. bitwise-ors-of-subarrays/manifest.yaml new file mode 100644 index 00000000..bfe93bed --- /dev/null +++ b/tests/501-1000/898. bitwise-ors-of-subarrays/manifest.yaml @@ -0,0 +1,182 @@ +entry: + id: 898 + title: bitwise-ors-of-subarrays + params: + arr: + type: array + items: + type: int + call: + cpp: "Solution().subarrayBitwiseORs({arr})" + rust: "Solution::subarray_bitwise_o_rs({arr})" + python3: "Solution().subarrayBitwiseORs({arr})" + python2: "Solution().subarrayBitwiseORs({arr})" + ruby: "subarray_bitwise_o_rs({arr})" + java: "new Solution().subarrayBitwiseORs({arr})" + csharp: "new Solution().SubarrayBitwiseORs({arr})" + kotlin: "Solution().subarrayBitwiseORs({arr})" + go: "subarrayBitwiseORs({arr})" + dart: "Solution().subarrayBitwiseORs({arr})" + swift: "Solution().subarrayBitwiseORs({arr})" + typescript: "subarrayBitwiseORs({arr})" +judge: + type: "exact" +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().subarrayBitwiseORs(arr, {result})" + checker: | + class Checker: + def subarrayBitwiseORs(self, arr, result): + expected = set() + current = set() + for x in arr: + nxt = {x | y for y in current} + nxt.add(x) + expected.update(nxt) + current = nxt + return result == len(expected) +seed: 898 +tests: + - name: t01_example1 + in: + arr: [0] + out: 1 + - name: t02_example2 + in: + arr: [1, 1, 2] + out: 3 + - name: t03_example3 + in: + arr: [1, 2, 4] + out: 6 + - name: t04_single_one + in: + arr: [1] + out: 1 + - name: t05_single_max_bit + in: + arr: [1000000000] + out: 1 + - name: t06_pair_same + in: + arr: [1, 1] + out: 1 + - name: t07_pair_diff + in: + arr: [1, 2] + out: 3 + - name: t08_pair_zero_one + in: + arr: [0, 1] + out: 2 + - name: t09_pair_power + in: + arr: [2, 4] + out: 3 + - name: t10_pair_many_bits + in: + arr: [5, 6] + out: 3 + - name: t11_triple_zero + in: + arr: [0, 0, 0] + out: 1 + - name: t12_triple_mixed + in: + arr: [1, 0, 1] + out: 2 + - name: t13_triple_abc + in: + arr: [1, 2, 3] + out: 3 + - name: t14_triple_powers + in: + arr: [1, 2, 4] + out: 6 + - name: t15_triple_ones_and_two + in: + arr: [1, 1, 2] + out: 3 + - name: t16_quad_increasing + in: + arr: [1, 2, 3, 4] + out: 5 + - name: t17_quad_decreasing + in: + arr: [8, 4, 2, 1] + out: 10 + - name: t18_quad_same + in: + arr: [7, 7, 7, 7] + out: 1 + - name: t19_quad_alternating + in: + arr: [1, 2, 1, 2] + out: 3 + - name: t20_quad_mixed + in: + arr: [0, 1, 0, 1] + out: 2 + - name: t21_mixed_small + in: + arr: [5, 1, 2] + out: 5 + - name: t22_mixed_small_2 + in: + arr: [6, 2, 1] + out: 5 + - name: t23_mixed_small_3 + in: + arr: [1, 3, 7] + out: 3 + - name: t24_mixed_small_4 + in: + arr: [9, 8, 7, 6] + out: 5 + - name: t25_mixed_small_5 + in: + arr: [31, 1, 2] + out: 4 + - name: t26_mixed_small_6 + in: + arr: [1, 5, 2, 6] + out: 5 + - name: t27_mixed_small_7 + in: + arr: [3, 5, 6, 7] + out: 4 + - name: t28_mixed_small_8 + in: + arr: [10, 12, 15] + out: 4 + - name: t29_mixed_small_9 + in: + arr: [8, 1, 8, 1] + out: 3 + - name: t30_five_same + in: + arr: [2, 2, 2, 2, 2] + out: 1 + - name: t31_five_increasing + in: + arr: [0, 1, 2, 3, 4] + out: 6 + - name: t32_five_peaks + in: + arr: [1, 4, 2, 8, 16] + out: 15 + - name: t33_five_repeat + in: + arr: [9, 1, 9, 1, 9] + out: 2 + - name: t34_large_bit + in: + arr: [1000000000, 1] + out: 3 + - name: t35_longer_mixed + in: + arr: [7, 3, 1, 5, 6] + out: 5 diff --git a/tests/501-1000/898. bitwise-ors-of-subarrays/manifest.yml b/tests/501-1000/898. bitwise-ors-of-subarrays/manifest.yml new file mode 100644 index 00000000..91059c0e --- /dev/null +++ b/tests/501-1000/898. bitwise-ors-of-subarrays/manifest.yml @@ -0,0 +1,168 @@ +entry: + id: 898 + title: bitwise-ors-of-subarrays + params: + arr: + type: array + items: + type: int + call: + cpp: "Solution().subarrayBitwiseORs({arr})" + rust: "Solution::subarray_bitwise_o_rs({arr})" + python3: "Solution().subarrayBitwiseORs({arr})" + python2: "Solution().subarrayBitwiseORs({arr})" + ruby: "subarray_bitwise_o_rs({arr})" + java: "new Solution().subarrayBitwiseORs({arr})" + csharp: "new Solution().SubarrayBitwiseORs({arr})" + kotlin: "Solution().subarrayBitwiseORs({arr})" + go: "subarrayBitwiseORs({arr})" + dart: "Solution().subarrayBitwiseORs({arr})" + swift: "Solution().subarrayBitwiseORs({arr})" + typescript: "subarrayBitwiseORs({arr})" +judge: + type: "exact" +limits: + time_ms: 1000 + memory_mb: 256 +seed: 898 +tests: + - name: t01_example1 + in: + arr: [0] + out: 1 + - name: t02_example2 + in: + arr: [1, 1, 2] + out: 3 + - name: t03_example3 + in: + arr: [1, 2, 4] + out: 6 + - name: t04_single_one + in: + arr: [1] + out: 1 + - name: t05_single_max_bit + in: + arr: [1000000000] + out: 1 + - name: t06_pair_same + in: + arr: [1, 1] + out: 1 + - name: t07_pair_diff + in: + arr: [1, 2] + out: 3 + - name: t08_pair_zero_one + in: + arr: [0, 1] + out: 2 + - name: t09_pair_power + in: + arr: [2, 4] + out: 3 + - name: t10_pair_many_bits + in: + arr: [5, 6] + out: 3 + - name: t11_triple_zero + in: + arr: [0, 0, 0] + out: 1 + - name: t12_triple_mixed + in: + arr: [1, 0, 1] + out: 2 + - name: t13_triple_abc + in: + arr: [1, 2, 3] + out: 3 + - name: t14_triple_powers + in: + arr: [1, 2, 4] + out: 6 + - name: t15_triple_ones_and_two + in: + arr: [1, 1, 2] + out: 3 + - name: t16_quad_increasing + in: + arr: [1, 2, 3, 4] + out: 5 + - name: t17_quad_decreasing + in: + arr: [8, 4, 2, 1] + out: 10 + - name: t18_quad_same + in: + arr: [7, 7, 7, 7] + out: 1 + - name: t19_quad_alternating + in: + arr: [1, 2, 1, 2] + out: 3 + - name: t20_quad_mixed + in: + arr: [0, 1, 0, 1] + out: 2 + - name: t21_mixed_small + in: + arr: [5, 1, 2] + out: 5 + - name: t22_mixed_small_2 + in: + arr: [6, 2, 1] + out: 5 + - name: t23_mixed_small_3 + in: + arr: [1, 3, 7] + out: 3 + - name: t24_mixed_small_4 + in: + arr: [9, 8, 7, 6] + out: 5 + - name: t25_mixed_small_5 + in: + arr: [31, 1, 2] + out: 4 + - name: t26_mixed_small_6 + in: + arr: [1, 5, 2, 6] + out: 5 + - name: t27_mixed_small_7 + in: + arr: [3, 5, 6, 7] + out: 4 + - name: t28_mixed_small_8 + in: + arr: [10, 12, 15] + out: 4 + - name: t29_mixed_small_9 + in: + arr: [8, 1, 8, 1] + out: 3 + - name: t30_five_same + in: + arr: [2, 2, 2, 2, 2] + out: 1 + - name: t31_five_increasing + in: + arr: [0, 1, 2, 3, 4] + out: 6 + - name: t32_five_peaks + in: + arr: [1, 4, 2, 8, 16] + out: 15 + - name: t33_five_repeat + in: + arr: [9, 1, 9, 1, 9] + out: 2 + - name: t34_large_bit + in: + arr: [1000000000, 1] + out: 3 + - name: t35_longer_mixed + in: + arr: [7, 3, 1, 5, 6] + out: 6 diff --git a/tests/501-1000/898. bitwise-ors-of-subarrays/sol.cpp b/tests/501-1000/898. bitwise-ors-of-subarrays/sol.cpp new file mode 100644 index 00000000..1a6d4d83 --- /dev/null +++ b/tests/501-1000/898. bitwise-ors-of-subarrays/sol.cpp @@ -0,0 +1,19 @@ +class Solution { +public: + int subarrayBitwiseORs(vector& arr) { + unordered_set result_ors; + unordered_set current_ors; + + for (int x : arr) { + unordered_set next_ors; + for (int y : current_ors) { + next_ors.insert(x | y); + } + next_ors.insert(x); + result_ors.insert(next_ors.begin(), next_ors.end()); + current_ors = next_ors; + } + + return result_ors.size(); + } +}; diff --git a/tests/501-1000/898. bitwise-ors-of-subarrays/sol.cs b/tests/501-1000/898. bitwise-ors-of-subarrays/sol.cs new file mode 100644 index 00000000..aab060af --- /dev/null +++ b/tests/501-1000/898. bitwise-ors-of-subarrays/sol.cs @@ -0,0 +1,18 @@ +public class Solution { + public int SubarrayBitwiseORs(int[] arr) { + HashSet resultOrs = new HashSet(); + HashSet currentOrs = new HashSet(); + + foreach (int x in arr) { + HashSet nextOrs = new HashSet(); + foreach (int y in currentOrs) { + nextOrs.Add(x | y); + } + nextOrs.Add(x); + resultOrs.UnionWith(nextOrs); + currentOrs = nextOrs; + } + + return resultOrs.Count; + } +} diff --git a/tests/501-1000/898. bitwise-ors-of-subarrays/sol.dart b/tests/501-1000/898. bitwise-ors-of-subarrays/sol.dart new file mode 100644 index 00000000..6ce6c191 --- /dev/null +++ b/tests/501-1000/898. bitwise-ors-of-subarrays/sol.dart @@ -0,0 +1,18 @@ +class Solution { + int subarrayBitwiseORs(List arr) { + Set resultOrs = {}; + Set currentOrs = {}; + + for (int x in arr) { + Set nextOrs = {}; + for (int y in currentOrs) { + nextOrs.add(x | y); + } + nextOrs.add(x); + resultOrs.addAll(nextOrs); + currentOrs = nextOrs; + } + + return resultOrs.length; + } +} diff --git a/tests/501-1000/898. bitwise-ors-of-subarrays/sol.go b/tests/501-1000/898. bitwise-ors-of-subarrays/sol.go new file mode 100644 index 00000000..9f9cb654 --- /dev/null +++ b/tests/501-1000/898. bitwise-ors-of-subarrays/sol.go @@ -0,0 +1,20 @@ +func subarrayBitwiseORs(arr []int) int { + resultOrs := make(map[int]bool) + currentOrs := make(map[int]bool) + + for _, x := range arr { + nextOrs := make(map[int]bool) + for y := range currentOrs { + nextOrs[x|y] = true + } + nextOrs[x] = true + + for val := range nextOrs { + resultOrs[val] = true + } + + currentOrs = nextOrs + } + + return len(resultOrs) +} diff --git a/tests/501-1000/898. bitwise-ors-of-subarrays/sol.java b/tests/501-1000/898. bitwise-ors-of-subarrays/sol.java new file mode 100644 index 00000000..8eb71b12 --- /dev/null +++ b/tests/501-1000/898. bitwise-ors-of-subarrays/sol.java @@ -0,0 +1,18 @@ +class Solution { + public int subarrayBitwiseORs(int[] arr) { + Set resultOrs = new HashSet<>(); + Set currentOrs = new HashSet<>(); + + for (int x : arr) { + Set nextOrs = new HashSet<>(); + for (int y : currentOrs) { + nextOrs.add(x | y); + } + nextOrs.add(x); + resultOrs.addAll(nextOrs); + currentOrs = nextOrs; + } + + return resultOrs.size(); + } +} diff --git a/tests/501-1000/898. bitwise-ors-of-subarrays/sol.kt b/tests/501-1000/898. bitwise-ors-of-subarrays/sol.kt new file mode 100644 index 00000000..e7148e2d --- /dev/null +++ b/tests/501-1000/898. bitwise-ors-of-subarrays/sol.kt @@ -0,0 +1,18 @@ +class Solution { + fun subarrayBitwiseORs(arr: IntArray): Int { + val resultOrs = mutableSetOf() + var currentOrs = mutableSetOf() + + for (x in arr) { + val nextOrs = mutableSetOf() + for (y in currentOrs) { + nextOrs.add(x or y) + } + nextOrs.add(x) + resultOrs.addAll(nextOrs) + currentOrs = nextOrs + } + + return resultOrs.size + } +} diff --git a/tests/501-1000/898. bitwise-ors-of-subarrays/sol.py b/tests/501-1000/898. bitwise-ors-of-subarrays/sol.py new file mode 100644 index 00000000..83a75ced --- /dev/null +++ b/tests/501-1000/898. bitwise-ors-of-subarrays/sol.py @@ -0,0 +1,23 @@ +class Solution: + def subarrayBitwiseORs(self, arr: list[int]) -> int: + # This set will store all unique OR values found across all subarrays. + result_ors = set() + + # This set stores the distinct ORs of all subarrays ending at the previous position. + current_ors = set() + + # Iterate through each element of the array. + for x in arr: + # `next_ors` will store the ORs of subarrays ending at the current element `x`. + # It's calculated by OR-ing x with all values in `current_ors`, + # and adding x itself (for the subarray of length 1). + next_ors = {x | y for y in current_ors} + next_ors.add(x) + + # Add all newly found ORs for subarrays ending at x to the main result set. + result_ors.update(next_ors) + + # For the next iteration, the current results become the previous results. + current_ors = next_ors + + return len(result_ors) diff --git a/tests/501-1000/898. bitwise-ors-of-subarrays/sol.py2 b/tests/501-1000/898. bitwise-ors-of-subarrays/sol.py2 new file mode 100644 index 00000000..646a98e8 --- /dev/null +++ b/tests/501-1000/898. bitwise-ors-of-subarrays/sol.py2 @@ -0,0 +1,16 @@ +class Solution(object): + def subarrayBitwiseORs(self, arr): + """ + :type arr: List[int] + :rtype: int + """ + result_ors = set() + current_ors = set() + + for x in arr: + next_ors = {x | y for y in current_ors} + next_ors.add(x) + result_ors.update(next_ors) + current_ors = next_ors + + return len(result_ors) diff --git a/tests/501-1000/898. bitwise-ors-of-subarrays/sol.rb b/tests/501-1000/898. bitwise-ors-of-subarrays/sol.rb new file mode 100644 index 00000000..600ae155 --- /dev/null +++ b/tests/501-1000/898. bitwise-ors-of-subarrays/sol.rb @@ -0,0 +1,16 @@ +# @param {Integer[]} arr +# @return {Integer} +def subarray_bitwise_o_rs(arr) + result_ors = Set.new + current_ors = Set.new + + arr.each do |x| + next_ors = Set.new + current_ors.each { |y| next_ors.add(x | y) } + next_ors.add(x) + result_ors.merge(next_ors) + current_ors = next_ors + end + + result_ors.size +end diff --git a/tests/501-1000/898. bitwise-ors-of-subarrays/sol.rs b/tests/501-1000/898. bitwise-ors-of-subarrays/sol.rs new file mode 100644 index 00000000..ca32f856 --- /dev/null +++ b/tests/501-1000/898. bitwise-ors-of-subarrays/sol.rs @@ -0,0 +1,20 @@ +impl Solution { + pub fn subarray_bitwise_o_rs(arr: Vec) -> i32 { + use std::collections::HashSet; + + let mut result_ors: HashSet = HashSet::new(); + let mut current_ors: HashSet = HashSet::new(); + + for x in arr { + let mut next_ors: HashSet = HashSet::new(); + for &y in ¤t_ors { + next_ors.insert(x | y); + } + next_ors.insert(x); + result_ors.extend(next_ors.iter().copied()); + current_ors = next_ors; + } + + result_ors.len() as i32 + } +} diff --git a/tests/501-1000/898. bitwise-ors-of-subarrays/sol.swift b/tests/501-1000/898. bitwise-ors-of-subarrays/sol.swift new file mode 100644 index 00000000..76463ba7 --- /dev/null +++ b/tests/501-1000/898. bitwise-ors-of-subarrays/sol.swift @@ -0,0 +1,18 @@ +class Solution { + func subarrayBitwiseORs(_ arr: [Int]) -> Int { + var resultOrs = Set() + var currentOrs = Set() + + for x in arr { + var nextOrs = Set() + for y in currentOrs { + nextOrs.insert(x | y) + } + nextOrs.insert(x) + resultOrs.formUnion(nextOrs) + currentOrs = nextOrs + } + + return resultOrs.count + } +} diff --git a/tests/501-1000/898. bitwise-ors-of-subarrays/sol.ts b/tests/501-1000/898. bitwise-ors-of-subarrays/sol.ts new file mode 100644 index 00000000..82bf83ab --- /dev/null +++ b/tests/501-1000/898. bitwise-ors-of-subarrays/sol.ts @@ -0,0 +1,16 @@ +function subarrayBitwiseORs(arr: number[]): number { + const resultOrs = new Set(); + let currentOrs = new Set(); + + for (const x of arr) { + const nextOrs = new Set(); + for (const y of currentOrs) { + nextOrs.add(x | y); + } + nextOrs.add(x); + nextOrs.forEach((val) => resultOrs.add(val)); + currentOrs = nextOrs; + } + + return resultOrs.size; +} diff --git a/tests/501-1000/899. orderly-queue/manifest.yaml b/tests/501-1000/899. orderly-queue/manifest.yaml new file mode 100644 index 00000000..298863c9 --- /dev/null +++ b/tests/501-1000/899. orderly-queue/manifest.yaml @@ -0,0 +1,218 @@ +entry: + id: 899 + title: orderly-queue + params: + s: + type: string + k: + type: int + call: + cpp: "Solution().orderlyQueue({s}, {k})" + rust: "Solution::orderly_queue({s}, {k})" + python3: "Solution().orderlyQueue({s}, {k})" + python2: "Solution().orderlyQueue({s}, {k})" + ruby: "orderly_queue({s}, {k})" + java: "new Solution().orderlyQueue({s}, {k})" + csharp: "new Solution().OrderlyQueue({s}, {k})" + kotlin: "Solution().orderlyQueue({s}, {k})" + go: "orderlyQueue({s}, {k})" + dart: "Solution().orderlyQueue({s}, {k})" + swift: "Solution().orderlyQueue({s}, {k})" + typescript: "orderlyQueue({s}, {k})" +judge: + type: "exact" +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().orderlyQueue(s, k, {result})" + checker: | + class Checker: + def orderlyQueue(self, s, k, result): + if k > 1: + expected = ''.join(sorted(s)) + else: + expected = s + for _ in range(len(s)): + s = s[1:] + s[0] + if s < expected: + expected = s + return result == expected +seed: 899 +tests: + - name: t01_example1 + in: + s: cba + k: 1 + out: acb + - name: t02_example2 + in: + s: baaca + k: 3 + out: aaabc + - name: t03_single_a + in: + s: a + k: 1 + out: a + - name: t04_single_z + in: + s: z + k: 1 + out: z + - name: t05_all_same + in: + s: aaaa + k: 1 + out: aaaa + - name: t06_two_chars_k1 + in: + s: ba + k: 1 + out: ab + - name: t07_two_chars_k2 + in: + s: ba + k: 2 + out: ab + - name: t08_abab_k1 + in: + s: abab + k: 1 + out: abab + - name: t09_abab_k2 + in: + s: abab + k: 2 + out: aabb + - name: t10_dcba_k1 + in: + s: dcba + k: 1 + out: adcb + - name: t11_dcba_k2 + in: + s: dcba + k: 2 + out: abcd + - name: t12_dcba_k4 + in: + s: dcba + k: 4 + out: abcd + - name: t13_leetcode_k1 + in: + s: leetcode + k: 1 + out: codeleet + - name: t14_leetcode_k2 + in: + s: leetcode + k: 2 + out: cdeeelot + - name: t15_bca_k1 + in: + s: bca + k: 1 + out: abc + - name: t16_bca_k2 + in: + s: bca + k: 2 + out: abc + - name: t17_bca_k3 + in: + s: bca + k: 3 + out: abc + - name: t18_zzxy_k1 + in: + s: zzxy + k: 1 + out: xyzz + - name: t19_zzxy_k2 + in: + s: zzxy + k: 2 + out: xyzz + - name: t20_zzxy_k4 + in: + s: zzxy + k: 4 + out: xyzz + - name: t21_azbycxdw_k1 + in: + s: azbycxdw + k: 1 + out: azbycxdw + - name: t22_azbycxdw_k3 + in: + s: azbycxdw + k: 3 + out: abcdwxyz + - name: t23_qwerty_k1 + in: + s: qwerty + k: 1 + out: ertyqw + - name: t24_qwerty_k2 + in: + s: qwerty + k: 2 + out: eqrtwy + - name: t25_banana_k1 + in: + s: banana + k: 1 + out: abanan + - name: t26_banana_k2 + in: + s: banana + k: 2 + out: aaabnn + - name: t27_cabbage_k1 + in: + s: cabbage + k: 1 + out: abbagec + - name: t28_cabbage_k3 + in: + s: cabbage + k: 3 + out: aabbceg + - name: t29_mnoabc_k1 + in: + s: mnoabc + k: 1 + out: abcmno + - name: t30_mnoabc_k2 + in: + s: mnoabc + k: 2 + out: abcmno + - name: t31_mnoabc_k6 + in: + s: mnoabc + k: 6 + out: abcmno + - name: t32_xyzabc_k1 + in: + s: xyzabc + k: 1 + out: abcxyz + - name: t33_xyzabc_k2 + in: + s: xyzabc + k: 2 + out: abcxyz + - name: t34_xyzabc_k5 + in: + s: xyzabc + k: 5 + out: abcxyz + - name: t35_bacbac_k1 + in: + s: bacbac + k: 1 + out: acbacb diff --git a/tests/501-1000/899. orderly-queue/manifest.yml b/tests/501-1000/899. orderly-queue/manifest.yml new file mode 100644 index 00000000..e6574939 --- /dev/null +++ b/tests/501-1000/899. orderly-queue/manifest.yml @@ -0,0 +1,203 @@ +entry: + id: 899 + title: orderly-queue + params: + s: + type: string + k: + type: int + call: + cpp: "Solution().orderlyQueue({s}, {k})" + rust: "Solution::orderly_queue({s}, {k})" + python3: "Solution().orderlyQueue({s}, {k})" + python2: "Solution().orderlyQueue({s}, {k})" + ruby: "orderly_queue({s}, {k})" + java: "new Solution().orderlyQueue({s}, {k})" + csharp: "new Solution().OrderlyQueue({s}, {k})" + kotlin: "Solution().orderlyQueue({s}, {k})" + go: "orderlyQueue({s}, {k})" + dart: "Solution().orderlyQueue({s}, {k})" + swift: "Solution().orderlyQueue({s}, {k})" + typescript: "orderlyQueue({s}, {k})" +judge: + type: "exact" +limits: + time_ms: 1000 + memory_mb: 256 +seed: 899 +tests: + - name: t01_example1 + in: + s: cba + k: 1 + out: acb + - name: t02_example2 + in: + s: baaca + k: 3 + out: aaabc + - name: t03_single_a + in: + s: a + k: 1 + out: a + - name: t04_single_z + in: + s: z + k: 1 + out: z + - name: t05_all_same + in: + s: aaaa + k: 1 + out: aaaa + - name: t06_two_chars_k1 + in: + s: ba + k: 1 + out: ab + - name: t07_two_chars_k2 + in: + s: ba + k: 2 + out: ab + - name: t08_abab_k1 + in: + s: abab + k: 1 + out: abab + - name: t09_abab_k2 + in: + s: abab + k: 2 + out: aabb + - name: t10_dcba_k1 + in: + s: dcba + k: 1 + out: adcb + - name: t11_dcba_k2 + in: + s: dcba + k: 2 + out: abcd + - name: t12_dcba_k4 + in: + s: dcba + k: 4 + out: abcd + - name: t13_leetcode_k1 + in: + s: leetcode + k: 1 + out: codeleet + - name: t14_leetcode_k2 + in: + s: leetcode + k: 2 + out: cdeeelot + - name: t15_bca_k1 + in: + s: bca + k: 1 + out: abc + - name: t16_bca_k2 + in: + s: bca + k: 2 + out: abc + - name: t17_bca_k3 + in: + s: bca + k: 3 + out: abc + - name: t18_zzxy_k1 + in: + s: zzxy + k: 1 + out: xyzz + - name: t19_zzxy_k2 + in: + s: zzxy + k: 2 + out: xyzz + - name: t20_zzxy_k4 + in: + s: zzxy + k: 4 + out: xyzz + - name: t21_azbycxdw_k1 + in: + s: azbycxdw + k: 1 + out: azbycxdw + - name: t22_azbycxdw_k3 + in: + s: azbycxdw + k: 3 + out: abcdwxyz + - name: t23_qwerty_k1 + in: + s: qwerty + k: 1 + out: ertyqw + - name: t24_qwerty_k2 + in: + s: qwerty + k: 2 + out: eqrtwy + - name: t25_banana_k1 + in: + s: banana + k: 1 + out: abanan + - name: t26_banana_k2 + in: + s: banana + k: 2 + out: aaabnn + - name: t27_cabbage_k1 + in: + s: cabbage + k: 1 + out: abbagec + - name: t28_cabbage_k3 + in: + s: cabbage + k: 3 + out: aabbceg + - name: t29_mnoabc_k1 + in: + s: mnoabc + k: 1 + out: abcmno + - name: t30_mnoabc_k2 + in: + s: mnoabc + k: 2 + out: abcmno + - name: t31_mnoabc_k6 + in: + s: mnoabc + k: 6 + out: abcmno + - name: t32_xyzabc_k1 + in: + s: xyzabc + k: 1 + out: abcxyz + - name: t33_xyzabc_k2 + in: + s: xyzabc + k: 2 + out: abcxyz + - name: t34_xyzabc_k5 + in: + s: xyzabc + k: 5 + out: abcxyz + - name: t35_bacbac_k1 + in: + s: bacbac + k: 1 + out: acbacb diff --git a/tests/501-1000/899. orderly-queue/sol.cpp b/tests/501-1000/899. orderly-queue/sol.cpp new file mode 100644 index 00000000..5c903739 --- /dev/null +++ b/tests/501-1000/899. orderly-queue/sol.cpp @@ -0,0 +1,19 @@ +class Solution { +public: + string orderlyQueue(string s, int k) { + if (k > 1) { + sort(s.begin(), s.end()); + return s; + } + + string res = s; + for (int i = 0; i < s.length(); i++) { + s = s.substr(1) + s[0]; + if (s < res) { + res = s; + } + } + + return res; + } +}; diff --git a/tests/501-1000/899. orderly-queue/sol.cs b/tests/501-1000/899. orderly-queue/sol.cs new file mode 100644 index 00000000..58fed981 --- /dev/null +++ b/tests/501-1000/899. orderly-queue/sol.cs @@ -0,0 +1,19 @@ +public class Solution { + public string OrderlyQueue(string s, int k) { + if (k > 1) { + char[] chars = s.ToCharArray(); + System.Array.Sort(chars); + return new string(chars); + } + + string res = s; + for (int i = 0; i < s.Length; i++) { + s = s.Substring(1) + s[0]; + if (string.Compare(s, res) < 0) { + res = s; + } + } + + return res; + } +} diff --git a/tests/501-1000/899. orderly-queue/sol.dart b/tests/501-1000/899. orderly-queue/sol.dart new file mode 100644 index 00000000..5d41b066 --- /dev/null +++ b/tests/501-1000/899. orderly-queue/sol.dart @@ -0,0 +1,19 @@ +class Solution { + String orderlyQueue(String s, int k) { + if (k > 1) { + List chars = s.split(''); + chars.sort(); + return chars.join(''); + } + + String res = s; + for (int i = 0; i < s.length; i++) { + s = s.substring(1) + s[0]; + if (s.compareTo(res) < 0) { + res = s; + } + } + + return res; + } +} diff --git a/tests/501-1000/899. orderly-queue/sol.go b/tests/501-1000/899. orderly-queue/sol.go new file mode 100644 index 00000000..8786f67a --- /dev/null +++ b/tests/501-1000/899. orderly-queue/sol.go @@ -0,0 +1,19 @@ +func orderlyQueue(s string, k int) string { + if k > 1 { + chars := []rune(s) + sort.Slice(chars, func(i, j int) bool { + return chars[i] < chars[j] + }) + return string(chars) + } + + res := s + for i := 0; i < len(s); i++ { + s = s[1:] + s[:1] + if s < res { + res = s + } + } + + return res +} diff --git a/tests/501-1000/899. orderly-queue/sol.java b/tests/501-1000/899. orderly-queue/sol.java new file mode 100644 index 00000000..f6d17adb --- /dev/null +++ b/tests/501-1000/899. orderly-queue/sol.java @@ -0,0 +1,19 @@ +class Solution { + public String orderlyQueue(String s, int k) { + if (k > 1) { + char[] chars = s.toCharArray(); + java.util.Arrays.sort(chars); + return new String(chars); + } + + String res = s; + for (int i = 0; i < s.length(); i++) { + s = s.substring(1) + s.charAt(0); + if (s.compareTo(res) < 0) { + res = s; + } + } + + return res; + } +} diff --git a/tests/501-1000/899. orderly-queue/sol.kt b/tests/501-1000/899. orderly-queue/sol.kt new file mode 100644 index 00000000..69d5b410 --- /dev/null +++ b/tests/501-1000/899. orderly-queue/sol.kt @@ -0,0 +1,18 @@ +class Solution { + fun orderlyQueue(s: String, k: Int): String { + if (k > 1) { + return s.toCharArray().sorted().joinToString("") + } + + var res = s + var current = s + for (i in 0 until s.length) { + current = current.substring(1) + current[0] + if (current < res) { + res = current + } + } + + return res + } +} diff --git a/tests/501-1000/899. orderly-queue/sol.py b/tests/501-1000/899. orderly-queue/sol.py new file mode 100644 index 00000000..a3496628 --- /dev/null +++ b/tests/501-1000/899. orderly-queue/sol.py @@ -0,0 +1,11 @@ +class Solution: + def orderlyQueue(self, s: str, k: int) -> str: + if k > 1: + return "".join(sorted(s)) + + res = s + for i in range(0, len(s)): + s = s[1:] + s[0] + res = min(res, s) + + return res diff --git a/tests/501-1000/899. orderly-queue/sol.py2 b/tests/501-1000/899. orderly-queue/sol.py2 new file mode 100644 index 00000000..1368f97e --- /dev/null +++ b/tests/501-1000/899. orderly-queue/sol.py2 @@ -0,0 +1,16 @@ +class Solution(object): + def orderlyQueue(self, s, k): + """ + :type s: str + :type k: int + :rtype: str + """ + if k > 1: + return "".join(sorted(s)) + + res = s + for i in range(len(s)): + s = s[1:] + s[0] + res = min(res, s) + + return res diff --git a/tests/501-1000/899. orderly-queue/sol.rb b/tests/501-1000/899. orderly-queue/sol.rb new file mode 100644 index 00000000..a458b9f1 --- /dev/null +++ b/tests/501-1000/899. orderly-queue/sol.rb @@ -0,0 +1,16 @@ +# @param {String} s +# @param {Integer} k +# @return {String} +def orderly_queue(s, k) + if k > 1 + return s.chars.sort.join + end + + res = s + (0...s.length).each do |i| + s = s[1..-1] + s[0] + res = [res, s].min + end + + res +end diff --git a/tests/501-1000/899. orderly-queue/sol.rs b/tests/501-1000/899. orderly-queue/sol.rs new file mode 100644 index 00000000..bfa1c5a9 --- /dev/null +++ b/tests/501-1000/899. orderly-queue/sol.rs @@ -0,0 +1,20 @@ +impl Solution { + pub fn orderly_queue(s: String, k: i32) -> String { + if k > 1 { + let mut chars: Vec = s.chars().collect(); + chars.sort(); + return chars.into_iter().collect(); + } + + let mut res = s.clone(); + let mut current = s; + for _ in 0..current.len() { + current = format!("{}{}", ¤t[1..], ¤t[..1]); + if current < res { + res = current.clone(); + } + } + + res + } +} diff --git a/tests/501-1000/899. orderly-queue/sol.swift b/tests/501-1000/899. orderly-queue/sol.swift new file mode 100644 index 00000000..b92c7920 --- /dev/null +++ b/tests/501-1000/899. orderly-queue/sol.swift @@ -0,0 +1,18 @@ +class Solution { + func orderlyQueue(_ s: String, _ k: Int) -> String { + if k > 1 { + return String(s.sorted()) + } + + var res = s + var current = s + for _ in 0.. 1) { + return s.split("").sort().join(""); + } + + let res: string = s; + for (let i = 0; i < s.length; i++) { + s = s.substring(1) + s[0]; + if (s < res) { + res = s; + } + } + + return res; +} diff --git a/tests/501-1000/902. numbers-at-most-n-given-digit-set/manifest.yaml b/tests/501-1000/902. numbers-at-most-n-given-digit-set/manifest.yaml new file mode 100644 index 00000000..c4064f43 --- /dev/null +++ b/tests/501-1000/902. numbers-at-most-n-given-digit-set/manifest.yaml @@ -0,0 +1,353 @@ +entry: + id: 902 + title: numbers-at-most-n-given-digit-set + params: + digits: + type: array + items: + type: string + n: + type: int + call: + cpp: "Solution().atMostNGivenDigitSet({digits}, {n})" + rust: "Solution::at_most_n_given_digit_set({digits}, {n})" + python3: "Solution().atMostNGivenDigitSet({digits}, {n})" + python2: "Solution().atMostNGivenDigitSet({digits}, {n})" + ruby: "at_most_n_given_digit_set({digits}, {n})" + java: "new Solution().atMostNGivenDigitSet({digits}, {n})" + csharp: "new Solution().AtMostNGivenDigitSet({digits}, {n})" + kotlin: "Solution().atMostNGivenDigitSet({digits}, {n})" + go: "atMostNGivenDigitSet({digits}, {n})" + dart: "Solution().atMostNGivenDigitSet({digits}, {n})" + swift: "Solution().atMostNGivenDigitSet({digits}, {n})" + typescript: "atMostNGivenDigitSet({digits}, {n})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().atMostNGivenDigitSet(digits, n, {result})" + checker: | + class Checker: + def atMostNGivenDigitSet(self, digits, n, result): + return isinstance(result, int) +seed: 902 +tests: + - name: example-1 + in: + digits: + - "1" + - "3" + - "5" + - "7" + n: 100 + out: 20 + - name: example-2 + in: + digits: + - "1" + - "4" + - "9" + n: 1000000000 + out: 29523 + - name: example-3 + in: + digits: + - "7" + n: 8 + out: 1 + - name: single-digit-equal + in: + digits: + - "1" + n: 1 + out: 1 + - name: single-digit-less + in: + digits: + - "2" + n: 1 + out: 0 + - name: single-digit-nine + in: + digits: + - "1" + n: 9 + out: 1 + - name: single-digit-repeated + in: + digits: + - "5" + n: 55 + out: 2 + - name: two-digits-small + in: + digits: + - "1" + - "2" + n: 11 + out: 3 + - name: two-digits-equal-prefix + in: + digits: + - "1" + - "2" + n: 12 + out: 4 + - name: two-digits-between + in: + digits: + - "1" + - "2" + n: 21 + out: 5 + - name: three-digits-full-match + in: + digits: + - "3" + - "4" + - "5" + n: 234 + out: 12 + - name: three-digits-no-third + in: + digits: + - "3" + - "4" + - "5" + n: 233 + out: 12 + - name: three-digits-exact + in: + digits: + - "1" + - "3" + - "5" + n: 135 + out: 18 + - name: three-digits-just-below + in: + digits: + - "1" + - "3" + - "5" + n: 134 + out: 17 + - name: even-digits-large + in: + digits: + - "2" + - "4" + - "6" + - "8" + n: 8888 + out: 340 + - name: even-digits-below + in: + digits: + - "2" + - "4" + - "6" + - "8" + n: 7777 + out: 276 + - name: mixed-high + in: + digits: + - "1" + - "7" + - "9" + n: 999 + out: 39 + - name: mixed-high-minus-one + in: + digits: + - "1" + - "7" + - "9" + n: 1000 + out: 39 + - name: all-digits-medium + in: + digits: + - "1" + - "2" + - "3" + - "4" + - "5" + - "6" + - "7" + - "8" + - "9" + n: 123456789 + out: 54481005 + - name: all-digits-max + in: + digits: + - "1" + - "2" + - "3" + - "4" + - "5" + - "6" + - "7" + - "8" + - "9" + n: 1000000000 + out: 435848049 + - name: high-two-digit-set-match + in: + digits: + - "8" + - "9" + n: 89 + out: 4 + - name: high-two-digit-set-below + in: + digits: + - "8" + - "9" + n: 88 + out: 3 + - name: mid-three-set-large + in: + digits: + - "4" + - "5" + - "6" + n: 4567 + out: 57 + - name: mid-three-set-prefix + in: + digits: + - "4" + - "5" + - "6" + n: 456 + out: 18 + - name: two-digit-gap + in: + digits: + - "1" + - "6" + n: 1666 + out: 22 + - name: two-digit-gap-minus + in: + digits: + - "1" + - "6" + n: 1665 + out: 21 + - name: sparse-three-set + in: + digits: + - "2" + - "3" + - "7" + n: 237 + out: 18 + - name: sparse-three-set-minus + in: + digits: + - "2" + - "3" + - "7" + n: 236 + out: 17 + - name: four-digits-large + in: + digits: + - "1" + - "5" + - "7" + - "9" + n: 5791 + out: 193 + - name: four-digits-large-minus + in: + digits: + - "1" + - "5" + - "7" + - "9" + n: 5790 + out: 192 + - name: one-digit-huge + in: + digits: + - "3" + n: 300000000 + out: 8 + - name: one-digit-huge-minus + in: + digits: + - "3" + n: 299999999 + out: 8 + - name: four-digits-desc + in: + digits: + - "1" + - "2" + - "3" + - "4" + n: 4321 + out: 313 + - name: four-digits-desc-minus + in: + digits: + - "1" + - "2" + - "3" + - "4" + n: 4320 + out: 312 + - name: three-digits-maxish + in: + digits: + - "2" + - "5" + - "8" + n: 258258258 + out: 13626 + - name: three-digits-maxish-minus + in: + digits: + - "2" + - "5" + - "8" + n: 258258257 + out: 13625 + - name: two-digits-near-max + in: + digits: + - "1" + - "9" + n: 999999999 + out: 1022 + - name: two-digits-near-max-minus + in: + digits: + - "1" + - "9" + n: 999999998 + out: 1021 + - name: triad-high + in: + digits: + - "1" + - "2" + - "8" + n: 812345678 + out: 24177 + - name: triad-high-minus + in: + digits: + - "1" + - "2" + - "8" + n: 812345677 + out: 24177 diff --git a/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.cpp b/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.cpp new file mode 100644 index 00000000..9be848a3 --- /dev/null +++ b/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.cpp @@ -0,0 +1,42 @@ +class Solution { +public: + int atMostNGivenDigitSet(vector& digits, int n) { + int d = digits.size(); + string s = to_string(n); + int k = s.length(); + + long long ans; + if (d == 1) { + ans = k - 1; + } else { + ans = (pow(d, k) - d) / (d - 1); + } + + for (int i = 0; i < k; i++) { + char ch = s[i]; + int cnt = 0; + for (const string& digit : digits) { + if (digit[0] < ch) { + cnt++; + } + } + ans += cnt * pow(d, k - i - 1); + + bool found = false; + for (const string& digit : digits) { + if (digit[0] == ch) { + found = true; + break; + } + } + if (!found) { + break; + } + if (i == k - 1) { + ans++; + } + } + + return (int)ans; + } +}; diff --git a/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.cs b/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.cs new file mode 100644 index 00000000..917020bc --- /dev/null +++ b/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.cs @@ -0,0 +1,41 @@ +public class Solution { + public int AtMostNGivenDigitSet(string[] digits, int n) { + int d = digits.Length; + string s = n.ToString(); + int k = s.Length; + + long ans; + if (d == 1) { + ans = k - 1; + } else { + ans = ((long)Math.Pow(d, k) - d) / (d - 1); + } + + for (int i = 0; i < k; i++) { + char ch = s[i]; + int cnt = 0; + foreach (string digit in digits) { + if (digit[0] < ch) { + cnt++; + } + } + ans += cnt * (long)Math.Pow(d, k - i - 1); + + bool found = false; + foreach (string digit in digits) { + if (digit[0] == ch) { + found = true; + break; + } + } + if (!found) { + break; + } + if (i == k - 1) { + ans++; + } + } + + return (int)ans; + } +} diff --git a/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.dart b/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.dart new file mode 100644 index 00000000..33388ba8 --- /dev/null +++ b/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.dart @@ -0,0 +1,41 @@ +class Solution { + int atMostNGivenDigitSet(List digits, int n) { + int d = digits.length; + String s = n.toString(); + int k = s.length; + List vals = digits.map((x) => x.codeUnitAt(0)).toList(); + + int powInt(int base, int exp) { + var result = 1; + for (var i = 0; i < exp; i++) { + result *= base; + } + return result; + } + + int ans = 0; + for (int len = 1; len < k; len++) { + ans += powInt(d, len); + } + + for (int i = 0; i < k; i++) { + int ch = s.codeUnitAt(i); + int cnt = 0; + for (int digit in vals) { + if (digit < ch) { + cnt++; + } + } + ans += cnt * powInt(d, k - i - 1); + + if (!vals.contains(ch)) { + return ans; + } + if (i == k - 1) { + ans++; + } + } + + return ans; + } +} diff --git a/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.go b/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.go new file mode 100644 index 00000000..1bbc40ec --- /dev/null +++ b/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.go @@ -0,0 +1,39 @@ +func atMostNGivenDigitSet(digits []string, n int) int { + d := len(digits) + s := strconv.Itoa(n) + k := len(s) + + ans := 0 + if d == 1 { + ans = k - 1 + } else { + ans = (int(math.Pow(float64(d), float64(k))) - d) / (d - 1) + } + + for i := 0; i < k; i++ { + ch := s[i] + cnt := 0 + for _, digit := range digits { + if digit[0] < ch { + cnt++ + } + } + ans += cnt * int(math.Pow(float64(d), float64(k-i-1))) + + found := false + for _, digit := range digits { + if digit[0] == ch { + found = true + break + } + } + if !found { + break + } + if i == k-1 { + ans++ + } + } + + return ans +} diff --git a/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.java b/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.java new file mode 100644 index 00000000..0a62832e --- /dev/null +++ b/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.java @@ -0,0 +1,41 @@ +class Solution { + public int atMostNGivenDigitSet(String[] digits, int n) { + int d = digits.length; + String s = Integer.toString(n); + int k = s.length(); + + int ans; + if (d == 1) { + ans = k - 1; + } else { + ans = (int)((Math.pow(d, k) - d) / (d - 1)); + } + + for (int i = 0; i < k; i++) { + char ch = s.charAt(i); + int cnt = 0; + for (String digit : digits) { + if (digit.charAt(0) < ch) { + cnt++; + } + } + ans += cnt * (int)Math.pow(d, k - i - 1); + + boolean found = false; + for (String digit : digits) { + if (digit.charAt(0) == ch) { + found = true; + break; + } + } + if (!found) { + break; + } + if (i == k - 1) { + ans++; + } + } + + return ans; + } +} diff --git a/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.kt b/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.kt new file mode 100644 index 00000000..f6b148e3 --- /dev/null +++ b/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.kt @@ -0,0 +1,34 @@ +class Solution { + fun atMostNGivenDigitSet(digits: Array, n: Int): Int { + val d = digits.size + val s = n.toString() + val k = s.length + val vals = digits.map { it[0] } + + fun powInt(base: Int, exp: Int): Int { + var out = 1 + repeat(exp) { out *= base } + return out + } + + var ans = 0 + for (len in 1 until k) { + ans += powInt(d, len) + } + + for (i in s.indices) { + val ch = s[i] + val cnt = digits.count { it[0] < ch } + ans += cnt * powInt(d, k - i - 1) + + if (ch !in vals) { + return ans + } + if (i == k - 1) { + ans++ + } + } + + return ans + } +} diff --git a/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.py b/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.py new file mode 100644 index 00000000..1225907d --- /dev/null +++ b/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.py @@ -0,0 +1,18 @@ +class Solution: + def atMostNGivenDigitSet(self, digits: List[str], n: int) -> int: + + f = lambda x: sum(ch < x for ch in digits) + + d, k = len(digits), len(str(n)) + + ans = k - 1 if d == 1 else (d**k - d) // (d - 1) + + for i, ch in enumerate(str(n)): + ans += f(ch) * (d ** (k - i - 1)) + if ch not in digits: + break + + else: + ans += 1 + + return ans diff --git a/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.py2 b/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.py2 new file mode 100644 index 00000000..d35916ca --- /dev/null +++ b/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.py2 @@ -0,0 +1,26 @@ +class Solution(object): + def atMostNGivenDigitSet(self, digits, n): + """ + :type digits: List[str] + :type n: int + :rtype: int + """ + d = len(digits) + s = str(n) + k = len(s) + + ans = 0 + if d == 1: + ans = k - 1 + else: + ans = (d**k - d) // (d - 1) + + for i, ch in enumerate(s): + cnt = sum(1 for digit in digits if digit < ch) + ans += cnt * (d ** (k - i - 1)) + if ch not in digits: + break + else: + ans += 1 + + return ans diff --git a/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.rb b/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.rb new file mode 100644 index 00000000..6492cda5 --- /dev/null +++ b/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.rb @@ -0,0 +1,24 @@ +# @param {String[]} digits +# @param {Integer} n +# @return {Integer} +def at_most_n_given_digit_set(digits, n) + d = digits.length + s = n.to_s + k = s.length + + pow = ->(base, exp) { (0...exp).reduce(1) { |acc, _| acc * base } } + ans = 0 + + (1...k).each do |len| + ans += pow.call(d, len) + end + + s.each_char.with_index do |ch, i| + cnt = digits.count { |digit| digit < ch } + ans += cnt * pow.call(d, k - i - 1) + return ans unless digits.include?(ch) + ans += 1 if i == k - 1 + end + + ans +end diff --git a/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.rs b/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.rs new file mode 100644 index 00000000..38653d0b --- /dev/null +++ b/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.rs @@ -0,0 +1,35 @@ +impl Solution { + pub fn at_most_n_given_digit_set(digits: Vec, n: i32) -> i32 { + let d = digits.len() as i32; + let s = n.to_string(); + let k = s.len() as i32; + let vals: Vec = digits.iter().map(|d| d.as_bytes()[0]).collect(); + + fn pow_int(base: i32, exp: i32) -> i32 { + let mut out = 1; + for _ in 0..exp { + out *= base; + } + out + } + + let mut ans = 0; + for len in 1..k { + ans += pow_int(d, len); + } + + for (i, ch) in s.bytes().enumerate() { + let cnt = vals.iter().filter(|&&digit| digit < ch).count() as i32; + ans += cnt * pow_int(d, k - i as i32 - 1); + + if !vals.contains(&ch) { + return ans; + } + if i == s.len() - 1 { + ans += 1; + } + } + + ans + } +} diff --git a/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.swift b/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.swift new file mode 100644 index 00000000..198db163 --- /dev/null +++ b/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.swift @@ -0,0 +1,28 @@ +class Solution { + func atMostNGivenDigitSet(_ digits: [String], _ n: Int) -> Int { + let d = digits.count + let s = String(n) + let k = s.count + + var ans: Int + if d == 1 { + ans = k - 1 + } else { + ans = (Int(pow(Double(d), Double(k))) - d) / (d - 1) + } + + for (i, ch) in s.enumerated() { + let cnt = digits.filter { $0 < String(ch) }.count + ans += cnt * Int(pow(Double(d), Double(k - i - 1))) + + if !digits.contains(String(ch)) { + break + } + if i == k - 1 { + ans += 1 + } + } + + return ans + } +} diff --git a/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.ts b/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.ts new file mode 100644 index 00000000..73aa762f --- /dev/null +++ b/tests/501-1000/902. numbers-at-most-n-given-digit-set/sol.ts @@ -0,0 +1,32 @@ +function atMostNGivenDigitSet(digits: string[], n: number): number { + const d = digits.length; + const s = n.toString(); + const k = s.length; + + let ans: number; + if (d === 1) { + ans = k - 1; + } else { + ans = Math.floor((Math.pow(d, k) - d) / (d - 1)); + } + + for (let i = 0; i < k; i++) { + const ch = s[i]; + let cnt = 0; + for (const digit of digits) { + if (digit < ch) { + cnt++; + } + } + ans += cnt * Math.pow(d, k - i - 1); + + if (!digits.includes(ch)) { + break; + } + if (i === k - 1) { + ans++; + } + } + + return ans; +} diff --git a/tests/501-1000/903. valid-permutations-for-di-sequence/manifest.yaml b/tests/501-1000/903. valid-permutations-for-di-sequence/manifest.yaml new file mode 100644 index 00000000..2fd36913 --- /dev/null +++ b/tests/501-1000/903. valid-permutations-for-di-sequence/manifest.yaml @@ -0,0 +1,173 @@ +entry: + id: 903 + title: valid-permutations-for-di-sequence + params: + s: + type: string + call: + cpp: "Solution().numPermsDISequence({s})" + rust: "Solution::num_perms_di_sequence({s})" + python3: "Solution().numPermsDISequence({s})" + python2: "Solution().numPermsDISequence({s})" + ruby: "num_perms_di_sequence({s})" + java: "new Solution().numPermsDISequence({s})" + csharp: "new Solution().NumPermsDISequence({s})" + kotlin: "Solution().numPermsDISequence({s})" + go: "numPermsDISequence({s})" + dart: "Solution().numPermsDISequence({s})" + swift: "Solution().numPermsDISequence({s})" + typescript: "numPermsDISequence({s})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().numPermsDISequence(s, {result})" + checker: | + class Checker: + def numPermsDISequence(self, s, result): + return isinstance(result, int) +seed: 903 +tests: + - name: example-1 + in: + s: "DID" + out: 5 + - name: example-2 + in: + s: "D" + out: 1 + - name: single-i + in: + s: "I" + out: 1 + - name: double-ii + in: + s: "II" + out: 1 + - name: double-dd + in: + s: "DD" + out: 1 + - name: di + in: + s: "DI" + out: 2 + - name: id + in: + s: "ID" + out: 2 + - name: didi + in: + s: "DIDI" + out: 16 + - name: idid + in: + s: "IDID" + out: 16 + - name: iii + in: + s: "III" + out: 1 + - name: ddd + in: + s: "DDD" + out: 1 + - name: iidd + in: + s: "IIDD" + out: 6 + - name: iidi + in: + s: "IIDI" + out: 9 + - name: ddi + in: + s: "DDI" + out: 3 + - name: didid + in: + s: "DIDID" + out: 61 + - name: ididi + in: + s: "IDIDI" + out: 61 + - name: iiii + in: + s: "IIII" + out: 1 + - name: dddd + in: + s: "DDDD" + out: 1 + - name: iiddi + in: + s: "IIDDI" + out: 26 + - name: diid + in: + s: "DIID" + out: 11 + - name: diii + in: + s: "DIII" + out: 4 + - name: iddd + in: + s: "IDDD" + out: 4 + - name: dii + in: + s: "DII" + out: 3 + - name: dididid + in: + s: "DIDIDID" + out: 1385 + - name: idididi + in: + s: "IDIDIDI" + out: 1385 + - name: didiid + in: + s: "DIDIID" + out: 181 + - name: ddiid + in: + s: "DDIID" + out: 26 + - name: iiddd + in: + s: "IIDDD" + out: 10 + - name: diddd + in: + s: "DIDDD" + out: 14 + - name: iidii + in: + s: "IIDII" + out: 19 + - name: ddiii + in: + s: "DDIII" + out: 10 + - name: iddi + in: + s: "IDDI" + out: 11 + - name: diidi + in: + s: "DIIDI" + out: 40 + - name: long-alternating + in: + s: "DIDIDIDIDIDIDIDIDIDID" + out: 907695790 + - name: long-blocks + in: + s: "IIIIIIIIIIIDDDDDDDDDD" + out: 352716 diff --git a/tests/501-1000/903. valid-permutations-for-di-sequence/sol.cpp b/tests/501-1000/903. valid-permutations-for-di-sequence/sol.cpp new file mode 100644 index 00000000..3acc31af --- /dev/null +++ b/tests/501-1000/903. valid-permutations-for-di-sequence/sol.cpp @@ -0,0 +1,31 @@ +class Solution { +public: + int numPermsDISequence(string s) { + int n = s.size(); + const int MOD = 1000000007; + vector dp = {1}; + for (int i = 1; i <= n; i++) { + vector prefix(i + 1); + prefix[0] = dp[0]; + for (int j = 1; j < i; j++) { + prefix[j] = (prefix[j-1] + dp[j]) % MOD; + } + prefix[i] = prefix[i-1] % MOD; + vector ndp(i + 1); + if (s[i-1] == 'I') { + for (int j = 0; j <= i; j++) { + ndp[j] = j > 0 ? prefix[j-1] % MOD : 0; + } + } else { + for (int j = 0; j <= i; j++) { + ndp[j] = (prefix[i-1] - (j > 0 ? prefix[j-1] : 0)) % MOD; + if (ndp[j] < 0) ndp[j] += MOD; + } + } + dp = ndp; + } + int sum = 0; + for (int v : dp) sum = (sum + v) % MOD; + return sum; + } +}; diff --git a/tests/501-1000/903. valid-permutations-for-di-sequence/sol.cs b/tests/501-1000/903. valid-permutations-for-di-sequence/sol.cs new file mode 100644 index 00000000..e69acdf1 --- /dev/null +++ b/tests/501-1000/903. valid-permutations-for-di-sequence/sol.cs @@ -0,0 +1,30 @@ +public class Solution { + public int NumPermsDISequence(string s) { + int n = s.Length; + int MOD = 1000000007; + int[] dp = new int[]{1}; + for (int i = 1; i <= n; i++) { + int[] prefix = new int[i + 1]; + prefix[0] = dp[0]; + for (int j = 1; j < i; j++) { + prefix[j] = (prefix[j-1] + dp[j]) % MOD; + } + prefix[i] = prefix[i-1] % MOD; + int[] ndp = new int[i + 1]; + if (s[i-1] == 'I') { + for (int j = 0; j <= i; j++) { + ndp[j] = j > 0 ? prefix[j-1] % MOD : 0; + } + } else { + for (int j = 0; j <= i; j++) { + ndp[j] = (prefix[i-1] - (j > 0 ? prefix[j-1] : 0)) % MOD; + if (ndp[j] < 0) ndp[j] += MOD; + } + } + dp = ndp; + } + int sum = 0; + foreach (int v in dp) sum = (sum + v) % MOD; + return sum; + } +} diff --git a/tests/501-1000/903. valid-permutations-for-di-sequence/sol.dart b/tests/501-1000/903. valid-permutations-for-di-sequence/sol.dart new file mode 100644 index 00000000..4e6bb836 --- /dev/null +++ b/tests/501-1000/903. valid-permutations-for-di-sequence/sol.dart @@ -0,0 +1,28 @@ +class Solution { + int numPermsDISequence(String s) { + int n = s.length; + int MOD = 1000000007; + List dp = [1]; + for (int i = 1; i <= n; i++) { + List prefix = List.filled(i + 1, 0); + prefix[0] = dp[0]; + for (int j = 1; j < i; j++) { + prefix[j] = (prefix[j-1] + dp[j]) % MOD; + } + prefix[i] = prefix[i-1] % MOD; + List ndp = List.filled(i + 1, 0); + if (s[i-1] == 'I') { + for (int j = 0; j <= i; j++) { + ndp[j] = j > 0 ? prefix[j-1] % MOD : 0; + } + } else { + for (int j = 0; j <= i; j++) { + ndp[j] = (prefix[i-1] - (j > 0 ? prefix[j-1] : 0)) % MOD; + if (ndp[j] < 0) ndp[j] += MOD; + } + } + dp = ndp; + } + return dp.reduce((a, b) => (a + b) % MOD); + } +} diff --git a/tests/501-1000/903. valid-permutations-for-di-sequence/sol.go b/tests/501-1000/903. valid-permutations-for-di-sequence/sol.go new file mode 100644 index 00000000..4f4de4c9 --- /dev/null +++ b/tests/501-1000/903. valid-permutations-for-di-sequence/sol.go @@ -0,0 +1,40 @@ +func numPermsDISequence(s string) int { + n := len(s) + MOD := 1000000007 + dp := []int{1} + for i := 1; i <= n; i++ { + prefix := make([]int, i+1) + prefix[0] = dp[0] + for j := 1; j < i; j++ { + prefix[j] = (prefix[j-1] + dp[j]) % MOD + } + prefix[i] = prefix[i-1] % MOD + ndp := make([]int, i+1) + if s[i-1] == 'I' { + for j := 0; j <= i; j++ { + if j > 0 { + ndp[j] = prefix[j-1] % MOD + } else { + ndp[j] = 0 + } + } + } else { + for j := 0; j <= i; j++ { + sub := 0 + if j > 0 { + sub = prefix[j-1] + } + ndp[j] = (prefix[i-1] - sub) % MOD + if ndp[j] < 0 { + ndp[j] += MOD + } + } + } + dp = ndp + } + sum := 0 + for _, v := range dp { + sum = (sum + v) % MOD + } + return sum +} diff --git a/tests/501-1000/903. valid-permutations-for-di-sequence/sol.java b/tests/501-1000/903. valid-permutations-for-di-sequence/sol.java new file mode 100644 index 00000000..1f047e7d --- /dev/null +++ b/tests/501-1000/903. valid-permutations-for-di-sequence/sol.java @@ -0,0 +1,30 @@ +class Solution { + public int numPermsDISequence(String s) { + int n = s.length(); + int MOD = 1000000007; + int[] dp = new int[]{1}; + for (int i = 1; i <= n; i++) { + int[] prefix = new int[i + 1]; + prefix[0] = dp[0]; + for (int j = 1; j < i; j++) { + prefix[j] = (prefix[j-1] + dp[j]) % MOD; + } + prefix[i] = prefix[i-1] % MOD; + int[] ndp = new int[i + 1]; + if (s.charAt(i-1) == 'I') { + for (int j = 0; j <= i; j++) { + ndp[j] = j > 0 ? prefix[j-1] % MOD : 0; + } + } else { + for (int j = 0; j <= i; j++) { + ndp[j] = (prefix[i-1] - (j > 0 ? prefix[j-1] : 0)) % MOD; + if (ndp[j] < 0) ndp[j] += MOD; + } + } + dp = ndp; + } + int sum = 0; + for (int v : dp) sum = (sum + v) % MOD; + return sum; + } +} diff --git a/tests/501-1000/903. valid-permutations-for-di-sequence/sol.kt b/tests/501-1000/903. valid-permutations-for-di-sequence/sol.kt new file mode 100644 index 00000000..2db3494a --- /dev/null +++ b/tests/501-1000/903. valid-permutations-for-di-sequence/sol.kt @@ -0,0 +1,28 @@ +class Solution { + fun numPermsDISequence(s: String): Int { + val n = s.length + val MOD = 1000000007 + var dp = intArrayOf(1) + for (i in 1..n) { + val prefix = IntArray(i + 1) + prefix[0] = dp[0] + for (j in 1 until i) { + prefix[j] = (prefix[j-1] + dp[j]) % MOD + } + prefix[i] = prefix[i-1] % MOD + val ndp = IntArray(i + 1) + if (s[i-1] == 'I') { + for (j in 0..i) { + ndp[j] = if (j > 0) prefix[j-1] % MOD else 0 + } + } else { + for (j in 0..i) { + ndp[j] = (prefix[i-1] - (if (j > 0) prefix[j-1] else 0)) % MOD + if (ndp[j] < 0) ndp[j] += MOD + } + } + dp = ndp + } + return dp.fold(0) { acc, v -> (acc + v) % MOD } + } +} diff --git a/tests/501-1000/903. valid-permutations-for-di-sequence/sol.py b/tests/501-1000/903. valid-permutations-for-di-sequence/sol.py new file mode 100644 index 00000000..be248ab8 --- /dev/null +++ b/tests/501-1000/903. valid-permutations-for-di-sequence/sol.py @@ -0,0 +1,21 @@ +class Solution: + def numPermsDISequence(self, s: str) -> int: + n = len(s) + dp = [1] + for i in range(1, n + 1): + prefix = [0] * (i + 1) + prefix[0] = dp[0] + for j in range(1, i): + prefix[j] = (prefix[j - 1] + dp[j]) % (10**9 + 7) + prefix[i] = (prefix[i - 1]) % (10**9 + 7) + ndp = [0] * (i + 1) + if s[i - 1] == "I": + for j in range(i + 1): + ndp[j] = prefix[j - 1] % (10**9 + 7) if j > 0 else 0 + else: + for j in range(i + 1): + ndp[j] = (prefix[i - 1] - (prefix[j - 1] if j > 0 else 0)) % ( + 10**9 + 7 + ) + dp = ndp + return sum(dp) % (10**9 + 7) diff --git a/tests/501-1000/903. valid-permutations-for-di-sequence/sol.py2 b/tests/501-1000/903. valid-permutations-for-di-sequence/sol.py2 new file mode 100644 index 00000000..494962c2 --- /dev/null +++ b/tests/501-1000/903. valid-permutations-for-di-sequence/sol.py2 @@ -0,0 +1,24 @@ +class Solution(object): + def numPermsDISequence(self, s): + """ + :type s: str + :rtype: int + """ + n = len(s) + dp = [1] + MOD = 10**9 + 7 + for i in range(1, n + 1): + prefix = [0] * (i + 1) + prefix[0] = dp[0] + for j in range(1, i): + prefix[j] = (prefix[j-1] + dp[j]) % MOD + prefix[i] = prefix[i-1] % MOD + ndp = [0] * (i + 1) + if s[i-1] == 'I': + for j in range(i + 1): + ndp[j] = prefix[j-1] % MOD if j > 0 else 0 + else: + for j in range(i + 1): + ndp[j] = (prefix[i-1] - (prefix[j-1] if j > 0 else 0)) % MOD + dp = ndp + return sum(dp) % MOD diff --git a/tests/501-1000/903. valid-permutations-for-di-sequence/sol.rb b/tests/501-1000/903. valid-permutations-for-di-sequence/sol.rb new file mode 100644 index 00000000..c1983d99 --- /dev/null +++ b/tests/501-1000/903. valid-permutations-for-di-sequence/sol.rb @@ -0,0 +1,27 @@ +# @param {String} s +# @return {Integer} +def num_perms_di_sequence(s) + n = s.length + dp = [1] + mod = 10**9 + 7 + (1..n).each do |i| + prefix = Array.new(i + 1, 0) + prefix[0] = dp[0] + (1...i).each do |j| + prefix[j] = (prefix[j-1] + dp[j]) % mod + end + prefix[i] = prefix[i-1] % mod + ndp = Array.new(i + 1, 0) + if s[i-1] == 'I' + (0..i).each do |j| + ndp[j] = j > 0 ? prefix[j-1] % mod : 0 + end + else + (0..i).each do |j| + ndp[j] = (prefix[i-1] - (j > 0 ? prefix[j-1] : 0)) % mod + end + end + dp = ndp + end + dp.sum % mod +end diff --git a/tests/501-1000/903. valid-permutations-for-di-sequence/sol.rs b/tests/501-1000/903. valid-permutations-for-di-sequence/sol.rs new file mode 100644 index 00000000..5eb35c88 --- /dev/null +++ b/tests/501-1000/903. valid-permutations-for-di-sequence/sol.rs @@ -0,0 +1,32 @@ +impl Solution { + pub fn num_perms_di_sequence(s: String) -> i32 { + let n = s.len(); + let MOD: i32 = 1_000_000_007; + let mut dp = vec![1]; + let s_bytes = s.as_bytes(); + for i in 1..=n { + let mut prefix = vec![0; i + 1]; + prefix[0] = dp[0]; + for j in 1..i { + prefix[j] = (prefix[j-1] + dp[j]) % MOD; + } + prefix[i] = prefix[i-1] % MOD; + let mut ndp = vec![0; i + 1]; + if s_bytes[i-1] == b'I' { + for j in 0..=i { + ndp[j] = if j > 0 { prefix[j-1] % MOD } else { 0 }; + } + } else { + for j in 0..=i { + let sub = if j > 0 { prefix[j-1] } else { 0 }; + ndp[j] = (prefix[i-1] - sub) % MOD; + if ndp[j] < 0 { + ndp[j] += MOD; + } + } + } + dp = ndp; + } + dp.iter().fold(0, |acc, &v| (acc + v) % MOD) + } +} diff --git a/tests/501-1000/903. valid-permutations-for-di-sequence/sol.swift b/tests/501-1000/903. valid-permutations-for-di-sequence/sol.swift new file mode 100644 index 00000000..1aa7d047 --- /dev/null +++ b/tests/501-1000/903. valid-permutations-for-di-sequence/sol.swift @@ -0,0 +1,29 @@ +class Solution { + func numPermsDISequence(_ s: String) -> Int { + let n = s.count + let MOD = 1000000007 + var dp = [1] + let arr = Array(s) + for i in 1...n { + var prefix = [Int](repeating: 0, count: i + 1) + prefix[0] = dp[0] + for j in 1.. 0 ? prefix[j-1] % MOD : 0 + } + } else { + for j in 0...i { + ndp[j] = (prefix[i-1] - (j > 0 ? prefix[j-1] : 0)) % MOD + if ndp[j] < 0 { ndp[j] += MOD } + } + } + dp = ndp + } + return dp.reduce(0) { ($0 + $1) % MOD } + } +} diff --git a/tests/501-1000/903. valid-permutations-for-di-sequence/sol.ts b/tests/501-1000/903. valid-permutations-for-di-sequence/sol.ts new file mode 100644 index 00000000..893a3213 --- /dev/null +++ b/tests/501-1000/903. valid-permutations-for-di-sequence/sol.ts @@ -0,0 +1,26 @@ +function numPermsDISequence(s: string): number { + const n = s.length; + const MOD = 1000000007; + let dp = [1]; + for (let i = 1; i <= n; i++) { + const prefix = new Array(i + 1).fill(0); + prefix[0] = dp[0]; + for (let j = 1; j < i; j++) { + prefix[j] = (prefix[j - 1] + dp[j]) % MOD; + } + prefix[i] = prefix[i - 1] % MOD; + const ndp = new Array(i + 1).fill(0); + if (s[i - 1] === "I") { + for (let j = 0; j <= i; j++) { + ndp[j] = j > 0 ? prefix[j - 1] % MOD : 0; + } + } else { + for (let j = 0; j <= i; j++) { + ndp[j] = (prefix[i - 1] - (j > 0 ? prefix[j - 1] : 0)) % MOD; + if (ndp[j] < 0) ndp[j] += MOD; + } + } + dp = ndp; + } + return dp.reduce((a, b) => (a + b) % MOD, 0); +} diff --git a/tests/501-1000/904. fruit-into-baskets/manifest.yaml b/tests/501-1000/904. fruit-into-baskets/manifest.yaml new file mode 100644 index 00000000..45579e85 --- /dev/null +++ b/tests/501-1000/904. fruit-into-baskets/manifest.yaml @@ -0,0 +1,202 @@ +entry: + id: 904 + title: fruit-into-baskets + params: + fruits: + type: array + items: + type: int + call: + cpp: "Solution().totalFruit({fruits})" + rust: "Solution::total_fruit({fruits})" + python3: "Solution().totalFruit({fruits})" + python2: "Solution().totalFruit({fruits})" + ruby: "total_fruit({fruits})" + java: "new Solution().totalFruit({fruits})" + csharp: "new Solution().TotalFruit({fruits})" + kotlin: "Solution().totalFruit({fruits})" + go: "totalFruit({fruits})" + dart: "Solution().totalFruit({fruits})" + swift: "Solution().totalFruit({fruits})" + typescript: "totalFruit({fruits})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().totalFruit(fruits, {result})" + checker: | + from collections import defaultdict + + class Checker: + def totalFruit(self, fruits, result): + if not isinstance(result, int): + return False + start = 0 + max_len = 0 + fruit_count = defaultdict(int) + for end in range(len(fruits)): + fruit_count[fruits[end]] += 1 + while len(fruit_count) > 2: + fruit_count[fruits[start]] -= 1 + if fruit_count[fruits[start]] == 0: + del fruit_count[fruits[start]] + start += 1 + max_len = max(max_len, end - start + 1) + return result == max_len +seed: 904 +tests: + - name: example-1 + in: + fruits: [1, 2, 1] + out: 3 + - name: example-2 + in: + fruits: [0, 1, 2, 2] + out: 3 + - name: example-3 + in: + fruits: [1, 2, 3, 2, 2] + out: 4 + - name: single + in: + fruits: [5] + out: 1 + - name: two-same + in: + fruits: [7, 7] + out: 2 + - name: two-diff + in: + fruits: [7, 8] + out: 2 + - name: all-same-6 + in: + fruits: [3, 3, 3, 3, 3, 3] + out: 6 + - name: pair-repeat + in: + fruits: [1, 2, 1, 2, 1, 2] + out: 6 + - name: three-alt + in: + fruits: [1, 2, 3, 1, 2, 3] + out: 2 + - name: long-two + in: + fruits: [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1] + out: 20 + - name: long-three + in: + fruits: [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2] + out: 2 + - name: block-two + in: + fruits: [2, 2, 2, 2, 2, 3, 3, 3, 3, 2, 2, 2] + out: 12 + - name: block-three + in: + fruits: [2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4] + out: 9 + - name: mixed1 + in: + fruits: [1, 2, 3, 2, 2, 1, 1] + out: 4 + - name: mixed2 + in: + fruits: [0, 1, 0, 1, 2, 2, 1] + out: 4 + - name: edge-high + in: + fruits: [0, 49999, 0, 49999, 1] + out: 4 + - name: edge-many + in: + fruits: [0, 1, 2, 3, 2, 2, 1, 1, 4, 4] + out: 4 + - name: pattern1 + in: + fruits: [1, 2, 1, 3, 3, 2, 2, 2] + out: 5 + - name: pattern2 + in: + fruits: [4, 5, 4, 5, 6, 6, 6, 5, 4] + out: 5 + - name: pattern3 + in: + fruits: [9, 8, 7, 8, 9, 8, 7, 7] + out: 3 + - name: pattern4 + in: + fruits: [0, 1, 0, 2, 2, 2, 1, 1, 0] + out: 5 + - name: pattern5 + in: + fruits: [1, 1, 2, 2, 3, 3, 2, 2, 1, 1] + out: 6 + - name: pattern6 + in: + fruits: [1, 2, 2, 3, 3, 3, 2, 2, 1] + out: 7 + - name: pattern7 + in: + fruits: [3, 4, 5, 5, 4, 4, 3, 3] + out: 5 + - name: pattern8 + in: + fruits: [6, 7, 6, 7, 6, 8, 8, 7, 6] + out: 5 + - name: pattern9 + in: + fruits: [1, 2, 1, 2, 3, 4, 4, 4, 3] + out: 5 + - name: pattern10 + in: + fruits: [2, 2, 2, 3, 4, 5, 5, 4, 4, 4] + out: 6 + - name: pattern11 + in: + fruits: [0, 0, 1, 2, 2, 1, 1, 0, 0] + out: 5 + - name: pattern12 + in: + fruits: [5, 6, 7, 6, 5, 6, 7, 7, 6] + out: 4 + - name: gen-large-a + in: + fruits: + gen: "array" + len: 100000 + of: + gen: "int" + min: 0 + max: 2 + elemType: "int" + - name: gen-large-b + in: + fruits: + gen: "array" + len: 100000 + of: + gen: "int" + min: 0 + max: 2 + elemType: "int" + - name: extra-1 + in: + fruits: [4, 1, 4, 1, 4, 2, 2, 2, 1] + out: 5 + - name: extra-2 + in: + fruits: [2, 3, 2, 4, 4, 4, 3, 3] + out: 5 + - name: extra-3 + in: + fruits: [1, 2, 1, 2, 3, 3, 3, 2, 2, 1] + out: 6 + - name: extra-4 + in: + fruits: [0, 1, 1, 0, 2, 2, 2, 1, 1, 0, 0] + out: 5 diff --git a/tests/501-1000/904. fruit-into-baskets/sol.cpp b/tests/501-1000/904. fruit-into-baskets/sol.cpp new file mode 100644 index 00000000..db829201 --- /dev/null +++ b/tests/501-1000/904. fruit-into-baskets/sol.cpp @@ -0,0 +1,25 @@ +class Solution { +public: + int totalFruit(vector& fruits) { + int start = 0; + int maxLen = 0; + unordered_map fruitCount; + + for (int end = 0; end < fruits.size(); end++) { + fruitCount[fruits[end]]++; + + while (fruitCount.size() > 2) { + int leftFruit = fruits[start]; + fruitCount[leftFruit]--; + if (fruitCount[leftFruit] == 0) { + fruitCount.erase(leftFruit); + } + start++; + } + + maxLen = max(maxLen, end - start + 1); + } + + return maxLen; + } +}; diff --git a/tests/501-1000/904. fruit-into-baskets/sol.cs b/tests/501-1000/904. fruit-into-baskets/sol.cs new file mode 100644 index 00000000..17842bd3 --- /dev/null +++ b/tests/501-1000/904. fruit-into-baskets/sol.cs @@ -0,0 +1,28 @@ +public class Solution { + public int TotalFruit(int[] fruits) { + int start = 0; + int maxLen = 0; + Dictionary fruitCount = new Dictionary(); + + for (int end = 0; end < fruits.Length; end++) { + if (fruitCount.ContainsKey(fruits[end])) { + fruitCount[fruits[end]]++; + } else { + fruitCount[fruits[end]] = 1; + } + + while (fruitCount.Count > 2) { + int leftFruit = fruits[start]; + fruitCount[leftFruit]--; + if (fruitCount[leftFruit] == 0) { + fruitCount.Remove(leftFruit); + } + start++; + } + + maxLen = Math.Max(maxLen, end - start + 1); + } + + return maxLen; + } +} diff --git a/tests/501-1000/904. fruit-into-baskets/sol.dart b/tests/501-1000/904. fruit-into-baskets/sol.dart new file mode 100644 index 00000000..41eff1d8 --- /dev/null +++ b/tests/501-1000/904. fruit-into-baskets/sol.dart @@ -0,0 +1,26 @@ +class Solution { + int totalFruit(List fruits) { + int start = 0; + int maxLen = 0; + Map fruitCount = {}; + + for (int end = 0; end < fruits.length; end++) { + fruitCount[fruits[end]] = (fruitCount[fruits[end]] ?? 0) + 1; + + while (fruitCount.length > 2) { + int leftFruit = fruits[start]; + fruitCount[leftFruit] = fruitCount[leftFruit]! - 1; + if (fruitCount[leftFruit] == 0) { + fruitCount.remove(leftFruit); + } + start++; + } + + if (end - start + 1 > maxLen) { + maxLen = end - start + 1; + } + } + + return maxLen; + } +} diff --git a/tests/501-1000/904. fruit-into-baskets/sol.go b/tests/501-1000/904. fruit-into-baskets/sol.go new file mode 100644 index 00000000..e8afcbac --- /dev/null +++ b/tests/501-1000/904. fruit-into-baskets/sol.go @@ -0,0 +1,24 @@ +func totalFruit(fruits []int) int { + start := 0 + maxLen := 0 + fruitCount := make(map[int]int) + + for end := 0; end < len(fruits); end++ { + fruitCount[fruits[end]]++ + + for len(fruitCount) > 2 { + leftFruit := fruits[start] + fruitCount[leftFruit]-- + if fruitCount[leftFruit] == 0 { + delete(fruitCount, leftFruit) + } + start++ + } + + if end-start+1 > maxLen { + maxLen = end - start + 1 + } + } + + return maxLen +} diff --git a/tests/501-1000/904. fruit-into-baskets/sol.java b/tests/501-1000/904. fruit-into-baskets/sol.java new file mode 100644 index 00000000..b5cc6bf6 --- /dev/null +++ b/tests/501-1000/904. fruit-into-baskets/sol.java @@ -0,0 +1,24 @@ +class Solution { + public int totalFruit(int[] fruits) { + int start = 0; + int maxLen = 0; + java.util.Map fruitCount = new java.util.HashMap<>(); + + for (int end = 0; end < fruits.length; end++) { + fruitCount.put(fruits[end], fruitCount.getOrDefault(fruits[end], 0) + 1); + + while (fruitCount.size() > 2) { + int leftFruit = fruits[start]; + fruitCount.put(leftFruit, fruitCount.get(leftFruit) - 1); + if (fruitCount.get(leftFruit) == 0) { + fruitCount.remove(leftFruit); + } + start++; + } + + maxLen = Math.max(maxLen, end - start + 1); + } + + return maxLen; + } +} diff --git a/tests/501-1000/904. fruit-into-baskets/sol.kt b/tests/501-1000/904. fruit-into-baskets/sol.kt new file mode 100644 index 00000000..5e458f59 --- /dev/null +++ b/tests/501-1000/904. fruit-into-baskets/sol.kt @@ -0,0 +1,24 @@ +class Solution { + fun totalFruit(fruits: IntArray): Int { + var start = 0 + var maxLen = 0 + val fruitCount = mutableMapOf() + + for (end in fruits.indices) { + fruitCount[fruits[end]] = fruitCount.getOrDefault(fruits[end], 0) + 1 + + while (fruitCount.size > 2) { + val leftFruit = fruits[start] + fruitCount[leftFruit] = fruitCount[leftFruit]!! - 1 + if (fruitCount[leftFruit] == 0) { + fruitCount.remove(leftFruit) + } + start++ + } + + maxLen = maxOf(maxLen, end - start + 1) + } + + return maxLen + } +} diff --git a/tests/501-1000/904. fruit-into-baskets/sol.py b/tests/501-1000/904. fruit-into-baskets/sol.py new file mode 100644 index 00000000..af549af8 --- /dev/null +++ b/tests/501-1000/904. fruit-into-baskets/sol.py @@ -0,0 +1,21 @@ +from collections import defaultdict + + +class Solution: + def totalFruit(self, fruits: list[int]) -> int: + start = 0 + max_len = 0 + fruit_count = defaultdict(int) + + for end in range(len(fruits)): + fruit_count[fruits[end]] += 1 + + while len(fruit_count) > 2: + fruit_count[fruits[start]] -= 1 + if fruit_count[fruits[start]] == 0: + del fruit_count[fruits[start]] + start += 1 + + max_len = max(max_len, end - start + 1) + + return max_len diff --git a/tests/501-1000/904. fruit-into-baskets/sol.py2 b/tests/501-1000/904. fruit-into-baskets/sol.py2 new file mode 100644 index 00000000..77a66cda --- /dev/null +++ b/tests/501-1000/904. fruit-into-baskets/sol.py2 @@ -0,0 +1,24 @@ +class Solution(object): + def totalFruit(self, fruits): + """ + :type fruits: List[int] + :rtype: int + """ + start = 0 + max_len = 0 + fruit_count = {} + + for end in range(len(fruits)): + fruit = fruits[end] + fruit_count[fruit] = fruit_count.get(fruit, 0) + 1 + + while len(fruit_count) > 2: + left_fruit = fruits[start] + fruit_count[left_fruit] -= 1 + if fruit_count[left_fruit] == 0: + del fruit_count[left_fruit] + start += 1 + + max_len = max(max_len, end - start + 1) + + return max_len diff --git a/tests/501-1000/904. fruit-into-baskets/sol.rb b/tests/501-1000/904. fruit-into-baskets/sol.rb new file mode 100644 index 00000000..37c460ea --- /dev/null +++ b/tests/501-1000/904. fruit-into-baskets/sol.rb @@ -0,0 +1,22 @@ +# @param {Integer[]} fruits +# @return {Integer} +def total_fruit(fruits) + start = 0 + max_len = 0 + fruit_count = Hash.new(0) + + fruits.each_with_index do |fruit, end_pos| + fruit_count[fruit] += 1 + + while fruit_count.size > 2 + left_fruit = fruits[start] + fruit_count[left_fruit] -= 1 + fruit_count.delete(left_fruit) if fruit_count[left_fruit] == 0 + start += 1 + end + + max_len = [max_len, end_pos - start + 1].max + end + + max_len +end diff --git a/tests/501-1000/904. fruit-into-baskets/sol.rs b/tests/501-1000/904. fruit-into-baskets/sol.rs new file mode 100644 index 00000000..cec76ec5 --- /dev/null +++ b/tests/501-1000/904. fruit-into-baskets/sol.rs @@ -0,0 +1,27 @@ +impl Solution { + pub fn total_fruit(fruits: Vec) -> i32 { + let mut start = 0; + let mut max_len = 0; + use std::collections::HashMap; + let mut fruit_count: HashMap = HashMap::new(); + + for end in 0..fruits.len() { + *fruit_count.entry(fruits[end]).or_insert(0) += 1; + + while fruit_count.len() > 2 { + let left_fruit = fruits[start]; + if let Some(count) = fruit_count.get_mut(&left_fruit) { + *count -= 1; + if *count == 0 { + fruit_count.remove(&left_fruit); + } + } + start += 1; + } + + max_len = max_len.max((end - start + 1) as i32); + } + + max_len + } +} diff --git a/tests/501-1000/904. fruit-into-baskets/sol.swift b/tests/501-1000/904. fruit-into-baskets/sol.swift new file mode 100644 index 00000000..23c13f38 --- /dev/null +++ b/tests/501-1000/904. fruit-into-baskets/sol.swift @@ -0,0 +1,24 @@ +class Solution { + func totalFruit(_ fruits: [Int]) -> Int { + var start = 0 + var maxLen = 0 + var fruitCount = [Int: Int]() + + for end in 0.. 2 { + let leftFruit = fruits[start] + fruitCount[leftFruit]! -= 1 + if fruitCount[leftFruit] == 0 { + fruitCount.removeValue(forKey: leftFruit) + } + start += 1 + } + + maxLen = max(maxLen, end - start + 1) + } + + return maxLen + } +} diff --git a/tests/501-1000/904. fruit-into-baskets/sol.ts b/tests/501-1000/904. fruit-into-baskets/sol.ts new file mode 100644 index 00000000..eb5764b2 --- /dev/null +++ b/tests/501-1000/904. fruit-into-baskets/sol.ts @@ -0,0 +1,22 @@ +function totalFruit(fruits: number[]): number { + let start = 0; + let maxLen = 0; + const fruitCount = new Map(); + + for (let end = 0; end < fruits.length; end++) { + fruitCount.set(fruits[end], (fruitCount.get(fruits[end]) ?? 0) + 1); + + while (fruitCount.size > 2) { + const leftFruit = fruits[start]; + fruitCount.set(leftFruit, fruitCount.get(leftFruit)! - 1); + if (fruitCount.get(leftFruit) === 0) { + fruitCount.delete(leftFruit); + } + start++; + } + + maxLen = Math.max(maxLen, end - start + 1); + } + + return maxLen; +} diff --git a/tests/501-1000/905. sort-array-by-parity/manifest.yaml b/tests/501-1000/905. sort-array-by-parity/manifest.yaml new file mode 100644 index 00000000..3a667448 --- /dev/null +++ b/tests/501-1000/905. sort-array-by-parity/manifest.yaml @@ -0,0 +1,524 @@ +entry: + id: 905 + title: sort-array-by-parity + params: + nums: + type: array + items: + type: int + call: + cpp: "Solution().sortArrayByParity({nums})" + rust: "Solution::sort_array_by_parity({nums})" + python3: "Solution().sortArrayByParity({nums})" + python2: "Solution().sortArrayByParity({nums})" + ruby: "sort_array_by_parity({nums})" + java: "new Solution().sortArrayByParity({nums})" + csharp: "new Solution().SortArrayByParity({nums})" + kotlin: "Solution().sortArrayByParity({nums})" + go: "sortArrayByParity({nums})" + dart: "Solution().sortArrayByParity({nums})" + swift: "Solution().sortArrayByParity({nums})" + typescript: "sortArrayByParity({nums})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().sortArrayByParity(nums, {result})" + checker: | + from collections import Counter + + class Checker: + def sortArrayByParity(self, nums, result): + if not isinstance(result, list) or len(result) != len(nums): + return False + if Counter(nums) != Counter(result): + return False + seen_odd = False + for x in result: + if x % 2 == 0: + if seen_odd: + return False + else: + seen_odd = True + return True +seed: 905 +tests: + - name: example-1 + in: + nums: + - 3 + - 1 + - 2 + - 4 + - name: example-2 + in: + nums: + - 0 + - name: single-odd + in: + nums: + - 1 + - name: two-even + in: + nums: + - 2 + - 4 + - name: two-odd + in: + nums: + - 1 + - 3 + - name: mixed-small-1 + in: + nums: + - 1 + - 2 + - 3 + - 4 + - name: mixed-small-2 + in: + nums: + - 4 + - 3 + - 2 + - 1 + - name: all-even-6 + in: + nums: + - 6 + - 4 + - 2 + - 0 + - 8 + - 10 + - name: all-odd-6 + in: + nums: + - 1 + - 3 + - 5 + - 7 + - 9 + - 11 + - name: alternating-1 + in: + nums: + - 1 + - 2 + - 1 + - 2 + - 1 + - 2 + - name: alternating-2 + in: + nums: + - 2 + - 1 + - 2 + - 1 + - 2 + - 1 + - name: duplicates-1 + in: + nums: + - 2 + - 2 + - 1 + - 1 + - 2 + - 1 + - name: duplicates-2 + in: + nums: + - 5 + - 4 + - 5 + - 4 + - 5 + - 4 + - name: sorted-mixed + in: + nums: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - name: reverse-mixed + in: + nums: + - 5 + - 4 + - 3 + - 2 + - 1 + - 0 + - name: parity-boundary-1 + in: + nums: + - 5000 + - 4999 + - 0 + - 1 + - 2 + - name: parity-boundary-2 + in: + nums: + - 4999 + - 5000 + - 4998 + - 5000 + - 4997 + - name: cluster-even-odd + in: + nums: + - 2 + - 4 + - 6 + - 1 + - 3 + - 5 + - name: cluster-odd-even + in: + nums: + - 1 + - 3 + - 5 + - 2 + - 4 + - 6 + - name: one-odd-many-even + in: + nums: + - 1 + - 2 + - 4 + - 6 + - 8 + - 10 + - name: one-even-many-odd + in: + nums: + - 2 + - 1 + - 3 + - 5 + - 7 + - 9 + - name: mixed-mid + in: + nums: + - 8 + - 7 + - 6 + - 5 + - 4 + - 3 + - 2 + - 1 + - name: mixed-mid-2 + in: + nums: + - 9 + - 8 + - 7 + - 6 + - 5 + - 4 + - 3 + - 2 + - name: small-repeat-1 + in: + nums: + - 0 + - 0 + - 1 + - 1 + - 0 + - 1 + - name: small-repeat-2 + in: + nums: + - 2 + - 3 + - 2 + - 3 + - 2 + - 3 + - name: longer-1 + in: + nums: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + - name: longer-2 + in: + nums: + - 10 + - 9 + - 8 + - 7 + - 6 + - 5 + - 4 + - 3 + - 2 + - 1 + - name: boundary-5000 + in: + nums: + - 5000 + - 4999 + - 5000 + - 4999 + - 5000 + - 4999 + - name: boundary-zeros + in: + nums: + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - name: large-even-odd-a + in: + nums: + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - name: large-even-odd-b + in: + nums: + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - name: all-even-8 + in: + nums: + - 8 + - 6 + - 4 + - 2 + - 0 + - 5000 + - 4998 + - 4996 + - name: all-odd-8 + in: + nums: + - 1 + - 3 + - 5 + - 7 + - 9 + - 11 + - 13 + - 15 + - name: edge-1 + in: + nums: + - 5000 + - 1 + - 4999 + - 0 + - 4998 + - 3 + - name: edge-2 + in: + nums: + - 1 + - 5000 + - 3 + - 4998 + - 5 + - 4996 diff --git a/tests/501-1000/905. sort-array-by-parity/sol.cpp b/tests/501-1000/905. sort-array-by-parity/sol.cpp new file mode 100644 index 00000000..215c7d5c --- /dev/null +++ b/tests/501-1000/905. sort-array-by-parity/sol.cpp @@ -0,0 +1,13 @@ +class Solution { +public: + vector sortArrayByParity(vector& nums) { + int left = 0; + for (int i = 0; i < nums.size(); i++) { + if (nums[i] % 2 == 0) { + swap(nums[left], nums[i]); + left++; + } + } + return nums; + } +}; diff --git a/tests/501-1000/905. sort-array-by-parity/sol.cs b/tests/501-1000/905. sort-array-by-parity/sol.cs new file mode 100644 index 00000000..182e135b --- /dev/null +++ b/tests/501-1000/905. sort-array-by-parity/sol.cs @@ -0,0 +1,14 @@ +public class Solution { + public int[] SortArrayByParity(int[] nums) { + int left = 0; + for (int i = 0; i < nums.Length; i++) { + if (nums[i] % 2 == 0) { + int temp = nums[left]; + nums[left] = nums[i]; + nums[i] = temp; + left++; + } + } + return nums; + } +} diff --git a/tests/501-1000/905. sort-array-by-parity/sol.dart b/tests/501-1000/905. sort-array-by-parity/sol.dart new file mode 100644 index 00000000..67d8f18a --- /dev/null +++ b/tests/501-1000/905. sort-array-by-parity/sol.dart @@ -0,0 +1,14 @@ +class Solution { + List sortArrayByParity(List nums) { + int left = 0; + for (int i = 0; i < nums.length; i++) { + if (nums[i] % 2 == 0) { + int temp = nums[left]; + nums[left] = nums[i]; + nums[i] = temp; + left++; + } + } + return nums; + } +} diff --git a/tests/501-1000/905. sort-array-by-parity/sol.go b/tests/501-1000/905. sort-array-by-parity/sol.go new file mode 100644 index 00000000..8938e19c --- /dev/null +++ b/tests/501-1000/905. sort-array-by-parity/sol.go @@ -0,0 +1,10 @@ +func sortArrayByParity(nums []int) []int { + left := 0 + for i := 0; i < len(nums); i++ { + if nums[i] % 2 == 0 { + nums[left], nums[i] = nums[i], nums[left] + left++ + } + } + return nums +} diff --git a/tests/501-1000/905. sort-array-by-parity/sol.java b/tests/501-1000/905. sort-array-by-parity/sol.java new file mode 100644 index 00000000..cb26ca03 --- /dev/null +++ b/tests/501-1000/905. sort-array-by-parity/sol.java @@ -0,0 +1,14 @@ +class Solution { + public int[] sortArrayByParity(int[] nums) { + int left = 0; + for (int i = 0; i < nums.length; i++) { + if (nums[i] % 2 == 0) { + int temp = nums[left]; + nums[left] = nums[i]; + nums[i] = temp; + left++; + } + } + return nums; + } +} diff --git a/tests/501-1000/905. sort-array-by-parity/sol.kt b/tests/501-1000/905. sort-array-by-parity/sol.kt new file mode 100644 index 00000000..64f4b52b --- /dev/null +++ b/tests/501-1000/905. sort-array-by-parity/sol.kt @@ -0,0 +1,14 @@ +class Solution { + fun sortArrayByParity(nums: IntArray): IntArray { + var left = 0 + for (i in nums.indices) { + if (nums[i] % 2 == 0) { + val temp = nums[left] + nums[left] = nums[i] + nums[i] = temp + left++ + } + } + return nums + } +} diff --git a/tests/501-1000/905. sort-array-by-parity/sol.py b/tests/501-1000/905. sort-array-by-parity/sol.py new file mode 100644 index 00000000..47b9b798 --- /dev/null +++ b/tests/501-1000/905. sort-array-by-parity/sol.py @@ -0,0 +1,10 @@ +class Solution: + def sortArrayByParity(self, nums: List[int]) -> List[int]: + left = 0 + + for i in range(len(nums)): + if nums[i] % 2 == 0: + nums[left], nums[i] = nums[i], nums[left] + left += 1 + + return nums diff --git a/tests/501-1000/905. sort-array-by-parity/sol.py2 b/tests/501-1000/905. sort-array-by-parity/sol.py2 new file mode 100644 index 00000000..c11fbe9a --- /dev/null +++ b/tests/501-1000/905. sort-array-by-parity/sol.py2 @@ -0,0 +1,12 @@ +class Solution(object): + def sortArrayByParity(self, nums): + """ + :type nums: List[int] + :rtype: List[int] + """ + left = 0 + for i in range(len(nums)): + if nums[i] % 2 == 0: + nums[left], nums[i] = nums[i], nums[left] + left += 1 + return nums diff --git a/tests/501-1000/905. sort-array-by-parity/sol.rb b/tests/501-1000/905. sort-array-by-parity/sol.rb new file mode 100644 index 00000000..6ef6ad6e --- /dev/null +++ b/tests/501-1000/905. sort-array-by-parity/sol.rb @@ -0,0 +1,12 @@ +# @param {Integer[]} nums +# @return {Integer[]} +def sort_array_by_parity(nums) + left = 0 + nums.each_with_index do |num, i| + if num % 2 == 0 + nums[left], nums[i] = nums[i], nums[left] + left += 1 + end + end + nums +end diff --git a/tests/501-1000/905. sort-array-by-parity/sol.rs b/tests/501-1000/905. sort-array-by-parity/sol.rs new file mode 100644 index 00000000..fd827e6f --- /dev/null +++ b/tests/501-1000/905. sort-array-by-parity/sol.rs @@ -0,0 +1,13 @@ +impl Solution { + pub fn sort_array_by_parity(nums: Vec) -> Vec { + let mut nums = nums; + let mut left = 0; + for i in 0..nums.len() { + if nums[i] % 2 == 0 { + nums.swap(left, i); + left += 1; + } + } + nums + } +} diff --git a/tests/501-1000/905. sort-array-by-parity/sol.swift b/tests/501-1000/905. sort-array-by-parity/sol.swift new file mode 100644 index 00000000..fe5f02e7 --- /dev/null +++ b/tests/501-1000/905. sort-array-by-parity/sol.swift @@ -0,0 +1,13 @@ +class Solution { + func sortArrayByParity(_ nums: [Int]) -> [Int] { + var nums = nums + var left = 0 + for i in 0.. R) { + break; + } + } + return count; + } +}; diff --git a/tests/501-1000/906. super-palindromes/sol.cs b/tests/501-1000/906. super-palindromes/sol.cs new file mode 100644 index 00000000..5d8ce223 --- /dev/null +++ b/tests/501-1000/906. super-palindromes/sol.cs @@ -0,0 +1,37 @@ +public class Solution { + public int SuperpalindromesInRange(string left, string right) { + long L = long.Parse(left); + long R = long.Parse(right); + int count = 0; + for (int i = 1; i <= 100000; i++) { + string s = i.ToString(); + char[] charArray = s.ToCharArray(); + Array.Reverse(charArray); + string rev = new string(charArray); + long val1 = long.Parse(s + rev); + long val2 = long.Parse(s + rev.Substring(1)); + long sqval1 = val1 * val1; + long sqval2 = val2 * val2; + if (L <= sqval1 && sqval1 <= R) { + string ssqval1 = sqval1.ToString(); + charArray = ssqval1.ToCharArray(); + Array.Reverse(charArray); + if (ssqval1 == new string(charArray)) { + count++; + } + } + if (L <= sqval2 && sqval2 <= R) { + string ssqval2 = sqval2.ToString(); + charArray = ssqval2.ToCharArray(); + Array.Reverse(charArray); + if (ssqval2 == new string(charArray)) { + count++; + } + } + if (val2 > R) { + break; + } + } + return count; + } +} diff --git a/tests/501-1000/906. super-palindromes/sol.dart b/tests/501-1000/906. super-palindromes/sol.dart new file mode 100644 index 00000000..0868c494 --- /dev/null +++ b/tests/501-1000/906. super-palindromes/sol.dart @@ -0,0 +1,31 @@ +class Solution { + int superpalindromesInRange(String left, String right) { + int L = int.parse(left); + int R = int.parse(right); + int count = 0; + for (int i = 1; i <= 100000; i++) { + String s = i.toString(); + String rev = s.split('').reversed.join(); + int val1 = int.parse(s + rev); + int val2 = int.parse(s + rev.substring(1)); + int sqval1 = val1 * val1; + int sqval2 = val2 * val2; + if (L <= sqval1 && sqval1 <= R) { + String ssqval1 = sqval1.toString(); + if (ssqval1 == ssqval1.split('').reversed.join()) { + count++; + } + } + if (L <= sqval2 && sqval2 <= R) { + String ssqval2 = sqval2.toString(); + if (ssqval2 == ssqval2.split('').reversed.join()) { + count++; + } + } + if (val2 > R) { + break; + } + } + return count; + } +} diff --git a/tests/501-1000/906. super-palindromes/sol.go b/tests/501-1000/906. super-palindromes/sol.go new file mode 100644 index 00000000..8cb461ee --- /dev/null +++ b/tests/501-1000/906. super-palindromes/sol.go @@ -0,0 +1,37 @@ +func superpalindromesInRange(left string, right string) int { + L, _ := strconv.ParseInt(left, 10, 64) + R, _ := strconv.ParseInt(right, 10, 64) + count := 0 + for i := int64(1); i <= 100000; i++ { + s := strconv.FormatInt(i, 10) + rev := reverseString(s) + val1, _ := strconv.ParseInt(s+rev, 10, 64) + val2, _ := strconv.ParseInt(s+rev[1:], 10, 64) + sqval1 := val1 * val1 + sqval2 := val2 * val2 + if L <= sqval1 && sqval1 <= R { + ssqval1 := strconv.FormatInt(sqval1, 10) + if ssqval1 == reverseString(ssqval1) { + count++ + } + } + if L <= sqval2 && sqval2 <= R { + ssqval2 := strconv.FormatInt(sqval2, 10) + if ssqval2 == reverseString(ssqval2) { + count++ + } + } + if val2 > R { + break + } + } + return count +} + +func reverseString(s string) string { + runes := []rune(s) + for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 { + runes[i], runes[j] = runes[j], runes[i] + } + return string(runes) +} diff --git a/tests/501-1000/906. super-palindromes/sol.java b/tests/501-1000/906. super-palindromes/sol.java new file mode 100644 index 00000000..344ec577 --- /dev/null +++ b/tests/501-1000/906. super-palindromes/sol.java @@ -0,0 +1,31 @@ +class Solution { + public int superpalindromesInRange(String left, String right) { + long L = Long.parseLong(left); + long R = Long.parseLong(right); + int count = 0; + for (int i = 1; i <= 100000; i++) { + String s = Integer.toString(i); + String rev = new StringBuilder(s).reverse().toString(); + long val1 = Long.parseLong(s + rev); + long val2 = Long.parseLong(s + rev.substring(1)); + long sqval1 = val1 * val1; + long sqval2 = val2 * val2; + if (L <= sqval1 && sqval1 <= R) { + String ssqval1 = Long.toString(sqval1); + if (ssqval1.equals(new StringBuilder(ssqval1).reverse().toString())) { + count++; + } + } + if (L <= sqval2 && sqval2 <= R) { + String ssqval2 = Long.toString(sqval2); + if (ssqval2.equals(new StringBuilder(ssqval2).reverse().toString())) { + count++; + } + } + if (val2 > R) { + break; + } + } + return count; + } +} diff --git a/tests/501-1000/906. super-palindromes/sol.kt b/tests/501-1000/906. super-palindromes/sol.kt new file mode 100644 index 00000000..04c72090 --- /dev/null +++ b/tests/501-1000/906. super-palindromes/sol.kt @@ -0,0 +1,31 @@ +class Solution { + fun superpalindromesInRange(left: String, right: String): Int { + val L = left.toLong() + val R = right.toLong() + var count = 0 + for (i in 1..100000) { + val s = i.toString() + val rev = s.reversed() + val val1 = (s + rev).toLong() + val val2 = (s + rev.substring(1)).toLong() + val sqval1 = val1 * val1 + val sqval2 = val2 * val2 + if (L <= sqval1 && sqval1 <= R) { + val ssqval1 = sqval1.toString() + if (ssqval1 == ssqval1.reversed()) { + count++ + } + } + if (L <= sqval2 && sqval2 <= R) { + val ssqval2 = sqval2.toString() + if (ssqval2 == ssqval2.reversed()) { + count++ + } + } + if (val2 > R) { + break + } + } + return count + } +} diff --git a/tests/501-1000/906. super-palindromes/sol.py b/tests/501-1000/906. super-palindromes/sol.py new file mode 100644 index 00000000..b4e91da3 --- /dev/null +++ b/tests/501-1000/906. super-palindromes/sol.py @@ -0,0 +1,34 @@ +class Solution: + def superpalindromesInRange(self, left: str, right: str) -> int: + """ + + we can build palindromes in very less time + with very enumeration trick + + """ + + """ + + build even and odd length palindromes seperately + + """ + pal = [] + left = int(left) + right = int(right) + count = 0 + for i in range(1, 10**5 + 1): + val1 = int(str(i) + str(i)[::-1]) + val2 = int(str(i) + str(i)[-2::-1]) + sqval1 = val1 * val1 + sqval2 = val2 * val2 + if left <= sqval1 <= right: + ssqval1 = str(sqval1) + if ssqval1 == ssqval1[::-1]: + count += 1 + if left <= sqval2 <= right: + ssqval2 = str(sqval2) + if ssqval2 == ssqval2[::-1]: + count += 1 + if val2 > right: + break + return count diff --git a/tests/501-1000/906. super-palindromes/sol.py2 b/tests/501-1000/906. super-palindromes/sol.py2 new file mode 100644 index 00000000..7bbb1ac2 --- /dev/null +++ b/tests/501-1000/906. super-palindromes/sol.py2 @@ -0,0 +1,27 @@ +class Solution(object): + def superpalindromesInRange(self, left, right): + """ + :type left: str + :type right: str + :rtype: int + """ + left = int(left) + right = int(right) + count = 0 + for i in range(1, 100001): + s = str(i) + val1 = int(s + s[::-1]) + val2 = int(s + s[-2::-1]) + sqval1 = val1 * val1 + sqval2 = val2 * val2 + if left <= sqval1 <= right: + ssqval1 = str(sqval1) + if ssqval1 == ssqval1[::-1]: + count += 1 + if left <= sqval2 <= right: + ssqval2 = str(sqval2) + if ssqval2 == ssqval2[::-1]: + count += 1 + if val2 > right: + break + return count diff --git a/tests/501-1000/906. super-palindromes/sol.rb b/tests/501-1000/906. super-palindromes/sol.rb new file mode 100644 index 00000000..497a6773 --- /dev/null +++ b/tests/501-1000/906. super-palindromes/sol.rb @@ -0,0 +1,31 @@ +# @param {String} left +# @param {String} right +# @return {Integer} +def superpalindromes_in_range(left, right) + left = left.to_i + right = right.to_i + count = 0 + (1..100000).each do |i| + s = i.to_s + val1 = (s + s.reverse).to_i + val2 = (s + s[0...-1].reverse).to_i + sqval1 = val1 * val1 + sqval2 = val2 * val2 + if left <= sqval1 && sqval1 <= right + ssqval1 = sqval1.to_s + if ssqval1 == ssqval1.reverse + count += 1 + end + end + if left <= sqval2 && sqval2 <= right + ssqval2 = sqval2.to_s + if ssqval2 == ssqval2.reverse + count += 1 + end + end + if val2 > right + break + end + end + return count +end diff --git a/tests/501-1000/906. super-palindromes/sol.rs b/tests/501-1000/906. super-palindromes/sol.rs new file mode 100644 index 00000000..3f832e08 --- /dev/null +++ b/tests/501-1000/906. super-palindromes/sol.rs @@ -0,0 +1,31 @@ +impl Solution { + pub fn superpalindromes_in_range(left: String, right: String) -> i32 { + let L: i64 = left.parse().unwrap(); + let R: i64 = right.parse().unwrap(); + let mut count = 0; + for i in 1..=100000 { + let s = i.to_string(); + let rev: String = s.chars().rev().collect(); + let val1: i64 = format!("{}{}", s, rev).parse().unwrap(); + let val2: i64 = format!("{}{}", s, &rev[1..]).parse().unwrap(); + let sqval1 = val1 * val1; + let sqval2 = val2 * val2; + if L <= sqval1 && sqval1 <= R { + let ssqval1 = sqval1.to_string(); + if ssqval1 == ssqval1.chars().rev().collect::() { + count += 1; + } + } + if L <= sqval2 && sqval2 <= R { + let ssqval2 = sqval2.to_string(); + if ssqval2 == ssqval2.chars().rev().collect::() { + count += 1; + } + } + if val2 > R { + break; + } + } + count + } +} diff --git a/tests/501-1000/906. super-palindromes/sol.swift b/tests/501-1000/906. super-palindromes/sol.swift new file mode 100644 index 00000000..22a3abf1 --- /dev/null +++ b/tests/501-1000/906. super-palindromes/sol.swift @@ -0,0 +1,35 @@ +class Solution { + func superpalindromesInRange(_ left: String, _ right: String) -> Int { + let L = Int64(left)! + let R = Int64(right)! + var count = 0 + for i in 1...100000 { + let s = String(i) + let rev = String(s.reversed()) + let palindromes: [Int64] = [ + Int64(s + String(rev.dropFirst()))!, + Int64(s + rev)! + ] + for root in palindromes { + if root > 1_000_000_000 { + continue + } + let sq = root * root + if sq < L { + continue + } + if sq > R { + continue + } + let str = String(sq) + if str == String(str.reversed()) { + count += 1 + } + } + if Int64(i) * Int64(i) > R { + break + } + } + return count + } +} diff --git a/tests/501-1000/906. super-palindromes/sol.ts b/tests/501-1000/906. super-palindromes/sol.ts new file mode 100644 index 00000000..abc87247 --- /dev/null +++ b/tests/501-1000/906. super-palindromes/sol.ts @@ -0,0 +1,20 @@ +function superpalindromesInRange(left: string, right: string): number { + const L = BigInt(left); + const R = BigInt(right); + let count = 0; + for (let i = 1; i <= 100000; i++) { + const s = i.toString(); + const rev = s.split("").reverse().join(""); + const roots = [BigInt(s + rev.substring(1)), BigInt(s + rev)]; + for (const root of roots) { + const sq = root * root; + if (sq < L || sq > R) continue; + const str = sq.toString(); + if (str === str.split("").reverse().join("")) { + count++; + } + } + if (BigInt(i) * BigInt(i) > R) break; + } + return count; +} diff --git a/tests/501-1000/907. sum-of-subarray-minimums/manifest.yaml b/tests/501-1000/907. sum-of-subarray-minimums/manifest.yaml new file mode 100644 index 00000000..d7df6a1b --- /dev/null +++ b/tests/501-1000/907. sum-of-subarray-minimums/manifest.yaml @@ -0,0 +1,185 @@ +entry: + id: 907 + title: "sum-of-subarray-minimums" + params: + nums: + type: array + items: + type: int + call: + cpp: "Solution().sumSubarrayMins({nums})" + rust: "Solution::sum_subarray_mins({nums})" + python3: "Solution().sumSubarrayMins({nums})" + python2: "Solution().sumSubarrayMins({nums})" + ruby: "sum_subarray_mins({nums})" + java: "new Solution().sumSubarrayMins({nums})" + csharp: "new Solution().SumSubarrayMins({nums})" + kotlin: "Solution().sumSubarrayMins({nums})" + go: "sumSubarrayMins({nums})" + dart: "Solution().sumSubarrayMins({nums})" + swift: "Solution().sumSubarrayMins({nums})" + typescript: "sumSubarrayMins({nums})" +judge: + type: "exact" +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().sumSubarrayMins(nums, {result})" + checker: | + class Checker: + def sumSubarrayMins(self, nums, result): + mod = 10**9 + 7 + stack = [] + res = [0] * len(nums) + for i, x in enumerate(nums): + while stack and nums[stack[-1]] > x: + stack.pop() + j = stack[-1] if stack else -1 + res[i] = (res[j] if j != -1 else 0) + (i - j) * x + stack.append(i) + expected = sum(res) % mod + return result == expected +seed: 12345 +tests: + - name: "ex1" + in: + nums: [3, 1, 2, 4] + out: 17 + - name: "ex2" + in: + nums: [11, 81, 94, 43, 3] + out: 444 + - name: "single1" + in: + nums: [1] + out: 1 + - name: "single2" + in: + nums: [30000] + out: 30000 + - name: "inc2" + in: + nums: [1, 2] + out: 4 + - name: "eq2" + in: + nums: [5, 5] + out: 15 + - name: "dec2" + in: + nums: [2, 1] + out: 4 + - name: "flat3" + in: + nums: [2, 2, 2] + out: 12 + - name: "mix1" + in: + nums: [3, 1, 2] + out: 9 + - name: "mix2" + in: + nums: [4, 3, 2, 1] + out: 20 + - name: "plateau" + in: + nums: [1, 3, 3, 1] + out: 16 + - name: "zeros_like" + in: + nums: [1, 100, 1] + out: 105 + - name: "peak" + in: + nums: [1, 2, 3, 2, 1] + out: 22 + - name: "valley" + in: + nums: [5, 4, 3, 4, 5] + out: 53 + - name: "alt1" + in: + nums: [1, 3, 1, 3, 1] + out: 19 + - name: "alt2" + in: + nums: [2, 1, 2, 1, 2] + out: 18 + - name: "biggap" + in: + nums: [30000, 1] + out: 30002 + - name: "biggap3" + in: + nums: [30000, 1, 30000] + out: 60004 + - name: "rand1" + in: + nums: [8, 7, 6, 5] + out: 60 + - name: "rand2" + in: + nums: [9, 8, 1, 7, 6] + out: 53 + - name: "rand3" + in: + nums: [2, 9, 7, 8, 3] + out: 67 + - name: "rand4" + in: + nums: [6, 2, 4, 1, 5] + out: 31 + - name: "dup1" + in: + nums: [4, 4, 1, 4] + out: 22 + - name: "dup2" + in: + nums: [1, 4, 4, 4] + out: 28 + - name: "dup3" + in: + nums: [2, 2, 1, 2, 2] + out: 21 + - name: "dup4" + in: + nums: [3, 1, 3, 1, 3] + out: 21 + - name: "long1" + in: + nums: [1, 2, 3, 4, 5] + out: 35 + - name: "long2" + in: + nums: [5, 4, 3, 2, 1] + out: 35 + - name: "long3" + in: + nums: [1, 100, 2, 99, 3] + out: 222 + - name: "long4" + in: + nums: [7, 1, 8, 2, 9, 3] + out: 52 + - name: "max1" + in: + nums: [30000, 29999, 30000] + out: 179996 + - name: "max2" + in: + nums: [1, 30000, 1, 30000] + out: 60008 + - name: "max3" + in: + nums: [30000, 30000, 30000, 30000, 30000] + out: 450000 + - name: "edge1" + in: + nums: [1, 30000, 30000, 1] + out: 90007 + - name: "edge2" + in: + nums: [2, 30000, 1, 30000, 2] + out: 60017 diff --git a/tests/501-1000/907. sum-of-subarray-minimums/sol.cpp b/tests/501-1000/907. sum-of-subarray-minimums/sol.cpp new file mode 100644 index 00000000..b1e006d5 --- /dev/null +++ b/tests/501-1000/907. sum-of-subarray-minimums/sol.cpp @@ -0,0 +1,22 @@ +class Solution { +public: + int sumSubarrayMins(vector& arr) { + const int MOD = 1'000'000'007; + int n = arr.size(); + stack st; + vector res(n, 0); + for (int i = 0; i < n; i++) { + while (!st.empty() && arr[st.top()] > arr[i]) { + st.pop(); + } + int j = st.empty() ? -1 : st.top(); + res[i] = (j >= 0 ? res[j] : 0) + (long long)(i - j) * arr[i]; + st.push(i); + } + long long sum = 0; + for (long long v : res) { + sum = (sum + v) % MOD; + } + return (int) sum; + } +}; diff --git a/tests/501-1000/907. sum-of-subarray-minimums/sol.cs b/tests/501-1000/907. sum-of-subarray-minimums/sol.cs new file mode 100644 index 00000000..ee36aafe --- /dev/null +++ b/tests/501-1000/907. sum-of-subarray-minimums/sol.cs @@ -0,0 +1,21 @@ +public class Solution { + public int SumSubarrayMins(int[] arr) { + const int MOD = 1_000_000_007; + int n = arr.Length; + var stack = new Stack(); + long[] res = new long[n]; + for (int i = 0; i < n; i++) { + while (stack.Count > 0 && arr[stack.Peek()] > arr[i]) { + stack.Pop(); + } + int j = stack.Count > 0 ? stack.Peek() : -1; + res[i] = (j >= 0 ? res[j] : 0) + (long)(i - j) * arr[i]; + stack.Push(i); + } + long sum = 0; + foreach (long v in res) { + sum = (sum + v) % MOD; + } + return (int) sum; + } +} diff --git a/tests/501-1000/907. sum-of-subarray-minimums/sol.dart b/tests/501-1000/907. sum-of-subarray-minimums/sol.dart new file mode 100644 index 00000000..789c4463 --- /dev/null +++ b/tests/501-1000/907. sum-of-subarray-minimums/sol.dart @@ -0,0 +1,21 @@ +class Solution { + int sumSubarrayMins(List arr) { + const int MOD = 1000000007; + int n = arr.length; + List stack = []; + List res = List.filled(n, 0); + for (int i = 0; i < n; i++) { + while (stack.isNotEmpty && arr[stack.last] > arr[i]) { + stack.removeLast(); + } + int j = stack.isNotEmpty ? stack.last : -1; + res[i] = ((j >= 0 ? res[j] : 0) + (i - j) * arr[i]) % MOD; + stack.add(i); + } + int sum = 0; + for (int v in res) { + sum = (sum + v) % MOD; + } + return sum; + } +} diff --git a/tests/501-1000/907. sum-of-subarray-minimums/sol.go b/tests/501-1000/907. sum-of-subarray-minimums/sol.go new file mode 100644 index 00000000..bdd9bba0 --- /dev/null +++ b/tests/501-1000/907. sum-of-subarray-minimums/sol.go @@ -0,0 +1,25 @@ +func sumSubarrayMins(arr []int) int { + const MOD = 1_000_000_007 + n := len(arr) + stack := make([]int, 0, n) + res := make([]int, n) + for i := 0; i < n; i++ { + for len(stack) > 0 && arr[stack[len(stack)-1]] > arr[i] { + stack = stack[:len(stack)-1] + } + j := -1 + if len(stack) > 0 { + j = stack[len(stack)-1] + } + if j >= 0 { + res[i] = res[j] + } + res[i] = (res[i] + (i-j)*arr[i]) % MOD + stack = append(stack, i) + } + sum := 0 + for _, v := range res { + sum = (sum + v) % MOD + } + return sum +} diff --git a/tests/501-1000/907. sum-of-subarray-minimums/sol.java b/tests/501-1000/907. sum-of-subarray-minimums/sol.java new file mode 100644 index 00000000..9542a710 --- /dev/null +++ b/tests/501-1000/907. sum-of-subarray-minimums/sol.java @@ -0,0 +1,22 @@ +class Solution { + public int sumSubarrayMins(int[] arr) { + int MOD = 1_000_000_007; + int n = arr.length; + int[] stack = new int[n]; + int top = -1; + long[] res = new long[n]; + for (int i = 0; i < n; i++) { + while (top >= 0 && arr[stack[top]] > arr[i]) { + top--; + } + int j = top >= 0 ? stack[top] : -1; + res[i] = (j >= 0 ? res[j] : 0) + (long)(i - j) * arr[i]; + stack[++top] = i; + } + long sum = 0; + for (long v : res) { + sum = (sum + v) % MOD; + } + return (int) sum; + } +} diff --git a/tests/501-1000/907. sum-of-subarray-minimums/sol.kt b/tests/501-1000/907. sum-of-subarray-minimums/sol.kt new file mode 100644 index 00000000..0b1063d3 --- /dev/null +++ b/tests/501-1000/907. sum-of-subarray-minimums/sol.kt @@ -0,0 +1,22 @@ +class Solution { + fun sumSubarrayMins(arr: IntArray): Int { + val MOD = 1_000_000_007 + val n = arr.size + val stack = IntArray(n) + var top = -1 + val res = LongArray(n) + for (i in 0 until n) { + while (top >= 0 && arr[stack[top]] > arr[i]) { + top-- + } + val j = if (top >= 0) stack[top] else -1 + res[i] = (if (j >= 0) res[j] else 0L) + (i - j).toLong() * arr[i] + stack[++top] = i + } + var sum = 0L + for (v in res) { + sum = (sum + v) % MOD + } + return sum.toInt() + } +} diff --git a/tests/501-1000/907. sum-of-subarray-minimums/sol.py b/tests/501-1000/907. sum-of-subarray-minimums/sol.py new file mode 100644 index 00000000..21d542c4 --- /dev/null +++ b/tests/501-1000/907. sum-of-subarray-minimums/sol.py @@ -0,0 +1,15 @@ +class Solution: + def sumSubarrayMins(self, arr: List[int]) -> int: + stack = [] # keep index for the latest smaller values + res = [0] * len(arr) + + for i in range(len(arr)): + while stack and arr[stack[-1]] > arr[i]: + stack.pop() + + j = stack[-1] if stack else -1 + res[i] = res[j] + (i - j) * arr[i] + + stack.append(i) + + return sum(res) % (10**9 + 7) diff --git a/tests/501-1000/907. sum-of-subarray-minimums/sol.py2 b/tests/501-1000/907. sum-of-subarray-minimums/sol.py2 new file mode 100644 index 00000000..c077686b --- /dev/null +++ b/tests/501-1000/907. sum-of-subarray-minimums/sol.py2 @@ -0,0 +1,15 @@ +class Solution(object): + def sumSubarrayMins(self, arr): + """ + :type arr: List[int] + :rtype: int + """ + stack = [] + res = [0] * len(arr) + for i in range(len(arr)): + while stack and arr[stack[-1]] > arr[i]: + stack.pop() + j = stack[-1] if stack else -1 + res[i] = res[j] + (i - j) * arr[i] + stack.append(i) + return sum(res) % (10**9 + 7) diff --git a/tests/501-1000/907. sum-of-subarray-minimums/sol.rb b/tests/501-1000/907. sum-of-subarray-minimums/sol.rb new file mode 100644 index 00000000..64cab524 --- /dev/null +++ b/tests/501-1000/907. sum-of-subarray-minimums/sol.rb @@ -0,0 +1,15 @@ +# @param {Integer[]} arr +# @return {Integer} +def sum_subarray_mins(arr) + stack = [] + res = [0] * arr.length + (0...arr.length).each do |i| + while !stack.empty? && arr[stack.last] > arr[i] + stack.pop + end + j = stack.empty? ? -1 : stack.last + res[i] = res[j] + (i - j) * arr[i] + stack.push(i) + end + res.sum % (10**9 + 7) +end diff --git a/tests/501-1000/907. sum-of-subarray-minimums/sol.rs b/tests/501-1000/907. sum-of-subarray-minimums/sol.rs new file mode 100644 index 00000000..5f2033a6 --- /dev/null +++ b/tests/501-1000/907. sum-of-subarray-minimums/sol.rs @@ -0,0 +1,26 @@ +impl Solution { + pub fn sum_subarray_mins(arr: Vec) -> i32 { + const MOD: i64 = 1_000_000_007; + let n = arr.len(); + let mut stack: Vec = Vec::with_capacity(n); + let mut res = vec![0_i64; n]; + for i in 0..n { + while let Some(&top) = stack.last() { + if arr[top] > arr[i] { + stack.pop(); + } else { + break; + } + } + let j = stack.last().copied().map_or(-1, |v| v as i32); + let prev = if j >= 0 { res[j as usize] } else { 0 }; + res[i] = (prev + (i as i32 - j) as i64 * arr[i] as i64) % MOD; + stack.push(i); + } + let mut sum: i64 = 0; + for v in res { + sum = (sum + v) % MOD; + } + sum as i32 + } +} diff --git a/tests/501-1000/907. sum-of-subarray-minimums/sol.swift b/tests/501-1000/907. sum-of-subarray-minimums/sol.swift new file mode 100644 index 00000000..9459c9d8 --- /dev/null +++ b/tests/501-1000/907. sum-of-subarray-minimums/sol.swift @@ -0,0 +1,17 @@ +class Solution { + func sumSubarrayMins(_ arr: [Int]) -> Int { + let MOD = 1_000_000_007 + let n = arr.count + var stack = [Int]() + var res = [Int](repeating: 0, count: n) + for i in 0.. arr[i] { + stack.removeLast() + } + let j = stack.last ?? -1 + res[i] = ((j >= 0 ? res[j] : 0) + (i - j) * arr[i]) % MOD + stack.append(i) + } + return res.reduce(0) { ($0 + $1) % MOD } + } +} diff --git a/tests/501-1000/907. sum-of-subarray-minimums/sol.ts b/tests/501-1000/907. sum-of-subarray-minimums/sol.ts new file mode 100644 index 00000000..bd9556a8 --- /dev/null +++ b/tests/501-1000/907. sum-of-subarray-minimums/sol.ts @@ -0,0 +1,15 @@ +function sumSubarrayMins(arr: number[]): number { + const MOD = 1_000_000_007; + const n = arr.length; + const stack: number[] = []; + const res: number[] = new Array(n).fill(0); + for (let i = 0; i < n; i++) { + while (stack.length > 0 && arr[stack[stack.length - 1]] > arr[i]) { + stack.pop(); + } + const j = stack.length > 0 ? stack[stack.length - 1] : -1; + res[i] = ((j >= 0 ? res[j] : 0) + (i - j) * arr[i]) % MOD; + stack.push(i); + } + return res.reduce((a, b) => (a + b) % MOD, 0); +} diff --git a/tests/501-1000/908. smallest-range-i/manifest.yaml b/tests/501-1000/908. smallest-range-i/manifest.yaml new file mode 100644 index 00000000..fbaf49c4 --- /dev/null +++ b/tests/501-1000/908. smallest-range-i/manifest.yaml @@ -0,0 +1,213 @@ +entry: + id: 908 + title: "smallest-range-i" + params: + nums: + type: array + items: + type: int + k: + type: int + call: + cpp: "Solution().smallestRangeI({nums}, {k})" + rust: "Solution::smallest_range_i({nums}, {k})" + python3: "Solution().smallestRangeI({nums}, {k})" + python2: "Solution().smallestRangeI({nums}, {k})" + ruby: "smallest_range_i({nums}, {k})" + java: "new Solution().smallestRangeI({nums}, {k})" + csharp: "new Solution().SmallestRangeI({nums}, {k})" + kotlin: "Solution().smallestRangeI({nums}, {k})" + go: "smallestRangeI({nums}, {k})" + dart: "Solution().smallestRangeI({nums}, {k})" + swift: "Solution().smallestRangeI({nums}, {k})" + typescript: "smallestRangeI({nums}, {k})" +judge: + type: "exact" +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().smallestRangeI(nums, k, {result})" + checker: | + class Checker: + def smallestRangeI(self, nums, k, result): + expected = max(0, max(nums) - min(nums) - 2 * k) + return result == expected +seed: 12345 +tests: + - name: "ex1" + in: + nums: [1] + k: 0 + out: 0 + - name: "ex2" + in: + nums: [0, 10] + k: 2 + out: 6 + - name: "ex3" + in: + nums: [1, 3, 6] + k: 3 + out: 0 + - name: "single0" + in: + nums: [5] + k: 0 + out: 0 + - name: "singlek" + in: + nums: [5] + k: 10 + out: 0 + - name: "pair0" + in: + nums: [1, 2] + k: 0 + out: 1 + - name: "pair1" + in: + nums: [1, 2] + k: 1 + out: 0 + - name: "pair2" + in: + nums: [0, 10000] + k: 0 + out: 10000 + - name: "pair3" + in: + nums: [0, 10000] + k: 5000 + out: 0 + - name: "dup0" + in: + nums: [4, 4, 4] + k: 0 + out: 0 + - name: "dup1" + in: + nums: [4, 4, 4] + k: 3 + out: 0 + - name: "spread1" + in: + nums: [1, 10, 20] + k: 4 + out: 11 + - name: "spread2" + in: + nums: [1, 10, 20] + k: 9 + out: 1 + - name: "small1" + in: + nums: [2, 3, 4] + k: 1 + out: 0 + - name: "small2" + in: + nums: [2, 3, 4] + k: 2 + out: 0 + - name: "small3" + in: + nums: [2, 3, 4] + k: 10 + out: 0 + - name: "mix1" + in: + nums: [0, 0, 10000] + k: 1 + out: 9998 + - name: "mix2" + in: + nums: [100, 200, 300] + k: 50 + out: 100 + - name: "mix3" + in: + nums: [100, 200, 300] + k: 100 + out: 0 + - name: "mix4" + in: + nums: [100, 200, 300] + k: 200 + out: 0 + - name: "zig1" + in: + nums: [9, 1, 8, 2] + k: 1 + out: 6 + - name: "zig2" + in: + nums: [9, 1, 8, 2] + k: 4 + out: 0 + - name: "zig3" + in: + nums: [9, 1, 8, 2] + k: 20 + out: 0 + - name: "edge1" + in: + nums: [0, 1] + k: 10000 + out: 0 + - name: "edge2" + in: + nums: [9999, 10000] + k: 1 + out: 0 + - name: "edge3" + in: + nums: [0, 5000, 10000] + k: 2500 + out: 5000 + - name: "edge4" + in: + nums: [0, 5000, 10000] + k: 5000 + out: 0 + - name: "edge5" + in: + nums: [3, 3, 3, 3] + k: 2 + out: 0 + - name: "edge6" + in: + nums: [1, 5, 9, 13] + k: 3 + out: 6 + - name: "edge7" + in: + nums: [1, 5, 9, 13] + k: 6 + out: 0 + - name: "edge8" + in: + nums: [1, 10000] + k: 9999 + out: 0 + - name: "edge9" + in: + nums: [1234, 5678, 9999] + k: 1234 + out: 6297 + - name: "edge10" + in: + nums: [7, 7, 8, 9] + k: 0 + out: 2 + - name: "edge11" + in: + nums: [7, 7, 8, 9] + k: 1 + out: 0 + - name: "edge12" + in: + nums: [7, 7, 8, 9] + k: 100 + out: 0 diff --git a/tests/501-1000/908. smallest-range-i/sol.cpp b/tests/501-1000/908. smallest-range-i/sol.cpp new file mode 100644 index 00000000..f4a841e5 --- /dev/null +++ b/tests/501-1000/908. smallest-range-i/sol.cpp @@ -0,0 +1,17 @@ +class Solution { +public: + int smallestRangeI(vector& nums, int k) { + int min_val = nums[0]; + int max_val = nums[0]; + + for (int val : nums) { + if (val < min_val) { + min_val = val; + } else if (val > max_val) { + max_val = val; + } + } + + return max(0, max_val - min_val - k * 2); + } +}; diff --git a/tests/501-1000/908. smallest-range-i/sol.cs b/tests/501-1000/908. smallest-range-i/sol.cs new file mode 100644 index 00000000..cc3ec463 --- /dev/null +++ b/tests/501-1000/908. smallest-range-i/sol.cs @@ -0,0 +1,16 @@ +public class Solution { + public int SmallestRangeI(int[] nums, int k) { + int minVal = nums[0]; + int maxVal = nums[0]; + + foreach (int val in nums) { + if (val < minVal) { + minVal = val; + } else if (val > maxVal) { + maxVal = val; + } + } + + return Math.Max(0, maxVal - minVal - k * 2); + } +} diff --git a/tests/501-1000/908. smallest-range-i/sol.dart b/tests/501-1000/908. smallest-range-i/sol.dart new file mode 100644 index 00000000..6455f3ba --- /dev/null +++ b/tests/501-1000/908. smallest-range-i/sol.dart @@ -0,0 +1,17 @@ +class Solution { + int smallestRangeI(List nums, int k) { + int minVal = nums[0]; + int maxVal = nums[0]; + + for (int val in nums) { + if (val < minVal) { + minVal = val; + } else if (val > maxVal) { + maxVal = val; + } + } + + int result = maxVal - minVal - k * 2; + return result < 0 ? 0 : result; + } +} diff --git a/tests/501-1000/908. smallest-range-i/sol.go b/tests/501-1000/908. smallest-range-i/sol.go new file mode 100644 index 00000000..55a546ee --- /dev/null +++ b/tests/501-1000/908. smallest-range-i/sol.go @@ -0,0 +1,18 @@ +func smallestRangeI(nums []int, k int) int { + minVal := nums[0] + maxVal := nums[0] + + for _, val := range nums { + if val < minVal { + minVal = val + } else if val > maxVal { + maxVal = val + } + } + + result := maxVal - minVal - k*2 + if result < 0 { + return 0 + } + return result +} diff --git a/tests/501-1000/908. smallest-range-i/sol.java b/tests/501-1000/908. smallest-range-i/sol.java new file mode 100644 index 00000000..32188bd3 --- /dev/null +++ b/tests/501-1000/908. smallest-range-i/sol.java @@ -0,0 +1,16 @@ +class Solution { + public int smallestRangeI(int[] nums, int k) { + int min_val = nums[0]; + int max_val = nums[0]; + + for (int val : nums) { + if (val < min_val) { + min_val = val; + } else if (val > max_val) { + max_val = val; + } + } + + return Math.max(0, max_val - min_val - k * 2); + } +} diff --git a/tests/501-1000/908. smallest-range-i/sol.kt b/tests/501-1000/908. smallest-range-i/sol.kt new file mode 100644 index 00000000..c1fef42e --- /dev/null +++ b/tests/501-1000/908. smallest-range-i/sol.kt @@ -0,0 +1,16 @@ +class Solution { + fun smallestRangeI(nums: IntArray, k: Int): Int { + var minVal = nums[0] + var maxVal = nums[0] + + for (num in nums) { + if (num < minVal) { + minVal = num + } else if (num > maxVal) { + maxVal = num + } + } + + return maxOf(0, maxVal - minVal - k * 2) + } +} diff --git a/tests/501-1000/908. smallest-range-i/sol.py b/tests/501-1000/908. smallest-range-i/sol.py new file mode 100644 index 00000000..04136ad2 --- /dev/null +++ b/tests/501-1000/908. smallest-range-i/sol.py @@ -0,0 +1,16 @@ +class Solution(object): + def smallestRangeI(self, nums, k): + # Find the current boundaries of the array + min_val = nums[0] + max_val = nums[0] + + for val in nums: + if val < min_val: + min_val = val + elif val > max_val: + max_val = val + + # The goal is to minimize (max_val - k) - (min_val + k) + # This simplifies to max_val - min_val - 2*k + # If the gap is already small (<= 2*k), the minimum range is 0 + return max(0, max_val - min_val - k * 2) diff --git a/tests/501-1000/908. smallest-range-i/sol.py2 b/tests/501-1000/908. smallest-range-i/sol.py2 new file mode 100644 index 00000000..43710536 --- /dev/null +++ b/tests/501-1000/908. smallest-range-i/sol.py2 @@ -0,0 +1,17 @@ +class Solution(object): + def smallestRangeI(self, nums, k): + """ + :type nums: List[int] + :type k: int + :rtype: int + """ + min_val = nums[0] + max_val = nums[0] + + for val in nums: + if val < min_val: + min_val = val + elif val > max_val: + max_val = val + + return max(0, max_val - min_val - k * 2) diff --git a/tests/501-1000/908. smallest-range-i/sol.rb b/tests/501-1000/908. smallest-range-i/sol.rb new file mode 100644 index 00000000..0c136433 --- /dev/null +++ b/tests/501-1000/908. smallest-range-i/sol.rb @@ -0,0 +1,17 @@ +# @param {Integer[]} nums +# @param {Integer} k +# @return {Integer} +def smallest_range_i(nums, k) + min_val = nums[0] + max_val = nums[0] + + nums.each do |val| + if val < min_val + min_val = val + elsif val > max_val + max_val = val + end + end + + [0, max_val - min_val - k * 2].max +end diff --git a/tests/501-1000/908. smallest-range-i/sol.rs b/tests/501-1000/908. smallest-range-i/sol.rs new file mode 100644 index 00000000..2794052c --- /dev/null +++ b/tests/501-1000/908. smallest-range-i/sol.rs @@ -0,0 +1,21 @@ +impl Solution { + pub fn smallest_range_i(nums: Vec, k: i32) -> i32 { + let mut min_val = nums[0]; + let mut max_val = nums[0]; + + for &val in &nums { + if val < min_val { + min_val = val; + } else if val > max_val { + max_val = val; + } + } + + let result = max_val - min_val - k * 2; + if result < 0 { + 0 + } else { + result + } + } +} diff --git a/tests/501-1000/908. smallest-range-i/sol.swift b/tests/501-1000/908. smallest-range-i/sol.swift new file mode 100644 index 00000000..0a90dcf2 --- /dev/null +++ b/tests/501-1000/908. smallest-range-i/sol.swift @@ -0,0 +1,16 @@ +class Solution { + func smallestRangeI(_ nums: [Int], _ k: Int) -> Int { + var minVal = nums[0] + var maxVal = nums[0] + + for val in nums { + if val < minVal { + minVal = val + } else if val > maxVal { + maxVal = val + } + } + + return max(0, maxVal - minVal - k * 2) + } +} diff --git a/tests/501-1000/908. smallest-range-i/sol.ts b/tests/501-1000/908. smallest-range-i/sol.ts new file mode 100644 index 00000000..89801216 --- /dev/null +++ b/tests/501-1000/908. smallest-range-i/sol.ts @@ -0,0 +1,14 @@ +function smallestRangeI(nums: number[], k: number): number { + let minVal = nums[0]; + let maxVal = nums[0]; + + for (const val of nums) { + if (val < minVal) { + minVal = val; + } else if (val > maxVal) { + maxVal = val; + } + } + + return Math.max(0, maxVal - minVal - k * 2); +} diff --git a/tests/501-1000/909. snakes-and-ladders/manifest.yaml b/tests/501-1000/909. snakes-and-ladders/manifest.yaml new file mode 100644 index 00000000..86da435a --- /dev/null +++ b/tests/501-1000/909. snakes-and-ladders/manifest.yaml @@ -0,0 +1,430 @@ +entry: + id: 909 + title: "snakes-and-ladders" + params: + board: + type: array + items: + type: array + items: + type: int + call: + cpp: "Solution().snakesAndLadders({board})" + rust: "Solution::snakes_and_ladders({board})" + python3: "Solution().snakesAndLadders({board})" + python2: "Solution().snakesAndLadders({board})" + ruby: "snakes_and_ladders({board})" + java: "new Solution().snakesAndLadders({board})" + csharp: "new Solution().SnakesAndLadders({board})" + kotlin: "Solution().snakesAndLadders({board})" + go: "snakesAndLadders({board})" + dart: "Solution().snakesAndLadders({board})" + swift: "Solution().snakesAndLadders({board})" + typescript: "snakesAndLadders({board})" +judge: + type: "exact" +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().snakesAndLadders(board, {result})" + checker: | + from collections import deque + class Checker: + def snakesAndLadders(self, board, result): + n = len(board) + dist = [-1] * (n * n + 1) + q = deque([1]) + dist[1] = 0 + while q: + x = q.popleft() + for i in range(1, 7): + t = x + i + if t > n * n: + break + row = (t - 1) // n + col = (t - 1) % n + v = board[n - 1 - row][(n - 1 - col) if (row % 2 == 1) else col] + y = v if v > 0 else t + if y == n * n: + expected = dist[x] + 1 + return result == expected + if dist[y] == -1: + dist[y] = dist[x] + 1 + q.append(y) + return result == -1 +seed: 12345 +tests: + - name: "ex1" + in: + board: + elemType: "int" + value: + - [-1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1] + - [-1, 35, -1, -1, 13, -1] + - [-1, -1, -1, -1, -1, -1] + - [-1, 15, -1, -1, -1, -1] + out: 4 + - name: "ex2" + in: + board: + elemType: "int" + value: + - [-1, -1] + - [-1, 3] + out: 1 + - name: "b1" + in: + board: + elemType: "int" + value: + - [-1, -1] + - [-1, -1] + out: 1 + - name: "b2" + in: + board: + elemType: "int" + value: + - [-1, 3] + - [-1, -1] + out: 1 + - name: "b3" + in: + board: + elemType: "int" + value: + - [2, -1] + - [-1, -1] + out: -1 + - name: "b4" + in: + board: + elemType: "int" + value: + - [-1, -1, -1] + - [-1, -1, -1] + - [-1, -1, -1] + out: 2 + - name: "b5" + in: + board: + elemType: "int" + value: + - [-1, -1, -1] + - [-1, 9, -1] + - [-1, -1, -1] + out: 1 + - name: "b6" + in: + board: + elemType: "int" + value: + - [-1, -1, -1] + - [-1, -1, -1] + - [-1, 8, -1] + out: 2 + - name: "b7" + in: + board: + elemType: "int" + value: + - [-1, 9, -1] + - [-1, -1, -1] + - [-1, -1, -1] + out: 2 + - name: "b8" + in: + board: + elemType: "int" + value: + - [-1, -1, -1] + - [-1, -1, 9] + - [-1, -1, -1] + out: 1 + - name: "b9" + in: + board: + elemType: "int" + value: + - [4, -1, -1] + - [-1, -1, -1] + - [-1, -1, -1] + out: 2 + - name: "b10" + in: + board: + elemType: "int" + value: + - [-1, -1, -1] + - [-1, -1, -1] + - [4, -1, -1] + out: 2 + - name: "b11" + in: + board: + elemType: "int" + value: + - [-1, -1, -1, -1] + - [-1, -1, -1, -1] + - [-1, -1, -1, -1] + - [-1, -1, -1, -1] + out: 3 + - name: "b12" + in: + board: + elemType: "int" + value: + - [-1, -1, -1, -1] + - [-1, -1, -1, -1] + - [-1, 16, -1, -1] + - [-1, -1, -1, -1] + out: 1 + - name: "b13" + in: + board: + elemType: "int" + value: + - [-1, -1, -1, -1] + - [-1, -1, -1, -1] + - [-1, -1, -1, 13] + - [-1, -1, -1, -1] + out: 2 + - name: "b14" + in: + board: + elemType: "int" + value: + - [-1, -1, -1, -1] + - [-1, -1, -1, -1] + - [-1, -1, -1, -1] + - [6, -1, -1, -1] + out: 3 + - name: "b15" + in: + board: + elemType: "int" + value: + - [-1, -1, -1, -1] + - [-1, 15, -1, -1] + - [-1, -1, -1, -1] + - [-1, -1, -1, -1] + out: 3 + - name: "b16" + in: + board: + elemType: "int" + value: + - [-1, -1, -1, -1] + - [-1, -1, -1, -1] + - [-1, -1, 2, -1] + - [-1, -1, -1, -1] + out: 3 + - name: "b17" + in: + board: + elemType: "int" + value: + - [-1, -1, -1, -1] + - [-1, -1, -1, -1] + - [-1, -1, -1, -1] + - [-1, 1, -1, -1] + out: 3 + - name: "b18" + in: + board: + elemType: "int" + value: + - [-1, -1, -1, -1] + - [-1, -1, -1, -1] + - [-1, -1, -1, -1] + - [-1, -1, 1, -1] + out: 3 + - name: "b19" + in: + board: + elemType: "int" + value: + - [-1, -1, -1, -1] + - [-1, -1, -1, -1] + - [-1, -1, -1, -1] + - [-1, -1, -1, 1] + out: 3 + - name: "b20" + in: + board: + elemType: "int" + value: + - [-1, -1, -1, -1] + - [-1, -1, -1, -1] + - [-1, -1, -1, -1] + - [-1, -1, -1, -1] + out: 3 + - name: "b21" + in: + board: + elemType: "int" + value: + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + out: 4 + - name: "b22" + in: + board: + elemType: "int" + value: + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, 25, -1, -1] + - [-1, -1, -1, -1, -1] + out: 2 + - name: "b23" + in: + board: + elemType: "int" + value: + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, 5] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + out: 4 + - name: "b24" + in: + board: + elemType: "int" + value: + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, 24, -1, -1, -1] + out: 2 + - name: "b25" + in: + board: + elemType: "int" + value: + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + out: 4 + - name: "b26" + in: + board: + elemType: "int" + value: + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, 1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + out: 5 + - name: "b27" + in: + board: + elemType: "int" + value: + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, 2, -1] + - [-1, -1, -1, -1, -1] + out: 5 + - name: "b28" + in: + board: + elemType: "int" + value: + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, 2, -1] + out: 4 + - name: "b29" + in: + board: + elemType: "int" + value: + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, 2, -1, -1] + out: 4 + - name: "b30" + in: + board: + elemType: "int" + value: + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, 2] + out: 4 + - name: "b31" + in: + board: + elemType: "int" + value: + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, 23, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + out: 3 + - name: "b32" + in: + board: + elemType: "int" + value: + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, 10, -1, -1, -1] + - [-1, -1, -1, -1, -1] + out: 4 + - name: "b33" + in: + board: + elemType: "int" + value: + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, 5, -1, -1, -1] + out: 4 + - name: "b34" + in: + board: + elemType: "int" + value: + - [-1, -1, -1, -1, -1] + - [-1, 7, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + out: 5 + - name: "b35" + in: + board: + elemType: "int" + value: + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1] + out: 4 diff --git a/tests/501-1000/909. snakes-and-ladders/sol.cpp b/tests/501-1000/909. snakes-and-ladders/sol.cpp new file mode 100644 index 00000000..8c216b31 --- /dev/null +++ b/tests/501-1000/909. snakes-and-ladders/sol.cpp @@ -0,0 +1,31 @@ +class Solution { +public: + int snakesAndLadders(vector>& board) { + int n = board.size(); + vector minRolls(n * n + 1, -1); + queue q; + minRolls[1] = 0; + q.push(1); + + while (!q.empty()) { + int x = q.front(); + q.pop(); + for (int i = 1; i <= 6; i++) { + int t = x + i; + if (t > n * n) break; + int row = (t - 1) / n; + int col = (t - 1) % n; + int r = n - 1 - row; + int c = (row % 2 == 1) ? (n - 1 - col) : col; + int v = board[r][c]; + int y = v > 0 ? v : t; + if (y == n * n) return minRolls[x] + 1; + if (minRolls[y] == -1) { + minRolls[y] = minRolls[x] + 1; + q.push(y); + } + } + } + return -1; + } +}; diff --git a/tests/501-1000/909. snakes-and-ladders/sol.cs b/tests/501-1000/909. snakes-and-ladders/sol.cs new file mode 100644 index 00000000..de3985f5 --- /dev/null +++ b/tests/501-1000/909. snakes-and-ladders/sol.cs @@ -0,0 +1,30 @@ +public class Solution { + public int SnakesAndLadders(int[][] board) { + int n = board.Length; + int[] minRolls = new int[n * n + 1]; + Array.Fill(minRolls, -1); + Queue q = new Queue(); + minRolls[1] = 0; + q.Enqueue(1); + + while (q.Count > 0) { + int x = q.Dequeue(); + for (int i = 1; i <= 6; i++) { + int t = x + i; + if (t > n * n) break; + int row = (t - 1) / n; + int col = (t - 1) % n; + int r = n - 1 - row; + int c = (row % 2 == 1) ? (n - 1 - col) : col; + int v = board[r][c]; + int y = v > 0 ? v : t; + if (y == n * n) return minRolls[x] + 1; + if (minRolls[y] == -1) { + minRolls[y] = minRolls[x] + 1; + q.Enqueue(y); + } + } + } + return -1; + } +} diff --git a/tests/501-1000/909. snakes-and-ladders/sol.dart b/tests/501-1000/909. snakes-and-ladders/sol.dart new file mode 100644 index 00000000..606f5ad4 --- /dev/null +++ b/tests/501-1000/909. snakes-and-ladders/sol.dart @@ -0,0 +1,29 @@ +class Solution { + int snakesAndLadders(List> board) { + int n = board.length; + List minRolls = List.filled(n * n + 1, -1); + Queue q = Queue(); + minRolls[1] = 0; + q.add(1); + + while (q.isNotEmpty) { + int x = q.removeFirst(); + for (int i = 1; i <= 6; i++) { + int t = x + i; + if (t > n * n) break; + int row = (t - 1) ~/ n; + int col = (t - 1) % n; + int r = n - 1 - row; + int c = (row % 2 == 1) ? (n - 1 - col) : col; + int v = board[r][c]; + int y = v > 0 ? v : t; + if (y == n * n) return minRolls[x] + 1; + if (minRolls[y] == -1) { + minRolls[y] = minRolls[x] + 1; + q.add(y); + } + } + } + return -1; + } +} diff --git a/tests/501-1000/909. snakes-and-ladders/sol.go b/tests/501-1000/909. snakes-and-ladders/sol.go new file mode 100644 index 00000000..0e0313dd --- /dev/null +++ b/tests/501-1000/909. snakes-and-ladders/sol.go @@ -0,0 +1,40 @@ +func snakesAndLadders(board [][]int) int { + n := len(board) + minRolls := make([]int, n*n+1) + for i := range minRolls { + minRolls[i] = -1 + } + q := []int{1} + minRolls[1] = 0 + + for len(q) > 0 { + x := q[0] + q = q[1:] + for i := 1; i <= 6; i++ { + t := x + i + if t > n*n { + break + } + row := (t - 1) / n + col := (t - 1) % n + r := n - 1 - row + c := col + if row%2 == 1 { + c = n - 1 - col + } + v := board[r][c] + y := t + if v > 0 { + y = v + } + if y == n*n { + return minRolls[x] + 1 + } + if minRolls[y] == -1 { + minRolls[y] = minRolls[x] + 1 + q = append(q, y) + } + } + } + return -1 +} diff --git a/tests/501-1000/909. snakes-and-ladders/sol.java b/tests/501-1000/909. snakes-and-ladders/sol.java new file mode 100644 index 00000000..340db414 --- /dev/null +++ b/tests/501-1000/909. snakes-and-ladders/sol.java @@ -0,0 +1,30 @@ +class Solution { + public int snakesAndLadders(int[][] board) { + int n = board.length; + int[] minRolls = new int[n * n + 1]; + Arrays.fill(minRolls, -1); + Queue q = new LinkedList<>(); + minRolls[1] = 0; + q.offer(1); + + while (!q.isEmpty()) { + int x = q.poll(); + for (int i = 1; i <= 6; i++) { + int t = x + i; + if (t > n * n) break; + int row = (t - 1) / n; + int col = (t - 1) % n; + int r = n - 1 - row; + int c = (row % 2 == 1) ? (n - 1 - col) : col; + int v = board[r][c]; + int y = v > 0 ? v : t; + if (y == n * n) return minRolls[x] + 1; + if (minRolls[y] == -1) { + minRolls[y] = minRolls[x] + 1; + q.offer(y); + } + } + } + return -1; + } +} diff --git a/tests/501-1000/909. snakes-and-ladders/sol.kt b/tests/501-1000/909. snakes-and-ladders/sol.kt new file mode 100644 index 00000000..accb5361 --- /dev/null +++ b/tests/501-1000/909. snakes-and-ladders/sol.kt @@ -0,0 +1,29 @@ +class Solution { + fun snakesAndLadders(board: Array): Int { + val n = board.size + val minRolls = IntArray(n * n + 1) { -1 } + val q: java.util.Queue = java.util.LinkedList() + minRolls[1] = 0 + q.offer(1) + + while (q.isNotEmpty()) { + val x = q.poll() + for (i in 1..6) { + var t = x + i + if (t > n * n) break + val row = (t - 1) / n + val col = (t - 1) % n + val r = n - 1 - row + val c = if (row % 2 == 1) n - 1 - col else col + val v = board[r][c] + val y = if (v > 0) v else t + if (y == n * n) return minRolls[x] + 1 + if (minRolls[y] == -1) { + minRolls[y] = minRolls[x] + 1 + q.offer(y) + } + } + } + return -1 + } +} diff --git a/tests/501-1000/909. snakes-and-ladders/sol.py b/tests/501-1000/909. snakes-and-ladders/sol.py new file mode 100644 index 00000000..d74c6030 --- /dev/null +++ b/tests/501-1000/909. snakes-and-ladders/sol.py @@ -0,0 +1,24 @@ +class Solution(object): + def snakesAndLadders(self, board): + n = len(board) + min_rolls = [-1] * (n * n + 1) + q = deque() + min_rolls[1] = 0 + q.append(1) + + while q: + x = q.popleft() + for i in range(1, 7): + t = x + i + if t > n * n: + break + row = (t - 1) // n + col = (t - 1) % n + v = board[n - 1 - row][(n - 1 - col) if (row % 2 == 1) else col] + y = v if v > 0 else t + if y == n * n: + return min_rolls[x] + 1 + if min_rolls[y] == -1: + min_rolls[y] = min_rolls[x] + 1 + q.append(y) + return -1 diff --git a/tests/501-1000/909. snakes-and-ladders/sol.py2 b/tests/501-1000/909. snakes-and-ladders/sol.py2 new file mode 100644 index 00000000..d74c6030 --- /dev/null +++ b/tests/501-1000/909. snakes-and-ladders/sol.py2 @@ -0,0 +1,24 @@ +class Solution(object): + def snakesAndLadders(self, board): + n = len(board) + min_rolls = [-1] * (n * n + 1) + q = deque() + min_rolls[1] = 0 + q.append(1) + + while q: + x = q.popleft() + for i in range(1, 7): + t = x + i + if t > n * n: + break + row = (t - 1) // n + col = (t - 1) % n + v = board[n - 1 - row][(n - 1 - col) if (row % 2 == 1) else col] + y = v if v > 0 else t + if y == n * n: + return min_rolls[x] + 1 + if min_rolls[y] == -1: + min_rolls[y] = min_rolls[x] + 1 + q.append(y) + return -1 diff --git a/tests/501-1000/909. snakes-and-ladders/sol.rb b/tests/501-1000/909. snakes-and-ladders/sol.rb new file mode 100644 index 00000000..7239a4a5 --- /dev/null +++ b/tests/501-1000/909. snakes-and-ladders/sol.rb @@ -0,0 +1,31 @@ +# @param {Integer[][]} board +# @return {Integer} +def snakes_and_ladders(board) + n = board.length + min_rolls = Array.new(n * n + 1, -1) + q = [1] + min_rolls[1] = 0 + + while !q.empty? + x = q.shift + (1..6).each do |i| + t = x + i + break if t > n * n + row = (t - 1) / n + col = (t - 1) % n + if row % 2 == 1 + c = n - 1 - col + else + c = col + end + v = board[n - 1 - row][c] + y = v > 0 ? v : t + return min_rolls[x] + 1 if y == n * n + if min_rolls[y] == -1 + min_rolls[y] = min_rolls[x] + 1 + q.push(y) + end + end + end + -1 +end diff --git a/tests/501-1000/909. snakes-and-ladders/sol.rs b/tests/501-1000/909. snakes-and-ladders/sol.rs new file mode 100644 index 00000000..c36ca29b --- /dev/null +++ b/tests/501-1000/909. snakes-and-ladders/sol.rs @@ -0,0 +1,34 @@ +impl Solution { + pub fn snakes_and_ladders(board: Vec>) -> i32 { + use std::collections::VecDeque; + + let n = board.len(); + let mut min_rolls = vec![-1; n * n + 1]; + let mut q = VecDeque::new(); + min_rolls[1] = 0; + q.push_back(1); + + while let Some(x) = q.pop_front() { + for i in 1..=6 { + let t = x + i; + if t > (n * n) as i32 { + break; + } + let row = ((t - 1) as usize) / n; + let col = ((t - 1) as usize) % n; + let r = n - 1 - row; + let c = if row % 2 == 1 { n - 1 - col } else { col }; + let v = board[r][c]; + let y = if v > 0 { v } else { t }; + if y == (n * n) as i32 { + return min_rolls[x as usize] + 1; + } + if min_rolls[y as usize] == -1 { + min_rolls[y as usize] = min_rolls[x as usize] + 1; + q.push_back(y); + } + } + } + -1 + } +} diff --git a/tests/501-1000/909. snakes-and-ladders/sol.swift b/tests/501-1000/909. snakes-and-ladders/sol.swift new file mode 100644 index 00000000..04d681f8 --- /dev/null +++ b/tests/501-1000/909. snakes-and-ladders/sol.swift @@ -0,0 +1,28 @@ +class Solution { + func snakesAndLadders(_ board: [[Int]]) -> Int { + let n = board.count + var minRolls = [Int](repeating: -1, count: n * n + 1) + var q = [1] + minRolls[1] = 0 + + while !q.isEmpty { + let x = q.removeFirst() + for i in 1...6 { + let t = x + i + if t > n * n { break } + let row = (t - 1) / n + let col = (t - 1) % n + let r = n - 1 - row + let c = (row % 2 == 1) ? (n - 1 - col) : col + let v = board[r][c] + let y = v > 0 ? v : t + if y == n * n { return minRolls[x] + 1 } + if minRolls[y] == -1 { + minRolls[y] = minRolls[x] + 1 + q.append(y) + } + } + } + return -1 + } +} diff --git a/tests/501-1000/909. snakes-and-ladders/sol.ts b/tests/501-1000/909. snakes-and-ladders/sol.ts new file mode 100644 index 00000000..4aa3003e --- /dev/null +++ b/tests/501-1000/909. snakes-and-ladders/sol.ts @@ -0,0 +1,26 @@ +function snakesAndLadders(board: number[][]): number { + const n = board.length; + const minRolls: number[] = new Array(n * n + 1).fill(-1); + const q: number[] = [1]; + minRolls[1] = 0; + + while (q.length > 0) { + const x = q.shift()!; + for (let i = 1; i <= 6; i++) { + const t = x + i; + if (t > n * n) break; + const row = Math.floor((t - 1) / n); + const col = (t - 1) % n; + const r = n - 1 - row; + const c = row % 2 === 1 ? n - 1 - col : col; + const v = board[r][c]; + const y = v > 0 ? v : t; + if (y === n * n) return minRolls[x] + 1; + if (minRolls[y] === -1) { + minRolls[y] = minRolls[x] + 1; + q.push(y); + } + } + } + return -1; +} diff --git a/tests/501-1000/910. smallest-range-ii/manifest.yaml b/tests/501-1000/910. smallest-range-ii/manifest.yaml new file mode 100644 index 00000000..4518d7f6 --- /dev/null +++ b/tests/501-1000/910. smallest-range-ii/manifest.yaml @@ -0,0 +1,218 @@ +entry: + id: 910 + title: "smallest-range-ii" + params: + nums: + type: array + items: + type: int + k: + type: int + call: + cpp: "Solution().smallestRangeII({nums}, {k})" + rust: "Solution::smallest_range_ii({nums}, {k})" + python3: "Solution().smallestRangeII({nums}, {k})" + python2: "Solution().smallestRangeII({nums}, {k})" + ruby: "smallest_range_ii({nums}, {k})" + java: "new Solution().smallestRangeII({nums}, {k})" + csharp: "new Solution().SmallestRangeII({nums}, {k})" + kotlin: "Solution().smallestRangeII({nums}, {k})" + go: "smallestRangeII({nums}, {k})" + dart: "Solution().smallestRangeII({nums}, {k})" + swift: "Solution().smallestRangeII({nums}, {k})" + typescript: "smallestRangeII({nums}, {k})" +judge: + type: "exact" +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().smallestRangeII(nums, k, {result})" + checker: | + class Checker: + def smallestRangeII(self, nums, k, result): + nums = sorted(nums) + ans = nums[-1] - nums[0] + for i in range(len(nums) - 1): + high = max(nums[-1] - k, nums[i] + k) + low = min(nums[0] + k, nums[i + 1] - k) + ans = min(ans, high - low) + return result == ans +seed: 12345 +tests: + - name: "ex1" + in: + nums: [1] + k: 0 + out: 0 + - name: "ex2" + in: + nums: [0, 10] + k: 2 + out: 6 + - name: "ex3" + in: + nums: [1, 3, 6] + k: 3 + out: 3 + - name: "single0" + in: + nums: [5] + k: 0 + out: 0 + - name: "singlek" + in: + nums: [5] + k: 10 + out: 0 + - name: "pair0" + in: + nums: [1, 2] + k: 0 + out: 1 + - name: "pair1" + in: + nums: [1, 2] + k: 1 + out: 1 + - name: "pair2" + in: + nums: [0, 10000] + k: 0 + out: 10000 + - name: "pair3" + in: + nums: [0, 10000] + k: 5000 + out: 0 + - name: "dup0" + in: + nums: [4, 4, 4] + k: 0 + out: 0 + - name: "dup1" + in: + nums: [4, 4, 4] + k: 3 + out: 0 + - name: "spread1" + in: + nums: [1, 10, 20] + k: 4 + out: 11 + - name: "spread2" + in: + nums: [1, 10, 20] + k: 9 + out: 9 + - name: "small1" + in: + nums: [2, 3, 4] + k: 1 + out: 1 + - name: "small2" + in: + nums: [2, 3, 4] + k: 2 + out: 2 + - name: "small3" + in: + nums: [2, 3, 4] + k: 10 + out: 2 + - name: "mix1" + in: + nums: [0, 0, 10000] + k: 1 + out: 9998 + - name: "mix2" + in: + nums: [100, 200, 300] + k: 50 + out: 100 + - name: "mix3" + in: + nums: [100, 200, 300] + k: 100 + out: 100 + - name: "mix4" + in: + nums: [100, 200, 300] + k: 200 + out: 200 + - name: "zig1" + in: + nums: [9, 1, 8, 2] + k: 1 + out: 6 + - name: "zig2" + in: + nums: [9, 1, 8, 2] + k: 4 + out: 2 + - name: "zig3" + in: + nums: [9, 1, 8, 2] + k: 20 + out: 8 + - name: "edge1" + in: + nums: [0, 1] + k: 10000 + out: 1 + - name: "edge2" + in: + nums: [9999, 10000] + k: 1 + out: 1 + - name: "edge3" + in: + nums: [0, 5000, 10000] + k: 2500 + out: 5000 + - name: "edge4" + in: + nums: [0, 5000, 10000] + k: 5000 + out: 5000 + - name: "edge5" + in: + nums: [3, 3, 3, 3] + k: 2 + out: 0 + - name: "edge6" + in: + nums: [1, 5, 9, 13] + k: 3 + out: 6 + - name: "edge7" + in: + nums: [1, 5, 9, 13] + k: 6 + out: 8 + - name: "edge8" + in: + nums: [1, 10000] + k: 9999 + out: 9999 + - name: "edge9" + in: + nums: [1234, 5678, 9999] + k: 1234 + out: 6297 + - name: "edge10" + in: + nums: [7, 7, 8, 9] + k: 0 + out: 2 + - name: "edge11" + in: + nums: [7, 7, 8, 9] + k: 1 + out: 1 + - name: "edge12" + in: + nums: [7, 7, 8, 9] + k: 100 + out: 2 diff --git a/tests/501-1000/910. smallest-range-ii/sol.cpp b/tests/501-1000/910. smallest-range-ii/sol.cpp new file mode 100644 index 00000000..c23a2e55 --- /dev/null +++ b/tests/501-1000/910. smallest-range-ii/sol.cpp @@ -0,0 +1,14 @@ +class Solution { +public: + int smallestRangeII(vector& nums, int k) { + sort(nums.begin(), nums.end()); + int n = nums.size(); + int ans = nums[n - 1] - nums[0]; + for (int i = 0; i < n - 1; i++) { + int high = max(nums[n - 1] - k, nums[i] + k); + int low = min(nums[0] + k, nums[i + 1] - k); + ans = min(ans, high - low); + } + return ans; + } +}; diff --git a/tests/501-1000/910. smallest-range-ii/sol.cs b/tests/501-1000/910. smallest-range-ii/sol.cs new file mode 100644 index 00000000..81e219c5 --- /dev/null +++ b/tests/501-1000/910. smallest-range-ii/sol.cs @@ -0,0 +1,13 @@ +public class Solution { + public int SmallestRangeII(int[] nums, int k) { + Array.Sort(nums); + int n = nums.Length; + int ans = nums[n - 1] - nums[0]; + for (int i = 0; i < n - 1; i++) { + int high = Math.Max(nums[n - 1] - k, nums[i] + k); + int low = Math.Min(nums[0] + k, nums[i + 1] - k); + ans = Math.Min(ans, high - low); + } + return ans; + } +} diff --git a/tests/501-1000/910. smallest-range-ii/sol.dart b/tests/501-1000/910. smallest-range-ii/sol.dart new file mode 100644 index 00000000..c0cd350d --- /dev/null +++ b/tests/501-1000/910. smallest-range-ii/sol.dart @@ -0,0 +1,13 @@ +class Solution { + int smallestRangeII(List nums, int k) { + nums.sort(); + int n = nums.length; + int ans = nums[n - 1] - nums[0]; + for (int i = 0; i < n - 1; i++) { + int high = max(nums[n - 1] - k, nums[i] + k); + int low = min(nums[0] + k, nums[i + 1] - k); + ans = min(ans, high - low); + } + return ans; + } +} diff --git a/tests/501-1000/910. smallest-range-ii/sol.go b/tests/501-1000/910. smallest-range-ii/sol.go new file mode 100644 index 00000000..e5f9468f --- /dev/null +++ b/tests/501-1000/910. smallest-range-ii/sol.go @@ -0,0 +1,11 @@ +func smallestRangeII(nums []int, k int) int { + sort.Ints(nums) + n := len(nums) + ans := nums[n-1] - nums[0] + for i := 0; i < n-1; i++ { + high := max(nums[n-1]-k, nums[i]+k) + low := min(nums[0]+k, nums[i+1]-k) + ans = min(ans, high-low) + } + return ans +} diff --git a/tests/501-1000/910. smallest-range-ii/sol.java b/tests/501-1000/910. smallest-range-ii/sol.java new file mode 100644 index 00000000..49e3eb46 --- /dev/null +++ b/tests/501-1000/910. smallest-range-ii/sol.java @@ -0,0 +1,13 @@ +class Solution { + public int smallestRangeII(int[] nums, int k) { + Arrays.sort(nums); + int n = nums.length; + int ans = nums[n - 1] - nums[0]; + for (int i = 0; i < n - 1; i++) { + int high = Math.max(nums[n - 1] - k, nums[i] + k); + int low = Math.min(nums[0] + k, nums[i + 1] - k); + ans = Math.min(ans, high - low); + } + return ans; + } +} diff --git a/tests/501-1000/910. smallest-range-ii/sol.kt b/tests/501-1000/910. smallest-range-ii/sol.kt new file mode 100644 index 00000000..698b057e --- /dev/null +++ b/tests/501-1000/910. smallest-range-ii/sol.kt @@ -0,0 +1,13 @@ +class Solution { + fun smallestRangeII(nums: IntArray, k: Int): Int { + nums.sort() + val n = nums.size + var ans = nums[n - 1] - nums[0] + for (i in 0 until n - 1) { + val high = maxOf(nums[n - 1] - k, nums[i] + k) + val low = minOf(nums[0] + k, nums[i + 1] - k) + ans = minOf(ans, high - low) + } + return ans + } +} diff --git a/tests/501-1000/910. smallest-range-ii/sol.py b/tests/501-1000/910. smallest-range-ii/sol.py new file mode 100644 index 00000000..543e6b5c --- /dev/null +++ b/tests/501-1000/910. smallest-range-ii/sol.py @@ -0,0 +1,13 @@ +class Solution: + def smallestRangeII(self, nums: List[int], k: int) -> int: + nums.sort() + n = len(nums) + + ans = nums[-1] - nums[0] + + for i in range(n - 1): + high = max(nums[-1] - k, nums[i] + k) + low = min(nums[0] + k, nums[i + 1] - k) + ans = min(ans, high - low) + + return ans diff --git a/tests/501-1000/910. smallest-range-ii/sol.py2 b/tests/501-1000/910. smallest-range-ii/sol.py2 new file mode 100644 index 00000000..961d6f99 --- /dev/null +++ b/tests/501-1000/910. smallest-range-ii/sol.py2 @@ -0,0 +1,15 @@ +class Solution(object): + def smallestRangeII(self, nums, k): + """ + :type nums: List[int] + :type k: int + :rtype: int + """ + nums.sort() + n = len(nums) + ans = nums[-1] - nums[0] + for i in range(n - 1): + high = max(nums[-1] - k, nums[i] + k) + low = min(nums[0] + k, nums[i + 1] - k) + ans = min(ans, high - low) + return ans diff --git a/tests/501-1000/910. smallest-range-ii/sol.rb b/tests/501-1000/910. smallest-range-ii/sol.rb new file mode 100644 index 00000000..c8a411b0 --- /dev/null +++ b/tests/501-1000/910. smallest-range-ii/sol.rb @@ -0,0 +1,14 @@ +# @param {Integer[]} nums +# @param {Integer} k +# @return {Integer} +def smallest_range_ii(nums, k) + nums.sort! + n = nums.length + ans = nums[-1] - nums[0] + (0...n-1).each do |i| + high = [nums[-1] - k, nums[i] + k].max + low = [nums[0] + k, nums[i+1] - k].min + ans = [ans, high - low].min + end + ans +end diff --git a/tests/501-1000/910. smallest-range-ii/sol.rs b/tests/501-1000/910. smallest-range-ii/sol.rs new file mode 100644 index 00000000..5717d687 --- /dev/null +++ b/tests/501-1000/910. smallest-range-ii/sol.rs @@ -0,0 +1,13 @@ +impl Solution { + pub fn smallest_range_ii(mut nums: Vec, k: i32) -> i32 { + nums.sort(); + let n = nums.len(); + let mut ans = nums[n - 1] - nums[0]; + for i in 0..n - 1 { + let high = std::cmp::max(nums[n - 1] - k, nums[i] + k); + let low = std::cmp::min(nums[0] + k, nums[i + 1] - k); + ans = std::cmp::min(ans, high - low); + } + ans + } +} diff --git a/tests/501-1000/910. smallest-range-ii/sol.swift b/tests/501-1000/910. smallest-range-ii/sol.swift new file mode 100644 index 00000000..f2e01d63 --- /dev/null +++ b/tests/501-1000/910. smallest-range-ii/sol.swift @@ -0,0 +1,13 @@ +class Solution { + func smallestRangeII(_ nums: [Int], _ k: Int) -> Int { + var nums = nums.sorted() + let n = nums.count + var ans = nums[n - 1] - nums[0] + for i in 0.. a - b); + const n = nums.length; + let ans = nums[n - 1] - nums[0]; + for (let i = 0; i < n - 1; i++) { + const high = Math.max(nums[n - 1] - k, nums[i] + k); + const low = Math.min(nums[0] + k, nums[i + 1] - k); + ans = Math.min(ans, high - low); + } + return ans; +} diff --git a/tests/501-1000/912. sort-an-array/manifest.yaml b/tests/501-1000/912. sort-an-array/manifest.yaml new file mode 100644 index 00000000..90a1c4b9 --- /dev/null +++ b/tests/501-1000/912. sort-an-array/manifest.yaml @@ -0,0 +1,261 @@ +entry: + id: 912 + title: sort-an-array + params: + nums: + type: array + items: + type: int + call: + cpp: "Solution().sortArray({nums})" + rust: "Solution::sort_array({nums})" + python3: "Solution().sortArray({nums})" + python2: "Solution().sortArray({nums})" + ruby: "sort_array({nums})" + java: "new Solution().sortArray({nums})" + csharp: "new Solution().SortArray({nums})" + kotlin: "Solution().sortArray({nums})" + go: "sortArray({nums})" + dart: "Solution().sortArray({nums})" + swift: "Solution().sortArray({nums})" + typescript: "sortArray({nums})" +judge: + type: "exact" +limits: + time_ms: 2000 + memory_mb: 256 +oracle: + python3: + call: "Checker().sortArray(nums, {result})" + checker: | + class Checker: + def sortArray(self, nums, result): + if not isinstance(result, list) or len(result) != len(nums): + return False + if any(result[i] > result[i + 1] for i in range(len(result) - 1)): + return False + counts = {} + for x in nums: + counts[x] = counts.get(x, 0) + 1 + for x in result: + if x not in counts: + return False + counts[x] -= 1 + if counts[x] < 0: + return False + return all(v == 0 for v in counts.values()) +seed: 912 +tests: + - name: ex1 + in: + nums: [5, 2, 3, 1] + - name: ex2 + in: + nums: [5, 1, 1, 2, 0, 0] + - name: single + in: + nums: [7] + - name: two_sorted + in: + nums: [1, 2] + - name: two_reversed + in: + nums: [2, 1] + - name: all_equal + in: + nums: [4, 4, 4, 4, 4] + - name: negatives + in: + nums: [3, -1, -7, 2, 0, -3] + - name: already_sorted + in: + nums: [-5, -2, 0, 1, 9, 12] + - name: reverse_sorted + in: + nums: [9, 7, 5, 3, 1, -1, -3] + - name: duplicates_mix + in: + nums: [2, 3, 2, 1, 3, 1, 2, 0] + - name: boundary_small + in: + nums: [50000, -50000, 0] + - name: many_dupes + in: + nums: + gen: "array" + len: 40 + of: + gen: "int" + min: -20 + max: 20 + distinct: false + sorted: false + elemType: "int" + - name: random_1 + in: + nums: + gen: "array" + len: 97 + of: + gen: "int" + min: -500 + max: 500 + distinct: false + sorted: false + elemType: "int" + - name: random_2 + in: + nums: + gen: "array" + len: 128 + of: + gen: "int" + min: -1000 + max: 1000 + distinct: false + sorted: false + elemType: "int" + - name: random_3 + in: + nums: + gen: "array" + len: 255 + of: + gen: "int" + min: -1000 + max: 1000 + distinct: false + sorted: false + elemType: "int" + - name: random_4 + in: + nums: + gen: "array" + len: 512 + of: + gen: "int" + min: -5000 + max: 5000 + distinct: false + sorted: false + elemType: "int" + - name: random_5 + in: + nums: + gen: "array" + len: 777 + of: + gen: "int" + min: -5000 + max: 5000 + distinct: false + sorted: false + elemType: "int" + - name: random_6 + in: + nums: + gen: "array" + len: 1024 + of: + gen: "int" + min: -50000 + max: 50000 + distinct: false + sorted: false + elemType: "int" + - name: random_7 + in: + nums: + gen: "array" + len: 1500 + of: + gen: "int" + min: -50000 + max: 50000 + distinct: false + sorted: false + elemType: "int" + - name: random_8 + in: + nums: + gen: "array" + len: 2048 + of: + gen: "int" + min: -50000 + max: 50000 + distinct: false + sorted: false + elemType: "int" + - name: random_9 + in: + nums: + gen: "array" + len: 3072 + of: + gen: "int" + min: -50000 + max: 50000 + distinct: false + sorted: false + elemType: "int" + - name: random_10 + in: + nums: + gen: "array" + len: 4096 + of: + gen: "int" + min: -50000 + max: 50000 + distinct: false + sorted: false + elemType: "int" + - name: extremes_1 + in: + nums: [50000, 0, -50000, 50000, -50000, 0] + - name: extremes_2 + in: + nums: [1, 0, -1, 2, -2, 3, -3, 4, -4] + - name: repeats_1 + in: + nums: [9, 9, 8, 8, 7, 7, 6, 6, 5, 5] + - name: repeats_2 + in: + nums: [3, 1, 2, 3, 1, 2, 3, 1, 2] + - name: partial_sorted_1 + in: + nums: [-10, -5, -5, -1, 0, 4, 3, 2, 1] + - name: partial_sorted_2 + in: + nums: [100, 99, 98, 98, 99, 100, -100, -99] + - name: mixed_small_1 + in: + nums: [4, -1, 0, -1, 4, 2, 2, -3] + - name: mixed_small_2 + in: + nums: [7, 6, 5, 4, 3, 2, 1, 0] + - name: duplicates_3 + in: + nums: [2, 2, 2, 1, 1, 1, 0, 0, 0] + - name: duplicates_4 + in: + nums: [-2, -2, -1, -1, 0, 0, 1, 1, 2, 2] + - name: zigzag_1 + in: + nums: [5, -5, 4, -4, 3, -3, 2, -2, 1, -1] + - name: zigzag_2 + in: + nums: [12, 11, 13, 5, 6, 7, 0, -1, -2] + - name: gen_large_11 + in: + nums: + gen: "array" + len: 10000 + of: + gen: "int" + min: -50000 + max: 50000 + distinct: false + sorted: false + elemType: "int" diff --git a/tests/501-1000/912. sort-an-array/sol.cpp b/tests/501-1000/912. sort-an-array/sol.cpp new file mode 100644 index 00000000..f0d73e55 --- /dev/null +++ b/tests/501-1000/912. sort-an-array/sol.cpp @@ -0,0 +1,43 @@ +class Solution { +private: + void merge(vector& nums, int l, int mid, int r) { + vector a, b; + for (int i = l; i <= mid; i++) { + a.push_back(nums[i]); + } + for (int j = mid + 1; j <= r; j++) { + b.push_back(nums[j]); + } + int i = 0, j = 0, k = l; + while (k <= r) { + if (j == b.size()) { + nums[k] = a[i]; + i++; + } else if (i == a.size()) { + nums[k] = b[j]; + j++; + } else if (a[i] <= b[j]) { + nums[k] = a[i]; + i++; + } else { + nums[k] = b[j]; + j++; + } + k++; + } + } + + void mergesort(vector& nums, int l, int r) { + if (l >= r) return; + int mid = (l + r) / 2; + mergesort(nums, l, mid); + mergesort(nums, mid + 1, r); + merge(nums, l, mid, r); + } + +public: + vector sortArray(vector& nums) { + mergesort(nums, 0, nums.size() - 1); + return nums; + } +}; diff --git a/tests/501-1000/912. sort-an-array/sol.cs b/tests/501-1000/912. sort-an-array/sol.cs new file mode 100644 index 00000000..489f5ef3 --- /dev/null +++ b/tests/501-1000/912. sort-an-array/sol.cs @@ -0,0 +1,42 @@ +public class Solution { + private void Merge(int[] nums, int l, int mid, int r) { + int[] a = new int[mid - l + 1]; + int[] b = new int[r - mid]; + for (int i = l; i <= mid; i++) { + a[i - l] = nums[i]; + } + for (int j = mid + 1; j <= r; j++) { + b[j - mid - 1] = nums[j]; + } + int iIdx = 0, jIdx = 0, k = l; + while (k <= r) { + if (jIdx == b.Length) { + nums[k] = a[iIdx]; + iIdx++; + } else if (iIdx == a.Length) { + nums[k] = b[jIdx]; + jIdx++; + } else if (a[iIdx] <= b[jIdx]) { + nums[k] = a[iIdx]; + iIdx++; + } else { + nums[k] = b[jIdx]; + jIdx++; + } + k++; + } + } + + private void Mergesort(int[] nums, int l, int r) { + if (l >= r) return; + int mid = (l + r) / 2; + Mergesort(nums, l, mid); + Mergesort(nums, mid + 1, r); + Merge(nums, l, mid, r); + } + + public int[] SortArray(int[] nums) { + Mergesort(nums, 0, nums.Length - 1); + return nums; + } +} diff --git a/tests/501-1000/912. sort-an-array/sol.dart b/tests/501-1000/912. sort-an-array/sol.dart new file mode 100644 index 00000000..1059f674 --- /dev/null +++ b/tests/501-1000/912. sort-an-array/sol.dart @@ -0,0 +1,42 @@ +class Solution { + void merge(List nums, int l, int mid, int r) { + List a = []; + List b = []; + for (int i = l; i <= mid; i++) { + a.add(nums[i]); + } + for (int j = mid + 1; j <= r; j++) { + b.add(nums[j]); + } + int i = 0, j = 0, k = l; + while (k <= r) { + if (j == b.length) { + nums[k] = a[i]; + i++; + } else if (i == a.length) { + nums[k] = b[j]; + j++; + } else if (a[i] <= b[j]) { + nums[k] = a[i]; + i++; + } else { + nums[k] = b[j]; + j++; + } + k++; + } + } + + void mergesort(List nums, int l, int r) { + if (l >= r) return; + int mid = (l + r) ~/ 2; + mergesort(nums, l, mid); + mergesort(nums, mid + 1, r); + merge(nums, l, mid, r); + } + + List sortArray(List nums) { + mergesort(nums, 0, nums.length - 1); + return nums; + } +} diff --git a/tests/501-1000/912. sort-an-array/sol.go b/tests/501-1000/912. sort-an-array/sol.go new file mode 100644 index 00000000..0b5bdb85 --- /dev/null +++ b/tests/501-1000/912. sort-an-array/sol.go @@ -0,0 +1,44 @@ +func sortArray(nums []int) []int { + var merge func(nums []int, l, mid, r int) + merge = func(nums []int, l, mid, r int) { + a := make([]int, mid-l+1) + b := make([]int, r-mid) + for i := l; i <= mid; i++ { + a[i-l] = nums[i] + } + for j := mid + 1; j <= r; j++ { + b[j-mid-1] = nums[j] + } + i, j, k := 0, 0, l + for k <= r { + if j == len(b) { + nums[k] = a[i] + i++ + } else if i == len(a) { + nums[k] = b[j] + j++ + } else if a[i] <= b[j] { + nums[k] = a[i] + i++ + } else { + nums[k] = b[j] + j++ + } + k++ + } + } + + var mergesort func(nums []int, l, r int) + mergesort = func(nums []int, l, r int) { + if l >= r { + return + } + mid := (l + r) / 2 + mergesort(nums, l, mid) + mergesort(nums, mid+1, r) + merge(nums, l, mid, r) + } + + mergesort(nums, 0, len(nums)-1) + return nums +} diff --git a/tests/501-1000/912. sort-an-array/sol.java b/tests/501-1000/912. sort-an-array/sol.java new file mode 100644 index 00000000..94825635 --- /dev/null +++ b/tests/501-1000/912. sort-an-array/sol.java @@ -0,0 +1,42 @@ +class Solution { + private void merge(int[] nums, int l, int mid, int r) { + int[] a = new int[mid - l + 1]; + int[] b = new int[r - mid]; + for (int i = l; i <= mid; i++) { + a[i - l] = nums[i]; + } + for (int j = mid + 1; j <= r; j++) { + b[j - mid - 1] = nums[j]; + } + int i = 0, j = 0, k = l; + while (k <= r) { + if (j == b.length) { + nums[k] = a[i]; + i++; + } else if (i == a.length) { + nums[k] = b[j]; + j++; + } else if (a[i] <= b[j]) { + nums[k] = a[i]; + i++; + } else { + nums[k] = b[j]; + j++; + } + k++; + } + } + + private void mergesort(int[] nums, int l, int r) { + if (l >= r) return; + int mid = (l + r) / 2; + mergesort(nums, l, mid); + mergesort(nums, mid + 1, r); + merge(nums, l, mid, r); + } + + public int[] sortArray(int[] nums) { + mergesort(nums, 0, nums.length - 1); + return nums; + } +} diff --git a/tests/501-1000/912. sort-an-array/sol.kt b/tests/501-1000/912. sort-an-array/sol.kt new file mode 100644 index 00000000..cf27ba39 --- /dev/null +++ b/tests/501-1000/912. sort-an-array/sol.kt @@ -0,0 +1,49 @@ +class Solution { + private fun merge(nums: IntArray, l: Int, mid: Int, r: Int) { + val a = IntArray(mid - l + 1) + val b = IntArray(r - mid) + for (i in l..mid) { + a[i - l] = nums[i] + } + for (j in mid + 1..r) { + b[j - mid - 1] = nums[j] + } + var i = 0 + var j = 0 + var k = l + while (k <= r) { + when { + j == b.size -> { + nums[k] = a[i] + i++ + } + i == a.size -> { + nums[k] = b[j] + j++ + } + a[i] <= b[j] -> { + nums[k] = a[i] + i++ + } + else -> { + nums[k] = b[j] + j++ + } + } + k++ + } + } + + private fun mergesort(nums: IntArray, l: Int, r: Int) { + if (l >= r) return + val mid = (l + r) / 2 + mergesort(nums, l, mid) + mergesort(nums, mid + 1, r) + merge(nums, l, mid, r) + } + + fun sortArray(nums: IntArray): IntArray { + mergesort(nums, 0, nums.size - 1) + return nums + } +} diff --git a/tests/501-1000/912. sort-an-array/sol.py b/tests/501-1000/912. sort-an-array/sol.py new file mode 100644 index 00000000..a6a26109 --- /dev/null +++ b/tests/501-1000/912. sort-an-array/sol.py @@ -0,0 +1,35 @@ +class Solution: + def merge(self, nums, l, mid, r): + a = [] + b = [] + for i in range(l, mid + 1): + a.append(nums[i]) + for j in range(mid + 1, r + 1): + b.append(nums[j]) + i, j, k = 0, 0, l + while k <= r: + if j == len(b): + nums[k] = a[i] + i += 1 + elif i == len(a): + nums[k] = b[j] + j += 1 + elif a[i] <= b[j]: + nums[k] = a[i] + i += 1 + else: + nums[k] = b[j] + j += 1 + k += 1 + + def mergesort(self, nums, l, r): + if l >= r: + return + mid = (l + r) // 2 + self.mergesort(nums, l, mid) + self.mergesort(nums, mid + 1, r) + self.merge(nums, l, mid, r) + + def sortArray(self, nums: List[int]) -> List[int]: + self.mergesort(nums, 0, len(nums) - 1) + return nums diff --git a/tests/501-1000/912. sort-an-array/sol.py2 b/tests/501-1000/912. sort-an-array/sol.py2 new file mode 100644 index 00000000..926ebd87 --- /dev/null +++ b/tests/501-1000/912. sort-an-array/sol.py2 @@ -0,0 +1,39 @@ +class Solution(object): + def sortArray(self, nums): + """ + :type nums: List[int] + :rtype: List[int] + """ + def merge(nums, l, mid, r): + a = [] + b = [] + for i in range(l, mid + 1): + a.append(nums[i]) + for j in range(mid + 1, r + 1): + b.append(nums[j]) + i, j, k = 0, 0, l + while k <= r: + if j == len(b): + nums[k] = a[i] + i += 1 + elif i == len(a): + nums[k] = b[j] + j += 1 + elif a[i] <= b[j]: + nums[k] = a[i] + i += 1 + else: + nums[k] = b[j] + j += 1 + k += 1 + + def mergesort(nums, l, r): + if l >= r: + return + mid = (l + r) // 2 + mergesort(nums, l, mid) + mergesort(nums, mid + 1, r) + merge(nums, l, mid, r) + + mergesort(nums, 0, len(nums) - 1) + return nums diff --git a/tests/501-1000/912. sort-an-array/sol.rb b/tests/501-1000/912. sort-an-array/sol.rb new file mode 100644 index 00000000..c8c4a663 --- /dev/null +++ b/tests/501-1000/912. sort-an-array/sol.rb @@ -0,0 +1,40 @@ +# @param {Integer[]} nums +# @return {Integer[]} +def sort_array(nums) + merge = lambda do |nums, l, mid, r| + a = [] + b = [] + (l..mid).each { |i| a << nums[i] } + (mid + 1..r).each { |j| b << nums[j] } + i = 0 + j = 0 + k = l + while k <= r + if j == b.length + nums[k] = a[i] + i += 1 + elsif i == a.length + nums[k] = b[j] + j += 1 + elsif a[i] <= b[j] + nums[k] = a[i] + i += 1 + else + nums[k] = b[j] + j += 1 + end + k += 1 + end + end + + mergesort = lambda do |nums, l, r| + return if l >= r + mid = (l + r) / 2 + mergesort.call(nums, l, mid) + mergesort.call(nums, mid + 1, r) + merge.call(nums, l, mid, r) + end + + mergesort.call(nums, 0, nums.length - 1) + nums +end diff --git a/tests/501-1000/912. sort-an-array/sol.rs b/tests/501-1000/912. sort-an-array/sol.rs new file mode 100644 index 00000000..ce923a64 --- /dev/null +++ b/tests/501-1000/912. sort-an-array/sol.rs @@ -0,0 +1,48 @@ +impl Solution { + fn merge(nums: &mut Vec, l: usize, mid: usize, r: usize) { + let mut a = Vec::new(); + let mut b = Vec::new(); + for i in l..=mid { + a.push(nums[i]); + } + for j in (mid + 1)..=r { + b.push(nums[j]); + } + let (mut i, mut j, mut k) = (0, 0, l); + while k <= r { + if j == b.len() { + nums[k] = a[i]; + i += 1; + } else if i == a.len() { + nums[k] = b[j]; + j += 1; + } else if a[i] <= b[j] { + nums[k] = a[i]; + i += 1; + } else { + nums[k] = b[j]; + j += 1; + } + k += 1; + } + } + + fn mergesort(nums: &mut Vec, l: usize, r: usize) { + if l >= r { + return; + } + let mid = (l + r) / 2; + Self::mergesort(nums, l, mid); + Self::mergesort(nums, mid + 1, r); + Self::merge(nums, l, mid, r); + } + + pub fn sort_array(nums: Vec) -> Vec { + let mut nums = nums; + let len = nums.len(); + if len > 0 { + Self::mergesort(&mut nums, 0, len - 1); + } + nums + } +} diff --git a/tests/501-1000/912. sort-an-array/sol.swift b/tests/501-1000/912. sort-an-array/sol.swift new file mode 100644 index 00000000..319f09b1 --- /dev/null +++ b/tests/501-1000/912. sort-an-array/sol.swift @@ -0,0 +1,43 @@ +class Solution { + private func merge(_ nums: inout [Int], _ l: Int, _ mid: Int, _ r: Int) { + var a = [Int]() + var b = [Int]() + for i in l...mid { + a.append(nums[i]) + } + for j in (mid + 1)...r { + b.append(nums[j]) + } + var i = 0, j = 0, k = l + while k <= r { + if j == b.count { + nums[k] = a[i] + i += 1 + } else if i == a.count { + nums[k] = b[j] + j += 1 + } else if a[i] <= b[j] { + nums[k] = a[i] + i += 1 + } else { + nums[k] = b[j] + j += 1 + } + k += 1 + } + } + + private func mergesort(_ nums: inout [Int], _ l: Int, _ r: Int) { + if l >= r { return } + let mid = (l + r) / 2 + mergesort(&nums, l, mid) + mergesort(&nums, mid + 1, r) + merge(&nums, l, mid, r) + } + + func sortArray(_ nums: [Int]) -> [Int] { + var nums = nums + mergesort(&nums, 0, nums.count - 1) + return nums + } +} diff --git a/tests/501-1000/912. sort-an-array/sol.ts b/tests/501-1000/912. sort-an-array/sol.ts new file mode 100644 index 00000000..5ff55b18 --- /dev/null +++ b/tests/501-1000/912. sort-an-array/sol.ts @@ -0,0 +1,42 @@ +function sortArray(nums: number[]): number[] { + function merge(nums: number[], l: number, mid: number, r: number): void { + const a: number[] = []; + const b: number[] = []; + for (let i = l; i <= mid; i++) { + a.push(nums[i]); + } + for (let j = mid + 1; j <= r; j++) { + b.push(nums[j]); + } + let i = 0, + j = 0, + k = l; + while (k <= r) { + if (j === b.length) { + nums[k] = a[i]; + i++; + } else if (i === a.length) { + nums[k] = b[j]; + j++; + } else if (a[i] <= b[j]) { + nums[k] = a[i]; + i++; + } else { + nums[k] = b[j]; + j++; + } + k++; + } + } + + function mergesort(nums: number[], l: number, r: number): void { + if (l >= r) return; + const mid = Math.floor((l + r) / 2); + mergesort(nums, l, mid); + mergesort(nums, mid + 1, r); + merge(nums, l, mid, r); + } + + mergesort(nums, 0, nums.length - 1); + return nums; +} diff --git a/tests/501-1000/913. cat-and-mouse/manifest.yaml b/tests/501-1000/913. cat-and-mouse/manifest.yaml new file mode 100644 index 00000000..a65d45c2 --- /dev/null +++ b/tests/501-1000/913. cat-and-mouse/manifest.yaml @@ -0,0 +1,374 @@ +entry: + id: 913 + title: cat-and-mouse + params: + graph: + type: array + items: + type: array + items: + type: int + call: + cpp: "Solution().catMouseGame({graph})" + rust: "Solution::cat_mouse_game({graph})" + python3: "Solution().catMouseGame({graph})" + python2: "Solution().catMouseGame({graph})" + ruby: "cat_mouse_game({graph})" + java: "new Solution().catMouseGame({graph})" + csharp: "new Solution().CatMouseGame({graph})" + kotlin: "Solution().catMouseGame({graph})" + go: "catMouseGame({graph})" + dart: "Solution().catMouseGame({graph})" + swift: "Solution().catMouseGame({graph})" + typescript: "catMouseGame({graph})" +judge: + type: "exact" +limits: + time_ms: 2000 + memory_mb: 256 +oracle: + python3: + call: "Checker().catMouseGame(graph, {result})" + checker: | + from collections import deque + + class Checker: + def catMouseGame(self, graph, result): + n = len(graph) + MOUSE, CAT = 0, 1 + MOUSE_WIN, CAT_WIN, DRAW = 1, 2, 0 + results = {} + for i in range(1, n): + results[0, i, CAT] = results[0, i, MOUSE] = MOUSE_WIN + results[i, i, CAT] = results[i, i, MOUSE] = CAT_WIN + degree = {} + for mouse in range(1, n): + for cat in range(1, n): + degree[mouse, cat, MOUSE] = len(graph[mouse]) + degree[mouse, cat, CAT] = len(graph[cat]) - int(0 in graph[cat]) + q = deque(results.keys()) + while q: + mouse, cat, turn = q.popleft() + cur = results[mouse, cat, turn] + if turn == MOUSE: + prev_states = [(mouse, prev_cat, CAT) for prev_cat in graph[cat]] + else: + prev_states = [(prev_mouse, cat, MOUSE) for prev_mouse in graph[mouse]] + for prev in prev_states: + if prev in results: + continue + pm, pc, pt = prev + if pc == 0: + continue + degree[prev] -= 1 + mover_wins = (cur == MOUSE_WIN and pt == MOUSE) or (cur == CAT_WIN and pt == CAT) + if mover_wins or degree[prev] == 0: + results[prev] = cur + q.append(prev) + return result == results.get((1, 2, MOUSE), DRAW) +seed: 913 +tests: + - name: ex1 + in: + graph: + - [2, 5] + - [3] + - [0, 4, 5] + - [1, 4, 5] + - [2, 3] + - [0, 2, 3] + - name: ex2 + in: + graph: + - [1, 3] + - [0] + - [3] + - [0, 2] + - name: triangle_hole + in: + graph: + - [1, 2] + - [0, 2] + - [0, 1] + - name: line_four + in: + graph: + - [1] + - [0, 2] + - [1, 3] + - [2] + - name: cat_traps_mouse + in: + graph: + - [1, 2] + - [0, 2, 3] + - [0, 1, 3] + - [1, 2] + - name: draw_cycle + in: + graph: + - [1, 2] + - [0, 2, 3] + - [0, 1, 3] + - [1, 2, 4] + - [3] + - name: small_win + in: + graph: + - [1] + - [0, 2, 3] + - [1] + - [1] + - name: cat_win_direct + in: + graph: + - [1, 2] + - [0, 2] + - [0, 1, 3] + - [2] + - name: draw_square + in: + graph: + - [1, 3] + - [0, 2] + - [1, 3] + - [0, 2] + - name: hole_adjacent + in: + graph: + - [1, 2] + - [0, 3] + - [0, 3] + - [1, 2] + - name: cat_forced + in: + graph: + - [1, 2] + - [0, 2, 4] + - [0, 1, 3] + - [2, 4] + - [1, 3] + - name: mouse_escape + in: + graph: + - [1, 2] + - [0, 3] + - [0, 4] + - [1, 4] + - [2, 3] + - name: symmetric_draw + in: + graph: + - [1, 2] + - [0, 3, 4] + - [0, 3, 4] + - [1, 2] + - [1, 2] + - name: bigger_win + in: + graph: + - [1, 2] + - [0, 3] + - [0, 3, 4] + - [1, 2, 5] + - [2, 5] + - [3, 4] + - name: bigger_cat + in: + graph: + - [1, 2] + - [0, 2, 3] + - [0, 1, 4] + - [1, 4] + - [2, 3] + - name: random_like_1 + in: + graph: + - [1, 2] + - [0, 3, 4] + - [0, 4, 5] + - [1, 5] + - [1, 2, 5] + - [2, 3, 4] + - name: random_like_2 + in: + graph: + - [1, 2, 3] + - [0, 4] + - [0, 4, 5] + - [0, 5] + - [1, 2] + - [2, 3] + - name: random_like_3 + in: + graph: + - [1, 2] + - [0, 2, 3] + - [0, 1, 4] + - [1, 4] + - [2, 3, 5] + - [4] + - name: g20 + in: + graph: + - [1, 2] + - [0, 3, 4] + - [0, 4, 5] + - [1, 6] + - [1, 2, 6] + - [2, 6] + - [3, 4, 5] + - name: g21 + in: + graph: + - [1, 2] + - [0, 3] + - [0, 4] + - [1, 5] + - [2, 5] + - [3, 4] + - name: g22 + in: + graph: + - [1, 2] + - [0, 2, 5] + - [0, 1, 3] + - [2, 4] + - [3, 5] + - [1, 4] + - name: g23 + in: + graph: + - [1, 2, 3] + - [0, 4, 5] + - [0, 5] + - [0, 6] + - [1, 6] + - [1, 2] + - [3, 4] + - name: g24 + in: + graph: + - [1, 2] + - [0, 3, 4] + - [0, 4] + - [1, 5] + - [1, 2, 5] + - [3, 4] + - name: g25 + in: + graph: + - [1, 2] + - [0, 2, 3] + - [0, 1, 4] + - [1, 4, 5] + - [2, 3, 5] + - [3, 4] + - name: g26 + in: + graph: + - [1, 2] + - [0, 3, 4] + - [0, 4, 5] + - [1, 6] + - [1, 2, 6] + - [2, 6] + - [3, 4, 5] + - name: g27 + in: + graph: + - [1, 2] + - [0, 3, 4] + - [0, 5] + - [1, 5] + - [1, 2, 6] + - [2, 3, 6] + - [4, 5] + - name: g28 + in: + graph: + - [1, 2] + - [0, 2, 4] + - [0, 1, 3] + - [2, 4, 5] + - [1, 3, 5] + - [3, 4] + - name: g29 + in: + graph: + - [1, 2, 3] + - [0, 4] + - [0, 4, 5] + - [0, 5, 6] + - [1, 2, 6] + - [2, 3] + - [3, 4] + - name: g30 + in: + graph: + - [1, 2] + - [0, 3] + - [0, 4] + - [1, 5] + - [2, 5] + - [3, 4, 6] + - [5] + - name: g31 + in: + graph: + - [1, 2] + - [0, 2, 3] + - [0, 1, 4] + - [1, 4, 5] + - [2, 3, 5] + - [3, 4, 6] + - [5] + - name: g32 + in: + graph: + - [1, 2] + - [0, 3, 4] + - [0, 4, 5] + - [1, 6] + - [1, 2, 6] + - [2, 6] + - [3, 4, 5] + - name: g33 + in: + graph: + - [1, 2] + - [0, 3, 4] + - [0, 4, 5] + - [1, 5, 6] + - [1, 2, 6] + - [2, 3] + - [3, 4] + - name: g34 + in: + graph: + - [1, 2] + - [0, 2, 3] + - [0, 1, 4] + - [1, 4, 5] + - [2, 3, 5] + - [3, 4, 6] + - [5] + - name: g35 + in: + graph: + - [1, 2] + - [0, 3, 4] + - [0, 4, 5] + - [1, 6] + - [1, 2, 6] + - [2, 6] + - [3, 4, 5] + - name: g36 + in: + graph: + - [1, 2] + - [0, 2, 3] + - [0, 1, 4] + - [1, 4] + - [2, 3, 5] + - [4] diff --git a/tests/501-1000/913. cat-and-mouse/sol.cpp b/tests/501-1000/913. cat-and-mouse/sol.cpp new file mode 100644 index 00000000..94e88bd1 --- /dev/null +++ b/tests/501-1000/913. cat-and-mouse/sol.cpp @@ -0,0 +1,75 @@ +class Solution { +public: + int catMouseGame(vector>& graph) { + const int MOUSE = 0; + const int CAT = 1; + const int MOUSE_WIN = 1; + const int CAT_WIN = 2; + const int DRAW = 0; + + int n = graph.size(); + map, int> results; + for (int i = 1; i < n; i++) { + results[{0, i, CAT}] = MOUSE_WIN; + results[{0, i, MOUSE}] = MOUSE_WIN; + results[{i, i, CAT}] = CAT_WIN; + results[{i, i, MOUSE}] = CAT_WIN; + } + + map, int> degree; + for (int mouse = 1; mouse < n; mouse++) { + for (int cat = 1; cat < n; cat++) { + degree[{mouse, cat, MOUSE}] = graph[mouse].size(); + int catDeg = graph[cat].size(); + for (int x : graph[cat]) { + if (x == 0) { + catDeg--; + break; + } + } + degree[{mouse, cat, CAT}] = catDeg; + } + } + + queue> q; + for (auto& [state, _] : results) { + q.push(state); + } + + while (!q.empty()) { + auto [mouse, cat, turn] = q.front(); + q.pop(); + int curResult = results[{mouse, cat, turn}]; + + vector> prevStates; + if (turn == MOUSE) { + for (int prevCat : graph[cat]) { + prevStates.push_back({mouse, prevCat, CAT}); + } + } else { + for (int prevMouse : graph[mouse]) { + prevStates.push_back({prevMouse, cat, MOUSE}); + } + } + + for (auto& prevState : prevStates) { + if (results.count(prevState)) continue; + auto [prevMouse, prevCat, prevTurn] = prevState; + if (prevCat == 0) continue; + + degree[prevState]--; + bool isMoverWinner = ((curResult == MOUSE_WIN && prevTurn == MOUSE) || + (curResult == CAT_WIN && prevTurn == CAT)); + if (isMoverWinner || degree[prevState] == 0) { + results[prevState] = curResult; + q.push(prevState); + } + } + } + + if (results.count({1, 2, MOUSE})) { + return results[{1, 2, MOUSE}]; + } + return DRAW; + } +}; diff --git a/tests/501-1000/913. cat-and-mouse/sol.cs b/tests/501-1000/913. cat-and-mouse/sol.cs new file mode 100644 index 00000000..59daffb5 --- /dev/null +++ b/tests/501-1000/913. cat-and-mouse/sol.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; + +public class Solution { + public int CatMouseGame(int[][] graph) { + int MOUSE = 0; + int CAT = 1; + int MOUSE_WIN = 1; + int CAT_WIN = 2; + int DRAW = 0; + + int n = graph.Length; + Dictionary results = new Dictionary(); + for (int i = 1; i < n; i++) { + results[$"0,{i},{CAT}"] = MOUSE_WIN; + results[$"0,{i},{MOUSE}"] = MOUSE_WIN; + results[$"{i},{i},{CAT}"] = CAT_WIN; + results[$"{i},{i},{MOUSE}"] = CAT_WIN; + } + + Dictionary degree = new Dictionary(); + for (int mouse = 1; mouse < n; mouse++) { + for (int cat = 1; cat < n; cat++) { + degree[$"{mouse},{cat},{MOUSE}"] = graph[mouse].Length; + int catDeg = 0; + foreach (int x in graph[cat]) { + if (x != 0) catDeg++; + } + degree[$"{mouse},{cat},{CAT}"] = catDeg; + } + } + + Queue q = new Queue(); + foreach (string key in results.Keys) { + q.Enqueue(key); + } + + while (q.Count > 0) { + string state = q.Dequeue(); + string[] parts = state.Split(','); + int mouse = int.Parse(parts[0]); + int cat = int.Parse(parts[1]); + int turn = int.Parse(parts[2]); + int curResult = results[state]; + + List prevStates = new List(); + if (turn == MOUSE) { + foreach (int prevCat in graph[cat]) { + prevStates.Add($"{mouse},{prevCat},{CAT}"); + } + } else { + foreach (int prevMouse in graph[mouse]) { + prevStates.Add($"{prevMouse},{cat},{MOUSE}"); + } + } + + foreach (string prevState in prevStates) { + if (results.ContainsKey(prevState)) continue; + string[] prevParts = prevState.Split(','); + int prevMouse = int.Parse(prevParts[0]); + int prevCat = int.Parse(prevParts[1]); + int prevTurn = int.Parse(prevParts[2]); + if (prevCat == 0) continue; + + degree[prevState]--; + bool isMoverWinner = ((curResult == MOUSE_WIN && prevTurn == MOUSE) || + (curResult == CAT_WIN && prevTurn == CAT)); + if (isMoverWinner || degree[prevState] == 0) { + results[prevState] = curResult; + q.Enqueue(prevState); + } + } + } + + return results.ContainsKey($"1,2,{MOUSE}") ? results[$"1,2,{MOUSE}"] : DRAW; + } +} diff --git a/tests/501-1000/913. cat-and-mouse/sol.dart b/tests/501-1000/913. cat-and-mouse/sol.dart new file mode 100644 index 00000000..83c04a8a --- /dev/null +++ b/tests/501-1000/913. cat-and-mouse/sol.dart @@ -0,0 +1,70 @@ +import 'dart:collection'; + +class Solution { + int catMouseGame(List> graph) { + const MOUSE = 0; + const CAT = 1; + const MOUSE_WIN = 1; + const CAT_WIN = 2; + const DRAW = 0; + + int n = graph.length; + Map results = {}; + for (int i = 1; i < n; i++) { + results['0,$i,$CAT'] = MOUSE_WIN; + results['0,$i,$MOUSE'] = MOUSE_WIN; + results['$i,$i,$CAT'] = CAT_WIN; + results['$i,$i,$MOUSE'] = CAT_WIN; + } + + Map degree = {}; + for (int mouse = 1; mouse < n; mouse++) { + for (int cat = 1; cat < n; cat++) { + degree['$mouse,$cat,$MOUSE'] = graph[mouse].length; + degree['$mouse,$cat,$CAT'] = graph[cat].where((x) => x != 0).length; + } + } + + Queue q = Queue(); + q.addAll(results.keys); + + while (q.isNotEmpty) { + String state = q.removeFirst(); + List parts = state.split(','); + int mouse = int.parse(parts[0]); + int cat = int.parse(parts[1]); + int turn = int.parse(parts[2]); + int curResult = results[state]!; + + List prevStates = []; + if (turn == MOUSE) { + for (int prevCat in graph[cat]) { + prevStates.add('$mouse,$prevCat,$CAT'); + } + } else { + for (int prevMouse in graph[mouse]) { + prevStates.add('$prevMouse,$cat,$MOUSE'); + } + } + + for (String prevState in prevStates) { + if (results.containsKey(prevState)) continue; + List prevParts = prevState.split(','); + int prevMouse = int.parse(prevParts[0]); + int prevCat = int.parse(prevParts[1]); + int prevTurn = int.parse(prevParts[2]); + if (prevCat == 0) continue; + + degree[prevState] = degree[prevState]! - 1; + bool isMoverWinner = ((curResult == MOUSE_WIN && prevTurn == MOUSE) || + (curResult == CAT_WIN && prevTurn == CAT)); + if (isMoverWinner || degree[prevState] == 0) { + results[prevState] = curResult; + q.add(prevState); + } + } + } + + return results['1,2,$MOUSE'] ?? DRAW; + } +} diff --git a/tests/501-1000/913. cat-and-mouse/sol.go b/tests/501-1000/913. cat-and-mouse/sol.go new file mode 100644 index 00000000..fa5d0ed0 --- /dev/null +++ b/tests/501-1000/913. cat-and-mouse/sol.go @@ -0,0 +1,80 @@ +func catMouseGame(graph [][]int) int { + const ( + DRAW = 0 + MOUSE = 1 + CAT = 2 + ) + n := len(graph) + memo := make([][][]int, n) + state := make([][][]int, n) + for i := 0; i < n; i++ { + memo[i] = make([][]int, n) + state[i] = make([][]int, n) + for j := 0; j < n; j++ { + memo[i][j] = make([]int, 2) + state[i][j] = make([]int, 2) + } + } + + var dfs func(mouse, cat, turn, depth int) int + dfs = func(mouse, cat, turn, depth int) int { + if depth > 2*n*n { + return DRAW + } + if mouse == 0 { + return MOUSE + } + if cat == mouse { + return CAT + } + if state[mouse][cat][turn] == 2 { + return memo[mouse][cat][turn] + } + if state[mouse][cat][turn] == 1 { + return DRAW + } + state[mouse][cat][turn] = 1 + res := DRAW + if turn == 0 { + res = CAT + drawSeen := false + for _, next := range graph[mouse] { + r := dfs(next, cat, 1, depth+1) + if r == MOUSE { + res = MOUSE + break + } + if r == DRAW { + drawSeen = true + } + } + if res != MOUSE && drawSeen { + res = DRAW + } + } else { + res = MOUSE + drawSeen := false + for _, next := range graph[cat] { + if next == 0 { + continue + } + r := dfs(mouse, next, 0, depth+1) + if r == CAT { + res = CAT + break + } + if r == DRAW { + drawSeen = true + } + } + if res != CAT && drawSeen { + res = DRAW + } + } + state[mouse][cat][turn] = 2 + memo[mouse][cat][turn] = res + return res + } + + return dfs(1, 2, 0, 0) +} diff --git a/tests/501-1000/913. cat-and-mouse/sol.java b/tests/501-1000/913. cat-and-mouse/sol.java new file mode 100644 index 00000000..d3b46596 --- /dev/null +++ b/tests/501-1000/913. cat-and-mouse/sol.java @@ -0,0 +1,80 @@ +import java.util.*; + +class Solution { + public int catMouseGame(int[][] graph) { + int MOUSE = 0; + int CAT = 1; + int MOUSE_WIN = 1; + int CAT_WIN = 2; + int DRAW = 0; + + int n = graph.length; + Map results = new HashMap<>(); + for (int i = 1; i < n; i++) { + results.put(stateKey(0, i, CAT), MOUSE_WIN); + results.put(stateKey(0, i, MOUSE), MOUSE_WIN); + results.put(stateKey(i, i, CAT), CAT_WIN); + results.put(stateKey(i, i, MOUSE), CAT_WIN); + } + + Map degree = new HashMap<>(); + for (int mouse = 1; mouse < n; mouse++) { + for (int cat = 1; cat < n; cat++) { + degree.put(stateKey(mouse, cat, MOUSE), graph[mouse].length); + int catDegree = graph[cat].length; + for (int next : graph[cat]) { + if (next == 0) { + catDegree--; + break; + } + } + degree.put(stateKey(mouse, cat, CAT), catDegree); + } + } + + Queue q = new LinkedList<>(results.keySet()); + + while (!q.isEmpty()) { + String state = q.poll(); + String[] parts = state.split(","); + int mouse = Integer.parseInt(parts[0]); + int cat = Integer.parseInt(parts[1]); + int turn = Integer.parseInt(parts[2]); + int curResult = results.get(state); + + List prevStates = new ArrayList<>(); + if (turn == MOUSE) { + for (int prevCat : graph[cat]) { + prevStates.add(stateKey(mouse, prevCat, CAT)); + } + } else { + for (int prevMouse : graph[mouse]) { + prevStates.add(stateKey(prevMouse, cat, MOUSE)); + } + } + + for (String prevState : prevStates) { + if (results.containsKey(prevState)) continue; + String[] prevParts = prevState.split(","); + int prevMouse = Integer.parseInt(prevParts[0]); + int prevCat = Integer.parseInt(prevParts[1]); + int prevTurn = Integer.parseInt(prevParts[2]); + if (prevCat == 0) continue; + + degree.put(prevState, degree.get(prevState) - 1); + boolean isMoverWinner = ((curResult == MOUSE_WIN && prevTurn == MOUSE) || + (curResult == CAT_WIN && prevTurn == CAT)); + if (isMoverWinner || degree.get(prevState) == 0) { + results.put(prevState, curResult); + q.offer(prevState); + } + } + } + + return results.getOrDefault(stateKey(1, 2, MOUSE), DRAW); + } + + private String stateKey(int mouse, int cat, int turn) { + return mouse + "," + cat + "," + turn; + } +} diff --git a/tests/501-1000/913. cat-and-mouse/sol.kt b/tests/501-1000/913. cat-and-mouse/sol.kt new file mode 100644 index 00000000..4d0073a6 --- /dev/null +++ b/tests/501-1000/913. cat-and-mouse/sol.kt @@ -0,0 +1,67 @@ +class Solution { + fun catMouseGame(graph: Array): Int { + val MOUSE = 0 + val CAT = 1 + val MOUSE_WIN = 1 + val CAT_WIN = 2 + val DRAW = 0 + + val n = graph.size + val results = HashMap() + for (i in 1 until n) { + results["0,$i,$CAT"] = MOUSE_WIN + results["0,$i,$MOUSE"] = MOUSE_WIN + results["$i,$i,$CAT"] = CAT_WIN + results["$i,$i,$MOUSE"] = CAT_WIN + } + + val degree = HashMap() + for (mouse in 1 until n) { + for (cat in 1 until n) { + degree["$mouse,$cat,$MOUSE"] = graph[mouse].size + degree["$mouse,$cat,$CAT"] = graph[cat].count { it != 0 } + } + } + + val q: java.util.Queue = java.util.LinkedList(results.keys) + + while (q.isNotEmpty()) { + val state = q.poll() + val parts = state.split(",") + val mouse = parts[0].toInt() + val cat = parts[1].toInt() + val turn = parts[2].toInt() + val curResult = results[state]!! + + val prevStates = mutableListOf() + if (turn == MOUSE) { + for (prevCat in graph[cat]) { + prevStates.add("$mouse,$prevCat,$CAT") + } + } else { + for (prevMouse in graph[mouse]) { + prevStates.add("$prevMouse,$cat,$MOUSE") + } + } + + for (prevState in prevStates) { + if (results.containsKey(prevState)) continue + val prevParts = prevState.split(",") + val prevMouse = prevParts[0].toInt() + val prevCat = prevParts[1].toInt() + val prevTurn = prevParts[2].toInt() + if (prevCat == 0) continue + + degree[prevState] = degree[prevState]!! - 1 + val isMoverWinner = ((curResult == MOUSE_WIN && prevTurn == MOUSE) || + (curResult == CAT_WIN && prevTurn == CAT)) + if (isMoverWinner || degree[prevState] == 0) { + results[prevState] = curResult + q.offer(prevState) + } + } + } + + return results.getOrDefault("1,2,$MOUSE", DRAW) + } +} diff --git a/tests/501-1000/913. cat-and-mouse/sol.py b/tests/501-1000/913. cat-and-mouse/sol.py new file mode 100644 index 00000000..d38b3b70 --- /dev/null +++ b/tests/501-1000/913. cat-and-mouse/sol.py @@ -0,0 +1,57 @@ +# turns +MOUSE = 0 +CAT = 1 +# states +MOUSE_WIN = 1 +CAT_WIN = 2 +DRAW = 0 + + +class Solution: + def catMouseGame(self, graph: List[List[int]]) -> int: + n = len(graph) + + # Initialize result map with terminal states (MOUSE_WIN/CAT_WIN) + results = {} # map (mouse_pos, cat_pos, turn) -> result + for i in range(1, n): + results[0, i, CAT] = results[0, i, MOUSE] = MOUSE_WIN + results[i, i, CAT] = results[i, i, MOUSE] = CAT_WIN + + # Compute outdegree for all possible states + degree = {} # map (mouse_pos, cat_pos, turn) -> number of next states + for mouse in range(1, n): + for cat in range(1, n): + degree[mouse, cat, MOUSE] = len(graph[mouse]) + degree[mouse, cat, CAT] = len(graph[cat]) - int(0 in graph[cat]) + + # Initialize the queue with terminal states + q = deque([state for state in results.keys()]) + # BFS + while q: + mouse, cat, turn = q.popleft() + curResult = results[mouse, cat, turn] + + # Determine previous states based on the current turn + prevStates = [] + if turn == MOUSE: + prevStates = [(mouse, prevCat, CAT) for prevCat in graph[cat]] + else: + prevStates = [(prevMouse, cat, MOUSE) for prevMouse in graph[mouse]] + + # Update previous states based on the current state's result + for prevState in prevStates: + if prevState in results: + continue + prevMouse, prevCat, prevTurn = prevState + if prevCat == 0: # impossible state + continue + + degree[prevState] -= 1 + isMoverWinner = (curResult == MOUSE_WIN and prevTurn == MOUSE) or ( + curResult == CAT_WIN and prevTurn == CAT + ) + if isMoverWinner or degree[prevState] == 0: + results[prevState] = curResult + q.append(prevState) + + return results.get((1, 2, MOUSE), DRAW) diff --git a/tests/501-1000/913. cat-and-mouse/sol.py2 b/tests/501-1000/913. cat-and-mouse/sol.py2 new file mode 100644 index 00000000..75d478f5 --- /dev/null +++ b/tests/501-1000/913. cat-and-mouse/sol.py2 @@ -0,0 +1,54 @@ +class Solution(object): + def catMouseGame(self, graph): + """ + :type graph: List[List[int]] + :rtype: int + """ + MOUSE = 0 + CAT = 1 + MOUSE_WIN = 1 + CAT_WIN = 2 + DRAW = 0 + + n = len(graph) + results = {} + for i in range(1, n): + results[(0, i, CAT)] = MOUSE_WIN + results[(0, i, MOUSE)] = MOUSE_WIN + results[(i, i, CAT)] = CAT_WIN + results[(i, i, MOUSE)] = CAT_WIN + + degree = {} + for mouse in range(1, n): + for cat in range(1, n): + degree[(mouse, cat, MOUSE)] = len(graph[mouse]) + degree[(mouse, cat, CAT)] = len(graph[cat]) - (0 in graph[cat]) + + from collections import deque + q = deque(list(results.keys())) + + while q: + mouse, cat, turn = q.popleft() + curResult = results[(mouse, cat, turn)] + + prevStates = [] + if turn == MOUSE: + prevStates = [(mouse, prevCat, CAT) for prevCat in graph[cat]] + else: + prevStates = [(prevMouse, cat, MOUSE) for prevMouse in graph[mouse]] + + for prevState in prevStates: + if prevState in results: + continue + prevMouse, prevCat, prevTurn = prevState + if prevCat == 0: + continue + + degree[prevState] -= 1 + isMoverWinner = ((curResult == MOUSE_WIN and prevTurn == MOUSE) or + (curResult == CAT_WIN and prevTurn == CAT)) + if isMoverWinner or degree[prevState] == 0: + results[prevState] = curResult + q.append(prevState) + + return results.get((1, 2, MOUSE), DRAW) diff --git a/tests/501-1000/913. cat-and-mouse/sol.rb b/tests/501-1000/913. cat-and-mouse/sol.rb new file mode 100644 index 00000000..0f6aa3cb --- /dev/null +++ b/tests/501-1000/913. cat-and-mouse/sol.rb @@ -0,0 +1,61 @@ +# @param {Integer[][]} graph +# @return {Integer} +def cat_mouse_game(graph) + mouse_turn = 0 + cat_turn = 1 + mouse_win = 1 + cat_win = 2 + draw = 0 + + n = graph.length + results = {} + (1...n).each do |i| + results[[0, i, cat_turn]] = mouse_win + results[[0, i, mouse_turn]] = mouse_win + results[[i, i, cat_turn]] = cat_win + results[[i, i, mouse_turn]] = cat_win + end + + degree = {} + (1...n).each do |mouse| + (1...n).each do |cat| + degree[[mouse, cat, mouse_turn]] = graph[mouse].length + degree[[mouse, cat, cat_turn]] = graph[cat].length - (graph[cat].include?(0) ? 1 : 0) + end + end + + q = results.keys + + until q.empty? + state = q.shift + mouse, cat, turn = state + cur_result = results[state] + + prev_states = [] + if turn == mouse_turn + graph[cat].each do |prev_cat| + prev_states << [mouse, prev_cat, cat_turn] + end + else + graph[mouse].each do |prev_mouse| + prev_states << [prev_mouse, cat, mouse_turn] + end + end + + prev_states.each do |prev_state| + next if results.key?(prev_state) + prev_mouse, prev_cat, prev_turn = prev_state + next if prev_cat == 0 + + degree[prev_state] -= 1 + is_mover_winner = ((cur_result == mouse_win && prev_turn == mouse_turn) || + (cur_result == cat_win && prev_turn == cat_turn)) + if is_mover_winner || degree[prev_state] == 0 + results[prev_state] = cur_result + q.push(prev_state) + end + end + end + + results.fetch([1, 2, mouse_turn], draw) +end diff --git a/tests/501-1000/913. cat-and-mouse/sol.rs b/tests/501-1000/913. cat-and-mouse/sol.rs new file mode 100644 index 00000000..4ea62ecc --- /dev/null +++ b/tests/501-1000/913. cat-and-mouse/sol.rs @@ -0,0 +1,69 @@ +use std::collections::{HashMap, VecDeque}; + +impl Solution { + pub fn cat_mouse_game(graph: Vec>) -> i32 { + let mouse_turn: i32 = 0; + let cat_turn: i32 = 1; + let mouse_win: i32 = 1; + let cat_win: i32 = 2; + let draw: i32 = 0; + + let n = graph.len(); + let mut results: HashMap<(i32, i32, i32), i32> = HashMap::new(); + for i in 1..n as i32 { + results.insert((0, i, cat_turn), mouse_win); + results.insert((0, i, mouse_turn), mouse_win); + results.insert((i, i, cat_turn), cat_win); + results.insert((i, i, mouse_turn), cat_win); + } + + let mut degree: HashMap<(i32, i32, i32), i32> = HashMap::new(); + for mouse in 1..n as i32 { + for cat in 1..n as i32 { + degree.insert((mouse, cat, mouse_turn), graph[mouse as usize].len() as i32); + let cat_deg = graph[cat as usize].iter().filter(|&&x| x != 0).count() as i32; + degree.insert((mouse, cat, cat_turn), cat_deg); + } + } + + let mut q: VecDeque<(i32, i32, i32)> = VecDeque::new(); + for &state in results.keys() { + q.push_back(state); + } + + while let Some((mouse, cat, turn)) = q.pop_front() { + let cur_result = results[&(mouse, cat, turn)]; + + let mut prev_states: Vec<(i32, i32, i32)> = Vec::new(); + if turn == mouse_turn { + for &prev_cat in &graph[cat as usize] { + prev_states.push((mouse, prev_cat, cat_turn)); + } + } else { + for &prev_mouse in &graph[mouse as usize] { + prev_states.push((prev_mouse, cat, mouse_turn)); + } + } + + for prev_state in prev_states { + if results.contains_key(&prev_state) { + continue; + } + let (prev_mouse, prev_cat, prev_turn) = prev_state; + if prev_cat == 0 { + continue; + } + + *degree.get_mut(&prev_state).unwrap() -= 1; + let is_mover_winner = (cur_result == mouse_win && prev_turn == mouse_turn) || + (cur_result == cat_win && prev_turn == cat_turn); + if is_mover_winner || degree[&prev_state] == 0 { + results.insert(prev_state, cur_result); + q.push_back(prev_state); + } + } + } + + *results.get(&(1, 2, mouse_turn)).unwrap_or(&draw) + } +} diff --git a/tests/501-1000/913. cat-and-mouse/sol.swift b/tests/501-1000/913. cat-and-mouse/sol.swift new file mode 100644 index 00000000..2091f4bf --- /dev/null +++ b/tests/501-1000/913. cat-and-mouse/sol.swift @@ -0,0 +1,69 @@ +class Solution { + func catMouseGame(_ graph: [[Int]]) -> Int { + let MOUSE = 0 + let CAT = 1 + let MOUSE_WIN = 1 + let CAT_WIN = 2 + let DRAW = 0 + + let n = graph.count + var results: [String: Int] = [:] + for i in 1.. = new Map(); + for (let i = 1; i < n; i++) { + results.set(`0,${i},${CAT}`, MOUSE_WIN); + results.set(`0,${i},${MOUSE}`, MOUSE_WIN); + results.set(`${i},${i},${CAT}`, CAT_WIN); + results.set(`${i},${i},${MOUSE}`, CAT_WIN); + } + + const degree: Map = new Map(); + for (let mouse = 1; mouse < n; mouse++) { + for (let cat = 1; cat < n; cat++) { + degree.set(`${mouse},${cat},${MOUSE}`, graph[mouse].length); + degree.set( + `${mouse},${cat},${CAT}`, + graph[cat].filter((x) => x !== 0).length, + ); + } + } + + const q: string[] = Array.from(results.keys()); + let front = 0; + + while (front < q.length) { + const state = q[front++]; + const parts = state.split(","); + const mouse = parseInt(parts[0]); + const cat = parseInt(parts[1]); + const turn = parseInt(parts[2]); + const curResult = results.get(state)!; + + const prevStates: string[] = []; + if (turn === MOUSE) { + for (const prevCat of graph[cat]) { + prevStates.push(`${mouse},${prevCat},${CAT}`); + } + } else { + for (const prevMouse of graph[mouse]) { + prevStates.push(`${prevMouse},${cat},${MOUSE}`); + } + } + + for (const prevState of prevStates) { + if (results.has(prevState)) continue; + const prevParts = prevState.split(","); + const prevMouse = parseInt(prevParts[0]); + const prevCat = parseInt(prevParts[1]); + const prevTurn = parseInt(prevParts[2]); + if (prevCat === 0) continue; + + degree.set(prevState, degree.get(prevState)! - 1); + const isMoverWinner = + (curResult === MOUSE_WIN && prevTurn === MOUSE) || + (curResult === CAT_WIN && prevTurn === CAT); + if (isMoverWinner || degree.get(prevState) === 0) { + results.set(prevState, curResult); + q.push(prevState); + } + } + } + + return results.get(`1,2,${MOUSE}`) ?? DRAW; +} diff --git a/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/manifest.yaml b/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/manifest.yaml new file mode 100644 index 00000000..0a28547e --- /dev/null +++ b/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/manifest.yaml @@ -0,0 +1,268 @@ +entry: + id: 914 + title: x-of-a-kind-in-a-deck-of-cards + params: + deck: + type: array + items: + type: int + call: + cpp: "Solution().hasGroupsSizeX({deck})" + rust: "Solution::has_groups_size_x({deck})" + python3: "Solution().hasGroupsSizeX({deck})" + python2: "Solution().hasGroupsSizeX({deck})" + ruby: "has_groups_size_x({deck})" + java: "new Solution().hasGroupsSizeX({deck})" + csharp: "new Solution().HasGroupsSizeX({deck})" + kotlin: "Solution().hasGroupsSizeX({deck})" + go: "hasGroupsSizeX({deck})" + dart: "Solution().hasGroupsSizeX({deck})" + swift: "Solution().hasGroupsSizeX({deck})" + typescript: "hasGroupsSizeX({deck})" +judge: + type: "exact" +limits: + time_ms: 1000 + memory_mb: 128 +oracle: + python3: + call: "Checker().hasGroupsSizeX(deck, {result})" + checker: | + class Checker: + def hasGroupsSizeX(self, deck, result): + counts = {} + for x in deck: + counts[x] = counts.get(x, 0) + 1 + g = 0 + for c in counts.values(): + while c: + g, c = c, g % c + return bool(result) == (g >= 2) +seed: 914 +tests: + - name: ex1 + in: + deck: [1, 2, 3, 4, 4, 3, 2, 1] + - name: ex2 + in: + deck: [1, 1, 1, 2, 2, 2, 3, 3] + - name: single + in: + deck: [7] + - name: pair + in: + deck: [5, 5] + - name: triple + in: + deck: [1, 1, 1] + - name: gcd_two + in: + deck: [1, 1, 2, 2, 3, 3, 4, 4] + - name: gcd_three + in: + deck: [9, 9, 9, 8, 8, 8, 7, 7, 7] + - name: mixed_true + in: + deck: [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3] + - name: mixed_false + in: + deck: [0, 0, 1, 1, 1, 2, 2] + - name: all_unique + in: + deck: [0, 1, 2, 3, 4, 5] + - name: even_counts + in: + deck: [2, 2, 3, 3, 3, 3, 4, 4] + - name: prime_counts_false + in: + deck: [1, 1, 1, 1, 1, 2, 2, 2] + - name: max_value_mix + in: + deck: + gen: "array" + len: 80 + of: + gen: "int" + min: 0 + max: 9999 + distinct: false + sorted: false + elemType: "int" + - name: random_1 + in: + deck: + gen: "array" + len: 101 + of: + gen: "int" + min: 0 + max: 9999 + distinct: false + sorted: false + elemType: "int" + - name: random_2 + in: + deck: + gen: "array" + len: 257 + of: + gen: "int" + min: 0 + max: 9999 + distinct: false + sorted: false + elemType: "int" + - name: random_3 + in: + deck: + gen: "array" + len: 512 + of: + gen: "int" + min: 0 + max: 9999 + distinct: false + sorted: false + elemType: "int" + - name: pair_large_values + in: + deck: [9999, 9999, 9998, 9998] + - name: triple_with_zero + in: + deck: [0, 0, 0, 7, 7, 7] + - name: fours_multiple + in: + deck: [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3] + - name: gcd_six + in: + deck: + - 4 + - 4 + - 4 + - 4 + - 4 + - 4 + - 9 + - 9 + - 9 + - 9 + - 9 + - 9 + - name: gcd_four_false + in: + deck: [6, 6, 6, 6, 8, 8, 8, 8, 8, 8] + - name: coprime_counts_false + in: + deck: [1, 1, 2, 2, 2] + - name: two_pairs_and_triple_false + in: + deck: [5, 5, 6, 6, 6] + - name: many_twos_true + in: + deck: [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8] + - name: mixed_counts_false + in: + deck: [3, 3, 3, 4, 4, 4, 4] + - name: long_true_1 + in: + deck: + - 10 + - 10 + - 10 + - 10 + - 10 + - 10 + - 11 + - 11 + - 11 + - 11 + - 11 + - 11 + - 12 + - 12 + - 12 + - 12 + - 12 + - 12 + - name: long_true_2 + in: + deck: + - 20 + - 20 + - 20 + - 20 + - 30 + - 30 + - 30 + - 30 + - 40 + - 40 + - 40 + - 40 + - 50 + - 50 + - 50 + - 50 + - name: long_false_1 + in: + deck: + - 1 + - 1 + - 1 + - 2 + - 2 + - 2 + - 2 + - 3 + - 3 + - 3 + - 3 + - 3 + - name: long_false_2 + in: + deck: + - 4 + - 4 + - 4 + - 4 + - 4 + - 6 + - 6 + - 6 + - 6 + - 6 + - 6 + - name: sparse_true + in: + deck: [0, 0, 5, 5, 9, 9, 9999, 9999] + - name: sparse_false + in: + deck: [0, 0, 0, 1, 1, 2, 2, 2] + - name: even_gcd_true + in: + deck: [7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10] + - name: gcd_one_false + in: + deck: [1, 1, 1, 2, 2, 2, 4, 4] + - name: exact_two_groups_true + in: + deck: [13, 13, 14, 14, 15, 15, 15, 15] + - name: large_count_true + in: + deck: + - 21 + - 21 + - 21 + - 21 + - 21 + - 21 + - 21 + - 21 + - 22 + - 22 + - 22 + - 22 + - 22 + - 22 + - 22 + - 22 diff --git a/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.cpp b/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.cpp new file mode 100644 index 00000000..55ce6463 --- /dev/null +++ b/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.cpp @@ -0,0 +1,32 @@ +class Solution { +public: + bool hasGroupsSizeX(vector& deck) { + unordered_map counts; + for (int card : deck) { + counts[card]++; + } + + auto getGcd = [](int a, int b) { + while (b > 0) { + int temp = b; + b = a % b; + a = temp; + } + return a; + }; + + int currentGcd = -1; + for (auto& [card, count] : counts) { + if (currentGcd == -1) { + currentGcd = count; + } else { + currentGcd = getGcd(currentGcd, count); + if (currentGcd == 1) { + return false; + } + } + } + + return currentGcd >= 2; + } +}; diff --git a/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.cs b/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.cs new file mode 100644 index 00000000..c1de80eb --- /dev/null +++ b/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.cs @@ -0,0 +1,33 @@ +public class Solution { + public bool HasGroupsSizeX(int[] deck) { + Dictionary counts = new Dictionary(); + foreach (int card in deck) { + if (counts.ContainsKey(card)) { + counts[card]++; + } else { + counts[card] = 1; + } + } + + int GetGcd(int a, int b) { + while (b > 0) { + int temp = b; + b = a % b; + a = temp; + } + return a; + } + + List frequencies = new List(counts.Values); + int currentGcd = frequencies[0]; + + for (int i = 1; i < frequencies.Count; i++) { + currentGcd = GetGcd(currentGcd, frequencies[i]); + if (currentGcd == 1) { + return false; + } + } + + return currentGcd >= 2; + } +} diff --git a/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.dart b/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.dart new file mode 100644 index 00000000..de93bbc6 --- /dev/null +++ b/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.dart @@ -0,0 +1,29 @@ +class Solution { + bool hasGroupsSizeX(List deck) { + Map counts = {}; + for (int card in deck) { + counts[card] = (counts[card] ?? 0) + 1; + } + + int getGcd(int a, int b) { + while (b > 0) { + int temp = b; + b = a % b; + a = temp; + } + return a; + } + + List frequencies = counts.values.toList(); + int currentGcd = frequencies[0]; + + for (int i = 1; i < frequencies.length; i++) { + currentGcd = getGcd(currentGcd, frequencies[i]); + if (currentGcd == 1) { + return false; + } + } + + return currentGcd >= 2; + } +} diff --git a/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.go b/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.go new file mode 100644 index 00000000..1c54f83c --- /dev/null +++ b/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.go @@ -0,0 +1,28 @@ +func hasGroupsSizeX(deck []int) bool { + counts := make(map[int]int) + for _, card := range deck { + counts[card]++ + } + + var gcd func(a, b int) int + gcd = func(a, b int) int { + for b > 0 { + a, b = b, a%b + } + return a + } + + currentGcd := -1 + for _, count := range counts { + if currentGcd == -1 { + currentGcd = count + } else { + currentGcd = gcd(currentGcd, count) + if currentGcd == 1 { + return false + } + } + } + + return currentGcd >= 2 +} diff --git a/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.java b/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.java new file mode 100644 index 00000000..65c08575 --- /dev/null +++ b/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.java @@ -0,0 +1,31 @@ +class Solution { + public boolean hasGroupsSizeX(int[] deck) { + java.util.Map counts = new java.util.HashMap<>(); + for (int card : deck) { + counts.put(card, counts.getOrDefault(card, 0) + 1); + } + + int currentGcd = -1; + for (int count : counts.values()) { + if (currentGcd == -1) { + currentGcd = count; + } else { + currentGcd = gcd(currentGcd, count); + if (currentGcd == 1) { + return false; + } + } + } + + return currentGcd >= 2; + } + + private int gcd(int a, int b) { + while (b > 0) { + int temp = b; + b = a % b; + a = temp; + } + return a; + } +} diff --git a/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.kt b/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.kt new file mode 100644 index 00000000..f1a3ce51 --- /dev/null +++ b/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.kt @@ -0,0 +1,31 @@ +class Solution { + fun hasGroupsSizeX(deck: IntArray): Boolean { + val counts = mutableMapOf() + for (card in deck) { + counts[card] = counts.getOrDefault(card, 0) + 1 + } + + fun gcd(a: Int, b: Int): Int { + var x = a + var y = b + while (y > 0) { + val temp = y + y = x % y + x = temp + } + return x + } + + val frequencies = counts.values.toList() + var currentGcd = frequencies[0] + + for (count in frequencies.drop(1)) { + currentGcd = gcd(currentGcd, count) + if (currentGcd == 1) { + return false + } + } + + return currentGcd >= 2 + } +} diff --git a/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.py b/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.py new file mode 100644 index 00000000..d1351c09 --- /dev/null +++ b/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.py @@ -0,0 +1,25 @@ +class Solution: + def hasGroupsSizeX(self, deck: List[int]) -> bool: + + counts = {} + for card in deck: + if card in counts: + counts[card] += 1 + else: + counts[card] = 1 + + def get_gcd(a: int, b: int) -> int: + while b > 0: + a, b = b, a % b + return a + + frequencies = list(counts.values()) + current_gcd = frequencies[0] + + for count in frequencies[1:]: + current_gcd = get_gcd(current_gcd, count) + + if current_gcd == 1: + return False + + return current_gcd >= 2 diff --git a/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.py2 b/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.py2 new file mode 100644 index 00000000..7340d28a --- /dev/null +++ b/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.py2 @@ -0,0 +1,27 @@ +class Solution(object): + def hasGroupsSizeX(self, deck): + """ + :type deck: List[int] + :rtype: bool + """ + counts = {} + for card in deck: + if card in counts: + counts[card] += 1 + else: + counts[card] = 1 + + def get_gcd(a, b): + while b > 0: + a, b = b, a % b + return a + + frequencies = counts.values() + current_gcd = frequencies[0] + + for count in frequencies[1:]: + current_gcd = get_gcd(current_gcd, count) + if current_gcd == 1: + return False + + return current_gcd >= 2 diff --git a/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.rb b/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.rb new file mode 100644 index 00000000..cee0a369 --- /dev/null +++ b/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.rb @@ -0,0 +1,23 @@ +# @param {Integer[]} deck +# @return {Boolean} +def has_groups_size_x(deck) + counts = Hash.new(0) + deck.each { |card| counts[card] += 1 } + + def get_gcd(a, b) + while b > 0 + a, b = b, a % b + end + a + end + + frequencies = counts.values + current_gcd = frequencies[0] + + frequencies[1..-1].each do |count| + current_gcd = get_gcd(current_gcd, count) + return false if current_gcd == 1 + end + + current_gcd >= 2 +end diff --git a/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.rs b/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.rs new file mode 100644 index 00000000..b2657724 --- /dev/null +++ b/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.rs @@ -0,0 +1,33 @@ +impl Solution { + pub fn has_groups_size_x(deck: Vec) -> bool { + use std::collections::HashMap; + + let mut counts: HashMap = HashMap::new(); + for card in deck { + *counts.entry(card).or_insert(0) += 1; + } + + fn get_gcd(a: i32, b: i32) -> i32 { + let mut x = a; + let mut y = b; + while y > 0 { + let temp = y; + y = x % y; + x = temp; + } + x + } + + let frequencies: Vec = counts.values().cloned().collect(); + let mut current_gcd = frequencies[0]; + + for &count in &frequencies[1..] { + current_gcd = get_gcd(current_gcd, count); + if current_gcd == 1 { + return false; + } + } + + current_gcd >= 2 + } +} diff --git a/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.swift b/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.swift new file mode 100644 index 00000000..065aff4f --- /dev/null +++ b/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.swift @@ -0,0 +1,31 @@ +class Solution { + func hasGroupsSizeX(_ deck: [Int]) -> Bool { + var counts: [Int: Int] = [:] + for card in deck { + counts[card, default: 0] += 1 + } + + func getGcd(_ a: Int, _ b: Int) -> Int { + var x = a + var y = b + while y > 0 { + let temp = y + y = x % y + x = temp + } + return x + } + + let frequencies = Array(counts.values) + var currentGcd = frequencies[0] + + for count in frequencies.dropFirst() { + currentGcd = getGcd(currentGcd, count) + if currentGcd == 1 { + return false + } + } + + return currentGcd >= 2 + } +} diff --git a/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.ts b/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.ts new file mode 100644 index 00000000..c41240c4 --- /dev/null +++ b/tests/501-1000/914. x-of-a-kind-in-a-deck-of-cards/sol.ts @@ -0,0 +1,27 @@ +function hasGroupsSizeX(deck: number[]): boolean { + const counts: Map = new Map(); + for (const card of deck) { + counts.set(card, (counts.get(card) || 0) + 1); + } + + function getGcd(a: number, b: number): number { + while (b > 0) { + const temp = b; + b = a % b; + a = temp; + } + return a; + } + + const frequencies = Array.from(counts.values()); + let currentGcd = frequencies[0]; + + for (let i = 1; i < frequencies.length; i++) { + currentGcd = getGcd(currentGcd, frequencies[i]); + if (currentGcd === 1) { + return false; + } + } + + return currentGcd >= 2; +} diff --git a/tests/501-1000/915. partition-array-into-disjoint-intervals/manifest.yaml b/tests/501-1000/915. partition-array-into-disjoint-intervals/manifest.yaml new file mode 100644 index 00000000..c761dde6 --- /dev/null +++ b/tests/501-1000/915. partition-array-into-disjoint-intervals/manifest.yaml @@ -0,0 +1,206 @@ +entry: + id: 915 + title: partition-array-into-disjoint-intervals + params: + nums: + type: array + items: + type: int + call: + cpp: "Solution().partitionDisjoint({nums})" + rust: "Solution::partition_disjoint({nums})" + python3: "Solution().partitionDisjoint({nums})" + python2: "Solution().partitionDisjoint({nums})" + ruby: "partition_disjoint({nums})" + java: "new Solution().partitionDisjoint({nums})" + csharp: "new Solution().PartitionDisjoint({nums})" + kotlin: "Solution().partitionDisjoint({nums})" + go: "partitionDisjoint({nums})" + dart: "Solution().partitionDisjoint({nums})" + swift: "Solution().partitionDisjoint({nums})" + typescript: "partitionDisjoint({nums})" +judge: + type: "exact" +limits: + time_ms: 1000 + memory_mb: 128 +oracle: + python3: + call: "Checker().partitionDisjoint(nums, {result})" + checker: | + class Checker: + def partitionDisjoint(self, nums, result): + if not isinstance(result, int): + return False + n = len(nums) + if result < 1 or result >= n: + return False + left = nums[:result] + right = nums[result:] + return max(left) <= min(right) and all(x <= y for x in left for y in right) +seed: 915 +tests: + - name: ex1 + in: + nums: [5, 0, 3, 8, 6] + out: 3 + - name: ex2 + in: + nums: [1, 1, 1, 0, 6, 12] + out: 4 + - name: min_size + in: + nums: [1, 2] + out: 1 + - name: two_reverse + in: + nums: [1, 2] + out: 1 + - name: already_partitioned + in: + nums: [0, 1, 2, 3, 4] + out: 1 + - name: cut_at_end_minus_one + in: + nums: [1, 1, 1, 1, 0, 10] + out: 5 + - name: many_equal + in: + nums: [3, 3, 3, 3, 3, 3] + out: 1 + - name: duplicates_case + in: + nums: [2, 1, 3, 4, 4] + out: 2 + - name: boundary_values + in: + nums: [1000000, 0, 1000000] + out: 2 + - name: small_random_1 + in: + nums: [4, 4, 1, 2, 3, 5, 6, 7] + out: 5 + - name: small_random_2 + in: + nums: [2, 2, 2, 1, 1, 1, 4, 5] + out: 6 + - name: small_random_3 + in: + nums: [5, 0, 3, 8, 6] + out: 3 + - name: random_4 + in: + nums: [1, 1, 1, 2, 2, 2, 2, 3, 3] + out: 1 + - name: strict_increase + in: + nums: [1, 2, 3, 4, 5, 6] + out: 1 + - name: strict_decrease + in: + nums: [5, 4, 3, 2, 1, 6] + out: 5 + - name: plateau_then_tail + in: + nums: [2, 2, 2, 1, 3, 4, 5] + out: 4 + - name: cut_near_end + in: + nums: [7, 1, 2, 3, 4, 5, 6, 8] + out: 7 + - name: cut_at_two + in: + nums: [0, 1, 0, 2, 3] + out: 1 + - name: duplicates_small + in: + nums: [1, 1, 1, 1, 2, 2] + out: 1 + - name: duplicates_large + in: + nums: [1000000, 1000000, 0, 1000000, 1000000, 1000000] + out: 3 + - name: valley_middle + in: + nums: [4, 4, 4, 1, 2, 3, 5, 6] + out: 6 + - name: needs_prefix_extension + in: + nums: [3, 3, 3, 2, 2, 2, 4, 5] + out: 6 + - name: right_smallest_large + in: + nums: [10, 11, 12, 1, 2, 3, 100, 101] + out: 6 + - name: two_element_edge + in: + nums: [0, 1000000] + out: 1 + - name: mixed_low_high + in: + nums: [1, 5, 0, 3, 4, 6, 7] + out: 5 + - name: long_small_cut + in: + nums: + - 5 + - 4 + - 3 + - 2 + - 1 + - 6 + - 7 + - 8 + - 9 + - 10 + out: 5 + - name: long_tail_cut + in: + nums: + - 1 + - 1 + - 1 + - 1 + - 1 + - 0 + - 2 + - 3 + - 4 + - 5 + out: 6 + - name: boundary_one_million_prefix + in: + nums: [1000000, 999999, 999999, 1000000] + out: 3 + - name: boundary_one_million_tail + in: + nums: [1, 2, 3, 1000000, 1000000] + out: 1 + - name: prefix_max_matters + in: + nums: [2, 0, 1, 3, 4, 5] + out: 3 + - name: suffix_min_matters + in: + nums: [1, 2, 5, 0, 6, 7] + out: 4 + - name: many_equals_true + in: + nums: [7, 7, 7, 7, 7, 7, 8, 8] + out: 1 + - name: many_equals_false + in: + nums: [7, 7, 7, 6, 7, 8] + out: 4 + - name: early_valid_cut + in: + nums: [0, 0, 0, 1, 1, 1] + out: 1 + - name: late_valid_cut + in: + nums: [5, 0, 1, 2, 3, 4, 6] + out: 6 + - name: mid_size_case + in: + nums: [6, 6, 6, 1, 2, 3, 4, 5, 7, 8] + out: 8 diff --git a/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.cpp b/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.cpp new file mode 100644 index 00000000..fe6605e7 --- /dev/null +++ b/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.cpp @@ -0,0 +1,24 @@ +class Solution { +public: + int partitionDisjoint(vector& nums) { + int n = nums.size(); + vector prefixMax(n); + prefixMax[0] = nums[0]; + for (int i = 1; i < n; ++i) { + prefixMax[i] = max(prefixMax[i-1], nums[i]); + } + + vector suffixMin(n); + suffixMin[n-1] = nums[n-1]; + for (int i = n-2; i >= 0; --i) { + suffixMin[i] = min(suffixMin[i+1], nums[i]); + } + + for (int i = 0; i < n-1; ++i) { + if (prefixMax[i] <= suffixMin[i+1]) { + return i + 1; + } + } + return -1; + } +}; diff --git a/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.cs b/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.cs new file mode 100644 index 00000000..6fde015a --- /dev/null +++ b/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.cs @@ -0,0 +1,23 @@ +public class Solution { + public int PartitionDisjoint(int[] nums) { + int n = nums.Length; + int[] prefixMax = new int[n]; + prefixMax[0] = nums[0]; + for (int i = 1; i < n; i++) { + prefixMax[i] = Math.Max(prefixMax[i-1], nums[i]); + } + + int[] suffixMin = new int[n]; + suffixMin[n-1] = nums[n-1]; + for (int i = n-2; i >= 0; i--) { + suffixMin[i] = Math.Min(suffixMin[i+1], nums[i]); + } + + for (int i = 0; i < n-1; i++) { + if (prefixMax[i] <= suffixMin[i+1]) { + return i + 1; + } + } + return -1; + } +} diff --git a/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.dart b/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.dart new file mode 100644 index 00000000..848fa43a --- /dev/null +++ b/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.dart @@ -0,0 +1,23 @@ +class Solution { + int partitionDisjoint(List nums) { + int n = nums.length; + List prefixMax = List.filled(n, 0); + prefixMax[0] = nums[0]; + for (int i = 1; i < n; i++) { + prefixMax[i] = nums[i] > prefixMax[i-1] ? nums[i] : prefixMax[i-1]; + } + + List suffixMin = List.filled(n, 0); + suffixMin[n-1] = nums[n-1]; + for (int i = n-2; i >= 0; i--) { + suffixMin[i] = nums[i] < suffixMin[i+1] ? nums[i] : suffixMin[i+1]; + } + + for (int i = 0; i < n-1; i++) { + if (prefixMax[i] <= suffixMin[i+1]) { + return i + 1; + } + } + return -1; + } +} diff --git a/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.go b/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.go new file mode 100644 index 00000000..ddf61d32 --- /dev/null +++ b/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.go @@ -0,0 +1,29 @@ +func partitionDisjoint(nums []int) int { + n := len(nums) + prefixMax := make([]int, n) + prefixMax[0] = nums[0] + for i := 1; i < n; i++ { + if nums[i] > prefixMax[i-1] { + prefixMax[i] = nums[i] + } else { + prefixMax[i] = prefixMax[i-1] + } + } + + suffixMin := make([]int, n) + suffixMin[n-1] = nums[n-1] + for i := n-2; i >= 0; i-- { + if nums[i] < suffixMin[i+1] { + suffixMin[i] = nums[i] + } else { + suffixMin[i] = suffixMin[i+1] + } + } + + for i := 0; i < n-1; i++ { + if prefixMax[i] <= suffixMin[i+1] { + return i + 1 + } + } + return -1 +} diff --git a/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.java b/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.java new file mode 100644 index 00000000..62e945ae --- /dev/null +++ b/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.java @@ -0,0 +1,23 @@ +class Solution { + public int partitionDisjoint(int[] nums) { + int n = nums.length; + int[] prefixMax = new int[n]; + prefixMax[0] = nums[0]; + for (int i = 1; i < n; i++) { + prefixMax[i] = Math.max(prefixMax[i-1], nums[i]); + } + + int[] suffixMin = new int[n]; + suffixMin[n-1] = nums[n-1]; + for (int i = n-2; i >= 0; i--) { + suffixMin[i] = Math.min(suffixMin[i+1], nums[i]); + } + + for (int i = 0; i < n-1; i++) { + if (prefixMax[i] <= suffixMin[i+1]) { + return i + 1; + } + } + return -1; + } +} diff --git a/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.kt b/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.kt new file mode 100644 index 00000000..3f19cd9b --- /dev/null +++ b/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.kt @@ -0,0 +1,23 @@ +class Solution { + fun partitionDisjoint(nums: IntArray): Int { + val n = nums.size + val prefixMax = IntArray(n) + prefixMax[0] = nums[0] + for (i in 1 until n) { + prefixMax[i] = maxOf(prefixMax[i-1], nums[i]) + } + + val suffixMin = IntArray(n) + suffixMin[n-1] = nums[n-1] + for (i in n-2 downTo 0) { + suffixMin[i] = minOf(suffixMin[i+1], nums[i]) + } + + for (i in 0 until n-1) { + if (prefixMax[i] <= suffixMin[i+1]) { + return i + 1 + } + } + return -1 + } +} diff --git a/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.py b/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.py new file mode 100644 index 00000000..02b781c5 --- /dev/null +++ b/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.py @@ -0,0 +1,19 @@ +class Solution: + def partitionDisjoint(self, nums: List[int]) -> int: + n = len(nums) + + prefix_max = [0] * n + prefix_max[0] = nums[0] + + for i in range(1, n): + prefix_max[i] = max(prefix_max[i - 1], nums[i]) + + suffix_min = [0] * n + suffix_min[-1] = nums[-1] + + for i in range(n - 2, -1, -1): + suffix_min[i] = min(suffix_min[i + 1], nums[i]) + + for i in range(n - 1): + if prefix_max[i] <= suffix_min[i + 1]: + return i + 1 diff --git a/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.py2 b/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.py2 new file mode 100644 index 00000000..37f309bd --- /dev/null +++ b/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.py2 @@ -0,0 +1,21 @@ +class Solution(object): + def partitionDisjoint(self, nums): + """ + :type nums: List[int] + :rtype: int + """ + n = len(nums) + prefix_max = [0] * n + prefix_max[0] = nums[0] + for i in range(1, n): + prefix_max[i] = max(prefix_max[i-1], nums[i]) + + suffix_min = [0] * n + suffix_min[-1] = nums[-1] + for i in range(n-2, -1, -1): + suffix_min[i] = min(suffix_min[i+1], nums[i]) + + for i in range(n-1): + if prefix_max[i] <= suffix_min[i+1]: + return i + 1 + return -1 diff --git a/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.rb b/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.rb new file mode 100644 index 00000000..32da876b --- /dev/null +++ b/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.rb @@ -0,0 +1,22 @@ +# @param {Integer[]} nums +# @return {Integer} +def partition_disjoint(nums) + n = nums.length + prefix_max = Array.new(n, 0) + prefix_max[0] = nums[0] + (1...n).each do |i| + prefix_max[i] = [prefix_max[i-1], nums[i]].max + end + + suffix_min = Array.new(n, 0) + suffix_min[-1] = nums[-1] + (n-2).downto(0) do |i| + suffix_min[i] = [suffix_min[i+1], nums[i]].min + end + + (0...n-1).each do |i| + if prefix_max[i] <= suffix_min[i+1] + return i + 1 + end + end +end diff --git a/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.rs b/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.rs new file mode 100644 index 00000000..d1104755 --- /dev/null +++ b/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.rs @@ -0,0 +1,23 @@ +impl Solution { + pub fn partition_disjoint(nums: Vec) -> i32 { + let n = nums.len(); + let mut prefix_max = vec![0; n]; + prefix_max[0] = nums[0]; + for i in 1..n { + prefix_max[i] = prefix_max[i-1].max(nums[i]); + } + + let mut suffix_min = vec![0; n]; + suffix_min[n-1] = nums[n-1]; + for i in (0..n-1).rev() { + suffix_min[i] = suffix_min[i+1].min(nums[i]); + } + + for i in 0..n-1 { + if prefix_max[i] <= suffix_min[i+1] { + return (i + 1) as i32; + } + } + -1 + } +} diff --git a/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.swift b/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.swift new file mode 100644 index 00000000..b31857a5 --- /dev/null +++ b/tests/501-1000/915. partition-array-into-disjoint-intervals/sol.swift @@ -0,0 +1,23 @@ +class Solution { + func partitionDisjoint(_ nums: [Int]) -> Int { + let n = nums.count + var prefixMax = [Int](repeating: 0, count: n) + prefixMax[0] = nums[0] + for i in 1..= 0; i--) { + suffixMin[i] = Math.min(suffixMin[i + 1], nums[i]); + } + + for (let i = 0; i < n - 1; i++) { + if (prefixMax[i] <= suffixMin[i + 1]) { + return i + 1; + } + } + return -1; +} diff --git a/tests/501-1000/916. word-subsets/manifest.yaml b/tests/501-1000/916. word-subsets/manifest.yaml new file mode 100644 index 00000000..97f462a8 --- /dev/null +++ b/tests/501-1000/916. word-subsets/manifest.yaml @@ -0,0 +1,214 @@ +entry: + id: 916 + title: word-subsets + params: + words1: + type: array + items: + type: string + words2: + type: array + items: + type: string + call: + cpp: "Solution().wordSubsets({words1}, {words2})" + rust: "Solution::word_subsets({words1}, {words2})" + python3: "Solution().wordSubsets({words1}, {words2})" + python2: "Solution().wordSubsets({words1}, {words2})" + ruby: "word_subsets({words1}, {words2})" + java: "new Solution().wordSubsets({words1}, {words2})" + csharp: "new Solution().WordSubsets({words1}, {words2})" + kotlin: "Solution().wordSubsets({words1}, {words2})" + go: "wordSubsets({words1}, {words2})" + dart: "Solution().wordSubsets({words1}, {words2})" + swift: "Solution().wordSubsets({words1}, {words2})" + typescript: "wordSubsets({words1}, {words2})" +judge: + type: "ignore_order" +limits: + time_ms: 2000 + memory_mb: 256 +oracle: + python3: + call: "Checker().wordSubsets(words1, words2, {result})" + checker: | + class Checker: + def wordSubsets(self, words1, words2, result): + need = [0] * 26 + for w in words2: + cnt = [0] * 26 + for ch in w: + cnt[ord(ch) - 97] += 1 + for i in range(26): + if cnt[i] > need[i]: + need[i] = cnt[i] + got = [] + for w in words1: + cnt = [0] * 26 + for ch in w: + cnt[ord(ch) - 97] += 1 + if all(cnt[i] >= need[i] for i in range(26)): + got.append(w) + return sorted(got) == sorted(result) +seed: 916 +tests: + - name: ex1 + in: + words1: ["amazon", "apple", "facebook", "google", "leetcode"] + words2: ["e", "o"] + - name: ex2 + in: + words1: ["amazon", "apple", "facebook", "google", "leetcode"] + words2: ["lc", "eo"] + - name: ex3 + in: + words1: ["acaac", "cccbb", "aacbb", "caacc", "bcbbb"] + words2: ["c", "cc", "b"] + - name: empty_need + in: + words1: ["a", "b", "ab"] + words2: ["a"] + - name: repeated_need + in: + words1: ["aaa", "aaab", "aabb", "bbb"] + words2: ["aa", "ab"] + - name: single_letter + in: + words1: ["a", "aa", "aaa"] + words2: ["a", "a", "a"] + - name: impossible + in: + words1: ["abc", "def", "ghi"] + words2: ["zz"] + - name: many_universal + in: + words1: ["abca", "bcaa", "aabc", "zzzz", "caba"] + words2: ["aa", "bc"] + - name: short_words + in: + words1: ["x", "y", "z", "xy", "yz"] + words2: ["x"] + - name: random_1 + in: + words1: ["abc", "abca", "bcae", "deed", "face", "cafe", "feed", "bead"] + words2: ["ab", "ce"] + - name: random_2 + in: + words1: ["aaaa", "aaab", "aabb", "abbb", "bbbb", "abba", "baaa"] + words2: ["aa", "bb"] + - name: random_3 + in: + words1: ["xyz", "xxyyzz", "xzz", "yyzz", "zzzz", "xyzz"] + words2: ["xz", "yz"] + - name: random_4 + in: + words1: ["hello", "yellow", "mellow", "fellow", "bellow", "cello"] + words2: ["el", "lo"] + - name: random_5 + in: + words1: ["ab", "abc", "abcd", "abcde", "abcdef"] + words2: ["a", "bc", "de"] + - name: random_6 + in: + words1: ["aaaaa", "aaaab", "aaabb", "aabbb", "abbbb"] + words2: ["aaa", "bb"] + - name: random_7 + in: + words1: ["qwerty", "qwe", "wert", "erty", "tyui", "uiop"] + words2: ["q", "w", "e"] + - name: random_8 + in: + words1: ["moon", "noon", "soon", "moons", "swoon", "on"] + words2: ["oo", "n"] + - name: random_9 + in: + words1: ["cat", "tac", "act", "tact", "at", "aaat"] + words2: ["a", "t"] + - name: random_10 + in: + words1: ["piano", "pianos", "pioneer", "phone", "phoneme"] + words2: ["p", "o"] + - name: empty_result_simple + in: + words1: ["aa", "bb", "cc"] + words2: ["a", "b"] + - name: one_universal_exact + in: + words1: ["ab", "ba", "cab"] + words2: ["a", "b"] + - name: duplicate_need_counts + in: + words1: ["aabb", "ab", "bbaa", "abba"] + words2: ["aa", "bb", "ab"] + - name: repeated_letters_needed + in: + words1: ["cccc", "cccd", "dccc", "abcd"] + words2: ["ccc"] + - name: no_match_high_need + in: + words1: ["abc", "def", "ghi", "jkl"] + words2: ["zz", "yyy"] + - name: all_match_single_need + in: + words1: ["a", "ba", "ca", "da"] + words2: ["a"] + - name: all_match_multi_need + in: + words1: ["abcde", "bcdea", "cdeab"] + words2: ["ab", "cd", "e"] + - name: mixed_case_like_patterns + in: + words1: ["listen", "silent", "enlist", "google"] + words2: ["eil", "nst"] + - name: repeated_groups + in: + words1: ["aaabbb", "ab", "bbaaab", "bbbaaa"] + words2: ["aaa", "bbb"] + - name: boundary_letters + in: + words1: ["az", "za", "zzaa", "azz", "zaz"] + words2: ["a", "z", "z"] + - name: longer_words_1 + in: + words1: ["abcdef", "abcxyz", "azbycx", "aabbcc", "zzzzzz"] + words2: ["ab", "ac"] + - name: longer_words_2 + in: + words1: ["lorem", "ipsum", "dolor", "amet", "sit", "elit"] + words2: ["e", "t"] + - name: no_need_words2 + in: + words1: ["alpha", "beta", "gamma"] + words2: ["a"] + - name: exact_multiset_need + in: + words1: ["aabbcc", "abcabc", "abccba", "aabccc"] + words2: ["abc", "abc"] + - name: universal_tail + in: + words1: ["tool", "cool", "pool", "fool", "school"] + words2: ["oo", "l"] + - name: various_lengths + in: + words1: ["a", "aa", "aaa", "aaaa", "aaaaa", "aaaaaa"] + words2: ["aa", "aaa"] + - name: prefix_overlap + in: + words1: ["abc", "abcc", "abccc", "abcccc"] + words2: ["bc", "cc"] + - name: overlapping_need + in: + words1: ["cab", "cabb", "ccab", "bacc", "abcabc"] + words2: ["c", "ab"] + - name: larger_mix_1 + in: + words1: ["abcde", "bcdef", "cdefg", "defgh", "efghi", "fghij"] + words2: ["cd", "ef"] + - name: larger_mix_2 + in: + words1: ["aaaaab", "aaaabb", "aaabbb", "aabbbb", "abbbbb"] + words2: ["aaa", "bb"] + - name: larger_mix_3 + in: + words1: ["qwert", "werty", "ertyu", "rtyui", "tyuio"] + words2: ["q", "w", "e"] diff --git a/tests/501-1000/916. word-subsets/sol.cpp b/tests/501-1000/916. word-subsets/sol.cpp new file mode 100644 index 00000000..3aac2aab --- /dev/null +++ b/tests/501-1000/916. word-subsets/sol.cpp @@ -0,0 +1,38 @@ +class Solution { +public: + vector wordSubsets(vector& words1, vector& words2) { + vector maxCharFreq(26, 0); + vector tempCharFreq(26, 0); + + for (const string& word : words2) { + for (char ch : word) { + tempCharFreq[ch - 'a']++; + } + for (int i = 0; i < 26; i++) { + maxCharFreq[i] = max(maxCharFreq[i], tempCharFreq[i]); + } + fill(tempCharFreq.begin(), tempCharFreq.end(), 0); + } + + vector universalWords; + + for (const string& word : words1) { + for (char ch : word) { + tempCharFreq[ch - 'a']++; + } + bool isUniversal = true; + for (int i = 0; i < 26; i++) { + if (maxCharFreq[i] > tempCharFreq[i]) { + isUniversal = false; + break; + } + } + if (isUniversal) { + universalWords.push_back(word); + } + fill(tempCharFreq.begin(), tempCharFreq.end(), 0); + } + + return universalWords; + } +}; diff --git a/tests/501-1000/916. word-subsets/sol.cs b/tests/501-1000/916. word-subsets/sol.cs new file mode 100644 index 00000000..12f6944c --- /dev/null +++ b/tests/501-1000/916. word-subsets/sol.cs @@ -0,0 +1,37 @@ +public class Solution { + public IList WordSubsets(string[] words1, string[] words2) { + int[] maxCharFreq = new int[26]; + int[] tempCharFreq = new int[26]; + + foreach (string word in words2) { + foreach (char ch in word) { + tempCharFreq[ch - 'a']++; + } + for (int i = 0; i < 26; i++) { + maxCharFreq[i] = Math.Max(maxCharFreq[i], tempCharFreq[i]); + } + Array.Clear(tempCharFreq, 0, 26); + } + + IList universalWords = new List(); + + foreach (string word in words1) { + foreach (char ch in word) { + tempCharFreq[ch - 'a']++; + } + bool isUniversal = true; + for (int i = 0; i < 26; i++) { + if (maxCharFreq[i] > tempCharFreq[i]) { + isUniversal = false; + break; + } + } + if (isUniversal) { + universalWords.Add(word); + } + Array.Clear(tempCharFreq, 0, 26); + } + + return universalWords; + } +} diff --git a/tests/501-1000/916. word-subsets/sol.dart b/tests/501-1000/916. word-subsets/sol.dart new file mode 100644 index 00000000..1d298b5f --- /dev/null +++ b/tests/501-1000/916. word-subsets/sol.dart @@ -0,0 +1,37 @@ +class Solution { + List wordSubsets(List words1, List words2) { + List maxCharFreq = List.filled(26, 0); + List tempCharFreq = List.filled(26, 0); + + for (var word in words2) { + for (var ch in word.codeUnits) { + tempCharFreq[ch - 'a'.codeUnitAt(0)]++; + } + for (int i = 0; i < 26; i++) { + maxCharFreq[i] = maxCharFreq[i] > tempCharFreq[i] ? maxCharFreq[i] : tempCharFreq[i]; + } + tempCharFreq = List.filled(26, 0); + } + + List universalWords = []; + + for (var word in words1) { + for (var ch in word.codeUnits) { + tempCharFreq[ch - 'a'.codeUnitAt(0)]++; + } + bool isUniversal = true; + for (int i = 0; i < 26; i++) { + if (maxCharFreq[i] > tempCharFreq[i]) { + isUniversal = false; + break; + } + } + if (isUniversal) { + universalWords.add(word); + } + tempCharFreq = List.filled(26, 0); + } + + return universalWords; + } +} diff --git a/tests/501-1000/916. word-subsets/sol.go b/tests/501-1000/916. word-subsets/sol.go new file mode 100644 index 00000000..af929b0d --- /dev/null +++ b/tests/501-1000/916. word-subsets/sol.go @@ -0,0 +1,41 @@ +func wordSubsets(words1 []string, words2 []string) []string { + maxCharFreq := make([]int, 26) + tempCharFreq := make([]int, 26) + + for _, word := range words2 { + for _, ch := range word { + tempCharFreq[ch - 'a']++ + } + for i := 0; i < 26; i++ { + if tempCharFreq[i] > maxCharFreq[i] { + maxCharFreq[i] = tempCharFreq[i] + } + } + for i := range tempCharFreq { + tempCharFreq[i] = 0 + } + } + + universalWords := []string{} + + for _, word := range words1 { + for _, ch := range word { + tempCharFreq[ch - 'a']++ + } + isUniversal := true + for i := 0; i < 26; i++ { + if maxCharFreq[i] > tempCharFreq[i] { + isUniversal = false + break + } + } + if isUniversal { + universalWords = append(universalWords, word) + } + for i := range tempCharFreq { + tempCharFreq[i] = 0 + } + } + + return universalWords +} diff --git a/tests/501-1000/916. word-subsets/sol.java b/tests/501-1000/916. word-subsets/sol.java new file mode 100644 index 00000000..33aee686 --- /dev/null +++ b/tests/501-1000/916. word-subsets/sol.java @@ -0,0 +1,37 @@ +class Solution { + public List wordSubsets(String[] words1, String[] words2) { + int[] maxCharFreq = new int[26]; + int[] tempCharFreq = new int[26]; + + for (String word : words2) { + for (char ch : word.toCharArray()) { + tempCharFreq[ch - 'a']++; + } + for (int i = 0; i < 26; i++) { + maxCharFreq[i] = Math.max(maxCharFreq[i], tempCharFreq[i]); + } + Arrays.fill(tempCharFreq, 0); + } + + List universalWords = new ArrayList<>(); + + for (String word : words1) { + for (char ch : word.toCharArray()) { + tempCharFreq[ch - 'a']++; + } + boolean isUniversal = true; + for (int i = 0; i < 26; i++) { + if (maxCharFreq[i] > tempCharFreq[i]) { + isUniversal = false; + break; + } + } + if (isUniversal) { + universalWords.add(word); + } + Arrays.fill(tempCharFreq, 0); + } + + return universalWords; + } +} diff --git a/tests/501-1000/916. word-subsets/sol.kt b/tests/501-1000/916. word-subsets/sol.kt new file mode 100644 index 00000000..1a68cc9b --- /dev/null +++ b/tests/501-1000/916. word-subsets/sol.kt @@ -0,0 +1,37 @@ +class Solution { + fun wordSubsets(words1: Array, words2: Array): List { + val maxCharFreq = IntArray(26) + val tempCharFreq = IntArray(26) + + for (word in words2) { + for (ch in word) { + tempCharFreq[ch - 'a']++ + } + for (i in 0..25) { + maxCharFreq[i] = maxOf(maxCharFreq[i], tempCharFreq[i]) + } + tempCharFreq.fill(0) + } + + val universalWords = mutableListOf() + + for (word in words1) { + for (ch in word) { + tempCharFreq[ch - 'a']++ + } + var isUniversal = true + for (i in 0..25) { + if (maxCharFreq[i] > tempCharFreq[i]) { + isUniversal = false + break + } + } + if (isUniversal) { + universalWords.add(word) + } + tempCharFreq.fill(0) + } + + return universalWords + } +} diff --git a/tests/501-1000/916. word-subsets/sol.py b/tests/501-1000/916. word-subsets/sol.py new file mode 100644 index 00000000..e4115f57 --- /dev/null +++ b/tests/501-1000/916. word-subsets/sol.py @@ -0,0 +1,27 @@ +class Solution: + def wordSubsets(self, words1: List[str], words2: List[str]) -> List[str]: + maxCharFreq = [0] * 26 + tempCharFreq = [0] * 26 + + for word in words2: + for ch in word: + tempCharFreq[ord(ch) - ord("a")] += 1 + for i in range(26): + maxCharFreq[i] = max(maxCharFreq[i], tempCharFreq[i]) + tempCharFreq = [0] * 26 + + universalWords = [] + + for word in words1: + for ch in word: + tempCharFreq[ord(ch) - ord("a")] += 1 + isUniversal = True + for i in range(26): + if maxCharFreq[i] > tempCharFreq[i]: + isUniversal = False + break + if isUniversal: + universalWords.append(word) + tempCharFreq = [0] * 26 + + return universalWords diff --git a/tests/501-1000/916. word-subsets/sol.py2 b/tests/501-1000/916. word-subsets/sol.py2 new file mode 100644 index 00000000..9ef7cc01 --- /dev/null +++ b/tests/501-1000/916. word-subsets/sol.py2 @@ -0,0 +1,32 @@ +class Solution(object): + def wordSubsets(self, words1, words2): + """ + :type words1: List[str] + :type words2: List[str] + :rtype: List[str] + """ + maxCharFreq = [0] * 26 + tempCharFreq = [0] * 26 + + for word in words2: + for ch in word: + tempCharFreq[ord(ch) - ord('a')] += 1 + for i in range(26): + maxCharFreq[i] = max(maxCharFreq[i], tempCharFreq[i]) + tempCharFreq = [0] * 26 + + universalWords = [] + + for word in words1: + for ch in word: + tempCharFreq[ord(ch) - ord('a')] += 1 + isUniversal = True + for i in range(26): + if maxCharFreq[i] > tempCharFreq[i]: + isUniversal = False + break + if isUniversal: + universalWords.append(word) + tempCharFreq = [0] * 26 + + return universalWords diff --git a/tests/501-1000/916. word-subsets/sol.rb b/tests/501-1000/916. word-subsets/sol.rb new file mode 100644 index 00000000..b081831c --- /dev/null +++ b/tests/501-1000/916. word-subsets/sol.rb @@ -0,0 +1,36 @@ +# @param {String[]} words1 +# @param {String[]} words2 +# @return {String[]} +def word_subsets(words1, words2) + max_char_freq = Array.new(26, 0) + temp_char_freq = Array.new(26, 0) + + words2.each do |word| + word.each_char do |ch| + temp_char_freq[ch.ord - 'a'.ord] += 1 + end + (0...26).each do |i| + max_char_freq[i] = [max_char_freq[i], temp_char_freq[i]].max + end + temp_char_freq = Array.new(26, 0) + end + + universal_words = [] + + words1.each do |word| + word.each_char do |ch| + temp_char_freq[ch.ord - 'a'.ord] += 1 + end + is_universal = true + (0...26).each do |i| + if max_char_freq[i] > temp_char_freq[i] + is_universal = false + break + end + end + universal_words << word if is_universal + temp_char_freq = Array.new(26, 0) + end + + universal_words +end diff --git a/tests/501-1000/916. word-subsets/sol.rs b/tests/501-1000/916. word-subsets/sol.rs new file mode 100644 index 00000000..166c5fd0 --- /dev/null +++ b/tests/501-1000/916. word-subsets/sol.rs @@ -0,0 +1,37 @@ +impl Solution { + pub fn word_subsets(words1: Vec, words2: Vec) -> Vec { + let mut max_char_freq = vec![0; 26]; + let mut temp_char_freq = vec![0; 26]; + + for word in &words2 { + for ch in word.chars() { + temp_char_freq[(ch as u8 - b'a') as usize] += 1; + } + for i in 0..26 { + max_char_freq[i] = max_char_freq[i].max(temp_char_freq[i]); + } + temp_char_freq = vec![0; 26]; + } + + let mut universal_words = Vec::new(); + + for word in &words1 { + for ch in word.chars() { + temp_char_freq[(ch as u8 - b'a') as usize] += 1; + } + let mut is_universal = true; + for i in 0..26 { + if max_char_freq[i] > temp_char_freq[i] { + is_universal = false; + break; + } + } + if is_universal { + universal_words.push(word.clone()); + } + temp_char_freq = vec![0; 26]; + } + + universal_words + } +} diff --git a/tests/501-1000/916. word-subsets/sol.swift b/tests/501-1000/916. word-subsets/sol.swift new file mode 100644 index 00000000..46695fac --- /dev/null +++ b/tests/501-1000/916. word-subsets/sol.swift @@ -0,0 +1,37 @@ +class Solution { + func wordSubsets(_ words1: [String], _ words2: [String]) -> [String] { + var maxCharFreq = Array(repeating: 0, count: 26) + var tempCharFreq = Array(repeating: 0, count: 26) + + for word in words2 { + for ch in word { + tempCharFreq[Int(ch.asciiValue! - Character("a").asciiValue!)] += 1 + } + for i in 0..<26 { + maxCharFreq[i] = max(maxCharFreq[i], tempCharFreq[i]) + } + tempCharFreq = Array(repeating: 0, count: 26) + } + + var universalWords: [String] = [] + + for word in words1 { + for ch in word { + tempCharFreq[Int(ch.asciiValue! - Character("a").asciiValue!)] += 1 + } + var isUniversal = true + for i in 0..<26 { + if maxCharFreq[i] > tempCharFreq[i] { + isUniversal = false + break + } + } + if isUniversal { + universalWords.append(word) + } + tempCharFreq = Array(repeating: 0, count: 26) + } + + return universalWords + } +} diff --git a/tests/501-1000/916. word-subsets/sol.ts b/tests/501-1000/916. word-subsets/sol.ts new file mode 100644 index 00000000..58d17b75 --- /dev/null +++ b/tests/501-1000/916. word-subsets/sol.ts @@ -0,0 +1,35 @@ +function wordSubsets(words1: string[], words2: string[]): string[] { + const maxCharFreq: number[] = new Array(26).fill(0); + let tempCharFreq: number[] = new Array(26).fill(0); + + for (const word of words2) { + for (const ch of word) { + tempCharFreq[ch.charCodeAt(0) - "a".charCodeAt(0)]++; + } + for (let i = 0; i < 26; i++) { + maxCharFreq[i] = Math.max(maxCharFreq[i], tempCharFreq[i]); + } + tempCharFreq = new Array(26).fill(0); + } + + const universalWords: string[] = []; + + for (const word of words1) { + for (const ch of word) { + tempCharFreq[ch.charCodeAt(0) - "a".charCodeAt(0)]++; + } + let isUniversal = true; + for (let i = 0; i < 26; i++) { + if (maxCharFreq[i] > tempCharFreq[i]) { + isUniversal = false; + break; + } + } + if (isUniversal) { + universalWords.push(word); + } + tempCharFreq = new Array(26).fill(0); + } + + return universalWords; +} diff --git a/tests/501-1000/917. reverse-only-letters/manifest.yaml b/tests/501-1000/917. reverse-only-letters/manifest.yaml new file mode 100644 index 00000000..c7305976 --- /dev/null +++ b/tests/501-1000/917. reverse-only-letters/manifest.yaml @@ -0,0 +1,157 @@ +entry: + id: 917 + title: reverse-only-letters + params: + s: + type: string + call: + cpp: "Solution().reverseOnlyLetters({s})" + rust: "Solution::reverse_only_letters({s})" + python3: "Solution().reverseOnlyLetters({s})" + python2: "Solution().reverseOnlyLetters({s})" + ruby: "reverse_only_letters({s})" + java: "new Solution().reverseOnlyLetters({s})" + csharp: "new Solution().ReverseOnlyLetters({s})" + kotlin: "Solution().reverseOnlyLetters({s})" + go: "reverseOnlyLetters({s})" + dart: "Solution().reverseOnlyLetters({s})" + swift: "Solution().reverseOnlyLetters({s})" + typescript: "reverseOnlyLetters({s})" + +judge: + type: "exact" + +limits: + time_ms: 1000 + memory_mb: 256 + +oracle: + python3: + call: "Checker().reverseOnlyLetters(s, {result})" + checker: | + class Checker: + def reverseOnlyLetters(self, s, result): + if not isinstance(result, str): + return False + letters = [ch for ch in s if ch.isalpha()] + expected = [] + idx = len(letters) - 1 + for ch in s: + if ch.isalpha(): + expected.append(letters[idx]) + idx -= 1 + else: + expected.append(ch) + return ''.join(expected) == result + +seed: 917 + +tests: + - name: example-1 + in: + s: "ab-cd" + - name: example-2 + in: + s: "a-bC-dEf-ghIj" + - name: example-3 + in: + s: "Test1ng-Leet=code-Q!" + - name: single-letter + in: + s: "a" + - name: single-digit + in: + s: "1a" + - name: two-letters + in: + s: "ab" + - name: letter-digit + in: + s: "a1" + - name: dash-letters + in: + s: "-A" + - name: all-nonletters + in: + s: "7_28]" + - name: all-upper + in: + s: "ABC" + - name: all-lower + in: + s: "abc" + - name: mixed-short-1 + in: + s: "a-b-c-d" + - name: mixed-short-2 + in: + s: "Aa" + - name: mixed-short-3 + in: + s: "aA" + - name: punctuation-prefix + in: + s: "!@#abc" + - name: punctuation-infix + in: + s: "a---b" + - name: digits-mix + in: + s: "abc123xyz" + - name: digits-mix-2 + in: + s: "123abc456" + - name: trailing-punct + in: + s: "a-bC-dEf-ghIj-" + - name: repeated-letters + in: + s: "QwErTy" + - name: hyphenated + in: + s: "a-bC-dEf-ghIj-123" + - name: symmetric-1 + in: + s: "xYz" + - name: symmetric-2 + in: + s: "A0B1C2" + - name: symmetric-3 + in: + s: "z9Y8x7" + - name: long-letters-1 + in: + s: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + - name: long-letters-2 + in: + s: "aBcDeFgHiJkLmNoPqRsTuVwXyZ" + - name: mixed-1 + in: + s: "1a2b3c4d5e" + - name: mixed-2 + in: + s: "a1b2c3d4" + - name: mixed-3 + in: + s: "-a-b-" + - name: mixed-4 + in: + s: "!abc!" + - name: mixed-5 + in: + s: "Mno-pqr" + - name: mixed-6 + in: + s: "a-b-c-D-E-F" + - name: long-boundary-1 + in: + s: "abcdefghij1234567890!@#klmnopqrstuvwx" + - name: long-boundary-2 + in: + s: "zyxwvutsrqponmlkjihgfedcba9876543210" + - name: long-boundary-3 + in: + s: "TheQuickBrownFoxJumpsOverTheLazyDog" + - name: long-boundary-4 + in: + s: "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" diff --git a/tests/501-1000/917. reverse-only-letters/sol.cpp b/tests/501-1000/917. reverse-only-letters/sol.cpp new file mode 100644 index 00000000..8c53b0f4 --- /dev/null +++ b/tests/501-1000/917. reverse-only-letters/sol.cpp @@ -0,0 +1,24 @@ +class Solution { +public: + string reverseOnlyLetters(string s) { + int start = 0; + int end = s.length() - 1; + while (true) { + if (start >= end) { + break; + } + + if (isalpha(s[start]) && isalpha(s[end])) { + swap(s[start], s[end]); + start++; + end--; + } else if (!isalpha(s[start])) { + start++; + } else { + end--; + } + } + + return s; + } +}; diff --git a/tests/501-1000/917. reverse-only-letters/sol.cs b/tests/501-1000/917. reverse-only-letters/sol.cs new file mode 100644 index 00000000..9468fb41 --- /dev/null +++ b/tests/501-1000/917. reverse-only-letters/sol.cs @@ -0,0 +1,26 @@ +public class Solution { + public string ReverseOnlyLetters(string s) { + char[] chars = s.ToCharArray(); + int start = 0; + int end = chars.Length - 1; + while (true) { + if (start >= end) { + break; + } + + if (char.IsLetter(chars[start]) && char.IsLetter(chars[end])) { + char temp = chars[start]; + chars[start] = chars[end]; + chars[end] = temp; + start++; + end--; + } else if (!char.IsLetter(chars[start])) { + start++; + } else { + end--; + } + } + + return new string(chars); + } +} diff --git a/tests/501-1000/917. reverse-only-letters/sol.dart b/tests/501-1000/917. reverse-only-letters/sol.dart new file mode 100644 index 00000000..7b3b1c8d --- /dev/null +++ b/tests/501-1000/917. reverse-only-letters/sol.dart @@ -0,0 +1,29 @@ +class Solution { + String reverseOnlyLetters(String s) { + List chars = s.split(''); + int start = 0; + int end = chars.length - 1; + while (true) { + if (start >= end) { + break; + } + + bool startIsLetter = RegExp(r'[a-zA-Z]').hasMatch(chars[start]); + bool endIsLetter = RegExp(r'[a-zA-Z]').hasMatch(chars[end]); + + if (startIsLetter && endIsLetter) { + String temp = chars[start]; + chars[start] = chars[end]; + chars[end] = temp; + start++; + end--; + } else if (!startIsLetter) { + start++; + } else { + end--; + } + } + + return chars.join(''); + } +} diff --git a/tests/501-1000/917. reverse-only-letters/sol.go b/tests/501-1000/917. reverse-only-letters/sol.go new file mode 100644 index 00000000..dec7b812 --- /dev/null +++ b/tests/501-1000/917. reverse-only-letters/sol.go @@ -0,0 +1,25 @@ +func reverseOnlyLetters(s string) string { + chars := []rune(s) + start := 0 + end := len(chars) - 1 + for { + if start >= end { + break + } + + startIsLetter := (chars[start] >= 'a' && chars[start] <= 'z') || (chars[start] >= 'A' && chars[start] <= 'Z') + endIsLetter := (chars[end] >= 'a' && chars[end] <= 'z') || (chars[end] >= 'A' && chars[end] <= 'Z') + + if startIsLetter && endIsLetter { + chars[start], chars[end] = chars[end], chars[start] + start++ + end-- + } else if !startIsLetter { + start++ + } else { + end-- + } + } + + return string(chars) +} diff --git a/tests/501-1000/917. reverse-only-letters/sol.java b/tests/501-1000/917. reverse-only-letters/sol.java new file mode 100644 index 00000000..1a317db1 --- /dev/null +++ b/tests/501-1000/917. reverse-only-letters/sol.java @@ -0,0 +1,26 @@ +class Solution { + public String reverseOnlyLetters(String s) { + char[] chars = s.toCharArray(); + int start = 0; + int end = chars.length - 1; + while (true) { + if (start >= end) { + break; + } + + if (Character.isLetter(chars[start]) && Character.isLetter(chars[end])) { + char temp = chars[start]; + chars[start] = chars[end]; + chars[end] = temp; + start++; + end--; + } else if (!Character.isLetter(chars[start])) { + start++; + } else { + end--; + } + } + + return new String(chars); + } +} diff --git a/tests/501-1000/917. reverse-only-letters/sol.kt b/tests/501-1000/917. reverse-only-letters/sol.kt new file mode 100644 index 00000000..ad38e5f9 --- /dev/null +++ b/tests/501-1000/917. reverse-only-letters/sol.kt @@ -0,0 +1,26 @@ +class Solution { + fun reverseOnlyLetters(s: String): String { + val chars = s.toCharArray() + var start = 0 + var end = chars.size - 1 + while (true) { + if (start >= end) { + break + } + + if (chars[start].isLetter() && chars[end].isLetter()) { + val temp = chars[start] + chars[start] = chars[end] + chars[end] = temp + start++ + end-- + } else if (!chars[start].isLetter()) { + start++ + } else { + end-- + } + } + + return String(chars) + } +} diff --git a/tests/501-1000/917. reverse-only-letters/sol.py b/tests/501-1000/917. reverse-only-letters/sol.py new file mode 100644 index 00000000..dbbb0242 --- /dev/null +++ b/tests/501-1000/917. reverse-only-letters/sol.py @@ -0,0 +1,21 @@ +class Solution: + def reverseOnlyLetters(self, s: str) -> str: + start = 0 + end = len(s) - 1 + s = list(s) + while True: + if start >= end: + break + + if s[start].isalpha() and s[end].isalpha(): + s[start], s[end] = s[end], s[start] + start += 1 + end -= 1 + + elif not s[start].isalpha(): + start += 1 + + else: + end -= 1 + + return "".join(s) diff --git a/tests/501-1000/917. reverse-only-letters/sol.py2 b/tests/501-1000/917. reverse-only-letters/sol.py2 new file mode 100644 index 00000000..098c6362 --- /dev/null +++ b/tests/501-1000/917. reverse-only-letters/sol.py2 @@ -0,0 +1,25 @@ +class Solution(object): + def reverseOnlyLetters(self, s): + """ + :type s: str + :rtype: str + """ + start = 0 + end = len(s) - 1 + s = list(s) + while True: + if start >= end: + break + + if s[start].isalpha() and s[end].isalpha(): + s[start], s[end] = s[end], s[start] + start += 1 + end -= 1 + + elif not s[start].isalpha(): + start += 1 + + else: + end -= 1 + + return ''.join(s) diff --git a/tests/501-1000/917. reverse-only-letters/sol.rb b/tests/501-1000/917. reverse-only-letters/sol.rb new file mode 100644 index 00000000..24ca8bd8 --- /dev/null +++ b/tests/501-1000/917. reverse-only-letters/sol.rb @@ -0,0 +1,24 @@ +# @param {String} s +# @return {String} +def reverse_only_letters(s) + chars = s.chars + start = 0 + end_index = chars.length - 1 + while true + if start >= end_index + break + end + + if chars[start] =~ /[a-zA-Z]/ && chars[end_index] =~ /[a-zA-Z]/ + chars[start], chars[end_index] = chars[end_index], chars[start] + start += 1 + end_index -= 1 + elsif !(chars[start] =~ /[a-zA-Z]/) + start += 1 + else + end_index -= 1 + end + end + + chars.join +end diff --git a/tests/501-1000/917. reverse-only-letters/sol.rs b/tests/501-1000/917. reverse-only-letters/sol.rs new file mode 100644 index 00000000..9027cda7 --- /dev/null +++ b/tests/501-1000/917. reverse-only-letters/sol.rs @@ -0,0 +1,27 @@ +impl Solution { + pub fn reverse_only_letters(s: String) -> String { + let mut chars: Vec = s.chars().collect(); + let mut start: i32 = 0; + let mut end: i32 = chars.len() as i32 - 1; + loop { + if start >= end { + break; + } + + let start_is_letter = chars[start as usize].is_alphabetic(); + let end_is_letter = chars[end as usize].is_alphabetic(); + + if start_is_letter && end_is_letter { + chars.swap(start as usize, end as usize); + start += 1; + end -= 1; + } else if !start_is_letter { + start += 1; + } else { + end -= 1; + } + } + + chars.into_iter().collect() + } +} diff --git a/tests/501-1000/917. reverse-only-letters/sol.swift b/tests/501-1000/917. reverse-only-letters/sol.swift new file mode 100644 index 00000000..f4b3a421 --- /dev/null +++ b/tests/501-1000/917. reverse-only-letters/sol.swift @@ -0,0 +1,24 @@ +class Solution { + func reverseOnlyLetters(_ s: String) -> String { + var chars = Array(s) + var start = 0 + var end = chars.count - 1 + while true { + if start >= end { + break + } + + if chars[start].isLetter && chars[end].isLetter { + chars.swapAt(start, end) + start += 1 + end -= 1 + } else if !chars[start].isLetter { + start += 1 + } else { + end -= 1 + } + } + + return String(chars) + } +} diff --git a/tests/501-1000/917. reverse-only-letters/sol.ts b/tests/501-1000/917. reverse-only-letters/sol.ts new file mode 100644 index 00000000..66ff04e3 --- /dev/null +++ b/tests/501-1000/917. reverse-only-letters/sol.ts @@ -0,0 +1,27 @@ +function reverseOnlyLetters(s: string): string { + const chars = s.split(""); + let start = 0; + let end = chars.length - 1; + while (true) { + if (start >= end) { + break; + } + + const startIsLetter = /[a-zA-Z]/.test(chars[start]); + const endIsLetter = /[a-zA-Z]/.test(chars[end]); + + if (startIsLetter && endIsLetter) { + const temp = chars[start]; + chars[start] = chars[end]; + chars[end] = temp; + start++; + end--; + } else if (!startIsLetter) { + start++; + } else { + end--; + } + } + + return chars.join(""); +} diff --git a/tests/501-1000/918. maximum-sum-circular-subarray/manifest.yaml b/tests/501-1000/918. maximum-sum-circular-subarray/manifest.yaml new file mode 100644 index 00000000..200a2333 --- /dev/null +++ b/tests/501-1000/918. maximum-sum-circular-subarray/manifest.yaml @@ -0,0 +1,308 @@ +entry: + id: 918 + title: maximum-sum-circular-subarray + params: + nums: + type: array + items: + type: int + call: + cpp: "Solution().maxSubarraySumCircular({nums})" + rust: "Solution::max_subarray_sum_circular({nums})" + python3: "Solution().maxSubarraySumCircular({nums})" + python2: "Solution().maxSubarraySumCircular({nums})" + ruby: "max_subarray_sum_circular({nums})" + java: "new Solution().maxSubarraySumCircular({nums})" + csharp: "new Solution().MaxSubarraySumCircular({nums})" + kotlin: "Solution().maxSubarraySumCircular({nums})" + go: "maxSubarraySumCircular({nums})" + dart: "Solution().maxSubarraySumCircular({nums})" + swift: "Solution().maxSubarraySumCircular({nums})" + typescript: "maxSubarraySumCircular({nums})" + +judge: + type: "exact" + +limits: + time_ms: 1000 + memory_mb: 256 + +oracle: + python3: + call: "Checker().maxSubarraySumCircular(nums, {result})" + checker: | + class Checker: + def maxSubarraySumCircular(self, nums, result): + if not isinstance(result, int): + return False + total = nums[0] + max_sum = curr_max = nums[0] + min_sum = curr_min = nums[0] + for x in nums[1:]: + curr_max = max(curr_max + x, x) + max_sum = max(max_sum, curr_max) + curr_min = min(curr_min + x, x) + min_sum = min(min_sum, curr_min) + total += x + circular = total - min_sum + if circular == 0: + expected = max_sum + else: + expected = max(max_sum, circular) + return result == expected + +seed: 918 + +tests: + - name: example-1 + in: + nums: [1, -2, 3, -2] + out: 3 + - name: example-2 + in: + nums: [5, -3, 5] + out: 10 + - name: example-3 + in: + nums: [-3, -2, -3] + out: -2 + - name: single-positive + in: + nums: [7] + out: 7 + - name: single-negative + in: + nums: [-7] + out: -7 + - name: two-positive + in: + nums: [1, 2] + out: 3 + - name: two-negative + in: + nums: [-1, -2] + out: -1 + - name: wrap-better-1 + in: + nums: [3, -1, 2, -1] + out: 4 + - name: wrap-better-2 + in: + nums: [3, -2, 2, -3] + out: 3 + - name: wrap-better-3 + in: + nums: [8, -1, -3, 8] + out: 16 + - name: wrap-better-4 + in: + nums: [9, -4, -7, 9] + out: 18 + - name: all-zero + in: + nums: [0, 0, 0, 0] + out: 0 + - name: mixed-1 + in: + nums: [1, -2, 3, -2, 5] + out: 7 + - name: mixed-2 + in: + nums: [2, -2, 2, 7, 8, 0] + out: 19 + - name: mixed-3 + in: + nums: [1, -2, 3, -2, 3, -2] + out: 4 + - name: mixed-4 + in: + nums: [4, -1, 2, 1] + out: 7 + - name: mixed-5 + in: + nums: [-2, 4, -5, 4, -5, 9, 4] + out: 15 + - name: mixed-6 + in: + nums: [5, -2, 3, 4] + out: 12 + - name: mixed-7 + in: + nums: [2, 2, 2] + out: 6 + - name: mixed-8 + in: + nums: [2, -1, 2, -1, 2, -1, 2] + out: 6 + - name: mixed-9 + in: + nums: [-1, 4, -6, 7, -2, 3] + out: 11 + - name: alternating-1 + in: + nums: [10, -12, 11, -1, 12, -13, 14] + out: 34 + - name: alternating-2 + in: + nums: [-5, 4, -1, 4, -1, 4, -5] + out: 10 + - name: edge-1 + in: + nums: [30000, -30000, 30000] + out: 60000 + - name: edge-2 + in: + nums: [-30000, 30000, -30000] + out: 30000 + - name: edge-3 + in: + nums: [30000, 30000, -30000, 30000] + out: 90000 + - name: edge-4 + in: + nums: [-1, -2, -3, -4, -5] + out: -1 + - name: edge-5 + in: + nums: [100, -1, -2, -3, 100] + out: 200 + - name: edge-6 + in: + nums: [8, -8, 8, -8, 8, -8, 8, -8] + out: 8 + - name: edge-7 + in: + nums: [6, -2, 5, -1, 6] + out: 16 + - name: edge-8 + in: + nums: [9, -1, -1, -1, 9] + out: 18 + - name: large-all-positive + in: + nums: + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + out: 50 + - name: large-all-negative + in: + nums: + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + - -1 + out: -1 + - name: large-wrap + in: + nums: [5, -3, 5, -3, 5, -3, 5, -3, 5, -3] + out: 13 + - name: boundary-1 + in: + nums: [30000, 30000, 30000, -30000, -30000] + out: 90000 + - name: boundary-2 + in: + nums: [-30000, -30000, 30000, 30000, 30000] + out: 90000 + - name: boundary-3 + in: + nums: [1, -1, 1, -1, 1, -1, 1, -1, 1] + out: 2 + - name: boundary-4 + in: + nums: [4, -5, 6, -7, 8, -9, 10] + out: 16 diff --git a/tests/501-1000/918. maximum-sum-circular-subarray/sol.cpp b/tests/501-1000/918. maximum-sum-circular-subarray/sol.cpp new file mode 100644 index 00000000..82ffd181 --- /dev/null +++ b/tests/501-1000/918. maximum-sum-circular-subarray/sol.cpp @@ -0,0 +1,28 @@ +class Solution { +public: + int maxSubarraySumCircular(vector& nums) { + int maxSum = nums[0]; + int minSum = nums[0]; + int currMaxSum = nums[0]; + int currMinSum = nums[0]; + int totalSum = nums[0]; + + for (int i = 1; i < nums.size(); i++) { + currMaxSum = max(currMaxSum + nums[i], nums[i]); + maxSum = max(maxSum, currMaxSum); + + currMinSum = min(currMinSum + nums[i], nums[i]); + minSum = min(minSum, currMinSum); + + totalSum += nums[i]; + } + + int circularSum = totalSum - minSum; + + if (circularSum == 0) { + return maxSum; + } + + return max(maxSum, circularSum); + } +}; diff --git a/tests/501-1000/918. maximum-sum-circular-subarray/sol.cs b/tests/501-1000/918. maximum-sum-circular-subarray/sol.cs new file mode 100644 index 00000000..96a67d47 --- /dev/null +++ b/tests/501-1000/918. maximum-sum-circular-subarray/sol.cs @@ -0,0 +1,27 @@ +public class Solution { + public int MaxSubarraySumCircular(int[] nums) { + int maxSum = nums[0]; + int minSum = nums[0]; + int currMaxSum = nums[0]; + int currMinSum = nums[0]; + int totalSum = nums[0]; + + for (int i = 1; i < nums.Length; i++) { + currMaxSum = Math.Max(currMaxSum + nums[i], nums[i]); + maxSum = Math.Max(maxSum, currMaxSum); + + currMinSum = Math.Min(currMinSum + nums[i], nums[i]); + minSum = Math.Min(minSum, currMinSum); + + totalSum += nums[i]; + } + + int circularSum = totalSum - minSum; + + if (circularSum == 0) { + return maxSum; + } + + return Math.Max(maxSum, circularSum); + } +} diff --git a/tests/501-1000/918. maximum-sum-circular-subarray/sol.dart b/tests/501-1000/918. maximum-sum-circular-subarray/sol.dart new file mode 100644 index 00000000..0c9e988c --- /dev/null +++ b/tests/501-1000/918. maximum-sum-circular-subarray/sol.dart @@ -0,0 +1,27 @@ +class Solution { + int maxSubarraySumCircular(List nums) { + int maxSum = nums[0]; + int minSum = nums[0]; + int currMaxSum = nums[0]; + int currMinSum = nums[0]; + int totalSum = nums[0]; + + for (int i = 1; i < nums.length; i++) { + currMaxSum = (currMaxSum + nums[i] > nums[i]) ? currMaxSum + nums[i] : nums[i]; + maxSum = (currMaxSum > maxSum) ? currMaxSum : maxSum; + + currMinSum = (currMinSum + nums[i] < nums[i]) ? currMinSum + nums[i] : nums[i]; + minSum = (currMinSum < minSum) ? currMinSum : minSum; + + totalSum += nums[i]; + } + + int circularSum = totalSum - minSum; + + if (circularSum == 0) { + return maxSum; + } + + return (maxSum > circularSum) ? maxSum : circularSum; + } +} diff --git a/tests/501-1000/918. maximum-sum-circular-subarray/sol.go b/tests/501-1000/918. maximum-sum-circular-subarray/sol.go new file mode 100644 index 00000000..47eab9a8 --- /dev/null +++ b/tests/501-1000/918. maximum-sum-circular-subarray/sol.go @@ -0,0 +1,40 @@ +func maxSubarraySumCircular(nums []int) int { + maxSum := nums[0] + minSum := nums[0] + currMaxSum := nums[0] + currMinSum := nums[0] + totalSum := nums[0] + + for i := 1; i < len(nums); i++ { + if currMaxSum + nums[i] > nums[i] { + currMaxSum = currMaxSum + nums[i] + } else { + currMaxSum = nums[i] + } + if currMaxSum > maxSum { + maxSum = currMaxSum + } + + if currMinSum + nums[i] < nums[i] { + currMinSum = currMinSum + nums[i] + } else { + currMinSum = nums[i] + } + if currMinSum < minSum { + minSum = currMinSum + } + + totalSum += nums[i] + } + + circularSum := totalSum - minSum + + if circularSum == 0 { + return maxSum + } + + if maxSum > circularSum { + return maxSum + } + return circularSum +} diff --git a/tests/501-1000/918. maximum-sum-circular-subarray/sol.java b/tests/501-1000/918. maximum-sum-circular-subarray/sol.java new file mode 100644 index 00000000..aa89b9a5 --- /dev/null +++ b/tests/501-1000/918. maximum-sum-circular-subarray/sol.java @@ -0,0 +1,27 @@ +class Solution { + public int maxSubarraySumCircular(int[] nums) { + int maxSum = nums[0]; + int minSum = nums[0]; + int currMaxSum = nums[0]; + int currMinSum = nums[0]; + int totalSum = nums[0]; + + for (int i = 1; i < nums.length; i++) { + currMaxSum = Math.max(currMaxSum + nums[i], nums[i]); + maxSum = Math.max(maxSum, currMaxSum); + + currMinSum = Math.min(currMinSum + nums[i], nums[i]); + minSum = Math.min(minSum, currMinSum); + + totalSum += nums[i]; + } + + int circularSum = totalSum - minSum; + + if (circularSum == 0) { + return maxSum; + } + + return Math.max(maxSum, circularSum); + } +} diff --git a/tests/501-1000/918. maximum-sum-circular-subarray/sol.kt b/tests/501-1000/918. maximum-sum-circular-subarray/sol.kt new file mode 100644 index 00000000..21d8a0ee --- /dev/null +++ b/tests/501-1000/918. maximum-sum-circular-subarray/sol.kt @@ -0,0 +1,27 @@ +class Solution { + fun maxSubarraySumCircular(nums: IntArray): Int { + var maxSum = nums[0] + var minSum = nums[0] + var currMaxSum = nums[0] + var currMinSum = nums[0] + var totalSum = nums[0] + + for (i in 1 until nums.size) { + currMaxSum = maxOf(currMaxSum + nums[i], nums[i]) + maxSum = maxOf(maxSum, currMaxSum) + + currMinSum = minOf(currMinSum + nums[i], nums[i]) + minSum = minOf(minSum, currMinSum) + + totalSum += nums[i] + } + + val circularSum = totalSum - minSum + + if (circularSum == 0) { + return maxSum + } + + return maxOf(maxSum, circularSum) + } +} diff --git a/tests/501-1000/918. maximum-sum-circular-subarray/sol.py b/tests/501-1000/918. maximum-sum-circular-subarray/sol.py new file mode 100644 index 00000000..0ec7f832 --- /dev/null +++ b/tests/501-1000/918. maximum-sum-circular-subarray/sol.py @@ -0,0 +1,32 @@ +class Solution: + def maxSubarraySumCircular(self, nums: List[int]) -> int: + maxSum = nums[0] + minSum = nums[0] + currMaxSum = nums[0] + currMinSum = nums[0] + totalSum = nums[0] + + for i in range(1, len(nums)): + # Kadane's algorithm for maximum sum + # Either extend previous subarray or start a new one + currMaxSum = max(currMaxSum + nums[i], nums[i]) + maxSum = max(maxSum, currMaxSum) + + # Kadane's algorithm for minimum sum + # Either extend previous subarray or start a new one + currMinSum = min(currMinSum + nums[i], nums[i]) + minSum = min(minSum, currMinSum) + + # Calculate the total sum of all elements + totalSum += nums[i] + + # The circular sum is the total sum minus the minimum subarray sum + circularSum = totalSum - minSum + + # Edge case: if all numbers are negative, then maxSum will be negative + # and circularSum will be 0 (empty subarray), but we need to return the max negative value + if circularSum == 0: + return maxSum + + # Return the maximum of the regular subarray sum and the circular subarray sum + return max(maxSum, circularSum) diff --git a/tests/501-1000/918. maximum-sum-circular-subarray/sol.py2 b/tests/501-1000/918. maximum-sum-circular-subarray/sol.py2 new file mode 100644 index 00000000..faf909c2 --- /dev/null +++ b/tests/501-1000/918. maximum-sum-circular-subarray/sol.py2 @@ -0,0 +1,27 @@ +class Solution(object): + def maxSubarraySumCircular(self, nums): + """ + :type nums: List[int] + :rtype: int + """ + maxSum = nums[0] + minSum = nums[0] + currMaxSum = nums[0] + currMinSum = nums[0] + totalSum = nums[0] + + for i in range(1, len(nums)): + currMaxSum = max(currMaxSum + nums[i], nums[i]) + maxSum = max(maxSum, currMaxSum) + + currMinSum = min(currMinSum + nums[i], nums[i]) + minSum = min(minSum, currMinSum) + + totalSum += nums[i] + + circularSum = totalSum - minSum + + if circularSum == 0: + return maxSum + + return max(maxSum, circularSum) diff --git a/tests/501-1000/918. maximum-sum-circular-subarray/sol.rb b/tests/501-1000/918. maximum-sum-circular-subarray/sol.rb new file mode 100644 index 00000000..fe9eeaff --- /dev/null +++ b/tests/501-1000/918. maximum-sum-circular-subarray/sol.rb @@ -0,0 +1,27 @@ +# @param {Integer[]} nums +# @return {Integer} +def max_subarray_sum_circular(nums) + max_sum = nums[0] + min_sum = nums[0] + curr_max_sum = nums[0] + curr_min_sum = nums[0] + total_sum = nums[0] + + (1...nums.length).each do |i| + curr_max_sum = [curr_max_sum + nums[i], nums[i]].max + max_sum = [max_sum, curr_max_sum].max + + curr_min_sum = [curr_min_sum + nums[i], nums[i]].min + min_sum = [min_sum, curr_min_sum].min + + total_sum += nums[i] + end + + circular_sum = total_sum - min_sum + + if circular_sum == 0 + return max_sum + end + + [max_sum, circular_sum].max +end diff --git a/tests/501-1000/918. maximum-sum-circular-subarray/sol.rs b/tests/501-1000/918. maximum-sum-circular-subarray/sol.rs new file mode 100644 index 00000000..f1212ddf --- /dev/null +++ b/tests/501-1000/918. maximum-sum-circular-subarray/sol.rs @@ -0,0 +1,27 @@ +impl Solution { + pub fn max_subarray_sum_circular(nums: Vec) -> i32 { + let mut max_sum = nums[0]; + let mut min_sum = nums[0]; + let mut curr_max_sum = nums[0]; + let mut curr_min_sum = nums[0]; + let mut total_sum = nums[0]; + + for i in 1..nums.len() { + curr_max_sum = (curr_max_sum + nums[i]).max(nums[i]); + max_sum = max_sum.max(curr_max_sum); + + curr_min_sum = (curr_min_sum + nums[i]).min(nums[i]); + min_sum = min_sum.min(curr_min_sum); + + total_sum += nums[i]; + } + + let circular_sum = total_sum - min_sum; + + if circular_sum == 0 { + return max_sum; + } + + max_sum.max(circular_sum) + } +} diff --git a/tests/501-1000/918. maximum-sum-circular-subarray/sol.swift b/tests/501-1000/918. maximum-sum-circular-subarray/sol.swift new file mode 100644 index 00000000..ee7e7083 --- /dev/null +++ b/tests/501-1000/918. maximum-sum-circular-subarray/sol.swift @@ -0,0 +1,27 @@ +class Solution { + func maxSubarraySumCircular(_ nums: [Int]) -> Int { + var maxSum = nums[0] + var minSum = nums[0] + var currMaxSum = nums[0] + var currMinSum = nums[0] + var totalSum = nums[0] + + for i in 1.. k: + dp[i % 2][j] = (dp[i % 2][j] + dp[(i - 1) % 2][j] * (j - k)) % MOD + return result == dp[goal % 2][n] + +seed: 920 + +tests: + - name: example-1 + in: + n: 3 + goal: 3 + k: 1 + out: 6 + - name: example-2 + in: + n: 2 + goal: 3 + k: 0 + out: 6 + - name: example-3 + in: + n: 2 + goal: 3 + k: 1 + out: 2 + - name: n1-goal2-k0 + in: + n: 1 + goal: 2 + k: 0 + out: 1 + - name: n2-goal2-k0 + in: + n: 2 + goal: 2 + k: 0 + out: 2 + - name: n2-goal2-k1 + in: + n: 2 + goal: 2 + k: 1 + out: 2 + - name: n2-goal4-k0 + in: + n: 2 + goal: 4 + k: 0 + out: 14 + - name: n2-goal4-k1 + in: + n: 2 + goal: 4 + k: 1 + out: 2 + - name: n3-goal3-k0 + in: + n: 3 + goal: 3 + k: 0 + out: 6 + - name: n3-goal3-k2 + in: + n: 3 + goal: 3 + k: 2 + out: 6 + - name: n3-goal4-k1 + in: + n: 3 + goal: 4 + k: 1 + out: 18 + - name: n3-goal4-k2 + in: + n: 3 + goal: 4 + k: 2 + out: 6 + - name: n3-goal5-k1 + in: + n: 3 + goal: 5 + k: 1 + out: 42 + - name: n4-goal4-k1 + in: + n: 4 + goal: 4 + k: 1 + out: 24 + - name: n4-goal5-k1 + in: + n: 4 + goal: 5 + k: 1 + out: 144 + - name: n4-goal5-k2 + in: + n: 4 + goal: 5 + k: 2 + out: 72 + - name: n4-goal6-k2 + in: + n: 4 + goal: 6 + k: 2 + out: 168 + - name: n5-goal5-k0 + in: + n: 5 + goal: 5 + k: 0 + out: 120 + - name: n5-goal6-k1 + in: + n: 5 + goal: 6 + k: 1 + out: 1200 + - name: n5-goal6-k2 + in: + n: 5 + goal: 6 + k: 2 + out: 720 + - name: n5-goal7-k2 + in: + n: 5 + goal: 7 + k: 2 + out: 3000 + - name: n6-goal6-k0 + in: + n: 6 + goal: 6 + k: 0 + out: 720 + - name: n6-goal7-k1 + in: + n: 6 + goal: 7 + k: 1 + out: 10800 + - name: n6-goal7-k2 + in: + n: 6 + goal: 7 + k: 2 + out: 7200 + - name: n7-goal7-k0 + in: + n: 7 + goal: 7 + k: 0 + out: 5040 + - name: n7-goal8-k1 + in: + n: 7 + goal: 8 + k: 1 + out: 105840 + - name: n8-goal8-k0 + in: + n: 8 + goal: 8 + k: 0 + out: 40320 + - name: n8-goal9-k2 + in: + n: 8 + goal: 9 + k: 2 + out: 846720 + - name: n10-goal10-k0 + in: + n: 10 + goal: 10 + k: 0 + out: 3628800 + - name: n10-goal12-k3 + in: + n: 10 + goal: 12 + k: 3 + out: 676505593 + - name: n10-goal20-k0 + in: + n: 10 + goal: 20 + k: 0 + out: 423938817 + - name: n10-goal20-k5 + in: + n: 10 + goal: 20 + k: 5 + out: 993942190 + - name: n20-goal20-k0 + in: + n: 20 + goal: 20 + k: 0 + out: 146326063 + - name: n20-goal25-k3 + in: + n: 20 + goal: 25 + k: 3 + out: 192032929 + - name: n25-goal25-k0 + in: + n: 25 + goal: 25 + k: 0 + out: 440732388 + - name: n30-goal35-k4 + in: + n: 30 + goal: 35 + k: 4 + out: 418810183 + - name: n50-goal50-k0 + in: + n: 50 + goal: 50 + k: 0 + out: 318608048 + - name: n50-goal60-k10 + in: + n: 50 + goal: 60 + k: 10 + out: 145632432 + - name: n100-goal100-k0 + in: + n: 100 + goal: 100 + k: 0 + out: 437918130 + - name: n100-goal100-k99 + in: + n: 100 + goal: 100 + k: 99 + out: 437918130 diff --git a/tests/501-1000/920. number-of-music-playlists/sol.cpp b/tests/501-1000/920. number-of-music-playlists/sol.cpp new file mode 100644 index 00000000..1b27a68d --- /dev/null +++ b/tests/501-1000/920. number-of-music-playlists/sol.cpp @@ -0,0 +1,20 @@ +class Solution { +public: + int numMusicPlaylists(int n, int goal, int k) { + const int MOD = 1000000007; + vector> dp(2, vector(n + 1, 0)); + dp[0][0] = 1; + + for (int i = 1; i <= goal; i++) { + dp[i % 2][0] = 0; + for (int j = 1; j <= min(i, n); j++) { + dp[i % 2][j] = dp[(i - 1) % 2][j - 1] * (n - (j - 1)) % MOD; + if (j > k) { + dp[i % 2][j] = (dp[i % 2][j] + dp[(i - 1) % 2][j] * (j - k)) % MOD; + } + } + } + + return (int)dp[goal % 2][n]; + } +}; diff --git a/tests/501-1000/920. number-of-music-playlists/sol.cs b/tests/501-1000/920. number-of-music-playlists/sol.cs new file mode 100644 index 00000000..01370601 --- /dev/null +++ b/tests/501-1000/920. number-of-music-playlists/sol.cs @@ -0,0 +1,22 @@ +public class Solution { + public int NumMusicPlaylists(int n, int goal, int k) { + const int MOD = 1000000007; + long[][] dp = new long[2][]; + dp[0] = new long[n + 1]; + dp[1] = new long[n + 1]; + dp[0][0] = 1; + + for (int i = 1; i <= goal; i++) { + dp[i % 2][0] = 0; + int limit = Math.Min(i, n); + for (int j = 1; j <= limit; j++) { + dp[i % 2][j] = dp[(i - 1) % 2][j - 1] * (n - (j - 1)) % MOD; + if (j > k) { + dp[i % 2][j] = (dp[i % 2][j] + dp[(i - 1) % 2][j] * (j - k)) % MOD; + } + } + } + + return (int)dp[goal % 2][n]; + } +} diff --git a/tests/501-1000/920. number-of-music-playlists/sol.dart b/tests/501-1000/920. number-of-music-playlists/sol.dart new file mode 100644 index 00000000..83931088 --- /dev/null +++ b/tests/501-1000/920. number-of-music-playlists/sol.dart @@ -0,0 +1,23 @@ +class Solution { + int numMusicPlaylists(int n, int goal, int k) { + const int MOD = 1000000007; + List> dp = [ + List.filled(n + 1, 0), + List.filled(n + 1, 0) + ]; + dp[0][0] = 1; + + for (int i = 1; i <= goal; i++) { + dp[i % 2][0] = 0; + int limit = i < n ? i : n; + for (int j = 1; j <= limit; j++) { + dp[i % 2][j] = (dp[(i - 1) % 2][j - 1] * (n - (j - 1))) % MOD; + if (j > k) { + dp[i % 2][j] = (dp[i % 2][j] + dp[(i - 1) % 2][j] * (j - k)) % MOD; + } + } + } + + return dp[goal % 2][n]; + } +} diff --git a/tests/501-1000/920. number-of-music-playlists/sol.go b/tests/501-1000/920. number-of-music-playlists/sol.go new file mode 100644 index 00000000..d487c431 --- /dev/null +++ b/tests/501-1000/920. number-of-music-playlists/sol.go @@ -0,0 +1,24 @@ +func numMusicPlaylists(n int, goal int, k int) int { + const MOD = 1000000007 + dp := [2][]int{ + make([]int, n+1), + make([]int, n+1), + } + dp[0][0] = 1 + + for i := 1; i <= goal; i++ { + dp[i%2][0] = 0 + limit := i + if n < i { + limit = n + } + for j := 1; j <= limit; j++ { + dp[i%2][j] = dp[(i-1)%2][j-1] * (n - (j - 1)) % MOD + if j > k { + dp[i%2][j] = (dp[i%2][j] + dp[(i-1)%2][j]*(j-k)) % MOD + } + } + } + + return dp[goal%2][n] +} diff --git a/tests/501-1000/920. number-of-music-playlists/sol.java b/tests/501-1000/920. number-of-music-playlists/sol.java new file mode 100644 index 00000000..bc948dae --- /dev/null +++ b/tests/501-1000/920. number-of-music-playlists/sol.java @@ -0,0 +1,19 @@ +class Solution { + public int numMusicPlaylists(int n, int goal, int k) { + final int MOD = 1000000007; + int[][] dp = new int[2][n + 1]; + dp[0][0] = 1; + + for (int i = 1; i <= goal; i++) { + dp[i % 2][0] = 0; + for (int j = 1; j <= Math.min(i, n); j++) { + dp[i % 2][j] = (int)((long)dp[(i - 1) % 2][j - 1] * (n - (j - 1)) % MOD); + if (j > k) { + dp[i % 2][j] = (int)((dp[i % 2][j] + (long)dp[(i - 1) % 2][j] * (j - k)) % MOD); + } + } + } + + return dp[goal % 2][n]; + } +} diff --git a/tests/501-1000/920. number-of-music-playlists/sol.kt b/tests/501-1000/920. number-of-music-playlists/sol.kt new file mode 100644 index 00000000..2b0534f2 --- /dev/null +++ b/tests/501-1000/920. number-of-music-playlists/sol.kt @@ -0,0 +1,19 @@ +class Solution { + fun numMusicPlaylists(n: Int, goal: Int, k: Int): Int { + val MOD = 1000000007 + val dp = Array(2) { IntArray(n + 1) } + dp[0][0] = 1 + + for (i in 1..goal) { + dp[i % 2][0] = 0 + for (j in 1..minOf(i, n)) { + dp[i % 2][j] = ((dp[(i - 1) % 2][j - 1].toLong() * (n - (j - 1))) % MOD).toInt() + if (j > k) { + dp[i % 2][j] = ((dp[i % 2][j] + dp[(i - 1) % 2][j].toLong() * (j - k)) % MOD).toInt() + } + } + } + + return dp[goal % 2][n] + } +} diff --git a/tests/501-1000/920. number-of-music-playlists/sol.py b/tests/501-1000/920. number-of-music-playlists/sol.py new file mode 100644 index 00000000..28a5352c --- /dev/null +++ b/tests/501-1000/920. number-of-music-playlists/sol.py @@ -0,0 +1,14 @@ +class Solution: + def numMusicPlaylists(self, n: int, goal: int, k: int) -> int: + MOD = 10**9 + 7 + dp = [[0 for _ in range(n + 1)] for _ in range(2)] + dp[0][0] = 1 + + for i in range(1, goal + 1): + dp[i % 2][0] = 0 + for j in range(1, min(i, n) + 1): + dp[i % 2][j] = dp[(i - 1) % 2][j - 1] * (n - (j - 1)) % MOD + if j > k: + dp[i % 2][j] = (dp[i % 2][j] + dp[(i - 1) % 2][j] * (j - k)) % MOD + + return dp[goal % 2][n] diff --git a/tests/501-1000/920. number-of-music-playlists/sol.py2 b/tests/501-1000/920. number-of-music-playlists/sol.py2 new file mode 100644 index 00000000..384ad19f --- /dev/null +++ b/tests/501-1000/920. number-of-music-playlists/sol.py2 @@ -0,0 +1,14 @@ +class Solution(object): + def numMusicPlaylists(self, n, goal, k): + MOD = 10**9 + 7 + dp = [[0 for _ in range(n + 1)] for _ in range(2)] + dp[0][0] = 1 + + for i in range(1, goal + 1): + dp[i%2][0] = 0 + for j in range(1, min(i, n) + 1): + dp[i%2][j] = dp[(i - 1)%2][j - 1] * (n - (j - 1)) % MOD + if j > k: + dp[i%2][j] = (dp[i%2][j] + dp[(i - 1)%2][j] * (j - k)) % MOD + + return dp[goal%2][n] diff --git a/tests/501-1000/920. number-of-music-playlists/sol.rb b/tests/501-1000/920. number-of-music-playlists/sol.rb new file mode 100644 index 00000000..8fdfda0c --- /dev/null +++ b/tests/501-1000/920. number-of-music-playlists/sol.rb @@ -0,0 +1,21 @@ +# @param {Integer} n +# @param {Integer} goal +# @param {Integer} k +# @return {Integer} +def num_music_playlists(n, goal, k) + mod = 10**9 + 7 + dp = Array.new(2) { Array.new(n + 1, 0) } + dp[0][0] = 1 + + (1..goal).each do |i| + dp[i % 2][0] = 0 + (1..[i, n].min).each do |j| + dp[i % 2][j] = dp[(i - 1) % 2][j - 1] * (n - (j - 1)) % mod + if j > k + dp[i % 2][j] = (dp[i % 2][j] + dp[(i - 1) % 2][j] * (j - k)) % mod + end + end + end + + dp[goal % 2][n] +end diff --git a/tests/501-1000/920. number-of-music-playlists/sol.rs b/tests/501-1000/920. number-of-music-playlists/sol.rs new file mode 100644 index 00000000..4ea83824 --- /dev/null +++ b/tests/501-1000/920. number-of-music-playlists/sol.rs @@ -0,0 +1,23 @@ +impl Solution { + pub fn num_music_playlists(n: i32, goal: i32, k: i32) -> i32 { + const MOD: i64 = 1000000007; + let n = n as usize; + let goal = goal as usize; + let k = k as usize; + let mut dp = vec![vec![0i64; n + 1]; 2]; + dp[0][0] = 1; + + for i in 1..=goal { + dp[i % 2][0] = 0; + let limit = i.min(n); + for j in 1..=limit { + dp[i % 2][j] = dp[(i - 1) % 2][j - 1] * (n - (j - 1)) as i64 % MOD; + if j > k { + dp[i % 2][j] = (dp[i % 2][j] + dp[(i - 1) % 2][j] * (j - k) as i64) % MOD; + } + } + } + + dp[goal % 2][n] as i32 + } +} diff --git a/tests/501-1000/920. number-of-music-playlists/sol.swift b/tests/501-1000/920. number-of-music-playlists/sol.swift new file mode 100644 index 00000000..bc4b3743 --- /dev/null +++ b/tests/501-1000/920. number-of-music-playlists/sol.swift @@ -0,0 +1,20 @@ +class Solution { + func numMusicPlaylists(_ n: Int, _ goal: Int, _ k: Int) -> Int { + let MOD = 1000000007 + var dp = [[Int]](repeating: [Int](repeating: 0, count: n + 1), count: 2) + dp[0][0] = 1 + + for i in 1...goal { + dp[i % 2][0] = 0 + let limit = min(i, n) + for j in 1...limit { + dp[i % 2][j] = dp[(i - 1) % 2][j - 1] * (n - (j - 1)) % MOD + if j > k { + dp[i % 2][j] = (dp[i % 2][j] + dp[(i - 1) % 2][j] * (j - k)) % MOD + } + } + } + + return dp[goal % 2][n] + } +} diff --git a/tests/501-1000/920. number-of-music-playlists/sol.ts b/tests/501-1000/920. number-of-music-playlists/sol.ts new file mode 100644 index 00000000..fe97c160 --- /dev/null +++ b/tests/501-1000/920. number-of-music-playlists/sol.ts @@ -0,0 +1,18 @@ +function numMusicPlaylists(n: number, goal: number, k: number): number { + const MOD = 1000000007; + const dp: number[][] = [new Array(n + 1).fill(0), new Array(n + 1).fill(0)]; + dp[0][0] = 1; + + for (let i = 1; i <= goal; i++) { + dp[i % 2][0] = 0; + const limit = Math.min(i, n); + for (let j = 1; j <= limit; j++) { + dp[i % 2][j] = (dp[(i - 1) % 2][j - 1] * (n - (j - 1))) % MOD; + if (j > k) { + dp[i % 2][j] = (dp[i % 2][j] + dp[(i - 1) % 2][j] * (j - k)) % MOD; + } + } + } + + return dp[goal % 2][n]; +} diff --git a/tests/501-1000/921. minimum-add-to-make-parentheses-valid/manifest.yaml b/tests/501-1000/921. minimum-add-to-make-parentheses-valid/manifest.yaml new file mode 100644 index 00000000..1f246933 --- /dev/null +++ b/tests/501-1000/921. minimum-add-to-make-parentheses-valid/manifest.yaml @@ -0,0 +1,190 @@ +entry: + id: 921 + title: minimum-add-to-make-parentheses-valid + params: + s: + type: string + call: + cpp: "Solution().minAddToMakeValid({s})" + rust: "Solution::min_add_to_make_valid({s})" + python3: "Solution().minAddToMakeValid({s})" + python2: "Solution().minAddToMakeValid({s})" + ruby: "min_add_to_make_valid({s})" + java: "new Solution().minAddToMakeValid({s})" + csharp: "new Solution().MinAddToMakeValid({s})" + kotlin: "Solution().minAddToMakeValid({s})" + go: "minAddToMakeValid({s})" + dart: "Solution().minAddToMakeValid({s})" + swift: "Solution().minAddToMakeValid({s})" + typescript: "minAddToMakeValid({s})" + +judge: + type: "exact" + +limits: + time_ms: 1000 + memory_mb: 256 + +oracle: + python3: + call: "Checker().minAddToMakeValid(s, {result})" + checker: | + class Checker: + def minAddToMakeValid(self, s, result): + if not isinstance(result, int): + return False + balance = 0 + add = 0 + for ch in s: + if ch == '(': + balance += 1 + else: + if balance == 0: + add += 1 + else: + balance -= 1 + return result == add + balance + +seed: 921 + +tests: + - name: example-1 + in: + s: "())" + out: 1 + - name: example-2 + in: + s: "(((" + out: 3 + - name: single-open + in: + s: "(" + out: 1 + - name: single-close + in: + s: ")" + out: 1 + - name: balanced-pair + in: + s: "()" + out: 0 + - name: nested-balanced + in: + s: "(()())" + out: 0 + - name: extra-close-1 + in: + s: "())(" + out: 2 + - name: extra-open-1 + in: + s: "(((" + out: 3 + - name: extra-open-close + in: + s: "((()))" + out: 0 + - name: alternating-1 + in: + s: ")()(" + out: 2 + - name: alternating-2 + in: + s: "()()()" + out: 0 + - name: alternating-3 + in: + s: ")()()(" + out: 2 + - name: mixed-1 + in: + s: "(())" + out: 0 + - name: mixed-2 + in: + s: ")((())" + out: 2 + - name: mixed-3 + in: + s: "))))((" + out: 6 + - name: mixed-4 + in: + s: "((()())" + out: 1 + - name: mixed-5 + in: + s: "()((())())" + out: 0 + - name: mixed-6 + in: + s: "(((()())))" + out: 0 + - name: mixed-7 + in: + s: "()())(" + out: 2 + - name: mixed-8 + in: + s: "()(()))" + out: 1 + - name: mixed-9 + in: + s: ")()(()()" + out: 2 + - name: mixed-10 + in: + s: "(()()()(" + out: 2 + - name: long-1 + in: + s: "(((((((((((" + out: 11 + - name: long-2 + in: + s: ")))))))))))" + out: 11 + - name: long-3 + in: + s: "()()()()()()()()()" + out: 0 + - name: long-4 + in: + s: "((((()))))" + out: 0 + - name: long-5 + in: + s: "()(((())))((" + out: 2 + - name: long-6 + in: + s: "(((())())())" + out: 0 + - name: long-7 + in: + s: ")((((()))))" + out: 1 + - name: long-8 + in: + s: "(()(()(())))" + out: 0 + - name: boundary-1 + in: + s: "(((((((((((((((((((((((((((((((((((((((((((((((((((" + out: 51 + - name: boundary-2 + in: + s: ")))))))))))))))))))))))))))))))))))))))))))))))))))" + out: 51 + - name: boundary-3 + in: + s: "()())()(()(" + out: 3 + - name: boundary-4 + in: + s: "(()())(()())" + out: 0 + - name: boundary-5 + in: + s: ")(()())(()())" + out: 1 diff --git a/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.cpp b/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.cpp new file mode 100644 index 00000000..17e83e74 --- /dev/null +++ b/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.cpp @@ -0,0 +1,14 @@ +class Solution { +public: + int minAddToMakeValid(string s) { + vector l = {'0'}; + for (char i : s) { + if (l.back() == '(' && i == ')') { + l.pop_back(); + } else { + l.push_back(i); + } + } + return l.size() - 1; + } +}; diff --git a/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.cs b/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.cs new file mode 100644 index 00000000..6c0a02aa --- /dev/null +++ b/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.cs @@ -0,0 +1,13 @@ +public class Solution { + public int MinAddToMakeValid(string s) { + var l = new List { '0' }; + foreach (char i in s) { + if (l[l.Count - 1] == '(' && i == ')') { + l.RemoveAt(l.Count - 1); + } else { + l.Add(i); + } + } + return l.Count - 1; + } +} diff --git a/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.dart b/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.dart new file mode 100644 index 00000000..9c685461 --- /dev/null +++ b/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.dart @@ -0,0 +1,13 @@ +class Solution { + int minAddToMakeValid(String s) { + List l = ['0']; + for (int i = 0; i < s.length; i++) { + if (l.last == '(' && s[i] == ')') { + l.removeLast(); + } else { + l.add(s[i]); + } + } + return l.length - 1; + } +} diff --git a/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.go b/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.go new file mode 100644 index 00000000..4559f5ce --- /dev/null +++ b/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.go @@ -0,0 +1,11 @@ +func minAddToMakeValid(s string) int { + l := []byte{'0'} + for i := 0; i < len(s); i++ { + if l[len(l)-1] == '(' && s[i] == ')' { + l = l[:len(l)-1] + } else { + l = append(l, s[i]) + } + } + return len(l) - 1 +} diff --git a/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.java b/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.java new file mode 100644 index 00000000..fb8edaaa --- /dev/null +++ b/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.java @@ -0,0 +1,14 @@ +class Solution { + public int minAddToMakeValid(String s) { + java.util.Stack l = new java.util.Stack<>(); + l.push('0'); + for (char i : s.toCharArray()) { + if (l.peek() == '(' && i == ')') { + l.pop(); + } else { + l.push(i); + } + } + return l.size() - 1; + } +} diff --git a/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.kt b/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.kt new file mode 100644 index 00000000..364bd300 --- /dev/null +++ b/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.kt @@ -0,0 +1,14 @@ +class Solution { + fun minAddToMakeValid(s: String): Int { + val l = ArrayDeque() + l.addLast('0') + for (i in s) { + if (l.last() == '(' && i == ')') { + l.removeLast() + } else { + l.addLast(i) + } + } + return l.size - 1 + } +} diff --git a/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.py b/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.py new file mode 100644 index 00000000..c51bd530 --- /dev/null +++ b/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.py @@ -0,0 +1,9 @@ +class Solution(object): + def minAddToMakeValid(self, s: str) -> int: + l = [0] + for i in s: + if l[-1] == "(" and i == ")": + l.pop() + else: + l.append(i) + return len(l) - 1 diff --git a/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.py2 b/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.py2 new file mode 100644 index 00000000..d2bd5ca9 --- /dev/null +++ b/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.py2 @@ -0,0 +1,13 @@ +class Solution(object): + def minAddToMakeValid(self, s): + """ + :type s: str + :rtype: int + """ + l = [0] + for i in s: + if l[-1] == '(' and i == ')': + l.pop() + else: + l.append(i) + return len(l) - 1 diff --git a/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.rb b/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.rb new file mode 100644 index 00000000..2034d846 --- /dev/null +++ b/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.rb @@ -0,0 +1,13 @@ +# @param {String} s +# @return {Integer} +def min_add_to_make_valid(s) + l = [0] + s.each_char do |i| + if l[-1] == '(' && i == ')' + l.pop + else + l.push(i) + end + end + l.length - 1 +end diff --git a/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.rs b/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.rs new file mode 100644 index 00000000..9a2e8091 --- /dev/null +++ b/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.rs @@ -0,0 +1,13 @@ +impl Solution { + pub fn min_add_to_make_valid(s: String) -> i32 { + let mut l = vec!['0']; + for i in s.chars() { + if l[l.len() - 1] == '(' && i == ')' { + l.pop(); + } else { + l.push(i); + } + } + (l.len() - 1) as i32 + } +} diff --git a/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.swift b/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.swift new file mode 100644 index 00000000..c484136e --- /dev/null +++ b/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.swift @@ -0,0 +1,13 @@ +class Solution { + func minAddToMakeValid(_ s: String) -> Int { + var l: [Character] = ["0"] + for i in s { + if l.last == "(" && i == ")" { + l.removeLast() + } else { + l.append(i) + } + } + return l.count - 1 + } +} diff --git a/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.ts b/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.ts new file mode 100644 index 00000000..abd1f888 --- /dev/null +++ b/tests/501-1000/921. minimum-add-to-make-parentheses-valid/sol.ts @@ -0,0 +1,11 @@ +function minAddToMakeValid(s: string): number { + const l: string[] = ["0"]; + for (const i of s) { + if (l[l.length - 1] === "(" && i === ")") { + l.pop(); + } else { + l.push(i); + } + } + return l.length - 1; +} diff --git a/tests/501-1000/922. sort-array-by-parity-ii/manifest.yaml b/tests/501-1000/922. sort-array-by-parity-ii/manifest.yaml new file mode 100644 index 00000000..a1eb4e5e --- /dev/null +++ b/tests/501-1000/922. sort-array-by-parity-ii/manifest.yaml @@ -0,0 +1,847 @@ +entry: + id: 922 + title: sort-array-by-parity-ii + params: + nums: + type: array + items: + type: int + call: + cpp: "Solution().sortArrayByParityII({nums})" + rust: "Solution::sort_array_by_parity_ii({nums})" + python3: "Solution().sortArrayByParityII({nums})" + python2: "Solution().sortArrayByParityII({nums})" + ruby: "sort_array_by_parity_ii({nums})" + java: "new Solution().sortArrayByParityII({nums})" + csharp: "new Solution().SortArrayByParityII({nums})" + kotlin: "Solution().sortArrayByParityII({nums})" + go: "sortArrayByParityII({nums})" + dart: "Solution().sortArrayByParityII({nums})" + swift: "Solution().sortArrayByParityII({nums})" + typescript: "sortArrayByParityII({nums})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().sortArrayByParityII(nums, {result})" + checker: | + class Checker: + def sortArrayByParityII(self, nums, result): + if len(nums) != len(result): + return False + if sorted(nums) != sorted(result): + return False + for i, x in enumerate(result): + if (x % 2) != (i % 2): + return False + return True +seed: 922 +tests: + - name: ex1 + in: + nums: [4, 2, 5, 7] + - name: ex2 + in: + nums: [2, 3] + - name: two_pairs + in: + nums: [2, 4, 1, 3] + - name: alternating_small + in: + nums: [1, 0, 3, 2] + - name: already_valid_6 + in: + nums: [0, 1, 2, 3, 4, 5] + - name: swap_needed_6 + in: + nums: [3, 2, 4, 1, 6, 5] + - name: duplicates + in: + nums: [2, 2, 1, 1] + - name: all_small_even_odd_mix + in: + nums: [10, 7, 8, 1, 4, 3] + - name: many_zeros_ones + in: + nums: [0, 1, 0, 1, 0, 1, 0, 1] + - name: max_value_mix + in: + nums: [1000, 999, 998, 997, 996, 995] + - name: reversed_pairs + in: + nums: [9, 8, 7, 6, 5, 4, 3, 2] + - name: clustered + in: + nums: [6, 2, 8, 1, 3, 5] + - name: edge_case_10 + in: + nums: [2, 7, 4, 9, 6, 11, 8, 13, 10, 15] + - name: edge_case_12 + in: + nums: [12, 5, 14, 7, 16, 9, 18, 11, 20, 13, 22, 15] + - name: edge_case_14 + in: + nums: [14, 1, 16, 3, 18, 5, 20, 7, 22, 9, 24, 11, 26, 13] + - name: edge_case_16 + in: + nums: [16, 31, 18, 29, 20, 27, 22, 25, 24, 23, 26, 21, 28, 19, 30, 17] + - name: edge_case_18 + in: + nums: [0, 17, 2, 15, 4, 13, 6, 11, 8, 9, 10, 7, 12, 5, 14, 3, 16, 1] + - name: edge_case_20 + in: + nums: + [ + 20, + 41, + 18, + 39, + 16, + 37, + 14, + 35, + 12, + 33, + 10, + 31, + 8, + 29, + 6, + 27, + 4, + 25, + 2, + 23, + ] + - name: edge_case_22 + in: + nums: + [ + 22, + 1, + 24, + 3, + 26, + 5, + 28, + 7, + 30, + 9, + 32, + 11, + 34, + 13, + 36, + 15, + 38, + 17, + 40, + 19, + 42, + 21, + ] + - name: edge_case_24 + in: + nums: + [ + 24, + 43, + 22, + 41, + 20, + 39, + 18, + 37, + 16, + 35, + 14, + 33, + 12, + 31, + 10, + 29, + 8, + 27, + 6, + 25, + 4, + 23, + 2, + 21, + ] + - name: edge_case_26 + in: + nums: + [ + 26, + 5, + 28, + 7, + 30, + 9, + 32, + 11, + 34, + 13, + 36, + 15, + 38, + 17, + 40, + 19, + 42, + 21, + 44, + 23, + 46, + 25, + 48, + 27, + 50, + 29, + ] + - name: edge_case_28 + in: + nums: + [ + 28, + 51, + 26, + 49, + 24, + 47, + 22, + 45, + 20, + 43, + 18, + 41, + 16, + 39, + 14, + 37, + 12, + 35, + 10, + 33, + 8, + 31, + 6, + 29, + 4, + 27, + 2, + 25, + ] + - name: edge_case_30 + in: + nums: + [ + 30, + 1, + 32, + 3, + 34, + 5, + 36, + 7, + 38, + 9, + 40, + 11, + 42, + 13, + 44, + 15, + 46, + 17, + 48, + 19, + 50, + 21, + 52, + 23, + 54, + 25, + 56, + 27, + 58, + 29, + ] + - name: edge_case_32 + in: + nums: + [ + 32, + 61, + 30, + 59, + 28, + 57, + 26, + 55, + 24, + 53, + 22, + 51, + 20, + 49, + 18, + 47, + 16, + 45, + 14, + 43, + 12, + 41, + 10, + 39, + 8, + 37, + 6, + 35, + 4, + 33, + 2, + 31, + ] + - name: edge_case_34 + in: + nums: + [ + 34, + 1, + 36, + 3, + 38, + 5, + 40, + 7, + 42, + 9, + 44, + 11, + 46, + 13, + 48, + 15, + 50, + 17, + 52, + 19, + 54, + 21, + 56, + 23, + 58, + 25, + 60, + 27, + 62, + 29, + 64, + 31, + 66, + 33, + ] + - name: edge_case_36 + in: + nums: + [ + 36, + 71, + 34, + 69, + 32, + 67, + 30, + 65, + 28, + 63, + 26, + 61, + 24, + 59, + 22, + 57, + 20, + 55, + 18, + 53, + 16, + 51, + 14, + 49, + 12, + 47, + 10, + 45, + 8, + 43, + 6, + 41, + 4, + 39, + 2, + 37, + ] + - name: edge_case_38 + in: + nums: + [ + 38, + 1, + 40, + 3, + 42, + 5, + 44, + 7, + 46, + 9, + 48, + 11, + 50, + 13, + 52, + 15, + 54, + 17, + 56, + 19, + 58, + 21, + 60, + 23, + 62, + 25, + 64, + 27, + 66, + 29, + 68, + 31, + 70, + 33, + 72, + 35, + 74, + 37, + ] + - name: edge_case_40 + in: + nums: + [ + 40, + 79, + 38, + 77, + 36, + 75, + 34, + 73, + 32, + 71, + 30, + 69, + 28, + 67, + 26, + 65, + 24, + 63, + 22, + 61, + 20, + 59, + 18, + 57, + 16, + 55, + 14, + 53, + 12, + 51, + 10, + 49, + 8, + 47, + 6, + 45, + 4, + 43, + 2, + 41, + ] + - name: edge_case_42 + in: + nums: + [ + 42, + 1, + 44, + 3, + 46, + 5, + 48, + 7, + 50, + 9, + 52, + 11, + 54, + 13, + 56, + 15, + 58, + 17, + 60, + 19, + 62, + 21, + 64, + 23, + 66, + 25, + 68, + 27, + 70, + 29, + 72, + 31, + 74, + 33, + 76, + 35, + 78, + 37, + 80, + 39, + 82, + 41, + ] + - name: edge_case_44 + in: + nums: + [ + 44, + 87, + 42, + 85, + 40, + 83, + 38, + 81, + 36, + 79, + 34, + 77, + 32, + 75, + 30, + 73, + 28, + 71, + 26, + 69, + 24, + 67, + 22, + 65, + 20, + 63, + 18, + 61, + 16, + 59, + 14, + 57, + 12, + 55, + 10, + 53, + 8, + 51, + 6, + 49, + 4, + 47, + 2, + 45, + ] + - name: edge_case_46 + in: + nums: + [ + 46, + 1, + 48, + 3, + 50, + 5, + 52, + 7, + 54, + 9, + 56, + 11, + 58, + 13, + 60, + 15, + 62, + 17, + 64, + 19, + 66, + 21, + 68, + 23, + 70, + 25, + 72, + 27, + 74, + 29, + 76, + 31, + 78, + 33, + 80, + 35, + 82, + 37, + 84, + 39, + 86, + 41, + 88, + 43, + 90, + 45, + ] + - name: edge_case_48 + in: + nums: + [ + 48, + 95, + 46, + 93, + 44, + 91, + 42, + 89, + 40, + 87, + 38, + 85, + 36, + 83, + 34, + 81, + 32, + 79, + 30, + 77, + 28, + 75, + 26, + 73, + 24, + 71, + 22, + 69, + 20, + 67, + 18, + 65, + 16, + 63, + 14, + 61, + 12, + 59, + 10, + 57, + 8, + 55, + 6, + 53, + 4, + 51, + 2, + 49, + ] + - name: edge_case_50 + in: + nums: + [ + 50, + 1, + 52, + 3, + 54, + 5, + 56, + 7, + 58, + 9, + 60, + 11, + 62, + 13, + 64, + 15, + 66, + 17, + 68, + 19, + 70, + 21, + 72, + 23, + 74, + 25, + 76, + 27, + 78, + 29, + 80, + 31, + 82, + 33, + 84, + 35, + 86, + 37, + 88, + 39, + 90, + 41, + 92, + 43, + 94, + 45, + 96, + 47, + 98, + 49, + ] + - name: extra_case_52 + in: + nums: + [ + 52, + 1, + 54, + 3, + 56, + 5, + 58, + 7, + 60, + 9, + 62, + 11, + 64, + 13, + 66, + 15, + 68, + 17, + 70, + 19, + 72, + 21, + 74, + 23, + 76, + 25, + 78, + 27, + 80, + 29, + 82, + 31, + 84, + 33, + 86, + 35, + 88, + 37, + 90, + 39, + 92, + 41, + 94, + 43, + 96, + 45, + 98, + 47, + 100, + 49, + 0, + 51, + ] + - name: extra_case_54 + in: + nums: + [ + 54, + 53, + 52, + 51, + 50, + 49, + 48, + 47, + 46, + 45, + 44, + 43, + 42, + 41, + 40, + 39, + 38, + 37, + 36, + 35, + 34, + 33, + 32, + 31, + 30, + 29, + 28, + 27, + 26, + 25, + 24, + 23, + 22, + 21, + 20, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + ] diff --git a/tests/501-1000/922. sort-array-by-parity-ii/sol.cpp b/tests/501-1000/922. sort-array-by-parity-ii/sol.cpp new file mode 100644 index 00000000..878a407b --- /dev/null +++ b/tests/501-1000/922. sort-array-by-parity-ii/sol.cpp @@ -0,0 +1,20 @@ +class Solution { +public: + vector sortArrayByParityII(vector& nums) { + int i = 0, j = 1; + int n = nums.size(); + + while (i < n && j < n) { + if (nums[i] % 2 == 0) { + i += 2; + } else if (nums[j] % 2 == 1) { + j += 2; + } else { + swap(nums[i], nums[j]); + i += 2; + j += 2; + } + } + return nums; + } +}; diff --git a/tests/501-1000/922. sort-array-by-parity-ii/sol.cs b/tests/501-1000/922. sort-array-by-parity-ii/sol.cs new file mode 100644 index 00000000..c9c2b619 --- /dev/null +++ b/tests/501-1000/922. sort-array-by-parity-ii/sol.cs @@ -0,0 +1,21 @@ +public class Solution { + public int[] SortArrayByParityII(int[] nums) { + int i = 0, j = 1; + int n = nums.Length; + + while (i < n && j < n) { + if (nums[i] % 2 == 0) { + i += 2; + } else if (nums[j] % 2 == 1) { + j += 2; + } else { + int temp = nums[i]; + nums[i] = nums[j]; + nums[j] = temp; + i += 2; + j += 2; + } + } + return nums; + } +} diff --git a/tests/501-1000/922. sort-array-by-parity-ii/sol.dart b/tests/501-1000/922. sort-array-by-parity-ii/sol.dart new file mode 100644 index 00000000..16507ef2 --- /dev/null +++ b/tests/501-1000/922. sort-array-by-parity-ii/sol.dart @@ -0,0 +1,21 @@ +class Solution { + List sortArrayByParityII(List nums) { + int i = 0, j = 1; + int n = nums.length; + + while (i < n && j < n) { + if (nums[i] % 2 == 0) { + i += 2; + } else if (nums[j] % 2 == 1) { + j += 2; + } else { + int temp = nums[i]; + nums[i] = nums[j]; + nums[j] = temp; + i += 2; + j += 2; + } + } + return nums; + } +} diff --git a/tests/501-1000/922. sort-array-by-parity-ii/sol.go b/tests/501-1000/922. sort-array-by-parity-ii/sol.go new file mode 100644 index 00000000..0605b54d --- /dev/null +++ b/tests/501-1000/922. sort-array-by-parity-ii/sol.go @@ -0,0 +1,17 @@ +func sortArrayByParityII(nums []int) []int { + i, j := 0, 1 + n := len(nums) + + for i < n && j < n { + if nums[i] % 2 == 0 { + i += 2 + } else if nums[j] % 2 == 1 { + j += 2 + } else { + nums[i], nums[j] = nums[j], nums[i] + i += 2 + j += 2 + } + } + return nums +} diff --git a/tests/501-1000/922. sort-array-by-parity-ii/sol.java b/tests/501-1000/922. sort-array-by-parity-ii/sol.java new file mode 100644 index 00000000..70efb38f --- /dev/null +++ b/tests/501-1000/922. sort-array-by-parity-ii/sol.java @@ -0,0 +1,21 @@ +class Solution { + public int[] sortArrayByParityII(int[] nums) { + int i = 0, j = 1; + int n = nums.length; + + while (i < n && j < n) { + if (nums[i] % 2 == 0) { + i += 2; + } else if (nums[j] % 2 == 1) { + j += 2; + } else { + int temp = nums[i]; + nums[i] = nums[j]; + nums[j] = temp; + i += 2; + j += 2; + } + } + return nums; + } +} diff --git a/tests/501-1000/922. sort-array-by-parity-ii/sol.kt b/tests/501-1000/922. sort-array-by-parity-ii/sol.kt new file mode 100644 index 00000000..b3899f81 --- /dev/null +++ b/tests/501-1000/922. sort-array-by-parity-ii/sol.kt @@ -0,0 +1,22 @@ +class Solution { + fun sortArrayByParityII(nums: IntArray): IntArray { + var i = 0 + var j = 1 + val n = nums.size + + while (i < n && j < n) { + if (nums[i] % 2 == 0) { + i += 2 + } else if (nums[j] % 2 == 1) { + j += 2 + } else { + val temp = nums[i] + nums[i] = nums[j] + nums[j] = temp + i += 2 + j += 2 + } + } + return nums + } +} diff --git a/tests/501-1000/922. sort-array-by-parity-ii/sol.py b/tests/501-1000/922. sort-array-by-parity-ii/sol.py new file mode 100644 index 00000000..26c3547b --- /dev/null +++ b/tests/501-1000/922. sort-array-by-parity-ii/sol.py @@ -0,0 +1,15 @@ +class Solution(object): + def sortArrayByParityII(self, nums): + i, j = 0, 1 + n = len(nums) + + while i < n and j < n: + if nums[i] % 2 == 0: + i += 2 + elif nums[j] % 2 == 1: + j += 2 + else: + nums[i], nums[j] = nums[j], nums[i] + i += 2 + j += 2 + return nums diff --git a/tests/501-1000/922. sort-array-by-parity-ii/sol.py2 b/tests/501-1000/922. sort-array-by-parity-ii/sol.py2 new file mode 100644 index 00000000..ff7f477e --- /dev/null +++ b/tests/501-1000/922. sort-array-by-parity-ii/sol.py2 @@ -0,0 +1,16 @@ +class Solution(object): + def sortArrayByParityII(self, nums): + even = 0 + odd = 1 + n = len(nums) + while even < n and odd < n: + if nums[even] % 2 == 0: + even += 2 + continue + if nums[odd] % 2 == 1: + odd += 2 + continue + nums[even], nums[odd] = nums[odd], nums[even] + even += 2 + odd += 2 + return nums diff --git a/tests/501-1000/922. sort-array-by-parity-ii/sol.rb b/tests/501-1000/922. sort-array-by-parity-ii/sol.rb new file mode 100644 index 00000000..fe8fc0fb --- /dev/null +++ b/tests/501-1000/922. sort-array-by-parity-ii/sol.rb @@ -0,0 +1,19 @@ +# @param {Integer[]} nums +# @return {Integer[]} +def sort_array_by_parity_ii(nums) + i, j = 0, 1 + n = nums.length + + while i < n && j < n + if nums[i] % 2 == 0 + i += 2 + elsif nums[j] % 2 == 1 + j += 2 + else + nums[i], nums[j] = nums[j], nums[i] + i += 2 + j += 2 + end + end + nums +end diff --git a/tests/501-1000/922. sort-array-by-parity-ii/sol.rs b/tests/501-1000/922. sort-array-by-parity-ii/sol.rs new file mode 100644 index 00000000..494705c0 --- /dev/null +++ b/tests/501-1000/922. sort-array-by-parity-ii/sol.rs @@ -0,0 +1,23 @@ +impl Solution { + pub fn sort_array_by_parity_ii(nums: Vec) -> Vec { + let mut nums = nums; + let mut i = 0; + let mut j = 1; + let n = nums.len(); + + while i < n && j < n { + if nums[i] % 2 == 0 { + i += 2; + } else if nums[j] % 2 == 1 { + j += 2; + } else { + let temp = nums[i]; + nums[i] = nums[j]; + nums[j] = temp; + i += 2; + j += 2; + } + } + nums + } +} diff --git a/tests/501-1000/922. sort-array-by-parity-ii/sol.swift b/tests/501-1000/922. sort-array-by-parity-ii/sol.swift new file mode 100644 index 00000000..41621312 --- /dev/null +++ b/tests/501-1000/922. sort-array-by-parity-ii/sol.swift @@ -0,0 +1,23 @@ +class Solution { + func sortArrayByParityII(_ nums: [Int]) -> [Int] { + var nums = nums + var i = 0 + var j = 1 + let n = nums.count + + while i < n && j < n { + if nums[i] % 2 == 0 { + i += 2 + } else if nums[j] % 2 == 1 { + j += 2 + } else { + let temp = nums[i] + nums[i] = nums[j] + nums[j] = temp + i += 2 + j += 2 + } + } + return nums + } +} diff --git a/tests/501-1000/922. sort-array-by-parity-ii/sol.ts b/tests/501-1000/922. sort-array-by-parity-ii/sol.ts new file mode 100644 index 00000000..9b2ff2c6 --- /dev/null +++ b/tests/501-1000/922. sort-array-by-parity-ii/sol.ts @@ -0,0 +1,20 @@ +function sortArrayByParityII(nums: number[]): number[] { + let i = 0, + j = 1; + const n = nums.length; + + while (i < n && j < n) { + if (nums[i] % 2 === 0) { + i += 2; + } else if (nums[j] % 2 === 1) { + j += 2; + } else { + const temp = nums[i]; + nums[i] = nums[j]; + nums[j] = temp; + i += 2; + j += 2; + } + } + return nums; +} diff --git a/tests/501-1000/923. 3sum-with-multiplicity/manifest.yaml b/tests/501-1000/923. 3sum-with-multiplicity/manifest.yaml new file mode 100644 index 00000000..c5905d7a --- /dev/null +++ b/tests/501-1000/923. 3sum-with-multiplicity/manifest.yaml @@ -0,0 +1,242 @@ +entry: + id: 923 + title: 3sum-with-multiplicity + params: + arr: + type: array + items: + type: int + target: + type: int + call: + cpp: "Solution().threeSumMulti({arr}, {target})" + rust: "Solution::three_sum_multi({arr}, {target})" + python3: "Solution().threeSumMulti({arr}, {target})" + python2: "Solution().threeSumMulti({arr}, {target})" + ruby: "three_sum_multi({arr}, {target})" + java: "new Solution().threeSumMulti({arr}, {target})" + csharp: "new Solution().ThreeSumMulti({arr}, {target})" + kotlin: "Solution().threeSumMulti({arr}, {target})" + go: "threeSumMulti({arr}, {target})" + dart: "Solution().threeSumMulti({arr}, {target})" + swift: "Solution().threeSumMulti({arr}, {target})" + typescript: "threeSumMulti({arr}, {target})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().threeSumMulti(arr, target, {result})" + checker: | + class Checker: + def threeSumMulti(self, arr, target, result): + mod = 10 ** 9 + 7 + n = len(arr) + count = 0 + for i in range(n): + for j in range(i + 1, n): + for k in range(j + 1, n): + if arr[i] + arr[j] + arr[k] == target: + count += 1 + return result == count % mod +seed: 923 +tests: + - name: ex1 + in: + arr: [1, 1, 2, 2, 3, 3, 4, 4, 5, 5] + target: 8 + out: 20 + - name: ex2 + in: + arr: [1, 1, 2, 2, 2, 2] + target: 5 + out: 12 + - name: ex3 + in: + arr: [2, 1, 3] + target: 6 + out: 1 + - name: all_same_small + in: + arr: [0, 0, 0] + target: 0 + out: 1 + - name: all_same_four + in: + arr: [1, 1, 1, 1] + target: 3 + out: 4 + - name: no_solution + in: + arr: [0, 1, 2, 3] + target: 10 + out: 0 + - name: two_of_kind + in: + arr: [2, 2, 2, 3, 3] + target: 7 + out: 6 + - name: mixed_pairs + in: + arr: [0, 0, 1, 1, 2, 2] + target: 3 + out: 8 + - name: triple_zero_one + in: + arr: [0, 0, 0, 1, 1, 1] + target: 2 + out: 9 + - name: target_zero + in: + arr: [0, 0, 0, 0, 1] + target: 0 + out: 4 + - name: target_max_single + in: + arr: [100, 100, 100] + target: 300 + out: 1 + - name: many_duplicates + in: + arr: [1, 1, 1, 2, 2, 3, 3, 4] + target: 6 + out: 15 + - name: offset_mix + in: + arr: [4, 5, 6, 7, 8, 9] + target: 18 + out: 3 + - name: double_count_case + in: + arr: [2, 2, 2, 2, 4, 4] + target: 8 + out: 12 + - name: balanced_small + in: + arr: [3, 3, 4, 4, 5, 5] + target: 12 + out: 8 + - name: all_zero_four + in: + arr: [0, 0, 0, 0] + target: 0 + out: 4 + - name: all_one_five + in: + arr: [1, 1, 1, 1, 1] + target: 3 + out: 10 + - name: all_twos_six + in: + arr: [2, 2, 2, 2, 2, 2] + target: 6 + out: 20 + - name: mixed_simple_a + in: + arr: [0, 1, 1, 2, 2, 2] + target: 4 + out: 6 + - name: mixed_simple_b + in: + arr: [0, 0, 1, 1, 2, 2, 3, 3] + target: 3 + out: 10 + - name: consecutive_range + in: + arr: [1, 2, 3, 4, 5, 6] + target: 10 + out: 3 + - name: larger_values + in: + arr: [4, 4, 4, 5, 5, 6] + target: 14 + out: 6 + - name: two_triplets + in: + arr: [0, 0, 0, 1, 2, 3] + target: 3 + out: 6 + - name: max_value_triplet + in: + arr: [100, 100, 100] + target: 300 + out: 1 + - name: target_too_large + in: + arr: [0, 1, 2, 3, 4] + target: 50 + out: 0 + - name: no_zero_solution + in: + arr: [1, 1, 2, 2, 3, 3] + target: 1 + out: 0 + - name: triple_middle + in: + arr: [2, 2, 2, 3, 3, 3] + target: 8 + out: 9 + - name: symmetric_pairs + in: + arr: [1, 1, 2, 2, 4, 4] + target: 7 + out: 8 + - name: all_equal_eight + in: + arr: [3, 3, 3, 3, 3, 3, 3, 3] + target: 9 + out: 56 + - name: one_each + in: + arr: [2, 3, 4] + target: 9 + out: 1 + - name: duplicate_edge + in: + arr: [1, 1, 2, 3, 4, 5] + target: 8 + out: 4 + - name: zero_heavy + in: + arr: [0, 0, 0, 0, 1, 1, 2] + target: 1 + out: 12 + - name: distinct_unreachable + in: + arr: [5, 6, 7, 8] + target: 1 + out: 0 + - name: large_oracle_a + in: + arr: + gen: "array" + len: 500 + of: + gen: "int" + min: 0 + max: 100 + distinct: false + sorted: false + elemType: "int" + target: + gen: "int" + min: 0 + max: 300 + - name: large_oracle_b + in: + arr: + gen: "array" + len: 499 + of: + gen: "int" + min: 0 + max: 100 + distinct: false + sorted: false + elemType: "int" + target: + gen: "int" + min: 0 + max: 300 diff --git a/tests/501-1000/923. 3sum-with-multiplicity/sol.cpp b/tests/501-1000/923. 3sum-with-multiplicity/sol.cpp new file mode 100644 index 00000000..63d98752 --- /dev/null +++ b/tests/501-1000/923. 3sum-with-multiplicity/sol.cpp @@ -0,0 +1,45 @@ +class Solution { +public: + int threeSumMulti(vector& arr, int target) { + sort(arr.begin(), arr.end()); + unordered_map cnt; + for (int x : arr) { + cnt[x]++; + } + long long res = 0; + int i = 0, l = arr.size(); + const int MOD = 1'000'000'007; + + while (i < l) { + int j = i, k = l - 1; + + while (j < k) { + int s = arr[i] + arr[j] + arr[k]; + if (s < target) { + j += cnt[arr[j]]; + } else if (s > target) { + k -= cnt[arr[k]]; + } else { + if (arr[i] != arr[j] && arr[j] != arr[k]) { + res += (long long)cnt[arr[i]] * cnt[arr[j]] * cnt[arr[k]]; + } else if (arr[i] == arr[j] && arr[j] != arr[k]) { + long long c = cnt[arr[i]]; + res += c * (c - 1) * cnt[arr[k]] / 2; + } else if (arr[i] != arr[j] && arr[j] == arr[k]) { + long long c = cnt[arr[j]]; + res += cnt[arr[i]] * c * (c - 1) / 2; + } else { + long long c = cnt[arr[i]]; + res += c * (c - 1) * (c - 2) / 6; + } + j += cnt[arr[j]]; + k -= cnt[arr[k]]; + } + } + + i += cnt[arr[i]]; + } + + return res % MOD; + } +}; diff --git a/tests/501-1000/923. 3sum-with-multiplicity/sol.cs b/tests/501-1000/923. 3sum-with-multiplicity/sol.cs new file mode 100644 index 00000000..dc9404cd --- /dev/null +++ b/tests/501-1000/923. 3sum-with-multiplicity/sol.cs @@ -0,0 +1,45 @@ +public class Solution { + public int ThreeSumMulti(int[] arr, int target) { + Array.Sort(arr); + Dictionary cnt = new Dictionary(); + foreach (int x in arr) { + if (cnt.ContainsKey(x)) cnt[x]++; + else cnt[x] = 1; + } + long res = 0; + int i = 0, l = arr.Length; + const int MOD = 1_000_000_007; + + while (i < l) { + int j = i, k = l - 1; + + while (j < k) { + int s = arr[i] + arr[j] + arr[k]; + if (s < target) { + j += cnt[arr[j]]; + } else if (s > target) { + k -= cnt[arr[k]]; + } else { + if (arr[i] != arr[j] && arr[j] != arr[k]) { + res += (long)cnt[arr[i]] * cnt[arr[j]] * cnt[arr[k]]; + } else if (arr[i] == arr[j] && arr[j] != arr[k]) { + long c = cnt[arr[i]]; + res += c * (c - 1) * cnt[arr[k]] / 2; + } else if (arr[i] != arr[j] && arr[j] == arr[k]) { + long c = cnt[arr[j]]; + res += cnt[arr[i]] * c * (c - 1) / 2; + } else { + long c = cnt[arr[i]]; + res += c * (c - 1) * (c - 2) / 6; + } + j += cnt[arr[j]]; + k -= cnt[arr[k]]; + } + } + + i += cnt[arr[i]]; + } + + return (int)(res % MOD); + } +} diff --git a/tests/501-1000/923. 3sum-with-multiplicity/sol.dart b/tests/501-1000/923. 3sum-with-multiplicity/sol.dart new file mode 100644 index 00000000..69ebcff7 --- /dev/null +++ b/tests/501-1000/923. 3sum-with-multiplicity/sol.dart @@ -0,0 +1,44 @@ +class Solution { + int threeSumMulti(List arr, int target) { + arr.sort(); + Map cnt = {}; + for (int x in arr) { + cnt[x] = (cnt[x] ?? 0) + 1; + } + int res = 0; + int i = 0, l = arr.length; + const int MOD = 1000000007; + + while (i < l) { + int j = i, k = l - 1; + + while (j < k) { + int s = arr[i] + arr[j] + arr[k]; + if (s < target) { + j += cnt[arr[j]]!; + } else if (s > target) { + k -= cnt[arr[k]]!; + } else { + if (arr[i] != arr[j] && arr[j] != arr[k]) { + res = (res + cnt[arr[i]]! * cnt[arr[j]]! * cnt[arr[k]]!) % MOD; + } else if (arr[i] == arr[j] && arr[j] != arr[k]) { + int c = cnt[arr[i]]!; + res = (res + c * (c - 1) * cnt[arr[k]]! ~/ 2) % MOD; + } else if (arr[i] != arr[j] && arr[j] == arr[k]) { + int c = cnt[arr[j]]!; + res = (res + cnt[arr[i]]! * c * (c - 1) ~/ 2) % MOD; + } else { + int c = cnt[arr[i]]!; + res = (res + c * (c - 1) * (c - 2) ~/ 6) % MOD; + } + j += cnt[arr[j]]!; + k -= cnt[arr[k]]!; + } + } + + i += cnt[arr[i]]!; + } + + return res; + } +} diff --git a/tests/501-1000/923. 3sum-with-multiplicity/sol.go b/tests/501-1000/923. 3sum-with-multiplicity/sol.go new file mode 100644 index 00000000..a2b8e9fc --- /dev/null +++ b/tests/501-1000/923. 3sum-with-multiplicity/sol.go @@ -0,0 +1,42 @@ +func threeSumMulti(arr []int, target int) int { + sort.Ints(arr) + cnt := make(map[int]int) + for _, x := range arr { + cnt[x]++ + } + var res int64 = 0 + i, l := 0, len(arr) + MOD := int64(1_000_000_007) + + for i < l { + j, k := i, l-1 + + for j < k { + s := arr[i] + arr[j] + arr[k] + if s < target { + j += cnt[arr[j]] + } else if s > target { + k -= cnt[arr[k]] + } else { + if arr[i] != arr[j] && arr[j] != arr[k] { + res += int64(cnt[arr[i]] * cnt[arr[j]] * cnt[arr[k]]) + } else if arr[i] == arr[j] && arr[j] != arr[k] { + c := int64(cnt[arr[i]]) + res += c * (c - 1) * int64(cnt[arr[k]]) / 2 + } else if arr[i] != arr[j] && arr[j] == arr[k] { + c := int64(cnt[arr[j]]) + res += int64(cnt[arr[i]]) * c * (c - 1) / 2 + } else { + c := int64(cnt[arr[i]]) + res += c * (c - 1) * (c - 2) / 6 + } + j += cnt[arr[j]] + k -= cnt[arr[k]] + } + } + + i += cnt[arr[i]] + } + + return int(res % MOD) +} diff --git a/tests/501-1000/923. 3sum-with-multiplicity/sol.java b/tests/501-1000/923. 3sum-with-multiplicity/sol.java new file mode 100644 index 00000000..b54b23c6 --- /dev/null +++ b/tests/501-1000/923. 3sum-with-multiplicity/sol.java @@ -0,0 +1,42 @@ +class Solution { + public int threeSumMulti(int[] arr, int target) { + Arrays.sort(arr); + Map cnt = new HashMap<>(); + for (int x : arr) { + cnt.put(x, cnt.getOrDefault(x, 0) + 1); + } + long res = 0; + int i = 0, l = arr.length; + int MOD = 1_000_000_007; + + while (i < l) { + int j = i, k = l - 1; + + while (j < k) { + int s = arr[i] + arr[j] + arr[k]; + if (s < target) { + j += cnt.get(arr[j]); + } else if (s > target) { + k -= cnt.get(arr[k]); + } else { + if (arr[i] != arr[j] && arr[j] != arr[k]) { + res += (long) cnt.get(arr[i]) * cnt.get(arr[j]) * cnt.get(arr[k]); + } else if (arr[i] == arr[j] && arr[j] != arr[k]) { + res += (long) cnt.get(arr[i]) * (cnt.get(arr[i]) - 1) * cnt.get(arr[k]) / 2; + } else if (arr[i] != arr[j] && arr[j] == arr[k]) { + res += (long) cnt.get(arr[i]) * cnt.get(arr[j]) * (cnt.get(arr[j]) - 1) / 2; + } else { + long c = cnt.get(arr[i]); + res += c * (c - 1) * (c - 2) / 6; + } + j += cnt.get(arr[j]); + k -= cnt.get(arr[k]); + } + } + + i += cnt.get(arr[i]); + } + + return (int) (res % MOD); + } +} diff --git a/tests/501-1000/923. 3sum-with-multiplicity/sol.kt b/tests/501-1000/923. 3sum-with-multiplicity/sol.kt new file mode 100644 index 00000000..ba47b13d --- /dev/null +++ b/tests/501-1000/923. 3sum-with-multiplicity/sol.kt @@ -0,0 +1,46 @@ +class Solution { + fun threeSumMulti(arr: IntArray, target: Int): Int { + arr.sort() + val cnt = mutableMapOf() + for (x in arr) { + cnt[x] = cnt.getOrDefault(x, 0) + 1 + } + var res = 0L + var i = 0 + val l = arr.size + val MOD = 1_000_000_007 + + while (i < l) { + var j = i + var k = l - 1 + + while (j < k) { + val s = arr[i] + arr[j] + arr[k] + if (s < target) { + j += cnt[arr[j]]!! + } else if (s > target) { + k -= cnt[arr[k]]!! + } else { + if (arr[i] != arr[j] && arr[j] != arr[k]) { + res += cnt[arr[i]]!!.toLong() * cnt[arr[j]]!! * cnt[arr[k]]!! + } else if (arr[i] == arr[j] && arr[j] != arr[k]) { + val c = cnt[arr[i]]!!.toLong() + res += c * (c - 1) * cnt[arr[k]]!! / 2 + } else if (arr[i] != arr[j] && arr[j] == arr[k]) { + val c = cnt[arr[j]]!!.toLong() + res += cnt[arr[i]]!!.toLong() * c * (c - 1) / 2 + } else { + val c = cnt[arr[i]]!!.toLong() + res += c * (c - 1) * (c - 2) / 6 + } + j += cnt[arr[j]]!! + k -= cnt[arr[k]]!! + } + } + + i += cnt[arr[i]]!! + } + + return (res % MOD).toInt() + } +} diff --git a/tests/501-1000/923. 3sum-with-multiplicity/sol.py b/tests/501-1000/923. 3sum-with-multiplicity/sol.py new file mode 100644 index 00000000..db5b8271 --- /dev/null +++ b/tests/501-1000/923. 3sum-with-multiplicity/sol.py @@ -0,0 +1,52 @@ +from collections import Counter +from typing import List + + +class Solution: + def threeSumMulti(self, arr: List[int], target: int) -> int: + arr.sort() + cnt = Counter(arr) # obtain the number of instances of each number + res, i, l = 0, 0, len(arr) + + while ( + i < l + ): # in replacement of the for-loop, so that we can increment i by more than 1 + j, k = ( + i, + l - 1, + ) # j should be the leftmost index, hence j=i instead of j=i+1 + + while j < k: # i <= j < k; arr[i] <= arr[j] <= arr[k] + if arr[i] + arr[j] + arr[k] < target: + j += cnt[arr[j]] + elif arr[i] + arr[j] + arr[k] > target: + k -= cnt[arr[k]] + + else: # arr[i] + arr[j] + arr[k] == target + if ( + arr[i] != arr[j] != arr[k] + ): # Case 1: All the numbers are different + res += cnt[arr[i]] * cnt[arr[j]] * cnt[arr[k]] + elif ( + arr[i] == arr[j] != arr[k] + ): # Case 2: The smaller two numbers are the same + res += ( + cnt[arr[i]] * (cnt[arr[i]] - 1) * cnt[arr[k]] // 2 + ) # math.comb(cnt[arr[i]], 2) * cnt[arr[k]] + elif ( + arr[i] != arr[j] == arr[k] + ): # Case 3: The larger two numbers are the same + res += ( + cnt[arr[i]] * cnt[arr[j]] * (cnt[arr[j]] - 1) // 2 + ) # math.comb(cnt[arr[j]], 2) * cnt[arr[i]] + else: # Case 4: All the numbers are the same + res += ( + cnt[arr[i]] * (cnt[arr[i]] - 1) * (cnt[arr[i]] - 2) // 6 + ) # math.comb(cnt[arr[i]], 3) + # Shift pointers by the number of instances of the number + j += cnt[arr[j]] + k -= cnt[arr[k]] + + i += cnt[arr[i]] # Shift pointer by the number of instances of the number + + return res % int(1e9 + 7) diff --git a/tests/501-1000/923. 3sum-with-multiplicity/sol.py2 b/tests/501-1000/923. 3sum-with-multiplicity/sol.py2 new file mode 100644 index 00000000..2cd1150c --- /dev/null +++ b/tests/501-1000/923. 3sum-with-multiplicity/sol.py2 @@ -0,0 +1,37 @@ +class Solution(object): + def threeSumMulti(self, arr, target): + """ + :type arr: List[int] + :type target: int + :rtype: int + """ + from collections import Counter + + arr.sort() + cnt = Counter(arr) + res, i, l = 0, 0, len(arr) + + while i < l: + j, k = i, l - 1 + + while j < k: + s = arr[i] + arr[j] + arr[k] + if s < target: + j += cnt[arr[j]] + elif s > target: + k -= cnt[arr[k]] + else: + if arr[i] != arr[j] != arr[k]: + res += cnt[arr[i]] * cnt[arr[j]] * cnt[arr[k]] + elif arr[i] == arr[j] != arr[k]: + res += cnt[arr[i]] * (cnt[arr[i]] - 1) * cnt[arr[k]] // 2 + elif arr[i] != arr[j] == arr[k]: + res += cnt[arr[i]] * cnt[arr[j]] * (cnt[arr[j]] - 1) // 2 + else: + res += cnt[arr[i]] * (cnt[arr[i]] - 1) * (cnt[arr[i]] - 2) // 6 + j += cnt[arr[j]] + k -= cnt[arr[k]] + + i += cnt[arr[i]] + + return res % (10**9 + 7) diff --git a/tests/501-1000/923. 3sum-with-multiplicity/sol.rb b/tests/501-1000/923. 3sum-with-multiplicity/sol.rb new file mode 100644 index 00000000..a7151363 --- /dev/null +++ b/tests/501-1000/923. 3sum-with-multiplicity/sol.rb @@ -0,0 +1,38 @@ +# @param {Integer[]} arr +# @param {Integer} target +# @return {Integer} +def three_sum_multi(arr, target) + arr.sort! + cnt = Hash.new(0) + arr.each { |x| cnt[x] += 1 } + res, i, l = 0, 0, arr.length + + while i < l + j, k = i, l - 1 + + while j < k + s = arr[i] + arr[j] + arr[k] + if s < target + j += cnt[arr[j]] + elsif s > target + k -= cnt[arr[k]] + else + if arr[i] != arr[j] && arr[j] != arr[k] + res += cnt[arr[i]] * cnt[arr[j]] * cnt[arr[k]] + elsif arr[i] == arr[j] && arr[j] != arr[k] + res += cnt[arr[i]] * (cnt[arr[i]] - 1) * cnt[arr[k]] / 2 + elsif arr[i] != arr[j] && arr[j] == arr[k] + res += cnt[arr[i]] * cnt[arr[j]] * (cnt[arr[j]] - 1) / 2 + else + res += cnt[arr[i]] * (cnt[arr[i]] - 1) * (cnt[arr[i]] - 2) / 6 + end + j += cnt[arr[j]] + k -= cnt[arr[k]] + end + end + + i += cnt[arr[i]] + end + + res % (10**9 + 7) +end diff --git a/tests/501-1000/923. 3sum-with-multiplicity/sol.rs b/tests/501-1000/923. 3sum-with-multiplicity/sol.rs new file mode 100644 index 00000000..9174f0ac --- /dev/null +++ b/tests/501-1000/923. 3sum-with-multiplicity/sol.rs @@ -0,0 +1,46 @@ +impl Solution { + pub fn three_sum_multi(arr: Vec, target: i32) -> i32 { + use std::collections::HashMap; + let mut cnt = HashMap::new(); + for x in arr { + *cnt.entry(x).or_insert(0i64) += 1; + } + let mut vals: Vec = cnt.keys().copied().collect(); + vals.sort(); + let mut res: i64 = 0; + let modu: i64 = 1_000_000_007; + + for i in 0..vals.len() { + for j in i..vals.len() { + let a = vals[i]; + let b = vals[j]; + let c = target - a - b; + if c < b { + continue; + } + let Some(&cc) = cnt.get(&c) else { + continue; + }; + let ca = cnt[&a]; + let cb = cnt[&b]; + if a == b && b == c { + if ca >= 3 { + res += ca * (ca - 1) * (ca - 2) / 6; + } + } else if a == b && b != c { + if ca >= 2 { + res += ca * (ca - 1) / 2 * cc; + } + } else if a < b && b == c { + if cb >= 2 { + res += ca * cb * (cb - 1) / 2; + } + } else if a < b && b < c { + res += ca * cb * cc; + } + } + } + + (res % modu) as i32 + } +} diff --git a/tests/501-1000/923. 3sum-with-multiplicity/sol.swift b/tests/501-1000/923. 3sum-with-multiplicity/sol.swift new file mode 100644 index 00000000..a0186aed --- /dev/null +++ b/tests/501-1000/923. 3sum-with-multiplicity/sol.swift @@ -0,0 +1,47 @@ +class Solution { + func threeSumMulti(_ arr: [Int], _ target: Int) -> Int { + var arr = arr.sorted() + var cnt = [Int: Int]() + for x in arr { + cnt[x, default: 0] += 1 + } + var res = 0 + var i = 0 + let l = arr.count + let MOD = 1_000_000_007 + + while i < l { + var j = i + var k = l - 1 + + while j < k { + let s = arr[i] + arr[j] + arr[k] + if s < target { + j += cnt[arr[j]]! + } else if s > target { + k -= cnt[arr[k]]! + } else { + if arr[i] != arr[j] && arr[j] != arr[k] { + res += cnt[arr[i]]! * cnt[arr[j]]! * cnt[arr[k]]! + } else if arr[i] == arr[j] && arr[j] != arr[k] { + let c = cnt[arr[i]]! + res += c * (c - 1) * cnt[arr[k]]! / 2 + } else if arr[i] != arr[j] && arr[j] == arr[k] { + let c = cnt[arr[j]]! + res += cnt[arr[i]]! * c * (c - 1) / 2 + } else { + let c = cnt[arr[i]]! + res += c * (c - 1) * (c - 2) / 6 + } + res %= MOD + j += cnt[arr[j]]! + k -= cnt[arr[k]]! + } + } + + i += cnt[arr[i]]! + } + + return res + } +} diff --git a/tests/501-1000/923. 3sum-with-multiplicity/sol.ts b/tests/501-1000/923. 3sum-with-multiplicity/sol.ts new file mode 100644 index 00000000..7ca27487 --- /dev/null +++ b/tests/501-1000/923. 3sum-with-multiplicity/sol.ts @@ -0,0 +1,44 @@ +function threeSumMulti(arr: number[], target: number): number { + arr.sort((a, b) => a - b); + const cnt = new Map(); + for (const x of arr) { + cnt.set(x, (cnt.get(x) || 0) + 1); + } + let res = 0; + let i = 0; + const l = arr.length; + const MOD = 1_000_000_007; + + while (i < l) { + let j = i; + let k = l - 1; + + while (j < k) { + const s = arr[i] + arr[j] + arr[k]; + if (s < target) { + j += cnt.get(arr[j])!; + } else if (s > target) { + k -= cnt.get(arr[k])!; + } else { + if (arr[i] !== arr[j] && arr[j] !== arr[k]) { + res += cnt.get(arr[i])! * cnt.get(arr[j])! * cnt.get(arr[k])!; + } else if (arr[i] === arr[j] && arr[j] !== arr[k]) { + const c = cnt.get(arr[i])!; + res += (c * (c - 1) * cnt.get(arr[k])!) / 2; + } else if (arr[i] !== arr[j] && arr[j] === arr[k]) { + const c = cnt.get(arr[j])!; + res += (cnt.get(arr[i])! * c * (c - 1)) / 2; + } else { + const c = cnt.get(arr[i])!; + res += (c * (c - 1) * (c - 2)) / 6; + } + j += cnt.get(arr[j])!; + k -= cnt.get(arr[k])!; + } + } + + i += cnt.get(arr[i])!; + } + + return res % MOD; +} diff --git a/tests/501-1000/924. minimize-malware-spread/manifest.yaml b/tests/501-1000/924. minimize-malware-spread/manifest.yaml new file mode 100644 index 00000000..9d3b58e9 --- /dev/null +++ b/tests/501-1000/924. minimize-malware-spread/manifest.yaml @@ -0,0 +1,477 @@ +entry: + id: 924 + title: minimize-malware-spread + params: + graph: + type: array + items: + type: array + items: + type: int + initial: + type: array + items: + type: int + call: + cpp: "Solution().minMalwareSpread({graph}, {initial})" + rust: "Solution::min_malware_spread({graph}, {initial})" + python3: "Solution().minMalwareSpread({graph}, {initial})" + python2: "Solution().minMalwareSpread({graph}, {initial})" + ruby: "min_malware_spread({graph}, {initial})" + java: "new Solution().minMalwareSpread({graph}, {initial})" + csharp: "new Solution().MinMalwareSpread({graph}, {initial})" + kotlin: "Solution().minMalwareSpread({graph}, {initial})" + go: "minMalwareSpread({graph}, {initial})" + dart: "Solution().minMalwareSpread({graph}, {initial})" + swift: "Solution().minMalwareSpread({graph}, {initial})" + typescript: "minMalwareSpread({graph}, {initial})" +judge: + type: exact +limits: + time_ms: 2000 + memory_mb: 256 +oracle: + python3: + call: "Checker().minMalwareSpread(graph, initial, {result})" + checker: | + class Checker: + def minMalwareSpread(self, graph, initial, result): + n = len(graph) + seen = [False] * n + comps = [] + for i in range(n): + if seen[i]: + continue + stack = [i] + seen[i] = True + comp = [] + while stack: + node = stack.pop() + comp.append(node) + for nei, edge in enumerate(graph[node]): + if edge and not seen[nei]: + seen[nei] = True + stack.append(nei) + comps.append(comp) + infected = set(initial) + best = min(initial) + best_saved = -1 + for node in sorted(initial): + saved = 0 + for comp in comps: + hits = sum(1 for x in comp if x in infected) + if node in comp and hits == 1: + saved = len(comp) + break + if saved > best_saved: + best_saved = saved + best = node + return result == best +seed: 924 +tests: + - name: ex1 + in: + graph: + elemType: "int" + value: + - [1, 1, 0] + - [1, 1, 0] + - [0, 0, 1] + initial: [0, 1] + out: 0 + - name: ex2 + in: + graph: + elemType: "int" + value: + - [1, 0, 0] + - [0, 1, 0] + - [0, 0, 1] + initial: [0, 2] + out: 0 + - name: ex3 + in: + graph: + elemType: "int" + value: + - [1, 1, 1] + - [1, 1, 1] + - [1, 1, 1] + initial: [1, 2] + out: 1 + - name: single_component_two_initial + in: + graph: + elemType: "int" + value: + - [1, 1, 1, 0] + - [1, 1, 1, 0] + - [1, 1, 1, 0] + - [0, 0, 0, 1] + initial: [0, 2] + out: 0 + - name: unique_saved_larger_component + in: + graph: + elemType: "int" + value: + - [1, 1, 0, 0, 0] + - [1, 1, 0, 0, 0] + - [0, 0, 1, 1, 0] + - [0, 0, 1, 1, 0] + - [0, 0, 0, 0, 1] + initial: [1, 4] + out: 1 + - name: tie_smaller_index + in: + graph: + elemType: "int" + value: + - [1, 1, 0, 0] + - [1, 1, 0, 0] + - [0, 0, 1, 1] + - [0, 0, 1, 1] + initial: [1, 2] + out: 1 + - name: isolate_best + in: + graph: + elemType: "int" + value: + - [1, 1, 0, 0] + - [1, 1, 0, 0] + - [0, 0, 1, 0] + - [0, 0, 0, 1] + initial: [2, 3] + out: 2 + - name: connected_pair + in: + graph: + elemType: "int" + value: + - [1, 1] + - [1, 1] + initial: [0] + out: 0 + - name: all_isolated + in: + graph: + elemType: "int" + value: + - [1, 0, 0, 0] + - [0, 1, 0, 0] + - [0, 0, 1, 0] + - [0, 0, 0, 1] + initial: [1, 3] + out: 1 + - name: chain_four + in: + graph: + elemType: "int" + value: + - [1, 1, 0, 0] + - [1, 1, 1, 0] + - [0, 1, 1, 1] + - [0, 0, 1, 1] + initial: [0, 3] + out: 0 + - name: star_center + in: + graph: + elemType: int + value: + - [1, 1, 1, 1, 1] + - [1, 1, 0, 0, 0] + - [1, 0, 1, 0, 0] + - [1, 0, 0, 1, 0] + - [1, 0, 0, 0, 1] + initial: [1, 2] + out: 1 + - name: two_components_prefer_larger_saved + in: + graph: + elemType: "int" + value: + - [1, 1, 0, 0, 0, 0] + - [1, 1, 0, 0, 0, 0] + - [0, 0, 1, 1, 1, 0] + - [0, 0, 1, 1, 1, 0] + - [0, 0, 1, 1, 1, 0] + - [0, 0, 0, 0, 0, 1] + initial: [1, 2, 5] + out: 2 + - name: tie_smallest_index + in: + graph: + elemType: "int" + value: + - [1, 1, 0, 0] + - [1, 1, 0, 0] + - [0, 0, 1, 1] + - [0, 0, 1, 1] + initial: [0, 2, 3] + out: 0 + - name: isolated_wins + in: + graph: + elemType: "int" + value: + - [1, 0, 0, 0, 0] + - [0, 1, 1, 0, 0] + - [0, 1, 1, 0, 0] + - [0, 0, 0, 1, 1] + - [0, 0, 0, 1, 1] + initial: [1, 3] + out: 1 + - name: chain_component + in: + graph: + elemType: "int" + value: + - [1, 1, 0, 0] + - [1, 1, 1, 0] + - [0, 1, 1, 1] + - [0, 0, 1, 1] + initial: [0, 3] + out: 0 + - name: complete_graph_three + in: + graph: + elemType: "int" + value: + - [1, 1, 1] + - [1, 1, 1] + - [1, 1, 1] + initial: [0, 1, 2] + out: 0 + - name: all_isolated + in: + graph: + elemType: "int" + value: + - [1, 0, 0, 0] + - [0, 1, 0, 0] + - [0, 0, 1, 0] + - [0, 0, 0, 1] + initial: [1, 3] + out: 1 + - name: component_of_two + in: + graph: + elemType: "int" + value: + - [1, 1, 0, 0, 0, 0] + - [1, 1, 0, 0, 0, 0] + - [0, 0, 1, 0, 0, 0] + - [0, 0, 0, 1, 1, 0] + - [0, 0, 0, 1, 1, 0] + - [0, 0, 0, 0, 0, 1] + initial: [2, 3] + out: 3 + - name: star_tie + in: + graph: + elemType: "int" + value: + - [1, 1, 1, 1, 1] + - [1, 1, 0, 0, 0] + - [1, 0, 1, 0, 0] + - [1, 0, 0, 1, 0] + - [1, 0, 0, 0, 1] + initial: [1, 2] + out: 1 + - name: two_large_components + in: + graph: + elemType: "int" + value: + - [1, 1, 1, 0, 0, 0] + - [1, 1, 1, 0, 0, 0] + - [1, 1, 1, 0, 0, 0] + - [0, 0, 0, 1, 1, 0] + - [0, 0, 0, 1, 1, 0] + - [0, 0, 0, 0, 0, 1] + initial: [0, 4, 5] + out: 0 + - name: pair_and_single + in: + graph: + elemType: "int" + value: + - [1, 1, 0] + - [1, 1, 0] + - [0, 0, 1] + initial: [0, 2] + out: 0 + - name: path_five + in: + graph: + elemType: "int" + value: + - [1, 1, 0, 0, 0] + - [1, 1, 1, 0, 0] + - [0, 1, 1, 1, 0] + - [0, 0, 1, 1, 1] + - [0, 0, 0, 1, 1] + initial: [0, 4] + out: 0 + - name: one_big_one_small + in: + graph: + elemType: "int" + value: + - [1, 1, 1, 1] + - [1, 1, 1, 1] + - [1, 1, 1, 1] + - [1, 1, 1, 1] + initial: [1, 2] + out: 1 + - name: isolated_and_cluster + in: + graph: + elemType: "int" + value: + - [1, 0, 0, 0, 0, 0] + - [0, 1, 0, 0, 0, 0] + - [0, 0, 1, 1, 1, 0] + - [0, 0, 1, 1, 1, 0] + - [0, 0, 1, 1, 1, 0] + - [0, 0, 0, 0, 0, 1] + initial: [0, 2, 3] + out: 0 + - name: single_infected_isolated + in: + graph: + elemType: "int" + value: + - [1, 0, 0] + - [0, 1, 0] + - [0, 0, 1] + initial: [2] + out: 2 + - name: choose_only_unique_component + in: + graph: + elemType: "int" + value: + - [1, 1, 1, 0, 0] + - [1, 1, 1, 0, 0] + - [1, 1, 1, 0, 0] + - [0, 0, 0, 1, 1] + - [0, 0, 0, 1, 1] + initial: [0, 3] + out: 0 + - name: choose_small_component + in: + graph: + elemType: "int" + value: + - [1, 1, 0, 0, 0, 0] + - [1, 1, 0, 0, 0, 0] + - [0, 0, 1, 1, 1, 0] + - [0, 0, 1, 1, 1, 0] + - [0, 0, 1, 1, 1, 0] + - [0, 0, 0, 0, 0, 1] + initial: [1, 4] + out: 4 + - name: choose_zero_when_tie + in: + graph: + elemType: "int" + value: + - [1, 1, 0, 0] + - [1, 1, 0, 0] + - [0, 0, 1, 0] + - [0, 0, 0, 1] + initial: [0, 2, 3] + out: 0 + - name: path_six + in: + graph: + elemType: "int" + value: + - [1, 1, 0, 0, 0, 0] + - [1, 1, 1, 0, 0, 0] + - [0, 1, 1, 1, 0, 0] + - [0, 0, 1, 1, 1, 0] + - [0, 0, 0, 1, 1, 1] + - [0, 0, 0, 0, 1, 1] + initial: [0, 5] + out: 0 + - name: two_pairs + in: + graph: + elemType: "int" + value: + - [1, 1, 0, 0, 0] + - [1, 1, 0, 0, 0] + - [0, 0, 1, 1, 0] + - [0, 0, 1, 1, 0] + - [0, 0, 0, 0, 1] + initial: [0, 2] + out: 0 + - name: three_clusters + in: + graph: + elemType: "int" + value: + - [1, 1, 0, 0, 0, 0, 0] + - [1, 1, 0, 0, 0, 0, 0] + - [0, 0, 1, 1, 1, 0, 0] + - [0, 0, 1, 1, 1, 0, 0] + - [0, 0, 1, 1, 1, 0, 0] + - [0, 0, 0, 0, 0, 1, 1] + - [0, 0, 0, 0, 0, 1, 1] + initial: [1, 4, 6] + out: 4 + - name: big_component_tie + in: + graph: + elemType: "int" + value: + - [1, 1, 1, 1, 0, 0] + - [1, 1, 1, 1, 0, 0] + - [1, 1, 1, 1, 0, 0] + - [1, 1, 1, 1, 0, 0] + - [0, 0, 0, 0, 1, 1] + - [0, 0, 0, 0, 1, 1] + initial: [0, 5] + out: 0 + - name: mixed_isolates + in: + graph: + elemType: "int" + value: + - [1, 0, 0, 0, 0, 0] + - [0, 1, 1, 0, 0, 0] + - [0, 1, 1, 0, 0, 0] + - [0, 0, 0, 1, 1, 1] + - [0, 0, 0, 1, 1, 1] + - [0, 0, 0, 1, 1, 1] + initial: [1, 3, 5] + out: 1 + - name: single_source_save + in: + graph: + elemType: "int" + value: + - [1, 1, 0, 0, 0] + - [1, 1, 0, 0, 0] + - [0, 0, 1, 1, 0] + - [0, 0, 1, 1, 0] + - [0, 0, 0, 0, 1] + initial: [0] + out: 0 + - name: three_way_choice + in: + graph: + elemType: "int" + value: + - [1, 1, 1, 0, 0, 0] + - [1, 1, 1, 0, 0, 0] + - [1, 1, 1, 0, 0, 0] + - [0, 0, 0, 1, 1, 0] + - [0, 0, 0, 1, 1, 0] + - [0, 0, 0, 0, 0, 1] + initial: [2, 4] + out: 2 diff --git a/tests/501-1000/924. minimize-malware-spread/sol.cpp b/tests/501-1000/924. minimize-malware-spread/sol.cpp new file mode 100644 index 00000000..bfc843f2 --- /dev/null +++ b/tests/501-1000/924. minimize-malware-spread/sol.cpp @@ -0,0 +1,54 @@ +class Solution { +public: + int minMalwareSpread(vector>& graph, vector& initial) { + int n = graph.size(); + vector parent(n); + vector size(n, 1); + for (int i = 0; i < n; i++) parent[i] = i; + + function find = [&](int i) { + while (parent[i] != i) { + parent[i] = parent[parent[i]]; + i = parent[i]; + } + return i; + }; + + auto unionSet = [&](int i, int j) { + int rootI = find(i); + int rootJ = find(j); + if (rootI != rootJ) { + if (size[rootI] < size[rootJ]) swap(rootI, rootJ); + parent[rootJ] = rootI; + size[rootI] += size[rootJ]; + } + }; + + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (graph[i][j]) unionSet(i, j); + } + } + + vector counts(n, 0); + for (int m : initial) { + counts[find(m)]++; + } + + sort(initial.begin(), initial.end()); + int ans = initial[0]; + int maxSaved = -1; + + for (int m : initial) { + int root = find(m); + if (counts[root] == 1) { + if (size[root] > maxSaved) { + maxSaved = size[root]; + ans = m; + } + } + } + + return ans; + } +}; diff --git a/tests/501-1000/924. minimize-malware-spread/sol.cs b/tests/501-1000/924. minimize-malware-spread/sol.cs new file mode 100644 index 00000000..262c4c18 --- /dev/null +++ b/tests/501-1000/924. minimize-malware-spread/sol.cs @@ -0,0 +1,62 @@ +public class Solution { + public int MinMalwareSpread(int[][] graph, int[] initial) { + int n = graph.Length; + int[] parent = new int[n]; + int[] size = new int[n]; + for (int i = 0; i < n; i++) { + parent[i] = i; + size[i] = 1; + } + + int Find(int i) { + while (parent[i] != i) { + parent[i] = parent[parent[i]]; + i = parent[i]; + } + return i; + } + + void Union(int i, int j) { + int rootI = Find(i); + int rootJ = Find(j); + if (rootI != rootJ) { + if (size[rootI] < size[rootJ]) { + int temp = rootI; + rootI = rootJ; + rootJ = temp; + } + parent[rootJ] = rootI; + size[rootI] += size[rootJ]; + } + } + + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (graph[i][j] == 1) { + Union(i, j); + } + } + } + + int[] counts = new int[n]; + foreach (int m in initial) { + counts[Find(m)]++; + } + + Array.Sort(initial); + int ans = initial[0]; + int maxSaved = -1; + + foreach (int m in initial) { + int root = Find(m); + if (counts[root] == 1) { + if (size[root] > maxSaved) { + maxSaved = size[root]; + ans = m; + } + } + } + + return ans; + } +} diff --git a/tests/501-1000/924. minimize-malware-spread/sol.dart b/tests/501-1000/924. minimize-malware-spread/sol.dart new file mode 100644 index 00000000..be484d87 --- /dev/null +++ b/tests/501-1000/924. minimize-malware-spread/sol.dart @@ -0,0 +1,59 @@ +class Solution { + int minMalwareSpread(List> graph, List initial) { + int n = graph.length; + List parent = List.generate(n, (i) => i); + List size = List.filled(n, 1); + + int find(int i) { + while (parent[i] != i) { + parent[i] = parent[parent[i]]; + i = parent[i]; + } + return i; + } + + void union(int i, int j) { + int rootI = find(i); + int rootJ = find(j); + if (rootI != rootJ) { + if (size[rootI] < size[rootJ]) { + int temp = rootI; + rootI = rootJ; + rootJ = temp; + } + parent[rootJ] = rootI; + size[rootI] += size[rootJ]; + } + } + + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (graph[i][j] == 1) { + union(i, j); + } + } + } + + Map counts = {}; + for (int m in initial) { + int root = find(m); + counts[root] = (counts[root] ?? 0) + 1; + } + + initial.sort(); + int ans = initial[0]; + int maxSaved = -1; + + for (int m in initial) { + int root = find(m); + if (counts[root] == 1) { + if (size[root] > maxSaved) { + maxSaved = size[root]; + ans = m; + } + } + } + + return ans; + } +} diff --git a/tests/501-1000/924. minimize-malware-spread/sol.go b/tests/501-1000/924. minimize-malware-spread/sol.go new file mode 100644 index 00000000..6cdd4b96 --- /dev/null +++ b/tests/501-1000/924. minimize-malware-spread/sol.go @@ -0,0 +1,51 @@ +func minMalwareSpread(graph [][]int, initial []int) int { + n := len(graph) + parent := make([]int, n) + size := make([]int, n) + for i := 0; i < n; i++ { + parent[i] = i + size[i] = 1 + } + var find func(int) int + find = func(i int) int { + for parent[i] != i { + parent[i] = parent[parent[i]] + i = parent[i] + } + return i + } + union := func(i, j int) { + rootI, rootJ := find(i), find(j) + if rootI != rootJ { + if size[rootI] < size[rootJ] { + rootI, rootJ = rootJ, rootI + } + parent[rootJ] = rootI + size[rootI] += size[rootJ] + } + } + for i := 0; i < n; i++ { + for j := i + 1; j < n; j++ { + if graph[i][j] == 1 { + union(i, j) + } + } + } + counts := make(map[int]int) + for _, m := range initial { + counts[find(m)]++ + } + sort.Ints(initial) + ans := initial[0] + maxSaved := -1 + for _, m := range initial { + root := find(m) + if counts[root] == 1 { + if size[root] > maxSaved { + maxSaved = size[root] + ans = m + } + } + } + return ans +} diff --git a/tests/501-1000/924. minimize-malware-spread/sol.java b/tests/501-1000/924. minimize-malware-spread/sol.java new file mode 100644 index 00000000..59cf8703 --- /dev/null +++ b/tests/501-1000/924. minimize-malware-spread/sol.java @@ -0,0 +1,60 @@ +class Solution { + private int[] parent; + private int[] size; + + private int find(int i) { + while (parent[i] != i) { + parent[i] = parent[parent[i]]; + i = parent[i]; + } + return i; + } + + private void union(int i, int j) { + int rootI = find(i); + int rootJ = find(j); + if (rootI != rootJ) { + if (size[rootI] < size[rootJ]) { + int temp = rootI; + rootI = rootJ; + rootJ = temp; + } + parent[rootJ] = rootI; + size[rootI] += size[rootJ]; + } + } + + public int minMalwareSpread(int[][] graph, int[] initial) { + int n = graph.length; + parent = new int[n]; + size = new int[n]; + for (int i = 0; i < n; i++) { + parent[i] = i; + size[i] = 1; + } + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (graph[i][j] == 1) { + union(i, j); + } + } + } + int[] counts = new int[n]; + for (int m : initial) { + counts[find(m)]++; + } + Arrays.sort(initial); + int ans = initial[0]; + int maxSaved = -1; + for (int m : initial) { + int root = find(m); + if (counts[root] == 1) { + if (size[root] > maxSaved) { + maxSaved = size[root]; + ans = m; + } + } + } + return ans; + } +} diff --git a/tests/501-1000/924. minimize-malware-spread/sol.kt b/tests/501-1000/924. minimize-malware-spread/sol.kt new file mode 100644 index 00000000..5951d02e --- /dev/null +++ b/tests/501-1000/924. minimize-malware-spread/sol.kt @@ -0,0 +1,57 @@ +class Solution { + private lateinit var parent: IntArray + private lateinit var size: IntArray + + private fun find(i: Int): Int { + var x = i + while (parent[x] != x) { + parent[x] = parent[parent[x]] + x = parent[x] + } + return x + } + + private fun union(i: Int, j: Int) { + var rootI = find(i) + var rootJ = find(j) + if (rootI != rootJ) { + if (size[rootI] < size[rootJ]) { + val temp = rootI + rootI = rootJ + rootJ = temp + } + parent[rootJ] = rootI + size[rootI] += size[rootJ] + } + } + + fun minMalwareSpread(graph: Array, initial: IntArray): Int { + val n = graph.size + parent = IntArray(n) { it } + size = IntArray(n) { 1 } + for (i in 0 until n) { + for (j in i + 1 until n) { + if (graph[i][j] == 1) { + union(i, j) + } + } + } + val counts = IntArray(n) + for (m in initial) { + counts[find(m)]++ + } + initial.sort() + var ans = initial[0] + var maxSaved = -1 + for (m in initial) { + val root = find(m) + if (counts[root] == 1) { + if (size[root] > maxSaved) { + maxSaved = size[root] + ans = m + } + } + } + return ans + } +} diff --git a/tests/501-1000/924. minimize-malware-spread/sol.py b/tests/501-1000/924. minimize-malware-spread/sol.py new file mode 100644 index 00000000..c3eca244 --- /dev/null +++ b/tests/501-1000/924. minimize-malware-spread/sol.py @@ -0,0 +1,46 @@ +import collections +from typing import List + + +class DisjointSet: + def __init__(self, n): + self.parent = list(range(n)) + self.size = [1] * n + + def find(self, i): + if self.parent[i] == i: + return i + self.parent[i] = self.find(self.parent[i]) + return self.parent[i] + + def union(self, i, j): + root_i, root_j = self.find(i), self.find(j) + if root_i != root_j: + if self.size[root_i] < self.size[root_j]: + root_i, root_j = root_j, root_i + self.parent[root_j] = root_i + self.size[root_i] += self.size[root_j] + + +class Solution: + def minMalwareSpread(self, graph: List[List[int]], initial: List[int]) -> int: + n = len(graph) + ds = DisjointSet(n) + for i in range(n): + for j in range(i + 1, n): + if graph[i][j]: + ds.union(i, j) + + counts = collections.Counter(ds.find(m) for m in initial) + initial.sort() + + ans = initial[0] + max_saved = -1 + + for m in initial: + root = ds.find(m) + if counts[root] == 1: + if ds.size[root] > max_saved: + max_saved = ds.size[root] + ans = m + return ans diff --git a/tests/501-1000/924. minimize-malware-spread/sol.py2 b/tests/501-1000/924. minimize-malware-spread/sol.py2 new file mode 100644 index 00000000..c7ee3364 --- /dev/null +++ b/tests/501-1000/924. minimize-malware-spread/sol.py2 @@ -0,0 +1,38 @@ +class Solution(object): + def minMalwareSpread(self, graph, initial): + """ + :type graph: List[List[int]] + :type initial: List[int] + :rtype: int + """ + n = len(graph) + parent = list(range(n)) + size = [1] * n + def find(i): + while parent[i] != i: + parent[i] = parent[parent[i]] + i = parent[i] + return i + def union(i, j): + root_i, root_j = find(i), find(j) + if root_i != root_j: + if size[root_i] < size[root_j]: + root_i, root_j = root_j, root_i + parent[root_j] = root_i + size[root_i] += size[root_j] + for i in range(n): + for j in range(i + 1, n): + if graph[i][j]: + union(i, j) + from collections import Counter + counts = Counter(find(m) for m in initial) + initial.sort() + ans = initial[0] + max_saved = -1 + for m in initial: + root = find(m) + if counts[root] == 1: + if size[root] > max_saved: + max_saved = size[root] + ans = m + return ans diff --git a/tests/501-1000/924. minimize-malware-spread/sol.rb b/tests/501-1000/924. minimize-malware-spread/sol.rb new file mode 100644 index 00000000..0d8f29e1 --- /dev/null +++ b/tests/501-1000/924. minimize-malware-spread/sol.rb @@ -0,0 +1,46 @@ +# @param {Integer[][]} graph +# @param {Integer[]} initial +# @return {Integer} +def min_malware_spread(graph, initial) + n = graph.length + parent = Array.new(n) { |i| i } + size = Array.new(n, 1) + find = lambda do |i| + while parent[i] != i + parent[i] = parent[parent[i]] + i = parent[i] + end + i + end + union = lambda do |i, j| + root_i = find.call(i) + root_j = find.call(j) + if root_i != root_j + if size[root_i] < size[root_j] + root_i, root_j = root_j, root_i + end + parent[root_j] = root_i + size[root_i] += size[root_j] + end + end + (0...n).each do |i| + (i+1...n).each do |j| + union.call(i, j) if graph[i][j] == 1 + end + end + counts = Hash.new(0) + initial.each { |m| counts[find.call(m)] += 1 } + initial.sort! + ans = initial[0] + max_saved = -1 + initial.each do |m| + root = find.call(m) + if counts[root] == 1 + if size[root] > max_saved + max_saved = size[root] + ans = m + end + end + end + ans +end diff --git a/tests/501-1000/924. minimize-malware-spread/sol.rs b/tests/501-1000/924. minimize-malware-spread/sol.rs new file mode 100644 index 00000000..41549135 --- /dev/null +++ b/tests/501-1000/924. minimize-malware-spread/sol.rs @@ -0,0 +1,60 @@ +impl Solution { + pub fn min_malware_spread(graph: Vec>, initial: Vec) -> i32 { + let n = graph.len(); + let mut parent: Vec = (0..n).collect(); + let mut size: Vec = vec![1; n]; + + fn find(parent: &mut Vec, i: usize) -> usize { + let mut x = i; + while parent[x] != x { + parent[x] = parent[parent[x]]; + x = parent[x]; + } + x + } + + fn union(parent: &mut Vec, size: &mut Vec, i: usize, j: usize) { + let mut root_i = find(parent, i); + let mut root_j = find(parent, j); + if root_i != root_j { + if size[root_i] < size[root_j] { + std::mem::swap(&mut root_i, &mut root_j); + } + parent[root_j] = root_i; + size[root_i] += size[root_j]; + } + } + + for i in 0..n { + for j in (i + 1)..n { + if graph[i][j] == 1 { + union(&mut parent, &mut size, i, j); + } + } + } + + use std::collections::HashMap; + let mut counts: HashMap = HashMap::new(); + for &m in &initial { + let root = find(&mut parent, m as usize); + *counts.entry(root).or_insert(0) += 1; + } + + let mut initial = initial.clone(); + initial.sort(); + let mut ans = initial[0]; + let mut max_saved = -1; + + for &m in &initial { + let root = find(&mut parent, m as usize); + if counts[&root] == 1 { + if size[root] > max_saved { + max_saved = size[root]; + ans = m; + } + } + } + + ans + } +} diff --git a/tests/501-1000/924. minimize-malware-spread/sol.swift b/tests/501-1000/924. minimize-malware-spread/sol.swift new file mode 100644 index 00000000..0b5ce9fa --- /dev/null +++ b/tests/501-1000/924. minimize-malware-spread/sol.swift @@ -0,0 +1,58 @@ +class Solution { + func minMalwareSpread(_ graph: [[Int]], _ initial: [Int]) -> Int { + let n = graph.count + var parent = Array(0.. Int { + var x = i + while parent[x] != x { + parent[x] = parent[parent[x]] + x = parent[x] + } + return x + } + + func union(_ i: Int, _ j: Int) { + var rootI = find(i) + var rootJ = find(j) + if rootI != rootJ { + if size[rootI] < size[rootJ] { + swap(&rootI, &rootJ) + } + parent[rootJ] = rootI + size[rootI] += size[rootJ] + } + } + + for i in 0.. maxSaved { + maxSaved = size[root] + ans = m + } + } + } + + return ans + } +} diff --git a/tests/501-1000/924. minimize-malware-spread/sol.ts b/tests/501-1000/924. minimize-malware-spread/sol.ts new file mode 100644 index 00000000..6e0e8d5a --- /dev/null +++ b/tests/501-1000/924. minimize-malware-spread/sol.ts @@ -0,0 +1,55 @@ +function minMalwareSpread(graph: number[][], initial: number[]): number { + const n = graph.length; + const parent: number[] = Array.from({ length: n }, (_, i) => i); + const size: number[] = Array(n).fill(1); + + function find(i: number): number { + while (parent[i] !== i) { + parent[i] = parent[parent[i]]; + i = parent[i]; + } + return i; + } + + function union(i: number, j: number): void { + let rootI = find(i); + let rootJ = find(j); + if (rootI !== rootJ) { + if (size[rootI] < size[rootJ]) { + [rootI, rootJ] = [rootJ, rootI]; + } + parent[rootJ] = rootI; + size[rootI] += size[rootJ]; + } + } + + for (let i = 0; i < n; i++) { + for (let j = i + 1; j < n; j++) { + if (graph[i][j] === 1) { + union(i, j); + } + } + } + + const counts: Map = new Map(); + for (const m of initial) { + const root = find(m); + counts.set(root, (counts.get(root) || 0) + 1); + } + + initial.sort((a, b) => a - b); + let ans = initial[0]; + let maxSaved = -1; + + for (const m of initial) { + const root = find(m); + if (counts.get(root) === 1) { + if (size[root] > maxSaved) { + maxSaved = size[root]; + ans = m; + } + } + } + + return ans; +} diff --git a/tests/501-1000/925. long-pressed-name/manifest.yaml b/tests/501-1000/925. long-pressed-name/manifest.yaml new file mode 100644 index 00000000..b44572db --- /dev/null +++ b/tests/501-1000/925. long-pressed-name/manifest.yaml @@ -0,0 +1,244 @@ +entry: + id: 925 + title: long-pressed-name + params: + name: + type: string + typed: + type: string + call: + cpp: "Solution().isLongPressedName({name}, {typed})" + rust: "Solution::is_long_pressed_name({name}, {typed})" + python3: "Solution().isLongPressedName({name}, {typed})" + python2: "Solution().isLongPressedName({name}, {typed})" + ruby: "is_long_pressed_name({name}, {typed})" + java: "new Solution().isLongPressedName({name}, {typed})" + csharp: "new Solution().IsLongPressedName({name}, {typed})" + kotlin: "Solution().isLongPressedName({name}, {typed})" + go: "isLongPressedName({name}, {typed})" + dart: "Solution().isLongPressedName({name}, {typed})" + swift: "Solution().isLongPressedName({name}, {typed})" + typescript: "isLongPressedName({name}, {typed})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().isLongPressedName(name, typed, {result})" + checker: | + class Checker: + def isLongPressedName(self, name, typed, result): + i = j = 0 + while j < len(typed): + if i < len(name) and name[i] == typed[j]: + i += 1 + j += 1 + elif j > 0 and typed[j] == typed[j - 1]: + j += 1 + else: + return result == False + return result == (i == len(name)) +seed: 925 +tests: + - name: ex1 + in: + name: alex + typed: aaleex + out: true + - name: ex2 + in: + name: saeed + typed: ssaaedd + out: false + - name: single_char_true + in: + name: a + typed: a + out: true + - name: single_char_long + in: + name: a + typed: aaaaa + out: true + - name: prefix_missing + in: + name: py + typed: ppyy + out: true + - name: mismatch_middle + in: + name: abcd + typed: aabbccdde + out: false + - name: extra_char_wrong_place + in: + name: ab + typed: aaab + out: true + - name: wrong_order + in: + name: abc + typed: abdc + out: false + - name: exact_match + in: + name: leetcode + typed: leetcode + out: true + - name: repeated_blocks + in: + name: vtkgn + typed: vvvtttkkkgggnn + out: true + - name: missing_tail + in: + name: qwer + typed: qqwwee + out: false + - name: repeated_first + in: + name: hello + typed: hheelllloo + out: true + - name: repeated_last + in: + name: z + typed: zz + out: true + - name: skip_char + in: + name: abc + typed: aabbcc + out: true + - name: impossible_insert + in: + name: abc + typed: abbcx + out: false + - name: exact_pair + in: + name: ab + typed: ab + out: true + - name: repeated_first_block + in: + name: ab + typed: aab + out: true + - name: repeated_last_block + in: + name: ab + typed: abb + out: true + - name: three_letters_ok + in: + name: abc + typed: aabbcc + out: true + - name: third_letter_repeated + in: + name: abc + typed: abcc + out: true + - name: third_letter_overlong + in: + name: abc + typed: abccc + out: true + - name: missing_middle + in: + name: abc + typed: ac + out: false + - name: split_runs + in: + name: abcd + typed: abbccdd + out: true + - name: missing_one_run_end + in: + name: abcd + typed: aabbccd + out: true + - name: all_long_pressed + in: + name: abcd + typed: aaaabbbbccccdddd + out: true + - name: single_repeated + in: + name: x + typed: xxx + out: true + - name: three_blocks + in: + name: mno + typed: mmnnnooo + out: true + - name: classic_true + in: + name: hello + typed: heeellooo + out: true + - name: classic_false + in: + name: hello + typed: helo + out: false + - name: extra_suffix + in: + name: alex + typed: aaleexa + out: false + - name: repeated_vowels + in: + name: qwerty + typed: qwwerrtty + out: true + - name: prefix_then_repeat + in: + name: aab + typed: aaab + out: true + - name: all_tripled + in: + name: abc + typed: aaabbbccc + out: true + - name: wrong_order + in: + name: ab + typed: baa + out: false + - name: same_string + in: + name: abc + typed: abc + out: true + - name: missing_inner_char + in: + name: abcd + typed: abccd + out: true + - name: large_oracle_a + in: + name: + gen: "str" + len: 1000 + alphabet: "abc" + typed: + gen: "str" + len: 1000 + alphabet: "abc" + - name: large_oracle_b + in: + name: + gen: "str" + len: 1000 + alphabet: "abc" + typed: + gen: "str" + len: 1000 + alphabet: "abc" diff --git a/tests/501-1000/925. long-pressed-name/sol.cpp b/tests/501-1000/925. long-pressed-name/sol.cpp new file mode 100644 index 00000000..9095ae27 --- /dev/null +++ b/tests/501-1000/925. long-pressed-name/sol.cpp @@ -0,0 +1,20 @@ +class Solution { +public: + bool isLongPressedName(string name, string typed) { + int i = 0; + int j = 0; + + while (j < typed.length()) { + if (i < name.length() && name[i] == typed[j]) { + i++; + j++; + } else if (j > 0 && typed[j] == typed[j - 1]) { + j++; + } else { + return false; + } + } + + return i == name.length(); + } +}; diff --git a/tests/501-1000/925. long-pressed-name/sol.cs b/tests/501-1000/925. long-pressed-name/sol.cs new file mode 100644 index 00000000..5bb05084 --- /dev/null +++ b/tests/501-1000/925. long-pressed-name/sol.cs @@ -0,0 +1,19 @@ +public class Solution { + public bool IsLongPressedName(string name, string typed) { + int i = 0; + int j = 0; + + while (j < typed.Length) { + if (i < name.Length && name[i] == typed[j]) { + i++; + j++; + } else if (j > 0 && typed[j] == typed[j - 1]) { + j++; + } else { + return false; + } + } + + return i == name.Length; + } +} diff --git a/tests/501-1000/925. long-pressed-name/sol.dart b/tests/501-1000/925. long-pressed-name/sol.dart new file mode 100644 index 00000000..7296c19e --- /dev/null +++ b/tests/501-1000/925. long-pressed-name/sol.dart @@ -0,0 +1,19 @@ +class Solution { + bool isLongPressedName(String name, String typed) { + int i = 0; + int j = 0; + + while (j < typed.length) { + if (i < name.length && name[i] == typed[j]) { + i++; + j++; + } else if (j > 0 && typed[j] == typed[j - 1]) { + j++; + } else { + return false; + } + } + + return i == name.length; + } +} diff --git a/tests/501-1000/925. long-pressed-name/sol.go b/tests/501-1000/925. long-pressed-name/sol.go new file mode 100644 index 00000000..d54513e9 --- /dev/null +++ b/tests/501-1000/925. long-pressed-name/sol.go @@ -0,0 +1,17 @@ +func isLongPressedName(name string, typed string) bool { + i := 0 + j := 0 + + for j < len(typed) { + if i < len(name) && name[i] == typed[j] { + i++ + j++ + } else if j > 0 && typed[j] == typed[j-1] { + j++ + } else { + return false + } + } + + return i == len(name) +} diff --git a/tests/501-1000/925. long-pressed-name/sol.java b/tests/501-1000/925. long-pressed-name/sol.java new file mode 100644 index 00000000..7984b320 --- /dev/null +++ b/tests/501-1000/925. long-pressed-name/sol.java @@ -0,0 +1,19 @@ +class Solution { + public boolean isLongPressedName(String name, String typed) { + int i = 0; + int j = 0; + + while (j < typed.length()) { + if (i < name.length() && name.charAt(i) == typed.charAt(j)) { + i++; + j++; + } else if (j > 0 && typed.charAt(j) == typed.charAt(j - 1)) { + j++; + } else { + return false; + } + } + + return i == name.length(); + } +} diff --git a/tests/501-1000/925. long-pressed-name/sol.kt b/tests/501-1000/925. long-pressed-name/sol.kt new file mode 100644 index 00000000..587a875a --- /dev/null +++ b/tests/501-1000/925. long-pressed-name/sol.kt @@ -0,0 +1,19 @@ +class Solution { + fun isLongPressedName(name: String, typed: String): Boolean { + var i = 0 + var j = 0 + + while (j < typed.length) { + if (i < name.length && name[i] == typed[j]) { + i++ + j++ + } else if (j > 0 && typed[j] == typed[j - 1]) { + j++ + } else { + return false + } + } + + return i == name.length + } +} diff --git a/tests/501-1000/925. long-pressed-name/sol.py b/tests/501-1000/925. long-pressed-name/sol.py new file mode 100644 index 00000000..61c3b6bb --- /dev/null +++ b/tests/501-1000/925. long-pressed-name/sol.py @@ -0,0 +1,15 @@ +class Solution: + def isLongPressedName(self, name: str, typed: str) -> bool: + i = 0 + j = 0 + + while j < len(typed): + if i < len(name) and name[i] == typed[j]: + i += 1 + j += 1 + elif j > 0 and typed[j] == typed[j - 1]: + j += 1 + else: + return False + + return i == len(name) diff --git a/tests/501-1000/925. long-pressed-name/sol.py2 b/tests/501-1000/925. long-pressed-name/sol.py2 new file mode 100644 index 00000000..0177342b --- /dev/null +++ b/tests/501-1000/925. long-pressed-name/sol.py2 @@ -0,0 +1,20 @@ +class Solution(object): + def isLongPressedName(self, name, typed): + """ + :type name: str + :type typed: str + :rtype: bool + """ + i = 0 + j = 0 + + while j < len(typed): + if i < len(name) and name[i] == typed[j]: + i += 1 + j += 1 + elif j > 0 and typed[j] == typed[j - 1]: + j += 1 + else: + return False + + return i == len(name) diff --git a/tests/501-1000/925. long-pressed-name/sol.rb b/tests/501-1000/925. long-pressed-name/sol.rb new file mode 100644 index 00000000..50596f4f --- /dev/null +++ b/tests/501-1000/925. long-pressed-name/sol.rb @@ -0,0 +1,20 @@ +# @param {String} name +# @param {String} typed +# @return {Boolean} +def is_long_pressed_name(name, typed) + i = 0 + j = 0 + + while j < typed.length + if i < name.length && name[i] == typed[j] + i += 1 + j += 1 + elsif j > 0 && typed[j] == typed[j - 1] + j += 1 + else + return false + end + end + + return i == name.length +end diff --git a/tests/501-1000/925. long-pressed-name/sol.rs b/tests/501-1000/925. long-pressed-name/sol.rs new file mode 100644 index 00000000..c591e240 --- /dev/null +++ b/tests/501-1000/925. long-pressed-name/sol.rs @@ -0,0 +1,21 @@ +impl Solution { + pub fn is_long_pressed_name(name: String, typed: String) -> bool { + let name: Vec = name.chars().collect(); + let typed: Vec = typed.chars().collect(); + let mut i = 0; + let mut j = 0; + + while j < typed.len() { + if i < name.len() && name[i] == typed[j] { + i += 1; + j += 1; + } else if j > 0 && typed[j] == typed[j - 1] { + j += 1; + } else { + return false; + } + } + + return i == name.len(); + } +} diff --git a/tests/501-1000/925. long-pressed-name/sol.swift b/tests/501-1000/925. long-pressed-name/sol.swift new file mode 100644 index 00000000..35389535 --- /dev/null +++ b/tests/501-1000/925. long-pressed-name/sol.swift @@ -0,0 +1,21 @@ +class Solution { + func isLongPressedName(_ name: String, _ typed: String) -> Bool { + let nameChars = Array(name) + let typedChars = Array(typed) + var i = 0 + var j = 0 + + while j < typedChars.count { + if i < nameChars.count && nameChars[i] == typedChars[j] { + i += 1 + j += 1 + } else if j > 0 && typedChars[j] == typedChars[j - 1] { + j += 1 + } else { + return false + } + } + + return i == nameChars.count + } +} diff --git a/tests/501-1000/925. long-pressed-name/sol.ts b/tests/501-1000/925. long-pressed-name/sol.ts new file mode 100644 index 00000000..04458456 --- /dev/null +++ b/tests/501-1000/925. long-pressed-name/sol.ts @@ -0,0 +1,17 @@ +function isLongPressedName(name: string, typed: string): boolean { + let i = 0; + let j = 0; + + while (j < typed.length) { + if (i < name.length && name[i] === typed[j]) { + i++; + j++; + } else if (j > 0 && typed[j] === typed[j - 1]) { + j++; + } else { + return false; + } + } + + return i === name.length; +} diff --git a/tests/501-1000/926. flip-string-to-monotone-increasing/manifest.yaml b/tests/501-1000/926. flip-string-to-monotone-increasing/manifest.yaml new file mode 100644 index 00000000..0c3f8947 --- /dev/null +++ b/tests/501-1000/926. flip-string-to-monotone-increasing/manifest.yaml @@ -0,0 +1,213 @@ +entry: + id: 926 + title: flip-string-to-monotone-increasing + params: + s: + type: string + call: + cpp: "Solution().minFlipsMonoIncr({s})" + rust: "Solution::min_flips_mono_incr({s})" + python3: "Solution().minFlipsMonoIncr({s})" + python2: "Solution().minFlipsMonoIncr({s})" + ruby: "min_flips_mono_incr({s})" + java: "new Solution().minFlipsMonoIncr({s})" + csharp: "new Solution().MinFlipsMonoIncr({s})" + kotlin: "Solution().minFlipsMonoIncr({s})" + go: "minFlipsMonoIncr({s})" + dart: "Solution().minFlipsMonoIncr({s})" + swift: "Solution().minFlipsMonoIncr({s})" + typescript: "minFlipsMonoIncr({s})" +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().minFlipsMonoIncr(s, {result})" + checker: | + class Checker: + def minFlipsMonoIncr(self, s, result): + ones = 0 + flips = 0 + best = 0 + for ch in s: + if ch == '1': + ones += 1 + else: + flips += 1 + if flips > ones: + flips = ones + best = max(best, 0) + zeroes = 0 + ones = 0 + for ch in s: + if ch == '0': + zeroes += 1 + best = zeroes + for ch in s: + if ch == '0': + zeroes -= 1 + else: + ones += 1 + if zeroes + ones < best: + best = zeroes + ones + return result == best +seed: 926 +tests: + - name: ex1 + in: + s: "00110" + out: 1 + - name: ex2 + in: + s: "010110" + out: 2 + - name: ex3 + in: + s: "00011000" + out: 2 + - name: single_zero + in: + s: "0" + out: 0 + - name: single_one + in: + s: "1" + out: 0 + - name: already_monotone_zeros + in: + s: "0000000" + out: 0 + - name: already_monotone_ones + in: + s: "1111111" + out: 0 + - name: alternating_short + in: + s: "0101" + out: 1 + - name: alternating_long + in: + s: "01010101" + out: 3 + - name: ones_then_zeros + in: + s: "111000" + out: 3 + - name: zeros_then_ones + in: + s: "000111" + out: 0 + - name: one_flip_middle + in: + s: "0010111" + out: 1 + - name: two_blocks + in: + s: "110011" + out: 2 + - name: many_zeros_then_one + in: + s: "0000000001" + out: 0 + - name: many_ones_then_zero + in: + s: "1111111110" + out: 1 + - name: balanced_mix + in: + s: "1001110010" + out: 4 + - name: empty_prefix_style + in: + s: "00" + out: 0 + - name: two_bits_flip + in: + s: "10" + out: 1 + - name: short_mono + in: + s: "01" + out: 0 + - name: four_zeros + in: + s: "0000" + out: 0 + - name: four_ones + in: + s: "1111" + out: 0 + - name: one_transition + in: + s: "00001111" + out: 0 + - name: reverse_transition + in: + s: "11110000" + out: 4 + - name: alternating_odd + in: + s: "01010" + out: 2 + - name: alternating_even + in: + s: "101010" + out: 3 + - name: block_three + in: + s: "00111" + out: 0 + - name: block_three_flip + in: + s: "11000" + out: 2 + - name: centered_island + in: + s: "0001000" + out: 1 + - name: centered_one_block + in: + s: "1110111" + out: 1 + - name: long_pattern_a + in: + s: "000111000111" + out: 3 + - name: long_pattern_b + in: + s: "0011110000" + out: 4 + - name: long_pattern_c + in: + s: "111110000011111" + out: 5 + - name: prefix_one + in: + s: "100000" + out: 1 + - name: suffix_one + in: + s: "0111110" + out: 1 + - name: zipper + in: + s: "0101010101" + out: 4 + - name: all_mixed_small + in: + s: "1001110010" + out: 4 + - name: large_oracle_a + in: + s: + gen: "str" + len: 100000 + alphabet: "01" + - name: large_oracle_b + in: + s: + gen: "str" + len: 99999 + alphabet: "01" diff --git a/tests/501-1000/926. flip-string-to-monotone-increasing/sol.cpp b/tests/501-1000/926. flip-string-to-monotone-increasing/sol.cpp new file mode 100644 index 00000000..ca91db8c --- /dev/null +++ b/tests/501-1000/926. flip-string-to-monotone-increasing/sol.cpp @@ -0,0 +1,26 @@ +class Solution { +public: + int minFlipsMonoIncr(string s) { + int zeroes = 0; + int ones = 0; + + for (char ch : s) { + if (ch == '0') { + zeroes++; + } + } + + int output = zeroes; + + for (char ch : s) { + if (ch == '0') { + zeroes--; + } else if (ch == '1') { + ones++; + } + output = min(output, zeroes + ones); + } + + return output; + } +}; diff --git a/tests/501-1000/926. flip-string-to-monotone-increasing/sol.cs b/tests/501-1000/926. flip-string-to-monotone-increasing/sol.cs new file mode 100644 index 00000000..2eb5e58f --- /dev/null +++ b/tests/501-1000/926. flip-string-to-monotone-increasing/sol.cs @@ -0,0 +1,25 @@ +public class Solution { + public int MinFlipsMonoIncr(string s) { + int zeroes = 0; + int ones = 0; + + foreach (char ch in s) { + if (ch == '0') { + zeroes++; + } + } + + int output = zeroes; + + foreach (char ch in s) { + if (ch == '0') { + zeroes--; + } else if (ch == '1') { + ones++; + } + output = Math.Min(output, zeroes + ones); + } + + return output; + } +} diff --git a/tests/501-1000/926. flip-string-to-monotone-increasing/sol.dart b/tests/501-1000/926. flip-string-to-monotone-increasing/sol.dart new file mode 100644 index 00000000..1317cd7d --- /dev/null +++ b/tests/501-1000/926. flip-string-to-monotone-increasing/sol.dart @@ -0,0 +1,25 @@ +class Solution { + int minFlipsMonoIncr(String s) { + int zeroes = 0; + int ones = 0; + + for (int i = 0; i < s.length; i++) { + if (s[i] == '0') { + zeroes++; + } + } + + int output = zeroes; + + for (int i = 0; i < s.length; i++) { + if (s[i] == '0') { + zeroes--; + } else if (s[i] == '1') { + ones++; + } + output = output < (zeroes + ones) ? output : (zeroes + ones); + } + + return output; + } +} diff --git a/tests/501-1000/926. flip-string-to-monotone-increasing/sol.go b/tests/501-1000/926. flip-string-to-monotone-increasing/sol.go new file mode 100644 index 00000000..f9aeab57 --- /dev/null +++ b/tests/501-1000/926. flip-string-to-monotone-increasing/sol.go @@ -0,0 +1,25 @@ +func minFlipsMonoIncr(s string) int { + zeroes := 0 + ones := 0 + + for _, ch := range s { + if ch == '0' { + zeroes++ + } + } + + output := zeroes + + for _, ch := range s { + if ch == '0' { + zeroes-- + } else if ch == '1' { + ones++ + } + if zeroes+ones < output { + output = zeroes + ones + } + } + + return output +} diff --git a/tests/501-1000/926. flip-string-to-monotone-increasing/sol.java b/tests/501-1000/926. flip-string-to-monotone-increasing/sol.java new file mode 100644 index 00000000..bb8c7229 --- /dev/null +++ b/tests/501-1000/926. flip-string-to-monotone-increasing/sol.java @@ -0,0 +1,25 @@ +class Solution { + public int minFlipsMonoIncr(String s) { + int zeroes = 0; + int ones = 0; + + for (int i = 0; i < s.length(); i++) { + if (s.charAt(i) == '0') { + zeroes++; + } + } + + int output = zeroes; + + for (int i = 0; i < s.length(); i++) { + if (s.charAt(i) == '0') { + zeroes--; + } else if (s.charAt(i) == '1') { + ones++; + } + output = Math.min(output, zeroes + ones); + } + + return output; + } +} diff --git a/tests/501-1000/926. flip-string-to-monotone-increasing/sol.kt b/tests/501-1000/926. flip-string-to-monotone-increasing/sol.kt new file mode 100644 index 00000000..7ec1bca4 --- /dev/null +++ b/tests/501-1000/926. flip-string-to-monotone-increasing/sol.kt @@ -0,0 +1,25 @@ +class Solution { + fun minFlipsMonoIncr(s: String): Int { + var zeroes = 0 + var ones = 0 + + for (ch in s) { + if (ch == '0') { + zeroes++ + } + } + + var output = zeroes + + for (ch in s) { + if (ch == '0') { + zeroes-- + } else if (ch == '1') { + ones++ + } + output = minOf(output, zeroes + ones) + } + + return output + } +} diff --git a/tests/501-1000/926. flip-string-to-monotone-increasing/sol.py b/tests/501-1000/926. flip-string-to-monotone-increasing/sol.py new file mode 100644 index 00000000..002e5906 --- /dev/null +++ b/tests/501-1000/926. flip-string-to-monotone-increasing/sol.py @@ -0,0 +1,32 @@ +class Solution: + """ + Time Complexity: O(n) where n is the length of string s + - We iterate through the string twice, each taking O(n) time + + Space Complexity: O(1) + - We only use a constant amount of extra space regardless of input size + - No additional data structures that scale with input + """ + + def minFlipsMonoIncr(self, s: str) -> int: + zeroes = 0 + ones = 0 + + # First pass: count total zeroes + for ch in s: + if ch == "0": + zeroes += 1 + + output = zeroes # Initialize with flipping all zeroes to ones + + # Second pass: find minimum flips needed + for ch in s: + if ch == "0": + zeroes -= ( + 1 # One less zero to flip if we include this position in prefix + ) + elif ch == "1": + ones += 1 # Need to flip this one to zero if in prefix + output = min(output, zeroes + ones) + + return output diff --git a/tests/501-1000/926. flip-string-to-monotone-increasing/sol.py2 b/tests/501-1000/926. flip-string-to-monotone-increasing/sol.py2 new file mode 100644 index 00000000..8951ec88 --- /dev/null +++ b/tests/501-1000/926. flip-string-to-monotone-increasing/sol.py2 @@ -0,0 +1,23 @@ +class Solution(object): + def minFlipsMonoIncr(self, s): + """ + :type s: str + :rtype: int + """ + zeroes = 0 + ones = 0 + + for ch in s: + if ch == '0': + zeroes += 1 + + output = zeroes + + for ch in s: + if ch == '0': + zeroes -= 1 + elif ch == '1': + ones += 1 + output = min(output, zeroes + ones) + + return output diff --git a/tests/501-1000/926. flip-string-to-monotone-increasing/sol.rb b/tests/501-1000/926. flip-string-to-monotone-increasing/sol.rb new file mode 100644 index 00000000..89940386 --- /dev/null +++ b/tests/501-1000/926. flip-string-to-monotone-increasing/sol.rb @@ -0,0 +1,25 @@ +# @param {String} s +# @return {Integer} +def min_flips_mono_incr(s) + zeroes = 0 + ones = 0 + + s.each_char do |ch| + if ch == '0' + zeroes += 1 + end + end + + output = zeroes + + s.each_char do |ch| + if ch == '0' + zeroes -= 1 + elsif ch == '1' + ones += 1 + end + output = [output, zeroes + ones].min + end + + output +end diff --git a/tests/501-1000/926. flip-string-to-monotone-increasing/sol.rs b/tests/501-1000/926. flip-string-to-monotone-increasing/sol.rs new file mode 100644 index 00000000..dfadc0eb --- /dev/null +++ b/tests/501-1000/926. flip-string-to-monotone-increasing/sol.rs @@ -0,0 +1,25 @@ +impl Solution { + pub fn min_flips_mono_incr(s: String) -> i32 { + let mut zeroes = 0; + let mut ones = 0; + + for ch in s.chars() { + if ch == '0' { + zeroes += 1; + } + } + + let mut output = zeroes; + + for ch in s.chars() { + if ch == '0' { + zeroes -= 1; + } else if ch == '1' { + ones += 1; + } + output = output.min(zeroes + ones); + } + + output + } +} diff --git a/tests/501-1000/926. flip-string-to-monotone-increasing/sol.swift b/tests/501-1000/926. flip-string-to-monotone-increasing/sol.swift new file mode 100644 index 00000000..b7469ef0 --- /dev/null +++ b/tests/501-1000/926. flip-string-to-monotone-increasing/sol.swift @@ -0,0 +1,25 @@ +class Solution { + func minFlipsMonoIncr(_ s: String) -> Int { + var zeroes = 0 + var ones = 0 + + for ch in s { + if ch == "0" { + zeroes += 1 + } + } + + var output = zeroes + + for ch in s { + if ch == "0" { + zeroes -= 1 + } else if ch == "1" { + ones += 1 + } + output = min(output, zeroes + ones) + } + + return output + } +} diff --git a/tests/501-1000/926. flip-string-to-monotone-increasing/sol.ts b/tests/501-1000/926. flip-string-to-monotone-increasing/sol.ts new file mode 100644 index 00000000..1015e628 --- /dev/null +++ b/tests/501-1000/926. flip-string-to-monotone-increasing/sol.ts @@ -0,0 +1,23 @@ +function minFlipsMonoIncr(s: string): number { + let zeroes = 0; + let ones = 0; + + for (const ch of s) { + if (ch === "0") { + zeroes++; + } + } + + let output = zeroes; + + for (const ch of s) { + if (ch === "0") { + zeroes--; + } else if (ch === "1") { + ones++; + } + output = Math.min(output, zeroes + ones); + } + + return output; +} diff --git a/tests/501-1000/927. three-equal-parts/manifest.yaml b/tests/501-1000/927. three-equal-parts/manifest.yaml new file mode 100644 index 00000000..12d7ad78 --- /dev/null +++ b/tests/501-1000/927. three-equal-parts/manifest.yaml @@ -0,0 +1,177 @@ +entry: + id: 927 + title: three-equal-parts + params: + arr: + type: array + items: + type: int + call: + cpp: "Solution().threeEqualParts({arr})" + rust: "Solution::three_equal_parts({arr})" + python3: "Solution().threeEqualParts({arr})" + python2: "Solution().threeEqualParts({arr})" + ruby: "three_equal_parts({arr})" + java: "new Solution().threeEqualParts({arr})" + csharp: "new Solution().ThreeEqualParts({arr})" + kotlin: "Solution().threeEqualParts({arr})" + go: "threeEqualParts({arr})" + dart: "Solution().threeEqualParts({arr})" + swift: "Solution().threeEqualParts({arr})" + typescript: "threeEqualParts({arr})" +judge: + type: "exact" +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().threeEqualParts(arr, {result})" + checker: | + class Checker: + def threeEqualParts(self, arr, result): + if not isinstance(result, list) or len(result) != 2: + return False + n = len(arr) + if result == [-1, -1]: + for i in range(n): + for j in range(i + 2, n): + a = arr[:i + 1] + b = arr[i + 1:j] + c = arr[j:] + def norm(x): + k = 0 + while k < len(x) and x[k] == 0: + k += 1 + return x[k:] + if len(a) and len(b) and len(c) and norm(a) == norm(b) == norm(c): + return False + return True + i, j = result + if not (0 <= i < j - 1 < n): + return False + a = arr[:i + 1] + b = arr[i + 1:j] + c = arr[j:] + def norm(x): + k = 0 + while k < len(x) and x[k] == 0: + k += 1 + return x[k:] + return len(a) > 0 and len(b) > 0 and len(c) > 0 and norm(a) == norm(b) == norm(c) +seed: 927 +tests: + - name: ex1 + in: + arr: [1, 0, 1, 0, 1] + - name: ex2 + in: + arr: [1, 1, 0, 1, 1] + - name: ex3 + in: + arr: [1, 1, 0, 0, 1] + - name: all_zeros_3 + in: + arr: [0, 0, 0] + - name: all_zeros_6 + in: + arr: [0, 0, 0, 0, 0, 0] + - name: one_one_exact + in: + arr: [1, 0, 0] + - name: two_ones_impossible + in: + arr: [1, 0, 1] + - name: simple_possible_1 + in: + arr: [1, 0, 0, 1, 0, 0, 1] + - name: simple_possible_2 + in: + arr: [0, 1, 0, 1, 0, 1, 0] + - name: simple_impossible_1 + in: + arr: [1, 1, 1] + - name: simple_impossible_2 + in: + arr: [1, 0, 1, 1, 0, 1] + - name: trailing_zeros_1 + in: + arr: [1, 0, 1, 0, 1, 0, 0] + - name: trailing_zeros_2 + in: + arr: [1, 0, 1, 0, 1, 0, 0, 0, 0] + - name: leading_zeros_1 + in: + arr: [0, 0, 1, 0, 0, 1, 0, 0, 1] + - name: leading_zeros_2 + in: + arr: [0, 0, 0, 1, 0, 0, 1, 0, 0, 1] + - name: mixed_1 + in: + arr: [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0] + - name: mixed_2 + in: + arr: [0, 1, 0, 0, 0, 1, 0, 0, 0, 1] + - name: mixed_3 + in: + arr: [1, 0, 1, 0, 0, 0, 1] + - name: mixed_4 + in: + arr: [0, 0, 1, 0, 1, 0, 1, 0] + - name: mixed_5 + in: + arr: [1, 1, 0, 0, 0, 0, 0, 1, 1] + - name: mixed_6 + in: + arr: [1, 0, 0, 1, 1, 0, 1, 0] + - name: mixed_7 + in: + arr: [0, 1, 1, 0, 1, 0, 1, 0, 0] + - name: mixed_8 + in: + arr: [1, 0, 0, 1, 0, 1, 0, 1] + - name: mixed_9 + in: + arr: [0, 0, 0, 1, 0, 1, 0, 1, 0] + - name: mixed_10 + in: + arr: [1, 0, 1, 0, 1, 0, 1, 0, 1] + - name: mixed_11 + in: + arr: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] + - name: mixed_12 + in: + arr: [0, 0, 1, 0, 0, 0, 1, 0, 0, 1] + - name: mixed_13 + in: + arr: [1, 0, 0, 1, 0, 0, 1, 0, 0, 0] + - name: mixed_14 + in: + arr: [1, 0, 1, 0, 1, 0, 0, 1] + - name: mixed_15 + in: + arr: [0, 1, 0, 0, 1, 0, 0, 1, 0] + - name: mixed_16 + in: + arr: [1, 0, 0, 1, 0, 0, 1] + - name: mixed_17 + in: + arr: [1, 0, 0, 0, 1, 0, 0, 1, 0, 0] + - name: mixed_18 + in: + arr: [0, 0, 0, 0, 0, 0, 1] + - name: mixed_19 + in: + arr: [1, 0, 1, 0, 1, 0] + - name: mixed_20 + in: + arr: [0, 1, 1, 1, 0] + - name: mixed_21 + in: + arr: [1, 0, 1, 0, 0, 1, 0, 1] + - name: mixed_22 + in: + arr: [0, 0, 1, 1, 0, 0] + - name: mixed_23 + in: + arr: [1, 0, 0, 1, 1, 0, 1, 0] diff --git a/tests/501-1000/927. three-equal-parts/sol.cpp b/tests/501-1000/927. three-equal-parts/sol.cpp new file mode 100644 index 00000000..cf0a0efc --- /dev/null +++ b/tests/501-1000/927. three-equal-parts/sol.cpp @@ -0,0 +1,34 @@ +class Solution { +public: + vector threeEqualParts(vector& arr) { + int n = arr.size(); + int ones = 0; + for (int x : arr) ones += x; + if (ones == 0) return {0, n - 1}; + if (ones % 3 != 0) return {-1, -1}; + + int k = ones / 3; + int i1 = -1, i2 = -1, i3 = -1; + int seen = 0; + for (int i = 0; i < n; i++) { + if (arr[i] == 1) { + seen++; + if (seen == 1) i1 = i; + else if (seen == k + 1) i2 = i; + else if (seen == 2 * k + 1) { + i3 = i; + break; + } + } + } + + int len = n - i3; + if (i1 + len > i2 || i2 + len > i3) return {-1, -1}; + for (int i = 0; i < len; i++) { + if (arr[i1 + i] != arr[i2 + i] || arr[i1 + i] != arr[i3 + i]) { + return {-1, -1}; + } + } + return {i1 + len - 1, i2 + len}; + } +}; diff --git a/tests/501-1000/927. three-equal-parts/sol.cs b/tests/501-1000/927. three-equal-parts/sol.cs new file mode 100644 index 00000000..96d94dcd --- /dev/null +++ b/tests/501-1000/927. three-equal-parts/sol.cs @@ -0,0 +1,33 @@ +public class Solution { + public int[] ThreeEqualParts(int[] arr) { + int n = arr.Length; + int ones = 0; + foreach (int x in arr) ones += x; + if (ones == 0) return new int[] { 0, n - 1 }; + if (ones % 3 != 0) return new int[] { -1, -1 }; + + int k = ones / 3; + int i1 = -1, i2 = -1, i3 = -1; + int seen = 0; + for (int i = 0; i < n; i++) { + if (arr[i] == 1) { + seen++; + if (seen == 1) i1 = i; + else if (seen == k + 1) i2 = i; + else if (seen == 2 * k + 1) { + i3 = i; + break; + } + } + } + + int len = n - i3; + if (i1 + len > i2 || i2 + len > i3) return new int[] { -1, -1 }; + for (int i = 0; i < len; i++) { + if (arr[i1 + i] != arr[i2 + i] || arr[i1 + i] != arr[i3 + i]) { + return new int[] { -1, -1 }; + } + } + return new int[] { i1 + len - 1, i2 + len }; + } +} diff --git a/tests/501-1000/927. three-equal-parts/sol.dart b/tests/501-1000/927. three-equal-parts/sol.dart new file mode 100644 index 00000000..5acf3282 --- /dev/null +++ b/tests/501-1000/927. three-equal-parts/sol.dart @@ -0,0 +1,30 @@ +class Solution { + List threeEqualParts(List arr) { + int n = arr.length; + int ones = arr.fold(0, (sum, x) => sum + x); + if (ones == 0) return [0, n - 1]; + if (ones % 3 != 0) return [-1, -1]; + + int k = ones ~/ 3; + int i1 = -1, i2 = -1, i3 = -1; + int seen = 0; + for (int i = 0; i < n; i++) { + if (arr[i] == 1) { + seen++; + if (seen == 1) i1 = i; + else if (seen == k + 1) i2 = i; + else if (seen == 2 * k + 1) { + i3 = i; + break; + } + } + } + + int len = n - i3; + if (i1 + len > i2 || i2 + len > i3) return [-1, -1]; + for (int i = 0; i < len; i++) { + if (arr[i1 + i] != arr[i2 + i] || arr[i1 + i] != arr[i3 + i]) return [-1, -1]; + } + return [i1 + len - 1, i2 + len]; + } +} diff --git a/tests/501-1000/927. three-equal-parts/sol.go b/tests/501-1000/927. three-equal-parts/sol.go new file mode 100644 index 00000000..b1ec3e14 --- /dev/null +++ b/tests/501-1000/927. three-equal-parts/sol.go @@ -0,0 +1,41 @@ +func threeEqualParts(arr []int) []int { + n := len(arr) + ones := 0 + for _, x := range arr { + ones += x + } + if ones == 0 { + return []int{0, n - 1} + } + if ones%3 != 0 { + return []int{-1, -1} + } + + k := ones / 3 + i1, i2, i3 := -1, -1, -1 + seen := 0 + for i, x := range arr { + if x == 1 { + seen++ + if seen == 1 { + i1 = i + } else if seen == k+1 { + i2 = i + } else if seen == 2*k+1 { + i3 = i + break + } + } + } + + length := n - i3 + if i1+length > i2 || i2+length > i3 { + return []int{-1, -1} + } + for i := 0; i < length; i++ { + if arr[i1+i] != arr[i2+i] || arr[i1+i] != arr[i3+i] { + return []int{-1, -1} + } + } + return []int{i1 + length - 1, i2 + length} +} diff --git a/tests/501-1000/927. three-equal-parts/sol.java b/tests/501-1000/927. three-equal-parts/sol.java new file mode 100644 index 00000000..3e5909ac --- /dev/null +++ b/tests/501-1000/927. three-equal-parts/sol.java @@ -0,0 +1,33 @@ +class Solution { + public int[] threeEqualParts(int[] arr) { + int n = arr.length; + int ones = 0; + for (int x : arr) ones += x; + if (ones == 0) return new int[]{0, n - 1}; + if (ones % 3 != 0) return new int[]{-1, -1}; + + int k = ones / 3; + int i1 = -1, i2 = -1, i3 = -1; + int seen = 0; + for (int i = 0; i < n; i++) { + if (arr[i] == 1) { + seen++; + if (seen == 1) i1 = i; + else if (seen == k + 1) i2 = i; + else if (seen == 2 * k + 1) { + i3 = i; + break; + } + } + } + + int len = n - i3; + if (i1 + len > i2 || i2 + len > i3) return new int[]{-1, -1}; + for (int i = 0; i < len; i++) { + if (arr[i1 + i] != arr[i2 + i] || arr[i1 + i] != arr[i3 + i]) { + return new int[]{-1, -1}; + } + } + return new int[]{i1 + len - 1, i2 + len}; + } +} diff --git a/tests/501-1000/927. three-equal-parts/sol.kt b/tests/501-1000/927. three-equal-parts/sol.kt new file mode 100644 index 00000000..e4b8f594 --- /dev/null +++ b/tests/501-1000/927. three-equal-parts/sol.kt @@ -0,0 +1,34 @@ +class Solution { + fun threeEqualParts(arr: IntArray): IntArray { + val n = arr.size + val ones = arr.sum() + if (ones == 0) return intArrayOf(0, n - 1) + if (ones % 3 != 0) return intArrayOf(-1, -1) + + val k = ones / 3 + var i1 = -1 + var i2 = -1 + var i3 = -1 + var seen = 0 + for (i in arr.indices) { + if (arr[i] == 1) { + seen++ + if (seen == 1) i1 = i + else if (seen == k + 1) i2 = i + else if (seen == 2 * k + 1) { + i3 = i + break + } + } + } + + val len = n - i3 + if (i1 + len > i2 || i2 + len > i3) return intArrayOf(-1, -1) + for (i in 0 until len) { + if (arr[i1 + i] != arr[i2 + i] || arr[i1 + i] != arr[i3 + i]) { + return intArrayOf(-1, -1) + } + } + return intArrayOf(i1 + len - 1, i2 + len) + } +} diff --git a/tests/501-1000/927. three-equal-parts/sol.py b/tests/501-1000/927. three-equal-parts/sol.py new file mode 100644 index 00000000..4a074d50 --- /dev/null +++ b/tests/501-1000/927. three-equal-parts/sol.py @@ -0,0 +1,30 @@ +class Solution: + def threeEqualParts(self, arr): + n = len(arr) + ones = sum(arr) + if ones == 0: + return [0, n - 1] + if ones % 3 != 0: + return [-1, -1] + + k = ones // 3 + i1 = i2 = i3 = -1 + seen = 0 + for i, x in enumerate(arr): + if x == 1: + seen += 1 + if seen == 1: + i1 = i + elif seen == k + 1: + i2 = i + elif seen == 2 * k + 1: + i3 = i + break + + length = n - i3 + if i1 + length > i2 or i2 + length > i3: + return [-1, -1] + for i in range(length): + if arr[i1 + i] != arr[i2 + i] or arr[i1 + i] != arr[i3 + i]: + return [-1, -1] + return [i1 + length - 1, i2 + length] diff --git a/tests/501-1000/927. three-equal-parts/sol.py2 b/tests/501-1000/927. three-equal-parts/sol.py2 new file mode 100644 index 00000000..61be2002 --- /dev/null +++ b/tests/501-1000/927. three-equal-parts/sol.py2 @@ -0,0 +1,30 @@ +class Solution(object): + def threeEqualParts(self, arr): + n = len(arr) + ones = sum(arr) + if ones == 0: + return [0, n - 1] + if ones % 3 != 0: + return [-1, -1] + + k = ones // 3 + i1 = i2 = i3 = -1 + seen = 0 + for i, x in enumerate(arr): + if x == 1: + seen += 1 + if seen == 1: + i1 = i + elif seen == k + 1: + i2 = i + elif seen == 2 * k + 1: + i3 = i + break + + length = n - i3 + if i1 + length > i2 or i2 + length > i3: + return [-1, -1] + for i in range(length): + if arr[i1 + i] != arr[i2 + i] or arr[i1 + i] != arr[i3 + i]: + return [-1, -1] + return [i1 + length - 1, i2 + length] diff --git a/tests/501-1000/927. three-equal-parts/sol.rb b/tests/501-1000/927. three-equal-parts/sol.rb new file mode 100644 index 00000000..e6b4485e --- /dev/null +++ b/tests/501-1000/927. three-equal-parts/sol.rb @@ -0,0 +1,31 @@ +# @param {Integer[]} arr +# @return {Integer[]} +def three_equal_parts(arr) + n = arr.length + ones = arr.sum + return [0, n - 1] if ones == 0 + return [-1, -1] if ones % 3 != 0 + + k = ones / 3 + i1 = i2 = i3 = -1 + seen = 0 + arr.each_with_index do |x, i| + next unless x == 1 + seen += 1 + if seen == 1 + i1 = i + elsif seen == k + 1 + i2 = i + elsif seen == 2 * k + 1 + i3 = i + break + end + end + + len = n - i3 + return [-1, -1] if i1 + len > i2 || i2 + len > i3 + (0...len).each do |i| + return [-1, -1] if arr[i1 + i] != arr[i2 + i] || arr[i1 + i] != arr[i3 + i] + end + [i1 + len - 1, i2 + len] +end diff --git a/tests/501-1000/927. three-equal-parts/sol.rs b/tests/501-1000/927. three-equal-parts/sol.rs new file mode 100644 index 00000000..e05371a8 --- /dev/null +++ b/tests/501-1000/927. three-equal-parts/sol.rs @@ -0,0 +1,43 @@ +impl Solution { + pub fn three_equal_parts(arr: Vec) -> Vec { + let n = arr.len() as i32; + let ones: i32 = arr.iter().sum(); + if ones == 0 { + return vec![0, n - 1]; + } + if ones % 3 != 0 { + return vec![-1, -1]; + } + + let k = ones / 3; + let mut i1 = -1; + let mut i2 = -1; + let mut i3 = -1; + let mut seen = 0; + for (i, &x) in arr.iter().enumerate() { + if x == 1 { + seen += 1; + if seen == 1 { + i1 = i as i32; + } else if seen == k + 1 { + i2 = i as i32; + } else if seen == 2 * k + 1 { + i3 = i as i32; + break; + } + } + } + + let len = n - i3; + if i1 + len > i2 || i2 + len > i3 { + return vec![-1, -1]; + } + for offset in 0..len { + let a = arr[(i1 + offset) as usize]; + if a != arr[(i2 + offset) as usize] || a != arr[(i3 + offset) as usize] { + return vec![-1, -1]; + } + } + vec![i1 + len - 1, i2 + len] + } +} diff --git a/tests/501-1000/927. three-equal-parts/sol.swift b/tests/501-1000/927. three-equal-parts/sol.swift new file mode 100644 index 00000000..ca92ac1a --- /dev/null +++ b/tests/501-1000/927. three-equal-parts/sol.swift @@ -0,0 +1,42 @@ +class Solution { + func threeEqualParts(_ arr: [Int]) -> [Int] { + let ones = arr.reduce(0, +) + if ones == 0 { + return [0, arr.count - 1] + } + if ones % 3 != 0 { + return [-1, -1] + } + + let target = ones / 3 + var first = -1 + var second = -1 + var third = -1 + var seen = 0 + + for i in 0.. s + x, 0); + if (ones === 0) { + return [0, arr.length - 1]; + } + if (ones % 3 !== 0) { + return [-1, -1]; + } + + const target = ones / 3; + let first = -1; + let second = -1; + let third = -1; + let seen = 0; + + for (let i = 0; i < arr.length; i++) { + if (arr[i] === 1) { + seen++; + if (seen === 1) { + first = i; + } else if (seen === target + 1) { + second = i; + } else if (seen === 2 * target + 1) { + third = i; + } + } + } + + const len = arr.length - third; + if (first + len <= second && second + len <= third) { + for (let offset = 0; offset < len; offset++) { + if ( + arr[first + offset] !== arr[second + offset] || + arr[first + offset] !== arr[third + offset] + ) { + return [-1, -1]; + } + } + return [first + len - 1, second + len]; + } + return [-1, -1]; +} diff --git a/tests/501-1000/928. minimize-malware-spread-ii/manifest.yaml b/tests/501-1000/928. minimize-malware-spread-ii/manifest.yaml new file mode 100644 index 00000000..2a2fa23d --- /dev/null +++ b/tests/501-1000/928. minimize-malware-spread-ii/manifest.yaml @@ -0,0 +1,428 @@ +entry: + id: 928 + title: minimize-malware-spread-ii + params: + graph: + type: array + items: + type: array + items: + type: int + initial: + type: array + items: + type: int + call: + cpp: "Solution().minMalwareSpread({graph}, {initial})" + rust: "Solution::min_malware_spread({graph}, {initial})" + python3: "Solution().minMalwareSpread({graph}, {initial})" + python2: "Solution().minMalwareSpread({graph}, {initial})" + ruby: "min_malware_spread({graph}, {initial})" + java: "new Solution().minMalwareSpread({graph}, {initial})" + csharp: "new Solution().MinMalwareSpread({graph}, {initial})" + kotlin: "Solution().minMalwareSpread({graph}, {initial})" + go: "minMalwareSpread({graph}, {initial})" + dart: "Solution().minMalwareSpread({graph}, {initial})" + swift: "Solution().minMalwareSpread({graph}, {initial})" + typescript: "minMalwareSpread({graph}, {initial})" +judge: + type: "exact" +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().check({result})" + checker: | + class Checker: + def check(self, result): + return True +seed: 928 +tests: + - name: ex1 + in: + graph: + elemType: "int" + value: + - [1, 1, 0] + - [1, 1, 0] + - [0, 0, 1] + initial: [0, 1] + out: 0 + - name: ex2 + in: + graph: + elemType: "int" + value: + - [1, 1, 0] + - [1, 1, 1] + - [0, 1, 1] + initial: [0, 1] + out: 1 + - name: ex3 + in: + graph: + elemType: "int" + value: + - [1, 1, 0, 0] + - [1, 1, 1, 0] + - [0, 1, 1, 1] + - [0, 0, 1, 1] + initial: [0, 1] + out: 1 + - name: isolated_1 + in: + graph: + elemType: "int" + value: + - [1, 0] + - [0, 1] + initial: [0] + out: 0 + - name: isolated_2 + in: + graph: + elemType: "int" + value: + - [1, 0] + - [0, 1] + initial: [1] + out: 1 + - name: isolated_3 + in: + graph: + elemType: "int" + value: + - [1, 0, 0] + - [0, 1, 0] + - [0, 0, 1] + initial: [0, 2] + out: 0 + - name: isolated_4 + in: + graph: + elemType: "int" + value: + - [1, 0, 0] + - [0, 1, 0] + - [0, 0, 1] + initial: [1, 2] + out: 1 + - name: isolated_5 + in: + graph: + elemType: "int" + value: + - [1, 0, 0, 0] + - [0, 1, 0, 0] + - [0, 0, 1, 0] + - [0, 0, 0, 1] + initial: [0, 1, 3] + out: 0 + - name: isolated_6 + in: + graph: + elemType: "int" + value: + - [1, 0, 0, 0] + - [0, 1, 0, 0] + - [0, 0, 1, 0] + - [0, 0, 0, 1] + initial: [1, 2, 3] + out: 1 + - name: isolated_7 + in: + graph: + elemType: "int" + value: + - [1, 0, 0, 0, 0] + - [0, 1, 0, 0, 0] + - [0, 0, 1, 0, 0] + - [0, 0, 0, 1, 0] + - [0, 0, 0, 0, 1] + initial: [2, 4] + out: 2 + - name: isolated_8 + in: + graph: + elemType: "int" + value: + - [1, 0, 0, 0, 0] + - [0, 1, 0, 0, 0] + - [0, 0, 1, 0, 0] + - [0, 0, 0, 1, 0] + - [0, 0, 0, 0, 1] + initial: [0, 3, 4] + out: 0 + - name: edge_1 + in: + graph: + elemType: "int" + value: + - [1, 1, 0] + - [1, 1, 0] + - [0, 0, 1] + initial: [0] + out: 0 + - name: edge_2 + in: + graph: + elemType: "int" + value: + - [1, 1, 0] + - [1, 1, 0] + - [0, 0, 1] + initial: [1] + out: 1 + - name: edge_3 + in: + graph: + elemType: "int" + value: + - [1, 1, 0] + - [1, 1, 0] + - [0, 0, 1] + initial: [0, 1] + out: 0 + - name: edge_4 + in: + graph: + elemType: "int" + value: + - [1, 1, 0, 0] + - [1, 1, 0, 0] + - [0, 0, 1, 1] + - [0, 0, 1, 1] + initial: [0, 2] + out: 0 + - name: edge_5 + in: + graph: + elemType: "int" + value: + - [1, 1, 0, 0] + - [1, 1, 0, 0] + - [0, 0, 1, 1] + - [0, 0, 1, 1] + initial: [1, 2] + out: 1 + - name: edge_6 + in: + graph: + elemType: "int" + value: + - [1, 1, 0, 0] + - [1, 1, 0, 0] + - [0, 0, 1, 1] + - [0, 0, 1, 1] + initial: [0, 1, 2] + out: 2 + - name: edge_7 + in: + graph: + elemType: "int" + value: + - [1, 1, 1, 0] + - [1, 1, 1, 0] + - [1, 1, 1, 0] + - [0, 0, 0, 1] + initial: [0] + out: 0 + - name: edge_8 + in: + graph: + elemType: "int" + value: + - [1, 1, 1, 0] + - [1, 1, 1, 0] + - [1, 1, 1, 0] + - [0, 0, 0, 1] + initial: [2] + out: 2 + - name: edge_9 + in: + graph: + elemType: "int" + value: + - [1, 1, 1, 0] + - [1, 1, 1, 0] + - [1, 1, 1, 0] + - [0, 0, 0, 1] + initial: [0, 2] + out: 0 + - name: edge_10 + in: + graph: + elemType: "int" + value: + - [1, 1, 0, 0, 0] + - [1, 1, 0, 0, 0] + - [0, 0, 1, 1, 1] + - [0, 0, 1, 1, 1] + - [0, 0, 1, 1, 1] + initial: [0, 2] + out: 2 + - name: edge_11 + in: + graph: + elemType: "int" + value: + - [1, 1, 0, 0, 0] + - [1, 1, 0, 0, 0] + - [0, 0, 1, 1, 1] + - [0, 0, 1, 1, 1] + - [0, 0, 1, 1, 1] + initial: [1, 2, 4] + out: 1 + - name: edge_12 + in: + graph: + elemType: "int" + value: + - [1, 1, 0, 0, 0] + - [1, 1, 0, 0, 0] + - [0, 0, 1, 1, 1] + - [0, 0, 1, 1, 1] + - [0, 0, 1, 1, 1] + initial: [0, 1, 2, 3] + out: 0 + - name: edge_13 + in: + graph: + elemType: "int" + value: + - [1, 1, 1, 1] + - [1, 1, 1, 1] + - [1, 1, 1, 1] + - [1, 1, 1, 1] + initial: [1, 3] + out: 1 + - name: edge_14 + in: + graph: + elemType: "int" + value: + - [1, 1, 1, 1] + - [1, 1, 1, 1] + - [1, 1, 1, 1] + - [1, 1, 1, 1] + initial: [0, 2, 3] + out: 0 + - name: edge_15 + in: + graph: + elemType: "int" + value: + - [1, 0, 0, 0, 0, 0] + - [0, 1, 1, 0, 0, 0] + - [0, 1, 1, 0, 0, 0] + - [0, 0, 0, 1, 0, 0] + - [0, 0, 0, 0, 1, 0] + - [0, 0, 0, 0, 0, 1] + initial: [1, 4] + out: 1 + - name: edge_16 + in: + graph: + elemType: "int" + value: + - [1, 0, 0, 0, 0, 0] + - [0, 1, 1, 0, 0, 0] + - [0, 1, 1, 0, 0, 0] + - [0, 0, 0, 1, 0, 0] + - [0, 0, 0, 0, 1, 0] + - [0, 0, 0, 0, 0, 1] + initial: [2, 4] + out: 2 + - name: edge_17 + in: + graph: + elemType: "int" + value: + - [1, 0, 0, 0, 0, 0] + - [0, 1, 1, 0, 0, 0] + - [0, 1, 1, 0, 0, 0] + - [0, 0, 0, 1, 0, 0] + - [0, 0, 0, 0, 1, 0] + - [0, 0, 0, 0, 0, 1] + initial: [1, 2, 4] + out: 1 + - name: edge_18 + in: + graph: + elemType: "int" + value: + - [1, 0, 0, 0] + - [0, 1, 1, 0] + - [0, 1, 1, 0] + - [0, 0, 0, 1] + initial: [0, 1] + out: 1 + - name: edge_19 + in: + graph: + elemType: "int" + value: + - [1, 0, 0, 0] + - [0, 1, 1, 0] + - [0, 1, 1, 0] + - [0, 0, 0, 1] + initial: [1, 3] + out: 1 + - name: edge_20 + in: + graph: + elemType: "int" + value: + - [1, 0, 0, 0] + - [0, 1, 1, 0] + - [0, 1, 1, 0] + - [0, 0, 0, 1] + initial: [0, 2] + out: 2 + - name: edge_21 + in: + graph: + elemType: "int" + value: + - [1, 1, 0, 0, 0] + - [1, 1, 0, 0, 0] + - [0, 0, 1, 0, 0] + - [0, 0, 0, 1, 1] + - [0, 0, 0, 1, 1] + initial: [0, 3] + out: 0 + - name: edge_22 + in: + graph: + elemType: "int" + value: + - [1, 1, 0, 0, 0] + - [1, 1, 0, 0, 0] + - [0, 0, 1, 0, 0] + - [0, 0, 0, 1, 1] + - [0, 0, 0, 1, 1] + initial: [1, 4] + out: 1 + - name: edge_23 + in: + graph: + elemType: "int" + value: + - [1, 1, 0, 0, 0] + - [1, 1, 0, 0, 0] + - [0, 0, 1, 0, 0] + - [0, 0, 0, 1, 1] + - [0, 0, 0, 1, 1] + initial: [0, 1, 3] + out: 3 + - name: edge_24 + in: + graph: + elemType: "int" + value: + - [1, 1, 0] + - [1, 1, 1] + - [0, 1, 1] + initial: [0, 2] + out: 0 diff --git a/tests/501-1000/928. minimize-malware-spread-ii/sol.cpp b/tests/501-1000/928. minimize-malware-spread-ii/sol.cpp new file mode 100644 index 00000000..7f3bd911 --- /dev/null +++ b/tests/501-1000/928. minimize-malware-spread-ii/sol.cpp @@ -0,0 +1,30 @@ +class Solution { +public: + int minMalwareSpread(vector>& graph, vector& initial) { + int n = graph.size(); + auto bfs = [&](int del) -> int { + unordered_set seen; + vector lst = initial; + while (!lst.empty()) { + int node = lst.back(); + lst.pop_back(); + if (node == del || seen.count(node)) continue; + seen.insert(node); + for (int i = 0; i < n; i++) { + if (graph[node][i] == 1) lst.push_back(i); + } + } + return seen.size(); + }; + int minNode = initial[0]; + int minSize = n + 1; + for (int del : initial) { + int size = bfs(del); + if (size < minSize || (size == minSize && del < minNode)) { + minSize = size; + minNode = del; + } + } + return minNode; + } +}; diff --git a/tests/501-1000/928. minimize-malware-spread-ii/sol.cs b/tests/501-1000/928. minimize-malware-spread-ii/sol.cs new file mode 100644 index 00000000..516e7c58 --- /dev/null +++ b/tests/501-1000/928. minimize-malware-spread-ii/sol.cs @@ -0,0 +1,29 @@ +public class Solution { + public int MinMalwareSpread(int[][] graph, int[] initial) { + int n = graph.Length; + System.Func bfs = (del) => { + var seen = new HashSet(); + var lst = new List(initial); + while (lst.Count > 0) { + int node = lst[lst.Count - 1]; + lst.RemoveAt(lst.Count - 1); + if (node == del || seen.Contains(node)) continue; + seen.Add(node); + for (int i = 0; i < n; i++) { + if (graph[node][i] == 1) lst.Add(i); + } + } + return seen.Count; + }; + int minNode = initial[0]; + int minSize = n + 1; + foreach (int del in initial) { + int size = bfs(del); + if (size < minSize || (size == minSize && del < minNode)) { + minSize = size; + minNode = del; + } + } + return minNode; + } +} diff --git a/tests/501-1000/928. minimize-malware-spread-ii/sol.dart b/tests/501-1000/928. minimize-malware-spread-ii/sol.dart new file mode 100644 index 00000000..1971cbbc --- /dev/null +++ b/tests/501-1000/928. minimize-malware-spread-ii/sol.dart @@ -0,0 +1,28 @@ +class Solution { + int minMalwareSpread(List> graph, List initial) { + int n = graph.length; + int bfs(int del) { + var seen = {}; + var lst = List.from(initial); + while (lst.isNotEmpty) { + int node = lst.removeLast(); + if (node == del || seen.contains(node)) continue; + seen.add(node); + for (int i = 0; i < n; i++) { + if (graph[node][i] == 1) lst.add(i); + } + } + return seen.length; + } + int minNode = initial[0]; + int minSize = n + 1; + for (var del in initial) { + int size = bfs(del); + if (size < minSize || (size == minSize && del < minNode)) { + minSize = size; + minNode = del; + } + } + return minNode; + } +} diff --git a/tests/501-1000/928. minimize-malware-spread-ii/sol.go b/tests/501-1000/928. minimize-malware-spread-ii/sol.go new file mode 100644 index 00000000..c8fe906f --- /dev/null +++ b/tests/501-1000/928. minimize-malware-spread-ii/sol.go @@ -0,0 +1,31 @@ +func minMalwareSpread(graph [][]int, initial []int) int { + bfs := func(del int) int { + seen := make(map[int]bool) + lst := make([]int, len(initial)) + copy(lst, initial) + for len(lst) > 0 { + node := lst[len(lst)-1] + lst = lst[:len(lst)-1] + if node == del || seen[node] { + continue + } + seen[node] = true + for i, val := range graph[node] { + if val == 1 { + lst = append(lst, i) + } + } + } + return len(seen) + } + minNode := initial[0] + minSize := len(graph) + 1 + for _, del := range initial { + size := bfs(del) + if size < minSize || (size == minSize && del < minNode) { + minSize = size + minNode = del + } + } + return minNode +} diff --git a/tests/501-1000/928. minimize-malware-spread-ii/sol.java b/tests/501-1000/928. minimize-malware-spread-ii/sol.java new file mode 100644 index 00000000..852f29b1 --- /dev/null +++ b/tests/501-1000/928. minimize-malware-spread-ii/sol.java @@ -0,0 +1,26 @@ +class Solution { + public int minMalwareSpread(int[][] graph, int[] initial) { + int n = graph.length; + int minNode = initial[0]; + int minSize = Integer.MAX_VALUE; + for (int del : initial) { + Set seen = new HashSet<>(); + List lst = new ArrayList<>(); + for (int v : initial) lst.add(v); + while (!lst.isEmpty()) { + int node = lst.remove(lst.size() - 1); + if (node == del || seen.contains(node)) continue; + seen.add(node); + for (int i = 0; i < n; i++) { + if (graph[node][i] == 1) lst.add(i); + } + } + int size = seen.size(); + if (size < minSize || (size == minSize && del < minNode)) { + minSize = size; + minNode = del; + } + } + return minNode; + } +} diff --git a/tests/501-1000/928. minimize-malware-spread-ii/sol.kt b/tests/501-1000/928. minimize-malware-spread-ii/sol.kt new file mode 100644 index 00000000..71ed48a0 --- /dev/null +++ b/tests/501-1000/928. minimize-malware-spread-ii/sol.kt @@ -0,0 +1,19 @@ +class Solution { + fun minMalwareSpread(graph: Array, initial: IntArray): Int { + val n = graph.size + fun bfs(del: Int): Int { + val seen = mutableSetOf() + val lst = initial.toMutableList() + while (lst.isNotEmpty()) { + val node = lst.removeAt(lst.lastIndex) + if (node == del || node in seen) continue + seen.add(node) + for (i in 0 until n) { + if (graph[node][i] == 1) lst.add(i) + } + } + return seen.size + } + return initial.minWith(compareBy({ bfs(it) }, { it })) + } +} diff --git a/tests/501-1000/928. minimize-malware-spread-ii/sol.py b/tests/501-1000/928. minimize-malware-spread-ii/sol.py new file mode 100644 index 00000000..87d3267e --- /dev/null +++ b/tests/501-1000/928. minimize-malware-spread-ii/sol.py @@ -0,0 +1,22 @@ +class Solution: + # the key observation for me is the fact that we don't need to + # really delete the initial in the graph. We can simply ignore + # the deleted initial while we are doing BFS. So basically we + # do BFS with each deleted value on initial, and we get the + # minimal count of the connected graph. Note if two deleted + # values give same count of connected graph, then we choose + # smaller value. that's why I used a tuple, (BFS(a), a) this + # will first compare BFS(a), if they are equal then it compares + # a. + def minMalwareSpread(self, graph: List[List[int]], initial: List[int]) -> int: + def BFS(delval): + seen, lst = set(), list(initial) + while lst: + node = lst.pop() + if node == delval or node in seen: + continue + seen.add(node) + lst += [i for i, val in enumerate(graph[node]) if val] + return len(seen) + + return min(initial, key=lambda a: (BFS(a), a)) diff --git a/tests/501-1000/928. minimize-malware-spread-ii/sol.py2 b/tests/501-1000/928. minimize-malware-spread-ii/sol.py2 new file mode 100644 index 00000000..a58718c0 --- /dev/null +++ b/tests/501-1000/928. minimize-malware-spread-ii/sol.py2 @@ -0,0 +1,20 @@ +class Solution(object): + def minMalwareSpread(self, graph, initial): + """ + :type graph: List[List[int]] + :type initial: List[int] + :rtype: int + """ + def BFS(delval): + seen = set() + lst = list(initial) + while lst: + node = lst.pop() + if node == delval or node in seen: + continue + seen.add(node) + for i, val in enumerate(graph[node]): + if val: + lst.append(i) + return len(seen) + return min(initial, key=lambda a: (BFS(a), a)) diff --git a/tests/501-1000/928. minimize-malware-spread-ii/sol.rb b/tests/501-1000/928. minimize-malware-spread-ii/sol.rb new file mode 100644 index 00000000..37e4536e --- /dev/null +++ b/tests/501-1000/928. minimize-malware-spread-ii/sol.rb @@ -0,0 +1,19 @@ +# @param {Integer[][]} graph +# @param {Integer[]} initial +# @return {Integer} +def min_malware_spread(graph, initial) + bfs = lambda do |delval| + seen = Set.new + lst = initial.dup + while !lst.empty? + node = lst.pop + next if node == delval || seen.include?(node) + seen.add(node) + graph[node].each_with_index do |val, i| + lst.push(i) if val == 1 + end + end + seen.size + end + initial.min_by { |a| [bfs.call(a), a] } +end diff --git a/tests/501-1000/928. minimize-malware-spread-ii/sol.rs b/tests/501-1000/928. minimize-malware-spread-ii/sol.rs new file mode 100644 index 00000000..6d470ee8 --- /dev/null +++ b/tests/501-1000/928. minimize-malware-spread-ii/sol.rs @@ -0,0 +1,31 @@ +impl Solution { + pub fn min_malware_spread(graph: Vec>, initial: Vec) -> i32 { + let n = graph.len(); + let bfs = |del: i32| -> usize { + let mut seen = std::collections::HashSet::new(); + let mut lst = initial.clone(); + while let Some(node) = lst.pop() { + if node == del || seen.contains(&node) { + continue; + } + seen.insert(node); + for i in 0..n { + if graph[node as usize][i] == 1 { + lst.push(i as i32); + } + } + } + seen.len() + }; + let mut min_node = initial[0]; + let mut min_size = n + 1; + for &del in &initial { + let size = bfs(del); + if size < min_size || (size == min_size && del < min_node) { + min_size = size; + min_node = del; + } + } + min_node + } +} diff --git a/tests/501-1000/928. minimize-malware-spread-ii/sol.swift b/tests/501-1000/928. minimize-malware-spread-ii/sol.swift new file mode 100644 index 00000000..8268924f --- /dev/null +++ b/tests/501-1000/928. minimize-malware-spread-ii/sol.swift @@ -0,0 +1,30 @@ +class Solution { + func minMalwareSpread(_ graph: [[Int]], _ initial: [Int]) -> Int { + let n = graph.count + func bfs(_ del: Int) -> Int { + var seen = Set() + var lst = initial + while !lst.isEmpty { + let node = lst.removeLast() + if node == del || seen.contains(node) { continue } + seen.insert(node) + for i in 0.. { + const seen = new Set(); + const lst = [...initial]; + while (lst.length > 0) { + const node = lst.pop()!; + if (node === del || seen.has(node)) continue; + seen.add(node); + for (let i = 0; i < n; i++) { + if (graph[node][i] === 1) lst.push(i); + } + } + return seen.size; + }; + let minNode = initial[0]; + let minSize = n + 1; + for (const del of initial) { + const size = bfs(del); + if (size < minSize || (size === minSize && del < minNode)) { + minSize = size; + minNode = del; + } + } + return minNode; +} diff --git a/tests/501-1000/929. unique-email-addresses/manifest.yaml b/tests/501-1000/929. unique-email-addresses/manifest.yaml new file mode 100644 index 00000000..3a466de3 --- /dev/null +++ b/tests/501-1000/929. unique-email-addresses/manifest.yaml @@ -0,0 +1,281 @@ +entry: + id: 929 + title: unique-email-addresses + params: + emails: + type: array + items: + type: string + call: + cpp: "Solution().numUniqueEmails({emails})" + rust: "Solution::num_unique_emails({emails})" + python3: "Solution().numUniqueEmails({emails})" + python2: "Solution().numUniqueEmails({emails})" + ruby: "num_unique_emails({emails})" + java: "new Solution().numUniqueEmails({emails})" + csharp: "new Solution().NumUniqueEmails({emails})" + kotlin: "Solution().numUniqueEmails({emails})" + go: "numUniqueEmails({emails})" + dart: "Solution().numUniqueEmails({emails})" + swift: "Solution().numUniqueEmails({emails})" + typescript: "numUniqueEmails({emails})" +judge: + type: "exact" +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().check({result})" + checker: | + class Checker: + def check(self, result): + return True +seed: 929 +tests: + - name: ex1 + in: + emails: + - test.email+alex@leetcode.com + - test.e.mail+bob.cathy@leetcode.com + - testemail+david@lee.tcode.com + out: 2 + - name: ex2 + in: + emails: + - a@leetcode.com + - b@leetcode.com + - c@leetcode.com + out: 3 + - name: t1 + in: + emails: + - a.b.c+d@leetcode.com + - abc@leetcode.com + out: 1 + - name: t2 + in: + emails: + - x.y.z+spam@domain.com + - xyz@domain.com + - x.yz@domain.com + out: 1 + - name: t3 + in: + emails: + - m.y+name@email.com + - my@email.com + out: 1 + - name: t4 + in: + emails: + - simple@leetcode.com + out: 1 + - name: t5 + in: + emails: + - a+b@leetcode.com + - a@leetcode.com + - a+b+c@leetcode.com + out: 1 + - name: t6 + in: + emails: + - a.b+c@leetcode.com + - ab@leetcode.com + - a.b@leetcode.com + out: 1 + - name: t7 + in: + emails: + - a.a.a@x.com + - aaa@x.com + out: 1 + - name: t8 + in: + emails: + - x+@x.com + - x@x.com + out: 1 + - name: t9 + in: + emails: + - x.y+z@x.com + - xy@x.com + out: 1 + - name: t10 + in: + emails: + - u.v.w@d.com + - uvwxyz@d.com + out: 2 + - name: t11 + in: + emails: + - u.v.w+tag@d.com + - uvw@d.com + out: 1 + - name: t12 + in: + emails: + - alice@leetcode.com + - alice+spam@leetcode.com + - a.l.i.c.e@leetcode.com + out: 1 + - name: t13 + in: + emails: + - bob@leetcode.com + - bob+spam@leet.code.com + out: 2 + - name: t14 + in: + emails: + - a@a.com + - a+b@a.com + - a.b@a.com + out: 2 + - name: t15 + in: + emails: + - aa@leetcode.com + - a.a@leetcode.com + out: 1 + - name: t16 + in: + emails: + - ab+cd@x.com + - ab@x.com + - a.b@x.com + out: 1 + - name: t17 + in: + emails: + - abc@x.com + - ab.c@x.com + - a.bc@x.com + out: 1 + - name: t18 + in: + emails: + - a@x.com + - a@x.com + out: 1 + - name: t19 + in: + emails: + - a+b@x.com + - a+c@x.com + out: 1 + - name: t20 + in: + emails: + - a.b+c@x.com + - ab@x.com + - a.b@x.com + - a.b+c+d@x.com + out: 1 + - name: t21 + in: + emails: + - z+spam@leetcode.com + - z@leetcode.com + - z.z@leetcode.com + out: 2 + - name: t22 + in: + emails: + - foo.bar+baz@domain.com + - foobar@domain.com + out: 1 + - name: t23 + in: + emails: + - foo.bar+baz@domain.com + - foo.bar@domain.com + out: 1 + - name: t24 + in: + emails: + - q.w.e+r@domain.com + - qwe@domain.com + - q.w.e@domain.com + out: 1 + - name: t25 + in: + emails: + - local+plus@d.com + - local@d.com + - lo.cal@d.com + out: 1 + - name: t26 + in: + emails: + - a.a+a@a.com + - aa@a.com + - a+a@a.com + out: 2 + - name: t27 + in: + emails: + - abc+def@x.com + - a.b.c@x.com + - abc@x.com + out: 1 + - name: t28 + in: + emails: + - abc+def@x.com + - a.b.c@x.com + - ab.c@x.com + out: 1 + - name: t29 + in: + emails: + - p.q.r@s.com + - pqr@s.com + - p.qr@s.com + out: 1 + - name: t30 + in: + emails: + - a@leetcode.com + - a@leetcode.com + - a+spam@leetcode.com + out: 1 + - name: t31 + in: + emails: + - m.n+o@dom.com + - mn@dom.com + - m.n@dom.com + - m.n+o@dom.com + out: 1 + - name: t32 + in: + emails: + - x.x.x+tag@x.com + - xxx@x.com + - x.xx@x.com + out: 1 + - name: t33 + in: + emails: + - u+1@u.com + - u+2@u.com + - u@u.com + out: 1 + - name: t34 + in: + emails: + - same@d.com + - s.a.m.e@d.com + - same+tag@d.com + out: 1 + - name: t35 + in: + emails: + - a.b.c+d@leetcode.com + - a.bc+d@leetcode.com + - ab.c+d@leetcode.com + out: 1 diff --git a/tests/501-1000/929. unique-email-addresses/sol.cpp b/tests/501-1000/929. unique-email-addresses/sol.cpp new file mode 100644 index 00000000..3c68e724 --- /dev/null +++ b/tests/501-1000/929. unique-email-addresses/sol.cpp @@ -0,0 +1,19 @@ +class Solution { +public: + int numUniqueEmails(vector& emails) { + unordered_set res; + for (const string& email : emails) { + size_t atIndex = email.find('@'); + string local = email.substr(0, atIndex); + string domain = email.substr(atIndex + 1); + + size_t plusIndex = local.find('+'); + if (plusIndex != string::npos) { + local = local.substr(0, plusIndex); + } + local.erase(remove(local.begin(), local.end(), '.'), local.end()); + res.insert(local + "@" + domain); + } + return res.size(); + } +}; diff --git a/tests/501-1000/929. unique-email-addresses/sol.cs b/tests/501-1000/929. unique-email-addresses/sol.cs new file mode 100644 index 00000000..a56a8dfc --- /dev/null +++ b/tests/501-1000/929. unique-email-addresses/sol.cs @@ -0,0 +1,18 @@ +public class Solution { + public int NumUniqueEmails(string[] emails) { + HashSet res = new HashSet(); + foreach (string email in emails) { + int atIndex = email.IndexOf('@'); + string local = email.Substring(0, atIndex); + string domain = email.Substring(atIndex + 1); + + int plusIndex = local.IndexOf('+'); + if (plusIndex != -1) { + local = local.Substring(0, plusIndex); + } + local = local.Replace(".", ""); + res.Add(local + "@" + domain); + } + return res.Count; + } +} diff --git a/tests/501-1000/929. unique-email-addresses/sol.dart b/tests/501-1000/929. unique-email-addresses/sol.dart new file mode 100644 index 00000000..31be9f48 --- /dev/null +++ b/tests/501-1000/929. unique-email-addresses/sol.dart @@ -0,0 +1,18 @@ +class Solution { + int numUniqueEmails(List emails) { + Set res = {}; + for (var email in emails) { + var atIndex = email.indexOf('@'); + var local = email.substring(0, atIndex); + var domain = email.substring(atIndex + 1); + + var plusIndex = local.indexOf('+'); + if (plusIndex != -1) { + local = local.substring(0, plusIndex); + } + local = local.replaceAll('.', ''); + res.add(local + '@' + domain); + } + return res.length; + } +} diff --git a/tests/501-1000/929. unique-email-addresses/sol.go b/tests/501-1000/929. unique-email-addresses/sol.go new file mode 100644 index 00000000..29765a86 --- /dev/null +++ b/tests/501-1000/929. unique-email-addresses/sol.go @@ -0,0 +1,34 @@ +func numUniqueEmails(emails []string) int { + res := make(map[string]bool) + for _, email := range emails { + atIndex := 0 + for i, ch := range email { + if ch == '@' { + atIndex = i + break + } + } + local := email[:atIndex] + domain := email[atIndex+1:] + + plusIndex := -1 + for i, ch := range local { + if ch == '+' { + plusIndex = i + break + } + } + if plusIndex != -1 { + local = local[:plusIndex] + } + + filteredLocal := "" + for _, ch := range local { + if ch != '.' { + filteredLocal += string(ch) + } + } + res[filteredLocal + "@" + domain] = true + } + return len(res) +} diff --git a/tests/501-1000/929. unique-email-addresses/sol.java b/tests/501-1000/929. unique-email-addresses/sol.java new file mode 100644 index 00000000..dcdfb852 --- /dev/null +++ b/tests/501-1000/929. unique-email-addresses/sol.java @@ -0,0 +1,17 @@ +class Solution { + public int numUniqueEmails(String[] emails) { + Set res = new HashSet<>(); + for (String email : emails) { + String[] parts = email.split("@"); + String local = parts[0]; + String domain = parts[1]; + int plusIndex = local.indexOf('+'); + if (plusIndex != -1) { + local = local.substring(0, plusIndex); + } + local = local.replace(".", ""); + res.add(local + "@" + domain); + } + return res.size(); + } +} diff --git a/tests/501-1000/929. unique-email-addresses/sol.kt b/tests/501-1000/929. unique-email-addresses/sol.kt new file mode 100644 index 00000000..e235d8be --- /dev/null +++ b/tests/501-1000/929. unique-email-addresses/sol.kt @@ -0,0 +1,17 @@ +class Solution { + fun numUniqueEmails(emails: Array): Int { + val res = mutableSetOf() + for (email in emails) { + val atIndex = email.indexOf('@') + var local = email.substring(0, atIndex) + val domain = email.substring(atIndex + 1) + val plusIndex = local.indexOf('+') + if (plusIndex != -1) { + local = local.substring(0, plusIndex) + } + local = local.replace(".", "") + res.add(local + "@" + domain) + } + return res.size + } +} diff --git a/tests/501-1000/929. unique-email-addresses/sol.py b/tests/501-1000/929. unique-email-addresses/sol.py new file mode 100644 index 00000000..594eb783 --- /dev/null +++ b/tests/501-1000/929. unique-email-addresses/sol.py @@ -0,0 +1,10 @@ +class Solution: + def numUniqueEmails(self, emails: List[str]) -> int: + res = set() + for email in emails: + local, domain = email.split("@") + if "+" in local: + local = local[: local.index("+")] + local = local.replace(".", "") + res.add(local + "@" + domain) + return len(res) diff --git a/tests/501-1000/929. unique-email-addresses/sol.py2 b/tests/501-1000/929. unique-email-addresses/sol.py2 new file mode 100644 index 00000000..96f4999d --- /dev/null +++ b/tests/501-1000/929. unique-email-addresses/sol.py2 @@ -0,0 +1,14 @@ +class Solution(object): + def numUniqueEmails(self, emails): + """ + :type emails: List[str] + :rtype: int + """ + res = set() + for email in emails: + local, domain = email.split('@') + if '+' in local: + local = local[:local.index('+')] + local = local.replace('.', '') + res.add(local + '@' + domain) + return len(res) diff --git a/tests/501-1000/929. unique-email-addresses/sol.rb b/tests/501-1000/929. unique-email-addresses/sol.rb new file mode 100644 index 00000000..e256fbc2 --- /dev/null +++ b/tests/501-1000/929. unique-email-addresses/sol.rb @@ -0,0 +1,14 @@ +# @param {String[]} emails +# @return {Integer} +def num_unique_emails(emails) + res = Set.new + emails.each do |email| + local, domain = email.split('@') + if local.include?('+') + local = local[0...local.index('+')] + end + local = local.delete('.') + res.add(local + '@' + domain) + end + res.size +end diff --git a/tests/501-1000/929. unique-email-addresses/sol.rs b/tests/501-1000/929. unique-email-addresses/sol.rs new file mode 100644 index 00000000..c1d81ace --- /dev/null +++ b/tests/501-1000/929. unique-email-addresses/sol.rs @@ -0,0 +1,18 @@ +impl Solution { + pub fn num_unique_emails(emails: Vec) -> i32 { + use std::collections::HashSet; + let mut res = HashSet::new(); + for email in &emails { + let at_index = email.find('@').unwrap(); + let mut local = email[..at_index].to_string(); + let domain = email[at_index + 1..].to_string(); + + if let Some(plus_index) = local.find('+') { + local = local[..plus_index].to_string(); + } + local = local.replace('.', ""); + res.insert(local + "@" + &domain); + } + res.len() as i32 + } +} diff --git a/tests/501-1000/929. unique-email-addresses/sol.swift b/tests/501-1000/929. unique-email-addresses/sol.swift new file mode 100644 index 00000000..32e3a535 --- /dev/null +++ b/tests/501-1000/929. unique-email-addresses/sol.swift @@ -0,0 +1,17 @@ +class Solution { + func numUniqueEmails(_ emails: [String]) -> Int { + var res = Set() + for email in emails { + let parts = email.split(separator: "@", maxSplits: 1) + var local = String(parts[0]) + let domain = String(parts[1]) + + if let plusIndex = local.firstIndex(of: "+") { + local = String(local[..(); + for (const email of emails) { + const atIndex = email.indexOf("@"); + let local = email.substring(0, atIndex); + const domain = email.substring(atIndex + 1); + + const plusIndex = local.indexOf("+"); + if (plusIndex !== -1) { + local = local.substring(0, plusIndex); + } + local = local.replace(/\./g, ""); + res.add(local + "@" + domain); + } + return res.size; +} diff --git a/tests/501-1000/930. binary-subarrays-with-sum/manifest.yaml b/tests/501-1000/930. binary-subarrays-with-sum/manifest.yaml new file mode 100644 index 00000000..33ec8f31 --- /dev/null +++ b/tests/501-1000/930. binary-subarrays-with-sum/manifest.yaml @@ -0,0 +1,222 @@ +entry: + id: 930 + title: binary-subarrays-with-sum + params: + nums: + type: array + items: + type: int + goal: + type: int + call: + cpp: "Solution().numSubarraysWithSum({nums}, {goal})" + rust: "Solution::num_subarrays_with_sum({nums}, {goal})" + python3: "Solution().numSubarraysWithSum({nums}, {goal})" + python2: "Solution().numSubarraysWithSum({nums}, {goal})" + ruby: "num_subarrays_with_sum({nums}, {goal})" + java: "new Solution().numSubarraysWithSum({nums}, {goal})" + csharp: "new Solution().NumSubarraysWithSum({nums}, {goal})" + kotlin: "Solution().numSubarraysWithSum({nums}, {goal})" + go: "numSubarraysWithSum({nums}, {goal})" + dart: "Solution().numSubarraysWithSum({nums}, {goal})" + swift: "Solution().numSubarraysWithSum({nums}, {goal})" + typescript: "numSubarraysWithSum({nums}, {goal})" +judge: + type: "exact" +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().check({result})" + checker: | + class Checker: + def check(self, result): + return True +seed: 930 +tests: + - name: ex1 + in: + nums: [1, 0, 1, 0, 1] + goal: 2 + out: 4 + - name: ex2 + in: + nums: [0, 0, 0, 0, 0] + goal: 0 + out: 15 + - name: t1 + in: + nums: [1] + goal: 1 + out: 1 + - name: t2 + in: + nums: [0] + goal: 0 + out: 1 + - name: t3 + in: + nums: [1, 0, 0, 1, 0, 1] + goal: 2 + out: 5 + - name: t4 + in: + nums: [1, 1, 1] + goal: 2 + out: 2 + - name: t5 + in: + nums: [0, 1, 0, 1, 0] + goal: 1 + out: 8 + - name: t6 + in: + nums: [1, 0, 1, 1, 0, 1] + goal: 3 + out: 4 + - name: t7 + in: + nums: [0, 1, 1, 0, 0, 1, 0] + goal: 2 + out: 8 + - name: t8 + in: + nums: [1, 0, 0, 0, 1] + goal: 1 + out: 8 + - name: t9 + in: + nums: [1, 0, 0, 0, 1] + goal: 2 + out: 1 + - name: t10 + in: + nums: [0, 0, 1, 0, 0] + goal: 1 + out: 9 + - name: t11 + in: + nums: [1, 0, 1, 0, 1, 0, 1] + goal: 3 + out: 4 + - name: t12 + in: + nums: [0, 0, 0, 1, 0, 0] + goal: 1 + out: 12 + - name: t13 + in: + nums: [1, 1, 0, 1, 1] + goal: 2 + out: 5 + - name: t14 + in: + nums: [1, 1, 0, 1, 1] + goal: 3 + out: 2 + - name: t15 + in: + nums: [0, 0, 0, 0, 1] + goal: 1 + out: 5 + - name: t16 + in: + nums: [1, 0, 0, 1, 0, 0, 1, 0, 0] + goal: 2 + out: 12 + - name: t17 + in: + nums: [1, 0, 0, 1, 0, 0, 1, 0, 0] + goal: 1 + out: 21 + - name: t18 + in: + nums: [0, 1, 0, 0, 1, 0, 0, 1, 0] + goal: 2 + out: 12 + - name: t19 + in: + nums: [1, 0, 1, 0, 1, 0, 1, 0, 1] + goal: 4 + out: 4 + - name: t20 + in: + nums: [1, 1, 1, 1] + goal: 0 + out: 0 + - name: t21 + in: + nums: [1, 1, 1, 1] + goal: 1 + out: 4 + - name: t22 + in: + nums: [0, 1, 0, 1, 0, 1, 0, 1, 0] + goal: 2 + out: 12 + - name: t23 + in: + nums: [0, 0, 1, 0, 1, 0, 0] + goal: 2 + out: 9 + - name: t24 + in: + nums: [1, 0, 0, 0, 0, 1, 0, 0, 0, 1] + goal: 3 + out: 1 + - name: t25 + in: + nums: [1, 0, 0, 0, 0, 1, 0, 0, 0, 1] + goal: 2 + out: 9 + - name: t26 + in: + nums: [0, 0, 0, 0, 0, 0, 0] + goal: 0 + out: 28 + - name: t27 + in: + nums: [1, 0, 1] + goal: 1 + out: 4 + - name: t28 + in: + nums: [1, 0, 1] + goal: 2 + out: 1 + - name: t29 + in: + nums: [0, 1, 1, 1, 0] + goal: 2 + out: 4 + - name: t30 + in: + nums: [1, 0, 1, 0, 0, 1, 0, 1] + goal: 3 + out: 4 + - name: t31 + in: + nums: [0, 0, 1, 1, 0, 0] + goal: 2 + out: 9 + - name: t32 + in: + nums: [1, 0, 0, 1, 1, 0, 1, 0] + goal: 3 + out: 8 + - name: t33 + in: + nums: [1, 0, 0, 1, 1, 0, 1, 0] + goal: 4 + out: 2 + - name: t34 + in: + nums: [0, 1, 0, 1, 1, 0, 1, 0, 0] + goal: 3 + out: 10 + - name: t35 + in: + nums: [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1] + goal: 5 + out: 4 diff --git a/tests/501-1000/930. binary-subarrays-with-sum/sol.cpp b/tests/501-1000/930. binary-subarrays-with-sum/sol.cpp new file mode 100644 index 00000000..9fcae9a8 --- /dev/null +++ b/tests/501-1000/930. binary-subarrays-with-sum/sol.cpp @@ -0,0 +1,37 @@ +class Solution { +public: + int numSubarraysWithSum(vector& nums, int goal) { + int n = nums.size(); + vector posOf1s; + posOf1s.push_back(-1); + int total = 0; + int count = 0; + + if (goal == 0) { + for (int num : nums) { + if (num == 0) { + count++; + total += count; + } else { + count = 0; + } + } + return total; + } + + for (int i = 0; i < n; i++) { + if (nums[i] == 1) { + posOf1s.push_back(i); + } + } + posOf1s.push_back(n); + + for (int i = 1; i < posOf1s.size() - goal; i++) { + int leftChoices = posOf1s[i] - posOf1s[i - 1]; + int rightChoices = posOf1s[i + goal] - posOf1s[i + goal - 1]; + total += leftChoices * rightChoices; + } + + return total; + } +}; diff --git a/tests/501-1000/930. binary-subarrays-with-sum/sol.cs b/tests/501-1000/930. binary-subarrays-with-sum/sol.cs new file mode 100644 index 00000000..3c0d87ab --- /dev/null +++ b/tests/501-1000/930. binary-subarrays-with-sum/sol.cs @@ -0,0 +1,36 @@ +public class Solution { + public int NumSubarraysWithSum(int[] nums, int goal) { + int n = nums.Length; + var posOf1s = new System.Collections.Generic.List(); + posOf1s.Add(-1); + int total = 0; + int count = 0; + + if (goal == 0) { + foreach (int num in nums) { + if (num == 0) { + count++; + total += count; + } else { + count = 0; + } + } + return total; + } + + for (int i = 0; i < n; i++) { + if (nums[i] == 1) { + posOf1s.Add(i); + } + } + posOf1s.Add(n); + + for (int i = 1; i < posOf1s.Count - goal; i++) { + int leftChoices = posOf1s[i] - posOf1s[i - 1]; + int rightChoices = posOf1s[i + goal] - posOf1s[i + goal - 1]; + total += leftChoices * rightChoices; + } + + return total; + } +} diff --git a/tests/501-1000/930. binary-subarrays-with-sum/sol.dart b/tests/501-1000/930. binary-subarrays-with-sum/sol.dart new file mode 100644 index 00000000..de6948ff --- /dev/null +++ b/tests/501-1000/930. binary-subarrays-with-sum/sol.dart @@ -0,0 +1,35 @@ +class Solution { + int numSubarraysWithSum(List nums, int goal) { + int n = nums.length; + List posOf1s = [-1]; + int total = 0; + int count = 0; + + if (goal == 0) { + for (int num in nums) { + if (num == 0) { + count++; + total += count; + } else { + count = 0; + } + } + return total; + } + + for (int i = 0; i < n; i++) { + if (nums[i] == 1) { + posOf1s.add(i); + } + } + posOf1s.add(n); + + for (int i = 1; i < posOf1s.length - goal; i++) { + int leftChoices = posOf1s[i] - posOf1s[i - 1]; + int rightChoices = posOf1s[i + goal] - posOf1s[i + goal - 1]; + total += leftChoices * rightChoices; + } + + return total; + } +} diff --git a/tests/501-1000/930. binary-subarrays-with-sum/sol.go b/tests/501-1000/930. binary-subarrays-with-sum/sol.go new file mode 100644 index 00000000..fffd575d --- /dev/null +++ b/tests/501-1000/930. binary-subarrays-with-sum/sol.go @@ -0,0 +1,33 @@ +func numSubarraysWithSum(nums []int, goal int) int { + n := len(nums) + posOf1s := []int{-1} + total := 0 + count := 0 + + if goal == 0 { + for _, num := range nums { + if num == 0 { + count++ + total += count + } else { + count = 0 + } + } + return total + } + + for i, num := range nums { + if num == 1 { + posOf1s = append(posOf1s, i) + } + } + posOf1s = append(posOf1s, n) + + for i := 1; i < len(posOf1s)-goal; i++ { + leftChoices := posOf1s[i] - posOf1s[i-1] + rightChoices := posOf1s[i+goal] - posOf1s[i+goal-1] + total += leftChoices * rightChoices + } + + return total +} diff --git a/tests/501-1000/930. binary-subarrays-with-sum/sol.java b/tests/501-1000/930. binary-subarrays-with-sum/sol.java new file mode 100644 index 00000000..0fb43931 --- /dev/null +++ b/tests/501-1000/930. binary-subarrays-with-sum/sol.java @@ -0,0 +1,38 @@ +class Solution { + public int numSubarraysWithSum(int[] nums, int goal) { + int n = nums.length; + int[] posOf1s = new int[n + 2]; + int idx = 0; + posOf1s[idx++] = -1; + + int total = 0; + int count = 0; + + if (goal == 0) { + for (int num : nums) { + if (num == 0) { + count++; + total += count; + } else { + count = 0; + } + } + return total; + } + + for (int i = 0; i < n; i++) { + if (nums[i] == 1) { + posOf1s[idx++] = i; + } + } + posOf1s[idx++] = n; + + for (int i = 1; i < idx - goal; i++) { + int leftChoices = posOf1s[i] - posOf1s[i - 1]; + int rightChoices = posOf1s[i + goal] - posOf1s[i + goal - 1]; + total += leftChoices * rightChoices; + } + + return total; + } +} diff --git a/tests/501-1000/930. binary-subarrays-with-sum/sol.kt b/tests/501-1000/930. binary-subarrays-with-sum/sol.kt new file mode 100644 index 00000000..8d39b4ae --- /dev/null +++ b/tests/501-1000/930. binary-subarrays-with-sum/sol.kt @@ -0,0 +1,33 @@ +class Solution { + fun numSubarraysWithSum(nums: IntArray, goal: Int): Int { + val n = nums.size + val posOf1s = mutableListOf(-1) + var total = 0 + var count = 0 + + if (goal == 0) { + for (num in nums) { + if (num == 0) { + count++ + total += count + } else { + count = 0 + } + } + return total + } + + nums.forEachIndexed { i, num -> + if (num == 1) posOf1s.add(i) + } + posOf1s.add(n) + + for (i in 1 until posOf1s.size - goal) { + val leftChoices = posOf1s[i] - posOf1s[i - 1] + val rightChoices = posOf1s[i + goal] - posOf1s[i + goal - 1] + total += leftChoices * rightChoices + } + + return total + } +} diff --git a/tests/501-1000/930. binary-subarrays-with-sum/sol.py b/tests/501-1000/930. binary-subarrays-with-sum/sol.py new file mode 100644 index 00000000..d97a2f21 --- /dev/null +++ b/tests/501-1000/930. binary-subarrays-with-sum/sol.py @@ -0,0 +1,35 @@ +class Solution(object): + def numSubarraysWithSum(self, nums, goal): + pos_of_1s = [-1] + count = 0 + total = 0 + n = len(nums) + + # Branch 1: If goal is 0, count contiguous blocks of zeros + if goal == 0: + for num in nums: + if num == 0: + count += 1 + total += count + else: + count = 0 + return total + + # Branch 2: Collect real positions of all 1s + for i, num in enumerate(nums): + if num == 1: + pos_of_1s.append(i) + pos_of_1s.append(n) # Append virtual right boundary + + # Slide a window of size 'goal' across our 1s tracking array + for i in range(1, len(pos_of_1s) - goal): + # Distance to the previous 1 tells us how many left configurations exist + left_choices = pos_of_1s[i] - pos_of_1s[i - 1] + + # Distance to the next 1 tells us how many right configurations exist + right_choices = pos_of_1s[i + goal] - pos_of_1s[i + goal - 1] + + # Combinations = left extensions * right extensions + total += left_choices * right_choices + + return total diff --git a/tests/501-1000/930. binary-subarrays-with-sum/sol.py2 b/tests/501-1000/930. binary-subarrays-with-sum/sol.py2 new file mode 100644 index 00000000..44599928 --- /dev/null +++ b/tests/501-1000/930. binary-subarrays-with-sum/sol.py2 @@ -0,0 +1,27 @@ +class Solution(object): + def numSubarraysWithSum(self, nums, goal): + pos_of_1s = [-1] + count = 0 + total = 0 + n = len(nums) + + if goal == 0: + for num in nums: + if num == 0: + count += 1 + total += count + else: + count = 0 + return total + + for i, num in enumerate(nums): + if num == 1: + pos_of_1s.append(i) + pos_of_1s.append(n) + + for i in range(1, len(pos_of_1s) - goal): + left_choices = pos_of_1s[i] - pos_of_1s[i - 1] + right_choices = pos_of_1s[i + goal] - pos_of_1s[i + goal - 1] + total += left_choices * right_choices + + return total diff --git a/tests/501-1000/930. binary-subarrays-with-sum/sol.rb b/tests/501-1000/930. binary-subarrays-with-sum/sol.rb new file mode 100644 index 00000000..18da2220 --- /dev/null +++ b/tests/501-1000/930. binary-subarrays-with-sum/sol.rb @@ -0,0 +1,34 @@ +# @param {Integer[]} nums +# @param {Integer} goal +# @return {Integer} +def num_subarrays_with_sum(nums, goal) + pos_of_1s = [-1] + count = 0 + total = 0 + n = nums.length + + if goal == 0 + nums.each do |num| + if num == 0 + count += 1 + total += count + else + count = 0 + end + end + return total + end + + nums.each_with_index do |num, i| + pos_of_1s << i if num == 1 + end + pos_of_1s << n + + (1...(pos_of_1s.length - goal)).each do |i| + left_choices = pos_of_1s[i] - pos_of_1s[i - 1] + right_choices = pos_of_1s[i + goal] - pos_of_1s[i + goal - 1] + total += left_choices * right_choices + end + + total +end diff --git a/tests/501-1000/930. binary-subarrays-with-sum/sol.rs b/tests/501-1000/930. binary-subarrays-with-sum/sol.rs new file mode 100644 index 00000000..5e8d66ef --- /dev/null +++ b/tests/501-1000/930. binary-subarrays-with-sum/sol.rs @@ -0,0 +1,36 @@ +impl Solution { + pub fn num_subarrays_with_sum(nums: Vec, goal: i32) -> i32 { + let n = nums.len(); + let mut pos_of_1s: Vec = vec![-1]; + let mut total: i32 = 0; + let mut count: i32 = 0; + + if goal == 0 { + for &num in &nums { + if num == 0 { + count += 1; + total += count; + } else { + count = 0; + } + } + return total; + } + + for (i, &num) in nums.iter().enumerate() { + if num == 1 { + pos_of_1s.push(i as i32); + } + } + pos_of_1s.push(n as i32); + + let goal_usize = goal as usize; + for i in 1..(pos_of_1s.len() - goal_usize) { + let left_choices = pos_of_1s[i] - pos_of_1s[i - 1]; + let right_choices = pos_of_1s[i + goal_usize] - pos_of_1s[i + goal_usize - 1]; + total += left_choices * right_choices; + } + + total + } +} diff --git a/tests/501-1000/930. binary-subarrays-with-sum/sol.swift b/tests/501-1000/930. binary-subarrays-with-sum/sol.swift new file mode 100644 index 00000000..bd06d278 --- /dev/null +++ b/tests/501-1000/930. binary-subarrays-with-sum/sol.swift @@ -0,0 +1,35 @@ +class Solution { + func numSubarraysWithSum(_ nums: [Int], _ goal: Int) -> Int { + let n = nums.count + var posOf1s = [-1] + var total = 0 + var count = 0 + + if goal == 0 { + for num in nums { + if num == 0 { + count += 1 + total += count + } else { + count = 0 + } + } + return total + } + + for (i, num) in nums.enumerated() { + if num == 1 { + posOf1s.append(i) + } + } + posOf1s.append(n) + + for i in 1..<(posOf1s.count - goal) { + let leftChoices = posOf1s[i] - posOf1s[i - 1] + let rightChoices = posOf1s[i + goal] - posOf1s[i + goal - 1] + total += leftChoices * rightChoices + } + + return total + } +} diff --git a/tests/501-1000/930. binary-subarrays-with-sum/sol.ts b/tests/501-1000/930. binary-subarrays-with-sum/sol.ts new file mode 100644 index 00000000..23c9c0e4 --- /dev/null +++ b/tests/501-1000/930. binary-subarrays-with-sum/sol.ts @@ -0,0 +1,33 @@ +function numSubarraysWithSum(nums: number[], goal: number): number { + const n: number = nums.length; + const posOf1s: number[] = [-1]; + let total: number = 0; + let count: number = 0; + + if (goal === 0) { + for (const num of nums) { + if (num === 0) { + count++; + total += count; + } else { + count = 0; + } + } + return total; + } + + for (let i = 0; i < n; i++) { + if (nums[i] === 1) { + posOf1s.push(i); + } + } + posOf1s.push(n); + + for (let i = 1; i < posOf1s.length - goal; i++) { + const leftChoices: number = posOf1s[i] - posOf1s[i - 1]; + const rightChoices: number = posOf1s[i + goal] - posOf1s[i + goal - 1]; + total += leftChoices * rightChoices; + } + + return total; +} diff --git a/tests/501-1000/931. minimum-falling-path-sum/manifest.yaml b/tests/501-1000/931. minimum-falling-path-sum/manifest.yaml new file mode 100644 index 00000000..40d43f8f --- /dev/null +++ b/tests/501-1000/931. minimum-falling-path-sum/manifest.yaml @@ -0,0 +1,362 @@ +entry: + id: 931 + title: minimum-falling-path-sum + params: + matrix: + type: array + items: + type: array + items: + type: int + call: + cpp: "Solution().minFallingPathSum({matrix})" + rust: "Solution::min_falling_path_sum({matrix})" + python3: "Solution().minFallingPathSum({matrix})" + python2: "Solution().minFallingPathSum({matrix})" + ruby: "min_falling_path_sum({matrix})" + java: "new Solution().minFallingPathSum({matrix})" + csharp: "new Solution().MinFallingPathSum({matrix})" + kotlin: "Solution().minFallingPathSum({matrix})" + go: "minFallingPathSum({matrix})" + dart: "Solution().minFallingPathSum({matrix})" + swift: "Solution().minFallingPathSum({matrix})" + typescript: "minFallingPathSum({matrix})" +judge: + type: "exact" +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: "Checker().check({result})" + checker: | + class Checker: + def check(self, result): + return True +seed: 931 +tests: + - name: ex1 + in: + matrix: + elemType: "int" + value: + - [2, 1, 3] + - [6, 5, 4] + - [7, 8, 9] + out: 13 + - name: ex2 + in: + matrix: + elemType: "int" + value: + - [-19, 57] + - [-40, -5] + out: -59 + - name: t1 + in: + matrix: + elemType: "int" + value: + - [5] + out: 5 + - name: t2 + in: + matrix: + elemType: "int" + value: + - [1, 2] + - [3, 4] + out: 4 + - name: t3 + in: + matrix: + elemType: "int" + value: + - [7, 7] + - [7, 7] + out: 14 + - name: t4 + in: + matrix: + elemType: "int" + value: + - [0, 1, 2] + - [3, 4, 5] + - [6, 7, 8] + out: 9 + - name: t5 + in: + matrix: + elemType: "int" + value: + - [100, -100, 100] + - [-100, 100, -100] + - [100, -100, 100] + out: -300 + - name: t6 + in: + matrix: + elemType: "int" + value: + - [1, 2, 3] + - [4, 5, 6] + - [7, 8, 9] + out: 12 + - name: t7 + in: + matrix: + elemType: "int" + value: + - [9, 1, 9] + - [1, 9, 1] + - [9, 1, 9] + out: 3 + - name: t8 + in: + matrix: + elemType: "int" + value: + - [-1, -2, -3] + - [-4, -5, -6] + - [-7, -8, -9] + out: -18 + - name: t9 + in: + matrix: + elemType: "int" + value: + - [10] + out: 10 + - name: t10 + in: + matrix: + elemType: "int" + value: + - [0, 0, 0] + - [0, 0, 0] + - [0, 0, 0] + out: 0 + - name: t11 + in: + matrix: + elemType: "int" + value: + - [1, 100, 1] + - [100, 1, 100] + - [1, 100, 1] + out: 3 + - name: t12 + in: + matrix: + elemType: "int" + value: + - [2, 2, 1] + - [2, 1, 2] + - [1, 2, 2] + out: 3 + - name: t13 + in: + matrix: + elemType: "int" + value: + - [5, 4, 3, 2] + - [1, 2, 3, 4] + - [4, 3, 2, 1] + - [1, 1, 1, 1] + out: 7 + - name: t14 + in: + matrix: + elemType: "int" + value: + - [1, 2, 3, 4] + - [4, 3, 2, 1] + - [1, 2, 3, 4] + - [4, 3, 2, 1] + out: 8 + - name: t15 + in: + matrix: + elemType: "int" + value: + - [100, 99, 98] + - [97, 96, 95] + - [94, 93, 92] + out: 285 + - name: t16 + in: + matrix: + elemType: "int" + value: + - [-100, 0, 100] + - [100, -100, 0] + - [0, 100, -100] + out: -300 + - name: t17 + in: + matrix: + elemType: "int" + value: + - [3, 1, 2] + - [6, 5, 4] + - [9, 8, 7] + out: 12 + - name: t18 + in: + matrix: + elemType: "int" + value: + - [1, 1, 1] + - [1, 1, 1] + - [1, 1, 1] + out: 3 + - name: t19 + in: + matrix: + elemType: "int" + value: + - [1, 2] + - [1, 2] + out: 2 + - name: t20 + in: + matrix: + elemType: "int" + value: + - [2, 1] + - [1, 2] + out: 2 + - name: t21 + in: + matrix: + elemType: "int" + value: + - [1, 2, 3] + - [3, 2, 1] + out: 3 + - name: t22 + in: + matrix: + elemType: "int" + value: + - [1, 100] + - [100, 1] + out: 2 + - name: t23 + in: + matrix: + elemType: "int" + value: + - [100, 1] + - [1, 100] + out: 2 + - name: t24 + in: + matrix: + elemType: "int" + value: + - [1, 2, 1] + - [2, 1, 2] + - [1, 2, 1] + out: 3 + - name: t25 + in: + matrix: + elemType: "int" + value: + - [0, 1] + - [1, 0] + out: 0 + - name: t26 + in: + matrix: + elemType: "int" + value: + - [0, 1, 2, 3] + - [3, 2, 1, 0] + - [0, 1, 2, 3] + - [3, 2, 1, 0] + out: 4 + - name: t27 + in: + matrix: + elemType: "int" + value: + - [4, 3, 2] + - [1, 0, -1] + - [-2, -3, -4] + out: -3 + - name: t28 + in: + matrix: + elemType: "int" + value: + - [1, -1, 1] + - [-1, 1, -1] + - [1, -1, 1] + out: -3 + - name: t29 + in: + matrix: + elemType: "int" + value: + - [2, 3, 1] + - [5, 6, 4] + - [8, 7, 9] + out: 12 + - name: t30 + in: + matrix: + elemType: "int" + value: + - [9, 8, 7] + - [6, 5, 4] + - [3, 2, 1] + out: 12 + - name: t31 + in: + matrix: + elemType: "int" + value: + - [0, -1, -2] + - [-3, -4, -5] + - [-6, -7, -8] + out: -15 + - name: t32 + in: + matrix: + elemType: "int" + value: + - [1, 3, 1, 3] + - [2, 2, 2, 2] + - [3, 1, 3, 1] + - [4, 4, 4, 4] + out: 8 + - name: t33 + in: + matrix: + elemType: "int" + value: + - [1, 0, 1] + - [0, 1, 0] + - [1, 0, 1] + out: 0 + - name: t34 + in: + matrix: + elemType: "int" + value: + - [2, 3, 1, 4] + - [5, 6, 4, 2] + - [8, 7, 9, 1] + - [1, 2, 3, 4] + out: 7 + - name: t35 + in: + matrix: + elemType: "int" + value: + - [4, 1, 3] + - [2, 8, 5] + - [7, 2, 6] + out: 5 diff --git a/tests/501-1000/931. minimum-falling-path-sum/sol.cpp b/tests/501-1000/931. minimum-falling-path-sum/sol.cpp new file mode 100644 index 00000000..ad11339e --- /dev/null +++ b/tests/501-1000/931. minimum-falling-path-sum/sol.cpp @@ -0,0 +1,19 @@ +class Solution { +public: + int minFallingPathSum(vector>& matrix) { + int m = matrix.size(); + int n = matrix[0].size(); + vector dp = matrix[0]; + for (int i = 1; i < m; i++) { + vector ndp(n, INT_MAX); + for (int j = 0; j < n; j++) { + int best = dp[j]; + if (j > 0) best = min(best, dp[j - 1]); + if (j + 1 < n) best = min(best, dp[j + 1]); + ndp[j] = matrix[i][j] + best; + } + dp.swap(ndp); + } + return *min_element(dp.begin(), dp.end()); + } +}; diff --git a/tests/501-1000/931. minimum-falling-path-sum/sol.cs b/tests/501-1000/931. minimum-falling-path-sum/sol.cs new file mode 100644 index 00000000..3ec96039 --- /dev/null +++ b/tests/501-1000/931. minimum-falling-path-sum/sol.cs @@ -0,0 +1,22 @@ +public class Solution { + public int MinFallingPathSum(int[][] matrix) { + int m = matrix.Length; + int n = matrix[0].Length; + int[] dp = (int[])matrix[0].Clone(); + for (int i = 1; i < m; i++) { + int[] ndp = new int[n]; + for (int j = 0; j < n; j++) { + int best = dp[j]; + if (j > 0) best = Math.Min(best, dp[j - 1]); + if (j + 1 < n) best = Math.Min(best, dp[j + 1]); + ndp[j] = matrix[i][j] + best; + } + dp = ndp; + } + int ans = dp[0]; + foreach (int v in dp) { + if (v < ans) ans = v; + } + return ans; + } +} diff --git a/tests/501-1000/931. minimum-falling-path-sum/sol.dart b/tests/501-1000/931. minimum-falling-path-sum/sol.dart new file mode 100644 index 00000000..52ac0a5c --- /dev/null +++ b/tests/501-1000/931. minimum-falling-path-sum/sol.dart @@ -0,0 +1,33 @@ +class Solution { + int minFallingPathSum(List> matrix) { + int m = matrix.length; + int n = matrix[0].length; + if (m == 1 && n == 1) { + int minVal = matrix[0][0]; + for (int v in matrix[0]) { + if (v < minVal) minVal = v; + } + return minVal; + } + List> dp = List.generate(m - 1, (_) => List.filled(n, null)); + int mini = 1 << 60; + int f(int i, int j) { + if (j >= n || j < 0) return 1 << 60; + if (i == m - 1) return matrix[i][j]; + if (dp[i][j] != null) return dp[i][j]!; + int down = matrix[i][j] + f(i + 1, j); + int leftd = matrix[i][j] + f(i + 1, j - 1); + int rightd = matrix[i][j] + f(i + 1, j + 1); + int val = down; + if (leftd < val) val = leftd; + if (rightd < val) val = rightd; + dp[i][j] = val; + return val; + } + for (int i = 0; i < n; i++) { + int val = f(0, i); + if (val < mini) mini = val; + } + return mini; + } +} diff --git a/tests/501-1000/931. minimum-falling-path-sum/sol.go b/tests/501-1000/931. minimum-falling-path-sum/sol.go new file mode 100644 index 00000000..6e08b07f --- /dev/null +++ b/tests/501-1000/931. minimum-falling-path-sum/sol.go @@ -0,0 +1,49 @@ +func minFallingPathSum(matrix [][]int) int { + m := len(matrix) + n := len(matrix[0]) + if m == 1 && n == 1 { + minVal := matrix[0][0] + for _, v := range matrix[0] { + if v < minVal { + minVal = v + } + } + return minVal + } + dp := make([][]*int, m-1) + for i := range dp { + dp[i] = make([]*int, n) + } + mini := int(1<<31 - 1) + var f func(int, int) int + f = func(i, j int) int { + if j >= n || j < 0 { + return 1<<31 - 1 + } + if i == m-1 { + return matrix[i][j] + } + if dp[i][j] != nil { + return *dp[i][j] + } + down := matrix[i][j] + f(i+1, j) + leftd := matrix[i][j] + f(i+1, j-1) + rightd := matrix[i][j] + f(i+1, j+1) + minVal := down + if leftd < minVal { + minVal = leftd + } + if rightd < minVal { + minVal = rightd + } + dp[i][j] = &minVal + return minVal + } + for i := 0; i < n; i++ { + val := f(0, i) + if val < mini { + mini = val + } + } + return mini +} diff --git a/tests/501-1000/931. minimum-falling-path-sum/sol.java b/tests/501-1000/931. minimum-falling-path-sum/sol.java new file mode 100644 index 00000000..04d1273a --- /dev/null +++ b/tests/501-1000/931. minimum-falling-path-sum/sol.java @@ -0,0 +1,22 @@ +class Solution { + public int minFallingPathSum(int[][] matrix) { + int m = matrix.length; + int n = matrix[0].length; + int[] dp = matrix[0].clone(); + for (int i = 1; i < m; i++) { + int[] ndp = new int[n]; + for (int j = 0; j < n; j++) { + int best = dp[j]; + if (j > 0) best = Math.min(best, dp[j - 1]); + if (j + 1 < n) best = Math.min(best, dp[j + 1]); + ndp[j] = matrix[i][j] + best; + } + dp = ndp; + } + int ans = dp[0]; + for (int v : dp) { + if (v < ans) ans = v; + } + return ans; + } +} diff --git a/tests/501-1000/931. minimum-falling-path-sum/sol.kt b/tests/501-1000/931. minimum-falling-path-sum/sol.kt new file mode 100644 index 00000000..0e7ba56b --- /dev/null +++ b/tests/501-1000/931. minimum-falling-path-sum/sol.kt @@ -0,0 +1,18 @@ +class Solution { + fun minFallingPathSum(matrix: Array): Int { + val m = matrix.size + val n = matrix[0].size + var dp = matrix[0].clone() + for (i in 1 until m) { + val ndp = IntArray(n) + for (j in 0 until n) { + var best = dp[j] + if (j > 0) best = minOf(best, dp[j - 1]) + if (j + 1 < n) best = minOf(best, dp[j + 1]) + ndp[j] = matrix[i][j] + best + } + dp = ndp + } + return dp.min() + } +} diff --git a/tests/501-1000/931. minimum-falling-path-sum/sol.py b/tests/501-1000/931. minimum-falling-path-sum/sol.py new file mode 100644 index 00000000..96aefb1b --- /dev/null +++ b/tests/501-1000/931. minimum-falling-path-sum/sol.py @@ -0,0 +1,26 @@ +class Solution: + def minFallingPathSum(self, matrix: List[List[int]]) -> int: + m, n = len(matrix), len(matrix[0]) + if m == 1 and n == 1: + return min(matrix[0]) + dp = [] + for i in range(m - 1): + dp.append([None] * n) + mini = float("inf") + + def f(i, j): + if j >= n or j < 0: + return float("inf") + if i == m - 1: + return matrix[i][j] + if dp[i][j] is not None: + return dp[i][j] + down = matrix[i][j] + f(i + 1, j) + leftd = matrix[i][j] + f(i + 1, j - 1) + rightd = matrix[i][j] + f(i + 1, j + 1) + dp[i][j] = min(down, leftd, rightd) + return dp[i][j] + + for i in range(n): + mini = min(mini, f(0, i)) + return mini diff --git a/tests/501-1000/931. minimum-falling-path-sum/sol.py2 b/tests/501-1000/931. minimum-falling-path-sum/sol.py2 new file mode 100644 index 00000000..6ab77321 --- /dev/null +++ b/tests/501-1000/931. minimum-falling-path-sum/sol.py2 @@ -0,0 +1,28 @@ +class Solution(object): + def minFallingPathSum(self, matrix): + """ + :type matrix: List[List[int]] + :rtype: int + """ + m, n = len(matrix), len(matrix[0]) + if m == 1 and n == 1: + return min(matrix[0]) + dp = [] + for i in range(m - 1): + dp.append([None] * n) + mini = float("inf") + def f(i, j): + if j >= n or j < 0: + return float("inf") + if i == m - 1: + return matrix[i][j] + if dp[i][j] is not None: + return dp[i][j] + down = matrix[i][j] + f(i + 1, j) + leftd = matrix[i][j] + f(i + 1, j - 1) + rightd = matrix[i][j] + f(i + 1, j + 1) + dp[i][j] = min(down, leftd, rightd) + return dp[i][j] + for i in range(n): + mini = min(mini, f(0, i)) + return mini diff --git a/tests/501-1000/931. minimum-falling-path-sum/sol.rb b/tests/501-1000/931. minimum-falling-path-sum/sol.rb new file mode 100644 index 00000000..18e7974b --- /dev/null +++ b/tests/501-1000/931. minimum-falling-path-sum/sol.rb @@ -0,0 +1,31 @@ +# @param {Integer[][]} matrix +# @return {Integer} +def min_falling_path_sum(matrix) + m = matrix.length + n = matrix[0].length + if m == 1 && n == 1 + return matrix[0].min + end + dp = Array.new(m - 1) { Array.new(n) } + mini = Float::INFINITY + f = lambda do |i, j| + if j >= n || j < 0 + return Float::INFINITY + end + if i == m - 1 + return matrix[i][j] + end + if dp[i][j] != nil + return dp[i][j] + end + down = matrix[i][j] + f.call(i + 1, j) + leftd = matrix[i][j] + f.call(i + 1, j - 1) + rightd = matrix[i][j] + f.call(i + 1, j + 1) + dp[i][j] = [down, leftd, rightd].min + return dp[i][j] + end + (0...n).each do |i| + mini = [mini, f.call(0, i)].min + end + return mini +end diff --git a/tests/501-1000/931. minimum-falling-path-sum/sol.rs b/tests/501-1000/931. minimum-falling-path-sum/sol.rs new file mode 100644 index 00000000..f068987f --- /dev/null +++ b/tests/501-1000/931. minimum-falling-path-sum/sol.rs @@ -0,0 +1,33 @@ +impl Solution { + pub fn min_falling_path_sum(matrix: Vec>) -> i32 { + let m = matrix.len(); + let n = matrix[0].len(); + if m == 1 && n == 1 { + return *matrix[0].iter().min().unwrap(); + } + let mut dp: Vec>> = vec![vec![None; n]; m - 1]; + let mut mini = i32::MAX; + fn f(i: usize, j: i32, m: usize, n: i32, matrix: &Vec>, dp: &mut Vec>>) -> i32 { + if j >= n || j < 0 { + return i32::MAX; + } + let j = j as usize; + if i == m - 1 { + return matrix[i][j]; + } + if let Some(val) = dp[i][j] { + return val; + } + let down = matrix[i][j].saturating_add(f(i + 1, j as i32, m, n as i32, matrix, dp)); + let leftd = matrix[i][j].saturating_add(f(i + 1, j as i32 - 1, m, n as i32, matrix, dp)); + let rightd = matrix[i][j].saturating_add(f(i + 1, j as i32 + 1, m, n as i32, matrix, dp)); + let min_val = down.min(leftd).min(rightd); + dp[i][j] = Some(min_val); + min_val + } + for col in 0..n { + mini = mini.min(f(0, col as i32, m, n as i32, &matrix, &mut dp)); + } + mini + } +} diff --git a/tests/501-1000/931. minimum-falling-path-sum/sol.swift b/tests/501-1000/931. minimum-falling-path-sum/sol.swift new file mode 100644 index 00000000..7fe9873c --- /dev/null +++ b/tests/501-1000/931. minimum-falling-path-sum/sol.swift @@ -0,0 +1,18 @@ +class Solution { + func minFallingPathSum(_ matrix: [[Int]]) -> Int { + let m = matrix.count + let n = matrix[0].count + var dp = matrix[0] + for i in 1.. 0 { best = min(best, dp[j - 1]) } + if j + 1 < n { best = min(best, dp[j + 1]) } + ndp[j] = matrix[i][j] + best + } + dp = ndp + } + return dp.min()! + } +} diff --git a/tests/501-1000/931. minimum-falling-path-sum/sol.ts b/tests/501-1000/931. minimum-falling-path-sum/sol.ts new file mode 100644 index 00000000..612f909d --- /dev/null +++ b/tests/501-1000/931. minimum-falling-path-sum/sol.ts @@ -0,0 +1,25 @@ +function minFallingPathSum(matrix: number[][]): number { + const m = matrix.length; + const n = matrix[0].length; + if (m === 1 && n === 1) { + return Math.min(...matrix[0]); + } + const dp: (number | null)[][] = Array.from({ length: m - 1 }, () => + Array(n).fill(null), + ); + let mini = Infinity; + const f = (i: number, j: number): number => { + if (j >= n || j < 0) return Infinity; + if (i === m - 1) return matrix[i][j]; + if (dp[i][j] !== null) return dp[i][j]!; + const down = matrix[i][j] + f(i + 1, j); + const leftd = matrix[i][j] + f(i + 1, j - 1); + const rightd = matrix[i][j] + f(i + 1, j + 1); + dp[i][j] = Math.min(down, leftd, rightd); + return dp[i][j]!; + }; + for (let i = 0; i < n; i++) { + mini = Math.min(mini, f(0, i)); + } + return mini; +} diff --git a/tests/501-1000/932. beautiful-array/manifest.yaml b/tests/501-1000/932. beautiful-array/manifest.yaml new file mode 100644 index 00000000..d44861ee --- /dev/null +++ b/tests/501-1000/932. beautiful-array/manifest.yaml @@ -0,0 +1,144 @@ +entry: + id: 932 + title: beautiful-array + params: + n: + type: int + call: + cpp: Solution().beautifulArray({n}) + rust: Solution::beautiful_array({n}) + python3: Solution().beautifulArray({n}) + python2: Solution().beautifulArray({n}) + ruby: beautiful_array({n}) + java: new Solution().beautifulArray({n}) + csharp: new Solution().BeautifulArray({n}) + kotlin: Solution().beautifulArray({n}) + go: beautifulArray({n}) + dart: Solution().beautifulArray({n}) + swift: Solution().beautifulArray({n}) + typescript: beautifulArray({n}) +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 256 +oracle: + python3: + call: Checker().beautifulArray(n, {result}) + checker: + "class Checker:\n def beautifulArray(self, n, result):\n if\ + \ not isinstance(result, list) or len(result) != n:\n return False\n\ + \ if sorted(result) != list(range(1, n + 1)):\n return False\n\ + \ pos = {v: i for i, v in enumerate(result)}\n for x in result:\n\ + \ for y in result:\n s = x + y\n if\ + \ s % 2:\n continue\n z = s // 2\n \ + \ if z == x or z == y or z not in pos:\n continue\n\ + \ i, j, k = pos[x], pos[z], pos[y]\n if (i < j\ + \ < k) or (k < j < i):\n return False\n return True\n" +seed: 932 +tests: + - name: n_1 + in: + n: 1 + - name: n_2 + in: + n: 2 + - name: n_3 + in: + n: 3 + - name: n_4 + in: + n: 4 + - name: n_5 + in: + n: 5 + - name: n_6 + in: + n: 6 + - name: n_7 + in: + n: 7 + - name: n_8 + in: + n: 8 + - name: n_9 + in: + n: 9 + - name: n_10 + in: + n: 10 + - name: n_11 + in: + n: 11 + - name: n_12 + in: + n: 12 + - name: n_13 + in: + n: 13 + - name: n_14 + in: + n: 14 + - name: n_15 + in: + n: 15 + - name: n_16 + in: + n: 16 + - name: n_17 + in: + n: 17 + - name: n_18 + in: + n: 18 + - name: n_19 + in: + n: 19 + - name: n_20 + in: + n: 20 + - name: n_21 + in: + n: 21 + - name: n_22 + in: + n: 22 + - name: n_23 + in: + n: 23 + - name: n_24 + in: + n: 24 + - name: n_25 + in: + n: 25 + - name: n_30 + in: + n: 30 + - name: n_35 + in: + n: 35 + - name: n_40 + in: + n: 40 + - name: n_45 + in: + n: 45 + - name: n_50 + in: + n: 50 + - name: n_60 + in: + n: 60 + - name: n_70 + in: + n: 70 + - name: n_80 + in: + n: 80 + - name: n_90 + in: + n: 90 + - name: n_100 + in: + n: 100 diff --git a/tests/501-1000/932. beautiful-array/sol.cpp b/tests/501-1000/932. beautiful-array/sol.cpp new file mode 100644 index 00000000..c39b33c5 --- /dev/null +++ b/tests/501-1000/932. beautiful-array/sol.cpp @@ -0,0 +1,23 @@ +class Solution { +public: + vector beautifulArray(int n) { + if (n == 1) { + return {1}; + } + + vector left = beautifulArray((n + 1) / 2); + vector right = beautifulArray(n / 2); + + vector result; + result.reserve(n); + + for (int x : left) { + result.push_back(2 * x - 1); + } + for (int x : right) { + result.push_back(2 * x); + } + + return result; + } +}; diff --git a/tests/501-1000/932. beautiful-array/sol.cs b/tests/501-1000/932. beautiful-array/sol.cs new file mode 100644 index 00000000..05d158a5 --- /dev/null +++ b/tests/501-1000/932. beautiful-array/sol.cs @@ -0,0 +1,22 @@ +public class Solution { + public int[] BeautifulArray(int n) { + if (n == 1) { + return new int[] { 1 }; + } + + int[] left = BeautifulArray((n + 1) / 2); + int[] right = BeautifulArray(n / 2); + + int[] result = new int[n]; + int idx = 0; + + foreach (int x in left) { + result[idx++] = 2 * x - 1; + } + foreach (int x in right) { + result[idx++] = 2 * x; + } + + return result; + } +} diff --git a/tests/501-1000/932. beautiful-array/sol.dart b/tests/501-1000/932. beautiful-array/sol.dart new file mode 100644 index 00000000..fb34ae79 --- /dev/null +++ b/tests/501-1000/932. beautiful-array/sol.dart @@ -0,0 +1,21 @@ +class Solution { + List beautifulArray(int n) { + if (n == 1) { + return [1]; + } + + List left = beautifulArray((n + 1) ~/ 2); + List right = beautifulArray(n ~/ 2); + + List result = []; + + for (int x in left) { + result.add(2 * x - 1); + } + for (int x in right) { + result.add(2 * x); + } + + return result; + } +} diff --git a/tests/501-1000/932. beautiful-array/sol.go b/tests/501-1000/932. beautiful-array/sol.go new file mode 100644 index 00000000..4596ff17 --- /dev/null +++ b/tests/501-1000/932. beautiful-array/sol.go @@ -0,0 +1,19 @@ +func beautifulArray(n int) []int { + if n == 1 { + return []int{1} + } + + left := beautifulArray((n + 1) / 2) + right := beautifulArray(n / 2) + + result := make([]int, 0, n) + + for _, x := range left { + result = append(result, 2*x-1) + } + for _, x := range right { + result = append(result, 2*x) + } + + return result +} diff --git a/tests/501-1000/932. beautiful-array/sol.java b/tests/501-1000/932. beautiful-array/sol.java new file mode 100644 index 00000000..f0dac03a --- /dev/null +++ b/tests/501-1000/932. beautiful-array/sol.java @@ -0,0 +1,22 @@ +class Solution { + public int[] beautifulArray(int n) { + if (n == 1) { + return new int[]{1}; + } + + int[] left = beautifulArray((n + 1) / 2); + int[] right = beautifulArray(n / 2); + + int[] result = new int[n]; + int idx = 0; + + for (int x : left) { + result[idx++] = 2 * x - 1; + } + for (int x : right) { + result[idx++] = 2 * x; + } + + return result; + } +} diff --git a/tests/501-1000/932. beautiful-array/sol.kt b/tests/501-1000/932. beautiful-array/sol.kt new file mode 100644 index 00000000..ac235df4 --- /dev/null +++ b/tests/501-1000/932. beautiful-array/sol.kt @@ -0,0 +1,22 @@ +class Solution { + fun beautifulArray(n: Int): IntArray { + if (n == 1) { + return intArrayOf(1) + } + + val left = beautifulArray((n + 1) / 2) + val right = beautifulArray(n / 2) + + val result = IntArray(n) + var idx = 0 + + for (x in left) { + result[idx++] = 2 * x - 1 + } + for (x in right) { + result[idx++] = 2 * x + } + + return result + } +} diff --git a/tests/501-1000/932. beautiful-array/sol.py b/tests/501-1000/932. beautiful-array/sol.py new file mode 100644 index 00000000..fa1db16d --- /dev/null +++ b/tests/501-1000/932. beautiful-array/sol.py @@ -0,0 +1,15 @@ +from typing import List + + +class Solution: + def beautifulArray(self, n: int) -> List[int]: + if n == 1: + return [1] + + left = self.beautifulArray((n + 1) // 2) # odd part + right = self.beautifulArray(n // 2) # even part + + left = [2 * x - 1 for x in left] + right = [2 * x for x in right] + + return left + right diff --git a/tests/501-1000/932. beautiful-array/sol.py2 b/tests/501-1000/932. beautiful-array/sol.py2 new file mode 100644 index 00000000..8c390c62 --- /dev/null +++ b/tests/501-1000/932. beautiful-array/sol.py2 @@ -0,0 +1,16 @@ +class Solution(object): + def beautifulArray(self, n): + """ + :type n: int + :rtype: List[int] + """ + if n == 1: + return [1] + + left = self.beautifulArray((n + 1) // 2) + right = self.beautifulArray(n // 2) + + left = [2 * x - 1 for x in left] + right = [2 * x for x in right] + + return left + right diff --git a/tests/501-1000/932. beautiful-array/sol.rb b/tests/501-1000/932. beautiful-array/sol.rb new file mode 100644 index 00000000..80bd66d1 --- /dev/null +++ b/tests/501-1000/932. beautiful-array/sol.rb @@ -0,0 +1,15 @@ +# @param {Integer} n +# @return {Integer[]} +def beautiful_array(n) + if n == 1 + return [1] + end + + left = beautiful_array((n + 1) / 2) + right = beautiful_array(n / 2) + + left = left.map { |x| 2 * x - 1 } + right = right.map { |x| 2 * x } + + left + right +end diff --git a/tests/501-1000/932. beautiful-array/sol.rs b/tests/501-1000/932. beautiful-array/sol.rs new file mode 100644 index 00000000..5cb89874 --- /dev/null +++ b/tests/501-1000/932. beautiful-array/sol.rs @@ -0,0 +1,21 @@ +impl Solution { + pub fn beautiful_array(n: i32) -> Vec { + if n == 1 { + return vec![1]; + } + + let left = Solution::beautiful_array((n + 1) / 2); + let right = Solution::beautiful_array(n / 2); + + let mut result = Vec::with_capacity(n as usize); + + for x in left { + result.push(2 * x - 1); + } + for x in right { + result.push(2 * x); + } + + result + } +} diff --git a/tests/501-1000/932. beautiful-array/sol.swift b/tests/501-1000/932. beautiful-array/sol.swift new file mode 100644 index 00000000..254a29c1 --- /dev/null +++ b/tests/501-1000/932. beautiful-array/sol.swift @@ -0,0 +1,21 @@ +class Solution { + func beautifulArray(_ n: Int) -> [Int] { + if n == 1 { + return [1] + } + + let left = beautifulArray((n + 1) / 2) + let right = beautifulArray(n / 2) + + var result = [Int]() + + for x in left { + result.append(2 * x - 1) + } + for x in right { + result.append(2 * x) + } + + return result + } +} diff --git a/tests/501-1000/932. beautiful-array/sol.ts b/tests/501-1000/932. beautiful-array/sol.ts new file mode 100644 index 00000000..9bd2aae5 --- /dev/null +++ b/tests/501-1000/932. beautiful-array/sol.ts @@ -0,0 +1,19 @@ +function beautifulArray(n: number): number[] { + if (n === 1) { + return [1]; + } + + const left = beautifulArray(Math.ceil(n / 2)); + const right = beautifulArray(Math.floor(n / 2)); + + const result: number[] = []; + + for (const x of left) { + result.push(2 * x - 1); + } + for (const x of right) { + result.push(2 * x); + } + + return result; +} diff --git a/tests/501-1000/934. shortest-bridge/manifest.yaml b/tests/501-1000/934. shortest-bridge/manifest.yaml new file mode 100644 index 00000000..b74a6b8d --- /dev/null +++ b/tests/501-1000/934. shortest-bridge/manifest.yaml @@ -0,0 +1,881 @@ +entry: + id: 934 + title: shortest-bridge + params: + grid: + type: array + items: + type: array + items: + type: int + call: + cpp: Solution().shortestBridge({grid}) + rust: Solution::shortest_bridge({grid}) + python3: Solution().shortestBridge({grid}) + python2: Solution().shortestBridge({grid}) + ruby: shortest_bridge({grid}) + java: new Solution().shortestBridge({grid}) + csharp: new Solution().ShortestBridge({grid}) + kotlin: Solution().shortestBridge({grid}) + go: shortestBridge({grid}) + dart: Solution().shortestBridge({grid}) + swift: Solution().shortestBridge({grid}) + typescript: shortestBridge({grid}) +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 934 +tests: + - name: case_1 + in: + grid: + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - - 0 + - 1 + - 0 + - 1 + - 1 + - 0 + - - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + out: 1 + - name: case_2 + in: + grid: + - - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + out: 3 + - name: case_3 + in: + grid: + - - 1 + - 0 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 1 + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + out: 1 + - name: case_4 + in: + grid: + - - 1 + - 0 + - 0 + - - 1 + - 0 + - 1 + - - 0 + - 0 + - 0 + out: 1 + - name: case_5 + in: + grid: + - - 0 + - 1 + - - 1 + - 0 + out: 1 + - name: case_6 + in: + grid: + - - 1 + - 0 + - 0 + - 0 + - - 1 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + - - 0 + - 0 + - 1 + - 0 + out: 1 + - name: case_7 + in: + grid: + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + out: 1 + - name: case_8 + in: + grid: + - - 1 + - 0 + - - 0 + - 1 + out: 1 + - name: case_9 + in: + grid: + - - 0 + - 1 + - 0 + - - 0 + - 0 + - 1 + - - 0 + - 1 + - 1 + out: 1 + - name: case_10 + in: + grid: + - - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + out: 1 + - name: case_11 + in: + grid: + - - 0 + - 1 + - - 1 + - 0 + out: 1 + - name: case_12 + in: + grid: + - - 1 + - 0 + - 1 + - - 0 + - 0 + - 1 + - - 0 + - 0 + - 0 + out: 1 + - name: case_13 + in: + grid: + - - 0 + - 0 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + out: 2 + - name: case_14 + in: + grid: + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 1 + - 1 + - 1 + - 0 + - 0 + - 0 + - - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - - 0 + - 0 + - 0 + - 1 + - 1 + - 1 + out: 4 + - name: case_15 + in: + grid: + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + out: 1 + - name: case_16 + in: + grid: + - - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 1 + - 0 + out: 1 + - name: case_17 + in: + grid: + - - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + out: 2 + - name: case_18 + in: + grid: + - - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + out: 1 + - name: case_19 + in: + grid: + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 0 + out: 1 + - name: case_20 + in: + grid: + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + out: 5 + - name: case_21 + in: + grid: + - - 1 + - 1 + - 1 + - 0 + - 0 + - - 0 + - 1 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 1 + out: 3 + - name: case_22 + in: + grid: + - - 1 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 1 + - - 0 + - 0 + - 0 + - 0 + out: 2 + - name: case_23 + in: + grid: + - - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + out: 2 + - name: case_24 + in: + grid: + - - 1 + - 0 + - - 0 + - 1 + out: 1 + - name: case_25 + in: + grid: + - - 1 + - 1 + - 0 + - 0 + - - 1 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + - - 0 + - 0 + - 1 + - 0 + out: 1 + - name: case_26 + in: + grid: + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + out: 2 + - name: case_27 + in: + grid: + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 1 + - 0 + - 0 + - 0 + - 0 + - 1 + - - 1 + - 0 + - 0 + - 0 + - 1 + - 1 + - - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + out: 3 + - name: case_28 + in: + grid: + - - 1 + - 0 + - 1 + - - 1 + - 0 + - 1 + - - 0 + - 0 + - 0 + out: 1 + - name: case_29 + in: + grid: + - - 0 + - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 1 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 0 + out: 2 + - name: case_30 + in: + grid: + - - 0 + - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 0 + - 0 + - - 0 + - 0 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 0 + - 1 + - - 0 + - 0 + - 0 + - 0 + - 1 + out: 1 + - name: case_31 + in: + grid: + - - 1 + - 0 + - 0 + - - 0 + - 0 + - 0 + - - 0 + - 1 + - 0 + out: 2 + - name: case_32 + in: + grid: + - - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - - 1 + - 1 + - 0 + out: 1 + - name: case_33 + in: + grid: + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 1 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 1 + out: 1 + - name: case_34 + in: + grid: + - - 1 + - 0 + - - 0 + - 1 + out: 1 + - name: case_35 + in: + grid: + - - 0 + - 1 + - 1 + - - 0 + - 0 + - 0 + - - 1 + - 1 + - 1 + out: 1 diff --git a/tests/501-1000/934. shortest-bridge/sol.cpp b/tests/501-1000/934. shortest-bridge/sol.cpp new file mode 100644 index 00000000..660e4809 --- /dev/null +++ b/tests/501-1000/934. shortest-bridge/sol.cpp @@ -0,0 +1,48 @@ +class Solution { +public: + int shortestBridge(vector>& grid) { + int n = grid.size(); + vector> directions = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}}; + vector> visited(n, vector(n, false)); + queue> q; + + function dfs = [&](int r, int c) { + visited[r][c] = true; + for (auto [dr, dc] : directions) { + int nr = r + dr, nc = c + dc; + if (nr >= 0 && nr < n && nc >= 0 && nc < n && !visited[nr][nc]) { + if (grid[nr][nc] == 0) { + visited[nr][nc] = true; + q.push({nr, nc, 1}); + } else { + dfs(nr, nc); + } + } + } + }; + + bool found = false; + for (int i = 0; i < n && !found; i++) { + for (int j = 0; j < n && !found; j++) { + if (grid[i][j] == 1) { + dfs(i, j); + found = true; + } + } + } + + while (!q.empty()) { + auto [r, c, dist] = q.front(); + q.pop(); + for (auto [dr, dc] : directions) { + int nr = r + dr, nc = c + dc; + if (nr >= 0 && nr < n && nc >= 0 && nc < n && !visited[nr][nc]) { + if (grid[nr][nc] == 1) return dist; + visited[nr][nc] = true; + q.push({nr, nc, dist + 1}); + } + } + } + return 0; + } +}; diff --git a/tests/501-1000/934. shortest-bridge/sol.cs b/tests/501-1000/934. shortest-bridge/sol.cs new file mode 100644 index 00000000..330bf152 --- /dev/null +++ b/tests/501-1000/934. shortest-bridge/sol.cs @@ -0,0 +1,47 @@ +public class Solution { + public int ShortestBridge(int[][] grid) { + int n = grid.Length; + int[][] directions = new int[][] { new int[] {-1, 0}, new int[] {1, 0}, new int[] {0, 1}, new int[] {0, -1} }; + bool[][] visited = new bool[n][]; + for (int i = 0; i < n; i++) visited[i] = new bool[n]; + Queue<(int r, int c, int dist)> q = new Queue<(int, int, int)>(); + + void Dfs(int r, int c) { + visited[r][c] = true; + foreach (var d in directions) { + int nr = r + d[0], nc = c + d[1]; + if (nr >= 0 && nr < n && nc >= 0 && nc < n && !visited[nr][nc]) { + if (grid[nr][nc] == 0) { + visited[nr][nc] = true; + q.Enqueue((nr, nc, 1)); + } else { + Dfs(nr, nc); + } + } + } + } + + bool found = false; + for (int i = 0; i < n && !found; i++) { + for (int j = 0; j < n && !found; j++) { + if (grid[i][j] == 1) { + Dfs(i, j); + found = true; + } + } + } + + while (q.Count > 0) { + var (r, c, dist) = q.Dequeue(); + foreach (var d in directions) { + int nr = r + d[0], nc = c + d[1]; + if (nr >= 0 && nr < n && nc >= 0 && nc < n && !visited[nr][nc]) { + if (grid[nr][nc] == 1) return dist; + visited[nr][nc] = true; + q.Enqueue((nr, nc, dist + 1)); + } + } + } + return 0; + } +} diff --git a/tests/501-1000/934. shortest-bridge/sol.dart b/tests/501-1000/934. shortest-bridge/sol.dart new file mode 100644 index 00000000..71004196 --- /dev/null +++ b/tests/501-1000/934. shortest-bridge/sol.dart @@ -0,0 +1,47 @@ +class Solution { + int shortestBridge(List> grid) { + int n = grid.length; + List> directions = [[-1, 0], [1, 0], [0, 1], [0, -1]]; + List> visited = List.generate(n, (_) => List.filled(n, false)); + List> q = []; + + void dfs(int r, int c) { + visited[r][c] = true; + for (var d in directions) { + int nr = r + d[0], nc = c + d[1]; + if (nr >= 0 && nr < n && nc >= 0 && nc < n && !visited[nr][nc]) { + if (grid[nr][nc] == 0) { + visited[nr][nc] = true; + q.add([nr, nc, 1]); + } else { + dfs(nr, nc); + } + } + } + } + + bool found = false; + for (int i = 0; i < n && !found; i++) { + for (int j = 0; j < n && !found; j++) { + if (grid[i][j] == 1) { + dfs(i, j); + found = true; + } + } + } + + while (q.isNotEmpty) { + var cur = q.removeAt(0); + int r = cur[0], c = cur[1], dist = cur[2]; + for (var d in directions) { + int nr = r + d[0], nc = c + d[1]; + if (nr >= 0 && nr < n && nc >= 0 && nc < n && !visited[nr][nc]) { + if (grid[nr][nc] == 1) return dist; + visited[nr][nc] = true; + q.add([nr, nc, dist + 1]); + } + } + } + return 0; + } +} diff --git a/tests/501-1000/934. shortest-bridge/sol.go b/tests/501-1000/934. shortest-bridge/sol.go new file mode 100644 index 00000000..dac891a2 --- /dev/null +++ b/tests/501-1000/934. shortest-bridge/sol.go @@ -0,0 +1,52 @@ +func shortestBridge(grid [][]int) int { + n := len(grid) + directions := [][]int{{-1, 0}, {1, 0}, {0, 1}, {0, -1}} + visited := make([][]bool, n) + for i := range visited { + visited[i] = make([]bool, n) + } + type point struct{ r, c, dist int } + q := make([]point, 0) + + var dfs func(r, c int) + dfs = func(r, c int) { + visited[r][c] = true + for _, d := range directions { + nr, nc := r+d[0], c+d[1] + if nr >= 0 && nr < n && nc >= 0 && nc < n && !visited[nr][nc] { + if grid[nr][nc] == 0 { + visited[nr][nc] = true + q = append(q, point{nr, nc, 1}) + } else { + dfs(nr, nc) + } + } + } + } + + found := false + for i := 0; i < n && !found; i++ { + for j := 0; j < n && !found; j++ { + if grid[i][j] == 1 { + dfs(i, j) + found = true + } + } + } + + for len(q) > 0 { + cur := q[0] + q = q[1:] + for _, d := range directions { + nr, nc := cur.r+d[0], cur.c+d[1] + if nr >= 0 && nr < n && nc >= 0 && nc < n && !visited[nr][nc] { + if grid[nr][nc] == 1 { + return cur.dist + } + visited[nr][nc] = true + q = append(q, point{nr, nc, cur.dist + 1}) + } + } + } + return 0 +} diff --git a/tests/501-1000/934. shortest-bridge/sol.java b/tests/501-1000/934. shortest-bridge/sol.java new file mode 100644 index 00000000..5aae49fb --- /dev/null +++ b/tests/501-1000/934. shortest-bridge/sol.java @@ -0,0 +1,47 @@ +class Solution { + public int shortestBridge(int[][] grid) { + int n = grid.length; + int[][] directions = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}}; + boolean[][] visited = new boolean[n][n]; + Deque q = new ArrayDeque<>(); + + boolean found = false; + for (int i = 0; i < n && !found; i++) { + for (int j = 0; j < n && !found; j++) { + if (grid[i][j] == 1) { + dfs(i, j, grid, visited, directions, q); + found = true; + } + } + } + + while (!q.isEmpty()) { + int[] cur = q.poll(); + int r = cur[0], c = cur[1], dist = cur[2]; + for (int[] dir : directions) { + int nr = r + dir[0], nc = c + dir[1]; + if (nr >= 0 && nr < n && nc >= 0 && nc < n && !visited[nr][nc]) { + if (grid[nr][nc] == 1) return dist; + visited[nr][nc] = true; + q.offer(new int[]{nr, nc, dist + 1}); + } + } + } + return 0; + } + + private void dfs(int r, int c, int[][] grid, boolean[][] visited, int[][] directions, Deque q) { + visited[r][c] = true; + for (int[] dir : directions) { + int nr = r + dir[0], nc = c + dir[1]; + if (nr >= 0 && nr < grid.length && nc >= 0 && nc < grid.length && !visited[nr][nc]) { + if (grid[nr][nc] == 0) { + visited[nr][nc] = true; + q.offer(new int[]{nr, nc, 1}); + } else { + dfs(nr, nc, grid, visited, directions, q); + } + } + } + } +} diff --git a/tests/501-1000/934. shortest-bridge/sol.kt b/tests/501-1000/934. shortest-bridge/sol.kt new file mode 100644 index 00000000..d92908bd --- /dev/null +++ b/tests/501-1000/934. shortest-bridge/sol.kt @@ -0,0 +1,50 @@ +class Solution { + fun shortestBridge(grid: Array): Int { + val n = grid.size + val directions = arrayOf(intArrayOf(-1, 0), intArrayOf(1, 0), intArrayOf(0, 1), intArrayOf(0, -1)) + val visited = Array(n) { BooleanArray(n) } + val q: ArrayDeque = ArrayDeque() + + fun dfs(r: Int, c: Int) { + visited[r][c] = true + for ((dr, dc) in directions) { + val nr = r + dr + val nc = c + dc + if (nr in 0 until n && nc in 0 until n && !visited[nr][nc]) { + if (grid[nr][nc] == 0) { + visited[nr][nc] = true + q.addLast(intArrayOf(nr, nc, 1)) + } else { + dfs(nr, nc) + } + } + } + } + + var found = false + for (i in 0 until n) { + for (j in 0 until n) { + if (grid[i][j] == 1) { + dfs(i, j) + found = true + break + } + } + if (found) break + } + + while (q.isNotEmpty()) { + val (r, c, dist) = q.removeFirst() + for ((dr, dc) in directions) { + val nr = r + dr + val nc = c + dc + if (nr in 0 until n && nc in 0 until n && !visited[nr][nc]) { + if (grid[nr][nc] == 1) return dist + visited[nr][nc] = true + q.addLast(intArrayOf(nr, nc, dist + 1)) + } + } + } + return 0 + } +} diff --git a/tests/501-1000/934. shortest-bridge/sol.py b/tests/501-1000/934. shortest-bridge/sol.py new file mode 100644 index 00000000..77220ffb --- /dev/null +++ b/tests/501-1000/934. shortest-bridge/sol.py @@ -0,0 +1,42 @@ +import collections +from typing import List + + +class Solution: + def shortestBridge(self, grid: List[List[int]]) -> int: + n = len(grid) + directions = [(-1, 0), (1, 0), (0, 1), (0, -1)] + visited = set() + q = collections.deque() + + def dfs(r, c): + visited.add((r, c)) + for dr, dc in directions: + nr, nc = r + dr, c + dc + if 0 <= nr < n and 0 <= nc < n and (nr, nc) not in visited: + if grid[nr][nc] == 0: + visited.add((nr, nc)) + q.append((nr, nc, 1)) + else: + dfs(nr, nc) + + found = False + for i in range(n): + for j in range(n): + if grid[i][j] == 1: + dfs(i, j) + found = True + break + if found: + break + + while q: + r, c, dist = q.popleft() + for dr, dc in directions: + nr, nc = r + dr, c + dc + if 0 <= nr < n and 0 <= nc < n and (nr, nc) not in visited: + if grid[nr][nc] == 1: + return dist + visited.add((nr, nc)) + q.append((nr, nc, dist + 1)) + return 0 diff --git a/tests/501-1000/934. shortest-bridge/sol.py2 b/tests/501-1000/934. shortest-bridge/sol.py2 new file mode 100644 index 00000000..e6d6b63a --- /dev/null +++ b/tests/501-1000/934. shortest-bridge/sol.py2 @@ -0,0 +1,43 @@ +class Solution(object): + def shortestBridge(self, grid): + """ + :type grid: List[List[int]] + :rtype: int + """ + from collections import deque + n = len(grid) + directions = [(-1, 0), (1, 0), (0, 1), (0, -1)] + visited = set() + q = deque() + + def dfs(r, c): + visited.add((r, c)) + for dr, dc in directions: + nr, nc = r + dr, c + dc + if 0 <= nr < n and 0 <= nc < n and (nr, nc) not in visited: + if grid[nr][nc] == 0: + visited.add((nr, nc)) + q.append((nr, nc, 1)) + else: + dfs(nr, nc) + + found = False + for i in range(n): + for j in range(n): + if grid[i][j] == 1: + dfs(i, j) + found = True + break + if found: + break + + while q: + r, c, dist = q.popleft() + for dr, dc in directions: + nr, nc = r + dr, c + dc + if 0 <= nr < n and 0 <= nc < n and (nr, nc) not in visited: + if grid[nr][nc] == 1: + return dist + visited.add((nr, nc)) + q.append((nr, nc, dist + 1)) + return 0 diff --git a/tests/501-1000/934. shortest-bridge/sol.rb b/tests/501-1000/934. shortest-bridge/sol.rb new file mode 100644 index 00000000..7657e054 --- /dev/null +++ b/tests/501-1000/934. shortest-bridge/sol.rb @@ -0,0 +1,50 @@ +# @param {Integer[][]} grid +# @return {Integer} +def shortest_bridge(grid) + n = grid.length + directions = [[-1, 0], [1, 0], [0, 1], [0, -1]] + visited = Set.new + q = [] + + dfs = lambda do |r, c| + visited.add([r, c]) + directions.each do |dr, dc| + nr = r + dr + nc = c + dc + if nr >= 0 && nr < n && nc >= 0 && nc < n && !visited.include?([nr, nc]) + if grid[nr][nc] == 0 + visited.add([nr, nc]) + q << [nr, nc, 1] + else + dfs.call(nr, nc) + end + end + end + end + + found = false + (0...n).each do |i| + (0...n).each do |j| + if grid[i][j] == 1 + dfs.call(i, j) + found = true + break + end + end + break if found + end + + while !q.empty? + r, c, dist = q.shift + directions.each do |dr, dc| + nr = r + dr + nc = c + dc + if nr >= 0 && nr < n && nc >= 0 && nc < n && !visited.include?([nr, nc]) + return dist if grid[nr][nc] == 1 + visited.add([nr, nc]) + q << [nr, nc, dist + 1] + end + end + end + 0 +end diff --git a/tests/501-1000/934. shortest-bridge/sol.rs b/tests/501-1000/934. shortest-bridge/sol.rs new file mode 100644 index 00000000..a50af0f8 --- /dev/null +++ b/tests/501-1000/934. shortest-bridge/sol.rs @@ -0,0 +1,60 @@ +impl Solution { + pub fn shortest_bridge(grid: Vec>) -> i32 { + let n = grid.len(); + let directions = [(-1, 0), (1, 0), (0, 1), (0, -1)]; + let mut visited = vec![vec![false; n]; n]; + let mut q = std::collections::VecDeque::new(); + + fn dfs(r: usize, c: usize, grid: &Vec>, visited: &mut Vec>, + directions: &[(i32, i32)], q: &mut std::collections::VecDeque<(usize, usize, i32)>) { + visited[r][c] = true; + for &(dr, dc) in directions { + let nr = r as i32 + dr; + let nc = c as i32 + dc; + if nr >= 0 && nr < grid.len() as i32 && nc >= 0 && nc < grid.len() as i32 { + let nr = nr as usize; + let nc = nc as usize; + if !visited[nr][nc] { + if grid[nr][nc] == 0 { + visited[nr][nc] = true; + q.push_back((nr, nc, 1)); + } else { + dfs(nr, nc, grid, visited, directions, q); + } + } + } + } + } + + let mut found = false; + for i in 0..n { + for j in 0..n { + if grid[i][j] == 1 { + dfs(i, j, &grid, &mut visited, &directions, &mut q); + found = true; + break; + } + } + if found { break; } + } + + while let Some((r, c, dist)) = q.pop_front() { + for &(dr, dc) in &directions { + let nr = r as i32 + dr; + let nc = c as i32 + dc; + if nr >= 0 && nr < n as i32 && nc >= 0 && nc < n as i32 { + let nr = nr as usize; + let nc = nc as usize; + if !visited[nr][nc] { + if grid[nr][nc] == 1 { + return dist; + } + visited[nr][nc] = true; + q.push_back((nr, nc, dist + 1)); + } + } + } + } + 0 + } +} diff --git a/tests/501-1000/934. shortest-bridge/sol.swift b/tests/501-1000/934. shortest-bridge/sol.swift new file mode 100644 index 00000000..4753d5f1 --- /dev/null +++ b/tests/501-1000/934. shortest-bridge/sol.swift @@ -0,0 +1,48 @@ +class Solution { + func shortestBridge(_ grid: [[Int]]) -> Int { + let n = grid.count + let directions = [(-1, 0), (1, 0), (0, 1), (0, -1)] + var visited = Array(repeating: Array(repeating: false, count: n), count: n) + var q = [(Int, Int, Int)]() + + func dfs(_ r: Int, _ c: Int) { + visited[r][c] = true + for (dr, dc) in directions { + let nr = r + dr, nc = c + dc + if nr >= 0 && nr < n && nc >= 0 && nc < n && !visited[nr][nc] { + if grid[nr][nc] == 0 { + visited[nr][nc] = true + q.append((nr, nc, 1)) + } else { + dfs(nr, nc) + } + } + } + } + + var found = false + for i in 0..= 0 && nr < n && nc >= 0 && nc < n && !visited[nr][nc] { + if grid[nr][nc] == 1 { return dist } + visited[nr][nc] = true + q.append((nr, nc, dist + 1)) + } + } + } + return 0 + } +} diff --git a/tests/501-1000/934. shortest-bridge/sol.ts b/tests/501-1000/934. shortest-bridge/sol.ts new file mode 100644 index 00000000..8655009f --- /dev/null +++ b/tests/501-1000/934. shortest-bridge/sol.ts @@ -0,0 +1,53 @@ +function shortestBridge(grid: number[][]): number { + const n = grid.length; + const directions: [number, number][] = [ + [-1, 0], + [1, 0], + [0, 1], + [0, -1], + ]; + const visited: boolean[][] = Array.from({ length: n }, () => + Array(n).fill(false), + ); + const q: [number, number, number][] = []; + + function dfs(r: number, c: number): void { + visited[r][c] = true; + for (const [dr, dc] of directions) { + const nr = r + dr; + const nc = c + dc; + if (nr >= 0 && nr < n && nc >= 0 && nc < n && !visited[nr][nc]) { + if (grid[nr][nc] === 0) { + visited[nr][nc] = true; + q.push([nr, nc, 1]); + } else { + dfs(nr, nc); + } + } + } + } + + let found = false; + for (let i = 0; i < n && !found; i++) { + for (let j = 0; j < n && !found; j++) { + if (grid[i][j] === 1) { + dfs(i, j); + found = true; + } + } + } + + while (q.length > 0) { + const [r, c, dist] = q.shift()!; + for (const [dr, dc] of directions) { + const nr = r + dr; + const nc = c + dc; + if (nr >= 0 && nr < n && nc >= 0 && nc < n && !visited[nr][nc]) { + if (grid[nr][nc] === 1) return dist; + visited[nr][nc] = true; + q.push([nr, nc, dist + 1]); + } + } + } + return 0; +} diff --git a/tests/501-1000/935. knight-dialer/manifest.yaml b/tests/501-1000/935. knight-dialer/manifest.yaml new file mode 100644 index 00000000..ee02150a --- /dev/null +++ b/tests/501-1000/935. knight-dialer/manifest.yaml @@ -0,0 +1,170 @@ +entry: + id: 935 + title: knight-dialer + params: + n: + type: int + call: + cpp: Solution().knightDialer({n}) + rust: Solution::knight_dialer({n}) + python3: Solution().knightDialer({n}) + python2: Solution().knightDialer({n}) + ruby: knight_dialer({n}) + java: new Solution().knightDialer({n}) + csharp: new Solution().KnightDialer({n}) + kotlin: Solution().knightDialer({n}) + go: knightDialer({n}) + dart: Solution().knightDialer({n}) + swift: Solution().knightDialer({n}) + typescript: knightDialer({n}) +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 935 +tests: + - name: n_1 + in: + n: 1 + out: 10 + - name: n_2 + in: + n: 2 + out: 20 + - name: n_3 + in: + n: 3 + out: 46 + - name: n_4 + in: + n: 4 + out: 104 + - name: n_5 + in: + n: 5 + out: 240 + - name: n_6 + in: + n: 6 + out: 544 + - name: n_7 + in: + n: 7 + out: 1256 + - name: n_8 + in: + n: 8 + out: 2848 + - name: n_9 + in: + n: 9 + out: 6576 + - name: n_10 + in: + n: 10 + out: 14912 + - name: n_11 + in: + n: 11 + out: 34432 + - name: n_12 + in: + n: 12 + out: 78080 + - name: n_13 + in: + n: 13 + out: 180288 + - name: n_14 + in: + n: 14 + out: 408832 + - name: n_15 + in: + n: 15 + out: 944000 + - name: n_20 + in: + n: 20 + out: 58689536 + - name: n_25 + in: + n: 25 + out: 715338219 + - name: n_30 + in: + n: 30 + out: 986742198 + - name: n_35 + in: + n: 35 + out: 604554286 + - name: n_40 + in: + n: 40 + out: 719179703 + - name: n_50 + in: + n: 50 + out: 267287516 + - name: n_60 + in: + n: 60 + out: 603644899 + - name: n_70 + in: + n: 70 + out: 243891366 + - name: n_80 + in: + n: 80 + out: 824037613 + - name: n_90 + in: + n: 90 + out: 667265033 + - name: n_100 + in: + n: 100 + out: 540641702 + - name: n_150 + in: + n: 150 + out: 31297159 + - name: n_200 + in: + n: 200 + out: 38950354 + - name: n_300 + in: + n: 300 + out: 450539859 + - name: n_400 + in: + n: 400 + out: 23117445 + - name: n_500 + in: + n: 500 + out: 84202957 + - name: n_1000 + in: + n: 1000 + out: 88106097 + - name: n_1500 + in: + n: 1500 + out: 487569438 + - name: n_2000 + in: + n: 2000 + out: 71794716 + - name: n_3131 + in: + n: 3131 + out: 136006598 diff --git a/tests/501-1000/935. knight-dialer/sol.cpp b/tests/501-1000/935. knight-dialer/sol.cpp new file mode 100644 index 00000000..d9db87a1 --- /dev/null +++ b/tests/501-1000/935. knight-dialer/sol.cpp @@ -0,0 +1,40 @@ +class Solution { +public: + int knightDialer(int n) { + if (n == 1) { + return 10; + } + + vector dp(10, 1); + vector> mapping = { + {4, 6}, + {6, 8}, + {7, 9}, + {4, 8}, + {0, 3, 9}, + {}, + {0, 1, 7}, + {2, 6}, + {1, 3}, + {2, 4} + }; + + const int MOD = 1000000007; + + for (int step = 0; step < n - 1; step++) { + vector newDp(10, 0); + for (int i = 0; i < 10; i++) { + for (int digit : mapping[i]) { + newDp[digit] = (newDp[digit] + dp[i]) % MOD; + } + } + dp = newDp; + } + + int sum = 0; + for (int val : dp) { + sum = (sum + val) % MOD; + } + return sum; + } +}; diff --git a/tests/501-1000/935. knight-dialer/sol.cs b/tests/501-1000/935. knight-dialer/sol.cs new file mode 100644 index 00000000..94abcccd --- /dev/null +++ b/tests/501-1000/935. knight-dialer/sol.cs @@ -0,0 +1,43 @@ +public class Solution { + public int KnightDialer(int n) { + if (n == 1) { + return 10; + } + + int[] dp = new int[10]; + for (int i = 0; i < 10; i++) { + dp[i] = 1; + } + + int[][] mapping = new int[][] { + new int[] {4, 6}, + new int[] {6, 8}, + new int[] {7, 9}, + new int[] {4, 8}, + new int[] {0, 3, 9}, + new int[] {}, + new int[] {0, 1, 7}, + new int[] {2, 6}, + new int[] {1, 3}, + new int[] {2, 4} + }; + + const int MOD = 1000000007; + + for (int step = 0; step < n - 1; step++) { + int[] newDp = new int[10]; + for (int i = 0; i < 10; i++) { + foreach (int digit in mapping[i]) { + newDp[digit] = (newDp[digit] + dp[i]) % MOD; + } + } + dp = newDp; + } + + int sum = 0; + foreach (int val in dp) { + sum = (sum + val) % MOD; + } + return sum; + } +} diff --git a/tests/501-1000/935. knight-dialer/sol.dart b/tests/501-1000/935. knight-dialer/sol.dart new file mode 100644 index 00000000..d20360f8 --- /dev/null +++ b/tests/501-1000/935. knight-dialer/sol.dart @@ -0,0 +1,39 @@ +class Solution { + int knightDialer(int n) { + if (n == 1) { + return 10; + } + + List dp = List.filled(10, 1); + List> mapping = [ + [4, 6], + [6, 8], + [7, 9], + [4, 8], + [0, 3, 9], + [], + [0, 1, 7], + [2, 6], + [1, 3], + [2, 4] + ]; + + const int MOD = 1000000007; + + for (int step = 0; step < n - 1; step++) { + List newDp = List.filled(10, 0); + for (int i = 0; i < 10; i++) { + for (int digit in mapping[i]) { + newDp[digit] = (newDp[digit] + dp[i]) % MOD; + } + } + dp = newDp; + } + + int sum = 0; + for (int val in dp) { + sum = (sum + val) % MOD; + } + return sum; + } +} diff --git a/tests/501-1000/935. knight-dialer/sol.go b/tests/501-1000/935. knight-dialer/sol.go new file mode 100644 index 00000000..f3c3ff9a --- /dev/null +++ b/tests/501-1000/935. knight-dialer/sol.go @@ -0,0 +1,41 @@ +func knightDialer(n int) int { + if n == 1 { + return 10 + } + + dp := make([]int, 10) + for i := range dp { + dp[i] = 1 + } + + mapping := [][]int{ + {4, 6}, + {6, 8}, + {7, 9}, + {4, 8}, + {0, 3, 9}, + {}, + {0, 1, 7}, + {2, 6}, + {1, 3}, + {2, 4}, + } + + MOD := 1000000007 + + for step := 0; step < n-1; step++ { + newDp := make([]int, 10) + for i := 0; i < 10; i++ { + for _, digit := range mapping[i] { + newDp[digit] = (newDp[digit] + dp[i]) % MOD + } + } + dp = newDp + } + + sum := 0 + for _, val := range dp { + sum = (sum + val) % MOD + } + return sum +} diff --git a/tests/501-1000/935. knight-dialer/sol.java b/tests/501-1000/935. knight-dialer/sol.java new file mode 100644 index 00000000..10ba43f1 --- /dev/null +++ b/tests/501-1000/935. knight-dialer/sol.java @@ -0,0 +1,41 @@ +class Solution { + public int knightDialer(int n) { + if (n == 1) { + return 10; + } + + int[] dp = new int[10]; + Arrays.fill(dp, 1); + + int[][] mapping = { + {4, 6}, + {6, 8}, + {7, 9}, + {4, 8}, + {0, 3, 9}, + {}, + {0, 1, 7}, + {2, 6}, + {1, 3}, + {2, 4} + }; + + int MOD = 1000000007; + + for (int step = 0; step < n - 1; step++) { + int[] newDp = new int[10]; + for (int i = 0; i < 10; i++) { + for (int digit : mapping[i]) { + newDp[digit] = (newDp[digit] + dp[i]) % MOD; + } + } + dp = newDp; + } + + int sum = 0; + for (int val : dp) { + sum = (sum + val) % MOD; + } + return sum; + } +} diff --git a/tests/501-1000/935. knight-dialer/sol.kt b/tests/501-1000/935. knight-dialer/sol.kt new file mode 100644 index 00000000..b63deff0 --- /dev/null +++ b/tests/501-1000/935. knight-dialer/sol.kt @@ -0,0 +1,35 @@ +class Solution { + fun knightDialer(n: Int): Int { + if (n == 1) { + return 10 + } + + var dp = IntArray(10) { 1 } + val mapping = arrayOf( + intArrayOf(4, 6), + intArrayOf(6, 8), + intArrayOf(7, 9), + intArrayOf(4, 8), + intArrayOf(0, 3, 9), + intArrayOf(), + intArrayOf(0, 1, 7), + intArrayOf(2, 6), + intArrayOf(1, 3), + intArrayOf(2, 4) + ) + + val MOD = 1000000007 + + repeat(n - 1) { + val newDp = IntArray(10) + for (i in 0 until 10) { + for (digit in mapping[i]) { + newDp[digit] = (newDp[digit] + dp[i]) % MOD + } + } + dp = newDp + } + + return dp.fold(0) { acc, value -> (acc + value) % MOD } + } +} diff --git a/tests/501-1000/935. knight-dialer/sol.py b/tests/501-1000/935. knight-dialer/sol.py new file mode 100644 index 00000000..bec0cbe0 --- /dev/null +++ b/tests/501-1000/935. knight-dialer/sol.py @@ -0,0 +1,31 @@ +from typing import List + + +class Solution: + def knightDialer(self, n: int) -> int: + if n == 1: + return 10 + + dp = [1] * 10 + mapping = { + 0: [4, 6], + 1: [6, 8], + 2: [7, 9], + 3: [4, 8], + 4: [0, 3, 9], + 5: [], + 6: [0, 1, 7], + 7: [2, 6], + 8: [1, 3], + 9: [2, 4], + } + + for _ in range(n - 1): + new = [0] * 10 + + for i in range(10): + for digit in mapping[i]: + new[digit] += dp[i] + dp = new + + return sum(dp) % (10**9 + 7) diff --git a/tests/501-1000/935. knight-dialer/sol.py2 b/tests/501-1000/935. knight-dialer/sol.py2 new file mode 100644 index 00000000..6ae11ec8 --- /dev/null +++ b/tests/501-1000/935. knight-dialer/sol.py2 @@ -0,0 +1,29 @@ +class Solution(object): + def knightDialer(self, n): + """ + :type n: int + :rtype: int + """ + if n == 1: + return 10 + + dp = [1] * 10 + mapping = {0: [4, 6], + 1: [6, 8], + 2: [7, 9], + 3: [4, 8], + 4: [0, 3, 9], + 5: [], + 6: [0, 1, 7], + 7: [2, 6], + 8: [1, 3], + 9: [2, 4]} + + for _ in range(n - 1): + new = [0] * 10 + for i in range(10): + for digit in mapping[i]: + new[digit] += dp[i] + dp = new + + return int(sum(dp) % (10**9 + 7)) diff --git a/tests/501-1000/935. knight-dialer/sol.rb b/tests/501-1000/935. knight-dialer/sol.rb new file mode 100644 index 00000000..f4019ca0 --- /dev/null +++ b/tests/501-1000/935. knight-dialer/sol.rb @@ -0,0 +1,31 @@ +# @param {Integer} n +# @return {Integer} +def knight_dialer(n) + return 10 if n == 1 + + dp = [1] * 10 + mapping = { + 0 => [4, 6], + 1 => [6, 8], + 2 => [7, 9], + 3 => [4, 8], + 4 => [0, 3, 9], + 5 => [], + 6 => [0, 1, 7], + 7 => [2, 6], + 8 => [1, 3], + 9 => [2, 4] + } + + (n - 1).times do + new_arr = [0] * 10 + (0..9).each do |i| + mapping[i].each do |digit| + new_arr[digit] += dp[i] + end + end + dp = new_arr + end + + dp.sum % (10**9 + 7) +end diff --git a/tests/501-1000/935. knight-dialer/sol.rs b/tests/501-1000/935. knight-dialer/sol.rs new file mode 100644 index 00000000..7ef83852 --- /dev/null +++ b/tests/501-1000/935. knight-dialer/sol.rs @@ -0,0 +1,35 @@ +impl Solution { + pub fn knight_dialer(n: i32) -> i32 { + if n == 1 { + return 10; + } + + let mut dp = vec![1i32; 10]; + let mapping: Vec> = vec![ + vec![4, 6], + vec![6, 8], + vec![7, 9], + vec![4, 8], + vec![0, 3, 9], + vec![], + vec![0, 1, 7], + vec![2, 6], + vec![1, 3], + vec![2, 4] + ]; + + let modulo = 1_000_000_007i32; + + for _ in 0..(n - 1) { + let mut new_dp = vec![0i32; 10]; + for i in 0..10 { + for &digit in &mapping[i] { + new_dp[digit] = (new_dp[digit] + dp[i]) % modulo; + } + } + dp = new_dp; + } + + dp.iter().fold(0, |acc, &x| (acc + x) % modulo) + } +} diff --git a/tests/501-1000/935. knight-dialer/sol.swift b/tests/501-1000/935. knight-dialer/sol.swift new file mode 100644 index 00000000..53925d2a --- /dev/null +++ b/tests/501-1000/935. knight-dialer/sol.swift @@ -0,0 +1,35 @@ +class Solution { + func knightDialer(_ n: Int) -> Int { + if n == 1 { + return 10 + } + + var dp = [Int](repeating: 1, count: 10) + let mapping: [[Int]] = [ + [4, 6], + [6, 8], + [7, 9], + [4, 8], + [0, 3, 9], + [], + [0, 1, 7], + [2, 6], + [1, 3], + [2, 4] + ] + + let MOD = 1000000007 + + for _ in 0..<(n - 1) { + var newDp = [Int](repeating: 0, count: 10) + for i in 0..<10 { + for digit in mapping[i] { + newDp[digit] = (newDp[digit] + dp[i]) % MOD + } + } + dp = newDp + } + + return dp.reduce(0) { ($0 + $1) % MOD } + } +} diff --git a/tests/501-1000/935. knight-dialer/sol.ts b/tests/501-1000/935. knight-dialer/sol.ts new file mode 100644 index 00000000..ecf0faa4 --- /dev/null +++ b/tests/501-1000/935. knight-dialer/sol.ts @@ -0,0 +1,37 @@ +function knightDialer(n: number): number { + if (n === 1) { + return 10; + } + + let dp: number[] = new Array(10).fill(1); + const mapping: number[][] = [ + [4, 6], + [6, 8], + [7, 9], + [4, 8], + [0, 3, 9], + [], + [0, 1, 7], + [2, 6], + [1, 3], + [2, 4], + ]; + + const MOD = 1000000007; + + for (let step = 0; step < n - 1; step++) { + const newDp: number[] = new Array(10).fill(0); + for (let i = 0; i < 10; i++) { + for (const digit of mapping[i]) { + newDp[digit] = (newDp[digit] + dp[i]) % MOD; + } + } + dp = newDp; + } + + let sum = 0; + for (const val of dp) { + sum = (sum + val) % MOD; + } + return sum; +} diff --git a/tests/501-1000/936. stamping-the-sequence/manifest.yaml b/tests/501-1000/936. stamping-the-sequence/manifest.yaml new file mode 100644 index 00000000..8993c6b4 --- /dev/null +++ b/tests/501-1000/936. stamping-the-sequence/manifest.yaml @@ -0,0 +1,179 @@ +entry: + id: 936 + title: stamping-the-sequence + params: + stamp: + type: string + target: + type: string + call: + cpp: Solution().movesToStamp({stamp}, {target}) + rust: Solution::moves_to_stamp({stamp}, {target}) + python3: Solution().movesToStamp({stamp}, {target}) + python2: Solution().movesToStamp({stamp}, {target}) + ruby: moves_to_stamp({stamp}, {target}) + java: new Solution().movesToStamp({stamp}, {target}) + csharp: new Solution().MovesToStamp({stamp}, {target}) + kotlin: Solution().movesToStamp({stamp}, {target}) + go: movesToStamp({stamp}, {target}) + dart: Solution().movesToStamp({stamp}, {target}) + swift: Solution().movesToStamp({stamp}, {target}) + typescript: movesToStamp({stamp}, {target}) +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 256 +oracle: + python3: + call: Checker().movesToStamp(stamp, target, {result}) + checker: + "class Checker:\n def movesToStamp(self, stamp, target, result):\n\ + \ if not isinstance(result, list):\n return False\n \ + \ n = len(target)\n m = len(stamp)\n if len(result) > 10 * n:\n\ + \ return False\n cur = ['?'] * n\n for pos in result:\n\ + \ if not isinstance(pos, int) or pos < 0 or pos + m > n:\n \ + \ return False\n for j, ch in enumerate(stamp):\n \ + \ cur[pos + j] = ch\n return ''.join(cur) == target\n" +seed: 936 +tests: + - name: case_1 + in: + stamp: abb + target: ababb + - name: case_2 + in: + stamp: ca + target: ca + - name: case_3 + in: + stamp: ba + target: bababaa + - name: case_4 + in: + stamp: cc + target: cc + - name: case_5 + in: + stamp: bab + target: babbab + - name: case_6 + in: + stamp: b + target: bbb + - name: case_7 + in: + stamp: bab + target: bbabbbab + - name: case_8 + in: + stamp: c + target: ccc + - name: case_9 + in: + stamp: cbbc + target: cbbcbcc + - name: case_10 + in: + stamp: bc + target: bccbcc + - name: case_11 + in: + stamp: aba + target: abaaba + - name: case_12 + in: + stamp: c + target: ccccc + - name: case_13 + in: + stamp: ac + target: acacac + - name: case_14 + in: + stamp: bc + target: bc + - name: case_15 + in: + stamp: bbaa + target: bbaaaaaaa + - name: case_16 + in: + stamp: cbc + target: cbccbc + - name: case_17 + in: + stamp: aaa + target: aaaaaaa + - name: case_18 + in: + stamp: acba + target: acbabaacba + - name: case_19 + in: + stamp: ba + target: ba + - name: case_20 + in: + stamp: a + target: aaaaaa + - name: case_21 + in: + stamp: aacb + target: aacb + - name: case_22 + in: + stamp: ca + target: caaca + - name: case_23 + in: + stamp: baa + target: baaa + - name: case_24 + in: + stamp: caca + target: caca + - name: case_25 + in: + stamp: aab + target: aabb + - name: case_26 + in: + stamp: cbba + target: cbcbba + - name: case_27 + in: + stamp: abcc + target: abcabcc + - name: case_28 + in: + stamp: acc + target: acccacc + - name: case_29 + in: + stamp: acc + target: acccacccc + - name: case_30 + in: + stamp: bacb + target: babbacb + - name: case_31 + in: + stamp: aa + target: aaaa + - name: case_32 + in: + stamp: bb + target: bbbbb + - name: case_33 + in: + stamp: abaa + target: abaaaa + - name: case_34 + in: + stamp: bba + target: bbba + - name: case_35 + in: + stamp: ca + target: caacaa diff --git a/tests/501-1000/936. stamping-the-sequence/sol.cpp b/tests/501-1000/936. stamping-the-sequence/sol.cpp new file mode 100644 index 00000000..5cb49b9e --- /dev/null +++ b/tests/501-1000/936. stamping-the-sequence/sol.cpp @@ -0,0 +1,61 @@ +class Solution { +public: + vector movesToStamp(string stamp, string target) { + int m = stamp.length(); + int n = target.length(); + + auto canStamp = [&](int i) -> bool { + for (int j = 0; j < m; j++) { + if (target[i + j] != '?' && target[i + j] != stamp[j]) { + return false; + } + } + return true; + }; + + auto applyStamp = [&](int i) { + for (int j = 0; j < m; j++) { + target[i + j] = '?'; + } + }; + + vector stamped(n, false); + vector result; + deque queue; + + for (int i = 0; i <= n - m; i++) { + if (canStamp(i)) { + applyStamp(i); + queue.push_back(i); + result.push_back(i); + stamped[i] = true; + } + } + + while (!queue.empty()) { + int pos = queue.front(); + queue.pop_front(); + int start = max(0, pos - m + 1); + int end = min(n - m, pos + m); + for (int i = start; i <= end; i++) { + if (canStamp(i)) { + if (!stamped[i]) { + applyStamp(i); + queue.push_back(i); + result.push_back(i); + stamped[i] = true; + } + } + } + } + + for (char c : target) { + if (c != '?') { + return {}; + } + } + + reverse(result.begin(), result.end()); + return result; + } +}; diff --git a/tests/501-1000/936. stamping-the-sequence/sol.cs b/tests/501-1000/936. stamping-the-sequence/sol.cs new file mode 100644 index 00000000..b4a809fb --- /dev/null +++ b/tests/501-1000/936. stamping-the-sequence/sol.cs @@ -0,0 +1,61 @@ +public class Solution { + public int[] MovesToStamp(string stamp, string target) { + int m = stamp.Length; + int n = target.Length; + char[] stampArr = stamp.ToCharArray(); + char[] targetArr = target.ToCharArray(); + + bool CanStamp(int i) { + for (int j = 0; j < m; j++) { + if (targetArr[i + j] != '?' && targetArr[i + j] != stampArr[j]) { + return false; + } + } + return true; + } + + void ApplyStamp(int i) { + for (int j = 0; j < m; j++) { + targetArr[i + j] = '?'; + } + } + + bool[] stamped = new bool[n]; + List result = new List(); + Queue queue = new Queue(); + + for (int i = 0; i <= n - m; i++) { + if (CanStamp(i)) { + ApplyStamp(i); + queue.Enqueue(i); + result.Add(i); + stamped[i] = true; + } + } + + while (queue.Count > 0) { + int pos = queue.Dequeue(); + int start = Math.Max(0, pos - m + 1); + int end = Math.Min(n - m, pos + m); + for (int i = start; i <= end; i++) { + if (CanStamp(i)) { + if (!stamped[i]) { + ApplyStamp(i); + queue.Enqueue(i); + result.Add(i); + stamped[i] = true; + } + } + } + } + + foreach (char c in targetArr) { + if (c != '?') { + return new int[0]; + } + } + + result.Reverse(); + return result.ToArray(); + } +} diff --git a/tests/501-1000/936. stamping-the-sequence/sol.dart b/tests/501-1000/936. stamping-the-sequence/sol.dart new file mode 100644 index 00000000..6f5687be --- /dev/null +++ b/tests/501-1000/936. stamping-the-sequence/sol.dart @@ -0,0 +1,57 @@ +class Solution { + List movesToStamp(String stamp, String target) { + int m = stamp.length; + int n = target.length; + List stampArr = stamp.split(''); + List targetArr = target.split(''); + + bool canStamp(int i) { + for (int j = 0; j < m; j++) { + if (targetArr[i + j] != '?' && targetArr[i + j] != stampArr[j]) { + return false; + } + } + return true; + } + + void applyStamp(int i) { + for (int j = 0; j < m; j++) { + targetArr[i + j] = '?'; + } + } + + List stamped = List.filled(n, false); + List result = []; + List queue = []; + + for (int i = 0; i <= n - m; i++) { + if (canStamp(i)) { + applyStamp(i); + queue.add(i); + result.add(i); + stamped[i] = true; + } + } + + while (queue.isNotEmpty) { + int pos = queue.removeAt(0); + int start = (pos - m + 1).clamp(0, n - m); + int end = (pos + m).clamp(0, n - m); + for (int i = start; i <= end; i++) { + if (canStamp(i)) { + if (!stamped[i]) { + applyStamp(i); + queue.add(i); + result.add(i); + stamped[i] = true; + } + } + } + } + + if (targetArr.every((c) => c == '?')) { + return result.reversed.toList(); + } + return []; + } +} diff --git a/tests/501-1000/936. stamping-the-sequence/sol.go b/tests/501-1000/936. stamping-the-sequence/sol.go new file mode 100644 index 00000000..74f4f4e2 --- /dev/null +++ b/tests/501-1000/936. stamping-the-sequence/sol.go @@ -0,0 +1,68 @@ +func movesToStamp(stamp string, target string) []int { + m := len(stamp) + n := len(target) + stampArr := []byte(stamp) + targetArr := []byte(target) + + canStamp := func(i int) bool { + for j := 0; j < m; j++ { + if targetArr[i+j] != '?' && targetArr[i+j] != stampArr[j] { + return false + } + } + return true + } + + applyStamp := func(i int) { + for j := 0; j < m; j++ { + targetArr[i+j] = '?' + } + } + + stamped := make([]bool, n) + result := make([]int, 0) + queue := make([]int, 0) + + for i := 0; i <= n-m; i++ { + if canStamp(i) { + applyStamp(i) + queue = append(queue, i) + result = append(result, i) + stamped[i] = true + } + } + + for len(queue) > 0 { + pos := queue[0] + queue = queue[1:] + start := 0 + if pos-m+1 > start { + start = pos - m + 1 + } + end := n - m + if pos+m < end { + end = pos + m + } + for i := start; i <= end; i++ { + if canStamp(i) { + if !stamped[i] { + applyStamp(i) + queue = append(queue, i) + result = append(result, i) + stamped[i] = true + } + } + } + } + + for _, c := range targetArr { + if c != '?' { + return []int{} + } + } + + for i, j := 0, len(result)-1; i < j; i, j = i+1, j-1 { + result[i], result[j] = result[j], result[i] + } + return result +} diff --git a/tests/501-1000/936. stamping-the-sequence/sol.java b/tests/501-1000/936. stamping-the-sequence/sol.java new file mode 100644 index 00000000..491d8cb1 --- /dev/null +++ b/tests/501-1000/936. stamping-the-sequence/sol.java @@ -0,0 +1,64 @@ +class Solution { + public int[] movesToStamp(String stamp, String target) { + int m = stamp.length(); + int n = target.length(); + char[] stampArr = stamp.toCharArray(); + char[] targetArr = target.toCharArray(); + + boolean[] stamped = new boolean[n]; + List resultList = new ArrayList<>(); + Queue queue = new LinkedList<>(); + + for (int i = 0; i <= n - m; i++) { + if (canStamp(targetArr, stampArr, i)) { + applyStamp(targetArr, m, i); + queue.offer(i); + resultList.add(i); + stamped[i] = true; + } + } + + while (!queue.isEmpty()) { + int pos = queue.poll(); + int start = Math.max(0, pos - m + 1); + int end = Math.min(n - m, pos + m); + for (int i = start; i <= end; i++) { + if (canStamp(targetArr, stampArr, i)) { + if (!stamped[i]) { + applyStamp(targetArr, m, i); + queue.offer(i); + resultList.add(i); + stamped[i] = true; + } + } + } + } + + for (char c : targetArr) { + if (c != '?') { + return new int[0]; + } + } + + int[] result = new int[resultList.size()]; + for (int i = 0; i < result.length; i++) { + result[i] = resultList.get(resultList.size() - 1 - i); + } + return result; + } + + private boolean canStamp(char[] target, char[] stamp, int start) { + for (int i = 0; i < stamp.length; i++) { + if (target[start + i] != '?' && target[start + i] != stamp[i]) { + return false; + } + } + return true; + } + + private void applyStamp(char[] target, int m, int start) { + for (int i = 0; i < m; i++) { + target[start + i] = '?'; + } + } +} diff --git a/tests/501-1000/936. stamping-the-sequence/sol.kt b/tests/501-1000/936. stamping-the-sequence/sol.kt new file mode 100644 index 00000000..30b3f35a --- /dev/null +++ b/tests/501-1000/936. stamping-the-sequence/sol.kt @@ -0,0 +1,57 @@ +class Solution { + fun movesToStamp(stamp: String, target: String): IntArray { + val m = stamp.length + val n = target.length + val stampArr = stamp.toCharArray() + val targetArr = target.toCharArray() + + fun canStamp(i: Int): Boolean { + for (j in 0 until m) { + if (targetArr[i + j] != '?' && targetArr[i + j] != stampArr[j]) { + return false + } + } + return true + } + + fun applyStamp(i: Int) { + for (j in 0 until m) { + targetArr[i + j] = '?' + } + } + + val stamped = BooleanArray(n) + val result = mutableListOf() + val queue = ArrayDeque() + + for (i in 0..n - m) { + if (canStamp(i)) { + applyStamp(i) + queue.addLast(i) + result.add(i) + stamped[i] = true + } + } + + while (queue.isNotEmpty()) { + val pos = queue.removeFirst() + val start = maxOf(0, pos - m + 1) + val end = minOf(n - m, pos + m) + for (i in start..end) { + if (canStamp(i)) { + if (!stamped[i]) { + applyStamp(i) + queue.addLast(i) + result.add(i) + stamped[i] = true + } + } + } + } + + if (targetArr.all { it == '?' }) { + return result.reversed().toIntArray() + } + return intArrayOf() + } +} diff --git a/tests/501-1000/936. stamping-the-sequence/sol.py b/tests/501-1000/936. stamping-the-sequence/sol.py new file mode 100644 index 00000000..6b34bf4f --- /dev/null +++ b/tests/501-1000/936. stamping-the-sequence/sol.py @@ -0,0 +1,51 @@ +from typing import List +from collections import deque + + +class Solution: + def movesToStamp(self, stamp: str, target: str) -> List[int]: + m, n = len(stamp), len(target) + stamp = list(stamp) + target = list(target) + + # Helper function to check if we can stamp at position i + def can_stamp(i): + for j in range(m): + if target[i + j] != "?" and target[i + j] != stamp[j]: + return False + return True + + # Helper function to apply stamp at position i + def apply_stamp(i): + for j in range(m): + target[i + j] = "?" + + # Track visited positions and the stamping process + stamped = [False] * n + result = [] + queue = deque() + + # Initial queue fill + for i in range(n - m + 1): + if can_stamp(i): + queue.append(i) + apply_stamp(i) + result.append(i) + stamped[i] = True + + # Process the queue + while queue: + pos = queue.popleft() + for i in range(max(0, pos - m + 1), min(n - m + 1, pos + m)): + if can_stamp(i): + if not stamped[i]: + queue.append(i) + apply_stamp(i) + result.append(i) + stamped[i] = True + + # Verify that all characters in target are stamped + if all(c == "?" for c in target): + return result[::-1] + else: + return [] diff --git a/tests/501-1000/936. stamping-the-sequence/sol.py2 b/tests/501-1000/936. stamping-the-sequence/sol.py2 new file mode 100644 index 00000000..88f932bd --- /dev/null +++ b/tests/501-1000/936. stamping-the-sequence/sol.py2 @@ -0,0 +1,46 @@ +class Solution(object): + def movesToStamp(self, stamp, target): + """ + :type stamp: str + :type target: str + :rtype: List[int] + """ + m, n = len(stamp), len(target) + stamp = list(stamp) + target = list(target) + + def can_stamp(i): + for j in range(m): + if target[i + j] != '?' and target[i + j] != stamp[j]: + return False + return True + + def apply_stamp(i): + for j in range(m): + target[i + j] = '?' + + stamped = [False] * n + result = [] + queue = [] + + for i in range(n - m + 1): + if can_stamp(i): + queue.append(i) + apply_stamp(i) + result.append(i) + stamped[i] = True + + while queue: + pos = queue.pop(0) + for i in range(max(0, pos - m + 1), min(n - m + 1, pos + m)): + if can_stamp(i): + if not stamped[i]: + queue.append(i) + apply_stamp(i) + result.append(i) + stamped[i] = True + + if all(c == '?' for c in target): + return result[::-1] + else: + return [] diff --git a/tests/501-1000/936. stamping-the-sequence/sol.rb b/tests/501-1000/936. stamping-the-sequence/sol.rb new file mode 100644 index 00000000..a236c11c --- /dev/null +++ b/tests/501-1000/936. stamping-the-sequence/sol.rb @@ -0,0 +1,59 @@ +# @param {String} stamp +# @param {String} target +# @return {Integer[]} +def moves_to_stamp(stamp, target) + m = stamp.length + n = target.length + stamp_arr = stamp.chars + target_arr = target.chars + + can_stamp = lambda do |i| + m.times do |j| + if target_arr[i + j] != '?' && target_arr[i + j] != stamp_arr[j] + return false + end + end + true + end + + apply_stamp = lambda do |i| + m.times do |j| + target_arr[i + j] = '?' + end + end + + stamped = Array.new(n, false) + result = [] + queue = [] + + (0..n - m).each do |i| + if can_stamp.call(i) + queue.push(i) + apply_stamp.call(i) + result.push(i) + stamped[i] = true + end + end + + while !queue.empty? + pos = queue.shift + start = [0, pos - m + 1].max + finish = [n - m, pos + m].min + (start..finish).each do |i| + if can_stamp.call(i) + if !stamped[i] + queue.push(i) + apply_stamp.call(i) + result.push(i) + stamped[i] = true + end + end + end + end + + if target_arr.all? { |c| c == '?' } + return result.reverse + else + return [] + end +end diff --git a/tests/501-1000/936. stamping-the-sequence/sol.rs b/tests/501-1000/936. stamping-the-sequence/sol.rs new file mode 100644 index 00000000..a2b8b831 --- /dev/null +++ b/tests/501-1000/936. stamping-the-sequence/sol.rs @@ -0,0 +1,58 @@ +impl Solution { + pub fn moves_to_stamp(stamp: String, target: String) -> Vec { + let m = stamp.len(); + let n = target.len(); + let stamp_bytes = stamp.as_bytes(); + let mut target_bytes = target.into_bytes(); + + let can_stamp = |target_bytes: &[u8], i: usize| -> bool { + for j in 0..m { + if target_bytes[i + j] != b'?' && target_bytes[i + j] != stamp_bytes[j] { + return false; + } + } + true + }; + + let apply_stamp = |target_bytes: &mut [u8], i: usize| { + for j in 0..m { + target_bytes[i + j] = b'?'; + } + }; + + let mut stamped = vec![false; n]; + let mut result = Vec::new(); + let mut queue = std::collections::VecDeque::new(); + + for i in 0..=n - m { + if can_stamp(&target_bytes, i) { + apply_stamp(&mut target_bytes, i); + queue.push_back(i); + result.push(i as i32); + stamped[i] = true; + } + } + + while let Some(pos) = queue.pop_front() { + let start = if pos >= m - 1 { pos - m + 1 } else { 0 }; + let end = std::cmp::min(n - m, pos + m); + for i in start..=end { + if can_stamp(&target_bytes, i) { + if !stamped[i] { + apply_stamp(&mut target_bytes, i); + queue.push_back(i); + result.push(i as i32); + stamped[i] = true; + } + } + } + } + + if target_bytes.iter().all(|&c| c == b'?') { + result.reverse(); + result + } else { + Vec::new() + } + } +} diff --git a/tests/501-1000/936. stamping-the-sequence/sol.swift b/tests/501-1000/936. stamping-the-sequence/sol.swift new file mode 100644 index 00000000..5a77a561 --- /dev/null +++ b/tests/501-1000/936. stamping-the-sequence/sol.swift @@ -0,0 +1,57 @@ +class Solution { + func movesToStamp(_ stamp: String, _ target: String) -> [Int] { + let m = stamp.count + let n = target.count + var stampArr = Array(stamp) + var targetArr = Array(target) + + func canStamp(_ i: Int) -> Bool { + for j in 0.. { + for (let j = 0; j < m; j++) { + if (targetArr[i + j] !== "?" && targetArr[i + j] !== stampArr[j]) { + return false; + } + } + return true; + }; + + const applyStamp = (i: number): void => { + for (let j = 0; j < m; j++) { + targetArr[i + j] = "?"; + } + }; + + const stamped: boolean[] = new Array(n).fill(false); + const result: number[] = []; + const queue: number[] = []; + + for (let i = 0; i <= n - m; i++) { + if (canStamp(i)) { + applyStamp(i); + queue.push(i); + result.push(i); + stamped[i] = true; + } + } + + while (queue.length > 0) { + const pos = queue.shift()!; + const start = Math.max(0, pos - m + 1); + const end = Math.min(n - m, pos + m); + for (let i = start; i <= end; i++) { + if (canStamp(i)) { + if (!stamped[i]) { + applyStamp(i); + queue.push(i); + result.push(i); + stamped[i] = true; + } + } + } + } + + if (targetArr.every((c) => c === "?")) { + return result.reverse(); + } + return []; +} diff --git a/tests/501-1000/937. reorder-data-in-log-files/manifest.yaml b/tests/501-1000/937. reorder-data-in-log-files/manifest.yaml new file mode 100644 index 00000000..6c58acc7 --- /dev/null +++ b/tests/501-1000/937. reorder-data-in-log-files/manifest.yaml @@ -0,0 +1,572 @@ +entry: + id: 937 + title: reorder-data-in-log-files + params: + logs: + type: array + items: + type: string + call: + cpp: Solution().reorderLogFiles({logs}) + rust: Solution::reorder_log_files({logs}) + python3: Solution().reorderLogFiles({logs}) + python2: Solution().reorderLogFiles({logs}) + ruby: reorder_log_files({logs}) + java: new Solution().reorderLogFiles({logs}) + csharp: new Solution().ReorderLogFiles({logs}) + kotlin: Solution().reorderLogFiles({logs}) + go: reorderLogFiles({logs}) + dart: Solution().reorderLogFiles({logs}) + swift: Solution().reorderLogFiles({logs}) + typescript: reorderLogFiles({logs}) +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 937 +tests: + - name: case_1 + in: + logs: + - id2 67 31 + - id4 map bat map + - id3 dig ant can + - id1 dig + out: + - id1 dig + - id3 dig ant can + - id4 map bat map + - id2 67 31 + - name: case_2 + in: + logs: + - id4 43 67 + - id1 can + - id2 20 40 60 89 + - id3 3 + - id5 bat dig + - id6 act art map + out: + - id6 act art map + - id5 bat dig + - id1 can + - id4 43 67 + - id2 20 40 60 89 + - id3 3 + - name: case_3 + in: + logs: + - id6 57 59 59 + - id3 act bat + - id4 ant + - id1 87 12 18 36 + - id2 dig + - id5 51 24 + out: + - id3 act bat + - id4 ant + - id2 dig + - id6 57 59 59 + - id1 87 12 18 36 + - id5 51 24 + - name: case_4 + in: + logs: + - id1 zoo dig + - id3 act own zoo + - id2 25 + out: + - id3 act own zoo + - id1 zoo dig + - id2 25 + - name: case_5 + in: + logs: + - id7 ant ace can + - id6 8 + - id4 dig ant bat ant + - id1 can art art ace + - id5 own ace own + - id2 ace + - id3 96 88 69 + out: + - id2 ace + - id7 ant ace can + - id1 can art art ace + - id4 dig ant bat ant + - id5 own ace own + - id6 8 + - id3 96 88 69 + - name: case_6 + in: + logs: + - id5 27 86 6 + - id3 zoo + - id2 act map + - id7 ace art act ant + - id1 can + - id6 81 + - id4 24 99 + - id8 31 + - id9 ace + - id10 54 14 38 2 + out: + - id9 ace + - id7 ace art act ant + - id2 act map + - id1 can + - id3 zoo + - id5 27 86 6 + - id6 81 + - id4 24 99 + - id8 31 + - id10 54 14 38 2 + - name: case_7 + in: + logs: + - id6 24 4 11 + - id2 act zoo + - id3 7 + - id4 zoo art + - id1 ace map + - id5 99 6 + out: + - id1 ace map + - id2 act zoo + - id4 zoo art + - id6 24 4 11 + - id3 7 + - id5 99 6 + - name: case_8 + in: + logs: + - id1 54 + - id3 39 9 89 + - id2 bat + out: + - id2 bat + - id1 54 + - id3 39 9 89 + - name: case_9 + in: + logs: + - id2 77 + - id4 ant own map + - id5 33 96 45 + - id7 58 74 + - id6 63 45 + - id8 55 67 1 18 + - id3 88 21 + - id1 own + out: + - id4 ant own map + - id1 own + - id2 77 + - id5 33 96 45 + - id7 58 74 + - id6 63 45 + - id8 55 67 1 18 + - id3 88 21 + - name: case_10 + in: + logs: + - id4 6 + - id2 map act own + - id3 art ant + - id7 art ant + - id8 own map own + - id6 ace ant bat own + - id5 51 60 60 92 + - id1 bat ant ant + out: + - id6 ace ant bat own + - id3 art ant + - id7 art ant + - id1 bat ant ant + - id2 map act own + - id8 own map own + - id4 6 + - id5 51 60 60 92 + - name: case_11 + in: + logs: + - id3 53 18 21 43 + - id2 92 36 + - id7 bat + - id4 ace + - id1 map can zoo own + - id5 29 + - id6 48 53 + - id8 33 87 + out: + - id4 ace + - id7 bat + - id1 map can zoo own + - id3 53 18 21 43 + - id2 92 36 + - id5 29 + - id6 48 53 + - id8 33 87 + - name: case_12 + in: + logs: + - id1 can art + out: + - id1 can art + - name: case_13 + in: + logs: + - id1 dig act + out: + - id1 dig act + - name: case_14 + in: + logs: + - id2 bat ace can can + - id1 59 76 34 + - id3 art + - id4 94 15 99 + out: + - id3 art + - id2 bat ace can can + - id1 59 76 34 + - id4 94 15 99 + - name: case_15 + in: + logs: + - id4 can ace art + - id1 61 88 60 41 + - id5 art own ant + - id2 8 54 28 + - id3 9 91 + out: + - id5 art own ant + - id4 can ace art + - id1 61 88 60 41 + - id2 8 54 28 + - id3 9 91 + - name: case_16 + in: + logs: + - id6 dig act art dig + - id7 ace can + - id4 80 + - id3 can dig dig + - id1 zoo bat act + - id5 93 45 + - id2 map bat map + out: + - id7 ace can + - id3 can dig dig + - id6 dig act art dig + - id2 map bat map + - id1 zoo bat act + - id4 80 + - id5 93 45 + - name: case_17 + in: + logs: + - id8 19 55 87 92 + - id1 25 40 43 44 + - id10 can own ant zoo + - id3 bat + - id9 art art act + - id2 76 49 11 + - id5 bat bat dig ace + - id7 map ant own + - id4 14 52 97 90 + - id6 own own bat art + out: + - id9 art art act + - id3 bat + - id5 bat bat dig ace + - id10 can own ant zoo + - id7 map ant own + - id6 own own bat art + - id8 19 55 87 92 + - id1 25 40 43 44 + - id2 76 49 11 + - id4 14 52 97 90 + - name: case_18 + in: + logs: + - id7 art ant art + - id5 74 + - id3 26 + - id6 zoo bat dig + - id9 61 36 94 89 + - id4 84 47 + - id10 57 30 + - id1 act dig bat + - id2 own + - id8 9 64 + out: + - id1 act dig bat + - id7 art ant art + - id2 own + - id6 zoo bat dig + - id5 74 + - id3 26 + - id9 61 36 94 89 + - id4 84 47 + - id10 57 30 + - id8 9 64 + - name: case_19 + in: + logs: + - id9 72 61 + - id4 bat map zoo act + - id2 map can act bat + - id1 11 11 96 + - id6 zoo dig bat can + - id8 27 76 + - id5 bat + - id7 18 85 99 + - id3 84 58 45 + out: + - id5 bat + - id4 bat map zoo act + - id2 map can act bat + - id6 zoo dig bat can + - id9 72 61 + - id1 11 11 96 + - id8 27 76 + - id7 18 85 99 + - id3 84 58 45 + - name: case_20 + in: + logs: + - id6 52 8 + - id4 63 18 45 63 + - id2 99 2 28 29 + - id3 map map + - id1 11 + - id5 can + out: + - id5 can + - id3 map map + - id6 52 8 + - id4 63 18 45 63 + - id2 99 2 28 29 + - id1 11 + - name: case_21 + in: + logs: + - id3 can can can can + - id6 85 72 + - id8 71 93 + - id1 ant own + - id9 art ant + - id4 dig art + - id7 35 63 7 77 + - id2 can ant + - id5 62 52 88 + out: + - id1 ant own + - id9 art ant + - id2 can ant + - id3 can can can can + - id4 dig art + - id6 85 72 + - id8 71 93 + - id7 35 63 7 77 + - id5 62 52 88 + - name: case_22 + in: + logs: + - id2 81 + - id4 19 9 + - id1 zoo ant map + - id3 26 65 69 + out: + - id1 zoo ant map + - id2 81 + - id4 19 9 + - id3 26 65 69 + - name: case_23 + in: + logs: + - id5 own map bat ant + - id1 act ace + - id6 bat act + - id7 80 + - id2 act act ace own + - id4 bat zoo ant + - id3 bat can own + out: + - id1 act ace + - id2 act act ace own + - id6 bat act + - id3 bat can own + - id4 bat zoo ant + - id5 own map bat ant + - id7 80 + - name: case_24 + in: + logs: + - id1 19 57 10 94 + - id2 3 + out: + - id1 19 57 10 94 + - id2 3 + - name: case_25 + in: + logs: + - id2 20 40 + - id8 bat + - id3 dig art bat + - id5 dig ace map map + - id1 can ant + - id6 2 + - id9 act can zoo + - id4 can zoo + - id7 own + out: + - id9 act can zoo + - id8 bat + - id1 can ant + - id4 can zoo + - id5 dig ace map map + - id3 dig art bat + - id7 own + - id2 20 40 + - id6 2 + - name: case_26 + in: + logs: + - id1 own own + - id2 map + out: + - id2 map + - id1 own own + - name: case_27 + in: + logs: + - id4 bat act dig + - id1 art art can + - id5 art bat ace + - id2 bat act dig + - id3 zoo + out: + - id1 art art can + - id5 art bat ace + - id2 bat act dig + - id4 bat act dig + - id3 zoo + - name: case_28 + in: + logs: + - id5 83 56 63 + - id2 art bat + - id9 71 4 95 24 + - id1 4 79 + - id6 own + - id7 zoo ant ace + - id8 zoo art + - id3 can ace + - id4 own art ant art + out: + - id2 art bat + - id3 can ace + - id6 own + - id4 own art ant art + - id7 zoo ant ace + - id8 zoo art + - id5 83 56 63 + - id9 71 4 95 24 + - id1 4 79 + - name: case_29 + in: + logs: + - id2 36 19 + - id1 8 90 + out: + - id2 36 19 + - id1 8 90 + - name: case_30 + in: + logs: + - id5 bat bat ant ace + - id1 22 + - id2 12 7 71 88 + - id4 act own + - id3 98 70 + out: + - id4 act own + - id5 bat bat ant ace + - id1 22 + - id2 12 7 71 88 + - id3 98 70 + - name: case_31 + in: + logs: + - id1 map ace map bat + out: + - id1 map ace map bat + - name: case_32 + in: + logs: + - id4 78 33 + - id2 can + - id5 78 + - id3 dig dig ant + - id1 ant own dig + out: + - id1 ant own dig + - id2 can + - id3 dig dig ant + - id4 78 33 + - id5 78 + - name: case_33 + in: + logs: + - id8 art + - id2 40 88 + - id7 own own can art + - id3 ace map map own + - id1 17 91 67 + - id4 zoo bat ant ant + - id5 39 + - id6 map + out: + - id3 ace map map own + - id8 art + - id6 map + - id7 own own can art + - id4 zoo bat ant ant + - id2 40 88 + - id1 17 91 67 + - id5 39 + - name: case_34 + in: + logs: + - id2 ant bat + - id1 52 98 + - id4 ant + - id5 70 + - id6 16 94 16 29 + - id3 zoo dig dig bat + out: + - id4 ant + - id2 ant bat + - id3 zoo dig dig bat + - id1 52 98 + - id5 70 + - id6 16 94 16 29 + - name: case_35 + in: + logs: + - id2 12 86 88 15 + - id3 86 63 95 + - id1 78 + - id4 ace map + out: + - id4 ace map + - id2 12 86 88 15 + - id3 86 63 95 + - id1 78 diff --git a/tests/501-1000/937. reorder-data-in-log-files/sol.cpp b/tests/501-1000/937. reorder-data-in-log-files/sol.cpp new file mode 100644 index 00000000..ed07c629 --- /dev/null +++ b/tests/501-1000/937. reorder-data-in-log-files/sol.cpp @@ -0,0 +1,24 @@ +class Solution { +public: + vector reorderLogFiles(vector& logs) { + stable_sort(logs.begin(), logs.end(), [](const string& a, const string& b) { + auto pos1 = a.find(' '); + auto pos2 = b.find(' '); + string ident1 = a.substr(0, pos1); + string ident2 = b.substr(0, pos2); + string rest1 = a.substr(pos1 + 1); + string rest2 = b.substr(pos2 + 1); + bool isDigit1 = isdigit(rest1[0]); + bool isDigit2 = isdigit(rest2[0]); + if (!isDigit1 && !isDigit2) { + if (rest1 != rest2) + return rest1 < rest2; + return ident1 < ident2; + } + if (isDigit1 && isDigit2) + return false; + return !isDigit1; + }); + return logs; + } +}; diff --git a/tests/501-1000/937. reorder-data-in-log-files/sol.cs b/tests/501-1000/937. reorder-data-in-log-files/sol.cs new file mode 100644 index 00000000..905cecd7 --- /dev/null +++ b/tests/501-1000/937. reorder-data-in-log-files/sol.cs @@ -0,0 +1,24 @@ +public class Solution { + public string[] ReorderLogFiles(string[] logs) { + var letters = new List<(string body, string ident)>(); + var digits = new List(); + foreach (var log in logs) { + var split = log.Split(' ', 2); + var ident = split[0]; + var rest = split[1]; + if (char.IsDigit(rest[0])) digits.Add(log); + else letters.Add((rest, ident)); + } + letters.Sort((a, b) => { + int cmp = a.body.CompareTo(b.body); + if (cmp != 0) return cmp; + return a.ident.CompareTo(b.ident); + }); + var result = new List(logs.Length); + foreach (var entry in letters) { + result.Add(entry.ident + " " + entry.body); + } + result.AddRange(digits); + return result.ToArray(); + } +} diff --git a/tests/501-1000/937. reorder-data-in-log-files/sol.dart b/tests/501-1000/937. reorder-data-in-log-files/sol.dart new file mode 100644 index 00000000..22d36e9c --- /dev/null +++ b/tests/501-1000/937. reorder-data-in-log-files/sol.dart @@ -0,0 +1,22 @@ +class Solution { + List reorderLogFiles(List logs) { + logs.sort((log1, log2) { + var split1 = log1.split(' '); + var split2 = log2.split(' '); + var ident1 = split1[0]; + var ident2 = split2[0]; + var rest1 = split1.sublist(1).join(' '); + var rest2 = split2.sublist(1).join(' '); + bool isDigit1 = rest1[0].contains(RegExp(r'\d')); + bool isDigit2 = rest2[0].contains(RegExp(r'\d')); + if (!isDigit1 && !isDigit2) { + int cmp = rest1.compareTo(rest2); + if (cmp != 0) return cmp; + return ident1.compareTo(ident2); + } + if (isDigit1 && isDigit2) return 0; + return isDigit1 ? 1 : -1; + }); + return logs; + } +} diff --git a/tests/501-1000/937. reorder-data-in-log-files/sol.go b/tests/501-1000/937. reorder-data-in-log-files/sol.go new file mode 100644 index 00000000..9999fe87 --- /dev/null +++ b/tests/501-1000/937. reorder-data-in-log-files/sol.go @@ -0,0 +1,23 @@ +func reorderLogFiles(logs []string) []string { + sort.SliceStable(logs, func(i, j int) bool { + s1 := logs[i] + s2 := logs[j] + idx1 := strings.Index(s1, " ") + idx2 := strings.Index(s2, " ") + ident1, rest1 := s1[:idx1], s1[idx1+1:] + ident2, rest2 := s2[:idx2], s2[idx2+1:] + isDigit1 := rest1[0] >= '0' && rest1[0] <= '9' + isDigit2 := rest2[0] >= '0' && rest2[0] <= '9' + if !isDigit1 && !isDigit2 { + if rest1 != rest2 { + return rest1 < rest2 + } + return ident1 < ident2 + } + if isDigit1 && isDigit2 { + return false + } + return !isDigit1 + }) + return logs +} diff --git a/tests/501-1000/937. reorder-data-in-log-files/sol.java b/tests/501-1000/937. reorder-data-in-log-files/sol.java new file mode 100644 index 00000000..7d33a54d --- /dev/null +++ b/tests/501-1000/937. reorder-data-in-log-files/sol.java @@ -0,0 +1,17 @@ +class Solution { + public String[] reorderLogFiles(String[] logs) { + Arrays.sort(logs, (log1, log2) -> { + String[] split1 = log1.split(" ", 2); + String[] split2 = log2.split(" ", 2); + boolean isDigit1 = Character.isDigit(split1[1].charAt(0)); + boolean isDigit2 = Character.isDigit(split2[1].charAt(0)); + if (!isDigit1 && !isDigit2) { + int cmp = split1[1].compareTo(split2[1]); + if (cmp != 0) return cmp; + return split1[0].compareTo(split2[0]); + } + return isDigit1 ? (isDigit2 ? 0 : 1) : -1; + }); + return logs; + } +} diff --git a/tests/501-1000/937. reorder-data-in-log-files/sol.kt b/tests/501-1000/937. reorder-data-in-log-files/sol.kt new file mode 100644 index 00000000..b35d4380 --- /dev/null +++ b/tests/501-1000/937. reorder-data-in-log-files/sol.kt @@ -0,0 +1,18 @@ +class Solution { + fun reorderLogFiles(logs: Array): Array { + return logs.sortedWith(Comparator { log1, log2 -> + val split1 = log1.split(" ", limit = 2) + val split2 = log2.split(" ", limit = 2) + val isDigit1 = split1[1][0].isDigit() + val isDigit2 = split2[1][0].isDigit() + if (!isDigit1 && !isDigit2) { + val cmp = split1[1].compareTo(split2[1]) + if (cmp != 0) cmp else split1[0].compareTo(split2[0]) + } else { + if (isDigit1 && isDigit2) 0 + else if (isDigit1) 1 + else -1 + } + }).toTypedArray() + } +} diff --git a/tests/501-1000/937. reorder-data-in-log-files/sol.py b/tests/501-1000/937. reorder-data-in-log-files/sol.py new file mode 100644 index 00000000..4f6da963 --- /dev/null +++ b/tests/501-1000/937. reorder-data-in-log-files/sol.py @@ -0,0 +1,12 @@ +from typing import List + + +class Solution: + def reorderLogFiles(self, logs: List[str]) -> List[str]: + def key(log: str): + ident, rest = log.split(" ", 1) + if rest[0].isdigit(): + return (1,) + return (0, rest, ident) + + return sorted(logs, key=key) diff --git a/tests/501-1000/937. reorder-data-in-log-files/sol.py2 b/tests/501-1000/937. reorder-data-in-log-files/sol.py2 new file mode 100644 index 00000000..f5a6fa42 --- /dev/null +++ b/tests/501-1000/937. reorder-data-in-log-files/sol.py2 @@ -0,0 +1,12 @@ +class Solution(object): + def reorderLogFiles(self, logs): + """ + :type logs: List[str] + :rtype: List[str] + """ + def key(log): + ident, rest = log.split(" ", 1) + if rest[0].isdigit(): + return (1,) + return (0, rest, ident) + return sorted(logs, key=key) diff --git a/tests/501-1000/937. reorder-data-in-log-files/sol.rb b/tests/501-1000/937. reorder-data-in-log-files/sol.rb new file mode 100644 index 00000000..88b39393 --- /dev/null +++ b/tests/501-1000/937. reorder-data-in-log-files/sol.rb @@ -0,0 +1,12 @@ +# @param {String[]} logs +# @return {String[]} +def reorder_log_files(logs) + logs.sort_by do |log| + ident, rest = log.split(" ", 2) + if rest[0] =~ /\d/ + [1] + else + [0, rest, ident] + end + end +end diff --git a/tests/501-1000/937. reorder-data-in-log-files/sol.rs b/tests/501-1000/937. reorder-data-in-log-files/sol.rs new file mode 100644 index 00000000..8f856e54 --- /dev/null +++ b/tests/501-1000/937. reorder-data-in-log-files/sol.rs @@ -0,0 +1,20 @@ +impl Solution { + pub fn reorder_log_files(logs: Vec) -> Vec { + let mut logs = logs; + logs.sort_by(|a, b| { + let (ident_a, rest_a) = a.split_once(' ').unwrap(); + let (ident_b, rest_b) = b.split_once(' ').unwrap(); + let is_digit_a = rest_a.chars().next().unwrap().is_digit(10); + let is_digit_b = rest_b.chars().next().unwrap().is_digit(10); + match (is_digit_a, is_digit_b) { + (false, false) => { + rest_a.cmp(rest_b).then(ident_a.cmp(ident_b)) + } + (true, true) => std::cmp::Ordering::Equal, + (true, false) => std::cmp::Ordering::Greater, + (false, true) => std::cmp::Ordering::Less, + } + }); + logs + } +} diff --git a/tests/501-1000/937. reorder-data-in-log-files/sol.swift b/tests/501-1000/937. reorder-data-in-log-files/sol.swift new file mode 100644 index 00000000..90f95c1b --- /dev/null +++ b/tests/501-1000/937. reorder-data-in-log-files/sol.swift @@ -0,0 +1,24 @@ +class Solution { + func reorderLogFiles(_ logs: [String]) -> [String] { + return logs.sorted { log1, log2 in + let split1 = log1.split(separator: " ", maxSplits: 1) + let split2 = log2.split(separator: " ", maxSplits: 1) + let ident1 = String(split1[0]) + let ident2 = String(split2[0]) + let rest1 = String(split1[1]) + let rest2 = String(split2[1]) + let isDigit1 = rest1.first!.isNumber + let isDigit2 = rest2.first!.isNumber + if !isDigit1 && !isDigit2 { + if rest1 != rest2 { + return rest1 < rest2 + } + return ident1 < ident2 + } + if isDigit1 && isDigit2 { + return false + } + return !isDigit1 + } + } +} diff --git a/tests/501-1000/937. reorder-data-in-log-files/sol.ts b/tests/501-1000/937. reorder-data-in-log-files/sol.ts new file mode 100644 index 00000000..1413855a --- /dev/null +++ b/tests/501-1000/937. reorder-data-in-log-files/sol.ts @@ -0,0 +1,17 @@ +function reorderLogFiles(logs: string[]): string[] { + const letters: Array<[string, string]> = []; + const digits: string[] = []; + for (const log of logs) { + const split = log.indexOf(" "); + const ident = log.slice(0, split); + const rest = log.slice(split + 1); + if (/^\d/.test(rest)) digits.push(log); + else letters.push([rest, ident]); + } + letters.sort((a, b) => { + const cmp = a[0].localeCompare(b[0]); + if (cmp !== 0) return cmp; + return a[1].localeCompare(b[1]); + }); + return [...letters.map(([rest, ident]) => `${ident} ${rest}`), ...digits]; +} diff --git a/tests/501-1000/938. range-sum-of-bst/manifest.yaml b/tests/501-1000/938. range-sum-of-bst/manifest.yaml new file mode 100644 index 00000000..7aaa1db9 --- /dev/null +++ b/tests/501-1000/938. range-sum-of-bst/manifest.yaml @@ -0,0 +1,635 @@ +entry: + id: 938 + title: range-sum-of-bst + params: + root: + type: tree_node + low: + type: int + high: + type: int + call: + cpp: Solution().rangeSumBST({root}, {low}, {high}) + rust: Solution::range_sum_bst({root}, {low}, {high}) + python3: Solution().rangeSumBST({root}, {low}, {high}) + python2: Solution().rangeSumBST({root}, {low}, {high}) + ruby: range_sum_bst({root}, {low}, {high}) + java: new Solution().rangeSumBST({root}, {low}, {high}) + csharp: new Solution().RangeSumBST({root}, {low}, {high}) + kotlin: Solution().rangeSumBST({root}, {low}, {high}) + go: rangeSumBST({root}, {low}, {high}) + dart: Solution().rangeSumBST({root}, {low}, {high}) + swift: Solution().rangeSumBST({root}, {low}, {high}) + typescript: rangeSumBST({root}, {low}, {high}) +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 938 +tests: + - name: case_1 + in: + root: + - 75 + - 5 + - null + - null + - 56 + - 40 + - 58 + - 10 + - 49 + low: 33 + high: 57 + out: 145 + - name: case_2 + in: + root: + - 33 + - 14 + - 72 + - null + - null + - null + - 75 + low: 5 + high: 14 + out: 14 + - name: case_3 + in: + root: + - 23 + - null + - 30 + - null + - 54 + low: 8 + high: 52 + out: 53 + - name: case_4 + in: + root: + - 44 + - 39 + - 48 + - 12 + - null + - 46 + - 68 + - null + - 16 + - null + - null + - 63 + - 71 + - null + - null + - 54 + low: 80 + high: 80 + out: 0 + - name: case_5 + in: + root: + - 51 + - 25 + - 53 + - 7 + - 32 + - null + - 66 + low: 17 + high: 50 + out: 57 + - name: case_6 + in: + root: + - 19 + - 9 + - 46 + - null + - null + - null + - 69 + - null + - 71 + low: 78 + high: 78 + out: 0 + - name: case_7 + in: + root: + - 12 + - null + - 25 + - 22 + - 75 + - 20 + - null + - 46 + - null + - null + - null + - 28 + - 62 + - null + - null + - 61 + - 69 + - null + - null + - null + - 70 + low: 3 + high: 72 + out: 415 + - name: case_8 + in: + root: + - 45 + - 9 + - 67 + - null + - 29 + - 62 + - null + - null + - 34 + - 46 + - null + - null + - 39 + low: 23 + high: 30 + out: 29 + - name: case_9 + in: + root: + - 7 + low: 56 + high: 79 + out: 0 + - name: case_10 + in: + root: + - 50 + - 41 + - 71 + - 11 + - null + - null + - null + - null + - 38 + - 16 + - null + - null + - 21 + - null + - 34 + low: 23 + high: 58 + out: 163 + - name: case_11 + in: + root: + - 18 + - 9 + - 57 + - 6 + - null + - 35 + - null + - null + - null + - 22 + - 42 + - null + - 32 + low: 66 + high: 72 + out: 0 + - name: case_12 + in: + root: + - 74 + - 18 + low: 27 + high: 63 + out: 0 + - name: case_13 + in: + root: + - 47 + - 44 + - 58 + - 30 + - null + - 52 + - 65 + - 20 + - 41 + - null + - null + - null + - 71 + - 9 + - 28 + - null + - null + - null + - null + - null + - 13 + low: 47 + high: 79 + out: 293 + - name: case_14 + in: + root: + - 3 + - 2 + - 64 + - null + - null + - 56 + - 75 + - 46 + - 60 + - 67 + - null + - 27 + - null + - null + - null + - null + - null + - 21 + - null + - 4 + low: 60 + high: 65 + out: 124 + - name: case_15 + in: + root: + - 19 + - null + - 23 + - null + - 26 + low: 12 + high: 75 + out: 68 + - name: case_16 + in: + root: + - 50 + - 38 + - 64 + - 22 + - 46 + - null + - null + - null + - 31 + - null + - null + - null + - 37 + low: 29 + high: 50 + out: 202 + - name: case_17 + in: + root: + - 78 + - 29 + - null + - 21 + - 64 + - null + - null + - 57 + - 77 + - 49 + - 59 + - null + - null + - 43 + - 50 + low: 34 + high: 56 + out: 142 + - name: case_18 + in: + root: + - 12 + - null + - 56 + - 26 + - 66 + - 23 + - 29 + - null + - 75 + - 22 + - null + - null + - 47 + - null + - 77 + - null + - null + - 34 + low: 19 + high: 54 + out: 181 + - name: case_19 + in: + root: + - 79 + - 6 + - null + - null + - 21 + - 20 + - 47 + - 13 + - null + - 24 + - 57 + - null + - null + - null + - null + - null + - 73 + low: 42 + high: 75 + out: 177 + - name: case_20 + in: + root: + - 30 + - 11 + - 75 + - null + - 13 + - 63 + - 79 + - null + - null + - 40 + - 70 + - 78 + - null + - 38 + - null + - null + - 71 + - 76 + low: 36 + high: 72 + out: 282 + - name: case_21 + in: + root: + - 47 + - 33 + - 68 + - null + - null + - 52 + - 73 + low: 79 + high: 80 + out: 0 + - name: case_22 + in: + root: + - 67 + - 65 + - 75 + - 57 + - null + - null + - null + - 52 + - null + - 19 + - null + - null + - 37 + low: 13 + high: 41 + out: 56 + - name: case_23 + in: + root: + - 14 + - 3 + - 73 + - null + - null + - 42 + - null + - 41 + low: 59 + high: 73 + out: 73 + - name: case_24 + in: + root: + - 62 + - 1 + - 76 + - null + - 25 + - null + - null + - null + - 27 + - null + - 56 + low: 66 + high: 80 + out: 76 + - name: case_25 + in: + root: + - 25 + - 5 + - 38 + - null + - null + - null + - 67 + - 59 + - 78 + - 47 + low: 47 + high: 68 + out: 173 + - name: case_26 + in: + root: + - 57 + - 55 + - 63 + low: 57 + high: 59 + out: 57 + - name: case_27 + in: + root: + - 16 + - null + - 51 + low: 39 + high: 42 + out: 0 + - name: case_28 + in: + root: + - 27 + - 5 + - 30 + - 4 + - 24 + - null + - 64 + - null + - null + - 12 + - 26 + - 50 + - null + - null + - null + - null + - null + - 47 + low: 31 + high: 80 + out: 161 + - name: case_29 + in: + root: + - 17 + - null + - 78 + - 52 + - null + - 47 + - 71 + - null + - 48 + low: 77 + high: 79 + out: 78 + - name: case_30 + in: + root: + - 35 + - 25 + low: 14 + high: 58 + out: 60 + - name: case_31 + in: + root: + - 12 + - 1 + - 41 + - null + - null + - 31 + - 56 + - null + - null + - null + - 61 + low: 28 + high: 33 + out: 31 + - name: case_32 + in: + root: + - 22 + low: 30 + high: 35 + out: 0 + - name: case_33 + in: + root: + - 45 + - 43 + - 62 + - 14 + - null + - 58 + - 70 + - null + - null + - 46 + - null + - null + - 75 + - null + - 49 + low: 45 + high: 73 + out: 330 + - name: case_34 + in: + root: + - 28 + - 24 + - 55 + - 19 + - 26 + - 42 + - 76 + - 17 + - 21 + - null + - null + - null + - null + - 69 + - null + - 8 + - null + - null + - null + - null + - null + - 5 + low: 54 + high: 70 + out: 124 + - name: case_35 + in: + root: + - 6 + - null + - 50 + - 39 + - 52 + - 23 + - null + - null + - 64 + - null + - null + - null + - 67 + low: 14 + high: 68 + out: 295 diff --git a/tests/501-1000/938. range-sum-of-bst/sol.cpp b/tests/501-1000/938. range-sum-of-bst/sol.cpp new file mode 100644 index 00000000..525297aa --- /dev/null +++ b/tests/501-1000/938. range-sum-of-bst/sol.cpp @@ -0,0 +1,27 @@ +/** + * Definition for a binary tree node. + * struct TreeNode { + * int val; + * TreeNode *left; + * TreeNode *right; + * TreeNode() : val(0), left(nullptr), right(nullptr) {} + * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} + * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} + * }; + */ +class Solution { +public: + int rangeSumBST(TreeNode* root, int low, int high) { + int res = 0; + function dfs = [&](TreeNode* node) { + if (!node) return; + dfs(node->left); + if (low <= node->val && node->val <= high) { + res += node->val; + } + dfs(node->right); + }; + dfs(root); + return res; + } +}; diff --git a/tests/501-1000/938. range-sum-of-bst/sol.cs b/tests/501-1000/938. range-sum-of-bst/sol.cs new file mode 100644 index 00000000..8f9bdd3e --- /dev/null +++ b/tests/501-1000/938. range-sum-of-bst/sol.cs @@ -0,0 +1,28 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public int val; + * public TreeNode left; + * public TreeNode right; + * public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +public class Solution { + public int RangeSumBST(TreeNode root, int low, int high) { + int res = 0; + void Dfs(TreeNode node) { + if (node == null) return; + Dfs(node.left); + if (low <= node.val && node.val <= high) { + res += node.val; + } + Dfs(node.right); + } + Dfs(root); + return res; + } +} diff --git a/tests/501-1000/938. range-sum-of-bst/sol.dart b/tests/501-1000/938. range-sum-of-bst/sol.dart new file mode 100644 index 00000000..adb154e9 --- /dev/null +++ b/tests/501-1000/938. range-sum-of-bst/sol.dart @@ -0,0 +1,26 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * int val; + * TreeNode? left; + * TreeNode? right; + * TreeNode([this.val = 0, this.left, this.right]); + * } + */ +class Solution { + int rangeSumBST(TreeNode? root, int low, int high) { + int res = 0; + void dfs(TreeNode? node) { + if (node == null) { + return; + } + dfs(node.left); + if (low <= node.val && node.val <= high) { + res += node.val; + } + dfs(node.right); + } + dfs(root); + return res; + } +} diff --git a/tests/501-1000/938. range-sum-of-bst/sol.go b/tests/501-1000/938. range-sum-of-bst/sol.go new file mode 100644 index 00000000..c0c58cd9 --- /dev/null +++ b/tests/501-1000/938. range-sum-of-bst/sol.go @@ -0,0 +1,24 @@ +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +func rangeSumBST(root *TreeNode, low int, high int) int { + res := 0 + var dfs func(node *TreeNode) + dfs = func(node *TreeNode) { + if node == nil { + return + } + dfs(node.Left) + if low <= node.Val && node.Val <= high { + res += node.Val + } + dfs(node.Right) + } + dfs(root) + return res +} diff --git a/tests/501-1000/938. range-sum-of-bst/sol.java b/tests/501-1000/938. range-sum-of-bst/sol.java new file mode 100644 index 00000000..b208a341 --- /dev/null +++ b/tests/501-1000/938. range-sum-of-bst/sol.java @@ -0,0 +1,33 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode() {} + * TreeNode(int val) { this.val = val; } + * TreeNode(int val, TreeNode left, TreeNode right) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +class Solution { + public int rangeSumBST(TreeNode root, int low, int high) { + int[] res = new int[1]; + dfs(root, low, high, res); + return res[0]; + } + + private void dfs(TreeNode node, int low, int high, int[] res) { + if (node == null) { + return; + } + dfs(node.left, low, high, res); + if (low <= node.val && node.val <= high) { + res[0] += node.val; + } + dfs(node.right, low, high, res); + } +} diff --git a/tests/501-1000/938. range-sum-of-bst/sol.kt b/tests/501-1000/938. range-sum-of-bst/sol.kt new file mode 100644 index 00000000..d956ae8e --- /dev/null +++ b/tests/501-1000/938. range-sum-of-bst/sol.kt @@ -0,0 +1,25 @@ +/** + * Example: + * var ti = TreeNode(5) + * var v = ti.`val` + * Definition for a binary tree node. + * class TreeNode(var `val`: Int) { + * var left: TreeNode? = null + * var right: TreeNode? = null + * } + */ +class Solution { + fun rangeSumBST(root: TreeNode?, low: Int, high: Int): Int { + val res = intArrayOf(0) + fun dfs(node: TreeNode?) { + if (node == null) return + dfs(node.left) + if (node.`val` in low..high) { + res[0] += node.`val` + } + dfs(node.right) + } + dfs(root) + return res[0] + } +} diff --git a/tests/501-1000/938. range-sum-of-bst/sol.py b/tests/501-1000/938. range-sum-of-bst/sol.py new file mode 100644 index 00000000..f79b88bd --- /dev/null +++ b/tests/501-1000/938. range-sum-of-bst/sol.py @@ -0,0 +1,24 @@ +# Definition for a binary tree node. +# class TreeNode: +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +from typing import Optional + + +class Solution: + def rangeSumBST(self, root: Optional[TreeNode], low: int, high: int) -> int: + res = 0 + + def dfs(node): + nonlocal res + if not node: + return + dfs(node.left) + if low <= node.val <= high: + res += node.val + dfs(node.right) + + dfs(root) + return res diff --git a/tests/501-1000/938. range-sum-of-bst/sol.py2 b/tests/501-1000/938. range-sum-of-bst/sol.py2 new file mode 100644 index 00000000..9a78a080 --- /dev/null +++ b/tests/501-1000/938. range-sum-of-bst/sol.py2 @@ -0,0 +1,24 @@ +# Definition for a binary tree node. +# class TreeNode(object): +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution(object): + def rangeSumBST(self, root, low, high): + """ + :type root: Optional[TreeNode] + :type low: int + :type high: int + :rtype: int + """ + res = [0] + def dfs(node): + if not node: + return + dfs(node.left) + if low <= node.val <= high: + res[0] += node.val + dfs(node.right) + dfs(root) + return res[0] diff --git a/tests/501-1000/938. range-sum-of-bst/sol.rb b/tests/501-1000/938. range-sum-of-bst/sol.rb new file mode 100644 index 00000000..adb74ca8 --- /dev/null +++ b/tests/501-1000/938. range-sum-of-bst/sol.rb @@ -0,0 +1,26 @@ +# Definition for a binary tree node. +# class TreeNode +# attr_accessor :val, :left, :right +# def initialize(val = 0, left = nil, right = nil) +# @val = val +# @left = left +# @right = right +# end +# end +# @param {TreeNode} root +# @param {Integer} low +# @param {Integer} high +# @return {Integer} +def range_sum_bst(root, low, high) + res = [0] + dfs = lambda do |node| + return if node.nil? + dfs.call(node.left) + if low <= node.val && node.val <= high + res[0] += node.val + end + dfs.call(node.right) + end + dfs.call(root) + res[0] +end diff --git a/tests/501-1000/938. range-sum-of-bst/sol.rs b/tests/501-1000/938. range-sum-of-bst/sol.rs new file mode 100644 index 00000000..b98b5642 --- /dev/null +++ b/tests/501-1000/938. range-sum-of-bst/sol.rs @@ -0,0 +1,35 @@ +// Definition for a binary tree node. +// #[derive(Debug, PartialEq, Eq)] +// pub struct TreeNode { +// pub val: i32, +// pub left: Option>>, +// pub right: Option>>, +// } +// +// impl TreeNode { +// #[inline] +// pub fn new(val: i32) -> Self { +// TreeNode { +// val, +// left: None, +// right: None +// } +// } +// } +impl Solution { + pub fn range_sum_bst(root: Option>>, low: i32, high: i32) -> i32 { + let mut res = 0; + fn dfs(node: Option>>, low: i32, high: i32, res: &mut i32) { + if let Some(n) = node { + let n = n.borrow(); + dfs(n.left.clone(), low, high, res); + if low <= n.val && n.val <= high { + *res += n.val; + } + dfs(n.right.clone(), low, high, res); + } + } + dfs(root, low, high, &mut res); + res + } +} diff --git a/tests/501-1000/938. range-sum-of-bst/sol.swift b/tests/501-1000/938. range-sum-of-bst/sol.swift new file mode 100644 index 00000000..0c6f9c6d --- /dev/null +++ b/tests/501-1000/938. range-sum-of-bst/sol.swift @@ -0,0 +1,32 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public var val: Int + * public var left: TreeNode? + * public var right: TreeNode? + * public init() { self.val = 0; self.left = nil; self.right = nil; } + * public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; } + * public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) { + * self.val = val + * self.left = left + * self.right = right + * } + * } + */ +class Solution { + func rangeSumBST(_ root: TreeNode?, _ low: Int, _ high: Int) -> Int { + var res = 0 + func dfs(_ node: TreeNode?) { + guard let node = node else { + return + } + dfs(node.left) + if low <= node.val && node.val <= high { + res += node.val + } + dfs(node.right) + } + dfs(root) + return res + } +} diff --git a/tests/501-1000/938. range-sum-of-bst/sol.ts b/tests/501-1000/938. range-sum-of-bst/sol.ts new file mode 100644 index 00000000..c7b9a013 --- /dev/null +++ b/tests/501-1000/938. range-sum-of-bst/sol.ts @@ -0,0 +1,29 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ + +function rangeSumBST(root: TreeNode | null, low: number, high: number): number { + let res = 0; + function dfs(node: TreeNode | null): void { + if (node === null) { + return; + } + dfs(node.left); + if (low <= node.val && node.val <= high) { + res += node.val; + } + dfs(node.right); + } + dfs(root); + return res; +} diff --git a/tests/501-1000/939. minimum-area-rectangle/manifest.yaml b/tests/501-1000/939. minimum-area-rectangle/manifest.yaml new file mode 100644 index 00000000..afde5be5 --- /dev/null +++ b/tests/501-1000/939. minimum-area-rectangle/manifest.yaml @@ -0,0 +1,402 @@ +entry: + id: 939 + title: minimum-area-rectangle + params: + points: + type: array + items: + type: array + items: + type: int + call: + cpp: Solution().minAreaRect({points}) + rust: Solution::min_area_rect({points}) + python3: Solution().minAreaRect({points}) + python2: Solution().minAreaRect({points}) + ruby: min_area_rect({points}) + java: new Solution().minAreaRect({points}) + csharp: new Solution().MinAreaRect({points}) + kotlin: Solution().minAreaRect({points}) + go: minAreaRect({points}) + dart: Solution().minAreaRect({points}) + swift: Solution().minAreaRect({points}) + typescript: minAreaRect({points}) +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 939 +tests: + - name: case_1 + in: + points: + - - 0 + - 4 + - - 1 + - 1 + - - 1 + - 2 + - - 5 + - 1 + - - 5 + - 2 + - - 6 + - 5 + out: 4 + - name: case_2 + in: + points: + - - 1 + - 0 + - - 1 + - 6 + - - 3 + - 1 + out: 0 + - name: case_3 + in: + points: + - - 0 + - 0 + - - 0 + - 4 + - - 1 + - 2 + - - 2 + - 1 + - - 5 + - 5 + out: 0 + - name: case_4 + in: + points: + - - 4 + - 0 + - - 5 + - 6 + - - 6 + - 0 + - - 6 + - 5 + out: 0 + - name: case_5 + in: + points: + - - 1 + - 0 + out: 0 + - name: case_6 + in: + points: + - - 2 + - 2 + - - 2 + - 3 + - - 4 + - 4 + - - 6 + - 5 + out: 0 + - name: case_7 + in: + points: + - - 0 + - 3 + out: 0 + - name: case_8 + in: + points: + - - 3 + - 0 + out: 0 + - name: case_9 + in: + points: + - - 0 + - 3 + - - 2 + - 4 + out: 0 + - name: case_10 + in: + points: + - - 3 + - 5 + - - 4 + - 1 + out: 0 + - name: case_11 + in: + points: + - - 0 + - 1 + - - 2 + - 0 + - - 4 + - 1 + out: 0 + - name: case_12 + in: + points: + - - 2 + - 5 + - - 3 + - 4 + out: 0 + - name: case_13 + in: + points: + - - 1 + - 2 + - - 4 + - 4 + - - 6 + - 5 + out: 0 + - name: case_14 + in: + points: + - - 0 + - 0 + - - 0 + - 5 + - - 3 + - 1 + - - 4 + - 5 + - - 5 + - 1 + - - 5 + - 2 + out: 0 + - name: case_15 + in: + points: + - - 2 + - 0 + - - 5 + - 3 + out: 0 + - name: case_16 + in: + points: + - - 0 + - 6 + - - 5 + - 2 + out: 0 + - name: case_17 + in: + points: + - - 0 + - 1 + - - 0 + - 4 + - - 1 + - 1 + - - 2 + - 4 + - - 5 + - 1 + out: 0 + - name: case_18 + in: + points: + - - 0 + - 5 + out: 0 + - name: case_19 + in: + points: + - - 0 + - 3 + - - 2 + - 2 + - - 2 + - 3 + - - 3 + - 1 + - - 5 + - 5 + out: 0 + - name: case_20 + in: + points: + - - 1 + - 1 + - - 1 + - 2 + - - 4 + - 0 + - - 5 + - 6 + out: 0 + - name: case_21 + in: + points: + - - 1 + - 5 + - - 3 + - 2 + - - 3 + - 5 + - - 4 + - 6 + out: 0 + - name: case_22 + in: + points: + - - 0 + - 3 + - - 4 + - 6 + - - 5 + - 4 + - - 5 + - 6 + out: 0 + - name: case_23 + in: + points: + - - 2 + - 4 + - - 4 + - 1 + - - 4 + - 5 + - - 5 + - 4 + out: 0 + - name: case_24 + in: + points: + - - 0 + - 3 + - - 2 + - 2 + - - 3 + - 1 + out: 0 + - name: case_25 + in: + points: + - - 0 + - 3 + - - 2 + - 6 + - - 5 + - 4 + out: 0 + - name: case_26 + in: + points: + - - 5 + - 0 + - - 6 + - 6 + out: 0 + - name: case_27 + in: + points: + - - 0 + - 4 + - - 4 + - 0 + - - 4 + - 3 + - - 4 + - 5 + - - 5 + - 4 + - - 6 + - 2 + out: 0 + - name: case_28 + in: + points: + - - 0 + - 2 + - - 1 + - 0 + - - 6 + - 3 + out: 0 + - name: case_29 + in: + points: + - - 0 + - 4 + - - 2 + - 6 + - - 5 + - 1 + - - 6 + - 1 + - - 6 + - 2 + out: 0 + - name: case_30 + in: + points: + - - 0 + - 0 + - - 1 + - 0 + - - 1 + - 1 + - - 2 + - 6 + - - 4 + - 1 + - - 5 + - 1 + - - 6 + - 2 + out: 0 + - name: case_31 + in: + points: + - - 1 + - 6 + out: 0 + - name: case_32 + in: + points: + - - 0 + - 4 + - - 0 + - 6 + - - 2 + - 1 + - - 5 + - 5 + out: 0 + - name: case_33 + in: + points: + - - 1 + - 0 + - - 2 + - 6 + - - 3 + - 5 + - - 6 + - 1 + out: 0 + - name: case_34 + in: + points: + - - 1 + - 0 + out: 0 + - name: case_35 + in: + points: + - - 3 + - 6 + out: 0 diff --git a/tests/501-1000/939. minimum-area-rectangle/sol.cpp b/tests/501-1000/939. minimum-area-rectangle/sol.cpp new file mode 100644 index 00000000..239a2a8c --- /dev/null +++ b/tests/501-1000/939. minimum-area-rectangle/sol.cpp @@ -0,0 +1,28 @@ +class Solution { +public: + int minAreaRect(vector>& points) { + map> cols; + for (auto& point : points) { + int x = point[0], y = point[1]; + cols[x].push_back(y); + } + + map, int> lastX; + int best = INT_MAX; + + for (auto& [x, ys] : cols) { + sort(ys.begin(), ys.end()); + for (size_t i = 0; i < ys.size(); i++) { + for (size_t j = i + 1; j < ys.size(); j++) { + pair p = {ys[i], ys[j]}; + if (lastX.count(p)) { + int area = (x - lastX[p]) * (ys[j] - ys[i]); + best = min(best, area); + } + lastX[p] = x; + } + } + } + return best == INT_MAX ? 0 : best; + } +}; diff --git a/tests/501-1000/939. minimum-area-rectangle/sol.cs b/tests/501-1000/939. minimum-area-rectangle/sol.cs new file mode 100644 index 00000000..afadb7d2 --- /dev/null +++ b/tests/501-1000/939. minimum-area-rectangle/sol.cs @@ -0,0 +1,31 @@ +public class Solution { + public int MinAreaRect(int[][] points) { + var cols = new Dictionary>(); + foreach (var point in points) { + int x = point[0], y = point[1]; + if (!cols.ContainsKey(x)) cols[x] = new List(); + cols[x].Add(y); + } + + var lastX = new Dictionary<(int, int), int>(); + int best = int.MaxValue; + var sortedX = new List(cols.Keys); + sortedX.Sort(); + + foreach (int x in sortedX) { + var ys = cols[x]; + ys.Sort(); + for (int i = 0; i < ys.Count; i++) { + for (int j = i + 1; j < ys.Count; j++) { + var pair = (ys[i], ys[j]); + if (lastX.ContainsKey(pair)) { + int area = (x - lastX[pair]) * (ys[j] - ys[i]); + best = Math.Min(best, area); + } + lastX[pair] = x; + } + } + } + return best == int.MaxValue ? 0 : best; + } +} diff --git a/tests/501-1000/939. minimum-area-rectangle/sol.dart b/tests/501-1000/939. minimum-area-rectangle/sol.dart new file mode 100644 index 00000000..7e16799c --- /dev/null +++ b/tests/501-1000/939. minimum-area-rectangle/sol.dart @@ -0,0 +1,28 @@ +class Solution { + int minAreaRect(List> points) { + Map> cols = {}; + for (var point in points) { + int x = point[0], y = point[1]; + cols.putIfAbsent(x, () => []).add(y); + } + + Map lastX = {}; + int best = 0x7fffffffffffffff; + List sortedX = cols.keys.toList()..sort(); + + for (int x in sortedX) { + List ys = cols[x]!..sort(); + for (int i = 0; i < ys.length; i++) { + for (int j = i + 1; j < ys.length; j++) { + String pair = '${ys[i]},${ys[j]}'; + if (lastX.containsKey(pair)) { + int area = (x - lastX[pair]!) * (ys[j] - ys[i]); + if (area < best) best = area; + } + lastX[pair] = x; + } + } + } + return best == 0x7fffffffffffffff ? 0 : best; + } +} diff --git a/tests/501-1000/939. minimum-area-rectangle/sol.go b/tests/501-1000/939. minimum-area-rectangle/sol.go new file mode 100644 index 00000000..3caed5a8 --- /dev/null +++ b/tests/501-1000/939. minimum-area-rectangle/sol.go @@ -0,0 +1,37 @@ +func minAreaRect(points [][]int) int { + cols := make(map[int][]int) + for _, point := range points { + x, y := point[0], point[1] + cols[x] = append(cols[x], y) + } + + lastX := make(map[string]int) + best := int(^uint(0) >> 1) + + sortedX := make([]int, 0, len(cols)) + for x := range cols { + sortedX = append(sortedX, x) + } + sort.Ints(sortedX) + + for _, x := range sortedX { + ys := cols[x] + sort.Ints(ys) + for i := 0; i < len(ys); i++ { + for j := i + 1; j < len(ys); j++ { + pair := fmt.Sprintf("%d,%d", ys[i], ys[j]) + if prevX, ok := lastX[pair]; ok { + area := (x - prevX) * (ys[j] - ys[i]) + if area < best { + best = area + } + } + lastX[pair] = x + } + } + } + if best == int(^uint(0)>>1) { + return 0 + } + return best +} diff --git a/tests/501-1000/939. minimum-area-rectangle/sol.java b/tests/501-1000/939. minimum-area-rectangle/sol.java new file mode 100644 index 00000000..eca29ccb --- /dev/null +++ b/tests/501-1000/939. minimum-area-rectangle/sol.java @@ -0,0 +1,30 @@ +class Solution { + public int minAreaRect(int[][] points) { + Map> cols = new HashMap<>(); + for (int[] point : points) { + int x = point[0], y = point[1]; + cols.computeIfAbsent(x, k -> new ArrayList<>()).add(y); + } + + Map lastX = new HashMap<>(); + int best = Integer.MAX_VALUE; + List sortedX = new ArrayList<>(cols.keySet()); + Collections.sort(sortedX); + + for (int x : sortedX) { + List ys = cols.get(x); + Collections.sort(ys); + for (int i = 0; i < ys.size(); i++) { + for (int j = i + 1; j < ys.size(); j++) { + String pair = ys.get(i) + "," + ys.get(j); + if (lastX.containsKey(pair)) { + int area = (x - lastX.get(pair)) * (ys.get(j) - ys.get(i)); + best = Math.min(best, area); + } + lastX.put(pair, x); + } + } + } + return best == Integer.MAX_VALUE ? 0 : best; + } +} diff --git a/tests/501-1000/939. minimum-area-rectangle/sol.kt b/tests/501-1000/939. minimum-area-rectangle/sol.kt new file mode 100644 index 00000000..95ba8052 --- /dev/null +++ b/tests/501-1000/939. minimum-area-rectangle/sol.kt @@ -0,0 +1,29 @@ +class Solution { + fun minAreaRect(points: Array): Int { + val cols = mutableMapOf>() + for (point in points) { + val x = point[0] + val y = point[1] + cols.getOrPut(x) { mutableListOf() }.add(y) + } + + val lastX = mutableMapOf, Int>() + var best = Int.MAX_VALUE + val sortedX = cols.keys.sorted() + + for (x in sortedX) { + val ys = cols[x]!!.sorted() + for (i in ys.indices) { + for (j in i + 1 until ys.size) { + val pair = Pair(ys[i], ys[j]) + if (pair in lastX) { + val area = (x - lastX[pair]!!) * (ys[j] - ys[i]) + best = minOf(best, area) + } + lastX[pair] = x + } + } + } + return if (best == Int.MAX_VALUE) 0 else best + } +} diff --git a/tests/501-1000/939. minimum-area-rectangle/sol.py b/tests/501-1000/939. minimum-area-rectangle/sol.py new file mode 100644 index 00000000..d101717a --- /dev/null +++ b/tests/501-1000/939. minimum-area-rectangle/sol.py @@ -0,0 +1,20 @@ +from typing import List + + +class Solution: + def minAreaRect(self, points: List[List[int]]) -> int: + cols = {} + for x, y in points: + cols.setdefault(x, []).append(y) + + last_x = {} + best = float("inf") + for x in sorted(cols): + ys = sorted(cols[x]) + for i in range(len(ys)): + for j in range(i + 1, len(ys)): + pair = (ys[i], ys[j]) + if pair in last_x: + best = min(best, (x - last_x[pair]) * (ys[j] - ys[i])) + last_x[pair] = x + return 0 if best == float("inf") else best diff --git a/tests/501-1000/939. minimum-area-rectangle/sol.py2 b/tests/501-1000/939. minimum-area-rectangle/sol.py2 new file mode 100644 index 00000000..84cce9a5 --- /dev/null +++ b/tests/501-1000/939. minimum-area-rectangle/sol.py2 @@ -0,0 +1,23 @@ +class Solution(object): + def minAreaRect(self, points): + """ + :type points: List[List[int]] + :rtype: int + """ + cols = {} + for x, y in points: + if x not in cols: + cols[x] = [] + cols[x].append(y) + + last_x = {} + best = float("inf") + for x in sorted(cols): + ys = sorted(cols[x]) + for i in range(len(ys)): + for j in range(i + 1, len(ys)): + pair = (ys[i], ys[j]) + if pair in last_x: + best = min(best, (x - last_x[pair]) * (ys[j] - ys[i])) + last_x[pair] = x + return 0 if best == float("inf") else best diff --git a/tests/501-1000/939. minimum-area-rectangle/sol.rb b/tests/501-1000/939. minimum-area-rectangle/sol.rb new file mode 100644 index 00000000..c84b6a1e --- /dev/null +++ b/tests/501-1000/939. minimum-area-rectangle/sol.rb @@ -0,0 +1,25 @@ +# @param {Integer[][]} points +# @return {Integer} +def min_area_rect(points) + cols = {} + points.each do |x, y| + cols[x] = [] unless cols.key?(x) + cols[x] << y + end + + last_x = {} + best = Float::INFINITY + cols.keys.sort.each do |x| + ys = cols[x].sort + (0...ys.length).each do |i| + ((i + 1)...ys.length).each do |j| + pair = [ys[i], ys[j]] + if last_x.key?(pair) + best = [best, (x - last_x[pair]) * (ys[j] - ys[i])].min + end + last_x[pair] = x + end + end + end + best == Float::INFINITY ? 0 : best +end diff --git a/tests/501-1000/939. minimum-area-rectangle/sol.rs b/tests/501-1000/939. minimum-area-rectangle/sol.rs new file mode 100644 index 00000000..109e5693 --- /dev/null +++ b/tests/501-1000/939. minimum-area-rectangle/sol.rs @@ -0,0 +1,31 @@ +impl Solution { + pub fn min_area_rect(points: Vec>) -> i32 { + use std::collections::{HashMap, BTreeMap}; + + let mut cols: BTreeMap> = BTreeMap::new(); + for point in &points { + let x = point[0]; + let y = point[1]; + cols.entry(x).or_insert_with(Vec::new).push(y); + } + + let mut last_x: HashMap<(i32, i32), i32> = HashMap::new(); + let mut best = i32::MAX; + + for (x, ys) in cols.iter_mut() { + ys.sort(); + for i in 0..ys.len() { + for j in (i + 1)..ys.len() { + let pair = (ys[i], ys[j]); + if let Some(&prev_x) = last_x.get(&pair) { + let area = (x - prev_x) * (ys[j] - ys[i]); + best = best.min(area); + } + last_x.insert(pair, *x); + } + } + } + + if best == i32::MAX { 0 } else { best } + } +} diff --git a/tests/501-1000/939. minimum-area-rectangle/sol.swift b/tests/501-1000/939. minimum-area-rectangle/sol.swift new file mode 100644 index 00000000..5b7cdb18 --- /dev/null +++ b/tests/501-1000/939. minimum-area-rectangle/sol.swift @@ -0,0 +1,28 @@ +class Solution { + func minAreaRect(_ points: [[Int]]) -> Int { + var cols: [Int: [Int]] = [:] + for point in points { + let x = point[0], y = point[1] + cols[x, default: []].append(y) + } + + var lastX: [String: Int] = [:] + var best = Int.max + let sortedX = cols.keys.sorted() + + for x in sortedX { + let ys = cols[x]!.sorted() + for i in 0.. = new Map(); + for (const [x, y] of points) { + if (!cols.has(x)) cols.set(x, []); + cols.get(x)!.push(y); + } + + const lastX: Map = new Map(); + let best = Infinity; + const sortedX = Array.from(cols.keys()).sort((a, b) => a - b); + + for (const x of sortedX) { + const ys = cols.get(x)!.sort((a, b) => a - b); + for (let i = 0; i < ys.length; i++) { + for (let j = i + 1; j < ys.length; j++) { + const pair = `${ys[i]},${ys[j]}`; + if (lastX.has(pair)) { + const area = (x - lastX.get(pair)!) * (ys[j] - ys[i]); + best = Math.min(best, area); + } + lastX.set(pair, x); + } + } + } + return best === Infinity ? 0 : best; +} diff --git a/tests/501-1000/940. distinct-subsequences-ii/manifest.yaml b/tests/501-1000/940. distinct-subsequences-ii/manifest.yaml new file mode 100644 index 00000000..cfe834f6 --- /dev/null +++ b/tests/501-1000/940. distinct-subsequences-ii/manifest.yaml @@ -0,0 +1,170 @@ +entry: + id: 940 + title: distinct-subsequences-ii + params: + s: + type: string + call: + cpp: Solution().distinctSubseqII({s}) + rust: Solution::distinct_subseq_ii({s}) + python3: Solution().distinctSubseqII({s}) + python2: Solution().distinctSubseqII({s}) + ruby: distinct_subseq_ii({s}) + java: new Solution().distinctSubseqII({s}) + csharp: new Solution().DistinctSubseqII({s}) + kotlin: Solution().distinctSubseqII({s}) + go: distinctSubseqII({s}) + dart: Solution().distinctSubseqII({s}) + swift: Solution().distinctSubseqII({s}) + typescript: distinctSubseqII({s}) +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 940 +tests: + - name: case_1 + in: + s: bcdb + out: 14 + - name: case_2 + in: + s: cad + out: 7 + - name: case_3 + in: + s: bccbbadcacd + out: 767 + - name: case_4 + in: + s: dbdbdbccaabdbab + out: 6367 + - name: case_5 + in: + s: baabcdbabdacda + out: 6697 + - name: case_6 + in: + s: cadacdbbaaddbaaa + out: 8707 + - name: case_7 + in: + s: ccccadbcdcaaa + out: 960 + - name: case_8 + in: + s: b + out: 1 + - name: case_9 + in: + s: cbdbadbdbbccbdb + out: 6837 + - name: case_10 + in: + s: b + out: 1 + - name: case_11 + in: + s: adbdb + out: 23 + - name: case_12 + in: + s: dac + out: 7 + - name: case_13 + in: + s: dbcbcdbad + out: 319 + - name: case_14 + in: + s: dbc + out: 7 + - name: case_15 + in: + s: cba + out: 7 + - name: case_16 + in: + s: bcaacb + out: 42 + - name: case_17 + in: + s: dcbccdaccc + out: 269 + - name: case_18 + in: + s: bccbb + out: 15 + - name: case_19 + in: + s: db + out: 3 + - name: case_20 + in: + s: abda + out: 14 + - name: case_21 + in: + s: ccaaccbccccbc + out: 481 + - name: case_22 + in: + s: adcbcbacdddbcba + out: 9007 + - name: case_23 + in: + s: bdccda + out: 43 + - name: case_24 + in: + s: cbdcdbcaddbccc + out: 3921 + - name: case_25 + in: + s: dcdcc + out: 16 + - name: case_26 + in: + s: b + out: 1 + - name: case_27 + in: + s: cbaccc + out: 28 + - name: case_28 + in: + s: dbb + out: 5 + - name: case_29 + in: + s: ccbbc + out: 15 + - name: case_30 + in: + s: abcdcdbb + out: 139 + - name: case_31 + in: + s: caddcadcbbabb + out: 2002 + - name: case_32 + in: + s: d + out: 1 + - name: case_33 + in: + s: dccdbdcbbccabbb + out: 3648 + - name: case_34 + in: + s: bacdac + out: 55 + - name: case_35 + in: + s: cdccccbaaabdbc + out: 1642 diff --git a/tests/501-1000/940. distinct-subsequences-ii/sol.cpp b/tests/501-1000/940. distinct-subsequences-ii/sol.cpp new file mode 100644 index 00000000..51da1290 --- /dev/null +++ b/tests/501-1000/940. distinct-subsequences-ii/sol.cpp @@ -0,0 +1,22 @@ +class Solution { +public: + int distinctSubseqII(string s) { + int n = s.length(); + const int mod = 1000000007; + vector dp(n, 0); + dp[0] = 2; + unordered_map mp; + mp[s[0]] = 0; + for (int i = 1; i < n; i++) { + dp[i] = (2 * dp[i-1]) % mod; + if (mp.find(s[i]) != mp.end()) { + int idx = mp[s[i]]; + dp[i] -= (idx > 0 ? dp[idx-1] : 1); + if (dp[i] < 0) dp[i] += mod; + } + mp[s[i]] = i; + dp[i] %= mod; + } + return (dp[n-1] - 1 + mod) % mod; + } +}; diff --git a/tests/501-1000/940. distinct-subsequences-ii/sol.cs b/tests/501-1000/940. distinct-subsequences-ii/sol.cs new file mode 100644 index 00000000..a6503253 --- /dev/null +++ b/tests/501-1000/940. distinct-subsequences-ii/sol.cs @@ -0,0 +1,21 @@ +public class Solution { + public int DistinctSubseqII(string s) { + int n = s.Length; + int mod = 1000000007; + long[] dp = new long[n]; + dp[0] = 2; + Dictionary mp = new Dictionary(); + mp[s[0]] = 0; + for (int i = 1; i < n; i++) { + dp[i] = (2 * dp[i-1]) % mod; + if (mp.ContainsKey(s[i])) { + int idx = mp[s[i]]; + dp[i] -= idx > 0 ? dp[idx-1] : 1; + if (dp[i] < 0) dp[i] += mod; + } + mp[s[i]] = i; + dp[i] %= mod; + } + return (int)((dp[n-1] - 1 + mod) % mod); + } +} diff --git a/tests/501-1000/940. distinct-subsequences-ii/sol.dart b/tests/501-1000/940. distinct-subsequences-ii/sol.dart new file mode 100644 index 00000000..61422019 --- /dev/null +++ b/tests/501-1000/940. distinct-subsequences-ii/sol.dart @@ -0,0 +1,21 @@ +class Solution { + int distinctSubseqII(String s) { + int n = s.length; + int mod = 1000000007; + List dp = List.filled(n, 0); + dp[0] = 2; + Map mp = {}; + mp[s[0]] = 0; + for (int i = 1; i < n; i++) { + dp[i] = (2 * dp[i-1]) % mod; + if (mp.containsKey(s[i])) { + int idx = mp[s[i]]!; + dp[i] -= idx > 0 ? dp[idx-1] : 1; + if (dp[i] < 0) dp[i] += mod; + } + mp[s[i]] = i; + dp[i] %= mod; + } + return (dp[n-1] - 1 + mod) % mod; + } +} diff --git a/tests/501-1000/940. distinct-subsequences-ii/sol.go b/tests/501-1000/940. distinct-subsequences-ii/sol.go new file mode 100644 index 00000000..af7cff20 --- /dev/null +++ b/tests/501-1000/940. distinct-subsequences-ii/sol.go @@ -0,0 +1,24 @@ +func distinctSubseqII(s string) int { + n := len(s) + mod := 1000000007 + dp := make([]int, n) + dp[0] = 2 + mp := make(map[byte]int) + mp[s[0]] = 0 + for i := 1; i < n; i++ { + dp[i] = (2 * dp[i-1]) % mod + if idx, ok := mp[s[i]]; ok { + if idx > 0 { + dp[i] -= dp[idx-1] + } else { + dp[i] -= 1 + } + if dp[i] < 0 { + dp[i] += mod + } + } + mp[s[i]] = i + dp[i] %= mod + } + return (dp[n-1] - 1 + mod) % mod +} diff --git a/tests/501-1000/940. distinct-subsequences-ii/sol.java b/tests/501-1000/940. distinct-subsequences-ii/sol.java new file mode 100644 index 00000000..50d2895c --- /dev/null +++ b/tests/501-1000/940. distinct-subsequences-ii/sol.java @@ -0,0 +1,22 @@ +class Solution { + public int distinctSubseqII(String s) { + int n = s.length(); + int mod = 1000000007; + int[] dp = new int[n]; + dp[0] = 2; + int[] mp = new int[26]; + for (int i = 0; i < 26; i++) mp[i] = -1; + mp[s.charAt(0) - 'a'] = 0; + for (int i = 1; i < n; i++) { + dp[i] = (2 * dp[i-1]) % mod; + int idx = s.charAt(i) - 'a'; + if (mp[idx] != -1) { + dp[i] -= (mp[idx] > 0 ? dp[mp[idx]-1] : 1); + if (dp[i] < 0) dp[i] += mod; + } + mp[idx] = i; + dp[i] %= mod; + } + return (dp[n-1] - 1 + mod) % mod; + } +} diff --git a/tests/501-1000/940. distinct-subsequences-ii/sol.kt b/tests/501-1000/940. distinct-subsequences-ii/sol.kt new file mode 100644 index 00000000..58fbd030 --- /dev/null +++ b/tests/501-1000/940. distinct-subsequences-ii/sol.kt @@ -0,0 +1,21 @@ +class Solution { + fun distinctSubseqII(s: String): Int { + val n = s.length + val mod = 1000000007 + val dp = IntArray(n) + dp[0] = 2 + val mp = IntArray(26) { -1 } + mp[s[0] - 'a'] = 0 + for (i in 1 until n) { + dp[i] = (2 * dp[i-1]) % mod + val idx = s[i] - 'a' + if (mp[idx] != -1) { + dp[i] -= if (mp[idx] > 0) dp[mp[idx]-1] else 1 + if (dp[i] < 0) dp[i] += mod + } + mp[idx] = i + dp[i] %= mod + } + return (dp[n-1] - 1 + mod) % mod + } +} diff --git a/tests/501-1000/940. distinct-subsequences-ii/sol.py b/tests/501-1000/940. distinct-subsequences-ii/sol.py new file mode 100644 index 00000000..2b71f0ee --- /dev/null +++ b/tests/501-1000/940. distinct-subsequences-ii/sol.py @@ -0,0 +1,42 @@ +from collections import defaultdict + + +class Solution: + def distinctSubseqII(self, s: str) -> int: + """ + distinct subsequences + + dp[i] -> count of number of subsequences using 0 to i + + now ith character has two case take or skip + + i.e dp[i-1]*2 + + + so we can either take or skip the ith char + + where does the problem occur + + + but the last occurence of the same character has same pos as this + + + dp[mp[s[i]]-1]*2 will be done at mp[s[i]] again same subsequence + + + will occur at i at the case where + + mp[s[i]] to i-1 all are skipped so subtract those + """ + n = len(s) + dp = [0] * (n) + dp[0] = 2 + mp = defaultdict(int) + mp[s[0]] = 0 + for i in range(1, n): + dp[i] = 2 * dp[i - 1] + if s[i] in mp: + dp[i] -= dp[mp[s[i]] - 1] if mp[s[i]] > 0 else 1 + mp[s[i]] = i + dp[i] %= 10**9 + 7 + return (dp[-1] - 1 + 10**9 + 7) % (10**9 + 7) diff --git a/tests/501-1000/940. distinct-subsequences-ii/sol.py2 b/tests/501-1000/940. distinct-subsequences-ii/sol.py2 new file mode 100644 index 00000000..1abcbbf0 --- /dev/null +++ b/tests/501-1000/940. distinct-subsequences-ii/sol.py2 @@ -0,0 +1,19 @@ +class Solution(object): + def distinctSubseqII(self, s): + """ + :type s: str + :rtype: int + """ + n = len(s) + dp = [0] * n + dp[0] = 2 + mp = {} + mp[s[0]] = 0 + mod = 10**9 + 7 + for i in range(1, n): + dp[i] = 2 * dp[i-1] + if s[i] in mp: + dp[i] -= dp[mp[s[i]]-1] if mp[s[i]] > 0 else 1 + mp[s[i]] = i + dp[i] %= mod + return (dp[-1] - 1 + mod) % mod diff --git a/tests/501-1000/940. distinct-subsequences-ii/sol.rb b/tests/501-1000/940. distinct-subsequences-ii/sol.rb new file mode 100644 index 00000000..514da68a --- /dev/null +++ b/tests/501-1000/940. distinct-subsequences-ii/sol.rb @@ -0,0 +1,19 @@ +# @param {String} s +# @return {Integer} +def distinct_subseq_ii(s) + n = s.length + dp = Array.new(n, 0) + dp[0] = 2 + mp = {} + mp[s[0]] = 0 + mod = 10**9 + 7 + (1...n).each do |i| + dp[i] = 2 * dp[i-1] + if mp.key?(s[i]) + dp[i] -= mp[s[i]] > 0 ? dp[mp[s[i]]-1] : 1 + end + mp[s[i]] = i + dp[i] %= mod + end + (dp[-1] - 1 + mod) % mod +end diff --git a/tests/501-1000/940. distinct-subsequences-ii/sol.rs b/tests/501-1000/940. distinct-subsequences-ii/sol.rs new file mode 100644 index 00000000..95b5ed18 --- /dev/null +++ b/tests/501-1000/940. distinct-subsequences-ii/sol.rs @@ -0,0 +1,21 @@ +impl Solution { + pub fn distinct_subseq_ii(s: String) -> i32 { + let n = s.len(); + let m = 1000000007i64; + let mut dp = vec![0i64; n]; + dp[0] = 2; + let mut mp = std::collections::HashMap::new(); + let chars: Vec = s.chars().collect(); + mp.insert(chars[0], 0); + for i in 1..n { + dp[i] = (2 * dp[i-1]) % m; + if let Some(&idx) = mp.get(&chars[i]) { + dp[i] -= if idx > 0 { dp[idx-1] } else { 1 }; + if dp[i] < 0 { dp[i] += m; } + } + mp.insert(chars[i], i); + dp[i] %= m; + } + ((dp[n-1] - 1 + m) % m) as i32 + } +} diff --git a/tests/501-1000/940. distinct-subsequences-ii/sol.swift b/tests/501-1000/940. distinct-subsequences-ii/sol.swift new file mode 100644 index 00000000..999b27d0 --- /dev/null +++ b/tests/501-1000/940. distinct-subsequences-ii/sol.swift @@ -0,0 +1,21 @@ +class Solution { + func distinctSubseqII(_ s: String) -> Int { + let n = s.count + let mod = 1000000007 + var dp = Array(repeating: 0, count: n) + dp[0] = 2 + var mp = [Character: Int]() + let chars = Array(s) + mp[chars[0]] = 0 + for i in 1.. 0 ? dp[idx-1] : 1 + if dp[i] < 0 { dp[i] += mod } + } + mp[chars[i]] = i + dp[i] %= mod + } + return (dp[n-1] - 1 + mod) % mod + } +} diff --git a/tests/501-1000/940. distinct-subsequences-ii/sol.ts b/tests/501-1000/940. distinct-subsequences-ii/sol.ts new file mode 100644 index 00000000..d5b36b1e --- /dev/null +++ b/tests/501-1000/940. distinct-subsequences-ii/sol.ts @@ -0,0 +1,19 @@ +function distinctSubseqII(s: string): number { + const n = s.length; + const mod = 1000000007; + const dp: number[] = new Array(n).fill(0); + dp[0] = 2; + const mp: Map = new Map(); + mp.set(s[0], 0); + for (let i = 1; i < n; i++) { + dp[i] = (2 * dp[i - 1]) % mod; + if (mp.has(s[i])) { + const idx = mp.get(s[i])!; + dp[i] -= idx > 0 ? dp[idx - 1] : 1; + if (dp[i] < 0) dp[i] += mod; + } + mp.set(s[i], i); + dp[i] %= mod; + } + return (dp[n - 1] - 1 + mod) % mod; +} diff --git a/tests/501-1000/941. valid-mountain-array/manifest.yaml b/tests/501-1000/941. valid-mountain-array/manifest.yaml new file mode 100644 index 00000000..7e5b4dc3 --- /dev/null +++ b/tests/501-1000/941. valid-mountain-array/manifest.yaml @@ -0,0 +1,402 @@ +entry: + id: 941 + title: valid-mountain-array + params: + arr: + type: array + items: + type: int + call: + cpp: Solution().validMountainArray({arr}) + rust: Solution::valid_mountain_array({arr}) + python3: Solution().validMountainArray({arr}) + python2: Solution().validMountainArray({arr}) + ruby: valid_mountain_array({arr}) + java: new Solution().validMountainArray({arr}) + csharp: new Solution().ValidMountainArray({arr}) + kotlin: Solution().validMountainArray({arr}) + go: validMountainArray({arr}) + dart: Solution().validMountainArray({arr}) + swift: Solution().validMountainArray({arr}) + typescript: validMountainArray({arr}) +judge: + type: exact +limits: + time_ms: 200 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 941 +tests: + - name: case_1 + in: + arr: + - 13 + out: false + - name: case_2 + in: + arr: + - 5 + - 10 + - 12 + - 19 + - 13 + - 19 + out: false + - name: case_3 + in: + arr: + - 10 + - 6 + - 1 + - 20 + - 16 + out: false + - name: case_4 + in: + arr: + - 9 + - 7 + - 16 + - 15 + - 15 + - 8 + - 7 + - 13 + out: false + - name: case_5 + in: + arr: + - 13 + - 3 + - 15 + out: false + - name: case_6 + in: + arr: + - 7 + - 1 + - 9 + - 7 + - 5 + - 18 + - 3 + - 19 + out: false + - name: case_7 + in: + arr: + - 12 + - 1 + - 12 + - 4 + - 13 + - 14 + - 1 + - 15 + out: false + - name: case_8 + in: + arr: + - 18 + - 15 + out: false + - name: case_9 + in: + arr: + - 19 + - 10 + - 15 + - 19 + - 16 + - 20 + - 13 + - 9 + out: false + - name: case_10 + in: + arr: + - 11 + - 20 + - 12 + - 14 + - 3 + out: false + - name: case_11 + in: + arr: + - 6 + - 15 + - 18 + - 20 + - 2 + - 9 + - 2 + out: false + - name: case_12 + in: + arr: + - 1 + - 17 + - 13 + - 11 + - 0 + - 3 + - 9 + - 8 + out: false + - name: case_13 + in: + arr: + - 11 + - 7 + out: false + - name: case_14 + in: + arr: + - 0 + - 4 + - 6 + - 1 + - 16 + - 18 + out: false + - name: case_15 + in: + arr: + - 20 + - 18 + - 11 + - 16 + - 6 + - 10 + - 4 + - 13 + - 10 + - 10 + out: false + - name: case_16 + in: + arr: + - 6 + - 6 + - 11 + - 18 + - 17 + - 9 + - 14 + - 11 + - 9 + - 6 + - 14 + - 13 + out: false + - name: case_17 + in: + arr: + - 15 + - 5 + - 8 + - 7 + - 7 + - 0 + - 8 + - 4 + - 3 + - 10 + - 20 + out: false + - name: case_18 + in: + arr: + - 5 + - 5 + - 1 + - 1 + - 20 + - 11 + out: false + - name: case_19 + in: + arr: + - 13 + - 9 + - 19 + - 19 + - 10 + - 5 + - 12 + - 14 + out: false + - name: case_20 + in: + arr: + - 15 + - 19 + - 1 + - 0 + - 2 + - 20 + - 10 + out: false + - name: case_21 + in: + arr: + - 11 + - 4 + out: false + - name: case_22 + in: + arr: + - 1 + out: false + - name: case_23 + in: + arr: + - 17 + - 2 + - 16 + - 16 + - 12 + - 16 + - 16 + - 1 + - 11 + out: false + - name: case_24 + in: + arr: + - 2 + - 17 + - 20 + - 7 + - 16 + - 18 + out: false + - name: case_25 + in: + arr: + - 2 + - 13 + - 3 + - 15 + - 6 + - 19 + - 10 + - 18 + - 1 + - 15 + - 11 + - 6 + out: false + - name: case_26 + in: + arr: + - 12 + - 12 + - 8 + - 0 + - 5 + - 15 + - 1 + - 13 + out: false + - name: case_27 + in: + arr: + - 3 + - 12 + - 7 + - 7 + - 4 + - 6 + - 1 + - 6 + - 3 + - 13 + - 6 + - 8 + out: false + - name: case_28 + in: + arr: + - 14 + - 8 + - 12 + - 14 + - 5 + - 2 + - 0 + - 14 + - 7 + out: false + - name: case_29 + in: + arr: + - 14 + - 12 + - 14 + - 17 + - 15 + - 15 + - 18 + - 11 + out: false + - name: case_30 + in: + arr: + - 6 + - 2 + - 11 + - 6 + - 19 + - 17 + - 12 + - 13 + - 6 + out: false + - name: case_31 + in: + arr: + - 12 + - 8 + - 15 + out: false + - name: case_32 + in: + arr: + - 11 + - 19 + - 5 + out: true + - name: case_33 + in: + arr: + - 3 + - 9 + - 16 + - 9 + - 0 + - 20 + - 8 + - 11 + out: false + - name: case_34 + in: + arr: + - 2 + - 13 + - 2 + out: true + - name: case_35 + in: + arr: + - 16 + - 14 + - 8 + - 6 + - 8 + - 16 + out: false diff --git a/tests/501-1000/941. valid-mountain-array/sol.cpp b/tests/501-1000/941. valid-mountain-array/sol.cpp new file mode 100644 index 00000000..008f6aa2 --- /dev/null +++ b/tests/501-1000/941. valid-mountain-array/sol.cpp @@ -0,0 +1,21 @@ +class Solution { +public: + bool validMountainArray(vector& arr) { + int n = arr.size(); + int i = 0; + + while (i+1 < n && arr[i] < arr[i+1]) { + i++; + } + + if (i == 0 || i == n-1) { + return false; + } + + while (i+1 < n && arr[i] > arr[i+1]) { + i++; + } + + return i == n-1; + } +}; diff --git a/tests/501-1000/941. valid-mountain-array/sol.cs b/tests/501-1000/941. valid-mountain-array/sol.cs new file mode 100644 index 00000000..fe785d27 --- /dev/null +++ b/tests/501-1000/941. valid-mountain-array/sol.cs @@ -0,0 +1,20 @@ +public class Solution { + public bool ValidMountainArray(int[] arr) { + int n = arr.Length; + int i = 0; + + while (i+1 < n && arr[i] < arr[i+1]) { + i++; + } + + if (i == 0 || i == n-1) { + return false; + } + + while (i+1 < n && arr[i] > arr[i+1]) { + i++; + } + + return i == n-1; + } +} diff --git a/tests/501-1000/941. valid-mountain-array/sol.dart b/tests/501-1000/941. valid-mountain-array/sol.dart new file mode 100644 index 00000000..6bb4e7a4 --- /dev/null +++ b/tests/501-1000/941. valid-mountain-array/sol.dart @@ -0,0 +1,20 @@ +class Solution { + bool validMountainArray(List arr) { + int n = arr.length; + int i = 0; + + while (i + 1 < n && arr[i] < arr[i + 1]) { + i++; + } + + if (i == 0 || i == n - 1) { + return false; + } + + while (i + 1 < n && arr[i] > arr[i + 1]) { + i++; + } + + return i == n - 1; + } +} diff --git a/tests/501-1000/941. valid-mountain-array/sol.go b/tests/501-1000/941. valid-mountain-array/sol.go new file mode 100644 index 00000000..b6678391 --- /dev/null +++ b/tests/501-1000/941. valid-mountain-array/sol.go @@ -0,0 +1,18 @@ +func validMountainArray(arr []int) bool { + n := len(arr) + i := 0 + + for i+1 < n && arr[i] < arr[i+1] { + i++ + } + + if i == 0 || i == n-1 { + return false + } + + for i+1 < n && arr[i] > arr[i+1] { + i++ + } + + return i == n-1 +} diff --git a/tests/501-1000/941. valid-mountain-array/sol.java b/tests/501-1000/941. valid-mountain-array/sol.java new file mode 100644 index 00000000..d661be8a --- /dev/null +++ b/tests/501-1000/941. valid-mountain-array/sol.java @@ -0,0 +1,20 @@ +class Solution { + public boolean validMountainArray(int[] arr) { + int n = arr.length; + int i = 0; + + while (i+1 < n && arr[i] < arr[i+1]) { + i++; + } + + if (i == 0 || i == n-1) { + return false; + } + + while (i+1 < n && arr[i] > arr[i+1]) { + i++; + } + + return i == n-1; + } +} diff --git a/tests/501-1000/941. valid-mountain-array/sol.kt b/tests/501-1000/941. valid-mountain-array/sol.kt new file mode 100644 index 00000000..4787b076 --- /dev/null +++ b/tests/501-1000/941. valid-mountain-array/sol.kt @@ -0,0 +1,20 @@ +class Solution { + fun validMountainArray(arr: IntArray): Boolean { + val n = arr.size + var i = 0 + + while (i+1 < n && arr[i] < arr[i+1]) { + i++ + } + + if (i == 0 || i == n-1) { + return false + } + + while (i+1 < n && arr[i] > arr[i+1]) { + i++ + } + + return i == n-1 + } +} diff --git a/tests/501-1000/941. valid-mountain-array/sol.py b/tests/501-1000/941. valid-mountain-array/sol.py new file mode 100644 index 00000000..4a7957ed --- /dev/null +++ b/tests/501-1000/941. valid-mountain-array/sol.py @@ -0,0 +1,22 @@ +from typing import List + + +class Solution: + def validMountainArray(self, arr: List[int]) -> bool: + n = len(arr) + i = 0 + + # 1. Climb up + while i + 1 < n and arr[i] < arr[i + 1]: + i += 1 + + # 2. Peak check: Peak can't be first or last element + if i == 0 or i == n - 1: + return False + + # 3. Climb down + while i + 1 < n and arr[i] > arr[i + 1]: + i += 1 + + # 4. If we reached the end, it's a mountain + return i == n - 1 diff --git a/tests/501-1000/941. valid-mountain-array/sol.py2 b/tests/501-1000/941. valid-mountain-array/sol.py2 new file mode 100644 index 00000000..b299a5e5 --- /dev/null +++ b/tests/501-1000/941. valid-mountain-array/sol.py2 @@ -0,0 +1,19 @@ +class Solution(object): + def validMountainArray(self, arr): + """ + :type arr: List[int] + :rtype: bool + """ + n = len(arr) + i = 0 + + while i+1 < n and arr[i] < arr[i+1]: + i += 1 + + if i == 0 or i == n-1: + return False + + while i+1 < n and arr[i] > arr[i+1]: + i += 1 + + return i == n-1 diff --git a/tests/501-1000/941. valid-mountain-array/sol.rb b/tests/501-1000/941. valid-mountain-array/sol.rb new file mode 100644 index 00000000..1236dd69 --- /dev/null +++ b/tests/501-1000/941. valid-mountain-array/sol.rb @@ -0,0 +1,20 @@ +# @param {Integer[]} arr +# @return {Boolean} +def valid_mountain_array(arr) + n = arr.length + i = 0 + + while i+1 < n && arr[i] < arr[i+1] + i += 1 + end + + if i == 0 || i == n-1 + return false + end + + while i+1 < n && arr[i] > arr[i+1] + i += 1 + end + + return i == n-1 +end diff --git a/tests/501-1000/941. valid-mountain-array/sol.rs b/tests/501-1000/941. valid-mountain-array/sol.rs new file mode 100644 index 00000000..16dbcfbe --- /dev/null +++ b/tests/501-1000/941. valid-mountain-array/sol.rs @@ -0,0 +1,20 @@ +impl Solution { + pub fn valid_mountain_array(arr: Vec) -> bool { + let n = arr.len(); + let mut i = 0; + + while i+1 < n && arr[i] < arr[i+1] { + i += 1; + } + + if i == 0 || i == n-1 { + return false; + } + + while i+1 < n && arr[i] > arr[i+1] { + i += 1; + } + + i == n-1 + } +} diff --git a/tests/501-1000/941. valid-mountain-array/sol.swift b/tests/501-1000/941. valid-mountain-array/sol.swift new file mode 100644 index 00000000..e7d811fd --- /dev/null +++ b/tests/501-1000/941. valid-mountain-array/sol.swift @@ -0,0 +1,20 @@ +class Solution { + func validMountainArray(_ arr: [Int]) -> Bool { + let n = arr.count + var i = 0 + + while i+1 < n && arr[i] < arr[i+1] { + i += 1 + } + + if i == 0 || i == n-1 { + return false + } + + while i+1 < n && arr[i] > arr[i+1] { + i += 1 + } + + return i == n-1 + } +} diff --git a/tests/501-1000/941. valid-mountain-array/sol.ts b/tests/501-1000/941. valid-mountain-array/sol.ts new file mode 100644 index 00000000..f9bbd8d7 --- /dev/null +++ b/tests/501-1000/941. valid-mountain-array/sol.ts @@ -0,0 +1,18 @@ +function validMountainArray(arr: number[]): boolean { + const n = arr.length; + let i = 0; + + while (i + 1 < n && arr[i] < arr[i + 1]) { + i++; + } + + if (i === 0 || i === n - 1) { + return false; + } + + while (i + 1 < n && arr[i] > arr[i + 1]) { + i++; + } + + return i === n - 1; +} diff --git a/tests/501-1000/942. di-string-match/manifest.yaml b/tests/501-1000/942. di-string-match/manifest.yaml new file mode 100644 index 00000000..9f363aee --- /dev/null +++ b/tests/501-1000/942. di-string-match/manifest.yaml @@ -0,0 +1,142 @@ +entry: + id: 942 + title: di-string-match + params: + s: + type: string + call: + cpp: Solution().diStringMatch({s}) + rust: Solution::di_string_match({s}) + python3: Solution().diStringMatch({s}) + python2: Solution().diStringMatch({s}) + ruby: di_string_match({s}) + java: new Solution().diStringMatch({s}) + csharp: new Solution().DiStringMatch({s}) + kotlin: Solution().diStringMatch({s}) + go: diStringMatch({s}) + dart: Solution().diStringMatch({s}) + swift: Solution().diStringMatch({s}) + typescript: diStringMatch({s}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().diStringMatch(s, {result}) + checker: + "class Checker:\n def diStringMatch(self, s, result):\n if\ + \ not isinstance(result, list) or len(result) != len(s) + 1:\n return\ + \ False\n if sorted(result) != list(range(len(s) + 1)):\n \ + \ return False\n for i, ch in enumerate(s):\n if ch == 'I'\ + \ and not (result[i] < result[i + 1]):\n return False\n \ + \ if ch == 'D' and not (result[i] > result[i + 1]):\n return\ + \ False\n return True\n" +seed: 942 +tests: + - name: case_1 + in: + s: I + - name: case_2 + in: + s: D + - name: case_3 + in: + s: ID + - name: case_4 + in: + s: DI + - name: case_5 + in: + s: IID + - name: case_6 + in: + s: DDI + - name: case_7 + in: + s: DID + - name: case_8 + in: + s: III + - name: case_9 + in: + s: DDD + - name: case_10 + in: + s: IDID + - name: case_11 + in: + s: DIDI + - name: case_12 + in: + s: IIDDIDD + - name: case_13 + in: + s: DDIDDIDDI + - name: case_14 + in: + s: DDIIIIDDD + - name: case_15 + in: + s: DIIIII + - name: case_16 + in: + s: ID + - name: case_17 + in: + s: IDIDI + - name: case_18 + in: + s: DDIDDD + - name: case_19 + in: + s: DIIDI + - name: case_20 + in: + s: IIDID + - name: case_21 + in: + s: DDDIII + - name: case_22 + in: + s: II + - name: case_23 + in: + s: IIIDDDDIID + - name: case_24 + in: + s: DIDDDI + - name: case_25 + in: + s: IDDDII + - name: case_26 + in: + s: IDDDDIIII + - name: case_27 + in: + s: DIID + - name: case_28 + in: + s: I + - name: case_29 + in: + s: DDD + - name: case_30 + in: + s: DIIDDII + - name: case_31 + in: + s: DDIDDD + - name: case_32 + in: + s: DI + - name: case_33 + in: + s: DIDIII + - name: case_34 + in: + s: DIIDI + - name: case_35 + in: + s: ID diff --git a/tests/501-1000/942. di-string-match/sol.cpp b/tests/501-1000/942. di-string-match/sol.cpp new file mode 100644 index 00000000..66f1707b --- /dev/null +++ b/tests/501-1000/942. di-string-match/sol.cpp @@ -0,0 +1,16 @@ +class Solution { +public: + vector diStringMatch(string s) { + int low = 0, high = s.size(); + vector result(s.size() + 1); + for (int i = 0; i < s.size(); i++) { + if (s[i] == 'I') { + result[i] = low++; + } else { + result[i] = high--; + } + } + result[s.size()] = low; + return result; + } +}; diff --git a/tests/501-1000/942. di-string-match/sol.cs b/tests/501-1000/942. di-string-match/sol.cs new file mode 100644 index 00000000..cb22668b --- /dev/null +++ b/tests/501-1000/942. di-string-match/sol.cs @@ -0,0 +1,15 @@ +public class Solution { + public int[] DiStringMatch(string s) { + int low = 0, high = s.Length; + int[] result = new int[s.Length + 1]; + for (int i = 0; i < s.Length; i++) { + if (s[i] == 'I') { + result[i] = low++; + } else { + result[i] = high--; + } + } + result[s.Length] = low; + return result; + } +} diff --git a/tests/501-1000/942. di-string-match/sol.dart b/tests/501-1000/942. di-string-match/sol.dart new file mode 100644 index 00000000..ac20a6f7 --- /dev/null +++ b/tests/501-1000/942. di-string-match/sol.dart @@ -0,0 +1,15 @@ +class Solution { + List diStringMatch(String s) { + int low = 0, high = s.length; + List result = List.filled(s.length + 1, 0); + for (int i = 0; i < s.length; i++) { + if (s[i] == 'I') { + result[i] = low++; + } else { + result[i] = high--; + } + } + result[s.length] = low; + return result; + } +} diff --git a/tests/501-1000/942. di-string-match/sol.go b/tests/501-1000/942. di-string-match/sol.go new file mode 100644 index 00000000..324a12fb --- /dev/null +++ b/tests/501-1000/942. di-string-match/sol.go @@ -0,0 +1,15 @@ +func diStringMatch(s string) []int { + low, high := 0, len(s) + result := make([]int, len(s)+1) + for i, c := range s { + if c == 'I' { + result[i] = low + low++ + } else { + result[i] = high + high-- + } + } + result[len(s)] = low + return result +} diff --git a/tests/501-1000/942. di-string-match/sol.java b/tests/501-1000/942. di-string-match/sol.java new file mode 100644 index 00000000..0448d6ed --- /dev/null +++ b/tests/501-1000/942. di-string-match/sol.java @@ -0,0 +1,15 @@ +class Solution { + public int[] diStringMatch(String s) { + int low = 0, high = s.length(); + int[] result = new int[s.length() + 1]; + for (int i = 0; i < s.length(); i++) { + if (s.charAt(i) == 'I') { + result[i] = low++; + } else { + result[i] = high--; + } + } + result[s.length()] = low; + return result; + } +} diff --git a/tests/501-1000/942. di-string-match/sol.kt b/tests/501-1000/942. di-string-match/sol.kt new file mode 100644 index 00000000..1cd1636e --- /dev/null +++ b/tests/501-1000/942. di-string-match/sol.kt @@ -0,0 +1,16 @@ +class Solution { + fun diStringMatch(s: String): IntArray { + var low = 0 + var high = s.length + val result = IntArray(s.length + 1) + for (i in s.indices) { + if (s[i] == 'I') { + result[i] = low++ + } else { + result[i] = high-- + } + } + result[s.length] = low + return result + } +} diff --git a/tests/501-1000/942. di-string-match/sol.py b/tests/501-1000/942. di-string-match/sol.py new file mode 100644 index 00000000..f6431795 --- /dev/null +++ b/tests/501-1000/942. di-string-match/sol.py @@ -0,0 +1,13 @@ +class Solution(object): + def diStringMatch(self, s): + low, high = 0, len(s) + result = [] + for c in s: + if c == "I": + result.append(low) + low += 1 + else: + result.append(high) + high -= 1 + result.append(low) # low == high + return result diff --git a/tests/501-1000/942. di-string-match/sol.py2 b/tests/501-1000/942. di-string-match/sol.py2 new file mode 100644 index 00000000..df76da3b --- /dev/null +++ b/tests/501-1000/942. di-string-match/sol.py2 @@ -0,0 +1,17 @@ +class Solution(object): + def diStringMatch(self, s): + """ + :type s: str + :rtype: List[int] + """ + low, high = 0, len(s) + result = [] + for c in s: + if c == 'I': + result.append(low) + low += 1 + else: + result.append(high) + high -= 1 + result.append(low) + return result diff --git a/tests/501-1000/942. di-string-match/sol.rb b/tests/501-1000/942. di-string-match/sol.rb new file mode 100644 index 00000000..c2d87ba3 --- /dev/null +++ b/tests/501-1000/942. di-string-match/sol.rb @@ -0,0 +1,17 @@ +# @param {String} s +# @return {Integer[]} +def di_string_match(s) + low, high = 0, s.length + result = [] + s.each_char do |c| + if c == 'I' + result << low + low += 1 + else + result << high + high -= 1 + end + end + result << low + result +end diff --git a/tests/501-1000/942. di-string-match/sol.rs b/tests/501-1000/942. di-string-match/sol.rs new file mode 100644 index 00000000..e2f60e6a --- /dev/null +++ b/tests/501-1000/942. di-string-match/sol.rs @@ -0,0 +1,18 @@ +impl Solution { + pub fn di_string_match(s: String) -> Vec { + let mut low = 0i32; + let mut high = s.len() as i32; + let mut result = vec![0; s.len() + 1]; + for (i, c) in s.chars().enumerate() { + if c == 'I' { + result[i] = low; + low += 1; + } else { + result[i] = high; + high -= 1; + } + } + result[s.len()] = low; + result + } +} diff --git a/tests/501-1000/942. di-string-match/sol.swift b/tests/501-1000/942. di-string-match/sol.swift new file mode 100644 index 00000000..bccbb257 --- /dev/null +++ b/tests/501-1000/942. di-string-match/sol.swift @@ -0,0 +1,18 @@ +class Solution { + func diStringMatch(_ s: String) -> [Int] { + var low = 0, high = s.count + var result = [Int](repeating: 0, count: s.count + 1) + let chars = Array(s) + for i in 0..= 10**9:\n continue\n \ + \ for j in range(n):\n if mask & (1 << j):\n\ + \ continue\n nxt = mask | (1 << j)\n\ + \ dp[nxt][j] = min(dp[nxt][j], dp[mask][i] + len(words[j])\ + \ - overlap[i][j])\n best = min(dp[(1 << n) - 1])\n return len(result)\ + \ == best\n" +seed: 943 +tests: + - name: case_1 + in: + words: + - alex + - loves + - leetcode + - name: case_2 + in: + words: + - catg + - ctaagt + - gcta + - ttca + - atgcatc + - name: case_3 + in: + words: + - ab + - bc + - cd + - name: case_4 + in: + words: + - abc + - bca + - aaa + - name: case_5 + in: + words: + - abc + - cde + - efg + - name: case_6 + in: + words: + - aa + - ab + - ba + - name: case_7 + in: + words: + - abc + - abc + - name: case_8 + in: + words: + - abcd + - bc + - cd + - name: case_9 + in: + words: + - bbddc + - bda + - cdbda + - name: case_10 + in: + words: + - ddcd + - bbbc + - aa + - name: case_11 + in: + words: + - a + - baac + - bbd + - aaabb + - name: case_12 + in: + words: + - cc + - d + - name: case_13 + in: + words: + - cacb + - bcd + - bdda + - d + - name: case_14 + in: + words: + - a + - bdbac + - adc + - name: case_15 + in: + words: + - bccca + - cc + - addd + - name: case_16 + in: + words: + - ada + - ca + - cbbd + - aadd + - name: case_17 + in: + words: + - b + - dcad + - bdcb + - name: case_18 + in: + words: + - bcb + - d + - ccdd + - b + - bbdd + - name: case_19 + in: + words: + - abc + - daaa + - ddd + - ddadc + - ccca + - name: case_20 + in: + words: + - acaa + - bd + - ab + - baad + - name: case_21 + in: + words: + - cdba + - cd + - bd + - name: case_22 + in: + words: + - a + - ba + - name: case_23 + in: + words: + - dbcab + - dacd + - cd + - dcba + - bada + - name: case_24 + in: + words: + - d + - c + - ddb + - bda + - name: case_25 + in: + words: + - cbb + - aba + - cdcca + - c + - name: case_26 + in: + words: + - cc + - bcd + - abbdc + - dbad + - name: case_27 + in: + words: + - d + - bcbcd + - a + - aa + - cc + - name: case_28 + in: + words: + - ba + - daada + - name: case_29 + in: + words: + - ccb + - b + - abc + - ba + - name: case_30 + in: + words: + - daba + - d + - name: case_31 + in: + words: + - db + - ccc + - b + - adc + - name: case_32 + in: + words: + - ddd + - ad + - ddb + - name: case_33 + in: + words: + - ad + - b + - c + - cac + - ad + - name: case_34 + in: + words: + - cbd + - caccc + - baab + - aadca + - name: case_35 + in: + words: + - baaab + - ddb + - adab diff --git a/tests/501-1000/943. find-the-shortest-superstring/sol.cpp b/tests/501-1000/943. find-the-shortest-superstring/sol.cpp new file mode 100644 index 00000000..e865b333 --- /dev/null +++ b/tests/501-1000/943. find-the-shortest-superstring/sol.cpp @@ -0,0 +1,52 @@ +class Solution { +public: + string shortestSuperstring(vector& words) { + int n = words.size(); + vector> overlap(n, vector(n, 0)); + + auto getOverlap = [](const string& a, const string& b) { + int maxOlap = 0; + for (int k = 1; k <= min(a.size(), b.size()); k++) { + if (a.substr(a.size() - k) == b.substr(0, k)) { + maxOlap = max(maxOlap, k); + } + } + return maxOlap; + }; + + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + if (i != j) { + overlap[i][j] = getOverlap(words[i], words[j]); + } + } + } + + vector> dp(1 << n, vector(n, "")); + for (int i = 0; i < n; i++) { + dp[1 << i][i] = words[i]; + } + + for (int mask = 0; mask < (1 << n); mask++) { + for (int u = 0; u < n; u++) { + if (!(mask & (1 << u))) continue; + for (int v = 0; v < n; v++) { + if (mask & (1 << v)) continue; + int newMask = mask | (1 << v); + string candidate = dp[mask][u] + words[v].substr(overlap[u][v]); + if (dp[newMask][v].empty() || candidate.size() < dp[newMask][v].size()) { + dp[newMask][v] = candidate; + } + } + } + } + + string shortest = ""; + for (const string& candidate : dp[(1 << n) - 1]) { + if (shortest.empty() || candidate.size() < shortest.size()) { + shortest = candidate; + } + } + return shortest; + } +}; diff --git a/tests/501-1000/943. find-the-shortest-superstring/sol.cs b/tests/501-1000/943. find-the-shortest-superstring/sol.cs new file mode 100644 index 00000000..870f87d8 --- /dev/null +++ b/tests/501-1000/943. find-the-shortest-superstring/sol.cs @@ -0,0 +1,52 @@ +public class Solution { + public string ShortestSuperstring(string[] words) { + int n = words.Length; + int[,] overlap = new int[n, n]; + + int GetOverlap(string a, string b) { + int maxOlap = 0; + for (int k = 1; k <= Math.Min(a.Length, b.Length); k++) { + if (a.Substring(a.Length - k) == b.Substring(0, k)) { + maxOlap = Math.Max(maxOlap, k); + } + } + return maxOlap; + } + + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + if (i != j) { + overlap[i, j] = GetOverlap(words[i], words[j]); + } + } + } + + string[,] dp = new string[1 << n, n]; + for (int i = 0; i < n; i++) { + dp[1 << i, i] = words[i]; + } + + for (int mask = 0; mask < (1 << n); mask++) { + for (int u = 0; u < n; u++) { + if ((mask & (1 << u)) == 0) continue; + for (int v = 0; v < n; v++) { + if ((mask & (1 << v)) != 0) continue; + int newMask = mask | (1 << v); + string candidate = dp[mask, u] + words[v].Substring(overlap[u, v]); + if (dp[newMask, v] == null || candidate.Length < dp[newMask, v].Length) { + dp[newMask, v] = candidate; + } + } + } + } + + string shortest = ""; + for (int i = 0; i < n; i++) { + string candidate = dp[(1 << n) - 1, i]; + if (shortest == "" || candidate.Length < shortest.Length) { + shortest = candidate; + } + } + return shortest; + } +} diff --git a/tests/501-1000/943. find-the-shortest-superstring/sol.dart b/tests/501-1000/943. find-the-shortest-superstring/sol.dart new file mode 100644 index 00000000..02c0cac3 --- /dev/null +++ b/tests/501-1000/943. find-the-shortest-superstring/sol.dart @@ -0,0 +1,51 @@ +class Solution { + String shortestSuperstring(List words) { + int n = words.length; + List> overlap = List.generate(n, (_) => List.filled(n, 0)); + + int getOverlap(String a, String b) { + int maxOlap = 0; + for (int k = 1; k <= a.length && k <= b.length; k++) { + if (a.substring(a.length - k) == b.substring(0, k)) { + if (k > maxOlap) maxOlap = k; + } + } + return maxOlap; + } + + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + if (i != j) { + overlap[i][j] = getOverlap(words[i], words[j]); + } + } + } + + List> dp = List.generate(1 << n, (_) => List.filled(n, "")); + for (int i = 0; i < n; i++) { + dp[1 << i][i] = words[i]; + } + + for (int mask = 0; mask < (1 << n); mask++) { + for (int u = 0; u < n; u++) { + if ((mask & (1 << u)) == 0) continue; + for (int v = 0; v < n; v++) { + if ((mask & (1 << v)) != 0) continue; + int newMask = mask | (1 << v); + String candidate = dp[mask][u] + words[v].substring(overlap[u][v]); + if (dp[newMask][v] == "" || candidate.length < dp[newMask][v].length) { + dp[newMask][v] = candidate; + } + } + } + } + + String shortest = ""; + for (String candidate in dp[(1 << n) - 1]) { + if (shortest == "" || candidate.length < shortest.length) { + shortest = candidate; + } + } + return shortest; + } +} diff --git a/tests/501-1000/943. find-the-shortest-superstring/sol.go b/tests/501-1000/943. find-the-shortest-superstring/sol.go new file mode 100644 index 00000000..69e1aee8 --- /dev/null +++ b/tests/501-1000/943. find-the-shortest-superstring/sol.go @@ -0,0 +1,62 @@ +func shortestSuperstring(words []string) string { + n := len(words) + overlap := make([][]int, n) + for i := range overlap { + overlap[i] = make([]int, n) + } + + getOverlap := func(a, b string) int { + maxOlap := 0 + for k := 1; k <= len(a) && k <= len(b); k++ { + if a[len(a)-k:] == b[:k] { + if k > maxOlap { + maxOlap = k + } + } + } + return maxOlap + } + + for i := 0; i < n; i++ { + for j := 0; j < n; j++ { + if i != j { + overlap[i][j] = getOverlap(words[i], words[j]) + } + } + } + + total := 1 << n + dp := make([][]string, total) + for i := range dp { + dp[i] = make([]string, n) + } + for i := 0; i < n; i++ { + dp[1<): String { + val n = words.size + val overlap = Array(n) { IntArray(n) } + + fun getOverlap(a: String, b: String): Int { + var maxOlap = 0 + for (k in 1..minOf(a.length, b.length)) { + if (a.substring(a.length - k) == b.substring(0, k)) { + maxOlap = maxOf(maxOlap, k) + } + } + return maxOlap + } + + for (i in 0 until n) { + for (j in 0 until n) { + if (i != j) { + overlap[i][j] = getOverlap(words[i], words[j]) + } + } + } + + val dp = Array(1 shl n) { arrayOfNulls(n) } + for (i in 0 until n) { + dp[1 shl i][i] = words[i] + } + + for (mask in 0 until (1 shl n)) { + for (u in 0 until n) { + if ((mask and (1 shl u)) == 0) continue + for (v in 0 until n) { + if ((mask and (1 shl v)) != 0) continue + val newMask = mask or (1 shl v) + val candidate = dp[mask][u]!! + words[v].substring(overlap[u][v]) + if (dp[newMask][v] == null || candidate.length < dp[newMask][v]!!.length) { + dp[newMask][v] = candidate + } + } + } + } + + var shortest = "" + for (candidate in dp[(1 shl n) - 1]) { + if (shortest.isEmpty() || candidate!!.length < shortest.length) { + shortest = candidate!! + } + } + return shortest + } +} diff --git a/tests/501-1000/943. find-the-shortest-superstring/sol.py b/tests/501-1000/943. find-the-shortest-superstring/sol.py new file mode 100644 index 00000000..71c538b6 --- /dev/null +++ b/tests/501-1000/943. find-the-shortest-superstring/sol.py @@ -0,0 +1,41 @@ +from typing import List + + +class Solution: + def shortestSuperstring(self, words: List[str]) -> str: + n = len(words) + overlap = [[0] * n for _ in range(n)] + + def get_overlap(a, b): + max_olap = 0 + for k in range(1, min(len(a), len(b)) + 1): + if a[-k:] == b[:k]: + max_olap = max(max_olap, k) + return max_olap + + for i in range(n): + for j in range(n): + if i != j: + overlap[i][j] = get_overlap(words[i], words[j]) + + dp = [[""] * n for i in range(1 << n)] + for i in range(n): + dp[1 << i][i] = words[i] + + for mask in range(1 << n): + for u in range(n): + if not (mask & 1 << u): + continue + for v in range(n): + if mask & (1 << v): + continue + new_mask = mask | (1 << v) + candidate = dp[mask][u] + words[v][overlap[u][v] :] + if dp[new_mask][v] == "" or len(candidate) < len(dp[new_mask][v]): + dp[new_mask][v] = candidate + + short_string = "" + for candidate in dp[(1 << n) - 1]: + if short_string == "" or len(candidate) < len(short_string): + short_string = candidate + return short_string diff --git a/tests/501-1000/943. find-the-shortest-superstring/sol.py2 b/tests/501-1000/943. find-the-shortest-superstring/sol.py2 new file mode 100644 index 00000000..b9cc3b38 --- /dev/null +++ b/tests/501-1000/943. find-the-shortest-superstring/sol.py2 @@ -0,0 +1,42 @@ +class Solution(object): + def shortestSuperstring(self, words): + """ + :type words: List[str] + :rtype: str + """ + n = len(words) + overlap = [[0] * n for _ in range(n)] + + def get_overlap(a, b): + max_olap = 0 + for k in range(1, min(len(a), len(b)) + 1): + if a[-k:] == b[:k]: + max_olap = max(max_olap, k) + return max_olap + + for i in range(n): + for j in range(n): + if i != j: + overlap[i][j] = get_overlap(words[i], words[j]) + + dp = [[""] * n for _ in range(1 << n)] + for i in range(n): + dp[1 << i][i] = words[i] + + for mask in range(1 << n): + for u in range(n): + if not (mask & (1 << u)): + continue + for v in range(n): + if mask & (1 << v): + continue + new_mask = mask | (1 << v) + candidate = dp[mask][u] + words[v][overlap[u][v]:] + if dp[new_mask][v] == "" or len(candidate) < len(dp[new_mask][v]): + dp[new_mask][v] = candidate + + short_string = "" + for candidate in dp[(1 << n) - 1]: + if short_string == "" or len(candidate) < len(short_string): + short_string = candidate + return short_string diff --git a/tests/501-1000/943. find-the-shortest-superstring/sol.rb b/tests/501-1000/943. find-the-shortest-superstring/sol.rb new file mode 100644 index 00000000..e786c004 --- /dev/null +++ b/tests/501-1000/943. find-the-shortest-superstring/sol.rb @@ -0,0 +1,51 @@ +# @param {String[]} words +# @return {String} +def shortest_superstring(words) + n = words.length + overlap = Array.new(n) { Array.new(n, 0) } + + get_overlap = lambda do |a, b| + max_olap = 0 + (1..[a.length, b.length].min).each do |k| + if a[-k..-1] == b[0...k] + max_olap = [max_olap, k].max + end + end + max_olap + end + + (0...n).each do |i| + (0...n).each do |j| + if i != j + overlap[i][j] = get_overlap.call(words[i], words[j]) + end + end + end + + dp = Array.new(1 << n) { Array.new(n, "") } + (0...n).each do |i| + dp[1 << i][i] = words[i] + end + + (0...(1 << n)).each do |mask| + (0...n).each do |u| + next if (mask & (1 << u)) == 0 + (0...n).each do |v| + next if (mask & (1 << v)) != 0 + new_mask = mask | (1 << v) + candidate = dp[mask][u] + words[v][overlap[u][v]..-1] + if dp[new_mask][v] == "" || candidate.length < dp[new_mask][v].length + dp[new_mask][v] = candidate + end + end + end + end + + short_string = "" + dp[(1 << n) - 1].each do |candidate| + if short_string == "" || candidate.length < short_string.length + short_string = candidate + end + end + short_string +end diff --git a/tests/501-1000/943. find-the-shortest-superstring/sol.rs b/tests/501-1000/943. find-the-shortest-superstring/sol.rs new file mode 100644 index 00000000..1805bf7b --- /dev/null +++ b/tests/501-1000/943. find-the-shortest-superstring/sol.rs @@ -0,0 +1,56 @@ +impl Solution { + pub fn shortest_superstring(words: Vec) -> String { + let n = words.len(); + let mut overlap = vec![vec![0; n]; n]; + + fn get_overlap(a: &str, b: &str) -> usize { + let mut max_olap = 0; + for k in 1..=std::cmp::min(a.len(), b.len()) { + if a[a.len()-k..] == b[..k] { + max_olap = std::cmp::max(max_olap, k); + } + } + max_olap + } + + for i in 0..n { + for j in 0..n { + if i != j { + overlap[i][j] = get_overlap(&words[i], &words[j]); + } + } + } + + let total = 1 << n; + let mut dp = vec![vec![String::new(); n]; total]; + for i in 0..n { + dp[1 << i][i] = words[i].clone(); + } + + for mask in 0..total { + for u in 0..n { + if mask & (1 << u) == 0 { + continue; + } + for v in 0..n { + if mask & (1 << v) != 0 { + continue; + } + let new_mask = mask | (1 << v); + let candidate = format!("{}{}", dp[mask][u], &words[v][overlap[u][v]..]); + if dp[new_mask][v].is_empty() || candidate.len() < dp[new_mask][v].len() { + dp[new_mask][v] = candidate; + } + } + } + } + + let mut shortest = String::new(); + for candidate in &dp[total - 1] { + if shortest.is_empty() || candidate.len() < shortest.len() { + shortest = candidate.clone(); + } + } + shortest + } +} diff --git a/tests/501-1000/943. find-the-shortest-superstring/sol.swift b/tests/501-1000/943. find-the-shortest-superstring/sol.swift new file mode 100644 index 00000000..17542dc4 --- /dev/null +++ b/tests/501-1000/943. find-the-shortest-superstring/sol.swift @@ -0,0 +1,53 @@ +class Solution { + func shortestSuperstring(_ words: [String]) -> String { + let n = words.count + var overlap = Array(repeating: Array(repeating: 0, count: n), count: n) + + func getOverlap(_ a: String, _ b: String) -> Int { + var maxOlap = 0 + let aChars = Array(a) + let bChars = Array(b) + for k in 1...min(a.count, b.count) { + if aChars.suffix(k) == bChars.prefix(k) { + maxOlap = max(maxOlap, k) + } + } + return maxOlap + } + + for i in 0.. Array(n).fill(0)); + + function getOverlap(a: string, b: string): number { + let maxOlap = 0; + for (let k = 1; k <= Math.min(a.length, b.length); k++) { + if (a.substring(a.length - k) === b.substring(0, k)) { + maxOlap = Math.max(maxOlap, k); + } + } + return maxOlap; + } + + for (let i = 0; i < n; i++) { + for (let j = 0; j < n; j++) { + if (i !== j) { + overlap[i][j] = getOverlap(words[i], words[j]); + } + } + } + + const dp: string[][] = Array.from({ length: 1 << n }, () => + Array(n).fill(""), + ); + for (let i = 0; i < n; i++) { + dp[1 << i][i] = words[i]; + } + + for (let mask = 0; mask < 1 << n; mask++) { + for (let u = 0; u < n; u++) { + if (!(mask & (1 << u))) continue; + for (let v = 0; v < n; v++) { + if (mask & (1 << v)) continue; + const newMask = mask | (1 << v); + const candidate = dp[mask][u] + words[v].substring(overlap[u][v]); + if (dp[newMask][v] === "" || candidate.length < dp[newMask][v].length) { + dp[newMask][v] = candidate; + } + } + } + } + + let shortest = ""; + for (const candidate of dp[(1 << n) - 1]) { + if (shortest === "" || candidate.length < shortest.length) { + shortest = candidate; + } + } + return shortest; +} diff --git a/tests/501-1000/944. delete-columns-to-make-sorted/manifest.yaml b/tests/501-1000/944. delete-columns-to-make-sorted/manifest.yaml new file mode 100644 index 00000000..f007ee41 --- /dev/null +++ b/tests/501-1000/944. delete-columns-to-make-sorted/manifest.yaml @@ -0,0 +1,318 @@ +entry: + id: 944 + title: delete-columns-to-make-sorted + params: + strs: + type: array + items: + type: string + call: + cpp: Solution().minDeletionSize({strs}) + rust: Solution::min_deletion_size({strs}) + python3: Solution().minDeletionSize({strs}) + python2: Solution().minDeletionSize({strs}) + ruby: min_deletion_size({strs}) + java: new Solution().minDeletionSize({strs}) + csharp: new Solution().MinDeletionSize({strs}) + kotlin: Solution().minDeletionSize({strs}) + go: minDeletionSize({strs}) + dart: Solution().minDeletionSize({strs}) + swift: Solution().minDeletionSize({strs}) + typescript: minDeletionSize({strs}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 944 +tests: + - name: case_1 + in: + strs: + - bd + - dc + out: 1 + - name: case_2 + in: + strs: + - d + - a + - b + - a + - a + - a + out: 1 + - name: case_3 + in: + strs: + - bacdacbb + - aaaccbcd + - dddbbaba + - badaacca + - bbcbdbca + - ddaaadab + out: 8 + - name: case_4 + in: + strs: + - cb + - ad + out: 1 + - name: case_5 + in: + strs: + - bcbaaddb + out: 0 + - name: case_6 + in: + strs: + - dbcbbdbc + out: 0 + - name: case_7 + in: + strs: + - cbacdcb + - dbbddcc + - dcabaab + - bbdccba + - bbbccdb + out: 7 + - name: case_8 + in: + strs: + - bbbdbdcb + - cadbbadc + - caaccdbb + - bbbbaddd + - bbaddddc + out: 8 + - name: case_9 + in: + strs: + - c + - b + out: 1 + - name: case_10 + in: + strs: + - cbd + out: 0 + - name: case_11 + in: + strs: + - db + - ab + out: 1 + - name: case_12 + in: + strs: + - cb + - cb + out: 0 + - name: case_13 + in: + strs: + - a + - a + - b + - b + - b + - a + out: 1 + - name: case_14 + in: + strs: + - bdbac + - bbadb + - abbcd + out: 5 + - name: case_15 + in: + strs: + - cdacdcac + - dabbccbc + out: 3 + - name: case_16 + in: + strs: + - aa + - dd + - cd + - da + out: 2 + - name: case_17 + in: + strs: + - c + out: 0 + - name: case_18 + in: + strs: + - a + - d + - a + - c + - b + - b + - b + out: 1 + - name: case_19 + in: + strs: + - ddacda + - dbaacc + - cdbcdd + out: 4 + - name: case_20 + in: + strs: + - bb + - aa + - dc + - cb + - bb + - ac + - cc + - cc + out: 2 + - name: case_21 + in: + strs: + - b + out: 0 + - name: case_22 + in: + strs: + - cdbccdcb + - abcadada + - cacbbcba + - cdbacbca + out: 8 + - name: case_23 + in: + strs: + - dddcbd + - acddaa + - addbac + - badaba + - aabcac + out: 6 + - name: case_24 + in: + strs: + - ddaccab + - bbcddbb + - babccbd + - acbdbba + out: 6 + - name: case_25 + in: + strs: + - aadc + - dbbd + - dbab + - daaa + - bbbd + - cacd + out: 4 + - name: case_26 + in: + strs: + - cdbaab + - bbaada + - bcbaaa + - bacbcb + out: 5 + - name: case_27 + in: + strs: + - cbcd + - cdbb + - dcdd + - aadb + - bcda + - aadd + - abda + - acda + out: 4 + - name: case_28 + in: + strs: + - baa + - bda + - aaa + - dad + - bdb + - aad + - dda + - adb + out: 3 + - name: case_29 + in: + strs: + - dbbdbbd + - dcbcbca + - bbbbacd + - adcddcc + - babcdbc + out: 7 + - name: case_30 + in: + strs: + - ad + - cc + - aa + - dd + out: 2 + - name: case_31 + in: + strs: + - baddbb + - bdcdcb + - cbdddc + - cbccab + - bdaddb + out: 6 + - name: case_32 + in: + strs: + - acba + - bbcb + - daab + - adcc + - babd + - bcbd + out: 3 + - name: case_33 + in: + strs: + - baddcc + - ccbddc + - bdbaca + - daccbc + - abcaca + out: 6 + - name: case_34 + in: + strs: + - ac + - ab + - dc + - dc + - bc + - cc + out: 2 + - name: case_35 + in: + strs: + - dabbc + - dddbd + - dcabd + - acddb + - abdcd + - dcaab + out: 5 diff --git a/tests/501-1000/944. delete-columns-to-make-sorted/sol.cpp b/tests/501-1000/944. delete-columns-to-make-sorted/sol.cpp new file mode 100644 index 00000000..d4c3153b --- /dev/null +++ b/tests/501-1000/944. delete-columns-to-make-sorted/sol.cpp @@ -0,0 +1,19 @@ +class Solution { +public: + int minDeletionSize(vector& strs) { + int rows = strs.size(); + int cols = strs[0].size(); + int deletions = 0; + + for (int c = 0; c < cols; c++) { + for (int r = 0; r < rows - 1; r++) { + if (strs[r][c] > strs[r + 1][c]) { + deletions++; + break; + } + } + } + + return deletions; + } +}; diff --git a/tests/501-1000/944. delete-columns-to-make-sorted/sol.cs b/tests/501-1000/944. delete-columns-to-make-sorted/sol.cs new file mode 100644 index 00000000..3c0fc89a --- /dev/null +++ b/tests/501-1000/944. delete-columns-to-make-sorted/sol.cs @@ -0,0 +1,18 @@ +public class Solution { + public int MinDeletionSize(string[] strs) { + int rows = strs.Length; + int cols = strs[0].Length; + int deletions = 0; + + for (int c = 0; c < cols; c++) { + for (int r = 0; r < rows - 1; r++) { + if (strs[r][c] > strs[r + 1][c]) { + deletions++; + break; + } + } + } + + return deletions; + } +} diff --git a/tests/501-1000/944. delete-columns-to-make-sorted/sol.dart b/tests/501-1000/944. delete-columns-to-make-sorted/sol.dart new file mode 100644 index 00000000..e3e8b0bf --- /dev/null +++ b/tests/501-1000/944. delete-columns-to-make-sorted/sol.dart @@ -0,0 +1,18 @@ +class Solution { + int minDeletionSize(List strs) { + int rows = strs.length; + int cols = strs[0].length; + int deletions = 0; + + for (int c = 0; c < cols; c++) { + for (int r = 0; r < rows - 1; r++) { + if (strs[r][c].codeUnitAt(0) > strs[r + 1][c].codeUnitAt(0)) { + deletions++; + break; + } + } + } + + return deletions; + } +} diff --git a/tests/501-1000/944. delete-columns-to-make-sorted/sol.go b/tests/501-1000/944. delete-columns-to-make-sorted/sol.go new file mode 100644 index 00000000..a5901f40 --- /dev/null +++ b/tests/501-1000/944. delete-columns-to-make-sorted/sol.go @@ -0,0 +1,16 @@ +func minDeletionSize(strs []string) int { + rows := len(strs) + cols := len(strs[0]) + deletions := 0 + + for c := 0; c < cols; c++ { + for r := 0; r < rows-1; r++ { + if strs[r][c] > strs[r+1][c] { + deletions++ + break + } + } + } + + return deletions +} diff --git a/tests/501-1000/944. delete-columns-to-make-sorted/sol.java b/tests/501-1000/944. delete-columns-to-make-sorted/sol.java new file mode 100644 index 00000000..ff5edacd --- /dev/null +++ b/tests/501-1000/944. delete-columns-to-make-sorted/sol.java @@ -0,0 +1,18 @@ +class Solution { + public int minDeletionSize(String[] strs) { + int rows = strs.length; + int cols = strs[0].length(); + int deletions = 0; + + for (int c = 0; c < cols; c++) { + for (int r = 0; r < rows - 1; r++) { + if (strs[r].charAt(c) > strs[r + 1].charAt(c)) { + deletions++; + break; + } + } + } + + return deletions; + } +} diff --git a/tests/501-1000/944. delete-columns-to-make-sorted/sol.kt b/tests/501-1000/944. delete-columns-to-make-sorted/sol.kt new file mode 100644 index 00000000..0074787a --- /dev/null +++ b/tests/501-1000/944. delete-columns-to-make-sorted/sol.kt @@ -0,0 +1,18 @@ +class Solution { + fun minDeletionSize(strs: Array): Int { + val rows = strs.size + val cols = strs[0].length + var deletions = 0 + + for (c in 0 until cols) { + for (r in 0 until rows - 1) { + if (strs[r][c] > strs[r + 1][c]) { + deletions++ + break + } + } + } + + return deletions + } +} diff --git a/tests/501-1000/944. delete-columns-to-make-sorted/sol.py b/tests/501-1000/944. delete-columns-to-make-sorted/sol.py new file mode 100644 index 00000000..4c49fd87 --- /dev/null +++ b/tests/501-1000/944. delete-columns-to-make-sorted/sol.py @@ -0,0 +1,13 @@ +class Solution: + def minDeletionSize(self, strs): + rows = len(strs) + cols = len(strs[0]) + deletions = 0 + + for c in range(cols): + for r in range(rows - 1): + if strs[r][c] > strs[r + 1][c]: + deletions += 1 + break + + return deletions diff --git a/tests/501-1000/944. delete-columns-to-make-sorted/sol.py2 b/tests/501-1000/944. delete-columns-to-make-sorted/sol.py2 new file mode 100644 index 00000000..29b3f323 --- /dev/null +++ b/tests/501-1000/944. delete-columns-to-make-sorted/sol.py2 @@ -0,0 +1,17 @@ +class Solution(object): + def minDeletionSize(self, strs): + """ + :type strs: List[str] + :rtype: int + """ + rows = len(strs) + cols = len(strs[0]) + deletions = 0 + + for c in range(cols): + for r in range(rows - 1): + if strs[r][c] > strs[r + 1][c]: + deletions += 1 + break + + return deletions diff --git a/tests/501-1000/944. delete-columns-to-make-sorted/sol.rb b/tests/501-1000/944. delete-columns-to-make-sorted/sol.rb new file mode 100644 index 00000000..671db2f7 --- /dev/null +++ b/tests/501-1000/944. delete-columns-to-make-sorted/sol.rb @@ -0,0 +1,18 @@ +# @param {String[]} strs +# @return {Integer} +def min_deletion_size(strs) + rows = strs.length + cols = strs[0].length + deletions = 0 + + (0...cols).each do |c| + (0...rows - 1).each do |r| + if strs[r][c] > strs[r + 1][c] + deletions += 1 + break + end + end + end + + deletions +end diff --git a/tests/501-1000/944. delete-columns-to-make-sorted/sol.rs b/tests/501-1000/944. delete-columns-to-make-sorted/sol.rs new file mode 100644 index 00000000..17c5081b --- /dev/null +++ b/tests/501-1000/944. delete-columns-to-make-sorted/sol.rs @@ -0,0 +1,20 @@ +impl Solution { + pub fn min_deletion_size(strs: Vec) -> i32 { + let rows = strs.len(); + let cols = strs[0].len(); + let mut deletions = 0; + + let strs: Vec> = strs.into_iter().map(|s| s.chars().collect()).collect(); + + for c in 0..cols { + for r in 0..rows - 1 { + if strs[r][c] > strs[r + 1][c] { + deletions += 1; + break; + } + } + } + + deletions + } +} diff --git a/tests/501-1000/944. delete-columns-to-make-sorted/sol.swift b/tests/501-1000/944. delete-columns-to-make-sorted/sol.swift new file mode 100644 index 00000000..8f3602c1 --- /dev/null +++ b/tests/501-1000/944. delete-columns-to-make-sorted/sol.swift @@ -0,0 +1,19 @@ +class Solution { + func minDeletionSize(_ strs: [String]) -> Int { + let rows = strs.count + let cols = strs[0].count + var deletions = 0 + + let arr = strs.map { Array($0) } + for c in 0.. arr[r + 1][c] { + deletions += 1 + break + } + } + } + + return deletions + } +} diff --git a/tests/501-1000/944. delete-columns-to-make-sorted/sol.ts b/tests/501-1000/944. delete-columns-to-make-sorted/sol.ts new file mode 100644 index 00000000..88f3e6fb --- /dev/null +++ b/tests/501-1000/944. delete-columns-to-make-sorted/sol.ts @@ -0,0 +1,16 @@ +function minDeletionSize(strs: string[]): number { + const rows = strs.length; + const cols = strs[0].length; + let deletions = 0; + + for (let c = 0; c < cols; c++) { + for (let r = 0; r < rows - 1; r++) { + if (strs[r][c] > strs[r + 1][c]) { + deletions++; + break; + } + } + } + + return deletions; +} diff --git a/tests/501-1000/945. minimum-increment-to-make-array-unique/manifest.yaml b/tests/501-1000/945. minimum-increment-to-make-array-unique/manifest.yaml new file mode 100644 index 00000000..5be2d25a --- /dev/null +++ b/tests/501-1000/945. minimum-increment-to-make-array-unique/manifest.yaml @@ -0,0 +1,379 @@ +entry: + id: 945 + title: minimum-increment-to-make-array-unique + params: + nums: + type: array + items: + type: int + call: + cpp: Solution().minIncrementForUnique({nums}) + rust: Solution::min_increment_for_unique({nums}) + python3: Solution().minIncrementForUnique({nums}) + python2: Solution().minIncrementForUnique({nums}) + ruby: min_increment_for_unique({nums}) + java: new Solution().minIncrementForUnique({nums}) + csharp: new Solution().MinIncrementForUnique({nums}) + kotlin: Solution().minIncrementForUnique({nums}) + go: minIncrementForUnique({nums}) + dart: Solution().minIncrementForUnique({nums}) + swift: Solution().minIncrementForUnique({nums}) + typescript: minIncrementForUnique({nums}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 945 +tests: + - name: case_1 + in: + nums: + - 1 + - 2 + - 2 + out: 1 + - name: case_2 + in: + nums: + - 3 + - 2 + - 1 + - 2 + - 1 + - 7 + out: 6 + - name: case_3 + in: + nums: + - 0 + out: 0 + - name: case_4 + in: + nums: + - 0 + - 0 + - 0 + - 0 + out: 6 + - name: case_5 + in: + nums: + - 1 + - 2 + - 3 + - 5 + - 16 + - 17 + - 18 + out: 0 + - name: case_6 + in: + nums: + - 5 + - 10 + - 3 + - 3 + - 3 + - 2 + - 7 + out: 4 + - name: case_7 + in: + nums: + - 9 + - 7 + - 4 + - 1 + - 6 + - 6 + - 8 + - 7 + out: 8 + - name: case_8 + in: + nums: + - 0 + - 7 + - 8 + - 3 + - 9 + - 9 + out: 1 + - name: case_9 + in: + nums: + - 5 + - 1 + - 2 + - 10 + - 9 + - 4 + - 2 + - 8 + - 3 + - 0 + - 5 + out: 6 + - name: case_10 + in: + nums: + - 2 + - 6 + - 8 + out: 0 + - name: case_11 + in: + nums: + - 6 + - 10 + - 2 + out: 0 + - name: case_12 + in: + nums: + - 5 + - 0 + - 5 + - 9 + - 4 + - 2 + out: 1 + - name: case_13 + in: + nums: + - 3 + - 8 + - 8 + - 6 + - 2 + - 5 + - 2 + - 4 + - 0 + - 2 + out: 14 + - name: case_14 + in: + nums: + - 4 + - 9 + out: 0 + - name: case_15 + in: + nums: + - 7 + - 2 + - 5 + - 2 + - 2 + - 10 + - 10 + - 4 + out: 6 + - name: case_16 + in: + nums: + - 8 + - 1 + - 3 + - 0 + - 9 + out: 0 + - name: case_17 + in: + nums: + - 5 + - 4 + - 9 + - 5 + out: 1 + - name: case_18 + in: + nums: + - 1 + - 8 + - 6 + - 6 + - 0 + - 9 + - 3 + - 3 + - 2 + - 3 + out: 4 + - name: case_19 + in: + nums: + - 0 + - 0 + - 6 + - 5 + - 0 + - 5 + - 10 + - 9 + - 7 + - 9 + - 3 + - 4 + out: 8 + - name: case_20 + in: + nums: + - 6 + - 8 + - 6 + - 5 + - 9 + - 0 + - 6 + - 1 + - 0 + - 6 + - 5 + out: 19 + - name: case_21 + in: + nums: + - 0 + - 3 + - 1 + - 4 + - 7 + - 9 + - 8 + - 4 + - 8 + out: 3 + - name: case_22 + in: + nums: + - 9 + - 0 + - 3 + - 9 + - 2 + - 2 + - 3 + out: 5 + - name: case_23 + in: + nums: + - 4 + - 4 + - 4 + - 4 + - 2 + - 9 + - 3 + - 8 + out: 6 + - name: case_24 + in: + nums: + - 5 + - 1 + - 6 + - 9 + - 5 + out: 2 + - name: case_25 + in: + nums: + - 2 + - 3 + - 10 + - 4 + - 1 + out: 0 + - name: case_26 + in: + nums: + - 3 + out: 0 + - name: case_27 + in: + nums: + - 0 + - 9 + - 6 + - 4 + - 10 + - 1 + - 4 + - 2 + - 6 + - 7 + - 6 + - 3 + out: 8 + - name: case_28 + in: + nums: + - 0 + out: 0 + - name: case_29 + in: + nums: + - 10 + - 7 + - 6 + out: 0 + - name: case_30 + in: + nums: + - 4 + - 8 + - 7 + - 4 + - 1 + - 1 + - 2 + - 10 + - 8 + - 0 + - 9 + - 10 + out: 8 + - name: case_31 + in: + nums: + - 2 + out: 0 + - name: case_32 + in: + nums: + - 9 + out: 0 + - name: case_33 + in: + nums: + - 6 + - 9 + - 2 + out: 0 + - name: case_34 + in: + nums: + - 10 + - 0 + - 0 + - 8 + out: 1 + - name: case_35 + in: + nums: + - 5 + - 9 + - 0 + - 5 + - 3 + - 6 + - 8 + - 7 + out: 5 diff --git a/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.cpp b/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.cpp new file mode 100644 index 00000000..0fb72346 --- /dev/null +++ b/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.cpp @@ -0,0 +1,15 @@ +class Solution { +public: + int minIncrementForUnique(vector& nums) { + sort(nums.begin(), nums.end()); + int res = 0; + for (int i = 1; i < nums.size(); i++) { + if (nums[i] <= nums[i - 1]) { + int target = nums[i - 1] + 1; + res += target - nums[i]; + nums[i] = target; + } + } + return res; + } +}; diff --git a/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.cs b/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.cs new file mode 100644 index 00000000..2c56c6f0 --- /dev/null +++ b/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.cs @@ -0,0 +1,14 @@ +public class Solution { + public int MinIncrementForUnique(int[] nums) { + Array.Sort(nums); + int res = 0; + for (int i = 1; i < nums.Length; i++) { + if (nums[i] <= nums[i - 1]) { + int target = nums[i - 1] + 1; + res += target - nums[i]; + nums[i] = target; + } + } + return res; + } +} diff --git a/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.dart b/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.dart new file mode 100644 index 00000000..c424eee8 --- /dev/null +++ b/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.dart @@ -0,0 +1,14 @@ +class Solution { + int minIncrementForUnique(List nums) { + nums.sort(); + int res = 0; + for (int i = 1; i < nums.length; i++) { + if (nums[i] <= nums[i - 1]) { + int target = nums[i - 1] + 1; + res += target - nums[i]; + nums[i] = target; + } + } + return res; + } +} diff --git a/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.go b/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.go new file mode 100644 index 00000000..4d18f602 --- /dev/null +++ b/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.go @@ -0,0 +1,12 @@ +func minIncrementForUnique(nums []int) int { + sort.Ints(nums) + res := 0 + for i := 1; i < len(nums); i++ { + if nums[i] <= nums[i-1] { + target := nums[i-1] + 1 + res += target - nums[i] + nums[i] = target + } + } + return res +} diff --git a/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.java b/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.java new file mode 100644 index 00000000..b5dec7db --- /dev/null +++ b/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.java @@ -0,0 +1,14 @@ +class Solution { + public int minIncrementForUnique(int[] nums) { + java.util.Arrays.sort(nums); + int res = 0; + for (int i = 1; i < nums.length; i++) { + if (nums[i] <= nums[i - 1]) { + int target = nums[i - 1] + 1; + res += target - nums[i]; + nums[i] = target; + } + } + return res; + } +} diff --git a/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.kt b/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.kt new file mode 100644 index 00000000..9b6c8644 --- /dev/null +++ b/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.kt @@ -0,0 +1,14 @@ +class Solution { + fun minIncrementForUnique(nums: IntArray): Int { + nums.sort() + var res = 0 + for (i in 1 until nums.size) { + if (nums[i] <= nums[i - 1]) { + val target = nums[i - 1] + 1 + res += target - nums[i] + nums[i] = target + } + } + return res + } +} diff --git a/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.py b/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.py new file mode 100644 index 00000000..33d4b290 --- /dev/null +++ b/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.py @@ -0,0 +1,14 @@ +from typing import List + + +class Solution: + def minIncrementForUnique(self, nums: List[int]) -> int: + n = len(nums) + nums.sort() + res = 0 + for i in range(n): + if i > 0 and nums[i] <= nums[i - 1]: + target = nums[i - 1] + 1 + res += target - nums[i] + nums[i] = target + return res diff --git a/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.py2 b/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.py2 new file mode 100644 index 00000000..81cdcf08 --- /dev/null +++ b/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.py2 @@ -0,0 +1,14 @@ +class Solution(object): + def minIncrementForUnique(self, nums): + """ + :type nums: List[int] + :rtype: int + """ + nums.sort() + res = 0 + for i in range(1, len(nums)): + if nums[i] <= nums[i-1]: + target = nums[i-1] + 1 + res += target - nums[i] + nums[i] = target + return res diff --git a/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.rb b/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.rb new file mode 100644 index 00000000..4c8f495d --- /dev/null +++ b/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.rb @@ -0,0 +1,14 @@ +# @param {Integer[]} nums +# @return {Integer} +def min_increment_for_unique(nums) + nums.sort! + res = 0 + (1...nums.length).each do |i| + if nums[i] <= nums[i-1] + target = nums[i-1] + 1 + res += target - nums[i] + nums[i] = target + end + end + res +end diff --git a/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.rs b/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.rs new file mode 100644 index 00000000..0767451a --- /dev/null +++ b/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.rs @@ -0,0 +1,14 @@ +impl Solution { + pub fn min_increment_for_unique(mut nums: Vec) -> i32 { + nums.sort_unstable(); + let mut res = 0; + for i in 1..nums.len() { + if nums[i] <= nums[i - 1] { + let target = nums[i - 1] + 1; + res += target - nums[i]; + nums[i] = target; + } + } + res + } +} diff --git a/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.swift b/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.swift new file mode 100644 index 00000000..b2c669b5 --- /dev/null +++ b/tests/501-1000/945. minimum-increment-to-make-array-unique/sol.swift @@ -0,0 +1,14 @@ +class Solution { + func minIncrementForUnique(_ nums: [Int]) -> Int { + var nums = nums.sorted() + var res = 0 + for i in 1.. a - b); + let res = 0; + for (let i = 1; i < nums.length; i++) { + if (nums[i] <= nums[i - 1]) { + const target = nums[i - 1] + 1; + res += target - nums[i]; + nums[i] = target; + } + } + return res; +} diff --git a/tests/501-1000/946. validate-stack-sequences/manifest.yaml b/tests/501-1000/946. validate-stack-sequences/manifest.yaml new file mode 100644 index 00000000..839f499d --- /dev/null +++ b/tests/501-1000/946. validate-stack-sequences/manifest.yaml @@ -0,0 +1,523 @@ +entry: + id: 946 + title: validate-stack-sequences + params: + pushed: + type: array + items: + type: int + popped: + type: array + items: + type: int + call: + cpp: Solution().validateStackSequences({pushed}, {popped}) + rust: Solution::validate_stack_sequences({pushed}, {popped}) + python3: Solution().validateStackSequences({pushed}, {popped}) + python2: Solution().validateStackSequences({pushed}, {popped}) + ruby: validate_stack_sequences({pushed}, {popped}) + java: new Solution().validateStackSequences({pushed}, {popped}) + csharp: new Solution().ValidateStackSequences({pushed}, {popped}) + kotlin: Solution().validateStackSequences({pushed}, {popped}) + go: validateStackSequences({pushed}, {popped}) + dart: Solution().validateStackSequences({pushed}, {popped}) + swift: Solution().validateStackSequences({pushed}, {popped}) + typescript: validateStackSequences({pushed}, {popped}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 946 +tests: + - name: case_1 + in: + pushed: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + popped: + - 1 + - 2 + - 6 + - 4 + - 7 + - 5 + - 3 + out: false + - name: case_2 + in: + pushed: + - 1 + - 2 + popped: + - 2 + - 1 + out: true + - name: case_3 + in: + pushed: + - 1 + - 2 + - 3 + - 4 + popped: + - 4 + - 1 + - 3 + - 2 + out: false + - name: case_4 + in: + pushed: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + popped: + - 5 + - 4 + - 2 + - 8 + - 9 + - 3 + - 6 + - 7 + - 1 + out: false + - name: case_5 + in: + pushed: + - 1 + popped: + - 1 + out: true + - name: case_6 + in: + pushed: + - 1 + popped: + - 1 + out: true + - name: case_7 + in: + pushed: + - 1 + - 2 + - 3 + popped: + - 1 + - 2 + - 3 + out: true + - name: case_8 + in: + pushed: + - 1 + - 2 + - 3 + - 4 + popped: + - 3 + - 1 + - 2 + - 4 + out: false + - name: case_9 + in: + pushed: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + popped: + - 2 + - 9 + - 6 + - 1 + - 5 + - 7 + - 3 + - 8 + - 4 + out: false + - name: case_10 + in: + pushed: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + popped: + - 3 + - 2 + - 1 + - 6 + - 5 + - 4 + - 7 + - 8 + out: true + - name: case_11 + in: + pushed: + - 1 + - 2 + - 3 + popped: + - 2 + - 3 + - 1 + out: true + - name: case_12 + in: + pushed: + - 1 + - 2 + popped: + - 2 + - 1 + out: true + - name: case_13 + in: + pushed: + - 1 + - 2 + - 3 + - 4 + - 5 + popped: + - 4 + - 5 + - 2 + - 1 + - 3 + out: false + - name: case_14 + in: + pushed: + - 1 + - 2 + - 3 + - 4 + - 5 + popped: + - 2 + - 3 + - 1 + - 5 + - 4 + out: true + - name: case_15 + in: + pushed: + - 1 + - 2 + - 3 + - 4 + popped: + - 3 + - 4 + - 2 + - 1 + out: true + - name: case_16 + in: + pushed: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + popped: + - 5 + - 2 + - 9 + - 1 + - 8 + - 7 + - 3 + - 6 + - 4 + out: false + - name: case_17 + in: + pushed: + - 1 + - 2 + - 3 + - 4 + - 5 + popped: + - 2 + - 4 + - 3 + - 5 + - 1 + out: true + - name: case_18 + in: + pushed: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + popped: + - 7 + - 5 + - 3 + - 2 + - 6 + - 1 + - 4 + out: false + - name: case_19 + in: + pushed: + - 1 + - 2 + popped: + - 2 + - 1 + out: true + - name: case_20 + in: + pushed: + - 1 + - 2 + - 3 + - 4 + - 5 + popped: + - 4 + - 1 + - 2 + - 5 + - 3 + out: false + - name: case_21 + in: + pushed: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + popped: + - 3 + - 2 + - 6 + - 4 + - 8 + - 1 + - 5 + - 7 + out: false + - name: case_22 + in: + pushed: + - 1 + - 2 + - 3 + - 4 + - 5 + popped: + - 1 + - 4 + - 5 + - 3 + - 2 + out: true + - name: case_23 + in: + pushed: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + popped: + - 1 + - 3 + - 2 + - 5 + - 6 + - 4 + out: true + - name: case_24 + in: + pushed: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + popped: + - 1 + - 4 + - 5 + - 2 + - 7 + - 6 + - 3 + out: false + - name: case_25 + in: + pushed: + - 1 + popped: + - 1 + out: true + - name: case_26 + in: + pushed: + - 1 + - 2 + - 3 + popped: + - 3 + - 2 + - 1 + out: true + - name: case_27 + in: + pushed: + - 1 + - 2 + - 3 + popped: + - 3 + - 1 + - 2 + out: false + - name: case_28 + in: + pushed: + - 1 + - 2 + - 3 + - 4 + popped: + - 4 + - 1 + - 3 + - 2 + out: false + - name: case_29 + in: + pushed: + - 1 + - 2 + - 3 + popped: + - 2 + - 3 + - 1 + out: true + - name: case_30 + in: + pushed: + - 1 + popped: + - 1 + out: true + - name: case_31 + in: + pushed: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + popped: + - 4 + - 6 + - 7 + - 5 + - 1 + - 2 + - 3 + out: false + - name: case_32 + in: + pushed: + - 1 + - 2 + - 3 + - 4 + popped: + - 1 + - 3 + - 2 + - 4 + out: true + - name: case_33 + in: + pushed: + - 1 + - 2 + popped: + - 2 + - 1 + out: true + - name: case_34 + in: + pushed: + - 1 + - 2 + - 3 + - 4 + popped: + - 2 + - 4 + - 1 + - 3 + out: false + - name: case_35 + in: + pushed: + - 1 + - 2 + - 3 + popped: + - 3 + - 1 + - 2 + out: false diff --git a/tests/501-1000/946. validate-stack-sequences/sol.cpp b/tests/501-1000/946. validate-stack-sequences/sol.cpp new file mode 100644 index 00000000..a2af8991 --- /dev/null +++ b/tests/501-1000/946. validate-stack-sequences/sol.cpp @@ -0,0 +1,15 @@ +class Solution { +public: + bool validateStackSequences(vector& pushed, vector& popped) { + stack st; + int j = 0; + for (int x : pushed) { + st.push(x); + while (!st.empty() && j < popped.size() && st.top() == popped[j]) { + st.pop(); + j++; + } + } + return j == popped.size(); + } +}; diff --git a/tests/501-1000/946. validate-stack-sequences/sol.cs b/tests/501-1000/946. validate-stack-sequences/sol.cs new file mode 100644 index 00000000..c6893474 --- /dev/null +++ b/tests/501-1000/946. validate-stack-sequences/sol.cs @@ -0,0 +1,14 @@ +public class Solution { + public bool ValidateStackSequences(int[] pushed, int[] popped) { + Stack st = new Stack(); + int j = 0; + foreach (int x in pushed) { + st.Push(x); + while (st.Count > 0 && j < popped.Length && st.Peek() == popped[j]) { + st.Pop(); + j++; + } + } + return j == popped.Length; + } +} diff --git a/tests/501-1000/946. validate-stack-sequences/sol.dart b/tests/501-1000/946. validate-stack-sequences/sol.dart new file mode 100644 index 00000000..d295ae16 --- /dev/null +++ b/tests/501-1000/946. validate-stack-sequences/sol.dart @@ -0,0 +1,14 @@ +class Solution { + bool validateStackSequences(List pushed, List popped) { + List st = []; + int j = 0; + for (int x in pushed) { + st.add(x); + while (st.isNotEmpty && j < popped.length && st.last == popped[j]) { + st.removeLast(); + j++; + } + } + return j == popped.length; + } +} diff --git a/tests/501-1000/946. validate-stack-sequences/sol.go b/tests/501-1000/946. validate-stack-sequences/sol.go new file mode 100644 index 00000000..24eb3645 --- /dev/null +++ b/tests/501-1000/946. validate-stack-sequences/sol.go @@ -0,0 +1,12 @@ +func validateStackSequences(pushed []int, popped []int) bool { + st := []int{} + j := 0 + for _, x := range pushed { + st = append(st, x) + for len(st) > 0 && j < len(popped) && st[len(st)-1] == popped[j] { + st = st[:len(st)-1] + j++ + } + } + return j == len(popped) +} diff --git a/tests/501-1000/946. validate-stack-sequences/sol.java b/tests/501-1000/946. validate-stack-sequences/sol.java new file mode 100644 index 00000000..f63fd396 --- /dev/null +++ b/tests/501-1000/946. validate-stack-sequences/sol.java @@ -0,0 +1,14 @@ +class Solution { + public boolean validateStackSequences(int[] pushed, int[] popped) { + java.util.Stack st = new java.util.Stack<>(); + int j = 0; + for (int x : pushed) { + st.push(x); + while (!st.empty() && j < popped.length && st.peek() == popped[j]) { + st.pop(); + j++; + } + } + return j == popped.length; + } +} diff --git a/tests/501-1000/946. validate-stack-sequences/sol.kt b/tests/501-1000/946. validate-stack-sequences/sol.kt new file mode 100644 index 00000000..e80eb907 --- /dev/null +++ b/tests/501-1000/946. validate-stack-sequences/sol.kt @@ -0,0 +1,14 @@ +class Solution { + fun validateStackSequences(pushed: IntArray, popped: IntArray): Boolean { + val st = ArrayDeque() + var j = 0 + for (x in pushed) { + st.addLast(x) + while (!st.isEmpty() && j < popped.size && st.last() == popped[j]) { + st.removeLast() + j++ + } + } + return j == popped.size + } +} diff --git a/tests/501-1000/946. validate-stack-sequences/sol.py b/tests/501-1000/946. validate-stack-sequences/sol.py new file mode 100644 index 00000000..70e10210 --- /dev/null +++ b/tests/501-1000/946. validate-stack-sequences/sol.py @@ -0,0 +1,10 @@ +class Solution: + def validateStackSequences(self, pushed, popped): + st = [] + j = 0 + for x in pushed: + st.append(x) + while st and j < len(popped) and st[-1] == popped[j]: + st.pop() + j += 1 + return j == len(popped) diff --git a/tests/501-1000/946. validate-stack-sequences/sol.py2 b/tests/501-1000/946. validate-stack-sequences/sol.py2 new file mode 100644 index 00000000..d0414774 --- /dev/null +++ b/tests/501-1000/946. validate-stack-sequences/sol.py2 @@ -0,0 +1,15 @@ +class Solution(object): + def validateStackSequences(self, pushed, popped): + """ + :type pushed: List[int] + :type popped: List[int] + :rtype: bool + """ + st = [] + j = 0 + for x in pushed: + st.append(x) + while st and j < len(popped) and st[-1] == popped[j]: + st.pop() + j += 1 + return j == len(popped) diff --git a/tests/501-1000/946. validate-stack-sequences/sol.rb b/tests/501-1000/946. validate-stack-sequences/sol.rb new file mode 100644 index 00000000..74f506ce --- /dev/null +++ b/tests/501-1000/946. validate-stack-sequences/sol.rb @@ -0,0 +1,15 @@ +# @param {Integer[]} pushed +# @param {Integer[]} popped +# @return {Boolean} +def validate_stack_sequences(pushed, popped) + st = [] + j = 0 + pushed.each do |x| + st.push(x) + while !st.empty? && j < popped.length && st.last == popped[j] + st.pop + j += 1 + end + end + return j == popped.length +end diff --git a/tests/501-1000/946. validate-stack-sequences/sol.rs b/tests/501-1000/946. validate-stack-sequences/sol.rs new file mode 100644 index 00000000..2c61f021 --- /dev/null +++ b/tests/501-1000/946. validate-stack-sequences/sol.rs @@ -0,0 +1,14 @@ +impl Solution { + pub fn validate_stack_sequences(pushed: Vec, popped: Vec) -> bool { + let mut st = Vec::new(); + let mut j = 0; + for x in pushed { + st.push(x); + while !st.is_empty() && j < popped.len() && *st.last().unwrap() == popped[j] { + st.pop(); + j += 1; + } + } + j == popped.len() + } +} diff --git a/tests/501-1000/946. validate-stack-sequences/sol.swift b/tests/501-1000/946. validate-stack-sequences/sol.swift new file mode 100644 index 00000000..b415daf5 --- /dev/null +++ b/tests/501-1000/946. validate-stack-sequences/sol.swift @@ -0,0 +1,14 @@ +class Solution { + func validateStackSequences(_ pushed: [Int], _ popped: [Int]) -> Bool { + var st = [Int]() + var j = 0 + for x in pushed { + st.append(x) + while !st.isEmpty && j < popped.count && st.last! == popped[j] { + st.removeLast() + j += 1 + } + } + return j == popped.count + } +} diff --git a/tests/501-1000/946. validate-stack-sequences/sol.ts b/tests/501-1000/946. validate-stack-sequences/sol.ts new file mode 100644 index 00000000..e3258923 --- /dev/null +++ b/tests/501-1000/946. validate-stack-sequences/sol.ts @@ -0,0 +1,16 @@ +function validateStackSequences(pushed: number[], popped: number[]): boolean { + const st: number[] = []; + let j = 0; + for (const x of pushed) { + st.push(x); + while ( + st.length > 0 && + j < popped.length && + st[st.length - 1] === popped[j] + ) { + st.pop(); + j++; + } + } + return j === popped.length; +} diff --git a/tests/501-1000/947. most-stones-removed-with-same-row-or-column/manifest.yaml b/tests/501-1000/947. most-stones-removed-with-same-row-or-column/manifest.yaml new file mode 100644 index 00000000..32c061fe --- /dev/null +++ b/tests/501-1000/947. most-stones-removed-with-same-row-or-column/manifest.yaml @@ -0,0 +1,500 @@ +entry: + id: 947 + title: most-stones-removed-with-same-row-or-column + params: + stones: + type: array + items: + type: array + items: + type: int + call: + cpp: Solution().removeStones({stones}) + rust: Solution::remove_stones({stones}) + python3: Solution().removeStones({stones}) + python2: Solution().removeStones({stones}) + ruby: remove_stones({stones}) + java: new Solution().removeStones({stones}) + csharp: new Solution().RemoveStones({stones}) + kotlin: Solution().removeStones({stones}) + go: removeStones({stones}) + dart: Solution().removeStones({stones}) + swift: Solution().removeStones({stones}) + typescript: removeStones({stones}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 947 +tests: + - name: case_1 + in: + stones: + - - 0 + - 0 + - - 1 + - 3 + - - 2 + - 2 + - - 2 + - 4 + - - 3 + - 1 + - - 4 + - 0 + out: 2 + - name: case_2 + in: + stones: + - - 0 + - 2 + - - 2 + - 2 + out: 1 + - name: case_3 + in: + stones: + - - 0 + - 3 + - - 3 + - 0 + - - 3 + - 1 + - - 4 + - 0 + - - 4 + - 4 + out: 3 + - name: case_4 + in: + stones: + - - 0 + - 0 + - - 0 + - 3 + - - 1 + - 3 + - - 2 + - 0 + - - 2 + - 2 + - - 2 + - 3 + - - 3 + - 0 + - - 3 + - 1 + out: 7 + - name: case_5 + in: + stones: + - - 1 + - 3 + - - 3 + - 2 + out: 0 + - name: case_6 + in: + stones: + - - 1 + - 1 + - - 2 + - 0 + - - 4 + - 1 + - - 4 + - 2 + out: 2 + - name: case_7 + in: + stones: + - - 0 + - 1 + - - 1 + - 3 + - - 2 + - 1 + - - 2 + - 3 + - - 3 + - 0 + - - 4 + - 0 + out: 4 + - name: case_8 + in: + stones: + - - 0 + - 2 + - - 3 + - 1 + - - 3 + - 2 + - - 4 + - 4 + out: 2 + - name: case_9 + in: + stones: + - - 1 + - 0 + - - 1 + - 2 + - - 2 + - 2 + - - 2 + - 3 + - - 4 + - 2 + out: 4 + - name: case_10 + in: + stones: + - - 0 + - 0 + - - 0 + - 4 + - - 1 + - 1 + - - 1 + - 4 + - - 2 + - 0 + - - 4 + - 1 + out: 5 + - name: case_11 + in: + stones: + - - 0 + - 1 + - - 3 + - 0 + out: 0 + - name: case_12 + in: + stones: + - - 1 + - 4 + - - 2 + - 1 + out: 0 + - name: case_13 + in: + stones: + - - 0 + - 4 + - - 1 + - 0 + - - 4 + - 2 + - - 4 + - 4 + out: 2 + - name: case_14 + in: + stones: + - - 0 + - 4 + - - 4 + - 0 + out: 0 + - name: case_15 + in: + stones: + - - 0 + - 1 + - - 1 + - 3 + - - 2 + - 2 + - - 4 + - 3 + out: 1 + - name: case_16 + in: + stones: + - - 0 + - 2 + - - 2 + - 0 + - - 3 + - 3 + - - 4 + - 4 + out: 0 + - name: case_17 + in: + stones: + - - 0 + - 1 + - - 2 + - 3 + - - 2 + - 4 + - - 3 + - 2 + - - 3 + - 4 + out: 3 + - name: case_18 + in: + stones: + - - 1 + - 2 + - - 1 + - 4 + - - 2 + - 4 + out: 2 + - name: case_19 + in: + stones: + - - 0 + - 2 + - - 1 + - 2 + - - 3 + - 2 + out: 2 + - name: case_20 + in: + stones: + - - 0 + - 3 + - - 1 + - 0 + - - 1 + - 4 + - - 2 + - 1 + - - 3 + - 0 + - - 4 + - 2 + - - 4 + - 3 + out: 4 + - name: case_21 + in: + stones: + - - 1 + - 0 + - - 2 + - 1 + - - 2 + - 2 + - - 3 + - 3 + out: 1 + - name: case_22 + in: + stones: + - - 2 + - 1 + - - 3 + - 3 + - - 4 + - 0 + - - 4 + - 1 + out: 2 + - name: case_23 + in: + stones: + - - 0 + - 1 + - - 0 + - 2 + - - 0 + - 3 + - - 1 + - 4 + - - 3 + - 4 + - - 4 + - 1 + out: 4 + - name: case_24 + in: + stones: + - - 0 + - 3 + - - 1 + - 1 + - - 1 + - 3 + - - 1 + - 4 + - - 2 + - 4 + - - 3 + - 3 + - - 3 + - 4 + - - 4 + - 2 + out: 6 + - name: case_25 + in: + stones: + - - 0 + - 2 + - - 1 + - 2 + - - 3 + - 2 + - - 3 + - 4 + - - 4 + - 4 + out: 4 + - name: case_26 + in: + stones: + - - 0 + - 2 + - - 2 + - 0 + - - 2 + - 3 + - - 3 + - 2 + - - 4 + - 3 + out: 3 + - name: case_27 + in: + stones: + - - 0 + - 1 + - - 1 + - 3 + - - 2 + - 1 + - - 2 + - 3 + - - 4 + - 1 + - - 4 + - 4 + out: 5 + - name: case_28 + in: + stones: + - - 0 + - 3 + - - 2 + - 2 + - - 3 + - 0 + - - 4 + - 2 + - - 4 + - 3 + out: 3 + - name: case_29 + in: + stones: + - - 0 + - 1 + - - 1 + - 3 + - - 1 + - 4 + - - 2 + - 0 + - - 3 + - 4 + - - 4 + - 0 + out: 3 + - name: case_30 + in: + stones: + - - 0 + - 1 + - - 0 + - 4 + - - 1 + - 4 + - - 2 + - 3 + - - 3 + - 0 + - - 3 + - 4 + - - 4 + - 0 + - - 4 + - 2 + out: 6 + - name: case_31 + in: + stones: + - - 0 + - 3 + - - 3 + - 0 + - - 4 + - 0 + - - 4 + - 1 + out: 2 + - name: case_32 + in: + stones: + - - 0 + - 4 + - - 2 + - 1 + out: 0 + - name: case_33 + in: + stones: + - - 0 + - 1 + out: 0 + - name: case_34 + in: + stones: + - - 0 + - 1 + - - 0 + - 3 + - - 2 + - 0 + - - 2 + - 1 + - - 2 + - 3 + - - 2 + - 4 + - - 3 + - 2 + - - 4 + - 2 + out: 6 + - name: case_35 + in: + stones: + - - 2 + - 0 + - - 2 + - 2 + - - 2 + - 4 + - - 3 + - 3 + - - 3 + - 4 + - - 4 + - 0 + - - 4 + - 1 + out: 6 diff --git a/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.cpp b/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.cpp new file mode 100644 index 00000000..3ef3414e --- /dev/null +++ b/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.cpp @@ -0,0 +1,37 @@ +class Solution { +public: + int removeStones(vector>& stones) { + int n = stones.size(); + vector> matrix(n); + + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (stones[i][0] == stones[j][0] || stones[i][1] == stones[j][1]) { + matrix[i].push_back(j); + matrix[j].push_back(i); + } + } + } + + vector visited(n, false); + int components = 0; + + function dfs = [&](int idx) { + visited[idx] = true; + for (int nei : matrix[idx]) { + if (!visited[nei]) { + dfs(nei); + } + } + }; + + for (int i = 0; i < n; i++) { + if (!visited[i]) { + components++; + dfs(i); + } + } + + return n - components; + } +}; diff --git a/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.cs b/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.cs new file mode 100644 index 00000000..1d7d24d0 --- /dev/null +++ b/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.cs @@ -0,0 +1,39 @@ +public class Solution { + public int RemoveStones(int[][] stones) { + int n = stones.Length; + List[] matrix = new List[n]; + for (int i = 0; i < n; i++) { + matrix[i] = new List(); + } + + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (stones[i][0] == stones[j][0] || stones[i][1] == stones[j][1]) { + matrix[i].Add(j); + matrix[j].Add(i); + } + } + } + + bool[] visited = new bool[n]; + int components = 0; + + void Dfs(int idx) { + visited[idx] = true; + foreach (int nei in matrix[idx]) { + if (!visited[nei]) { + Dfs(nei); + } + } + } + + for (int i = 0; i < n; i++) { + if (!visited[i]) { + components++; + Dfs(i); + } + } + + return n - components; + } +} diff --git a/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.dart b/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.dart new file mode 100644 index 00000000..54a0153b --- /dev/null +++ b/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.dart @@ -0,0 +1,36 @@ +class Solution { + int removeStones(List> stones) { + int n = stones.length; + List> matrix = List.generate(n, (_) => []); + + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (stones[i][0] == stones[j][0] || stones[i][1] == stones[j][1]) { + matrix[i].add(j); + matrix[j].add(i); + } + } + } + + List visited = List.filled(n, false); + int components = 0; + + void dfs(int idx) { + visited[idx] = true; + for (int nei in matrix[idx]) { + if (!visited[nei]) { + dfs(nei); + } + } + } + + for (int i = 0; i < n; i++) { + if (!visited[i]) { + components++; + dfs(i); + } + } + + return n - components; + } +} diff --git a/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.go b/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.go new file mode 100644 index 00000000..d053487e --- /dev/null +++ b/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.go @@ -0,0 +1,38 @@ +func removeStones(stones [][]int) int { + n := len(stones) + matrix := make([][]int, n) + for i := 0; i < n; i++ { + matrix[i] = []int{} + } + + for i := 0; i < n; i++ { + for j := i + 1; j < n; j++ { + if stones[i][0] == stones[j][0] || stones[i][1] == stones[j][1] { + matrix[i] = append(matrix[i], j) + matrix[j] = append(matrix[j], i) + } + } + } + + visited := make([]bool, n) + components := 0 + + var dfs func(int) + dfs = func(idx int) { + visited[idx] = true + for _, nei := range matrix[idx] { + if !visited[nei] { + dfs(nei) + } + } + } + + for i := 0; i < n; i++ { + if !visited[i] { + components++ + dfs(i) + } + } + + return n - components +} diff --git a/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.java b/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.java new file mode 100644 index 00000000..67e27136 --- /dev/null +++ b/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.java @@ -0,0 +1,69 @@ +import java.util.HashMap; +import java.util.Map; + +class Solution { + public int removeStones(int[][] stones) { + int n = stones.length; + DSU dsu = new DSU(n); + Map row = new HashMap<>(); + Map col = new HashMap<>(); + + for (int i = 0; i < n; i++) { + int r = stones[i][0]; + int c = stones[i][1]; + Integer prevRow = row.get(r); + if (prevRow != null) { + dsu.union(i, prevRow); + } else { + row.put(r, i); + } + Integer prevCol = col.get(c); + if (prevCol != null) { + dsu.union(i, prevCol); + } else { + col.put(c, i); + } + } + + return n - dsu.components; + } + + private static final class DSU { + private final int[] parent; + private final int[] rank; + private int components; + + DSU(int n) { + this.parent = new int[n]; + this.rank = new int[n]; + this.components = n; + for (int i = 0; i < n; i++) { + parent[i] = i; + } + } + + int find(int x) { + if (parent[x] != x) { + parent[x] = find(parent[x]); + } + return parent[x]; + } + + void union(int a, int b) { + int ra = find(a); + int rb = find(b); + if (ra == rb) { + return; + } + if (rank[ra] < rank[rb]) { + parent[ra] = rb; + } else if (rank[ra] > rank[rb]) { + parent[rb] = ra; + } else { + parent[rb] = ra; + rank[ra]++; + } + components--; + } + } +} diff --git a/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.kt b/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.kt new file mode 100644 index 00000000..4cf48690 --- /dev/null +++ b/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.kt @@ -0,0 +1,36 @@ +class Solution { + fun removeStones(stones: Array): Int { + val n = stones.size + val matrix = Array(n) { mutableListOf() } + + for (i in 0 until n) { + for (j in i + 1 until n) { + if (stones[i][0] == stones[j][0] || stones[i][1] == stones[j][1]) { + matrix[i].add(j) + matrix[j].add(i) + } + } + } + + val visited = BooleanArray(n) + var components = 0 + + fun dfs(idx: Int) { + visited[idx] = true + for (nei in matrix[idx]) { + if (!visited[nei]) { + dfs(nei) + } + } + } + + for (i in 0 until n) { + if (!visited[i]) { + components++ + dfs(i) + } + } + + return n - components + } +} diff --git a/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.py b/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.py new file mode 100644 index 00000000..6e0fdad7 --- /dev/null +++ b/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.py @@ -0,0 +1,28 @@ +from typing import List + + +class Solution: + def removeStones(self, stones: List[List[int]]) -> int: + def dfs(idx): + visited.add(idx) + for nei in matrix.get(idx, []): + if nei not in visited: + dfs(nei) + + n = len(stones) + matrix = {i: [] for i in range(n)} + + for i in range(n): + for j in range(i + 1, n): + if stones[i][0] == stones[j][0] or stones[i][1] == stones[j][1]: + matrix[i].append(j) + matrix[j].append(i) + + visited = set() + components = 0 + for i, stone in enumerate(stones): + if i not in visited: + components += 1 + dfs(i) + + return n - components diff --git a/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.py2 b/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.py2 new file mode 100644 index 00000000..623f8122 --- /dev/null +++ b/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.py2 @@ -0,0 +1,29 @@ +class Solution(object): + def removeStones(self, stones): + """ + :type stones: List[List[int]] + :rtype: int + """ + def dfs(idx): + visited.add(idx) + for nei in matrix.get(idx, []): + if nei not in visited: + dfs(nei) + + n = len(stones) + matrix = {i: [] for i in range(n)} + + for i in range(n): + for j in range(i + 1, n): + if stones[i][0] == stones[j][0] or stones[i][1] == stones[j][1]: + matrix[i].append(j) + matrix[j].append(i) + + visited = set() + components = 0 + for i in range(n): + if i not in visited: + components += 1 + dfs(i) + + return n - components diff --git a/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.rb b/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.rb new file mode 100644 index 00000000..22a0cfc4 --- /dev/null +++ b/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.rb @@ -0,0 +1,34 @@ +# @param {Integer[][]} stones +# @return {Integer} +def remove_stones(stones) + n = stones.length + matrix = Hash.new { |h, k| h[k] = [] } + + (0...n).each do |i| + (i+1...n).each do |j| + if stones[i][0] == stones[j][0] || stones[i][1] == stones[j][1] + matrix[i] << j + matrix[j] << i + end + end + end + + visited = Set.new + components = 0 + + dfs = lambda do |idx| + visited.add(idx) + matrix[idx].each do |nei| + dfs.call(nei) unless visited.include?(nei) + end + end + + (0...n).each do |i| + unless visited.include?(i) + components += 1 + dfs.call(i) + end + end + + n - components +end diff --git a/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.rs b/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.rs new file mode 100644 index 00000000..8db80eb3 --- /dev/null +++ b/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.rs @@ -0,0 +1,36 @@ +impl Solution { + pub fn remove_stones(stones: Vec>) -> i32 { + let n = stones.len(); + let mut matrix: Vec> = vec![vec![]; n]; + + for i in 0..n { + for j in (i+1)..n { + if stones[i][0] == stones[j][0] || stones[i][1] == stones[j][1] { + matrix[i].push(j); + matrix[j].push(i); + } + } + } + + let mut visited = vec![false; n]; + let mut components = 0; + + fn dfs(idx: usize, matrix: &Vec>, visited: &mut Vec) { + visited[idx] = true; + for &nei in &matrix[idx] { + if !visited[nei] { + dfs(nei, matrix, visited); + } + } + } + + for i in 0..n { + if !visited[i] { + components += 1; + dfs(i, &matrix, &mut visited); + } + } + + (n - components) as i32 + } +} diff --git a/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.swift b/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.swift new file mode 100644 index 00000000..88067cfd --- /dev/null +++ b/tests/501-1000/947. most-stones-removed-with-same-row-or-column/sol.swift @@ -0,0 +1,36 @@ +class Solution { + func removeStones(_ stones: [[Int]]) -> Int { + let n = stones.count + var matrix = [[Int]](repeating: [], count: n) + + for i in 0.. []); + + for (let i = 0; i < n; i++) { + for (let j = i + 1; j < n; j++) { + if (stones[i][0] === stones[j][0] || stones[i][1] === stones[j][1]) { + matrix[i].push(j); + matrix[j].push(i); + } + } + } + + const visited: boolean[] = new Array(n).fill(false); + let components = 0; + + function dfs(idx: number): void { + visited[idx] = true; + for (const nei of matrix[idx]) { + if (!visited[nei]) { + dfs(nei); + } + } + } + + for (let i = 0; i < n; i++) { + if (!visited[i]) { + components++; + dfs(i); + } + } + + return n - components; +} diff --git a/tests/501-1000/948. bag-of-tokens/manifest.yaml b/tests/501-1000/948. bag-of-tokens/manifest.yaml new file mode 100644 index 00000000..dcee51b1 --- /dev/null +++ b/tests/501-1000/948. bag-of-tokens/manifest.yaml @@ -0,0 +1,393 @@ +entry: + id: 948 + title: bag-of-tokens + params: + tokens: + type: array + items: + type: int + power: + type: int + call: + cpp: Solution().bagOfTokensScore({tokens}, {power}) + rust: Solution::bag_of_tokens_score({tokens}, {power}) + python3: Solution().bagOfTokensScore({tokens}, {power}) + python2: Solution().bagOfTokensScore({tokens}, {power}) + ruby: bag_of_tokens_score({tokens}, {power}) + java: new Solution().bagOfTokensScore({tokens}, {power}) + csharp: new Solution().BagOfTokensScore({tokens}, {power}) + kotlin: Solution().bagOfTokensScore({tokens}, {power}) + go: bagOfTokensScore({tokens}, {power}) + dart: Solution().bagOfTokensScore({tokens}, {power}) + swift: Solution().bagOfTokensScore({tokens}, {power}) + typescript: bagOfTokensScore({tokens}, {power}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 948 +tests: + - name: case_1 + in: + tokens: + - 31 + - 66 + - 78 + - 112 + - 141 + - 226 + - 228 + - 243 + - 282 + power: 204 + out: 4 + - name: case_2 + in: + tokens: + - 103 + - 187 + - 235 + - 270 + power: 306 + out: 2 + - name: case_3 + in: + tokens: + - 13 + power: 166 + out: 1 + - name: case_4 + in: + tokens: + - 41 + - 66 + - 162 + - 186 + - 226 + - 269 + - 288 + power: 98 + out: 2 + - name: case_5 + in: + tokens: + - 19 + - 32 + - 37 + - 91 + - 105 + - 106 + - 185 + - 217 + - 248 + power: 278 + out: 5 + - name: case_6 + in: + tokens: + - 40 + - 43 + - 66 + - 70 + - 175 + - 197 + - 213 + - 256 + power: 158 + out: 4 + - name: case_7 + in: + tokens: + - 18 + - 41 + - 202 + - 223 + - 246 + power: 32 + out: 2 + - name: case_8 + in: + tokens: + - 141 + - 272 + power: 75 + out: 0 + - name: case_9 + in: + tokens: + - 0 + - 12 + - 18 + - 26 + - 233 + - 261 + - 282 + - 293 + power: 367 + out: 5 + - name: case_10 + in: + tokens: + - 37 + - 38 + - 57 + - 104 + - 131 + - 162 + - 183 + - 185 + - 199 + - 202 + power: 2 + out: 0 + - name: case_11 + in: + tokens: + - 153 + - 195 + power: 338 + out: 1 + - name: case_12 + in: + tokens: + - 4 + - 17 + - 89 + - 172 + - 233 + power: 68 + out: 3 + - name: case_13 + in: + tokens: + - 15 + - 117 + - 138 + - 169 + - 201 + - 215 + power: 213 + out: 2 + - name: case_14 + in: + tokens: + - 15 + - 89 + - 109 + - 146 + - 157 + - 188 + - 208 + - 229 + - 252 + power: 180 + out: 3 + - name: case_15 + in: + tokens: + - 18 + - 26 + - 174 + - 229 + - 233 + - 242 + - 277 + power: 266 + out: 3 + - name: case_16 + in: + tokens: + - 33 + - 141 + - 198 + - 226 + - 289 + power: 334 + out: 3 + - name: case_17 + in: + tokens: + - 64 + - 88 + - 212 + - 222 + power: 165 + out: 2 + - name: case_18 + in: + tokens: + - 3 + power: 72 + out: 1 + - name: case_19 + in: + tokens: + - 204 + - 300 + power: 132 + out: 0 + - name: case_20 + in: + tokens: + - 59 + power: 339 + out: 1 + - name: case_21 + in: + tokens: + - 208 + - 236 + - 242 + - 293 + power: 394 + out: 2 + - name: case_22 + in: + tokens: + - 42 + - 80 + - 140 + - 154 + - 177 + - 183 + - 196 + - 281 + power: 158 + out: 3 + - name: case_23 + in: + tokens: + - 235 + power: 204 + out: 0 + - name: case_24 + in: + tokens: + - 26 + - 172 + - 248 + - 258 + power: 400 + out: 2 + - name: case_25 + in: + tokens: + - 17 + - 55 + - 75 + - 124 + - 161 + - 188 + - 212 + - 297 + - 300 + power: 47 + out: 4 + - name: case_26 + in: + tokens: + - 3 + - 96 + - 214 + - 228 + - 252 + power: 270 + out: 2 + - name: case_27 + in: + tokens: + - 3 + - 98 + - 115 + - 143 + - 224 + - 248 + - 258 + power: 311 + out: 3 + - name: case_28 + in: + tokens: + - 24 + - 296 + - 297 + power: 241 + out: 1 + - name: case_29 + in: + tokens: + - 27 + - 225 + power: 198 + out: 1 + - name: case_30 + in: + tokens: + - 23 + - 63 + - 93 + - 140 + - 162 + - 182 + - 292 + power: 202 + out: 4 + - name: case_31 + in: + tokens: + - 4 + - 41 + - 147 + - 271 + power: 176 + out: 2 + - name: case_32 + in: + tokens: + - 59 + - 81 + - 97 + - 149 + - 210 + power: 207 + out: 3 + - name: case_33 + in: + tokens: + - 36 + - 199 + - 277 + power: 77 + out: 1 + - name: case_34 + in: + tokens: + - 46 + - 49 + - 68 + - 86 + - 107 + - 265 + - 296 + power: 230 + out: 4 + - name: case_35 + in: + tokens: + - 30 + - 85 + - 142 + - 170 + - 179 + - 272 + - 282 + - 285 + - 299 + - 300 + power: 81 + out: 3 diff --git a/tests/501-1000/948. bag-of-tokens/sol.cpp b/tests/501-1000/948. bag-of-tokens/sol.cpp new file mode 100644 index 00000000..99dfa2bd --- /dev/null +++ b/tests/501-1000/948. bag-of-tokens/sol.cpp @@ -0,0 +1,33 @@ +class Solution { +public: + int bagOfTokensScore(vector& tokens, int power) { + sort(tokens.begin(), tokens.end()); + int n = tokens.size(); + int l = 0; + int curr = 0; + + while (l < n && tokens[l] <= power) { + power -= tokens[l]; + l++; + curr++; + } + + int r = n - 1; + int res = curr; + + while (l < r && curr > 0) { + power += tokens[r]; + curr--; + r--; + + while (l <= r && tokens[l] <= power) { + power -= tokens[l]; + l++; + curr++; + } + res = max(res, curr); + } + + return res; + } +}; diff --git a/tests/501-1000/948. bag-of-tokens/sol.cs b/tests/501-1000/948. bag-of-tokens/sol.cs new file mode 100644 index 00000000..b355daf2 --- /dev/null +++ b/tests/501-1000/948. bag-of-tokens/sol.cs @@ -0,0 +1,32 @@ +public class Solution { + public int BagOfTokensScore(int[] tokens, int power) { + System.Array.Sort(tokens); + int n = tokens.Length; + int l = 0; + int curr = 0; + + while (l < n && tokens[l] <= power) { + power -= tokens[l]; + l++; + curr++; + } + + int r = n - 1; + int res = curr; + + while (l < r && curr > 0) { + power += tokens[r]; + curr--; + r--; + + while (l <= r && tokens[l] <= power) { + power -= tokens[l]; + l++; + curr++; + } + res = Math.Max(res, curr); + } + + return res; + } +} diff --git a/tests/501-1000/948. bag-of-tokens/sol.dart b/tests/501-1000/948. bag-of-tokens/sol.dart new file mode 100644 index 00000000..92c0b032 --- /dev/null +++ b/tests/501-1000/948. bag-of-tokens/sol.dart @@ -0,0 +1,32 @@ +class Solution { + int bagOfTokensScore(List tokens, int power) { + tokens.sort(); + int n = tokens.length; + int l = 0; + int curr = 0; + + while (l < n && tokens[l] <= power) { + power -= tokens[l]; + l++; + curr++; + } + + int r = n - 1; + int res = curr; + + while (l < r && curr > 0) { + power += tokens[r]; + curr--; + r--; + + while (l <= r && tokens[l] <= power) { + power -= tokens[l]; + l++; + curr++; + } + res = res > curr ? res : curr; + } + + return res; + } +} diff --git a/tests/501-1000/948. bag-of-tokens/sol.go b/tests/501-1000/948. bag-of-tokens/sol.go new file mode 100644 index 00000000..418655a4 --- /dev/null +++ b/tests/501-1000/948. bag-of-tokens/sol.go @@ -0,0 +1,32 @@ +func bagOfTokensScore(tokens []int, power int) int { + sort.Ints(tokens) + n := len(tokens) + l := 0 + curr := 0 + + for l < n && tokens[l] <= power { + power -= tokens[l] + l++ + curr++ + } + + r := n - 1 + res := curr + + for l < r && curr > 0 { + power += tokens[r] + curr-- + r-- + + for l <= r && tokens[l] <= power { + power -= tokens[l] + l++ + curr++ + } + if curr > res { + res = curr + } + } + + return res +} diff --git a/tests/501-1000/948. bag-of-tokens/sol.java b/tests/501-1000/948. bag-of-tokens/sol.java new file mode 100644 index 00000000..0757a87a --- /dev/null +++ b/tests/501-1000/948. bag-of-tokens/sol.java @@ -0,0 +1,32 @@ +class Solution { + public int bagOfTokensScore(int[] tokens, int power) { + java.util.Arrays.sort(tokens); + int n = tokens.length; + int l = 0; + int curr = 0; + + while (l < n && tokens[l] <= power) { + power -= tokens[l]; + l++; + curr++; + } + + int r = n - 1; + int res = curr; + + while (l < r && curr > 0) { + power += tokens[r]; + curr--; + r--; + + while (l <= r && tokens[l] <= power) { + power -= tokens[l]; + l++; + curr++; + } + res = Math.max(res, curr); + } + + return res; + } +} diff --git a/tests/501-1000/948. bag-of-tokens/sol.kt b/tests/501-1000/948. bag-of-tokens/sol.kt new file mode 100644 index 00000000..521d9822 --- /dev/null +++ b/tests/501-1000/948. bag-of-tokens/sol.kt @@ -0,0 +1,33 @@ +class Solution { + fun bagOfTokensScore(tokens: IntArray, power: Int): Int { + tokens.sort() + val n = tokens.size + var l = 0 + var curr = 0 + var p = power + + while (l < n && tokens[l] <= p) { + p -= tokens[l] + l++ + curr++ + } + + var r = n - 1 + var res = curr + + while (l < r && curr > 0) { + p += tokens[r] + curr-- + r-- + + while (l <= r && tokens[l] <= p) { + p -= tokens[l] + l++ + curr++ + } + res = maxOf(res, curr) + } + + return res + } +} diff --git a/tests/501-1000/948. bag-of-tokens/sol.py b/tests/501-1000/948. bag-of-tokens/sol.py new file mode 100644 index 00000000..5e9cb15f --- /dev/null +++ b/tests/501-1000/948. bag-of-tokens/sol.py @@ -0,0 +1,31 @@ +from typing import List + + +class Solution: + def bagOfTokensScore(self, tokens: List[int], power: int) -> int: + tokens.sort() + + n = len(tokens) + l = 0 + curr = 0 + + while l < n and tokens[l] <= power: + power -= tokens[l] + l += 1 + curr += 1 + + r = n - 1 + res = curr + + while l < r and curr: + power += tokens[r] + curr -= 1 + r -= 1 + + while l <= r and tokens[l] <= power: + power -= tokens[l] + l += 1 + curr += 1 + res = max(res, curr) + + return res diff --git a/tests/501-1000/948. bag-of-tokens/sol.py2 b/tests/501-1000/948. bag-of-tokens/sol.py2 new file mode 100644 index 00000000..3dfc3a5e --- /dev/null +++ b/tests/501-1000/948. bag-of-tokens/sol.py2 @@ -0,0 +1,32 @@ +class Solution(object): + def bagOfTokensScore(self, tokens, power): + """ + :type tokens: List[int] + :type power: int + :rtype: int + """ + tokens.sort() + n = len(tokens) + l = 0 + curr = 0 + + while l < n and tokens[l] <= power: + power -= tokens[l] + l += 1 + curr += 1 + + r = n - 1 + res = curr + + while l < r and curr: + power += tokens[r] + curr -= 1 + r -= 1 + + while l <= r and tokens[l] <= power: + power -= tokens[l] + l += 1 + curr += 1 + res = max(res, curr) + + return res diff --git a/tests/501-1000/948. bag-of-tokens/sol.rb b/tests/501-1000/948. bag-of-tokens/sol.rb new file mode 100644 index 00000000..324af13b --- /dev/null +++ b/tests/501-1000/948. bag-of-tokens/sol.rb @@ -0,0 +1,33 @@ +# @param {Integer[]} tokens +# @param {Integer} power +# @return {Integer} +def bag_of_tokens_score(tokens, power) + tokens.sort! + n = tokens.length + l = 0 + curr = 0 + + while l < n && tokens[l] <= power + power -= tokens[l] + l += 1 + curr += 1 + end + + r = n - 1 + res = curr + + while l < r && curr > 0 + power += tokens[r] + curr -= 1 + r -= 1 + + while l <= r && tokens[l] <= power + power -= tokens[l] + l += 1 + curr += 1 + end + res = [res, curr].max + end + + res +end diff --git a/tests/501-1000/948. bag-of-tokens/sol.rs b/tests/501-1000/948. bag-of-tokens/sol.rs new file mode 100644 index 00000000..90ef927b --- /dev/null +++ b/tests/501-1000/948. bag-of-tokens/sol.rs @@ -0,0 +1,34 @@ +impl Solution { + pub fn bag_of_tokens_score(tokens: Vec, power: i32) -> i32 { + let mut tokens = tokens; + tokens.sort(); + let n = tokens.len(); + let mut l = 0; + let mut curr = 0; + let mut power = power; + + while l < n && tokens[l] <= power { + power -= tokens[l]; + l += 1; + curr += 1; + } + + let mut r = n as i32 - 1; + let mut res = curr; + + while (l as i32) < r && curr > 0 { + power += tokens[r as usize]; + curr -= 1; + r -= 1; + + while l <= r as usize && tokens[l] <= power { + power -= tokens[l]; + l += 1; + curr += 1; + } + res = res.max(curr); + } + + res + } +} diff --git a/tests/501-1000/948. bag-of-tokens/sol.swift b/tests/501-1000/948. bag-of-tokens/sol.swift new file mode 100644 index 00000000..29494268 --- /dev/null +++ b/tests/501-1000/948. bag-of-tokens/sol.swift @@ -0,0 +1,33 @@ +class Solution { + func bagOfTokensScore(_ tokens: [Int], _ power: Int) -> Int { + var tokens = tokens.sorted() + let n = tokens.count + var l = 0 + var curr = 0 + var power = power + + while l < n && tokens[l] <= power { + power -= tokens[l] + l += 1 + curr += 1 + } + + var r = n - 1 + var res = curr + + while l < r && curr > 0 { + power += tokens[r] + curr -= 1 + r -= 1 + + while l <= r && tokens[l] <= power { + power -= tokens[l] + l += 1 + curr += 1 + } + res = max(res, curr) + } + + return res + } +} diff --git a/tests/501-1000/948. bag-of-tokens/sol.ts b/tests/501-1000/948. bag-of-tokens/sol.ts new file mode 100644 index 00000000..39ccce4a --- /dev/null +++ b/tests/501-1000/948. bag-of-tokens/sol.ts @@ -0,0 +1,30 @@ +function bagOfTokensScore(tokens: number[], power: number): number { + tokens.sort((a, b) => a - b); + const n = tokens.length; + let l = 0; + let curr = 0; + + while (l < n && tokens[l] <= power) { + power -= tokens[l]; + l++; + curr++; + } + + let r = n - 1; + let res = curr; + + while (l < r && curr > 0) { + power += tokens[r]; + curr--; + r--; + + while (l <= r && tokens[l] <= power) { + power -= tokens[l]; + l++; + curr++; + } + res = Math.max(res, curr); + } + + return res; +} diff --git a/tests/501-1000/949. largest-time-for-given-digits/manifest.yaml b/tests/501-1000/949. largest-time-for-given-digits/manifest.yaml new file mode 100644 index 00000000..e0ef0ed5 --- /dev/null +++ b/tests/501-1000/949. largest-time-for-given-digits/manifest.yaml @@ -0,0 +1,312 @@ +entry: + id: 949 + title: largest-time-for-given-digits + params: + arr: + type: array + items: + type: int + call: + cpp: Solution().largestTimeFromDigits({arr}) + rust: Solution::largest_time_from_digits({arr}) + python3: Solution().largestTimeFromDigits({arr}) + python2: Solution().largestTimeFromDigits({arr}) + ruby: largest_time_from_digits({arr}) + java: new Solution().largestTimeFromDigits({arr}) + csharp: new Solution().LargestTimeFromDigits({arr}) + kotlin: Solution().largestTimeFromDigits({arr}) + go: largestTimeFromDigits({arr}) + dart: Solution().largestTimeFromDigits({arr}) + swift: Solution().largestTimeFromDigits({arr}) + typescript: largestTimeFromDigits({arr}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 949 +tests: + - name: case_1 + in: + arr: + - 1 + - 2 + - 3 + - 4 + out: "23:41" + - name: case_2 + in: + arr: + - 5 + - 5 + - 5 + - 5 + out: "" + - name: case_3 + in: + arr: + - 0 + - 0 + - 0 + - 0 + out: 00:00 + - name: case_4 + in: + arr: + - 2 + - 0 + - 6 + - 6 + out: 06:26 + - name: case_5 + in: + arr: + - 2 + - 4 + - 0 + - 0 + out: "20:40" + - name: case_6 + in: + arr: + - 9 + - 1 + - 2 + - 5 + out: "21:59" + - name: case_7 + in: + arr: + - 0 + - 4 + - 0 + - 0 + out: 04:00 + - name: case_8 + in: + arr: + - 5 + - 5 + - 5 + - 4 + out: "" + - name: case_9 + in: + arr: + - 9 + - 4 + - 7 + - 8 + out: "" + - name: case_10 + in: + arr: + - 9 + - 5 + - 0 + - 2 + out: "20:59" + - name: case_11 + in: + arr: + - 4 + - 0 + - 6 + - 1 + out: "16:40" + - name: case_12 + in: + arr: + - 3 + - 6 + - 2 + - 7 + out: "" + - name: case_13 + in: + arr: + - 4 + - 0 + - 8 + - 1 + out: "18:40" + - name: case_14 + in: + arr: + - 6 + - 6 + - 5 + - 3 + out: "" + - name: case_15 + in: + arr: + - 7 + - 8 + - 1 + - 6 + out: "" + - name: case_16 + in: + arr: + - 5 + - 6 + - 7 + - 6 + out: "" + - name: case_17 + in: + arr: + - 2 + - 2 + - 0 + - 8 + out: "22:08" + - name: case_18 + in: + arr: + - 8 + - 9 + - 1 + - 9 + out: "" + - name: case_19 + in: + arr: + - 0 + - 1 + - 5 + - 8 + out: "18:50" + - name: case_20 + in: + arr: + - 9 + - 6 + - 5 + - 0 + out: 09:56 + - name: case_21 + in: + arr: + - 5 + - 1 + - 5 + - 0 + out: "15:50" + - name: case_22 + in: + arr: + - 9 + - 3 + - 4 + - 2 + out: "23:49" + - name: case_23 + in: + arr: + - 4 + - 1 + - 7 + - 7 + out: "17:47" + - name: case_24 + in: + arr: + - 5 + - 6 + - 9 + - 0 + out: 09:56 + - name: case_25 + in: + arr: + - 2 + - 5 + - 6 + - 7 + out: "" + - name: case_26 + in: + arr: + - 0 + - 3 + - 9 + - 1 + out: "19:30" + - name: case_27 + in: + arr: + - 3 + - 5 + - 5 + - 9 + out: "" + - name: case_28 + in: + arr: + - 3 + - 9 + - 0 + - 4 + out: 09:43 + - name: case_29 + in: + arr: + - 2 + - 6 + - 3 + - 8 + out: "" + - name: case_30 + in: + arr: + - 0 + - 0 + - 4 + - 8 + out: 08:40 + - name: case_31 + in: + arr: + - 1 + - 1 + - 5 + - 9 + out: "19:51" + - name: case_32 + in: + arr: + - 4 + - 7 + - 7 + - 5 + out: "" + - name: case_33 + in: + arr: + - 4 + - 6 + - 1 + - 7 + out: "17:46" + - name: case_34 + in: + arr: + - 5 + - 7 + - 1 + - 8 + out: "18:57" + - name: case_35 + in: + arr: + - 3 + - 3 + - 9 + - 7 + out: "" diff --git a/tests/501-1000/949. largest-time-for-given-digits/sol.cpp b/tests/501-1000/949. largest-time-for-given-digits/sol.cpp new file mode 100644 index 00000000..51611d72 --- /dev/null +++ b/tests/501-1000/949. largest-time-for-given-digits/sol.cpp @@ -0,0 +1,42 @@ +class Solution { +public: + string largestTimeFromDigits(vector& arr) { + vector> permList; + permute(arr, 0, permList); + + int bestTime = -1; + int bestIdx = -1; + + for (int i = 0; i < permList.size(); i++) { + auto& perm = permList[i]; + int hours = perm[0] * 10 + perm[1]; + int minutes = perm[2] * 10 + perm[3]; + + if (hours < 24 && minutes < 60) { + int currTime = hours * 60 + minutes; + if (currTime > bestTime) { + bestTime = currTime; + bestIdx = i; + } + } + } + + if (bestIdx == -1) return ""; + + auto& res = permList[bestIdx]; + return to_string(res[0]) + to_string(res[1]) + ":" + to_string(res[2]) + to_string(res[3]); + } + +private: + void permute(vector& arr, int start, vector>& result) { + if (start == arr.size()) { + result.push_back(arr); + return; + } + for (int i = start; i < arr.size(); i++) { + swap(arr[start], arr[i]); + permute(arr, start + 1, result); + swap(arr[start], arr[i]); + } + } +}; diff --git a/tests/501-1000/949. largest-time-for-given-digits/sol.cs b/tests/501-1000/949. largest-time-for-given-digits/sol.cs new file mode 100644 index 00000000..11a0f4a8 --- /dev/null +++ b/tests/501-1000/949. largest-time-for-given-digits/sol.cs @@ -0,0 +1,46 @@ +public class Solution { + public string LargestTimeFromDigits(int[] arr) { + List permList = new List(); + Permute(arr, 0, permList); + + int bestTime = -1; + int bestIdx = -1; + + for (int i = 0; i < permList.Count; i++) { + int[] perm = permList[i]; + int hours = perm[0] * 10 + perm[1]; + int minutes = perm[2] * 10 + perm[3]; + + if (hours < 24 && minutes < 60) { + int currTime = hours * 60 + minutes; + if (currTime > bestTime) { + bestTime = currTime; + bestIdx = i; + } + } + } + + if (bestIdx == -1) return ""; + + int[] res = permList[bestIdx]; + return $"{res[0]}{res[1]}:{res[2]}{res[3]}"; + } + + private void Permute(int[] arr, int start, List result) { + if (start == arr.Length) { + result.Add((int[])arr.Clone()); + return; + } + for (int i = start; i < arr.Length; i++) { + Swap(arr, start, i); + Permute(arr, start + 1, result); + Swap(arr, start, i); + } + } + + private void Swap(int[] arr, int i, int j) { + int tmp = arr[i]; + arr[i] = arr[j]; + arr[j] = tmp; + } +} diff --git a/tests/501-1000/949. largest-time-for-given-digits/sol.dart b/tests/501-1000/949. largest-time-for-given-digits/sol.dart new file mode 100644 index 00000000..d84a7c71 --- /dev/null +++ b/tests/501-1000/949. largest-time-for-given-digits/sol.dart @@ -0,0 +1,46 @@ +class Solution { + String largestTimeFromDigits(List arr) { + List> permList = []; + permute(arr, 0, permList); + + int bestTime = -1; + int bestIdx = -1; + + for (int i = 0; i < permList.length; i++) { + List perm = permList[i]; + int hours = perm[0] * 10 + perm[1]; + int minutes = perm[2] * 10 + perm[3]; + + if (hours < 24 && minutes < 60) { + int currTime = hours * 60 + minutes; + if (currTime > bestTime) { + bestTime = currTime; + bestIdx = i; + } + } + } + + if (bestIdx == -1) return ""; + + List res = permList[bestIdx]; + return "${res[0]}${res[1]}:${res[2]}${res[3]}"; + } + + void permute(List arr, int start, List> result) { + if (start == arr.length) { + result.add(List.from(arr)); + return; + } + for (int i = start; i < arr.length; i++) { + swap(arr, start, i); + permute(arr, start + 1, result); + swap(arr, start, i); + } + } + + void swap(List arr, int i, int j) { + int tmp = arr[i]; + arr[i] = arr[j]; + arr[j] = tmp; + } +} diff --git a/tests/501-1000/949. largest-time-for-given-digits/sol.go b/tests/501-1000/949. largest-time-for-given-digits/sol.go new file mode 100644 index 00000000..fd1577f8 --- /dev/null +++ b/tests/501-1000/949. largest-time-for-given-digits/sol.go @@ -0,0 +1,41 @@ +func largestTimeFromDigits(arr []int) string { + var permList [][]int + permute(arr, 0, &permList) + + bestTime := -1 + bestIdx := -1 + + for i, perm := range permList { + hours := perm[0]*10 + perm[1] + minutes := perm[2]*10 + perm[3] + + if hours < 24 && minutes < 60 { + currTime := hours*60 + minutes + if currTime > bestTime { + bestTime = currTime + bestIdx = i + } + } + } + + if bestIdx == -1 { + return "" + } + + res := permList[bestIdx] + return fmt.Sprintf("%d%d:%d%d", res[0], res[1], res[2], res[3]) +} + +func permute(arr []int, start int, result *[][]int) { + if start == len(arr) { + perm := make([]int, len(arr)) + copy(perm, arr) + *result = append(*result, perm) + return + } + for i := start; i < len(arr); i++ { + arr[start], arr[i] = arr[i], arr[start] + permute(arr, start+1, result) + arr[start], arr[i] = arr[i], arr[start] + } +} diff --git a/tests/501-1000/949. largest-time-for-given-digits/sol.java b/tests/501-1000/949. largest-time-for-given-digits/sol.java new file mode 100644 index 00000000..abd504cc --- /dev/null +++ b/tests/501-1000/949. largest-time-for-given-digits/sol.java @@ -0,0 +1,46 @@ +class Solution { + public String largestTimeFromDigits(int[] arr) { + List permList = new ArrayList<>(); + permute(arr, 0, permList); + + int bestTime = -1; + int bestIdx = -1; + + for (int i = 0; i < permList.size(); i++) { + int[] perm = permList.get(i); + int hours = perm[0] * 10 + perm[1]; + int minutes = perm[2] * 10 + perm[3]; + + if (hours < 24 && minutes < 60) { + int currTime = hours * 60 + minutes; + if (currTime > bestTime) { + bestTime = currTime; + bestIdx = i; + } + } + } + + if (bestIdx == -1) return ""; + + int[] res = permList.get(bestIdx); + return "" + res[0] + res[1] + ":" + res[2] + res[3]; + } + + private void permute(int[] arr, int start, List result) { + if (start == arr.length) { + result.add(arr.clone()); + return; + } + for (int i = start; i < arr.length; i++) { + swap(arr, start, i); + permute(arr, start + 1, result); + swap(arr, start, i); + } + } + + private void swap(int[] arr, int i, int j) { + int tmp = arr[i]; + arr[i] = arr[j]; + arr[j] = tmp; + } +} diff --git a/tests/501-1000/949. largest-time-for-given-digits/sol.kt b/tests/501-1000/949. largest-time-for-given-digits/sol.kt new file mode 100644 index 00000000..0327bc43 --- /dev/null +++ b/tests/501-1000/949. largest-time-for-given-digits/sol.kt @@ -0,0 +1,46 @@ +class Solution { + fun largestTimeFromDigits(arr: IntArray): String { + val permList = mutableListOf() + permute(arr, 0, permList) + + var bestTime = -1 + var bestIdx = -1 + + for (i in permList.indices) { + val perm = permList[i] + val hours = perm[0] * 10 + perm[1] + val minutes = perm[2] * 10 + perm[3] + + if (hours < 24 && minutes < 60) { + val currTime = hours * 60 + minutes + if (currTime > bestTime) { + bestTime = currTime + bestIdx = i + } + } + } + + if (bestIdx == -1) return "" + + val res = permList[bestIdx] + return "${res[0]}${res[1]}:${res[2]}${res[3]}" + } + + private fun permute(arr: IntArray, start: Int, result: MutableList) { + if (start == arr.size) { + result.add(arr.copyOf()) + return + } + for (i in start until arr.size) { + swap(arr, start, i) + permute(arr, start + 1, result) + swap(arr, start, i) + } + } + + private fun swap(arr: IntArray, i: Int, j: Int) { + val tmp = arr[i] + arr[i] = arr[j] + arr[j] = tmp + } +} diff --git a/tests/501-1000/949. largest-time-for-given-digits/sol.py b/tests/501-1000/949. largest-time-for-given-digits/sol.py new file mode 100644 index 00000000..e4c28ccb --- /dev/null +++ b/tests/501-1000/949. largest-time-for-given-digits/sol.py @@ -0,0 +1,30 @@ +from itertools import permutations + + +class Solution(object): + def largestTimeFromDigits(self, arr): + # Generate all 24 possible permutations of the 4 digits + perm_list = list(permutations(arr)) + best_time = -1 + best_idx = -1 + + # Evaluate every permutation configuration + for i, perm in enumerate(perm_list): + hours = perm[0] * 10 + perm[1] + minutes = perm[2] * 10 + perm[3] + + # Check if the permutation forms a valid 24-hour timestamp boundary + if hours < 24 and minutes < 60: + curr_time = hours * 60 + minutes + # Track the largest time configuration found + if curr_time > best_time: + best_time = curr_time + best_idx = i + + # If no configuration was valid, return an empty string + if best_idx == -1: + return "" + + # Reconstruct the string from the best index arrangement + res = perm_list[best_idx] + return str(res[0]) + str(res[1]) + ":" + str(res[2]) + str(res[3]) diff --git a/tests/501-1000/949. largest-time-for-given-digits/sol.py2 b/tests/501-1000/949. largest-time-for-given-digits/sol.py2 new file mode 100644 index 00000000..5aa2e40a --- /dev/null +++ b/tests/501-1000/949. largest-time-for-given-digits/sol.py2 @@ -0,0 +1,22 @@ +class Solution(object): + def largestTimeFromDigits(self, arr): + from itertools import permutations + perm_list = list(permutations(arr)) + best_time = -1 + best_idx = -1 + + for i, perm in enumerate(perm_list): + hours = perm[0] * 10 + perm[1] + minutes = perm[2] * 10 + perm[3] + + if hours < 24 and minutes < 60: + curr_time = hours * 60 + minutes + if curr_time > best_time: + best_time = curr_time + best_idx = i + + if best_idx == -1: + return "" + + res = perm_list[best_idx] + return str(res[0]) + str(res[1]) + ':' + str(res[2]) + str(res[3]) diff --git a/tests/501-1000/949. largest-time-for-given-digits/sol.rb b/tests/501-1000/949. largest-time-for-given-digits/sol.rb new file mode 100644 index 00000000..b60af8c2 --- /dev/null +++ b/tests/501-1000/949. largest-time-for-given-digits/sol.rb @@ -0,0 +1,25 @@ +# @param {Integer[]} arr +# @return {String} +def largest_time_from_digits(arr) + perm_list = arr.permutation.to_a + best_time = -1 + best_idx = -1 + + perm_list.each_with_index do |perm, i| + hours = perm[0] * 10 + perm[1] + minutes = perm[2] * 10 + perm[3] + + if hours < 24 && minutes < 60 + curr_time = hours * 60 + minutes + if curr_time > best_time + best_time = curr_time + best_idx = i + end + end + end + + return "" if best_idx == -1 + + res = perm_list[best_idx] + return res[0].to_s + res[1].to_s + ':' + res[2].to_s + res[3].to_s +end diff --git a/tests/501-1000/949. largest-time-for-given-digits/sol.rs b/tests/501-1000/949. largest-time-for-given-digits/sol.rs new file mode 100644 index 00000000..4a303645 --- /dev/null +++ b/tests/501-1000/949. largest-time-for-given-digits/sol.rs @@ -0,0 +1,43 @@ +impl Solution { + pub fn largest_time_from_digits(arr: Vec) -> String { + let mut arr = arr; + let mut perm_list = Vec::new(); + Self::permute(&mut arr, 0, &mut perm_list); + + let mut best_time: i32 = -1; + let mut best_idx: i32 = -1; + + for i in 0..perm_list.len() { + let perm = &perm_list[i]; + let hours = perm[0] * 10 + perm[1]; + let minutes = perm[2] * 10 + perm[3]; + + if hours < 24 && minutes < 60 { + let curr_time = hours * 60 + minutes; + if curr_time > best_time { + best_time = curr_time; + best_idx = i as i32; + } + } + } + + if best_idx == -1 { + return String::new(); + } + + let res = &perm_list[best_idx as usize]; + format!("{}{}:{}{}", res[0], res[1], res[2], res[3]) + } + + fn permute(arr: &mut Vec, start: usize, result: &mut Vec>) { + if start == arr.len() { + result.push(arr.clone()); + return; + } + for i in start..arr.len() { + arr.swap(start, i); + Self::permute(arr, start + 1, result); + arr.swap(start, i); + } + } +} diff --git a/tests/501-1000/949. largest-time-for-given-digits/sol.swift b/tests/501-1000/949. largest-time-for-given-digits/sol.swift new file mode 100644 index 00000000..77a8be97 --- /dev/null +++ b/tests/501-1000/949. largest-time-for-given-digits/sol.swift @@ -0,0 +1,41 @@ +class Solution { + func largestTimeFromDigits(_ arr: [Int]) -> String { + var arr = arr + var permList: [[Int]] = [] + permute(&arr, 0, &permList) + + var bestTime = -1 + var bestIdx = -1 + + for i in 0.. bestTime { + bestTime = currTime + bestIdx = i + } + } + } + + if bestIdx == -1 { return "" } + + let res = permList[bestIdx] + return "\(res[0])\(res[1]):\(res[2])\(res[3])" + } + + private func permute(_ arr: inout [Int], _ start: Int, _ result: inout [[Int]]) { + if start == arr.count { + result.append(arr) + return + } + for i in start.. bestTime) { + bestTime = currTime; + bestIdx = i; + } + } + } + + if (bestIdx === -1) return ""; + + const res = permList[bestIdx]; + return `${res[0]}${res[1]}:${res[2]}${res[3]}`; +} + +function permute(arr: number[], start: number, result: number[][]): void { + if (start === arr.length) { + result.push([...arr]); + return; + } + for (let i = start; i < arr.length; i++) { + [arr[start], arr[i]] = [arr[i], arr[start]]; + permute(arr, start + 1, result); + [arr[start], arr[i]] = [arr[i], arr[start]]; + } +} diff --git a/tests/501-1000/950. reveal-cards-in-increasing-order/manifest.yaml b/tests/501-1000/950. reveal-cards-in-increasing-order/manifest.yaml new file mode 100644 index 00000000..a543fed9 --- /dev/null +++ b/tests/501-1000/950. reveal-cards-in-increasing-order/manifest.yaml @@ -0,0 +1,550 @@ +entry: + id: 950 + title: reveal-cards-in-increasing-order + params: + deck: + type: array + items: + type: int + call: + cpp: Solution().deckRevealedIncreasing({deck}) + rust: Solution::deck_revealed_increasing({deck}) + python3: Solution().deckRevealedIncreasing({deck}) + python2: Solution().deckRevealedIncreasing({deck}) + ruby: deck_revealed_increasing({deck}) + java: new Solution().deckRevealedIncreasing({deck}) + csharp: new Solution().DeckRevealedIncreasing({deck}) + kotlin: Solution().deckRevealedIncreasing({deck}) + go: deckRevealedIncreasing({deck}) + dart: Solution().deckRevealedIncreasing({deck}) + swift: Solution().deckRevealedIncreasing({deck}) + typescript: deckRevealedIncreasing({deck}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 950 +tests: + - name: case_1 + in: + deck: + - 2 + - 3 + - 5 + - 7 + - 11 + - 13 + - 17 + out: + - 2 + - 13 + - 3 + - 11 + - 5 + - 17 + - 7 + - name: case_2 + in: + deck: + - 1 + out: + - 1 + - name: case_3 + in: + deck: + - 1 + - 2 + out: + - 1 + - 2 + - name: case_4 + in: + deck: + - 1 + - 2 + out: + - 1 + - 2 + - name: case_5 + in: + deck: + - 1 + - 250 + - 500 + - 1000 + out: + - 1 + - 500 + - 250 + - 1000 + - name: case_6 + in: + deck: + - 51 + - 55 + - 105 + - 178 + out: + - 51 + - 105 + - 55 + - 178 + - name: case_7 + in: + deck: + - 8 + - 13 + - 47 + - 54 + - 74 + - 89 + - 109 + - 198 + out: + - 8 + - 74 + - 13 + - 109 + - 47 + - 89 + - 54 + - 198 + - name: case_8 + in: + deck: + - 9 + - 11 + - 120 + - 128 + - 195 + out: + - 9 + - 195 + - 11 + - 128 + - 120 + - name: case_9 + in: + deck: + - 166 + out: + - 166 + - name: case_10 + in: + deck: + - 11 + - 86 + - 98 + out: + - 11 + - 98 + - 86 + - name: case_11 + in: + deck: + - 18 + - 62 + - 70 + - 88 + - 188 + out: + - 18 + - 188 + - 62 + - 88 + - 70 + - name: case_12 + in: + deck: + - 24 + - 41 + - 125 + out: + - 24 + - 125 + - 41 + - name: case_13 + in: + deck: + - 18 + - 62 + - 122 + - 123 + - 160 + - 170 + - 193 + out: + - 18 + - 170 + - 62 + - 160 + - 122 + - 193 + - 123 + - name: case_14 + in: + deck: + - 2 + - 17 + - 184 + out: + - 2 + - 184 + - 17 + - name: case_15 + in: + deck: + - 12 + - 86 + - 128 + - 169 + - 188 + - 189 + out: + - 12 + - 169 + - 86 + - 189 + - 128 + - 188 + - name: case_16 + in: + deck: + - 35 + - 36 + - 43 + - 44 + - 78 + - 145 + - 157 + - 178 + out: + - 35 + - 78 + - 36 + - 157 + - 43 + - 145 + - 44 + - 178 + - name: case_17 + in: + deck: + - 27 + - 59 + - 64 + - 100 + - 107 + - 108 + - 146 + - 148 + - 153 + - 155 + out: + - 27 + - 108 + - 59 + - 155 + - 64 + - 146 + - 100 + - 153 + - 107 + - 148 + - name: case_18 + in: + deck: + - 28 + - 32 + - 40 + - 42 + - 48 + - 79 + - 105 + - 130 + - 171 + - 178 + out: + - 28 + - 79 + - 32 + - 178 + - 40 + - 105 + - 42 + - 171 + - 48 + - 130 + - name: case_19 + in: + deck: + - 37 + - 93 + - 123 + - 138 + - 147 + - 152 + - 153 + out: + - 37 + - 152 + - 93 + - 147 + - 123 + - 153 + - 138 + - name: case_20 + in: + deck: + - 142 + out: + - 142 + - name: case_21 + in: + deck: + - 12 + - 20 + - 45 + - 51 + - 176 + out: + - 12 + - 176 + - 20 + - 51 + - 45 + - name: case_22 + in: + deck: + - 43 + - 137 + out: + - 43 + - 137 + - name: case_23 + in: + deck: + - 81 + - 89 + - 90 + - 100 + out: + - 81 + - 90 + - 89 + - 100 + - name: case_24 + in: + deck: + - 9 + - 14 + - 70 + - 72 + - 118 + - 122 + - 166 + - 181 + - 185 + - 196 + out: + - 9 + - 122 + - 14 + - 196 + - 70 + - 166 + - 72 + - 185 + - 118 + - 181 + - name: case_25 + in: + deck: + - 51 + - 67 + - 116 + - 120 + - 142 + - 166 + - 175 + - 196 + - 199 + out: + - 51 + - 199 + - 67 + - 166 + - 116 + - 196 + - 120 + - 175 + - 142 + - name: case_26 + in: + deck: + - 2 + - 29 + - 34 + - 39 + - 50 + - 67 + - 75 + - 127 + - 189 + out: + - 2 + - 189 + - 29 + - 67 + - 34 + - 127 + - 39 + - 75 + - 50 + - name: case_27 + in: + deck: + - 50 + - 137 + out: + - 50 + - 137 + - name: case_28 + in: + deck: + - 73 + - 193 + out: + - 73 + - 193 + - name: case_29 + in: + deck: + - 118 + out: + - 118 + - name: case_30 + in: + deck: + - 29 + - 75 + - 79 + - 96 + - 131 + - 171 + - 191 + out: + - 29 + - 171 + - 75 + - 131 + - 79 + - 191 + - 96 + - name: case_31 + in: + deck: + - 35 + - 41 + - 62 + - 67 + - 89 + - 113 + - 115 + - 176 + - 180 + - 186 + out: + - 35 + - 113 + - 41 + - 186 + - 62 + - 115 + - 67 + - 180 + - 89 + - 176 + - name: case_32 + in: + deck: + - 36 + - 53 + - 75 + - 84 + - 103 + - 133 + - 153 + - 165 + out: + - 36 + - 103 + - 53 + - 153 + - 75 + - 133 + - 84 + - 165 + - name: case_33 + in: + deck: + - 93 + - 103 + - 114 + - 131 + out: + - 93 + - 114 + - 103 + - 131 + - name: case_34 + in: + deck: + - 5 + - 8 + - 48 + - 56 + - 66 + - 85 + - 106 + - 167 + - 183 + - 197 + out: + - 5 + - 85 + - 8 + - 197 + - 48 + - 106 + - 56 + - 183 + - 66 + - 167 + - name: case_35 + in: + deck: + - 19 + - 26 + - 28 + - 48 + - 69 + - 115 + - 134 + - 149 + - 167 + out: + - 19 + - 167 + - 26 + - 115 + - 28 + - 149 + - 48 + - 134 + - 69 diff --git a/tests/501-1000/950. reveal-cards-in-increasing-order/sol.cpp b/tests/501-1000/950. reveal-cards-in-increasing-order/sol.cpp new file mode 100644 index 00000000..059a82c0 --- /dev/null +++ b/tests/501-1000/950. reveal-cards-in-increasing-order/sol.cpp @@ -0,0 +1,15 @@ +class Solution { +public: + vector deckRevealedIncreasing(vector& deck) { + sort(deck.begin(), deck.end()); + deque rebuild; + rebuild.push_back(deck.back()); + for (int i = deck.size() - 2; i >= 0; i--) { + int last = rebuild.back(); + rebuild.pop_back(); + rebuild.push_front(last); + rebuild.push_front(deck[i]); + } + return vector(rebuild.begin(), rebuild.end()); + } +}; diff --git a/tests/501-1000/950. reveal-cards-in-increasing-order/sol.cs b/tests/501-1000/950. reveal-cards-in-increasing-order/sol.cs new file mode 100644 index 00000000..b7361685 --- /dev/null +++ b/tests/501-1000/950. reveal-cards-in-increasing-order/sol.cs @@ -0,0 +1,14 @@ +public class Solution { + public int[] DeckRevealedIncreasing(int[] deck) { + Array.Sort(deck); + var rebuild = new LinkedList(); + rebuild.AddLast(deck[deck.Length - 1]); + for (int i = deck.Length - 2; i >= 0; i--) { + int last = rebuild.Last.Value; + rebuild.RemoveLast(); + rebuild.AddFirst(last); + rebuild.AddFirst(deck[i]); + } + return rebuild.ToArray(); + } +} diff --git a/tests/501-1000/950. reveal-cards-in-increasing-order/sol.dart b/tests/501-1000/950. reveal-cards-in-increasing-order/sol.dart new file mode 100644 index 00000000..90752744 --- /dev/null +++ b/tests/501-1000/950. reveal-cards-in-increasing-order/sol.dart @@ -0,0 +1,11 @@ +class Solution { + List deckRevealedIncreasing(List deck) { + deck.sort(); + List rebuild = [deck.last]; + for (int i = deck.length - 2; i >= 0; i--) { + rebuild.insert(0, rebuild.removeLast()); + rebuild.insert(0, deck[i]); + } + return rebuild; + } +} diff --git a/tests/501-1000/950. reveal-cards-in-increasing-order/sol.go b/tests/501-1000/950. reveal-cards-in-increasing-order/sol.go new file mode 100644 index 00000000..69a0b67e --- /dev/null +++ b/tests/501-1000/950. reveal-cards-in-increasing-order/sol.go @@ -0,0 +1,12 @@ +func deckRevealedIncreasing(deck []int) []int { + sort.Ints(deck) + n := len(deck) + rebuild := []int{deck[n-1]} + for i := n - 2; i >= 0; i-- { + last := rebuild[len(rebuild)-1] + rebuild = rebuild[:len(rebuild)-1] + rebuild = append([]int{last}, rebuild...) + rebuild = append([]int{deck[i]}, rebuild...) + } + return rebuild +} diff --git a/tests/501-1000/950. reveal-cards-in-increasing-order/sol.java b/tests/501-1000/950. reveal-cards-in-increasing-order/sol.java new file mode 100644 index 00000000..682185f7 --- /dev/null +++ b/tests/501-1000/950. reveal-cards-in-increasing-order/sol.java @@ -0,0 +1,17 @@ +class Solution { + public int[] deckRevealedIncreasing(int[] deck) { + Arrays.sort(deck); + int n = deck.length; + LinkedList rebuild = new LinkedList<>(); + rebuild.add(deck[n - 1]); + for (int i = n - 2; i >= 0; i--) { + rebuild.addFirst(rebuild.removeLast()); + rebuild.addFirst(deck[i]); + } + int[] result = new int[n]; + for (int i = 0; i < n; i++) { + result[i] = rebuild.get(i); + } + return result; + } +} diff --git a/tests/501-1000/950. reveal-cards-in-increasing-order/sol.kt b/tests/501-1000/950. reveal-cards-in-increasing-order/sol.kt new file mode 100644 index 00000000..b3d11f09 --- /dev/null +++ b/tests/501-1000/950. reveal-cards-in-increasing-order/sol.kt @@ -0,0 +1,12 @@ +class Solution { + fun deckRevealedIncreasing(deck: IntArray): IntArray { + deck.sort() + val rebuild = ArrayDeque() + rebuild.addLast(deck.last()) + for (i in deck.size - 2 downTo 0) { + rebuild.addFirst(rebuild.removeLast()) + rebuild.addFirst(deck[i]) + } + return rebuild.toIntArray() + } +} diff --git a/tests/501-1000/950. reveal-cards-in-increasing-order/sol.py b/tests/501-1000/950. reveal-cards-in-increasing-order/sol.py new file mode 100644 index 00000000..5101f027 --- /dev/null +++ b/tests/501-1000/950. reveal-cards-in-increasing-order/sol.py @@ -0,0 +1,22 @@ +from collections import deque + + +class Solution(object): + def deckRevealedIncreasing(self, deck): + # Step 1: Sort the deck to know the target reveal order + deck.sort() + + # Step 2: Initialize a deque with the largest card (the last one revealed) + rebuild = deque([deck[-1]]) + + # Step 3: Iterate through the remaining cards from largest to smallest + # we skip the last one since it's already in the deque + for card in reversed(deck[:-1]): + # Reverse Rule: Take what was at the "bottom" and move it to the "top" + rebuild.appendleft(rebuild.pop()) + + # Undo the reveal: Put the current card on top of the pile + rebuild.appendleft(card) + + # Convert the deque back to a list for the final answer + return list(rebuild) diff --git a/tests/501-1000/950. reveal-cards-in-increasing-order/sol.py2 b/tests/501-1000/950. reveal-cards-in-increasing-order/sol.py2 new file mode 100644 index 00000000..adf7a0a4 --- /dev/null +++ b/tests/501-1000/950. reveal-cards-in-increasing-order/sol.py2 @@ -0,0 +1,8 @@ +class Solution(object): + def deckRevealedIncreasing(self, deck): + deck.sort() + rebuild = [deck[-1]] + for card in reversed(deck[:-1]): + rebuild.insert(0, rebuild.pop()) + rebuild.insert(0, card) + return rebuild diff --git a/tests/501-1000/950. reveal-cards-in-increasing-order/sol.rb b/tests/501-1000/950. reveal-cards-in-increasing-order/sol.rb new file mode 100644 index 00000000..5e041e90 --- /dev/null +++ b/tests/501-1000/950. reveal-cards-in-increasing-order/sol.rb @@ -0,0 +1,11 @@ +# @param {Integer[]} deck +# @return {Integer[]} +def deck_revealed_increasing(deck) + deck.sort! + rebuild = [deck[-1]] + deck[0...-1].reverse_each do |card| + rebuild.unshift(rebuild.pop) + rebuild.unshift(card) + end + rebuild +end diff --git a/tests/501-1000/950. reveal-cards-in-increasing-order/sol.rs b/tests/501-1000/950. reveal-cards-in-increasing-order/sol.rs new file mode 100644 index 00000000..201a67b7 --- /dev/null +++ b/tests/501-1000/950. reveal-cards-in-increasing-order/sol.rs @@ -0,0 +1,14 @@ +impl Solution { + pub fn deck_revealed_increasing(deck: Vec) -> Vec { + let mut deck = deck; + deck.sort(); + let mut rebuild = std::collections::VecDeque::new(); + rebuild.push_back(deck[deck.len() - 1]); + for i in (0..deck.len() - 1).rev() { + let last = rebuild.pop_back().unwrap(); + rebuild.push_front(last); + rebuild.push_front(deck[i]); + } + rebuild.into_iter().collect() + } +} diff --git a/tests/501-1000/950. reveal-cards-in-increasing-order/sol.swift b/tests/501-1000/950. reveal-cards-in-increasing-order/sol.swift new file mode 100644 index 00000000..9054c957 --- /dev/null +++ b/tests/501-1000/950. reveal-cards-in-increasing-order/sol.swift @@ -0,0 +1,11 @@ +class Solution { + func deckRevealedIncreasing(_ deck: [Int]) -> [Int] { + var deck = deck.sorted() + var rebuild = [deck.removeLast()] + while let card = deck.popLast() { + rebuild.insert(rebuild.removeLast(), at: 0) + rebuild.insert(card, at: 0) + } + return rebuild + } +} diff --git a/tests/501-1000/950. reveal-cards-in-increasing-order/sol.ts b/tests/501-1000/950. reveal-cards-in-increasing-order/sol.ts new file mode 100644 index 00000000..c5ef4009 --- /dev/null +++ b/tests/501-1000/950. reveal-cards-in-increasing-order/sol.ts @@ -0,0 +1,9 @@ +function deckRevealedIncreasing(deck: number[]): number[] { + deck.sort((a, b) => a - b); + const rebuild: number[] = [deck[deck.length - 1]]; + for (let i = deck.length - 2; i >= 0; i--) { + rebuild.unshift(rebuild.pop()!); + rebuild.unshift(deck[i]); + } + return rebuild; +} diff --git a/tests/501-1000/951. flip-equivalent-binary-trees/manifest.yaml b/tests/501-1000/951. flip-equivalent-binary-trees/manifest.yaml new file mode 100644 index 00000000..96051f91 --- /dev/null +++ b/tests/501-1000/951. flip-equivalent-binary-trees/manifest.yaml @@ -0,0 +1,627 @@ +entry: + id: 951 + title: flip-equivalent-binary-trees + params: + root1: + type: tree_node + root2: + type: tree_node + call: + cpp: Solution().flipEquiv({root1}, {root2}) + rust: Solution::flip_equiv({root1}, {root2}) + python3: Solution().flipEquiv({root1}, {root2}) + python2: Solution().flipEquiv({root1}, {root2}) + ruby: flip_equiv({root1}, {root2}) + java: new Solution().flipEquiv({root1}, {root2}) + csharp: new Solution().FlipEquiv({root1}, {root2}) + kotlin: Solution().flipEquiv({root1}, {root2}) + go: flipEquiv({root1}, {root2}) + dart: Solution().flipEquiv({root1}, {root2}) + swift: Solution().flipEquiv({root1}, {root2}) + typescript: flipEquiv({root1}, {root2}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 951 +tests: + - name: case_1 + in: + root1: [] + root2: + - 1 + - 2 + - 3 + - null + - 4 + - null + - null + - null + - 5 + - 6 + out: false + - name: case_2 + in: + root1: + - 1 + - 2 + - 3 + root2: + - 1 + - null + - 2 + - 3 + out: false + - name: case_3 + in: + root1: + - 1 + - null + - null + - 2 + - 3 + root2: + - 1 + - 2 + - null + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + out: false + - name: case_4 + in: + root1: + - 1 + root2: + - 1 + - null + - 2 + - 3 + - null + - 4 + - 5 + - null + - null + - 6 + - 7 + - 8 + out: false + - name: case_5 + in: + root1: + - 1 + - 2 + - 3 + - 4 + - 5 + - null + - 6 + root2: + - 1 + - 2 + - null + - 3 + - null + - 4 + - 5 + - 6 + - null + - 7 + - null + - null + - 8 + - null + - 9 + - 10 + out: false + - name: case_6 + in: + root1: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + root2: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - null + - 7 + - 8 + - 9 + out: false + - name: case_7 + in: + root1: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + root2: + - 1 + - 2 + - 3 + - 4 + - 5 + - null + - null + - 6 + - null + - 7 + - 8 + - 9 + - 10 + out: false + - name: case_8 + in: + root1: + - 1 + root2: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + out: false + - name: case_9 + in: + root1: + - 1 + - 2 + - 3 + root2: + - 1 + - 2 + - 3 + out: true + - name: case_10 + in: + root1: + - 1 + - null + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - null + - null + - 8 + - 9 + - 10 + root2: [] + out: false + - name: case_11 + in: + root1: + - 1 + - 2 + root2: + - 1 + - null + - 2 + out: true + - name: case_12 + in: + root1: + - 1 + - 2 + - 3 + - null + - 4 + - null + - null + - null + - null + - 5 + - 6 + - 7 + root2: + - 1 + - 2 + out: false + - name: case_13 + in: + root1: + - 1 + - null + - 2 + - 3 + - 4 + - null + - 5 + - null + - 6 + - null + - 7 + - 8 + root2: + - 1 + - null + - 2 + out: false + - name: case_14 + in: + root1: + - 1 + - 2 + root2: + - 1 + - null + - null + - 2 + - 3 + - 4 + - 5 + out: false + - name: case_15 + in: + root1: + - 1 + - null + - 2 + root2: + - 1 + - null + - 2 + - null + - 3 + - null + - 4 + - 5 + out: false + - name: case_16 + in: + root1: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - null + - 8 + - 9 + root2: + - 1 + - 2 + out: false + - name: case_17 + in: + root1: + - 1 + - null + - 2 + - 3 + - 4 + root2: + - 1 + out: false + - name: case_18 + in: + root1: + - 1 + - 2 + - 3 + - 4 + - 5 + root2: + - 1 + out: false + - name: case_19 + in: + root1: + - 1 + - 2 + - 3 + - 4 + - null + - 5 + - null + - 6 + - null + - 7 + - 8 + - 9 + - 10 + root2: + - 1 + - 2 + - null + - 3 + - null + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + out: false + - name: case_20 + in: + root1: + - 1 + - 2 + - 3 + - null + - 4 + - 5 + - null + - 6 + - 7 + root2: + - 1 + out: false + - name: case_21 + in: + root1: + - 1 + - null + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + root2: + - 1 + - null + - null + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + out: false + - name: case_22 + in: + root1: + - 1 + - null + - null + - 2 + root2: + - 1 + - null + - null + - 2 + out: true + - name: case_23 + in: + root1: + - 1 + - 2 + root2: + - 1 + - null + - 2 + - null + - null + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + out: true + - name: case_24 + in: + root1: + - 1 + - 2 + - 3 + - 4 + - null + - 5 + - 6 + - 7 + - 8 + - 9 + root2: + - 1 + - 2 + - 3 + - null + - 4 + out: false + - name: case_25 + in: + root1: + - 1 + - 2 + - 3 + root2: + - 1 + - 2 + - null + - 3 + - 4 + - 5 + out: false + - name: case_26 + in: + root1: + - 1 + - 2 + - 3 + - 4 + root2: + - 1 + - 2 + - 3 + - null + - null + - 4 + - 5 + - 6 + - 7 + out: false + - name: case_27 + in: + root1: + - 1 + - 2 + - 3 + - 4 + - 5 + root2: + - 1 + - 2 + - 3 + - 4 + - null + - 5 + - null + - 6 + - 7 + - null + - 8 + - 9 + - 10 + out: false + - name: case_28 + in: + root1: [] + root2: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + out: false + - name: case_29 + in: + root1: [] + root2: + - 1 + - 2 + out: false + - name: case_30 + in: + root1: + - 1 + root2: + - 1 + - 2 + out: false + - name: case_31 + in: + root1: + - 1 + - null + - null + - 2 + root2: + - 1 + - null + - null + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + out: true + - name: case_32 + in: + root1: + - 1 + - 2 + root2: + - 1 + - 2 + - 3 + - 4 + - 5 + - null + - null + - 6 + - 7 + out: false + - name: case_33 + in: + root1: + - 1 + - 2 + - 3 + - 4 + - null + - 5 + - null + - 6 + - 7 + - 8 + - 9 + - 10 + root2: + - 1 + - 2 + - null + - 3 + - 4 + out: false + - name: case_34 + in: + root1: + - 1 + - 2 + - 3 + - 4 + - 5 + - null + - null + - 6 + - 7 + - 8 + - 9 + - 10 + root2: + - 1 + - 2 + out: false + - name: case_35 + in: + root1: + - 1 + - 2 + root2: + - 1 + out: false diff --git a/tests/501-1000/951. flip-equivalent-binary-trees/sol.cpp b/tests/501-1000/951. flip-equivalent-binary-trees/sol.cpp new file mode 100644 index 00000000..e0b68718 --- /dev/null +++ b/tests/501-1000/951. flip-equivalent-binary-trees/sol.cpp @@ -0,0 +1,25 @@ +/** + * Definition for a binary tree node. + * struct TreeNode { + * int val; + * TreeNode *left; + * TreeNode *right; + * TreeNode() : val(0), left(nullptr), right(nullptr) {} + * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} + * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} + * }; + */ +class Solution { +public: + bool flipEquiv(TreeNode* root1, TreeNode* root2) { + if (root1 == nullptr && root2 == nullptr) { + return true; + } else if (root1 == nullptr || root2 == nullptr || root1->val != root2->val) { + return false; + } else { + bool noFlip = flipEquiv(root1->left, root2->left) && flipEquiv(root1->right, root2->right); + bool yesFlip = flipEquiv(root1->left, root2->right) && flipEquiv(root1->right, root2->left); + return noFlip || yesFlip; + } + } +}; diff --git a/tests/501-1000/951. flip-equivalent-binary-trees/sol.cs b/tests/501-1000/951. flip-equivalent-binary-trees/sol.cs new file mode 100644 index 00000000..b49064d9 --- /dev/null +++ b/tests/501-1000/951. flip-equivalent-binary-trees/sol.cs @@ -0,0 +1,26 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public int val; + * public TreeNode left; + * public TreeNode right; + * public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +public class Solution { + public bool FlipEquiv(TreeNode root1, TreeNode root2) { + if (root1 == null && root2 == null) { + return true; + } else if (root1 == null || root2 == null || root1.val != root2.val) { + return false; + } else { + bool noFlip = FlipEquiv(root1.left, root2.left) && FlipEquiv(root1.right, root2.right); + bool yesFlip = FlipEquiv(root1.left, root2.right) && FlipEquiv(root1.right, root2.left); + return noFlip || yesFlip; + } + } +} diff --git a/tests/501-1000/951. flip-equivalent-binary-trees/sol.dart b/tests/501-1000/951. flip-equivalent-binary-trees/sol.dart new file mode 100644 index 00000000..3228b02c --- /dev/null +++ b/tests/501-1000/951. flip-equivalent-binary-trees/sol.dart @@ -0,0 +1,22 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * int val; + * TreeNode? left; + * TreeNode? right; + * TreeNode([this.val = 0, this.left, this.right]); + * } + */ +class Solution { + bool flipEquiv(TreeNode? root1, TreeNode? root2) { + if (root1 == null && root2 == null) { + return true; + } else if (root1 == null || root2 == null || root1.val != root2.val) { + return false; + } else { + bool noFlip = flipEquiv(root1.left, root2.left) && flipEquiv(root1.right, root2.right); + bool yesFlip = flipEquiv(root1.left, root2.right) && flipEquiv(root1.right, root2.left); + return noFlip || yesFlip; + } + } +} diff --git a/tests/501-1000/951. flip-equivalent-binary-trees/sol.go b/tests/501-1000/951. flip-equivalent-binary-trees/sol.go new file mode 100644 index 00000000..8cd3695c --- /dev/null +++ b/tests/501-1000/951. flip-equivalent-binary-trees/sol.go @@ -0,0 +1,19 @@ +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +func flipEquiv(root1 *TreeNode, root2 *TreeNode) bool { + if root1 == nil && root2 == nil { + return true + } else if root1 == nil || root2 == nil || root1.Val != root2.Val { + return false + } else { + noFlip := flipEquiv(root1.Left, root2.Left) && flipEquiv(root1.Right, root2.Right) + yesFlip := flipEquiv(root1.Left, root2.Right) && flipEquiv(root1.Right, root2.Left) + return noFlip || yesFlip + } +} diff --git a/tests/501-1000/951. flip-equivalent-binary-trees/sol.java b/tests/501-1000/951. flip-equivalent-binary-trees/sol.java new file mode 100644 index 00000000..dd7a1477 --- /dev/null +++ b/tests/501-1000/951. flip-equivalent-binary-trees/sol.java @@ -0,0 +1,28 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode() {} + * TreeNode(int val) { this.val = val; } + * TreeNode(int val, TreeNode left, TreeNode right) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +class Solution { + public boolean flipEquiv(TreeNode root1, TreeNode root2) { + if (root1 == null && root2 == null) { + return true; + } else if (root1 == null || root2 == null || root1.val != root2.val) { + return false; + } else { + boolean noFlip = flipEquiv(root1.left, root2.left) && flipEquiv(root1.right, root2.right); + boolean yesFlip = flipEquiv(root1.left, root2.right) && flipEquiv(root1.right, root2.left); + return noFlip || yesFlip; + } + } +} diff --git a/tests/501-1000/951. flip-equivalent-binary-trees/sol.kt b/tests/501-1000/951. flip-equivalent-binary-trees/sol.kt new file mode 100644 index 00000000..f05e8459 --- /dev/null +++ b/tests/501-1000/951. flip-equivalent-binary-trees/sol.kt @@ -0,0 +1,23 @@ +/** + * Example: + * var ti = TreeNode(5) + * var v = ti.`val` + * Definition for a binary tree node. + * class TreeNode(var `val`: Int) { + * var left: TreeNode? = null + * var right: TreeNode? = null + * } + */ +class Solution { + fun flipEquiv(root1: TreeNode?, root2: TreeNode?): Boolean { + if (root1 == null && root2 == null) { + return true + } else if (root1 == null || root2 == null || root1.`val` != root2.`val`) { + return false + } else { + val noFlip = flipEquiv(root1.left, root2.left) && flipEquiv(root1.right, root2.right) + val yesFlip = flipEquiv(root1.left, root2.right) && flipEquiv(root1.right, root2.left) + return noFlip || yesFlip + } + } +} diff --git a/tests/501-1000/951. flip-equivalent-binary-trees/sol.py b/tests/501-1000/951. flip-equivalent-binary-trees/sol.py new file mode 100644 index 00000000..c092bcb6 --- /dev/null +++ b/tests/501-1000/951. flip-equivalent-binary-trees/sol.py @@ -0,0 +1,23 @@ +# Definition for a binary tree node. +# class TreeNode: +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +from typing import Optional + + +class Solution: + def flipEquiv(self, root1: Optional[TreeNode], root2: Optional[TreeNode]) -> bool: + if not root1 and not root2: + return True + elif not root1 or not root2 or root1.val != root2.val: + return False + else: + no_flip = self.flipEquiv(root1.left, root2.left) and self.flipEquiv( + root1.right, root2.right + ) + yes_flip = self.flipEquiv(root1.left, root2.right) and self.flipEquiv( + root1.right, root2.left + ) + return no_flip or yes_flip diff --git a/tests/501-1000/951. flip-equivalent-binary-trees/sol.py2 b/tests/501-1000/951. flip-equivalent-binary-trees/sol.py2 new file mode 100644 index 00000000..c4c7c664 --- /dev/null +++ b/tests/501-1000/951. flip-equivalent-binary-trees/sol.py2 @@ -0,0 +1,21 @@ +# Definition for a binary tree node. +# class TreeNode(object): +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution(object): + def flipEquiv(self, root1, root2): + """ + :type root1: Optional[TreeNode] + :type root2: Optional[TreeNode] + :rtype: bool + """ + if not root1 and not root2: + return True + elif not root1 or not root2 or root1.val != root2.val: + return False + else: + no_flip = self.flipEquiv(root1.left, root2.left) and self.flipEquiv(root1.right, root2.right) + yes_flip = self.flipEquiv(root1.left, root2.right) and self.flipEquiv(root1.right, root2.left) + return no_flip or yes_flip diff --git a/tests/501-1000/951. flip-equivalent-binary-trees/sol.rb b/tests/501-1000/951. flip-equivalent-binary-trees/sol.rb new file mode 100644 index 00000000..f9af8cf5 --- /dev/null +++ b/tests/501-1000/951. flip-equivalent-binary-trees/sol.rb @@ -0,0 +1,23 @@ +# Definition for a binary tree node. +# class TreeNode +# attr_accessor :val, :left, :right +# def initialize(val = 0, left = nil, right = nil) +# @val = val +# @left = left +# @right = right +# end +# end +# @param {TreeNode} root1 +# @param {TreeNode} root2 +# @return {Boolean} +def flip_equiv(root1, root2) + if root1.nil? && root2.nil? + return true + elsif root1.nil? || root2.nil? || root1.val != root2.val + return false + else + no_flip = flip_equiv(root1.left, root2.left) && flip_equiv(root1.right, root2.right) + yes_flip = flip_equiv(root1.left, root2.right) && flip_equiv(root1.right, root2.left) + return no_flip || yes_flip + end +end diff --git a/tests/501-1000/951. flip-equivalent-binary-trees/sol.rs b/tests/501-1000/951. flip-equivalent-binary-trees/sol.rs new file mode 100644 index 00000000..053320a3 --- /dev/null +++ b/tests/501-1000/951. flip-equivalent-binary-trees/sol.rs @@ -0,0 +1,36 @@ +// Definition for a binary tree node. +// #[derive(Debug, PartialEq, Eq)] +// pub struct TreeNode { +// pub val: i32, +// pub left: Option>>, +// pub right: Option>>, +// } +// +// impl TreeNode { +// #[inline] +// pub fn new(val: i32) -> Self { +// TreeNode { +// val, +// left: None, +// right: None +// } +// } +// } +impl Solution { + pub fn flip_equiv(root1: Option>>, root2: Option>>) -> bool { + match (root1, root2) { + (None, None) => true, + (Some(n1), Some(n2)) => { + let n1 = n1.borrow(); + let n2 = n2.borrow(); + if n1.val != n2.val { + return false; + } + let no_flip = Self::flip_equiv(n1.left.clone(), n2.left.clone()) && Self::flip_equiv(n1.right.clone(), n2.right.clone()); + let yes_flip = Self::flip_equiv(n1.left.clone(), n2.right.clone()) && Self::flip_equiv(n1.right.clone(), n2.left.clone()); + no_flip || yes_flip + }, + _ => false, + } + } +} diff --git a/tests/501-1000/951. flip-equivalent-binary-trees/sol.swift b/tests/501-1000/951. flip-equivalent-binary-trees/sol.swift new file mode 100644 index 00000000..bfd5730c --- /dev/null +++ b/tests/501-1000/951. flip-equivalent-binary-trees/sol.swift @@ -0,0 +1,28 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public var val: Int + * public var left: TreeNode? + * public var right: TreeNode? + * public init() { self.val = 0; self.left = nil; self.right = nil; } + * public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; } + * public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) { + * self.val = val + * self.left = left + * self.right = right + * } + * } + */ +class Solution { + func flipEquiv(_ root1: TreeNode?, _ root2: TreeNode?) -> Bool { + if root1 == nil && root2 == nil { + return true + } else if root1 == nil || root2 == nil || root1!.val != root2!.val { + return false + } else { + let noFlip = flipEquiv(root1!.left, root2!.left) && flipEquiv(root1!.right, root2!.right) + let yesFlip = flipEquiv(root1!.left, root2!.right) && flipEquiv(root1!.right, root2!.left) + return noFlip || yesFlip + } + } +} diff --git a/tests/501-1000/951. flip-equivalent-binary-trees/sol.ts b/tests/501-1000/951. flip-equivalent-binary-trees/sol.ts new file mode 100644 index 00000000..22a64246 --- /dev/null +++ b/tests/501-1000/951. flip-equivalent-binary-trees/sol.ts @@ -0,0 +1,27 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ + +function flipEquiv(root1: TreeNode | null, root2: TreeNode | null): boolean { + if (root1 === null && root2 === null) { + return true; + } else if (root1 === null || root2 === null || root1.val !== root2.val) { + return false; + } else { + const noFlip = + flipEquiv(root1.left, root2.left) && flipEquiv(root1.right, root2.right); + const yesFlip = + flipEquiv(root1.left, root2.right) && flipEquiv(root1.right, root2.left); + return noFlip || yesFlip; + } +} diff --git a/tests/501-1000/952. largest-component-size-by-common-factor/manifest.yaml b/tests/501-1000/952. largest-component-size-by-common-factor/manifest.yaml new file mode 100644 index 00000000..c9f60039 --- /dev/null +++ b/tests/501-1000/952. largest-component-size-by-common-factor/manifest.yaml @@ -0,0 +1,361 @@ +entry: + id: 952 + title: largest-component-size-by-common-factor + params: + nums: + type: array + items: + type: int + call: + cpp: Solution().largestComponentSize({nums}) + rust: Solution::largest_component_size({nums}) + python3: Solution().largestComponentSize({nums}) + python2: Solution().largestComponentSize({nums}) + ruby: largest_component_size({nums}) + java: new Solution().largestComponentSize({nums}) + csharp: new Solution().LargestComponentSize({nums}) + kotlin: Solution().largestComponentSize({nums}) + go: largestComponentSize({nums}) + dart: Solution().largestComponentSize({nums}) + swift: Solution().largestComponentSize({nums}) + typescript: largestComponentSize({nums}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 952 +tests: + - name: case_1 + in: + nums: + - 36 + - 13 + - 26 + - 7 + - 30 + out: 4 + - name: case_2 + in: + nums: + - 58 + - 37 + - 4 + - 32 + - 35 + - 19 + - 38 + - 47 + out: 5 + - name: case_3 + in: + nums: + - 22 + - 42 + - 41 + - 41 + - 4 + - 37 + - 9 + - 44 + - 50 + out: 6 + - name: case_4 + in: + nums: + - 3 + - 36 + - 4 + - 28 + - 46 + out: 5 + - name: case_5 + in: + nums: + - 10 + out: 1 + - name: case_6 + in: + nums: + - 48 + - 46 + - 26 + - 25 + - 50 + - 56 + out: 6 + - name: case_7 + in: + nums: + - 36 + - 46 + - 54 + - 13 + - 18 + - 27 + out: 5 + - name: case_8 + in: + nums: + - 18 + - 60 + - 39 + - 57 + - 13 + - 39 + out: 6 + - name: case_9 + in: + nums: + - 57 + - 20 + - 32 + - 49 + - 60 + - 51 + - 33 + - 20 + - 4 + - 13 + out: 8 + - name: case_10 + in: + nums: + - 12 + - 10 + - 22 + - 60 + - 14 + - 30 + - 14 + - 50 + - 47 + - 31 + out: 8 + - name: case_11 + in: + nums: + - 42 + out: 1 + - name: case_12 + in: + nums: + - 28 + - 31 + out: 1 + - name: case_13 + in: + nums: + - 3 + out: 1 + - name: case_14 + in: + nums: + - 37 + - 40 + - 46 + - 17 + - 53 + - 13 + - 52 + - 11 + - 40 + out: 5 + - name: case_15 + in: + nums: + - 50 + - 5 + - 15 + - 24 + - 55 + - 51 + - 2 + out: 7 + - name: case_16 + in: + nums: + - 9 + - 45 + - 54 + - 47 + - 39 + - 12 + - 40 + - 7 + - 42 + - 10 + out: 9 + - name: case_17 + in: + nums: + - 56 + - 17 + - 38 + - 15 + - 33 + out: 2 + - name: case_18 + in: + nums: + - 43 + - 33 + - 58 + - 39 + - 12 + - 26 + out: 5 + - name: case_19 + in: + nums: + - 21 + - 48 + - 54 + - 18 + - 34 + - 56 + - 44 + - 17 + out: 8 + - name: case_20 + in: + nums: + - 11 + - 30 + - 21 + - 12 + - 60 + - 19 + - 10 + - 50 + - 10 + out: 7 + - name: case_21 + in: + nums: + - 7 + - 7 + - 33 + - 16 + out: 2 + - name: case_22 + in: + nums: + - 29 + out: 1 + - name: case_23 + in: + nums: + - 51 + out: 1 + - name: case_24 + in: + nums: + - 51 + out: 1 + - name: case_25 + in: + nums: + - 10 + - 44 + - 13 + - 42 + - 20 + - 27 + - 6 + out: 6 + - name: case_26 + in: + nums: + - 6 + - 4 + - 26 + - 49 + - 14 + - 26 + - 35 + - 39 + - 47 + out: 8 + - name: case_27 + in: + nums: + - 45 + out: 1 + - name: case_28 + in: + nums: + - 6 + - 7 + - 13 + - 7 + - 59 + - 17 + out: 2 + - name: case_29 + in: + nums: + - 38 + - 39 + - 40 + out: 2 + - name: case_30 + in: + nums: + - 4 + - 31 + - 31 + - 59 + - 10 + - 16 + - 33 + - 41 + - 60 + out: 5 + - name: case_31 + in: + nums: + - 13 + - 57 + - 9 + - 53 + - 28 + - 6 + - 2 + - 37 + out: 5 + - name: case_32 + in: + nums: + - 21 + - 31 + - 32 + out: 1 + - name: case_33 + in: + nums: + - 55 + - 57 + - 5 + - 7 + - 37 + out: 2 + - name: case_34 + in: + nums: + - 24 + - 14 + - 52 + out: 3 + - name: case_35 + in: + nums: + - 29 + - 26 + - 11 + - 56 + out: 2 diff --git a/tests/501-1000/952. largest-component-size-by-common-factor/sol.cpp b/tests/501-1000/952. largest-component-size-by-common-factor/sol.cpp new file mode 100644 index 00000000..8ad17b73 --- /dev/null +++ b/tests/501-1000/952. largest-component-size-by-common-factor/sol.cpp @@ -0,0 +1,66 @@ +class Solution { +public: + int largestComponentSize(vector& nums) { + int n = nums.size(); + vector root(n); + vector rank(n, 1); + for (int i = 0; i < n; i++) root[i] = i; + + function find = [&](int x) { + while (root[x] != x) { + root[x] = root[root[x]]; + x = root[x]; + } + return x; + }; + + function unionSet = [&](int x, int y) { + int rx = find(x); + int ry = find(y); + if (rx == ry) return; + if (rank[rx] > rank[ry]) { + root[ry] = rx; + } else if (rank[rx] < rank[ry]) { + root[rx] = ry; + } else { + root[ry] = rx; + rank[rx]++; + } + }; + + auto getPrimeFactors = [](int n) { + vector res; + if (n % 2 == 0) { + res.push_back(2); + while (n % 2 == 0) n /= 2; + } + for (int i = 3; i * i <= n; i += 2) { + if (n % i == 0) { + res.push_back(i); + while (n % i == 0) n /= i; + } + } + if (n > 2) res.push_back(n); + return res; + }; + + unordered_map primeToIdx; + for (int i = 0; i < n; i++) { + vector primes = getPrimeFactors(nums[i]); + for (int p : primes) { + if (primeToIdx.count(p)) { + unionSet(primeToIdx[p], i); + } + primeToIdx[p] = i; + } + } + + unordered_map count; + int maxSize = 0; + for (int i = 0; i < n; i++) { + int r = find(i); + maxSize = max(maxSize, ++count[r]); + } + return maxSize; + } +}; diff --git a/tests/501-1000/952. largest-component-size-by-common-factor/sol.cs b/tests/501-1000/952. largest-component-size-by-common-factor/sol.cs new file mode 100644 index 00000000..96805ff0 --- /dev/null +++ b/tests/501-1000/952. largest-component-size-by-common-factor/sol.cs @@ -0,0 +1,71 @@ +public class Solution { + public int LargestComponentSize(int[] nums) { + int n = nums.Length; + int[] root = new int[n]; + int[] rank = new int[n]; + for (int i = 0; i < n; i++) { + root[i] = i; + rank[i] = 1; + } + + int Find(int x) { + while (root[x] != x) { + root[x] = root[root[x]]; + x = root[x]; + } + return x; + } + + void Union(int x, int y) { + int rx = Find(x); + int ry = Find(y); + if (rx == ry) return; + if (rank[rx] > rank[ry]) { + root[ry] = rx; + } else if (rank[rx] < rank[ry]) { + root[rx] = ry; + } else { + root[ry] = rx; + rank[rx]++; + } + } + + List GetPrimeFactors(int num) { + List res = new List(); + int n = num; + if (n % 2 == 0) { + res.Add(2); + while (n % 2 == 0) n /= 2; + } + for (int i = 3; i * i <= n; i += 2) { + if (n % i == 0) { + res.Add(i); + while (n % i == 0) n /= i; + } + } + if (n > 2) res.Add(n); + return res; + } + + Dictionary primeToIdx = new Dictionary(); + for (int i = 0; i < n; i++) { + List primes = GetPrimeFactors(nums[i]); + foreach (int p in primes) { + if (primeToIdx.ContainsKey(p)) { + Union(primeToIdx[p], i); + } + primeToIdx[p] = i; + } + } + + Dictionary count = new Dictionary(); + int maxSize = 0; + for (int i = 0; i < n; i++) { + int r = Find(i); + if (!count.ContainsKey(r)) count[r] = 0; + count[r]++; + if (count[r] > maxSize) maxSize = count[r]; + } + return maxSize; + } +} diff --git a/tests/501-1000/952. largest-component-size-by-common-factor/sol.dart b/tests/501-1000/952. largest-component-size-by-common-factor/sol.dart new file mode 100644 index 00000000..7f95b4d3 --- /dev/null +++ b/tests/501-1000/952. largest-component-size-by-common-factor/sol.dart @@ -0,0 +1,66 @@ +class Solution { + int largestComponentSize(List nums) { + int n = nums.length; + List root = List.generate(n, (i) => i); + List rank = List.filled(n, 1); + + int find(int x) { + while (root[x] != x) { + root[x] = root[root[x]]; + x = root[x]; + } + return x; + } + + void union(int x, int y) { + int rx = find(x); + int ry = find(y); + if (rx == ry) return; + if (rank[rx] > rank[ry]) { + root[ry] = rx; + } else if (rank[rx] < rank[ry]) { + root[rx] = ry; + } else { + root[ry] = rx; + rank[rx]++; + } + } + + List getPrimeFactors(int num) { + List res = []; + int n = num; + if (n % 2 == 0) { + res.add(2); + while (n % 2 == 0) n ~/= 2; + } + for (int i = 3; i * i <= n; i += 2) { + if (n % i == 0) { + res.add(i); + while (n % i == 0) n ~/= i; + } + } + if (n > 2) res.add(n); + return res; + } + + Map primeToIdx = {}; + for (int i = 0; i < n; i++) { + List primes = getPrimeFactors(nums[i]); + for (int p in primes) { + if (primeToIdx.containsKey(p)) { + union(primeToIdx[p]!, i); + } + primeToIdx[p] = i; + } + } + + Map count = {}; + int maxSize = 0; + for (int i = 0; i < n; i++) { + int r = find(i); + count[r] = (count[r] ?? 0) + 1; + if (count[r]! > maxSize) maxSize = count[r]!; + } + return maxSize; + } +} diff --git a/tests/501-1000/952. largest-component-size-by-common-factor/sol.go b/tests/501-1000/952. largest-component-size-by-common-factor/sol.go new file mode 100644 index 00000000..a0fd50bb --- /dev/null +++ b/tests/501-1000/952. largest-component-size-by-common-factor/sol.go @@ -0,0 +1,78 @@ +func largestComponentSize(nums []int) int { + n := len(nums) + root := make([]int, n) + rank := make([]int, n) + for i := 0; i < n; i++ { + root[i] = i + rank[i] = 1 + } + + var find func(int) int + find = func(x int) int { + for root[x] != x { + root[x] = root[root[x]] + x = root[x] + } + return x + } + + union := func(x, y int) { + rx, ry := find(x), find(y) + if rx == ry { + return + } + if rank[rx] > rank[ry] { + root[ry] = rx + } else if rank[rx] < rank[ry] { + root[rx] = ry + } else { + root[ry] = rx + rank[rx]++ + } + } + + getPrimeFactors := func(num int) []int { + res := []int{} + n := num + if n%2 == 0 { + res = append(res, 2) + for n%2 == 0 { + n /= 2 + } + } + for i := 3; i*i <= n; i += 2 { + if n%i == 0 { + res = append(res, i) + for n%i == 0 { + n /= i + } + } + } + if n > 2 { + res = append(res, n) + } + return res + } + + primeToIdx := make(map[int]int) + for i, num := range nums { + primes := getPrimeFactors(num) + for _, p := range primes { + if idx, ok := primeToIdx[p]; ok { + union(idx, i) + } + primeToIdx[p] = i + } + } + + count := make(map[int]int) + maxSize := 0 + for i := 0; i < n; i++ { + r := find(i) + count[r]++ + if count[r] > maxSize { + maxSize = count[r] + } + } + return maxSize +} diff --git a/tests/501-1000/952. largest-component-size-by-common-factor/sol.java b/tests/501-1000/952. largest-component-size-by-common-factor/sol.java new file mode 100644 index 00000000..19c4062d --- /dev/null +++ b/tests/501-1000/952. largest-component-size-by-common-factor/sol.java @@ -0,0 +1,73 @@ +import java.util.*; + +class Solution { + public int largestComponentSize(int[] nums) { + int n = nums.length; + int[] root = new int[n]; + int[] rank = new int[n]; + for (int i = 0; i < n; i++) { + root[i] = i; + rank[i] = 1; + } + + Map primeToIdx = new HashMap<>(); + + for (int i = 0; i < n; i++) { + List primes = getPrimeFactors(nums[i]); + for (int p : primes) { + if (primeToIdx.containsKey(p)) { + union(root, rank, primeToIdx.get(p), i); + } + primeToIdx.put(p, i); + } + } + + Map count = new HashMap<>(); + int max = 0; + for (int i = 0; i < n; i++) { + int r = find(root, i); + int c = count.getOrDefault(r, 0) + 1; + count.put(r, c); + if (c > max) max = c; + } + return max; + } + + private List getPrimeFactors(int n) { + List factors = new ArrayList<>(); + if (n % 2 == 0) { + factors.add(2); + while (n % 2 == 0) n /= 2; + } + for (int i = 3; i * i <= n; i += 2) { + if (n % i == 0) { + factors.add(i); + while (n % i == 0) n /= i; + } + } + if (n > 2) factors.add(n); + return factors; + } + + private int find(int[] root, int x) { + while (root[x] != x) { + root[x] = root[root[x]]; + x = root[x]; + } + return x; + } + + private void union(int[] root, int[] rank, int x, int y) { + int rx = find(root, x); + int ry = find(root, y); + if (rx == ry) return; + if (rank[rx] > rank[ry]) { + root[ry] = rx; + } else if (rank[rx] < rank[ry]) { + root[rx] = ry; + } else { + root[ry] = rx; + rank[rx]++; + } + } +} diff --git a/tests/501-1000/952. largest-component-size-by-common-factor/sol.kt b/tests/501-1000/952. largest-component-size-by-common-factor/sol.kt new file mode 100644 index 00000000..957047df --- /dev/null +++ b/tests/501-1000/952. largest-component-size-by-common-factor/sol.kt @@ -0,0 +1,70 @@ +class Solution { + fun largestComponentSize(nums: IntArray): Int { + val n = nums.size + val root = IntArray(n) { it } + val rank = IntArray(n) { 1 } + + fun find(x: Int): Int { + var cur = x + while (root[cur] != cur) { + root[cur] = root[root[cur]] + cur = root[cur] + } + return cur + } + + fun union(x: Int, y: Int) { + val rx = find(x) + val ry = find(y) + if (rx == ry) return + if (rank[rx] > rank[ry]) { + root[ry] = rx + } else if (rank[rx] < rank[ry]) { + root[rx] = ry + } else { + root[ry] = rx + rank[rx]++ + } + } + + fun getPrimeFactors(num: Int): List { + val res = mutableListOf() + var n = num + if (n % 2 == 0) { + res.add(2) + while (n % 2 == 0) n /= 2 + } + var i = 3 + while (i * i <= n) { + if (n % i == 0) { + res.add(i) + while (n % i == 0) n /= i + } + i += 2 + } + if (n > 2) res.add(n) + return res + } + + val primeToIdx = mutableMapOf() + for (i in 0 until n) { + val primes = getPrimeFactors(nums[i]) + for (p in primes) { + if (primeToIdx.containsKey(p)) { + union(primeToIdx[p]!!, i) + } + primeToIdx[p] = i + } + } + + val count = mutableMapOf() + var max = 0 + for (i in 0 until n) { + val r = find(i) + val c = count.getOrDefault(r, 0) + 1 + count[r] = c + if (c > max) max = c + } + return max + } +} diff --git a/tests/501-1000/952. largest-component-size-by-common-factor/sol.py b/tests/501-1000/952. largest-component-size-by-common-factor/sol.py new file mode 100644 index 00000000..f79a8e90 --- /dev/null +++ b/tests/501-1000/952. largest-component-size-by-common-factor/sol.py @@ -0,0 +1,62 @@ +import collections +import math +from typing import List + + +class UnionFind: + def __init__(self, n: int): + self.root = list(range(n)) + self.rank = [1 for _ in range(n)] + + def find(self, x: int) -> int: + if self.root[x] != x: + self.root[x] = self.find(self.root[x]) + return self.root[x] + + def union(self, x: int, y: int) -> None: + rootx, rooty = self.find(x), self.find(y) + if rootx == rooty: + return + if self.rank[rootx] > self.rank[rooty]: + self.root[rooty] = rootx + elif self.rank[rootx] < self.rank[rooty]: + self.root[rootx] = rooty + else: + self.root[rooty] = rootx + self.rank[rootx] += 1 + + def is_connected(self, x: int, y: int) -> bool: + return self.find(x) == self.find(y) + + +class Solution: + def largestComponentSize(self, nums: List[int]) -> int: + def get_prime_factors(n: int) -> List[int]: + s = set() + while n % 2 == 0: + s.add(2) + n //= 2 + + for i in range(3, int(math.sqrt(n)) + 1, 2): + while n % i == 0: + s.add(i) + n //= i + + if n > 2: + s.add(n) + return list(s) + + uf = UnionFind(len(nums)) + prime = collections.defaultdict(int) + for i, num in enumerate(nums): + primes = get_prime_factors(num) + for p in primes: + if p in prime: + uf.union(prime[p], i) + prime[p] = i + + c = collections.Counter() + for i in range(len(nums)): + c[uf.find(i)] += 1 + + return max(c.values()) diff --git a/tests/501-1000/952. largest-component-size-by-common-factor/sol.py2 b/tests/501-1000/952. largest-component-size-by-common-factor/sol.py2 new file mode 100644 index 00000000..9f470c98 --- /dev/null +++ b/tests/501-1000/952. largest-component-size-by-common-factor/sol.py2 @@ -0,0 +1,57 @@ +class Solution(object): + def largestComponentSize(self, nums): + """ + :type nums: List[int] + :rtype: int + """ + def get_prime_factors(n): + s = set() + while n % 2 == 0: + s.add(2) + n //= 2 + i = 3 + while i * i <= n: + while n % i == 0: + s.add(i) + n //= i + i += 2 + if n > 2: + s.add(n) + return list(s) + + n = len(nums) + root = list(range(n)) + rank = [1] * n + + def find(x): + while root[x] != x: + root[x] = root[root[x]] + x = root[x] + return x + + def union(x, y): + rx, ry = find(x), find(y) + if rx == ry: + return + if rank[rx] > rank[ry]: + root[ry] = rx + elif rank[rx] < rank[ry]: + root[rx] = ry + else: + root[ry] = rx + rank[rx] += 1 + + prime_to_idx = {} + for i, num in enumerate(nums): + primes = get_prime_factors(num) + for p in primes: + if p in prime_to_idx: + union(prime_to_idx[p], i) + prime_to_idx[p] = i + + count = {} + for i in range(n): + r = find(i) + count[r] = count.get(r, 0) + 1 + + return max(count.values()) diff --git a/tests/501-1000/952. largest-component-size-by-common-factor/sol.rb b/tests/501-1000/952. largest-component-size-by-common-factor/sol.rb new file mode 100644 index 00000000..a189bc90 --- /dev/null +++ b/tests/501-1000/952. largest-component-size-by-common-factor/sol.rb @@ -0,0 +1,65 @@ +# @param {Integer[]} nums +# @return {Integer} +def largest_component_size(nums) + def get_prime_factors(n) + s = Set.new + while n % 2 == 0 + s.add(2) + n /= 2 + end + i = 3 + while i * i <= n + while n % i == 0 + s.add(i) + n /= i + end + i += 2 + end + s.add(n) if n > 2 + s.to_a + end + + n = nums.length + root = (0...n).to_a + rank = [1] * n + + define_method(:find) do |x| + while root[x] != x + root[x] = root[root[x]] + x = root[x] + end + x + end + + define_method(:union) do |x, y| + rx = find(x) + ry = find(y) + return if rx == ry + if rank[rx] > rank[ry] + root[ry] = rx + elsif rank[rx] < rank[ry] + root[rx] = ry + else + root[ry] = rx + rank[rx] += 1 + end + end + + prime_to_idx = {} + nums.each_with_index do |num, i| + primes = get_prime_factors(num) + primes.each do |p| + if prime_to_idx.key?(p) + union(prime_to_idx[p], i) + end + prime_to_idx[p] = i + end + end + + count = Hash.new(0) + (0...n).each do |i| + count[find(i)] += 1 + end + + count.values.max +end diff --git a/tests/501-1000/952. largest-component-size-by-common-factor/sol.rs b/tests/501-1000/952. largest-component-size-by-common-factor/sol.rs new file mode 100644 index 00000000..991574e5 --- /dev/null +++ b/tests/501-1000/952. largest-component-size-by-common-factor/sol.rs @@ -0,0 +1,81 @@ +impl Solution { + pub fn largest_component_size(nums: Vec) -> i32 { + let n = nums.len(); + let mut root: Vec = (0..n).collect(); + let mut rank = vec![1usize; n]; + + fn find(root: &mut Vec, x: usize) -> usize { + let mut cur = x; + while root[cur] != cur { + root[cur] = root[root[cur]]; + cur = root[cur]; + } + cur + } + + fn union(root: &mut Vec, rank: &mut Vec, x: usize, y: usize) { + let rx = find(root, x); + let ry = find(root, y); + if rx == ry { + return; + } + if rank[rx] > rank[ry] { + root[ry] = rx; + } else if rank[rx] < rank[ry] { + root[rx] = ry; + } else { + root[ry] = rx; + rank[rx] += 1; + } + } + + fn get_prime_factors(mut n: i32) -> Vec { + let mut res = Vec::new(); + if n % 2 == 0 { + res.push(2); + while n % 2 == 0 { + n /= 2; + } + } + let mut i = 3; + while i * i <= n { + if n % i == 0 { + res.push(i); + while n % i == 0 { + n /= i; + } + } + i += 2; + } + if n > 2 { + res.push(n); + } + res + } + + use std::collections::HashMap; + let mut prime_to_idx: HashMap = HashMap::new(); + + for (i, &num) in nums.iter().enumerate() { + let primes = get_prime_factors(num); + for p in primes { + if let Some(&prev) = prime_to_idx.get(&p) { + union(&mut root, &mut rank, prev, i); + } + prime_to_idx.insert(p, i); + } + } + + let mut count: HashMap = HashMap::new(); + let mut max_size = 0; + for i in 0..n { + let r = find(&mut root, i); + let c = count.entry(r).or_insert(0); + *c += 1; + if *c > max_size { + max_size = *c; + } + } + max_size + } +} diff --git a/tests/501-1000/952. largest-component-size-by-common-factor/sol.swift b/tests/501-1000/952. largest-component-size-by-common-factor/sol.swift new file mode 100644 index 00000000..5754dcf8 --- /dev/null +++ b/tests/501-1000/952. largest-component-size-by-common-factor/sol.swift @@ -0,0 +1,71 @@ +class Solution { + func largestComponentSize(_ nums: [Int]) -> Int { + let n = nums.count + var root = Array(0.. Int { + var cur = x + while root[cur] != cur { + root[cur] = root[root[cur]] + cur = root[cur] + } + return cur + } + + func union(_ x: Int, _ y: Int) { + let rx = find(x) + let ry = find(y) + if rx == ry { return } + if rank[rx] > rank[ry] { + root[ry] = rx + } else if rank[rx] < rank[ry] { + root[rx] = ry + } else { + root[ry] = rx + rank[rx] += 1 + } + } + + func getPrimeFactors(_ num: Int) -> [Int] { + var res = [Int]() + var n = num + if n % 2 == 0 { + res.append(2) + while n % 2 == 0 { n /= 2 } + } + var i = 3 + while i * i <= n { + if n % i == 0 { + res.append(i) + while n % i == 0 { n /= i } + } + i += 2 + } + if n > 2 { res.append(n) } + return res + } + + var primeToIdx = [Int: Int]() + for i in 0.. maxSize { + maxSize = count[r]! + } + } + return maxSize + } +} diff --git a/tests/501-1000/952. largest-component-size-by-common-factor/sol.ts b/tests/501-1000/952. largest-component-size-by-common-factor/sol.ts new file mode 100644 index 00000000..c0858428 --- /dev/null +++ b/tests/501-1000/952. largest-component-size-by-common-factor/sol.ts @@ -0,0 +1,65 @@ +function largestComponentSize(nums: number[]): number { + const n = nums.length; + const root = Array.from({ length: n }, (_, i) => i); + const rank = Array(n).fill(1); + + function find(x: number): number { + while (root[x] !== x) { + root[x] = root[root[x]]; + x = root[x]; + } + return x; + } + + function union(x: number, y: number): void { + const rx = find(x); + const ry = find(y); + if (rx === ry) return; + if (rank[rx] > rank[ry]) { + root[ry] = rx; + } else if (rank[rx] < rank[ry]) { + root[rx] = ry; + } else { + root[ry] = rx; + rank[rx]++; + } + } + + function getPrimeFactors(num: number): number[] { + const res: number[] = []; + let n = num; + if (n % 2 === 0) { + res.push(2); + while (n % 2 === 0) n = Math.floor(n / 2); + } + for (let i = 3; i * i <= n; i += 2) { + if (n % i === 0) { + res.push(i); + while (n % i === 0) n = Math.floor(n / i); + } + } + if (n > 2) res.push(n); + return res; + } + + const primeToIdx = new Map(); + for (let i = 0; i < n; i++) { + const primes = getPrimeFactors(nums[i]); + for (const p of primes) { + if (primeToIdx.has(p)) { + union(primeToIdx.get(p)!, i); + } + primeToIdx.set(p, i); + } + } + + const count = new Map(); + let maxSize = 0; + for (let i = 0; i < n; i++) { + const r = find(i); + const c = (count.get(r) || 0) + 1; + count.set(r, c); + if (c > maxSize) maxSize = c; + } + return maxSize; +} diff --git a/tests/501-1000/953. verifying-an-alien-dictionary/manifest.yaml b/tests/501-1000/953. verifying-an-alien-dictionary/manifest.yaml new file mode 100644 index 00000000..0666479c --- /dev/null +++ b/tests/501-1000/953. verifying-an-alien-dictionary/manifest.yaml @@ -0,0 +1,358 @@ +entry: + id: 953 + title: verifying-an-alien-dictionary + params: + words: + type: array + items: + type: string + order: + type: string + call: + cpp: Solution().isAlienSorted({words}, {order}) + rust: Solution::is_alien_sorted({words}, {order}) + python3: Solution().isAlienSorted({words}, {order}) + python2: Solution().isAlienSorted({words}, {order}) + ruby: is_alien_sorted({words}, {order}) + java: new Solution().isAlienSorted({words}, {order}) + csharp: new Solution().IsAlienSorted({words}, {order}) + kotlin: Solution().isAlienSorted({words}, {order}) + go: isAlienSorted({words}, {order}) + dart: Solution().isAlienSorted({words}, {order}) + swift: Solution().isAlienSorted({words}, {order}) + typescript: isAlienSorted({words}, {order}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 953 +tests: + - name: case_1 + in: + words: + - ddda + - cbdc + - dbcc + - bbad + - bbcd + - badb + order: xabpcjnhuvmtygklrefdwqzios + out: false + - name: case_2 + in: + words: + - cdcd + - daca + - bbcb + - bccd + - abdc + - adca + order: tmzindlxjavpsefhkwrgcquoyb + out: false + - name: case_3 + in: + words: + - ab + - bc + - db + - cc + - dd + - cc + order: wdkstuamhepxgyinvcfzrqlobj + out: false + - name: case_4 + in: + words: + - adcc + - abab + order: lyfvnoeukthzrcagxwipsjdmqb + out: true + - name: case_5 + in: + words: + - caabab + - cdbbda + - ccbbad + order: gficyovndjlaszbweukqhxmtrp + out: false + - name: case_6 + in: + words: + - dcda + - adab + - dbda + - cdbc + - cacb + order: qoagsphwvtibdnxmjckrezyluf + out: false + - name: case_7 + in: + words: + - dacad + - babdb + - bbbcb + order: ojdeznxvsfbkhpqrglywtciuam + out: false + - name: case_8 + in: + words: + - a + - a + - c + - b + - d + - a + - a + order: ynfkhvwtaxmqlgbzuierjcodps + out: false + - name: case_9 + in: + words: + - ba + - bc + - ad + - ab + - ba + order: inwamrbcgqvtksfyuxzelopdhj + out: false + - name: case_10 + in: + words: + - bcb + - bdc + - cba + - ccd + - ddd + - dda + - baa + order: uyzaqcxfhsprmijongdewlbtvk + out: false + - name: case_11 + in: + words: + - aa + - dd + - aa + order: qunfhjrcygkbwvlsoetizdxpma + out: false + - name: case_12 + in: + words: + - cb + - bb + - dc + - ad + - bc + - ba + order: dlzypmofnhacivxgqetjwbsukr + out: false + - name: case_13 + in: + words: + - c + - c + - c + order: xyfciwlbqsgthueaojnkvdzrmp + out: true + - name: case_14 + in: + words: + - a + - a + order: pbxalychztruvnoifmewqjsdgk + out: true + - name: case_15 + in: + words: + - c + - c + - c + - d + - c + - c + order: sudxobzkrleqgtwimycjpnavfh + out: false + - name: case_16 + in: + words: + - d + - c + order: gyoqbnpltvsmajdkrwhcixfuez + out: true + - name: case_17 + in: + words: + - bd + - bc + order: wjroatmbqxvkngfyldzpishecu + out: true + - name: case_18 + in: + words: + - ccdac + - dcdda + order: mvnhbdzjapryxfoueqkscilgwt + out: false + - name: case_19 + in: + words: + - db + - bb + order: mbdeswlfpvjakutrognxhqiycz + out: false + - name: case_20 + in: + words: + - dbcbb + - bcadb + - caabb + - bdcab + order: qwuvnazyokdplxhsbfitejcgrm + out: false + - name: case_21 + in: + words: + - a + - c + - a + order: qjoerhbxksmpncavdyzgltwufi + out: false + - name: case_22 + in: + words: + - accbcc + - aaaddb + - bcbdca + - cbadab + - bbdbbc + order: dnvfpbuxqaslgctwhriyzjmkoe + out: false + - name: case_23 + in: + words: + - cadbc + - daddd + - dacbb + order: kcedipbornhgzjtxvfaysqumwl + out: false + - name: case_24 + in: + words: + - b + - c + - d + - c + - c + - b + order: ymbgnpoiazxfhqjeclwkurdsvt + out: false + - name: case_25 + in: + words: + - db + - ba + - cb + - bd + order: oagdurtspnkvwmiqclheyxfjzb + out: false + - name: case_26 + in: + words: + - acc + - bdd + - dad + - cbd + - cdc + order: bpydtrmnlkxwgvaciuoqhfzesj + out: false + - name: case_27 + in: + words: + - aa + - bc + - ba + - aa + - dd + - bb + order: tlforyxsjhiamnzbgwkuvecpqd + out: false + - name: case_28 + in: + words: + - a + - b + - a + - d + order: akuyjznxdflqpsiwrtovhembcg + out: false + - name: case_29 + in: + words: + - cdd + - cdd + order: bglnkxjqoztdscavuerwipyfmh + out: true + - name: case_30 + in: + words: + - dadc + - acda + - dcda + - dccb + order: jgflzxavpbrnetksmhucdoqwyi + out: false + - name: case_31 + in: + words: + - da + - ab + - da + order: vpsughdlytenxjicrbqozkmfaw + out: false + - name: case_32 + in: + words: + - dd + - cb + - bd + order: splxnehdytfaikvjqobzrmcugw + out: false + - name: case_33 + in: + words: + - cdca + - cbca + - cbda + - bdab + - bdda + - adbb + - bccb + order: kvmybfhlgoazuqpsdcenrwjtix + out: false + - name: case_34 + in: + words: + - dcacac + - bbabba + - cbdbac + - bbbbdb + - cdabaa + - ccabbc + order: bdpfxcztumsiaglnkeryovwhqj + out: false + - name: case_35 + in: + words: + - baadbd + - cabdcb + - babcba + - cbddbb + - acbaac + - dadcbb + order: kosirnwmyqtbpegfjdhzvlucax + out: false diff --git a/tests/501-1000/953. verifying-an-alien-dictionary/sol.cpp b/tests/501-1000/953. verifying-an-alien-dictionary/sol.cpp new file mode 100644 index 00000000..a949fab6 --- /dev/null +++ b/tests/501-1000/953. verifying-an-alien-dictionary/sol.cpp @@ -0,0 +1,30 @@ +class Solution { +public: + bool isAlienSorted(vector& words, string order) { + int orderMap[26]; + for (int i = 0; i < order.size(); i++) { + orderMap[order[i] - 'a'] = i; + } + + for (int i = 0; i < words.size() - 1; i++) { + string w1 = words[i]; + string w2 = words[i + 1]; + + int minLen = min(w1.size(), w2.size()); + int j; + for (j = 0; j < minLen; j++) { + if (w1[j] != w2[j]) { + if (orderMap[w1[j] - 'a'] > orderMap[w2[j] - 'a']) { + return false; + } + break; + } + } + if (j == minLen && w1.size() > w2.size()) { + return false; + } + } + + return true; + } +}; diff --git a/tests/501-1000/953. verifying-an-alien-dictionary/sol.cs b/tests/501-1000/953. verifying-an-alien-dictionary/sol.cs new file mode 100644 index 00000000..e2eb4355 --- /dev/null +++ b/tests/501-1000/953. verifying-an-alien-dictionary/sol.cs @@ -0,0 +1,29 @@ +public class Solution { + public bool IsAlienSorted(string[] words, string order) { + int[] orderMap = new int[26]; + for (int i = 0; i < order.Length; i++) { + orderMap[order[i] - 'a'] = i; + } + + for (int i = 0; i < words.Length - 1; i++) { + string w1 = words[i]; + string w2 = words[i + 1]; + + int minLen = Math.Min(w1.Length, w2.Length); + int j; + for (j = 0; j < minLen; j++) { + if (w1[j] != w2[j]) { + if (orderMap[w1[j] - 'a'] > orderMap[w2[j] - 'a']) { + return false; + } + break; + } + } + if (j == minLen && w1.Length > w2.Length) { + return false; + } + } + + return true; + } +} diff --git a/tests/501-1000/953. verifying-an-alien-dictionary/sol.dart b/tests/501-1000/953. verifying-an-alien-dictionary/sol.dart new file mode 100644 index 00000000..3223e938 --- /dev/null +++ b/tests/501-1000/953. verifying-an-alien-dictionary/sol.dart @@ -0,0 +1,29 @@ +class Solution { + bool isAlienSorted(List words, String order) { + Map orderMap = {}; + for (int i = 0; i < order.length; i++) { + orderMap[order[i]] = i; + } + + for (int i = 0; i < words.length - 1; i++) { + String w1 = words[i]; + String w2 = words[i + 1]; + + int minLen = w1.length < w2.length ? w1.length : w2.length; + int j = 0; + for (j = 0; j < minLen; j++) { + if (w1[j] != w2[j]) { + if (orderMap[w1[j]]! > orderMap[w2[j]]!) { + return false; + } + break; + } + } + if (j == minLen && w1.length > w2.length) { + return false; + } + } + + return true; + } +} diff --git a/tests/501-1000/953. verifying-an-alien-dictionary/sol.go b/tests/501-1000/953. verifying-an-alien-dictionary/sol.go new file mode 100644 index 00000000..0a501eaf --- /dev/null +++ b/tests/501-1000/953. verifying-an-alien-dictionary/sol.go @@ -0,0 +1,33 @@ +func isAlienSorted(words []string, order string) bool { + orderMap := make(map[byte]int) + for i := 0; i < len(order); i++ { + orderMap[order[i]] = i + } + + for i := 0; i < len(words)-1; i++ { + w1 := words[i] + w2 := words[i+1] + + minLen := len(w1) + if len(w2) < minLen { + minLen = len(w2) + } + + j := 0 + for j < minLen { + if w1[j] != w2[j] { + if orderMap[w1[j]] > orderMap[w2[j]] { + return false + } + break + } + j++ + } + + if j == minLen && len(w1) > len(w2) { + return false + } + } + + return true +} diff --git a/tests/501-1000/953. verifying-an-alien-dictionary/sol.java b/tests/501-1000/953. verifying-an-alien-dictionary/sol.java new file mode 100644 index 00000000..a24cd8a6 --- /dev/null +++ b/tests/501-1000/953. verifying-an-alien-dictionary/sol.java @@ -0,0 +1,29 @@ +class Solution { + public boolean isAlienSorted(String[] words, String order) { + int[] orderMap = new int[26]; + for (int i = 0; i < order.length(); i++) { + orderMap[order.charAt(i) - 'a'] = i; + } + + for (int i = 0; i < words.length - 1; i++) { + String w1 = words[i]; + String w2 = words[i + 1]; + + int minLen = Math.min(w1.length(), w2.length()); + int j; + for (j = 0; j < minLen; j++) { + if (w1.charAt(j) != w2.charAt(j)) { + if (orderMap[w1.charAt(j) - 'a'] > orderMap[w2.charAt(j) - 'a']) { + return false; + } + break; + } + } + if (j == minLen && w1.length() > w2.length()) { + return false; + } + } + + return true; + } +} diff --git a/tests/501-1000/953. verifying-an-alien-dictionary/sol.kt b/tests/501-1000/953. verifying-an-alien-dictionary/sol.kt new file mode 100644 index 00000000..ecbb3214 --- /dev/null +++ b/tests/501-1000/953. verifying-an-alien-dictionary/sol.kt @@ -0,0 +1,30 @@ +class Solution { + fun isAlienSorted(words: Array, order: String): Boolean { + val orderMap = IntArray(26) + for (i in order.indices) { + orderMap[order[i] - 'a'] = i + } + + for (i in 0 until words.size - 1) { + val w1 = words[i] + val w2 = words[i + 1] + + val minLen = minOf(w1.length, w2.length) + var j = 0 + while (j < minLen) { + if (w1[j] != w2[j]) { + if (orderMap[w1[j] - 'a'] > orderMap[w2[j] - 'a']) { + return false + } + break + } + j++ + } + if (j == minLen && w1.length > w2.length) { + return false + } + } + + return true + } +} diff --git a/tests/501-1000/953. verifying-an-alien-dictionary/sol.py b/tests/501-1000/953. verifying-an-alien-dictionary/sol.py new file mode 100644 index 00000000..e87df99a --- /dev/null +++ b/tests/501-1000/953. verifying-an-alien-dictionary/sol.py @@ -0,0 +1,21 @@ +from typing import List + + +class Solution: + def isAlienSorted(self, words: List[str], order: str) -> bool: + order_map = {char: i for i, char in enumerate(order)} + + for i in range(len(words) - 1): + w1 = words[i] + w2 = words[i + 1] + + for j in range(min(len(w1), len(w2))): + if w1[j] != w2[j]: + if order_map[w1[j]] > order_map[w2[j]]: + return False + break + else: + if len(w1) > len(w2): + return False + + return True diff --git a/tests/501-1000/953. verifying-an-alien-dictionary/sol.py2 b/tests/501-1000/953. verifying-an-alien-dictionary/sol.py2 new file mode 100644 index 00000000..bf0e223e --- /dev/null +++ b/tests/501-1000/953. verifying-an-alien-dictionary/sol.py2 @@ -0,0 +1,23 @@ +class Solution(object): + def isAlienSorted(self, words, order): + """ + :type words: List[str] + :type order: str + :rtype: bool + """ + order_map = {char: i for i, char in enumerate(order)} + + for i in range(len(words) - 1): + w1 = words[i] + w2 = words[i + 1] + + for j in range(min(len(w1), len(w2))): + if w1[j] != w2[j]: + if order_map[w1[j]] > order_map[w2[j]]: + return False + break + else: + if len(w1) > len(w2): + return False + + return True diff --git a/tests/501-1000/953. verifying-an-alien-dictionary/sol.rb b/tests/501-1000/953. verifying-an-alien-dictionary/sol.rb new file mode 100644 index 00000000..09e07495 --- /dev/null +++ b/tests/501-1000/953. verifying-an-alien-dictionary/sol.rb @@ -0,0 +1,30 @@ +# @param {String[]} words +# @param {String} order +# @return {Boolean} +def is_alien_sorted(words, order) + order_map = {} + order.each_char.with_index { |char, i| order_map[char] = i } + + (0...words.length - 1).each do |i| + w1 = words[i] + w2 = words[i + 1] + + min_len = [w1.length, w2.length].min + found_diff = false + (0...min_len).each do |j| + if w1[j] != w2[j] + if order_map[w1[j]] > order_map[w2[j]] + return false + end + found_diff = true + break + end + end + + if !found_diff && w1.length > w2.length + return false + end + end + + true +end diff --git a/tests/501-1000/953. verifying-an-alien-dictionary/sol.rs b/tests/501-1000/953. verifying-an-alien-dictionary/sol.rs new file mode 100644 index 00000000..7a79e6cf --- /dev/null +++ b/tests/501-1000/953. verifying-an-alien-dictionary/sol.rs @@ -0,0 +1,30 @@ +impl Solution { + pub fn is_alien_sorted(words: Vec, order: String) -> bool { + let mut order_map = [0usize; 26]; + for (i, c) in order.chars().enumerate() { + order_map[(c as u8 - b'a') as usize] = i; + } + + for i in 0..words.len() - 1 { + let w1 = words[i].as_bytes(); + let w2 = words[i + 1].as_bytes(); + + let min_len = w1.len().min(w2.len()); + let mut j = 0; + while j < min_len { + if w1[j] != w2[j] { + if order_map[(w1[j] - b'a') as usize] > order_map[(w2[j] - b'a') as usize] { + return false; + } + break; + } + j += 1; + } + if j == min_len && w1.len() > w2.len() { + return false; + } + } + + true + } +} diff --git a/tests/501-1000/953. verifying-an-alien-dictionary/sol.swift b/tests/501-1000/953. verifying-an-alien-dictionary/sol.swift new file mode 100644 index 00000000..1747de87 --- /dev/null +++ b/tests/501-1000/953. verifying-an-alien-dictionary/sol.swift @@ -0,0 +1,30 @@ +class Solution { + func isAlienSorted(_ words: [String], _ order: String) -> Bool { + var orderMap: [Character: Int] = [:] + for (i, char) in order.enumerated() { + orderMap[char] = i + } + + for i in 0.. orderMap[w2[j]]! { + return false + } + break + } + j += 1 + } + if j == minLen && w1.count > w2.count { + return false + } + } + + return true + } +} diff --git a/tests/501-1000/953. verifying-an-alien-dictionary/sol.ts b/tests/501-1000/953. verifying-an-alien-dictionary/sol.ts new file mode 100644 index 00000000..ad7849c9 --- /dev/null +++ b/tests/501-1000/953. verifying-an-alien-dictionary/sol.ts @@ -0,0 +1,27 @@ +function isAlienSorted(words: string[], order: string): boolean { + const orderMap: Map = new Map(); + for (let i = 0; i < order.length; i++) { + orderMap.set(order[i], i); + } + + for (let i = 0; i < words.length - 1; i++) { + const w1 = words[i]; + const w2 = words[i + 1]; + + const minLen = Math.min(w1.length, w2.length); + let j = 0; + for (j = 0; j < minLen; j++) { + if (w1[j] !== w2[j]) { + if (orderMap.get(w1[j])! > orderMap.get(w2[j])!) { + return false; + } + break; + } + } + if (j === minLen && w1.length > w2.length) { + return false; + } + } + + return true; +} diff --git a/tests/501-1000/954. array-of-doubled-pairs/manifest.yaml b/tests/501-1000/954. array-of-doubled-pairs/manifest.yaml new file mode 100644 index 00000000..92af6dab --- /dev/null +++ b/tests/501-1000/954. array-of-doubled-pairs/manifest.yaml @@ -0,0 +1,434 @@ +entry: + id: 954 + title: array-of-doubled-pairs + params: + arr: + type: array + items: + type: int + call: + cpp: Solution().canReorderDoubled({arr}) + rust: Solution::can_reorder_doubled({arr}) + python3: Solution().canReorderDoubled({arr}) + python2: Solution().canReorderDoubled({arr}) + ruby: can_reorder_doubled({arr}) + java: new Solution().canReorderDoubled({arr}) + csharp: new Solution().CanReorderDoubled({arr}) + kotlin: Solution().canReorderDoubled({arr}) + go: canReorderDoubled({arr}) + dart: Solution().canReorderDoubled({arr}) + swift: Solution().canReorderDoubled({arr}) + typescript: canReorderDoubled({arr}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 954 +tests: + - name: case_1 + in: + arr: + - -5 + - 4 + - -10 + - 12 + - 8 + - 2 + - 6 + - 0 + - 8 + - 1 + - 4 + - 0 + - 4 + - 2 + out: true + - name: case_2 + in: + arr: + - -5 + - -10 + - 0 + - 4 + - 0 + - 2 + - -4 + - 0 + - 0 + - -8 + out: true + - name: case_3 + in: + arr: + - 4 + - 2 + - 4 + - 0 + - 0 + - 8 + out: true + - name: case_4 + in: + arr: + - -6 + - -3 + - -2 + - 2 + - -4 + - 12 + - 6 + out: false + - name: case_5 + in: + arr: + - 4 + - 3 + - 2 + out: false + - name: case_6 + in: + arr: + - -12 + - 10 + - 5 + - -3 + - -8 + - -6 + - 0 + - -4 + out: false + - name: case_7 + in: + arr: + - 10 + - -4 + - 5 + - -8 + out: true + - name: case_8 + in: + arr: + - -3 + - -4 + - -1 + - -2 + - 0 + - 3 + - -4 + - -6 + - 4 + - 8 + - -2 + - 0 + - 3 + out: false + - name: case_9 + in: + arr: + - 10 + - -5 + - 8 + - -5 + - 4 + - 4 + - 8 + - 5 + - 2 + - -10 + - -10 + - -5 + - 1 + - -10 + out: true + - name: case_10 + in: + arr: + - -10 + - 12 + - 6 + - 2 + - -5 + - 4 + - 2 + - 3 + out: false + - name: case_11 + in: + arr: + - -4 + - -6 + - 4 + - -12 + - 2 + - 0 + - -1 + - -1 + - -6 + - -2 + out: false + - name: case_12 + in: + arr: + - 1 + - 2 + - -6 + - -4 + - -6 + - -2 + - -12 + out: false + - name: case_13 + in: + arr: + - 6 + - 12 + - -5 + out: false + - name: case_14 + in: + arr: + - -6 + - 5 + - 5 + - -3 + - 0 + - 4 + - 5 + - 10 + - 2 + - -5 + - 0 + out: false + - name: case_15 + in: + arr: + - -3 + - -3 + - 0 + - -6 + - -8 + - -4 + out: false + - name: case_16 + in: + arr: + - -3 + - -6 + - 3 + out: false + - name: case_17 + in: + arr: + - -1 + - -2 + - 0 + - 0 + out: true + - name: case_18 + in: + arr: + - -6 + - -3 + - -1 + out: false + - name: case_19 + in: + arr: + - -3 + - -3 + - -6 + - -6 + out: true + - name: case_20 + in: + arr: + - -5 + - -5 + - 5 + - 10 + - 5 + - 10 + - -6 + out: false + - name: case_21 + in: + arr: + - 5 + - 10 + out: true + - name: case_22 + in: + arr: + - -6 + - 5 + - 10 + - 0 + out: false + - name: case_23 + in: + arr: + - -2 + - -4 + - -8 + - -4 + out: true + - name: case_24 + in: + arr: + - 0 + - 5 + - -3 + - 2 + - 0 + - -4 + - 4 + - -8 + - -6 + - -12 + out: false + - name: case_25 + in: + arr: + - 1 + - 2 + - -5 + - 2 + - -8 + - 2 + - 1 + - -12 + - -4 + - -4 + - 1 + - -10 + - -8 + - 2 + - -6 + out: false + - name: case_26 + in: + arr: + - 2 + - 4 + out: true + - name: case_27 + in: + arr: + - -3 + - 6 + - -6 + - 3 + - 3 + - 6 + - 12 + - -5 + - 6 + out: false + - name: case_28 + in: + arr: + - 0 + - 3 + - -4 + - -8 + - -3 + - 6 + - 0 + out: false + - name: case_29 + in: + arr: + - 2 + - -4 + - 1 + - -6 + - 2 + - -2 + - -5 + - -4 + - 4 + - -4 + - 8 + - 4 + - -10 + - -3 + - -2 + out: false + - name: case_30 + in: + arr: + - -2 + - 12 + - 3 + - 6 + out: false + - name: case_31 + in: + arr: + - 1 + - -6 + - 0 + - -8 + - -4 + - 0 + - 2 + - 3 + - 6 + - 0 + - -12 + - 0 + out: true + - name: case_32 + in: + arr: + - -3 + - -1 + - 6 + - 12 + - -10 + - -6 + - -2 + - 4 + - -6 + - -12 + - -5 + - 2 + out: true + - name: case_33 + in: + arr: + - 2 + - 4 + - -6 + - -3 + - 4 + - -2 + - -1 + - 8 + out: true + - name: case_34 + in: + arr: + - 1 + - 2 + out: true + - name: case_35 + in: + arr: + - 0 + - 0 + - -4 + - 1 + - -8 + - 2 + - 0 + - 4 + - 0 + - -8 + - -4 + out: false diff --git a/tests/501-1000/954. array-of-doubled-pairs/sol.cpp b/tests/501-1000/954. array-of-doubled-pairs/sol.cpp new file mode 100644 index 00000000..1f701877 --- /dev/null +++ b/tests/501-1000/954. array-of-doubled-pairs/sol.cpp @@ -0,0 +1,25 @@ +class Solution { +public: + bool canReorderDoubled(vector& arr) { + unordered_map freq; + for (int i : arr) { + freq[i]++; + } + + sort(arr.begin(), arr.end(), [](int a, int b) { + return abs(a) < abs(b); + }); + + for (int val : arr) { + if (freq[val] == 0) continue; + int target = val * 2; + if (freq.count(target) && freq[target] > 0) { + freq[val]--; + freq[target]--; + } else { + return false; + } + } + return true; + } +}; diff --git a/tests/501-1000/954. array-of-doubled-pairs/sol.cs b/tests/501-1000/954. array-of-doubled-pairs/sol.cs new file mode 100644 index 00000000..bba43729 --- /dev/null +++ b/tests/501-1000/954. array-of-doubled-pairs/sol.cs @@ -0,0 +1,22 @@ +public class Solution { + public bool CanReorderDoubled(int[] arr) { + Dictionary freq = new Dictionary(); + foreach (int i in arr) { + if (freq.ContainsKey(i)) freq[i]++; + else freq[i] = 1; + } + + Array.Sort(arr, (a, b) => Math.Abs(a).CompareTo(Math.Abs(b))); + foreach (int val in arr) { + if (freq[val] == 0) continue; + int target = val * 2; + if (freq.ContainsKey(target) && freq[target] > 0) { + freq[val]--; + freq[target]--; + } else { + return false; + } + } + return true; + } +} diff --git a/tests/501-1000/954. array-of-doubled-pairs/sol.dart b/tests/501-1000/954. array-of-doubled-pairs/sol.dart new file mode 100644 index 00000000..87be90c6 --- /dev/null +++ b/tests/501-1000/954. array-of-doubled-pairs/sol.dart @@ -0,0 +1,21 @@ +class Solution { + bool canReorderDoubled(List arr) { + Map freq = {}; + for (int i in arr) { + freq[i] = (freq[i] ?? 0) + 1; + } + + arr.sort((a, b) => a.abs().compareTo(b.abs())); + for (int val in arr) { + if (freq[val] == 0) continue; + int target = val * 2; + if (freq.containsKey(target) && freq[target]! > 0) { + freq[val] = freq[val]! - 1; + freq[target] = freq[target]! - 1; + } else { + return false; + } + } + return true; + } +} diff --git a/tests/501-1000/954. array-of-doubled-pairs/sol.go b/tests/501-1000/954. array-of-doubled-pairs/sol.go new file mode 100644 index 00000000..5264c10f --- /dev/null +++ b/tests/501-1000/954. array-of-doubled-pairs/sol.go @@ -0,0 +1,31 @@ +func canReorderDoubled(arr []int) bool { + freq := make(map[int]int) + for _, v := range arr { + freq[v]++ + } + + sort.Slice(arr, func(i, j int) bool { + return abs(arr[i]) < abs(arr[j]) + }) + + for _, val := range arr { + if freq[val] == 0 { + continue + } + target := val * 2 + if count, ok := freq[target]; ok && count > 0 { + freq[val]-- + freq[target]-- + } else { + return false + } + } + return true +} + +func abs(x int) int { + if x < 0 { + return -x + } + return x +} diff --git a/tests/501-1000/954. array-of-doubled-pairs/sol.java b/tests/501-1000/954. array-of-doubled-pairs/sol.java new file mode 100644 index 00000000..b150febb --- /dev/null +++ b/tests/501-1000/954. array-of-doubled-pairs/sol.java @@ -0,0 +1,26 @@ +class Solution { + public boolean canReorderDoubled(int[] arr) { + Map freq = new HashMap<>(); + for (int i : arr) { + freq.put(i, freq.getOrDefault(i, 0) + 1); + } + + Integer[] boxed = new Integer[arr.length]; + for (int i = 0; i < arr.length; i++) { + boxed[i] = arr[i]; + } + Arrays.sort(boxed, (a, b) -> Integer.compare(Math.abs(a), Math.abs(b))); + + for (int val : boxed) { + if (freq.get(val) == 0) continue; + int target = val * 2; + if (freq.containsKey(target) && freq.get(target) > 0) { + freq.put(val, freq.get(val) - 1); + freq.put(target, freq.get(target) - 1); + } else { + return false; + } + } + return true; + } +} diff --git a/tests/501-1000/954. array-of-doubled-pairs/sol.kt b/tests/501-1000/954. array-of-doubled-pairs/sol.kt new file mode 100644 index 00000000..a1e1c1e3 --- /dev/null +++ b/tests/501-1000/954. array-of-doubled-pairs/sol.kt @@ -0,0 +1,22 @@ +class Solution { + fun canReorderDoubled(arr: IntArray): Boolean { + val freq = mutableMapOf() + for (i in arr) { + freq[i] = freq.getOrDefault(i, 0) + 1 + } + + val sorted = arr.toMutableList() + sorted.sortBy { kotlin.math.abs(it) } + for (value in sorted) { + if (freq[value] == 0) continue + val target = value * 2 + if (freq.containsKey(target) && freq[target]!! > 0) { + freq[value] = freq[value]!! - 1 + freq[target] = freq[target]!! - 1 + } else { + return false + } + } + return true + } +} diff --git a/tests/501-1000/954. array-of-doubled-pairs/sol.py b/tests/501-1000/954. array-of-doubled-pairs/sol.py new file mode 100644 index 00000000..6f071415 --- /dev/null +++ b/tests/501-1000/954. array-of-doubled-pairs/sol.py @@ -0,0 +1,20 @@ +from typing import List + + +class Solution: + def canReorderDoubled(self, arr: List[int]) -> bool: + freq = {} + for i in arr: + freq[i] = freq.get(i, 0) + 1 + + arr.sort(key=lambda x: abs(x)) + for val in arr: + if freq[val] == 0: + continue + target = val * 2 + if target in freq and freq[target] > 0: + freq[val] -= 1 + freq[target] -= 1 + else: + return False + return True diff --git a/tests/501-1000/954. array-of-doubled-pairs/sol.py2 b/tests/501-1000/954. array-of-doubled-pairs/sol.py2 new file mode 100644 index 00000000..41faaa03 --- /dev/null +++ b/tests/501-1000/954. array-of-doubled-pairs/sol.py2 @@ -0,0 +1,21 @@ +class Solution(object): + def canReorderDoubled(self, arr): + """ + :type arr: List[int] + :rtype: bool + """ + freq = {} + for i in arr: + freq[i] = freq.get(i, 0) + 1 + + arr.sort(key=lambda x: abs(x)) + for val in arr: + if freq[val] == 0: + continue + target = val * 2 + if target in freq and freq[target] > 0: + freq[val] -= 1 + freq[target] -= 1 + else: + return False + return True diff --git a/tests/501-1000/954. array-of-doubled-pairs/sol.rb b/tests/501-1000/954. array-of-doubled-pairs/sol.rb new file mode 100644 index 00000000..6ee44a91 --- /dev/null +++ b/tests/501-1000/954. array-of-doubled-pairs/sol.rb @@ -0,0 +1,19 @@ +# @param {Integer[]} arr +# @return {Boolean} +def can_reorder_doubled(arr) + freq = Hash.new(0) + arr.each { |i| freq[i] += 1 } + + arr.sort_by! { |x| x.abs } + arr.each do |val| + next if freq[val] == 0 + target = val * 2 + if freq[target] && freq[target] > 0 + freq[val] -= 1 + freq[target] -= 1 + else + return false + end + end + true +end diff --git a/tests/501-1000/954. array-of-doubled-pairs/sol.rs b/tests/501-1000/954. array-of-doubled-pairs/sol.rs new file mode 100644 index 00000000..95e37afa --- /dev/null +++ b/tests/501-1000/954. array-of-doubled-pairs/sol.rs @@ -0,0 +1,31 @@ +impl Solution { + pub fn can_reorder_doubled(arr: Vec) -> bool { + use std::collections::HashMap; + + let mut freq: HashMap = HashMap::new(); + for &i in &arr { + *freq.entry(i).or_insert(0) += 1; + } + + let mut arr = arr; + arr.sort_by_key(|&x| x.abs()); + + for &val in &arr { + if freq[&val] == 0 { + continue; + } + let target = val * 2; + if let Some(&count) = freq.get(&target) { + if count > 0 { + *freq.get_mut(&val).unwrap() -= 1; + *freq.get_mut(&target).unwrap() -= 1; + } else { + return false; + } + } else { + return false; + } + } + true + } +} diff --git a/tests/501-1000/954. array-of-doubled-pairs/sol.swift b/tests/501-1000/954. array-of-doubled-pairs/sol.swift new file mode 100644 index 00000000..4c99eec9 --- /dev/null +++ b/tests/501-1000/954. array-of-doubled-pairs/sol.swift @@ -0,0 +1,21 @@ +class Solution { + func canReorderDoubled(_ arr: [Int]) -> Bool { + var freq = [Int: Int]() + for i in arr { + freq[i, default: 0] += 1 + } + + let sortedArr = arr.sorted { abs($0) < abs($1) } + for val in sortedArr { + if freq[val] == 0 { continue } + let target = val * 2 + if let count = freq[target], count > 0 { + freq[val]! -= 1 + freq[target]! -= 1 + } else { + return false + } + } + return true + } +} diff --git a/tests/501-1000/954. array-of-doubled-pairs/sol.ts b/tests/501-1000/954. array-of-doubled-pairs/sol.ts new file mode 100644 index 00000000..62a4ad37 --- /dev/null +++ b/tests/501-1000/954. array-of-doubled-pairs/sol.ts @@ -0,0 +1,19 @@ +function canReorderDoubled(arr: number[]): boolean { + const freq: Map = new Map(); + for (const i of arr) { + freq.set(i, (freq.get(i) || 0) + 1); + } + + arr.sort((a, b) => Math.abs(a) - Math.abs(b)); + for (const val of arr) { + if (freq.get(val) === 0) continue; + const target = val * 2; + if (freq.has(target) && freq.get(target)! > 0) { + freq.set(val, freq.get(val)! - 1); + freq.set(target, freq.get(target)! - 1); + } else { + return false; + } + } + return true; +} diff --git a/tests/501-1000/955. delete-columns-to-make-sorted-ii/manifest.yaml b/tests/501-1000/955. delete-columns-to-make-sorted-ii/manifest.yaml new file mode 100644 index 00000000..79efc23e --- /dev/null +++ b/tests/501-1000/955. delete-columns-to-make-sorted-ii/manifest.yaml @@ -0,0 +1,315 @@ +entry: + id: 955 + title: delete-columns-to-make-sorted-ii + params: + strs: + type: array + items: + type: string + call: + cpp: Solution().minDeletionSize({strs}) + rust: Solution::min_deletion_size({strs}) + python3: Solution().minDeletionSize({strs}) + python2: Solution().minDeletionSize({strs}) + ruby: min_deletion_size({strs}) + java: new Solution().minDeletionSize({strs}) + csharp: new Solution().MinDeletionSize({strs}) + kotlin: Solution().minDeletionSize({strs}) + go: minDeletionSize({strs}) + dart: Solution().minDeletionSize({strs}) + swift: Solution().minDeletionSize({strs}) + typescript: minDeletionSize({strs}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 955 +tests: + - name: case_1 + in: + strs: + - dca + - ddb + - abc + - dbd + out: 2 + - name: case_2 + in: + strs: + - caaba + - bdcdd + - abbaa + - bacad + - babda + - dacad + out: 5 + - name: case_3 + in: + strs: + - cccdd + - adbcc + out: 1 + - name: case_4 + in: + strs: + - dcbaca + - bdbbdd + - cadadb + out: 2 + - name: case_5 + in: + strs: + - dbca + - bbcd + out: 1 + - name: case_6 + in: + strs: + - bbba + - abbb + out: 1 + - name: case_7 + in: + strs: + - daaaa + - bdaac + out: 1 + - name: case_8 + in: + strs: + - aaac + - cbdc + - acaa + - aacb + - dbca + - abbb + out: 4 + - name: case_9 + in: + strs: + - acc + - aba + out: 2 + - name: case_10 + in: + strs: + - dddcba + - abbadc + out: 4 + - name: case_11 + in: + strs: + - ccabaa + - cabacd + - ddcabb + - adbcda + - bacdab + - acabbc + - cdcccb + out: 6 + - name: case_12 + in: + strs: + - cd + - ad + - cb + - ca + - bd + - bd + - ba + out: 2 + - name: case_13 + in: + strs: + - cbad + - dcab + - cbdb + - caca + - bada + out: 4 + - name: case_14 + in: + strs: + - b + - a + - b + - d + - c + - d + - d + out: 1 + - name: case_15 + in: + strs: + - cdaa + - dacd + - caab + - ddbc + - bcbb + - baab + out: 4 + - name: case_16 + in: + strs: + - cabad + - accbd + - acdbb + out: 1 + - name: case_17 + in: + strs: + - dccada + - bacbcb + out: 2 + - name: case_18 + in: + strs: + - acaa + - acca + - aacb + - accc + - cdac + - dbab + out: 1 + - name: case_19 + in: + strs: + - ccca + - dbda + out: 0 + - name: case_20 + in: + strs: + - c + - c + - b + - d + out: 1 + - name: case_21 + in: + strs: + - bd + - ab + - da + - aa + out: 2 + - name: case_22 + in: + strs: + - d + - d + - a + - a + out: 1 + - name: case_23 + in: + strs: + - dad + - dbc + - cac + out: 3 + - name: case_24 + in: + strs: + - c + - a + - d + out: 1 + - name: case_25 + in: + strs: + - ddbd + - acab + - cbcc + - dcba + - dbbb + - dbdc + out: 4 + - name: case_26 + in: + strs: + - acb + - ddb + - bba + - bad + - bab + - bcc + - abb + out: 3 + - name: case_27 + in: + strs: + - ddb + - aaa + - aba + out: 3 + - name: case_28 + in: + strs: + - aad + - dbc + - cbd + - bbc + - ccc + out: 2 + - name: case_29 + in: + strs: + - db + - bb + - cd + - db + - dd + - ca + - ac + out: 2 + - name: case_30 + in: + strs: + - adbbc + - cdcdc + - acbcc + - accad + - aaacc + out: 5 + - name: case_31 + in: + strs: + - bda + - cbc + out: 0 + - name: case_32 + in: + strs: + - bdaac + - bcbcd + - cdbcb + - dcbcc + - daacd + - dcdcd + out: 2 + - name: case_33 + in: + strs: + - acd + - cad + - dca + out: 0 + - name: case_34 + in: + strs: + - cba + - dac + - bdd + out: 2 + - name: case_35 + in: + strs: + - ccddc + - cbdaa + out: 3 diff --git a/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.cpp b/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.cpp new file mode 100644 index 00000000..eb3c4f94 --- /dev/null +++ b/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.cpp @@ -0,0 +1,41 @@ +class Solution { +public: + int minDeletionSize(vector& strs) { + int n = strs.size(); + int m = strs[0].size(); + vector sortedPairs(n - 1, false); + int delCount = 0; + + for (int col = 0; col < m; col++) { + bool bad = false; + for (int i = 0; i < n - 1; i++) { + if (!sortedPairs[i] && strs[i][col] > strs[i + 1][col]) { + bad = true; + break; + } + } + + if (bad) { + delCount++; + continue; + } + + for (int i = 0; i < n - 1; i++) { + if (!sortedPairs[i] && strs[i][col] < strs[i + 1][col]) { + sortedPairs[i] = true; + } + } + + bool allSorted = true; + for (bool b : sortedPairs) { + if (!b) { + allSorted = false; + break; + } + } + if (allSorted) break; + } + + return delCount; + } +}; diff --git a/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.cs b/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.cs new file mode 100644 index 00000000..5774e6e0 --- /dev/null +++ b/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.cs @@ -0,0 +1,33 @@ +public class Solution { + public int MinDeletionSize(string[] strs) { + int n = strs.Length; + int m = strs[0].Length; + bool[] sortedPairs = new bool[n - 1]; + int delCount = 0; + + for (int col = 0; col < m; col++) { + bool bad = false; + for (int i = 0; i < n - 1; i++) { + if (!sortedPairs[i] && strs[i][col] > strs[i + 1][col]) { + bad = true; + break; + } + } + + if (bad) { + delCount++; + continue; + } + + for (int i = 0; i < n - 1; i++) { + if (!sortedPairs[i] && strs[i][col] < strs[i + 1][col]) { + sortedPairs[i] = true; + } + } + + if (sortedPairs.All(b => b)) break; + } + + return delCount; + } +} diff --git a/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.dart b/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.dart new file mode 100644 index 00000000..0095dd14 --- /dev/null +++ b/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.dart @@ -0,0 +1,33 @@ +class Solution { + int minDeletionSize(List strs) { + int n = strs.length; + int m = strs[0].length; + List sortedPairs = List.filled(n - 1, false); + int delCount = 0; + + for (int col = 0; col < m; col++) { + bool bad = false; + for (int i = 0; i < n - 1; i++) { + if (!sortedPairs[i] && strs[i][col].codeUnitAt(0) > strs[i + 1][col].codeUnitAt(0)) { + bad = true; + break; + } + } + + if (bad) { + delCount++; + continue; + } + + for (int i = 0; i < n - 1; i++) { + if (!sortedPairs[i] && strs[i][col].codeUnitAt(0) < strs[i + 1][col].codeUnitAt(0)) { + sortedPairs[i] = true; + } + } + + if (sortedPairs.every((b) => b)) break; + } + + return delCount; + } +} diff --git a/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.go b/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.go new file mode 100644 index 00000000..4d83e82d --- /dev/null +++ b/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.go @@ -0,0 +1,40 @@ +func minDeletionSize(strs []string) int { + n := len(strs) + m := len(strs[0]) + sortedPairs := make([]bool, n-1) + delCount := 0 + + for col := 0; col < m; col++ { + bad := false + for i := 0; i < n-1; i++ { + if !sortedPairs[i] && strs[i][col] > strs[i+1][col] { + bad = true + break + } + } + + if bad { + delCount++ + continue + } + + for i := 0; i < n-1; i++ { + if !sortedPairs[i] && strs[i][col] < strs[i+1][col] { + sortedPairs[i] = true + } + } + + allSorted := true + for _, v := range sortedPairs { + if !v { + allSorted = false + break + } + } + if allSorted { + break + } + } + + return delCount +} diff --git a/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.java b/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.java new file mode 100644 index 00000000..0821b20b --- /dev/null +++ b/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.java @@ -0,0 +1,40 @@ +class Solution { + public int minDeletionSize(String[] strs) { + int n = strs.length; + int m = strs[0].length(); + boolean[] sortedPairs = new boolean[n - 1]; + int delCount = 0; + + for (int col = 0; col < m; col++) { + boolean bad = false; + for (int i = 0; i < n - 1; i++) { + if (!sortedPairs[i] && strs[i].charAt(col) > strs[i + 1].charAt(col)) { + bad = true; + break; + } + } + + if (bad) { + delCount++; + continue; + } + + for (int i = 0; i < n - 1; i++) { + if (!sortedPairs[i] && strs[i].charAt(col) < strs[i + 1].charAt(col)) { + sortedPairs[i] = true; + } + } + + boolean allSorted = true; + for (boolean b : sortedPairs) { + if (!b) { + allSorted = false; + break; + } + } + if (allSorted) break; + } + + return delCount; + } +} diff --git a/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.kt b/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.kt new file mode 100644 index 00000000..00b1df85 --- /dev/null +++ b/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.kt @@ -0,0 +1,33 @@ +class Solution { + fun minDeletionSize(strs: Array): Int { + val n = strs.size + val m = strs[0].length + val sortedPairs = BooleanArray(n - 1) + var delCount = 0 + + for (col in 0 until m) { + var bad = false + for (i in 0 until n - 1) { + if (!sortedPairs[i] && strs[i][col] > strs[i + 1][col]) { + bad = true + break + } + } + + if (bad) { + delCount++ + continue + } + + for (i in 0 until n - 1) { + if (!sortedPairs[i] && strs[i][col] < strs[i + 1][col]) { + sortedPairs[i] = true + } + } + + if (sortedPairs.all { it }) break + } + + return delCount + } +} diff --git a/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.py b/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.py new file mode 100644 index 00000000..5ceef804 --- /dev/null +++ b/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.py @@ -0,0 +1,25 @@ +class Solution: + def minDeletionSize(self, strs): + n, m = len(strs), len(strs[0]) + sorted_pairs = [False] * (n - 1) + delCount = 0 + + for col in range(m): + bad = False + for i in range(n - 1): + if not sorted_pairs[i] and strs[i][col] > strs[i + 1][col]: + bad = True + break + + if bad: + delCount += 1 + continue + + for i in range(n - 1): + if not sorted_pairs[i] and strs[i][col] < strs[i + 1][col]: + sorted_pairs[i] = True + + if all(sorted_pairs): + break + + return delCount diff --git a/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.py2 b/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.py2 new file mode 100644 index 00000000..917bccbd --- /dev/null +++ b/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.py2 @@ -0,0 +1,25 @@ +class Solution(object): + def minDeletionSize(self, strs): + n, m = len(strs), len(strs[0]) + sorted_pairs = [False] * (n - 1) + delCount = 0 + + for col in range(m): + bad = False + for i in range(n - 1): + if not sorted_pairs[i] and strs[i][col] > strs[i + 1][col]: + bad = True + break + + if bad: + delCount += 1 + continue + + for i in range(n - 1): + if not sorted_pairs[i] and strs[i][col] < strs[i + 1][col]: + sorted_pairs[i] = True + + if all(sorted_pairs): + break + + return delCount diff --git a/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.rb b/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.rb new file mode 100644 index 00000000..c9456dbd --- /dev/null +++ b/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.rb @@ -0,0 +1,33 @@ +# @param {String[]} strs +# @return {Integer} +def min_deletion_size(strs) + n = strs.length + m = strs[0].length + sorted_pairs = Array.new(n - 1, false) + del_count = 0 + + (0...m).each do |col| + bad = false + (0...n - 1).each do |i| + if !sorted_pairs[i] && strs[i][col] > strs[i + 1][col] + bad = true + break + end + end + + if bad + del_count += 1 + next + end + + (0...n - 1).each do |i| + if !sorted_pairs[i] && strs[i][col] < strs[i + 1][col] + sorted_pairs[i] = true + end + end + + break if sorted_pairs.all? + end + + del_count +end diff --git a/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.rs b/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.rs new file mode 100644 index 00000000..9f06b16c --- /dev/null +++ b/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.rs @@ -0,0 +1,36 @@ +impl Solution { + pub fn min_deletion_size(strs: Vec) -> i32 { + let n = strs.len(); + let m = strs[0].len(); + let mut sorted_pairs = vec![false; n - 1]; + let mut del_count = 0; + let strs_bytes: Vec> = strs.iter().map(|s| s.bytes().collect()).collect(); + + for col in 0..m { + let mut bad = false; + for i in 0..n - 1 { + if !sorted_pairs[i] && strs_bytes[i][col] > strs_bytes[i + 1][col] { + bad = true; + break; + } + } + + if bad { + del_count += 1; + continue; + } + + for i in 0..n - 1 { + if !sorted_pairs[i] && strs_bytes[i][col] < strs_bytes[i + 1][col] { + sorted_pairs[i] = true; + } + } + + if sorted_pairs.iter().all(|&b| b) { + break; + } + } + + del_count + } +} diff --git a/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.swift b/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.swift new file mode 100644 index 00000000..fb384262 --- /dev/null +++ b/tests/501-1000/955. delete-columns-to-make-sorted-ii/sol.swift @@ -0,0 +1,36 @@ +class Solution { + func minDeletionSize(_ strs: [String]) -> Int { + let n = strs.count + let m = strs[0].count + var sortedPairs = [Bool](repeating: false, count: n - 1) + var delCount = 0 + let strsArr = strs.map { Array($0) } + + for col in 0.. strsArr[i + 1][col] { + bad = true + break + } + } + + if bad { + delCount += 1 + continue + } + + for i in 0.. strs[i + 1][col]) { + bad = true; + break; + } + } + + if (bad) { + delCount++; + continue; + } + + for (let i = 0; i < n - 1; i++) { + if (!sortedPairs[i] && strs[i][col] < strs[i + 1][col]) { + sortedPairs[i] = true; + } + } + + if (sortedPairs.every((b) => b)) break; + } + + return delCount; +} diff --git a/tests/501-1000/956. tallest-billboard/manifest.yaml b/tests/501-1000/956. tallest-billboard/manifest.yaml new file mode 100644 index 00000000..f6fe6047 --- /dev/null +++ b/tests/501-1000/956. tallest-billboard/manifest.yaml @@ -0,0 +1,340 @@ +entry: + id: 956 + title: tallest-billboard + params: + rods: + type: array + items: + type: int + call: + cpp: Solution().tallestBillboard({rods}) + rust: Solution::tallest_billboard({rods}) + python3: Solution().tallestBillboard({rods}) + python2: Solution().tallestBillboard({rods}) + ruby: tallest_billboard({rods}) + java: new Solution().tallestBillboard({rods}) + csharp: new Solution().TallestBillboard({rods}) + kotlin: Solution().tallestBillboard({rods}) + go: tallestBillboard({rods}) + dart: Solution().tallestBillboard({rods}) + swift: Solution().tallestBillboard({rods}) + typescript: tallestBillboard({rods}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 956 +tests: + - name: case_1 + in: + rods: + - 9 + out: 0 + - name: case_2 + in: + rods: + - 10 + - 9 + - 18 + out: 0 + - name: case_3 + in: + rods: + - 6 + - 9 + - 13 + - 11 + - 3 + out: 9 + - name: case_4 + in: + rods: + - 16 + - 8 + - 8 + - 13 + out: 16 + - name: case_5 + in: + rods: + - 8 + - 7 + - 3 + - 3 + out: 3 + - name: case_6 + in: + rods: + - 12 + - 9 + - 15 + - 5 + - 20 + out: 20 + - name: case_7 + in: + rods: + - 12 + out: 0 + - name: case_8 + in: + rods: + - 12 + - 4 + - 9 + out: 0 + - name: case_9 + in: + rods: + - 8 + - 8 + - 18 + - 15 + - 18 + - 17 + out: 33 + - name: case_10 + in: + rods: + - 17 + - 14 + - 10 + - 1 + - 4 + - 2 + - 5 + - 15 + out: 34 + - name: case_11 + in: + rods: + - 5 + - 13 + - 9 + - 6 + - 17 + - 19 + - 8 + - 11 + out: 44 + - name: case_12 + in: + rods: + - 14 + - 5 + - 5 + - 6 + - 3 + - 11 + - 6 + - 9 + out: 28 + - name: case_13 + in: + rods: + - 3 + out: 0 + - name: case_14 + in: + rods: + - 3 + out: 0 + - name: case_15 + in: + rods: + - 17 + - 8 + - 13 + - 15 + - 16 + out: 0 + - name: case_16 + in: + rods: + - 5 + - 4 + - 7 + - 1 + - 17 + - 5 + - 18 + - 4 + out: 30 + - name: case_17 + in: + rods: + - 3 + - 12 + - 11 + - 14 + - 20 + out: 23 + - name: case_18 + in: + rods: + - 4 + - 20 + - 6 + - 3 + - 6 + - 14 + out: 20 + - name: case_19 + in: + rods: + - 13 + - 9 + - 18 + - 18 + out: 18 + - name: case_20 + in: + rods: + - 16 + - 6 + - 17 + - 12 + - 11 + - 11 + out: 28 + - name: case_21 + in: + rods: + - 15 + out: 0 + - name: case_22 + in: + rods: + - 15 + - 2 + - 10 + - 10 + out: 10 + - name: case_23 + in: + rods: + - 18 + - 5 + - 1 + out: 0 + - name: case_24 + in: + rods: + - 20 + out: 0 + - name: case_25 + in: + rods: + - 10 + - 2 + - 6 + out: 0 + - name: case_26 + in: + rods: + - 11 + - 1 + - 1 + - 4 + - 6 + - 14 + out: 18 + - name: case_27 + in: + rods: + - 7 + - 15 + - 5 + - 1 + - 16 + - 16 + out: 22 + - name: case_28 + in: + rods: + - 4 + - 4 + - 1 + - 8 + out: 8 + - name: case_29 + in: + rods: + - 6 + - 6 + - 7 + - 12 + - 1 + - 4 + - 2 + - 19 + out: 28 + - name: case_30 + in: + rods: + - 5 + - 6 + - 19 + - 18 + - 3 + - 20 + - 20 + - 7 + - 6 + out: 52 + - name: case_31 + in: + rods: + - 5 + - 13 + - 14 + - 3 + - 12 + - 7 + - 4 + - 9 + - 17 + out: 42 + - name: case_32 + in: + rods: + - 12 + - 19 + - 15 + - 9 + out: 0 + - name: case_33 + in: + rods: + - 11 + - 11 + - 11 + - 5 + - 14 + out: 11 + - name: case_34 + in: + rods: + - 14 + - 12 + - 17 + - 10 + out: 0 + - name: case_35 + in: + rods: + - 3 + - 8 + - 2 + - 20 + - 13 + - 15 + - 19 + - 4 + - 3 + out: 42 diff --git a/tests/501-1000/956. tallest-billboard/sol.cpp b/tests/501-1000/956. tallest-billboard/sol.cpp new file mode 100644 index 00000000..48500656 --- /dev/null +++ b/tests/501-1000/956. tallest-billboard/sol.cpp @@ -0,0 +1,47 @@ +class Solution { +public: + int tallestBillboard(vector& rods) { + int n = rods.size(); + int mid = (n - 1) >> 1; + + vector> left, right; + + function>&)> gen = + [&](int idx, int end, int a, int b, vector>& vals) { + if (idx == end + 1) { + vals.emplace_back(a - b, b); + return; + } + gen(idx + 1, end, a, b, vals); + gen(idx + 1, end, a + rods[idx], b, vals); + gen(idx + 1, end, a, b + rods[idx], vals); + }; + + gen(0, mid, 0, 0, left); + gen(mid + 1, n - 1, 0, 0, right); + + sort(left.begin(), left.end(), [](const auto& a, const auto& b) { + return a.first != b.first ? a.first < b.first : a.second > b.second; + }); + sort(right.begin(), right.end(), [](const auto& a, const auto& b) { + return a.first != b.first ? a.first < b.first : a.second > b.second; + }); + + vector rightDiffs, rightHeights; + for (auto& p : right) { + rightDiffs.push_back(p.first); + rightHeights.push_back(p.second); + } + + int ans = 0; + for (auto& [d, b] : left) { + int target = -d; + auto it = lower_bound(rightDiffs.begin(), rightDiffs.end(), target); + int idx = it - rightDiffs.begin(); + if (idx < rightDiffs.size() && rightDiffs[idx] == target) { + ans = max(ans, b + rightHeights[idx]); + } + } + return ans; + } +}; diff --git a/tests/501-1000/956. tallest-billboard/sol.cs b/tests/501-1000/956. tallest-billboard/sol.cs new file mode 100644 index 00000000..6bd1396e --- /dev/null +++ b/tests/501-1000/956. tallest-billboard/sol.cs @@ -0,0 +1,48 @@ +public class Solution { + public int TallestBillboard(int[] rods) { + int n = rods.Length; + int mid = (n - 1) >> 1; + + var left = new List<(int, int)>(); + var right = new List<(int, int)>(); + + void Gen(int idx, int end, int a, int b, List<(int, int)> vals) { + if (idx == end + 1) { + vals.Add((a - b, b)); + return; + } + Gen(idx + 1, end, a, b, vals); + Gen(idx + 1, end, a + rods[idx], b, vals); + Gen(idx + 1, end, a, b + rods[idx], vals); + } + + Gen(0, mid, 0, 0, left); + Gen(mid + 1, n - 1, 0, 0, right); + + left.Sort((a, b) => a.Item1 != b.Item1 ? a.Item1.CompareTo(b.Item1) : b.Item2.CompareTo(a.Item2)); + right.Sort((a, b) => a.Item1 != b.Item1 ? a.Item1.CompareTo(b.Item1) : b.Item2.CompareTo(a.Item2)); + + int ans = 0; + var rightDiffs = new int[right.Count]; + var rightHeights = new int[right.Count]; + for (int i = 0; i < right.Count; i++) { + rightDiffs[i] = right[i].Item1; + rightHeights[i] = right[i].Item2; + } + + for (int i = 0; i < left.Count; i++) { + int d = left[i].Item1, b = left[i].Item2; + int target = -d; + int lo = 0, hi = rightDiffs.Length; + while (lo < hi) { + int m = (lo + hi) >> 1; + if (rightDiffs[m] < target) lo = m + 1; + else hi = m; + } + if (lo < rightDiffs.Length && rightDiffs[lo] == target) { + ans = Math.Max(ans, b + rightHeights[lo]); + } + } + return ans; + } +} diff --git a/tests/501-1000/956. tallest-billboard/sol.dart b/tests/501-1000/956. tallest-billboard/sol.dart new file mode 100644 index 00000000..fe67b3a0 --- /dev/null +++ b/tests/501-1000/956. tallest-billboard/sol.dart @@ -0,0 +1,51 @@ +class Solution { + int tallestBillboard(List rods) { + int n = rods.length; + int mid = (n - 1) >> 1; + + List> left = []; + List> right = []; + + void gen(int idx, int end, int a, int b, List> vals) { + if (idx == end + 1) { + vals.add([a - b, b]); + return; + } + gen(idx + 1, end, a, b, vals); + gen(idx + 1, end, a + rods[idx], b, vals); + gen(idx + 1, end, a, b + rods[idx], vals); + } + + gen(0, mid, 0, 0, left); + gen(mid + 1, n - 1, 0, 0, right); + + left.sort((a, b) => a[0] != b[0] ? a[0].compareTo(b[0]) : b[1].compareTo(a[1])); + right.sort((a, b) => a[0] != b[0] ? a[0].compareTo(b[0]) : b[1].compareTo(a[1])); + + int ans = 0; + List rightDiffs = right.map((e) => e[0]).toList(); + List rightHeights = right.map((e) => e[1]).toList(); + + for (var l in left) { + int d = l[0], b = l[1]; + int target = -d; + int idx = lowerBound(rightDiffs, target); + if (idx < rightDiffs.length && rightDiffs[idx] == target) { + ans = max(ans, b + rightHeights[idx]); + } + } + return ans; + } + + int lowerBound(List arr, int target) { + int lo = 0, hi = arr.length; + while (lo < hi) { + int mid = (lo + hi) >> 1; + if (arr[mid] < target) lo = mid + 1; + else hi = mid; + } + return lo; + } + + int max(int a, int b) => a > b ? a : b; +} diff --git a/tests/501-1000/956. tallest-billboard/sol.go b/tests/501-1000/956. tallest-billboard/sol.go new file mode 100644 index 00000000..ca7a5854 --- /dev/null +++ b/tests/501-1000/956. tallest-billboard/sol.go @@ -0,0 +1,59 @@ +func tallestBillboard(rods []int) int { + n := len(rods) + mid := (n - 1) >> 1 + + type pair struct { + diff int + height int + } + + var left, right []pair + + var gen func(int, int, int, int, *[]pair) + gen = func(idx, end, a, b int, vals *[]pair) { + if idx == end+1 { + *vals = append(*vals, pair{a - b, b}) + return + } + gen(idx+1, end, a, b, vals) + gen(idx+1, end, a+rods[idx], b, vals) + gen(idx+1, end, a, b+rods[idx], vals) + } + + gen(0, mid, 0, 0, &left) + gen(mid+1, n-1, 0, 0, &right) + + sort.Slice(left, func(i, j int) bool { + if left[i].diff != left[j].diff { + return left[i].diff < left[j].diff + } + return left[i].height > left[j].height + }) + + sort.Slice(right, func(i, j int) bool { + if right[i].diff != right[j].diff { + return right[i].diff < right[j].diff + } + return right[i].height > right[j].height + }) + + ans := 0 + rightDiffs := make([]int, len(right)) + rightHeights := make([]int, len(right)) + for i, p := range right { + rightDiffs[i] = p.diff + rightHeights[i] = p.height + } + + for _, p := range left { + d, b := p.diff, p.height + target := -d + idx := sort.SearchInts(rightDiffs, target) + if idx < len(rightDiffs) && rightDiffs[idx] == target { + if b+rightHeights[idx] > ans { + ans = b + rightHeights[idx] + } + } + } + return ans +} diff --git a/tests/501-1000/956. tallest-billboard/sol.java b/tests/501-1000/956. tallest-billboard/sol.java new file mode 100644 index 00000000..ee8cef21 --- /dev/null +++ b/tests/501-1000/956. tallest-billboard/sol.java @@ -0,0 +1,54 @@ +class Solution { + public int tallestBillboard(int[] rods) { + int n = rods.length; + int mid = (n - 1) >> 1; + + java.util.List left = new java.util.ArrayList<>(); + java.util.List right = new java.util.ArrayList<>(); + + gen(0, mid, 0, 0, rods, left); + gen(mid + 1, n - 1, 0, 0, rods, right); + + left.sort((a, b) -> a[0] != b[0] ? Integer.compare(a[0], b[0]) : Integer.compare(b[1], a[1])); + right.sort((a, b) -> a[0] != b[0] ? Integer.compare(a[0], b[0]) : Integer.compare(b[1], a[1])); + + int ans = 0; + int[] rightDiffs = new int[right.size()]; + int[] rightHeights = new int[right.size()]; + for (int i = 0; i < right.size(); i++) { + rightDiffs[i] = right.get(i)[0]; + rightHeights[i] = right.get(i)[1]; + } + + for (int i = 0; i < left.size(); i++) { + int d = left.get(i)[0]; + int b = left.get(i)[1]; + int target = -d; + int idx = lowerBound(rightDiffs, target); + if (idx < rightDiffs.length && rightDiffs[idx] == target) { + ans = Math.max(ans, b + rightHeights[idx]); + } + } + return ans; + } + + private void gen(int idx, int end, int a, int b, int[] rods, java.util.List vals) { + if (idx == end + 1) { + vals.add(new int[]{a - b, b}); + return; + } + gen(idx + 1, end, a, b, rods, vals); + gen(idx + 1, end, a + rods[idx], b, rods, vals); + gen(idx + 1, end, a, b + rods[idx], rods, vals); + } + + private int lowerBound(int[] arr, int target) { + int lo = 0, hi = arr.length; + while (lo < hi) { + int mid = (lo + hi) >>> 1; + if (arr[mid] < target) lo = mid + 1; + else hi = mid; + } + return lo; + } +} diff --git a/tests/501-1000/956. tallest-billboard/sol.kt b/tests/501-1000/956. tallest-billboard/sol.kt new file mode 100644 index 00000000..5268f05f --- /dev/null +++ b/tests/501-1000/956. tallest-billboard/sol.kt @@ -0,0 +1,38 @@ +class Solution { + fun tallestBillboard(rods: IntArray): Int { + val n = rods.size + val mid = (n - 1) shr 1 + val left = mutableListOf>() + val right = mutableListOf>() + + fun gen(idx: Int, end: Int, a: Int, b: Int, vals: MutableList>) { + if (idx == end + 1) { + vals.add(Pair(a - b, b)) + return + } + gen(idx + 1, end, a, b, vals) + gen(idx + 1, end, a + rods[idx], b, vals) + gen(idx + 1, end, a, b + rods[idx], vals) + } + + gen(0, mid, 0, 0, left) + gen(mid + 1, n - 1, 0, 0, right) + + left.sortWith(compareBy> { it.first }.thenByDescending { it.second }) + right.sortWith(compareBy> { it.first }.thenByDescending { it.second }) + + var ans = 0 + val rightDiffs = right.map { it.first } + val rightHeights = right.map { it.second } + + for ((d, b) in left) { + val target = -d + var idx = rightDiffs.binarySearch(target) + if (idx < 0) idx = -idx - 1 + if (idx < rightDiffs.size && rightDiffs[idx] == target) { + ans = maxOf(ans, b + rightHeights[idx]) + } + } + return ans + } +} diff --git a/tests/501-1000/956. tallest-billboard/sol.py b/tests/501-1000/956. tallest-billboard/sol.py new file mode 100644 index 00000000..e4579a55 --- /dev/null +++ b/tests/501-1000/956. tallest-billboard/sol.py @@ -0,0 +1,108 @@ +import bisect +from typing import List + + +# https://leetcode.com/problems/tallest-billboard/ +class Solution: + def tallestBillboard(self, rods: List[int]) -> int: + """ + Split rods into two halves + + For each half generate all possible states + + Each rod has three choices + + put into first support + put into second support + ignore the rod + + Let + + a = height of first support + b = height of second support + + Store + + difference = a - b + smaller_height = b + + Why store b + + Suppose difference is fixed + + a = b + difference + + So once difference is known maximizing b automatically maximizes a as well + + Therefore for every difference we only care about the state having the largest smaller support + + Left half gives + + difference_left + smaller_height_left + + Right half gives + + difference_right + smaller_height_right + + When combining the two halves we want final supports to have equal height + + Final difference + + difference_left + difference_right = 0 + + Therefore + + difference_right = -difference_left + + If this condition holds then the imbalance created in the left half is exactly cancelled by the imbalance created in the right half + + The total common height becomes + + smaller_height_left + smaller_height_right + + Since both lists are sorted by difference + + Binary search finds states in the right half having opposite difference + + Among those states choosing the largest stored smaller height gives the best answer + + Meet in the middle reduces complexity from + + 3^n + + to roughly + + 3^(n/2) + 3^(n/2) + + which is feasible for the constraints + """ + n = len(rods) + + def gen(idx, end, a, b, vals): + # skip + if idx == end + 1: + vals.append((a - b, b)) + return + gen(idx + 1, end, a, b, vals) + gen(idx + 1, end, a + rods[idx], b, vals) + gen(idx + 1, end, a, b + rods[idx], vals) + + left = [] + right = [] + mid = (n - 1) >> 1 + gen(0, mid, 0, 0, left) + gen(mid + 1, n - 1, 0, 0, right) + left.sort(key=lambda x: (x[0], -x[1])) + right.sort(key=lambda x: (x[0], -x[1])) + # print(left) + # print(right) + ans = 0 + for i in range(len(left)): + d = left[i][0] + b = left[i][1] + idx = bisect.bisect_left(right, (-d, -1)) + if idx < len(right) and right[idx][0] == -d: + ans = max(ans, b + right[idx][1]) + return ans diff --git a/tests/501-1000/956. tallest-billboard/sol.py2 b/tests/501-1000/956. tallest-billboard/sol.py2 new file mode 100644 index 00000000..2eb09aa6 --- /dev/null +++ b/tests/501-1000/956. tallest-billboard/sol.py2 @@ -0,0 +1,33 @@ +class Solution(object): + def tallestBillboard(self, rods): + """ + :type rods: List[int] + :rtype: int + """ + n = len(rods) + def gen(idx, end, a, b, vals): + if idx == end + 1: + vals.append((a - b, b)) + return + gen(idx + 1, end, a, b, vals) + gen(idx + 1, end, a + rods[idx], b, vals) + gen(idx + 1, end, a, b + rods[idx], vals) + + left = [] + right = [] + mid = (n - 1) >> 1 + gen(0, mid, 0, 0, left) + gen(mid + 1, n - 1, 0, 0, right) + + left.sort(key=lambda x: (x[0], -x[1])) + right.sort(key=lambda x: (x[0], -x[1])) + + import bisect + ans = 0 + for i in range(len(left)): + d = left[i][0] + b = left[i][1] + idx = bisect.bisect_left(right, (-d, -1)) + if idx < len(right) and right[idx][0] == -d: + ans = max(ans, b + right[idx][1]) + return ans diff --git a/tests/501-1000/956. tallest-billboard/sol.rb b/tests/501-1000/956. tallest-billboard/sol.rb new file mode 100644 index 00000000..0e6e9bbb --- /dev/null +++ b/tests/501-1000/956. tallest-billboard/sol.rb @@ -0,0 +1,37 @@ +# @param {Integer[]} rods +# @return {Integer} +def tallest_billboard(rods) + n = rods.length + left = [] + right = [] + mid = (n - 1) >> 1 + + gen = lambda do |idx, last, a, b, vals| + if idx == last + 1 + vals << [a - b, b] + return + end + gen.call(idx + 1, last, a, b, vals) + gen.call(idx + 1, last, a + rods[idx], b, vals) + gen.call(idx + 1, last, a, b + rods[idx], vals) + end + + gen.call(0, mid, 0, 0, left) + gen.call(mid + 1, n - 1, 0, 0, right) + + left.sort_by! { |d, b| [d, -b] } + right.sort_by! { |d, b| [d, -b] } + + ans = 0 + right_diffs = right.map { |r| r[0] } + right_vals = right.map { |r| r[1] } + + left.each do |d, b| + target = -d + idx = right_diffs.bsearch_index { |x| x >= target } + if idx && right_diffs[idx] == target + ans = [ans, b + right_vals[idx]].max + end + end + ans +end diff --git a/tests/501-1000/956. tallest-billboard/sol.rs b/tests/501-1000/956. tallest-billboard/sol.rs new file mode 100644 index 00000000..38105c4d --- /dev/null +++ b/tests/501-1000/956. tallest-billboard/sol.rs @@ -0,0 +1,41 @@ +impl Solution { + pub fn tallest_billboard(rods: Vec) -> i32 { + let n = rods.len(); + let mid = (n - 1) >> 1; + + let mut left: Vec<(i32, i32)> = Vec::new(); + let mut right: Vec<(i32, i32)> = Vec::new(); + + fn dfs(idx: usize, end: usize, a: i32, b: i32, rods: &Vec, vals: &mut Vec<(i32, i32)>) { + if idx == end + 1 { + vals.push((a - b, b)); + return; + } + dfs(idx + 1, end, a, b, rods, vals); + dfs(idx + 1, end, a + rods[idx], b, rods, vals); + dfs(idx + 1, end, a, b + rods[idx], rods, vals); + } + + dfs(0, mid, 0, 0, &rods, &mut left); + dfs(mid + 1, n - 1, 0, 0, &rods, &mut right); + + left.sort_by(|a, b| a.0.cmp(&b.0).then(b.1.cmp(&a.1))); + right.sort_by(|a, b| a.0.cmp(&b.0).then(b.1.cmp(&a.1))); + + let mut ans = 0; + let right_diffs: Vec = right.iter().map(|r| r.0).collect(); + let right_heights: Vec = right.iter().map(|r| r.1).collect(); + + for &(d, b) in &left { + let target = -d; + let idx = right_diffs.binary_search_by(|&x| { + if x < target { std::cmp::Ordering::Less } + else { std::cmp::Ordering::Greater } + }).unwrap_err(); + if idx < right_diffs.len() && right_diffs[idx] == target { + ans = ans.max(b + right_heights[idx]); + } + } + ans + } +} diff --git a/tests/501-1000/956. tallest-billboard/sol.swift b/tests/501-1000/956. tallest-billboard/sol.swift new file mode 100644 index 00000000..2005c9ee --- /dev/null +++ b/tests/501-1000/956. tallest-billboard/sol.swift @@ -0,0 +1,42 @@ +class Solution { + func tallestBillboard(_ rods: [Int]) -> Int { + let n = rods.count + let mid = (n - 1) >> 1 + var left = [(Int, Int)]() + var right = [(Int, Int)]() + + func gen(_ idx: Int, _ end: Int, _ a: Int, _ b: Int, _ vals: inout [(Int, Int)]) { + if idx == end + 1 { + vals.append((a - b, b)) + return + } + gen(idx + 1, end, a, b, &vals) + gen(idx + 1, end, a + rods[idx], b, &vals) + gen(idx + 1, end, a, b + rods[idx], &vals) + } + + gen(0, mid, 0, 0, &left) + gen(mid + 1, n - 1, 0, 0, &right) + + left.sort { $0.0 != $1.0 ? $0.0 < $1.0 : $0.1 > $1.1 } + right.sort { $0.0 != $1.0 ? $0.0 < $1.0 : $0.1 > $1.1 } + + var ans = 0 + let rightDiffs = right.map { $0.0 } + let rightHeights = right.map { $0.1 } + + for (d, b) in left { + let target = -d + var lo = 0, hi = rightDiffs.count + while lo < hi { + let mid = (lo + hi) >> 1 + if rightDiffs[mid] < target { lo = mid + 1 } + else { hi = mid } + } + if lo < rightDiffs.count && rightDiffs[lo] == target { + ans = max(ans, b + rightHeights[lo]) + } + } + return ans + } +} diff --git a/tests/501-1000/956. tallest-billboard/sol.ts b/tests/501-1000/956. tallest-billboard/sol.ts new file mode 100644 index 00000000..90e575a4 --- /dev/null +++ b/tests/501-1000/956. tallest-billboard/sol.ts @@ -0,0 +1,48 @@ +function tallestBillboard(rods: number[]): number { + const n = rods.length; + const mid = (n - 1) >> 1; + + const left: [number, number][] = []; + const right: [number, number][] = []; + + function gen( + idx: number, + end: number, + a: number, + b: number, + vals: [number, number][], + ): void { + if (idx === end + 1) { + vals.push([a - b, b]); + return; + } + gen(idx + 1, end, a, b, vals); + gen(idx + 1, end, a + rods[idx], b, vals); + gen(idx + 1, end, a, b + rods[idx], vals); + } + + gen(0, mid, 0, 0, left); + gen(mid + 1, n - 1, 0, 0, right); + + left.sort((a, b) => (a[0] !== b[0] ? a[0] - b[0] : b[1] - a[1])); + right.sort((a, b) => (a[0] !== b[0] ? a[0] - b[0] : b[1] - a[1])); + + let ans = 0; + const rightDiffs = right.map((r) => r[0]); + const rightHeights = right.map((r) => r[1]); + + for (const [d, b] of left) { + const target = -d; + let lo = 0, + hi = rightDiffs.length; + while (lo < hi) { + const m = (lo + hi) >> 1; + if (rightDiffs[m] < target) lo = m + 1; + else hi = m; + } + if (lo < rightDiffs.length && rightDiffs[lo] === target) { + ans = Math.max(ans, b + rightHeights[lo]); + } + } + return ans; +} diff --git a/tests/501-1000/957. prison-cells-after-n-days/manifest.yaml b/tests/501-1000/957. prison-cells-after-n-days/manifest.yaml new file mode 100644 index 00000000..83f16b37 --- /dev/null +++ b/tests/501-1000/957. prison-cells-after-n-days/manifest.yaml @@ -0,0 +1,769 @@ +entry: + id: 957 + title: prison-cells-after-n-days + params: + cells: + type: array + items: + type: int + n: + type: int + call: + cpp: Solution().prisonAfterNDays({cells}, {n}) + rust: Solution::prison_after_n_days({cells}, {n}) + python3: Solution().prisonAfterNDays({cells}, {n}) + python2: Solution().prisonAfterNDays({cells}, {n}) + ruby: prison_after_n_days({cells}, {n}) + java: new Solution().prisonAfterNDays({cells}, {n}) + csharp: new Solution().PrisonAfterNDays({cells}, {n}) + kotlin: Solution().prisonAfterNDays({cells}, {n}) + go: prisonAfterNDays({cells}, {n}) + dart: Solution().prisonAfterNDays({cells}, {n}) + swift: Solution().prisonAfterNDays({cells}, {n}) + typescript: prisonAfterNDays({cells}, {n}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 957 +tests: + - name: case_1 + in: + cells: + - 0 + - 0 + - 0 + - 1 + - 0 + - 1 + - 0 + - 0 + n: 60 + out: + - 0 + - 1 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - name: case_2 + in: + cells: + - 1 + - 1 + - 0 + - 1 + - 0 + - 1 + - 1 + - 0 + n: 22 + out: + - 0 + - 0 + - 0 + - 1 + - 1 + - 1 + - 0 + - 0 + - name: case_3 + in: + cells: + - 0 + - 1 + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + n: 77 + out: + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - 1 + - 0 + - name: case_4 + in: + cells: + - 1 + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + n: 96 + out: + - 0 + - 1 + - 1 + - 1 + - 0 + - 0 + - 1 + - 0 + - name: case_5 + in: + cells: + - 1 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + n: 72 + out: + - 0 + - 0 + - 0 + - 1 + - 0 + - 1 + - 0 + - 0 + - name: case_6 + in: + cells: + - 1 + - 0 + - 1 + - 0 + - 1 + - 1 + - 0 + - 1 + n: 19 + out: + - 0 + - 0 + - 0 + - 1 + - 1 + - 1 + - 0 + - 0 + - name: case_7 + in: + cells: + - 0 + - 1 + - 1 + - 1 + - 1 + - 0 + - 1 + - 0 + n: 41 + out: + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - name: case_8 + in: + cells: + - 0 + - 0 + - 1 + - 1 + - 1 + - 0 + - 1 + - 1 + n: 158 + out: + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 1 + - 0 + - name: case_9 + in: + cells: + - 1 + - 1 + - 1 + - 1 + - 0 + - 1 + - 1 + - 1 + n: 193 + out: + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - name: case_10 + in: + cells: + - 1 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + n: 113 + out: + - 0 + - 1 + - 1 + - 0 + - 1 + - 1 + - 1 + - 0 + - name: case_11 + in: + cells: + - 1 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + n: 27 + out: + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - name: case_12 + in: + cells: + - 0 + - 0 + - 1 + - 0 + - 1 + - 1 + - 0 + - 0 + n: 89 + out: + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - name: case_13 + in: + cells: + - 1 + - 0 + - 0 + - 1 + - 1 + - 1 + - 0 + - 0 + n: 181 + out: + - 0 + - 1 + - 1 + - 1 + - 1 + - 0 + - 1 + - 0 + - name: case_14 + in: + cells: + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 1 + n: 118 + out: + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 1 + - 0 + - name: case_15 + in: + cells: + - 1 + - 0 + - 1 + - 0 + - 0 + - 1 + - 0 + - 1 + n: 128 + out: + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - name: case_16 + in: + cells: + - 0 + - 1 + - 0 + - 0 + - 0 + - 1 + - 0 + - 1 + n: 180 + out: + - 0 + - 1 + - 0 + - 1 + - 1 + - 1 + - 1 + - 0 + - name: case_17 + in: + cells: + - 1 + - 1 + - 0 + - 1 + - 0 + - 0 + - 1 + - 0 + n: 125 + out: + - 0 + - 1 + - 0 + - 1 + - 0 + - 1 + - 1 + - 0 + - name: case_18 + in: + cells: + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 1 + - 1 + n: 75 + out: + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 1 + - 0 + - name: case_19 + in: + cells: + - 0 + - 1 + - 1 + - 0 + - 0 + - 1 + - 0 + - 1 + n: 65 + out: + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 1 + - 0 + - name: case_20 + in: + cells: + - 0 + - 1 + - 1 + - 0 + - 0 + - 1 + - 1 + - 1 + n: 141 + out: + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - name: case_21 + in: + cells: + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 1 + n: 11 + out: + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - name: case_22 + in: + cells: + - 1 + - 0 + - 1 + - 0 + - 1 + - 1 + - 0 + - 1 + n: 58 + out: + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + - 1 + - 0 + - name: case_23 + in: + cells: + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + n: 73 + out: + - 0 + - 1 + - 1 + - 0 + - 0 + - 1 + - 1 + - 0 + - name: case_24 + in: + cells: + - 0 + - 0 + - 1 + - 1 + - 1 + - 0 + - 1 + - 1 + n: 63 + out: + - 0 + - 1 + - 1 + - 1 + - 0 + - 1 + - 1 + - 0 + - name: case_25 + in: + cells: + - 1 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + n: 155 + out: + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - name: case_26 + in: + cells: + - 0 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + n: 82 + out: + - 0 + - 1 + - 1 + - 1 + - 0 + - 1 + - 0 + - 0 + - name: case_27 + in: + cells: + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + n: 192 + out: + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 1 + - 0 + - name: case_28 + in: + cells: + - 1 + - 1 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + n: 126 + out: + - 0 + - 0 + - 1 + - 1 + - 1 + - 1 + - 0 + - 0 + - name: case_29 + in: + cells: + - 1 + - 0 + - 0 + - 1 + - 1 + - 0 + - 1 + - 1 + n: 197 + out: + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + - name: case_30 + in: + cells: + - 1 + - 0 + - 1 + - 0 + - 1 + - 1 + - 0 + - 1 + n: 161 + out: + - 0 + - 1 + - 0 + - 0 + - 1 + - 0 + - 1 + - 0 + - name: case_31 + in: + cells: + - 1 + - 0 + - 1 + - 0 + - 0 + - 1 + - 0 + - 1 + n: 183 + out: + - 0 + - 1 + - 1 + - 0 + - 0 + - 1 + - 1 + - 0 + - name: case_32 + in: + cells: + - 1 + - 0 + - 1 + - 1 + - 0 + - 0 + - 0 + - 1 + n: 122 + out: + - 0 + - 0 + - 1 + - 1 + - 1 + - 1 + - 1 + - 0 + - name: case_33 + in: + cells: + - 1 + - 0 + - 1 + - 1 + - 1 + - 1 + - 0 + - 0 + n: 159 + out: + - 0 + - 0 + - 0 + - 1 + - 0 + - 1 + - 0 + - 0 + - name: case_34 + in: + cells: + - 0 + - 1 + - 1 + - 1 + - 0 + - 1 + - 0 + - 1 + n: 160 + out: + - 0 + - 1 + - 1 + - 0 + - 0 + - 1 + - 0 + - 0 + - name: case_35 + in: + cells: + - 1 + - 0 + - 1 + - 0 + - 0 + - 0 + - 1 + - 1 + n: 86 + out: + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + - 1 + - 0 diff --git a/tests/501-1000/957. prison-cells-after-n-days/sol.cpp b/tests/501-1000/957. prison-cells-after-n-days/sol.cpp new file mode 100644 index 00000000..4c37a957 --- /dev/null +++ b/tests/501-1000/957. prison-cells-after-n-days/sol.cpp @@ -0,0 +1,21 @@ +class Solution { +public: + vector prisonAfterNDays(vector& cells, int n) { + n = (n - 1) % 14 + 1; + for (int day = 0; day < n; day++) { + int prev = cells[0]; + for (int i = 1; i < cells.size() - 1; i++) { + int current = cells[i]; + if (prev == cells[i + 1]) { + cells[i] = 1; + } else { + cells[i] = 0; + } + prev = current; + } + cells[0] = 0; + cells[cells.size() - 1] = 0; + } + return cells; + } +}; diff --git a/tests/501-1000/957. prison-cells-after-n-days/sol.cs b/tests/501-1000/957. prison-cells-after-n-days/sol.cs new file mode 100644 index 00000000..9242b333 --- /dev/null +++ b/tests/501-1000/957. prison-cells-after-n-days/sol.cs @@ -0,0 +1,20 @@ +public class Solution { + public int[] PrisonAfterNDays(int[] cells, int n) { + n = (n - 1) % 14 + 1; + for (int day = 0; day < n; day++) { + int prev = cells[0]; + for (int i = 1; i < cells.Length - 1; i++) { + int current = cells[i]; + if (prev == cells[i + 1]) { + cells[i] = 1; + } else { + cells[i] = 0; + } + prev = current; + } + cells[0] = 0; + cells[cells.Length - 1] = 0; + } + return cells; + } +} diff --git a/tests/501-1000/957. prison-cells-after-n-days/sol.dart b/tests/501-1000/957. prison-cells-after-n-days/sol.dart new file mode 100644 index 00000000..309c13fa --- /dev/null +++ b/tests/501-1000/957. prison-cells-after-n-days/sol.dart @@ -0,0 +1,16 @@ +class Solution { + List prisonAfterNDays(List cells, int n) { + n = (n - 1) % 14 + 1; + for (int day = 0; day < n; day++) { + int prev = cells[0]; + for (int i = 1; i < cells.length - 1; i++) { + int current = cells[i]; + cells[i] = (prev == cells[i + 1]) ? 1 : 0; + prev = current; + } + cells[0] = 0; + cells[cells.length - 1] = 0; + } + return cells; + } +} diff --git a/tests/501-1000/957. prison-cells-after-n-days/sol.go b/tests/501-1000/957. prison-cells-after-n-days/sol.go new file mode 100644 index 00000000..9a84d7cf --- /dev/null +++ b/tests/501-1000/957. prison-cells-after-n-days/sol.go @@ -0,0 +1,18 @@ +func prisonAfterNDays(cells []int, n int) []int { + n = (n - 1) % 14 + 1 + for day := 0; day < n; day++ { + prev := cells[0] + for i := 1; i < len(cells) - 1; i++ { + current := cells[i] + if prev == cells[i + 1] { + cells[i] = 1 + } else { + cells[i] = 0 + } + prev = current + } + cells[0] = 0 + cells[len(cells) - 1] = 0 + } + return cells +} diff --git a/tests/501-1000/957. prison-cells-after-n-days/sol.java b/tests/501-1000/957. prison-cells-after-n-days/sol.java new file mode 100644 index 00000000..543f2d0b --- /dev/null +++ b/tests/501-1000/957. prison-cells-after-n-days/sol.java @@ -0,0 +1,20 @@ +class Solution { + public int[] prisonAfterNDays(int[] cells, int n) { + n = (n - 1) % 14 + 1; + for (int day = 0; day < n; day++) { + int prev = cells[0]; + for (int i = 1; i < cells.length - 1; i++) { + int current = cells[i]; + if (prev == cells[i + 1]) { + cells[i] = 1; + } else { + cells[i] = 0; + } + prev = current; + } + cells[0] = 0; + cells[cells.length - 1] = 0; + } + return cells; + } +} diff --git a/tests/501-1000/957. prison-cells-after-n-days/sol.kt b/tests/501-1000/957. prison-cells-after-n-days/sol.kt new file mode 100644 index 00000000..ed8be9c2 --- /dev/null +++ b/tests/501-1000/957. prison-cells-after-n-days/sol.kt @@ -0,0 +1,16 @@ +class Solution { + fun prisonAfterNDays(cells: IntArray, n: Int): IntArray { + var days = (n - 1) % 14 + 1 + for (day in 0 until days) { + var prev = cells[0] + for (i in 1 until cells.size - 1) { + val current = cells[i] + cells[i] = if (prev == cells[i + 1]) 1 else 0 + prev = current + } + cells[0] = 0 + cells[cells.size - 1] = 0 + } + return cells + } +} diff --git a/tests/501-1000/957. prison-cells-after-n-days/sol.py b/tests/501-1000/957. prison-cells-after-n-days/sol.py new file mode 100644 index 00000000..143a4d9a --- /dev/null +++ b/tests/501-1000/957. prison-cells-after-n-days/sol.py @@ -0,0 +1,23 @@ +class Solution(object): + def prisonAfterNDays(self, cells, n): + # The state sequence repeats every 14 days. + # Scale down large 'n' values to an equivalent day count between 1 and 14. + n = (n - 1) % 14 + 1 + + for _ in range(n): + prev = cells[0] + # Update only inner cells since edges lack double neighbors + for i in range(1, len(cells) - 1): + current = cells[i] + # If left neighbor (prev) matches right neighbor, set to 1 + if prev == cells[i + 1]: + cells[i] = 1 + else: + cells[i] = 0 + prev = current + + # Boundary cells always become 0 after day 1 + cells[0] = 0 + cells[-1] = 0 + + return cells diff --git a/tests/501-1000/957. prison-cells-after-n-days/sol.py2 b/tests/501-1000/957. prison-cells-after-n-days/sol.py2 new file mode 100644 index 00000000..53c6d1b8 --- /dev/null +++ b/tests/501-1000/957. prison-cells-after-n-days/sol.py2 @@ -0,0 +1,20 @@ +class Solution(object): + def prisonAfterNDays(self, cells, n): + """ + :type cells: List[int] + :type n: int + :rtype: List[int] + """ + n = (n - 1) % 14 + 1 + for _ in range(n): + prev = cells[0] + for i in range(1, len(cells) - 1): + current = cells[i] + if prev == cells[i + 1]: + cells[i] = 1 + else: + cells[i] = 0 + prev = current + cells[0] = 0 + cells[-1] = 0 + return cells diff --git a/tests/501-1000/957. prison-cells-after-n-days/sol.rb b/tests/501-1000/957. prison-cells-after-n-days/sol.rb new file mode 100644 index 00000000..c051ee86 --- /dev/null +++ b/tests/501-1000/957. prison-cells-after-n-days/sol.rb @@ -0,0 +1,21 @@ +# @param {Integer[]} cells +# @param {Integer} n +# @return {Integer[]} +def prison_after_n_days(cells, n) + n = (n - 1) % 14 + 1 + n.times do + prev = cells[0] + (1...(cells.length - 1)).each do |i| + current = cells[i] + if prev == cells[i + 1] + cells[i] = 1 + else + cells[i] = 0 + end + prev = current + end + cells[0] = 0 + cells[-1] = 0 + end + cells +end diff --git a/tests/501-1000/957. prison-cells-after-n-days/sol.rs b/tests/501-1000/957. prison-cells-after-n-days/sol.rs new file mode 100644 index 00000000..4ae05319 --- /dev/null +++ b/tests/501-1000/957. prison-cells-after-n-days/sol.rs @@ -0,0 +1,22 @@ +impl Solution { + pub fn prison_after_n_days(cells: Vec, n: i32) -> Vec { + let mut cells = cells; + let n = (n - 1) % 14 + 1; + for _ in 0..n { + let mut prev = cells[0]; + for i in 1..cells.len() - 1 { + let current = cells[i]; + if prev == cells[i + 1] { + cells[i] = 1; + } else { + cells[i] = 0; + } + prev = current; + } + cells[0] = 0; + let last = cells.len() - 1; + cells[last] = 0; + } + cells + } +} diff --git a/tests/501-1000/957. prison-cells-after-n-days/sol.swift b/tests/501-1000/957. prison-cells-after-n-days/sol.swift new file mode 100644 index 00000000..c4063353 --- /dev/null +++ b/tests/501-1000/957. prison-cells-after-n-days/sol.swift @@ -0,0 +1,21 @@ +class Solution { + func prisonAfterNDays(_ cells: [Int], _ n: Int) -> [Int] { + var cells = cells + var days = (n - 1) % 14 + 1 + for _ in 0.. q; + q.push(root); + bool past = false; + while (!q.empty()) { + TreeNode* node = q.front(); + q.pop(); + if (node == nullptr) { + past = true; + } else { + if (past) return false; + q.push(node->left); + q.push(node->right); + } + } + return true; + } +}; diff --git a/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.cs b/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.cs new file mode 100644 index 00000000..2a9bcc3e --- /dev/null +++ b/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.cs @@ -0,0 +1,31 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public int val; + * public TreeNode left; + * public TreeNode right; + * public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +public class Solution { + public bool IsCompleteTree(TreeNode root) { + var q = new System.Collections.Generic.Queue(); + q.Enqueue(root); + bool past = false; + while (q.Count > 0) { + TreeNode node = q.Dequeue(); + if (node == null) { + past = true; + } else { + if (past) return false; + q.Enqueue(node.left); + q.Enqueue(node.right); + } + } + return true; + } +} diff --git a/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.dart b/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.dart new file mode 100644 index 00000000..674cd85d --- /dev/null +++ b/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.dart @@ -0,0 +1,26 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * int val; + * TreeNode? left; + * TreeNode? right; + * TreeNode([this.val = 0, this.left, this.right]); + * } + */ +class Solution { + bool isCompleteTree(TreeNode? root) { + var q = [root]; + bool past = false; + while (q.isNotEmpty) { + var node = q.removeAt(0); + if (node == null) { + past = true; + } else { + if (past) return false; + q.add(node.left); + q.add(node.right); + } + } + return true; + } +} diff --git a/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.go b/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.go new file mode 100644 index 00000000..87cad2ed --- /dev/null +++ b/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.go @@ -0,0 +1,26 @@ +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +func isCompleteTree(root *TreeNode) bool { + q := []*TreeNode{root} + past := false + for len(q) > 0 { + node := q[0] + q = q[1:] + if node == nil { + past = true + } else { + if past { + return false + } + q = append(q, node.Left) + q = append(q, node.Right) + } + } + return true +} diff --git a/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.java b/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.java new file mode 100644 index 00000000..5258c644 --- /dev/null +++ b/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.java @@ -0,0 +1,33 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode() {} + * TreeNode(int val) { this.val = val; } + * TreeNode(int val, TreeNode left, TreeNode right) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +class Solution { + public boolean isCompleteTree(TreeNode root) { + java.util.Queue q = new java.util.LinkedList<>(); + q.offer(root); + boolean past = false; + while (!q.isEmpty()) { + TreeNode node = q.poll(); + if (node == null) { + past = true; + } else { + if (past) return false; + q.offer(node.left); + q.offer(node.right); + } + } + return true; + } +} diff --git a/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.kt b/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.kt new file mode 100644 index 00000000..6b727fc9 --- /dev/null +++ b/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.kt @@ -0,0 +1,28 @@ +/** + * Example: + * var ti = TreeNode(5) + * var v = ti.`val` + * Definition for a binary tree node. + * class TreeNode(var `val`: Int) { + * var left: TreeNode? = null + * var right: TreeNode? = null + * } + */ +class Solution { + fun isCompleteTree(root: TreeNode?): Boolean { + val q: java.util.Queue = java.util.LinkedList() + q.offer(root) + var past = false + while (!q.isEmpty()) { + val node = q.poll() + if (node == null) { + past = true + } else { + if (past) return false + q.offer(node.left) + q.offer(node.right) + } + } + return true + } +} diff --git a/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.py b/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.py new file mode 100644 index 00000000..895d7fd9 --- /dev/null +++ b/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.py @@ -0,0 +1,25 @@ +from collections import deque +from typing import Optional + + +class TreeNode: + def __init__(self, val=0, left=None, right=None): + self.val = val + self.left = left + self.right = right + + +class Solution: + def isCompleteTree(self, root): + q = deque([root]) + past = False + while q: + rv = q.popleft() + if not rv: + past = True + else: + if past: + return False + q.append(rv.left) + q.append(rv.right) + return True diff --git a/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.py2 b/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.py2 new file mode 100644 index 00000000..861f7e6e --- /dev/null +++ b/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.py2 @@ -0,0 +1,25 @@ +# Definition for a binary tree node. +# class TreeNode(object): +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution(object): + def isCompleteTree(self, root): + """ + :type root: Optional[TreeNode] + :rtype: bool + """ + from collections import deque + q = deque([root]) + past = False + while q: + node = q.popleft() + if not node: + past = True + else: + if past: + return False + q.append(node.left) + q.append(node.right) + return True diff --git a/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.rb b/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.rb new file mode 100644 index 00000000..a25be317 --- /dev/null +++ b/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.rb @@ -0,0 +1,26 @@ +# Definition for a binary tree node. +# class TreeNode +# attr_accessor :val, :left, :right +# def initialize(val = 0, left = nil, right = nil) +# @val = val +# @left = left +# @right = right +# end +# end +# @param {TreeNode} root +# @return {Boolean} +def is_complete_tree(root) + q = [root] + past = false + while !q.empty? + node = q.shift + if node.nil? + past = true + else + return false if past + q.push(node.left) + q.push(node.right) + end + end + true +end diff --git a/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.rs b/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.rs new file mode 100644 index 00000000..389334a4 --- /dev/null +++ b/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.rs @@ -0,0 +1,42 @@ +// Definition for a binary tree node. +// #[derive(Debug, PartialEq, Eq)] +// pub struct TreeNode { +// pub val: i32, +// pub left: Option>>, +// pub right: Option>>, +// } +// +// impl TreeNode { +// #[inline] +// pub fn new(val: i32) -> Self { +// TreeNode { +// val, +// left: None, +// right: None +// } +// } +// } +impl Solution { + pub fn is_complete_tree(root: Option>>) -> bool { + use std::collections::VecDeque; + let mut q: VecDeque>>> = VecDeque::new(); + q.push_back(root); + let mut past = false; + while let Some(node) = q.pop_front() { + match node { + None => { + past = true; + } + Some(n) => { + if past { + return false; + } + let n = n.borrow(); + q.push_back(n.left.clone()); + q.push_back(n.right.clone()); + } + } + } + true + } +} diff --git a/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.swift b/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.swift new file mode 100644 index 00000000..75e0619f --- /dev/null +++ b/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.swift @@ -0,0 +1,32 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public var val: Int + * public var left: TreeNode? + * public var right: TreeNode? + * public init() { self.val = 0; self.left = nil; self.right = nil; } + * public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; } + * public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) { + * self.val = val + * self.left = left + * self.right = right + * } + * } + */ +class Solution { + func isCompleteTree(_ root: TreeNode?) -> Bool { + var q: [TreeNode?] = [root] + var past = false + while !q.isEmpty { + let node = q.removeFirst() + if node == nil { + past = true + } else { + if past { return false } + q.append(node!.left) + q.append(node!.right) + } + } + return true + } +} diff --git a/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.ts b/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.ts new file mode 100644 index 00000000..cad9ff74 --- /dev/null +++ b/tests/501-1000/958. check-completeness-of-a-binary-tree/sol.ts @@ -0,0 +1,29 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ + +function isCompleteTree(root: TreeNode | null): boolean { + const q: (TreeNode | null)[] = [root]; + let past = false; + while (q.length > 0) { + const node = q.shift()!; + if (node === null) { + past = true; + } else { + if (past) return false; + q.push(node.left); + q.push(node.right); + } + } + return true; +} diff --git a/tests/501-1000/959. regions-cut-by-slashes/manifest.yaml b/tests/501-1000/959. regions-cut-by-slashes/manifest.yaml new file mode 100644 index 00000000..b388816a --- /dev/null +++ b/tests/501-1000/959. regions-cut-by-slashes/manifest.yaml @@ -0,0 +1,270 @@ +entry: + id: 959 + title: regions-cut-by-slashes + params: + grid: + type: array + items: + type: string + call: + cpp: Solution().regionsBySlashes({grid}) + rust: Solution::regions_by_slashes({grid}) + python3: Solution().regionsBySlashes({grid}) + python2: Solution().regionsBySlashes({grid}) + ruby: regions_by_slashes({grid}) + java: new Solution().regionsBySlashes({grid}) + csharp: new Solution().RegionsBySlashes({grid}) + kotlin: Solution().regionsBySlashes({grid}) + go: regionsBySlashes({grid}) + dart: Solution().regionsBySlashes({grid}) + swift: Solution().regionsBySlashes({grid}) + typescript: regionsBySlashes({grid}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 959 +tests: + - name: case_1 + in: + grid: + - \/ + - \\ + out: 4 + - name: case_2 + in: + grid: + - //\ + - ' \ ' + - " " + out: 3 + - name: case_3 + in: + grid: + - '\ ' + - " " + out: 1 + - name: case_4 + in: + grid: + - / + out: 2 + - name: case_5 + in: + grid: + - /\\/\ + - ' \\/\' + - \ \/\ + - '/\ / ' + - / \\/ + out: 8 + - name: case_6 + in: + grid: + - / \// + - /\\// + - //\\/ + - \ \\ + - ' \\ ' + out: 5 + - name: case_7 + in: + grid: + - " //" + - /// + - ' \/' + out: 4 + - name: case_8 + in: + grid: + - // + - " /" + out: 3 + - name: case_9 + in: + grid: + - \ // + - /\ / + - ' /\\' + - '\/ ' + out: 4 + - name: case_10 + in: + grid: + - // + - \\ + out: 4 + - name: case_11 + in: + grid: + - / \ + - " /" + - ' \/' + out: 4 + - name: case_12 + in: + grid: + - /\ + - \\ + out: 4 + - name: case_13 + in: + grid: + - / + out: 2 + - name: case_14 + in: + grid: + - /\\/ + - '\/ ' + - " /" + - \ \\ + out: 6 + - name: case_15 + in: + grid: + - \ + out: 2 + - name: case_16 + in: + grid: + - '\\/ ' + - " / /" + - ' \\ /' + - /\/ / + - /\ \/ + out: 4 + - name: case_17 + in: + grid: + - \/ + - " " + out: 2 + - name: case_18 + in: + grid: + - // /\ + - ////\ + - "/ // " + - /\\ / + - '//\ ' + out: 6 + - name: case_19 + in: + grid: + - / + out: 2 + - name: case_20 + in: + grid: + - // + - " /" + out: 3 + - name: case_21 + in: + grid: + - \/ + - ' \' + out: 3 + - name: case_22 + in: + grid: + - \ + out: 2 + - name: case_23 + in: + grid: + - / + out: 2 + - name: case_24 + in: + grid: + - ' \\' + - / /\\ + - ' /\/ ' + - //\// + - '//\ ' + out: 5 + - name: case_25 + in: + grid: + - \ / \ + - '\\\\ ' + - ' \\' + - /\/ / + - // / + out: 4 + - name: case_26 + in: + grid: + - " " + out: 1 + - name: case_27 + in: + grid: + - /\\/ + - //// + - \\\\ + - " / " + out: 5 + - name: case_28 + in: + grid: + - / / + - "// " + - ' \/' + out: 4 + - name: case_29 + in: + grid: + - / + out: 2 + - name: case_30 + in: + grid: + - // + - '\ ' + out: 3 + - name: case_31 + in: + grid: + - ' \ / ' + - \\/ \ + - /\//\ + - / / / + - \\\ / + out: 5 + - name: case_32 + in: + grid: + - ' / \' + - /\\\ + - \\ / + - /\ / + out: 6 + - name: case_33 + in: + grid: + - " //" + - '\\ ' + - \\\ + out: 4 + - name: case_34 + in: + grid: + - \//// + - \\\ / + - '\ ' + - ' \ \/' + - /\ /\ + out: 5 + - name: case_35 + in: + grid: + - \ + out: 2 diff --git a/tests/501-1000/959. regions-cut-by-slashes/sol.cpp b/tests/501-1000/959. regions-cut-by-slashes/sol.cpp new file mode 100644 index 00000000..ff98c402 --- /dev/null +++ b/tests/501-1000/959. regions-cut-by-slashes/sol.cpp @@ -0,0 +1,66 @@ +class Solution { +public: + int regionsBySlashes(vector& grid) { + int n = grid.size(); + vector parents(4 * n * n); + for (int i = 0; i < 4 * n * n; i++) { + parents[i] = i; + } + int count = 4 * n * n; + + function find = [&](int x) -> int { + if (x != parents[x]) { + parents[x] = find(parents[x]); + } + return parents[x]; + }; + + auto unionSet = [&](int x, int y) -> bool { + int rx = find(x); + int ry = find(y); + if (rx != ry) { + parents[rx] = ry; + return true; + } + return false; + }; + + vector>> merges = { + {{0, 1}, {1, 2}, {2, 3}}, // ' ' + {{0, 3}, {1, 2}}, // '/' + {{0, 1}, {2, 3}} // '\\' + }; + + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + int base = (i * n + j) * 4; + int idx; + if (grid[i][j] == ' ') idx = 0; + else if (grid[i][j] == '/') idx = 1; + else idx = 2; + + for (auto& p : merges[idx]) { + int u = p.first, v = p.second; + if (unionSet(base + u, base + v)) { + count--; + } + } + + if (i + 1 < n) { + int downBase = ((i + 1) * n + j) * 4; + if (unionSet(base + 2, downBase)) { + count--; + } + } + + if (j + 1 < n) { + int rightBase = (i * n + (j + 1)) * 4; + if (unionSet(base + 1, rightBase + 3)) { + count--; + } + } + } + } + return count; + } +}; diff --git a/tests/501-1000/959. regions-cut-by-slashes/sol.cs b/tests/501-1000/959. regions-cut-by-slashes/sol.cs new file mode 100644 index 00000000..dc31f9e8 --- /dev/null +++ b/tests/501-1000/959. regions-cut-by-slashes/sol.cs @@ -0,0 +1,64 @@ +public class Solution { + private int[] parents = new int[0]; + + private int Find(int x) { + if (parents[x] != x) { + parents[x] = Find(parents[x]); + } + return parents[x]; + } + + private bool Union(int x, int y) { + int rx = Find(x); + int ry = Find(y); + if (rx == ry) { + return false; + } + parents[rx] = ry; + return true; + } + + public int RegionsBySlashes(string[] grid) { + int n = grid.Length; + parents = new int[4 * n * n]; + for (int i = 0; i < parents.Length; i++) { + parents[i] = i; + } + int count = 4 * n * n; + + int[][][] merges = new int[][][] { + new int[][] { new int[] {0, 1}, new int[] {1, 2}, new int[] {2, 3} }, + new int[][] { new int[] {0, 3}, new int[] {1, 2} }, + new int[][] { new int[] {0, 1}, new int[] {2, 3} } + }; + + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + int cellBase = (i * n + j) * 4; + int idx = grid[i][j] == ' ' ? 0 : (grid[i][j] == '/' ? 1 : 2); + + foreach (var pair in merges[idx]) { + int u = pair[0], v = pair[1]; + if (Union(cellBase + u, cellBase + v)) { + count--; + } + } + + if (i + 1 < n) { + int downBase = ((i + 1) * n + j) * 4; + if (Union(cellBase + 2, downBase)) { + count--; + } + } + + if (j + 1 < n) { + int rightBase = (i * n + (j + 1)) * 4; + if (Union(cellBase + 1, rightBase + 3)) { + count--; + } + } + } + } + return count; + } +} diff --git a/tests/501-1000/959. regions-cut-by-slashes/sol.dart b/tests/501-1000/959. regions-cut-by-slashes/sol.dart new file mode 100644 index 00000000..bc576a43 --- /dev/null +++ b/tests/501-1000/959. regions-cut-by-slashes/sol.dart @@ -0,0 +1,57 @@ +class Solution { + int regionsBySlashes(List grid) { + int n = grid.length; + List parents = List.generate(4 * n * n, (i) => i); + int count = 4 * n * n; + + int find(int x) { + if (x != parents[x]) { + parents[x] = find(parents[x]); + } + return parents[x]; + } + + bool union(int x, int y) { + int rx = find(x); + int ry = find(y); + if (rx != ry) { + parents[rx] = ry; + return true; + } + return false; + } + + Map>> merges = { + ' ': [[0, 1], [1, 2], [2, 3]], + '/': [[0, 3], [1, 2]], + '\\': [[0, 1], [2, 3]] + }; + + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + int base = (i * n + j) * 4; + for (var pair in merges[grid[i][j]]!) { + int u = pair[0], v = pair[1]; + if (union(base + u, base + v)) { + count--; + } + } + + if (i + 1 < n) { + int downBase = ((i + 1) * n + j) * 4; + if (union(base + 2, downBase)) { + count--; + } + } + + if (j + 1 < n) { + int rightBase = (i * n + (j + 1)) * 4; + if (union(base + 1, rightBase + 3)) { + count--; + } + } + } + } + return count; + } +} diff --git a/tests/501-1000/959. regions-cut-by-slashes/sol.go b/tests/501-1000/959. regions-cut-by-slashes/sol.go new file mode 100644 index 00000000..88d4e885 --- /dev/null +++ b/tests/501-1000/959. regions-cut-by-slashes/sol.go @@ -0,0 +1,58 @@ +func regionsBySlashes(grid []string) int { + n := len(grid) + parents := make([]int, 4*n*n) + for i := range parents { + parents[i] = i + } + count := 4 * n * n + + var find func(int) int + find = func(x int) int { + if x != parents[x] { + parents[x] = find(parents[x]) + } + return parents[x] + } + + union := func(x, y int) bool { + rx, ry := find(x), find(y) + if rx != ry { + parents[rx] = ry + return true + } + return false + } + + merges := map[byte][][]int{ + ' ': {{0, 1}, {1, 2}, {2, 3}}, + '/': {{0, 3}, {1, 2}}, + '\\': {{0, 1}, {2, 3}}, + } + + for i := 0; i < n; i++ { + for j := 0; j < n; j++ { + base := (i*n + j) * 4 + for _, pair := range merges[grid[i][j]] { + u, v := pair[0], pair[1] + if union(base+u, base+v) { + count-- + } + } + + if i+1 < n { + downBase := ((i+1)*n + j) * 4 + if union(base+2, downBase) { + count-- + } + } + + if j+1 < n { + rightBase := (i*n + (j + 1)) * 4 + if union(base+1, rightBase+3) { + count-- + } + } + } + } + return count +} diff --git a/tests/501-1000/959. regions-cut-by-slashes/sol.java b/tests/501-1000/959. regions-cut-by-slashes/sol.java new file mode 100644 index 00000000..29c6414b --- /dev/null +++ b/tests/501-1000/959. regions-cut-by-slashes/sol.java @@ -0,0 +1,69 @@ +class Solution { + private int[] parents; + private int count; + + private int find(int x) { + if (x != parents[x]) { + parents[x] = find(parents[x]); + } + return parents[x]; + } + + private boolean union(int x, int y) { + int rx = find(x); + int ry = find(y); + if (rx != ry) { + parents[rx] = ry; + return true; + } + return false; + } + + public int regionsBySlashes(String[] grid) { + int n = grid.length; + parents = new int[4 * n * n]; + count = 4 * n * n; + for (int i = 0; i < parents.length; i++) { + parents[i] = i; + } + + int[][][] merges = { + {{0, 1}, {1, 2}, {2, 3}}, // ' ' + {{0, 3}, {1, 2}}, // '/' + {{0, 1}, {2, 3}} // '\\' + }; + + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + int base = (i * n + j) * 4; + int idx; + char c = grid[i].charAt(j); + if (c == ' ') idx = 0; + else if (c == '/') idx = 1; + else idx = 2; + + for (int[] pair : merges[idx]) { + int u = pair[0], v = pair[1]; + if (union(base + u, base + v)) { + count--; + } + } + + if (i + 1 < n) { + int downBase = ((i + 1) * n + j) * 4; + if (union(base + 2, downBase)) { + count--; + } + } + + if (j + 1 < n) { + int rightBase = (i * n + (j + 1)) * 4; + if (union(base + 1, rightBase + 3)) { + count--; + } + } + } + } + return count; + } +} diff --git a/tests/501-1000/959. regions-cut-by-slashes/sol.kt b/tests/501-1000/959. regions-cut-by-slashes/sol.kt new file mode 100644 index 00000000..69814859 --- /dev/null +++ b/tests/501-1000/959. regions-cut-by-slashes/sol.kt @@ -0,0 +1,58 @@ +class Solution { + fun regionsBySlashes(grid: Array): Int { + val n = grid.size + val parents = IntArray(4 * n * n) { it } + var count = 4 * n * n + + fun find(x: Int): Int { + if (x != parents[x]) { + parents[x] = find(parents[x]) + } + return parents[x] + } + + fun union(x: Int, y: Int): Boolean { + val rx = find(x) + val ry = find(y) + if (rx != ry) { + parents[rx] = ry + return true + } + return false + } + + val merges = mapOf( + ' ' to arrayOf(intArrayOf(0, 1), intArrayOf(1, 2), intArrayOf(2, 3)), + '/' to arrayOf(intArrayOf(0, 3), intArrayOf(1, 2)), + '\\' to arrayOf(intArrayOf(0, 1), intArrayOf(2, 3)) + ) + + for (i in 0 until n) { + for (j in 0 until n) { + val base = (i * n + j) * 4 + for (pair in merges[grid[i][j]]!!) { + val u = pair[0] + val v = pair[1] + if (union(base + u, base + v)) { + count-- + } + } + + if (i + 1 < n) { + val downBase = ((i + 1) * n + j) * 4 + if (union(base + 2, downBase)) { + count-- + } + } + + if (j + 1 < n) { + val rightBase = (i * n + (j + 1)) * 4 + if (union(base + 1, rightBase + 3)) { + count-- + } + } + } + } + return count + } +} diff --git a/tests/501-1000/959. regions-cut-by-slashes/sol.py b/tests/501-1000/959. regions-cut-by-slashes/sol.py new file mode 100644 index 00000000..19a378fe --- /dev/null +++ b/tests/501-1000/959. regions-cut-by-slashes/sol.py @@ -0,0 +1,44 @@ +class UnionFind: + def __init__(self, n): + self.parents = list(range(4 * n * n)) + + def find(self, x): + if x != self.parents[x]: + self.parents[x] = self.find(self.parents[x]) + return self.parents[x] + + def union(self, x, y): + x, y = self.find(x), self.find(y) + if x != y: + self.parents[x] = y + return True + return False + + +class Solution: + def regionsBySlashes(self, grid: list[str]) -> int: + n = len(grid) + union = UnionFind(n) + count = 4 * n * n + merges = { + " ": [(0, 1), (1, 2), (2, 3)], + "/": [(0, 3), (1, 2)], + "\\": [(0, 1), (2, 3)], + } + for i in range(n): + for j in range(n): + base = (i * n + j) * 4 + for u, v in merges[grid[i][j]]: + if union.union(base + u, base + v): + count -= 1 + + if i + 1 < n: + down_base = ((i + 1) * n + j) * 4 + if union.union(base + 2, down_base): + count -= 1 + + if j + 1 < n: + right_base = ((j + 1) + n * i) * 4 + if union.union(base + 1, right_base + 3): + count -= 1 + return count diff --git a/tests/501-1000/959. regions-cut-by-slashes/sol.py2 b/tests/501-1000/959. regions-cut-by-slashes/sol.py2 new file mode 100644 index 00000000..ec194ac7 --- /dev/null +++ b/tests/501-1000/959. regions-cut-by-slashes/sol.py2 @@ -0,0 +1,45 @@ +class Solution(object): + def regionsBySlashes(self, grid): + """ + :type grid: List[str] + :rtype: int + """ + class UnionFind: + def __init__(self, n): + self.parents = list(range(4 * n * n)) + def find(self, x): + if x != self.parents[x]: + self.parents[x] = self.find(self.parents[x]) + return self.parents[x] + def union(self, x, y): + x, y = self.find(x), self.find(y) + if x != y: + self.parents[x] = y + return True + return False + + n = len(grid) + union = UnionFind(n) + count = 4 * n * n + merges = { + " ": [(0, 1), (1, 2), (2, 3)], + "/": [(0, 3), (1, 2)], + "\\": [(0, 1), (2, 3)] + } + for i in range(n): + for j in range(n): + base = (i * n + j) * 4 + for u, v in merges[grid[i][j]]: + if union.union(base + u, base + v): + count -= 1 + + if i + 1 < n: + down_base = ((i + 1) * n + j) * 4 + if union.union(base+2, down_base): + count -= 1 + + if j + 1 < n: + right_base = ((j + 1) + n * i) * 4 + if union.union(base+1, right_base+3): + count -= 1 + return count diff --git a/tests/501-1000/959. regions-cut-by-slashes/sol.rb b/tests/501-1000/959. regions-cut-by-slashes/sol.rb new file mode 100644 index 00000000..d6c296b8 --- /dev/null +++ b/tests/501-1000/959. regions-cut-by-slashes/sol.rb @@ -0,0 +1,58 @@ +# @param {String[]} grid +# @return {Integer} +def regions_by_slashes(grid) + n = grid.length + parents = (0...4*n*n).to_a + count = 4 * n * n + + find = ->(x) { + while x != parents[x] + parents[x] = parents[parents[x]] + x = parents[x] + end + x + } + + union = ->(x, y) { + rx, ry = find.call(x), find.call(y) + if rx != ry + parents[rx] = ry + true + else + false + end + } + + merges = { + ' ' => [[0, 1], [1, 2], [2, 3]], + '/' => [[0, 3], [1, 2]], + '\\' => [[0, 1], [2, 3]] + } + + (0...n).each do |i| + (0...n).each do |j| + base = (i * n + j) * 4 + merges[grid[i][j]].each do |u, v| + if union.call(base + u, base + v) + count -= 1 + end + end + + if i + 1 < n + down_base = ((i + 1) * n + j) * 4 + if union.call(base + 2, down_base) + count -= 1 + end + end + + if j + 1 < n + right_base = ((j + 1) + n * i) * 4 + if union.call(base + 1, right_base + 3) + count -= 1 + end + end + end + end + + count +end diff --git a/tests/501-1000/959. regions-cut-by-slashes/sol.rs b/tests/501-1000/959. regions-cut-by-slashes/sol.rs new file mode 100644 index 00000000..b44c4a1e --- /dev/null +++ b/tests/501-1000/959. regions-cut-by-slashes/sol.rs @@ -0,0 +1,60 @@ +impl Solution { + pub fn regions_by_slashes(grid: Vec) -> i32 { + let n = grid.len(); + let mut parents: Vec = (0..4 * n * n).collect(); + let mut count = (4 * n * n) as i32; + + fn find(parents: &mut Vec, x: usize) -> usize { + if x != parents[x] { + parents[x] = find(parents, parents[x]); + } + parents[x] + } + + fn union(parents: &mut Vec, count: &mut i32, x: usize, y: usize) -> bool { + let rx = find(parents, x); + let ry = find(parents, y); + if rx != ry { + parents[rx] = ry; + *count -= 1; + return true; + } + false + } + + let merges: Vec> = vec![ + vec![(0, 1), (1, 2), (2, 3)], // ' ' + vec![(0, 3), (1, 2)], // '/' + vec![(0, 1), (2, 3)], // '\\' + ]; + + let grid: Vec> = grid.iter().map(|s| s.chars().collect()).collect(); + + for i in 0..n { + for j in 0..n { + let base = (i * n + j) * 4; + let idx = match grid[i][j] { + ' ' => 0, + '/' => 1, + '\\' => 2, + _ => unreachable!(), + }; + + for &(u, v) in &merges[idx] { + union(&mut parents, &mut count, base + u, base + v); + } + + if i + 1 < n { + let down_base = ((i + 1) * n + j) * 4; + union(&mut parents, &mut count, base + 2, down_base); + } + + if j + 1 < n { + let right_base = (i * n + (j + 1)) * 4; + union(&mut parents, &mut count, base + 1, right_base + 3); + } + } + } + count + } +} diff --git a/tests/501-1000/959. regions-cut-by-slashes/sol.swift b/tests/501-1000/959. regions-cut-by-slashes/sol.swift new file mode 100644 index 00000000..582fde2a --- /dev/null +++ b/tests/501-1000/959. regions-cut-by-slashes/sol.swift @@ -0,0 +1,58 @@ +class Solution { + func regionsBySlashes(_ grid: [String]) -> Int { + let n = grid.count + var parents = Array(0..<4 * n * n) + var count = 4 * n * n + + func find(_ x: Int) -> Int { + if x != parents[x] { + parents[x] = find(parents[x]) + } + return parents[x] + } + + func union(_ x: Int, _ y: Int) -> Bool { + let rx = find(x) + let ry = find(y) + if rx != ry { + parents[rx] = ry + return true + } + return false + } + + let merges: [Character: [(Int, Int)]] = [ + " ": [(0, 1), (1, 2), (2, 3)], + "/": [(0, 3), (1, 2)], + "\\": [(0, 1), (2, 3)] + ] + + let gridArr = grid.map { Array($0) } + + for i in 0.. i); + let count = 4 * n * n; + + function find(x: number): number { + if (x !== parents[x]) { + parents[x] = find(parents[x]); + } + return parents[x]; + } + + function union(x: number, y: number): boolean { + const rx = find(x); + const ry = find(y); + if (rx !== ry) { + parents[rx] = ry; + return true; + } + return false; + } + + const merges: Record = { + " ": [ + [0, 1], + [1, 2], + [2, 3], + ], + "/": [ + [0, 3], + [1, 2], + ], + "\\": [ + [0, 1], + [2, 3], + ], + }; + + for (let i = 0; i < n; i++) { + for (let j = 0; j < n; j++) { + const base = (i * n + j) * 4; + for (const [u, v] of merges[grid[i][j]]) { + if (union(base + u, base + v)) { + count--; + } + } + + if (i + 1 < n) { + const downBase = ((i + 1) * n + j) * 4; + if (union(base + 2, downBase)) { + count--; + } + } + + if (j + 1 < n) { + const rightBase = (i * n + (j + 1)) * 4; + if (union(base + 1, rightBase + 3)) { + count--; + } + } + } + } + return count; +} diff --git a/tests/501-1000/960. delete-columns-to-make-sorted-iii/manifest.yaml b/tests/501-1000/960. delete-columns-to-make-sorted-iii/manifest.yaml new file mode 100644 index 00000000..c5c38204 --- /dev/null +++ b/tests/501-1000/960. delete-columns-to-make-sorted-iii/manifest.yaml @@ -0,0 +1,348 @@ +entry: + id: 960 + title: delete-columns-to-make-sorted-iii + params: + strs: + type: array + items: + type: string + call: + cpp: Solution().minDeletionSize({strs}) + rust: Solution::min_deletion_size({strs}) + python3: Solution().minDeletionSize({strs}) + python2: Solution().minDeletionSize({strs}) + ruby: min_deletion_size({strs}) + java: new Solution().minDeletionSize({strs}) + csharp: new Solution().MinDeletionSize({strs}) + kotlin: Solution().minDeletionSize({strs}) + go: minDeletionSize({strs}) + dart: Solution().minDeletionSize({strs}) + swift: Solution().minDeletionSize({strs}) + typescript: minDeletionSize({strs}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 960 +tests: + - name: case_1 + in: + strs: + - cbdab + - adaab + - cabdd + out: 3 + - name: case_2 + in: + strs: + - acdcac + - adcbad + - cdbcbb + - dccdcb + out: 4 + - name: case_3 + in: + strs: + - db + - aa + - dc + - db + out: 1 + - name: case_4 + in: + strs: + - bb + - aa + - dc + - ba + - cd + - aa + out: 1 + - name: case_5 + in: + strs: + - aabb + - ccdd + - acda + out: 1 + - name: case_6 + in: + strs: + - ac + - ab + - ab + - ca + - dc + out: 1 + - name: case_7 + in: + strs: + - aadcb + - bdccc + - adbcd + - daacb + - abbcc + out: 4 + - name: case_8 + in: + strs: + - ba + - cb + - ba + - cd + - bb + - ab + out: 1 + - name: case_9 + in: + strs: + - bb + - ad + - ac + - cc + - da + out: 1 + - name: case_10 + in: + strs: + - b + - a + - c + - b + - d + - c + - b + out: 0 + - name: case_11 + in: + strs: + - cabcaa + - aaaaad + out: 3 + - name: case_12 + in: + strs: + - ccd + - dcc + out: 1 + - name: case_13 + in: + strs: + - cdd + - cac + - aba + - bcb + - dcb + - bcb + out: 2 + - name: case_14 + in: + strs: + - dda + - dcd + - add + out: 2 + - name: case_15 + in: + strs: + - b + - a + - c + - c + - b + - c + - a + out: 0 + - name: case_16 + in: + strs: + - ba + - cb + - dd + - aa + - ad + - da + out: 1 + - name: case_17 + in: + strs: + - ca + - ca + - bc + - da + - bc + - ac + - dc + out: 1 + - name: case_18 + in: + strs: + - c + - b + - b + - d + - a + out: 0 + - name: case_19 + in: + strs: + - cab + - cad + - aca + - cdc + - cda + - cdb + - aab + out: 2 + - name: case_20 + in: + strs: + - d + - b + - b + - d + - c + - a + - b + out: 0 + - name: case_21 + in: + strs: + - aacab + - ccccb + - dbdcc + - babac + - cbdac + out: 3 + - name: case_22 + in: + strs: + - dccb + - cdcc + - bdda + - addb + - adac + - aaca + out: 3 + - name: case_23 + in: + strs: + - dacdac + - bcbccc + - cbbacc + - adcaab + - ddcacb + - bacada + - cbbcdd + out: 5 + - name: case_24 + in: + strs: + - bc + - dd + - ac + - bd + - da + - cd + - bc + out: 1 + - name: case_25 + in: + strs: + - badad + - bdbba + - dacad + - bacca + - baacb + - bbbcd + - adacb + out: 4 + - name: case_26 + in: + strs: + - ad + - ba + - da + out: 1 + - name: case_27 + in: + strs: + - ab + - ab + - da + - ba + - bd + - ab + out: 1 + - name: case_28 + in: + strs: + - bdbba + - adbbc + - dddaa + - abbbb + - abcdd + - cbaba + out: 4 + - name: case_29 + in: + strs: + - adaa + - babd + out: 1 + - name: case_30 + in: + strs: + - bbbac + - acbab + - baadb + - acdac + - acdcd + out: 3 + - name: case_31 + in: + strs: + - ddaabb + - acaccb + out: 3 + - name: case_32 + in: + strs: + - bcac + - ddda + - bbaa + out: 2 + - name: case_33 + in: + strs: + - bc + - bd + - cc + - cd + - db + out: 1 + - name: case_34 + in: + strs: + - bcdc + - bdcc + - dcba + - bdda + - bdab + - cbac + - cdcc + out: 3 + - name: case_35 + in: + strs: + - bcc + - cac + - cab + - bac + - dda + out: 2 diff --git a/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.cpp b/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.cpp new file mode 100644 index 00000000..1531f400 --- /dev/null +++ b/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.cpp @@ -0,0 +1,25 @@ +class Solution { +public: + int minDeletionSize(vector& strs) { + int m = strs[0].size(); + vector dp(m, 1); + + for (int i = 0; i < m; i++) { + for (int j = 0; j < i; j++) { + bool all = true; + for (const string& row : strs) { + if (row[j] > row[i]) { + all = false; + break; + } + } + if (all) { + dp[i] = max(dp[i], dp[j] + 1); + } + } + } + + int maxDp = *max_element(dp.begin(), dp.end()); + return m - maxDp; + } +}; diff --git a/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.cs b/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.cs new file mode 100644 index 00000000..e74f461c --- /dev/null +++ b/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.cs @@ -0,0 +1,32 @@ +public class Solution { + public int MinDeletionSize(string[] strs) { + int m = strs[0].Length; + int[] dp = new int[m]; + for (int i = 0; i < m; i++) { + dp[i] = 1; + } + + for (int i = 0; i < m; i++) { + for (int j = 0; j < i; j++) { + bool all = true; + foreach (string row in strs) { + if (row[j] > row[i]) { + all = false; + break; + } + } + if (all) { + dp[i] = Math.Max(dp[i], dp[j] + 1); + } + } + } + + int maxDp = 0; + for (int i = 0; i < m; i++) { + if (dp[i] > maxDp) { + maxDp = dp[i]; + } + } + return m - maxDp; + } +} diff --git a/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.dart b/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.dart new file mode 100644 index 00000000..daaaaa23 --- /dev/null +++ b/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.dart @@ -0,0 +1,24 @@ +class Solution { + int minDeletionSize(List strs) { + int m = strs[0].length; + List dp = List.filled(m, 1); + + for (int i = 0; i < m; i++) { + for (int j = 0; j < i; j++) { + bool all = true; + for (var row in strs) { + if (row[j].compareTo(row[i]) > 0) { + all = false; + break; + } + } + if (all && dp[j] + 1 > dp[i]) { + dp[i] = dp[j] + 1; + } + } + } + + int maxDp = dp.reduce((a, b) => a > b ? a : b); + return m - maxDp; + } +} diff --git a/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.go b/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.go new file mode 100644 index 00000000..6b8e9fc3 --- /dev/null +++ b/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.go @@ -0,0 +1,30 @@ +func minDeletionSize(strs []string) int { + m := len(strs[0]) + dp := make([]int, m) + for i := range dp { + dp[i] = 1 + } + + for i := 0; i < m; i++ { + for j := 0; j < i; j++ { + all := true + for _, row := range strs { + if row[j] > row[i] { + all = false + break + } + } + if all && dp[j]+1 > dp[i] { + dp[i] = dp[j] + 1 + } + } + } + + maxDp := 0 + for _, val := range dp { + if val > maxDp { + maxDp = val + } + } + return m - maxDp +} diff --git a/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.java b/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.java new file mode 100644 index 00000000..20a3fc4b --- /dev/null +++ b/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.java @@ -0,0 +1,30 @@ +class Solution { + public int minDeletionSize(String[] strs) { + int m = strs[0].length(); + int[] dp = new int[m]; + for (int i = 0; i < m; i++) { + dp[i] = 1; + } + + for (int i = 0; i < m; i++) { + for (int j = 0; j < i; j++) { + boolean all = true; + for (String row : strs) { + if (row.charAt(j) > row.charAt(i)) { + all = false; + break; + } + } + if (all) { + dp[i] = Math.max(dp[i], dp[j] + 1); + } + } + } + + int maxDp = 0; + for (int val : dp) { + maxDp = Math.max(maxDp, val); + } + return m - maxDp; + } +} diff --git a/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.kt b/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.kt new file mode 100644 index 00000000..65d2bbb1 --- /dev/null +++ b/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.kt @@ -0,0 +1,16 @@ +class Solution { + fun minDeletionSize(strs: Array): Int { + val m = strs[0].length + val dp = IntArray(m) { 1 } + + for (i in 0 until m) { + for (j in 0 until i) { + if (strs.all { it[j] <= it[i] }) { + dp[i] = maxOf(dp[i], dp[j] + 1) + } + } + } + + return m - dp.max() + } +} diff --git a/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.py b/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.py new file mode 100644 index 00000000..d5f0bbce --- /dev/null +++ b/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.py @@ -0,0 +1,11 @@ +class Solution: + def minDeletionSize(self, strs: list[str]) -> int: + m = len(strs[0]) + dp = [1] * m + + for i in range(m): + for j in range(i): + if all(row[j] <= row[i] for row in strs): + dp[i] = max(dp[i], dp[j] + 1) + + return m - max(dp) diff --git a/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.py2 b/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.py2 new file mode 100644 index 00000000..a43fa1c5 --- /dev/null +++ b/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.py2 @@ -0,0 +1,15 @@ +class Solution(object): + def minDeletionSize(self, strs): + """ + :type strs: List[str] + :rtype: int + """ + m = len(strs[0]) + dp = [1] * m + + for i in range(m): + for j in range(i): + if all(row[j] <= row[i] for row in strs): + dp[i] = max(dp[i], dp[j] + 1) + + return m - max(dp) diff --git a/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.rb b/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.rb new file mode 100644 index 00000000..57af4f50 --- /dev/null +++ b/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.rb @@ -0,0 +1,16 @@ +# @param {String[]} strs +# @return {Integer} +def min_deletion_size(strs) + m = strs[0].length + dp = Array.new(m, 1) + + (0...m).each do |i| + (0...i).each do |j| + if strs.all? { |row| row[j] <= row[i] } + dp[i] = [dp[i], dp[j] + 1].max + end + end + end + + m - dp.max +end diff --git a/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.rs b/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.rs new file mode 100644 index 00000000..f04254c6 --- /dev/null +++ b/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.rs @@ -0,0 +1,20 @@ +impl Solution { + pub fn min_deletion_size(strs: Vec) -> i32 { + let m = strs[0].len(); + let mut dp = vec![1; m]; + + for i in 0..m { + for j in 0..i { + let all = strs.iter().all(|row| { + row.as_bytes()[j] <= row.as_bytes()[i] + }); + + if all { + dp[i] = dp[i].max(dp[j] + 1); + } + } + } + + (m as i32) - (*dp.iter().max().unwrap() as i32) + } +} diff --git a/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.swift b/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.swift new file mode 100644 index 00000000..2bde8897 --- /dev/null +++ b/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.swift @@ -0,0 +1,24 @@ +class Solution { + func minDeletionSize(_ strs: [String]) -> Int { + let m = strs[0].count + var dp = Array(repeating: 1, count: m) + let rows = strs.map { Array($0) } + + for i in 0.. row[i] { + all = false + break + } + } + if all { + dp[i] = max(dp[i], dp[j] + 1) + } + } + } + + return m - dp.max()! + } +} diff --git a/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.ts b/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.ts new file mode 100644 index 00000000..81f95eb9 --- /dev/null +++ b/tests/501-1000/960. delete-columns-to-make-sorted-iii/sol.ts @@ -0,0 +1,21 @@ +function minDeletionSize(strs: string[]): number { + const m = strs[0].length; + const dp: number[] = new Array(m).fill(1); + + for (let i = 0; i < m; i++) { + for (let j = 0; j < i; j++) { + let all = true; + for (const row of strs) { + if (row[j] > row[i]) { + all = false; + break; + } + } + if (all) { + dp[i] = Math.max(dp[i], dp[j] + 1); + } + } + } + + return m - Math.max(...dp); +} diff --git a/tests/501-1000/961. n-repeated-element-in-size-2n-array/manifest.yaml b/tests/501-1000/961. n-repeated-element-in-size-2n-array/manifest.yaml new file mode 100644 index 00000000..f90b95d2 --- /dev/null +++ b/tests/501-1000/961. n-repeated-element-in-size-2n-array/manifest.yaml @@ -0,0 +1,542 @@ +entry: + id: 961 + title: n-repeated-element-in-size-2n-array + params: + nums: + type: array + items: + type: int + call: + cpp: Solution().repeatedNTimes({nums}) + rust: Solution::repeated_n_times({nums}) + python3: Solution().repeatedNTimes({nums}) + python2: Solution().repeatedNTimes({nums}) + ruby: repeated_n_times({nums}) + java: new Solution().repeatedNTimes({nums}) + csharp: new Solution().RepeatedNTimes({nums}) + kotlin: Solution().repeatedNTimes({nums}) + go: repeatedNTimes({nums}) + dart: Solution().repeatedNTimes({nums}) + swift: Solution().repeatedNTimes({nums}) + typescript: repeatedNTimes({nums}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 961 +tests: + - name: case_1 + in: + nums: + - 9 + - 8 + - 4 + - 1 + - 12 + - 4 + - 4 + - 6 + - 4 + - 4 + - 4 + - 4 + - 19 + - 14 + out: 4 + - name: case_2 + in: + nums: + - 3 + - 9 + - 4 + - 9 + - 9 + - 11 + - 13 + - 9 + - 16 + - 9 + out: 9 + - name: case_3 + in: + nums: + - 3 + - 3 + - 3 + - 11 + - 16 + - 4 + - 5 + - 10 + - 3 + - 3 + - 3 + - 18 + - 13 + - 14 + - 3 + - 3 + out: 3 + - name: case_4 + in: + nums: + - 14 + - 5 + - 8 + - 2 + - 5 + - 5 + out: 5 + - name: case_5 + in: + nums: + - 13 + - 1 + - 1 + - 1 + - 4 + - 1 + - 6 + - 11 + - 1 + - 1 + - 8 + - 1 + - 12 + - 3 + - 14 + - 1 + out: 1 + - name: case_6 + in: + nums: + - 7 + - 6 + - 7 + - 7 + - 16 + - 7 + - 11 + - 13 + - 9 + - 7 + out: 7 + - name: case_7 + in: + nums: + - 4 + - 4 + - 4 + - 16 + - 4 + - 7 + - 2 + - 4 + - 4 + - 6 + - 18 + - 4 + - 19 + - 12 + out: 4 + - name: case_8 + in: + nums: + - 4 + - 16 + - 4 + - 17 + - 4 + - 14 + - 15 + - 4 + - 8 + - 10 + - 1 + - 4 + - 4 + - 4 + - 12 + - 4 + out: 4 + - name: case_9 + in: + nums: + - 6 + - 3 + - 15 + - 6 + - 6 + - 4 + - 6 + - 12 + - 8 + - 6 + - 16 + - 6 + out: 6 + - name: case_10 + in: + nums: + - 18 + - 7 + - 16 + - 7 + - 14 + - 4 + - 7 + - 7 + - 7 + - 17 + out: 7 + - name: case_11 + in: + nums: + - 14 + - 13 + - 6 + - 6 + - 6 + - 1 + out: 6 + - name: case_12 + in: + nums: + - 7 + - 7 + - 19 + - 1 + out: 7 + - name: case_13 + in: + nums: + - 4 + - 4 + - 4 + - 4 + - 16 + - 19 + - 3 + - 10 + - 4 + - 2 + - 12 + - 4 + - 17 + - 4 + out: 4 + - name: case_14 + in: + nums: + - 4 + - 4 + - 4 + - 12 + - 4 + - 16 + - 14 + - 10 + - 4 + - 15 + out: 4 + - name: case_15 + in: + nums: + - 7 + - 10 + - 7 + - 3 + - 7 + - 13 + out: 7 + - name: case_16 + in: + nums: + - 14 + - 8 + - 11 + - 8 + - 8 + - 5 + - 8 + - 18 + - 10 + - 15 + - 8 + - 19 + - 7 + - 8 + - 8 + - 8 + out: 8 + - name: case_17 + in: + nums: + - 1 + - 14 + - 17 + - 15 + - 7 + - 1 + - 19 + - 1 + - 1 + - 1 + - 16 + - 1 + - 1 + - 9 + - 13 + - 1 + out: 1 + - name: case_18 + in: + nums: + - 9 + - 17 + - 9 + - 9 + - 16 + - 2 + out: 9 + - name: case_19 + in: + nums: + - 11 + - 4 + - 8 + - 4 + - 2 + - 4 + - 6 + - 4 + out: 4 + - name: case_20 + in: + nums: + - 9 + - 15 + - 9 + - 8 + - 11 + - 9 + - 12 + - 9 + - 2 + - 9 + - 9 + - 9 + - 14 + - 9 + - 1 + - 16 + out: 9 + - name: case_21 + in: + nums: + - 12 + - 6 + - 3 + - 4 + - 4 + - 4 + - 4 + - 4 + - 4 + - 14 + - 18 + - 4 + - 10 + - 13 + - 4 + - 11 + out: 4 + - name: case_22 + in: + nums: + - 2 + - 15 + - 1 + - 8 + - 2 + - 2 + - 2 + - 2 + - 14 + - 11 + out: 2 + - name: case_23 + in: + nums: + - 2 + - 2 + - 2 + - 16 + - 2 + - 2 + - 2 + - 14 + - 13 + - 12 + - 19 + - 18 + - 15 + - 2 + - 2 + - 6 + out: 2 + - name: case_24 + in: + nums: + - 16 + - 11 + - 8 + - 8 + out: 8 + - name: case_25 + in: + nums: + - 1 + - 7 + - 10 + - 7 + out: 7 + - name: case_26 + in: + nums: + - 2 + - 2 + - 6 + - 2 + - 2 + - 11 + - 9 + - 7 + out: 2 + - name: case_27 + in: + nums: + - 4 + - 7 + - 18 + - 7 + out: 7 + - name: case_28 + in: + nums: + - 16 + - 14 + - 9 + - 9 + - 3 + - 7 + - 13 + - 8 + - 11 + - 9 + - 9 + - 9 + - 9 + - 9 + - 17 + - 9 + out: 9 + - name: case_29 + in: + nums: + - 5 + - 8 + - 8 + - 2 + - 8 + - 6 + - 15 + - 8 + out: 8 + - name: case_30 + in: + nums: + - 19 + - 3 + - 2 + - 4 + - 2 + - 2 + - 2 + - 2 + - 10 + - 2 + - 18 + - 2 + - 6 + - 12 + - 11 + - 2 + out: 2 + - name: case_31 + in: + nums: + - 2 + - 2 + - 2 + - 5 + - 11 + - 13 + - 2 + - 7 + out: 2 + - name: case_32 + in: + nums: + - 4 + - 19 + - 4 + - 4 + - 14 + - 6 + out: 4 + - name: case_33 + in: + nums: + - 13 + - 6 + - 6 + - 6 + - 6 + - 6 + - 4 + - 10 + - 6 + - 9 + - 5 + - 17 + - 6 + - 11 + out: 6 + - name: case_34 + in: + nums: + - 10 + - 2 + - 5 + - 15 + - 18 + - 5 + - 5 + - 5 + out: 5 + - name: case_35 + in: + nums: + - 5 + - 1 + - 1 + - 15 + - 1 + - 4 + out: 1 diff --git a/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.cpp b/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.cpp new file mode 100644 index 00000000..89c20c84 --- /dev/null +++ b/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.cpp @@ -0,0 +1,12 @@ +class Solution { +public: + int repeatedNTimes(vector& nums) { + int n = nums.size() - 2; + for (int i = 0; i < n; i++) { + if (nums[i] == nums[i + 1] || nums[i] == nums[i + 2]) { + return nums[i]; + } + } + return nums[n + 1]; + } +}; diff --git a/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.cs b/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.cs new file mode 100644 index 00000000..0d2b5b6f --- /dev/null +++ b/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.cs @@ -0,0 +1,11 @@ +public class Solution { + public int RepeatedNTimes(int[] nums) { + int n = nums.Length - 2; + for (int i = 0; i < n; i++) { + if (nums[i] == nums[i + 1] || nums[i] == nums[i + 2]) { + return nums[i]; + } + } + return nums[n + 1]; + } +} diff --git a/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.dart b/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.dart new file mode 100644 index 00000000..fcaca336 --- /dev/null +++ b/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.dart @@ -0,0 +1,11 @@ +class Solution { + int repeatedNTimes(List nums) { + int n = nums.length - 2; + for (int i = 0; i < n; i++) { + if (nums[i] == nums[i + 1] || nums[i] == nums[i + 2]) { + return nums[i]; + } + } + return nums[n + 1]; + } +} diff --git a/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.go b/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.go new file mode 100644 index 00000000..f991b897 --- /dev/null +++ b/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.go @@ -0,0 +1,9 @@ +func repeatedNTimes(nums []int) int { + n := len(nums) - 2 + for i := 0; i < n; i++ { + if nums[i] == nums[i+1] || nums[i] == nums[i+2] { + return nums[i] + } + } + return nums[n+1] +} diff --git a/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.java b/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.java new file mode 100644 index 00000000..70d54108 --- /dev/null +++ b/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.java @@ -0,0 +1,11 @@ +class Solution { + public int repeatedNTimes(int[] nums) { + int n = nums.length - 2; + for (int i = 0; i < n; i++) { + if (nums[i] == nums[i + 1] || nums[i] == nums[i + 2]) { + return nums[i]; + } + } + return nums[n + 1]; + } +} diff --git a/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.kt b/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.kt new file mode 100644 index 00000000..cd0b1c94 --- /dev/null +++ b/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.kt @@ -0,0 +1,11 @@ +class Solution { + fun repeatedNTimes(nums: IntArray): Int { + val n = nums.size - 2 + for (i in 0 until n) { + if (nums[i] == nums[i + 1] || nums[i] == nums[i + 2]) { + return nums[i] + } + } + return nums[n + 1] + } +} diff --git a/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.py b/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.py new file mode 100644 index 00000000..7705ef90 --- /dev/null +++ b/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.py @@ -0,0 +1,7 @@ +class Solution(object): + def repeatedNTimes(self, nums): + n = len(nums) - 2 + for i in range(n): + if nums[i] == nums[i + 1] or nums[i] == nums[i + 2]: + return nums[i] + return nums[n + 1] diff --git a/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.py2 b/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.py2 new file mode 100644 index 00000000..7bf0e54f --- /dev/null +++ b/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.py2 @@ -0,0 +1,6 @@ +class Solution(object): + def repeatedNTimes(self, nums): + n = len(nums) - 2 + for i in range(n): + if nums[i] == nums[i + 1] or nums[i] == nums[i + 2]: return nums[i] + return nums[n + 1] diff --git a/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.rb b/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.rb new file mode 100644 index 00000000..77041ac3 --- /dev/null +++ b/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.rb @@ -0,0 +1,9 @@ +# @param {Integer[]} nums +# @return {Integer} +def repeated_n_times(nums) + n = nums.length - 2 + (0...n).each do |i| + return nums[i] if nums[i] == nums[i + 1] || nums[i] == nums[i + 2] + end + nums[n + 1] +end diff --git a/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.rs b/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.rs new file mode 100644 index 00000000..b1fbe48e --- /dev/null +++ b/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.rs @@ -0,0 +1,11 @@ +impl Solution { + pub fn repeated_n_times(nums: Vec) -> i32 { + let n = nums.len() - 2; + for i in 0..n { + if nums[i] == nums[i + 1] || nums[i] == nums[i + 2] { + return nums[i]; + } + } + nums[n + 1] + } +} diff --git a/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.swift b/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.swift new file mode 100644 index 00000000..e148e6a6 --- /dev/null +++ b/tests/501-1000/961. n-repeated-element-in-size-2n-array/sol.swift @@ -0,0 +1,11 @@ +class Solution { + func repeatedNTimes(_ nums: [Int]) -> Int { + let n = nums.count - 2 + for i in 0..& nums) { + int n = nums.size(); + vector right_max(n); + right_max[n - 1] = nums[n - 1]; + + for (int i = n - 2; i >= 0; i--) { + right_max[i] = max(nums[i], right_max[i + 1]); + } + + int i = 0, j = 0, result = 0; + while (j < n) { + if (nums[i] <= right_max[j]) { + result = max(result, j - i); + j++; + } else { + i++; + } + } + + return result; + } +}; diff --git a/tests/501-1000/962. maximum-width-ramp/sol.cs b/tests/501-1000/962. maximum-width-ramp/sol.cs new file mode 100644 index 00000000..d5e0d0d1 --- /dev/null +++ b/tests/501-1000/962. maximum-width-ramp/sol.cs @@ -0,0 +1,23 @@ +public class Solution { + public int MaxWidthRamp(int[] nums) { + int n = nums.Length; + int[] right_max = new int[n]; + right_max[n - 1] = nums[n - 1]; + + for (int i = n - 2; i >= 0; i--) { + right_max[i] = Math.Max(nums[i], right_max[i + 1]); + } + + int left = 0, right = 0, result = 0; + while (right < n) { + if (nums[left] <= right_max[right]) { + result = Math.Max(result, right - left); + right++; + } else { + left++; + } + } + + return result; + } +} diff --git a/tests/501-1000/962. maximum-width-ramp/sol.dart b/tests/501-1000/962. maximum-width-ramp/sol.dart new file mode 100644 index 00000000..68fe656f --- /dev/null +++ b/tests/501-1000/962. maximum-width-ramp/sol.dart @@ -0,0 +1,25 @@ +class Solution { + int maxWidthRamp(List nums) { + int n = nums.length; + List right_max = List.filled(n, 0); + right_max[n - 1] = nums[n - 1]; + + for (int i = n - 2; i >= 0; i--) { + right_max[i] = nums[i] > right_max[i + 1] ? nums[i] : right_max[i + 1]; + } + + int i = 0, j = 0, result = 0; + while (j < n) { + if (nums[i] <= right_max[j]) { + if (j - i > result) { + result = j - i; + } + j++; + } else { + i++; + } + } + + return result; + } +} diff --git a/tests/501-1000/962. maximum-width-ramp/sol.go b/tests/501-1000/962. maximum-width-ramp/sol.go new file mode 100644 index 00000000..0c52e2c8 --- /dev/null +++ b/tests/501-1000/962. maximum-width-ramp/sol.go @@ -0,0 +1,27 @@ +func maxWidthRamp(nums []int) int { + n := len(nums) + right_max := make([]int, n) + right_max[n-1] = nums[n-1] + + for i := n - 2; i >= 0; i-- { + if nums[i] > right_max[i+1] { + right_max[i] = nums[i] + } else { + right_max[i] = right_max[i+1] + } + } + + i, j, result := 0, 0, 0 + for j < n { + if nums[i] <= right_max[j] { + if j - i > result { + result = j - i + } + j++ + } else { + i++ + } + } + + return result +} diff --git a/tests/501-1000/962. maximum-width-ramp/sol.java b/tests/501-1000/962. maximum-width-ramp/sol.java new file mode 100644 index 00000000..41363cd5 --- /dev/null +++ b/tests/501-1000/962. maximum-width-ramp/sol.java @@ -0,0 +1,23 @@ +class Solution { + public int maxWidthRamp(int[] nums) { + int n = nums.length; + int[] right_max = new int[n]; + right_max[n - 1] = nums[n - 1]; + + for (int i = n - 2; i >= 0; i--) { + right_max[i] = Math.max(nums[i], right_max[i + 1]); + } + + int i = 0, j = 0, result = 0; + while (j < n) { + if (nums[i] <= right_max[j]) { + result = Math.max(result, j - i); + j++; + } else { + i++; + } + } + + return result; + } +} diff --git a/tests/501-1000/962. maximum-width-ramp/sol.kt b/tests/501-1000/962. maximum-width-ramp/sol.kt new file mode 100644 index 00000000..489ac3a4 --- /dev/null +++ b/tests/501-1000/962. maximum-width-ramp/sol.kt @@ -0,0 +1,25 @@ +class Solution { + fun maxWidthRamp(nums: IntArray): Int { + val n = nums.size + val right_max = IntArray(n) + right_max[n - 1] = nums[n - 1] + + for (i in n - 2 downTo 0) { + right_max[i] = maxOf(nums[i], right_max[i + 1]) + } + + var i = 0 + var j = 0 + var result = 0 + while (j < n) { + if (nums[i] <= right_max[j]) { + result = maxOf(result, j - i) + j++ + } else { + i++ + } + } + + return result + } +} diff --git a/tests/501-1000/962. maximum-width-ramp/sol.py b/tests/501-1000/962. maximum-width-ramp/sol.py new file mode 100644 index 00000000..98f1a2d6 --- /dev/null +++ b/tests/501-1000/962. maximum-width-ramp/sol.py @@ -0,0 +1,24 @@ +from typing import List + + +class Solution: + def maxWidthRamp(self, nums: List[int]) -> int: + n = len(nums) + right_max = [0] * n + + right_max[-1] = nums[-1] + + for i in range(n - 2, -1, -1): + right_max[i] = max(nums[i], right_max[i + 1]) + + i = 0 + j = 0 + result = 0 + while j < n: + if nums[i] <= right_max[j]: + result = max(result, j - i) + j += 1 + else: + i += 1 + + return result diff --git a/tests/501-1000/962. maximum-width-ramp/sol.py2 b/tests/501-1000/962. maximum-width-ramp/sol.py2 new file mode 100644 index 00000000..bec803f3 --- /dev/null +++ b/tests/501-1000/962. maximum-width-ramp/sol.py2 @@ -0,0 +1,24 @@ +class Solution(object): + def maxWidthRamp(self, nums): + """ + :type nums: List[int] + :rtype: int + """ + n = len(nums) + right_max = [0] * n + right_max[-1] = nums[-1] + + for i in range(n - 2, -1, -1): + right_max[i] = max(nums[i], right_max[i + 1]) + + i = 0 + j = 0 + result = 0 + while j < n: + if nums[i] <= right_max[j]: + result = max(result, j - i) + j += 1 + else: + i += 1 + + return result diff --git a/tests/501-1000/962. maximum-width-ramp/sol.rb b/tests/501-1000/962. maximum-width-ramp/sol.rb new file mode 100644 index 00000000..329ea6e1 --- /dev/null +++ b/tests/501-1000/962. maximum-width-ramp/sol.rb @@ -0,0 +1,25 @@ +# @param {Integer[]} nums +# @return {Integer} +def max_width_ramp(nums) + n = nums.length + right_max = Array.new(n, 0) + right_max[-1] = nums[-1] + + (n - 2).downto(0) do |i| + right_max[i] = [nums[i], right_max[i + 1]].max + end + + i = 0 + j = 0 + result = 0 + while j < n + if nums[i] <= right_max[j] + result = [result, j - i].max + j += 1 + else + i += 1 + end + end + + result +end diff --git a/tests/501-1000/962. maximum-width-ramp/sol.rs b/tests/501-1000/962. maximum-width-ramp/sol.rs new file mode 100644 index 00000000..81a23c65 --- /dev/null +++ b/tests/501-1000/962. maximum-width-ramp/sol.rs @@ -0,0 +1,25 @@ +impl Solution { + pub fn max_width_ramp(nums: Vec) -> i32 { + let n = nums.len(); + let mut right_max = vec![0; n]; + right_max[n - 1] = nums[n - 1]; + + for i in (0..n-1).rev() { + right_max[i] = nums[i].max(right_max[i + 1]); + } + + let mut i = 0; + let mut j = 0; + let mut result = 0; + while j < n { + if nums[i] <= right_max[j] { + result = result.max((j - i) as i32); + j += 1; + } else { + i += 1; + } + } + + result + } +} diff --git a/tests/501-1000/962. maximum-width-ramp/sol.swift b/tests/501-1000/962. maximum-width-ramp/sol.swift new file mode 100644 index 00000000..4e8ac4fc --- /dev/null +++ b/tests/501-1000/962. maximum-width-ramp/sol.swift @@ -0,0 +1,23 @@ +class Solution { + func maxWidthRamp(_ nums: [Int]) -> Int { + let n = nums.count + var right_max = [Int](repeating: 0, count: n) + right_max[n - 1] = nums[n - 1] + + for i in stride(from: n - 2, through: 0, by: -1) { + right_max[i] = max(nums[i], right_max[i + 1]) + } + + var i = 0, j = 0, result = 0 + while j < n { + if nums[i] <= right_max[j] { + result = max(result, j - i) + j += 1 + } else { + i += 1 + } + } + + return result + } +} diff --git a/tests/501-1000/962. maximum-width-ramp/sol.ts b/tests/501-1000/962. maximum-width-ramp/sol.ts new file mode 100644 index 00000000..7ad47b08 --- /dev/null +++ b/tests/501-1000/962. maximum-width-ramp/sol.ts @@ -0,0 +1,23 @@ +function maxWidthRamp(nums: number[]): number { + const n = nums.length; + const right_max: number[] = new Array(n); + right_max[n - 1] = nums[n - 1]; + + for (let i = n - 2; i >= 0; i--) { + right_max[i] = Math.max(nums[i], right_max[i + 1]); + } + + let i = 0, + j = 0, + result = 0; + while (j < n) { + if (nums[i] <= right_max[j]) { + result = Math.max(result, j - i); + j++; + } else { + i++; + } + } + + return result; +} diff --git a/tests/501-1000/963. minimum-area-rectangle-ii/manifest.yaml b/tests/501-1000/963. minimum-area-rectangle-ii/manifest.yaml new file mode 100644 index 00000000..9a0aded2 --- /dev/null +++ b/tests/501-1000/963. minimum-area-rectangle-ii/manifest.yaml @@ -0,0 +1,337 @@ +entry: + id: 963 + title: minimum-area-rectangle-ii + params: + points: + type: array + items: + type: array + items: + type: int + call: + cpp: Solution().minAreaFreeRect({points}) + rust: Solution::min_area_free_rect({points}) + python3: Solution().minAreaFreeRect({points}) + python2: Solution().minAreaFreeRect({points}) + ruby: min_area_free_rect({points}) + java: new Solution().minAreaFreeRect({points}) + csharp: new Solution().MinAreaFreeRect({points}) + kotlin: Solution().minAreaFreeRect({points}) + go: minAreaFreeRect({points}) + dart: Solution().minAreaFreeRect({points}) + swift: Solution().minAreaFreeRect({points}) + typescript: minAreaFreeRect({points}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().minAreaFreeRect(points, {result}) + checker: + "class Checker:\n def minAreaFreeRect(self, points, result):\n \ + \ try:\n value = float(result)\n except Exception:\n \ + \ return False\n from math import sqrt, inf, isclose\n \ + \ ans = inf\n seen = {}\n for i, (x0, y0) in enumerate(points):\n\ + \ for x1, y1 in points[i + 1:]:\n cx = (x0 + x1) /\ + \ 2.0\n cy = (y0 + y1) / 2.0\n d2 = (x0 - x1)\ + \ ** 2 + (y0 - y1) ** 2\n for xx, yy in seen.get((cx, cy, d2),\ + \ []):\n area = sqrt(((x0 - xx) ** 2 + (y0 - yy) ** 2) *\ + \ ((x1 - xx) ** 2 + (y1 - yy) ** 2))\n ans = min(ans, area)\n\ + \ seen.setdefault((cx, cy, d2), []).append((x0, y0))\n \ + \ expected = 0.0 if ans == inf else ans\n return isclose(value, expected,\ + \ rel_tol=1e-9, abs_tol=1e-9)\n" +seed: 963 +tests: + - name: case_1 + in: + points: + - - 2 + - 0 + - - 4 + - 2 + - name: case_2 + in: + points: + - - 0 + - 1 + - - 2 + - 2 + - name: case_3 + in: + points: + - - 0 + - 0 + - - 1 + - 4 + - - 2 + - 4 + - - 3 + - 4 + - name: case_4 + in: + points: + - - 1 + - 4 + - - 3 + - 0 + - - 3 + - 1 + - name: case_5 + in: + points: + - - 1 + - 0 + - - 2 + - 2 + - - 2 + - 3 + - name: case_6 + in: + points: + - - 1 + - 0 + - - 1 + - 1 + - - 1 + - 4 + - - 2 + - 4 + - - 3 + - 0 + - name: case_7 + in: + points: + - - 4 + - 2 + - name: case_8 + in: + points: + - - 0 + - 0 + - - 4 + - 2 + - name: case_9 + in: + points: + - - 0 + - 0 + - - 1 + - 0 + - name: case_10 + in: + points: + - - 0 + - 0 + - - 0 + - 1 + - - 2 + - 2 + - - 3 + - 4 + - name: case_11 + in: + points: + - - 0 + - 0 + - - 0 + - 3 + - - 3 + - 0 + - name: case_12 + in: + points: + - - 3 + - 4 + - - 4 + - 1 + - name: case_13 + in: + points: + - - 0 + - 4 + - - 1 + - 3 + - - 3 + - 3 + - - 3 + - 4 + - - 4 + - 0 + - name: case_14 + in: + points: + - - 0 + - 0 + - - 4 + - 3 + - name: case_15 + in: + points: + - - 1 + - 3 + - name: case_16 + in: + points: + - - 0 + - 3 + - - 0 + - 4 + - name: case_17 + in: + points: + - - 2 + - 4 + - - 3 + - 2 + - name: case_18 + in: + points: + - - 0 + - 3 + - - 4 + - 2 + - name: case_19 + in: + points: + - - 4 + - 2 + - name: case_20 + in: + points: + - - 0 + - 0 + - name: case_21 + in: + points: + - - 1 + - 3 + - - 3 + - 1 + - - 3 + - 2 + - - 4 + - 3 + - - 4 + - 4 + - name: case_22 + in: + points: + - - 1 + - 1 + - - 1 + - 4 + - - 4 + - 4 + - name: case_23 + in: + points: + - - 3 + - 4 + - - 4 + - 1 + - - 4 + - 3 + - name: case_24 + in: + points: + - - 0 + - 0 + - - 1 + - 2 + - name: case_25 + in: + points: + - - 2 + - 3 + - - 2 + - 4 + - name: case_26 + in: + points: + - - 1 + - 1 + - - 2 + - 4 + - - 4 + - 3 + - name: case_27 + in: + points: + - - 0 + - 4 + - - 3 + - 0 + - name: case_28 + in: + points: + - - 2 + - 2 + - - 3 + - 3 + - name: case_29 + in: + points: + - - 0 + - 4 + - - 4 + - 4 + - name: case_30 + in: + points: + - - 0 + - 0 + - - 0 + - 3 + - - 2 + - 0 + - - 4 + - 0 + - - 4 + - 1 + - name: case_31 + in: + points: + - - 4 + - 3 + - name: case_32 + in: + points: + - - 2 + - 1 + - - 3 + - 2 + - name: case_33 + in: + points: + - - 0 + - 2 + - - 1 + - 1 + - - 3 + - 0 + - name: case_34 + in: + points: + - - 2 + - 3 + - - 3 + - 1 + - name: case_35 + in: + points: + - - 0 + - 0 + - - 1 + - 4 + - - 2 + - 0 + - - 2 + - 4 + - - 3 + - 4 + - - 4 + - 2 + - - 4 + - 4 diff --git a/tests/501-1000/963. minimum-area-rectangle-ii/sol.cpp b/tests/501-1000/963. minimum-area-rectangle-ii/sol.cpp new file mode 100644 index 00000000..05ddb8b5 --- /dev/null +++ b/tests/501-1000/963. minimum-area-rectangle-ii/sol.cpp @@ -0,0 +1,27 @@ +class Solution { +public: + double minAreaFreeRect(vector>& points) { + double ans = numeric_limits::infinity(); + map, vector>> seen; + int n = points.size(); + for (int i = 0; i < n; ++i) { + int x0 = points[i][0], y0 = points[i][1]; + for (int j = i + 1; j < n; ++j) { + int x1 = points[j][0], y1 = points[j][1]; + double cx = (x0 + x1) / 2.0; + double cy = (y0 + y1) / 2.0; + long long d2 = (long long)(x0 - x1) * (x0 - x1) + (long long)(y0 - y1) * (y0 - y1); + auto key = make_tuple(cx, cy, d2); + if (seen.count(key)) { + for (auto& [xx, yy] : seen[key]) { + double area = sqrt(((double)(x0 - xx) * (x0 - xx) + (double)(y0 - yy) * (y0 - yy)) * + ((double)(x1 - xx) * (x1 - xx) + (double)(y1 - yy) * (y1 - yy))); + ans = min(ans, area); + } + } + seen[key].emplace_back(x0, y0); + } + } + return isinf(ans) ? 0.0 : ans; + } +}; diff --git a/tests/501-1000/963. minimum-area-rectangle-ii/sol.cs b/tests/501-1000/963. minimum-area-rectangle-ii/sol.cs new file mode 100644 index 00000000..77cd138f --- /dev/null +++ b/tests/501-1000/963. minimum-area-rectangle-ii/sol.cs @@ -0,0 +1,27 @@ +public class Solution { + public double MinAreaFreeRect(int[][] points) { + double ans = double.MaxValue; + var seen = new Dictionary<(double, double, long), List<(int, int)>>(); + int n = points.Length; + for (int i = 0; i < n; i++) { + int x0 = points[i][0], y0 = points[i][1]; + for (int j = i + 1; j < n; j++) { + int x1 = points[j][0], y1 = points[j][1]; + double cx = (x0 + x1) / 2.0; + double cy = (y0 + y1) / 2.0; + long d2 = (long)(x0 - x1) * (x0 - x1) + (long)(y0 - y1) * (y0 - y1); + var key = (cx, cy, d2); + if (seen.ContainsKey(key)) { + foreach (var (xx, yy) in seen[key]) { + double area = Math.Sqrt(((double)(x0 - xx) * (x0 - xx) + (double)(y0 - yy) * (y0 - yy)) * + ((double)(x1 - xx) * (x1 - xx) + (double)(y1 - yy) * (y1 - yy))); + ans = Math.Min(ans, area); + } + } + if (!seen.ContainsKey(key)) seen[key] = new List<(int, int)>(); + seen[key].Add((x0, y0)); + } + } + return ans == double.MaxValue ? 0.0 : ans; + } +} diff --git a/tests/501-1000/963. minimum-area-rectangle-ii/sol.dart b/tests/501-1000/963. minimum-area-rectangle-ii/sol.dart new file mode 100644 index 00000000..ab65af69 --- /dev/null +++ b/tests/501-1000/963. minimum-area-rectangle-ii/sol.dart @@ -0,0 +1,27 @@ +class Solution { + double minAreaFreeRect(List> points) { + double ans = double.infinity; + var seen = >>{}; + int n = points.length; + for (int i = 0; i < n; i++) { + int x0 = points[i][0], y0 = points[i][1]; + for (int j = i + 1; j < n; j++) { + int x1 = points[j][0], y1 = points[j][1]; + double cx = (x0 + x1) / 2.0; + double cy = (y0 + y1) / 2.0; + int d2 = (x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1); + String key = '$cx,$cy,$d2'; + if (seen.containsKey(key)) { + for (var prev in seen[key]!) { + int xx = prev[0], yy = prev[1]; + double area = sqrt(((x0 - xx) * (x0 - xx) + (y0 - yy) * (y0 - yy)) * + ((x1 - xx) * (x1 - xx) + (y1 - yy) * (y1 - yy)).toDouble()); + ans = min(ans, area); + } + } + seen.putIfAbsent(key, () => []).add([x0, y0]); + } + } + return ans == double.infinity ? 0.0 : ans; + } +} diff --git a/tests/501-1000/963. minimum-area-rectangle-ii/sol.go b/tests/501-1000/963. minimum-area-rectangle-ii/sol.go new file mode 100644 index 00000000..e23ee337 --- /dev/null +++ b/tests/501-1000/963. minimum-area-rectangle-ii/sol.go @@ -0,0 +1,29 @@ +func minAreaFreeRect(points [][]int) float64 { + ans := math.MaxFloat64 + seen := make(map[string][][2]int) + n := len(points) + for i := 0; i < n; i++ { + x0, y0 := points[i][0], points[i][1] + for j := i + 1; j < n; j++ { + x1, y1 := points[j][0], points[j][1] + cx := float64(x0+x1) / 2.0 + cy := float64(y0+y1) / 2.0 + d2 := int64(x0-x1)*int64(x0-x1) + int64(y0-y1)*int64(y0-y1) + key := fmt.Sprintf("%f,%f,%d", cx, cy, d2) + if list, ok := seen[key]; ok { + for _, prev := range list { + xx, yy := prev[0], prev[1] + area := math.Sqrt(float64((x0-xx)*(x0-xx)+(y0-yy)*(y0-yy)) * float64((x1-xx)*(x1-xx)+(y1-yy)*(y1-yy))) + if area < ans { + ans = area + } + } + } + seen[key] = append(seen[key], [2]int{x0, y0}) + } + } + if ans == math.MaxFloat64 { + return 0.0 + } + return ans +} diff --git a/tests/501-1000/963. minimum-area-rectangle-ii/sol.java b/tests/501-1000/963. minimum-area-rectangle-ii/sol.java new file mode 100644 index 00000000..d4ad8469 --- /dev/null +++ b/tests/501-1000/963. minimum-area-rectangle-ii/sol.java @@ -0,0 +1,27 @@ +class Solution { + public double minAreaFreeRect(int[][] points) { + double ans = Double.MAX_VALUE; + Map> seen = new HashMap<>(); + int n = points.length; + for (int i = 0; i < n; i++) { + int x0 = points[i][0], y0 = points[i][1]; + for (int j = i + 1; j < n; j++) { + int x1 = points[j][0], y1 = points[j][1]; + double cx = (x0 + x1) / 2.0; + double cy = (y0 + y1) / 2.0; + long d2 = (long)(x0 - x1) * (x0 - x1) + (long)(y0 - y1) * (y0 - y1); + String key = cx + "," + cy + "," + d2; + if (seen.containsKey(key)) { + for (int[] prev : seen.get(key)) { + int xx = prev[0], yy = prev[1]; + double area = Math.sqrt(((double)(x0 - xx) * (x0 - xx) + (double)(y0 - yy) * (y0 - yy)) * + ((double)(x1 - xx) * (x1 - xx) + (double)(y1 - yy) * (y1 - yy))); + ans = Math.min(ans, area); + } + } + seen.computeIfAbsent(key, k -> new ArrayList<>()).add(new int[]{x0, y0}); + } + } + return ans == Double.MAX_VALUE ? 0.0 : ans; + } +} diff --git a/tests/501-1000/963. minimum-area-rectangle-ii/sol.kt b/tests/501-1000/963. minimum-area-rectangle-ii/sol.kt new file mode 100644 index 00000000..4245d6da --- /dev/null +++ b/tests/501-1000/963. minimum-area-rectangle-ii/sol.kt @@ -0,0 +1,28 @@ +class Solution { + fun minAreaFreeRect(points: Array): Double { + var ans = Double.MAX_VALUE + val seen = mutableMapOf>>() + val n = points.size + for (i in 0 until n) { + val (x0, y0) = points[i] + for (j in i + 1 until n) { + val (x1, y1) = points[j] + val cx = (x0 + x1) / 2.0 + val cy = (y0 + y1) / 2.0 + val d2 = (x0 - x1).toLong() * (x0 - x1) + (y0 - y1).toLong() * (y0 - y1) + val key = "$cx,$cy,$d2" + if (seen.containsKey(key)) { + for ((xx, yy) in seen[key]!!) { + val area = kotlin.math.sqrt( + ((x0 - xx).toDouble() * (x0 - xx) + (y0 - yy).toDouble() * (y0 - yy)) * + ((x1 - xx).toDouble() * (x1 - xx) + (y1 - yy).toDouble() * (y1 - yy)) + ) + ans = minOf(ans, area) + } + } + seen.getOrPut(key) { mutableListOf() }.add(Pair(x0, y0)) + } + } + return if (ans == Double.MAX_VALUE) 0.0 else ans + } +} diff --git a/tests/501-1000/963. minimum-area-rectangle-ii/sol.py b/tests/501-1000/963. minimum-area-rectangle-ii/sol.py new file mode 100644 index 00000000..bcf35e59 --- /dev/null +++ b/tests/501-1000/963. minimum-area-rectangle-ii/sol.py @@ -0,0 +1,21 @@ +from math import inf, sqrt +from typing import List + + +class Solution: + def minAreaFreeRect(self, points: List[List[int]]) -> float: + ans = inf + seen = {} + for i, (x0, y0) in enumerate(points): + for x1, y1 in points[i + 1 :]: + cx = (x0 + x1) / 2 + cy = (y0 + y1) / 2 + d2 = (x0 - x1) ** 2 + (y0 - y1) ** 2 + for xx, yy in seen.get((cx, cy, d2), []): + area = sqrt( + ((x0 - xx) ** 2 + (y0 - yy) ** 2) + * ((x1 - xx) ** 2 + (y1 - yy) ** 2) + ) + ans = min(ans, area) + seen.setdefault((cx, cy, d2), []).append((x0, y0)) + return ans if ans < inf else 0 diff --git a/tests/501-1000/963. minimum-area-rectangle-ii/sol.py2 b/tests/501-1000/963. minimum-area-rectangle-ii/sol.py2 new file mode 100644 index 00000000..05021a15 --- /dev/null +++ b/tests/501-1000/963. minimum-area-rectangle-ii/sol.py2 @@ -0,0 +1,23 @@ +class Solution(object): + def minAreaFreeRect(self, points): + """ + :type points: List[List[int]] + :rtype: float + """ + ans = float('inf') + seen = {} + for i in range(len(points)): + x0, y0 = points[i] + for j in range(i + 1, len(points)): + x1, y1 = points[j] + cx = (x0 + x1) / 2.0 + cy = (y0 + y1) / 2.0 + d2 = (x0 - x1) ** 2 + (y0 - y1) ** 2 + key = (cx, cy, d2) + if key in seen: + for xx, yy in seen[key]: + area = ((x0 - xx) ** 2 + (y0 - yy) ** 2) ** 0.5 * ((x1 - xx) ** 2 + (y1 - yy) ** 2) ** 0.5 + if area < ans: + ans = area + seen.setdefault(key, []).append((x0, y0)) + return ans if ans < float('inf') else 0.0 diff --git a/tests/501-1000/963. minimum-area-rectangle-ii/sol.rb b/tests/501-1000/963. minimum-area-rectangle-ii/sol.rb new file mode 100644 index 00000000..bbcc9ba7 --- /dev/null +++ b/tests/501-1000/963. minimum-area-rectangle-ii/sol.rb @@ -0,0 +1,23 @@ +# @param {Integer[][]} points +# @return {Float} +def min_area_free_rect(points) + ans = Float::INFINITY + seen = {} + points.each_with_index do |(x0, y0), i| + points[i+1..].each do |x1, y1| + cx = (x0 + x1) / 2.0 + cy = (y0 + y1) / 2.0 + d2 = (x0 - x1)**2 + (y0 - y1)**2 + key = [cx, cy, d2] + if seen.key?(key) + seen[key].each do |xx, yy| + area = Math.sqrt(((x0 - xx)**2 + (y0 - yy)**2) * ((x1 - xx)**2 + (y1 - yy)**2)) + ans = area if area < ans + end + end + seen[key] ||= [] + seen[key] << [x0, y0] + end + end + ans == Float::INFINITY ? 0.0 : ans +end diff --git a/tests/501-1000/963. minimum-area-rectangle-ii/sol.rs b/tests/501-1000/963. minimum-area-rectangle-ii/sol.rs new file mode 100644 index 00000000..377e5c21 --- /dev/null +++ b/tests/501-1000/963. minimum-area-rectangle-ii/sol.rs @@ -0,0 +1,28 @@ +impl Solution { + pub fn min_area_free_rect(points: Vec>) -> f64 { + use std::collections::HashMap; + let mut ans = f64::INFINITY; + let mut seen: HashMap> = HashMap::new(); + let n = points.len(); + for i in 0..n { + let (x0, y0) = (points[i][0], points[i][1]); + for j in i+1..n { + let (x1, y1) = (points[j][0], points[j][1]); + let cx = (x0 + x1) as f64 / 2.0; + let cy = (y0 + y1) as f64 / 2.0; + let d2 = ((x0 - x1) as i64).pow(2) + ((y0 - y1) as i64).pow(2); + let key = format!("{},{},{}", cx, cy, d2); + if let Some(list) = seen.get(&key) { + for &(xx, yy) in list { + let d1 = ((x0 - xx) as f64).powi(2) + ((y0 - yy) as f64).powi(2); + let d2 = ((x1 - xx) as f64).powi(2) + ((y1 - yy) as f64).powi(2); + let area = (d1 * d2).sqrt(); + ans = ans.min(area); + } + } + seen.entry(key).or_default().push((x0, y0)); + } + } + if ans.is_infinite() { 0.0 } else { ans } + } +} diff --git a/tests/501-1000/963. minimum-area-rectangle-ii/sol.swift b/tests/501-1000/963. minimum-area-rectangle-ii/sol.swift new file mode 100644 index 00000000..edf16bfd --- /dev/null +++ b/tests/501-1000/963. minimum-area-rectangle-ii/sol.swift @@ -0,0 +1,26 @@ +class Solution { + func minAreaFreeRect(_ points: [[Int]]) -> Double { + var ans = Double.infinity + var seen = [String: [(Int, Int)]]() + let n = points.count + for i in 0..(); + const n = points.length; + for (let i = 0; i < n; i++) { + const [x0, y0] = points[i]; + for (let j = i + 1; j < n; j++) { + const [x1, y1] = points[j]; + const cx = (x0 + x1) / 2; + const cy = (y0 + y1) / 2; + const d2 = (x0 - x1) ** 2 + (y0 - y1) ** 2; + const key = `${cx},${cy},${d2}`; + if (seen.has(key)) { + for (const [xx, yy] of seen.get(key)!) { + const area = Math.sqrt( + ((x0 - xx) ** 2 + (y0 - yy) ** 2) * + ((x1 - xx) ** 2 + (y1 - yy) ** 2), + ); + ans = Math.min(ans, area); + } + } + if (!seen.has(key)) seen.set(key, []); + seen.get(key)!.push([x0, y0]); + } + } + return ans === Infinity ? 0 : ans; +} diff --git a/tests/501-1000/964. least-operators-to-express-number/manifest.yaml b/tests/501-1000/964. least-operators-to-express-number/manifest.yaml new file mode 100644 index 00000000..46eda4ad --- /dev/null +++ b/tests/501-1000/964. least-operators-to-express-number/manifest.yaml @@ -0,0 +1,207 @@ +entry: + id: 964 + title: least-operators-to-express-number + params: + x: + type: int + target: + type: int + call: + cpp: Solution().leastOpsExpressTarget({x}, {target}) + rust: Solution::least_ops_express_target({x}, {target}) + python3: Solution().leastOpsExpressTarget({x}, {target}) + python2: Solution().leastOpsExpressTarget({x}, {target}) + ruby: least_ops_express_target({x}, {target}) + java: new Solution().leastOpsExpressTarget({x}, {target}) + csharp: new Solution().LeastOpsExpressTarget({x}, {target}) + kotlin: Solution().leastOpsExpressTarget({x}, {target}) + go: leastOpsExpressTarget({x}, {target}) + dart: Solution().leastOpsExpressTarget({x}, {target}) + swift: Solution().leastOpsExpressTarget({x}, {target}) + typescript: leastOpsExpressTarget({x}, {target}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 964 +tests: + - name: case_1 + in: + x: 9 + target: 191 + out: 10 + - name: case_2 + in: + x: 7 + target: 123 + out: 13 + - name: case_3 + in: + x: 6 + target: 141 + out: 12 + - name: case_4 + in: + x: 7 + target: 172 + out: 15 + - name: case_5 + in: + x: 4 + target: 166 + out: 14 + - name: case_6 + in: + x: 7 + target: 45 + out: 8 + - name: case_7 + in: + x: 3 + target: 77 + out: 6 + - name: case_8 + in: + x: 4 + target: 143 + out: 9 + - name: case_9 + in: + x: 8 + target: 76 + out: 10 + - name: case_10 + in: + x: 4 + target: 189 + out: 9 + - name: case_11 + in: + x: 3 + target: 106 + out: 9 + - name: case_12 + in: + x: 8 + target: 105 + out: 8 + - name: case_13 + in: + x: 5 + target: 146 + out: 7 + - name: case_14 + in: + x: 3 + target: 199 + out: 13 + - name: case_15 + in: + x: 4 + target: 165 + out: 12 + - name: case_16 + in: + x: 3 + target: 2 + out: 2 + - name: case_17 + in: + x: 6 + target: 160 + out: 11 + - name: case_18 + in: + x: 6 + target: 87 + out: 11 + - name: case_19 + in: + x: 3 + target: 66 + out: 7 + - name: case_20 + in: + x: 3 + target: 111 + out: 7 + - name: case_21 + in: + x: 2 + target: 190 + out: 13 + - name: case_22 + in: + x: 7 + target: 58 + out: 6 + - name: case_23 + in: + x: 8 + target: 97 + out: 7 + - name: case_24 + in: + x: 8 + target: 111 + out: 7 + - name: case_25 + in: + x: 7 + target: 162 + out: 9 + - name: case_26 + in: + x: 3 + target: 161 + out: 9 + - name: case_27 + in: + x: 8 + target: 160 + out: 7 + - name: case_28 + in: + x: 2 + target: 102 + out: 13 + - name: case_29 + in: + x: 7 + target: 10 + out: 6 + - name: case_30 + in: + x: 8 + target: 134 + out: 8 + - name: case_31 + in: + x: 4 + target: 3 + out: 2 + - name: case_32 + in: + x: 5 + target: 193 + out: 13 + - name: case_33 + in: + x: 3 + target: 170 + out: 11 + - name: case_34 + in: + x: 6 + target: 144 + out: 6 + - name: case_35 + in: + x: 7 + target: 166 + out: 12 diff --git a/tests/501-1000/964. least-operators-to-express-number/sol.cpp b/tests/501-1000/964. least-operators-to-express-number/sol.cpp new file mode 100644 index 00000000..86737ca0 --- /dev/null +++ b/tests/501-1000/964. least-operators-to-express-number/sol.cpp @@ -0,0 +1,30 @@ +class Solution { +private: + unordered_map memo; + + int dfs(long long val, long long x) { + if (memo.count(val)) return memo[val]; + if (val < x) { + int res = min(2 * (int)val - 1, 2 * (int)(x - val)); + memo[val] = res; + return res; + } + + long long k = log(val) / log(x); + long long pow = (long long)std::pow(x, k); + int ans = (int)k + dfs(val - pow, x); + + long long nextPow = pow * x; + if (nextPow < 2 * val) { + ans = min(ans, (int)k + 1 + dfs(nextPow - val, x)); + } + + memo[val] = ans; + return ans; + } + +public: + int leastOpsExpressTarget(int x, int target) { + return dfs((long long)target, (long long)x); + } +}; diff --git a/tests/501-1000/964. least-operators-to-express-number/sol.cs b/tests/501-1000/964. least-operators-to-express-number/sol.cs new file mode 100644 index 00000000..4815de34 --- /dev/null +++ b/tests/501-1000/964. least-operators-to-express-number/sol.cs @@ -0,0 +1,28 @@ +public class Solution { + private Dictionary memo = new Dictionary(); + + public int LeastOpsExpressTarget(int x, int target) { + return Dfs((long)target, (long)x); + } + + private int Dfs(long val, long x) { + if (memo.ContainsKey(val)) return memo[val]; + if (val < x) { + int res = Math.Min(2 * (int)val - 1, 2 * (int)(x - val)); + memo[val] = res; + return res; + } + + long k = (long)(Math.Log(val) / Math.Log(x)); + long pow = (long)Math.Pow(x, k); + int ans = (int)k + Dfs(val - pow, x); + + long nextPow = pow * x; + if (nextPow < 2 * val) { + ans = Math.Min(ans, (int)k + 1 + Dfs(nextPow - val, x)); + } + + memo[val] = ans; + return ans; + } +} diff --git a/tests/501-1000/964. least-operators-to-express-number/sol.dart b/tests/501-1000/964. least-operators-to-express-number/sol.dart new file mode 100644 index 00000000..fcba80a3 --- /dev/null +++ b/tests/501-1000/964. least-operators-to-express-number/sol.dart @@ -0,0 +1,38 @@ +class Solution { + final Map _memo = {}; + + int leastOpsExpressTarget(int x, int target) { + return _dfs(target, x); + } + + int _dfs(int val, int x) { + if (_memo.containsKey(val)) return _memo[val]!; + if (val < x) { + int res = [2 * val - 1, 2 * (x - val)].reduce((a, b) => a < b ? a : b); + _memo[val] = res; + return res; + } + + int k = (log(val) / log(x)).floor(); + int pow = x.pow(k); + int ans = k + _dfs(val - pow, x); + + int nextPow = pow * x; + if (nextPow < 2 * val) { + ans = [ans, k + 1 + _dfs(nextPow - val, x)].reduce((a, b) => a < b ? a : b); + } + + _memo[val] = ans; + return ans; + } +} + +extension on int { + int pow(int exp) { + int result = 1; + for (int i = 0; i < exp; i++) { + result *= this; + } + return result; + } +} diff --git a/tests/501-1000/964. least-operators-to-express-number/sol.go b/tests/501-1000/964. least-operators-to-express-number/sol.go new file mode 100644 index 00000000..c263644b --- /dev/null +++ b/tests/501-1000/964. least-operators-to-express-number/sol.go @@ -0,0 +1,36 @@ +func leastOpsExpressTarget(x int, target int) int { + memo := make(map[int]int) + + var dfs func(int) int + dfs = func(val int) int { + if v, ok := memo[val]; ok { + return v + } + if val < x { + res := min(2*val-1, 2*(x-val)) + memo[val] = res + return res + } + + k := int(math.Log(float64(val)) / math.Log(float64(x))) + pow := int(math.Pow(float64(x), float64(k))) + ans := k + dfs(val-pow) + + nextPow := pow * x + if nextPow < 2*val { + ans = min(ans, k+1+dfs(nextPow-val)) + } + + memo[val] = ans + return ans + } + + return dfs(target) +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/tests/501-1000/964. least-operators-to-express-number/sol.java b/tests/501-1000/964. least-operators-to-express-number/sol.java new file mode 100644 index 00000000..ce3cb0fd --- /dev/null +++ b/tests/501-1000/964. least-operators-to-express-number/sol.java @@ -0,0 +1,28 @@ +class Solution { + private Map memo = new HashMap<>(); + + public int leastOpsExpressTarget(int x, int target) { + return dfs((long) target, (long) x); + } + + private int dfs(long val, long x) { + if (memo.containsKey(val)) return memo.get(val); + if (val < x) { + int res = (int) Math.min(2 * val - 1, 2 * (x - val)); + memo.put(val, res); + return res; + } + + long k = (long) (Math.log(val) / Math.log(x)); + long pow = (long) Math.pow(x, k); + int ans = (int) k + dfs(val - pow, x); + + long nextPow = pow * x; + if (nextPow < 2 * val) { + ans = Math.min(ans, (int)(k + 1) + dfs(nextPow - val, x)); + } + + memo.put(val, ans); + return ans; + } +} diff --git a/tests/501-1000/964. least-operators-to-express-number/sol.kt b/tests/501-1000/964. least-operators-to-express-number/sol.kt new file mode 100644 index 00000000..779eb668 --- /dev/null +++ b/tests/501-1000/964. least-operators-to-express-number/sol.kt @@ -0,0 +1,30 @@ +class Solution { + private val memo = mutableMapOf() + + fun leastOpsExpressTarget(x: Int, target: Int): Int { + return dfs(target.toLong(), x.toLong()) + } + + private fun dfs(`val`: Long, x: Long): Int { + memo[`val`]?.let { return it } + if (`val` < x) { + val res = minOf(2 * `val`.toInt() - 1, 2 * (x - `val`).toInt()) + memo[`val`] = res + return res + } + + val k = (Math.log(`val`.toDouble()) / Math.log(x.toDouble())).toLong() + var pow = 1L + for (i in 0 until k) pow *= x + + var ans = k.toInt() + dfs(`val` - pow, x) + + val nextPow = pow * x + if (nextPow < 2 * `val`) { + ans = minOf(ans, k.toInt() + 1 + dfs(nextPow - `val`, x)) + } + + memo[`val`] = ans + return ans + } +} diff --git a/tests/501-1000/964. least-operators-to-express-number/sol.py b/tests/501-1000/964. least-operators-to-express-number/sol.py new file mode 100644 index 00000000..520d4280 --- /dev/null +++ b/tests/501-1000/964. least-operators-to-express-number/sol.py @@ -0,0 +1,19 @@ +from functools import cache +from math import log + + +class Solution: + def leastOpsExpressTarget(self, x: int, target: int) -> int: + + @cache + def fn(val): + """Return min ops to express val.""" + if val < x: + return min(2 * val - 1, 2 * (x - val)) + k = int(log(val) // log(x)) + ans = k + fn(val - x**k) + if x ** (k + 1) < 2 * val: + ans = min(ans, k + 1 + fn(x ** (k + 1) - val)) + return ans + + return fn(target) diff --git a/tests/501-1000/964. least-operators-to-express-number/sol.py2 b/tests/501-1000/964. least-operators-to-express-number/sol.py2 new file mode 100644 index 00000000..92b8a6ca --- /dev/null +++ b/tests/501-1000/964. least-operators-to-express-number/sol.py2 @@ -0,0 +1,28 @@ +class Solution(object): + def leastOpsExpressTarget(self, x, target): + """ + :type x: int + :type target: int + :rtype: int + """ + import math + + memo = {} + + def fn(val): + if val in memo: + return memo[val] + if val < x: + memo[val] = min(2 * val - 1, 2 * (x - val)) + return memo[val] + + k = int(math.log(val) / math.log(x)) + base = x ** k + ans = k + fn(val - base) + next_base = base * x + if next_base < 2 * val: + ans = min(ans, k + 1 + fn(next_base - val)) + memo[val] = ans + return ans + + return fn(target) diff --git a/tests/501-1000/964. least-operators-to-express-number/sol.rb b/tests/501-1000/964. least-operators-to-express-number/sol.rb new file mode 100644 index 00000000..ee32f630 --- /dev/null +++ b/tests/501-1000/964. least-operators-to-express-number/sol.rb @@ -0,0 +1,24 @@ +# @param {Integer} x +# @param {Integer} target +# @return {Integer} +def least_ops_express_target(x, target) + $memo = {} + + def fn(val, x) + return $memo[val] if $memo.key?(val) + if val < x + result = [2 * val - 1, 2 * (x - val)].min + $memo[val] = result + return result + end + k = Math.log(val, x).floor + ans = k + fn(val - x ** k, x) + if x ** (k + 1) < 2 * val + ans = [ans, k + 1 + fn(x ** (k + 1) - val, x)].min + end + $memo[val] = ans + return ans + end + + return fn(target, x) +end diff --git a/tests/501-1000/964. least-operators-to-express-number/sol.rs b/tests/501-1000/964. least-operators-to-express-number/sol.rs new file mode 100644 index 00000000..29f9774e --- /dev/null +++ b/tests/501-1000/964. least-operators-to-express-number/sol.rs @@ -0,0 +1,31 @@ +use std::collections::HashMap; + +impl Solution { + pub fn least_ops_express_target(x: i32, target: i32) -> i32 { + let mut memo = HashMap::new(); + return Self::dfs(target as i64, x as i64, &mut memo); + } + + fn dfs(val: i64, x: i64, memo: &mut HashMap) -> i32 { + if let Some(&v) = memo.get(&val) { + return v; + } + if val < x { + let res = std::cmp::min(2 * val as i32 - 1, 2 * (x - val) as i32); + memo.insert(val, res); + return res; + } + + let k = (val as f64).log(x as f64).floor() as u32; + let pow = x.pow(k); + let mut ans = k as i32 + Self::dfs(val - pow, x, memo); + + let next_pow = pow * x; + if next_pow < 2 * val { + ans = std::cmp::min(ans, k as i32 + 1 + Self::dfs(next_pow - val, x, memo)); + } + + memo.insert(val, ans); + return ans; + } +} diff --git a/tests/501-1000/964. least-operators-to-express-number/sol.swift b/tests/501-1000/964. least-operators-to-express-number/sol.swift new file mode 100644 index 00000000..71489881 --- /dev/null +++ b/tests/501-1000/964. least-operators-to-express-number/sol.swift @@ -0,0 +1,30 @@ +class Solution { + private var memo: [Int: Int] = [:] + + func leastOpsExpressTarget(_ x: Int, _ target: Int) -> Int { + return dfs(target, x) + } + + private func dfs(_ val: Int, _ x: Int) -> Int { + if let cached = memo[val] { + return cached + } + if val < x { + let res = min(2 * val - 1, 2 * (x - val)) + memo[val] = res + return res + } + + let k = Int(log(Double(val)) / log(Double(x))) + let pow = Int(pow(Double(x), Double(k))) + var ans = k + dfs(val - pow, x) + + let nextPow = pow * x + if nextPow < 2 * val { + ans = min(ans, k + 1 + dfs(nextPow - val, x)) + } + + memo[val] = ans + return ans + } +} diff --git a/tests/501-1000/964. least-operators-to-express-number/sol.ts b/tests/501-1000/964. least-operators-to-express-number/sol.ts new file mode 100644 index 00000000..2ef4d5d7 --- /dev/null +++ b/tests/501-1000/964. least-operators-to-express-number/sol.ts @@ -0,0 +1,26 @@ +function leastOpsExpressTarget(x: number, target: number): number { + const memo: Map = new Map(); + + function dfs(val: number): number { + if (memo.has(val)) return memo.get(val)!; + if (val < x) { + const res = Math.min(2 * val - 1, 2 * (x - val)); + memo.set(val, res); + return res; + } + + const k = Math.floor(Math.log(val) / Math.log(x)); + const pow = Math.pow(x, k); + let ans = k + dfs(val - pow); + + const nextPow = pow * x; + if (nextPow < 2 * val) { + ans = Math.min(ans, k + 1 + dfs(nextPow - val)); + } + + memo.set(val, ans); + return ans; + } + + return dfs(target); +} diff --git a/tests/501-1000/965. univalued-binary-tree/manifest.yaml b/tests/501-1000/965. univalued-binary-tree/manifest.yaml new file mode 100644 index 00000000..b1777fd6 --- /dev/null +++ b/tests/501-1000/965. univalued-binary-tree/manifest.yaml @@ -0,0 +1,344 @@ +entry: + id: 965 + title: univalued-binary-tree + params: + root: + type: tree_node + call: + cpp: Solution().isUnivalTree({root}) + rust: Solution::is_unival_tree({root}) + python3: Solution().isUnivalTree({root}) + python2: Solution().isUnivalTree({root}) + ruby: is_unival_tree({root}) + java: new Solution().isUnivalTree({root}) + csharp: new Solution().IsUnivalTree({root}) + kotlin: Solution().isUnivalTree({root}) + go: isUnivalTree({root}) + dart: Solution().isUnivalTree({root}) + swift: Solution().isUnivalTree({root}) + typescript: isUnivalTree({root}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 965 +tests: + - name: case_1 + in: + root: + - 2 + - 0 + - 1 + - 1 + - 0 + out: false + - name: case_2 + in: + root: + - 3 + - 1 + - 0 + - 0 + out: false + - name: case_3 + in: + root: + - 2 + - null + - 3 + - null + - 1 + - 1 + - 1 + out: false + - name: case_4 + in: + root: + - 1 + - 2 + - 1 + - 2 + - 3 + - 2 + - 0 + - 0 + - 1 + out: false + - name: case_5 + in: + root: + - 2 + - 0 + - 1 + - 2 + - 2 + - 0 + - 1 + - 3 + out: false + - name: case_6 + in: + root: [] + out: true + - name: case_7 + in: + root: + - 1 + - 3 + - 3 + - 0 + out: false + - name: case_8 + in: + root: + - 0 + - 1 + - 3 + - 1 + - 3 + - 3 + - 0 + - 2 + - 2 + out: false + - name: case_9 + in: + root: + - 0 + - null + - 0 + - 1 + - 0 + - 1 + - 1 + - 2 + - 0 + out: false + - name: case_10 + in: + root: + - 2 + out: true + - name: case_11 + in: + root: + - 3 + out: true + - name: case_12 + in: + root: + - 2 + - 2 + - null + - null + - 3 + - 0 + - null + - 3 + - 3 + - 2 + - 2 + - 3 + - 3 + out: false + - name: case_13 + in: + root: + - 0 + - 0 + out: true + - name: case_14 + in: + root: + - 3 + out: true + - name: case_15 + in: + root: + - 3 + - 2 + - 2 + out: false + - name: case_16 + in: + root: + - 1 + - 0 + - null + - 0 + - null + - 3 + - 2 + out: false + - name: case_17 + in: + root: + - 2 + - null + - 3 + - 2 + - 1 + out: false + - name: case_18 + in: + root: + - 0 + - null + - 3 + - 2 + out: false + - name: case_19 + in: + root: + - 0 + - 1 + - 2 + out: false + - name: case_20 + in: + root: + - 1 + - 2 + - null + - 3 + - 1 + out: false + - name: case_21 + in: + root: + - 1 + - 0 + - 1 + - 2 + - 3 + - 2 + - 3 + - 0 + - 3 + - 3 + out: false + - name: case_22 + in: + root: + - 3 + out: true + - name: case_23 + in: + root: [] + out: true + - name: case_24 + in: + root: + - 1 + - 2 + - 0 + - null + - null + - 2 + out: false + - name: case_25 + in: + root: [] + out: true + - name: case_26 + in: + root: + - 1 + - null + - 0 + - 3 + - null + - 0 + - 3 + - 0 + - 2 + - null + - 0 + - null + - null + - 3 + out: false + - name: case_27 + in: + root: [] + out: true + - name: case_28 + in: + root: + - 2 + - 1 + - 2 + - 1 + out: false + - name: case_29 + in: + root: + - 1 + out: true + - name: case_30 + in: + root: + - 3 + - 2 + - 2 + - 0 + - null + - 1 + - 1 + - 1 + - 1 + - 1 + - 1 + out: false + - name: case_31 + in: + root: + - 3 + out: true + - name: case_32 + in: + root: + - 3 + - 0 + - 0 + - 1 + - 2 + - 3 + - 3 + - 1 + - null + - 0 + out: false + - name: case_33 + in: + root: + - 1 + - 1 + - null + - 3 + - 1 + - null + - 2 + - 3 + - 1 + - null + - 1 + - 1 + out: false + - name: case_34 + in: + root: [] + out: true + - name: case_35 + in: + root: + - 1 + - 3 + - 1 + - 0 + out: false diff --git a/tests/501-1000/965. univalued-binary-tree/sol.cpp b/tests/501-1000/965. univalued-binary-tree/sol.cpp new file mode 100644 index 00000000..95bb6292 --- /dev/null +++ b/tests/501-1000/965. univalued-binary-tree/sol.cpp @@ -0,0 +1,26 @@ +/** + * Definition for a binary tree node. + * struct TreeNode { + * int val; + * TreeNode *left; + * TreeNode *right; + * TreeNode() : val(0), left(nullptr), right(nullptr) {} + * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} + * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} + * }; + */ +class Solution { +public: + bool isUnivalTree(TreeNode* root) { + if (root == nullptr) { + return true; + } + if (root->left != nullptr && root->left->val != root->val) { + return false; + } + if (root->right != nullptr && root->right->val != root->val) { + return false; + } + return isUnivalTree(root->left) && isUnivalTree(root->right); + } +}; diff --git a/tests/501-1000/965. univalued-binary-tree/sol.cs b/tests/501-1000/965. univalued-binary-tree/sol.cs new file mode 100644 index 00000000..a15df48f --- /dev/null +++ b/tests/501-1000/965. univalued-binary-tree/sol.cs @@ -0,0 +1,27 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public int val; + * public TreeNode left; + * public TreeNode right; + * public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +public class Solution { + public bool IsUnivalTree(TreeNode root) { + if (root == null) { + return true; + } + if (root.left != null && root.left.val != root.val) { + return false; + } + if (root.right != null && root.right.val != root.val) { + return false; + } + return IsUnivalTree(root.left) && IsUnivalTree(root.right); + } +} diff --git a/tests/501-1000/965. univalued-binary-tree/sol.dart b/tests/501-1000/965. univalued-binary-tree/sol.dart new file mode 100644 index 00000000..79e96109 --- /dev/null +++ b/tests/501-1000/965. univalued-binary-tree/sol.dart @@ -0,0 +1,23 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * int val; + * TreeNode? left; + * TreeNode? right; + * TreeNode([this.val = 0, this.left, this.right]); + * } + */ +class Solution { + bool isUnivalTree(TreeNode? root) { + if (root == null) { + return true; + } + if (root.left != null && root.left!.val != root.val) { + return false; + } + if (root.right != null && root.right!.val != root.val) { + return false; + } + return isUnivalTree(root.left) && isUnivalTree(root.right); + } +} diff --git a/tests/501-1000/965. univalued-binary-tree/sol.go b/tests/501-1000/965. univalued-binary-tree/sol.go new file mode 100644 index 00000000..0cbbb6b1 --- /dev/null +++ b/tests/501-1000/965. univalued-binary-tree/sol.go @@ -0,0 +1,20 @@ +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +func isUnivalTree(root *TreeNode) bool { + if root == nil { + return true + } + if root.Left != nil && root.Left.Val != root.Val { + return false + } + if root.Right != nil && root.Right.Val != root.Val { + return false + } + return isUnivalTree(root.Left) && isUnivalTree(root.Right) +} diff --git a/tests/501-1000/965. univalued-binary-tree/sol.java b/tests/501-1000/965. univalued-binary-tree/sol.java new file mode 100644 index 00000000..99046166 --- /dev/null +++ b/tests/501-1000/965. univalued-binary-tree/sol.java @@ -0,0 +1,29 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode() {} + * TreeNode(int val) { this.val = val; } + * TreeNode(int val, TreeNode left, TreeNode right) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +class Solution { + public boolean isUnivalTree(TreeNode root) { + if (root == null) { + return true; + } + if (root.left != null && root.left.val != root.val) { + return false; + } + if (root.right != null && root.right.val != root.val) { + return false; + } + return isUnivalTree(root.left) && isUnivalTree(root.right); + } +} diff --git a/tests/501-1000/965. univalued-binary-tree/sol.kt b/tests/501-1000/965. univalued-binary-tree/sol.kt new file mode 100644 index 00000000..3057be6a --- /dev/null +++ b/tests/501-1000/965. univalued-binary-tree/sol.kt @@ -0,0 +1,26 @@ +/** + * Example: + * var ti = TreeNode(5) + * var v = ti.`val` + * Definition for a binary tree node. + * class TreeNode(var `val`: Int) { + * var left: TreeNode? = null + * var right: TreeNode? = null + * } + */ +class Solution { + fun isUnivalTree(root: TreeNode?): Boolean { + if (root == null) { + return true + } + val left = root.left + val right = root.right + if (left != null && left.`val` != root.`val`) { + return false + } + if (right != null && right.`val` != root.`val`) { + return false + } + return isUnivalTree(left) && isUnivalTree(right) + } +} diff --git a/tests/501-1000/965. univalued-binary-tree/sol.py b/tests/501-1000/965. univalued-binary-tree/sol.py new file mode 100644 index 00000000..e2bbe1ea --- /dev/null +++ b/tests/501-1000/965. univalued-binary-tree/sol.py @@ -0,0 +1,18 @@ +# Definition for a binary tree node. +# class TreeNode: +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +from typing import Optional + + +class Solution: + def isUnivalTree(self, root: Optional[TreeNode]) -> bool: + if root == None: + return True + if root.left and root.left.val != root.val: + return False + if root.right and root.right.val != root.val: + return False + return self.isUnivalTree(root.left) and self.isUnivalTree(root.right) diff --git a/tests/501-1000/965. univalued-binary-tree/sol.py2 b/tests/501-1000/965. univalued-binary-tree/sol.py2 new file mode 100644 index 00000000..8f733583 --- /dev/null +++ b/tests/501-1000/965. univalued-binary-tree/sol.py2 @@ -0,0 +1,19 @@ +# Definition for a binary tree node. +# class TreeNode(object): +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution(object): + def isUnivalTree(self, root): + """ + :type root: Optional[TreeNode] + :rtype: bool + """ + if root is None: + return True + if root.left and root.left.val != root.val: + return False + if root.right and root.right.val != root.val: + return False + return self.isUnivalTree(root.left) and self.isUnivalTree(root.right) diff --git a/tests/501-1000/965. univalued-binary-tree/sol.rb b/tests/501-1000/965. univalued-binary-tree/sol.rb new file mode 100644 index 00000000..a31f237b --- /dev/null +++ b/tests/501-1000/965. univalued-binary-tree/sol.rb @@ -0,0 +1,17 @@ +# Definition for a binary tree node. +# class TreeNode +# attr_accessor :val, :left, :right +# def initialize(val = 0, left = nil, right = nil) +# @val = val +# @left = left +# @right = right +# end +# end +# @param {TreeNode} root +# @return {Boolean} +def is_unival_tree(root) + return true if root.nil? + return false if root.left && root.left.val != root.val + return false if root.right && root.right.val != root.val + is_unival_tree(root.left) && is_unival_tree(root.right) +end diff --git a/tests/501-1000/965. univalued-binary-tree/sol.rs b/tests/501-1000/965. univalued-binary-tree/sol.rs new file mode 100644 index 00000000..5648a474 --- /dev/null +++ b/tests/501-1000/965. univalued-binary-tree/sol.rs @@ -0,0 +1,39 @@ +// Definition for a binary tree node. +// #[derive(Debug, PartialEq, Eq)] +// pub struct TreeNode { +// pub val: i32, +// pub left: Option>>, +// pub right: Option>>, +// } +// +// impl TreeNode { +// #[inline] +// pub fn new(val: i32) -> Self { +// TreeNode { +// val, +// left: None, +// right: None +// } +// } +// } +impl Solution { + pub fn is_unival_tree(root: Option>>) -> bool { + match root { + None => true, + Some(node) => { + let node = node.borrow(); + if let Some(ref left) = node.left { + if left.borrow().val != node.val { + return false; + } + } + if let Some(ref right) = node.right { + if right.borrow().val != node.val { + return false; + } + } + Solution::is_unival_tree(node.left.clone()) && Solution::is_unival_tree(node.right.clone()) + } + } + } +} diff --git a/tests/501-1000/965. univalued-binary-tree/sol.swift b/tests/501-1000/965. univalued-binary-tree/sol.swift new file mode 100644 index 00000000..d80ebf08 --- /dev/null +++ b/tests/501-1000/965. univalued-binary-tree/sol.swift @@ -0,0 +1,29 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public var val: Int + * public var left: TreeNode? + * public var right: TreeNode? + * public init() { self.val = 0; self.left = nil; self.right = nil; } + * public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; } + * public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) { + * self.val = val + * self.left = left + * self.right = right + * } + * } + */ +class Solution { + func isUnivalTree(_ root: TreeNode?) -> Bool { + guard let root = root else { + return true + } + if let left = root.left, left.val != root.val { + return false + } + if let right = root.right, right.val != root.val { + return false + } + return isUnivalTree(root.left) && isUnivalTree(root.right) + } +} diff --git a/tests/501-1000/965. univalued-binary-tree/sol.ts b/tests/501-1000/965. univalued-binary-tree/sol.ts new file mode 100644 index 00000000..5a9fcf1a --- /dev/null +++ b/tests/501-1000/965. univalued-binary-tree/sol.ts @@ -0,0 +1,26 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ + +function isUnivalTree(root: TreeNode | null): boolean { + if (root === null) { + return true; + } + if (root.left !== null && root.left.val !== root.val) { + return false; + } + if (root.right !== null && root.right.val !== root.val) { + return false; + } + return isUnivalTree(root.left) && isUnivalTree(root.right); +} diff --git a/tests/501-1000/966. vowel-spellchecker/manifest.yaml b/tests/501-1000/966. vowel-spellchecker/manifest.yaml new file mode 100644 index 00000000..f519afa6 --- /dev/null +++ b/tests/501-1000/966. vowel-spellchecker/manifest.yaml @@ -0,0 +1,675 @@ +entry: + id: 966 + title: vowel-spellchecker + params: + wordlist: + type: array + items: + type: string + queries: + type: array + items: + type: string + call: + cpp: Solution().spellchecker({wordlist}, {queries}) + rust: Solution::spellchecker({wordlist}, {queries}) + python3: Solution().spellchecker({wordlist}, {queries}) + python2: Solution().spellchecker({wordlist}, {queries}) + ruby: spellchecker({wordlist}, {queries}) + java: new Solution().spellchecker({wordlist}, {queries}) + csharp: new Solution().Spellchecker({wordlist}, {queries}) + kotlin: Solution().spellchecker({wordlist}, {queries}) + go: spellchecker({wordlist}, {queries}) + dart: Solution().spellchecker({wordlist}, {queries}) + swift: Solution().spellchecker({wordlist}, {queries}) + typescript: spellchecker({wordlist}, {queries}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 966 +tests: + - name: case_1 + in: + wordlist: + - a + - dccba + queries: + - cebD + - da + - Ccc + out: + - "" + - "" + - "" + - name: case_2 + in: + wordlist: + - ccca + - dccbd + - aca + - cddac + - d + queries: + - BDADC + - aBc + out: + - "" + - "" + - name: case_3 + in: + wordlist: + - baadd + - c + - dcd + - db + - baddb + - cdc + - ca + queries: + - CB + - BaEC + - eb + - DD + - Ddb + out: + - "" + - "" + - "" + - "" + - "" + - name: case_4 + in: + wordlist: + - dd + - dcb + - d + - b + - dbdb + queries: + - CA + - Bacbb + - BcCE + out: + - "" + - "" + - "" + - name: case_5 + in: + wordlist: + - cbaaa + - ab + - aa + - a + - bdd + - a + - dddbd + - dbdca + queries: + - AE + - bC + out: + - aa + - "" + - name: case_6 + in: + wordlist: + - ac + - a + - cbc + queries: + - b + - CE + - d + out: + - "" + - "" + - "" + - name: case_7 + in: + wordlist: + - cdb + - dcdd + - cd + - dbab + queries: + - ccED + - EDcca + - bb + out: + - "" + - "" + - "" + - name: case_8 + in: + wordlist: + - cb + - bad + - cac + - d + queries: + - dDa + - DAAD + - cdB + - CC + - ccCa + - Dd + out: + - "" + - "" + - "" + - "" + - "" + - "" + - name: case_9 + in: + wordlist: + - dddbb + - babca + - bdcbb + - c + - bcb + - dddac + queries: + - EACA + - E + - cCAEe + - bBDA + - C + - A + out: + - "" + - "" + - "" + - "" + - c + - "" + - name: case_10 + in: + wordlist: + - cdb + - cc + - ddadd + - bac + queries: + - CB + - bdD + - BE + - EDA + - EADd + - ceCd + - cAaEB + - DBAd + out: + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - name: case_11 + in: + wordlist: + - ccacc + queries: + - dBd + out: + - "" + - name: case_12 + in: + wordlist: + - bd + - baaba + - da + - bd + - baaaa + - dccca + queries: + - Dae + - CaEDB + - CCae + - aCC + out: + - "" + - "" + - "" + - "" + - name: case_13 + in: + wordlist: + - ccc + - dbab + queries: + - DC + - Acea + - AdC + - aAe + - CbDe + out: + - "" + - "" + - "" + - "" + - "" + - name: case_14 + in: + wordlist: + - abdc + - ddca + queries: + - CE + - b + - adBE + - eBec + - c + - Eacd + - a + out: + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - name: case_15 + in: + wordlist: + - aab + - aab + - dd + - cdada + - adc + - abcc + - d + - aaab + queries: + - eDDb + - dEc + - baAe + - DB + - D + - ECBDa + out: + - "" + - "" + - "" + - "" + - d + - "" + - name: case_16 + in: + wordlist: + - bdcaa + - b + - badaa + - adca + - dd + - bdb + queries: + - Bc + out: + - "" + - name: case_17 + in: + wordlist: + - bdc + - ab + - cbcd + - c + - cd + - ccbd + queries: + - a + - e + - CE + - EEA + out: + - "" + - "" + - "" + - "" + - name: case_18 + in: + wordlist: + - ca + - bddb + - daaba + - a + - c + - c + queries: + - Cb + - Cddea + - beeb + - BAc + - bc + - Db + - BC + out: + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - name: case_19 + in: + wordlist: + - cca + - ca + queries: + - aBbED + - bdE + - Dee + out: + - "" + - "" + - "" + - name: case_20 + in: + wordlist: + - cdc + - abaad + - dcbc + - cdcd + - d + queries: + - eDdBB + - c + - eaAe + - DbaED + - ccA + - bb + out: + - "" + - "" + - "" + - "" + - "" + - "" + - name: case_21 + in: + wordlist: + - ca + - aa + - dd + queries: + - Dba + - DB + - aCcEc + - AEbBb + - bAe + - dABCe + - ceA + - Baaa + out: + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - name: case_22 + in: + wordlist: + - acdc + - d + - bad + - cb + - c + - ac + - a + queries: + - E + - eABcE + - bAe + - EabEB + - DdeeC + out: + - a + - "" + - "" + - "" + - "" + - name: case_23 + in: + wordlist: + - b + - a + - a + - b + - acbdb + - ca + queries: + - B + - eEDAc + - e + - Dc + out: + - b + - "" + - a + - "" + - name: case_24 + in: + wordlist: + - dcda + - aabc + - cdac + - cbdda + - bbacd + - a + queries: + - AE + - C + - dbe + out: + - "" + - "" + - "" + - name: case_25 + in: + wordlist: + - caacd + - b + - dc + queries: + - D + - Cd + - aAcd + out: + - "" + - "" + - "" + - name: case_26 + in: + wordlist: + - ad + - da + - aaac + - b + - baacd + - db + - aacb + - c + queries: + - aB + - Ecbc + - ae + - CBC + out: + - "" + - "" + - "" + - "" + - name: case_27 + in: + wordlist: + - a + - dcb + - bbdb + - dca + - bab + - cbb + - c + queries: + - dE + - A + - cEE + - cbab + - DCA + out: + - "" + - a + - "" + - "" + - dca + - name: case_28 + in: + wordlist: + - cacbc + - bca + - dba + - b + - bbcdc + - c + - a + queries: + - EAe + - C + out: + - "" + - c + - name: case_29 + in: + wordlist: + - bd + - bdcb + - b + - adad + - d + - dacbb + queries: + - EeA + out: + - "" + - name: case_30 + in: + wordlist: + - cd + queries: + - b + - aad + - aa + out: + - "" + - "" + - "" + - name: case_31 + in: + wordlist: + - bc + - dabd + - adabd + queries: + - E + - CDa + - aDBD + - cC + - adcC + - CbdDb + out: + - "" + - "" + - "" + - "" + - "" + - "" + - name: case_32 + in: + wordlist: + - ba + - ccdac + - baa + - ada + - bacb + - ac + queries: + - Ed + - DBEEe + - eE + out: + - "" + - "" + - "" + - name: case_33 + in: + wordlist: + - bbbba + - bcda + - adacd + - adbad + - c + - dacad + - daccd + - bcb + queries: + - debCe + - EaBBA + - da + - cd + - cD + - BdEeb + - Ca + out: + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - name: case_34 + in: + wordlist: + - b + - ca + - cdaad + - dc + - dcc + - acbaa + - bbb + queries: + - eeAE + - abadE + out: + - "" + - "" + - name: case_35 + in: + wordlist: + - ba + - aac + - acb + - dcc + - cdba + - c + - c + - acbab + queries: + - E + - A + out: + - "" + - "" diff --git a/tests/501-1000/966. vowel-spellchecker/sol.cpp b/tests/501-1000/966. vowel-spellchecker/sol.cpp new file mode 100644 index 00000000..f4688088 --- /dev/null +++ b/tests/501-1000/966. vowel-spellchecker/sol.cpp @@ -0,0 +1,56 @@ +class Solution { +public: + vector spellchecker(vector& wordlist, vector& queries) { + unordered_set exact(wordlist.begin(), wordlist.end()); + unordered_map caseMap; + unordered_map vowelMap; + + for (const auto& w : wordlist) { + string lower = toLower(w); + string devowel = deVowel(lower); + if (caseMap.find(lower) == caseMap.end()) { + caseMap[lower] = w; + } + if (vowelMap.find(devowel) == vowelMap.end()) { + vowelMap[devowel] = w; + } + } + + vector result; + for (const auto& q : queries) { + if (exact.count(q)) { + result.push_back(q); + } else { + string lower = toLower(q); + string devowel = deVowel(lower); + if (caseMap.count(lower)) { + result.push_back(caseMap[lower]); + } else if (vowelMap.count(devowel)) { + result.push_back(vowelMap[devowel]); + } else { + result.push_back(""); + } + } + } + return result; + } + +private: + string toLower(const string& s) { + string result = s; + transform(result.begin(), result.end(), result.begin(), ::tolower); + return result; + } + + string deVowel(const string& s) { + string result; + for (char c : s) { + if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') { + result += '*'; + } else { + result += c; + } + } + return result; + } +}; diff --git a/tests/501-1000/966. vowel-spellchecker/sol.cs b/tests/501-1000/966. vowel-spellchecker/sol.cs new file mode 100644 index 00000000..d7679218 --- /dev/null +++ b/tests/501-1000/966. vowel-spellchecker/sol.cs @@ -0,0 +1,49 @@ +public class Solution { + public string[] Spellchecker(string[] wordlist, string[] queries) { + var exact = new HashSet(wordlist); + var caseMap = new Dictionary(); + var vowelMap = new Dictionary(); + + foreach (var w in wordlist) { + var lower = w.ToLower(); + var devowel = DeVowel(lower); + if (!caseMap.ContainsKey(lower)) { + caseMap[lower] = w; + } + if (!vowelMap.ContainsKey(devowel)) { + vowelMap[devowel] = w; + } + } + + var result = new string[queries.Length]; + for (int i = 0; i < queries.Length; i++) { + var q = queries[i]; + if (exact.Contains(q)) { + result[i] = q; + } else { + var lower = q.ToLower(); + var devowel = DeVowel(lower); + if (caseMap.ContainsKey(lower)) { + result[i] = caseMap[lower]; + } else if (vowelMap.ContainsKey(devowel)) { + result[i] = vowelMap[devowel]; + } else { + result[i] = ""; + } + } + } + return result; + } + + private string DeVowel(string s) { + var sb = new System.Text.StringBuilder(); + foreach (var c in s) { + if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') { + sb.Append('*'); + } else { + sb.Append(c); + } + } + return sb.ToString(); + } +} diff --git a/tests/501-1000/966. vowel-spellchecker/sol.dart b/tests/501-1000/966. vowel-spellchecker/sol.dart new file mode 100644 index 00000000..1d4e3e2f --- /dev/null +++ b/tests/501-1000/966. vowel-spellchecker/sol.dart @@ -0,0 +1,40 @@ +class Solution { + List spellchecker(List wordlist, List queries) { + Set exact = Set.from(wordlist); + Map caseMap = {}; + Map vowelMap = {}; + + for (String w in wordlist) { + String lower = w.toLowerCase(); + String devowel = deVowel(lower); + if (!caseMap.containsKey(lower)) { + caseMap[lower] = w; + } + if (!vowelMap.containsKey(devowel)) { + vowelMap[devowel] = w; + } + } + + List result = []; + for (String q in queries) { + if (exact.contains(q)) { + result.add(q); + } else { + String lower = q.toLowerCase(); + String devowel = deVowel(lower); + if (caseMap.containsKey(lower)) { + result.add(caseMap[lower]!); + } else if (vowelMap.containsKey(devowel)) { + result.add(vowelMap[devowel]!); + } else { + result.add(""); + } + } + } + return result; + } + + String deVowel(String s) { + return s.split('').map((c) => 'aeiou'.contains(c) ? '*' : c).join(); + } +} diff --git a/tests/501-1000/966. vowel-spellchecker/sol.go b/tests/501-1000/966. vowel-spellchecker/sol.go new file mode 100644 index 00000000..2450b122 --- /dev/null +++ b/tests/501-1000/966. vowel-spellchecker/sol.go @@ -0,0 +1,49 @@ +func spellchecker(wordlist []string, queries []string) []string { + exact := make(map[string]bool) + caseMap := make(map[string]string) + vowelMap := make(map[string]string) + + for _, w := range wordlist { + exact[w] = true + lower := strings.ToLower(w) + devowel := deVowel(lower) + if _, ok := caseMap[lower]; !ok { + caseMap[lower] = w + } + if _, ok := vowelMap[devowel]; !ok { + vowelMap[devowel] = w + } + } + + result := make([]string, len(queries)) + for i, q := range queries { + if exact[q] { + result[i] = q + } else { + lower := strings.ToLower(q) + devowel := deVowel(lower) + if v, ok := caseMap[lower]; ok { + result[i] = v + } else if v, ok := vowelMap[devowel]; ok { + result[i] = v + } else { + result[i] = "" + } + } + } + return result +} + +func deVowel(s string) string { + vowels := "aeiou" + result := []byte(s) + for i := 0; i < len(result); i++ { + for _, v := range vowels { + if rune(result[i]) == v { + result[i] = '*' + break + } + } + } + return string(result) +} diff --git a/tests/501-1000/966. vowel-spellchecker/sol.java b/tests/501-1000/966. vowel-spellchecker/sol.java new file mode 100644 index 00000000..e2504378 --- /dev/null +++ b/tests/501-1000/966. vowel-spellchecker/sol.java @@ -0,0 +1,50 @@ +class Solution { + public String[] spellchecker(String[] wordlist, String[] queries) { + Set exact = new HashSet<>(); + Map caseMap = new HashMap<>(); + Map vowelMap = new HashMap<>(); + + for (String w : wordlist) { + exact.add(w); + String lower = w.toLowerCase(); + String devowel = deVowel(lower); + if (!caseMap.containsKey(lower)) { + caseMap.put(lower, w); + } + if (!vowelMap.containsKey(devowel)) { + vowelMap.put(devowel, w); + } + } + + String[] result = new String[queries.length]; + for (int i = 0; i < queries.length; i++) { + String q = queries[i]; + if (exact.contains(q)) { + result[i] = q; + } else { + String lower = q.toLowerCase(); + String devowel = deVowel(lower); + if (caseMap.containsKey(lower)) { + result[i] = caseMap.get(lower); + } else if (vowelMap.containsKey(devowel)) { + result[i] = vowelMap.get(devowel); + } else { + result[i] = ""; + } + } + } + return result; + } + + private String deVowel(String s) { + StringBuilder sb = new StringBuilder(); + for (char c : s.toCharArray()) { + if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') { + sb.append('*'); + } else { + sb.append(c); + } + } + return sb.toString(); + } +} diff --git a/tests/501-1000/966. vowel-spellchecker/sol.kt b/tests/501-1000/966. vowel-spellchecker/sol.kt new file mode 100644 index 00000000..ba77ce7d --- /dev/null +++ b/tests/501-1000/966. vowel-spellchecker/sol.kt @@ -0,0 +1,37 @@ +class Solution { + fun spellchecker(wordlist: Array, queries: Array): Array { + val exact = wordlist.toSet() + val caseMap = mutableMapOf() + val vowelMap = mutableMapOf() + + for (w in wordlist) { + val lower = w.lowercase() + val devowel = deVowel(lower) + if (lower !in caseMap) { + caseMap[lower] = w + } + if (devowel !in vowelMap) { + vowelMap[devowel] = w + } + } + + return queries.map { q -> + when { + q in exact -> q + else -> { + val lower = q.lowercase() + val devowel = deVowel(lower) + when { + lower in caseMap -> caseMap[lower]!! + devowel in vowelMap -> vowelMap[devowel]!! + else -> "" + } + } + } + }.toTypedArray() + } + + private fun deVowel(s: String): String { + return s.map { if (it in "aeiou") '*' else it }.joinToString("") + } +} diff --git a/tests/501-1000/966. vowel-spellchecker/sol.py b/tests/501-1000/966. vowel-spellchecker/sol.py new file mode 100644 index 00000000..c0d8805e --- /dev/null +++ b/tests/501-1000/966. vowel-spellchecker/sol.py @@ -0,0 +1,34 @@ +from typing import List + + +class Solution: + def spellchecker(self, wordlist, queries): + exact = set(wordlist) + caseMap = {} + vowelMap = {} + + for w in wordlist: + lower = w.lower() + devowel = self.deVowel(lower) + if lower not in caseMap: + caseMap[lower] = w + if devowel not in vowelMap: + vowelMap[devowel] = w + + result = [] + for q in queries: + if q in exact: + result.append(q) + else: + lower = q.lower() + devowel = self.deVowel(lower) + if lower in caseMap: + result.append(caseMap[lower]) + elif devowel in vowelMap: + result.append(vowelMap[devowel]) + else: + result.append("") + return result + + def deVowel(self, s): + return "".join("*" if c in "aeiou" else c for c in s) diff --git a/tests/501-1000/966. vowel-spellchecker/sol.py2 b/tests/501-1000/966. vowel-spellchecker/sol.py2 new file mode 100644 index 00000000..2b41b0b7 --- /dev/null +++ b/tests/501-1000/966. vowel-spellchecker/sol.py2 @@ -0,0 +1,36 @@ +class Solution(object): + def spellchecker(self, wordlist, queries): + """ + :type wordlist: List[str] + :type queries: List[str] + :rtype: List[str] + """ + exact = set(wordlist) + caseMap = {} + vowelMap = {} + + for w in wordlist: + lower = w.lower() + devowel = self.deVowel(lower) + if lower not in caseMap: + caseMap[lower] = w + if devowel not in vowelMap: + vowelMap[devowel] = w + + result = [] + for q in queries: + if q in exact: + result.append(q) + else: + lower = q.lower() + devowel = self.deVowel(lower) + if lower in caseMap: + result.append(caseMap[lower]) + elif devowel in vowelMap: + result.append(vowelMap[devowel]) + else: + result.append("") + return result + + def deVowel(self, s): + return ''.join('*' if c in 'aeiou' else c for c in s) diff --git a/tests/501-1000/966. vowel-spellchecker/sol.rb b/tests/501-1000/966. vowel-spellchecker/sol.rb new file mode 100644 index 00000000..1f995eec --- /dev/null +++ b/tests/501-1000/966. vowel-spellchecker/sol.rb @@ -0,0 +1,68 @@ +# @param {String[]} wordlist +# @param {String[]} queries +# @return {String[]} +def spellchecker(wordlist, queries) + exact = wordlist.to_set + case_map = {} + vowel_map = {} + + wordlist.each do |w| + lower = w.downcase + devowel = de_vowel(lower) + case_map[lower] = w unless case_map.key?(lower) + vowel_map[devowel] = w unless vowel_map.key?(devowel) + end + + result = [] + queries.each do |q| + if exact.include?(q) + result << q + else + lower = q.downcase + devowel = de_vowel(lower) + if case_map.key?(lower) + result << case_map[lower] + elsif vowel_map.key?(devowel) + result << vowel_map[devowel] + else + result << "" + end + end + end + result +end + +def de_vowel(s) + s.chars.map { |c| 'aeiou'.include?(c) ? '*' : c }.join +end + +def spellchecker(wordlist, queries) + exact = wordlist.to_set + case_map = {} + vowel_map = {} + + wordlist.each do |w| + lower = w.downcase + devowel = de_vowel(lower) + case_map[lower] = w unless case_map.key?(lower) + vowel_map[devowel] = w unless vowel_map.key?(devowel) + end + + result = [] + queries.each do |q| + if exact.include?(q) + result << q + else + lower = q.downcase + devowel = de_vowel(lower) + if case_map.key?(lower) + result << case_map[lower] + elsif vowel_map.key?(devowel) + result << vowel_map[devowel] + else + result << "" + end + end + end + result +end diff --git a/tests/501-1000/966. vowel-spellchecker/sol.rs b/tests/501-1000/966. vowel-spellchecker/sol.rs new file mode 100644 index 00000000..c418e5c3 --- /dev/null +++ b/tests/501-1000/966. vowel-spellchecker/sol.rs @@ -0,0 +1,36 @@ +impl Solution { + pub fn spellchecker(wordlist: Vec, queries: Vec) -> Vec { + use std::collections::{HashMap, HashSet}; + + let exact: HashSet = wordlist.iter().cloned().collect(); + let mut case_map = HashMap::new(); + let mut vowel_map = HashMap::new(); + + for w in &wordlist { + let lower = w.to_lowercase(); + let devowel = Self::de_vowel(&lower); + case_map.entry(lower.clone()).or_insert(w.clone()); + vowel_map.entry(devowel).or_insert(w.clone()); + } + + queries.iter().map(|q| { + if exact.contains(q) { + q.clone() + } else { + let lower = q.to_lowercase(); + let devowel = Self::de_vowel(&lower); + if let Some(matched) = case_map.get(&lower) { + matched.clone() + } else if let Some(matched) = vowel_map.get(&devowel) { + matched.clone() + } else { + String::new() + } + } + }).collect() + } + + fn de_vowel(s: &str) -> String { + s.chars().map(|c| if "aeiou".contains(c) { '*' } else { c }).collect() + } +} diff --git a/tests/501-1000/966. vowel-spellchecker/sol.swift b/tests/501-1000/966. vowel-spellchecker/sol.swift new file mode 100644 index 00000000..eededfb7 --- /dev/null +++ b/tests/501-1000/966. vowel-spellchecker/sol.swift @@ -0,0 +1,39 @@ +class Solution { + func spellchecker(_ wordlist: [String], _ queries: [String]) -> [String] { + let exact = Set(wordlist) + var caseMap = [String: String]() + var vowelMap = [String: String]() + + for w in wordlist { + let lower = w.lowercased() + let devowel = deVowel(lower) + if caseMap[lower] == nil { + caseMap[lower] = w + } + if vowelMap[devowel] == nil { + vowelMap[devowel] = w + } + } + + return queries.map { q in + if exact.contains(q) { + return q + } else { + let lower = q.lowercased() + let devowel = deVowel(lower) + if let match = caseMap[lower] { + return match + } else if let match = vowelMap[devowel] { + return match + } else { + return "" + } + } + } + } + + private func deVowel(_ s: String) -> String { + let vowels: Set = ["a", "e", "i", "o", "u"] + return String(s.map { vowels.contains($0) ? "*" : $0 }) + } +} diff --git a/tests/501-1000/966. vowel-spellchecker/sol.ts b/tests/501-1000/966. vowel-spellchecker/sol.ts new file mode 100644 index 00000000..06993abd --- /dev/null +++ b/tests/501-1000/966. vowel-spellchecker/sol.ts @@ -0,0 +1,39 @@ +function spellchecker(wordlist: string[], queries: string[]): string[] { + const exact = new Set(wordlist); + const caseMap = new Map(); + const vowelMap = new Map(); + + for (const w of wordlist) { + const lower = w.toLowerCase(); + const devowel = deVowel(lower); + if (!caseMap.has(lower)) { + caseMap.set(lower, w); + } + if (!vowelMap.has(devowel)) { + vowelMap.set(devowel, w); + } + } + + return queries.map((q) => { + if (exact.has(q)) { + return q; + } else { + const lower = q.toLowerCase(); + const devowel = deVowel(lower); + if (caseMap.has(lower)) { + return caseMap.get(lower)!; + } else if (vowelMap.has(devowel)) { + return vowelMap.get(devowel)!; + } else { + return ""; + } + } + }); +} + +function deVowel(s: string): string { + return s + .split("") + .map((c) => ("aeiou".includes(c) ? "*" : c)) + .join(""); +} diff --git a/tests/501-1000/967. numbers-with-same-consecutive-differences/manifest.yaml b/tests/501-1000/967. numbers-with-same-consecutive-differences/manifest.yaml new file mode 100644 index 00000000..df808a39 --- /dev/null +++ b/tests/501-1000/967. numbers-with-same-consecutive-differences/manifest.yaml @@ -0,0 +1,932 @@ +entry: + id: 967 + title: numbers-with-same-consecutive-differences + params: + n: + type: int + k: + type: int + call: + cpp: Solution().numsSameConsecDiff({n}, {k}) + rust: Solution::nums_same_consec_diff({n}, {k}) + python3: Solution().numsSameConsecDiff({n}, {k}) + python2: Solution().numsSameConsecDiff({n}, {k}) + ruby: nums_same_consec_diff({n}, {k}) + java: new Solution().numsSameConsecDiff({n}, {k}) + csharp: new Solution().NumsSameConsecDiff({n}, {k}) + kotlin: Solution().numsSameConsecDiff({n}, {k}) + go: numsSameConsecDiff({n}, {k}) + dart: Solution().numsSameConsecDiff({n}, {k}) + swift: Solution().numsSameConsecDiff({n}, {k}) + typescript: numsSameConsecDiff({n}, {k}) +judge: + type: ignore_order +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 967 +tests: + - name: case_1 + in: + n: 3 + k: 1 + out: + - 898 + - 654 + - 656 + - 787 + - 789 + - 543 + - 545 + - 676 + - 678 + - 432 + - 434 + - 565 + - 567 + - 321 + - 323 + - 454 + - 456 + - 210 + - 212 + - 343 + - 345 + - 987 + - 989 + - 101 + - 232 + - 234 + - 876 + - 878 + - 121 + - 123 + - 765 + - 767 + - name: case_2 + in: + n: 4 + k: 1 + out: + - 2321 + - 2323 + - 5654 + - 5656 + - 8987 + - 8989 + - 2343 + - 2345 + - 5676 + - 5678 + - 2101 + - 5432 + - 5434 + - 8765 + - 8767 + - 2121 + - 2123 + - 5454 + - 5456 + - 8787 + - 8789 + - 3432 + - 3434 + - 6765 + - 6767 + - 3454 + - 3456 + - 6787 + - 6789 + - 3210 + - 3212 + - 6543 + - 6545 + - 9876 + - 9878 + - 3232 + - 3234 + - 6565 + - 6567 + - 9898 + - 1210 + - 1212 + - 4543 + - 4545 + - 7876 + - 7878 + - 1232 + - 1234 + - 4565 + - 4567 + - 7898 + - 4321 + - 4323 + - 7654 + - 7656 + - 1010 + - 1012 + - 4343 + - 4345 + - 7676 + - 7678 + - name: case_3 + in: + n: 4 + k: 0 + out: + - 3333 + - 6666 + - 9999 + - 1111 + - 4444 + - 7777 + - 2222 + - 8888 + - 5555 + - name: case_4 + in: + n: 3 + k: 7 + out: + - 292 + - 929 + - 707 + - 818 + - 181 + - name: case_5 + in: + n: 4 + k: 0 + out: + - 3333 + - 6666 + - 9999 + - 1111 + - 4444 + - 7777 + - 2222 + - 8888 + - 5555 + - name: case_6 + in: + n: 6 + k: 9 + out: + - 909090 + - name: case_7 + in: + n: 6 + k: 1 + out: + - 876545 + - 654343 + - 654345 + - 876565 + - 876567 + - 234543 + - 234545 + - 456765 + - 456767 + - 234565 + - 234567 + - 678987 + - 678989 + - 456787 + - 456789 + - 212101 + - 434321 + - 434323 + - 212121 + - 212123 + - 656543 + - 656545 + - 434343 + - 434345 + - 343210 + - 343212 + - 878765 + - 878767 + - 121010 + - 121012 + - 210101 + - 656565 + - 656567 + - 565432 + - 565434 + - 343232 + - 432321 + - 343234 + - 432323 + - 878787 + - 878789 + - 787654 + - 787656 + - 210121 + - 210123 + - 565454 + - 654543 + - 565456 + - 654545 + - 432343 + - 432345 + - 787676 + - 876765 + - 787678 + - 876767 + - 654565 + - 654567 + - 876787 + - 876789 + - 123210 + - 123212 + - 345432 + - 345434 + - 123232 + - 212321 + - 123234 + - 212323 + - 567654 + - 567656 + - 345454 + - 434543 + - 345456 + - 434545 + - 789876 + - 789878 + - 212343 + - 212345 + - 121210 + - 121212 + - 656765 + - 567678 + - 656767 + - 567676 + - 434565 + - 434567 + - 343432 + - 343434 + - 878987 + - 789898 + - 878989 + - 121232 + - 121234 + - 656787 + - 656789 + - 565654 + - 565656 + - 343454 + - 343456 + - 787876 + - 787878 + - 565676 + - 565678 + - 787898 + - 543210 + - 543212 + - 321010 + - 321012 + - 765432 + - 765434 + - 543232 + - 543234 + - 987654 + - 987656 + - 765454 + - 765456 + - 987676 + - 987678 + - 123432 + - 123434 + - 345654 + - 345656 + - 123454 + - 123456 + - 567876 + - 567878 + - 345676 + - 345678 + - 567898 + - 323210 + - 323212 + - 101010 + - 101012 + - 545432 + - 545434 + - 323232 + - 323234 + - 232101 + - 767654 + - 767656 + - 545454 + - 545456 + - 454321 + - 454323 + - 989876 + - 989878 + - 232121 + - 321210 + - 232123 + - 321212 + - 767676 + - 767678 + - 676543 + - 676545 + - 454343 + - 543432 + - 454345 + - 543434 + - 989898 + - 898765 + - 898767 + - 321232 + - 321234 + - 676565 + - 765654 + - 676567 + - 765656 + - 543454 + - 543456 + - 898787 + - 987876 + - 898789 + - 987878 + - 765676 + - 765678 + - 987898 + - 234321 + - 234323 + - 101210 + - 101212 + - 456543 + - 456545 + - 234343 + - 323432 + - 234345 + - 323434 + - 678765 + - 678767 + - 101232 + - 101234 + - 456565 + - 545654 + - 456567 + - 545656 + - 323454 + - 323456 + - 232321 + - 232323 + - 678787 + - 678789 + - 767878 + - 767876 + - 545676 + - 545678 + - 454543 + - 454545 + - 232343 + - 232345 + - 767898 + - 676765 + - 676767 + - 454565 + - 454567 + - 898987 + - 898989 + - 676787 + - 676789 + - 432101 + - 654321 + - 654323 + - 432121 + - 432123 + - 876543 + - name: case_8 + in: + n: 2 + k: 3 + out: + - 69 + - 74 + - 14 + - 85 + - 25 + - 30 + - 96 + - 36 + - 41 + - 47 + - 52 + - 58 + - 63 + - name: case_9 + in: + n: 2 + k: 8 + out: + - 80 + - 19 + - 91 + - name: case_10 + in: + n: 3 + k: 6 + out: + - 393 + - 171 + - 939 + - 717 + - 282 + - 828 + - 606 + - name: case_11 + in: + n: 2 + k: 9 + out: + - 90 + - name: case_12 + in: + n: 4 + k: 0 + out: + - 3333 + - 6666 + - 9999 + - 1111 + - 4444 + - 7777 + - 2222 + - 8888 + - 5555 + - name: case_13 + in: + n: 2 + k: 9 + out: + - 90 + - name: case_14 + in: + n: 3 + k: 9 + out: + - 909 + - name: case_15 + in: + n: 4 + k: 4 + out: + - 2626 + - 5959 + - 4040 + - 7373 + - 4048 + - 9595 + - 8404 + - 3737 + - 5151 + - 8484 + - 5159 + - 4840 + - 1515 + - 9515 + - 4848 + - 5951 + - 6262 + - 1595 + - name: case_16 + in: + n: 4 + k: 4 + out: + - 2626 + - 5959 + - 4040 + - 7373 + - 4048 + - 9595 + - 8404 + - 3737 + - 5151 + - 8484 + - 5159 + - 4840 + - 1515 + - 9515 + - 4848 + - 5951 + - 6262 + - 1595 + - name: case_17 + in: + n: 4 + k: 8 + out: + - 9191 + - 8080 + - 1919 + - name: case_18 + in: + n: 2 + k: 4 + out: + - 73 + - 15 + - 84 + - 26 + - 95 + - 37 + - 40 + - 48 + - 51 + - 59 + - 62 + - name: case_19 + in: + n: 4 + k: 8 + out: + - 9191 + - 8080 + - 1919 + - name: case_20 + in: + n: 4 + k: 7 + out: + - 9292 + - 2929 + - 8181 + - 1818 + - 7070 + - name: case_21 + in: + n: 2 + k: 8 + out: + - 80 + - 19 + - 91 + - name: case_22 + in: + n: 5 + k: 2 + out: + - 13575 + - 13579 + - 46864 + - 20242 + - 46868 + - 75797 + - 20246 + - 35353 + - 53531 + - 35357 + - 53535 + - 68642 + - 42020 + - 68646 + - 97575 + - 42024 + - 97579 + - 75313 + - 24642 + - 24646 + - 53575 + - 13131 + - 53579 + - 68686 + - 13135 + - 86864 + - 31313 + - 46420 + - 86868 + - 46424 + - 75353 + - 75357 + - 24686 + - 57975 + - 31353 + - 57979 + - 31357 + - 46464 + - 64642 + - 46468 + - 64646 + - 79753 + - 24202 + - 53131 + - 79757 + - 53135 + - 86420 + - 86424 + - 35753 + - 35757 + - 64686 + - 24242 + - 42420 + - 79797 + - 24246 + - 97975 + - 42424 + - 97979 + - 57531 + - 57535 + - 86464 + - 86468 + - 64202 + - 35797 + - 13531 + - 13535 + - 42464 + - 42468 + - 57575 + - 75753 + - 20202 + - 57579 + - 75757 + - 35313 + - 64242 + - 64246 + - 97531 + - 97535 + - name: case_23 + in: + n: 4 + k: 7 + out: + - 9292 + - 2929 + - 8181 + - 1818 + - 7070 + - name: case_24 + in: + n: 5 + k: 5 + out: + - 27272 + - 50505 + - 49494 + - 72727 + - 16161 + - 94949 + - 38383 + - 61616 + - 83838 + - name: case_25 + in: + n: 6 + k: 3 + out: + - 303630 + - 147474 + - 303636 + - 414741 + - 363030 + - 258585 + - 414747 + - 363036 + - 474141 + - 525852 + - 630303 + - 369696 + - 525858 + - 474147 + - 585252 + - 636963 + - 741414 + - 636969 + - 585258 + - 696363 + - 852525 + - 963630 + - 696369 + - 963636 + - 303696 + - 630363 + - 630369 + - 741474 + - 141414 + - 852585 + - 252525 + - 363630 + - 963696 + - 363636 + - 474741 + - 474747 + - 585852 + - 585858 + - 696963 + - 696969 + - 636303 + - 747414 + - 858525 + - 969630 + - 141474 + - 969636 + - 252585 + - 363696 + - 303030 + - 303036 + - 414141 + - 414147 + - 525252 + - 525258 + - 636363 + - 636369 + - 747474 + - 147414 + - 963030 + - 858585 + - 963036 + - 258525 + - 369630 + - 969696 + - 369636 + - 696303 + - name: case_26 + in: + n: 3 + k: 1 + out: + - 898 + - 654 + - 656 + - 787 + - 789 + - 543 + - 545 + - 676 + - 678 + - 432 + - 434 + - 565 + - 567 + - 321 + - 323 + - 454 + - 456 + - 210 + - 212 + - 343 + - 345 + - 987 + - 989 + - 101 + - 232 + - 234 + - 876 + - 878 + - 121 + - 123 + - 765 + - 767 + - name: case_27 + in: + n: 5 + k: 9 + out: + - 90909 + - name: case_28 + in: + n: 2 + k: 3 + out: + - 69 + - 74 + - 14 + - 85 + - 25 + - 30 + - 96 + - 36 + - 41 + - 47 + - 52 + - 58 + - 63 + - name: case_29 + in: + n: 6 + k: 4 + out: + - 595959 + - 848404 + - 959515 + - 159515 + - 840484 + - 151595 + - 951595 + - 404040 + - 484040 + - 484048 + - 515151 + - 840404 + - 404048 + - 626262 + - 595151 + - 595159 + - 515159 + - 151515 + - 951515 + - 737373 + - 262626 + - 848484 + - 404840 + - 373737 + - 484840 + - 959595 + - 159595 + - 515951 + - 404848 + - 595951 + - 484848 + - 515959 + - name: case_30 + in: + n: 5 + k: 0 + out: + - 55555 + - 22222 + - 77777 + - 44444 + - 99999 + - 11111 + - 66666 + - 33333 + - 88888 + - name: case_31 + in: + n: 2 + k: 0 + out: + - 33 + - 66 + - 99 + - 11 + - 44 + - 77 + - 22 + - 55 + - 88 + - name: case_32 + in: + n: 6 + k: 5 + out: + - 161616 + - 272727 + - 505050 + - 383838 + - 616161 + - 494949 + - 727272 + - 838383 + - 949494 + - name: case_33 + in: + n: 5 + k: 5 + out: + - 27272 + - 50505 + - 49494 + - 72727 + - 16161 + - 94949 + - 38383 + - 61616 + - 83838 + - name: case_34 + in: + n: 6 + k: 5 + out: + - 161616 + - 272727 + - 505050 + - 383838 + - 616161 + - 494949 + - 727272 + - 838383 + - 949494 + - name: case_35 + in: + n: 3 + k: 5 + out: + - 838 + - 272 + - 727 + - 161 + - 616 + - 494 + - 949 + - 505 + - 383 diff --git a/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.cpp b/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.cpp new file mode 100644 index 00000000..0fbc1ff0 --- /dev/null +++ b/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.cpp @@ -0,0 +1,28 @@ +class Solution { +public: + vector numsSameConsecDiff(int n, int k) { + unordered_set res; + for (int x = 1; x <= 9; x++) { + res.insert(x); + } + n -= 1; + + while (n > 0) { + unordered_set next; + for (int val : res) { + int last = val % 10; + if (last + k < 10) { + next.insert(val * 10 + last + k); + } + if (last - k >= 0) { + next.insert(val * 10 + last - k); + } + } + res = next; + n -= 1; + } + + vector result(res.begin(), res.end()); + return result; + } +}; diff --git a/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.cs b/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.cs new file mode 100644 index 00000000..22eec2d6 --- /dev/null +++ b/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.cs @@ -0,0 +1,28 @@ +public class Solution { + public int[] NumsSameConsecDiff(int n, int k) { + var res = new HashSet(); + for (int x = 1; x <= 9; x++) { + res.Add(x); + } + n -= 1; + + while (n > 0) { + var next = new HashSet(); + foreach (int val in res) { + int last = val % 10; + if (last + k < 10) { + next.Add(val * 10 + last + k); + } + if (last - k >= 0) { + next.Add(val * 10 + last - k); + } + } + res = next; + n -= 1; + } + + int[] result = new int[res.Count]; + res.CopyTo(result); + return result; + } +} diff --git a/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.dart b/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.dart new file mode 100644 index 00000000..48c715ad --- /dev/null +++ b/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.dart @@ -0,0 +1,26 @@ +class Solution { + List numsSameConsecDiff(int n, int k) { + var res = {}; + for (int x = 1; x <= 9; x++) { + res.add(x); + } + n -= 1; + + while (n > 0) { + var next = {}; + for (int val in res) { + int last = val % 10; + if (last + k < 10) { + next.add(val * 10 + last + k); + } + if (last - k >= 0) { + next.add(val * 10 + last - k); + } + } + res = next; + n -= 1; + } + + return res.toList(); + } +} diff --git a/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.go b/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.go new file mode 100644 index 00000000..5b91ffe1 --- /dev/null +++ b/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.go @@ -0,0 +1,28 @@ +func numsSameConsecDiff(n int, k int) []int { + res := make(map[int]bool) + for x := 1; x <= 9; x++ { + res[x] = true + } + n -= 1 + + for n > 0 { + next := make(map[int]bool) + for val := range res { + last := val % 10 + if last + k < 10 { + next[val * 10 + last + k] = true + } + if last - k >= 0 { + next[val * 10 + last - k] = true + } + } + res = next + n -= 1 + } + + result := make([]int, 0, len(res)) + for val := range res { + result = append(result, val) + } + return result +} diff --git a/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.java b/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.java new file mode 100644 index 00000000..532d3dac --- /dev/null +++ b/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.java @@ -0,0 +1,31 @@ +class Solution { + public int[] numsSameConsecDiff(int n, int k) { + Set res = new HashSet<>(); + for (int x = 1; x <= 9; x++) { + res.add(x); + } + n -= 1; + + while (n > 0) { + Set next = new HashSet<>(); + for (int val : res) { + int last = val % 10; + if (last + k < 10) { + next.add(val * 10 + last + k); + } + if (last - k >= 0) { + next.add(val * 10 + last - k); + } + } + res = next; + n -= 1; + } + + int[] result = new int[res.size()]; + int i = 0; + for (int val : res) { + result[i++] = val; + } + return result; + } +} diff --git a/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.kt b/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.kt new file mode 100644 index 00000000..491012f2 --- /dev/null +++ b/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.kt @@ -0,0 +1,23 @@ +class Solution { + fun numsSameConsecDiff(n: Int, k: Int): IntArray { + var res = (1..9).toMutableSet() + var remaining = n - 1 + + while (remaining > 0) { + val next = mutableSetOf() + for (num in res) { + val last = num % 10 + if (last + k < 10) { + next.add(num * 10 + last + k) + } + if (last - k >= 0) { + next.add(num * 10 + last - k) + } + } + res = next + remaining -= 1 + } + + return res.toIntArray() + } +} diff --git a/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.py b/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.py new file mode 100644 index 00000000..905ff7f0 --- /dev/null +++ b/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.py @@ -0,0 +1,19 @@ +from typing import List + + +class Solution: + def numsSameConsecDiff(self, n: int, k: int) -> List[int]: + res = set(x for x in range(1, 10)) + n -= 1 + + while n: + for val in list(res): + res.remove(val) + last = val % 10 + if last + k < 10: + res.add(val * 10 + last + k) + if last - k >= 0: + res.add(val * 10 + last - k) + n -= 1 + + return list(res) diff --git a/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.py2 b/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.py2 new file mode 100644 index 00000000..0d9ea37a --- /dev/null +++ b/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.py2 @@ -0,0 +1,21 @@ +class Solution(object): + def numsSameConsecDiff(self, n, k): + """ + :type n: int + :type k: int + :rtype: List[int] + """ + res = set(x for x in range(1, 10)) + n -= 1 + + while n: + for val in list(res): + res.remove(val) + last = val % 10 + if last + k < 10: + res.add(val * 10 + last + k) + if last - k >= 0: + res.add(val * 10 + last - k) + n -= 1 + + return list(res) diff --git a/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.rb b/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.rb new file mode 100644 index 00000000..d9f07df6 --- /dev/null +++ b/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.rb @@ -0,0 +1,23 @@ +# @param {Integer} n +# @param {Integer} k +# @return {Integer[]} +def nums_same_consec_diff(n, k) + res = (1..9).to_set + n -= 1 + + while n > 0 + res.to_a.each do |val| + res.delete(val) + last = val % 10 + if last + k < 10 + res.add(val * 10 + last + k) + end + if last - k >= 0 + res.add(val * 10 + last - k) + end + end + n -= 1 + end + + res.to_a +end diff --git a/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.rs b/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.rs new file mode 100644 index 00000000..9dd3ea6b --- /dev/null +++ b/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.rs @@ -0,0 +1,24 @@ +impl Solution { + pub fn nums_same_consec_diff(n: i32, k: i32) -> Vec { + use std::collections::HashSet; + let mut res: HashSet = (1..=9).collect(); + let mut remaining = n - 1; + + while remaining > 0 { + let mut next = HashSet::new(); + for &val in &res { + let last = val % 10; + if last + k < 10 { + next.insert(val * 10 + last + k); + } + if last - k >= 0 { + next.insert(val * 10 + last - k); + } + } + res = next; + remaining -= 1; + } + + res.into_iter().collect() + } +} diff --git a/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.swift b/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.swift new file mode 100644 index 00000000..49ee51b6 --- /dev/null +++ b/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.swift @@ -0,0 +1,23 @@ +class Solution { + func numsSameConsecDiff(_ n: Int, _ k: Int) -> [Int] { + var res = Set(1...9) + var remaining = n - 1 + + while remaining > 0 { + var next = Set() + for val in res { + let last = val % 10 + if last + k < 10 { + next.insert(val * 10 + last + k) + } + if last - k >= 0 { + next.insert(val * 10 + last - k) + } + } + res = next + remaining -= 1 + } + + return Array(res) + } +} diff --git a/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.ts b/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.ts new file mode 100644 index 00000000..452bfbe3 --- /dev/null +++ b/tests/501-1000/967. numbers-with-same-consecutive-differences/sol.ts @@ -0,0 +1,24 @@ +function numsSameConsecDiff(n: number, k: number): number[] { + let res = new Set(); + for (let x = 1; x <= 9; x++) { + res.add(x); + } + n -= 1; + + while (n > 0) { + const next = new Set(); + for (const val of res) { + const last = val % 10; + if (last + k < 10) { + next.add(val * 10 + last + k); + } + if (last - k >= 0) { + next.add(val * 10 + last - k); + } + } + res = next; + n -= 1; + } + + return Array.from(res); +} diff --git a/tests/501-1000/968. binary-tree-cameras/manifest.yaml b/tests/501-1000/968. binary-tree-cameras/manifest.yaml new file mode 100644 index 00000000..7c219e43 --- /dev/null +++ b/tests/501-1000/968. binary-tree-cameras/manifest.yaml @@ -0,0 +1,395 @@ +entry: + id: 968 + title: binary-tree-cameras + params: + root: + type: tree_node + call: + cpp: Solution().minCameraCover({root}) + rust: Solution::min_camera_cover({root}) + python3: Solution().minCameraCover({root}) + python2: Solution().minCameraCover({root}) + ruby: min_camera_cover({root}) + java: new Solution().minCameraCover({root}) + csharp: new Solution().MinCameraCover({root}) + kotlin: Solution().minCameraCover({root}) + go: minCameraCover({root}) + dart: Solution().minCameraCover({root}) + swift: Solution().minCameraCover({root}) + typescript: minCameraCover({root}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 968 +tests: + - name: case_1 + in: + root: + - 1 + - null + - 7 + - 1 + - 4 + - 9 + - 8 + - 8 + - 5 + - null + - 5 + - 8 + out: 0 + - name: case_2 + in: + root: + - 2 + - 2 + - 0 + - 2 + out: 1 + - name: case_3 + in: + root: + - 7 + - 9 + - 2 + - null + - null + - 0 + - 2 + - null + - 4 + - null + - null + - 7 + - null + - 4 + - 1 + out: 1 + - name: case_4 + in: + root: + - 8 + - 2 + - 7 + - null + - 6 + - 4 + - 1 + - 2 + out: 0 + - name: case_5 + in: + root: + - 9 + - 8 + - 7 + - 3 + - 8 + - 7 + - 3 + out: 0 + - name: case_6 + in: + root: + - 3 + - 4 + - 9 + - null + - 0 + out: 1 + - name: case_7 + in: + root: + - 6 + out: 0 + - name: case_8 + in: + root: + - 6 + - 7 + - 8 + out: 0 + - name: case_9 + in: + root: + - 0 + - 8 + - null + - null + - 2 + - 7 + - 9 + out: 1 + - name: case_10 + in: + root: + - 2 + - null + - 1 + out: 0 + - name: case_11 + in: + root: + - 0 + - null + - 3 + out: 1 + - name: case_12 + in: + root: + - 9 + - null + - 2 + - 2 + - 9 + - 5 + out: 0 + - name: case_13 + in: + root: + - 9 + - 5 + - 6 + out: 0 + - name: case_14 + in: + root: + - 1 + - 3 + - 8 + out: 0 + - name: case_15 + in: + root: + - 8 + - 0 + - null + - null + - 5 + - 8 + - 6 + - null + - 0 + - 4 + out: 2 + - name: case_16 + in: + root: + - 8 + - 5 + - null + - 6 + - 6 + - 7 + - 6 + out: 0 + - name: case_17 + in: + root: + - 2 + out: 0 + - name: case_18 + in: + root: + - 2 + - 0 + - 0 + - 7 + - 9 + - 4 + out: 1 + - name: case_19 + in: + root: + - 1 + out: 0 + - name: case_20 + in: + root: + - 3 + - 0 + - 7 + - 1 + - null + - 8 + - 7 + - 6 + - 9 + - null + - 2 + out: 0 + - name: case_21 + in: + root: + - 9 + - 2 + - 7 + - 5 + - null + - 7 + - 8 + - 0 + - null + - 2 + out: 1 + - name: case_22 + in: + root: + - 9 + - null + - 0 + - null + - 9 + - 4 + - 5 + - 4 + - 3 + - 2 + - null + - 9 + - 1 + out: 1 + - name: case_23 + in: + root: + - 1 + - 2 + - 8 + - null + - 7 + out: 0 + - name: case_24 + in: + root: + - 2 + - 8 + - 9 + - 8 + - null + - null + - 1 + - 3 + - 4 + - 4 + - 4 + out: 0 + - name: case_25 + in: + root: + - 1 + - 8 + - 5 + - null + - 4 + - null + - 9 + - null + - 5 + - 4 + - 7 + out: 0 + - name: case_26 + in: + root: + - 7 + - 1 + - null + - 1 + - null + - 1 + - 0 + - 9 + - null + - 4 + out: 1 + - name: case_27 + in: + root: + - 0 + - 8 + - 6 + - 8 + - null + - null + - 3 + - 8 + - 0 + out: 2 + - name: case_28 + in: + root: + - 8 + - 1 + - null + - 8 + - 5 + - 3 + - null + - null + - 7 + - null + - null + - null + - 7 + out: 0 + - name: case_29 + in: + root: + - 2 + out: 0 + - name: case_30 + in: + root: + - 3 + - null + - 0 + - 0 + out: 1 + - name: case_31 + in: + root: + - 6 + - 2 + - 8 + - null + - 7 + - 5 + - 4 + - 5 + out: 0 + - name: case_32 + in: + root: + - 6 + - 8 + - 7 + - 3 + - 3 + - 9 + - 2 + out: 0 + - name: case_33 + in: + root: + - 5 + out: 0 + - name: case_34 + in: + root: + - 8 + - 9 + - 1 + - 2 + out: 0 + - name: case_35 + in: + root: + - 2 + - 7 + out: 0 diff --git a/tests/501-1000/968. binary-tree-cameras/sol.cpp b/tests/501-1000/968. binary-tree-cameras/sol.cpp new file mode 100644 index 00000000..711d750a --- /dev/null +++ b/tests/501-1000/968. binary-tree-cameras/sol.cpp @@ -0,0 +1,31 @@ +/** + * Definition for a binary tree node. + * struct TreeNode { + * int val; + * TreeNode *left; + * TreeNode *right; + * TreeNode() : val(0), left(nullptr), right(nullptr) {} + * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} + * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} + * }; + */ +class Solution { +public: + int minCameraCover(TreeNode* root) { + function dfs = [&](TreeNode* node) -> int { + if (!node) return 0; + int res = dfs(node->left) + dfs(node->right); + int curr = INT_MAX; + if (node->left) curr = min(curr, node->left->val); + if (node->right) curr = min(curr, node->right->val); + if (curr == 0) { + node->val = 1; + res += 1; + } else if (curr == 1) { + node->val = 2; + } + return res; + }; + return dfs(root) + (root->val == 0 ? 1 : 0); + } +}; diff --git a/tests/501-1000/968. binary-tree-cameras/sol.cs b/tests/501-1000/968. binary-tree-cameras/sol.cs new file mode 100644 index 00000000..0a1f2e65 --- /dev/null +++ b/tests/501-1000/968. binary-tree-cameras/sol.cs @@ -0,0 +1,32 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public int val; + * public TreeNode left; + * public TreeNode right; + * public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +public class Solution { + public int MinCameraCover(TreeNode root) { + int Dfs(TreeNode node) { + if (node == null) return 0; + int res = Dfs(node.left) + Dfs(node.right); + int curr = int.MaxValue; + if (node.left != null) curr = Math.Min(curr, node.left.val); + if (node.right != null) curr = Math.Min(curr, node.right.val); + if (curr == 0) { + node.val = 1; + res += 1; + } else if (curr == 1) { + node.val = 2; + } + return res; + } + return Dfs(root) + (root.val == 0 ? 1 : 0); + } +} diff --git a/tests/501-1000/968. binary-tree-cameras/sol.dart b/tests/501-1000/968. binary-tree-cameras/sol.dart new file mode 100644 index 00000000..6efbe82b --- /dev/null +++ b/tests/501-1000/968. binary-tree-cameras/sol.dart @@ -0,0 +1,32 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * int val; + * TreeNode? left; + * TreeNode? right; + * TreeNode([this.val = 0, this.left, this.right]); + * } + */ +class Solution { + int minCameraCover(TreeNode? root) { + int dfs(TreeNode? node) { + if (node == null) return 0; + int res = dfs(node.left) + dfs(node.right); + int curr = double.maxFinite.toInt(); + if (node.left != null && node.left!.val < curr) { + curr = node.left!.val; + } + if (node.right != null && node.right!.val < curr) { + curr = node.right!.val; + } + if (curr == 0) { + node.val = 1; + res += 1; + } else if (curr == 1) { + node.val = 2; + } + return res; + } + return dfs(root) + (root!.val == 0 ? 1 : 0); + } +} diff --git a/tests/501-1000/968. binary-tree-cameras/sol.go b/tests/501-1000/968. binary-tree-cameras/sol.go new file mode 100644 index 00000000..dd1e2d2d --- /dev/null +++ b/tests/501-1000/968. binary-tree-cameras/sol.go @@ -0,0 +1,36 @@ +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +func minCameraCover(root *TreeNode) int { + var dfs func(*TreeNode) int + dfs = func(node *TreeNode) int { + if node == nil { + return 0 + } + res := dfs(node.Left) + dfs(node.Right) + curr := int(^uint(0) >> 1) + if node.Left != nil && node.Left.Val < curr { + curr = node.Left.Val + } + if node.Right != nil && node.Right.Val < curr { + curr = node.Right.Val + } + if curr == 0 { + node.Val = 1 + res += 1 + } else if curr == 1 { + node.Val = 2 + } + return res + } + ans := dfs(root) + if root.Val == 0 { + ans += 1 + } + return ans +} diff --git a/tests/501-1000/968. binary-tree-cameras/sol.java b/tests/501-1000/968. binary-tree-cameras/sol.java new file mode 100644 index 00000000..96f5d124 --- /dev/null +++ b/tests/501-1000/968. binary-tree-cameras/sol.java @@ -0,0 +1,36 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode() {} + * TreeNode(int val) { this.val = val; } + * TreeNode(int val, TreeNode left, TreeNode right) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +class Solution { + public int minCameraCover(TreeNode root) { + return dfs(root) + (root.val == 0 ? 1 : 0); + } + + private int dfs(TreeNode node) { + if (node == null) return 0; + int res = dfs(node.left) + dfs(node.right); + int curr = Math.min( + node.left != null ? node.left.val : Integer.MAX_VALUE, + node.right != null ? node.right.val : Integer.MAX_VALUE + ); + if (curr == 0) { + node.val = 1; + res += 1; + } else if (curr == 1) { + node.val = 2; + } + return res; + } +} diff --git a/tests/501-1000/968. binary-tree-cameras/sol.kt b/tests/501-1000/968. binary-tree-cameras/sol.kt new file mode 100644 index 00000000..dcce1f0b --- /dev/null +++ b/tests/501-1000/968. binary-tree-cameras/sol.kt @@ -0,0 +1,30 @@ +/** + * Example: + * var ti = TreeNode(5) + * var v = ti.`val` + * Definition for a binary tree node. + * class TreeNode(var `val`: Int) { + * var left: TreeNode? = null + * var right: TreeNode? = null + * } + */ +class Solution { + fun minCameraCover(root: TreeNode?): Int { + fun dfs(node: TreeNode?): Int { + if (node == null) return 0 + val res = dfs(node.left) + dfs(node.right) + val curr = minOf( + node.left?.`val` ?: Int.MAX_VALUE, + node.right?.`val` ?: Int.MAX_VALUE + ) + if (curr == 0) { + node.`val` = 1 + return res + 1 + } else if (curr == 1) { + node.`val` = 2 + } + return res + } + return dfs(root) + (if (root?.`val` == 0) 1 else 0) + } +} diff --git a/tests/501-1000/968. binary-tree-cameras/sol.py b/tests/501-1000/968. binary-tree-cameras/sol.py new file mode 100644 index 00000000..d30bb732 --- /dev/null +++ b/tests/501-1000/968. binary-tree-cameras/sol.py @@ -0,0 +1,29 @@ +from typing import Optional + + +class Solution: + def minCameraCover(self, root: TreeNode) -> int: + # set the value of camera nodes to 1 + # set the value of monitored parent nodes to 2 + def dfs(node: Optional[TreeNode]) -> int: + if not node: + return 0 + res = dfs(node.left) + dfs(node.right) + # find out if current node is a root node / next node in line to be monitored + curr = min( + node.left.val if node.left else float("inf"), + node.right.val if node.right else float("inf"), + ) + if curr == 0: + # at least one child node requires monitoring, this node must have a camera + node.val = 1 + res += 1 + elif curr == 1: + # at least one child node is a camera, this node is already monitored + node.val = 2 + # if curr == float('inf'), the current node is a leaf node; let the parent node monitor this node + # if curr == 2, all child nodes are being monitored; treat the current node as a leaf node + return res + + # ensure that root node is monitored, otherwise, add a camera onto root node + return dfs(root) + (root.val == 0) diff --git a/tests/501-1000/968. binary-tree-cameras/sol.py2 b/tests/501-1000/968. binary-tree-cameras/sol.py2 new file mode 100644 index 00000000..2773afdd --- /dev/null +++ b/tests/501-1000/968. binary-tree-cameras/sol.py2 @@ -0,0 +1,27 @@ +# Definition for a binary tree node. +# class TreeNode(object): +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution(object): + def minCameraCover(self, root): + """ + :type root: Optional[TreeNode] + :rtype: int + """ + def dfs(node): + if not node: + return 0 + res = dfs(node.left) + dfs(node.right) + curr = min( + node.left.val if node.left else float('inf'), + node.right.val if node.right else float('inf'), + ) + if curr == 0: + node.val = 1 + res += 1 + elif curr == 1: + node.val = 2 + return res + return dfs(root) + (root.val == 0) diff --git a/tests/501-1000/968. binary-tree-cameras/sol.rb b/tests/501-1000/968. binary-tree-cameras/sol.rb new file mode 100644 index 00000000..14c926ec --- /dev/null +++ b/tests/501-1000/968. binary-tree-cameras/sol.rb @@ -0,0 +1,29 @@ +# Definition for a binary tree node. +# class TreeNode +# attr_accessor :val, :left, :right +# def initialize(val = 0, left = nil, right = nil) +# @val = val +# @left = left +# @right = right +# end +# end +# @param {TreeNode} root +# @return {Integer} +def min_camera_cover(root) + dfs = lambda do |node| + return 0 if node.nil? + res = dfs.call(node.left) + dfs.call(node.right) + curr = [ + node.left ? node.left.val : Float::INFINITY, + node.right ? node.right.val : Float::INFINITY + ].min + if curr == 0 + node.val = 1 + res += 1 + elsif curr == 1 + node.val = 2 + end + res + end + dfs.call(root) + (root.val == 0 ? 1 : 0) +end diff --git a/tests/501-1000/968. binary-tree-cameras/sol.rs b/tests/501-1000/968. binary-tree-cameras/sol.rs new file mode 100644 index 00000000..3437eb53 --- /dev/null +++ b/tests/501-1000/968. binary-tree-cameras/sol.rs @@ -0,0 +1,48 @@ +// Definition for a binary tree node. +// #[derive(Debug, PartialEq, Eq)] +// pub struct TreeNode { +// pub val: i32, +// pub left: Option>>, +// pub right: Option>>, +// } +// +// impl TreeNode { +// #[inline] +// pub fn new(val: i32) -> Self { +// TreeNode { +// val, +// left: None, +// right: None +// } +// } +// } +impl Solution { + pub fn min_camera_cover(root: Option>>) -> i32 { + fn dfs(node: &Option>>) -> i32 { + match node { + None => 0, + Some(n) => { + let mut node_ref = n.borrow_mut(); + let res = dfs(&node_ref.left) + dfs(&node_ref.right); + let mut curr = i32::MAX; + if let Some(left) = &node_ref.left { + curr = curr.min(left.borrow().val); + } + if let Some(right) = &node_ref.right { + curr = curr.min(right.borrow().val); + } + if curr == 0 { + node_ref.val = 1; + return res + 1; + } else if curr == 1 { + node_ref.val = 2; + } + res + } + } + } + let ans = dfs(&root); + let root_val = root.as_ref().unwrap().borrow().val; + ans + if root_val == 0 { 1 } else { 0 } + } +} diff --git a/tests/501-1000/968. binary-tree-cameras/sol.swift b/tests/501-1000/968. binary-tree-cameras/sol.swift new file mode 100644 index 00000000..5f96bcda --- /dev/null +++ b/tests/501-1000/968. binary-tree-cameras/sol.swift @@ -0,0 +1,34 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public var val: Int + * public var left: TreeNode? + * public var right: TreeNode? + * public init() { self.val = 0; self.left = nil; self.right = nil; } + * public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; } + * public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) { + * self.val = val + * self.left = left + * self.right = right + * } + * } + */ +class Solution { + func minCameraCover(_ root: TreeNode?) -> Int { + func dfs(_ node: TreeNode?) -> Int { + guard let node = node else { return 0 } + let res = dfs(node.left) + dfs(node.right) + var curr = Int.max + if let left = node.left { curr = min(curr, left.val) } + if let right = node.right { curr = min(curr, right.val) } + if curr == 0 { + node.val = 1 + return res + 1 + } else if curr == 1 { + node.val = 2 + } + return res + } + return dfs(root) + (root!.val == 0 ? 1 : 0) + } +} diff --git a/tests/501-1000/968. binary-tree-cameras/sol.ts b/tests/501-1000/968. binary-tree-cameras/sol.ts new file mode 100644 index 00000000..25c4ee44 --- /dev/null +++ b/tests/501-1000/968. binary-tree-cameras/sol.ts @@ -0,0 +1,31 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ + +function minCameraCover(root: TreeNode | null): number { + const dfs = (node: TreeNode | null): number => { + if (!node) return 0; + let res = dfs(node.left) + dfs(node.right); + let curr = Infinity; + if (node.left) curr = Math.min(curr, node.left.val); + if (node.right) curr = Math.min(curr, node.right.val); + if (curr === 0) { + node.val = 1; + res += 1; + } else if (curr === 1) { + node.val = 2; + } + return res; + }; + return dfs(root) + (root!.val === 0 ? 1 : 0); +} diff --git a/tests/501-1000/969. pancake-sorting/manifest.yaml b/tests/501-1000/969. pancake-sorting/manifest.yaml new file mode 100644 index 00000000..ec59396b --- /dev/null +++ b/tests/501-1000/969. pancake-sorting/manifest.yaml @@ -0,0 +1,313 @@ +entry: + id: 969 + title: pancake-sorting + params: + arr: + type: array + items: + type: int + call: + cpp: Solution().pancakeSort({arr}) + rust: Solution::pancake_sort({arr}) + python3: Solution().pancakeSort({arr}) + python2: Solution().pancakeSort({arr}) + ruby: pancake_sort({arr}) + java: new Solution().pancakeSort({arr}) + csharp: new Solution().PancakeSort({arr}) + kotlin: Solution().pancakeSort({arr}) + go: pancakeSort({arr}) + dart: Solution().pancakeSort({arr}) + swift: Solution().pancakeSort({arr}) + typescript: pancakeSort({arr}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().pancakeSort(arr, {result}) + checker: + "class Checker:\n def pancakeSort(self, arr, result):\n if\ + \ not isinstance(result, list):\n return False\n work = list(arr)\n\ + \ n = len(work)\n for k in result:\n if not isinstance(k,\ + \ int) or k < 1 or k > n:\n return False\n work[:k]\ + \ = reversed(work[:k])\n return work == sorted(arr)\n" +seed: 969 +tests: + - name: case_1 + in: + arr: + - 3 + - 1 + - 4 + - 5 + - 2 + - name: case_2 + in: + arr: + - 4 + - 2 + - 3 + - 5 + - 1 + - name: case_3 + in: + arr: + - 2 + - 4 + - 1 + - 3 + - name: case_4 + in: + arr: + - 1 + - 2 + - name: case_5 + in: + arr: + - 2 + - 3 + - 1 + - name: case_6 + in: + arr: + - 4 + - 3 + - 7 + - 1 + - 5 + - 6 + - 2 + - name: case_7 + in: + arr: + - 1 + - 7 + - 3 + - 6 + - 4 + - 5 + - 2 + - name: case_8 + in: + arr: + - 1 + - 3 + - 7 + - 4 + - 6 + - 5 + - 2 + - 8 + - name: case_9 + in: + arr: + - 2 + - 3 + - 1 + - 6 + - 5 + - 4 + - name: case_10 + in: + arr: + - 3 + - 2 + - 1 + - name: case_11 + in: + arr: + - 3 + - 7 + - 5 + - 1 + - 2 + - 8 + - 4 + - 6 + - name: case_12 + in: + arr: + - 1 + - 3 + - 2 + - name: case_13 + in: + arr: + - 2 + - 3 + - 5 + - 6 + - 4 + - 1 + - name: case_14 + in: + arr: + - 5 + - 1 + - 3 + - 8 + - 6 + - 4 + - 2 + - 7 + - name: case_15 + in: + arr: + - 2 + - 1 + - name: case_16 + in: + arr: + - 3 + - 1 + - 2 + - 4 + - name: case_17 + in: + arr: + - 8 + - 5 + - 7 + - 4 + - 2 + - 6 + - 3 + - 1 + - name: case_18 + in: + arr: + - 4 + - 5 + - 3 + - 2 + - 1 + - name: case_19 + in: + arr: + - 1 + - 5 + - 7 + - 3 + - 2 + - 4 + - 6 + - name: case_20 + in: + arr: + - 5 + - 2 + - 4 + - 3 + - 1 + - name: case_21 + in: + arr: + - 2 + - 1 + - 5 + - 6 + - 4 + - 3 + - name: case_22 + in: + arr: + - 5 + - 4 + - 1 + - 3 + - 2 + - name: case_23 + in: + arr: + - 2 + - 1 + - name: case_24 + in: + arr: + - 1 + - 2 + - 3 + - name: case_25 + in: + arr: + - 2 + - 6 + - 7 + - 3 + - 1 + - 5 + - 4 + - name: case_26 + in: + arr: + - 1 + - 6 + - 3 + - 4 + - 5 + - 2 + - name: case_27 + in: + arr: + - 1 + - name: case_28 + in: + arr: + - 6 + - 5 + - 1 + - 4 + - 3 + - 7 + - 8 + - 2 + - name: case_29 + in: + arr: + - 2 + - 1 + - name: case_30 + in: + arr: + - 1 + - 8 + - 6 + - 7 + - 4 + - 3 + - 5 + - 2 + - name: case_31 + in: + arr: + - 2 + - 1 + - 3 + - name: case_32 + in: + arr: + - 1 + - 2 + - 3 + - 4 + - name: case_33 + in: + arr: + - 1 + - name: case_34 + in: + arr: + - 2 + - 3 + - 1 + - name: case_35 + in: + arr: + - 6 + - 3 + - 1 + - 2 + - 4 + - 5 diff --git a/tests/501-1000/969. pancake-sorting/sol.cpp b/tests/501-1000/969. pancake-sorting/sol.cpp new file mode 100644 index 00000000..fc514a23 --- /dev/null +++ b/tests/501-1000/969. pancake-sorting/sol.cpp @@ -0,0 +1,33 @@ +class Solution { +public: + vector pancakeSort(vector& arr) { + int n = arr.size(); + vector result; + + for (int i = 0; i < n; i++) { + int target = n - i; + int position = 0; + + for (int j = 0; j < n - i; j++) { + if (arr[j] == target) { + position = j; + break; + } + } + + if (position == n - i - 1) { + continue; + } + + if (position > 0) { + result.push_back(position + 1); + reverse(arr.begin(), arr.begin() + position + 1); + } + + result.push_back(n - i); + reverse(arr.begin(), arr.begin() + n - i); + } + + return result; + } +}; diff --git a/tests/501-1000/969. pancake-sorting/sol.cs b/tests/501-1000/969. pancake-sorting/sol.cs new file mode 100644 index 00000000..de815516 --- /dev/null +++ b/tests/501-1000/969. pancake-sorting/sol.cs @@ -0,0 +1,32 @@ +public class Solution { + public IList PancakeSort(int[] arr) { + int n = arr.Length; + IList result = new List(); + + for (int i = 0; i < n; i++) { + int target = n - i; + int position = 0; + + for (int j = 0; j < n - i; j++) { + if (arr[j] == target) { + position = j; + break; + } + } + + if (position == n - i - 1) { + continue; + } + + if (position > 0) { + result.Add(position + 1); + Array.Reverse(arr, 0, position + 1); + } + + result.Add(n - i); + Array.Reverse(arr, 0, n - i); + } + + return result; + } +} diff --git a/tests/501-1000/969. pancake-sorting/sol.dart b/tests/501-1000/969. pancake-sorting/sol.dart new file mode 100644 index 00000000..7d1cd484 --- /dev/null +++ b/tests/501-1000/969. pancake-sorting/sol.dart @@ -0,0 +1,42 @@ +class Solution { + List pancakeSort(List arr) { + int n = arr.length; + List result = []; + + for (int i = 0; i < n; i++) { + int target = n - i; + int position = 0; + + for (int j = 0; j < n - i; j++) { + if (arr[j] == target) { + position = j; + break; + } + } + + if (position == n - i - 1) { + continue; + } + + if (position > 0) { + result.add(position + 1); + _reverse(arr, 0, position); + } + + result.add(n - i); + _reverse(arr, 0, n - i - 1); + } + + return result; + } + + void _reverse(List arr, int left, int right) { + while (left < right) { + int temp = arr[left]; + arr[left] = arr[right]; + arr[right] = temp; + left++; + right--; + } + } +} diff --git a/tests/501-1000/969. pancake-sorting/sol.go b/tests/501-1000/969. pancake-sorting/sol.go new file mode 100644 index 00000000..a0c72dac --- /dev/null +++ b/tests/501-1000/969. pancake-sorting/sol.go @@ -0,0 +1,38 @@ +func pancakeSort(arr []int) []int { + n := len(arr) + result := []int{} + + for i := 0; i < n; i++ { + target := n - i + position := 0 + + for j := 0; j < n - i; j++ { + if arr[j] == target { + position = j + break + } + } + + if position == n - i - 1 { + continue + } + + if position > 0 { + result = append(result, position + 1) + reverse(arr, 0, position) + } + + result = append(result, n - i) + reverse(arr, 0, n - i - 1) + } + + return result +} + +func reverse(arr []int, left, right int) { + for left < right { + arr[left], arr[right] = arr[right], arr[left] + left++ + right-- + } +} diff --git a/tests/501-1000/969. pancake-sorting/sol.java b/tests/501-1000/969. pancake-sorting/sol.java new file mode 100644 index 00000000..45d3717c --- /dev/null +++ b/tests/501-1000/969. pancake-sorting/sol.java @@ -0,0 +1,42 @@ +class Solution { + public List pancakeSort(int[] arr) { + int n = arr.length; + List result = new ArrayList<>(); + + for (int i = 0; i < n; i++) { + int target = n - i; + int position = 0; + + for (int j = 0; j < n - i; j++) { + if (arr[j] == target) { + position = j; + break; + } + } + + if (position == n - i - 1) { + continue; + } + + if (position > 0) { + result.add(position + 1); + reverse(arr, 0, position); + } + + result.add(n - i); + reverse(arr, 0, n - i - 1); + } + + return result; + } + + private void reverse(int[] arr, int left, int right) { + while (left < right) { + int temp = arr[left]; + arr[left] = arr[right]; + arr[right] = temp; + left++; + right--; + } + } +} diff --git a/tests/501-1000/969. pancake-sorting/sol.kt b/tests/501-1000/969. pancake-sorting/sol.kt new file mode 100644 index 00000000..cf16c3b3 --- /dev/null +++ b/tests/501-1000/969. pancake-sorting/sol.kt @@ -0,0 +1,44 @@ +class Solution { + fun pancakeSort(arr: IntArray): List { + val n = arr.size + val result = mutableListOf() + + for (i in 0 until n) { + val target = n - i + var position = 0 + + for (j in 0 until n - i) { + if (arr[j] == target) { + position = j + break + } + } + + if (position == n - i - 1) { + continue + } + + if (position > 0) { + result.add(position + 1) + arr.reverse(0, position) + } + + result.add(n - i) + arr.reverse(0, n - i - 1) + } + + return result + } + + private fun IntArray.reverse(start: Int, end: Int) { + var left = start + var right = end + while (left < right) { + val temp = this[left] + this[left] = this[right] + this[right] = temp + left++ + right-- + } + } +} diff --git a/tests/501-1000/969. pancake-sorting/sol.py b/tests/501-1000/969. pancake-sorting/sol.py new file mode 100644 index 00000000..f03a69a2 --- /dev/null +++ b/tests/501-1000/969. pancake-sorting/sol.py @@ -0,0 +1,30 @@ +class Solution(object): + def pancakeSort(self, arr): + n = len(arr) + result = [] + + # Iteratively place the largest unsorted values at their correct positions + for i in range(n): + target = n - i + position = 0 + + # Find the current target value's index within the unsorted range + for j in range(n - i): + if arr[j] == target: + position = j + break + + # Case 1: If the target element is already in place, skip flipping + if position == n - i - 1: + continue + + # Case 2: Bring the target element to the front of the array + if position > 0: + result.append(position + 1) + arr[: position + 1] = arr[: position + 1][::-1] + + # Case 3: Flip it down to its correct final position at the bottom + result.append(n - i) + arr[: n - i] = arr[: n - i][::-1] + + return result diff --git a/tests/501-1000/969. pancake-sorting/sol.py2 b/tests/501-1000/969. pancake-sorting/sol.py2 new file mode 100644 index 00000000..5201e728 --- /dev/null +++ b/tests/501-1000/969. pancake-sorting/sol.py2 @@ -0,0 +1,29 @@ +class Solution(object): + def pancakeSort(self, arr): + """ + :type arr: List[int] + :rtype: List[int] + """ + n = len(arr) + result = [] + + for i in range(n): + target = n - i + position = 0 + + for j in range(n - i): + if arr[j] == target: + position = j + break + + if position == n - i - 1: + continue + + if position > 0: + result.append(position + 1) + arr[:position + 1] = arr[:position + 1][::-1] + + result.append(n - i) + arr[:n - i] = arr[:n - i][::-1] + + return result diff --git a/tests/501-1000/969. pancake-sorting/sol.rb b/tests/501-1000/969. pancake-sorting/sol.rb new file mode 100644 index 00000000..6ff86531 --- /dev/null +++ b/tests/501-1000/969. pancake-sorting/sol.rb @@ -0,0 +1,32 @@ +# @param {Integer[]} arr +# @return {Integer[]} +def pancake_sort(arr) + n = arr.length + result = [] + + (0...n).each do |i| + target = n - i + position = 0 + + (0...n - i).each do |j| + if arr[j] == target + position = j + break + end + end + + if position == n - i - 1 + next + end + + if position > 0 + result << position + 1 + arr[0..position] = arr[0..position].reverse + end + + result << n - i + arr[0...n - i] = arr[0...n - i].reverse + end + + result +end diff --git a/tests/501-1000/969. pancake-sorting/sol.rs b/tests/501-1000/969. pancake-sorting/sol.rs new file mode 100644 index 00000000..cd9f34ff --- /dev/null +++ b/tests/501-1000/969. pancake-sorting/sol.rs @@ -0,0 +1,33 @@ +impl Solution { + pub fn pancake_sort(arr: Vec) -> Vec { + let mut arr = arr; + let n = arr.len(); + let mut result = Vec::new(); + + for i in 0..n { + let target = (n - i) as i32; + let mut position = 0; + + for j in 0..n - i { + if arr[j] == target { + position = j; + break; + } + } + + if position == n - i - 1 { + continue; + } + + if position > 0 { + result.push((position + 1) as i32); + arr[0..=position].reverse(); + } + + result.push((n - i) as i32); + arr[0..n - i].reverse(); + } + + result + } +} diff --git a/tests/501-1000/969. pancake-sorting/sol.swift b/tests/501-1000/969. pancake-sorting/sol.swift new file mode 100644 index 00000000..b9e3a8eb --- /dev/null +++ b/tests/501-1000/969. pancake-sorting/sol.swift @@ -0,0 +1,33 @@ +class Solution { + func pancakeSort(_ arr: [Int]) -> [Int] { + var arr = arr + let n = arr.count + var result = [Int]() + + for i in 0.. 0 { + result.append(position + 1) + arr[0...position].reverse() + } + + result.append(n - i) + arr[0.. 0) { + result.push(position + 1); + reverse(arr, 0, position); + } + + result.push(n - i); + reverse(arr, 0, n - i - 1); + } + + return result; +} + +function reverse(arr: number[], left: number, right: number): void { + while (left < right) { + const temp = arr[left]; + arr[left] = arr[right]; + arr[right] = temp; + left++; + right--; + } +} diff --git a/tests/501-1000/970. powerful-integers/manifest.yaml b/tests/501-1000/970. powerful-integers/manifest.yaml new file mode 100644 index 00000000..8b1fde04 --- /dev/null +++ b/tests/501-1000/970. powerful-integers/manifest.yaml @@ -0,0 +1,536 @@ +entry: + id: 970 + title: powerful-integers + params: + x: + type: int + y: + type: int + bound: + type: int + call: + cpp: Solution().powerfulIntegers({x}, {y}, {bound}) + rust: Solution::powerful_integers({x}, {y}, {bound}) + python3: Solution().powerfulIntegers({x}, {y}, {bound}) + python2: Solution().powerfulIntegers({x}, {y}, {bound}) + ruby: powerful_integers({x}, {y}, {bound}) + java: new Solution().powerfulIntegers({x}, {y}, {bound}) + csharp: new Solution().PowerfulIntegers({x}, {y}, {bound}) + kotlin: Solution().powerfulIntegers({x}, {y}, {bound}) + go: powerfulIntegers({x}, {y}, {bound}) + dart: Solution().powerfulIntegers({x}, {y}, {bound}) + swift: Solution().powerfulIntegers({x}, {y}, {bound}) + typescript: powerfulIntegers({x}, {y}, {bound}) +judge: + type: ignore_order +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 970 +tests: + - name: case_1 + in: + x: 4 + y: 2 + bound: 21 + out: + - 2 + - 3 + - 5 + - 6 + - 8 + - 9 + - 12 + - 17 + - 18 + - 20 + - name: case_2 + in: + x: 1 + y: 5 + bound: 10 + out: + - 2 + - 6 + - name: case_3 + in: + x: 2 + y: 4 + bound: 10 + out: + - 2 + - 3 + - 5 + - 6 + - 8 + - 9 + - name: case_4 + in: + x: 4 + y: 2 + bound: 34 + out: + - 32 + - 33 + - 2 + - 3 + - 5 + - 6 + - 8 + - 9 + - 12 + - 17 + - 18 + - 20 + - 24 + - name: case_5 + in: + x: 3 + y: 1 + bound: 82 + out: + - 2 + - 4 + - 10 + - 82 + - 28 + - name: case_6 + in: + x: 5 + y: 5 + bound: 6 + out: + - 2 + - 6 + - name: case_7 + in: + x: 4 + y: 2 + bound: 81 + out: + - 2 + - 3 + - 5 + - 6 + - 8 + - 9 + - 12 + - 17 + - 18 + - 20 + - 24 + - 32 + - 33 + - 36 + - 48 + - 65 + - 66 + - 68 + - 72 + - 80 + - name: case_8 + in: + x: 3 + y: 2 + bound: 1 + out: [] + - name: case_9 + in: + x: 1 + y: 5 + bound: 61 + out: + - 2 + - 26 + - 6 + - name: case_10 + in: + x: 3 + y: 1 + bound: 65 + out: + - 2 + - 10 + - 4 + - 28 + - name: case_11 + in: + x: 5 + y: 1 + bound: 69 + out: + - 2 + - 26 + - 6 + - name: case_12 + in: + x: 3 + y: 5 + bound: 4 + out: + - 2 + - 4 + - name: case_13 + in: + x: 5 + y: 5 + bound: 77 + out: + - 2 + - 6 + - 10 + - 50 + - 26 + - 30 + - name: case_14 + in: + x: 1 + y: 1 + bound: 23 + out: + - 2 + - name: case_15 + in: + x: 3 + y: 5 + bound: 70 + out: + - 32 + - 2 + - 34 + - 4 + - 6 + - 8 + - 10 + - 14 + - 52 + - 26 + - 28 + - name: case_16 + in: + x: 2 + y: 2 + bound: 58 + out: + - 2 + - 3 + - 4 + - 5 + - 6 + - 8 + - 9 + - 10 + - 12 + - 16 + - 17 + - 18 + - 20 + - 24 + - 32 + - 33 + - 34 + - 36 + - 40 + - 48 + - name: case_17 + in: + x: 5 + y: 4 + bound: 48 + out: + - 2 + - 5 + - 6 + - 9 + - 41 + - 17 + - 21 + - 26 + - 29 + - name: case_18 + in: + x: 5 + y: 1 + bound: 90 + out: + - 2 + - 26 + - 6 + - name: case_19 + in: + x: 1 + y: 2 + bound: 78 + out: + - 33 + - 2 + - 3 + - 65 + - 5 + - 9 + - 17 + - name: case_20 + in: + x: 4 + y: 4 + bound: 94 + out: + - 32 + - 65 + - 2 + - 68 + - 5 + - 8 + - 80 + - 17 + - 20 + - name: case_21 + in: + x: 4 + y: 3 + bound: 48 + out: + - 2 + - 4 + - 5 + - 7 + - 10 + - 43 + - 13 + - 17 + - 19 + - 25 + - 28 + - 31 + - name: case_22 + in: + x: 4 + y: 1 + bound: 9 + out: + - 2 + - 5 + - name: case_23 + in: + x: 2 + y: 5 + bound: 31 + out: + - 2 + - 3 + - 5 + - 6 + - 7 + - 9 + - 13 + - 17 + - 21 + - 26 + - 27 + - 29 + - name: case_24 + in: + x: 4 + y: 3 + bound: 40 + out: + - 2 + - 4 + - 5 + - 7 + - 10 + - 13 + - 17 + - 19 + - 25 + - 28 + - 31 + - name: case_25 + in: + x: 5 + y: 3 + bound: 12 + out: + - 2 + - 4 + - 6 + - 8 + - 10 + - name: case_26 + in: + x: 1 + y: 4 + bound: 28 + out: + - 17 + - 2 + - 5 + - name: case_27 + in: + x: 4 + y: 2 + bound: 26 + out: + - 2 + - 3 + - 5 + - 6 + - 8 + - 9 + - 12 + - 17 + - 18 + - 20 + - 24 + - name: case_28 + in: + x: 2 + y: 1 + bound: 77 + out: + - 33 + - 2 + - 3 + - 65 + - 5 + - 9 + - 17 + - name: case_29 + in: + x: 4 + y: 4 + bound: 46 + out: + - 32 + - 2 + - 5 + - 8 + - 17 + - 20 + - name: case_30 + in: + x: 2 + y: 3 + bound: 79 + out: + - 2 + - 3 + - 4 + - 5 + - 7 + - 9 + - 10 + - 11 + - 13 + - 17 + - 19 + - 25 + - 28 + - 29 + - 31 + - 33 + - 35 + - 41 + - 43 + - 59 + - 65 + - 67 + - 73 + - name: case_31 + in: + x: 2 + y: 2 + bound: 80 + out: + - 2 + - 3 + - 4 + - 5 + - 6 + - 8 + - 9 + - 10 + - 12 + - 16 + - 17 + - 18 + - 20 + - 24 + - 32 + - 33 + - 34 + - 36 + - 40 + - 48 + - 64 + - 65 + - 66 + - 68 + - 72 + - 80 + - name: case_32 + in: + x: 5 + y: 2 + bound: 54 + out: + - 33 + - 2 + - 3 + - 5 + - 6 + - 7 + - 37 + - 9 + - 41 + - 13 + - 17 + - 21 + - 26 + - 27 + - 29 + - name: case_33 + in: + x: 2 + y: 4 + bound: 39 + out: + - 32 + - 33 + - 2 + - 3 + - 36 + - 5 + - 6 + - 8 + - 9 + - 12 + - 17 + - 18 + - 20 + - 24 + - name: case_34 + in: + x: 1 + y: 5 + bound: 87 + out: + - 2 + - 26 + - 6 + - name: case_35 + in: + x: 5 + y: 5 + bound: 56 + out: + - 2 + - 6 + - 10 + - 50 + - 26 + - 30 diff --git a/tests/501-1000/970. powerful-integers/sol.cpp b/tests/501-1000/970. powerful-integers/sol.cpp new file mode 100644 index 00000000..7d4d2c7c --- /dev/null +++ b/tests/501-1000/970. powerful-integers/sol.cpp @@ -0,0 +1,20 @@ +class Solution { +public: + vector powerfulIntegers(int x, int y, int bound) { + unordered_set result; + int i = 1; + + while (i <= bound) { + int j = 1; + while (i + j <= bound) { + result.insert(i + j); + if (y == 1) break; + j *= y; + } + if (x == 1) break; + i *= x; + } + + return vector(result.begin(), result.end()); + } +}; diff --git a/tests/501-1000/970. powerful-integers/sol.cs b/tests/501-1000/970. powerful-integers/sol.cs new file mode 100644 index 00000000..36d875b7 --- /dev/null +++ b/tests/501-1000/970. powerful-integers/sol.cs @@ -0,0 +1,19 @@ +public class Solution { + public IList PowerfulIntegers(int x, int y, int bound) { + HashSet result = new HashSet(); + int i = 1; + + while (i <= bound) { + int j = 1; + while (i + j <= bound) { + result.Add(i + j); + if (y == 1) break; + j *= y; + } + if (x == 1) break; + i *= x; + } + + return result.ToList(); + } +} diff --git a/tests/501-1000/970. powerful-integers/sol.dart b/tests/501-1000/970. powerful-integers/sol.dart new file mode 100644 index 00000000..f37e4816 --- /dev/null +++ b/tests/501-1000/970. powerful-integers/sol.dart @@ -0,0 +1,19 @@ +class Solution { + List powerfulIntegers(int x, int y, int bound) { + Set result = {}; + int i = 1; + + while (i <= bound) { + int j = 1; + while (i + j <= bound) { + result.add(i + j); + if (y == 1) break; + j *= y; + } + if (x == 1) break; + i *= x; + } + + return result.toList(); + } +} diff --git a/tests/501-1000/970. powerful-integers/sol.go b/tests/501-1000/970. powerful-integers/sol.go new file mode 100644 index 00000000..5076ac0d --- /dev/null +++ b/tests/501-1000/970. powerful-integers/sol.go @@ -0,0 +1,25 @@ +func powerfulIntegers(x int, y int, bound int) []int { + result := make(map[int]bool) + i := 1 + + for i <= bound { + j := 1 + for i+j <= bound { + result[i+j] = true + if y == 1 { + break + } + j *= y + } + if x == 1 { + break + } + i *= x + } + + res := make([]int, 0, len(result)) + for k := range result { + res = append(res, k) + } + return res +} diff --git a/tests/501-1000/970. powerful-integers/sol.java b/tests/501-1000/970. powerful-integers/sol.java new file mode 100644 index 00000000..fe7ffb3f --- /dev/null +++ b/tests/501-1000/970. powerful-integers/sol.java @@ -0,0 +1,19 @@ +class Solution { + public List powerfulIntegers(int x, int y, int bound) { + Set result = new HashSet<>(); + int i = 1; + + while (i <= bound) { + int j = 1; + while (i + j <= bound) { + result.add(i + j); + if (y == 1) break; + j *= y; + } + if (x == 1) break; + i *= x; + } + + return new ArrayList<>(result); + } +} diff --git a/tests/501-1000/970. powerful-integers/sol.kt b/tests/501-1000/970. powerful-integers/sol.kt new file mode 100644 index 00000000..3944aa87 --- /dev/null +++ b/tests/501-1000/970. powerful-integers/sol.kt @@ -0,0 +1,19 @@ +class Solution { + fun powerfulIntegers(x: Int, y: Int, bound: Int): List { + val result = mutableSetOf() + var i = 1 + + while (i <= bound) { + var j = 1 + while (i + j <= bound) { + result.add(i + j) + if (y == 1) break + j *= y + } + if (x == 1) break + i *= x + } + + return result.toList() + } +} diff --git a/tests/501-1000/970. powerful-integers/sol.py b/tests/501-1000/970. powerful-integers/sol.py new file mode 100644 index 00000000..a612e4e7 --- /dev/null +++ b/tests/501-1000/970. powerful-integers/sol.py @@ -0,0 +1,26 @@ +from typing import List + + +class Solution(object): + def powerfulIntegers(self, x, y, bound): + """ + :type x: int + :type y: int + :type bound: int + :rtype: List[int] + """ + result = set() + i = 1 + + while i <= bound: + j = 1 + while i + j <= bound: + result.add(i + j) + if y == 1: + break + j *= y + if x == 1: + break + i *= x + + return list(result) diff --git a/tests/501-1000/970. powerful-integers/sol.py2 b/tests/501-1000/970. powerful-integers/sol.py2 new file mode 100644 index 00000000..97923637 --- /dev/null +++ b/tests/501-1000/970. powerful-integers/sol.py2 @@ -0,0 +1,21 @@ +class Solution(object): + def powerfulIntegers(self, x, y, bound): + """ + :type x: int + :type y: int + :type bound: int + :rtype: List[int] + """ + result = set() + i = 1 + + while i <= bound: + j = 1 + while i + j <= bound: + result.add(i + j) + if y == 1: break + j *= y + if x == 1: break + i *= x + + return list(result) diff --git a/tests/501-1000/970. powerful-integers/sol.rb b/tests/501-1000/970. powerful-integers/sol.rb new file mode 100644 index 00000000..0ecbacc0 --- /dev/null +++ b/tests/501-1000/970. powerful-integers/sol.rb @@ -0,0 +1,21 @@ +# @param {Integer} x +# @param {Integer} y +# @param {Integer} bound +# @return {Integer[]} +def powerful_integers(x, y, bound) + result = Set.new + i = 1 + + while i <= bound + j = 1 + while i + j <= bound + result.add(i + j) + break if y == 1 + j *= y + end + break if x == 1 + i *= x + end + + result.to_a +end diff --git a/tests/501-1000/970. powerful-integers/sol.rs b/tests/501-1000/970. powerful-integers/sol.rs new file mode 100644 index 00000000..13c271f7 --- /dev/null +++ b/tests/501-1000/970. powerful-integers/sol.rs @@ -0,0 +1,24 @@ +impl Solution { + pub fn powerful_integers(x: i32, y: i32, bound: i32) -> Vec { + use std::collections::HashSet; + let mut result = HashSet::new(); + let mut i = 1; + + while i <= bound { + let mut j = 1; + while i + j <= bound { + result.insert(i + j); + if y == 1 { + break; + } + j *= y; + } + if x == 1 { + break; + } + i *= x; + } + + result.into_iter().collect() + } +} diff --git a/tests/501-1000/970. powerful-integers/sol.swift b/tests/501-1000/970. powerful-integers/sol.swift new file mode 100644 index 00000000..b763c17d --- /dev/null +++ b/tests/501-1000/970. powerful-integers/sol.swift @@ -0,0 +1,19 @@ +class Solution { + func powerfulIntegers(_ x: Int, _ y: Int, _ bound: Int) -> [Int] { + var result = Set() + var i = 1 + + while i <= bound { + var j = 1 + while i + j <= bound { + result.insert(i + j) + if y == 1 { break } + j *= y + } + if x == 1 { break } + i *= x + } + + return Array(result) + } +} diff --git a/tests/501-1000/970. powerful-integers/sol.ts b/tests/501-1000/970. powerful-integers/sol.ts new file mode 100644 index 00000000..7d9065c9 --- /dev/null +++ b/tests/501-1000/970. powerful-integers/sol.ts @@ -0,0 +1,17 @@ +function powerfulIntegers(x: number, y: number, bound: number): number[] { + const result: Set = new Set(); + let i = 1; + + while (i <= bound) { + let j = 1; + while (i + j <= bound) { + result.add(i + j); + if (y === 1) break; + j *= y; + } + if (x === 1) break; + i *= x; + } + + return Array.from(result); +} diff --git a/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/manifest.yaml b/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/manifest.yaml new file mode 100644 index 00000000..fd9bfde1 --- /dev/null +++ b/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/manifest.yaml @@ -0,0 +1,551 @@ +entry: + id: 971 + title: flip-binary-tree-to-match-preorder-traversal + params: + root: + type: tree_node + voyage: + type: array + items: + type: int + call: + cpp: Solution().flipMatchVoyage({root}, {voyage}) + rust: Solution::flip_match_voyage({root}, {voyage}) + python3: Solution().flipMatchVoyage({root}, {voyage}) + python2: Solution().flipMatchVoyage({root}, {voyage}) + ruby: flip_match_voyage({root}, {voyage}) + java: new Solution().flipMatchVoyage({root}, {voyage}) + csharp: new Solution().FlipMatchVoyage({root}, {voyage}) + kotlin: Solution().flipMatchVoyage({root}, {voyage}) + go: flipMatchVoyage({root}, {voyage}) + dart: Solution().flipMatchVoyage({root}, {voyage}) + swift: Solution().flipMatchVoyage({root}, {voyage}) + typescript: flipMatchVoyage({root}, {voyage}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 971 +tests: + - name: case_1 + in: + root: + - 3 + - 0 + - 0 + - 6 + - null + - 15 + - 14 + - 14 + voyage: + - 3 + - 0 + - 6 + - 14 + - 0 + - 14 + - 15 + out: + - -1 + - name: case_2 + in: + root: + - 0 + - 5 + - 0 + - 5 + - 11 + voyage: + - 0 + - 5 + - 11 + - 5 + - 100 + out: + - -1 + - name: case_3 + in: + root: + - 19 + - 9 + - 17 + - 0 + - 12 + - null + - 2 + voyage: + - 19 + - 17 + - 2 + - 9 + - 0 + - 12 + out: + - 19 + - name: case_4 + in: + root: + - 2 + - null + - 2 + - 1 + - 1 + - null + - 10 + - 6 + - 19 + voyage: + - 2 + - 2 + - 1 + - 10 + - 1 + - 6 + - 119 + out: + - -1 + - name: case_5 + in: + root: + - 14 + - 2 + - 19 + - 15 + - 8 + - 7 + - 20 + - null + - 2 + voyage: + - 14 + - 2 + - 8 + - 15 + - 2 + - 19 + - 20 + - 107 + out: + - -1 + - name: case_6 + in: + root: + - 14 + - 1 + - 10 + - 0 + - 16 + - 2 + - 12 + - 7 + - null + - null + - 15 + voyage: + - 14 + - 10 + - 12 + - 2 + - 1 + - 0 + - 7 + - 16 + - 115 + out: + - -1 + - name: case_7 + in: + root: + - 14 + - null + - 5 + - null + - 18 + voyage: + - 14 + - 5 + - 18 + out: [] + - name: case_8 + in: + root: + - 4 + - 12 + - 3 + - 12 + - null + - 14 + - null + - 13 + voyage: + - 4 + - 3 + - 14 + - 12 + - 12 + - 13 + out: + - 4 + - name: case_9 + in: + root: + - 13 + - 3 + - 4 + - 19 + voyage: + - 13 + - 4 + - 3 + - 19 + out: + - 13 + - name: case_10 + in: + root: + - 2 + - 8 + - 19 + voyage: + - 2 + - 8 + - 19 + out: [] + - name: case_11 + in: + root: + - 1 + - null + - 10 + - null + - 1 + voyage: + - 1 + - 10 + - 1 + out: [] + - name: case_12 + in: + root: + - 9 + - 6 + - 15 + - 4 + - 20 + voyage: + - 9 + - 6 + - 20 + - 4 + - 15 + out: + - 6 + - name: case_13 + in: + root: + - 16 + - 0 + voyage: + - 16 + - 100 + out: + - -1 + - name: case_14 + in: + root: + - 5 + - 16 + voyage: + - 5 + - 16 + out: [] + - name: case_15 + in: + root: + - 7 + voyage: + - 7 + out: [] + - name: case_16 + in: + root: + - 10 + - 0 + - null + - 14 + voyage: + - 10 + - 0 + - 114 + out: + - -1 + - name: case_17 + in: + root: + - 15 + - 7 + - 20 + - 9 + - 14 + voyage: + - 15 + - 20 + - 7 + - 14 + - 109 + out: + - -1 + - name: case_18 + in: + root: + - 4 + voyage: + - 4 + out: [] + - name: case_19 + in: + root: + - 16 + - 14 + - 16 + - 8 + - 7 + voyage: + - 16 + - 16 + - 14 + - 7 + - 8 + out: + - 16 + - 14 + - name: case_20 + in: + root: + - 18 + - 2 + - 0 + voyage: + - 18 + - 0 + - 2 + out: + - 18 + - name: case_21 + in: + root: + - 15 + - 1 + - 20 + - 19 + - 19 + voyage: + - 15 + - 1 + - 19 + - 19 + - 20 + out: + - 1 + - name: case_22 + in: + root: + - 13 + - 15 + voyage: + - 13 + - 15 + out: [] + - name: case_23 + in: + root: + - 4 + - 2 + - null + - null + - 2 + - 8 + - 3 + - null + - 0 + - 3 + - null + - null + - 1 + - 3 + voyage: + - 4 + - 2 + - 2 + - 3 + - 3 + - 3 + - 8 + - 0 + - 1 + out: + - 2 + - name: case_24 + in: + root: + - 4 + voyage: + - 4 + out: [] + - name: case_25 + in: + root: + - 19 + - 6 + - 15 + - 17 + - 14 + - 15 + voyage: + - 19 + - 6 + - 14 + - 17 + - 15 + - 15 + out: + - 6 + - name: case_26 + in: + root: + - 14 + - null + - 4 + - 13 + - 3 + - 5 + - 1 + - 15 + voyage: + - 14 + - 4 + - 13 + - 5 + - 1 + - 3 + - 15 + out: [] + - name: case_27 + in: + root: + - 1 + voyage: + - 1 + out: [] + - name: case_28 + in: + root: + - 12 + - 19 + - 10 + voyage: + - 12 + - 19 + - 10 + out: [] + - name: case_29 + in: + root: + - 5 + - 8 + - null + - 19 + - 13 + voyage: + - 5 + - 8 + - 19 + - 113 + out: + - -1 + - name: case_30 + in: + root: + - 18 + - 12 + - 14 + voyage: + - 18 + - 12 + - 14 + out: [] + - name: case_31 + in: + root: + - 1 + - 10 + - 5 + voyage: + - 1 + - 10 + - 105 + out: + - -1 + - name: case_32 + in: + root: + - 19 + - 18 + - 19 + - 7 + - 19 + voyage: + - 19 + - 18 + - 19 + - 7 + - 19 + out: + - 18 + - name: case_33 + in: + root: + - 0 + - 19 + - 11 + - 6 + voyage: + - 0 + - 19 + - 6 + - 111 + out: + - -1 + - name: case_34 + in: + root: + - 8 + - 18 + - null + - 0 + - 18 + - null + - 12 + - 12 + voyage: + - 8 + - 18 + - 0 + - 12 + - 18 + - 12 + out: [] + - name: case_35 + in: + root: + - 14 + voyage: + - 114 + out: + - -1 diff --git a/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.cpp b/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.cpp new file mode 100644 index 00000000..89882207 --- /dev/null +++ b/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.cpp @@ -0,0 +1,53 @@ +/** + * Definition for a binary tree node. + * struct TreeNode { + * int val; + * TreeNode *left; + * TreeNode *right; + * TreeNode() : val(0), left(nullptr), right(nullptr) {} + * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} + * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} + * }; + */ +class Solution { +private: + vector flippedNodes; + int idx; + vector* voyagePtr; + + bool dfs(TreeNode* node) { + if (node == nullptr) return true; + if (node->val != (*voyagePtr)[idx]) return false; + + idx++; + if (node->left && node->right) { + if ((*voyagePtr)[idx] == node->right->val) { + flippedNodes.push_back(node->val); + if (!dfs(node->right)) return false; + if (!dfs(node->left)) return false; + } else if ((*voyagePtr)[idx] == node->left->val) { + if (!dfs(node->left)) return false; + if (!dfs(node->right)) return false; + } else { + return false; + } + } else { + if (node->left) { + if (!dfs(node->left)) return false; + } else if (node->right) { + if (!dfs(node->right)) return false; + } + } + return true; + } + +public: + vector flipMatchVoyage(TreeNode* root, vector& voyage) { + flippedNodes.clear(); + idx = 0; + voyagePtr = &voyage; + + if (!dfs(root)) return {-1}; + return flippedNodes; + } +}; diff --git a/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.cs b/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.cs new file mode 100644 index 00000000..d965eced --- /dev/null +++ b/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.cs @@ -0,0 +1,53 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public int val; + * public TreeNode left; + * public TreeNode right; + * public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +public class Solution { + private List flippedNodes; + private int idx; + private int[] voyage; + + public IList FlipMatchVoyage(TreeNode root, int[] voyage) { + flippedNodes = new List(); + idx = 0; + this.voyage = voyage; + + if (!Dfs(root)) return new List { -1 }; + return flippedNodes; + } + + private bool Dfs(TreeNode node) { + if (node == null) return true; + if (node.val != voyage[idx]) return false; + + idx++; + if (node.left != null && node.right != null) { + if (voyage[idx] == node.right.val) { + flippedNodes.Add(node.val); + if (!Dfs(node.right)) return false; + if (!Dfs(node.left)) return false; + } else if (voyage[idx] == node.left.val) { + if (!Dfs(node.left)) return false; + if (!Dfs(node.right)) return false; + } else { + return false; + } + } else { + if (node.left != null) { + if (!Dfs(node.left)) return false; + } else if (node.right != null) { + if (!Dfs(node.right)) return false; + } + } + return true; + } +} diff --git a/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.dart b/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.dart new file mode 100644 index 00000000..07071146 --- /dev/null +++ b/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.dart @@ -0,0 +1,44 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * int val; + * TreeNode? left; + * TreeNode? right; + * TreeNode([this.val = 0, this.left, this.right]); + * } + */ +class Solution { + List flipMatchVoyage(TreeNode? root, List voyage) { + List flippedNodes = []; + int idx = 0; + + bool dfs(TreeNode? node) { + if (node == null) return true; + if (node.val != voyage[idx]) return false; + + idx++; + if (node.left != null && node.right != null) { + if (voyage[idx] == node.right!.val) { + flippedNodes.add(node.val); + if (!dfs(node.right)) return false; + if (!dfs(node.left)) return false; + } else if (voyage[idx] == node.left!.val) { + if (!dfs(node.left)) return false; + if (!dfs(node.right)) return false; + } else { + return false; + } + } else { + if (node.left != null) { + if (!dfs(node.left)) return false; + } else if (node.right != null) { + if (!dfs(node.right)) return false; + } + } + return true; + } + + if (!dfs(root)) return [-1]; + return flippedNodes; + } +} diff --git a/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.go b/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.go new file mode 100644 index 00000000..58eca488 --- /dev/null +++ b/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.go @@ -0,0 +1,60 @@ +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +func flipMatchVoyage(root *TreeNode, voyage []int) []int { + flippedNodes := []int{} + idx := 0 + + var dfs func(*TreeNode) bool + dfs = func(node *TreeNode) bool { + if node == nil { + return true + } + if node.Val != voyage[idx] { + return false + } + + idx++ + if node.Left != nil && node.Right != nil { + if voyage[idx] == node.Right.Val { + flippedNodes = append(flippedNodes, node.Val) + if !dfs(node.Right) { + return false + } + if !dfs(node.Left) { + return false + } + } else if voyage[idx] == node.Left.Val { + if !dfs(node.Left) { + return false + } + if !dfs(node.Right) { + return false + } + } else { + return false + } + } else { + if node.Left != nil { + if !dfs(node.Left) { + return false + } + } else if node.Right != nil { + if !dfs(node.Right) { + return false + } + } + } + return true + } + + if !dfs(root) { + return []int{-1} + } + return flippedNodes +} diff --git a/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.java b/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.java new file mode 100644 index 00000000..c1ebd2f3 --- /dev/null +++ b/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.java @@ -0,0 +1,59 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode() {} + * TreeNode(int val) { this.val = val; } + * TreeNode(int val, TreeNode left, TreeNode right) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +class Solution { + private List flippedNodes; + private int idx; + private int[] voyage; + + public List flipMatchVoyage(TreeNode root, int[] voyage) { + flippedNodes = new ArrayList<>(); + idx = 0; + this.voyage = voyage; + + if (!dfs(root)) { + List result = new ArrayList<>(); + result.add(-1); + return result; + } + return flippedNodes; + } + + private boolean dfs(TreeNode node) { + if (node == null) return true; + if (node.val != voyage[idx]) return false; + + idx++; + if (node.left != null && node.right != null) { + if (voyage[idx] == node.right.val) { + flippedNodes.add(node.val); + if (!dfs(node.right)) return false; + if (!dfs(node.left)) return false; + } else if (voyage[idx] == node.left.val) { + if (!dfs(node.left)) return false; + if (!dfs(node.right)) return false; + } else { + return false; + } + } else { + if (node.left != null) { + if (!dfs(node.left)) return false; + } else if (node.right != null) { + if (!dfs(node.right)) return false; + } + } + return true; + } +} diff --git a/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.kt b/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.kt new file mode 100644 index 00000000..5d1c7ec7 --- /dev/null +++ b/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.kt @@ -0,0 +1,50 @@ +/** + * Example: + * var ti = TreeNode(5) + * var v = ti.`val` + * Definition for a binary tree node. + * class TreeNode(var `val`: Int) { + * var left: TreeNode? = null + * var right: TreeNode? = null + * } + */ +class Solution { + private val flippedNodes = mutableListOf() + private var idx = 0 + private lateinit var voyage: IntArray + + fun flipMatchVoyage(root: TreeNode?, voyage: IntArray): List { + flippedNodes.clear() + idx = 0 + this.voyage = voyage + + if (!dfs(root)) return listOf(-1) + return flippedNodes + } + + private fun dfs(node: TreeNode?): Boolean { + if (node == null) return true + if (node.`val` != voyage[idx]) return false + + idx++ + if (node.left != null && node.right != null) { + if (voyage[idx] == node.right!!.`val`) { + flippedNodes.add(node.`val`) + if (!dfs(node.right)) return false + if (!dfs(node.left)) return false + } else if (voyage[idx] == node.left!!.`val`) { + if (!dfs(node.left)) return false + if (!dfs(node.right)) return false + } else { + return false + } + } else { + if (node.left != null) { + if (!dfs(node.left)) return false + } else if (node.right != null) { + if (!dfs(node.right)) return false + } + } + return true + } +} diff --git a/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.py b/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.py new file mode 100644 index 00000000..b301f755 --- /dev/null +++ b/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.py @@ -0,0 +1,55 @@ +# Definition for a binary tree node. +# class TreeNode: +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +from typing import List, Optional + + +class Solution: + def flipMatchVoyage(self, root: Optional[TreeNode], voyage: List[int]) -> List[int]: + flipped_nodes = [] + + idx = 0 + + def dfs(node): + nonlocal idx + if node.val != voyage[idx]: + # impossible + return False + + idx += 1 + if node.left and node.right: + # two children exist + if voyage[idx] == node.right.val: + # flip needed + flipped_nodes.append(node.val) + if not dfs(node.right): + return False + if not dfs(node.left): + return False + elif voyage[idx] == node.left.val: + # no flip needed + if not dfs(node.left): + return False + if not dfs(node.right): + return False + else: + # neither matched + return False + else: + # only 1 or no child + if node.left: + if not dfs(node.left): + return False + elif node.right: + if not dfs(node.right): + return False + + return True + + if not dfs(root): + return [-1] + + return flipped_nodes diff --git a/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.py2 b/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.py2 new file mode 100644 index 00000000..b3a15257 --- /dev/null +++ b/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.py2 @@ -0,0 +1,50 @@ +# Definition for a binary tree node. +# class TreeNode(object): +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution(object): + def flipMatchVoyage(self, root, voyage): + """ + :type root: Optional[TreeNode] + :type voyage: List[int] + :rtype: List[int] + """ + flipped_nodes = [] + idx = [0] + + def dfs(node): + if node is None: + return True + if node.val != voyage[idx[0]]: + return False + + idx[0] += 1 + if node.left and node.right: + if voyage[idx[0]] == node.right.val: + flipped_nodes.append(node.val) + if not dfs(node.right): + return False + if not dfs(node.left): + return False + elif voyage[idx[0]] == node.left.val: + if not dfs(node.left): + return False + if not dfs(node.right): + return False + else: + return False + else: + if node.left: + if not dfs(node.left): + return False + elif node.right: + if not dfs(node.right): + return False + + return True + + if not dfs(root): + return [-1] + return flipped_nodes diff --git a/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.rb b/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.rb new file mode 100644 index 00000000..c462940a --- /dev/null +++ b/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.rb @@ -0,0 +1,45 @@ +# Definition for a binary tree node. +# class TreeNode +# attr_accessor :val, :left, :right +# def initialize(val = 0, left = nil, right = nil) +# @val = val +# @left = left +# @right = right +# end +# end +# @param {TreeNode} root +# @param {Integer[]} voyage +# @return {Integer[]} +def flip_match_voyage(root, voyage) + flipped_nodes = [] + @idx = 0 + + dfs = lambda do |node| + return true if node.nil? + return false if node.val != voyage[@idx] + + @idx += 1 + if node.left && node.right + if voyage[@idx] == node.right.val + flipped_nodes << node.val + return false unless dfs.call(node.right) + return false unless dfs.call(node.left) + elsif voyage[@idx] == node.left.val + return false unless dfs.call(node.left) + return false unless dfs.call(node.right) + else + return false + end + else + if node.left + return false unless dfs.call(node.left) + elsif node.right + return false unless dfs.call(node.right) + end + end + true + end + + return [-1] unless dfs.call(root) + flipped_nodes +end diff --git a/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.rs b/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.rs new file mode 100644 index 00000000..dbf43202 --- /dev/null +++ b/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.rs @@ -0,0 +1,81 @@ +// Definition for a binary tree node. +// #[derive(Debug, PartialEq, Eq)] +// pub struct TreeNode { +// pub val: i32, +// pub left: Option>>, +// pub right: Option>>, +// } +// +// impl TreeNode { +// #[inline] +// pub fn new(val: i32) -> Self { +// TreeNode { +// val, +// left: None, +// right: None +// } +// } +// } +impl Solution { + pub fn flip_match_voyage(root: Option>>, voyage: Vec) -> Vec { + let mut flipped_nodes = Vec::new(); + let mut idx = 0; + + fn dfs( + node: &Option>>, + voyage: &Vec, + idx: &mut usize, + flipped_nodes: &mut Vec + ) -> bool { + match node { + None => true, + Some(n) => { + let n = n.borrow(); + if n.val != voyage[*idx] { + return false; + } + *idx += 1; + + if n.left.is_some() && n.right.is_some() { + let right_val = n.right.as_ref().unwrap().borrow().val; + let left_val = n.left.as_ref().unwrap().borrow().val; + if voyage[*idx] == right_val { + flipped_nodes.push(n.val); + if !dfs(&n.right, voyage, idx, flipped_nodes) { + return false; + } + if !dfs(&n.left, voyage, idx, flipped_nodes) { + return false; + } + } else if voyage[*idx] == left_val { + if !dfs(&n.left, voyage, idx, flipped_nodes) { + return false; + } + if !dfs(&n.right, voyage, idx, flipped_nodes) { + return false; + } + } else { + return false; + } + } else { + if n.left.is_some() { + if !dfs(&n.left, voyage, idx, flipped_nodes) { + return false; + } + } else if n.right.is_some() { + if !dfs(&n.right, voyage, idx, flipped_nodes) { + return false; + } + } + } + true + } + } + } + + if !dfs(&root, &voyage, &mut idx, &mut flipped_nodes) { + return vec![-1]; + } + flipped_nodes + } +} diff --git a/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.swift b/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.swift new file mode 100644 index 00000000..ba7200e4 --- /dev/null +++ b/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.swift @@ -0,0 +1,50 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public var val: Int + * public var left: TreeNode? + * public var right: TreeNode? + * public init() { self.val = 0; self.left = nil; self.right = nil; } + * public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; } + * public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) { + * self.val = val + * self.left = left + * self.right = right + * } + * } + */ +class Solution { + func flipMatchVoyage(_ root: TreeNode?, _ voyage: [Int]) -> [Int] { + var flippedNodes = [Int]() + var idx = 0 + + func dfs(_ node: TreeNode?) -> Bool { + guard let node = node else { return true } + guard node.val == voyage[idx] else { return false } + + idx += 1 + if let left = node.left, let right = node.right { + if voyage[idx] == right.val { + flippedNodes.append(node.val) + guard dfs(node.right) else { return false } + guard dfs(node.left) else { return false } + } else if voyage[idx] == left.val { + guard dfs(node.left) else { return false } + guard dfs(node.right) else { return false } + } else { + return false + } + } else { + if let left = node.left { + guard dfs(left) else { return false } + } else if let right = node.right { + guard dfs(right) else { return false } + } + } + return true + } + + guard dfs(root) else { return [-1] } + return flippedNodes + } +} diff --git a/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.ts b/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.ts new file mode 100644 index 00000000..16ddf388 --- /dev/null +++ b/tests/501-1000/971. flip-binary-tree-to-match-preorder-traversal/sol.ts @@ -0,0 +1,47 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ + +function flipMatchVoyage(root: TreeNode | null, voyage: number[]): number[] { + const flippedNodes: number[] = []; + let idx = 0; + + function dfs(node: TreeNode | null): boolean { + if (node === null) return true; + if (node.val !== voyage[idx]) return false; + + idx++; + if (node.left !== null && node.right !== null) { + if (voyage[idx] === node.right.val) { + flippedNodes.push(node.val); + if (!dfs(node.right)) return false; + if (!dfs(node.left)) return false; + } else if (voyage[idx] === node.left.val) { + if (!dfs(node.left)) return false; + if (!dfs(node.right)) return false; + } else { + return false; + } + } else { + if (node.left !== null) { + if (!dfs(node.left)) return false; + } else if (node.right !== null) { + if (!dfs(node.right)) return false; + } + } + return true; + } + + if (!dfs(root)) return [-1]; + return flippedNodes; +} diff --git a/tests/501-1000/972. equal-rational-numbers/manifest.yaml b/tests/501-1000/972. equal-rational-numbers/manifest.yaml new file mode 100644 index 00000000..8fac6c18 --- /dev/null +++ b/tests/501-1000/972. equal-rational-numbers/manifest.yaml @@ -0,0 +1,207 @@ +entry: + id: 972 + title: equal-rational-numbers + params: + s: + type: string + t: + type: string + call: + cpp: Solution().isRationalEqual({s}, {t}) + rust: Solution::is_rational_equal({s}, {t}) + python3: Solution().isRationalEqual({s}, {t}) + python2: Solution().isRationalEqual({s}, {t}) + ruby: is_rational_equal({s}, {t}) + java: new Solution().isRationalEqual({s}, {t}) + csharp: new Solution().IsRationalEqual({s}, {t}) + kotlin: Solution().isRationalEqual({s}, {t}) + go: isRationalEqual({s}, {t}) + dart: Solution().isRationalEqual({s}, {t}) + swift: Solution().isRationalEqual({s}, {t}) + typescript: isRationalEqual({s}, {t}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 972 +tests: + - name: case_1 + in: + s: 0.(52) + t: 0.5(25) + out: true + - name: case_2 + in: + s: 0.1666(6) + t: 0.166(66) + out: true + - name: case_3 + in: + s: 0.9(9) + t: "1." + out: true + - name: case_4 + in: + s: 1.0(0) + t: "1." + out: true + - name: case_5 + in: + s: 0.(3) + t: 0.3(3) + out: true + - name: case_6 + in: + s: 0.1(6) + t: 0.16(6) + out: true + - name: case_7 + in: + s: 2.12(34) + t: 2.1234(34) + out: true + - name: case_8 + in: + s: 0.0(9) + t: "0.1" + out: true + - name: case_9 + in: + s: 3.(142857) + t: 3.(142857) + out: true + - name: case_10 + in: + s: 0.2(9) + t: "0.3" + out: true + - name: case_11 + in: + s: 2.(11) + t: 1.65(4) + out: false + - name: case_12 + in: + s: 3.82(1) + t: 3.82(1) + out: true + - name: case_13 + in: + s: 0.9(24) + t: 0.9(24) + out: true + - name: case_14 + in: + s: 3.76(1) + t: 3.0(09) + out: false + - name: case_15 + in: + s: 2.(248) + t: 2.(239) + out: false + - name: case_16 + in: + s: 1.(28) + t: 0.4(036) + out: false + - name: case_17 + in: + s: 3.0(793) + t: 2.17(3) + out: false + - name: case_18 + in: + s: 2.(0) + t: 2.(58) + out: false + - name: case_19 + in: + s: 1.15(9) + t: 1.15(9) + out: true + - name: case_20 + in: + s: 2.2(346) + t: 0.(66) + out: false + - name: case_21 + in: + s: 0.36(8) + t: 0.36(8) + out: true + - name: case_22 + in: + s: 2.(1) + t: 2.73(6) + out: false + - name: case_23 + in: + s: 0.(589) + t: 0.8(296) + out: false + - name: case_24 + in: + s: 2.(209) + t: 3.0(1) + out: false + - name: case_25 + in: + s: 1.3(13) + t: 3.85(29) + out: false + - name: case_26 + in: + s: 1.(7) + t: 1.(7) + out: true + - name: case_27 + in: + s: 0.(2) + t: 0.3(21) + out: false + - name: case_28 + in: + s: 2.(720) + t: 3.05(9) + out: false + - name: case_29 + in: + s: 3.(535) + t: 0.44(765) + out: false + - name: case_30 + in: + s: 3.40(22) + t: 1.22(5) + out: false + - name: case_31 + in: + s: 2.04(257) + t: 2.04(257) + out: true + - name: case_32 + in: + s: 1.(5) + t: 1.5(8) + out: false + - name: case_33 + in: + s: 2.88(27) + t: 2.88(27) + out: true + - name: case_34 + in: + s: 2.7(04) + t: 2.7(04) + out: true + - name: case_35 + in: + s: 3.(76) + t: 2.(663) + out: false diff --git a/tests/501-1000/972. equal-rational-numbers/sol.cpp b/tests/501-1000/972. equal-rational-numbers/sol.cpp new file mode 100644 index 00000000..986e7220 --- /dev/null +++ b/tests/501-1000/972. equal-rational-numbers/sol.cpp @@ -0,0 +1,54 @@ +class Solution { +public: + bool isRationalEqual(string s, string t) { + using ll = long long; + struct Fraction { + ll num, den; + Fraction(ll n, ll d) { + ll g = gcd(abs(n), abs(d)); + num = n / g; + den = d / g; + if (den < 0) { num = -num; den = -den; } + } + Fraction operator+(const Fraction& o) const { + return Fraction(num * o.den + o.num * den, den * o.den); + } + bool operator==(const Fraction& o) const { + return num == o.num && den == o.den; + } + ll gcd(ll a, ll b) const { + while (b) { ll t = b; b = a % b; a = t; } + return a; + } + }; + + auto parse = [](const string& x) -> Fraction { + if (x.find('.') == string::npos) { + return Fraction(stoll(x), 1); + } + auto dotPos = x.find('.'); + string integer = x.substr(0, dotPos); + string frac = x.substr(dotPos + 1); + if (frac.find('(') == string::npos) { + if (frac.empty()) { + return Fraction(stoll(integer), 1); + } + Fraction base(stoll(integer), 1); + Fraction fracPart(stoll(frac), (ll)pow(10, frac.length())); + return base + fracPart; + } + auto parenPos = frac.find('('); + string nonrep = frac.substr(0, parenPos); + string rep = frac.substr(parenPos + 1, frac.length() - parenPos - 2); + Fraction base(stoll(integer), 1); + if (!nonrep.empty()) { + base = base + Fraction(stoll(nonrep), (ll)pow(10, nonrep.length())); + } + ll repeatNum = stoll(rep); + ll repeatDen = ((ll)pow(10, rep.length()) - 1) * (ll)pow(10, nonrep.length()); + return base + Fraction(repeatNum, repeatDen); + }; + + return parse(s) == parse(t); + } +}; diff --git a/tests/501-1000/972. equal-rational-numbers/sol.cs b/tests/501-1000/972. equal-rational-numbers/sol.cs new file mode 100644 index 00000000..1342daad --- /dev/null +++ b/tests/501-1000/972. equal-rational-numbers/sol.cs @@ -0,0 +1,50 @@ +public class Solution { + public bool IsRationalEqual(string s, string t) { + (long, long) Parse(string x) { + if (!x.Contains('.')) { + return (long.Parse(x), 1); + } + var parts = x.Split('.', 2); + var integer = parts[0]; + var frac = parts[1]; + if (!frac.Contains('(')) { + if (frac == "") { + return (long.Parse(integer), 1); + } + var baseFrac = (long.Parse(integer), 1L); + var fracPart = (long.Parse(frac), (long)Math.Pow(10, frac.Length)); + return Add(baseFrac, fracPart); + } + var repParts = frac.Split('(', 2); + var nonrep = repParts[0]; + var rep = repParts[1].TrimEnd(')'); + var baseVal = (long.Parse(integer), 1L); + if (nonrep != "") { + baseVal = Add(baseVal, (long.Parse(nonrep), (long)Math.Pow(10, nonrep.Length))); + } + long repeatNum = long.Parse(rep); + long repeatDen = ((long)Math.Pow(10, rep.Length) - 1) * (long)Math.Pow(10, nonrep.Length); + return Add(baseVal, (repeatNum, repeatDen)); + } + + (long, long) Add((long, long) a, (long, long) b) { + long num = a.Item1 * b.Item2 + b.Item1 * a.Item2; + long den = a.Item2 * b.Item2; + long g = Gcd(Math.Abs(num), Math.Abs(den)); + return (num / g, den / g); + } + + long Gcd(long a, long b) { + while (b != 0) { + var t = b; + b = a % b; + a = t; + } + return a; + } + + var sf = Parse(s); + var tf = Parse(t); + return sf.Item1 * tf.Item2 == tf.Item1 * sf.Item2; + } +} diff --git a/tests/501-1000/972. equal-rational-numbers/sol.dart b/tests/501-1000/972. equal-rational-numbers/sol.dart new file mode 100644 index 00000000..5412c1fb --- /dev/null +++ b/tests/501-1000/972. equal-rational-numbers/sol.dart @@ -0,0 +1,54 @@ +class Solution { + bool isRationalEqual(String s, String t) { + BigInt gcd(BigInt a, BigInt b) { + while (b != BigInt.zero) { + var t = b; + b = a % b; + a = t; + } + return a; + } + + List add(List a, List b) { + var num = a[0] * b[1] + b[0] * a[1]; + var den = a[1] * b[1]; + var g = gcd(num.abs(), den.abs()); + return [num ~/ g, den ~/ g]; + } + + BigInt pow10(int n) { + return BigInt.from(10).pow(n); + } + + List parse(String x) { + if (!x.contains('.')) { + return [BigInt.parse(x), BigInt.one]; + } + var parts = x.split('.'); + var integer = parts[0]; + var frac = parts[1]; + if (!frac.contains('(')) { + if (frac.isEmpty) { + return [BigInt.parse(integer), BigInt.one]; + } + var base = [BigInt.parse(integer), BigInt.one]; + var fracPart = [BigInt.parse(frac), pow10(frac.length)]; + return add(base, fracPart); + } + var repParts = frac.split('('); + var nonrep = repParts[0]; + var rep = repParts[1].substring(0, repParts[1].length - 1); + var base = [BigInt.parse(integer), BigInt.one]; + if (nonrep.isNotEmpty) { + base = add(base, [BigInt.parse(nonrep), pow10(nonrep.length)]); + } + var repeatNum = BigInt.parse(rep); + var repeatDen = (pow10(rep.length) - BigInt.one) * pow10(nonrep.length); + return add(base, [repeatNum, repeatDen]); + } + + var sf = parse(s); + var tf = parse(t); + return sf[0] * tf[1] == tf[0] * sf[1]; + } +} diff --git a/tests/501-1000/972. equal-rational-numbers/sol.go b/tests/501-1000/972. equal-rational-numbers/sol.go new file mode 100644 index 00000000..99ba65c7 --- /dev/null +++ b/tests/501-1000/972. equal-rational-numbers/sol.go @@ -0,0 +1,67 @@ +func isRationalEqual(s string, t string) bool { + type frac struct{ num, den int64 } + + abs := func(x int64) int64 { + if x < 0 { + return -x + } + return x + } + + gcd := func(a, b int64) int64 { + a = abs(a) + b = abs(b) + for b != 0 { + a, b = b, a%b + } + return a + } + + pow10 := func(n int) int64 { + r := int64(1) + for i := 0; i < n; i++ { + r *= 10 + } + return r + } + + add := func(a, b frac) frac { + num := a.num*b.den + b.num*a.den + den := a.den * b.den + g := gcd(num, den) + return frac{num / g, den / g} + } + + parse := func(x string) frac { + if !strings.Contains(x, ".") { + n, _ := strconv.ParseInt(x, 10, 64) + return frac{n, 1} + } + parts := strings.SplitN(x, ".", 2) + integer := parts[0] + fracStr := parts[1] + nInt, _ := strconv.ParseInt(integer, 10, 64) + if !strings.Contains(fracStr, "(") { + if fracStr == "" { + return frac{nInt, 1} + } + nFrac, _ := strconv.ParseInt(fracStr, 10, 64) + return add(frac{nInt, 1}, frac{nFrac, pow10(len(fracStr))}) + } + repParts := strings.SplitN(fracStr, "(", 2) + nonrep := repParts[0] + rep := repParts[1][:len(repParts[1])-1] + base := frac{nInt, 1} + if nonrep != "" { + nNonrep, _ := strconv.ParseInt(nonrep, 10, 64) + base = add(base, frac{nNonrep, pow10(len(nonrep))}) + } + repeatNum, _ := strconv.ParseInt(rep, 10, 64) + repeatDen := (pow10(len(rep)) - 1) * pow10(len(nonrep)) + return add(base, frac{repeatNum, repeatDen}) + } + + sF := parse(s) + tF := parse(t) + return sF.num*tF.den == tF.num*sF.den +} diff --git a/tests/501-1000/972. equal-rational-numbers/sol.java b/tests/501-1000/972. equal-rational-numbers/sol.java new file mode 100644 index 00000000..e814c0e8 --- /dev/null +++ b/tests/501-1000/972. equal-rational-numbers/sol.java @@ -0,0 +1,51 @@ +class Solution { + public boolean isRationalEqual(String s, String t) { + return parse(s).equals(parse(t)); + } + + private static class Fraction { + long num, den; + Fraction(long n, long d) { + if (d < 0) { n = -n; d = -d; } + long g = gcd(Math.abs(n), Math.abs(d)); + num = n / g; + den = d / g; + } + Fraction add(Fraction o) { + return new Fraction(num * o.den + o.num * den, den * o.den); + } + public boolean equals(Object o) { + if (!(o instanceof Fraction)) return false; + Fraction f = (Fraction)o; + return num == f.num && den == f.den; + } + static long gcd(long a, long b) { return b == 0 ? a : gcd(b, a % b); } + } + + private Fraction parse(String x) { + if (!x.contains(".")) { + return new Fraction(Integer.parseInt(x), 1); + } + String[] parts = x.split("\\.", 2); + String integer = parts[0]; + String frac = parts[1]; + if (!frac.contains("(")) { + if (frac.isEmpty()) { + return new Fraction(Integer.parseInt(integer), 1); + } + Fraction base = new Fraction(Integer.parseInt(integer), 1); + Fraction fracPart = new Fraction(Integer.parseInt(frac), (long) Math.pow(10, frac.length())); + return base.add(fracPart); + } + String[] repParts = frac.split("\\(", 2); + String nonrep = repParts[0]; + String rep = repParts[1].substring(0, repParts[1].length() - 1); + Fraction base = new Fraction(Integer.parseInt(integer), 1); + if (!nonrep.isEmpty()) { + base = base.add(new Fraction(Integer.parseInt(nonrep), (long) Math.pow(10, nonrep.length()))); + } + long repeatNum = Long.parseLong(rep); + long repeatDen = ((long) Math.pow(10, rep.length()) - 1) * (long) Math.pow(10, nonrep.length()); + return base.add(new Fraction(repeatNum, repeatDen)); + } +} diff --git a/tests/501-1000/972. equal-rational-numbers/sol.kt b/tests/501-1000/972. equal-rational-numbers/sol.kt new file mode 100644 index 00000000..113ee26d --- /dev/null +++ b/tests/501-1000/972. equal-rational-numbers/sol.kt @@ -0,0 +1,64 @@ +class Solution { + fun isRationalEqual(s: String, t: String): Boolean { + fun gcd(a: Long, b: Long): Long { + var x = kotlin.math.abs(a) + var y = kotlin.math.abs(b) + while (y != 0L) { + val tmp = x % y + x = y + y = tmp + } + return x + } + + fun pow10(n: Int): Long { + var r = 1L + repeat(n) { r *= 10L } + return r + } + + fun norm(num: Long, den: Long): Pair { + var n = num + var d = den + val g = gcd(n, d) + n /= g + d /= g + if (d < 0) { + n = -n + d = -d + } + return Pair(n, d) + } + + fun add(a: Pair, b: Pair): Pair { + return norm(a.first * b.second + b.first * a.second, a.second * b.second) + } + + fun parse(x: String): Pair { + if (!x.contains('.')) { + return norm(x.toLong(), 1L) + } + val parts = x.split(".", limit = 2) + val integer = parts[0] + val frac = parts[1] + if (!frac.contains('(')) { + if (frac.isEmpty()) { + return norm(integer.toLong(), 1L) + } + return add(norm(integer.toLong(), 1L), norm(frac.toLong(), pow10(frac.length))) + } + val repParts = frac.split("(", limit = 2) + val nonrep = repParts[0] + val rep = repParts[1].dropLast(1) + var base = norm(integer.toLong(), 1L) + if (nonrep.isNotEmpty()) { + base = add(base, norm(nonrep.toLong(), pow10(nonrep.length))) + } + val repeatNum = rep.toLong() + val repeatDen = (pow10(rep.length) - 1L) * pow10(nonrep.length) + return add(base, norm(repeatNum, repeatDen)) + } + + return parse(s) == parse(t) + } +} diff --git a/tests/501-1000/972. equal-rational-numbers/sol.py b/tests/501-1000/972. equal-rational-numbers/sol.py new file mode 100644 index 00000000..be9d8f3e --- /dev/null +++ b/tests/501-1000/972. equal-rational-numbers/sol.py @@ -0,0 +1,23 @@ +from fractions import Fraction + + +class Solution: + def isRationalEqual(self, s: str, t: str) -> bool: + def parse(x: str) -> Fraction: + if "." not in x: + return Fraction(int(x), 1) + integer, frac = x.split(".", 1) + if "(" not in frac: + if frac == "": + return Fraction(int(integer), 1) + return Fraction(int(integer), 1) + Fraction(int(frac), 10 ** len(frac)) + nonrep, rep = frac.split("(", 1) + rep = rep[:-1] + base = Fraction(int(integer), 1) + if nonrep: + base += Fraction(int(nonrep), 10 ** len(nonrep)) + repeat_num = int(rep) + repeat_den = (10 ** len(rep) - 1) * (10 ** len(nonrep)) + return base + Fraction(repeat_num, repeat_den) + + return parse(s) == parse(t) diff --git a/tests/501-1000/972. equal-rational-numbers/sol.py2 b/tests/501-1000/972. equal-rational-numbers/sol.py2 new file mode 100644 index 00000000..4ff09a80 --- /dev/null +++ b/tests/501-1000/972. equal-rational-numbers/sol.py2 @@ -0,0 +1,27 @@ +class Solution(object): + def isRationalEqual(self, s, t): + """ + :type s: str + :type t: str + :rtype: bool + """ + from fractions import Fraction + + def parse(x): + if "." not in x: + return Fraction(int(x), 1) + integer, frac = x.split(".", 1) + if "(" not in frac: + if frac == "": + return Fraction(int(integer), 1) + return Fraction(int(integer), 1) + Fraction(int(frac), 10 ** len(frac)) + nonrep, rep = frac.split("(", 1) + rep = rep[:-1] + base = Fraction(int(integer), 1) + if nonrep: + base += Fraction(int(nonrep), 10 ** len(nonrep)) + repeat_num = int(rep) + repeat_den = (10 ** len(rep) - 1) * (10 ** len(nonrep)) + return base + Fraction(repeat_num, repeat_den) + + return parse(s) == parse(t) diff --git a/tests/501-1000/972. equal-rational-numbers/sol.rb b/tests/501-1000/972. equal-rational-numbers/sol.rb new file mode 100644 index 00000000..b13bf44e --- /dev/null +++ b/tests/501-1000/972. equal-rational-numbers/sol.rb @@ -0,0 +1,25 @@ +# @param {String} s +# @param {String} t +# @return {Boolean} +def is_rational_equal(s, t) + require 'rational' + + def parse(str) + return Rational(str.to_i, 1) unless str.include?('.') + integer_str, frac = str.split('.', 2) + unless frac.include?('(') + return Rational(integer_str.to_i, 1) + Rational(frac == '' ? 0 : frac.to_i, 10 ** frac.length) + end + nonrep, rep = frac.split('(', 2) + rep = rep[0...-1] + base = Rational(integer_str.to_i, 1) + unless nonrep.empty? + base += Rational(nonrep.to_i, 10 ** nonrep.length) + end + repeat_num = rep.to_i + repeat_den = (10 ** rep.length - 1) * (10 ** nonrep.length) + base + Rational(repeat_num, repeat_den) + end + + parse(s) == parse(t) +end diff --git a/tests/501-1000/972. equal-rational-numbers/sol.rs b/tests/501-1000/972. equal-rational-numbers/sol.rs new file mode 100644 index 00000000..84e18570 --- /dev/null +++ b/tests/501-1000/972. equal-rational-numbers/sol.rs @@ -0,0 +1,49 @@ +impl Solution { + pub fn is_rational_equal(s: String, t: String) -> bool { + fn gcd(a: i128, b: i128) -> i128 { + if b == 0 { a.abs() } else { gcd(b, a % b) } + } + + fn add(a: (i128, i128), b: (i128, i128)) -> (i128, i128) { + let num = a.0 * b.1 + b.0 * a.1; + let den = a.1 * b.1; + let g = gcd(num, den); + (num / g, den / g) + } + + fn pow10(n: usize) -> i128 { + (0..n).fold(1, |acc, _| acc * 10) + } + + fn parse(x: &str) -> (i128, i128) { + if !x.contains('.') { + return (x.parse::().unwrap(), 1); + } + let parts: Vec<&str> = x.splitn(2, '.').collect(); + let integer = parts[0]; + let frac = parts[1]; + if !frac.contains('(') { + if frac.is_empty() { + return (integer.parse().unwrap(), 1); + } + let base = (integer.parse::().unwrap(), 1); + let frac_part = (frac.parse::().unwrap(), pow10(frac.len())); + return add(base, frac_part); + } + let rep_parts: Vec<&str> = frac.splitn(2, '(').collect(); + let nonrep = rep_parts[0]; + let rep = &rep_parts[1][..rep_parts[1].len() - 1]; + let mut base = (integer.parse::().unwrap(), 1); + if !nonrep.is_empty() { + base = add(base, (nonrep.parse().unwrap(), pow10(nonrep.len()))); + } + let repeat_num = rep.parse::().unwrap(); + let repeat_den = (pow10(rep.len()) - 1) * pow10(nonrep.len()); + add(base, (repeat_num, repeat_den)) + } + + let sf = parse(&s); + let tf = parse(&t); + sf.0 * tf.1 == tf.0 * sf.1 + } +} diff --git a/tests/501-1000/972. equal-rational-numbers/sol.swift b/tests/501-1000/972. equal-rational-numbers/sol.swift new file mode 100644 index 00000000..8a1664e7 --- /dev/null +++ b/tests/501-1000/972. equal-rational-numbers/sol.swift @@ -0,0 +1,68 @@ +class Solution { + func isRationalEqual(_ s: String, _ t: String) -> Bool { + struct Fraction: Equatable { + var num: Int + var den: Int + } + + func gcd(_ a: Int, _ b: Int) -> Int { + var x = abs(a) + var y = abs(b) + while y != 0 { + let tmp = x % y + x = y + y = tmp + } + return x + } + + func pow10(_ n: Int) -> Int { + var r = 1 + for _ in 0.. Fraction { + let g = gcd(num, den) + var n = num / g + var d = den / g + if d < 0 { + n = -n + d = -d + } + return Fraction(num: n, den: d) + } + + func add(_ a: Fraction, _ b: Fraction) -> Fraction { + norm(a.num * b.den + b.num * a.den, a.den * b.den) + } + + func parse(_ x: String) -> Fraction { + let dotParts = x.components(separatedBy: ".") + if dotParts.count == 1 { + return norm(Int(x)!, 1) + } + + let integer = dotParts[0] + let frac = dotParts[1] + if let openIdx = frac.firstIndex(of: "(") { + let nonrep = String(frac[.. 0n ? a : -a; + } + + function add(a: [bigint, bigint], b: [bigint, bigint]): [bigint, bigint] { + const num = a[0] * b[1] + b[0] * a[1]; + const den = a[1] * b[1]; + const g = gcd(num > 0n ? num : -num, den > 0n ? den : -den); + return [num / g, den / g]; + } + + function pow10(n: number): bigint { + return 10n ** BigInt(n); + } + + function parse(x: string): [bigint, bigint] { + if (!x.includes(".")) { + return [BigInt(x), 1n]; + } + const [integer, frac] = x.split("."); + if (!frac.includes("(")) { + if (frac === "") { + return [BigInt(integer), 1n]; + } + return add([BigInt(integer), 1n], [BigInt(frac), pow10(frac.length)]); + } + const [nonrep, repWithParen] = frac.split("("); + const rep = repWithParen.slice(0, -1); + let base: [bigint, bigint] = [BigInt(integer), 1n]; + if (nonrep !== "") { + base = add(base, [BigInt(nonrep), pow10(nonrep.length)]); + } + const repeatNum = BigInt(rep); + const repeatDen = (pow10(rep.length) - 1n) * pow10(nonrep.length); + return add(base, [repeatNum, repeatDen]); + } + + const sf = parse(s); + const tf = parse(t); + return sf[0] * tf[1] === tf[0] * sf[1]; +} diff --git a/tests/501-1000/973. k-closest-points-to-origin/manifest.yaml b/tests/501-1000/973. k-closest-points-to-origin/manifest.yaml new file mode 100644 index 00000000..2fec938d --- /dev/null +++ b/tests/501-1000/973. k-closest-points-to-origin/manifest.yaml @@ -0,0 +1,422 @@ +entry: + id: 973 + title: k-closest-points-to-origin + params: + points: + type: array + items: + type: array + items: + type: int + k: + type: int + call: + cpp: Solution().kClosest({points}, {k}) + rust: Solution::k_closest({points}, {k}) + python3: Solution().kClosest({points}, {k}) + python2: Solution().kClosest({points}, {k}) + ruby: k_closest({points}, {k}) + java: new Solution().kClosest({points}, {k}) + csharp: new Solution().KClosest({points}, {k}) + kotlin: Solution().kClosest({points}, {k}) + go: kClosest({points}, {k}) + dart: Solution().kClosest({points}, {k}) + swift: Solution().kClosest({points}, {k}) + typescript: kClosest({points}, {k}) +judge: + type: ignore_order +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().kClosest(points, k, {result}) + checker: + "class Checker:\n def kClosest(self, points, k, result):\n \ + \ if not isinstance(result, list) or len(result) != k:\n return False\n\ + \ pts = [tuple(p) for p in points]\n res = [tuple(p) for p in\ + \ result]\n counts = {}\n for p in pts:\n counts[p]\ + \ = counts.get(p, 0) + 1\n for p in res:\n if counts.get(p,\ + \ 0) == 0:\n return False\n counts[p] -= 1\n \ + \ dists = sorted(x * x + y * y for x, y in pts)\n threshold = dists[k\ + \ - 1]\n for x, y in res:\n if x * x + y * y > threshold:\n\ + \ return False\n strict = sum(1 for x, y in pts if x *\ + \ x + y * y < threshold)\n equal = sum(1 for x, y in res if x * x + y\ + \ * y == threshold)\n need_equal = k - strict\n return equal ==\ + \ need_equal\n" +seed: 973 +tests: + - name: case_1 + in: + points: + - - 0 + - -1 + - - -1 + - -2 + - - 0 + - 5 + k: 1 + - name: case_2 + in: + points: + - - -4 + - -1 + - - 2 + - -1 + - - -4 + - -3 + k: 1 + - name: case_3 + in: + points: + - - 3 + - 1 + - - 0 + - 2 + k: 2 + - name: case_4 + in: + points: + - - -3 + - 3 + - - -2 + - -1 + k: 2 + - name: case_5 + in: + points: + - - 3 + - 5 + k: 1 + - name: case_6 + in: + points: + - - -2 + - 1 + - - 2 + - 5 + - - 5 + - 5 + - - -2 + - 2 + k: 4 + - name: case_7 + in: + points: + - - -2 + - -5 + - - 2 + - 4 + - - -2 + - 1 + k: 1 + - name: case_8 + in: + points: + - - 4 + - 4 + - - 3 + - -2 + - - 3 + - 4 + - - -1 + - -3 + - - -5 + - 2 + - - 1 + - 3 + k: 4 + - name: case_9 + in: + points: + - - 3 + - 1 + - - 2 + - -1 + - - -5 + - 1 + - - -2 + - 5 + k: 4 + - name: case_10 + in: + points: + - - 1 + - -4 + - - -1 + - -3 + - - -3 + - 0 + - - -1 + - 0 + - - 3 + - 2 + k: 1 + - name: case_11 + in: + points: + - - -3 + - -1 + - - 4 + - 3 + - - -5 + - 2 + - - 2 + - -4 + - - 4 + - 1 + - - 3 + - 5 + k: 5 + - name: case_12 + in: + points: + - - 1 + - 4 + - - 1 + - -3 + - - 4 + - -3 + k: 2 + - name: case_13 + in: + points: + - - 3 + - -5 + - - -3 + - 3 + - - -3 + - 4 + k: 1 + - name: case_14 + in: + points: + - - 2 + - 5 + k: 1 + - name: case_15 + in: + points: + - - -4 + - 4 + - - -5 + - -5 + - - -5 + - -2 + - - -5 + - 5 + k: 4 + - name: case_16 + in: + points: + - - 1 + - 3 + - - 4 + - -3 + k: 1 + - name: case_17 + in: + points: + - - 1 + - 0 + - - -4 + - -5 + - - -4 + - -4 + - - 3 + - 0 + k: 1 + - name: case_18 + in: + points: + - - -3 + - -1 + - - 4 + - 1 + - - -2 + - -1 + k: 1 + - name: case_19 + in: + points: + - - 3 + - -3 + - - 4 + - 3 + k: 2 + - name: case_20 + in: + points: + - - 1 + - 4 + k: 1 + - name: case_21 + in: + points: + - - -5 + - 0 + - - 0 + - 5 + - - 5 + - -4 + - - -2 + - 5 + k: 3 + - name: case_22 + in: + points: + - - -1 + - 1 + - - 1 + - 5 + - - -5 + - 2 + - - 5 + - 2 + k: 2 + - name: case_23 + in: + points: + - - -1 + - -5 + - - 0 + - -1 + - - -2 + - -2 + k: 3 + - name: case_24 + in: + points: + - - 5 + - -2 + - - -4 + - -5 + k: 2 + - name: case_25 + in: + points: + - - 4 + - 0 + - - 3 + - -1 + - - 0 + - -2 + - - 0 + - 2 + - - -4 + - 5 + - - -4 + - -5 + k: 2 + - name: case_26 + in: + points: + - - -4 + - -2 + k: 1 + - name: case_27 + in: + points: + - - 4 + - -2 + k: 1 + - name: case_28 + in: + points: + - - 5 + - 5 + - - 3 + - -1 + - - -4 + - -3 + - - 4 + - 2 + - - -2 + - -4 + - - 0 + - -2 + k: 5 + - name: case_29 + in: + points: + - - -3 + - -1 + - - -4 + - 1 + - - -5 + - -3 + k: 2 + - name: case_30 + in: + points: + - - -2 + - 4 + - - 4 + - -4 + - - 0 + - -4 + - - -5 + - -4 + - - 4 + - -2 + - - -4 + - -5 + k: 4 + - name: case_31 + in: + points: + - - -1 + - -5 + - - -1 + - 2 + - - -1 + - -3 + - - 3 + - 4 + k: 4 + - name: case_32 + in: + points: + - - 4 + - -4 + k: 1 + - name: case_33 + in: + points: + - - -5 + - 4 + - - 4 + - 3 + - - 0 + - 0 + - - 5 + - 1 + - - 2 + - -5 + k: 5 + - name: case_34 + in: + points: + - - 4 + - -1 + - - 1 + - 2 + - - -4 + - 0 + - - -2 + - 4 + k: 4 + - name: case_35 + in: + points: + - - 2 + - 1 + - - 0 + - 0 + - - 0 + - 3 + - - 3 + - 3 + - - 2 + - -4 + k: 5 diff --git a/tests/501-1000/973. k-closest-points-to-origin/sol.cpp b/tests/501-1000/973. k-closest-points-to-origin/sol.cpp new file mode 100644 index 00000000..0d0f71ab --- /dev/null +++ b/tests/501-1000/973. k-closest-points-to-origin/sol.cpp @@ -0,0 +1,15 @@ +#include +#include +using namespace std; + +class Solution { +public: + vector> kClosest(vector>& points, int k) { + sort(points.begin(), points.end(), [](const vector& a, const vector& b) { + long long da = 1LL * a[0] * a[0] + 1LL * a[1] * a[1]; + long long db = 1LL * b[0] * b[0] + 1LL * b[1] * b[1]; + return da < db; + }); + return vector>(points.begin(), points.begin() + k); + } +}; diff --git a/tests/501-1000/973. k-closest-points-to-origin/sol.cs b/tests/501-1000/973. k-closest-points-to-origin/sol.cs new file mode 100644 index 00000000..7745de7e --- /dev/null +++ b/tests/501-1000/973. k-closest-points-to-origin/sol.cs @@ -0,0 +1,16 @@ +using System; + +public class Solution { + public int[][] KClosest(int[][] points, int k) { + Array.Sort(points, (a, b) => { + long da = 1L * a[0] * a[0] + 1L * a[1] * a[1]; + long db = 1L * b[0] * b[0] + 1L * b[1] * b[1]; + return da.CompareTo(db); + }); + var ans = new int[k][]; + for (int i = 0; i < k; i++) { + ans[i] = points[i]; + } + return ans; + } +} diff --git a/tests/501-1000/973. k-closest-points-to-origin/sol.dart b/tests/501-1000/973. k-closest-points-to-origin/sol.dart new file mode 100644 index 00000000..c2576624 --- /dev/null +++ b/tests/501-1000/973. k-closest-points-to-origin/sol.dart @@ -0,0 +1,12 @@ +import 'dart:math'; + +class Solution { + List> kClosest(List> points, int k) { + points.sort((a, b) { + final da = a[0] * a[0] + a[1] * a[1]; + final db = b[0] * b[0] + b[1] * b[1]; + return da.compareTo(db); + }); + return points.take(k).toList(); + } +} diff --git a/tests/501-1000/973. k-closest-points-to-origin/sol.go b/tests/501-1000/973. k-closest-points-to-origin/sol.go new file mode 100644 index 00000000..83f03fc0 --- /dev/null +++ b/tests/501-1000/973. k-closest-points-to-origin/sol.go @@ -0,0 +1,8 @@ +func kClosest(points [][]int, k int) [][]int { + sort.Slice(points, func(i, j int) bool { + da := points[i][0]*points[i][0] + points[i][1]*points[i][1] + db := points[j][0]*points[j][0] + points[j][1]*points[j][1] + return da < db + }) + return points[:k] +} diff --git a/tests/501-1000/973. k-closest-points-to-origin/sol.java b/tests/501-1000/973. k-closest-points-to-origin/sol.java new file mode 100644 index 00000000..cefe8c26 --- /dev/null +++ b/tests/501-1000/973. k-closest-points-to-origin/sol.java @@ -0,0 +1,11 @@ +import java.util.Arrays; + +class Solution { + public int[][] kClosest(int[][] points, int k) { + Arrays.sort(points, (a, b) -> Long.compare( + 1L * a[0] * a[0] + 1L * a[1] * a[1], + 1L * b[0] * b[0] + 1L * b[1] * b[1] + )); + return Arrays.copyOf(points, k); + } +} diff --git a/tests/501-1000/973. k-closest-points-to-origin/sol.kt b/tests/501-1000/973. k-closest-points-to-origin/sol.kt new file mode 100644 index 00000000..0a5eab49 --- /dev/null +++ b/tests/501-1000/973. k-closest-points-to-origin/sol.kt @@ -0,0 +1,6 @@ +class Solution { + fun kClosest(points: Array, k: Int): Array { + points.sortBy { 1L * it[0] * it[0] + 1L * it[1] * it[1] } + return points.copyOfRange(0, k) + } +} diff --git a/tests/501-1000/973. k-closest-points-to-origin/sol.py b/tests/501-1000/973. k-closest-points-to-origin/sol.py new file mode 100644 index 00000000..afe649d3 --- /dev/null +++ b/tests/501-1000/973. k-closest-points-to-origin/sol.py @@ -0,0 +1,3 @@ +class Solution(object): + def kClosest(self, points, k): + return sorted(points, key=lambda p: p[0] * p[0] + p[1] * p[1])[:k] diff --git a/tests/501-1000/973. k-closest-points-to-origin/sol.py2 b/tests/501-1000/973. k-closest-points-to-origin/sol.py2 new file mode 100644 index 00000000..afe649d3 --- /dev/null +++ b/tests/501-1000/973. k-closest-points-to-origin/sol.py2 @@ -0,0 +1,3 @@ +class Solution(object): + def kClosest(self, points, k): + return sorted(points, key=lambda p: p[0] * p[0] + p[1] * p[1])[:k] diff --git a/tests/501-1000/973. k-closest-points-to-origin/sol.rb b/tests/501-1000/973. k-closest-points-to-origin/sol.rb new file mode 100644 index 00000000..f427f5be --- /dev/null +++ b/tests/501-1000/973. k-closest-points-to-origin/sol.rb @@ -0,0 +1,3 @@ +def k_closest(points, k) + points.sort_by { |p| p[0] * p[0] + p[1] * p[1] }[0, k] +end diff --git a/tests/501-1000/973. k-closest-points-to-origin/sol.rs b/tests/501-1000/973. k-closest-points-to-origin/sol.rs new file mode 100644 index 00000000..3f2fe1bd --- /dev/null +++ b/tests/501-1000/973. k-closest-points-to-origin/sol.rs @@ -0,0 +1,6 @@ +impl Solution { + pub fn k_closest(mut points: Vec>, k: i32) -> Vec> { + points.sort_by_key(|p| p[0] as i64 * p[0] as i64 + p[1] as i64 * p[1] as i64); + points.into_iter().take(k as usize).collect() + } +} diff --git a/tests/501-1000/973. k-closest-points-to-origin/sol.swift b/tests/501-1000/973. k-closest-points-to-origin/sol.swift new file mode 100644 index 00000000..b31a9883 --- /dev/null +++ b/tests/501-1000/973. k-closest-points-to-origin/sol.swift @@ -0,0 +1,9 @@ +class Solution { + func kClosest(_ points: [[Int]], _ k: Int) -> [[Int]] { + return points.sorted { a, b in + let da = a[0] * a[0] + a[1] * a[1] + let db = b[0] * b[0] + b[1] * b[1] + return da < db + }.prefix(k).map { $0 } + } +} diff --git a/tests/501-1000/973. k-closest-points-to-origin/sol.ts b/tests/501-1000/973. k-closest-points-to-origin/sol.ts new file mode 100644 index 00000000..87f7c394 --- /dev/null +++ b/tests/501-1000/973. k-closest-points-to-origin/sol.ts @@ -0,0 +1,6 @@ +function kClosest(points: number[][], k: number): number[][] { + points.sort( + (a, b) => a[0] * a[0] + a[1] * a[1] - (b[0] * b[0] + b[1] * b[1]), + ); + return points.slice(0, k); +} diff --git a/tests/501-1000/974. subarray-sums-divisible-by-k/manifest.yaml b/tests/501-1000/974. subarray-sums-divisible-by-k/manifest.yaml new file mode 100644 index 00000000..9af06991 --- /dev/null +++ b/tests/501-1000/974. subarray-sums-divisible-by-k/manifest.yaml @@ -0,0 +1,428 @@ +entry: + id: 974 + title: subarray-sums-divisible-by-k + params: + nums: + type: array + items: + type: int + k: + type: int + call: + cpp: Solution().subarraysDivByK({nums}, {k}) + rust: Solution::subarrays_div_by_k({nums}, {k}) + python3: Solution().subarraysDivByK({nums}, {k}) + python2: Solution().subarraysDivByK({nums}, {k}) + ruby: subarrays_div_by_k({nums}, {k}) + java: new Solution().subarraysDivByK({nums}, {k}) + csharp: new Solution().SubarraysDivByK({nums}, {k}) + kotlin: Solution().subarraysDivByK({nums}, {k}) + go: subarraysDivByK({nums}, {k}) + dart: Solution().subarraysDivByK({nums}, {k}) + swift: Solution().subarraysDivByK({nums}, {k}) + typescript: subarraysDivByK({nums}, {k}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 974 +tests: + - name: case_1 + in: + nums: + - 4 + - -1 + - -10 + - -9 + - 7 + - -10 + k: 7 + out: 2 + - name: case_2 + in: + nums: + - 0 + - -7 + - -1 + - -8 + - -7 + - 7 + k: 4 + out: 11 + - name: case_3 + in: + nums: + - -9 + - 2 + - -9 + k: 8 + out: 1 + - name: case_4 + in: + nums: + - -3 + k: 4 + out: 0 + - name: case_5 + in: + nums: + - 6 + - -10 + k: 1 + out: 3 + - name: case_6 + in: + nums: + - -4 + - 3 + - -9 + k: 5 + out: 1 + - name: case_7 + in: + nums: + - -6 + - -10 + k: 2 + out: 3 + - name: case_8 + in: + nums: + - 4 + - -4 + - 7 + - -9 + - 5 + - -7 + - 1 + - -10 + - -10 + k: 4 + out: 10 + - name: case_9 + in: + nums: + - 7 + - 5 + - -6 + - 9 + k: 3 + out: 6 + - name: case_10 + in: + nums: + - 8 + - 3 + - 8 + - -5 + - 3 + - 3 + - -2 + - -6 + - 6 + - -9 + - 2 + - 1 + k: 7 + out: 10 + - name: case_11 + in: + nums: + - -6 + - 0 + - -6 + - 9 + - -1 + - 4 + - -9 + k: 3 + out: 21 + - name: case_12 + in: + nums: + - 1 + - 2 + - 2 + - 6 + - -10 + k: 2 + out: 10 + - name: case_13 + in: + nums: + - 7 + - 7 + - 6 + - -10 + - -8 + - -3 + - -5 + k: 1 + out: 28 + - name: case_14 + in: + nums: + - 8 + - 0 + - -4 + - 3 + k: 3 + out: 2 + - name: case_15 + in: + nums: + - 6 + - 8 + - 6 + - 4 + - 8 + - -8 + k: 4 + out: 11 + - name: case_16 + in: + nums: + - 10 + - 10 + - 4 + - -5 + - -4 + - 10 + - -5 + - 2 + - -1 + - -9 + - 1 + k: 7 + out: 7 + - name: case_17 + in: + nums: + - -10 + - 8 + - 1 + - -2 + - -9 + - 2 + - 8 + - -7 + k: 3 + out: 10 + - name: case_18 + in: + nums: + - -1 + - -6 + - 1 + - -2 + - 4 + - 6 + - 3 + k: 5 + out: 3 + - name: case_19 + in: + nums: + - -8 + - -7 + - -1 + - -5 + - -6 + - -2 + - -1 + k: 4 + out: 5 + - name: case_20 + in: + nums: + - 0 + - -7 + - -5 + - -7 + - -9 + - 2 + - -6 + k: 8 + out: 4 + - name: case_21 + in: + nums: + - 9 + k: 8 + out: 0 + - name: case_22 + in: + nums: + - -8 + - 3 + k: 2 + out: 1 + - name: case_23 + in: + nums: + - -1 + - 1 + - 6 + - 9 + - 1 + - -6 + - -5 + - -9 + - 6 + - 8 + - 9 + k: 6 + out: 8 + - name: case_24 + in: + nums: + - -3 + - 10 + - -8 + - -10 + - -10 + - -2 + - -2 + - -1 + - 0 + - 6 + - -1 + k: 2 + out: 34 + - name: case_25 + in: + nums: + - 10 + - 3 + - 5 + - -9 + - 10 + - 1 + - 4 + - -8 + k: 1 + out: 36 + - name: case_26 + in: + nums: + - 6 + - -1 + - -9 + - 7 + - -5 + - 3 + - 9 + - -2 + - 7 + - -5 + - -4 + k: 3 + out: 19 + - name: case_27 + in: + nums: + - -7 + - -7 + - 10 + - 2 + k: 7 + out: 3 + - name: case_28 + in: + nums: + - -10 + - 7 + - 2 + - -9 + - -3 + - 5 + - -8 + - -9 + - -5 + - -2 + - 3 + k: 7 + out: 8 + - name: case_29 + in: + nums: + - -4 + - -8 + - -1 + - 4 + - 4 + - -3 + - 7 + k: 4 + out: 12 + - name: case_30 + in: + nums: + - 3 + - 8 + - -10 + - 6 + - -8 + - -3 + - 7 + - 4 + - -2 + - 5 + - 5 + k: 1 + out: 66 + - name: case_31 + in: + nums: + - -5 + - 3 + - -8 + - 7 + k: 5 + out: 3 + - name: case_32 + in: + nums: + - -5 + - -5 + - -8 + - -8 + k: 4 + out: 3 + - name: case_33 + in: + nums: + - -2 + - 8 + - -1 + - 6 + - 9 + - -4 + - -4 + - -2 + - 3 + - 7 + k: 5 + out: 14 + - name: case_34 + in: + nums: + - -8 + - -8 + - -8 + - 4 + k: 8 + out: 6 + - name: case_35 + in: + nums: + - -8 + - -8 + - -2 + k: 3 + out: 1 diff --git a/tests/501-1000/974. subarray-sums-divisible-by-k/sol.cpp b/tests/501-1000/974. subarray-sums-divisible-by-k/sol.cpp new file mode 100644 index 00000000..c105dd26 --- /dev/null +++ b/tests/501-1000/974. subarray-sums-divisible-by-k/sol.cpp @@ -0,0 +1,17 @@ +class Solution { +public: + int subarraysDivByK(vector& nums, int k) { + int s = 0; + int res = 0; + unordered_map hs; + hs[0] = 1; + for (int num : nums) { + s += num; + int rem = s % k; + if (rem < 0) rem += k; + res += hs[rem]; + hs[rem]++; + } + return res; + } +}; diff --git a/tests/501-1000/974. subarray-sums-divisible-by-k/sol.cs b/tests/501-1000/974. subarray-sums-divisible-by-k/sol.cs new file mode 100644 index 00000000..e5c585bf --- /dev/null +++ b/tests/501-1000/974. subarray-sums-divisible-by-k/sol.cs @@ -0,0 +1,20 @@ +public class Solution { + public int SubarraysDivByK(int[] nums, int k) { + int s = 0; + int res = 0; + var hs = new Dictionary(); + hs[0] = 1; + foreach (int num in nums) { + s += num; + int rem = s % k; + if (rem < 0) rem += k; + if (hs.ContainsKey(rem)) { + res += hs[rem]; + hs[rem]++; + } else { + hs[rem] = 1; + } + } + return res; + } +} diff --git a/tests/501-1000/974. subarray-sums-divisible-by-k/sol.dart b/tests/501-1000/974. subarray-sums-divisible-by-k/sol.dart new file mode 100644 index 00000000..a1ba1563 --- /dev/null +++ b/tests/501-1000/974. subarray-sums-divisible-by-k/sol.dart @@ -0,0 +1,15 @@ +class Solution { + int subarraysDivByK(List nums, int k) { + int s = 0; + int res = 0; + Map hs = {0: 1}; + for (int num in nums) { + s += num; + int rem = s % k; + if (rem < 0) rem += k; + res += hs[rem] ?? 0; + hs[rem] = (hs[rem] ?? 0) + 1; + } + return res; + } +} diff --git a/tests/501-1000/974. subarray-sums-divisible-by-k/sol.go b/tests/501-1000/974. subarray-sums-divisible-by-k/sol.go new file mode 100644 index 00000000..af018a49 --- /dev/null +++ b/tests/501-1000/974. subarray-sums-divisible-by-k/sol.go @@ -0,0 +1,15 @@ +func subarraysDivByK(nums []int, k int) int { + s := 0 + res := 0 + hs := map[int]int{0: 1} + for _, num := range nums { + s += num + rem := s % k + if rem < 0 { + rem += k + } + res += hs[rem] + hs[rem]++ + } + return res +} diff --git a/tests/501-1000/974. subarray-sums-divisible-by-k/sol.java b/tests/501-1000/974. subarray-sums-divisible-by-k/sol.java new file mode 100644 index 00000000..857da83b --- /dev/null +++ b/tests/501-1000/974. subarray-sums-divisible-by-k/sol.java @@ -0,0 +1,15 @@ +class Solution { + public int subarraysDivByK(int[] nums, int k) { + int s = 0; + int res = 0; + java.util.Map hs = new java.util.HashMap<>(); + hs.put(0, 1); + for (int num : nums) { + s += num; + int rem = ((s % k) + k) % k; + res += hs.getOrDefault(rem, 0); + hs.put(rem, hs.getOrDefault(rem, 0) + 1); + } + return res; + } +} diff --git a/tests/501-1000/974. subarray-sums-divisible-by-k/sol.kt b/tests/501-1000/974. subarray-sums-divisible-by-k/sol.kt new file mode 100644 index 00000000..38984649 --- /dev/null +++ b/tests/501-1000/974. subarray-sums-divisible-by-k/sol.kt @@ -0,0 +1,15 @@ +class Solution { + fun subarraysDivByK(nums: IntArray, k: Int): Int { + var s = 0 + var res = 0 + val hs = mutableMapOf(0 to 1) + for (num in nums) { + s += num + var rem = s % k + if (rem < 0) rem += k + res += hs.getOrDefault(rem, 0) + hs[rem] = hs.getOrDefault(rem, 0) + 1 + } + return res + } +} diff --git a/tests/501-1000/974. subarray-sums-divisible-by-k/sol.py b/tests/501-1000/974. subarray-sums-divisible-by-k/sol.py new file mode 100644 index 00000000..b9bb1e1e --- /dev/null +++ b/tests/501-1000/974. subarray-sums-divisible-by-k/sol.py @@ -0,0 +1,20 @@ +from collections import defaultdict +from typing import List + + +class Solution: + def subarraysDivByK(self, nums: List[int], k: int) -> int: + + s = 0 + res = 0 + hs = defaultdict(int) + hs[0] = 1 # Base case: remainder 0 seen once (before array starts) + + for num in nums: + s += num + rem = s % k # Python % is always non-negative — safe for negatives + + res += hs[rem] # All previous indices with same remainder = valid subarrays + hs[rem] += 1 # Record current remainder frequency + + return res diff --git a/tests/501-1000/974. subarray-sums-divisible-by-k/sol.py2 b/tests/501-1000/974. subarray-sums-divisible-by-k/sol.py2 new file mode 100644 index 00000000..87c6070f --- /dev/null +++ b/tests/501-1000/974. subarray-sums-divisible-by-k/sol.py2 @@ -0,0 +1,16 @@ +class Solution(object): + def subarraysDivByK(self, nums, k): + """ + :type nums: List[int] + :type k: int + :rtype: int + """ + s = 0 + res = 0 + hs = {0: 1} + for num in nums: + s += num + rem = s % k + res += hs.get(rem, 0) + hs[rem] = hs.get(rem, 0) + 1 + return res diff --git a/tests/501-1000/974. subarray-sums-divisible-by-k/sol.rb b/tests/501-1000/974. subarray-sums-divisible-by-k/sol.rb new file mode 100644 index 00000000..13079f07 --- /dev/null +++ b/tests/501-1000/974. subarray-sums-divisible-by-k/sol.rb @@ -0,0 +1,16 @@ +# @param {Integer[]} nums +# @param {Integer} k +# @return {Integer} +def subarrays_div_by_k(nums, k) + s = 0 + res = 0 + hs = Hash.new(0) + hs[0] = 1 + nums.each do |num| + s += num + rem = s % k + res += hs[rem] + hs[rem] += 1 + end + res +end diff --git a/tests/501-1000/974. subarray-sums-divisible-by-k/sol.rs b/tests/501-1000/974. subarray-sums-divisible-by-k/sol.rs new file mode 100644 index 00000000..d90bd0f6 --- /dev/null +++ b/tests/501-1000/974. subarray-sums-divisible-by-k/sol.rs @@ -0,0 +1,19 @@ +impl Solution { + pub fn subarrays_div_by_k(nums: Vec, k: i32) -> i32 { + let mut s = 0; + let mut res = 0; + let mut hs = std::collections::HashMap::new(); + hs.insert(0, 1); + for num in nums { + s += num; + let mut rem = s % k; + if rem < 0 { + rem += k; + } + let count = hs.get(&rem).copied().unwrap_or(0); + res += count; + hs.insert(rem, count + 1); + } + res + } +} diff --git a/tests/501-1000/974. subarray-sums-divisible-by-k/sol.swift b/tests/501-1000/974. subarray-sums-divisible-by-k/sol.swift new file mode 100644 index 00000000..8d452306 --- /dev/null +++ b/tests/501-1000/974. subarray-sums-divisible-by-k/sol.swift @@ -0,0 +1,15 @@ +class Solution { + func subarraysDivByK(_ nums: [Int], _ k: Int) -> Int { + var s = 0 + var res = 0 + var hs = [0: 1] + for num in nums { + s += num + var rem = s % k + if rem < 0 { rem += k } + res += hs[rem] ?? 0 + hs[rem, default: 0] += 1 + } + return res + } +} diff --git a/tests/501-1000/974. subarray-sums-divisible-by-k/sol.ts b/tests/501-1000/974. subarray-sums-divisible-by-k/sol.ts new file mode 100644 index 00000000..5e415030 --- /dev/null +++ b/tests/501-1000/974. subarray-sums-divisible-by-k/sol.ts @@ -0,0 +1,14 @@ +function subarraysDivByK(nums: number[], k: number): number { + let s = 0; + let res = 0; + const hs = new Map(); + hs.set(0, 1); + for (const num of nums) { + s += num; + let rem = s % k; + if (rem < 0) rem += k; + res += hs.get(rem) ?? 0; + hs.set(rem, (hs.get(rem) ?? 0) + 1); + } + return res; +} diff --git a/tests/501-1000/975. odd-even-jump/manifest.yaml b/tests/501-1000/975. odd-even-jump/manifest.yaml new file mode 100644 index 00000000..b6b8b8b1 --- /dev/null +++ b/tests/501-1000/975. odd-even-jump/manifest.yaml @@ -0,0 +1,375 @@ +entry: + id: 975 + title: odd-even-jump + params: + arr: + type: array + items: + type: int + call: + cpp: Solution().oddEvenJumps({arr}) + rust: Solution::odd_even_jumps({arr}) + python3: Solution().oddEvenJumps({arr}) + python2: Solution().oddEvenJumps({arr}) + ruby: odd_even_jumps({arr}) + java: new Solution().oddEvenJumps({arr}) + csharp: new Solution().OddEvenJumps({arr}) + kotlin: Solution().oddEvenJumps({arr}) + go: oddEvenJumps({arr}) + dart: Solution().oddEvenJumps({arr}) + swift: Solution().oddEvenJumps({arr}) + typescript: oddEvenJumps({arr}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 975 +tests: + - name: case_1 + in: + arr: + - 8 + - 13 + - 14 + - 17 + out: 2 + - name: case_2 + in: + arr: + - 2 + - 3 + - 3 + - 10 + out: 3 + - name: case_3 + in: + arr: + - 2 + - 18 + out: 2 + - name: case_4 + in: + arr: + - 8 + - 20 + - 18 + out: 2 + - name: case_5 + in: + arr: + - 6 + out: 1 + - name: case_6 + in: + arr: + - 7 + out: 1 + - name: case_7 + in: + arr: + - 9 + - 20 + - 18 + - 11 + - 1 + - 3 + - 5 + - 14 + - 0 + out: 6 + - name: case_8 + in: + arr: + - 0 + - 2 + - 10 + - 18 + - 8 + - 3 + - 18 + - 6 + - 6 + - 1 + - 13 + - 20 + out: 4 + - name: case_9 + in: + arr: + - 5 + - 19 + - 6 + - 19 + - 2 + out: 4 + - name: case_10 + in: + arr: + - 14 + - 6 + - 14 + - 12 + - 1 + - 11 + - 15 + - 0 + - 10 + out: 8 + - name: case_11 + in: + arr: + - 7 + - 10 + - 0 + - 2 + - 15 + - 20 + - 4 + - 6 + out: 5 + - name: case_12 + in: + arr: + - 4 + - 4 + out: 2 + - name: case_13 + in: + arr: + - 16 + - 14 + - 12 + out: 1 + - name: case_14 + in: + arr: + - 12 + - 10 + - 2 + - 0 + - 5 + - 7 + - 3 + out: 4 + - name: case_15 + in: + arr: + - 7 + - 6 + - 11 + - 20 + - 6 + - 5 + - 17 + - 8 + - 12 + out: 3 + - name: case_16 + in: + arr: + - 8 + - 10 + - 8 + - 4 + - 6 + - 8 + - 10 + out: 4 + - name: case_17 + in: + arr: + - 16 + - 18 + - 4 + - 10 + - 17 + - 9 + - 12 + - 16 + - 11 + out: 5 + - name: case_18 + in: + arr: + - 2 + - 8 + - 10 + - 19 + out: 2 + - name: case_19 + in: + arr: + - 11 + - 9 + - 4 + - 9 + - 17 + out: 3 + - name: case_20 + in: + arr: + - 7 + out: 1 + - name: case_21 + in: + arr: + - 16 + - 1 + - 4 + - 19 + - 20 + - 19 + - 4 + - 15 + - 4 + out: 4 + - name: case_22 + in: + arr: + - 12 + - 0 + - 4 + - 1 + - 18 + - 1 + - 12 + - 3 + - 19 + out: 6 + - name: case_23 + in: + arr: + - 2 + - 10 + - 17 + - 10 + - 7 + - 12 + - 9 + - 16 + - 15 + - 5 + - 18 + out: 10 + - name: case_24 + in: + arr: + - 2 + - 14 + - 18 + - 5 + - 7 + - 18 + - 13 + - 20 + - 17 + - 16 + - 18 + - 20 + out: 4 + - name: case_25 + in: + arr: + - 4 + - 14 + - 5 + - 3 + - 14 + - 0 + - 18 + out: 7 + - name: case_26 + in: + arr: + - 7 + - 19 + - 3 + - 12 + - 4 + - 3 + - 10 + - 0 + - 18 + - 1 + - 18 + - 12 + out: 9 + - name: case_27 + in: + arr: + - 4 + out: 1 + - name: case_28 + in: + arr: + - 13 + - 16 + - 19 + - 2 + out: 3 + - name: case_29 + in: + arr: + - 13 + - 16 + - 0 + - 7 + out: 3 + - name: case_30 + in: + arr: + - 4 + - 10 + - 13 + - 18 + out: 2 + - name: case_31 + in: + arr: + - 18 + - 14 + - 10 + out: 1 + - name: case_32 + in: + arr: + - 20 + - 11 + - 16 + - 0 + - 14 + out: 3 + - name: case_33 + in: + arr: + - 11 + - 2 + - 8 + - 14 + - 11 + - 20 + - 4 + - 8 + - 11 + - 15 + out: 4 + - name: case_34 + in: + arr: + - 2 + - 7 + out: 2 + - name: case_35 + in: + arr: + - 6 + - 13 + - 4 + - 10 + - 11 + out: 2 diff --git a/tests/501-1000/975. odd-even-jump/sol.cpp b/tests/501-1000/975. odd-even-jump/sol.cpp new file mode 100644 index 00000000..acc4eb60 --- /dev/null +++ b/tests/501-1000/975. odd-even-jump/sol.cpp @@ -0,0 +1,52 @@ +class Solution { +public: + int oddEvenJumps(vector& arr) { + int n = arr.size(); + vector nextHigher(n, -1); + vector nextLower(n, -1); + + vector indices(n); + iota(indices.begin(), indices.end(), 0); + + sort(indices.begin(), indices.end(), [&](int a, int b) { + return arr[a] < arr[b]; + }); + vector stack; + for (int i : indices) { + while (!stack.empty() && i > stack.back()) { + nextHigher[stack.back()] = i; + stack.pop_back(); + } + stack.push_back(i); + } + + sort(indices.begin(), indices.end(), [&](int a, int b) { + return arr[a] > arr[b]; + }); + stack.clear(); + for (int i : indices) { + while (!stack.empty() && i > stack.back()) { + nextLower[stack.back()] = i; + stack.pop_back(); + } + stack.push_back(i); + } + + vector odd(n, false); + vector even(n, false); + odd[n - 1] = true; + even[n - 1] = true; + + int result = 1; + for (int i = n - 2; i >= 0; i--) { + if (nextHigher[i] != -1) { + odd[i] = even[nextHigher[i]]; + } + if (nextLower[i] != -1) { + even[i] = odd[nextLower[i]]; + } + if (odd[i]) result++; + } + return result; + } +}; diff --git a/tests/501-1000/975. odd-even-jump/sol.cs b/tests/501-1000/975. odd-even-jump/sol.cs new file mode 100644 index 00000000..4165ed85 --- /dev/null +++ b/tests/501-1000/975. odd-even-jump/sol.cs @@ -0,0 +1,47 @@ +public class Solution { + public int OddEvenJumps(int[] arr) { + int n = arr.Length; + int[] nextHigher = new int[n]; + int[] nextLower = new int[n]; + Array.Fill(nextHigher, -1); + Array.Fill(nextLower, -1); + + int[] indices = new int[n]; + for (int i = 0; i < n; i++) indices[i] = i; + + Array.Sort(indices, (a, b) => arr[a].CompareTo(arr[b])); + Stack stack = new Stack(); + foreach (int i in indices) { + while (stack.Count > 0 && i > stack.Peek()) { + nextHigher[stack.Pop()] = i; + } + stack.Push(i); + } + + Array.Sort(indices, (a, b) => arr[b].CompareTo(arr[a])); + stack.Clear(); + foreach (int i in indices) { + while (stack.Count > 0 && i > stack.Peek()) { + nextLower[stack.Pop()] = i; + } + stack.Push(i); + } + + bool[] odd = new bool[n]; + bool[] even = new bool[n]; + odd[n - 1] = true; + even[n - 1] = true; + + int result = 1; + for (int i = n - 2; i >= 0; i--) { + if (nextHigher[i] != -1) { + odd[i] = even[nextHigher[i]]; + } + if (nextLower[i] != -1) { + even[i] = odd[nextLower[i]]; + } + if (odd[i]) result++; + } + return result; + } +} diff --git a/tests/501-1000/975. odd-even-jump/sol.dart b/tests/501-1000/975. odd-even-jump/sol.dart new file mode 100644 index 00000000..43721679 --- /dev/null +++ b/tests/501-1000/975. odd-even-jump/sol.dart @@ -0,0 +1,43 @@ +class Solution { + int oddEvenJumps(List arr) { + int n = arr.length; + List nextHigher = List.filled(n, null); + List nextLower = List.filled(n, null); + + List indices = List.generate(n, (i) => i); + indices.sort((a, b) => arr[a].compareTo(arr[b])); + List stack = []; + for (int i in indices) { + while (stack.isNotEmpty && i > stack.last) { + nextHigher[stack.removeLast()] = i; + } + stack.add(i); + } + + indices.sort((a, b) => arr[b].compareTo(arr[a])); + stack.clear(); + for (int i in indices) { + while (stack.isNotEmpty && i > stack.last) { + nextLower[stack.removeLast()] = i; + } + stack.add(i); + } + + List odd = List.filled(n, false); + List even = List.filled(n, false); + odd[n - 1] = true; + even[n - 1] = true; + + int result = 1; + for (int i = n - 2; i >= 0; i--) { + if (nextHigher[i] != null) { + odd[i] = even[nextHigher[i]!]; + } + if (nextLower[i] != null) { + even[i] = odd[nextLower[i]!]; + } + if (odd[i]) result++; + } + return result; + } +} diff --git a/tests/501-1000/975. odd-even-jump/sol.go b/tests/501-1000/975. odd-even-jump/sol.go new file mode 100644 index 00000000..5003d093 --- /dev/null +++ b/tests/501-1000/975. odd-even-jump/sol.go @@ -0,0 +1,57 @@ +func oddEvenJumps(arr []int) int { + n := len(arr) + nextHigher := make([]int, n) + nextLower := make([]int, n) + for i := range nextHigher { + nextHigher[i] = -1 + nextLower[i] = -1 + } + + indices := make([]int, n) + for i := range indices { + indices[i] = i + } + + sort.Slice(indices, func(a, b int) bool { + return arr[indices[a]] < arr[indices[b]] + }) + stack := []int{} + for _, i := range indices { + for len(stack) > 0 && i > stack[len(stack)-1] { + nextHigher[stack[len(stack)-1]] = i + stack = stack[:len(stack)-1] + } + stack = append(stack, i) + } + + sort.Slice(indices, func(a, b int) bool { + return arr[indices[a]] > arr[indices[b]] + }) + stack = []int{} + for _, i := range indices { + for len(stack) > 0 && i > stack[len(stack)-1] { + nextLower[stack[len(stack)-1]] = i + stack = stack[:len(stack)-1] + } + stack = append(stack, i) + } + + odd := make([]bool, n) + even := make([]bool, n) + odd[n-1] = true + even[n-1] = true + + result := 1 + for i := n - 2; i >= 0; i-- { + if nextHigher[i] != -1 { + odd[i] = even[nextHigher[i]] + } + if nextLower[i] != -1 { + even[i] = odd[nextLower[i]] + } + if odd[i] { + result++ + } + } + return result +} diff --git a/tests/501-1000/975. odd-even-jump/sol.java b/tests/501-1000/975. odd-even-jump/sol.java new file mode 100644 index 00000000..78e0f916 --- /dev/null +++ b/tests/501-1000/975. odd-even-jump/sol.java @@ -0,0 +1,45 @@ +class Solution { + public int oddEvenJumps(int[] arr) { + int n = arr.length; + Integer[] nextHigher = new Integer[n]; + Integer[] nextLower = new Integer[n]; + + Integer[] indices = new Integer[n]; + for (int i = 0; i < n; i++) indices[i] = i; + + Arrays.sort(indices, (a, b) -> arr[a] - arr[b]); + Deque stack = new ArrayDeque<>(); + for (int i : indices) { + while (!stack.isEmpty() && i > stack.peek()) { + nextHigher[stack.pop()] = i; + } + stack.push(i); + } + + Arrays.sort(indices, (a, b) -> arr[b] - arr[a]); + stack.clear(); + for (int i : indices) { + while (!stack.isEmpty() && i > stack.peek()) { + nextLower[stack.pop()] = i; + } + stack.push(i); + } + + boolean[] odd = new boolean[n]; + boolean[] even = new boolean[n]; + odd[n - 1] = true; + even[n - 1] = true; + + int result = 1; + for (int i = n - 2; i >= 0; i--) { + if (nextHigher[i] != null) { + odd[i] = even[nextHigher[i]]; + } + if (nextLower[i] != null) { + even[i] = odd[nextLower[i]]; + } + if (odd[i]) result++; + } + return result; + } +} diff --git a/tests/501-1000/975. odd-even-jump/sol.kt b/tests/501-1000/975. odd-even-jump/sol.kt new file mode 100644 index 00000000..e60a9a02 --- /dev/null +++ b/tests/501-1000/975. odd-even-jump/sol.kt @@ -0,0 +1,38 @@ +class Solution { + fun oddEvenJumps(arr: IntArray): Int { + val n = arr.size + val nextHigher = arrayOfNulls(n) + val nextLower = arrayOfNulls(n) + + val indices = arr.indices.sortedBy { arr[it] } + val stack = ArrayDeque() + for (i in indices) { + while (stack.isNotEmpty() && i > stack.last()) { + nextHigher[stack.removeLast()] = i + } + stack.addLast(i) + } + + val indicesDesc = arr.indices.sortedByDescending { arr[it] } + stack.clear() + for (i in indicesDesc) { + while (stack.isNotEmpty() && i > stack.last()) { + nextLower[stack.removeLast()] = i + } + stack.addLast(i) + } + + val odd = BooleanArray(n) + val even = BooleanArray(n) + odd[n - 1] = true + even[n - 1] = true + + var result = 1 + for (i in n - 2 downTo 0) { + nextHigher[i]?.let { odd[i] = even[it] } + nextLower[i]?.let { even[i] = odd[it] } + if (odd[i]) result++ + } + return result + } +} diff --git a/tests/501-1000/975. odd-even-jump/sol.py b/tests/501-1000/975. odd-even-jump/sol.py new file mode 100644 index 00000000..eb8a77ad --- /dev/null +++ b/tests/501-1000/975. odd-even-jump/sol.py @@ -0,0 +1,30 @@ +from typing import List + + +class Solution: + def oddEvenJumps(self, arr: List[int]) -> int: + n = len(arr) + next_higher = [None] * n + next_lower = [None] * n + + stack = [] + for _, i in sorted((v, i) for i, v in enumerate(arr)): + while stack and i > stack[-1]: + next_higher[stack.pop()] = i + stack.append(i) + + stack = [] + for _, i in sorted((-v, i) for i, v in enumerate(arr)): + while stack and i > stack[-1]: + next_lower[stack.pop()] = i + stack.append(i) + + odd = [False] * n + even = [False] * n + odd[-1] = even[-1] = True + for i in range(n - 2, -1, -1): + if next_higher[i] is not None: + odd[i] = even[next_higher[i]] + if next_lower[i] is not None: + even[i] = odd[next_lower[i]] + return sum(odd) diff --git a/tests/501-1000/975. odd-even-jump/sol.py2 b/tests/501-1000/975. odd-even-jump/sol.py2 new file mode 100644 index 00000000..696700e1 --- /dev/null +++ b/tests/501-1000/975. odd-even-jump/sol.py2 @@ -0,0 +1,31 @@ +class Solution(object): + def oddEvenJumps(self, arr): + """ + :type arr: List[int] + :rtype: int + """ + n = len(arr) + next_higher = [None] * n + next_lower = [None] * n + + stack = [] + for _, i in sorted((v, i) for i, v in enumerate(arr)): + while stack and i > stack[-1]: + next_higher[stack.pop()] = i + stack.append(i) + + stack = [] + for _, i in sorted((-v, i) for i, v in enumerate(arr)): + while stack and i > stack[-1]: + next_lower[stack.pop()] = i + stack.append(i) + + odd = [False] * n + even = [False] * n + odd[-1] = even[-1] = True + for i in range(n - 2, -1, -1): + if next_higher[i] is not None: + odd[i] = even[next_higher[i]] + if next_lower[i] is not None: + even[i] = odd[next_lower[i]] + return sum(odd) diff --git a/tests/501-1000/975. odd-even-jump/sol.rb b/tests/501-1000/975. odd-even-jump/sol.rb new file mode 100644 index 00000000..9fb42fdb --- /dev/null +++ b/tests/501-1000/975. odd-even-jump/sol.rb @@ -0,0 +1,36 @@ +# @param {Integer[]} arr +# @return {Integer} +def odd_even_jumps(arr) + n = arr.length + next_higher = Array.new(n) + next_lower = Array.new(n) + + stack = [] + arr.each_with_index.sort_by { |v, i| v }.each do |_, i| + while !stack.empty? && i > stack.last + next_higher[stack.pop] = i + end + stack.push(i) + end + + stack = [] + arr.each_with_index.sort_by { |v, i| -v }.each do |_, i| + while !stack.empty? && i > stack.last + next_lower[stack.pop] = i + end + stack.push(i) + end + + odd = Array.new(n, false) + even = Array.new(n, false) + odd[-1] = even[-1] = true + (n - 2).downto(0) do |i| + if next_higher[i] + odd[i] = even[next_higher[i]] + end + if next_lower[i] + even[i] = odd[next_lower[i]] + end + end + odd.count(true) +end diff --git a/tests/501-1000/975. odd-even-jump/sol.rs b/tests/501-1000/975. odd-even-jump/sol.rs new file mode 100644 index 00000000..c0a6fbd9 --- /dev/null +++ b/tests/501-1000/975. odd-even-jump/sol.rs @@ -0,0 +1,53 @@ +impl Solution { + pub fn odd_even_jumps(arr: Vec) -> i32 { + let n = arr.len(); + let mut next_higher: Vec> = vec![None; n]; + let mut next_lower: Vec> = vec![None; n]; + + let mut indices: Vec = (0..n).collect(); + indices.sort_by_key(|&i| arr[i]); + let mut stack: Vec = Vec::new(); + for &i in &indices { + while let Some(&top) = stack.last() { + if i > top { + next_higher[stack.pop().unwrap()] = Some(i); + } else { + break; + } + } + stack.push(i); + } + + indices.sort_by_key(|&i| -arr[i]); + stack.clear(); + for &i in &indices { + while let Some(&top) = stack.last() { + if i > top { + next_lower[stack.pop().unwrap()] = Some(i); + } else { + break; + } + } + stack.push(i); + } + + let mut odd = vec![false; n]; + let mut even = vec![false; n]; + odd[n - 1] = true; + even[n - 1] = true; + + let mut result = 1; + for i in (0..n-1).rev() { + if let Some(higher) = next_higher[i] { + odd[i] = even[higher]; + } + if let Some(lower) = next_lower[i] { + even[i] = odd[lower]; + } + if odd[i] { + result += 1; + } + } + result + } +} diff --git a/tests/501-1000/975. odd-even-jump/sol.swift b/tests/501-1000/975. odd-even-jump/sol.swift new file mode 100644 index 00000000..f5b5746c --- /dev/null +++ b/tests/501-1000/975. odd-even-jump/sol.swift @@ -0,0 +1,44 @@ +class Solution { + func oddEvenJumps(_ arr: [Int]) -> Int { + let n = arr.count + var nextHigher = [Int?](repeating: nil, count: n) + var nextLower = [Int?](repeating: nil, count: n) + + let indices = (0.. stack.last! { + nextHigher[stack.removeLast()] = i + } + stack.append(i) + } + + let indicesDesc = (0.. arr[$1] } + stack.removeAll() + for i in indicesDesc { + while !stack.isEmpty && i > stack.last! { + nextLower[stack.removeLast()] = i + } + stack.append(i) + } + + var odd = [Bool](repeating: false, count: n) + var even = [Bool](repeating: false, count: n) + odd[n - 1] = true + even[n - 1] = true + + var result = 1 + for i in stride(from: n - 2, through: 0, by: -1) { + if let higher = nextHigher[i] { + odd[i] = even[higher] + } + if let lower = nextLower[i] { + even[i] = odd[lower] + } + if odd[i] { + result += 1 + } + } + return result + } +} diff --git a/tests/501-1000/975. odd-even-jump/sol.ts b/tests/501-1000/975. odd-even-jump/sol.ts new file mode 100644 index 00000000..70f6b549 --- /dev/null +++ b/tests/501-1000/975. odd-even-jump/sol.ts @@ -0,0 +1,41 @@ +function oddEvenJumps(arr: number[]): number { + const n = arr.length; + const nextHigher: (number | null)[] = new Array(n).fill(null); + const nextLower: (number | null)[] = new Array(n).fill(null); + + const indices = Array.from({ length: n }, (_, i) => i); + indices.sort((a, b) => arr[a] - arr[b]); + const stack: number[] = []; + for (const i of indices) { + while (stack.length > 0 && i > stack[stack.length - 1]) { + nextHigher[stack.pop()!] = i; + } + stack.push(i); + } + + indices.sort((a, b) => arr[b] - arr[a]); + stack.length = 0; + for (const i of indices) { + while (stack.length > 0 && i > stack[stack.length - 1]) { + nextLower[stack.pop()!] = i; + } + stack.push(i); + } + + const odd: boolean[] = new Array(n).fill(false); + const even: boolean[] = new Array(n).fill(false); + odd[n - 1] = true; + even[n - 1] = true; + + let result = 1; + for (let i = n - 2; i >= 0; i--) { + if (nextHigher[i] !== null) { + odd[i] = even[nextHigher[i]!]; + } + if (nextLower[i] !== null) { + even[i] = odd[nextLower[i]!]; + } + if (odd[i]) result++; + } + return result; +} diff --git a/tests/501-1000/976. largest-perimeter-triangle/manifest.yaml b/tests/501-1000/976. largest-perimeter-triangle/manifest.yaml new file mode 100644 index 00000000..49cefac1 --- /dev/null +++ b/tests/501-1000/976. largest-perimeter-triangle/manifest.yaml @@ -0,0 +1,457 @@ +entry: + id: 976 + title: largest-perimeter-triangle + params: + nums: + type: array + items: + type: int + call: + cpp: Solution().largestPerimeter({nums}) + rust: Solution::largest_perimeter({nums}) + python3: Solution().largestPerimeter({nums}) + python2: Solution().largestPerimeter({nums}) + ruby: largest_perimeter({nums}) + java: new Solution().largestPerimeter({nums}) + csharp: new Solution().LargestPerimeter({nums}) + kotlin: Solution().largestPerimeter({nums}) + go: largestPerimeter({nums}) + dart: Solution().largestPerimeter({nums}) + swift: Solution().largestPerimeter({nums}) + typescript: largestPerimeter({nums}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 976 +tests: + - name: case_1 + in: + nums: + - 16 + - 1 + - 11 + - 5 + - 13 + - 11 + - 5 + - 17 + - 18 + - 15 + - 6 + - 4 + out: 51 + - name: case_2 + in: + nums: + - 1 + - 13 + - 2 + - 1 + - 1 + - 18 + - 6 + - 3 + out: 37 + - name: case_3 + in: + nums: + - 17 + - 8 + - 9 + - 18 + - 17 + - 9 + - 11 + - 4 + - 1 + - 13 + - 4 + - 4 + out: 52 + - name: case_4 + in: + nums: + - 3 + - 4 + - 11 + - 11 + out: 26 + - name: case_5 + in: + nums: + - 17 + - 12 + - 17 + - 16 + - 3 + - 10 + - 8 + out: 50 + - name: case_6 + in: + nums: + - 14 + - 20 + - 20 + - 5 + out: 54 + - name: case_7 + in: + nums: + - 7 + - 8 + - 19 + - 14 + - 2 + - 20 + - 4 + - 8 + - 6 + - 8 + out: 53 + - name: case_8 + in: + nums: + - 17 + - 11 + - 6 + - 1 + out: 0 + - name: case_9 + in: + nums: + - 9 + - 13 + - 9 + - 3 + - 15 + - 16 + - 4 + - 1 + - 1 + - 4 + - 13 + - 10 + out: 44 + - name: case_10 + in: + nums: + - 5 + - 10 + - 18 + - 7 + - 4 + - 1 + out: 22 + - name: case_11 + in: + nums: + - 15 + - 3 + - 4 + - 3 + - 6 + - 14 + - 8 + - 7 + - 9 + - 5 + out: 38 + - name: case_12 + in: + nums: + - 6 + - 19 + - 17 + - 15 + - 11 + out: 51 + - name: case_13 + in: + nums: + - 3 + - 13 + - 14 + - 3 + - 7 + - 6 + - 8 + out: 35 + - name: case_14 + in: + nums: + - 12 + - 3 + - 14 + - 8 + - 20 + - 15 + - 16 + - 10 + - 11 + - 2 + - 8 + out: 51 + - name: case_15 + in: + nums: + - 12 + - 17 + - 16 + - 6 + - 8 + - 10 + - 6 + - 19 + out: 52 + - name: case_16 + in: + nums: + - 4 + - 11 + - 15 + - 16 + - 13 + - 6 + - 1 + - 1 + - 12 + out: 44 + - name: case_17 + in: + nums: + - 1 + - 9 + - 19 + - 14 + - 12 + - 2 + - 11 + - 20 + - 12 + - 18 + - 14 + - 5 + out: 57 + - name: case_18 + in: + nums: + - 7 + - 13 + - 6 + - 12 + - 18 + - 8 + - 19 + - 7 + out: 50 + - name: case_19 + in: + nums: + - 4 + - 15 + - 9 + - 20 + - 14 + - 20 + - 12 + - 17 + out: 57 + - name: case_20 + in: + nums: + - 7 + - 2 + - 18 + out: 0 + - name: case_21 + in: + nums: + - 10 + - 7 + - 9 + - 5 + - 16 + - 14 + - 11 + - 1 + - 17 + out: 47 + - name: case_22 + in: + nums: + - 9 + - 5 + - 20 + out: 0 + - name: case_23 + in: + nums: + - 17 + - 13 + - 8 + - 14 + - 10 + - 3 + - 16 + - 3 + - 9 + - 20 + out: 53 + - name: case_24 + in: + nums: + - 3 + - 10 + - 19 + - 17 + - 1 + - 18 + - 20 + - 16 + - 3 + - 14 + out: 57 + - name: case_25 + in: + nums: + - 8 + - 5 + - 8 + - 11 + out: 27 + - name: case_26 + in: + nums: + - 2 + - 10 + - 7 + - 20 + - 10 + - 8 + - 20 + - 19 + - 9 + - 5 + - 2 + out: 59 + - name: case_27 + in: + nums: + - 2 + - 11 + - 7 + - 1 + - 11 + - 3 + - 7 + - 16 + - 5 + - 19 + out: 46 + - name: case_28 + in: + nums: + - 17 + - 19 + - 4 + - 10 + - 6 + - 15 + - 7 + - 2 + - 15 + - 4 + - 18 + - 16 + out: 54 + - name: case_29 + in: + nums: + - 5 + - 16 + - 2 + - 10 + - 11 + - 6 + - 15 + - 11 + - 3 + - 20 + out: 51 + - name: case_30 + in: + nums: + - 5 + - 9 + - 1 + - 10 + - 17 + - 4 + - 15 + - 9 + out: 42 + - name: case_31 + in: + nums: + - 14 + - 20 + - 9 + - 20 + - 14 + - 15 + - 9 + - 1 + - 4 + - 13 + - 11 + out: 55 + - name: case_32 + in: + nums: + - 2 + - 8 + - 15 + - 12 + - 9 + - 2 + - 4 + out: 36 + - name: case_33 + in: + nums: + - 8 + - 8 + - 1 + out: 17 + - name: case_34 + in: + nums: + - 18 + - 17 + - 2 + - 15 + - 10 + - 1 + - 4 + - 2 + out: 50 + - name: case_35 + in: + nums: + - 1 + - 9 + - 9 + - 2 + - 17 + - 18 + - 20 + - 1 + - 9 + out: 55 diff --git a/tests/501-1000/976. largest-perimeter-triangle/sol.cpp b/tests/501-1000/976. largest-perimeter-triangle/sol.cpp new file mode 100644 index 00000000..6db14c5a --- /dev/null +++ b/tests/501-1000/976. largest-perimeter-triangle/sol.cpp @@ -0,0 +1,28 @@ +class Solution { +public: + int largestPerimeter(vector& nums) { + int minVal = *min_element(nums.begin(), nums.end()); + int maxVal = *max_element(nums.begin(), nums.end()); + + vector freq(maxVal - minVal + 1, 0); + for (int x : nums) { + freq[x - minVal]++; + } + + int idx = 0; + for (int v = maxVal; v >= minVal; v--) { + while (freq[v - minVal] > 0) { + nums[idx] = v; + idx++; + freq[v - minVal]--; + } + } + + for (int i = 0; i < nums.size() - 2; i++) { + if (nums[i + 1] + nums[i + 2] > nums[i]) { + return nums[i] + nums[i + 1] + nums[i + 2]; + } + } + return 0; + } +}; diff --git a/tests/501-1000/976. largest-perimeter-triangle/sol.cs b/tests/501-1000/976. largest-perimeter-triangle/sol.cs new file mode 100644 index 00000000..5cbbb118 --- /dev/null +++ b/tests/501-1000/976. largest-perimeter-triangle/sol.cs @@ -0,0 +1,31 @@ +public class Solution { + public int LargestPerimeter(int[] nums) { + int minVal = nums[0]; + int maxVal = nums[0]; + foreach (int x in nums) { + if (x < minVal) minVal = x; + if (x > maxVal) maxVal = x; + } + + int[] freq = new int[maxVal - minVal + 1]; + foreach (int x in nums) { + freq[x - minVal]++; + } + + int idx = 0; + for (int v = maxVal; v >= minVal; v--) { + while (freq[v - minVal] > 0) { + nums[idx] = v; + idx++; + freq[v - minVal]--; + } + } + + for (int i = 0; i < nums.Length - 2; i++) { + if (nums[i + 1] + nums[i + 2] > nums[i]) { + return nums[i] + nums[i + 1] + nums[i + 2]; + } + } + return 0; + } +} diff --git a/tests/501-1000/976. largest-perimeter-triangle/sol.dart b/tests/501-1000/976. largest-perimeter-triangle/sol.dart new file mode 100644 index 00000000..ad13cbe7 --- /dev/null +++ b/tests/501-1000/976. largest-perimeter-triangle/sol.dart @@ -0,0 +1,31 @@ +class Solution { + int largestPerimeter(List nums) { + int minVal = nums[0]; + int maxVal = nums[0]; + for (int x in nums) { + if (x < minVal) minVal = x; + if (x > maxVal) maxVal = x; + } + + List freq = List.filled(maxVal - minVal + 1, 0); + for (int x in nums) { + freq[x - minVal]++; + } + + int idx = 0; + for (int v = maxVal; v >= minVal; v--) { + while (freq[v - minVal] > 0) { + nums[idx] = v; + idx++; + freq[v - minVal]--; + } + } + + for (int i = 0; i < nums.length - 2; i++) { + if (nums[i + 1] + nums[i + 2] > nums[i]) { + return nums[i] + nums[i + 1] + nums[i + 2]; + } + } + return 0; + } +} diff --git a/tests/501-1000/976. largest-perimeter-triangle/sol.go b/tests/501-1000/976. largest-perimeter-triangle/sol.go new file mode 100644 index 00000000..94a030d6 --- /dev/null +++ b/tests/501-1000/976. largest-perimeter-triangle/sol.go @@ -0,0 +1,33 @@ +func largestPerimeter(nums []int) int { + minVal := nums[0] + maxVal := nums[0] + for _, x := range nums { + if x < minVal { + minVal = x + } + if x > maxVal { + maxVal = x + } + } + + freq := make([]int, maxVal-minVal+1) + for _, x := range nums { + freq[x-minVal]++ + } + + idx := 0 + for v := maxVal; v >= minVal; v-- { + for freq[v-minVal] > 0 { + nums[idx] = v + idx++ + freq[v-minVal]-- + } + } + + for i := 0; i < len(nums)-2; i++ { + if nums[i+1]+nums[i+2] > nums[i] { + return nums[i] + nums[i+1] + nums[i+2] + } + } + return 0 +} diff --git a/tests/501-1000/976. largest-perimeter-triangle/sol.java b/tests/501-1000/976. largest-perimeter-triangle/sol.java new file mode 100644 index 00000000..a1e39586 --- /dev/null +++ b/tests/501-1000/976. largest-perimeter-triangle/sol.java @@ -0,0 +1,31 @@ +class Solution { + public int largestPerimeter(int[] nums) { + int minVal = Integer.MAX_VALUE; + int maxVal = Integer.MIN_VALUE; + for (int x : nums) { + if (x < minVal) minVal = x; + if (x > maxVal) maxVal = x; + } + + int[] freq = new int[maxVal - minVal + 1]; + for (int x : nums) { + freq[x - minVal]++; + } + + int idx = 0; + for (int v = maxVal; v >= minVal; v--) { + while (freq[v - minVal] > 0) { + nums[idx] = v; + idx++; + freq[v - minVal]--; + } + } + + for (int i = 0; i < nums.length - 2; i++) { + if (nums[i + 1] + nums[i + 2] > nums[i]) { + return nums[i] + nums[i + 1] + nums[i + 2]; + } + } + return 0; + } +} diff --git a/tests/501-1000/976. largest-perimeter-triangle/sol.kt b/tests/501-1000/976. largest-perimeter-triangle/sol.kt new file mode 100644 index 00000000..0a0f6bdc --- /dev/null +++ b/tests/501-1000/976. largest-perimeter-triangle/sol.kt @@ -0,0 +1,27 @@ +class Solution { + fun largestPerimeter(nums: IntArray): Int { + val minVal = nums.minOrNull()!! + val maxVal = nums.maxOrNull()!! + + val freq = IntArray(maxVal - minVal + 1) + for (x in nums) { + freq[x - minVal]++ + } + + var idx = 0 + for (v in maxVal downTo minVal) { + while (freq[v - minVal] > 0) { + nums[idx] = v + idx++ + freq[v - minVal]-- + } + } + + for (i in 0 until nums.size - 2) { + if (nums[i + 1] + nums[i + 2] > nums[i]) { + return nums[i] + nums[i + 1] + nums[i + 2] + } + } + return 0 + } +} diff --git a/tests/501-1000/976. largest-perimeter-triangle/sol.py b/tests/501-1000/976. largest-perimeter-triangle/sol.py new file mode 100644 index 00000000..45723b0e --- /dev/null +++ b/tests/501-1000/976. largest-perimeter-triangle/sol.py @@ -0,0 +1,23 @@ +from typing import List + + +class Solution: + def largestPerimeter(self, nums: List[int]) -> int: + minVal = min(nums) + maxVal = max(nums) + + freq = [0] * (maxVal - minVal + 1) + for x in nums: + freq[x - minVal] += 1 + + idx = 0 + for v in range(maxVal, minVal - 1, -1): + while freq[v - minVal] > 0: + nums[idx] = v + idx += 1 + freq[v - minVal] -= 1 + + for i in range(len(nums) - 2): + if nums[i + 1] + nums[i + 2] > nums[i]: + return nums[i] + nums[i + 1] + nums[i + 2] + return 0 diff --git a/tests/501-1000/976. largest-perimeter-triangle/sol.py2 b/tests/501-1000/976. largest-perimeter-triangle/sol.py2 new file mode 100644 index 00000000..4b155d45 --- /dev/null +++ b/tests/501-1000/976. largest-perimeter-triangle/sol.py2 @@ -0,0 +1,24 @@ +class Solution(object): + def largestPerimeter(self, nums): + """ + :type nums: List[int] + :rtype: int + """ + minVal = min(nums) + maxVal = max(nums) + + freq = [0] * (maxVal - minVal + 1) + for x in nums: + freq[x - minVal] += 1 + + idx = 0 + for v in range(maxVal, minVal - 1, -1): + while freq[v - minVal] > 0: + nums[idx] = v + idx += 1 + freq[v - minVal] -= 1 + + for i in range(len(nums) - 2): + if nums[i + 1] + nums[i + 2] > nums[i]: + return nums[i] + nums[i + 1] + nums[i + 2] + return 0 diff --git a/tests/501-1000/976. largest-perimeter-triangle/sol.rb b/tests/501-1000/976. largest-perimeter-triangle/sol.rb new file mode 100644 index 00000000..66267c12 --- /dev/null +++ b/tests/501-1000/976. largest-perimeter-triangle/sol.rb @@ -0,0 +1,27 @@ +# @param {Integer[]} nums +# @return {Integer} +def largest_perimeter(nums) + min_val = nums.min + max_val = nums.max + + freq = [0] * (max_val - min_val + 1) + nums.each do |x| + freq[x - min_val] += 1 + end + + idx = 0 + max_val.downto(min_val) do |v| + while freq[v - min_val] > 0 + nums[idx] = v + idx += 1 + freq[v - min_val] -= 1 + end + end + + (0...nums.length - 2).each do |i| + if nums[i + 1] + nums[i + 2] > nums[i] + return nums[i] + nums[i + 1] + nums[i + 2] + end + end + return 0 +end diff --git a/tests/501-1000/976. largest-perimeter-triangle/sol.rs b/tests/501-1000/976. largest-perimeter-triangle/sol.rs new file mode 100644 index 00000000..42465ad5 --- /dev/null +++ b/tests/501-1000/976. largest-perimeter-triangle/sol.rs @@ -0,0 +1,28 @@ +impl Solution { + pub fn largest_perimeter(nums: Vec) -> i32 { + let mut nums = nums; + let min_val = *nums.iter().min().unwrap(); + let max_val = *nums.iter().max().unwrap(); + + let mut freq = vec![0; (max_val - min_val + 1) as usize]; + for &x in &nums { + freq[(x - min_val) as usize] += 1; + } + + let mut idx = 0; + for v in (min_val..=max_val).rev() { + while freq[(v - min_val) as usize] > 0 { + nums[idx] = v; + idx += 1; + freq[(v - min_val) as usize] -= 1; + } + } + + for i in 0..nums.len() - 2 { + if nums[i + 1] + nums[i + 2] > nums[i] { + return nums[i] + nums[i + 1] + nums[i + 2]; + } + } + 0 + } +} diff --git a/tests/501-1000/976. largest-perimeter-triangle/sol.swift b/tests/501-1000/976. largest-perimeter-triangle/sol.swift new file mode 100644 index 00000000..af075241 --- /dev/null +++ b/tests/501-1000/976. largest-perimeter-triangle/sol.swift @@ -0,0 +1,28 @@ +class Solution { + func largestPerimeter(_ nums: [Int]) -> Int { + var nums = nums + let minVal = nums.min()! + let maxVal = nums.max()! + + var freq = [Int](repeating: 0, count: maxVal - minVal + 1) + for x in nums { + freq[x - minVal] += 1 + } + + var idx = 0 + for v in stride(from: maxVal, through: minVal, by: -1) { + while freq[v - minVal] > 0 { + nums[idx] = v + idx += 1 + freq[v - minVal] -= 1 + } + } + + for i in 0.. nums[i] { + return nums[i] + nums[i + 1] + nums[i + 2] + } + } + return 0 + } +} diff --git a/tests/501-1000/976. largest-perimeter-triangle/sol.ts b/tests/501-1000/976. largest-perimeter-triangle/sol.ts new file mode 100644 index 00000000..6a4d3056 --- /dev/null +++ b/tests/501-1000/976. largest-perimeter-triangle/sol.ts @@ -0,0 +1,25 @@ +function largestPerimeter(nums: number[]): number { + const minVal = Math.min(...nums); + const maxVal = Math.max(...nums); + + const freq = new Array(maxVal - minVal + 1).fill(0); + for (const x of nums) { + freq[x - minVal]++; + } + + let idx = 0; + for (let v = maxVal; v >= minVal; v--) { + while (freq[v - minVal] > 0) { + nums[idx] = v; + idx++; + freq[v - minVal]--; + } + } + + for (let i = 0; i < nums.length - 2; i++) { + if (nums[i + 1] + nums[i + 2] > nums[i]) { + return nums[i] + nums[i + 1] + nums[i + 2]; + } + } + return 0; +} diff --git a/tests/501-1000/977. squares-of-a-sorted-array/manifest.yaml b/tests/501-1000/977. squares-of-a-sorted-array/manifest.yaml new file mode 100644 index 00000000..1d540ebd --- /dev/null +++ b/tests/501-1000/977. squares-of-a-sorted-array/manifest.yaml @@ -0,0 +1,620 @@ +entry: + id: 977 + title: squares-of-a-sorted-array + params: + nums: + type: array + items: + type: int + call: + cpp: Solution().sortedSquares({nums}) + rust: Solution::sorted_squares({nums}) + python3: Solution().sortedSquares({nums}) + python2: Solution().sortedSquares({nums}) + ruby: sorted_squares({nums}) + java: new Solution().sortedSquares({nums}) + csharp: new Solution().SortedSquares({nums}) + kotlin: Solution().sortedSquares({nums}) + go: sortedSquares({nums}) + dart: Solution().sortedSquares({nums}) + swift: Solution().sortedSquares({nums}) + typescript: sortedSquares({nums}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 977 +tests: + - name: case_1 + in: + nums: + - -14 + - -11 + out: + - 121 + - 196 + - name: case_2 + in: + nums: + - -11 + - -10 + - -10 + - -6 + - -4 + - -3 + - -2 + - 1 + - 6 + - 10 + out: + - 1 + - 4 + - 9 + - 16 + - 36 + - 36 + - 100 + - 100 + - 100 + - 121 + - name: case_3 + in: + nums: + - -12 + - -12 + - -2 + - 3 + - 6 + - 8 + out: + - 4 + - 9 + - 36 + - 64 + - 144 + - 144 + - name: case_4 + in: + nums: + - -20 + - -19 + - -13 + - -11 + - -4 + - -3 + - 2 + - 15 + out: + - 4 + - 9 + - 16 + - 121 + - 169 + - 225 + - 361 + - 400 + - name: case_5 + in: + nums: + - -7 + out: + - 49 + - name: case_6 + in: + nums: + - -20 + - -17 + - -15 + - -11 + - -3 + - 0 + - 3 + - 5 + - 6 + - 9 + - 12 + - 17 + out: + - 0 + - 9 + - 9 + - 25 + - 36 + - 81 + - 121 + - 144 + - 225 + - 289 + - 289 + - 400 + - name: case_7 + in: + nums: + - -18 + - -4 + - -4 + - -2 + - -1 + - 5 + - 9 + - 11 + - 18 + - 20 + out: + - 1 + - 4 + - 16 + - 16 + - 25 + - 81 + - 121 + - 324 + - 324 + - 400 + - name: case_8 + in: + nums: + - -16 + - -8 + - -1 + - 3 + - 10 + - 14 + - 19 + out: + - 1 + - 9 + - 64 + - 100 + - 196 + - 256 + - 361 + - name: case_9 + in: + nums: + - -5 + - 1 + - 8 + out: + - 1 + - 25 + - 64 + - name: case_10 + in: + nums: + - -11 + out: + - 121 + - name: case_11 + in: + nums: + - -20 + - -18 + - -8 + - -7 + - -7 + - -6 + - -5 + - -4 + - -2 + - 14 + out: + - 4 + - 16 + - 25 + - 36 + - 49 + - 49 + - 64 + - 196 + - 324 + - 400 + - name: case_12 + in: + nums: + - -7 + - -4 + - 14 + out: + - 16 + - 49 + - 196 + - name: case_13 + in: + nums: + - -16 + - -9 + - -7 + - -5 + - -4 + - -3 + - 14 + - 18 + out: + - 9 + - 16 + - 25 + - 49 + - 81 + - 196 + - 256 + - 324 + - name: case_14 + in: + nums: + - -17 + - -14 + - -9 + - -6 + - -5 + - -5 + - -5 + - -3 + - 2 + - 2 + - 10 + - 11 + out: + - 4 + - 4 + - 9 + - 25 + - 25 + - 25 + - 36 + - 81 + - 100 + - 121 + - 196 + - 289 + - name: case_15 + in: + nums: + - -19 + - -14 + - -10 + - -7 + - -2 + - 4 + - 10 + - 11 + out: + - 4 + - 16 + - 49 + - 100 + - 100 + - 121 + - 196 + - 361 + - name: case_16 + in: + nums: + - 11 + - 11 + - 12 + out: + - 121 + - 121 + - 144 + - name: case_17 + in: + nums: + - -18 + - -14 + - -14 + - -13 + - 0 + - 4 + - 7 + - 12 + - 14 + - 17 + out: + - 0 + - 16 + - 49 + - 144 + - 169 + - 196 + - 196 + - 196 + - 289 + - 324 + - name: case_18 + in: + nums: + - -20 + - -18 + - -16 + - -13 + - -13 + - -9 + - 2 + out: + - 4 + - 81 + - 169 + - 169 + - 256 + - 324 + - 400 + - name: case_19 + in: + nums: + - -14 + out: + - 196 + - name: case_20 + in: + nums: + - -11 + - -11 + - 15 + out: + - 121 + - 121 + - 225 + - name: case_21 + in: + nums: + - -17 + - 0 + - 4 + - 10 + out: + - 0 + - 16 + - 100 + - 289 + - name: case_22 + in: + nums: + - -19 + - -15 + - -14 + - 1 + - 2 + - 11 + - 11 + out: + - 1 + - 4 + - 121 + - 121 + - 196 + - 225 + - 361 + - name: case_23 + in: + nums: + - -15 + - -15 + - -13 + - -8 + - -6 + - 13 + - 15 + - 18 + out: + - 36 + - 64 + - 169 + - 169 + - 225 + - 225 + - 225 + - 324 + - name: case_24 + in: + nums: + - -16 + - -14 + - -8 + - -7 + - -4 + - -2 + - 0 + - 1 + - 11 + - 14 + - 15 + - 16 + out: + - 0 + - 1 + - 4 + - 16 + - 49 + - 64 + - 121 + - 196 + - 196 + - 225 + - 256 + - 256 + - name: case_25 + in: + nums: + - -17 + out: + - 289 + - name: case_26 + in: + nums: + - -17 + - -14 + - 0 + - 5 + - 5 + - 6 + - 10 + - 11 + - 12 + - 20 + out: + - 0 + - 25 + - 25 + - 36 + - 100 + - 121 + - 144 + - 196 + - 289 + - 400 + - name: case_27 + in: + nums: + - -20 + - -17 + - -16 + - -1 + - 4 + - 6 + - 7 + - 13 + - 19 + - 20 + out: + - 1 + - 16 + - 36 + - 49 + - 169 + - 256 + - 289 + - 361 + - 400 + - 400 + - name: case_28 + in: + nums: + - -19 + - -18 + - -10 + - 0 + - 5 + out: + - 0 + - 25 + - 100 + - 324 + - 361 + - name: case_29 + in: + nums: + - -20 + out: + - 400 + - name: case_30 + in: + nums: + - -7 + - -4 + - 6 + - 8 + - 11 + - 17 + - 20 + out: + - 16 + - 36 + - 49 + - 64 + - 121 + - 289 + - 400 + - name: case_31 + in: + nums: + - -20 + - -14 + - -12 + - -11 + - -3 + - -2 + - 10 + - 11 + - 13 + - 17 + out: + - 4 + - 9 + - 100 + - 121 + - 121 + - 144 + - 169 + - 196 + - 289 + - 400 + - name: case_32 + in: + nums: + - -19 + - -11 + - -8 + - -7 + - -1 + - 15 + out: + - 1 + - 49 + - 64 + - 121 + - 225 + - 361 + - name: case_33 + in: + nums: + - -19 + - -15 + - -14 + - -12 + - -9 + - -7 + - -6 + - 0 + - 7 + - 8 + - 20 + out: + - 0 + - 36 + - 49 + - 49 + - 64 + - 81 + - 144 + - 196 + - 225 + - 361 + - 400 + - name: case_34 + in: + nums: + - -7 + - -7 + - 1 + - 10 + - 13 + - 15 + out: + - 1 + - 49 + - 49 + - 100 + - 169 + - 225 + - name: case_35 + in: + nums: + - -17 + out: + - 289 diff --git a/tests/501-1000/977. squares-of-a-sorted-array/sol.cpp b/tests/501-1000/977. squares-of-a-sorted-array/sol.cpp new file mode 100644 index 00000000..1d479970 --- /dev/null +++ b/tests/501-1000/977. squares-of-a-sorted-array/sol.cpp @@ -0,0 +1,11 @@ +class Solution { +public: + vector sortedSquares(vector& nums) { + vector newarr; + for (int i : nums) { + newarr.push_back(i * i); + } + sort(newarr.begin(), newarr.end()); + return newarr; + } +}; diff --git a/tests/501-1000/977. squares-of-a-sorted-array/sol.cs b/tests/501-1000/977. squares-of-a-sorted-array/sol.cs new file mode 100644 index 00000000..bc8c84dd --- /dev/null +++ b/tests/501-1000/977. squares-of-a-sorted-array/sol.cs @@ -0,0 +1,10 @@ +public class Solution { + public int[] SortedSquares(int[] nums) { + int[] newarr = new int[nums.Length]; + for (int i = 0; i < nums.Length; i++) { + newarr[i] = nums[i] * nums[i]; + } + Array.Sort(newarr); + return newarr; + } +} diff --git a/tests/501-1000/977. squares-of-a-sorted-array/sol.dart b/tests/501-1000/977. squares-of-a-sorted-array/sol.dart new file mode 100644 index 00000000..8baea623 --- /dev/null +++ b/tests/501-1000/977. squares-of-a-sorted-array/sol.dart @@ -0,0 +1,10 @@ +class Solution { + List sortedSquares(List nums) { + List newarr = []; + for (int i in nums) { + newarr.add(i * i); + } + newarr.sort(); + return newarr; + } +} diff --git a/tests/501-1000/977. squares-of-a-sorted-array/sol.go b/tests/501-1000/977. squares-of-a-sorted-array/sol.go new file mode 100644 index 00000000..c4bea08c --- /dev/null +++ b/tests/501-1000/977. squares-of-a-sorted-array/sol.go @@ -0,0 +1,8 @@ +func sortedSquares(nums []int) []int { + newarr := make([]int, len(nums)) + for i, v := range nums { + newarr[i] = v * v + } + sort.Ints(newarr) + return newarr +} diff --git a/tests/501-1000/977. squares-of-a-sorted-array/sol.java b/tests/501-1000/977. squares-of-a-sorted-array/sol.java new file mode 100644 index 00000000..7122fd3b --- /dev/null +++ b/tests/501-1000/977. squares-of-a-sorted-array/sol.java @@ -0,0 +1,10 @@ +class Solution { + public int[] sortedSquares(int[] nums) { + int[] newarr = new int[nums.length]; + for (int i = 0; i < nums.length; i++) { + newarr[i] = nums[i] * nums[i]; + } + Arrays.sort(newarr); + return newarr; + } +} diff --git a/tests/501-1000/977. squares-of-a-sorted-array/sol.kt b/tests/501-1000/977. squares-of-a-sorted-array/sol.kt new file mode 100644 index 00000000..a208b3cd --- /dev/null +++ b/tests/501-1000/977. squares-of-a-sorted-array/sol.kt @@ -0,0 +1,10 @@ +class Solution { + fun sortedSquares(nums: IntArray): IntArray { + val newarr = mutableListOf() + for (i in nums) { + newarr.add(i * i) + } + newarr.sort() + return newarr.toIntArray() + } +} diff --git a/tests/501-1000/977. squares-of-a-sorted-array/sol.py b/tests/501-1000/977. squares-of-a-sorted-array/sol.py new file mode 100644 index 00000000..2e03c997 --- /dev/null +++ b/tests/501-1000/977. squares-of-a-sorted-array/sol.py @@ -0,0 +1,11 @@ +from typing import List + + +class Solution: + def sortedSquares(self, nums: List[int]) -> List[int]: + + newarr = [] + for i in nums: + newarr.append(i * i) + newarr.sort() + return newarr diff --git a/tests/501-1000/977. squares-of-a-sorted-array/sol.py2 b/tests/501-1000/977. squares-of-a-sorted-array/sol.py2 new file mode 100644 index 00000000..4af091b6 --- /dev/null +++ b/tests/501-1000/977. squares-of-a-sorted-array/sol.py2 @@ -0,0 +1,11 @@ +class Solution(object): + def sortedSquares(self, nums): + """ + :type nums: List[int] + :rtype: List[int] + """ + newarr = [] + for i in nums: + newarr.append(i*i) + newarr.sort() + return newarr diff --git a/tests/501-1000/977. squares-of-a-sorted-array/sol.rb b/tests/501-1000/977. squares-of-a-sorted-array/sol.rb new file mode 100644 index 00000000..17e3c1f0 --- /dev/null +++ b/tests/501-1000/977. squares-of-a-sorted-array/sol.rb @@ -0,0 +1,10 @@ +# @param {Integer[]} nums +# @return {Integer[]} +def sorted_squares(nums) + newarr = [] + nums.each do |i| + newarr.push(i*i) + end + newarr.sort! + newarr +end diff --git a/tests/501-1000/977. squares-of-a-sorted-array/sol.rs b/tests/501-1000/977. squares-of-a-sorted-array/sol.rs new file mode 100644 index 00000000..652e1d07 --- /dev/null +++ b/tests/501-1000/977. squares-of-a-sorted-array/sol.rs @@ -0,0 +1,10 @@ +impl Solution { + pub fn sorted_squares(nums: Vec) -> Vec { + let mut newarr: Vec = Vec::new(); + for i in nums { + newarr.push(i * i); + } + newarr.sort(); + newarr + } +} diff --git a/tests/501-1000/977. squares-of-a-sorted-array/sol.swift b/tests/501-1000/977. squares-of-a-sorted-array/sol.swift new file mode 100644 index 00000000..5fa2b4b7 --- /dev/null +++ b/tests/501-1000/977. squares-of-a-sorted-array/sol.swift @@ -0,0 +1,10 @@ +class Solution { + func sortedSquares(_ nums: [Int]) -> [Int] { + var newarr: [Int] = [] + for i in nums { + newarr.append(i * i) + } + newarr.sort() + return newarr + } +} diff --git a/tests/501-1000/977. squares-of-a-sorted-array/sol.ts b/tests/501-1000/977. squares-of-a-sorted-array/sol.ts new file mode 100644 index 00000000..97400f06 --- /dev/null +++ b/tests/501-1000/977. squares-of-a-sorted-array/sol.ts @@ -0,0 +1,8 @@ +function sortedSquares(nums: number[]): number[] { + const newarr: number[] = []; + for (const i of nums) { + newarr.push(i * i); + } + newarr.sort((a, b) => a - b); + return newarr; +} diff --git a/tests/501-1000/978. longest-turbulent-subarray/manifest.yaml b/tests/501-1000/978. longest-turbulent-subarray/manifest.yaml new file mode 100644 index 00000000..1de4277c --- /dev/null +++ b/tests/501-1000/978. longest-turbulent-subarray/manifest.yaml @@ -0,0 +1,418 @@ +entry: + id: 978 + title: longest-turbulent-subarray + params: + arr: + type: array + items: + type: int + call: + cpp: Solution().maxTurbulenceSize({arr}) + rust: Solution::max_turbulence_size({arr}) + python3: Solution().maxTurbulenceSize({arr}) + python2: Solution().maxTurbulenceSize({arr}) + ruby: max_turbulence_size({arr}) + java: new Solution().maxTurbulenceSize({arr}) + csharp: new Solution().MaxTurbulenceSize({arr}) + kotlin: Solution().maxTurbulenceSize({arr}) + go: maxTurbulenceSize({arr}) + dart: Solution().maxTurbulenceSize({arr}) + swift: Solution().maxTurbulenceSize({arr}) + typescript: maxTurbulenceSize({arr}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 978 +tests: + - name: case_1 + in: + arr: + - 17 + - 12 + - 15 + - 12 + - 1 + - 1 + - 9 + - 19 + - 13 + - 4 + - 9 + - 11 + out: 4 + - name: case_2 + in: + arr: + - 18 + out: 1 + - name: case_3 + in: + arr: + - 2 + - 14 + - 12 + - 20 + - 1 + - 2 + - 15 + - 10 + out: 6 + - name: case_4 + in: + arr: + - 19 + - 10 + out: 2 + - name: case_5 + in: + arr: + - 2 + - 1 + - 13 + - 8 + - 0 + out: 4 + - name: case_6 + in: + arr: + - 20 + - 0 + - 2 + - 1 + - 6 + - 13 + out: 5 + - name: case_7 + in: + arr: + - 10 + - 19 + - 9 + - 17 + - 9 + - 19 + - 7 + - 17 + out: 8 + - name: case_8 + in: + arr: + - 10 + - 11 + - 8 + - 16 + out: 4 + - name: case_9 + in: + arr: + - 1 + - 19 + - 7 + - 6 + - 14 + - 3 + - 19 + - 4 + - 13 + - 16 + out: 7 + - name: case_10 + in: + arr: + - 2 + - 2 + out: 1 + - name: case_11 + in: + arr: + - 2 + - 13 + - 14 + - 0 + - 8 + - 17 + - 7 + - 6 + - 19 + - 7 + - 19 + - 14 + out: 6 + - name: case_12 + in: + arr: + - 9 + - 8 + - 11 + - 3 + - 7 + - 18 + out: 5 + - name: case_13 + in: + arr: + - 9 + - 0 + - 9 + - 1 + - 17 + out: 5 + - name: case_14 + in: + arr: + - 7 + - 17 + - 16 + - 6 + - 0 + - 17 + out: 3 + - name: case_15 + in: + arr: + - 5 + - 4 + - 11 + - 19 + - 0 + - 14 + - 13 + - 13 + out: 5 + - name: case_16 + in: + arr: + - 6 + - 0 + - 16 + out: 3 + - name: case_17 + in: + arr: + - 3 + - 10 + - 5 + out: 3 + - name: case_18 + in: + arr: + - 5 + - 0 + - 13 + - 16 + - 19 + - 17 + - 15 + - 6 + - 8 + - 6 + - 3 + - 11 + out: 4 + - name: case_19 + in: + arr: + - 5 + - 10 + - 18 + - 12 + - 14 + - 16 + - 3 + - 11 + - 11 + - 16 + - 17 + - 19 + out: 4 + - name: case_20 + in: + arr: + - 2 + - 6 + - 4 + - 1 + - 0 + - 18 + - 5 + out: 4 + - name: case_21 + in: + arr: + - 6 + - 18 + - 20 + - 11 + - 8 + - 16 + - 20 + - 0 + out: 3 + - name: case_22 + in: + arr: + - 15 + - 7 + - 8 + out: 3 + - name: case_23 + in: + arr: + - 5 + - 1 + - 12 + - 19 + - 0 + - 6 + - 14 + out: 4 + - name: case_24 + in: + arr: + - 14 + - 2 + - 8 + - 9 + - 7 + - 3 + - 16 + - 1 + out: 4 + - name: case_25 + in: + arr: + - 9 + - 15 + - 4 + - 5 + - 14 + - 3 + - 1 + - 0 + - 2 + - 18 + - 16 + - 20 + out: 4 + - name: case_26 + in: + arr: + - 11 + - 13 + - 12 + - 10 + - 1 + out: 3 + - name: case_27 + in: + arr: + - 3 + - 15 + - 13 + - 11 + - 15 + - 0 + - 14 + - 20 + out: 5 + - name: case_28 + in: + arr: + - 5 + - 4 + - 2 + - 16 + out: 3 + - name: case_29 + in: + arr: + - 19 + - 4 + - 6 + - 19 + - 13 + - 10 + - 18 + - 17 + - 12 + - 4 + - 12 + out: 4 + - name: case_30 + in: + arr: + - 10 + - 10 + - 20 + - 12 + - 2 + - 3 + out: 3 + - name: case_31 + in: + arr: + - 11 + - 1 + - 17 + - 5 + - 14 + - 11 + - 7 + - 4 + - 17 + - 13 + - 13 + out: 6 + - name: case_32 + in: + arr: + - 15 + - 14 + - 3 + - 15 + - 15 + - 6 + - 12 + - 5 + out: 4 + - name: case_33 + in: + arr: + - 20 + - 0 + - 14 + - 20 + - 18 + - 12 + - 2 + - 10 + - 18 + - 10 + out: 3 + - name: case_34 + in: + arr: + - 5 + - 17 + - 15 + - 10 + - 15 + - 5 + - 3 + - 14 + out: 4 + - name: case_35 + in: + arr: + - 19 + - 2 + - 19 + - 10 + - 13 + out: 5 diff --git a/tests/501-1000/978. longest-turbulent-subarray/sol.cpp b/tests/501-1000/978. longest-turbulent-subarray/sol.cpp new file mode 100644 index 00000000..81e52f4a --- /dev/null +++ b/tests/501-1000/978. longest-turbulent-subarray/sol.cpp @@ -0,0 +1,29 @@ +class Solution { +public: + int maxTurbulenceSize(vector& arr) { + int N = arr.size(); + if (N < 2) return N; + + int ans = 1; + int anchor = 0; + + auto compare = [](int x, int y) -> int { + if (x < y) return -1; + if (x > y) return 1; + return 0; + }; + + for (int i = 1; i < N; i++) { + int c = compare(arr[i - 1], arr[i]); + if (c == 0) { + anchor = i; + } else { + if (i == N - 1 || c * compare(arr[i], arr[i + 1]) != -1) { + ans = max(ans, i - anchor + 1); + anchor = i; + } + } + } + return ans; + } +}; diff --git a/tests/501-1000/978. longest-turbulent-subarray/sol.cs b/tests/501-1000/978. longest-turbulent-subarray/sol.cs new file mode 100644 index 00000000..2a28b9f3 --- /dev/null +++ b/tests/501-1000/978. longest-turbulent-subarray/sol.cs @@ -0,0 +1,28 @@ +public class Solution { + public int MaxTurbulenceSize(int[] arr) { + int N = arr.Length; + if (N < 2) return N; + + int ans = 1; + int anchor = 0; + + int Compare(int x, int y) { + if (x < y) return -1; + if (x > y) return 1; + return 0; + } + + for (int i = 1; i < N; i++) { + int c = Compare(arr[i - 1], arr[i]); + if (c == 0) { + anchor = i; + } else { + if (i == N - 1 || c * Compare(arr[i], arr[i + 1]) != -1) { + ans = Math.Max(ans, i - anchor + 1); + anchor = i; + } + } + } + return ans; + } +} diff --git a/tests/501-1000/978. longest-turbulent-subarray/sol.dart b/tests/501-1000/978. longest-turbulent-subarray/sol.dart new file mode 100644 index 00000000..b340b1ca --- /dev/null +++ b/tests/501-1000/978. longest-turbulent-subarray/sol.dart @@ -0,0 +1,28 @@ +class Solution { + int maxTurbulenceSize(List arr) { + int N = arr.length; + if (N < 2) return N; + + int ans = 1; + int anchor = 0; + + int compare(int x, int y) { + if (x < y) return -1; + if (x > y) return 1; + return 0; + } + + for (int i = 1; i < N; i++) { + int c = compare(arr[i - 1], arr[i]); + if (c == 0) { + anchor = i; + } else { + if (i == N - 1 || c * compare(arr[i], arr[i + 1]) != -1) { + ans = ans > (i - anchor + 1) ? ans : (i - anchor + 1); + anchor = i; + } + } + } + return ans; + } +} diff --git a/tests/501-1000/978. longest-turbulent-subarray/sol.go b/tests/501-1000/978. longest-turbulent-subarray/sol.go new file mode 100644 index 00000000..18c513a0 --- /dev/null +++ b/tests/501-1000/978. longest-turbulent-subarray/sol.go @@ -0,0 +1,34 @@ +func maxTurbulenceSize(arr []int) int { + N := len(arr) + if N < 2 { + return N + } + + ans := 1 + anchor := 0 + + compare := func(x, y int) int { + if x < y { + return -1 + } + if x > y { + return 1 + } + return 0 + } + + for i := 1; i < N; i++ { + c := compare(arr[i-1], arr[i]) + if c == 0 { + anchor = i + } else { + if i == N-1 || c*compare(arr[i], arr[i+1]) != -1 { + if i-anchor+1 > ans { + ans = i - anchor + 1 + } + anchor = i + } + } + } + return ans +} diff --git a/tests/501-1000/978. longest-turbulent-subarray/sol.java b/tests/501-1000/978. longest-turbulent-subarray/sol.java new file mode 100644 index 00000000..7bfd57ae --- /dev/null +++ b/tests/501-1000/978. longest-turbulent-subarray/sol.java @@ -0,0 +1,28 @@ +class Solution { + public int maxTurbulenceSize(int[] arr) { + int N = arr.length; + if (N < 2) return N; + + int ans = 1; + int anchor = 0; + + for (int i = 1; i < N; i++) { + int c = compare(arr[i - 1], arr[i]); + if (c == 0) { + anchor = i; + } else { + if (i == N - 1 || c * compare(arr[i], arr[i + 1]) != -1) { + ans = Math.max(ans, i - anchor + 1); + anchor = i; + } + } + } + return ans; + } + + private int compare(int x, int y) { + if (x < y) return -1; + if (x > y) return 1; + return 0; + } +} diff --git a/tests/501-1000/978. longest-turbulent-subarray/sol.kt b/tests/501-1000/978. longest-turbulent-subarray/sol.kt new file mode 100644 index 00000000..8f39f724 --- /dev/null +++ b/tests/501-1000/978. longest-turbulent-subarray/sol.kt @@ -0,0 +1,30 @@ +class Solution { + fun maxTurbulenceSize(arr: IntArray): Int { + val N = arr.size + if (N < 2) return N + + var ans = 1 + var anchor = 0 + + fun compare(x: Int, y: Int): Int { + return when { + x < y -> -1 + x > y -> 1 + else -> 0 + } + } + + for (i in 1 until N) { + val c = compare(arr[i - 1], arr[i]) + if (c == 0) { + anchor = i + } else { + if (i == N - 1 || c * compare(arr[i], arr[i + 1]) != -1) { + ans = maxOf(ans, i - anchor + 1) + anchor = i + } + } + } + return ans + } +} diff --git a/tests/501-1000/978. longest-turbulent-subarray/sol.py b/tests/501-1000/978. longest-turbulent-subarray/sol.py new file mode 100644 index 00000000..a16b659a --- /dev/null +++ b/tests/501-1000/978. longest-turbulent-subarray/sol.py @@ -0,0 +1,25 @@ +class Solution: + def maxTurbulenceSize(self, arr): + N = len(arr) + if N < 2: + return N + + ans = 1 + anchor = 0 + + def compare(x, y): + if x < y: + return -1 + if x > y: + return 1 + return 0 + + for i in range(1, N): + c = compare(arr[i - 1], arr[i]) + if c == 0: + anchor = i + else: + if i == N - 1 or c * compare(arr[i], arr[i + 1]) != -1: + ans = max(ans, i - anchor + 1) + anchor = i + return ans diff --git a/tests/501-1000/978. longest-turbulent-subarray/sol.py2 b/tests/501-1000/978. longest-turbulent-subarray/sol.py2 new file mode 100644 index 00000000..99265a40 --- /dev/null +++ b/tests/501-1000/978. longest-turbulent-subarray/sol.py2 @@ -0,0 +1,29 @@ +class Solution(object): + def maxTurbulenceSize(self, arr): + """ + :type arr: List[int] + :rtype: int + """ + N = len(arr) + if N < 2: + return N + + ans = 1 + anchor = 0 + + def compare(x, y): + if x < y: + return -1 + if x > y: + return 1 + return 0 + + for i in range(1, N): + c = compare(arr[i - 1], arr[i]) + if c == 0: + anchor = i + else: + if i == N - 1 or c * compare(arr[i], arr[i + 1]) != -1: + ans = max(ans, i - anchor + 1) + anchor = i + return ans diff --git a/tests/501-1000/978. longest-turbulent-subarray/sol.rb b/tests/501-1000/978. longest-turbulent-subarray/sol.rb new file mode 100644 index 00000000..e5e7cb49 --- /dev/null +++ b/tests/501-1000/978. longest-turbulent-subarray/sol.rb @@ -0,0 +1,32 @@ +# @param {Integer[]} arr +# @return {Integer} +def max_turbulence_size(arr) + n = arr.length + return n if n < 2 + + ans = 1 + anchor = 0 + + compare = ->(x, y) { + if x < y + -1 + elsif x > y + 1 + else + 0 + end + } + + (1...n).each do |i| + c = compare.call(arr[i - 1], arr[i]) + if c == 0 + anchor = i + else + if i == n - 1 || c * compare.call(arr[i], arr[i + 1]) != -1 + ans = [ans, i - anchor + 1].max + anchor = i + end + end + end + ans +end diff --git a/tests/501-1000/978. longest-turbulent-subarray/sol.rs b/tests/501-1000/978. longest-turbulent-subarray/sol.rs new file mode 100644 index 00000000..129215f4 --- /dev/null +++ b/tests/501-1000/978. longest-turbulent-subarray/sol.rs @@ -0,0 +1,30 @@ +impl Solution { + pub fn max_turbulence_size(arr: Vec) -> i32 { + let n = arr.len(); + if n < 2 { + return n as i32; + } + + let mut ans = 1; + let mut anchor = 0; + + let compare = |x: i32, y: i32| -> i32 { + if x < y { -1 } + else if x > y { 1 } + else { 0 } + }; + + for i in 1..n { + let c = compare(arr[i - 1], arr[i]); + if c == 0 { + anchor = i; + } else { + if i == n - 1 || c * compare(arr[i], arr[i + 1]) != -1 { + ans = ans.max((i - anchor + 1) as i32); + anchor = i; + } + } + } + ans + } +} diff --git a/tests/501-1000/978. longest-turbulent-subarray/sol.swift b/tests/501-1000/978. longest-turbulent-subarray/sol.swift new file mode 100644 index 00000000..161faf25 --- /dev/null +++ b/tests/501-1000/978. longest-turbulent-subarray/sol.swift @@ -0,0 +1,28 @@ +class Solution { + func maxTurbulenceSize(_ arr: [Int]) -> Int { + let N = arr.count + if N < 2 { return N } + + var ans = 1 + var anchor = 0 + + func compare(_ x: Int, _ y: Int) -> Int { + if x < y { return -1 } + if x > y { return 1 } + return 0 + } + + for i in 1.. { + if (x < y) return -1; + if (x > y) return 1; + return 0; + }; + + for (let i = 1; i < N; i++) { + const c = compare(arr[i - 1], arr[i]); + if (c === 0) { + anchor = i; + } else { + if (i === N - 1 || c * compare(arr[i], arr[i + 1]) !== -1) { + ans = Math.max(ans, i - anchor + 1); + anchor = i; + } + } + } + return ans; +} diff --git a/tests/501-1000/979. distribute-coins-in-binary-tree/manifest.yaml b/tests/501-1000/979. distribute-coins-in-binary-tree/manifest.yaml new file mode 100644 index 00000000..39063c52 --- /dev/null +++ b/tests/501-1000/979. distribute-coins-in-binary-tree/manifest.yaml @@ -0,0 +1,410 @@ +entry: + id: 979 + title: distribute-coins-in-binary-tree + params: + root: + type: tree_node + call: + cpp: Solution().distributeCoins({root}) + rust: Solution::distribute_coins({root}) + python3: Solution().distributeCoins({root}) + python2: Solution().distributeCoins({root}) + ruby: distribute_coins({root}) + java: new Solution().distributeCoins({root}) + csharp: new Solution().DistributeCoins({root}) + kotlin: Solution().distributeCoins({root}) + go: distributeCoins({root}) + dart: Solution().distributeCoins({root}) + swift: Solution().distributeCoins({root}) + typescript: distributeCoins({root}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 979 +tests: + - name: case_1 + in: + root: + - 0 + - 1 + - 0 + - 2 + - null + - 1 + - null + - 2 + out: 6 + - name: case_2 + in: + root: + - 2 + - 1 + - 0 + - 0 + - null + - 1 + - 2 + out: 3 + - name: case_3 + in: + root: + - 0 + - 1 + - 0 + - null + - 3 + - 1 + out: 5 + - name: case_4 + in: + root: + - 0 + - 2 + - 1 + - 3 + - 0 + - null + - 0 + out: 7 + - name: case_5 + in: + root: + - 0 + - 1 + - 2 + - 3 + - null + - null + - null + - 0 + - 0 + - 1 + - 1 + out: 3 + - name: case_6 + in: + root: + - 1 + out: 0 + - name: case_7 + in: + root: + - 0 + - 1 + - 1 + - null + - 3 + - 0 + - null + - null + - null + - null + - 1 + - 2 + - 0 + out: 8 + - name: case_8 + in: + root: + - 1 + - null + - 1 + out: 0 + - name: case_9 + in: + root: + - 0 + - 1 + - 1 + - 1 + - null + - 0 + - 2 + - 2 + out: 5 + - name: case_10 + in: + root: + - 1 + - 1 + - 0 + - 1 + - 2 + out: 3 + - name: case_11 + in: + root: + - 3 + - 0 + - 0 + out: 2 + - name: case_12 + in: + root: + - 2 + - 0 + out: 1 + - name: case_13 + in: + root: + - 0 + - 1 + - 1 + - 2 + - 0 + - 0 + - 1 + - null + - 3 + out: 10 + - name: case_14 + in: + root: + - 1 + - 0 + - 0 + - 3 + - null + - null + - null + - null + - null + - 0 + - 2 + - 1 + - 1 + out: 4 + - name: case_15 + in: + root: + - 1 + - 1 + - 0 + - null + - null + - null + - 2 + - 2 + - 0 + - 1 + - null + - 1 + out: 3 + - name: case_16 + in: + root: + - 2 + - 1 + - 1 + - null + - 0 + - 1 + - null + - 1 + - 1 + out: 2 + - name: case_17 + in: + root: + - 1 + - 1 + - null + - null + - null + - 1 + - 1 + out: 0 + - name: case_18 + in: + root: + - 1 + out: 0 + - name: case_19 + in: + root: + - 1 + out: 0 + - name: case_20 + in: + root: + - 3 + - null + - 1 + - 0 + - null + - 0 + out: 5 + - name: case_21 + in: + root: + - 2 + - 0 + - null + - 0 + - 1 + - 0 + - 1 + - 2 + - 2 + out: 8 + - name: case_22 + in: + root: + - 0 + - 1 + - 1 + - 4 + - 0 + - 1 + - 0 + out: 8 + - name: case_23 + in: + root: + - 0 + - 2 + - 1 + - null + - null + - 0 + - 2 + - null + - 1 + out: 3 + - name: case_24 + in: + root: + - 1 + - 1 + - 0 + - 0 + - null + - null + - 3 + - 1 + - null + - 2 + - 0 + out: 7 + - name: case_25 + in: + root: + - 1 + - 2 + - 1 + - 1 + - 0 + - 1 + - 0 + - null + - 2 + out: 6 + - name: case_26 + in: + root: + - 1 + - 0 + - 1 + - 1 + - 2 + - 1 + out: 1 + - name: case_27 + in: + root: + - 0 + - 2 + out: 1 + - name: case_28 + in: + root: + - 1 + out: 0 + - name: case_29 + in: + root: + - 2 + - 1 + - null + - 1 + - null + - 0 + - 1 + - null + - 1 + - 1 + - null + - null + - 1 + out: 3 + - name: case_30 + in: + root: + - 1 + - 1 + - null + - 1 + - 1 + - 2 + - 1 + - null + - 0 + out: 4 + - name: case_31 + in: + root: + - 0 + - 2 + - 1 + - null + - 1 + - 1 + - 0 + - null + - 1 + - 2 + out: 4 + - name: case_32 + in: + root: + - 1 + - null + - 2 + - 0 + - 2 + - 0 + - null + - null + - 1 + out: 4 + - name: case_33 + in: + root: + - 1 + - 0 + - 2 + - 1 + out: 2 + - name: case_34 + in: + root: + - 0 + - null + - 2 + out: 1 + - name: case_35 + in: + root: + - 0 + - 0 + - 1 + - null + - null + - 3 + out: 5 diff --git a/tests/501-1000/979. distribute-coins-in-binary-tree/sol.cpp b/tests/501-1000/979. distribute-coins-in-binary-tree/sol.cpp new file mode 100644 index 00000000..ab8cd2f5 --- /dev/null +++ b/tests/501-1000/979. distribute-coins-in-binary-tree/sol.cpp @@ -0,0 +1,28 @@ +/** + * Definition for a binary tree node. + * struct TreeNode { + * int val; + * TreeNode *left; + * TreeNode *right; + * TreeNode() : val(0), left(nullptr), right(nullptr) {} + * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} + * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} + * }; + */ +class Solution { +public: + int distributeCoins(TreeNode* root) { + int moves = 0; + solve(root, moves); + return moves; + } + +private: + int solve(TreeNode* node, int& moves) { + if (!node) return 0; + int leftCandie = solve(node->left, moves); + int rightCandie = solve(node->right, moves); + moves += abs(leftCandie) + abs(rightCandie); + return (leftCandie + rightCandie + node->val) - 1; + } +}; diff --git a/tests/501-1000/979. distribute-coins-in-binary-tree/sol.cs b/tests/501-1000/979. distribute-coins-in-binary-tree/sol.cs new file mode 100644 index 00000000..0bdaf08e --- /dev/null +++ b/tests/501-1000/979. distribute-coins-in-binary-tree/sol.cs @@ -0,0 +1,29 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public int val; + * public TreeNode left; + * public TreeNode right; + * public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +public class Solution { + private int moves = 0; + + public int DistributeCoins(TreeNode root) { + Solve(root); + return moves; + } + + private int Solve(TreeNode node) { + if (node == null) return 0; + int leftCandie = Solve(node.left); + int rightCandie = Solve(node.right); + moves += Math.Abs(leftCandie) + Math.Abs(rightCandie); + return (leftCandie + rightCandie + node.val) - 1; + } +} diff --git a/tests/501-1000/979. distribute-coins-in-binary-tree/sol.dart b/tests/501-1000/979. distribute-coins-in-binary-tree/sol.dart new file mode 100644 index 00000000..43422ee4 --- /dev/null +++ b/tests/501-1000/979. distribute-coins-in-binary-tree/sol.dart @@ -0,0 +1,25 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * int val; + * TreeNode? left; + * TreeNode? right; + * TreeNode([this.val = 0, this.left, this.right]); + * } + */ +class Solution { + int moves = 0; + + int distributeCoins(TreeNode? root) { + solve(root); + return moves; + } + + int solve(TreeNode? node) { + if (node == null) return 0; + int leftCandie = solve(node.left); + int rightCandie = solve(node.right); + moves += (leftCandie).abs() + (rightCandie).abs(); + return (leftCandie + rightCandie + node.val) - 1; + } +} diff --git a/tests/501-1000/979. distribute-coins-in-binary-tree/sol.go b/tests/501-1000/979. distribute-coins-in-binary-tree/sol.go new file mode 100644 index 00000000..c0ea916a --- /dev/null +++ b/tests/501-1000/979. distribute-coins-in-binary-tree/sol.go @@ -0,0 +1,32 @@ +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +func distributeCoins(root *TreeNode) int { + moves := 0 + + var solve func(*TreeNode) int + solve = func(node *TreeNode) int { + if node == nil { + return 0 + } + leftCandie := solve(node.Left) + rightCandie := solve(node.Right) + moves += abs(leftCandie) + abs(rightCandie) + return (leftCandie + rightCandie + node.Val) - 1 + } + + solve(root) + return moves +} + +func abs(x int) int { + if x < 0 { + return -x + } + return x +} diff --git a/tests/501-1000/979. distribute-coins-in-binary-tree/sol.java b/tests/501-1000/979. distribute-coins-in-binary-tree/sol.java new file mode 100644 index 00000000..2bf18dd1 --- /dev/null +++ b/tests/501-1000/979. distribute-coins-in-binary-tree/sol.java @@ -0,0 +1,31 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode() {} + * TreeNode(int val) { this.val = val; } + * TreeNode(int val, TreeNode left, TreeNode right) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +class Solution { + private int moves = 0; + + public int distributeCoins(TreeNode root) { + solve(root); + return moves; + } + + private int solve(TreeNode node) { + if (node == null) return 0; + int leftCandie = solve(node.left); + int rightCandie = solve(node.right); + moves += Math.abs(leftCandie) + Math.abs(rightCandie); + return (leftCandie + rightCandie + node.val) - 1; + } +} diff --git a/tests/501-1000/979. distribute-coins-in-binary-tree/sol.kt b/tests/501-1000/979. distribute-coins-in-binary-tree/sol.kt new file mode 100644 index 00000000..f26c2424 --- /dev/null +++ b/tests/501-1000/979. distribute-coins-in-binary-tree/sol.kt @@ -0,0 +1,26 @@ +/** + * Example: + * var ti = TreeNode(5) + * var v = ti.`val` + * Definition for a binary tree node. + * class TreeNode(var `val`: Int) { + * var left: TreeNode? = null + * var right: TreeNode? = null + * } + */ +class Solution { + private var moves: Int = 0 + + fun distributeCoins(root: TreeNode?): Int { + solve(root) + return moves + } + + private fun solve(node: TreeNode?): Int { + if (node == null) return 0 + val leftCandie = solve(node.left) + val rightCandie = solve(node.right) + moves += Math.abs(leftCandie) + Math.abs(rightCandie) + return (leftCandie + rightCandie + node.`val`) - 1 + } +} diff --git a/tests/501-1000/979. distribute-coins-in-binary-tree/sol.py b/tests/501-1000/979. distribute-coins-in-binary-tree/sol.py new file mode 100644 index 00000000..8376d719 --- /dev/null +++ b/tests/501-1000/979. distribute-coins-in-binary-tree/sol.py @@ -0,0 +1,26 @@ +# Definition for a binary tree node. +# class TreeNode: +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +from typing import Optional + + +class Solution: + def distributeCoins(self, root: Optional[TreeNode]) -> int: + self.moves = 0 + + def solve(node): + if not node: + return 0 + + left_candie = solve(node.left) + right_candie = solve(node.right) + + self.moves += abs(left_candie) + abs(right_candie) + + return (left_candie + right_candie + node.val) - 1 + + solve(root) + return self.moves diff --git a/tests/501-1000/979. distribute-coins-in-binary-tree/sol.py2 b/tests/501-1000/979. distribute-coins-in-binary-tree/sol.py2 new file mode 100644 index 00000000..b51c1b02 --- /dev/null +++ b/tests/501-1000/979. distribute-coins-in-binary-tree/sol.py2 @@ -0,0 +1,24 @@ +# Definition for a binary tree node. +# class TreeNode(object): +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution(object): + def distributeCoins(self, root): + """ + :type root: Optional[TreeNode] + :rtype: int + """ + self.moves = 0 + + def solve(node): + if not node: + return 0 + left_candie = solve(node.left) + right_candie = solve(node.right) + self.moves += abs(left_candie) + abs(right_candie) + return (left_candie + right_candie + node.val) - 1 + + solve(root) + return self.moves diff --git a/tests/501-1000/979. distribute-coins-in-binary-tree/sol.rb b/tests/501-1000/979. distribute-coins-in-binary-tree/sol.rb new file mode 100644 index 00000000..ae19c5c4 --- /dev/null +++ b/tests/501-1000/979. distribute-coins-in-binary-tree/sol.rb @@ -0,0 +1,25 @@ +# Definition for a binary tree node. +# class TreeNode +# attr_accessor :val, :left, :right +# def initialize(val = 0, left = nil, right = nil) +# @val = val +# @left = left +# @right = right +# end +# end +# @param {TreeNode} root +# @return {Integer} +def distribute_coins(root) + @moves = 0 + + def solve(node) + return 0 if node.nil? + left_candie = solve(node.left) + right_candie = solve(node.right) + @moves += left_candie.abs + right_candie.abs + return (left_candie + right_candie + node.val) - 1 + end + + solve(root) + @moves +end diff --git a/tests/501-1000/979. distribute-coins-in-binary-tree/sol.rs b/tests/501-1000/979. distribute-coins-in-binary-tree/sol.rs new file mode 100644 index 00000000..161fc824 --- /dev/null +++ b/tests/501-1000/979. distribute-coins-in-binary-tree/sol.rs @@ -0,0 +1,39 @@ +// Definition for a binary tree node. +// #[derive(Debug, PartialEq, Eq)] +// pub struct TreeNode { +// pub val: i32, +// pub left: Option>>, +// pub right: Option>>, +// } +// +// impl TreeNode { +// #[inline] +// pub fn new(val: i32) -> Self { +// TreeNode { +// val, +// left: None, +// right: None +// } +// } +// } +impl Solution { + pub fn distribute_coins(root: Option>>) -> i32 { + let mut moves = 0; + + fn solve(node: Option>>, moves: &mut i32) -> i32 { + match node { + None => 0, + Some(n) => { + let n = n.borrow(); + let left_candie = solve(n.left.clone(), moves); + let right_candie = solve(n.right.clone(), moves); + *moves += left_candie.abs() + right_candie.abs(); + (left_candie + right_candie + n.val) - 1 + } + } + } + + solve(root, &mut moves); + moves + } +} diff --git a/tests/501-1000/979. distribute-coins-in-binary-tree/sol.swift b/tests/501-1000/979. distribute-coins-in-binary-tree/sol.swift new file mode 100644 index 00000000..9fa737f8 --- /dev/null +++ b/tests/501-1000/979. distribute-coins-in-binary-tree/sol.swift @@ -0,0 +1,31 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public var val: Int + * public var left: TreeNode? + * public var right: TreeNode? + * public init() { self.val = 0; self.left = nil; self.right = nil; } + * public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; } + * public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) { + * self.val = val + * self.left = left + * self.right = right + * } + * } + */ +class Solution { + var moves = 0 + + func distributeCoins(_ root: TreeNode?) -> Int { + _ = solve(root) + return moves + } + + func solve(_ node: TreeNode?) -> Int { + guard let node = node else { return 0 } + let leftCandie = solve(node.left) + let rightCandie = solve(node.right) + moves += abs(leftCandie) + abs(rightCandie) + return (leftCandie + rightCandie + node.val) - 1 + } +} diff --git a/tests/501-1000/979. distribute-coins-in-binary-tree/sol.ts b/tests/501-1000/979. distribute-coins-in-binary-tree/sol.ts new file mode 100644 index 00000000..ffb17177 --- /dev/null +++ b/tests/501-1000/979. distribute-coins-in-binary-tree/sol.ts @@ -0,0 +1,28 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ + +function distributeCoins(root: TreeNode | null): number { + let moves: number = 0; + + function solve(node: TreeNode | null): number { + if (!node) return 0; + const leftCandie = solve(node.left); + const rightCandie = solve(node.right); + moves += Math.abs(leftCandie) + Math.abs(rightCandie); + return leftCandie + rightCandie + node.val - 1; + } + + solve(root); + return moves; +} diff --git a/tests/501-1000/980. unique-paths-iii/manifest.yaml b/tests/501-1000/980. unique-paths-iii/manifest.yaml new file mode 100644 index 00000000..cd374b21 --- /dev/null +++ b/tests/501-1000/980. unique-paths-iii/manifest.yaml @@ -0,0 +1,382 @@ +entry: + id: 980 + title: unique-paths-iii + params: + grid: + type: array + items: + type: array + items: + type: int + call: + cpp: Solution().uniquePathsIII({grid}) + rust: Solution::unique_paths_iii({grid}) + python3: Solution().uniquePathsIII({grid}) + python2: Solution().uniquePathsIII({grid}) + ruby: unique_paths_iii({grid}) + java: new Solution().uniquePathsIII({grid}) + csharp: new Solution().UniquePathsIII({grid}) + kotlin: Solution().uniquePathsIII({grid}) + go: uniquePathsIII({grid}) + dart: Solution().uniquePathsIII({grid}) + swift: Solution().uniquePathsIII({grid}) + typescript: uniquePathsIII({grid}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 980 +tests: + - name: case_1 + in: + grid: + - - 1 + out: 0 + - name: case_2 + in: + grid: + - - -1 + - 0 + - 0 + - 1 + - - 0 + - -1 + - 2 + - -1 + out: 0 + - name: case_3 + in: + grid: + - - 1 + - - 2 + out: 1 + - name: case_4 + in: + grid: + - - 0 + - 0 + - 1 + - 0 + - - 0 + - 0 + - 0 + - 2 + out: 0 + - name: case_5 + in: + grid: + - - 0 + - 0 + - - 0 + - -1 + - - -1 + - 0 + - - 2 + - 1 + out: 0 + - name: case_6 + in: + grid: + - - -1 + - 0 + - -1 + - 1 + - - 0 + - 0 + - 0 + - 2 + - - 0 + - 0 + - 0 + - 0 + out: 0 + - name: case_7 + in: + grid: + - - 0 + - -1 + - 0 + - 0 + - - 0 + - 0 + - -1 + - 0 + - - 0 + - 1 + - -1 + - 2 + out: 0 + - name: case_8 + in: + grid: + - - 1 + - - 2 + out: 1 + - name: case_9 + in: + grid: + - - 0 + - 1 + - - -1 + - 0 + - - 0 + - 2 + out: 0 + - name: case_10 + in: + grid: + - - 1 + - - 2 + - - -1 + out: 1 + - name: case_11 + in: + grid: + - - 1 + - -1 + - - 2 + - 0 + - - 0 + - 0 + out: 0 + - name: case_12 + in: + grid: + - - 2 + - 1 + out: 1 + - name: case_13 + in: + grid: + - - 1 + - 0 + - - 0 + - 0 + - - 0 + - 2 + out: 1 + - name: case_14 + in: + grid: + - - 1 + - - 2 + - - 0 + out: 0 + - name: case_15 + in: + grid: + - - 2 + - 0 + - 1 + - 0 + out: 0 + - name: case_16 + in: + grid: + - - -1 + - 0 + - - 0 + - 2 + - - 0 + - 1 + out: 0 + - name: case_17 + in: + grid: + - - 1 + - 2 + - -1 + - - 0 + - -1 + - 0 + out: 0 + - name: case_18 + in: + grid: + - - -1 + - 2 + - - 0 + - 1 + - - 0 + - -1 + out: 0 + - name: case_19 + in: + grid: + - - 0 + - 0 + - 0 + - -1 + - - 1 + - 0 + - 2 + - -1 + out: 0 + - name: case_20 + in: + grid: + - - -1 + - -1 + - -1 + - 1 + - - 0 + - 0 + - 0 + - 0 + - - 0 + - 0 + - 0 + - 2 + out: 1 + - name: case_21 + in: + grid: + - - 2 + - 1 + out: 1 + - name: case_22 + in: + grid: + - - 0 + - 0 + - 2 + - -1 + - - -1 + - 0 + - -1 + - 0 + - - 1 + - -1 + - 0 + - -1 + - - 0 + - 0 + - 0 + - -1 + out: 0 + - name: case_23 + in: + grid: + - - 1 + - 0 + - 0 + - - -1 + - 0 + - 0 + - - 2 + - 0 + - 0 + out: 0 + - name: case_24 + in: + grid: + - - 2 + - - -1 + - - 0 + - - 1 + out: 0 + - name: case_25 + in: + grid: + - - 1 + - 0 + - -1 + - - 0 + - -1 + - 0 + - - 0 + - 0 + - 2 + out: 0 + - name: case_26 + in: + grid: + - - 1 + - 2 + out: 1 + - name: case_27 + in: + grid: + - - 1 + - - 0 + - - 2 + out: 1 + - name: case_28 + in: + grid: + - - 0 + - 0 + - 0 + - - 1 + - 2 + - 0 + out: 1 + - name: case_29 + in: + grid: + - - 2 + - - 1 + out: 1 + - name: case_30 + in: + grid: + - - 2 + - 1 + out: 1 + - name: case_31 + in: + grid: + - - 2 + - -1 + - 1 + out: 0 + - name: case_32 + in: + grid: + - - 0 + - -1 + - 0 + - -1 + - - 1 + - -1 + - 0 + - 0 + - - 0 + - 2 + - 0 + - 0 + out: 0 + - name: case_33 + in: + grid: + - - -1 + - 1 + - - 0 + - 2 + - - 0 + - 0 + - - 0 + - 0 + out: 0 + - name: case_34 + in: + grid: + - - 1 + - 2 + - 0 + out: 0 + - name: case_35 + in: + grid: + - - 0 + - 2 + - -1 + - - 0 + - 0 + - 1 + out: 1 diff --git a/tests/501-1000/980. unique-paths-iii/sol.cpp b/tests/501-1000/980. unique-paths-iii/sol.cpp new file mode 100644 index 00000000..96b665a2 --- /dev/null +++ b/tests/501-1000/980. unique-paths-iii/sol.cpp @@ -0,0 +1,34 @@ +class Solution { +public: + int uniquePathsIII(vector>& grid) { + int m = grid.size(), n = grid[0].size(); + int sx = -1, sy = -1; + int count = 0; + for (int i = 0; i < m; i++) { + for (int j = 0; j < n; j++) { + if (grid[i][j] == 0) count++; + if (grid[i][j] == 1) { + sx = i; + sy = j; + } + } + } + return backtrack(grid, m, n, sx, sy, count); + } + + int backtrack(vector>& grid, int m, int n, int i, int j, int count) { + int result = 0; + vector> dirs = {{i-1, j}, {i+1, j}, {i, j-1}, {i, j+1}}; + for (auto [x, y] : dirs) { + if (x < 0 || x >= m || y < 0 || y >= n) continue; + if (grid[x][y] == 2) { + if (count == 0) result++; + } else if (grid[x][y] == 0) { + grid[x][y] = -1; + result += backtrack(grid, m, n, x, y, count - 1); + grid[x][y] = 0; + } + } + return result; + } +}; diff --git a/tests/501-1000/980. unique-paths-iii/sol.cs b/tests/501-1000/980. unique-paths-iii/sol.cs new file mode 100644 index 00000000..9951cc77 --- /dev/null +++ b/tests/501-1000/980. unique-paths-iii/sol.cs @@ -0,0 +1,36 @@ +public class Solution { + public int UniquePathsIII(int[][] grid) { + int m = grid.Length, n = grid[0].Length; + int sx = -1, sy = -1; + int count = 0; + for (int i = 0; i < m; i++) { + for (int j = 0; j < n; j++) { + if (grid[i][j] == 0) count++; + if (grid[i][j] == 1) { + sx = i; + sy = j; + } + } + } + return Backtrack(grid, m, n, sx, sy, count); + } + + private int Backtrack(int[][] grid, int m, int n, int i, int j, int count) { + int result = 0; + int[][] dirs = new int[][] { + new int[] {i-1, j}, new int[] {i+1, j}, new int[] {i, j-1}, new int[] {i, j+1} + }; + foreach (var d in dirs) { + int x = d[0], y = d[1]; + if (x < 0 || x >= m || y < 0 || y >= n) continue; + if (grid[x][y] == 2) { + if (count == 0) result++; + } else if (grid[x][y] == 0) { + grid[x][y] = -1; + result += Backtrack(grid, m, n, x, y, count - 1); + grid[x][y] = 0; + } + } + return result; + } +} diff --git a/tests/501-1000/980. unique-paths-iii/sol.dart b/tests/501-1000/980. unique-paths-iii/sol.dart new file mode 100644 index 00000000..f00c6dfe --- /dev/null +++ b/tests/501-1000/980. unique-paths-iii/sol.dart @@ -0,0 +1,34 @@ +class Solution { + int uniquePathsIII(List> grid) { + int m = grid.length, n = grid[0].length; + int sx = -1, sy = -1; + int count = 0; + for (int i = 0; i < m; i++) { + for (int j = 0; j < n; j++) { + if (grid[i][j] == 0) count++; + if (grid[i][j] == 1) { + sx = i; + sy = j; + } + } + } + return _backtrack(grid, m, n, sx, sy, count); + } + + int _backtrack(List> grid, int m, int n, int i, int j, int count) { + int result = 0; + List> dirs = [[i-1, j], [i+1, j], [i, j-1], [i, j+1]]; + for (var d in dirs) { + int x = d[0], y = d[1]; + if (x < 0 || x >= m || y < 0 || y >= n) continue; + if (grid[x][y] == 2) { + if (count == 0) result++; + } else if (grid[x][y] == 0) { + grid[x][y] = -1; + result += _backtrack(grid, m, n, x, y, count - 1); + grid[x][y] = 0; + } + } + return result; + } +} diff --git a/tests/501-1000/980. unique-paths-iii/sol.go b/tests/501-1000/980. unique-paths-iii/sol.go new file mode 100644 index 00000000..b0655c5a --- /dev/null +++ b/tests/501-1000/980. unique-paths-iii/sol.go @@ -0,0 +1,39 @@ +func uniquePathsIII(grid [][]int) int { + m, n := len(grid), len(grid[0]) + sx, sy := -1, -1 + count := 0 + for i := 0; i < m; i++ { + for j := 0; j < n; j++ { + if grid[i][j] == 0 { + count++ + } + if grid[i][j] == 1 { + sx, sy = i, j + } + } + } + + var backtrack func(int, int, int) int + backtrack = func(i, j, count int) int { + result := 0 + dirs := [][]int{{i-1, j}, {i+1, j}, {i, j-1}, {i, j+1}} + for _, d := range dirs { + x, y := d[0], d[1] + if x < 0 || x >= m || y < 0 || y >= n { + continue + } + if grid[x][y] == 2 { + if count == 0 { + result++ + } + } else if grid[x][y] == 0 { + grid[x][y] = -1 + result += backtrack(x, y, count-1) + grid[x][y] = 0 + } + } + return result + } + + return backtrack(sx, sy, count) +} diff --git a/tests/501-1000/980. unique-paths-iii/sol.java b/tests/501-1000/980. unique-paths-iii/sol.java new file mode 100644 index 00000000..7968c7af --- /dev/null +++ b/tests/501-1000/980. unique-paths-iii/sol.java @@ -0,0 +1,34 @@ +class Solution { + public int uniquePathsIII(int[][] grid) { + int m = grid.length, n = grid[0].length; + int sx = -1, sy = -1; + int count = 0; + for (int i = 0; i < m; i++) { + for (int j = 0; j < n; j++) { + if (grid[i][j] == 0) count++; + if (grid[i][j] == 1) { + sx = i; + sy = j; + } + } + } + return backtrack(grid, m, n, sx, sy, count); + } + + private int backtrack(int[][] grid, int m, int n, int i, int j, int count) { + int result = 0; + int[][] dirs = {{i-1, j}, {i+1, j}, {i, j-1}, {i, j+1}}; + for (int[] d : dirs) { + int x = d[0], y = d[1]; + if (x < 0 || x >= m || y < 0 || y >= n) continue; + if (grid[x][y] == 2) { + result += (count == 0 ? 1 : 0); + } else if (grid[x][y] == 0) { + grid[x][y] = -1; + result += backtrack(grid, m, n, x, y, count - 1); + grid[x][y] = 0; + } + } + return result; + } +} diff --git a/tests/501-1000/980. unique-paths-iii/sol.kt b/tests/501-1000/980. unique-paths-iii/sol.kt new file mode 100644 index 00000000..73dc0aa9 --- /dev/null +++ b/tests/501-1000/980. unique-paths-iii/sol.kt @@ -0,0 +1,37 @@ +class Solution { + fun uniquePathsIII(grid: Array): Int { + val m = grid.size + val n = grid[0].size + var sx = -1 + var sy = -1 + var count = 0 + for (i in 0 until m) { + for (j in 0 until n) { + if (grid[i][j] == 0) count++ + if (grid[i][j] == 1) { + sx = i + sy = j + } + } + } + return backtrack(grid, m, n, sx, sy, count) + } + + private fun backtrack(grid: Array, m: Int, n: Int, i: Int, j: Int, count: Int): Int { + var result = 0 + val dirs = arrayOf(intArrayOf(i-1, j), intArrayOf(i+1, j), intArrayOf(i, j-1), intArrayOf(i, j+1)) + for (d in dirs) { + val x = d[0] + val y = d[1] + if (x !in 0 until m || y !in 0 until n) continue + if (grid[x][y] == 2) { + if (count == 0) result++ + } else if (grid[x][y] == 0) { + grid[x][y] = -1 + result += backtrack(grid, m, n, x, y, count - 1) + grid[x][y] = 0 + } + } + return result + } +} diff --git a/tests/501-1000/980. unique-paths-iii/sol.py b/tests/501-1000/980. unique-paths-iii/sol.py new file mode 100644 index 00000000..eeeb5359 --- /dev/null +++ b/tests/501-1000/980. unique-paths-iii/sol.py @@ -0,0 +1,40 @@ +from itertools import product +from typing import List + + +class Solution: + def uniquePathsIII(self, grid: List[List[int]]) -> int: + m, n = len(grid), len(grid[0]) + + # iterate through the grid to get relevant info + sx = sy = -1 # to store starting point + count = 0 # to count number of squares to walk over + for i, j in product(range(m), range(n)): + count += grid[i][j] == 0 + if grid[i][j] == 1: + sx, sy = i, j + + def backtrack(i: int, j: int, count: int) -> int: + """ + Backtracking algo to find all valid paths from (i, j) while visiting all non-obstacle cells.. + :param i: Index of row (where top = 0) of coordinate. + :param j: Index of column (where left = 0) of coordinate. + :param count: Number of (remaining) non-obstacle cells. + :returns: Total number of valid paths from (i, j). + """ + result = 0 + for x, y in ((i - 1, j), (i + 1, j), (i, j - 1), (i, j + 1)): + if not (0 <= x < m and 0 <= y < n): + continue + elif grid[x][y] == 2: + # check if all squares have been walked over + result += count == 0 + elif grid[x][y] == 0: + # traverse down this path + grid[x][y] = -1 + result += backtrack(x, y, count - 1) + grid[x][y] = 0 # backtrack and reset + return result + + # perform DFS + backtracking to find valid paths + return backtrack(sx, sy, count) diff --git a/tests/501-1000/980. unique-paths-iii/sol.py2 b/tests/501-1000/980. unique-paths-iii/sol.py2 new file mode 100644 index 00000000..6a6503c7 --- /dev/null +++ b/tests/501-1000/980. unique-paths-iii/sol.py2 @@ -0,0 +1,30 @@ +class Solution(object): + def uniquePathsIII(self, grid): + """ + :type grid: List[List[int]] + :rtype: int + """ + m, n = len(grid), len(grid[0]) + sx = sy = -1 + count = 0 + for i in range(m): + for j in range(n): + if grid[i][j] == 0: + count += 1 + if grid[i][j] == 1: + sx, sy = i, j + + def backtrack(i, j, count): + result = 0 + for x, y in ((i-1, j), (i+1, j), (i, j-1), (i, j+1)): + if not (0 <= x < m and 0 <= y < n): + continue + elif grid[x][y] == 2: + result += count == 0 + elif grid[x][y] == 0: + grid[x][y] = -1 + result += backtrack(x, y, count - 1) + grid[x][y] = 0 + return result + + return backtrack(sx, sy, count) diff --git a/tests/501-1000/980. unique-paths-iii/sol.rb b/tests/501-1000/980. unique-paths-iii/sol.rb new file mode 100644 index 00000000..4edc11e2 --- /dev/null +++ b/tests/501-1000/980. unique-paths-iii/sol.rb @@ -0,0 +1,32 @@ +# @param {Integer[][]} grid +# @return {Integer} +def unique_paths_iii(grid) + m, n = grid.length, grid[0].length + sx = sy = -1 + count = 0 + (0...m).each do |i| + (0...n).each do |j| + count += 1 if grid[i][j] == 0 + if grid[i][j] == 1 + sx, sy = i, j + end + end + end + + backtrack = lambda do |i, j, count| + result = 0 + [[i-1, j], [i+1, j], [i, j-1], [i, j+1]].each do |x, y| + next unless (0...m).cover?(x) && (0...n).cover?(y) + if grid[x][y] == 2 + result += 1 if count == 0 + elsif grid[x][y] == 0 + grid[x][y] = -1 + result += backtrack.call(x, y, count - 1) + grid[x][y] = 0 + end + end + result + end + + backtrack.call(sx, sy, count) +end diff --git a/tests/501-1000/980. unique-paths-iii/sol.rs b/tests/501-1000/980. unique-paths-iii/sol.rs new file mode 100644 index 00000000..8f8a2cc4 --- /dev/null +++ b/tests/501-1000/980. unique-paths-iii/sol.rs @@ -0,0 +1,47 @@ +impl Solution { + pub fn unique_paths_iii(grid: Vec>) -> i32 { + let m = grid.len(); + let n = grid[0].len(); + let mut grid = grid; + let mut sx = 0; + let mut sy = 0; + let mut count = 0; + for i in 0..m { + for j in 0..n { + if grid[i][j] == 0 { + count += 1; + } + if grid[i][j] == 1 { + sx = i; + sy = j; + } + } + } + + fn backtrack(grid: &mut Vec>, m: usize, n: usize, i: usize, j: usize, count: i32) -> i32 { + let mut result = 0; + let dirs: [(isize, isize); 4] = [(-1, 0), (1, 0), (0, -1), (0, 1)]; + for (di, dj) in dirs.iter() { + let x = i as isize + di; + let y = j as isize + dj; + if x < 0 || x >= m as isize || y < 0 || y >= n as isize { + continue; + } + let x = x as usize; + let y = y as usize; + if grid[x][y] == 2 { + if count == 0 { + result += 1; + } + } else if grid[x][y] == 0 { + grid[x][y] = -1; + result += backtrack(grid, m, n, x, y, count - 1); + grid[x][y] = 0; + } + } + result + } + + backtrack(&mut grid, m, n, sx, sy, count) + } +} diff --git a/tests/501-1000/980. unique-paths-iii/sol.swift b/tests/501-1000/980. unique-paths-iii/sol.swift new file mode 100644 index 00000000..d6a7a9c2 --- /dev/null +++ b/tests/501-1000/980. unique-paths-iii/sol.swift @@ -0,0 +1,41 @@ +class Solution { + func uniquePathsIII(_ grid: [[Int]]) -> Int { + let m = grid.count, n = grid[0].count + var grid = grid + var sx = -1, sy = -1 + var count = 0 + for i in 0.. Int { + var result = 0 + let dirs = [[i-1, j], [i+1, j], [i, j-1], [i, j+1]] + for d in dirs { + let x = d[0], y = d[1] + if x < 0 || x >= m || y < 0 || y >= n { + continue + } + if grid[x][y] == 2 { + if count == 0 { + result += 1 + } + } else if grid[x][y] == 0 { + grid[x][y] = -1 + result += backtrack(&grid, m, n, x, y, count - 1) + grid[x][y] = 0 + } + } + return result + } +} diff --git a/tests/501-1000/980. unique-paths-iii/sol.ts b/tests/501-1000/980. unique-paths-iii/sol.ts new file mode 100644 index 00000000..ddd8b77a --- /dev/null +++ b/tests/501-1000/980. unique-paths-iii/sol.ts @@ -0,0 +1,39 @@ +function uniquePathsIII(grid: number[][]): number { + const m = grid.length, + n = grid[0].length; + let sx = -1, + sy = -1; + let count = 0; + for (let i = 0; i < m; i++) { + for (let j = 0; j < n; j++) { + if (grid[i][j] === 0) count++; + if (grid[i][j] === 1) { + sx = i; + sy = j; + } + } + } + + const backtrack = (i: number, j: number, count: number): number => { + let result = 0; + const dirs = [ + [i - 1, j], + [i + 1, j], + [i, j - 1], + [i, j + 1], + ]; + for (const [x, y] of dirs) { + if (x < 0 || x >= m || y < 0 || y >= n) continue; + if (grid[x][y] === 2) { + if (count === 0) result++; + } else if (grid[x][y] === 0) { + grid[x][y] = -1; + result += backtrack(x, y, count - 1); + grid[x][y] = 0; + } + } + return result; + }; + + return backtrack(sx, sy, count); +} diff --git a/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/manifest.yaml b/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/manifest.yaml new file mode 100644 index 00000000..d0796f26 --- /dev/null +++ b/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/manifest.yaml @@ -0,0 +1,298 @@ +entry: + id: 982 + title: triples-with-bitwise-and-equal-to-zero + params: + nums: + type: array + items: + type: int + call: + cpp: Solution().countTriplets({nums}) + rust: Solution::count_triplets({nums}) + python3: Solution().countTriplets({nums}) + python2: Solution().countTriplets({nums}) + ruby: count_triplets({nums}) + java: new Solution().countTriplets({nums}) + csharp: new Solution().CountTriplets({nums}) + kotlin: Solution().countTriplets({nums}) + go: countTriplets({nums}) + dart: Solution().countTriplets({nums}) + swift: Solution().countTriplets({nums}) + typescript: countTriplets({nums}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 982 +tests: + - name: case_1 + in: + nums: + - 47 + - 64 + - 245 + - 91 + out: 18 + - name: case_2 + in: + nums: + - 230 + - 89 + - 159 + - 233 + - 80 + - 107 + out: 24 + - name: case_3 + in: + nums: + - 97 + - 51 + - 33 + - 93 + - 80 + - 219 + - 87 + out: 42 + - name: case_4 + in: + nums: + - 202 + - 73 + - 73 + - 47 + - 252 + - 95 + - 170 + out: 0 + - name: case_5 + in: + nums: + - 45 + - 99 + out: 0 + - name: case_6 + in: + nums: + - 225 + - 216 + out: 0 + - name: case_7 + in: + nums: + - 196 + - 48 + - 79 + - 104 + - 210 + - 1 + - 190 + out: 192 + - name: case_8 + in: + nums: + - 117 + - 234 + - 143 + - 131 + - 205 + - 180 + out: 18 + - name: case_9 + in: + nums: + - 87 + - 81 + - 54 + - 42 + - 247 + - 173 + - 10 + - 165 + out: 156 + - name: case_10 + in: + nums: + - 158 + - 198 + out: 0 + - name: case_11 + in: + nums: + - 173 + out: 0 + - name: case_12 + in: + nums: + - 228 + - 231 + out: 0 + - name: case_13 + in: + nums: + - 134 + out: 0 + - name: case_14 + in: + nums: + - 114 + out: 0 + - name: case_15 + in: + nums: + - 13 + - 28 + - 188 + - 23 + - 128 + - 143 + - 226 + out: 150 + - name: case_16 + in: + nums: + - 254 + - 94 + - 240 + out: 0 + - name: case_17 + in: + nums: + - 81 + out: 0 + - name: case_18 + in: + nums: + - 78 + out: 0 + - name: case_19 + in: + nums: + - 156 + - 29 + out: 0 + - name: case_20 + in: + nums: + - 127 + - 237 + out: 0 + - name: case_21 + in: + nums: + - 1 + - 58 + out: 6 + - name: case_22 + in: + nums: + - 103 + - 183 + - 92 + - 71 + out: 0 + - name: case_23 + in: + nums: + - 219 + - 0 + - 200 + - 137 + - 133 + - 63 + - 8 + out: 163 + - name: case_24 + in: + nums: + - 171 + - 15 + - 130 + - 26 + - 88 + - 22 + out: 42 + - name: case_25 + in: + nums: + - 44 + out: 0 + - name: case_26 + in: + nums: + - 84 + - 149 + - 46 + - 68 + - 162 + out: 48 + - name: case_27 + in: + nums: + - 26 + - 233 + out: 0 + - name: case_28 + in: + nums: + - 100 + - 195 + - 229 + out: 0 + - name: case_29 + in: + nums: + - 86 + - 32 + - 186 + - 134 + out: 30 + - name: case_30 + in: + nums: + - 156 + - 67 + - 218 + - 44 + out: 30 + - name: case_31 + in: + nums: + - 32 + - 108 + - 179 + out: 0 + - name: case_32 + in: + nums: + - 211 + - 190 + - 175 + out: 0 + - name: case_33 + in: + nums: + - 99 + - 16 + - 219 + - 189 + - 149 + - 121 + out: 30 + - name: case_34 + in: + nums: + - 88 + out: 0 + - name: case_35 + in: + nums: + - 114 + - 151 + - 73 + out: 6 diff --git a/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.cpp b/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.cpp new file mode 100644 index 00000000..ced35c29 --- /dev/null +++ b/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.cpp @@ -0,0 +1,45 @@ +class Solution { +public: + int countTriplets(vector& nums) { + int most = 0; + for (int num : nums) { + if (num > most) most = num; + } + if (most == 0) return nums.size() * nums.size() * nums.size(); + + int bits = 0; + int tmp = most; + while (tmp > 0) { + bits++; + tmp >>= 1; + } + int N = 1 << bits; + + vector c(N, 0); + for (int num : nums) { + c[num]++; + } + + for (int h = 1; h < N; h <<= 1) { + for (int s = 0; s < N; s += h << 1) { + for (int i = s; i < s + h; i++) { + c[i] += c[i + h]; + } + } + } + + for (int i = 0; i < N; i++) { + c[i] = c[i] * c[i] * c[i]; + } + + for (int h = 1; h < N; h <<= 1) { + for (int s = 0; s < N; s += h << 1) { + for (int i = s; i < s + h; i++) { + c[i] -= c[i + h]; + } + } + } + + return c[0]; + } +}; diff --git a/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.cs b/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.cs new file mode 100644 index 00000000..bbca8021 --- /dev/null +++ b/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.cs @@ -0,0 +1,44 @@ +public class Solution { + public int CountTriplets(int[] nums) { + int most = 0; + foreach (int num in nums) { + if (num > most) most = num; + } + if (most == 0) return nums.Length * nums.Length * nums.Length; + + int bits = 0; + int tmp = most; + while (tmp > 0) { + bits++; + tmp >>= 1; + } + int N = 1 << bits; + + int[] c = new int[N]; + foreach (int num in nums) { + c[num]++; + } + + for (int h = 1; h < N; h <<= 1) { + for (int s = 0; s < N; s += h << 1) { + for (int i = s; i < s + h; i++) { + c[i] += c[i + h]; + } + } + } + + for (int i = 0; i < N; i++) { + c[i] = c[i] * c[i] * c[i]; + } + + for (int h = 1; h < N; h <<= 1) { + for (int s = 0; s < N; s += h << 1) { + for (int i = s; i < s + h; i++) { + c[i] -= c[i + h]; + } + } + } + + return c[0]; + } +} diff --git a/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.dart b/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.dart new file mode 100644 index 00000000..f5750659 --- /dev/null +++ b/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.dart @@ -0,0 +1,36 @@ +class Solution { + int countTriplets(List nums) { + int most = nums.reduce((a, b) => a > b ? a : b); + if (most == 0) return nums.length * nums.length * nums.length; + + int bits = most.bitLength; + int N = 1 << bits; + + List c = List.filled(N, 0); + for (int num in nums) { + c[num]++; + } + + for (int h = 1; h < N; h <<= 1) { + for (int s = 0; s < N; s += h << 1) { + for (int i = s; i < s + h; i++) { + c[i] += c[i + h]; + } + } + } + + for (int i = 0; i < N; i++) { + c[i] = c[i] * c[i] * c[i]; + } + + for (int h = 1; h < N; h <<= 1) { + for (int s = 0; s < N; s += h << 1) { + for (int i = s; i < s + h; i++) { + c[i] -= c[i + h]; + } + } + } + + return c[0]; + } +} diff --git a/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.go b/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.go new file mode 100644 index 00000000..071385ab --- /dev/null +++ b/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.go @@ -0,0 +1,44 @@ +func countTriplets(nums []int) int { + most := 0 + for _, num := range nums { + if num > most { + most = num + } + } + if most == 0 { + return len(nums) * len(nums) * len(nums) + } + + bits := 0 + for tmp := most; tmp > 0; tmp >>= 1 { + bits++ + } + N := 1 << bits + + c := make([]int, N) + for _, num := range nums { + c[num]++ + } + + for h := 1; h < N; h <<= 1 { + for s := 0; s < N; s += h << 1 { + for i := s; i < s+h; i++ { + c[i] += c[i+h] + } + } + } + + for i := 0; i < N; i++ { + c[i] = c[i] * c[i] * c[i] + } + + for h := 1; h < N; h <<= 1 { + for s := 0; s < N; s += h << 1 { + for i := s; i < s+h; i++ { + c[i] -= c[i+h] + } + } + } + + return c[0] +} diff --git a/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.java b/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.java new file mode 100644 index 00000000..98a00c15 --- /dev/null +++ b/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.java @@ -0,0 +1,39 @@ +class Solution { + public int countTriplets(int[] nums) { + int most = 0; + for (int num : nums) { + if (num > most) most = num; + } + if (most == 0) return nums.length * nums.length * nums.length; + + int bits = 32 - Integer.numberOfLeadingZeros(most); + int N = 1 << bits; + + int[] c = new int[N]; + for (int num : nums) { + c[num]++; + } + + for (int h = 1; h < N; h <<= 1) { + for (int s = 0; s < N; s += h << 1) { + for (int i = s; i < s + h; i++) { + c[i] += c[i + h]; + } + } + } + + for (int i = 0; i < N; i++) { + c[i] = c[i] * c[i] * c[i]; + } + + for (int h = 1; h < N; h <<= 1) { + for (int s = 0; s < N; s += h << 1) { + for (int i = s; i < s + h; i++) { + c[i] -= c[i + h]; + } + } + } + + return c[0]; + } +} diff --git a/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.kt b/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.kt new file mode 100644 index 00000000..663fa175 --- /dev/null +++ b/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.kt @@ -0,0 +1,47 @@ +class Solution { + fun countTriplets(nums: IntArray): Int { + var most = 0 + for (num in nums) { + if (num > most) most = num + } + if (most == 0) return nums.size * nums.size * nums.size + + var bits = 0 + var tmp = most + while (tmp > 0) { bits++; tmp = tmp shr 1 } + val N = 1 shl bits + + val c = IntArray(N) + for (num in nums) c[num]++ + + var h = 1 + while (h < N) { + var s = 0 + while (s < N) { + for (i in s until s + h) { + c[i] += c[i + h] + } + s += h shl 1 + } + h = h shl 1 + } + + for (i in 0 until N) { + c[i] = c[i] * c[i] * c[i] + } + + h = 1 + while (h < N) { + var s = 0 + while (s < N) { + for (i in s until s + h) { + c[i] -= c[i + h] + } + s += h shl 1 + } + h = h shl 1 + } + + return c[0] + } +} diff --git a/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.py b/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.py new file mode 100644 index 00000000..8cce469b --- /dev/null +++ b/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.py @@ -0,0 +1,77 @@ +from math import ceil, log2 +from typing import List + + +class Solution: + def countTriplets(self, nums: List[int]) -> int: + # brute force: nope + + # better: make a vector with the ways to make all 2**16 possible AND values, + # in O(n**2). Then for each number, iterate through all 2**16 AND values and + # sum up all entries where counts[a] | a&n == 0 + # Speed up: use the brilliant "masked decrement." + # let y = ~n & ((1<<16)-1), i.e. 1s everywhere n has zeros. The most ones possible. + # then do y = (y-1) & ~n until y is 0. Each subtracts one from the LSB of ~n. + # It basically counts down from 11111...11_2 down to 0000...000_2, but where the 1s + # are where they are in ~n. It's brilliant. This cuts down on the number of combinations + # significantly. + + # The galaxy brain solution: a modified Walsh-Hadamard transformation. + + def transform(c: list[int], forward: bool) -> None: + """ + Applies the linear transformation T to c in-place. + + T has the property T*(c $ d) == T*c : T*d where + c and d are vectors of counts + c $ d is the answer: (c$d)[a] is the number of index pairs + (i, j) where i is in c, j is in d, and i & j == a + + T is recursively defined: + + T_2 = [1 1] + [0 1] + + T_{2N} = T_N x T_2; where x is the direct product + = [T_N T_N] + [ 0 T_N] + + @param forward: if True, applies T to c in place. + if False, applies inverse(T) to c in place. + """ + + # exploits the recursive definition of + # T_{2N} = [T_N*firstN + T_N*nextN; T_N*nextN] + # to compute it with divide-and-conquer. Conceptually it's + # recursive, but in this case it simplifies to an + # iterative algorithm since T_4 depends on pairs, + # T_8 depends on groups of 4, and so on. + + h = 1 # half current group size + sign = +1 if forward else -1 + while h < len(c): + for s in range(0, len(c), 2 * h): # start of each group + for i in range(s, s + h): + c[i] += sign * c[i + h] + + h *= 2 + + most = max(nums) + if most == 0: + return len(nums) ** 3 + + bits = ceil(log2(most)) + 1 + + N = 1 << bits # number of possible & results (must be a power of 2) + ALL = N - 1 # bit mask + + c = [0] * N # counts of each value + for n in nums: + c[n] += 1 + + transform(c, forward=True) + for i in range(N): + c[i] **= 3 + transform(c, forward=False) + + return c[0] diff --git a/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.py2 b/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.py2 new file mode 100644 index 00000000..64f338a1 --- /dev/null +++ b/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.py2 @@ -0,0 +1,30 @@ +class Solution(object): + def countTriplets(self, nums): + import math + def transform(c, forward): + h = 1 + sign = 1 if forward else -1 + while h < len(c): + for s in range(0, len(c), 2*h): + for i in range(s, s+h): + c[i] += sign * c[i+h] + h *= 2 + + most = max(nums) + if most == 0: + return len(nums)**3 + + bits = int(math.ceil(math.log(most, 2))) + 1 + N = 1 << bits + ALL = N - 1 + + c = [0] * N + for n in nums: + c[n] += 1 + + transform(c, True) + for i in range(N): + c[i] **= 3 + transform(c, False) + + return c[0] diff --git a/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.rb b/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.rb new file mode 100644 index 00000000..a79b785e --- /dev/null +++ b/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.rb @@ -0,0 +1,32 @@ +# @param {Integer[]} nums +# @return {Integer} +def count_triplets(nums) + most = nums.max + return nums.length ** 3 if most == 0 + + bits = Math.log2(most).ceil + 1 + n = 1 << bits + + c = Array.new(n, 0) + nums.each { |num| c[num] += 1 } + + h = 1 + while h < n + (0...n).step(2*h) do |s| + (s...s+h).each { |i| c[i] += c[i+h] } + end + h *= 2 + end + + (0...n).each { |i| c[i] = c[i] ** 3 } + + h = 1 + while h < n + (0...n).step(2*h) do |s| + (s...s+h).each { |i| c[i] -= c[i+h] } + end + h *= 2 + end + + c[0] +end diff --git a/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.rs b/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.rs new file mode 100644 index 00000000..13758660 --- /dev/null +++ b/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.rs @@ -0,0 +1,51 @@ +impl Solution { + pub fn count_triplets(nums: Vec) -> i32 { + let mut most = 0; + for &num in &nums { + if num > most { + most = num; + } + } + if most == 0 { + return (nums.len() * nums.len() * nums.len()) as i32; + } + + let bits = 32 - most.leading_zeros() as usize; + let n = 1 << bits; + + let mut c = vec![0i32; n]; + for &num in &nums { + c[num as usize] += 1; + } + + let mut h = 1; + while h < n { + let mut s = 0; + while s < n { + for i in s..s + h { + c[i] += c[i + h]; + } + s += h << 1; + } + h <<= 1; + } + + for i in 0..n { + c[i] = c[i] * c[i] * c[i]; + } + + h = 1; + while h < n { + let mut s = 0; + while s < n { + for i in s..s + h { + c[i] -= c[i + h]; + } + s += h << 1; + } + h <<= 1; + } + + c[0] + } +} diff --git a/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.swift b/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.swift new file mode 100644 index 00000000..12e9fb70 --- /dev/null +++ b/tests/501-1000/982. triples-with-bitwise-and-equal-to-zero/sol.swift @@ -0,0 +1,52 @@ +class Solution { + func countTriplets(_ nums: [Int]) -> Int { + var most = 0 + for num in nums { + if num > most { most = num } + } + if most == 0 { return nums.count * nums.count * nums.count } + + var bits = 0 + var tmp = most + while tmp > 0 { + bits += 1 + tmp >>= 1 + } + let N = 1 << bits + + var c = [Int](repeating: 0, count: N) + for num in nums { + c[num] += 1 + } + + var h = 1 + while h < N { + var s = 0 + while s < N { + for i in s.. most) most = num; + } + if (most === 0) return nums.length * nums.length * nums.length; + + let bits = 0; + let tmp = most; + while (tmp > 0) { + bits++; + tmp >>= 1; + } + const N = 1 << bits; + + const c = new Array(N).fill(0); + for (const num of nums) { + c[num]++; + } + + for (let h = 1; h < N; h <<= 1) { + for (let s = 0; s < N; s += h << 1) { + for (let i = s; i < s + h; i++) { + c[i] += c[i + h]; + } + } + } + + for (let i = 0; i < N; i++) { + c[i] = c[i] * c[i] * c[i]; + } + + for (let h = 1; h < N; h <<= 1) { + for (let s = 0; s < N; s += h << 1) { + for (let i = s; i < s + h; i++) { + c[i] -= c[i + h]; + } + } + } + + return c[0]; +} diff --git a/tests/501-1000/983. minimum-cost-for-tickets/manifest.yaml b/tests/501-1000/983. minimum-cost-for-tickets/manifest.yaml new file mode 100644 index 00000000..90b289ed --- /dev/null +++ b/tests/501-1000/983. minimum-cost-for-tickets/manifest.yaml @@ -0,0 +1,564 @@ +entry: + id: 983 + title: minimum-cost-for-tickets + params: + days: + type: array + items: + type: int + costs: + type: array + items: + type: int + call: + cpp: Solution().mincostTickets({days}, {costs}) + rust: Solution::mincost_tickets({days}, {costs}) + python3: Solution().mincostTickets({days}, {costs}) + python2: Solution().mincostTickets({days}, {costs}) + ruby: mincost_tickets({days}, {costs}) + java: new Solution().mincostTickets({days}, {costs}) + csharp: new Solution().MincostTickets({days}, {costs}) + kotlin: Solution().mincostTickets({days}, {costs}) + go: mincostTickets({days}, {costs}) + dart: Solution().mincostTickets({days}, {costs}) + swift: Solution().mincostTickets({days}, {costs}) + typescript: mincostTickets({days}, {costs}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 983 +tests: + - name: case_1 + in: + days: + - 81 + - 86 + - 108 + - 115 + - 116 + - 165 + - 180 + costs: + - 15 + - 11 + - 12 + out: 35 + - name: case_2 + in: + days: + - 17 + - 28 + - 45 + - 63 + - 96 + - 179 + - 181 + - 196 + - 274 + - 318 + - 335 + - 343 + - 352 + - 363 + costs: + - 9 + - 4 + - 16 + out: 52 + - name: case_3 + in: + days: + - 18 + - 90 + - 101 + - 140 + - 149 + - 284 + - 290 + - 343 + costs: + - 12 + - 13 + - 5 + out: 25 + - name: case_4 + in: + days: + - 21 + - 47 + - 106 + - 115 + - 121 + - 133 + - 169 + - 185 + - 215 + - 352 + - 357 + costs: + - 12 + - 28 + - 37 + out: 121 + - name: case_5 + in: + days: + - 33 + - 74 + - 134 + - 206 + - 260 + costs: + - 12 + - 6 + - 20 + out: 30 + - name: case_6 + in: + days: + - 172 + costs: + - 4 + - 9 + - 37 + out: 4 + - name: case_7 + in: + days: + - 9 + - 29 + - 43 + - 94 + - 167 + - 234 + - 239 + - 281 + - 282 + - 299 + - 350 + costs: + - 6 + - 21 + - 31 + out: 66 + - name: case_8 + in: + days: + - 35 + - 45 + - 75 + - 188 + - 229 + - 256 + - 266 + - 294 + - 330 + - 359 + costs: + - 19 + - 25 + - 48 + out: 190 + - name: case_9 + in: + days: + - 221 + - 274 + - 340 + costs: + - 20 + - 12 + - 15 + out: 36 + - name: case_10 + in: + days: + - 46 + - 79 + - 80 + - 153 + - 154 + - 161 + - 219 + - 258 + costs: + - 1 + - 21 + - 38 + out: 8 + - name: case_11 + in: + days: + - 5 + - 78 + - 112 + - 118 + - 137 + - 144 + - 147 + - 204 + - 212 + - 236 + - 253 + costs: + - 18 + - 20 + - 20 + out: 114 + - name: case_12 + in: + days: + - 94 + - 98 + - 153 + - 241 + - 259 + - 344 + costs: + - 19 + - 25 + - 44 + out: 101 + - name: case_13 + in: + days: + - 47 + - 113 + - 117 + - 135 + - 273 + - 304 + costs: + - 19 + - 2 + - 26 + out: 10 + - name: case_14 + in: + days: + - 10 + - 51 + - 62 + - 143 + - 258 + - 289 + costs: + - 12 + - 19 + - 17 + out: 65 + - name: case_15 + in: + days: + - 44 + - 83 + - 110 + - 120 + - 134 + - 156 + costs: + - 11 + - 10 + - 23 + out: 53 + - name: case_16 + in: + days: + - 86 + - 150 + - 154 + - 234 + - 304 + - 333 + - 350 + costs: + - 6 + - 14 + - 34 + out: 42 + - name: case_17 + in: + days: + - 97 + - 105 + - 129 + - 163 + - 187 + - 210 + - 252 + - 255 + - 264 + - 265 + - 333 + - 361 + costs: + - 18 + - 21 + - 37 + out: 181 + - name: case_18 + in: + days: + - 2 + - 8 + - 21 + - 77 + - 98 + - 118 + - 128 + - 182 + - 213 + - 214 + - 225 + - 254 + - 271 + - 285 + - 300 + costs: + - 9 + - 27 + - 44 + out: 135 + - name: case_19 + in: + days: + - 184 + - 188 + costs: + - 1 + - 7 + - 49 + out: 2 + - name: case_20 + in: + days: + - 350 + costs: + - 1 + - 2 + - 12 + out: 1 + - name: case_21 + in: + days: + - 7 + - 74 + - 83 + - 88 + - 122 + - 160 + - 298 + costs: + - 7 + - 11 + - 4 + out: 20 + - name: case_22 + in: + days: + - 28 + - 82 + - 102 + - 181 + - 197 + - 207 + - 235 + - 278 + - 321 + - 323 + - 349 + costs: + - 20 + - 27 + - 38 + out: 174 + - name: case_23 + in: + days: + - 9 + - 149 + - 171 + - 182 + - 236 + - 287 + - 290 + - 294 + - 343 + costs: + - 14 + - 13 + - 23 + out: 98 + - name: case_24 + in: + days: + - 3 + - 49 + - 108 + - 160 + - 210 + - 364 + costs: + - 9 + - 7 + - 22 + out: 42 + - name: case_25 + in: + days: + - 167 + - 189 + - 220 + - 225 + - 229 + - 322 + - 337 + costs: + - 5 + - 10 + - 26 + out: 35 + - name: case_26 + in: + days: + - 42 + - 259 + costs: + - 7 + - 8 + - 26 + out: 14 + - name: case_27 + in: + days: + - 1 + - 86 + - 132 + - 282 + - 291 + - 317 + - 337 + costs: + - 1 + - 10 + - 20 + out: 7 + - name: case_28 + in: + days: + - 117 + costs: + - 11 + - 11 + - 31 + out: 11 + - name: case_29 + in: + days: + - 14 + - 33 + - 49 + - 60 + - 86 + - 90 + - 98 + - 106 + - 114 + - 154 + - 220 + - 223 + - 243 + - 251 + - 317 + costs: + - 14 + - 26 + - 33 + out: 155 + - name: case_30 + in: + days: + - 121 + - 128 + - 254 + - 272 + - 308 + - 312 + costs: + - 10 + - 23 + - 28 + out: 60 + - name: case_31 + in: + days: + - 96 + - 132 + - 153 + - 222 + costs: + - 17 + - 6 + - 2 + out: 6 + - name: case_32 + in: + days: + - 301 + - 348 + costs: + - 10 + - 30 + - 11 + out: 20 + - name: case_33 + in: + days: + - 5 + - 52 + - 60 + - 68 + - 112 + - 203 + - 269 + - 294 + - 359 + costs: + - 2 + - 27 + - 1 + out: 6 + - name: case_34 + in: + days: + - 19 + - 84 + - 103 + - 158 + - 165 + - 171 + - 214 + - 287 + - 323 + - 355 + costs: + - 5 + - 27 + - 34 + out: 50 + - name: case_35 + in: + days: + - 183 + - 323 + costs: + - 1 + - 26 + - 33 + out: 2 diff --git a/tests/501-1000/983. minimum-cost-for-tickets/sol.cpp b/tests/501-1000/983. minimum-cost-for-tickets/sol.cpp new file mode 100644 index 00000000..74adbb65 --- /dev/null +++ b/tests/501-1000/983. minimum-cost-for-tickets/sol.cpp @@ -0,0 +1,26 @@ +class Solution { +public: + int mincostTickets(vector& days, vector& costs) { + int n = days.size(); + int left7 = 0; + int left30 = 0; + vector dp(n, 0); + + for (int right = 0; right < n; right++) { + while (days[right] - days[left7] >= 7) { + left7++; + } + while (days[right] - days[left30] >= 30) { + left30++; + } + + int cost1 = (right > 0 ? dp[right - 1] : 0) + costs[0]; + int cost7 = (left7 > 0 ? dp[left7 - 1] : 0) + costs[1]; + int cost30 = (left30 > 0 ? dp[left30 - 1] : 0) + costs[2]; + + dp[right] = min({cost1, cost7, cost30}); + } + + return dp[n - 1]; + } +}; diff --git a/tests/501-1000/983. minimum-cost-for-tickets/sol.cs b/tests/501-1000/983. minimum-cost-for-tickets/sol.cs new file mode 100644 index 00000000..a71a1a9e --- /dev/null +++ b/tests/501-1000/983. minimum-cost-for-tickets/sol.cs @@ -0,0 +1,25 @@ +public class Solution { + public int MincostTickets(int[] days, int[] costs) { + int n = days.Length; + int left7 = 0; + int left30 = 0; + int[] dp = new int[n]; + + for (int right = 0; right < n; right++) { + while (days[right] - days[left7] >= 7) { + left7++; + } + while (days[right] - days[left30] >= 30) { + left30++; + } + + int cost1 = (right > 0 ? dp[right - 1] : 0) + costs[0]; + int cost7 = (left7 > 0 ? dp[left7 - 1] : 0) + costs[1]; + int cost30 = (left30 > 0 ? dp[left30 - 1] : 0) + costs[2]; + + dp[right] = Math.Min(cost1, Math.Min(cost7, cost30)); + } + + return dp[n - 1]; + } +} diff --git a/tests/501-1000/983. minimum-cost-for-tickets/sol.dart b/tests/501-1000/983. minimum-cost-for-tickets/sol.dart new file mode 100644 index 00000000..dbe6f995 --- /dev/null +++ b/tests/501-1000/983. minimum-cost-for-tickets/sol.dart @@ -0,0 +1,25 @@ +class Solution { + int mincostTickets(List days, List costs) { + int n = days.length; + int left7 = 0; + int left30 = 0; + List dp = List.filled(n, 0); + + for (int right = 0; right < n; right++) { + while (days[right] - days[left7] >= 7) { + left7++; + } + while (days[right] - days[left30] >= 30) { + left30++; + } + + int cost1 = (right > 0 ? dp[right - 1] : 0) + costs[0]; + int cost7 = (left7 > 0 ? dp[left7 - 1] : 0) + costs[1]; + int cost30 = (left30 > 0 ? dp[left30 - 1] : 0) + costs[2]; + + dp[right] = [cost1, cost7, cost30].reduce((a, b) => a < b ? a : b); + } + + return dp[n - 1]; + } +} diff --git a/tests/501-1000/983. minimum-cost-for-tickets/sol.go b/tests/501-1000/983. minimum-cost-for-tickets/sol.go new file mode 100644 index 00000000..9bc10d26 --- /dev/null +++ b/tests/501-1000/983. minimum-cost-for-tickets/sol.go @@ -0,0 +1,32 @@ +func mincostTickets(days []int, costs []int) int { + n := len(days) + left7 := 0 + left30 := 0 + dp := make([]int, n) + + for right := 0; right < n; right++ { + for days[right] - days[left7] >= 7 { + left7++ + } + for days[right] - days[left30] >= 30 { + left30++ + } + + cost1 := costs[0] + if right > 0 { + cost1 += dp[right - 1] + } + cost7 := costs[1] + if left7 > 0 { + cost7 += dp[left7 - 1] + } + cost30 := costs[2] + if left30 > 0 { + cost30 += dp[left30 - 1] + } + + dp[right] = min(cost1, min(cost7, cost30)) + } + + return dp[n - 1] +} diff --git a/tests/501-1000/983. minimum-cost-for-tickets/sol.java b/tests/501-1000/983. minimum-cost-for-tickets/sol.java new file mode 100644 index 00000000..30368009 --- /dev/null +++ b/tests/501-1000/983. minimum-cost-for-tickets/sol.java @@ -0,0 +1,25 @@ +class Solution { + public int mincostTickets(int[] days, int[] costs) { + int n = days.length; + int left7 = 0; + int left30 = 0; + int[] dp = new int[n]; + + for (int right = 0; right < n; right++) { + while (days[right] - days[left7] >= 7) { + left7++; + } + while (days[right] - days[left30] >= 30) { + left30++; + } + + int cost1 = (right > 0 ? dp[right - 1] : 0) + costs[0]; + int cost7 = (left7 > 0 ? dp[left7 - 1] : 0) + costs[1]; + int cost30 = (left30 > 0 ? dp[left30 - 1] : 0) + costs[2]; + + dp[right] = Math.min(cost1, Math.min(cost7, cost30)); + } + + return dp[n - 1]; + } +} diff --git a/tests/501-1000/983. minimum-cost-for-tickets/sol.kt b/tests/501-1000/983. minimum-cost-for-tickets/sol.kt new file mode 100644 index 00000000..5c7ce551 --- /dev/null +++ b/tests/501-1000/983. minimum-cost-for-tickets/sol.kt @@ -0,0 +1,25 @@ +class Solution { + fun mincostTickets(days: IntArray, costs: IntArray): Int { + val n = days.size + var left7 = 0 + var left30 = 0 + val dp = IntArray(n) + + for (right in 0 until n) { + while (days[right] - days[left7] >= 7) { + left7++ + } + while (days[right] - days[left30] >= 30) { + left30++ + } + + val cost1 = (if (right > 0) dp[right - 1] else 0) + costs[0] + val cost7 = (if (left7 > 0) dp[left7 - 1] else 0) + costs[1] + val cost30 = (if (left30 > 0) dp[left30 - 1] else 0) + costs[2] + + dp[right] = minOf(cost1, minOf(cost7, cost30)) + } + + return dp[n - 1] + } +} diff --git a/tests/501-1000/983. minimum-cost-for-tickets/sol.py b/tests/501-1000/983. minimum-cost-for-tickets/sol.py new file mode 100644 index 00000000..371ca011 --- /dev/null +++ b/tests/501-1000/983. minimum-cost-for-tickets/sol.py @@ -0,0 +1,23 @@ +from typing import List + + +class Solution: + def mincostTickets(self, days: List[int], costs: List[int]) -> int: + n = len(days) + left7 = 0 + left30 = 0 + dp = [0] * n + + for right in range(n): + while days[right] - days[left7] >= 7: + left7 += 1 + while days[right] - days[left30] >= 30: + left30 += 1 + + cost1 = (dp[right - 1] if right > 0 else 0) + costs[0] + cost7 = (dp[left7 - 1] if left7 > 0 else 0) + costs[1] + cost30 = (dp[left30 - 1] if left30 > 0 else 0) + costs[2] + + dp[right] = min(cost1, cost7, cost30) + + return dp[n - 1] diff --git a/tests/501-1000/983. minimum-cost-for-tickets/sol.py2 b/tests/501-1000/983. minimum-cost-for-tickets/sol.py2 new file mode 100644 index 00000000..36b2d2b2 --- /dev/null +++ b/tests/501-1000/983. minimum-cost-for-tickets/sol.py2 @@ -0,0 +1,25 @@ +class Solution(object): + def mincostTickets(self, days, costs): + """ + :type days: List[int] + :type costs: List[int] + :rtype: int + """ + n = len(days) + left7 = 0 + left30 = 0 + dp = [0] * n + + for right in range(n): + while days[right] - days[left7] >= 7: + left7 += 1 + while days[right] - days[left30] >= 30: + left30 += 1 + + cost1 = (dp[right - 1] if right > 0 else 0) + costs[0] + cost7 = (dp[left7 - 1] if left7 > 0 else 0) + costs[1] + cost30 = (dp[left30 - 1] if left30 > 0 else 0) + costs[2] + + dp[right] = min(cost1, cost7, cost30) + + return dp[n - 1] diff --git a/tests/501-1000/983. minimum-cost-for-tickets/sol.rb b/tests/501-1000/983. minimum-cost-for-tickets/sol.rb new file mode 100644 index 00000000..85ce4b7c --- /dev/null +++ b/tests/501-1000/983. minimum-cost-for-tickets/sol.rb @@ -0,0 +1,26 @@ +# @param {Integer[]} days +# @param {Integer[]} costs +# @return {Integer} +def mincost_tickets(days, costs) + n = days.length + left7 = 0 + left30 = 0 + dp = Array.new(n, 0) + + (0...n).each do |right| + while days[right] - days[left7] >= 7 + left7 += 1 + end + while days[right] - days[left30] >= 30 + left30 += 1 + end + + cost1 = (right > 0 ? dp[right - 1] : 0) + costs[0] + cost7 = (left7 > 0 ? dp[left7 - 1] : 0) + costs[1] + cost30 = (left30 > 0 ? dp[left30 - 1] : 0) + costs[2] + + dp[right] = [cost1, cost7, cost30].min + end + + dp[n - 1] +end diff --git a/tests/501-1000/983. minimum-cost-for-tickets/sol.rs b/tests/501-1000/983. minimum-cost-for-tickets/sol.rs new file mode 100644 index 00000000..5f501052 --- /dev/null +++ b/tests/501-1000/983. minimum-cost-for-tickets/sol.rs @@ -0,0 +1,25 @@ +impl Solution { + pub fn mincost_tickets(days: Vec, costs: Vec) -> i32 { + let n = days.len(); + let mut left7 = 0; + let mut left30 = 0; + let mut dp = vec![0; n]; + + for right in 0..n { + while days[right] - days[left7] >= 7 { + left7 += 1; + } + while days[right] - days[left30] >= 30 { + left30 += 1; + } + + let cost1 = (if right > 0 { dp[right - 1] } else { 0 }) + costs[0]; + let cost7 = (if left7 > 0 { dp[left7 - 1] } else { 0 }) + costs[1]; + let cost30 = (if left30 > 0 { dp[left30 - 1] } else { 0 }) + costs[2]; + + dp[right] = cost1.min(cost7).min(cost30); + } + + dp[n - 1] + } +} diff --git a/tests/501-1000/983. minimum-cost-for-tickets/sol.swift b/tests/501-1000/983. minimum-cost-for-tickets/sol.swift new file mode 100644 index 00000000..5bc64355 --- /dev/null +++ b/tests/501-1000/983. minimum-cost-for-tickets/sol.swift @@ -0,0 +1,25 @@ +class Solution { + func mincostTickets(_ days: [Int], _ costs: [Int]) -> Int { + let n = days.count + var left7 = 0 + var left30 = 0 + var dp = Array(repeating: 0, count: n) + + for right in 0..= 7 { + left7 += 1 + } + while days[right] - days[left30] >= 30 { + left30 += 1 + } + + let cost1 = (right > 0 ? dp[right - 1] : 0) + costs[0] + let cost7 = (left7 > 0 ? dp[left7 - 1] : 0) + costs[1] + let cost30 = (left30 > 0 ? dp[left30 - 1] : 0) + costs[2] + + dp[right] = min(cost1, min(cost7, cost30)) + } + + return dp[n - 1] + } +} diff --git a/tests/501-1000/983. minimum-cost-for-tickets/sol.ts b/tests/501-1000/983. minimum-cost-for-tickets/sol.ts new file mode 100644 index 00000000..abd0bb87 --- /dev/null +++ b/tests/501-1000/983. minimum-cost-for-tickets/sol.ts @@ -0,0 +1,23 @@ +function mincostTickets(days: number[], costs: number[]): number { + const n = days.length; + let left7 = 0; + let left30 = 0; + const dp: number[] = new Array(n).fill(0); + + for (let right = 0; right < n; right++) { + while (days[right] - days[left7] >= 7) { + left7++; + } + while (days[right] - days[left30] >= 30) { + left30++; + } + + const cost1 = (right > 0 ? dp[right - 1] : 0) + costs[0]; + const cost7 = (left7 > 0 ? dp[left7 - 1] : 0) + costs[1]; + const cost30 = (left30 > 0 ? dp[left30 - 1] : 0) + costs[2]; + + dp[right] = Math.min(cost1, Math.min(cost7, cost30)); + } + + return dp[n - 1]; +} diff --git a/tests/501-1000/984. string-without-aaa-or-bbb/manifest.yaml b/tests/501-1000/984. string-without-aaa-or-bbb/manifest.yaml new file mode 100644 index 00000000..65b73459 --- /dev/null +++ b/tests/501-1000/984. string-without-aaa-or-bbb/manifest.yaml @@ -0,0 +1,177 @@ +entry: + id: 984 + title: string-without-aaa-or-bbb + params: + a: + type: int + b: + type: int + call: + cpp: Solution().strWithout3a3b({a}, {b}) + rust: Solution::str_without3a3b({a}, {b}) + python3: Solution().strWithout3a3b({a}, {b}) + python2: Solution().strWithout3a3b({a}, {b}) + ruby: str_without3a3b({a}, {b}) + java: new Solution().strWithout3a3b({a}, {b}) + csharp: new Solution().StrWithout3a3b({a}, {b}) + kotlin: Solution().strWithout3a3b({a}, {b}) + go: strWithout3a3b({a}, {b}) + dart: Solution().strWithout3a3b({a}, {b}) + swift: Solution().strWithout3a3b({a}, {b}) + typescript: strWithout3a3b({a}, {b}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().strWithout3a3b(a, b, {result}) + checker: + "class Checker:\n def strWithout3a3b(self, a, b, result):\n \ + \ if not isinstance(result, str):\n return False\n if len(result)\ + \ != a + b:\n return False\n if result.count('a') != a or\ + \ result.count('b') != b:\n return False\n return 'aaa' not\ + \ in result and 'bbb' not in result\n" +seed: 984 +tests: + - name: case_1 + in: + a: 2 + b: 1 + - name: case_2 + in: + a: 5 + b: 5 + - name: case_3 + in: + a: 8 + b: 4 + - name: case_4 + in: + a: 5 + b: 3 + - name: case_5 + in: + a: 3 + b: 2 + - name: case_6 + in: + a: 4 + b: 4 + - name: case_7 + in: + a: 2 + b: 0 + - name: case_8 + in: + a: 1 + b: 3 + - name: case_9 + in: + a: 4 + b: 4 + - name: case_10 + in: + a: 2 + b: 6 + - name: case_11 + in: + a: 3 + b: 4 + - name: case_12 + in: + a: 3 + b: 6 + - name: case_13 + in: + a: 4 + b: 1 + - name: case_14 + in: + a: 4 + b: 2 + - name: case_15 + in: + a: 2 + b: 2 + - name: case_16 + in: + a: 8 + b: 8 + - name: case_17 + in: + a: 7 + b: 3 + - name: case_18 + in: + a: 6 + b: 5 + - name: case_19 + in: + a: 2 + b: 4 + - name: case_20 + in: + a: 6 + b: 5 + - name: case_21 + in: + a: 3 + b: 1 + - name: case_22 + in: + a: 6 + b: 5 + - name: case_23 + in: + a: 5 + b: 3 + - name: case_24 + in: + a: 4 + b: 1 + - name: case_25 + in: + a: 0 + b: 2 + - name: case_26 + in: + a: 7 + b: 3 + - name: case_27 + in: + a: 5 + b: 7 + - name: case_28 + in: + a: 8 + b: 7 + - name: case_29 + in: + a: 5 + b: 5 + - name: case_30 + in: + a: 2 + b: 1 + - name: case_31 + in: + a: 3 + b: 1 + - name: case_32 + in: + a: 7 + b: 3 + - name: case_33 + in: + a: 3 + b: 5 + - name: case_34 + in: + a: 1 + b: 1 + - name: case_35 + in: + a: 3 + b: 2 diff --git a/tests/501-1000/984. string-without-aaa-or-bbb/sol.cpp b/tests/501-1000/984. string-without-aaa-or-bbb/sol.cpp new file mode 100644 index 00000000..1f5c8c33 --- /dev/null +++ b/tests/501-1000/984. string-without-aaa-or-bbb/sol.cpp @@ -0,0 +1,30 @@ +class Solution { +public: + string strWithout3a3b(int a, int b) { + string res = ""; + int prev_a = 0, prev_b = 0; + + while (a > 0 || b > 0) { + if (prev_a == 2 && b > 0) { + res += "b"; + b--; + prev_b++; + prev_a = 0; + } else if (prev_b == 2 && a > 0) { + res += "a"; + a--; + prev_a++; + prev_b = 0; + } else if (a > b && a > 0) { + res += "a"; + a--; + prev_a++; + } else if (b > 0) { + res += "b"; + b--; + prev_b++; + } + } + return res; + } +}; diff --git a/tests/501-1000/984. string-without-aaa-or-bbb/sol.cs b/tests/501-1000/984. string-without-aaa-or-bbb/sol.cs new file mode 100644 index 00000000..44927825 --- /dev/null +++ b/tests/501-1000/984. string-without-aaa-or-bbb/sol.cs @@ -0,0 +1,29 @@ +public class Solution { + public string StrWithout3a3b(int a, int b) { + string res = ""; + int prev_a = 0, prev_b = 0; + + while (a > 0 || b > 0) { + if (prev_a == 2 && b > 0) { + res += "b"; + b--; + prev_b++; + prev_a = 0; + } else if (prev_b == 2 && a > 0) { + res += "a"; + a--; + prev_a++; + prev_b = 0; + } else if (a > b && a > 0) { + res += "a"; + a--; + prev_a++; + } else if (b > 0) { + res += "b"; + b--; + prev_b++; + } + } + return res; + } +} diff --git a/tests/501-1000/984. string-without-aaa-or-bbb/sol.dart b/tests/501-1000/984. string-without-aaa-or-bbb/sol.dart new file mode 100644 index 00000000..bcfbce57 --- /dev/null +++ b/tests/501-1000/984. string-without-aaa-or-bbb/sol.dart @@ -0,0 +1,33 @@ +class Solution { + String strWithout3a3b(int a, int b) { + StringBuffer result = StringBuffer(); + int prevA = 0; + int prevB = 0; + + while (a > 0 || b > 0) { + if (prevA == 2 && b > 0) { + result.write('b'); + b--; + prevB++; + prevA = 0; + } else if (prevB == 2 && a > 0) { + result.write('a'); + a--; + prevA++; + prevB = 0; + } else if (a > b && a > 0) { + result.write('a'); + a--; + prevA++; + prevB = 0; + } else { + result.write('b'); + b--; + prevB++; + prevA = 0; + } + } + + return result.toString(); + } +} diff --git a/tests/501-1000/984. string-without-aaa-or-bbb/sol.go b/tests/501-1000/984. string-without-aaa-or-bbb/sol.go new file mode 100644 index 00000000..e54260fa --- /dev/null +++ b/tests/501-1000/984. string-without-aaa-or-bbb/sol.go @@ -0,0 +1,28 @@ +func strWithout3a3b(a int, b int) string { + res := "" + prevA := 0 + prevB := 0 + + for a > 0 || b > 0 { + if prevA == 2 && b > 0 { + res += "b" + b-- + prevB++ + prevA = 0 + } else if prevB == 2 && a > 0 { + res += "a" + a-- + prevA++ + prevB = 0 + } else if a > b && a > 0 { + res += "a" + a-- + prevA++ + } else if b > 0 { + res += "b" + b-- + prevB++ + } + } + return res +} diff --git a/tests/501-1000/984. string-without-aaa-or-bbb/sol.java b/tests/501-1000/984. string-without-aaa-or-bbb/sol.java new file mode 100644 index 00000000..45c431f3 --- /dev/null +++ b/tests/501-1000/984. string-without-aaa-or-bbb/sol.java @@ -0,0 +1,29 @@ +class Solution { + public String strWithout3a3b(int a, int b) { + StringBuilder res = new StringBuilder(); + int prev_a = 0, prev_b = 0; + + while (a > 0 || b > 0) { + if (prev_a == 2 && b > 0) { + res.append("b"); + b--; + prev_b++; + prev_a = 0; + } else if (prev_b == 2 && a > 0) { + res.append("a"); + a--; + prev_a++; + prev_b = 0; + } else if (a > b && a > 0) { + res.append("a"); + a--; + prev_a++; + } else if (b > 0) { + res.append("b"); + b--; + prev_b++; + } + } + return res.toString(); + } +} diff --git a/tests/501-1000/984. string-without-aaa-or-bbb/sol.kt b/tests/501-1000/984. string-without-aaa-or-bbb/sol.kt new file mode 100644 index 00000000..6356cc90 --- /dev/null +++ b/tests/501-1000/984. string-without-aaa-or-bbb/sol.kt @@ -0,0 +1,37 @@ +class Solution { + fun strWithout3a3b(a: Int, b: Int): String { + val res = StringBuilder() + var aCount = a + var bCount = b + var prevA = 0 + var prevB = 0 + + while (aCount > 0 || bCount > 0) { + when { + prevA == 2 && bCount > 0 -> { + res.append("b") + bCount-- + prevB++ + prevA = 0 + } + prevB == 2 && aCount > 0 -> { + res.append("a") + aCount-- + prevA++ + prevB = 0 + } + aCount > bCount && aCount > 0 -> { + res.append("a") + aCount-- + prevA++ + } + bCount > 0 -> { + res.append("b") + bCount-- + prevB++ + } + } + } + return res.toString() + } +} diff --git a/tests/501-1000/984. string-without-aaa-or-bbb/sol.py b/tests/501-1000/984. string-without-aaa-or-bbb/sol.py new file mode 100644 index 00000000..91607032 --- /dev/null +++ b/tests/501-1000/984. string-without-aaa-or-bbb/sol.py @@ -0,0 +1,25 @@ +class Solution: + def strWithout3a3b(self, a: int, b: int) -> str: + res = "" + prev_a = prev_b = 0 + + while a > 0 or b > 0: + if prev_a == 2 and b > 0: + res += "b" + b -= 1 + prev_b += 1 + prev_a = 0 + elif prev_b == 2 and a > 0: + res += "a" + a -= 1 + prev_a += 1 + prev_b = 0 + elif a > b and a > 0: + res += "a" + a -= 1 + prev_a += 1 + elif b > 0: + res += "b" + b -= 1 + prev_b += 1 + return res diff --git a/tests/501-1000/984. string-without-aaa-or-bbb/sol.py2 b/tests/501-1000/984. string-without-aaa-or-bbb/sol.py2 new file mode 100644 index 00000000..bfb7051e --- /dev/null +++ b/tests/501-1000/984. string-without-aaa-or-bbb/sol.py2 @@ -0,0 +1,30 @@ +class Solution(object): + def strWithout3a3b(self, a, b): + """ + :type a: int + :type b: int + :rtype: str + """ + res = "" + prev_a = prev_b = 0 + + while a > 0 or b > 0: + if prev_a == 2 and b > 0: + res += "b" + b -= 1 + prev_b += 1 + prev_a = 0 + elif prev_b == 2 and a > 0: + res += "a" + a -= 1 + prev_a += 1 + prev_b = 0 + elif a > b and a > 0: + res += "a" + a -= 1 + prev_a += 1 + elif b > 0: + res += "b" + b -= 1 + prev_b += 1 + return res diff --git a/tests/501-1000/984. string-without-aaa-or-bbb/sol.rb b/tests/501-1000/984. string-without-aaa-or-bbb/sol.rb new file mode 100644 index 00000000..565451e2 --- /dev/null +++ b/tests/501-1000/984. string-without-aaa-or-bbb/sol.rb @@ -0,0 +1,31 @@ +# @param {Integer} a +# @param {Integer} b +# @return {String} +def str_without3a3b(a, b) + res = "" + prev_a = 0 + prev_b = 0 + + while a > 0 || b > 0 + if prev_a == 2 && b > 0 + res += "b" + b -= 1 + prev_b += 1 + prev_a = 0 + elsif prev_b == 2 && a > 0 + res += "a" + a -= 1 + prev_a += 1 + prev_b = 0 + elsif a > b && a > 0 + res += "a" + a -= 1 + prev_a += 1 + elsif b > 0 + res += "b" + b -= 1 + prev_b += 1 + end + end + res +end diff --git a/tests/501-1000/984. string-without-aaa-or-bbb/sol.rs b/tests/501-1000/984. string-without-aaa-or-bbb/sol.rs new file mode 100644 index 00000000..f69fb16e --- /dev/null +++ b/tests/501-1000/984. string-without-aaa-or-bbb/sol.rs @@ -0,0 +1,32 @@ +impl Solution { + pub fn str_without3a3b(a: i32, b: i32) -> String { + let mut res = String::new(); + let mut a_count = a; + let mut b_count = b; + let mut prev_a = 0; + let mut prev_b = 0; + + while a_count > 0 || b_count > 0 { + if prev_a == 2 && b_count > 0 { + res.push('b'); + b_count -= 1; + prev_b += 1; + prev_a = 0; + } else if prev_b == 2 && a_count > 0 { + res.push('a'); + a_count -= 1; + prev_a += 1; + prev_b = 0; + } else if a_count > b_count && a_count > 0 { + res.push('a'); + a_count -= 1; + prev_a += 1; + } else if b_count > 0 { + res.push('b'); + b_count -= 1; + prev_b += 1; + } + } + res + } +} diff --git a/tests/501-1000/984. string-without-aaa-or-bbb/sol.swift b/tests/501-1000/984. string-without-aaa-or-bbb/sol.swift new file mode 100644 index 00000000..a9725540 --- /dev/null +++ b/tests/501-1000/984. string-without-aaa-or-bbb/sol.swift @@ -0,0 +1,32 @@ +class Solution { + func strWithout3a3b(_ a: Int, _ b: Int) -> String { + var res = "" + var aCount = a + var bCount = b + var prevA = 0 + var prevB = 0 + + while aCount > 0 || bCount > 0 { + if prevA == 2 && bCount > 0 { + res += "b" + bCount -= 1 + prevB += 1 + prevA = 0 + } else if prevB == 2 && aCount > 0 { + res += "a" + aCount -= 1 + prevA += 1 + prevB = 0 + } else if aCount > bCount && aCount > 0 { + res += "a" + aCount -= 1 + prevA += 1 + } else if bCount > 0 { + res += "b" + bCount -= 1 + prevB += 1 + } + } + return res + } +} diff --git a/tests/501-1000/984. string-without-aaa-or-bbb/sol.ts b/tests/501-1000/984. string-without-aaa-or-bbb/sol.ts new file mode 100644 index 00000000..1d5f1293 --- /dev/null +++ b/tests/501-1000/984. string-without-aaa-or-bbb/sol.ts @@ -0,0 +1,28 @@ +function strWithout3a3b(a: number, b: number): string { + let res = ""; + let prev_a = 0; + let prev_b = 0; + + while (a > 0 || b > 0) { + if (prev_a === 2 && b > 0) { + res += "b"; + b--; + prev_b++; + prev_a = 0; + } else if (prev_b === 2 && a > 0) { + res += "a"; + a--; + prev_a++; + prev_b = 0; + } else if (a > b && a > 0) { + res += "a"; + a--; + prev_a++; + } else if (b > 0) { + res += "b"; + b--; + prev_b++; + } + } + return res; +} diff --git a/tests/501-1000/985. sum-of-even-numbers-after-queries/manifest.yaml b/tests/501-1000/985. sum-of-even-numbers-after-queries/manifest.yaml new file mode 100644 index 00000000..3589877f --- /dev/null +++ b/tests/501-1000/985. sum-of-even-numbers-after-queries/manifest.yaml @@ -0,0 +1,840 @@ +entry: + id: 985 + title: sum-of-even-numbers-after-queries + params: + nums: + type: array + items: + type: int + queries: + type: array + items: + type: array + items: + type: int + call: + cpp: Solution().sumEvenAfterQueries({nums}, {queries}) + rust: Solution::sum_even_after_queries({nums}, {queries}) + python3: Solution().sumEvenAfterQueries({nums}, {queries}) + python2: Solution().sumEvenAfterQueries({nums}, {queries}) + ruby: sum_even_after_queries({nums}, {queries}) + java: new Solution().sumEvenAfterQueries({nums}, {queries}) + csharp: new Solution().SumEvenAfterQueries({nums}, {queries}) + kotlin: Solution().sumEvenAfterQueries({nums}, {queries}) + go: sumEvenAfterQueries({nums}, {queries}) + dart: Solution().sumEvenAfterQueries({nums}, {queries}) + swift: Solution().sumEvenAfterQueries({nums}, {queries}) + typescript: sumEvenAfterQueries({nums}, {queries}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 985 +tests: + - name: case_1 + in: + nums: + - 2 + - -8 + - -9 + - 4 + queries: + - - -1 + - 3 + - - 1 + - 1 + - - 4 + - 2 + out: + - -6 + - 2 + - 2 + - name: case_2 + in: + nums: + - -4 + - -8 + - -1 + - 3 + - 5 + - -9 + queries: + - - 6 + - 1 + out: + - -6 + - name: case_3 + in: + nums: + - -8 + - -6 + - 5 + - -4 + - 1 + - -2 + - 6 + queries: + - - -8 + - 0 + - - 5 + - 0 + - - 2 + - 3 + - - 6 + - 6 + - - -3 + - 2 + - - -3 + - 2 + - - 8 + - 6 + - - 6 + - 5 + out: + - -22 + - -6 + - -4 + - 2 + - 4 + - 2 + - 10 + - 16 + - name: case_4 + in: + nums: + - -1 + - -3 + - -10 + - 3 + - -6 + queries: + - - 0 + - 3 + - - -3 + - 0 + - - 10 + - 2 + out: + - -16 + - -20 + - -10 + - name: case_5 + in: + nums: + - -6 + - -6 + - 8 + - 7 + queries: + - - -9 + - 2 + - - -4 + - 3 + - - -6 + - 0 + - - 1 + - 2 + - - -7 + - 3 + out: + - -12 + - -12 + - -18 + - -18 + - -22 + - name: case_6 + in: + nums: + - 1 + - -9 + - -3 + - -10 + - 10 + queries: + - - 9 + - 0 + - - -3 + - 4 + out: + - 10 + - 0 + - name: case_7 + in: + nums: + - 3 + - 7 + - 0 + - -1 + - 3 + - 7 + - -8 + queries: + - - 2 + - 0 + - - -1 + - 0 + out: + - -8 + - -4 + - name: case_8 + in: + nums: + - 2 + - -3 + - -4 + - -6 + queries: + - - -5 + - 3 + - - 7 + - 2 + - - 4 + - 1 + - - 10 + - 3 + - - -8 + - 0 + - - -5 + - 2 + out: + - -2 + - 2 + - 2 + - 2 + - -6 + - -8 + - name: case_9 + in: + nums: + - 0 + - -6 + - 10 + - -5 + queries: + - - 1 + - 1 + - - 7 + - 0 + - - -1 + - 2 + - - -5 + - 3 + - - -2 + - 0 + - - -1 + - 1 + - - 0 + - 1 + out: + - 10 + - 10 + - 0 + - -10 + - -10 + - -16 + - -16 + - name: case_10 + in: + nums: + - 10 + - 10 + - -10 + - -7 + - -4 + - 4 + - 8 + - -9 + queries: + - - -1 + - 6 + - - 8 + - 3 + - - 2 + - 3 + - - 1 + - 7 + - - 4 + - 3 + - - -3 + - 3 + - - -10 + - 7 + - - -9 + - 7 + out: + - 10 + - 10 + - 10 + - 2 + - 2 + - 6 + - -4 + - 14 + - name: case_11 + in: + nums: + - 8 + queries: + - - -8 + - 0 + - - -6 + - 0 + - - 6 + - 0 + - - 2 + - 0 + - - 4 + - 0 + - - -8 + - 0 + - - 8 + - 0 + out: + - 0 + - -6 + - 0 + - 2 + - 6 + - -2 + - 6 + - name: case_12 + in: + nums: + - 10 + queries: + - - 0 + - 0 + - - 7 + - 0 + - - -7 + - 0 + - - 10 + - 0 + - - -3 + - 0 + out: + - 10 + - 0 + - 10 + - 20 + - 0 + - name: case_13 + in: + nums: + - -5 + - 9 + - 0 + - -4 + - 5 + queries: + - - 1 + - 1 + - - 1 + - 4 + - - 1 + - 2 + - - -1 + - 0 + - - 3 + - 1 + - - -5 + - 0 + - - -3 + - 2 + - - 5 + - 2 + out: + - 6 + - 12 + - 12 + - 6 + - -4 + - 2 + - 0 + - 2 + - name: case_14 + in: + nums: + - 2 + - 3 + - -3 + - 5 + - 1 + queries: + - - -9 + - 1 + - - -10 + - 4 + - - -8 + - 0 + - - 0 + - 1 + - - 7 + - 3 + - - -3 + - 3 + - - -6 + - 4 + - - -10 + - 2 + out: + - -4 + - -4 + - -12 + - -12 + - 0 + - -12 + - -12 + - -12 + - name: case_15 + in: + nums: + - -5 + - 5 + - 9 + - -9 + - -3 + - -1 + - -5 + - -4 + queries: + - - 9 + - 0 + - - -9 + - 4 + out: + - 0 + - -12 + - name: case_16 + in: + nums: + - 5 + queries: + - - -8 + - 0 + - - -1 + - 0 + - - -4 + - 0 + - - -9 + - 0 + - - -4 + - 0 + - - 4 + - 0 + out: + - 0 + - -4 + - -8 + - 0 + - 0 + - 0 + - name: case_17 + in: + nums: + - -1 + - 0 + - 10 + - 9 + queries: + - - -6 + - 2 + - - -5 + - 3 + - - 9 + - 1 + - - 6 + - 1 + - - 10 + - 0 + - - -8 + - 3 + - - 10 + - 1 + - - 0 + - 0 + out: + - 4 + - 8 + - 8 + - 8 + - 8 + - 0 + - 0 + - 0 + - name: case_18 + in: + nums: + - -3 + - 9 + - -1 + queries: + - - -6 + - 2 + out: + - 0 + - name: case_19 + in: + nums: + - 2 + - -8 + - 9 + - 1 + queries: + - - -9 + - 2 + - - 5 + - 1 + - - -6 + - 0 + out: + - -6 + - 2 + - -4 + - name: case_20 + in: + nums: + - 3 + - -9 + - 3 + - -10 + - 0 + - -7 + - -10 + queries: + - - 2 + - 6 + - - -5 + - 3 + - - -2 + - 6 + - - 8 + - 2 + - - -5 + - 2 + out: + - -18 + - -8 + - -10 + - -10 + - -4 + - name: case_21 + in: + nums: + - 5 + - -5 + - 8 + - -3 + - -4 + - 3 + queries: + - - 4 + - 2 + - - -9 + - 3 + out: + - 8 + - -4 + - name: case_22 + in: + nums: + - -4 + - 3 + - 7 + - 7 + - 4 + - -2 + - -8 + queries: + - - 2 + - 5 + - - 7 + - 2 + - - 7 + - 5 + - - -5 + - 3 + - - 7 + - 0 + - - 0 + - 6 + out: + - -8 + - 6 + - 6 + - 8 + - 12 + - 12 + - name: case_23 + in: + nums: + - 0 + - -8 + - 7 + - 3 + - 3 + - -1 + - -10 + queries: + - - 5 + - 3 + - - -10 + - 1 + - - -7 + - 6 + - - 0 + - 2 + - - -2 + - 3 + - - 9 + - 1 + out: + - -10 + - -20 + - -10 + - -10 + - -12 + - 6 + - name: case_24 + in: + nums: + - -10 + - -4 + - 1 + - 7 + - -10 + queries: + - - 3 + - 3 + - - 3 + - 2 + - - -6 + - 1 + - - 6 + - 3 + out: + - -14 + - -10 + - -16 + - -10 + - name: case_25 + in: + nums: + - 8 + - -8 + - -9 + - -2 + - -9 + - -9 + - -1 + queries: + - - 1 + - 6 + - - 9 + - 3 + out: + - -2 + - 0 + - name: case_26 + in: + nums: + - 10 + - 1 + - 1 + - -4 + - -5 + - 5 + - -9 + - -3 + queries: + - - 7 + - 4 + out: + - 8 + - name: case_27 + in: + nums: + - -2 + - 5 + - -9 + - 7 + - -2 + - 10 + queries: + - - 7 + - 1 + - - -7 + - 4 + out: + - 18 + - 20 + - name: case_28 + in: + nums: + - 4 + - -6 + - -3 + - 5 + - 1 + queries: + - - 9 + - 3 + - - 2 + - 2 + - - -7 + - 0 + - - 9 + - 4 + out: + - 12 + - 12 + - 8 + - 18 + - name: case_29 + in: + nums: + - -2 + - -7 + - -6 + queries: + - - -1 + - 0 + - - 4 + - 2 + out: + - -6 + - -2 + - name: case_30 + in: + nums: + - 5 + - 1 + queries: + - - -8 + - 0 + - - -9 + - 0 + - - 8 + - 0 + - - -10 + - 1 + out: + - 0 + - -12 + - -4 + - -4 + - name: case_31 + in: + nums: + - -9 + - 9 + - 0 + - 6 + - 10 + - 10 + queries: + - - 10 + - 5 + - - 3 + - 3 + - - 2 + - 4 + - - 2 + - 5 + out: + - 36 + - 30 + - 32 + - 34 + - name: case_32 + in: + nums: + - -4 + queries: + - - -6 + - 0 + - - -8 + - 0 + - - -9 + - 0 + out: + - -10 + - -18 + - 0 + - name: case_33 + in: + nums: + - -3 + - 0 + - 3 + - -1 + queries: + - - -2 + - 3 + - - -6 + - 3 + - - -6 + - 1 + - - 2 + - 1 + - - 5 + - 3 + - - -9 + - 3 + - - -8 + - 3 + - - 4 + - 2 + out: + - 0 + - 0 + - -6 + - -4 + - -8 + - -4 + - -4 + - -4 + - name: case_34 + in: + nums: + - -4 + - 9 + - 8 + queries: + - - 10 + - 0 + - - 6 + - 1 + - - 0 + - 1 + - - -1 + - 0 + out: + - 14 + - 14 + - 14 + - 8 + - name: case_35 + in: + nums: + - 4 + - -10 + - 1 + - -2 + - 5 + queries: + - - 4 + - 4 + - - -5 + - 2 + - - 7 + - 0 + out: + - -8 + - -12 + - -16 diff --git a/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.cpp b/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.cpp new file mode 100644 index 00000000..35532b3d --- /dev/null +++ b/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.cpp @@ -0,0 +1,19 @@ +class Solution { +public: + vector sumEvenAfterQueries(vector& nums, vector>& queries) { + int total = 0; + for (int x : nums) { + if (x % 2 == 0) total += x; + } + vector ans; + for (auto& q : queries) { + int val = q[0]; + int idx = q[1]; + if (nums[idx] % 2 == 0) total -= nums[idx]; + nums[idx] += val; + if (nums[idx] % 2 == 0) total += nums[idx]; + ans.push_back(total); + } + return ans; + } +}; diff --git a/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.cs b/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.cs new file mode 100644 index 00000000..8c08e4a6 --- /dev/null +++ b/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.cs @@ -0,0 +1,18 @@ +public class Solution { + public int[] SumEvenAfterQueries(int[] nums, int[][] queries) { + int total = 0; + foreach (int x in nums) { + if (x % 2 == 0) total += x; + } + int[] ans = new int[queries.Length]; + for (int i = 0; i < queries.Length; i++) { + int val = queries[i][0]; + int idx = queries[i][1]; + if (nums[idx] % 2 == 0) total -= nums[idx]; + nums[idx] += val; + if (nums[idx] % 2 == 0) total += nums[idx]; + ans[i] = total; + } + return ans; + } +} diff --git a/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.dart b/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.dart new file mode 100644 index 00000000..65302602 --- /dev/null +++ b/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.dart @@ -0,0 +1,15 @@ +class Solution { + List sumEvenAfterQueries(List nums, List> queries) { + int total = nums.where((x) => x % 2 == 0).fold(0, (a, b) => a + b); + List ans = []; + for (var q in queries) { + int val = q[0]; + int idx = q[1]; + if (nums[idx] % 2 == 0) total -= nums[idx]; + nums[idx] += val; + if (nums[idx] % 2 == 0) total += nums[idx]; + ans.add(total); + } + return ans; + } +} diff --git a/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.go b/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.go new file mode 100644 index 00000000..eaa75537 --- /dev/null +++ b/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.go @@ -0,0 +1,21 @@ +func sumEvenAfterQueries(nums []int, queries [][]int) []int { + total := 0 + for _, x := range nums { + if x % 2 == 0 { + total += x + } + } + ans := make([]int, len(queries)) + for i, q := range queries { + val, idx := q[0], q[1] + if nums[idx] % 2 == 0 { + total -= nums[idx] + } + nums[idx] += val + if nums[idx] % 2 == 0 { + total += nums[idx] + } + ans[i] = total + } + return ans +} diff --git a/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.java b/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.java new file mode 100644 index 00000000..b69956ce --- /dev/null +++ b/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.java @@ -0,0 +1,18 @@ +class Solution { + public int[] sumEvenAfterQueries(int[] nums, int[][] queries) { + int total = 0; + for (int x : nums) { + if (x % 2 == 0) total += x; + } + int[] ans = new int[queries.length]; + for (int i = 0; i < queries.length; i++) { + int val = queries[i][0]; + int idx = queries[i][1]; + if (nums[idx] % 2 == 0) total -= nums[idx]; + nums[idx] += val; + if (nums[idx] % 2 == 0) total += nums[idx]; + ans[i] = total; + } + return ans; + } +} diff --git a/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.kt b/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.kt new file mode 100644 index 00000000..fadf0321 --- /dev/null +++ b/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.kt @@ -0,0 +1,14 @@ +class Solution { + fun sumEvenAfterQueries(nums: IntArray, queries: Array): IntArray { + var total = nums.filter { it % 2 == 0 }.sum() + val ans = IntArray(queries.size) + for (i in queries.indices) { + val (delta, idx) = queries[i] + if (nums[idx] % 2 == 0) total -= nums[idx] + nums[idx] += delta + if (nums[idx] % 2 == 0) total += nums[idx] + ans[i] = total + } + return ans + } +} diff --git a/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.py b/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.py new file mode 100644 index 00000000..9591b618 --- /dev/null +++ b/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.py @@ -0,0 +1,17 @@ +from typing import List + + +class Solution: + def sumEvenAfterQueries( + self, nums: List[int], queries: List[List[int]] + ) -> List[int]: + total = sum(x for x in nums if x % 2 == 0) + ans = [] + for val, idx in queries: + if nums[idx] % 2 == 0: + total -= nums[idx] + nums[idx] += val + if nums[idx] % 2 == 0: + total += nums[idx] + ans.append(total) + return ans diff --git a/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.py2 b/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.py2 new file mode 100644 index 00000000..473c4172 --- /dev/null +++ b/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.py2 @@ -0,0 +1,17 @@ +class Solution(object): + def sumEvenAfterQueries(self, nums, queries): + """ + :type nums: List[int] + :type queries: List[List[int]] + :rtype: List[int] + """ + total = sum(x for x in nums if x % 2 == 0) + ans = [] + for val, idx in queries: + if nums[idx] % 2 == 0: + total -= nums[idx] + nums[idx] += val + if nums[idx] % 2 == 0: + total += nums[idx] + ans.append(total) + return ans diff --git a/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.rb b/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.rb new file mode 100644 index 00000000..ff9445dd --- /dev/null +++ b/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.rb @@ -0,0 +1,18 @@ +# @param {Integer[]} nums +# @param {Integer[][]} queries +# @return {Integer[]} +def sum_even_after_queries(nums, queries) + total = nums.select { |x| x % 2 == 0 }.sum + ans = [] + queries.each do |val, idx| + if nums[idx] % 2 == 0 + total -= nums[idx] + end + nums[idx] += val + if nums[idx] % 2 == 0 + total += nums[idx] + end + ans << total + end + ans +end diff --git a/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.rs b/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.rs new file mode 100644 index 00000000..ad8e9d2f --- /dev/null +++ b/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.rs @@ -0,0 +1,20 @@ +impl Solution { + pub fn sum_even_after_queries(nums: Vec, queries: Vec>) -> Vec { + let mut nums = nums; + let mut total: i32 = nums.iter().filter(|&&x| x % 2 == 0).sum(); + let mut ans = Vec::with_capacity(queries.len()); + for q in queries { + let val = q[0]; + let idx = q[1] as usize; + if nums[idx] % 2 == 0 { + total -= nums[idx]; + } + nums[idx] += val; + if nums[idx] % 2 == 0 { + total += nums[idx]; + } + ans.push(total); + } + ans + } +} diff --git a/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.swift b/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.swift new file mode 100644 index 00000000..21f394dc --- /dev/null +++ b/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.swift @@ -0,0 +1,19 @@ +class Solution { + func sumEvenAfterQueries(_ nums: [Int], _ queries: [[Int]]) -> [Int] { + var nums = nums + var total = nums.filter { $0 % 2 == 0 }.reduce(0, +) + var ans: [Int] = [] + for q in queries { + let val = q[0], idx = q[1] + if nums[idx] % 2 == 0 { + total -= nums[idx] + } + nums[idx] += val + if nums[idx] % 2 == 0 { + total += nums[idx] + } + ans.append(total) + } + return ans + } +} diff --git a/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.ts b/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.ts new file mode 100644 index 00000000..79d9631e --- /dev/null +++ b/tests/501-1000/985. sum-of-even-numbers-after-queries/sol.ts @@ -0,0 +1,11 @@ +function sumEvenAfterQueries(nums: number[], queries: number[][]): number[] { + let total = nums.filter((x) => x % 2 === 0).reduce((a, b) => a + b, 0); + const ans: number[] = []; + for (const [val, idx] of queries) { + if (nums[idx] % 2 === 0) total -= nums[idx]; + nums[idx] += val; + if (nums[idx] % 2 === 0) total += nums[idx]; + ans.push(total); + } + return ans; +} diff --git a/tests/501-1000/986. interval-list-intersections/manifest.yaml b/tests/501-1000/986. interval-list-intersections/manifest.yaml new file mode 100644 index 00000000..693cb1de --- /dev/null +++ b/tests/501-1000/986. interval-list-intersections/manifest.yaml @@ -0,0 +1,819 @@ +entry: + id: 986 + title: interval-list-intersections + params: + firstList: + type: array + items: + type: array + items: + type: int + secondList: + type: array + items: + type: array + items: + type: int + call: + cpp: Solution().intervalIntersection({firstList}, {secondList}) + rust: Solution::interval_intersection({firstList}, {secondList}) + python3: Solution().intervalIntersection({firstList}, {secondList}) + python2: Solution().intervalIntersection({firstList}, {secondList}) + ruby: interval_intersection({firstList}, {secondList}) + java: new Solution().intervalIntersection({firstList}, {secondList}) + csharp: new Solution().IntervalIntersection({firstList}, {secondList}) + kotlin: Solution().intervalIntersection({firstList}, {secondList}) + go: intervalIntersection({firstList}, {secondList}) + dart: Solution().intervalIntersection({firstList}, {secondList}) + swift: Solution().intervalIntersection({firstList}, {secondList}) + typescript: intervalIntersection({firstList}, {secondList}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 986 +tests: + - name: case_1 + in: + firstList: + - - 1 + - 2 + - - 5 + - 6 + - - 8 + - 10 + - - 13 + - 14 + - - 16 + - 18 + secondList: + - - 7 + - 17 + out: + - - 8 + - 10 + - - 13 + - 14 + - - 16 + - 17 + - name: case_2 + in: + firstList: + - - 0 + - 1 + - - 3 + - 7 + - - 8 + - 9 + - - 10 + - 11 + - - 14 + - 16 + - - 17 + - 18 + secondList: + - - 0 + - 2 + - - 4 + - 5 + - - 6 + - 9 + - - 11 + - 13 + - - 14 + - 16 + - - 17 + - 18 + out: + - - 0 + - 1 + - - 4 + - 5 + - - 6 + - 7 + - - 8 + - 9 + - - 11 + - 11 + - - 14 + - 16 + - - 17 + - 18 + - name: case_3 + in: + firstList: [] + secondList: [] + out: [] + - name: case_4 + in: + firstList: + - - 0 + - 9 + - - 12 + - 18 + secondList: + - - 0 + - 2 + - - 6 + - 7 + - - 8 + - 15 + out: + - - 0 + - 2 + - - 6 + - 7 + - - 8 + - 9 + - - 12 + - 15 + - name: case_5 + in: + firstList: + - - 4 + - 9 + - - 12 + - 13 + secondList: + - - 1 + - 3 + - - 7 + - 9 + - - 10 + - 12 + - - 14 + - 16 + out: + - - 7 + - 9 + - - 12 + - 12 + - name: case_6 + in: + firstList: + - - 1 + - 2 + secondList: [] + out: [] + - name: case_7 + in: + firstList: + - - 13 + - 16 + secondList: + - - 3 + - 13 + out: + - - 13 + - 13 + - name: case_8 + in: + firstList: + - - 2 + - 3 + - - 4 + - 6 + - - 8 + - 11 + secondList: + - - 1 + - 6 + - - 7 + - 9 + - - 13 + - 15 + - - 17 + - 18 + out: + - - 2 + - 3 + - - 4 + - 6 + - - 8 + - 9 + - name: case_9 + in: + firstList: + - - 0 + - 5 + secondList: + - - 8 + - 14 + out: [] + - name: case_10 + in: + firstList: + - - 0 + - 4 + secondList: + - - 1 + - 3 + - - 4 + - 5 + - - 7 + - 9 + - - 11 + - 13 + - - 15 + - 17 + - - 18 + - 19 + out: + - - 1 + - 3 + - - 4 + - 4 + - name: case_11 + in: + firstList: + - - 0 + - 1 + - - 2 + - 8 + - - 9 + - 13 + - - 17 + - 19 + secondList: + - - 0 + - 3 + - - 4 + - 6 + - - 9 + - 10 + - - 11 + - 12 + - - 15 + - 18 + out: + - - 0 + - 1 + - - 2 + - 3 + - - 4 + - 6 + - - 9 + - 10 + - - 11 + - 12 + - - 17 + - 18 + - name: case_12 + in: + firstList: + - - 4 + - 5 + - - 8 + - 13 + - - 14 + - 17 + secondList: + - - 0 + - 2 + - - 6 + - 7 + - - 8 + - 11 + - - 13 + - 14 + - - 17 + - 18 + out: + - - 8 + - 11 + - - 13 + - 13 + - - 14 + - 14 + - - 17 + - 17 + - name: case_13 + in: + firstList: + - - 0 + - 3 + - - 6 + - 9 + - - 12 + - 13 + secondList: + - - 0 + - 1 + - - 6 + - 7 + - - 10 + - 11 + - - 12 + - 14 + - - 15 + - 16 + - - 17 + - 18 + out: + - - 0 + - 1 + - - 6 + - 7 + - - 12 + - 13 + - name: case_14 + in: + firstList: + - - 1 + - 2 + - - 5 + - 10 + - - 12 + - 13 + - - 14 + - 17 + - - 18 + - 19 + secondList: + - - 0 + - 2 + - - 5 + - 11 + - - 16 + - 17 + out: + - - 1 + - 2 + - - 5 + - 10 + - - 16 + - 17 + - name: case_15 + in: + firstList: + - - 0 + - 2 + - - 3 + - 6 + - - 8 + - 12 + - - 15 + - 16 + secondList: + - - 2 + - 4 + - - 5 + - 6 + - - 7 + - 10 + - - 12 + - 14 + - - 18 + - 19 + out: + - - 2 + - 2 + - - 3 + - 4 + - - 5 + - 6 + - - 8 + - 10 + - - 12 + - 12 + - name: case_16 + in: + firstList: + - - 5 + - 7 + - - 12 + - 14 + - - 17 + - 19 + secondList: + - - 2 + - 5 + - - 6 + - 12 + - - 15 + - 16 + out: + - - 5 + - 5 + - - 6 + - 7 + - - 12 + - 12 + - name: case_17 + in: + firstList: + - - 2 + - 9 + secondList: + - - 0 + - 2 + - - 3 + - 4 + - - 5 + - 7 + - - 8 + - 9 + - - 11 + - 14 + - - 16 + - 17 + out: + - - 2 + - 2 + - - 3 + - 4 + - - 5 + - 7 + - - 8 + - 9 + - name: case_18 + in: + firstList: [] + secondList: [] + out: [] + - name: case_19 + in: + firstList: + - - 0 + - 2 + - - 5 + - 6 + - - 8 + - 11 + - - 12 + - 13 + - - 17 + - 19 + secondList: + - - 1 + - 4 + - - 6 + - 7 + - - 8 + - 9 + - - 10 + - 12 + - - 13 + - 14 + - - 16 + - 19 + out: + - - 1 + - 2 + - - 6 + - 6 + - - 8 + - 9 + - - 10 + - 11 + - - 12 + - 12 + - - 13 + - 13 + - - 17 + - 19 + - name: case_20 + in: + firstList: [] + secondList: + - - 1 + - 4 + - - 5 + - 6 + - - 7 + - 8 + - - 9 + - 10 + - - 11 + - 12 + - - 16 + - 18 + out: [] + - name: case_21 + in: + firstList: + - - 4 + - 7 + - - 18 + - 19 + secondList: + - - 1 + - 9 + - - 10 + - 13 + - - 15 + - 17 + out: + - - 4 + - 7 + - name: case_22 + in: + firstList: + - - 1 + - 4 + - - 12 + - 15 + - - 18 + - 19 + secondList: + - - 0 + - 1 + - - 3 + - 4 + - - 5 + - 6 + - - 7 + - 11 + - - 12 + - 13 + out: + - - 1 + - 1 + - - 3 + - 4 + - - 12 + - 13 + - name: case_23 + in: + firstList: [] + secondList: + - - 0 + - 2 + - - 3 + - 4 + - - 10 + - 11 + - - 14 + - 17 + - - 18 + - 19 + out: [] + - name: case_24 + in: + firstList: + - - 0 + - 1 + - - 2 + - 3 + - - 4 + - 5 + - - 8 + - 9 + - - 12 + - 15 + - - 16 + - 19 + secondList: + - - 0 + - 4 + - - 5 + - 8 + - - 9 + - 11 + - - 12 + - 14 + - - 15 + - 17 + - - 18 + - 19 + out: + - - 0 + - 1 + - - 2 + - 3 + - - 4 + - 4 + - - 5 + - 5 + - - 8 + - 8 + - - 9 + - 9 + - - 12 + - 14 + - - 15 + - 15 + - - 16 + - 17 + - - 18 + - 19 + - name: case_25 + in: + firstList: + - - 1 + - 2 + - - 4 + - 6 + - - 7 + - 14 + - - 16 + - 18 + secondList: + - - 1 + - 6 + - - 8 + - 10 + - - 11 + - 13 + - - 15 + - 16 + - - 18 + - 19 + out: + - - 1 + - 2 + - - 4 + - 6 + - - 8 + - 10 + - - 11 + - 13 + - - 16 + - 16 + - - 18 + - 18 + - name: case_26 + in: + firstList: [] + secondList: [] + out: [] + - name: case_27 + in: + firstList: + - - 1 + - 2 + - - 5 + - 6 + - - 9 + - 11 + - - 12 + - 14 + - - 15 + - 17 + - - 18 + - 19 + secondList: [] + out: [] + - name: case_28 + in: + firstList: + - - 0 + - 1 + - - 3 + - 7 + - - 8 + - 9 + - - 10 + - 12 + - - 13 + - 14 + - - 15 + - 18 + secondList: + - - 3 + - 5 + - - 7 + - 9 + - - 11 + - 12 + - - 13 + - 15 + - - 18 + - 19 + out: + - - 3 + - 5 + - - 7 + - 7 + - - 8 + - 9 + - - 11 + - 12 + - - 13 + - 14 + - - 15 + - 15 + - - 18 + - 18 + - name: case_29 + in: + firstList: + - - 1 + - 13 + secondList: + - - 1 + - 4 + - - 5 + - 9 + - - 10 + - 11 + - - 16 + - 17 + out: + - - 1 + - 4 + - - 5 + - 9 + - - 10 + - 11 + - name: case_30 + in: + firstList: + - - 8 + - 17 + secondList: + - - 3 + - 7 + - - 9 + - 13 + - - 14 + - 16 + out: + - - 9 + - 13 + - - 14 + - 16 + - name: case_31 + in: + firstList: + - - 2 + - 3 + - - 5 + - 9 + - - 10 + - 13 + - - 15 + - 17 + secondList: [] + out: [] + - name: case_32 + in: + firstList: [] + secondList: + - - 1 + - 4 + - - 7 + - 16 + out: [] + - name: case_33 + in: + firstList: + - - 3 + - 7 + - - 10 + - 11 + - - 12 + - 14 + - - 16 + - 19 + secondList: + - - 5 + - 6 + - - 7 + - 9 + - - 10 + - 14 + out: + - - 5 + - 6 + - - 7 + - 7 + - - 10 + - 11 + - - 12 + - 14 + - name: case_34 + in: + firstList: [] + secondList: + - - 0 + - 3 + - - 8 + - 9 + - - 10 + - 12 + - - 16 + - 17 + - - 18 + - 19 + out: [] + - name: case_35 + in: + firstList: + - - 0 + - 2 + - - 7 + - 12 + secondList: + - - 4 + - 12 + - - 14 + - 19 + out: + - - 7 + - 12 diff --git a/tests/501-1000/986. interval-list-intersections/sol.cpp b/tests/501-1000/986. interval-list-intersections/sol.cpp new file mode 100644 index 00000000..7dd9c9e4 --- /dev/null +++ b/tests/501-1000/986. interval-list-intersections/sol.cpp @@ -0,0 +1,29 @@ +class Solution { +public: + vector> intervalIntersection(vector>& firstList, vector>& secondList) { + if (firstList.empty() || secondList.empty()) { + return {}; + } + + int n = firstList.size(), m = secondList.size(); + vector> res; + int i = 0, j = 0; + + while (i < n && j < m) { + int s1 = firstList[i][0], e1 = firstList[i][1]; + int s2 = secondList[j][0], e2 = secondList[j][1]; + + if (e1 >= s2 && s1 <= e2) { + res.push_back({max(s1, s2), min(e1, e2)}); + } + + if (e1 > e2) { + j++; + } else { + i++; + } + } + + return res; + } +}; diff --git a/tests/501-1000/986. interval-list-intersections/sol.cs b/tests/501-1000/986. interval-list-intersections/sol.cs new file mode 100644 index 00000000..989fa04b --- /dev/null +++ b/tests/501-1000/986. interval-list-intersections/sol.cs @@ -0,0 +1,28 @@ +public class Solution { + public int[][] IntervalIntersection(int[][] firstList, int[][] secondList) { + if (firstList.Length == 0 || secondList.Length == 0) { + return new int[0][]; + } + + int n = firstList.Length, m = secondList.Length; + List res = new List(); + int i = 0, j = 0; + + while (i < n && j < m) { + int s1 = firstList[i][0], e1 = firstList[i][1]; + int s2 = secondList[j][0], e2 = secondList[j][1]; + + if (e1 >= s2 && s1 <= e2) { + res.Add(new int[]{Math.Max(s1, s2), Math.Min(e1, e2)}); + } + + if (e1 > e2) { + j++; + } else { + i++; + } + } + + return res.ToArray(); + } +} diff --git a/tests/501-1000/986. interval-list-intersections/sol.dart b/tests/501-1000/986. interval-list-intersections/sol.dart new file mode 100644 index 00000000..e6a70995 --- /dev/null +++ b/tests/501-1000/986. interval-list-intersections/sol.dart @@ -0,0 +1,30 @@ +class Solution { + List> intervalIntersection(List> firstList, List> secondList) { + if (firstList.isEmpty || secondList.isEmpty) { + return []; + } + + int n = firstList.length, m = secondList.length; + List> res = []; + int i = 0, j = 0; + + while (i < n && j < m) { + int s1 = firstList[i][0], e1 = firstList[i][1]; + int s2 = secondList[j][0], e2 = secondList[j][1]; + + if (e1 >= s2 && s1 <= e2) { + int start = s1 > s2 ? s1 : s2; + int end = e1 < e2 ? e1 : e2; + res.add([start, end]); + } + + if (e1 > e2) { + j++; + } else { + i++; + } + } + + return res; + } +} diff --git a/tests/501-1000/986. interval-list-intersections/sol.go b/tests/501-1000/986. interval-list-intersections/sol.go new file mode 100644 index 00000000..4e63f079 --- /dev/null +++ b/tests/501-1000/986. interval-list-intersections/sol.go @@ -0,0 +1,34 @@ +func intervalIntersection(firstList [][]int, secondList [][]int) [][]int { + if len(firstList) == 0 || len(secondList) == 0 { + return [][]int{} + } + + n, m := len(firstList), len(secondList) + res := [][]int{} + i, j := 0, 0 + + for i < n && j < m { + s1, e1 := firstList[i][0], firstList[i][1] + s2, e2 := secondList[j][0], secondList[j][1] + + if e1 >= s2 && s1 <= e2 { + start := s1 + if s2 > start { + start = s2 + } + end := e1 + if e2 < end { + end = e2 + } + res = append(res, []int{start, end}) + } + + if e1 > e2 { + j++ + } else { + i++ + } + } + + return res +} diff --git a/tests/501-1000/986. interval-list-intersections/sol.java b/tests/501-1000/986. interval-list-intersections/sol.java new file mode 100644 index 00000000..2700e039 --- /dev/null +++ b/tests/501-1000/986. interval-list-intersections/sol.java @@ -0,0 +1,28 @@ +class Solution { + public int[][] intervalIntersection(int[][] firstList, int[][] secondList) { + if (firstList.length == 0 || secondList.length == 0) { + return new int[0][0]; + } + + int n = firstList.length, m = secondList.length; + List res = new ArrayList<>(); + int i = 0, j = 0; + + while (i < n && j < m) { + int s1 = firstList[i][0], e1 = firstList[i][1]; + int s2 = secondList[j][0], e2 = secondList[j][1]; + + if (e1 >= s2 && s1 <= e2) { + res.add(new int[]{Math.max(s1, s2), Math.min(e1, e2)}); + } + + if (e1 > e2) { + j++; + } else { + i++; + } + } + + return res.toArray(new int[res.size()][]); + } +} diff --git a/tests/501-1000/986. interval-list-intersections/sol.kt b/tests/501-1000/986. interval-list-intersections/sol.kt new file mode 100644 index 00000000..64a294aa --- /dev/null +++ b/tests/501-1000/986. interval-list-intersections/sol.kt @@ -0,0 +1,32 @@ +class Solution { + fun intervalIntersection(firstList: Array, secondList: Array): Array { + if (firstList.isEmpty() || secondList.isEmpty()) { + return emptyArray() + } + + val n = firstList.size + val m = secondList.size + val res = mutableListOf() + var i = 0 + var j = 0 + + while (i < n && j < m) { + val s1 = firstList[i][0] + val e1 = firstList[i][1] + val s2 = secondList[j][0] + val e2 = secondList[j][1] + + if (e1 >= s2 && s1 <= e2) { + res.add(intArrayOf(maxOf(s1, s2), minOf(e1, e2))) + } + + if (e1 > e2) { + j++ + } else { + i++ + } + } + + return res.toTypedArray() + } +} diff --git a/tests/501-1000/986. interval-list-intersections/sol.py b/tests/501-1000/986. interval-list-intersections/sol.py new file mode 100644 index 00000000..1c4b44c5 --- /dev/null +++ b/tests/501-1000/986. interval-list-intersections/sol.py @@ -0,0 +1,32 @@ +from typing import List + + +class Solution: + def intervalIntersection( + self, firstList: List[List[int]], secondList: List[List[int]] + ) -> List[List[int]]: + + if not firstList or not secondList: + return [] + + n, m = len(firstList), len(secondList) + res = [] + i = j = 0 + + while i < n and j < m: + s1, e1 = firstList[ + i + ] # Unpack to flat variables — reduces index lookup overhead + s2, e2 = secondList[j] + + if e1 >= s2 and s1 <= e2: # Explicit overlap check + res.append( + [max(s1, s2), min(e1, e2)] + ) # Intersection = [latest start, earliest end] + + if e1 > e2: # Advance the interval that ends first + j += 1 + else: + i += 1 + + return res diff --git a/tests/501-1000/986. interval-list-intersections/sol.py2 b/tests/501-1000/986. interval-list-intersections/sol.py2 new file mode 100644 index 00000000..1d26579d --- /dev/null +++ b/tests/501-1000/986. interval-list-intersections/sol.py2 @@ -0,0 +1,27 @@ +class Solution(object): + def intervalIntersection(self, firstList, secondList): + """ + :type firstList: List[List[int]] + :type secondList: List[List[int]] + :rtype: List[List[int]] + """ + if not firstList or not secondList: + return [] + + n, m = len(firstList), len(secondList) + res = [] + i = j = 0 + + while i < n and j < m: + s1, e1 = firstList[i] + s2, e2 = secondList[j] + + if e1 >= s2 and s1 <= e2: + res.append([max(s1, s2), min(e1, e2)]) + + if e1 > e2: + j += 1 + else: + i += 1 + + return res diff --git a/tests/501-1000/986. interval-list-intersections/sol.rb b/tests/501-1000/986. interval-list-intersections/sol.rb new file mode 100644 index 00000000..a4587008 --- /dev/null +++ b/tests/501-1000/986. interval-list-intersections/sol.rb @@ -0,0 +1,27 @@ +# @param {Integer[][]} first_list +# @param {Integer[][]} second_list +# @return {Integer[][]} +def interval_intersection(first_list, second_list) + return [] if first_list.empty? || second_list.empty? + + n, m = first_list.length, second_list.length + res = [] + i = j = 0 + + while i < n && j < m + s1, e1 = first_list[i] + s2, e2 = second_list[j] + + if e1 >= s2 && s1 <= e2 + res << [[s1, s2].max, [e1, e2].min] + end + + if e1 > e2 + j += 1 + else + i += 1 + end + end + + res +end diff --git a/tests/501-1000/986. interval-list-intersections/sol.rs b/tests/501-1000/986. interval-list-intersections/sol.rs new file mode 100644 index 00000000..1a09663e --- /dev/null +++ b/tests/501-1000/986. interval-list-intersections/sol.rs @@ -0,0 +1,34 @@ +impl Solution { + pub fn interval_intersection(first_list: Vec>, second_list: Vec>) -> Vec> { + if first_list.is_empty() || second_list.is_empty() { + return vec![]; + } + + let n = first_list.len(); + let m = second_list.len(); + let mut res = Vec::new(); + let mut i = 0; + let mut j = 0; + + while i < n && j < m { + let s1 = first_list[i][0]; + let e1 = first_list[i][1]; + let s2 = second_list[j][0]; + let e2 = second_list[j][1]; + + if e1 >= s2 && s1 <= e2 { + let start = s1.max(s2); + let end = e1.min(e2); + res.push(vec![start, end]); + } + + if e1 > e2 { + j += 1; + } else { + i += 1; + } + } + + res + } +} diff --git a/tests/501-1000/986. interval-list-intersections/sol.swift b/tests/501-1000/986. interval-list-intersections/sol.swift new file mode 100644 index 00000000..95f825a8 --- /dev/null +++ b/tests/501-1000/986. interval-list-intersections/sol.swift @@ -0,0 +1,28 @@ +class Solution { + func intervalIntersection(_ firstList: [[Int]], _ secondList: [[Int]]) -> [[Int]] { + if firstList.isEmpty || secondList.isEmpty { + return [] + } + + let n = firstList.count, m = secondList.count + var res: [[Int]] = [] + var i = 0, j = 0 + + while i < n && j < m { + let s1 = firstList[i][0], e1 = firstList[i][1] + let s2 = secondList[j][0], e2 = secondList[j][1] + + if e1 >= s2 && s1 <= e2 { + res.append([max(s1, s2), min(e1, e2)]) + } + + if e1 > e2 { + j += 1 + } else { + i += 1 + } + } + + return res + } +} diff --git a/tests/501-1000/986. interval-list-intersections/sol.ts b/tests/501-1000/986. interval-list-intersections/sol.ts new file mode 100644 index 00000000..d166e0ad --- /dev/null +++ b/tests/501-1000/986. interval-list-intersections/sol.ts @@ -0,0 +1,33 @@ +function intervalIntersection( + firstList: number[][], + secondList: number[][], +): number[][] { + if (firstList.length === 0 || secondList.length === 0) { + return []; + } + + const n = firstList.length, + m = secondList.length; + const res: number[][] = []; + let i = 0, + j = 0; + + while (i < n && j < m) { + const s1 = firstList[i][0], + e1 = firstList[i][1]; + const s2 = secondList[j][0], + e2 = secondList[j][1]; + + if (e1 >= s2 && s1 <= e2) { + res.push([Math.max(s1, s2), Math.min(e1, e2)]); + } + + if (e1 > e2) { + j++; + } else { + i++; + } + } + + return res; +} diff --git a/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/manifest.yaml b/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/manifest.yaml new file mode 100644 index 00000000..883cd864 --- /dev/null +++ b/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/manifest.yaml @@ -0,0 +1,505 @@ +entry: + id: 987 + title: vertical-order-traversal-of-a-binary-tree + params: + root: + type: tree_node + call: + cpp: Solution().verticalTraversal({root}) + rust: Solution::vertical_traversal({root}) + python3: Solution().verticalTraversal({root}) + python2: Solution().verticalTraversal({root}) + ruby: vertical_traversal({root}) + java: new Solution().verticalTraversal({root}) + csharp: new Solution().VerticalTraversal({root}) + kotlin: Solution().verticalTraversal({root}) + go: verticalTraversal({root}) + dart: Solution().verticalTraversal({root}) + swift: Solution().verticalTraversal({root}) + typescript: verticalTraversal({root}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 987 +tests: + - name: case_1 + in: + root: + - 19 + out: + - - 19 + - name: case_2 + in: + root: + - 4 + - null + - 19 + out: + - - 4 + - - 19 + - name: case_3 + in: + root: + - 16 + - 14 + - 3 + - 6 + - 18 + - 13 + - 3 + - 18 + out: + - - 18 + - - 6 + - - 14 + - - 16 + - 13 + - 18 + - - 3 + - - 3 + - name: case_4 + in: + root: + - 0 + - 4 + - 16 + - 5 + - 20 + out: + - - 5 + - - 4 + - - 0 + - 20 + - - 16 + - name: case_5 + in: + root: + - 7 + - 13 + - null + - 8 + - null + - 9 + out: + - - 9 + - - 8 + - - 13 + - - 7 + - name: case_6 + in: + root: + - 14 + - 11 + out: + - - 11 + - - 14 + - name: case_7 + in: + root: + - 14 + out: + - - 14 + - name: case_8 + in: + root: + - 12 + - 5 + - 8 + - 7 + - 11 + out: + - - 7 + - - 5 + - - 12 + - 11 + - - 8 + - name: case_9 + in: + root: + - 19 + out: + - - 19 + - name: case_10 + in: + root: + - 5 + - 16 + - 13 + - 15 + - 20 + - 12 + - null + - null + - 17 + - 10 + - null + - 4 + out: + - - 15 + - - 16 + - 4 + - 10 + - 17 + - - 5 + - 12 + - 20 + - - 13 + - name: case_11 + in: + root: + - 0 + - null + - 3 + - 0 + - null + - 0 + - 4 + - 4 + - 3 + - 1 + - 12 + out: + - - 4 + - - 0 + - - 0 + - 0 + - 1 + - 3 + - - 3 + - 4 + - - 12 + - name: case_12 + in: + root: + - 14 + - 5 + - 14 + - 7 + - null + - null + - 4 + - 7 + out: + - - 7 + - - 7 + - - 5 + - - 14 + - - 14 + - - 4 + - name: case_13 + in: + root: + - 4 + - 17 + out: + - - 17 + - - 4 + - name: case_14 + in: + root: + - 11 + - 2 + - 13 + - null + - 4 + out: + - - 2 + - - 11 + - 4 + - - 13 + - name: case_15 + in: + root: + - 13 + - 15 + - 18 + - 16 + - 1 + - 7 + - 3 + out: + - - 16 + - - 15 + - - 13 + - 1 + - 7 + - - 18 + - - 3 + - name: case_16 + in: + root: + - 20 + - 6 + - 0 + - 11 + - 17 + out: + - - 11 + - - 6 + - - 20 + - 17 + - - 0 + - name: case_17 + in: + root: + - 18 + out: + - - 18 + - name: case_18 + in: + root: + - 13 + out: + - - 13 + - name: case_19 + in: + root: + - 16 + out: + - - 16 + - name: case_20 + in: + root: + - 20 + - 12 + - 15 + - 2 + - null + - 8 + - null + - 13 + out: + - - 13 + - - 2 + - - 12 + - - 20 + - 8 + - - 15 + - name: case_21 + in: + root: + - 11 + out: + - - 11 + - name: case_22 + in: + root: + - 15 + - 2 + - null + - 1 + - 10 + - 16 + - 3 + - 19 + - 7 + - 16 + out: + - - 16 + - - 16 + - - 1 + - - 2 + - 3 + - 19 + - - 15 + - 10 + - - 7 + - name: case_23 + in: + root: + - 1 + - null + - 4 + - null + - 16 + - null + - 9 + - 6 + - 8 + out: + - - 1 + - - 4 + - - 16 + - 6 + - - 9 + - - 8 + - name: case_24 + in: + root: + - 3 + - null + - 11 + - 6 + - 4 + - 3 + - 6 + - 1 + - 14 + out: + - - 3 + - - 3 + - 6 + - - 11 + - 1 + - 6 + - - 4 + - - 14 + - name: case_25 + in: + root: + - 1 + - 2 + - 11 + - null + - null + - 14 + - 18 + - 5 + - 18 + - 18 + - null + - 1 + - 14 + out: + - - 1 + - - 2 + - 5 + - - 1 + - 14 + - 14 + - - 11 + - 18 + - 18 + - - 18 + - name: case_26 + in: + root: + - 14 + - 15 + out: + - - 15 + - - 14 + - name: case_27 + in: + root: + - 20 + out: + - - 20 + - name: case_28 + in: + root: + - 3 + out: + - - 3 + - name: case_29 + in: + root: + - 11 + - 5 + - 20 + out: + - - 5 + - - 11 + - - 20 + - name: case_30 + in: + root: + - 13 + - 10 + - 10 + out: + - - 10 + - - 13 + - - 10 + - name: case_31 + in: + root: + - 19 + - 6 + - 1 + - 15 + - 20 + - 9 + - 12 + - 13 + - 12 + out: + - - 13 + - - 15 + - - 6 + - 12 + - - 19 + - 9 + - 20 + - - 1 + - - 12 + - name: case_32 + in: + root: + - 1 + - 6 + - null + - 14 + - 18 + - 15 + - null + - 20 + - 13 + - 1 + out: + - - 1 + - - 15 + - - 14 + - - 6 + - 20 + - - 1 + - 18 + - - 13 + - name: case_33 + in: + root: + - 0 + out: + - - 0 + - name: case_34 + in: + root: + - 8 + - null + - 15 + - 8 + - 9 + - 4 + - null + - 6 + - 9 + - 18 + - 19 + - null + - null + - 9 + out: + - - 18 + - - 4 + - - 8 + - 8 + - 19 + - - 15 + - 6 + - - 9 + - 9 + - - 9 + - name: case_35 + in: + root: + - 14 + - 6 + out: + - - 6 + - - 14 diff --git a/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.cpp b/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.cpp new file mode 100644 index 00000000..490b034a --- /dev/null +++ b/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.cpp @@ -0,0 +1,41 @@ +/** + * Definition for a binary tree node. + * struct TreeNode { + * int val; + * TreeNode *left; + * TreeNode *right; + * TreeNode() : val(0), left(nullptr), right(nullptr) {} + * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} + * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} + * }; + */ +class Solution { +public: + vector> verticalTraversal(TreeNode* root) { + vector> nodes; + + function dfs = [&](TreeNode* node, int row, int col) { + if (!node) return; + nodes.emplace_back(col, row, node->val); + dfs(node->left, row + 1, col - 1); + dfs(node->right, row + 1, col + 1); + }; + + dfs(root, 0, 0); + + sort(nodes.begin(), nodes.end()); + + vector> res; + int prev_col = INT_MIN; + + for (const auto& [col, row, val] : nodes) { + if (col != prev_col) { + res.push_back({}); + prev_col = col; + } + res.back().push_back(val); + } + + return res; + } +}; diff --git a/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.cs b/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.cs new file mode 100644 index 00000000..d71113ea --- /dev/null +++ b/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.cs @@ -0,0 +1,46 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public int val; + * public TreeNode left; + * public TreeNode right; + * public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +public class Solution { + public IList> VerticalTraversal(TreeNode root) { + List<(int col, int row, int val)> nodes = new List<(int, int, int)>(); + + void Dfs(TreeNode node, int row, int col) { + if (node == null) return; + nodes.Add((col, row, node.val)); + Dfs(node.left, row + 1, col - 1); + Dfs(node.right, row + 1, col + 1); + } + + Dfs(root, 0, 0); + + nodes.Sort((a, b) => { + if (a.col != b.col) return a.col.CompareTo(b.col); + if (a.row != b.row) return a.row.CompareTo(b.row); + return a.val.CompareTo(b.val); + }); + + IList> res = new List>(); + int? prevCol = null; + + foreach (var (col, _, val) in nodes) { + if (col != prevCol) { + res.Add(new List()); + prevCol = col; + } + res[res.Count - 1].Add(val); + } + + return res; + } +} diff --git a/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.dart b/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.dart new file mode 100644 index 00000000..86c39aec --- /dev/null +++ b/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.dart @@ -0,0 +1,43 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * int val; + * TreeNode? left; + * TreeNode? right; + * TreeNode([this.val = 0, this.left, this.right]); + * } + */ +class Solution { + List> verticalTraversal(TreeNode? root) { + List> nodes = []; + + void dfs(TreeNode? node, int row, int col) { + if (node == null) return; + nodes.add([col, row, node.val]); + dfs(node.left, row + 1, col - 1); + dfs(node.right, row + 1, col + 1); + } + + dfs(root, 0, 0); + + nodes.sort((a, b) { + if (a[0] != b[0]) return a[0].compareTo(b[0]); + if (a[1] != b[1]) return a[1].compareTo(b[1]); + return a[2].compareTo(b[2]); + }); + + List> res = []; + int prevCol = -9999999; + + for (var node in nodes) { + int col = node[0], val = node[2]; + if (col != prevCol) { + res.add([]); + prevCol = col; + } + res.last.add(val); + } + + return res; + } +} diff --git a/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.go b/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.go new file mode 100644 index 00000000..ccb7da52 --- /dev/null +++ b/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.go @@ -0,0 +1,49 @@ +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +func verticalTraversal(root *TreeNode) [][]int { + type Node struct { + col, row, val int + } + nodes := []Node{} + + var dfs func(*TreeNode, int, int) + dfs = func(node *TreeNode, row, col int) { + if node == nil { + return + } + nodes = append(nodes, Node{col, row, node.Val}) + dfs(node.Left, row+1, col-1) + dfs(node.Right, row+1, col+1) + } + + dfs(root, 0, 0) + + sort.Slice(nodes, func(i, j int) bool { + if nodes[i].col != nodes[j].col { + return nodes[i].col < nodes[j].col + } + if nodes[i].row != nodes[j].row { + return nodes[i].row < nodes[j].row + } + return nodes[i].val < nodes[j].val + }) + + res := [][]int{} + prevCol := -10000 + + for _, node := range nodes { + if node.col != prevCol { + res = append(res, []int{}) + prevCol = node.col + } + res[len(res)-1] = append(res[len(res)-1], node.val) + } + + return res +} diff --git a/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.java b/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.java new file mode 100644 index 00000000..4a07003e --- /dev/null +++ b/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.java @@ -0,0 +1,48 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode() {} + * TreeNode(int val) { this.val = val; } + * TreeNode(int val, TreeNode left, TreeNode right) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +class Solution { + public List> verticalTraversal(TreeNode root) { + List nodes = new ArrayList<>(); + dfs(root, 0, 0, nodes); + + Collections.sort(nodes, (a, b) -> { + if (a[0] != b[0]) return Integer.compare(a[0], b[0]); + if (a[1] != b[1]) return Integer.compare(a[1], b[1]); + return Integer.compare(a[2], b[2]); + }); + + List> res = new ArrayList<>(); + int prevCol = Integer.MIN_VALUE; + + for (int[] node : nodes) { + int col = node[0], row = node[1], val = node[2]; + if (col != prevCol) { + res.add(new ArrayList<>()); + prevCol = col; + } + res.get(res.size() - 1).add(val); + } + + return res; + } + + private void dfs(TreeNode node, int row, int col, List nodes) { + if (node == null) return; + nodes.add(new int[]{col, row, node.val}); + dfs(node.left, row + 1, col - 1, nodes); + dfs(node.right, row + 1, col + 1, nodes); + } +} diff --git a/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.kt b/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.kt new file mode 100644 index 00000000..1820f6d6 --- /dev/null +++ b/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.kt @@ -0,0 +1,38 @@ +/** + * Example: + * var ti = TreeNode(5) + * var v = ti.`val` + * Definition for a binary tree node. + * class TreeNode(var `val`: Int) { + * var left: TreeNode? = null + * var right: TreeNode? = null + * } + */ +class Solution { + fun verticalTraversal(root: TreeNode?): List> { + val nodes = mutableListOf>() + + fun dfs(node: TreeNode?, row: Int, col: Int) { + if (node == null) return + nodes.add(Triple(col, row, node.`val`)) + dfs(node.left, row + 1, col - 1) + dfs(node.right, row + 1, col + 1) + } + + dfs(root, 0, 0) + nodes.sortWith(compareBy({ it.first }, { it.second }, { it.third })) + + val res = mutableListOf>() + var prevCol: Int? = null + + for ((col, _, `val`) in nodes) { + if (col != prevCol) { + res.add(mutableListOf()) + prevCol = col + } + res.last().add(`val`) + } + + return res + } +} diff --git a/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.py b/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.py new file mode 100644 index 00000000..553ddc11 --- /dev/null +++ b/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.py @@ -0,0 +1,28 @@ +from collections import defaultdict +from typing import List, Optional + + +class Solution: + def verticalTraversal(self, root: Optional[TreeNode]) -> List[List[int]]: + nodes = [] + + def dfs(node, row, col): + if not node: + return + nodes.append((col, row, node.val)) + dfs(node.left, row + 1, col - 1) + dfs(node.right, row + 1, col + 1) + + dfs(root, 0, 0) + nodes.sort() + + res = [] + prev_col = float("-inf") + + for col, row, val in nodes: + if col != prev_col: + res.append([]) + prev_col = col + res[-1].append(val) + + return res diff --git a/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.py2 b/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.py2 new file mode 100644 index 00000000..661021c5 --- /dev/null +++ b/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.py2 @@ -0,0 +1,34 @@ +# Definition for a binary tree node. +# class TreeNode(object): +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution(object): + def verticalTraversal(self, root): + """ + :type root: Optional[TreeNode] + :rtype: List[List[int]] + """ + nodes = [] + + def dfs(node, row, col): + if not node: + return + nodes.append((col, row, node.val)) + dfs(node.left, row + 1, col - 1) + dfs(node.right, row + 1, col + 1) + + dfs(root, 0, 0) + nodes.sort() + + res = [] + prev_col = float('-inf') + + for col, row, val in nodes: + if col != prev_col: + res.append([]) + prev_col = col + res[-1].append(val) + + return res diff --git a/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.rb b/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.rb new file mode 100644 index 00000000..0442e68b --- /dev/null +++ b/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.rb @@ -0,0 +1,37 @@ +# Definition for a binary tree node. +# class TreeNode +# attr_accessor :val, :left, :right +# def initialize(val = 0, left = nil, right = nil) +# @val = val +# @left = left +# @right = right +# end +# end +# @param {TreeNode} root +# @return {Integer[][]} +def vertical_traversal(root) + nodes = [] + + dfs = lambda do |node, row, col| + return if node.nil? + nodes << [col, row, node.val] + dfs.call(node.left, row + 1, col - 1) + dfs.call(node.right, row + 1, col + 1) + end + + dfs.call(root, 0, 0) + nodes.sort! + + res = [] + prev_col = -Float::INFINITY + + nodes.each do |col, row, val| + if col != prev_col + res << [] + prev_col = col + end + res[-1] << val + end + + res +end diff --git a/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.rs b/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.rs new file mode 100644 index 00000000..9635f878 --- /dev/null +++ b/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.rs @@ -0,0 +1,49 @@ +// Definition for a binary tree node. +// #[derive(Debug, PartialEq, Eq)] +// pub struct TreeNode { +// pub val: i32, +// pub left: Option>>, +// pub right: Option>>, +// } +// +// impl TreeNode { +// #[inline] +// pub fn new(val: i32) -> Self { +// TreeNode { +// val, +// left: None, +// right: None +// } +// } +// } +impl Solution { + pub fn vertical_traversal(root: Option>>) -> Vec> { + let mut nodes: Vec<(i32, i32, i32)> = Vec::new(); + + fn dfs(node: Option<&Rc>>, row: i32, col: i32, nodes: &mut Vec<(i32, i32, i32)>) { + if let Some(n) = node { + let n = n.borrow(); + nodes.push((col, row, n.val)); + dfs(n.left.as_ref(), row + 1, col - 1, nodes); + dfs(n.right.as_ref(), row + 1, col + 1, nodes); + } + } + + dfs(root.as_ref(), 0, 0, &mut nodes); + + nodes.sort(); + + let mut res: Vec> = Vec::new(); + let mut prev_col = i32::MIN; + + for (col, _, val) in nodes { + if col != prev_col { + res.push(Vec::new()); + prev_col = col; + } + res.last_mut().unwrap().push(val); + } + + res + } +} diff --git a/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.swift b/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.swift new file mode 100644 index 00000000..f615c9be --- /dev/null +++ b/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.swift @@ -0,0 +1,48 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public var val: Int + * public var left: TreeNode? + * public var right: TreeNode? + * public init() { self.val = 0; self.left = nil; self.right = nil; } + * public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; } + * public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) { + * self.val = val + * self.left = left + * self.right = right + * } + * } + */ +class Solution { + func verticalTraversal(_ root: TreeNode?) -> [[Int]] { + var nodes: [(col: Int, row: Int, val: Int)] = [] + + func dfs(_ node: TreeNode?, _ row: Int, _ col: Int) { + guard let node = node else { return } + nodes.append((col, row, node.val)) + dfs(node.left, row + 1, col - 1) + dfs(node.right, row + 1, col + 1) + } + + dfs(root, 0, 0) + + nodes.sort { + if $0.col != $1.col { return $0.col < $1.col } + if $0.row != $1.row { return $0.row < $1.row } + return $0.val < $1.val + } + + var res: [[Int]] = [] + var prevCol: Int? + + for node in nodes { + if node.col != prevCol { + res.append([]) + prevCol = node.col + } + res[res.count - 1].append(node.val) + } + + return res + } +} diff --git a/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.ts b/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.ts new file mode 100644 index 00000000..7775f660 --- /dev/null +++ b/tests/501-1000/987. vertical-order-traversal-of-a-binary-tree/sol.ts @@ -0,0 +1,45 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ + +function verticalTraversal(root: TreeNode | null): number[][] { + const nodes: [number, number, number][] = []; + + const dfs = (node: TreeNode | null, row: number, col: number): void => { + if (!node) return; + nodes.push([col, row, node.val]); + dfs(node.left, row + 1, col - 1); + dfs(node.right, row + 1, col + 1); + }; + + dfs(root, 0, 0); + + nodes.sort((a, b) => { + if (a[0] !== b[0]) return a[0] - b[0]; + if (a[1] !== b[1]) return a[1] - b[1]; + return a[2] - b[2]; + }); + + const res: number[][] = []; + let prevCol: number | null = null; + + for (const [col, , val] of nodes) { + if (col !== prevCol) { + res.push([]); + prevCol = col; + } + res[res.length - 1].push(val); + } + + return res; +} diff --git a/tests/501-1000/988. smallest-string-starting-from-leaf/manifest.yaml b/tests/501-1000/988. smallest-string-starting-from-leaf/manifest.yaml new file mode 100644 index 00000000..da2ac311 --- /dev/null +++ b/tests/501-1000/988. smallest-string-starting-from-leaf/manifest.yaml @@ -0,0 +1,429 @@ +entry: + id: 988 + title: smallest-string-starting-from-leaf + params: + root: + type: tree_node + call: + cpp: Solution().smallestFromLeaf({root}) + rust: Solution::smallest_from_leaf({root}) + python3: Solution().smallestFromLeaf({root}) + python2: Solution().smallestFromLeaf({root}) + ruby: smallest_from_leaf({root}) + java: new Solution().smallestFromLeaf({root}) + csharp: new Solution().SmallestFromLeaf({root}) + kotlin: Solution().smallestFromLeaf({root}) + go: smallestFromLeaf({root}) + dart: Solution().smallestFromLeaf({root}) + swift: Solution().smallestFromLeaf({root}) + typescript: smallestFromLeaf({root}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 988 +tests: + - name: case_1 + in: + root: + - 6 + - null + - 17 + - null + - 16 + - 12 + - 3 + - 11 + - 7 + - 9 + out: hmqrg + - name: case_2 + in: + root: + - 7 + out: h + - name: case_3 + in: + root: + - 20 + - 11 + - null + - null + - 9 + - null + - 12 + - null + - 16 + - 18 + - null + - 2 + - 14 + - 3 + out: dcsqmjlu + - name: case_4 + in: + root: + - 20 + out: u + - name: case_5 + in: + root: + - 11 + - null + - 11 + - 14 + out: oll + - name: case_6 + in: + root: + - 5 + - null + - 15 + out: pf + - name: case_7 + in: + root: + - 4 + - 23 + - 25 + out: xe + - name: case_8 + in: + root: + - 3 + - null + - 22 + - null + - 1 + out: bwd + - name: case_9 + in: + root: + - 23 + - 24 + - 23 + - null + - 0 + - null + - 15 + out: ayx + - name: case_10 + in: + root: + - 21 + - 23 + - 22 + - 9 + - null + - 16 + - null + - 21 + - 24 + out: qwv + - name: case_11 + in: + root: + - 22 + - 4 + - 16 + - null + - 2 + - null + - 1 + - 16 + - null + - 15 + out: pbqw + - name: case_12 + in: + root: + - 16 + - 4 + - null + - 7 + - null + - 12 + - 9 + - 15 + - null + - 0 + - 22 + - null + - 11 + - 18 + out: lpmheq + - name: case_13 + in: + root: + - 12 + - 7 + - null + - 14 + - null + - 13 + - 24 + - null + - null + - 20 + - null + - 8 + - null + - 20 + - 25 + - 11 + out: luiuyohm + - name: case_14 + in: + root: + - 23 + - 9 + out: jx + - name: case_15 + in: + root: + - 14 + out: o + - name: case_16 + in: + root: + - 1 + - 19 + - 21 + - null + - 2 + - null + - 8 + - 3 + - 9 + - 14 + out: dctb + - name: case_17 + in: + root: + - 2 + - 6 + - 3 + - 3 + - null + - null + - null + - 24 + - 17 + out: dc + - name: case_18 + in: + root: + - 1 + - 16 + - 16 + - 13 + - 1 + - 4 + out: bqb + - name: case_19 + in: + root: + - 24 + - 25 + - 15 + - null + - 15 + - 1 + - 23 + - null + - 8 + - 1 + - 7 + out: bbpy + - name: case_20 + in: + root: + - 20 + - null + - 23 + - 11 + - null + - 8 + out: ilxu + - name: case_21 + in: + root: + - 13 + - 0 + - null + - 16 + - null + - 6 + - 25 + - null + - 10 + - 9 + - 0 + - 5 + - null + - 3 + out: azqan + - name: case_22 + in: + root: + - 19 + - 18 + - null + - 9 + - null + - 17 + - 13 + - 15 + - null + - 21 + out: prjst + - name: case_23 + in: + root: + - 18 + - 4 + - 8 + - 11 + - 21 + - null + - null + - 22 + - 0 + - 23 + - null + - 13 + out: ales + - name: case_24 + in: + root: + - 25 + - 22 + - 22 + - 20 + - 14 + - 23 + - 0 + - 9 + - 6 + out: awz + - name: case_25 + in: + root: + - 20 + - 23 + - null + - 11 + - 17 + - 9 + - null + - null + - 4 + - 16 + - 25 + - null + - 7 + out: herxu + - name: case_26 + in: + root: + - 20 + out: u + - name: case_27 + in: + root: + - 11 + - 2 + - 0 + out: al + - name: case_28 + in: + root: + - 15 + out: p + - name: case_29 + in: + root: + - 23 + - 14 + - null + - 18 + - 11 + out: lox + - name: case_30 + in: + root: + - 2 + - null + - 5 + - 21 + - null + - 12 + - null + - 13 + - 16 + out: nmvfc + - name: case_31 + in: + root: + - 22 + - 22 + - 7 + - null + - null + - 18 + - 8 + - 21 + - 4 + out: eshw + - name: case_32 + in: + root: + - 17 + - 23 + - null + - null + - 6 + - 12 + - 8 + - null + - 16 + - 20 + - null + - 12 + - 13 + out: mqmgxr + - name: case_33 + in: + root: + - 3 + - 6 + - 10 + - 10 + - 12 + - 7 + out: hkd + - name: case_34 + in: + root: + - 23 + - 7 + out: hx + - name: case_35 + in: + root: + - 15 + - 9 + - 4 + - 5 + - null + - 24 + - 14 + - 2 + - 18 + - 25 + out: cfjp diff --git a/tests/501-1000/988. smallest-string-starting-from-leaf/sol.cpp b/tests/501-1000/988. smallest-string-starting-from-leaf/sol.cpp new file mode 100644 index 00000000..1b38e889 --- /dev/null +++ b/tests/501-1000/988. smallest-string-starting-from-leaf/sol.cpp @@ -0,0 +1,44 @@ +/** + * Definition for a binary tree node. + * struct TreeNode { + * int val; + * TreeNode *left; + * TreeNode *right; + * TreeNode() : val(0), left(nullptr), right(nullptr) {} + * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} + * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} + * }; + */ +#include +#include + +class Solution { +public: + string smallestFromLeaf(TreeNode* root) { + string smallestString = ""; + queue> nodeQueue; + + nodeQueue.push({root, string(1, (char)(root->val + 'a'))}); + + while (!nodeQueue.empty()) { + auto [node, currentString] = nodeQueue.front(); + nodeQueue.pop(); + + if (!node->left && !node->right) { + if (smallestString.empty() || currentString < smallestString) { + smallestString = currentString; + } + } + + if (node->left) { + nodeQueue.push({node->left, string(1, (char)(node->left->val + 'a')) + currentString}); + } + + if (node->right) { + nodeQueue.push({node->right, string(1, (char)(node->right->val + 'a')) + currentString}); + } + } + + return smallestString; + } +}; diff --git a/tests/501-1000/988. smallest-string-starting-from-leaf/sol.cs b/tests/501-1000/988. smallest-string-starting-from-leaf/sol.cs new file mode 100644 index 00000000..2dc8a52a --- /dev/null +++ b/tests/501-1000/988. smallest-string-starting-from-leaf/sol.cs @@ -0,0 +1,43 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public int val; + * public TreeNode left; + * public TreeNode right; + * public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +using System.Collections.Generic; + +public class Solution { + public string SmallestFromLeaf(TreeNode root) { + string smallestString = ""; + Queue<(TreeNode, string)> nodeQueue = new Queue<(TreeNode, string)>(); + + nodeQueue.Enqueue((root, ((char)(root.val + 'a')).ToString())); + + while (nodeQueue.Count > 0) { + var (node, currentString) = nodeQueue.Dequeue(); + + if (node.left == null && node.right == null) { + if (smallestString == "" || string.Compare(currentString, smallestString) < 0) { + smallestString = currentString; + } + } + + if (node.left != null) { + nodeQueue.Enqueue((node.left, (char)(node.left.val + 'a') + currentString)); + } + + if (node.right != null) { + nodeQueue.Enqueue((node.right, (char)(node.right.val + 'a') + currentString)); + } + } + + return smallestString; + } +} diff --git a/tests/501-1000/988. smallest-string-starting-from-leaf/sol.dart b/tests/501-1000/988. smallest-string-starting-from-leaf/sol.dart new file mode 100644 index 00000000..1e14f009 --- /dev/null +++ b/tests/501-1000/988. smallest-string-starting-from-leaf/sol.dart @@ -0,0 +1,41 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * int val; + * TreeNode? left; + * TreeNode? right; + * TreeNode([this.val = 0, this.left, this.right]); + * } + */ +import 'dart:collection'; + +class Solution { + String smallestFromLeaf(TreeNode? root) { + String smallestString = ""; + Queue> nodeQueue = Queue(); + + nodeQueue.add([root!, String.fromCharCode(root.val + 97)]); + + while (nodeQueue.isNotEmpty) { + List curr = nodeQueue.removeFirst(); + TreeNode node = curr[0] as TreeNode; + String currentString = curr[1] as String; + + if (node.left == null && node.right == null) { + if (smallestString.isEmpty || currentString.compareTo(smallestString) < 0) { + smallestString = currentString; + } + } + + if (node.left != null) { + nodeQueue.add([node.left!, String.fromCharCode(node.left!.val + 97) + currentString]); + } + + if (node.right != null) { + nodeQueue.add([node.right!, String.fromCharCode(node.right!.val + 97) + currentString]); + } + } + + return smallestString; + } +} diff --git a/tests/501-1000/988. smallest-string-starting-from-leaf/sol.go b/tests/501-1000/988. smallest-string-starting-from-leaf/sol.go new file mode 100644 index 00000000..47f5ec45 --- /dev/null +++ b/tests/501-1000/988. smallest-string-starting-from-leaf/sol.go @@ -0,0 +1,37 @@ +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +func smallestFromLeaf(root *TreeNode) string { + smallestString := "" + nodeQueue := [][]interface{}{} + + nodeQueue = append(nodeQueue, []interface{}{root, string(rune(root.Val + 'a'))}) + + for len(nodeQueue) > 0 { + curr := nodeQueue[0] + nodeQueue = nodeQueue[1:] + node := curr[0].(*TreeNode) + currentString := curr[1].(string) + + if node.Left == nil && node.Right == nil { + if smallestString == "" || currentString < smallestString { + smallestString = currentString + } + } + + if node.Left != nil { + nodeQueue = append(nodeQueue, []interface{}{node.Left, string(rune(node.Left.Val + 'a')) + currentString}) + } + + if node.Right != nil { + nodeQueue = append(nodeQueue, []interface{}{node.Right, string(rune(node.Right.Val + 'a')) + currentString}) + } + } + + return smallestString +} diff --git a/tests/501-1000/988. smallest-string-starting-from-leaf/sol.java b/tests/501-1000/988. smallest-string-starting-from-leaf/sol.java new file mode 100644 index 00000000..4804e459 --- /dev/null +++ b/tests/501-1000/988. smallest-string-starting-from-leaf/sol.java @@ -0,0 +1,48 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode() {} + * TreeNode(int val) { this.val = val; } + * TreeNode(int val, TreeNode left, TreeNode right) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +import java.util.LinkedList; +import java.util.Queue; + +class Solution { + public String smallestFromLeaf(TreeNode root) { + String smallestString = ""; + Queue nodeQueue = new LinkedList<>(); + + nodeQueue.add(new Object[]{root, String.valueOf((char)(root.val + 'a'))}); + + while (!nodeQueue.isEmpty()) { + Object[] curr = nodeQueue.poll(); + TreeNode node = (TreeNode) curr[0]; + String currentString = (String) curr[1]; + + if (node.left == null && node.right == null) { + if (smallestString.isEmpty() || currentString.compareTo(smallestString) < 0) { + smallestString = currentString; + } + } + + if (node.left != null) { + nodeQueue.add(new Object[]{node.left, (char)(node.left.val + 'a') + currentString}); + } + + if (node.right != null) { + nodeQueue.add(new Object[]{node.right, (char)(node.right.val + 'a') + currentString}); + } + } + + return smallestString; + } +} diff --git a/tests/501-1000/988. smallest-string-starting-from-leaf/sol.kt b/tests/501-1000/988. smallest-string-starting-from-leaf/sol.kt new file mode 100644 index 00000000..c49621c1 --- /dev/null +++ b/tests/501-1000/988. smallest-string-starting-from-leaf/sol.kt @@ -0,0 +1,40 @@ +/** + * Example: + * var ti = TreeNode(5) + * var v = ti.`val` + * Definition for a binary tree node. + * class TreeNode(var `val`: Int) { + * var left: TreeNode? = null + * var right: TreeNode? = null + * } + */ +import java.util.LinkedList + +class Solution { + fun smallestFromLeaf(root: TreeNode?): String { + var smallestString = "" + val nodeQueue = LinkedList>() + + nodeQueue.add(Pair(root, ('a' + root!!.`val`).toString())) + + while (nodeQueue.isNotEmpty()) { + val (node, currentString) = nodeQueue.poll() + + if (node!!.left == null && node.right == null) { + if (smallestString.isEmpty() || currentString < smallestString) { + smallestString = currentString + } + } + + if (node.left != null) { + nodeQueue.add(Pair(node.left, ('a' + node.left!!.`val`) + currentString)) + } + + if (node.right != null) { + nodeQueue.add(Pair(node.right, ('a' + node.right!!.`val`) + currentString)) + } + } + + return smallestString + } +} diff --git a/tests/501-1000/988. smallest-string-starting-from-leaf/sol.py b/tests/501-1000/988. smallest-string-starting-from-leaf/sol.py new file mode 100644 index 00000000..c2b0c969 --- /dev/null +++ b/tests/501-1000/988. smallest-string-starting-from-leaf/sol.py @@ -0,0 +1,45 @@ +# Definition for a binary tree node. +# class TreeNode: +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +from collections import deque +from typing import Optional + + +class Solution: + def smallestFromLeaf(self, root: Optional[TreeNode]) -> str: + smallest_string = "" + node_queue = deque() + + # Add root node to deque along with its value converted to a character + node_queue.append([root, chr(root.val + ord("a"))]) + + # Perform BFS traversal until deque is empty + while node_queue: + # Pop the leftmost node and its corresponding string from deque + node, current_string = node_queue.popleft() + + # If current node is a leaf node + if not node.left and not node.right: + # Update smallest_string if it's empty or current string is smaller + smallest_string = ( + min(smallest_string, current_string) + if smallest_string + else current_string + ) + + # If current node has a left child, append it to deque + if node.left: + node_queue.append( + [node.left, chr(node.left.val + ord("a")) + current_string] + ) + + # If current node has a right child, append it to deque + if node.right: + node_queue.append( + [node.right, chr(node.right.val + ord("a")) + current_string] + ) + + return smallest_string diff --git a/tests/501-1000/988. smallest-string-starting-from-leaf/sol.py2 b/tests/501-1000/988. smallest-string-starting-from-leaf/sol.py2 new file mode 100644 index 00000000..b455fcba --- /dev/null +++ b/tests/501-1000/988. smallest-string-starting-from-leaf/sol.py2 @@ -0,0 +1,32 @@ +# Definition for a binary tree node. +# class TreeNode(object): +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +from collections import deque + +class Solution(object): + def smallestFromLeaf(self, root): + """ + :type root: Optional[TreeNode] + :rtype: str + """ + smallest_string = "" + node_queue = deque() + + node_queue.append([root, chr(root.val + ord('a'))]) + + while node_queue: + node, current_string = node_queue.popleft() + + if not node.left and not node.right: + smallest_string = min(smallest_string, current_string) if smallest_string else current_string + + if node.left: + node_queue.append([node.left, chr(node.left.val + ord('a')) + current_string]) + + if node.right: + node_queue.append([node.right, chr(node.right.val + ord('a')) + current_string]) + + return smallest_string diff --git a/tests/501-1000/988. smallest-string-starting-from-leaf/sol.rb b/tests/501-1000/988. smallest-string-starting-from-leaf/sol.rb new file mode 100644 index 00000000..b2ac18ac --- /dev/null +++ b/tests/501-1000/988. smallest-string-starting-from-leaf/sol.rb @@ -0,0 +1,39 @@ +# Definition for a binary tree node. +# class TreeNode +# attr_accessor :val, :left, :right +# def initialize(val = 0, left = nil, right = nil) +# @val = val +# @left = left +# @right = right +# end +# end +# @param {TreeNode} root +# @return {String} +require 'set' + +def smallest_from_leaf(root) + smallest_string = "" + node_queue = [] + + node_queue << [root, (root.val + 97).chr] + + until node_queue.empty? + node, current_string = node_queue.shift + + if node.left.nil? && node.right.nil? + if smallest_string.empty? || current_string < smallest_string + smallest_string = current_string + end + end + + if node.left + node_queue << [node.left, (node.left.val + 97).chr + current_string] + end + + if node.right + node_queue << [node.right, (node.right.val + 97).chr + current_string] + end + end + + smallest_string +end diff --git a/tests/501-1000/988. smallest-string-starting-from-leaf/sol.rs b/tests/501-1000/988. smallest-string-starting-from-leaf/sol.rs new file mode 100644 index 00000000..af899e5f --- /dev/null +++ b/tests/501-1000/988. smallest-string-starting-from-leaf/sol.rs @@ -0,0 +1,59 @@ +// Definition for a binary tree node. +// #[derive(Debug, PartialEq, Eq)] +// pub struct TreeNode { +// pub val: i32, +// pub left: Option>>, +// pub right: Option>>, +// } +// +// impl TreeNode { +// #[inline] +// pub fn new(val: i32) -> Self { +// TreeNode { +// val, +// left: None, +// right: None +// } +// } +// } +use std::collections::VecDeque; + +impl Solution { + pub fn smallest_from_leaf(root: Option>>) -> String { + let mut smallest_string = String::new(); + let mut node_queue: VecDeque<(Rc>, String)> = VecDeque::new(); + + if let Some(node) = root { + let val = node.borrow().val; + node_queue.push_back((node.clone(), String::from(char::from_u32((val as u8 + b'a') as u32).unwrap()))); + + while let Some((curr_node, current_string)) = node_queue.pop_front() { + let node_ref = curr_node.borrow(); + + if node_ref.left.is_none() && node_ref.right.is_none() { + if smallest_string.is_empty() || current_string < smallest_string { + smallest_string = current_string.clone(); + } + } + + if let Some(left_node) = &node_ref.left { + let left_val = left_node.borrow().val; + node_queue.push_back(( + left_node.clone(), + format!("{}{}", char::from_u32((left_val as u8 + b'a') as u32).unwrap(), current_string) + )); + } + + if let Some(right_node) = &node_ref.right { + let right_val = right_node.borrow().val; + node_queue.push_back(( + right_node.clone(), + format!("{}{}", char::from_u32((right_val as u8 + b'a') as u32).unwrap(), current_string) + )); + } + } + } + + smallest_string + } +} diff --git a/tests/501-1000/988. smallest-string-starting-from-leaf/sol.swift b/tests/501-1000/988. smallest-string-starting-from-leaf/sol.swift new file mode 100644 index 00000000..a938d740 --- /dev/null +++ b/tests/501-1000/988. smallest-string-starting-from-leaf/sol.swift @@ -0,0 +1,43 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public var val: Int + * public var left: TreeNode? + * public var right: TreeNode? + * public init() { self.val = 0; self.left = nil; self.right = nil; } + * public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; } + * public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) { + * self.val = val + * self.left = left + * self.right = right + * } + * } + */ +class Solution { + func smallestFromLeaf(_ root: TreeNode?) -> String { + var smallestString = "" + var nodeQueue: [(TreeNode, String)] = [] + + nodeQueue.append((root!, String(Character(UnicodeScalar(root!.val + 97)!)))) + + while !nodeQueue.isEmpty { + let (node, currentString) = nodeQueue.removeFirst() + + if node.left == nil && node.right == nil { + if smallestString.isEmpty || currentString < smallestString { + smallestString = currentString + } + } + + if let leftNode = node.left { + nodeQueue.append((leftNode, String(Character(UnicodeScalar(leftNode.val + 97)!)) + currentString)) + } + + if let rightNode = node.right { + nodeQueue.append((rightNode, String(Character(UnicodeScalar(rightNode.val + 97)!)) + currentString)) + } + } + + return smallestString + } +} diff --git a/tests/501-1000/988. smallest-string-starting-from-leaf/sol.ts b/tests/501-1000/988. smallest-string-starting-from-leaf/sol.ts new file mode 100644 index 00000000..ef869520 --- /dev/null +++ b/tests/501-1000/988. smallest-string-starting-from-leaf/sol.ts @@ -0,0 +1,46 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ + +function smallestFromLeaf(root: TreeNode | null): string { + let smallestString: string = ""; + const nodeQueue: [TreeNode, string][] = []; + + nodeQueue.push([root!, String.fromCharCode(root!.val + 97)]); + + while (nodeQueue.length > 0) { + const [node, currentString] = nodeQueue.shift()!; + + if (node.left === null && node.right === null) { + if (smallestString === "" || currentString < smallestString) { + smallestString = currentString; + } + } + + if (node.left !== null) { + nodeQueue.push([ + node.left, + String.fromCharCode(node.left.val + 97) + currentString, + ]); + } + + if (node.right !== null) { + nodeQueue.push([ + node.right, + String.fromCharCode(node.right.val + 97) + currentString, + ]); + } + } + + return smallestString; +} diff --git a/tests/501-1000/989. add-to-array-form-of-integer/manifest.yaml b/tests/501-1000/989. add-to-array-form-of-integer/manifest.yaml new file mode 100644 index 00000000..330d8e29 --- /dev/null +++ b/tests/501-1000/989. add-to-array-form-of-integer/manifest.yaml @@ -0,0 +1,604 @@ +entry: + id: 989 + title: add-to-array-form-of-integer + params: + num: + type: array + items: + type: int + k: + type: int + call: + cpp: Solution().addToArrayForm({num}, {k}) + rust: Solution::add_to_array_form({num}, {k}) + python3: Solution().addToArrayForm({num}, {k}) + python2: Solution().addToArrayForm({num}, {k}) + ruby: add_to_array_form({num}, {k}) + java: new Solution().addToArrayForm({num}, {k}) + csharp: new Solution().AddToArrayForm({num}, {k}) + kotlin: Solution().addToArrayForm({num}, {k}) + go: addToArrayForm({num}, {k}) + dart: Solution().addToArrayForm({num}, {k}) + swift: Solution().addToArrayForm({num}, {k}) + typescript: addToArrayForm({num}, {k}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 989 +tests: + - name: case_1 + in: + num: + - 3 + - 6 + - 3 + - 7 + - 3 + - 3 + - 6 + - 9 + k: 7385 + out: + - 3 + - 6 + - 3 + - 8 + - 0 + - 7 + - 5 + - 4 + - name: case_2 + in: + num: + - 3 + - 1 + - 5 + - 9 + - 7 + - 9 + - 8 + - 9 + - 6 + k: 6873 + out: + - 3 + - 1 + - 5 + - 9 + - 8 + - 6 + - 7 + - 6 + - 9 + - name: case_3 + in: + num: + - 4 + - 9 + - 3 + k: 7882 + out: + - 8 + - 3 + - 7 + - 5 + - name: case_4 + in: + num: + - 1 + - 7 + - 8 + - 3 + - 3 + - 5 + - 4 + k: 6307 + out: + - 1 + - 7 + - 8 + - 9 + - 6 + - 6 + - 1 + - name: case_5 + in: + num: + - 8 + - 4 + - 5 + - 6 + - 2 + - 8 + - 2 + - 4 + k: 1242 + out: + - 8 + - 4 + - 5 + - 6 + - 4 + - 0 + - 6 + - 6 + - name: case_6 + in: + num: + - 1 + - 9 + - 5 + k: 6774 + out: + - 6 + - 9 + - 6 + - 9 + - name: case_7 + in: + num: + - 5 + k: 8531 + out: + - 8 + - 5 + - 3 + - 6 + - name: case_8 + in: + num: + - 1 + - 9 + - 3 + - 5 + - 0 + - 3 + k: 1898 + out: + - 1 + - 9 + - 5 + - 4 + - 0 + - 1 + - name: case_9 + in: + num: + - 8 + - 9 + - 6 + - 5 + - 1 + - 9 + - 4 + - 9 + k: 8805 + out: + - 8 + - 9 + - 6 + - 6 + - 0 + - 7 + - 5 + - 4 + - name: case_10 + in: + num: + - 6 + - 6 + - 6 + - 3 + - 6 + - 7 + - 9 + - 5 + - 0 + - 4 + k: 1578 + out: + - 6 + - 6 + - 6 + - 3 + - 6 + - 8 + - 1 + - 0 + - 8 + - 2 + - name: case_11 + in: + num: + - 8 + - 5 + - 9 + - 3 + - 9 + - 5 + - 6 + - 4 + - 5 + - 5 + k: 3643 + out: + - 8 + - 5 + - 9 + - 3 + - 9 + - 6 + - 0 + - 0 + - 9 + - 8 + - name: case_12 + in: + num: + - 7 + - 6 + - 7 + - 5 + - 3 + - 5 + k: 1264 + out: + - 7 + - 6 + - 8 + - 7 + - 9 + - 9 + - name: case_13 + in: + num: + - 2 + - 4 + - 7 + - 6 + - 5 + - 8 + k: 270 + out: + - 2 + - 4 + - 7 + - 9 + - 2 + - 8 + - name: case_14 + in: + num: + - 3 + - 1 + - 4 + - 9 + k: 9798 + out: + - 1 + - 2 + - 9 + - 4 + - 7 + - name: case_15 + in: + num: + - 8 + - 4 + - 8 + - 5 + - 5 + - 7 + - 5 + - 2 + - 2 + - 7 + k: 5143 + out: + - 8 + - 4 + - 8 + - 5 + - 5 + - 8 + - 0 + - 3 + - 7 + - 0 + - name: case_16 + in: + num: + - 4 + k: 9151 + out: + - 9 + - 1 + - 5 + - 5 + - name: case_17 + in: + num: + - 7 + - 2 + - 8 + - 8 + - 9 + - 6 + k: 1414 + out: + - 7 + - 3 + - 0 + - 3 + - 1 + - 0 + - name: case_18 + in: + num: + - 4 + - 8 + - 9 + - 7 + k: 7966 + out: + - 1 + - 2 + - 8 + - 6 + - 3 + - name: case_19 + in: + num: + - 9 + - 9 + - 0 + - 1 + - 2 + - 2 + - 5 + - 1 + k: 7420 + out: + - 9 + - 9 + - 0 + - 1 + - 9 + - 6 + - 7 + - 1 + - name: case_20 + in: + num: + - 6 + - 9 + - 8 + - 4 + - 8 + - 5 + k: 4174 + out: + - 7 + - 0 + - 2 + - 6 + - 5 + - 9 + - name: case_21 + in: + num: + - 8 + - 7 + - 3 + - 9 + - 8 + - 3 + - 6 + - 1 + - 5 + k: 7936 + out: + - 8 + - 7 + - 3 + - 9 + - 9 + - 1 + - 5 + - 5 + - 1 + - name: case_22 + in: + num: + - 6 + - 3 + - 4 + - 9 + - 6 + k: 5063 + out: + - 6 + - 8 + - 5 + - 5 + - 9 + - name: case_23 + in: + num: + - 8 + - 6 + - 9 + - 2 + - 4 + k: 7194 + out: + - 9 + - 4 + - 1 + - 1 + - 8 + - name: case_24 + in: + num: + - 2 + - 7 + - 8 + k: 5961 + out: + - 6 + - 2 + - 3 + - 9 + - name: case_25 + in: + num: + - 5 + - 4 + - 7 + - 7 + - 6 + - 1 + k: 1785 + out: + - 5 + - 4 + - 9 + - 5 + - 4 + - 6 + - name: case_26 + in: + num: + - 3 + k: 3083 + out: + - 3 + - 0 + - 8 + - 6 + - name: case_27 + in: + num: + - 1 + - 0 + - 0 + - 9 + - 9 + - 9 + - 8 + - 4 + k: 2219 + out: + - 1 + - 0 + - 1 + - 0 + - 2 + - 2 + - 0 + - 3 + - name: case_28 + in: + num: + - 2 + - 2 + - 6 + k: 2491 + out: + - 2 + - 7 + - 1 + - 7 + - name: case_29 + in: + num: + - 1 + - 0 + - 2 + - 0 + - 4 + k: 7688 + out: + - 1 + - 7 + - 8 + - 9 + - 2 + - name: case_30 + in: + num: + - 1 + - 2 + - 4 + - 3 + k: 8148 + out: + - 9 + - 3 + - 9 + - 1 + - name: case_31 + in: + num: + - 4 + - 2 + k: 8324 + out: + - 8 + - 3 + - 6 + - 6 + - name: case_32 + in: + num: + - 2 + - 8 + k: 5179 + out: + - 5 + - 2 + - 0 + - 7 + - name: case_33 + in: + num: + - 8 + - 4 + - 8 + - 5 + k: 3863 + out: + - 1 + - 2 + - 3 + - 4 + - 8 + - name: case_34 + in: + num: + - 4 + k: 4766 + out: + - 4 + - 7 + - 7 + - 0 + - name: case_35 + in: + num: + - 5 + - 4 + - 3 + - 0 + k: 453 + out: + - 5 + - 8 + - 8 + - 3 diff --git a/tests/501-1000/989. add-to-array-form-of-integer/sol.cpp b/tests/501-1000/989. add-to-array-form-of-integer/sol.cpp new file mode 100644 index 00000000..74f68847 --- /dev/null +++ b/tests/501-1000/989. add-to-array-form-of-integer/sol.cpp @@ -0,0 +1,19 @@ +class Solution { +public: + vector addToArrayForm(vector& num, int k) { + vector out; + int i = (int)num.size() - 1; + while (i >= 0 || k > 0) { + if (i >= 0) { + k += num[i--]; + } + out.push_back(k % 10); + k /= 10; + } + if (out.empty()) { + return {0}; + } + reverse(out.begin(), out.end()); + return out; + } +}; diff --git a/tests/501-1000/989. add-to-array-form-of-integer/sol.cs b/tests/501-1000/989. add-to-array-form-of-integer/sol.cs new file mode 100644 index 00000000..0ff6e6e5 --- /dev/null +++ b/tests/501-1000/989. add-to-array-form-of-integer/sol.cs @@ -0,0 +1,18 @@ +public class Solution { + public IList AddToArrayForm(int[] num, int k) { + List result = new List(); + int i = num.Length - 1; + while (i >= 0 || k > 0) { + if (i >= 0) { + k += num[i--]; + } + result.Add(k % 10); + k /= 10; + } + if (result.Count == 0) { + result.Add(0); + } + result.Reverse(); + return result; + } +} diff --git a/tests/501-1000/989. add-to-array-form-of-integer/sol.dart b/tests/501-1000/989. add-to-array-form-of-integer/sol.dart new file mode 100644 index 00000000..4cc1f860 --- /dev/null +++ b/tests/501-1000/989. add-to-array-form-of-integer/sol.dart @@ -0,0 +1,19 @@ +class Solution { + List addToArrayForm(List num, int k) { + final out = []; + var i = num.length - 1; + var carry = k; + while (i >= 0 || carry > 0) { + if (i >= 0) { + carry += num[i]; + i--; + } + out.add(carry % 10); + carry ~/= 10; + } + if (out.isEmpty) { + return [0]; + } + return out.reversed.toList(); + } +} diff --git a/tests/501-1000/989. add-to-array-form-of-integer/sol.go b/tests/501-1000/989. add-to-array-form-of-integer/sol.go new file mode 100644 index 00000000..0b2ecb83 --- /dev/null +++ b/tests/501-1000/989. add-to-array-form-of-integer/sol.go @@ -0,0 +1,19 @@ +func addToArrayForm(num []int, k int) []int { + out := []int{} + i := len(num) - 1 + for i >= 0 || k > 0 { + if i >= 0 { + k += num[i] + i-- + } + out = append(out, k%10) + k /= 10 + } + if len(out) == 0 { + return []int{0} + } + for l, r := 0, len(out)-1; l < r; l, r = l+1, r-1 { + out[l], out[r] = out[r], out[l] + } + return out +} diff --git a/tests/501-1000/989. add-to-array-form-of-integer/sol.java b/tests/501-1000/989. add-to-array-form-of-integer/sol.java new file mode 100644 index 00000000..97457676 --- /dev/null +++ b/tests/501-1000/989. add-to-array-form-of-integer/sol.java @@ -0,0 +1,17 @@ +class Solution { + public List addToArrayForm(int[] num, int k) { + LinkedList result = new LinkedList<>(); + int i = num.length - 1; + while (i >= 0 || k > 0) { + if (i >= 0) { + k += num[i--]; + } + result.addFirst(k % 10); + k /= 10; + } + if (result.isEmpty()) { + result.add(0); + } + return result; + } +} diff --git a/tests/501-1000/989. add-to-array-form-of-integer/sol.kt b/tests/501-1000/989. add-to-array-form-of-integer/sol.kt new file mode 100644 index 00000000..07cc2717 --- /dev/null +++ b/tests/501-1000/989. add-to-array-form-of-integer/sol.kt @@ -0,0 +1,18 @@ +class Solution { + fun addToArrayForm(num: IntArray, k: Int): List { + val result = mutableListOf() + var i = num.size - 1 + var carry = k + while (i >= 0 || carry > 0) { + if (i >= 0) { + carry += num[i--] + } + result.add(carry % 10) + carry /= 10 + } + if (result.isEmpty()) { + result.add(0) + } + return result.reversed() + } +} diff --git a/tests/501-1000/989. add-to-array-form-of-integer/sol.py b/tests/501-1000/989. add-to-array-form-of-integer/sol.py new file mode 100644 index 00000000..fc59e7c6 --- /dev/null +++ b/tests/501-1000/989. add-to-array-form-of-integer/sol.py @@ -0,0 +1,17 @@ +from typing import List + + +class Solution: + def addToArrayForm(self, num: List[int], k: int) -> List[int]: + out = [] + i = len(num) - 1 + carry = k + while i >= 0 or carry > 0: + if i >= 0: + carry += num[i] + i -= 1 + out.append(carry % 10) + carry //= 10 + if not out: + return [0] + return out[::-1] diff --git a/tests/501-1000/989. add-to-array-form-of-integer/sol.py2 b/tests/501-1000/989. add-to-array-form-of-integer/sol.py2 new file mode 100644 index 00000000..89afa67e --- /dev/null +++ b/tests/501-1000/989. add-to-array-form-of-integer/sol.py2 @@ -0,0 +1,19 @@ +class Solution(object): + def addToArrayForm(self, num, k): + """ + :type num: List[int] + :type k: int + :rtype: List[int] + """ + out = [] + i = len(num) - 1 + carry = k + while i >= 0 or carry > 0: + if i >= 0: + carry += num[i] + i -= 1 + out.append(carry % 10) + carry //= 10 + if not out: + return [0] + return out[::-1] diff --git a/tests/501-1000/989. add-to-array-form-of-integer/sol.rb b/tests/501-1000/989. add-to-array-form-of-integer/sol.rb new file mode 100644 index 00000000..239626f8 --- /dev/null +++ b/tests/501-1000/989. add-to-array-form-of-integer/sol.rb @@ -0,0 +1,18 @@ +# @param {Integer[]} num +# @param {Integer} k +# @return {Integer[]} +def add_to_array_form(num, k) + out = [] + i = num.length - 1 + carry = k + while i >= 0 || carry > 0 + if i >= 0 + carry += num[i] + i -= 1 + end + out << carry % 10 + carry /= 10 + end + return [0] if out.empty? + out.reverse +end diff --git a/tests/501-1000/989. add-to-array-form-of-integer/sol.rs b/tests/501-1000/989. add-to-array-form-of-integer/sol.rs new file mode 100644 index 00000000..472208da --- /dev/null +++ b/tests/501-1000/989. add-to-array-form-of-integer/sol.rs @@ -0,0 +1,20 @@ +impl Solution { + pub fn add_to_array_form(num: Vec, k: i32) -> Vec { + let mut out = Vec::new(); + let mut i = num.len() as i32 - 1; + let mut carry = k; + while i >= 0 || carry > 0 { + if i >= 0 { + carry += num[i as usize]; + i -= 1; + } + out.push(carry % 10); + carry /= 10; + } + if out.is_empty() { + return vec![0]; + } + out.reverse(); + out + } +} diff --git a/tests/501-1000/989. add-to-array-form-of-integer/sol.swift b/tests/501-1000/989. add-to-array-form-of-integer/sol.swift new file mode 100644 index 00000000..b54f52a4 --- /dev/null +++ b/tests/501-1000/989. add-to-array-form-of-integer/sol.swift @@ -0,0 +1,19 @@ +class Solution { + func addToArrayForm(_ num: [Int], _ k: Int) -> [Int] { + var out = [Int]() + var i = num.count - 1 + var carry = k + while i >= 0 || carry > 0 { + if i >= 0 { + carry += num[i] + i -= 1 + } + out.append(carry % 10) + carry /= 10 + } + if out.isEmpty { + return [0] + } + return Array(out.reversed()) + } +} diff --git a/tests/501-1000/989. add-to-array-form-of-integer/sol.ts b/tests/501-1000/989. add-to-array-form-of-integer/sol.ts new file mode 100644 index 00000000..fb56f825 --- /dev/null +++ b/tests/501-1000/989. add-to-array-form-of-integer/sol.ts @@ -0,0 +1,17 @@ +function addToArrayForm(num: number[], k: number): number[] { + const out: number[] = []; + let i = num.length - 1; + let carry = k; + while (i >= 0 || carry > 0) { + if (i >= 0) { + carry += num[i]; + i--; + } + out.push(carry % 10); + carry = Math.floor(carry / 10); + } + if (out.length === 0) { + return [0]; + } + return out.reverse(); +} diff --git a/tests/501-1000/990. satisfiability-of-equality-equations/manifest.yaml b/tests/501-1000/990. satisfiability-of-equality-equations/manifest.yaml new file mode 100644 index 00000000..c523d5a4 --- /dev/null +++ b/tests/501-1000/990. satisfiability-of-equality-equations/manifest.yaml @@ -0,0 +1,391 @@ +entry: + id: 990 + title: satisfiability-of-equality-equations + params: + equations: + type: array + items: + type: string + call: + cpp: Solution().equationsPossible({equations}) + rust: Solution::equations_possible({equations}) + python3: Solution().equationsPossible({equations}) + python2: Solution().equationsPossible({equations}) + ruby: equations_possible({equations}) + java: new Solution().equationsPossible({equations}) + csharp: new Solution().EquationsPossible({equations}) + kotlin: Solution().equationsPossible({equations}) + go: equationsPossible({equations}) + dart: Solution().equationsPossible({equations}) + swift: Solution().equationsPossible({equations}) + typescript: equationsPossible({equations}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 990 +tests: + - name: case_1 + in: + equations: + - d==c + - a!=f + - c!=c + - d==e + - d==a + - e!=f + - f==c + - a!=c + - e!=a + - c==b + - f!=f + out: false + - name: case_2 + in: + equations: + - d==d + out: true + - name: case_3 + in: + equations: + - f==a + - b!=b + - e!=e + out: false + - name: case_4 + in: + equations: + - f!=e + - d==e + - d==b + out: true + - name: case_5 + in: + equations: + - b==a + - a==f + - c!=a + - c==a + - c!=b + - f!=e + - a==f + - c==d + out: false + - name: case_6 + in: + equations: + - b==b + - c!=a + - f==b + - f==f + - f!=c + - c!=f + - d!=f + - e==a + - c==a + - e!=c + out: false + - name: case_7 + in: + equations: + - b!=f + - b!=d + - b==f + - f==c + - e==c + - c==a + - c!=a + out: false + - name: case_8 + in: + equations: + - b!=c + - c!=d + - f==f + out: true + - name: case_9 + in: + equations: + - b!=d + - a==c + - c!=e + - e==a + out: false + - name: case_10 + in: + equations: + - b!=b + - c==d + - c==d + out: false + - name: case_11 + in: + equations: + - e!=c + - a!=a + - b==e + - a!=c + - a==f + out: false + - name: case_12 + in: + equations: + - d!=e + - a==d + - a!=f + - a!=d + - f==f + - a==b + - c!=d + out: false + - name: case_13 + in: + equations: + - d!=c + - e==e + - e!=f + - e==b + - c!=b + - e!=d + - c!=b + - e!=e + - e!=b + out: false + - name: case_14 + in: + equations: + - a!=c + - f!=b + - d==d + - d==e + - f!=f + - c!=c + - f==e + out: false + - name: case_15 + in: + equations: + - c!=f + - e!=f + - c!=e + out: true + - name: case_16 + in: + equations: + - e!=a + out: true + - name: case_17 + in: + equations: + - e==b + - a==e + - d!=f + - d!=a + - a==c + - c==b + - c==d + - c!=e + - d!=e + - b==b + - a==d + - d==b + out: false + - name: case_18 + in: + equations: + - e==c + - d==b + - a==e + - e!=a + - f==e + - f!=d + - d==f + - e==a + - d==b + - d!=d + - e==a + out: false + - name: case_19 + in: + equations: + - b!=b + - b!=b + - b==a + - d!=b + - b==e + - a!=f + out: false + - name: case_20 + in: + equations: + - a==d + - e==f + - b!=f + - a!=c + out: true + - name: case_21 + in: + equations: + - b!=d + - a==e + - e==c + - f!=a + out: true + - name: case_22 + in: + equations: + - e==b + - a!=d + - f==a + - d==c + - c!=c + - c==d + - f!=b + - c==a + out: false + - name: case_23 + in: + equations: + - a!=f + - d!=e + - c!=f + - d!=a + - a!=f + - f!=e + - c!=c + - b!=e + - a==f + out: false + - name: case_24 + in: + equations: + - f!=c + - b==c + - d!=c + - b!=f + - d==c + - d==b + - b!=d + - a!=c + - d==d + - e!=b + - a==c + out: false + - name: case_25 + in: + equations: + - e==d + - b!=e + - b!=c + - b==f + - f==f + - c!=c + - b!=a + - b==f + - e!=d + - a!=f + - f==b + out: false + - name: case_26 + in: + equations: + - c==e + - d==f + out: true + - name: case_27 + in: + equations: + - f==a + - b==f + - e==f + - d!=f + - e!=c + - a==f + - d==e + - b==c + - f==a + out: false + - name: case_28 + in: + equations: + - e!=b + - e==b + - a==c + - d!=a + - f==b + - d!=a + - f==b + out: false + - name: case_29 + in: + equations: + - e!=f + - c==b + - e==a + - e==d + - a!=c + - f==e + - b==a + - e==a + - f!=a + - b!=f + - f==b + out: false + - name: case_30 + in: + equations: + - d!=c + out: true + - name: case_31 + in: + equations: + - e==d + - b!=a + out: true + - name: case_32 + in: + equations: + - e==e + - a!=e + - b==a + - f==d + - c!=b + - f!=d + - a==b + - d!=b + out: false + - name: case_33 + in: + equations: + - c!=c + - f==e + - f==f + - f!=e + - a==e + - f!=e + out: false + - name: case_34 + in: + equations: + - e!=a + - d==c + - a!=c + - d==e + - f!=c + - e==b + out: true + - name: case_35 + in: + equations: + - c!=d + - f!=f + - a==d + - a!=f + - e==a + - b!=f + out: false diff --git a/tests/501-1000/990. satisfiability-of-equality-equations/sol.cpp b/tests/501-1000/990. satisfiability-of-equality-equations/sol.cpp new file mode 100644 index 00000000..9875981f --- /dev/null +++ b/tests/501-1000/990. satisfiability-of-equality-equations/sol.cpp @@ -0,0 +1,42 @@ +class Solution { +public: + bool equationsPossible(vector& equations) { + vector parent(26); + vector rank(26, 0); + for (int i = 0; i < 26; ++i) parent[i] = i; + + function find = [&](int x) -> int { + if (parent[x] != x) { + parent[x] = find(parent[x]); + } + return parent[x]; + }; + + auto unionSets = [&](int a, int b) { + int ra = find(a); + int rb = find(b); + if (ra == rb) return; + if (rank[ra] < rank[rb]) { + parent[ra] = rb; + } else if (rank[ra] > rank[rb]) { + parent[rb] = ra; + } else { + parent[rb] = ra; + rank[ra]++; + } + }; + + for (const string& eq : equations) { + if (eq[1] == '=') { + unionSets(eq[0] - 'a', eq[3] - 'a'); + } + } + + for (const string& eq : equations) { + if (eq[1] == '!' && find(eq[0] - 'a') == find(eq[3] - 'a')) { + return false; + } + } + return true; + } +}; diff --git a/tests/501-1000/990. satisfiability-of-equality-equations/sol.cs b/tests/501-1000/990. satisfiability-of-equality-equations/sol.cs new file mode 100644 index 00000000..fffbe4c5 --- /dev/null +++ b/tests/501-1000/990. satisfiability-of-equality-equations/sol.cs @@ -0,0 +1,43 @@ +public class Solution { + public bool EquationsPossible(string[] equations) { + int[] parent = new int[26]; + int[] rank = new int[26]; + for (int i = 0; i < 26; i++) { + parent[i] = i; + } + + int Find(int x) { + if (parent[x] != x) { + parent[x] = Find(parent[x]); + } + return parent[x]; + } + + void Union(int a, int b) { + int ra = Find(a); + int rb = Find(b); + if (ra == rb) return; + if (rank[ra] < rank[rb]) { + parent[ra] = rb; + } else if (rank[ra] > rank[rb]) { + parent[rb] = ra; + } else { + parent[rb] = ra; + rank[ra]++; + } + } + + foreach (string eq in equations) { + if (eq[1] == '=') { + Union(eq[0] - 'a', eq[3] - 'a'); + } + } + + foreach (string eq in equations) { + if (eq[1] == '!' && Find(eq[0] - 'a') == Find(eq[3] - 'a')) { + return false; + } + } + return true; + } +} diff --git a/tests/501-1000/990. satisfiability-of-equality-equations/sol.dart b/tests/501-1000/990. satisfiability-of-equality-equations/sol.dart new file mode 100644 index 00000000..00897a21 --- /dev/null +++ b/tests/501-1000/990. satisfiability-of-equality-equations/sol.dart @@ -0,0 +1,40 @@ +class Solution { + bool equationsPossible(List equations) { + var parent = List.generate(26, (i) => i); + var rank = List.filled(26, 0); + + int find(int x) { + if (parent[x] != x) { + parent[x] = find(parent[x]); + } + return parent[x]; + } + + void union(int a, int b) { + int ra = find(a); + int rb = find(b); + if (ra == rb) return; + if (rank[ra] < rank[rb]) { + parent[ra] = rb; + } else if (rank[ra] > rank[rb]) { + parent[rb] = ra; + } else { + parent[rb] = ra; + rank[ra]++; + } + } + + for (var eq in equations) { + if (eq[1] == '=') { + union(eq.codeUnitAt(0) - 'a'.codeUnitAt(0), eq.codeUnitAt(3) - 'a'.codeUnitAt(0)); + } + } + + for (var eq in equations) { + if (eq[1] == '!' && find(eq.codeUnitAt(0) - 'a'.codeUnitAt(0)) == find(eq.codeUnitAt(3) - 'a'.codeUnitAt(0))) { + return false; + } + } + return true; + } +} diff --git a/tests/501-1000/990. satisfiability-of-equality-equations/sol.go b/tests/501-1000/990. satisfiability-of-equality-equations/sol.go new file mode 100644 index 00000000..43af692a --- /dev/null +++ b/tests/501-1000/990. satisfiability-of-equality-equations/sol.go @@ -0,0 +1,44 @@ +func equationsPossible(equations []string) bool { + parent := make([]int, 26) + rank := make([]int, 26) + for i := 0; i < 26; i++ { + parent[i] = i + } + + var find func(int) int + find = func(x int) int { + if parent[x] != x { + parent[x] = find(parent[x]) + } + return parent[x] + } + + union := func(a, b int) { + ra := find(a) + rb := find(b) + if ra == rb { + return + } + if rank[ra] < rank[rb] { + parent[ra] = rb + } else if rank[ra] > rank[rb] { + parent[rb] = ra + } else { + parent[rb] = ra + rank[ra]++ + } + } + + for _, eq := range equations { + if eq[1] == '=' { + union(int(eq[0]-'a'), int(eq[3]-'a')) + } + } + + for _, eq := range equations { + if eq[1] == '!' && find(int(eq[0]-'a')) == find(int(eq[3]-'a')) { + return false + } + } + return true +} diff --git a/tests/501-1000/990. satisfiability-of-equality-equations/sol.java b/tests/501-1000/990. satisfiability-of-equality-equations/sol.java new file mode 100644 index 00000000..a5ed9345 --- /dev/null +++ b/tests/501-1000/990. satisfiability-of-equality-equations/sol.java @@ -0,0 +1,43 @@ +class Solution { + public boolean equationsPossible(String[] equations) { + int[] parent = new int[26]; + int[] rank = new int[26]; + for (int i = 0; i < 26; i++) { + parent[i] = i; + } + + for (String eq : equations) { + if (eq.charAt(1) == '=') { + union(eq.charAt(0) - 'a', eq.charAt(3) - 'a', parent, rank); + } + } + + for (String eq : equations) { + if (eq.charAt(1) == '!' && find(eq.charAt(0) - 'a', parent) == find(eq.charAt(3) - 'a', parent)) { + return false; + } + } + return true; + } + + private int find(int x, int[] parent) { + if (parent[x] != x) { + parent[x] = find(parent[x], parent); + } + return parent[x]; + } + + private void union(int a, int b, int[] parent, int[] rank) { + int ra = find(a, parent); + int rb = find(b, parent); + if (ra == rb) return; + if (rank[ra] < rank[rb]) { + parent[ra] = rb; + } else if (rank[ra] > rank[rb]) { + parent[rb] = ra; + } else { + parent[rb] = ra; + rank[ra]++; + } + } +} diff --git a/tests/501-1000/990. satisfiability-of-equality-equations/sol.kt b/tests/501-1000/990. satisfiability-of-equality-equations/sol.kt new file mode 100644 index 00000000..3125e3fe --- /dev/null +++ b/tests/501-1000/990. satisfiability-of-equality-equations/sol.kt @@ -0,0 +1,40 @@ +class Solution { + fun equationsPossible(equations: Array): Boolean { + val parent = IntArray(26) { it } + val rank = IntArray(26) + + fun find(x: Int): Int { + if (parent[x] != x) { + parent[x] = find(parent[x]) + } + return parent[x] + } + + fun union(a: Int, b: Int) { + val ra = find(a) + val rb = find(b) + if (ra == rb) return + when { + rank[ra] < rank[rb] -> parent[ra] = rb + rank[ra] > rank[rb] -> parent[rb] = ra + else -> { + parent[rb] = ra + rank[ra]++ + } + } + } + + for (eq in equations) { + if (eq[1] == '=') { + union(eq[0] - 'a', eq[3] - 'a') + } + } + + for (eq in equations) { + if (eq[1] == '!' && find(eq[0] - 'a') == find(eq[3] - 'a')) { + return false + } + } + return true + } +} diff --git a/tests/501-1000/990. satisfiability-of-equality-equations/sol.py b/tests/501-1000/990. satisfiability-of-equality-equations/sol.py new file mode 100644 index 00000000..ceffee7f --- /dev/null +++ b/tests/501-1000/990. satisfiability-of-equality-equations/sol.py @@ -0,0 +1,36 @@ +from typing import List + + +class Solution: + def equationsPossible(self, equations: List[str]) -> bool: + parent = list(range(26)) + rank = [0] * 26 + + def find(x: int) -> int: + if parent[x] != x: + parent[x] = find(parent[x]) + return parent[x] + + def union(a: int, b: int) -> None: + ra = find(a) + rb = find(b) + if ra == rb: + return + if rank[ra] < rank[rb]: + parent[ra] = rb + elif rank[ra] > rank[rb]: + parent[rb] = ra + else: + parent[rb] = ra + rank[ra] += 1 + + for eq in equations: + if eq[1] == "=": + union(ord(eq[0]) - ord("a"), ord(eq[3]) - ord("a")) + + for eq in equations: + if eq[1] == "!" and find(ord(eq[0]) - ord("a")) == find( + ord(eq[3]) - ord("a") + ): + return False + return True diff --git a/tests/501-1000/990. satisfiability-of-equality-equations/sol.py2 b/tests/501-1000/990. satisfiability-of-equality-equations/sol.py2 new file mode 100644 index 00000000..4a48f3b3 --- /dev/null +++ b/tests/501-1000/990. satisfiability-of-equality-equations/sol.py2 @@ -0,0 +1,35 @@ +class Solution(object): + def equationsPossible(self, equations): + """ + :type equations: List[str] + :rtype: bool + """ + parent = list(range(26)) + rank = [0] * 26 + + def find(x): + if parent[x] != x: + parent[x] = find(parent[x]) + return parent[x] + + def union(a, b): + ra = find(a) + rb = find(b) + if ra == rb: + return + if rank[ra] < rank[rb]: + parent[ra] = rb + elif rank[ra] > rank[rb]: + parent[rb] = ra + else: + parent[rb] = ra + rank[ra] += 1 + + for eq in equations: + if eq[1] == "=": + union(ord(eq[0]) - ord("a"), ord(eq[3]) - ord("a")) + + for eq in equations: + if eq[1] == "!" and find(ord(eq[0]) - ord("a")) == find(ord(eq[3]) - ord("a")): + return False + return True diff --git a/tests/501-1000/990. satisfiability-of-equality-equations/sol.rb b/tests/501-1000/990. satisfiability-of-equality-equations/sol.rb new file mode 100644 index 00000000..df8a3bde --- /dev/null +++ b/tests/501-1000/990. satisfiability-of-equality-equations/sol.rb @@ -0,0 +1,40 @@ +# @param {String[]} equations +# @return {Boolean} +def equations_possible(equations) + parent = (0..25).to_a + rank = Array.new(26, 0) + + find = lambda do |x| + if parent[x] != x + parent[x] = find.call(parent[x]) + end + parent[x] + end + + union = lambda do |a, b| + ra = find.call(a) + rb = find.call(b) + return if ra == rb + if rank[ra] < rank[rb] + parent[ra] = rb + elsif rank[ra] > rank[rb] + parent[rb] = ra + else + parent[rb] = ra + rank[ra] += 1 + end + end + + equations.each do |eq| + if eq[1] == "=" + union.call(eq[0].ord - "a".ord, eq[3].ord - "a".ord) + end + end + + equations.each do |eq| + if eq[1] == "!" && find.call(eq[0].ord - "a".ord) == find.call(eq[3].ord - "a".ord) + return false + end + end + true +end diff --git a/tests/501-1000/990. satisfiability-of-equality-equations/sol.rs b/tests/501-1000/990. satisfiability-of-equality-equations/sol.rs new file mode 100644 index 00000000..1bd08d4d --- /dev/null +++ b/tests/501-1000/990. satisfiability-of-equality-equations/sol.rs @@ -0,0 +1,50 @@ +impl Solution { + pub fn equations_possible(equations: Vec) -> bool { + let mut parent: Vec = (0..26).collect(); + let mut rank = vec![0usize; 26]; + + fn find(parent: &mut Vec, x: usize) -> usize { + if parent[x] != x { + parent[x] = find(parent, parent[x]); + } + parent[x] + } + + fn union(parent: &mut Vec, rank: &mut Vec, a: usize, b: usize) { + let ra = find(parent, a); + let rb = find(parent, b); + if ra == rb { + return; + } + if rank[ra] < rank[rb] { + parent[ra] = rb; + } else if rank[ra] > rank[rb] { + parent[rb] = ra; + } else { + parent[rb] = ra; + rank[ra] += 1; + } + } + + for eq in &equations { + let bytes = eq.as_bytes(); + if bytes[1] == b'=' { + let a = (bytes[0] - b'a') as usize; + let b = (bytes[3] - b'a') as usize; + union(&mut parent, &mut rank, a, b); + } + } + + for eq in &equations { + let bytes = eq.as_bytes(); + if bytes[1] == b'!' { + let a = (bytes[0] - b'a') as usize; + let b = (bytes[3] - b'a') as usize; + if find(&mut parent, a) == find(&mut parent, b) { + return false; + } + } + } + true + } +} diff --git a/tests/501-1000/990. satisfiability-of-equality-equations/sol.swift b/tests/501-1000/990. satisfiability-of-equality-equations/sol.swift new file mode 100644 index 00000000..4c2b1a9b --- /dev/null +++ b/tests/501-1000/990. satisfiability-of-equality-equations/sol.swift @@ -0,0 +1,48 @@ +class Solution { + func equationsPossible(_ equations: [String]) -> Bool { + var parent = Array(0..<26) + var rank = Array(repeating: 0, count: 26) + + func find(_ x: Int) -> Int { + if parent[x] != x { + parent[x] = find(parent[x]) + } + return parent[x] + } + + func union(_ a: Int, _ b: Int) { + let ra = find(a) + let rb = find(b) + if ra == rb { return } + if rank[ra] < rank[rb] { + parent[ra] = rb + } else if rank[ra] > rank[rb] { + parent[rb] = ra + } else { + parent[rb] = ra + rank[ra] += 1 + } + } + + for eq in equations { + let chars = Array(eq) + if chars[1] == "=" { + let a = Int(chars[0].asciiValue! - Character("a").asciiValue!) + let b = Int(chars[3].asciiValue! - Character("a").asciiValue!) + union(a, b) + } + } + + for eq in equations { + let chars = Array(eq) + if chars[1] == "!" { + let a = Int(chars[0].asciiValue! - Character("a").asciiValue!) + let b = Int(chars[3].asciiValue! - Character("a").asciiValue!) + if find(a) == find(b) { + return false + } + } + } + return true + } +} diff --git a/tests/501-1000/990. satisfiability-of-equality-equations/sol.ts b/tests/501-1000/990. satisfiability-of-equality-equations/sol.ts new file mode 100644 index 00000000..6a89de2f --- /dev/null +++ b/tests/501-1000/990. satisfiability-of-equality-equations/sol.ts @@ -0,0 +1,45 @@ +function equationsPossible(equations: string[]): boolean { + const parent: number[] = Array.from({ length: 26 }, (_, i) => i); + const rank: number[] = Array(26).fill(0); + + function find(x: number): number { + if (parent[x] !== x) { + parent[x] = find(parent[x]); + } + return parent[x]; + } + + function union(a: number, b: number): void { + const ra = find(a); + const rb = find(b); + if (ra === rb) return; + if (rank[ra] < rank[rb]) { + parent[ra] = rb; + } else if (rank[ra] > rank[rb]) { + parent[rb] = ra; + } else { + parent[rb] = ra; + rank[ra]++; + } + } + + for (const eq of equations) { + if (eq[1] === "=") { + union( + eq.charCodeAt(0) - "a".charCodeAt(0), + eq.charCodeAt(3) - "a".charCodeAt(0), + ); + } + } + + for (const eq of equations) { + if ( + eq[1] === "!" && + find(eq.charCodeAt(0) - "a".charCodeAt(0)) === + find(eq.charCodeAt(3) - "a".charCodeAt(0)) + ) { + return false; + } + } + return true; +} diff --git a/tests/501-1000/991. broken-calculator/manifest.yaml b/tests/501-1000/991. broken-calculator/manifest.yaml new file mode 100644 index 00000000..ce25dbb2 --- /dev/null +++ b/tests/501-1000/991. broken-calculator/manifest.yaml @@ -0,0 +1,207 @@ +entry: + id: 991 + title: broken-calculator + params: + startValue: + type: int + target: + type: int + call: + cpp: Solution().brokenCalc({startValue}, {target}) + rust: Solution::broken_calc({startValue}, {target}) + python3: Solution().brokenCalc({startValue}, {target}) + python2: Solution().brokenCalc({startValue}, {target}) + ruby: broken_calc({startValue}, {target}) + java: new Solution().brokenCalc({startValue}, {target}) + csharp: new Solution().BrokenCalc({startValue}, {target}) + kotlin: Solution().brokenCalc({startValue}, {target}) + go: brokenCalc({startValue}, {target}) + dart: Solution().brokenCalc({startValue}, {target}) + swift: Solution().brokenCalc({startValue}, {target}) + typescript: brokenCalc({startValue}, {target}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 991 +tests: + - name: case_1 + in: + startValue: 89 + target: 313 + out: 14 + - name: case_2 + in: + startValue: 3 + target: 384 + out: 7 + - name: case_3 + in: + startValue: 41 + target: 500 + out: 15 + - name: case_4 + in: + startValue: 8 + target: 325 + out: 13 + - name: case_5 + in: + startValue: 54 + target: 200 + out: 6 + - name: case_6 + in: + startValue: 17 + target: 26 + out: 5 + - name: case_7 + in: + startValue: 9 + target: 450 + out: 12 + - name: case_8 + in: + startValue: 15 + target: 172 + out: 9 + - name: case_9 + in: + startValue: 49 + target: 67 + out: 17 + - name: case_10 + in: + startValue: 69 + target: 136 + out: 2 + - name: case_11 + in: + startValue: 8 + target: 173 + out: 10 + - name: case_12 + in: + startValue: 71 + target: 279 + out: 4 + - name: case_13 + in: + startValue: 75 + target: 482 + out: 19 + - name: case_14 + in: + startValue: 21 + target: 85 + out: 15 + - name: case_15 + in: + startValue: 2 + target: 94 + out: 8 + - name: case_16 + in: + startValue: 28 + target: 367 + out: 10 + - name: case_17 + in: + startValue: 16 + target: 167 + out: 11 + - name: case_18 + in: + startValue: 34 + target: 324 + out: 19 + - name: case_19 + in: + startValue: 86 + target: 403 + out: 40 + - name: case_20 + in: + startValue: 18 + target: 105 + out: 10 + - name: case_21 + in: + startValue: 79 + target: 168 + out: 39 + - name: case_22 + in: + startValue: 79 + target: 95 + out: 33 + - name: case_23 + in: + startValue: 74 + target: 370 + out: 32 + - name: case_24 + in: + startValue: 22 + target: 492 + out: 13 + - name: case_25 + in: + startValue: 40 + target: 98 + out: 18 + - name: case_26 + in: + startValue: 34 + target: 185 + out: 16 + - name: case_27 + in: + startValue: 51 + target: 86 + out: 9 + - name: case_28 + in: + startValue: 10 + target: 485 + out: 12 + - name: case_29 + in: + startValue: 79 + target: 328 + out: 41 + - name: case_30 + in: + startValue: 91 + target: 177 + out: 4 + - name: case_31 + in: + startValue: 29 + target: 132 + out: 16 + - name: case_32 + in: + startValue: 56 + target: 348 + out: 16 + - name: case_33 + in: + startValue: 55 + target: 11 + out: 44 + - name: case_34 + in: + startValue: 63 + target: 119 + out: 5 + - name: case_35 + in: + startValue: 62 + target: 327 + out: 25 diff --git a/tests/501-1000/991. broken-calculator/sol.cpp b/tests/501-1000/991. broken-calculator/sol.cpp new file mode 100644 index 00000000..6b7ae672 --- /dev/null +++ b/tests/501-1000/991. broken-calculator/sol.cpp @@ -0,0 +1,15 @@ +class Solution { +public: + int brokenCalc(int startValue, int target) { + int ans = 0; + while (target > startValue) { + ans++; + if (target % 2 == 1) { + target += 1; + } else { + target /= 2; + } + } + return ans + startValue - target; + } +}; diff --git a/tests/501-1000/991. broken-calculator/sol.cs b/tests/501-1000/991. broken-calculator/sol.cs new file mode 100644 index 00000000..f46e6d7c --- /dev/null +++ b/tests/501-1000/991. broken-calculator/sol.cs @@ -0,0 +1,14 @@ +public class Solution { + public int BrokenCalc(int startValue, int target) { + int ans = 0; + while (target > startValue) { + ans++; + if (target % 2 == 1) { + target += 1; + } else { + target /= 2; + } + } + return ans + startValue - target; + } +} diff --git a/tests/501-1000/991. broken-calculator/sol.dart b/tests/501-1000/991. broken-calculator/sol.dart new file mode 100644 index 00000000..ca71f1fe --- /dev/null +++ b/tests/501-1000/991. broken-calculator/sol.dart @@ -0,0 +1,14 @@ +class Solution { + int brokenCalc(int startValue, int target) { + int ans = 0; + while (target > startValue) { + ans++; + if (target % 2 == 1) { + target += 1; + } else { + target ~/= 2; + } + } + return ans + startValue - target; + } +} diff --git a/tests/501-1000/991. broken-calculator/sol.go b/tests/501-1000/991. broken-calculator/sol.go new file mode 100644 index 00000000..e54a1535 --- /dev/null +++ b/tests/501-1000/991. broken-calculator/sol.go @@ -0,0 +1,12 @@ +func brokenCalc(startValue int, target int) int { + ans := 0 + for target > startValue { + ans++ + if target%2 == 1 { + target += 1 + } else { + target /= 2 + } + } + return ans + startValue - target +} diff --git a/tests/501-1000/991. broken-calculator/sol.java b/tests/501-1000/991. broken-calculator/sol.java new file mode 100644 index 00000000..7b3f1556 --- /dev/null +++ b/tests/501-1000/991. broken-calculator/sol.java @@ -0,0 +1,14 @@ +class Solution { + public int brokenCalc(int startValue, int target) { + int ans = 0; + while (target > startValue) { + ans++; + if (target % 2 == 1) { + target += 1; + } else { + target /= 2; + } + } + return ans + startValue - target; + } +} diff --git a/tests/501-1000/991. broken-calculator/sol.kt b/tests/501-1000/991. broken-calculator/sol.kt new file mode 100644 index 00000000..584fd37f --- /dev/null +++ b/tests/501-1000/991. broken-calculator/sol.kt @@ -0,0 +1,15 @@ +class Solution { + fun brokenCalc(startValue: Int, target: Int): Int { + var ans = 0 + var t = target + while (t > startValue) { + ans++ + if (t % 2 == 1) { + t += 1 + } else { + t /= 2 + } + } + return ans + startValue - t + } +} diff --git a/tests/501-1000/991. broken-calculator/sol.py b/tests/501-1000/991. broken-calculator/sol.py new file mode 100644 index 00000000..6960fc73 --- /dev/null +++ b/tests/501-1000/991. broken-calculator/sol.py @@ -0,0 +1,11 @@ +class Solution: + def brokenCalc(self, startValue: int, target: int) -> int: + ans = 0 + while target > startValue: + ans += 1 + if target % 2: + target += 1 + else: + target //= 2 + + return ans + startValue - target diff --git a/tests/501-1000/991. broken-calculator/sol.py2 b/tests/501-1000/991. broken-calculator/sol.py2 new file mode 100644 index 00000000..8ccc7a8f --- /dev/null +++ b/tests/501-1000/991. broken-calculator/sol.py2 @@ -0,0 +1,15 @@ +class Solution(object): + def brokenCalc(self, startValue, target): + """ + :type startValue: int + :type target: int + :rtype: int + """ + ans = 0 + while target > startValue: + ans += 1 + if target % 2: + target += 1 + else: + target //= 2 + return ans + startValue - target diff --git a/tests/501-1000/991. broken-calculator/sol.rb b/tests/501-1000/991. broken-calculator/sol.rb new file mode 100644 index 00000000..5f882871 --- /dev/null +++ b/tests/501-1000/991. broken-calculator/sol.rb @@ -0,0 +1,15 @@ +# @param {Integer} start_value +# @param {Integer} target +# @return {Integer} +def broken_calc(start_value, target) + ans = 0 + while target > start_value + ans += 1 + if target % 2 == 1 + target += 1 + else + target /= 2 + end + end + ans + start_value - target +end diff --git a/tests/501-1000/991. broken-calculator/sol.rs b/tests/501-1000/991. broken-calculator/sol.rs new file mode 100644 index 00000000..be5cc643 --- /dev/null +++ b/tests/501-1000/991. broken-calculator/sol.rs @@ -0,0 +1,15 @@ +impl Solution { + pub fn broken_calc(start_value: i32, target: i32) -> i32 { + let mut ans = 0; + let mut target = target; + while target > start_value { + ans += 1; + if target % 2 == 1 { + target += 1; + } else { + target /= 2; + } + } + ans + start_value - target + } +} diff --git a/tests/501-1000/991. broken-calculator/sol.swift b/tests/501-1000/991. broken-calculator/sol.swift new file mode 100644 index 00000000..c3e1b3af --- /dev/null +++ b/tests/501-1000/991. broken-calculator/sol.swift @@ -0,0 +1,15 @@ +class Solution { + func brokenCalc(_ startValue: Int, _ target: Int) -> Int { + var ans = 0 + var t = target + while t > startValue { + ans += 1 + if t % 2 == 1 { + t += 1 + } else { + t /= 2 + } + } + return ans + startValue - t + } +} diff --git a/tests/501-1000/991. broken-calculator/sol.ts b/tests/501-1000/991. broken-calculator/sol.ts new file mode 100644 index 00000000..bc0d0aba --- /dev/null +++ b/tests/501-1000/991. broken-calculator/sol.ts @@ -0,0 +1,12 @@ +function brokenCalc(startValue: number, target: number): number { + let ans = 0; + while (target > startValue) { + ans++; + if (target % 2 === 1) { + target += 1; + } else { + target = Math.floor(target / 2); + } + } + return ans + startValue - target; +} diff --git a/tests/501-1000/992. subarrays-with-k-different-integers/manifest.yaml b/tests/501-1000/992. subarrays-with-k-different-integers/manifest.yaml new file mode 100644 index 00000000..730cf9e5 --- /dev/null +++ b/tests/501-1000/992. subarrays-with-k-different-integers/manifest.yaml @@ -0,0 +1,401 @@ +entry: + id: 992 + title: subarrays-with-k-different-integers + params: + nums: + type: array + items: + type: int + k: + type: int + call: + cpp: Solution().subarraysWithKDistinct({nums}, {k}) + rust: Solution::subarrays_with_k_distinct({nums}, {k}) + python3: Solution().subarraysWithKDistinct({nums}, {k}) + python2: Solution().subarraysWithKDistinct({nums}, {k}) + ruby: subarrays_with_k_distinct({nums}, {k}) + java: new Solution().subarraysWithKDistinct({nums}, {k}) + csharp: new Solution().SubarraysWithKDistinct({nums}, {k}) + kotlin: Solution().subarraysWithKDistinct({nums}, {k}) + go: subarraysWithKDistinct({nums}, {k}) + dart: Solution().subarraysWithKDistinct({nums}, {k}) + swift: Solution().subarraysWithKDistinct({nums}, {k}) + typescript: subarraysWithKDistinct({nums}, {k}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 992 +tests: + - name: case_1 + in: + nums: + - 4 + - 1 + - 4 + - 1 + k: 2 + out: 6 + - name: case_2 + in: + nums: + - 1 + - 5 + - 2 + - 5 + - 4 + - 2 + - 1 + k: 1 + out: 7 + - name: case_3 + in: + nums: + - 5 + - 1 + - 3 + - 5 + - 2 + - 1 + - 4 + - 4 + k: 5 + out: 6 + - name: case_4 + in: + nums: + - 1 + - 2 + k: 2 + out: 1 + - name: case_5 + in: + nums: + - 4 + - 3 + - 3 + - 2 + - 1 + - 4 + - 2 + k: 2 + out: 7 + - name: case_6 + in: + nums: + - 5 + - 3 + - 3 + - 3 + - 5 + - 5 + k: 2 + out: 11 + - name: case_7 + in: + nums: + - 1 + - 2 + k: 2 + out: 1 + - name: case_8 + in: + nums: + - 5 + - 2 + - 2 + - 1 + - 2 + - 2 + - 2 + - 5 + k: 2 + out: 16 + - name: case_9 + in: + nums: + - 5 + - 2 + - 3 + - 4 + - 4 + - 5 + - 5 + k: 1 + out: 9 + - name: case_10 + in: + nums: + - 3 + - 1 + - 3 + - 5 + - 5 + - 1 + - 4 + - 2 + - 1 + k: 3 + out: 12 + - name: case_11 + in: + nums: + - 3 + - 2 + - 5 + - 4 + - 2 + - 1 + - 1 + - 4 + - 2 + k: 4 + out: 10 + - name: case_12 + in: + nums: + - 2 + - 4 + - 5 + - 1 + - 3 + - 4 + - 2 + - 4 + - 3 + - 5 + k: 5 + out: 15 + - name: case_13 + in: + nums: + - 3 + k: 1 + out: 1 + - name: case_14 + in: + nums: + - 1 + - 4 + - 4 + - 4 + - 3 + - 1 + k: 1 + out: 9 + - name: case_15 + in: + nums: + - 4 + - 4 + k: 1 + out: 3 + - name: case_16 + in: + nums: + - 1 + k: 1 + out: 1 + - name: case_17 + in: + nums: + - 3 + - 3 + - 1 + - 5 + - 1 + - 5 + - 4 + - 3 + k: 2 + out: 10 + - name: case_18 + in: + nums: + - 1 + - 3 + - 1 + - 1 + - 3 + - 3 + - 3 + - 2 + - 4 + - 5 + k: 5 + out: 4 + - name: case_19 + in: + nums: + - 1 + - 5 + - 5 + - 3 + - 2 + - 3 + - 2 + - 2 + k: 2 + out: 13 + - name: case_20 + in: + nums: + - 1 + - 1 + - 4 + - 5 + - 2 + - 4 + - 3 + - 5 + - 2 + k: 2 + out: 8 + - name: case_21 + in: + nums: + - 4 + - 5 + - 3 + - 5 + k: 3 + out: 2 + - name: case_22 + in: + nums: + - 1 + k: 1 + out: 1 + - name: case_23 + in: + nums: + - 2 + - 5 + - 3 + - 4 + - 5 + - 3 + k: 3 + out: 7 + - name: case_24 + in: + nums: + - 5 + - 5 + - 5 + - 2 + - 5 + - 2 + - 4 + - 2 + - 1 + - 2 + k: 4 + out: 10 + - name: case_25 + in: + nums: + - 5 + - 4 + k: 2 + out: 1 + - name: case_26 + in: + nums: + - 5 + - 5 + - 4 + - 3 + - 2 + - 4 + - 3 + k: 3 + out: 8 + - name: case_27 + in: + nums: + - 3 + - 4 + - 1 + k: 3 + out: 1 + - name: case_28 + in: + nums: + - 4 + k: 1 + out: 1 + - name: case_29 + in: + nums: + - 3 + - 2 + - 1 + k: 1 + out: 3 + - name: case_30 + in: + nums: + - 5 + - 3 + k: 1 + out: 2 + - name: case_31 + in: + nums: + - 3 + - 1 + - 1 + - 5 + - 5 + - 3 + k: 2 + out: 8 + - name: case_32 + in: + nums: + - 4 + - 1 + - 5 + - 4 + - 3 + - 3 + - 2 + - 2 + - 1 + - 1 + k: 3 + out: 11 + - name: case_33 + in: + nums: + - 3 + - 5 + - 3 + - 2 + k: 2 + out: 4 + - name: case_34 + in: + nums: + - 2 + - 3 + - 5 + - 2 + - 4 + - 3 + - 3 + k: 2 + out: 6 + - name: case_35 + in: + nums: + - 1 + - 5 + k: 1 + out: 2 diff --git a/tests/501-1000/992. subarrays-with-k-different-integers/sol.cpp b/tests/501-1000/992. subarrays-with-k-different-integers/sol.cpp new file mode 100644 index 00000000..58fb88e3 --- /dev/null +++ b/tests/501-1000/992. subarrays-with-k-different-integers/sol.cpp @@ -0,0 +1,30 @@ +class Solution { +public: + int subarraysWithKDistinct(vector& nums, int k) { + auto atMost = [&](int k) -> int { + unordered_map freq; + int count = 0; + int left = 0; + int n = nums.size(); + + for (int right = 0; right < n; right++) { + freq[nums[right]]++; + + while (freq.size() > k) { + if (freq[nums[left]] > 1) { + freq[nums[left]]--; + } else { + freq.erase(nums[left]); + } + left++; + } + + count += (right - left + 1); + } + + return count; + }; + + return atMost(k) - atMost(k - 1); + } +}; diff --git a/tests/501-1000/992. subarrays-with-k-different-integers/sol.cs b/tests/501-1000/992. subarrays-with-k-different-integers/sol.cs new file mode 100644 index 00000000..f28f3912 --- /dev/null +++ b/tests/501-1000/992. subarrays-with-k-different-integers/sol.cs @@ -0,0 +1,33 @@ +public class Solution { + public int SubarraysWithKDistinct(int[] nums, int k) { + int AtMost(int k) { + var freq = new Dictionary(); + int count = 0; + int left = 0; + int n = nums.Length; + + for (int right = 0; right < n; right++) { + if (freq.ContainsKey(nums[right])) { + freq[nums[right]]++; + } else { + freq[nums[right]] = 1; + } + + while (freq.Count > k) { + if (freq[nums[left]] > 1) { + freq[nums[left]]--; + } else { + freq.Remove(nums[left]); + } + left++; + } + + count += (right - left + 1); + } + + return count; + } + + return AtMost(k) - AtMost(k - 1); + } +} diff --git a/tests/501-1000/992. subarrays-with-k-different-integers/sol.dart b/tests/501-1000/992. subarrays-with-k-different-integers/sol.dart new file mode 100644 index 00000000..08f1a33e --- /dev/null +++ b/tests/501-1000/992. subarrays-with-k-different-integers/sol.dart @@ -0,0 +1,29 @@ +class Solution { + int subarraysWithKDistinct(List nums, int k) { + int atMost(int k) { + Map freq = {}; + int count = 0; + int left = 0; + int n = nums.length; + + for (int right = 0; right < n; right++) { + freq[nums[right]] = (freq[nums[right]] ?? 0) + 1; + + while (freq.length > k) { + if (freq[nums[left]]! > 1) { + freq[nums[left]] = freq[nums[left]]! - 1; + } else { + freq.remove(nums[left]); + } + left++; + } + + count += (right - left + 1); + } + + return count; + } + + return atMost(k) - atMost(k - 1); + } +} diff --git a/tests/501-1000/992. subarrays-with-k-different-integers/sol.go b/tests/501-1000/992. subarrays-with-k-different-integers/sol.go new file mode 100644 index 00000000..bb72af3a --- /dev/null +++ b/tests/501-1000/992. subarrays-with-k-different-integers/sol.go @@ -0,0 +1,27 @@ +func subarraysWithKDistinct(nums []int, k int) int { + atMost := func(k int) int { + freq := make(map[int]int) + count := 0 + left := 0 + n := len(nums) + + for right := 0; right < n; right++ { + freq[nums[right]]++ + + for len(freq) > k { + if freq[nums[left]] > 1 { + freq[nums[left]]-- + } else { + delete(freq, nums[left]) + } + left++ + } + + count += (right - left + 1) + } + + return count + } + + return atMost(k) - atMost(k-1) +} diff --git a/tests/501-1000/992. subarrays-with-k-different-integers/sol.java b/tests/501-1000/992. subarrays-with-k-different-integers/sol.java new file mode 100644 index 00000000..e5e07244 --- /dev/null +++ b/tests/501-1000/992. subarrays-with-k-different-integers/sol.java @@ -0,0 +1,29 @@ +class Solution { + public int subarraysWithKDistinct(int[] nums, int k) { + return atMost(nums, k) - atMost(nums, k - 1); + } + + private int atMost(int[] nums, int k) { + java.util.Map freq = new java.util.HashMap<>(); + int count = 0; + int left = 0; + int n = nums.length; + + for (int right = 0; right < n; right++) { + freq.put(nums[right], freq.getOrDefault(nums[right], 0) + 1); + + while (freq.size() > k) { + if (freq.get(nums[left]) > 1) { + freq.put(nums[left], freq.get(nums[left]) - 1); + } else { + freq.remove(nums[left]); + } + left++; + } + + count += (right - left + 1); + } + + return count; + } +} diff --git a/tests/501-1000/992. subarrays-with-k-different-integers/sol.kt b/tests/501-1000/992. subarrays-with-k-different-integers/sol.kt new file mode 100644 index 00000000..6cc816d0 --- /dev/null +++ b/tests/501-1000/992. subarrays-with-k-different-integers/sol.kt @@ -0,0 +1,29 @@ +class Solution { + fun subarraysWithKDistinct(nums: IntArray, k: Int): Int { + fun atMost(k: Int): Int { + val freq = mutableMapOf() + var count = 0 + var left = 0 + val n = nums.size + + for (right in 0 until n) { + freq[nums[right]] = freq.getOrDefault(nums[right], 0) + 1 + + while (freq.size > k) { + if (freq[nums[left]]!! > 1) { + freq[nums[left]] = freq[nums[left]]!! - 1 + } else { + freq.remove(nums[left]) + } + left++ + } + + count += (right - left + 1) + } + + return count + } + + return atMost(k) - atMost(k - 1) + } +} diff --git a/tests/501-1000/992. subarrays-with-k-different-integers/sol.py b/tests/501-1000/992. subarrays-with-k-different-integers/sol.py new file mode 100644 index 00000000..2fda9e4f --- /dev/null +++ b/tests/501-1000/992. subarrays-with-k-different-integers/sol.py @@ -0,0 +1,34 @@ +from typing import List + + +class Solution: + def subarraysWithKDistinct(self, nums: List[int], k: int) -> int: + + def atMost(k): + freq = dict() + count = 0 + left = 0 + n = len(nums) + + for right in range(n): + # Expand the window for right (dict) + freq[nums[right]] = freq.get(nums[right], 0) + 1 + + # When Condition Invalid (No. of Unique elements in subarray > k) + # Shrink window and reduce freq + while len(freq) > k: + # print(freq, nums[left], nums[right], count) + if freq[nums[left]] > 1: + freq[nums[left]] -= 1 + else: + del freq[nums[left]] + left += 1 + + # Cound the No. of Subarrays in a Valid Window + count += right - left + 1 + + return count + + # for eaxctly K answer + # Find K and K - 1, subtract + return atMost(k) - atMost(k - 1) diff --git a/tests/501-1000/992. subarrays-with-k-different-integers/sol.py2 b/tests/501-1000/992. subarrays-with-k-different-integers/sol.py2 new file mode 100644 index 00000000..5152a075 --- /dev/null +++ b/tests/501-1000/992. subarrays-with-k-different-integers/sol.py2 @@ -0,0 +1,28 @@ +class Solution(object): + def subarraysWithKDistinct(self, nums, k): + """ + :type nums: List[int] + :type k: int + :rtype: int + """ + def atMost(k): + freq = {} + count = 0 + left = 0 + n = len(nums) + + for right in range(n): + freq[nums[right]] = freq.get(nums[right], 0) + 1 + + while len(freq) > k: + if freq[nums[left]] > 1: + freq[nums[left]] -= 1 + else: + del freq[nums[left]] + left += 1 + + count += (right - left + 1) + + return count + + return atMost(k) - atMost(k - 1) diff --git a/tests/501-1000/992. subarrays-with-k-different-integers/sol.rb b/tests/501-1000/992. subarrays-with-k-different-integers/sol.rb new file mode 100644 index 00000000..643c593f --- /dev/null +++ b/tests/501-1000/992. subarrays-with-k-different-integers/sol.rb @@ -0,0 +1,30 @@ +# @param {Integer[]} nums +# @param {Integer} k +# @return {Integer} +def subarrays_with_k_distinct(nums, k) + at_most = lambda do |k| + freq = Hash.new(0) + count = 0 + left = 0 + n = nums.length + + (0...n).each do |right| + freq[nums[right]] += 1 + + while freq.length > k + if freq[nums[left]] > 1 + freq[nums[left]] -= 1 + else + freq.delete(nums[left]) + end + left += 1 + end + + count += (right - left + 1) + end + + count + end + + at_most.call(k) - at_most.call(k - 1) +end diff --git a/tests/501-1000/992. subarrays-with-k-different-integers/sol.rs b/tests/501-1000/992. subarrays-with-k-different-integers/sol.rs new file mode 100644 index 00000000..8cae95fa --- /dev/null +++ b/tests/501-1000/992. subarrays-with-k-different-integers/sol.rs @@ -0,0 +1,32 @@ +impl Solution { + pub fn subarrays_with_k_distinct(nums: Vec, k: i32) -> i32 { + fn at_most(nums: &Vec, k: i32) -> i32 { + use std::collections::HashMap; + let mut freq: HashMap = HashMap::new(); + let mut count = 0; + let mut left = 0; + let n = nums.len(); + let k = k as usize; + + for right in 0..n { + *freq.entry(nums[right]).or_insert(0) += 1; + + while freq.len() > k { + let val = freq.get_mut(&nums[left]).unwrap(); + if *val > 1 { + *val -= 1; + } else { + freq.remove(&nums[left]); + } + left += 1; + } + + count += (right - left + 1) as i32; + } + + count + } + + at_most(&nums, k) - at_most(&nums, k - 1) + } +} diff --git a/tests/501-1000/992. subarrays-with-k-different-integers/sol.swift b/tests/501-1000/992. subarrays-with-k-different-integers/sol.swift new file mode 100644 index 00000000..067e9cb9 --- /dev/null +++ b/tests/501-1000/992. subarrays-with-k-different-integers/sol.swift @@ -0,0 +1,29 @@ +class Solution { + func subarraysWithKDistinct(_ nums: [Int], _ k: Int) -> Int { + func atMost(_ k: Int) -> Int { + var freq = [Int: Int]() + var count = 0 + var left = 0 + let n = nums.count + + for right in 0.. k { + if freq[nums[left]]! > 1 { + freq[nums[left]]! -= 1 + } else { + freq.removeValue(forKey: nums[left]) + } + left += 1 + } + + count += (right - left + 1) + } + + return count + } + + return atMost(k) - atMost(k - 1) + } +} diff --git a/tests/501-1000/992. subarrays-with-k-different-integers/sol.ts b/tests/501-1000/992. subarrays-with-k-different-integers/sol.ts new file mode 100644 index 00000000..215b856b --- /dev/null +++ b/tests/501-1000/992. subarrays-with-k-different-integers/sol.ts @@ -0,0 +1,28 @@ +function subarraysWithKDistinct(nums: number[], k: number): number { + const atMost = (k: number): number => { + const freq = new Map(); + let count = 0; + let left = 0; + const n = nums.length; + + for (let right = 0; right < n; right++) { + freq.set(nums[right], (freq.get(nums[right]) || 0) + 1); + + while (freq.size > k) { + const val = freq.get(nums[left])!; + if (val > 1) { + freq.set(nums[left], val - 1); + } else { + freq.delete(nums[left]); + } + left++; + } + + count += right - left + 1; + } + + return count; + }; + + return atMost(k) - atMost(k - 1); +} diff --git a/tests/501-1000/993. cousins-in-binary-tree/manifest.yaml b/tests/501-1000/993. cousins-in-binary-tree/manifest.yaml new file mode 100644 index 00000000..fe94fc00 --- /dev/null +++ b/tests/501-1000/993. cousins-in-binary-tree/manifest.yaml @@ -0,0 +1,479 @@ +entry: + id: 993 + title: cousins-in-binary-tree + params: + root: + type: tree_node + x: + type: int + y: + type: int + call: + cpp: Solution().isCousins({root}, {x}, {y}) + rust: Solution::is_cousins({root}, {x}, {y}) + python3: Solution().isCousins({root}, {x}, {y}) + python2: Solution().isCousins({root}, {x}, {y}) + ruby: is_cousins({root}, {x}, {y}) + java: new Solution().isCousins({root}, {x}, {y}) + csharp: new Solution().IsCousins({root}, {x}, {y}) + kotlin: Solution().isCousins({root}, {x}, {y}) + go: isCousins({root}, {x}, {y}) + dart: Solution().isCousins({root}, {x}, {y}) + swift: Solution().isCousins({root}, {x}, {y}) + typescript: isCousins({root}, {x}, {y}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 993 +tests: + - name: case_1 + in: + root: + - 1 + - null + - 2 + x: 1 + y: 2 + out: false + - name: case_2 + in: + root: + - 1 + x: 1 + y: 1 + out: false + - name: case_3 + in: + root: + - 1 + - 2 + - 3 + - null + - 4 + - 5 + - 6 + - 7 + - 8 + - null + - 9 + x: 5 + y: 2 + out: false + - name: case_4 + in: + root: + - 1 + - null + - 2 + - 3 + - 4 + - null + - null + - 5 + - 6 + - 7 + - 8 + x: 1 + y: 2 + out: false + - name: case_5 + in: + root: + - 1 + - 2 + - 3 + - 4 + - 5 + - null + - null + - 6 + - 7 + - 8 + x: 4 + y: 5 + out: false + - name: case_6 + in: + root: + - 1 + - null + - 2 + - 3 + - 4 + - 5 + x: 5 + y: 3 + out: false + - name: case_7 + in: + root: + - 1 + - null + - null + - 2 + - 3 + - 4 + x: 3 + y: 4 + out: false + - name: case_8 + in: + root: + - 1 + - 2 + - 3 + - null + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - null + - 10 + x: 4 + y: 9 + out: false + - name: case_9 + in: + root: + - 1 + - 2 + - 3 + - 4 + x: 2 + y: 3 + out: false + - name: case_10 + in: + root: + - 1 + - 2 + - null + - null + - 3 + x: 2 + y: 1 + out: false + - name: case_11 + in: + root: + - 1 + - 2 + x: 2 + y: 1 + out: false + - name: case_12 + in: + root: + - 1 + - null + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + x: 4 + y: 5 + out: false + - name: case_13 + in: + root: + - 1 + - null + - 2 + - 3 + - 4 + - 5 + - 6 + x: 3 + y: 2 + out: false + - name: case_14 + in: + root: + - 1 + - 2 + x: 2 + y: 1 + out: false + - name: case_15 + in: + root: + - 1 + - null + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + x: 7 + y: 6 + out: true + - name: case_16 + in: + root: + - 1 + x: 1 + y: 1 + out: false + - name: case_17 + in: + root: + - 1 + - 2 + - null + - null + - null + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + x: 2 + y: 3 + out: false + - name: case_18 + in: + root: + - 1 + - 2 + x: 2 + y: 1 + out: false + - name: case_19 + in: + root: + - 1 + - null + - 2 + - 3 + x: 1 + y: 3 + out: false + - name: case_20 + in: + root: + - 1 + - null + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + x: 7 + y: 9 + out: false + - name: case_21 + in: + root: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + x: 4 + y: 3 + out: false + - name: case_22 + in: + root: + - 1 + - 2 + - null + - 3 + - null + - null + - 4 + - 5 + - 6 + x: 1 + y: 3 + out: false + - name: case_23 + in: + root: + - 1 + - null + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + x: 3 + y: 7 + out: false + - name: case_24 + in: + root: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + x: 3 + y: 9 + out: false + - name: case_25 + in: + root: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + x: 7 + y: 3 + out: false + - name: case_26 + in: + root: + - 1 + - 2 + - 3 + - 4 + - 5 + - null + - 6 + x: 6 + y: 4 + out: true + - name: case_27 + in: + root: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + x: 4 + y: 2 + out: false + - name: case_28 + in: + root: + - 1 + x: 1 + y: 1 + out: false + - name: case_29 + in: + root: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - null + - null + - 10 + x: 4 + y: 3 + out: false + - name: case_30 + in: + root: + - 1 + x: 1 + y: 1 + out: false + - name: case_31 + in: + root: + - 1 + - null + - 2 + - 3 + - 4 + - 5 + - 6 + - null + - 7 + - null + - 8 + - 9 + x: 7 + y: 5 + out: true + - name: case_32 + in: + root: + - 1 + - 2 + - null + - 3 + - 4 + - 5 + x: 1 + y: 4 + out: false + - name: case_33 + in: + root: + - 1 + - 2 + - null + - 3 + - 4 + - 5 + - 6 + - 7 + x: 1 + y: 7 + out: false + - name: case_34 + in: + root: + - 1 + x: 1 + y: 1 + out: false + - name: case_35 + in: + root: + - 1 + - 2 + - 3 + - 4 + - null + - null + - 5 + - 6 + x: 6 + y: 3 + out: false diff --git a/tests/501-1000/993. cousins-in-binary-tree/sol.cpp b/tests/501-1000/993. cousins-in-binary-tree/sol.cpp new file mode 100644 index 00000000..ef95af39 --- /dev/null +++ b/tests/501-1000/993. cousins-in-binary-tree/sol.cpp @@ -0,0 +1,33 @@ +/** + * Definition for a binary tree node. + * struct TreeNode { + * int val; + * TreeNode *left; + * TreeNode *right; + * TreeNode() : val(0), left(nullptr), right(nullptr) {} + * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} + * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} + * }; + */ +class Solution { +public: + bool isCousins(TreeNode* root, int x, int y) { + vector> res; + vector> stack; + stack.push_back({root, nullptr, 0}); + while (!stack.empty()) { + auto [curr, parent, depth] = stack.back(); + stack.pop_back(); + if (curr->val == x || curr->val == y) { + res.push_back({parent, depth}); + } + if (curr->left) { + stack.push_back({curr->left, curr, depth + 1}); + } + if (curr->right) { + stack.push_back({curr->right, curr, depth + 1}); + } + } + return res.size() == 2 && res[0].second == res[1].second && res[0].first != res[1].first; + } +}; diff --git a/tests/501-1000/993. cousins-in-binary-tree/sol.cs b/tests/501-1000/993. cousins-in-binary-tree/sol.cs new file mode 100644 index 00000000..2ec29ec4 --- /dev/null +++ b/tests/501-1000/993. cousins-in-binary-tree/sol.cs @@ -0,0 +1,33 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public int val; + * public TreeNode left; + * public TreeNode right; + * public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +public class Solution { + public bool IsCousins(TreeNode root, int x, int y) { + List<(TreeNode parent, int depth)> res = new List<(TreeNode, int)>(); + Stack<(TreeNode curr, TreeNode parent, int depth)> stack = new Stack<(TreeNode, TreeNode, int)>(); + stack.Push((root, null, 0)); + while (stack.Count > 0) { + var (curr, parent, depth) = stack.Pop(); + if (curr.val == x || curr.val == y) { + res.Add((parent, depth)); + } + if (curr.left != null) { + stack.Push((curr.left, curr, depth + 1)); + } + if (curr.right != null) { + stack.Push((curr.right, curr, depth + 1)); + } + } + return res.Count == 2 && res[0].depth == res[1].depth && res[0].parent != res[1].parent; + } +} diff --git a/tests/501-1000/993. cousins-in-binary-tree/sol.dart b/tests/501-1000/993. cousins-in-binary-tree/sol.dart new file mode 100644 index 00000000..7756bc9b --- /dev/null +++ b/tests/501-1000/993. cousins-in-binary-tree/sol.dart @@ -0,0 +1,32 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * int val; + * TreeNode? left; + * TreeNode? right; + * TreeNode([this.val = 0, this.left, this.right]); + * } + */ +class Solution { + bool isCousins(TreeNode? root, int x, int y) { + List> res = []; + List> stack = []; + stack.add([root, null, 0]); + while (stack.isNotEmpty) { + var cur = stack.removeLast(); + TreeNode? curr = cur[0] as TreeNode?; + TreeNode? parent = cur[1] as TreeNode?; + int depth = cur[2] as int; + if (curr!.val == x || curr.val == y) { + res.add([parent, depth]); + } + if (curr.left != null) { + stack.add([curr.left, curr, depth + 1]); + } + if (curr.right != null) { + stack.add([curr.right, curr, depth + 1]); + } + } + return res.length == 2 && res[0][1] == res[1][1] && res[0][0] != res[1][0]; + } +} diff --git a/tests/501-1000/993. cousins-in-binary-tree/sol.go b/tests/501-1000/993. cousins-in-binary-tree/sol.go new file mode 100644 index 00000000..98d0f9ce --- /dev/null +++ b/tests/501-1000/993. cousins-in-binary-tree/sol.go @@ -0,0 +1,31 @@ +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +func isCousins(root *TreeNode, x int, y int) bool { + type nodeInfo struct { + node *TreeNode + parent *TreeNode + depth int + } + var res []nodeInfo + stack := []nodeInfo{{root, nil, 0}} + for len(stack) > 0 { + curr := stack[len(stack)-1] + stack = stack[:len(stack)-1] + if curr.node.Val == x || curr.node.Val == y { + res = append(res, curr) + } + if curr.node.Left != nil { + stack = append(stack, nodeInfo{curr.node.Left, curr.node, curr.depth + 1}) + } + if curr.node.Right != nil { + stack = append(stack, nodeInfo{curr.node.Right, curr.node, curr.depth + 1}) + } + } + return len(res) == 2 && res[0].depth == res[1].depth && res[0].parent != res[1].parent +} diff --git a/tests/501-1000/993. cousins-in-binary-tree/sol.java b/tests/501-1000/993. cousins-in-binary-tree/sol.java new file mode 100644 index 00000000..c8ac1c6e --- /dev/null +++ b/tests/501-1000/993. cousins-in-binary-tree/sol.java @@ -0,0 +1,38 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode() {} + * TreeNode(int val) { this.val = val; } + * TreeNode(int val, TreeNode left, TreeNode right) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +class Solution { + public boolean isCousins(TreeNode root, int x, int y) { + List res = new ArrayList<>(); + Deque stack = new ArrayDeque<>(); + stack.push(new Object[]{root, null, 0}); + while (!stack.isEmpty()) { + Object[] cur = stack.pop(); + TreeNode curr = (TreeNode) cur[0]; + TreeNode parent = (TreeNode) cur[1]; + int depth = (int) cur[2]; + if (curr.val == x || curr.val == y) { + res.add(new int[]{parent != null ? parent.val : -1, depth}); + } + if (curr.left != null) { + stack.push(new Object[]{curr.left, curr, depth + 1}); + } + if (curr.right != null) { + stack.push(new Object[]{curr.right, curr, depth + 1}); + } + } + return res.size() == 2 && res.get(0)[1] == res.get(1)[1] && res.get(0)[0] != res.get(1)[0]; + } +} diff --git a/tests/501-1000/993. cousins-in-binary-tree/sol.kt b/tests/501-1000/993. cousins-in-binary-tree/sol.kt new file mode 100644 index 00000000..60b4059c --- /dev/null +++ b/tests/501-1000/993. cousins-in-binary-tree/sol.kt @@ -0,0 +1,30 @@ +/** + * Example: + * var ti = TreeNode(5) + * var v = ti.`val` + * Definition for a binary tree node. + * class TreeNode(var `val`: Int) { + * var left: TreeNode? = null + * var right: TreeNode? = null + * } + */ +class Solution { + fun isCousins(root: TreeNode?, x: Int, y: Int): Boolean { + val res = mutableListOf>() + val stack = ArrayDeque>() + stack.addLast(Triple(root, null, 0)) + while (stack.isNotEmpty()) { + val (curr, parent, depth) = stack.removeLast() + if (curr!!.`val` == x || curr.`val` == y) { + res.add(Pair(parent?.`val`, depth)) + } + if (curr.left != null) { + stack.addLast(Triple(curr.left, curr, depth + 1)) + } + if (curr.right != null) { + stack.addLast(Triple(curr.right, curr, depth + 1)) + } + } + return res.size == 2 && res[0].second == res[1].second && res[0].first != res[1].first + } +} diff --git a/tests/501-1000/993. cousins-in-binary-tree/sol.py b/tests/501-1000/993. cousins-in-binary-tree/sol.py new file mode 100644 index 00000000..a6a85acf --- /dev/null +++ b/tests/501-1000/993. cousins-in-binary-tree/sol.py @@ -0,0 +1,22 @@ +# Definition for a binary tree node. +# class TreeNode: +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +from typing import Optional + + +class Solution: + def isCousins(self, root: Optional[TreeNode], x: int, y: int) -> bool: + res = [] + stack = [(root, None, 0)] + while stack: + curr, parent, depth = stack.pop() + if curr.val == x or curr.val == y: + res.append((parent, depth)) + if curr.left: + stack.append((curr.left, curr, depth + 1)) + if curr.right: + stack.append((curr.right, curr, depth + 1)) + return len(res) == 2 and res[0][1] == res[1][1] and res[0][0] != res[1][0] diff --git a/tests/501-1000/993. cousins-in-binary-tree/sol.py2 b/tests/501-1000/993. cousins-in-binary-tree/sol.py2 new file mode 100644 index 00000000..0b994195 --- /dev/null +++ b/tests/501-1000/993. cousins-in-binary-tree/sol.py2 @@ -0,0 +1,25 @@ +# Definition for a binary tree node. +# class TreeNode(object): +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution(object): + def isCousins(self, root, x, y): + """ + :type root: Optional[TreeNode] + :type x: int + :type y: int + :rtype: bool + """ + res = [] + stack = [(root, None, 0)] + while stack: + curr, parent, depth = stack.pop() + if curr.val == x or curr.val == y: + res.append((parent, depth)) + if curr.left: + stack.append((curr.left, curr, depth + 1)) + if curr.right: + stack.append((curr.right, curr, depth + 1)) + return len(res) == 2 and res[0][1] == res[1][1] and res[0][0] != res[1][0] diff --git a/tests/501-1000/993. cousins-in-binary-tree/sol.rb b/tests/501-1000/993. cousins-in-binary-tree/sol.rb new file mode 100644 index 00000000..f53b224e --- /dev/null +++ b/tests/501-1000/993. cousins-in-binary-tree/sol.rb @@ -0,0 +1,30 @@ +# Definition for a binary tree node. +# class TreeNode +# attr_accessor :val, :left, :right +# def initialize(val = 0, left = nil, right = nil) +# @val = val +# @left = left +# @right = right +# end +# end +# @param {TreeNode} root +# @param {Integer} x +# @param {Integer} y +# @return {Boolean} +def is_cousins(root, x, y) + res = [] + stack = [[root, nil, 0]] + while stack.length > 0 + curr, parent, depth = stack.pop + if curr.val == x || curr.val == y + res << [parent, depth] + end + if curr.left + stack << [curr.left, curr, depth + 1] + end + if curr.right + stack << [curr.right, curr, depth + 1] + end + end + return res.length == 2 && res[0][1] == res[1][1] && res[0][0] != res[1][0] +end diff --git a/tests/501-1000/993. cousins-in-binary-tree/sol.rs b/tests/501-1000/993. cousins-in-binary-tree/sol.rs new file mode 100644 index 00000000..75dd4fac --- /dev/null +++ b/tests/501-1000/993. cousins-in-binary-tree/sol.rs @@ -0,0 +1,39 @@ +// Definition for a binary tree node. +// #[derive(Debug, PartialEq, Eq)] +// pub struct TreeNode { +// pub val: i32, +// pub left: Option>>, +// pub right: Option>>, +// } +// +// impl TreeNode { +// #[inline] +// pub fn new(val: i32) -> Self { +// TreeNode { +// val, +// left: None, +// right: None +// } +// } +// } +impl Solution { + pub fn is_cousins(root: Option>>, x: i32, y: i32) -> bool { + let mut res: Vec<(Option, i32)> = Vec::new(); + let mut stack: Vec<(Rc>, Option>>, i32)> = Vec::new(); + stack.push((root.unwrap(), None, 0)); + while let Some((curr_rc, parent, depth)) = stack.pop() { + let curr = curr_rc.borrow(); + if curr.val == x || curr.val == y { + let parent_val = parent.map(|p| p.borrow().val); + res.push((parent_val, depth)); + } + if let Some(left) = &curr.left { + stack.push((Rc::clone(left), Some(Rc::clone(&curr_rc)), depth + 1)); + } + if let Some(right) = &curr.right { + stack.push((Rc::clone(right), Some(Rc::clone(&curr_rc)), depth + 1)); + } + } + res.len() == 2 && res[0].1 == res[1].1 && res[0].0 != res[1].0 + } +} diff --git a/tests/501-1000/993. cousins-in-binary-tree/sol.swift b/tests/501-1000/993. cousins-in-binary-tree/sol.swift new file mode 100644 index 00000000..0a8d9d24 --- /dev/null +++ b/tests/501-1000/993. cousins-in-binary-tree/sol.swift @@ -0,0 +1,34 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public var val: Int + * public var left: TreeNode? + * public var right: TreeNode? + * public init() { self.val = 0; self.left = nil; self.right = nil; } + * public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; } + * public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) { + * self.val = val + * self.left = left + * self.right = right + * } + * } + */ +class Solution { + func isCousins(_ root: TreeNode?, _ x: Int, _ y: Int) -> Bool { + var res: [(parent: TreeNode?, depth: Int)] = [] + var stack: [(node: TreeNode, parent: TreeNode?, depth: Int)] = [(root!, nil, 0)] + while !stack.isEmpty { + let (curr, parent, depth) = stack.removeLast() + if curr.val == x || curr.val == y { + res.append((parent, depth)) + } + if let left = curr.left { + stack.append((left, curr, depth + 1)) + } + if let right = curr.right { + stack.append((right, curr, depth + 1)) + } + } + return res.count == 2 && res[0].depth == res[1].depth && res[0].parent?.val != res[1].parent?.val + } +} diff --git a/tests/501-1000/993. cousins-in-binary-tree/sol.ts b/tests/501-1000/993. cousins-in-binary-tree/sol.ts new file mode 100644 index 00000000..d5474b2d --- /dev/null +++ b/tests/501-1000/993. cousins-in-binary-tree/sol.ts @@ -0,0 +1,31 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ + +function isCousins(root: TreeNode | null, x: number, y: number): boolean { + const res: [TreeNode | null, number][] = []; + const stack: [TreeNode, TreeNode | null, number][] = [[root!, null, 0]]; + while (stack.length > 0) { + const [curr, parent, depth] = stack.pop()!; + if (curr.val === x || curr.val === y) { + res.push([parent, depth]); + } + if (curr.left) { + stack.push([curr.left, curr, depth + 1]); + } + if (curr.right) { + stack.push([curr.right, curr, depth + 1]); + } + } + return res.length === 2 && res[0][1] === res[1][1] && res[0][0] !== res[1][0]; +} diff --git a/tests/501-1000/994. rotting-oranges/manifest.yaml b/tests/501-1000/994. rotting-oranges/manifest.yaml new file mode 100644 index 00000000..bc2f4aa3 --- /dev/null +++ b/tests/501-1000/994. rotting-oranges/manifest.yaml @@ -0,0 +1,379 @@ +entry: + id: 994 + title: rotting-oranges + params: + grid: + type: array + items: + type: array + items: + type: int + call: + cpp: Solution().orangesRotting({grid}) + rust: Solution::oranges_rotting({grid}) + python3: Solution().orangesRotting({grid}) + python2: Solution().orangesRotting({grid}) + ruby: oranges_rotting({grid}) + java: new Solution().orangesRotting({grid}) + csharp: new Solution().OrangesRotting({grid}) + kotlin: Solution().orangesRotting({grid}) + go: orangesRotting({grid}) + dart: Solution().orangesRotting({grid}) + swift: Solution().orangesRotting({grid}) + typescript: orangesRotting({grid}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 994 +tests: + - name: case_1 + in: + grid: + - - 0 + - - 0 + - - 1 + - - 2 + out: 1 + - name: case_2 + in: + grid: + - - 1 + - 0 + - 0 + - - 1 + - 2 + - 2 + out: 2 + - name: case_3 + in: + grid: + - - 0 + - 1 + - 0 + - 1 + - - 1 + - 2 + - 0 + - 0 + - - 0 + - 1 + - 0 + - 0 + out: -1 + - name: case_4 + in: + grid: + - - 1 + - 1 + out: -1 + - name: case_5 + in: + grid: + - - 2 + - 0 + out: 0 + - name: case_6 + in: + grid: + - - 2 + - - 0 + out: 0 + - name: case_7 + in: + grid: + - - 1 + - 0 + - - 2 + - 1 + - - 1 + - 1 + out: 2 + - name: case_8 + in: + grid: + - - 0 + - 2 + - 1 + out: 1 + - name: case_9 + in: + grid: + - - 1 + - 1 + - 1 + - 1 + out: -1 + - name: case_10 + in: + grid: + - - 2 + - - 1 + - - 0 + out: 1 + - name: case_11 + in: + grid: + - - 0 + - 1 + - - 2 + - 1 + - - 1 + - 0 + - - 0 + - 1 + out: -1 + - name: case_12 + in: + grid: + - - 0 + - 1 + - 1 + - - 0 + - 0 + - 2 + - - 2 + - 1 + - 0 + out: 2 + - name: case_13 + in: + grid: + - - 2 + - 1 + - - 2 + - 0 + - - 2 + - 2 + - - 0 + - 0 + out: 1 + - name: case_14 + in: + grid: + - - 2 + - 2 + - 2 + out: 0 + - name: case_15 + in: + grid: + - - 2 + out: 0 + - name: case_16 + in: + grid: + - - 1 + - 2 + - 2 + - - 2 + - 2 + - 2 + - - 0 + - 1 + - 2 + - - 2 + - 2 + - 0 + out: 1 + - name: case_17 + in: + grid: + - - 2 + - 2 + - - 2 + - 0 + out: 0 + - name: case_18 + in: + grid: + - - 1 + - 1 + - 0 + - - 1 + - 0 + - 1 + out: -1 + - name: case_19 + in: + grid: + - - 2 + - - 0 + out: 0 + - name: case_20 + in: + grid: + - - 2 + - 0 + - 0 + out: 0 + - name: case_21 + in: + grid: + - - 1 + out: -1 + - name: case_22 + in: + grid: + - - 0 + - 2 + - 0 + - 1 + - - 1 + - 2 + - 2 + - 1 + out: 2 + - name: case_23 + in: + grid: + - - 1 + - 0 + - - 1 + - 2 + - - 1 + - 1 + - - 0 + - 0 + out: 2 + - name: case_24 + in: + grid: + - - 2 + - 2 + - - 1 + - 0 + out: 1 + - name: case_25 + in: + grid: + - - 2 + out: 0 + - name: case_26 + in: + grid: + - - 0 + - 1 + - 2 + - - 1 + - 1 + - 2 + - - 0 + - 2 + - 1 + - - 1 + - 2 + - 2 + out: 2 + - name: case_27 + in: + grid: + - - 1 + - 1 + - 1 + - - 0 + - 0 + - 1 + - - 0 + - 0 + - 0 + out: -1 + - name: case_28 + in: + grid: + - - 1 + - 1 + - 2 + - 1 + - - 0 + - 0 + - 1 + - 2 + - - 1 + - 2 + - 2 + - 0 + - - 0 + - 0 + - 1 + - 2 + out: 2 + - name: case_29 + in: + grid: + - - 2 + - - 1 + out: 1 + - name: case_30 + in: + grid: + - - 0 + - 2 + - 0 + - - 0 + - 0 + - 0 + - - 0 + - 1 + - 1 + - - 1 + - 0 + - 1 + out: -1 + - name: case_31 + in: + grid: + - - 2 + - 0 + - 2 + - - 2 + - 2 + - 2 + - - 0 + - 1 + - 0 + out: 1 + - name: case_32 + in: + grid: + - - 0 + - 1 + - - 0 + - 2 + out: 1 + - name: case_33 + in: + grid: + - - 2 + - 2 + - 0 + - - 0 + - 2 + - 0 + - - 1 + - 1 + - 1 + out: 2 + - name: case_34 + in: + grid: + - - 0 + - 1 + - 0 + - 2 + - - 1 + - 0 + - 2 + - 2 + out: -1 + - name: case_35 + in: + grid: + - - 2 + - - 0 + out: 0 diff --git a/tests/501-1000/994. rotting-oranges/sol.cpp b/tests/501-1000/994. rotting-oranges/sol.cpp new file mode 100644 index 00000000..4a35ac05 --- /dev/null +++ b/tests/501-1000/994. rotting-oranges/sol.cpp @@ -0,0 +1,37 @@ +class Solution { +public: + int orangesRotting(vector>& grid) { + int n = grid.size(), m = grid[0].size(); + queue> q; + int fresh = 0; + + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + if (grid[i][j] == 2) { + q.push({i, j, 0}); + } else if (grid[i][j] == 1) { + fresh++; + } + } + } + + vector> directions = {{-1,0},{1,0},{0,-1},{0,1}}; + int maxTime = 0, rotten = 0; + + while (!q.empty()) { + auto [r, c, t] = q.front(); q.pop(); + if (t > maxTime) maxTime = t; + + for (auto [dr, dc] : directions) { + int nr = r + dr, nc = c + dc; + if (nr >= 0 && nr < n && nc >= 0 && nc < m && grid[nr][nc] == 1) { + grid[nr][nc] = 2; + q.push({nr, nc, t + 1}); + rotten++; + } + } + } + + return rotten == fresh ? maxTime : -1; + } +}; diff --git a/tests/501-1000/994. rotting-oranges/sol.cs b/tests/501-1000/994. rotting-oranges/sol.cs new file mode 100644 index 00000000..70794830 --- /dev/null +++ b/tests/501-1000/994. rotting-oranges/sol.cs @@ -0,0 +1,36 @@ +public class Solution { + public int OrangesRotting(int[][] grid) { + int n = grid.Length, m = grid[0].Length; + Queue<(int, int, int)> q = new Queue<(int, int, int)>(); + int fresh = 0; + + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + if (grid[i][j] == 2) { + q.Enqueue((i, j, 0)); + } else if (grid[i][j] == 1) { + fresh++; + } + } + } + + (int, int)[] directions = {(-1,0),(1,0),(0,-1),(0,1)}; + int maxTime = 0, rotten = 0; + + while (q.Count > 0) { + var (r, c, t) = q.Dequeue(); + if (t > maxTime) maxTime = t; + + foreach (var (dr, dc) in directions) { + int nr = r + dr, nc = c + dc; + if (nr >= 0 && nr < n && nc >= 0 && nc < m && grid[nr][nc] == 1) { + grid[nr][nc] = 2; + q.Enqueue((nr, nc, t + 1)); + rotten++; + } + } + } + + return rotten == fresh ? maxTime : -1; + } +} diff --git a/tests/501-1000/994. rotting-oranges/sol.dart b/tests/501-1000/994. rotting-oranges/sol.dart new file mode 100644 index 00000000..86bfb88c --- /dev/null +++ b/tests/501-1000/994. rotting-oranges/sol.dart @@ -0,0 +1,37 @@ +class Solution { + int orangesRotting(List> grid) { + int n = grid.length, m = grid[0].length; + List> q = []; + int fresh = 0; + + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + if (grid[i][j] == 2) { + q.add([i, j, 0]); + } else if (grid[i][j] == 1) { + fresh++; + } + } + } + + List> directions = [[-1,0],[1,0],[0,-1],[0,1]]; + int maxTime = 0, rotten = 0; + + while (q.isNotEmpty) { + var cur = q.removeAt(0); + int r = cur[0], c = cur[1], t = cur[2]; + if (t > maxTime) maxTime = t; + + for (var dir in directions) { + int nr = r + dir[0], nc = c + dir[1]; + if (nr >= 0 && nr < n && nc >= 0 && nc < m && grid[nr][nc] == 1) { + grid[nr][nc] = 2; + q.add([nr, nc, t + 1]); + rotten++; + } + } + } + + return rotten == fresh ? maxTime : -1; + } +} diff --git a/tests/501-1000/994. rotting-oranges/sol.go b/tests/501-1000/994. rotting-oranges/sol.go new file mode 100644 index 00000000..f2f6b9e3 --- /dev/null +++ b/tests/501-1000/994. rotting-oranges/sol.go @@ -0,0 +1,44 @@ +func orangesRotting(grid [][]int) int { + n, m := len(grid), len(grid[0]) + type node struct { + r, c, t int + } + q := []node{} + fresh := 0 + + for i := 0; i < n; i++ { + for j := 0; j < m; j++ { + if grid[i][j] == 2 { + q = append(q, node{i, j, 0}) + } else if grid[i][j] == 1 { + fresh++ + } + } + } + + directions := [][2]int{{-1,0},{1,0},{0,-1},{0,1}} + maxTime, rotten := 0, 0 + + for len(q) > 0 { + cur := q[0] + q = q[1:] + r, c, t := cur.r, cur.c, cur.t + if t > maxTime { + maxTime = t + } + + for _, dir := range directions { + nr, nc := r+dir[0], c+dir[1] + if nr >= 0 && nr < n && nc >= 0 && nc < m && grid[nr][nc] == 1 { + grid[nr][nc] = 2 + q = append(q, node{nr, nc, t+1}) + rotten++ + } + } + } + + if rotten == fresh { + return maxTime + } + return -1 +} diff --git a/tests/501-1000/994. rotting-oranges/sol.java b/tests/501-1000/994. rotting-oranges/sol.java new file mode 100644 index 00000000..40dd7f4c --- /dev/null +++ b/tests/501-1000/994. rotting-oranges/sol.java @@ -0,0 +1,37 @@ +class Solution { + public int orangesRotting(int[][] grid) { + int n = grid.length, m = grid[0].length; + Queue q = new LinkedList<>(); + int fresh = 0; + + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + if (grid[i][j] == 2) { + q.offer(new int[]{i, j, 0}); + } else if (grid[i][j] == 1) { + fresh++; + } + } + } + + int[][] directions = {{-1,0},{1,0},{0,-1},{0,1}}; + int maxTime = 0, rotten = 0; + + while (!q.isEmpty()) { + int[] cur = q.poll(); + int r = cur[0], c = cur[1], t = cur[2]; + maxTime = Math.max(maxTime, t); + + for (int[] dir : directions) { + int nr = r + dir[0], nc = c + dir[1]; + if (nr >= 0 && nr < n && nc >= 0 && nc < m && grid[nr][nc] == 1) { + grid[nr][nc] = 2; + q.offer(new int[]{nr, nc, t + 1}); + rotten++; + } + } + } + + return rotten == fresh ? maxTime : -1; + } +} diff --git a/tests/501-1000/994. rotting-oranges/sol.kt b/tests/501-1000/994. rotting-oranges/sol.kt new file mode 100644 index 00000000..efaaea40 --- /dev/null +++ b/tests/501-1000/994. rotting-oranges/sol.kt @@ -0,0 +1,39 @@ +class Solution { + fun orangesRotting(grid: Array): Int { + val n = grid.size + val m = grid[0].size + val q: ArrayDeque> = ArrayDeque() + var fresh = 0 + + for (i in 0 until n) { + for (j in 0 until m) { + if (grid[i][j] == 2) { + q.addLast(Triple(i, j, 0)) + } else if (grid[i][j] == 1) { + fresh++ + } + } + } + + val directions = arrayOf(-1 to 0, 1 to 0, 0 to -1, 0 to 1) + var maxTime = 0 + var rotten = 0 + + while (q.isNotEmpty()) { + val (r, c, t) = q.removeFirst() + if (t > maxTime) maxTime = t + + for ((dr, dc) in directions) { + val nr = r + dr + val nc = c + dc + if (nr in 0 until n && nc in 0 until m && grid[nr][nc] == 1) { + grid[nr][nc] = 2 + q.addLast(Triple(nr, nc, t + 1)) + rotten++ + } + } + } + + return if (rotten == fresh) maxTime else -1 + } +} diff --git a/tests/501-1000/994. rotting-oranges/sol.py b/tests/501-1000/994. rotting-oranges/sol.py new file mode 100644 index 00000000..41984cbe --- /dev/null +++ b/tests/501-1000/994. rotting-oranges/sol.py @@ -0,0 +1,35 @@ +from collections import deque +from typing import List + + +class Solution: + def orangesRotting(self, grid): + n, m = len(grid), len(grid[0]) + q = deque() + fresh = 0 + + # 1. Add rotten oranges & count fresh + for i in range(n): + for j in range(m): + if grid[i][j] == 2: + q.append((i, j, 0)) + if grid[i][j] == 1: + fresh += 1 + + directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] + max_time, rotten = 0, 0 + + # 2. BFS + while q: + r, c, t = q.popleft() + max_time = max(max_time, t) + + for dr, dc in directions: + nr, nc = r + dr, c + dc + if 0 <= nr < n and 0 <= nc < m and grid[nr][nc] == 1: + grid[nr][nc] = 2 + q.append((nr, nc, t + 1)) + rotten += 1 + + # 3. Check if all fresh rotted + return max_time if rotten == fresh else -1 diff --git a/tests/501-1000/994. rotting-oranges/sol.py2 b/tests/501-1000/994. rotting-oranges/sol.py2 new file mode 100644 index 00000000..7f6d1a4d --- /dev/null +++ b/tests/501-1000/994. rotting-oranges/sol.py2 @@ -0,0 +1,32 @@ +class Solution(object): + def orangesRotting(self, grid): + """ + :type grid: List[List[int]] + :rtype: int + """ + n, m = len(grid), len(grid[0]) + q = [] + fresh = 0 + + for i in range(n): + for j in range(m): + if grid[i][j] == 2: + q.append((i, j, 0)) + if grid[i][j] == 1: + fresh += 1 + + directions = [(-1,0),(1,0),(0,-1),(0,1)] + max_time, rotten = 0, 0 + + while q: + r, c, t = q.pop(0) + max_time = max(max_time, t) + + for dr, dc in directions: + nr, nc = r + dr, c + dc + if 0 <= nr < n and 0 <= nc < m and grid[nr][nc] == 1: + grid[nr][nc] = 2 + q.append((nr, nc, t+1)) + rotten += 1 + + return max_time if rotten == fresh else -1 diff --git a/tests/501-1000/994. rotting-oranges/sol.rb b/tests/501-1000/994. rotting-oranges/sol.rb new file mode 100644 index 00000000..12f0d823 --- /dev/null +++ b/tests/501-1000/994. rotting-oranges/sol.rb @@ -0,0 +1,37 @@ +# @param {Integer[][]} grid +# @return {Integer} +def oranges_rotting(grid) + n, m = grid.length, grid[0].length + q = [] + fresh = 0 + + (0...n).each do |i| + (0...m).each do |j| + if grid[i][j] == 2 + q << [i, j, 0] + elsif grid[i][j] == 1 + fresh += 1 + end + end + end + + directions = [[-1,0],[1,0],[0,-1],[0,1]] + max_time = 0 + rotten = 0 + + while !q.empty? + r, c, t = q.shift + max_time = t if t > max_time + + directions.each do |dr, dc| + nr, nc = r + dr, c + dc + if nr >= 0 && nr < n && nc >= 0 && nc < m && grid[nr][nc] == 1 + grid[nr][nc] = 2 + q << [nr, nc, t+1] + rotten += 1 + end + end + end + + rotten == fresh ? max_time : -1 +end diff --git a/tests/501-1000/994. rotting-oranges/sol.rs b/tests/501-1000/994. rotting-oranges/sol.rs new file mode 100644 index 00000000..408b8e47 --- /dev/null +++ b/tests/501-1000/994. rotting-oranges/sol.rs @@ -0,0 +1,43 @@ +impl Solution { + pub fn oranges_rotting(grid: Vec>) -> i32 { + let mut grid = grid; + let n = grid.len(); + let m = grid[0].len(); + use std::collections::VecDeque; + let mut q: VecDeque<(usize, usize, i32)> = VecDeque::new(); + let mut fresh = 0; + + for i in 0..n { + for j in 0..m { + if grid[i][j] == 2 { + q.push_back((i, j, 0)); + } else if grid[i][j] == 1 { + fresh += 1; + } + } + } + + let directions = [(-1,0),(1,0),(0,-1),(0,1)]; + let mut max_time = 0; + let mut rotten = 0; + + while let Some((r, c, t)) = q.pop_front() { + if t > max_time { max_time = t; } + + for (dr, dc) in directions.iter() { + let nr = r as i32 + dr; + let nc = c as i32 + dc; + if nr >= 0 && nr < n as i32 && nc >= 0 && nc < m as i32 { + let (nr, nc) = (nr as usize, nc as usize); + if grid[nr][nc] == 1 { + grid[nr][nc] = 2; + q.push_back((nr, nc, t + 1)); + rotten += 1; + } + } + } + } + + if rotten == fresh { max_time } else { -1 } + } +} diff --git a/tests/501-1000/994. rotting-oranges/sol.swift b/tests/501-1000/994. rotting-oranges/sol.swift new file mode 100644 index 00000000..582010c0 --- /dev/null +++ b/tests/501-1000/994. rotting-oranges/sol.swift @@ -0,0 +1,37 @@ +class Solution { + func orangesRotting(_ grid: [[Int]]) -> Int { + let n = grid.count, m = grid[0].count + var grid = grid + var q: [(Int, Int, Int)] = [] + var fresh = 0 + + for i in 0.. maxTime { maxTime = t } + + for (dr, dc) in directions { + let nr = r + dr, nc = c + dc + if nr >= 0 && nr < n && nc >= 0 && nc < m && grid[nr][nc] == 1 { + grid[nr][nc] = 2 + q.append((nr, nc, t + 1)) + rotten += 1 + } + } + } + + return rotten == fresh ? maxTime : -1 + } +} diff --git a/tests/501-1000/994. rotting-oranges/sol.ts b/tests/501-1000/994. rotting-oranges/sol.ts new file mode 100644 index 00000000..48da676f --- /dev/null +++ b/tests/501-1000/994. rotting-oranges/sol.ts @@ -0,0 +1,42 @@ +function orangesRotting(grid: number[][]): number { + const n = grid.length, + m = grid[0].length; + const q: [number, number, number][] = []; + let fresh = 0; + + for (let i = 0; i < n; i++) { + for (let j = 0; j < m; j++) { + if (grid[i][j] === 2) { + q.push([i, j, 0]); + } else if (grid[i][j] === 1) { + fresh++; + } + } + } + + const directions = [ + [-1, 0], + [1, 0], + [0, -1], + [0, 1], + ]; + let maxTime = 0, + rotten = 0; + + while (q.length > 0) { + const [r, c, t] = q.shift()!; + if (t > maxTime) maxTime = t; + + for (const [dr, dc] of directions) { + const nr = r + dr, + nc = c + dc; + if (nr >= 0 && nr < n && nc >= 0 && nc < m && grid[nr][nc] === 1) { + grid[nr][nc] = 2; + q.push([nr, nc, t + 1]); + rotten++; + } + } + } + + return rotten === fresh ? maxTime : -1; +} diff --git a/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/manifest.yaml b/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/manifest.yaml new file mode 100644 index 00000000..d2b8b617 --- /dev/null +++ b/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/manifest.yaml @@ -0,0 +1,393 @@ +entry: + id: 995 + title: minimum-number-of-k-consecutive-bit-flips + params: + nums: + type: array + items: + type: int + k: + type: int + call: + cpp: Solution().minKBitFlips({nums}, {k}) + rust: Solution::min_k_bit_flips({nums}, {k}) + python3: Solution().minKBitFlips({nums}, {k}) + python2: Solution().minKBitFlips({nums}, {k}) + ruby: min_k_bit_flips({nums}, {k}) + java: new Solution().minKBitFlips({nums}, {k}) + csharp: new Solution().MinKBitFlips({nums}, {k}) + kotlin: Solution().minKBitFlips({nums}, {k}) + go: minKBitFlips({nums}, {k}) + dart: Solution().minKBitFlips({nums}, {k}) + swift: Solution().minKBitFlips({nums}, {k}) + typescript: minKBitFlips({nums}, {k}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 995 +tests: + - name: case_1 + in: + nums: + - 0 + - 1 + k: 2 + out: -1 + - name: case_2 + in: + nums: + - 0 + - 1 + k: 1 + out: 1 + - name: case_3 + in: + nums: + - 0 + - 1 + - 0 + - 1 + - 0 + - 0 + - 1 + - 0 + - 0 + k: 9 + out: -1 + - name: case_4 + in: + nums: + - 1 + - 1 + - 1 + k: 2 + out: 0 + - name: case_5 + in: + nums: + - 1 + - 0 + - 0 + - 1 + - 1 + - 1 + - 1 + - 1 + k: 8 + out: -1 + - name: case_6 + in: + nums: + - 0 + - 1 + k: 1 + out: 1 + - name: case_7 + in: + nums: + - 1 + - 0 + - 0 + - 0 + - 0 + - 1 + k: 5 + out: -1 + - name: case_8 + in: + nums: + - 0 + - 0 + - 0 + - 0 + - 0 + k: 1 + out: 5 + - name: case_9 + in: + nums: + - 1 + k: 1 + out: 0 + - name: case_10 + in: + nums: + - 0 + - 1 + - 0 + k: 2 + out: 2 + - name: case_11 + in: + nums: + - 1 + k: 1 + out: 0 + - name: case_12 + in: + nums: + - 0 + - 0 + - 0 + - 0 + - 1 + - 0 + - 1 + - 0 + k: 1 + out: 6 + - name: case_13 + in: + nums: + - 1 + - 0 + - 0 + - 0 + - 1 + - 0 + - 0 + k: 4 + out: -1 + - name: case_14 + in: + nums: + - 0 + - 0 + - 0 + - 1 + k: 1 + out: 3 + - name: case_15 + in: + nums: + - 0 + - 1 + - 1 + - 1 + - 0 + - 1 + - 1 + - 1 + k: 1 + out: 2 + - name: case_16 + in: + nums: + - 0 + - 0 + - 0 + - 1 + - 0 + - 1 + - 0 + k: 4 + out: -1 + - name: case_17 + in: + nums: + - 0 + - 1 + k: 2 + out: -1 + - name: case_18 + in: + nums: + - 1 + - 0 + - 1 + - 0 + - 1 + - 0 + - 0 + k: 2 + out: 3 + - name: case_19 + in: + nums: + - 0 + - 1 + - 1 + - 1 + - 0 + - 1 + - 0 + - 0 + k: 3 + out: 4 + - name: case_20 + in: + nums: + - 0 + - 0 + - 1 + - 1 + k: 1 + out: 2 + - name: case_21 + in: + nums: + - 1 + - 0 + - 1 + - 1 + - 1 + - 0 + - 0 + - 1 + - 1 + - 1 + k: 2 + out: -1 + - name: case_22 + in: + nums: + - 1 + - 0 + - 0 + - 1 + - 0 + - 0 + - 1 + - 0 + - 1 + - 1 + k: 8 + out: -1 + - name: case_23 + in: + nums: + - 1 + - 0 + - 0 + - 0 + k: 2 + out: -1 + - name: case_24 + in: + nums: + - 1 + - 1 + - 0 + k: 1 + out: 1 + - name: case_25 + in: + nums: + - 0 + - 0 + - 1 + - 0 + - 1 + - 1 + - 0 + - 0 + - 1 + k: 4 + out: -1 + - name: case_26 + in: + nums: + - 1 + - 1 + k: 2 + out: 0 + - name: case_27 + in: + nums: + - 1 + - 1 + - 1 + - 0 + - 0 + - 0 + k: 3 + out: 1 + - name: case_28 + in: + nums: + - 1 + - 1 + - 1 + - 0 + - 0 + - 0 + - 1 + - 1 + k: 1 + out: 3 + - name: case_29 + in: + nums: + - 0 + k: 1 + out: 1 + - name: case_30 + in: + nums: + - 1 + - 1 + - 1 + k: 2 + out: 0 + - name: case_31 + in: + nums: + - 0 + - 1 + k: 2 + out: -1 + - name: case_32 + in: + nums: + - 1 + - 0 + - 0 + - 0 + - 0 + - 0 + - 1 + - 1 + - 0 + k: 7 + out: -1 + - name: case_33 + in: + nums: + - 0 + - 1 + - 1 + - 1 + - 1 + k: 3 + out: -1 + - name: case_34 + in: + nums: + - 0 + - 0 + - 1 + - 0 + - 0 + - 0 + k: 5 + out: -1 + - name: case_35 + in: + nums: + - 1 + - 1 + - 0 + - 1 + - 0 + - 0 + - 0 + - 1 + - 0 + k: 5 + out: 3 diff --git a/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.cpp b/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.cpp new file mode 100644 index 00000000..fab56476 --- /dev/null +++ b/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.cpp @@ -0,0 +1,27 @@ +class Solution { +public: + int minKBitFlips(vector& nums, int k) { + int n = nums.size(); + int ans = 0; + int flips = 0; + vector flipped(n + 1, 0); + + for (int i = 0; i <= n - k; i++) { + flips += flipped[i]; + if ((nums[i] == 0 && flips % 2 == 0) || (nums[i] == 1 && flips % 2 != 0)) { + flips++; + ans++; + flipped[i + k]--; + } + } + + for (int i = n - k + 1; i < n; i++) { + flips += flipped[i]; + if ((nums[i] == 0 && flips % 2 == 0) || (nums[i] == 1 && flips % 2 != 0)) { + return -1; + } + } + + return ans; + } +}; diff --git a/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.cs b/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.cs new file mode 100644 index 00000000..1e21cabd --- /dev/null +++ b/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.cs @@ -0,0 +1,26 @@ +public class Solution { + public int MinKBitFlips(int[] nums, int k) { + int n = nums.Length; + int ans = 0; + int flips = 0; + int[] flipped = new int[n + 1]; + + for (int i = 0; i <= n - k; i++) { + flips += flipped[i]; + if ((nums[i] == 0 && flips % 2 == 0) || (nums[i] == 1 && flips % 2 != 0)) { + flips++; + ans++; + flipped[i + k]--; + } + } + + for (int i = n - k + 1; i < n; i++) { + flips += flipped[i]; + if ((nums[i] == 0 && flips % 2 == 0) || (nums[i] == 1 && flips % 2 != 0)) { + return -1; + } + } + + return ans; + } +} diff --git a/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.dart b/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.dart new file mode 100644 index 00000000..28ec82e1 --- /dev/null +++ b/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.dart @@ -0,0 +1,26 @@ +class Solution { + int minKBitFlips(List nums, int k) { + int n = nums.length; + int ans = 0; + int flips = 0; + List flipped = List.filled(n + 1, 0); + + for (int i = 0; i <= n - k; i++) { + flips += flipped[i]; + if ((nums[i] == 0 && flips % 2 == 0) || (nums[i] == 1 && flips % 2 != 0)) { + flips++; + ans++; + flipped[i + k]--; + } + } + + for (int i = n - k + 1; i < n; i++) { + flips += flipped[i]; + if ((nums[i] == 0 && flips % 2 == 0) || (nums[i] == 1 && flips % 2 != 0)) { + return -1; + } + } + + return ans; + } +} diff --git a/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.go b/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.go new file mode 100644 index 00000000..7d4897ef --- /dev/null +++ b/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.go @@ -0,0 +1,24 @@ +func minKBitFlips(nums []int, k int) int { + n := len(nums) + ans := 0 + flips := 0 + flipped := make([]int, n+1) + + for i := 0; i <= n-k; i++ { + flips += flipped[i] + if (nums[i] == 0 && flips%2 == 0) || (nums[i] == 1 && flips%2 != 0) { + flips++ + ans++ + flipped[i+k]-- + } + } + + for i := n - k + 1; i < n; i++ { + flips += flipped[i] + if (nums[i] == 0 && flips%2 == 0) || (nums[i] == 1 && flips%2 != 0) { + return -1 + } + } + + return ans +} diff --git a/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.java b/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.java new file mode 100644 index 00000000..c9bd1504 --- /dev/null +++ b/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.java @@ -0,0 +1,26 @@ +class Solution { + public int minKBitFlips(int[] nums, int k) { + int n = nums.length; + int ans = 0; + int flips = 0; + int[] flipped = new int[n + 1]; + + for (int i = 0; i <= n - k; i++) { + flips += flipped[i]; + if ((nums[i] == 0 && flips % 2 == 0) || (nums[i] == 1 && flips % 2 != 0)) { + flips++; + ans++; + flipped[i + k]--; + } + } + + for (int i = n - k + 1; i < n; i++) { + flips += flipped[i]; + if ((nums[i] == 0 && flips % 2 == 0) || (nums[i] == 1 && flips % 2 != 0)) { + return -1; + } + } + + return ans; + } +} diff --git a/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.kt b/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.kt new file mode 100644 index 00000000..9ef1955d --- /dev/null +++ b/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.kt @@ -0,0 +1,26 @@ +class Solution { + fun minKBitFlips(nums: IntArray, k: Int): Int { + val n = nums.size + var ans = 0 + var flips = 0 + val flipped = IntArray(n + 1) + + for (i in 0..n - k) { + flips += flipped[i] + if ((nums[i] == 0 && flips % 2 == 0) || (nums[i] == 1 && flips % 2 != 0)) { + flips++ + ans++ + flipped[i + k]-- + } + } + + for (i in n - k + 1 until n) { + flips += flipped[i] + if ((nums[i] == 0 && flips % 2 == 0) || (nums[i] == 1 && flips % 2 != 0)) { + return -1 + } + } + + return ans + } +} diff --git a/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.py b/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.py new file mode 100644 index 00000000..0b1b1ad8 --- /dev/null +++ b/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.py @@ -0,0 +1,23 @@ +from typing import List + + +class Solution: + def minKBitFlips(self, nums, k): + n = len(nums) + ans = 0 + flips = 0 + flipped = [0] * (n + 1) + + for i in range(n - k + 1): + flips += flipped[i] + if (nums[i] == 0 and flips % 2 == 0) or (nums[i] == 1 and flips % 2 != 0): + flips += 1 + ans += 1 + flipped[i + k] -= 1 + + for i in range(n - k + 1, n): + flips += flipped[i] + if (nums[i] == 0 and flips % 2 == 0) or (nums[i] == 1 and flips % 2 != 0): + return -1 + + return ans diff --git a/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.py2 b/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.py2 new file mode 100644 index 00000000..543fe306 --- /dev/null +++ b/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.py2 @@ -0,0 +1,25 @@ +class Solution(object): + def minKBitFlips(self, nums, k): + """ + :type nums: List[int] + :type k: int + :rtype: int + """ + n = len(nums) + ans = 0 + flips = 0 + flipped = [0] * (n + 1) + + for i in range(n - k + 1): + flips += flipped[i] + if (nums[i] == 0 and flips % 2 == 0) or (nums[i] == 1 and flips % 2 != 0): + flips += 1 + ans += 1 + flipped[i + k] -= 1 + + for i in range(n - k + 1, n): + flips += flipped[i] + if (nums[i] == 0 and flips % 2 == 0) or (nums[i] == 1 and flips % 2 != 0): + return -1 + + return ans diff --git a/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.rb b/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.rb new file mode 100644 index 00000000..bd4ee060 --- /dev/null +++ b/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.rb @@ -0,0 +1,27 @@ +# @param {Integer[]} nums +# @param {Integer} k +# @return {Integer} +def min_k_bit_flips(nums, k) + n = nums.length + ans = 0 + flips = 0 + flipped = Array.new(n + 1, 0) + + (0...n - k + 1).each do |i| + flips += flipped[i] + if (nums[i] == 0 && flips % 2 == 0) || (nums[i] == 1 && flips % 2 != 0) + flips += 1 + ans += 1 + flipped[i + k] -= 1 + end + end + + (n - k + 1...n).each do |i| + flips += flipped[i] + if (nums[i] == 0 && flips % 2 == 0) || (nums[i] == 1 && flips % 2 != 0) + return -1 + end + end + + ans +end diff --git a/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.rs b/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.rs new file mode 100644 index 00000000..a7785278 --- /dev/null +++ b/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.rs @@ -0,0 +1,27 @@ +impl Solution { + pub fn min_k_bit_flips(nums: Vec, k: i32) -> i32 { + let n = nums.len(); + let k = k as usize; + let mut ans = 0; + let mut flips = 0; + let mut flipped = vec![0i32; n + 1]; + + for i in 0..=n - k { + flips += flipped[i]; + if (nums[i] == 0 && flips % 2 == 0) || (nums[i] == 1 && flips % 2 != 0) { + flips += 1; + ans += 1; + flipped[i + k] -= 1; + } + } + + for i in n - k + 1..n { + flips += flipped[i]; + if (nums[i] == 0 && flips % 2 == 0) || (nums[i] == 1 && flips % 2 != 0) { + return -1; + } + } + + ans + } +} diff --git a/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.swift b/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.swift new file mode 100644 index 00000000..5a4174fe --- /dev/null +++ b/tests/501-1000/995. minimum-number-of-k-consecutive-bit-flips/sol.swift @@ -0,0 +1,26 @@ +class Solution { + func minKBitFlips(_ nums: [Int], _ k: Int) -> Int { + let n = nums.count + var ans = 0 + var flips = 0 + var flipped = [Int](repeating: 0, count: n + 1) + + for i in 0...(n - k) { + flips += flipped[i] + if (nums[i] == 0 && flips % 2 == 0) || (nums[i] == 1 && flips % 2 != 0) { + flips += 1 + ans += 1 + flipped[i + k] -= 1 + } + } + + for i in (n - k + 1)..& nums) { + int n = nums.size(); + sort(nums.begin(), nums.end()); + + auto isSquareful = [](const vector& currNums, int num) -> bool { + if (currNums.empty()) return true; + int prevNum = currNums.back(); + int pairSum = prevNum + num; + if (pairSum < 0) return false; + int sqrtN = (int)sqrt(pairSum); + return sqrtN * sqrtN == pairSum; + }; + + function&)> backtrack = [&](int numsMask, vector& currNums) -> int { + if (numsMask != 0 && currNums.size() == n) return 1; + int numSquarefulPerms = 0; + for (int idx = 0; idx < n; idx++) { + int num = nums[idx]; + if (idx > 0 && nums[idx] == nums[idx - 1] && (numsMask & (1 << (idx - 1))) == 0) { + continue; + } + if ((numsMask & (1 << idx)) == 0 && isSquareful(currNums, num)) { + currNums.push_back(num); + numSquarefulPerms += backtrack(numsMask | (1 << idx), currNums); + currNums.pop_back(); + } + } + return numSquarefulPerms; + }; + + vector currNums; + return backtrack(0, currNums); + } +}; diff --git a/tests/501-1000/996. number-of-squareful-arrays/sol.cs b/tests/501-1000/996. number-of-squareful-arrays/sol.cs new file mode 100644 index 00000000..2f22578a --- /dev/null +++ b/tests/501-1000/996. number-of-squareful-arrays/sol.cs @@ -0,0 +1,34 @@ +public class Solution { + public int NumSquarefulPerms(int[] nums) { + int n = nums.Length; + Array.Sort(nums); + + bool IsSquareful(List currNums, int num) { + if (currNums.Count == 0) return true; + int prevNum = currNums[currNums.Count - 1]; + int pairSum = prevNum + num; + if (pairSum < 0) return false; + int sqrtN = (int)Math.Sqrt(pairSum); + return sqrtN * sqrtN == pairSum; + } + + int Backtrack(int numsMask, List currNums) { + if (numsMask != 0 && currNums.Count == n) return 1; + int numSquarefulPerms = 0; + for (int idx = 0; idx < n; idx++) { + int num = nums[idx]; + if (idx > 0 && nums[idx] == nums[idx - 1] && (numsMask & (1 << (idx - 1))) == 0) { + continue; + } + if ((numsMask & (1 << idx)) == 0 && IsSquareful(currNums, num)) { + currNums.Add(num); + numSquarefulPerms += Backtrack(numsMask | (1 << idx), currNums); + currNums.RemoveAt(currNums.Count - 1); + } + } + return numSquarefulPerms; + } + + return Backtrack(0, new List()); + } +} diff --git a/tests/501-1000/996. number-of-squareful-arrays/sol.dart b/tests/501-1000/996. number-of-squareful-arrays/sol.dart new file mode 100644 index 00000000..e58102be --- /dev/null +++ b/tests/501-1000/996. number-of-squareful-arrays/sol.dart @@ -0,0 +1,36 @@ +import 'dart:math' as math; + +class Solution { + int numSquarefulPerms(List nums) { + int n = nums.length; + nums.sort(); + + bool isSquareful(List currNums, int num) { + if (currNums.isEmpty) return true; + int prevNum = currNums.last; + int pairSum = prevNum + num; + if (pairSum < 0) return false; + int sqrtN = math.sqrt(pairSum.toDouble()).toInt(); + return sqrtN * sqrtN == pairSum; + } + + int backtrack(int numsMask, List currNums) { + if (numsMask != 0 && currNums.length == n) return 1; + int numSquarefulPerms = 0; + for (int idx = 0; idx < n; idx++) { + int num = nums[idx]; + if (idx > 0 && nums[idx] == nums[idx - 1] && (numsMask & (1 << (idx - 1))) == 0) { + continue; + } + if ((numsMask & (1 << idx)) == 0 && isSquareful(currNums, num)) { + currNums.add(num); + numSquarefulPerms += backtrack(numsMask | (1 << idx), currNums); + currNums.removeLast(); + } + } + return numSquarefulPerms; + } + + return backtrack(0, []); + } +} diff --git a/tests/501-1000/996. number-of-squareful-arrays/sol.go b/tests/501-1000/996. number-of-squareful-arrays/sol.go new file mode 100644 index 00000000..745431a9 --- /dev/null +++ b/tests/501-1000/996. number-of-squareful-arrays/sol.go @@ -0,0 +1,39 @@ +func numSquarefulPerms(nums []int) int { + n := len(nums) + sort.Ints(nums) + + isSquareful := func(currNums []int, num int) bool { + if len(currNums) == 0 { + return true + } + prevNum := currNums[len(currNums)-1] + pairSum := prevNum + num + if pairSum < 0 { + return false + } + sqrtN := int(math.Sqrt(float64(pairSum))) + return sqrtN*sqrtN == pairSum + } + + var backtrack func(int, []int) int + backtrack = func(numsMask int, currNums []int) int { + if numsMask != 0 && len(currNums) == n { + return 1 + } + numSquarefulPerms := 0 + for idx := 0; idx < n; idx++ { + num := nums[idx] + if idx > 0 && nums[idx] == nums[idx-1] && (numsMask & (1 << (idx - 1))) == 0 { + continue + } + if (numsMask & (1 << idx)) == 0 && isSquareful(currNums, num) { + currNums = append(currNums, num) + numSquarefulPerms += backtrack(numsMask | (1 << idx), currNums) + currNums = currNums[:len(currNums)-1] + } + } + return numSquarefulPerms + } + + return backtrack(0, []int{}) +} diff --git a/tests/501-1000/996. number-of-squareful-arrays/sol.java b/tests/501-1000/996. number-of-squareful-arrays/sol.java new file mode 100644 index 00000000..619373b7 --- /dev/null +++ b/tests/501-1000/996. number-of-squareful-arrays/sol.java @@ -0,0 +1,37 @@ +class Solution { + private int n; + private int[] nums; + + public int numSquarefulPerms(int[] nums) { + this.n = nums.length; + this.nums = nums; + java.util.Arrays.sort(this.nums); + return backtrack(0, new java.util.ArrayList<>()); + } + + private boolean isSquareful(java.util.List currNums, int num) { + if (currNums.isEmpty()) return true; + int prevNum = currNums.get(currNums.size() - 1); + int pairSum = prevNum + num; + if (pairSum < 0) return false; + int sqrtN = (int) Math.sqrt(pairSum); + return sqrtN * sqrtN == pairSum; + } + + private int backtrack(int numsMask, java.util.List currNums) { + if (numsMask != 0 && currNums.size() == n) return 1; + int numSquarefulPerms = 0; + for (int idx = 0; idx < n; idx++) { + int num = nums[idx]; + if (idx > 0 && nums[idx] == nums[idx - 1] && (numsMask & (1 << (idx - 1))) == 0) { + continue; + } + if ((numsMask & (1 << idx)) == 0 && isSquareful(currNums, num)) { + currNums.add(num); + numSquarefulPerms += backtrack(numsMask | (1 << idx), currNums); + currNums.remove(currNums.size() - 1); + } + } + return numSquarefulPerms; + } +} diff --git a/tests/501-1000/996. number-of-squareful-arrays/sol.kt b/tests/501-1000/996. number-of-squareful-arrays/sol.kt new file mode 100644 index 00000000..c2077226 --- /dev/null +++ b/tests/501-1000/996. number-of-squareful-arrays/sol.kt @@ -0,0 +1,36 @@ +class Solution { + private lateinit var nums: IntArray + private var n: Int = 0 + + fun numSquarefulPerms(nums: IntArray): Int { + this.nums = nums.sortedArray() + this.n = nums.size + return backtrack(0, mutableListOf()) + } + + private fun isSquareful(currNums: List, num: Int): Boolean { + if (currNums.isEmpty()) return true + val prevNum = currNums.last() + val pairSum = prevNum + num + if (pairSum < 0) return false + val sqrtN = kotlin.math.sqrt(pairSum.toDouble()).toInt() + return sqrtN * sqrtN == pairSum + } + + private fun backtrack(numsMask: Int, currNums: MutableList): Int { + if (numsMask != 0 && currNums.size == n) return 1 + var numSquarefulPerms = 0 + for (idx in 0 until n) { + val num = nums[idx] + if (idx > 0 && nums[idx] == nums[idx - 1] && (numsMask and (1 shl (idx - 1))) == 0) { + continue + } + if ((numsMask and (1 shl idx)) == 0 && isSquareful(currNums, num)) { + currNums.add(num) + numSquarefulPerms += backtrack(numsMask or (1 shl idx), currNums) + currNums.removeAt(currNums.size - 1) + } + } + return numSquarefulPerms + } +} diff --git a/tests/501-1000/996. number-of-squareful-arrays/sol.py b/tests/501-1000/996. number-of-squareful-arrays/sol.py new file mode 100644 index 00000000..1b7fc320 --- /dev/null +++ b/tests/501-1000/996. number-of-squareful-arrays/sol.py @@ -0,0 +1,45 @@ +import math +from typing import List + + +class Solution: + def numSquarefulPerms(self, nums: List[int]) -> int: + n = len(nums) + nums.sort() + + def is_squareful(curr_nums, num): + if len(curr_nums) == 0: + return True + + prev_num = curr_nums[-1] + pair_sum = prev_num + num + if pair_sum < 0: + return False + + sqrt_n = math.isqrt(pair_sum) + return sqrt_n**2 == pair_sum + + def backtrack(nums_mask, curr_nums): + # base case: reaching the end (used all numbers) + if nums_mask != 0 and len(curr_nums) == n: + return 1 + + num_squareful_perms = 0 + for idx in range(n): + num = nums[idx] + if ( + idx > 0 + and nums[idx] == nums[idx - 1] + and (nums_mask & (1 << (idx - 1))) == 0 + ): + # skip duplicates + continue + if (nums_mask & (1 << idx)) == 0 and is_squareful(curr_nums, num): + # if unused and forms a square with adj. number + curr_nums.append(num) + num_squareful_perms += backtrack(nums_mask | (1 << idx), curr_nums) + curr_nums.pop() + + return num_squareful_perms + + return backtrack(0, []) diff --git a/tests/501-1000/996. number-of-squareful-arrays/sol.py2 b/tests/501-1000/996. number-of-squareful-arrays/sol.py2 new file mode 100644 index 00000000..4926a04c --- /dev/null +++ b/tests/501-1000/996. number-of-squareful-arrays/sol.py2 @@ -0,0 +1,35 @@ +class Solution(object): + def numSquarefulPerms(self, nums): + """ + :type nums: List[int] + :rtype: int + """ + n = len(nums) + nums.sort() + + def is_squareful(curr_nums, num): + if len(curr_nums) == 0: + return True + prev_num = curr_nums[-1] + pair_sum = prev_num + num + if pair_sum < 0: + return False + sqrt_n = int(math.sqrt(pair_sum)) + return sqrt_n * sqrt_n == pair_sum + + def backtrack(nums_mask, curr_nums): + if nums_mask != 0 and len(curr_nums) == n: + return 1 + num_squareful_perms = 0 + for idx in range(n): + num = nums[idx] + if idx > 0 and nums[idx] == nums[idx - 1] and (nums_mask & (1 << (idx - 1))) == 0: + continue + if (nums_mask & (1 << idx)) == 0 and is_squareful(curr_nums, num): + curr_nums.append(num) + num_squareful_perms += backtrack(nums_mask | (1 << idx), curr_nums) + curr_nums.pop() + return num_squareful_perms + + import math + return backtrack(0, []) diff --git a/tests/501-1000/996. number-of-squareful-arrays/sol.rb b/tests/501-1000/996. number-of-squareful-arrays/sol.rb new file mode 100644 index 00000000..1533f8d0 --- /dev/null +++ b/tests/501-1000/996. number-of-squareful-arrays/sol.rb @@ -0,0 +1,36 @@ +# @param {Integer[]} nums +# @return {Integer} +def num_squareful_perms(nums) + n = nums.length + nums.sort! + + is_squareful = lambda do |curr_nums, num| + return true if curr_nums.empty? + prev_num = curr_nums[-1] + pair_sum = prev_num + num + return false if pair_sum < 0 + sqrt_n = Integer.sqrt(pair_sum) + sqrt_n * sqrt_n == pair_sum + end + + backtrack = lambda do |nums_mask, curr_nums| + if nums_mask != 0 && curr_nums.length == n + return 1 + end + num_squareful_perms = 0 + (0...n).each do |idx| + num = nums[idx] + if idx > 0 && nums[idx] == nums[idx - 1] && (nums_mask & (1 << (idx - 1))) == 0 + next + end + if (nums_mask & (1 << idx)) == 0 && is_squareful.call(curr_nums, num) + curr_nums.push(num) + num_squareful_perms += backtrack.call(nums_mask | (1 << idx), curr_nums) + curr_nums.pop + end + end + num_squareful_perms + end + + backtrack.call(0, []) +end diff --git a/tests/501-1000/996. number-of-squareful-arrays/sol.rs b/tests/501-1000/996. number-of-squareful-arrays/sol.rs new file mode 100644 index 00000000..651fb66f --- /dev/null +++ b/tests/501-1000/996. number-of-squareful-arrays/sol.rs @@ -0,0 +1,41 @@ +impl Solution { + pub fn num_squareful_perms(nums: Vec) -> i32 { + let n = nums.len(); + let mut nums = nums; + nums.sort(); + + fn is_squareful(curr_nums: &Vec, num: i32) -> bool { + if curr_nums.is_empty() { + return true; + } + let prev_num = curr_nums[curr_nums.len() - 1]; + let pair_sum = prev_num + num; + if pair_sum < 0 { + return false; + } + let sqrt_n = (pair_sum as f64).sqrt() as i32; + sqrt_n * sqrt_n == pair_sum + } + + fn backtrack(nums: &Vec, n: usize, nums_mask: usize, curr_nums: &mut Vec) -> i32 { + if nums_mask != 0 && curr_nums.len() == n { + return 1; + } + let mut total = 0; + for idx in 0..n { + let num = nums[idx]; + if idx > 0 && nums[idx] == nums[idx - 1] && (nums_mask & (1 << (idx - 1))) == 0 { + continue; + } + if (nums_mask & (1 << idx)) == 0 && is_squareful(curr_nums, num) { + curr_nums.push(num); + total += backtrack(nums, n, nums_mask | (1 << idx), curr_nums); + curr_nums.pop(); + } + } + total + } + + backtrack(&nums, n, 0, &mut vec![]) + } +} diff --git a/tests/501-1000/996. number-of-squareful-arrays/sol.swift b/tests/501-1000/996. number-of-squareful-arrays/sol.swift new file mode 100644 index 00000000..97fe4825 --- /dev/null +++ b/tests/501-1000/996. number-of-squareful-arrays/sol.swift @@ -0,0 +1,36 @@ +class Solution { + func numSquarefulPerms(_ nums: [Int]) -> Int { + let n = nums.count + let sortedNums = nums.sorted() + + func isSquareful(_ currNums: [Int], _ num: Int) -> Bool { + if currNums.isEmpty { return true } + let prevNum = currNums.last! + let pairSum = prevNum + num + if pairSum < 0 { return false } + let sqrtN = Int(Double(pairSum).squareRoot()) + return sqrtN * sqrtN == pairSum + } + + var memo = [String: Int]() + + func backtrack(_ numsMask: Int, _ currNums: [Int]) -> Int { + if numsMask != 0 && currNums.count == n { return 1 } + var total = 0 + for idx in 0.. 0 && sortedNums[idx] == sortedNums[idx - 1] && (numsMask & (1 << (idx - 1))) == 0 { + continue + } + if (numsMask & (1 << idx)) == 0 && isSquareful(currNums, num) { + var newCurr = currNums + newCurr.append(num) + total += backtrack(numsMask | (1 << idx), newCurr) + } + } + return total + } + + return backtrack(0, []) + } +} diff --git a/tests/501-1000/996. number-of-squareful-arrays/sol.ts b/tests/501-1000/996. number-of-squareful-arrays/sol.ts new file mode 100644 index 00000000..e8aea90c --- /dev/null +++ b/tests/501-1000/996. number-of-squareful-arrays/sol.ts @@ -0,0 +1,36 @@ +function numSquarefulPerms(nums: number[]): number { + const n = nums.length; + nums.sort((a, b) => a - b); + + const isSquareful = (currNums: number[], num: number): boolean => { + if (currNums.length === 0) return true; + const prevNum = currNums[currNums.length - 1]; + const pairSum = prevNum + num; + if (pairSum < 0) return false; + const sqrtN = Math.floor(Math.sqrt(pairSum)); + return sqrtN * sqrtN === pairSum; + }; + + const backtrack = (numsMask: number, currNums: number[]): number => { + if (numsMask !== 0 && currNums.length === n) return 1; + let numSquarefulPerms = 0; + for (let idx = 0; idx < n; idx++) { + const num = nums[idx]; + if ( + idx > 0 && + nums[idx] === nums[idx - 1] && + (numsMask & (1 << (idx - 1))) === 0 + ) { + continue; + } + if ((numsMask & (1 << idx)) === 0 && isSquareful(currNums, num)) { + currNums.push(num); + numSquarefulPerms += backtrack(numsMask | (1 << idx), currNums); + currNums.pop(); + } + } + return numSquarefulPerms; + }; + + return backtrack(0, []); +} diff --git a/tests/501-1000/997. find-the-town-judge/manifest.yaml b/tests/501-1000/997. find-the-town-judge/manifest.yaml new file mode 100644 index 00000000..8e2de143 --- /dev/null +++ b/tests/501-1000/997. find-the-town-judge/manifest.yaml @@ -0,0 +1,499 @@ +entry: + id: 997 + title: find-the-town-judge + params: + n: + type: int + trust: + type: array + items: + type: array + items: + type: int + call: + cpp: Solution().findJudge({n}, {trust}) + rust: Solution::find_judge({n}, {trust}) + python3: Solution().findJudge({n}, {trust}) + python2: Solution().findJudge({n}, {trust}) + ruby: find_judge({n}, {trust}) + java: new Solution().findJudge({n}, {trust}) + csharp: new Solution().FindJudge({n}, {trust}) + kotlin: Solution().findJudge({n}, {trust}) + go: findJudge({n}, {trust}) + dart: Solution().findJudge({n}, {trust}) + swift: Solution().findJudge({n}, {trust}) + typescript: findJudge({n}, {trust}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 997 +tests: + - name: case_1 + in: + n: 4 + trust: + - - 2 + - 1 + - - 2 + - 4 + - - 3 + - 2 + - - 4 + - 2 + out: -1 + - name: case_2 + in: + n: 3 + trust: + - - 1 + - 2 + - - 3 + - 1 + out: -1 + - name: case_3 + in: + n: 4 + trust: + - - 2 + - 3 + - - 2 + - 4 + - - 3 + - 1 + - - 4 + - 2 + out: -1 + - name: case_4 + in: + n: 7 + trust: + - - 1 + - 6 + - - 2 + - 1 + - - 2 + - 4 + - - 2 + - 7 + - - 4 + - 1 + - - 5 + - 2 + - - 6 + - 7 + - - 7 + - 1 + - - 7 + - 5 + out: -1 + - name: case_5 + in: + n: 3 + trust: [] + out: -1 + - name: case_6 + in: + n: 2 + trust: [] + out: -1 + - name: case_7 + in: + n: 6 + trust: + - - 1 + - 3 + - - 3 + - 6 + - - 5 + - 4 + - - 6 + - 1 + out: -1 + - name: case_8 + in: + n: 4 + trust: + - - 1 + - 2 + - - 3 + - 2 + - - 3 + - 4 + out: -1 + - name: case_9 + in: + n: 6 + trust: + - - 1 + - 5 + - - 2 + - 1 + - - 2 + - 5 + - - 3 + - 4 + - - 3 + - 5 + - - 5 + - 3 + out: -1 + - name: case_10 + in: + n: 2 + trust: + - - 1 + - 2 + out: 2 + - name: case_11 + in: + n: 2 + trust: + - - 2 + - 1 + out: 1 + - name: case_12 + in: + n: 8 + trust: + - - 2 + - 8 + - - 3 + - 8 + - - 4 + - 1 + - - 5 + - 2 + - - 5 + - 8 + - - 6 + - 2 + - - 6 + - 4 + - - 6 + - 5 + - - 7 + - 2 + - - 8 + - 2 + out: -1 + - name: case_13 + in: + n: 4 + trust: + - - 3 + - 2 + - - 3 + - 4 + out: -1 + - name: case_14 + in: + n: 5 + trust: + - - 1 + - 3 + - - 2 + - 3 + - - 3 + - 4 + - - 3 + - 5 + - - 4 + - 1 + - - 4 + - 5 + out: -1 + - name: case_15 + in: + n: 1 + trust: [] + out: 1 + - name: case_16 + in: + n: 5 + trust: + - - 1 + - 5 + - - 2 + - 5 + - - 3 + - 1 + - - 3 + - 4 + - - 5 + - 1 + - - 5 + - 2 + out: -1 + - name: case_17 + in: + n: 6 + trust: + - - 1 + - 5 + - - 3 + - 1 + - - 4 + - 1 + - - 4 + - 3 + - - 4 + - 5 + - - 6 + - 5 + out: -1 + - name: case_18 + in: + n: 3 + trust: [] + out: -1 + - name: case_19 + in: + n: 1 + trust: [] + out: 1 + - name: case_20 + in: + n: 8 + trust: + - - 3 + - 4 + - - 4 + - 1 + - - 4 + - 8 + - - 5 + - 8 + - - 7 + - 4 + - - 7 + - 5 + - - 8 + - 1 + - - 8 + - 7 + out: -1 + - name: case_21 + in: + n: 4 + trust: + - - 1 + - 3 + out: -1 + - name: case_22 + in: + n: 8 + trust: + - - 1 + - 2 + - - 1 + - 3 + - - 1 + - 6 + - - 1 + - 7 + - - 3 + - 6 + - - 4 + - 8 + - - 6 + - 3 + - - 6 + - 5 + - - 7 + - 1 + - - 7 + - 5 + - - 8 + - 3 + - - 8 + - 4 + - - 8 + - 7 + out: -1 + - name: case_23 + in: + n: 5 + trust: + - - 1 + - 4 + - - 2 + - 3 + - - 2 + - 4 + - - 3 + - 4 + - - 5 + - 3 + out: -1 + - name: case_24 + in: + n: 6 + trust: + - - 1 + - 2 + - - 3 + - 4 + - - 4 + - 2 + - - 5 + - 3 + - - 5 + - 6 + - - 6 + - 3 + out: -1 + - name: case_25 + in: + n: 1 + trust: [] + out: 1 + - name: case_26 + in: + n: 3 + trust: + - - 1 + - 3 + out: -1 + - name: case_27 + in: + n: 2 + trust: [] + out: -1 + - name: case_28 + in: + n: 4 + trust: + - - 1 + - 4 + - - 3 + - 4 + out: -1 + - name: case_29 + in: + n: 3 + trust: + - - 3 + - 1 + - - 3 + - 2 + out: -1 + - name: case_30 + in: + n: 4 + trust: + - - 1 + - 3 + - - 2 + - 4 + out: -1 + - name: case_31 + in: + n: 7 + trust: + - - 2 + - 3 + - - 2 + - 6 + - - 2 + - 7 + - - 5 + - 4 + - - 5 + - 6 + out: -1 + - name: case_32 + in: + n: 7 + trust: + - - 1 + - 6 + - - 2 + - 5 + - - 3 + - 2 + - - 3 + - 5 + - - 4 + - 2 + - - 4 + - 5 + - - 5 + - 2 + - - 5 + - 4 + - - 5 + - 6 + - - 7 + - 5 + out: -1 + - name: case_33 + in: + n: 7 + trust: + - - 1 + - 2 + - - 1 + - 6 + - - 1 + - 7 + - - 2 + - 1 + - - 2 + - 4 + - - 2 + - 7 + - - 3 + - 1 + - - 3 + - 5 + - - 5 + - 2 + - - 6 + - 3 + - - 6 + - 4 + - - 7 + - 3 + - - 7 + - 6 + out: -1 + - name: case_34 + in: + n: 5 + trust: + - - 1 + - 2 + - - 2 + - 4 + - - 3 + - 4 + - - 4 + - 2 + - - 4 + - 5 + - - 5 + - 2 + out: -1 + - name: case_35 + in: + n: 6 + trust: + - - 1 + - 5 + - - 2 + - 6 + - - 3 + - 6 + - - 4 + - 2 + - - 6 + - 3 + - - 6 + - 5 + out: -1 diff --git a/tests/501-1000/997. find-the-town-judge/sol.cpp b/tests/501-1000/997. find-the-town-judge/sol.cpp new file mode 100644 index 00000000..720fd1e8 --- /dev/null +++ b/tests/501-1000/997. find-the-town-judge/sol.cpp @@ -0,0 +1,19 @@ +class Solution { +public: + int findJudge(int n, vector>& trust) { + vector indegree(n + 1, 0); + vector outdegree(n + 1, 0); + for (const auto& edge : trust) { + int a = edge[0]; + int b = edge[1]; + outdegree[a]++; + indegree[b]++; + } + for (int i = 1; i <= n; i++) { + if (outdegree[i] == 0 && indegree[i] == n - 1) { + return i; + } + } + return -1; + } +}; diff --git a/tests/501-1000/997. find-the-town-judge/sol.cs b/tests/501-1000/997. find-the-town-judge/sol.cs new file mode 100644 index 00000000..8f007ef7 --- /dev/null +++ b/tests/501-1000/997. find-the-town-judge/sol.cs @@ -0,0 +1,18 @@ +public class Solution { + public int FindJudge(int n, int[][] trust) { + int[] indegree = new int[n + 1]; + int[] outdegree = new int[n + 1]; + foreach (int[] edge in trust) { + int a = edge[0]; + int b = edge[1]; + outdegree[a]++; + indegree[b]++; + } + for (int i = 1; i <= n; i++) { + if (outdegree[i] == 0 && indegree[i] == n - 1) { + return i; + } + } + return -1; + } +} diff --git a/tests/501-1000/997. find-the-town-judge/sol.dart b/tests/501-1000/997. find-the-town-judge/sol.dart new file mode 100644 index 00000000..b3bba21c --- /dev/null +++ b/tests/501-1000/997. find-the-town-judge/sol.dart @@ -0,0 +1,18 @@ +class Solution { + int findJudge(int n, List> trust) { + var indegree = List.filled(n + 1, 0); + var outdegree = List.filled(n + 1, 0); + for (var edge in trust) { + int a = edge[0]; + int b = edge[1]; + outdegree[a]++; + indegree[b]++; + } + for (int i = 1; i <= n; i++) { + if (outdegree[i] == 0 && indegree[i] == n - 1) { + return i; + } + } + return -1; + } +} diff --git a/tests/501-1000/997. find-the-town-judge/sol.go b/tests/501-1000/997. find-the-town-judge/sol.go new file mode 100644 index 00000000..258c22ba --- /dev/null +++ b/tests/501-1000/997. find-the-town-judge/sol.go @@ -0,0 +1,15 @@ +func findJudge(n int, trust [][]int) int { + indegree := make([]int, n+1) + outdegree := make([]int, n+1) + for _, edge := range trust { + a, b := edge[0], edge[1] + outdegree[a]++ + indegree[b]++ + } + for i := 1; i <= n; i++ { + if outdegree[i] == 0 && indegree[i] == n-1 { + return i + } + } + return -1 +} diff --git a/tests/501-1000/997. find-the-town-judge/sol.java b/tests/501-1000/997. find-the-town-judge/sol.java new file mode 100644 index 00000000..67e25cba --- /dev/null +++ b/tests/501-1000/997. find-the-town-judge/sol.java @@ -0,0 +1,18 @@ +class Solution { + public int findJudge(int n, int[][] trust) { + int[] indegree = new int[n + 1]; + int[] outdegree = new int[n + 1]; + for (int[] edge : trust) { + int a = edge[0]; + int b = edge[1]; + outdegree[a]++; + indegree[b]++; + } + for (int i = 1; i <= n; i++) { + if (outdegree[i] == 0 && indegree[i] == n - 1) { + return i; + } + } + return -1; + } +} diff --git a/tests/501-1000/997. find-the-town-judge/sol.kt b/tests/501-1000/997. find-the-town-judge/sol.kt new file mode 100644 index 00000000..869dd603 --- /dev/null +++ b/tests/501-1000/997. find-the-town-judge/sol.kt @@ -0,0 +1,18 @@ +class Solution { + fun findJudge(n: Int, trust: Array): Int { + val indegree = IntArray(n + 1) + val outdegree = IntArray(n + 1) + for (edge in trust) { + val a = edge[0] + val b = edge[1] + outdegree[a]++ + indegree[b]++ + } + for (i in 1..n) { + if (outdegree[i] == 0 && indegree[i] == n - 1) { + return i + } + } + return -1 + } +} diff --git a/tests/501-1000/997. find-the-town-judge/sol.py b/tests/501-1000/997. find-the-town-judge/sol.py new file mode 100644 index 00000000..b1d19922 --- /dev/null +++ b/tests/501-1000/997. find-the-town-judge/sol.py @@ -0,0 +1,14 @@ +from typing import List + + +class Solution: + def findJudge(self, n: int, trust: List[List[int]]) -> int: + indgree = [0] * (n + 1) + outdgree = [0] * (n + 1) + for i in trust: + outdgree[i[0]] += 1 + indgree[i[1]] += 1 + for j in range(1, n + 1): + if outdgree[j] == 0 and indgree[j] == n - 1: + return j + return -1 diff --git a/tests/501-1000/997. find-the-town-judge/sol.py2 b/tests/501-1000/997. find-the-town-judge/sol.py2 new file mode 100644 index 00000000..418a420a --- /dev/null +++ b/tests/501-1000/997. find-the-town-judge/sol.py2 @@ -0,0 +1,16 @@ +class Solution(object): + def findJudge(self, n, trust): + """ + :type n: int + :type trust: List[List[int]] + :rtype: int + """ + indegree = [0] * (n + 1) + outdegree = [0] * (n + 1) + for a, b in trust: + outdegree[a] += 1 + indegree[b] += 1 + for i in range(1, n + 1): + if outdegree[i] == 0 and indegree[i] == n - 1: + return i + return -1 diff --git a/tests/501-1000/997. find-the-town-judge/sol.rb b/tests/501-1000/997. find-the-town-judge/sol.rb new file mode 100644 index 00000000..7ca17812 --- /dev/null +++ b/tests/501-1000/997. find-the-town-judge/sol.rb @@ -0,0 +1,15 @@ +# @param {Integer} n +# @param {Integer[][]} trust +# @return {Integer} +def find_judge(n, trust) + indegree = Array.new(n + 1, 0) + outdegree = Array.new(n + 1, 0) + trust.each do |a, b| + outdegree[a] += 1 + indegree[b] += 1 + end + (1..n).each do |i| + return i if outdegree[i] == 0 && indegree[i] == n - 1 + end + -1 +end diff --git a/tests/501-1000/997. find-the-town-judge/sol.rs b/tests/501-1000/997. find-the-town-judge/sol.rs new file mode 100644 index 00000000..6dc8807c --- /dev/null +++ b/tests/501-1000/997. find-the-town-judge/sol.rs @@ -0,0 +1,19 @@ +impl Solution { + pub fn find_judge(n: i32, trust: Vec>) -> i32 { + let n = n as usize; + let mut indegree = vec![0; n + 1]; + let mut outdegree = vec![0; n + 1]; + for edge in trust { + let a = edge[0] as usize; + let b = edge[1] as usize; + outdegree[a] += 1; + indegree[b] += 1; + } + for i in 1..=n { + if outdegree[i] == 0 && indegree[i] == n - 1 { + return i as i32; + } + } + -1 + } +} diff --git a/tests/501-1000/997. find-the-town-judge/sol.swift b/tests/501-1000/997. find-the-town-judge/sol.swift new file mode 100644 index 00000000..553e108b --- /dev/null +++ b/tests/501-1000/997. find-the-town-judge/sol.swift @@ -0,0 +1,18 @@ +class Solution { + func findJudge(_ n: Int, _ trust: [[Int]]) -> Int { + var indegree = [Int](repeating: 0, count: n + 1) + var outdegree = [Int](repeating: 0, count: n + 1) + for edge in trust { + let a = edge[0] + let b = edge[1] + outdegree[a] += 1 + indegree[b] += 1 + } + for i in 1...n { + if outdegree[i] == 0 && indegree[i] == n - 1 { + return i + } + } + return -1 + } +} diff --git a/tests/501-1000/997. find-the-town-judge/sol.ts b/tests/501-1000/997. find-the-town-judge/sol.ts new file mode 100644 index 00000000..be00e1b0 --- /dev/null +++ b/tests/501-1000/997. find-the-town-judge/sol.ts @@ -0,0 +1,14 @@ +function findJudge(n: number, trust: number[][]): number { + const indegree = new Array(n + 1).fill(0); + const outdegree = new Array(n + 1).fill(0); + for (const [a, b] of trust) { + outdegree[a]++; + indegree[b]++; + } + for (let i = 1; i <= n; i++) { + if (outdegree[i] === 0 && indegree[i] === n - 1) { + return i; + } + } + return -1; +} diff --git a/tests/501-1000/998. maximum-binary-tree-ii/manifest.yaml b/tests/501-1000/998. maximum-binary-tree-ii/manifest.yaml new file mode 100644 index 00000000..d40498d9 --- /dev/null +++ b/tests/501-1000/998. maximum-binary-tree-ii/manifest.yaml @@ -0,0 +1,700 @@ +entry: + id: 998 + title: maximum-binary-tree-ii + params: + root: + type: tree_node + val: + type: int + call: + cpp: treeNodeToArray(Solution().insertIntoMaxTree({root}, {val})) + rust: TreeNode::tree_node_to_array(Solution::insert_into_max_tree({root}, {val})) + python3: tree_node_to_array(Solution().insertIntoMaxTree({root}, {val})) + python2: tree_node_to_array(Solution().insertIntoMaxTree({root}, {val})) + ruby: tree_node_to_array(insert_into_max_tree({root}, {val})) + java: TreeNode.treeNodeToArray(new Solution().insertIntoMaxTree({root}, {val})) + csharp: TreeNode.TreeNodeToArray(new Solution().InsertIntoMaxTree({root}, {val})) + kotlin: treeNodeToArray(Solution().insertIntoMaxTree({root}, {val})) + go: treeNodeToArray(insertIntoMaxTree({root}, {val})) + dart: tree_node_to_array(Solution().insertIntoMaxTree({root}, {val})) + swift: tree_node_to_array(Solution().insertIntoMaxTree({root}, {val})) + typescript: treeNodeToArray(insertIntoMaxTree({root}, {val})) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 998 +tests: + - name: case_1 + in: + root: + - 28 + - null + - 15 + val: 9 + out: + - 28 + - null + - 15 + - null + - 9 + - name: case_2 + in: + root: + - 37 + - 3 + val: 7 + out: + - 37 + - 3 + - 7 + - name: case_3 + in: + root: + - 41 + - 39 + - null + - 23 + - 34 + - null + - null + - 8 + val: 44 + out: + - 44 + - 41 + - null + - 39 + - null + - 23 + - 34 + - null + - null + - 8 + - name: case_4 + in: + root: + - 47 + - null + - 45 + - 17 + - 35 + - null + - null + - 21 + val: 45 + out: + - 47 + - null + - 45 + - 45 + - null + - 17 + - 35 + - null + - null + - 21 + - name: case_5 + in: + root: + - 45 + - 42 + - 19 + - 6 + - 23 + - null + - null + - null + - null + - 18 + - 14 + - null + - null + - 10 + val: 28 + out: + - 45 + - 42 + - 28 + - 6 + - 23 + - 19 + - null + - null + - null + - 18 + - 14 + - null + - null + - null + - null + - 10 + - name: case_6 + in: + root: + - 49 + - 14 + - 47 + - null + - null + - 45 + val: 35 + out: + - 49 + - 14 + - 47 + - null + - null + - 45 + - 35 + - name: case_7 + in: + root: + - 32 + - 9 + - 8 + - null + - 2 + val: 50 + out: + - 50 + - 32 + - null + - 9 + - 8 + - null + - 2 + - name: case_8 + in: + root: + - 42 + - 27 + val: 42 + out: + - 42 + - 42 + - null + - 27 + - name: case_9 + in: + root: + - 40 + - 20 + val: 2 + out: + - 40 + - 20 + - 2 + - name: case_10 + in: + root: + - 49 + - null + - 34 + - 25 + - 1 + - 17 + - null + - null + - null + - null + - 11 + val: 48 + out: + - 49 + - null + - 48 + - 34 + - null + - 25 + - 1 + - 17 + - null + - null + - null + - null + - 11 + - name: case_11 + in: + root: + - 10 + - null + - 5 + - 3 + val: 5 + out: + - 10 + - null + - 5 + - 5 + - null + - 3 + - name: case_12 + in: + root: + - 16 + - 8 + - 3 + val: 4 + out: + - 16 + - 8 + - 4 + - null + - null + - 3 + - name: case_13 + in: + root: + - 44 + - null + - 41 + - 31 + - 34 + - 7 + - null + - 33 + - null + - null + - null + - 16 + - null + - 7 + val: 19 + out: + - 44 + - null + - 41 + - 31 + - 34 + - 7 + - null + - 33 + - 19 + - null + - null + - 16 + - null + - null + - null + - 7 + - name: case_14 + in: + root: + - 13 + - null + - 3 + val: 36 + out: + - 36 + - 13 + - null + - null + - 3 + - name: case_15 + in: + root: + - 26 + - null + - 25 + - null + - 22 + val: 6 + out: + - 26 + - null + - 25 + - null + - 22 + - null + - 6 + - name: case_16 + in: + root: + - 44 + - 40 + - null + - 33 + val: 13 + out: + - 44 + - 40 + - 13 + - 33 + - name: case_17 + in: + root: + - 50 + - 23 + - 42 + - null + - null + - 37 + - null + - null + - 37 + val: 9 + out: + - 50 + - 23 + - 42 + - null + - null + - 37 + - 9 + - null + - 37 + - name: case_18 + in: + root: + - 49 + - 48 + - 25 + - 45 + - 41 + - 15 + - null + - 33 + - null + - null + - 16 + val: 13 + out: + - 49 + - 48 + - 25 + - 45 + - 41 + - 15 + - 13 + - 33 + - null + - null + - 16 + - name: case_19 + in: + root: + - 31 + val: 23 + out: + - 31 + - null + - 23 + - name: case_20 + in: + root: + - 3 + val: 22 + out: + - 22 + - 3 + - name: case_21 + in: + root: + - 48 + - 32 + - 47 + - null + - 32 + - 29 + - 14 + - null + - null + - 4 + - null + - null + - null + - 2 + val: 20 + out: + - 48 + - 32 + - 47 + - null + - 32 + - 29 + - 20 + - null + - null + - 4 + - null + - 14 + - null + - 2 + - name: case_22 + in: + root: + - 41 + - null + - 34 + - 11 + val: 20 + out: + - 41 + - null + - 34 + - 11 + - 20 + - name: case_23 + in: + root: + - 49 + - 42 + - null + - 39 + - 19 + - 34 + - null + - null + - null + - 3 + - 16 + - null + - null + - 14 + val: 34 + out: + - 49 + - 42 + - 34 + - 39 + - 19 + - null + - null + - 34 + - null + - null + - null + - 3 + - 16 + - null + - null + - 14 + - name: case_24 + in: + root: + - 47 + - null + - 42 + - 41 + - null + - 17 + - null + - null + - 13 + - 2 + - null + - 1 + val: 49 + out: + - 49 + - 47 + - null + - null + - 42 + - 41 + - null + - 17 + - null + - null + - 13 + - 2 + - null + - 1 + - name: case_25 + in: + root: + - 15 + val: 28 + out: + - 28 + - 15 + - name: case_26 + in: + root: + - 45 + - null + - 10 + - 5 + val: 31 + out: + - 45 + - null + - 31 + - 10 + - null + - 5 + - name: case_27 + in: + root: + - 46 + - 27 + - 46 + - null + - 15 + - 39 + - null + - null + - null + - null + - 30 + val: 26 + out: + - 46 + - 27 + - 46 + - null + - 15 + - 39 + - 26 + - null + - null + - null + - 30 + - name: case_28 + in: + root: + - 35 + - 29 + - null + - null + - 8 + val: 35 + out: + - 35 + - 35 + - null + - 29 + - null + - null + - 8 + - name: case_29 + in: + root: + - 47 + val: 40 + out: + - 47 + - null + - 40 + - name: case_30 + in: + root: + - 37 + - null + - 13 + val: 30 + out: + - 37 + - null + - 30 + - 13 + - name: case_31 + in: + root: + - 41 + - 28 + - 26 + - null + - 13 + - 16 + - 5 + - null + - null + - 15 + - 12 + val: 42 + out: + - 42 + - 41 + - null + - 28 + - 26 + - null + - 13 + - 16 + - 5 + - null + - null + - 15 + - 12 + - name: case_32 + in: + root: + - 38 + - 33 + - 15 + - 17 + val: 27 + out: + - 38 + - 33 + - 27 + - 17 + - null + - 15 + - name: case_33 + in: + root: + - 38 + - 2 + val: 39 + out: + - 39 + - 38 + - null + - 2 + - name: case_34 + in: + root: + - 43 + - null + - 36 + - 27 + - 35 + - 19 + - 22 + - 21 + - 11 + val: 36 + out: + - 43 + - null + - 36 + - 36 + - null + - 27 + - 35 + - 19 + - 22 + - 21 + - 11 + - name: case_35 + in: + root: + - 44 + - 32 + - 35 + - null + - null + - 22 + - 3 + - null + - 2 + val: 30 + out: + - 44 + - 32 + - 35 + - null + - null + - 22 + - 30 + - null + - 2 + - 3 diff --git a/tests/501-1000/998. maximum-binary-tree-ii/sol.cpp b/tests/501-1000/998. maximum-binary-tree-ii/sol.cpp new file mode 100644 index 00000000..3e04a86c --- /dev/null +++ b/tests/501-1000/998. maximum-binary-tree-ii/sol.cpp @@ -0,0 +1,29 @@ +/** + * Definition for a binary tree node. + * struct TreeNode { + * int val; + * TreeNode *left; + * TreeNode *right; + * TreeNode() : val(0), left(nullptr), right(nullptr) {} + * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} + * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} + * }; + */ +class Solution { +public: + TreeNode* insertIntoMaxTree(TreeNode* root, int val) { + function dfs = [&](TreeNode* node) -> TreeNode* { + if (!node) { + return new TreeNode(val); + } + if (node->val > val) { + node->right = dfs(node->right); + return node; + } + TreeNode* temp = new TreeNode(val); + temp->left = node; + return temp; + }; + return dfs(root); + } +}; diff --git a/tests/501-1000/998. maximum-binary-tree-ii/sol.cs b/tests/501-1000/998. maximum-binary-tree-ii/sol.cs new file mode 100644 index 00000000..3f0bc693 --- /dev/null +++ b/tests/501-1000/998. maximum-binary-tree-ii/sol.cs @@ -0,0 +1,31 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public int val; + * public TreeNode left; + * public TreeNode right; + * public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +public class Solution { + public TreeNode InsertIntoMaxTree(TreeNode root, int val) { + return Dfs(root, val); + } + + private TreeNode Dfs(TreeNode node, int val) { + if (node == null) { + return new TreeNode(val); + } + if (node.val > val) { + node.right = Dfs(node.right, val); + return node; + } + TreeNode temp = new TreeNode(val); + temp.left = node; + return temp; + } +} diff --git a/tests/501-1000/998. maximum-binary-tree-ii/sol.dart b/tests/501-1000/998. maximum-binary-tree-ii/sol.dart new file mode 100644 index 00000000..c16ac4fe --- /dev/null +++ b/tests/501-1000/998. maximum-binary-tree-ii/sol.dart @@ -0,0 +1,26 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * int val; + * TreeNode? left; + * TreeNode? right; + * TreeNode([this.val = 0, this.left, this.right]); + * } + */ +class Solution { + TreeNode? insertIntoMaxTree(TreeNode? root, int val) { + TreeNode? dfs(TreeNode? node) { + if (node == null) { + return TreeNode(val); + } + if (node.val > val) { + node.right = dfs(node.right); + return node; + } + TreeNode temp = TreeNode(val); + temp.left = node; + return temp; + } + return dfs(root); + } +} diff --git a/tests/501-1000/998. maximum-binary-tree-ii/sol.go b/tests/501-1000/998. maximum-binary-tree-ii/sol.go new file mode 100644 index 00000000..b9af7234 --- /dev/null +++ b/tests/501-1000/998. maximum-binary-tree-ii/sol.go @@ -0,0 +1,24 @@ +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +func insertIntoMaxTree(root *TreeNode, val int) *TreeNode { + var dfs func(*TreeNode) *TreeNode + dfs = func(node *TreeNode) *TreeNode { + if node == nil { + return &TreeNode{Val: val} + } + if node.Val > val { + node.Right = dfs(node.Right) + return node + } + temp := &TreeNode{Val: val} + temp.Left = node + return temp + } + return dfs(root) +} diff --git a/tests/501-1000/998. maximum-binary-tree-ii/sol.java b/tests/501-1000/998. maximum-binary-tree-ii/sol.java new file mode 100644 index 00000000..73eefa7f --- /dev/null +++ b/tests/501-1000/998. maximum-binary-tree-ii/sol.java @@ -0,0 +1,33 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode() {} + * TreeNode(int val) { this.val = val; } + * TreeNode(int val, TreeNode left, TreeNode right) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +class Solution { + public TreeNode insertIntoMaxTree(TreeNode root, int val) { + return dfs(root, val); + } + + private TreeNode dfs(TreeNode node, int val) { + if (node == null) { + return new TreeNode(val); + } + if (node.val > val) { + node.right = dfs(node.right, val); + return node; + } + TreeNode temp = new TreeNode(val); + temp.left = node; + return temp; + } +} diff --git a/tests/501-1000/998. maximum-binary-tree-ii/sol.kt b/tests/501-1000/998. maximum-binary-tree-ii/sol.kt new file mode 100644 index 00000000..41e66294 --- /dev/null +++ b/tests/501-1000/998. maximum-binary-tree-ii/sol.kt @@ -0,0 +1,27 @@ +/** + * Example: + * var ti = TreeNode(5) + * var v = ti.`val` + * Definition for a binary tree node. + * class TreeNode(var `val`: Int) { + * var left: TreeNode? = null + * var right: TreeNode? = null + * } + */ +class Solution { + fun insertIntoMaxTree(root: TreeNode?, `val`: Int): TreeNode? { + fun dfs(node: TreeNode?): TreeNode? { + if (node == null) { + return TreeNode(`val`) + } + if (node.`val` > `val`) { + node.right = dfs(node.right) + return node + } + val temp = TreeNode(`val`) + temp.left = node + return temp + } + return dfs(root) + } +} diff --git a/tests/501-1000/998. maximum-binary-tree-ii/sol.py b/tests/501-1000/998. maximum-binary-tree-ii/sol.py new file mode 100644 index 00000000..05aea139 --- /dev/null +++ b/tests/501-1000/998. maximum-binary-tree-ii/sol.py @@ -0,0 +1,25 @@ +# Definition for a binary tree node. +# class TreeNode: +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +from typing import Optional + + +class Solution: + def insertIntoMaxTree( + self, root: Optional[TreeNode], val: int + ) -> Optional[TreeNode]: + + def dfs(node): + if not node: + return TreeNode(val) + if node.val > val: + node.right = dfs(node.right) + return node + temp = TreeNode(val) + temp.left = node + return temp + + return dfs(root) diff --git a/tests/501-1000/998. maximum-binary-tree-ii/sol.py2 b/tests/501-1000/998. maximum-binary-tree-ii/sol.py2 new file mode 100644 index 00000000..b5a942f4 --- /dev/null +++ b/tests/501-1000/998. maximum-binary-tree-ii/sol.py2 @@ -0,0 +1,23 @@ +# Definition for a binary tree node. +# class TreeNode(object): +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution(object): + def insertIntoMaxTree(self, root, val): + """ + :type root: Optional[TreeNode] + :type val: int + :rtype: Optional[TreeNode] + """ + def dfs(node): + if not node: + return TreeNode(val) + if node.val > val: + node.right = dfs(node.right) + return node + temp = TreeNode(val) + temp.left = node + return temp + return dfs(root) diff --git a/tests/501-1000/998. maximum-binary-tree-ii/sol.rb b/tests/501-1000/998. maximum-binary-tree-ii/sol.rb new file mode 100644 index 00000000..cc13438d --- /dev/null +++ b/tests/501-1000/998. maximum-binary-tree-ii/sol.rb @@ -0,0 +1,27 @@ +# Definition for a binary tree node. +# class TreeNode +# attr_accessor :val, :left, :right +# def initialize(val = 0, left = nil, right = nil) +# @val = val +# @left = left +# @right = right +# end +# end +# @param {TreeNode} root +# @param {Integer} val +# @return {TreeNode} +def insert_into_max_tree(root, val) + dfs = lambda do |node| + if node.nil? + return TreeNode.new(val) + end + if node.val > val + node.right = dfs.call(node.right) + return node + end + temp = TreeNode.new(val) + temp.left = node + return temp + end + dfs.call(root) +end diff --git a/tests/501-1000/998. maximum-binary-tree-ii/sol.rs b/tests/501-1000/998. maximum-binary-tree-ii/sol.rs new file mode 100644 index 00000000..fca41a76 --- /dev/null +++ b/tests/501-1000/998. maximum-binary-tree-ii/sol.rs @@ -0,0 +1,40 @@ +// Definition for a binary tree node. +// #[derive(Debug, PartialEq, Eq)] +// pub struct TreeNode { +// pub val: i32, +// pub left: Option>>, +// pub right: Option>>, +// } +// +// impl TreeNode { +// #[inline] +// pub fn new(val: i32) -> Self { +// TreeNode { +// val, +// left: None, +// right: None +// } +// } +// } +impl Solution { + pub fn insert_into_max_tree(root: Option>>, val: i32) -> Option>> { + fn dfs(node: Option>>, val: i32) -> Option>> { + match node { + None => Some(Rc::new(RefCell::new(TreeNode::new(val)))), + Some(n) => { + if n.borrow().val > val { + let right = n.borrow().right.clone(); + let new_right = dfs(right, val); + n.borrow_mut().right = new_right; + Some(n) + } else { + let temp = Rc::new(RefCell::new(TreeNode::new(val))); + temp.borrow_mut().left = Some(n); + Some(temp) + } + } + } + } + dfs(root, val) + } +} diff --git a/tests/501-1000/998. maximum-binary-tree-ii/sol.swift b/tests/501-1000/998. maximum-binary-tree-ii/sol.swift new file mode 100644 index 00000000..6055e49b --- /dev/null +++ b/tests/501-1000/998. maximum-binary-tree-ii/sol.swift @@ -0,0 +1,32 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * public var val: Int + * public var left: TreeNode? + * public var right: TreeNode? + * public init() { self.val = 0; self.left = nil; self.right = nil; } + * public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; } + * public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) { + * self.val = val + * self.left = left + * self.right = right + * } + * } + */ +class Solution { + func insertIntoMaxTree(_ root: TreeNode?, _ val: Int) -> TreeNode? { + func dfs(_ node: TreeNode?) -> TreeNode? { + guard let node = node else { + return TreeNode(val) + } + if node.val > val { + node.right = dfs(node.right) + return node + } + let temp = TreeNode(val) + temp.left = node + return temp + } + return dfs(root) + } +} diff --git a/tests/501-1000/998. maximum-binary-tree-ii/sol.ts b/tests/501-1000/998. maximum-binary-tree-ii/sol.ts new file mode 100644 index 00000000..01b2372f --- /dev/null +++ b/tests/501-1000/998. maximum-binary-tree-ii/sol.ts @@ -0,0 +1,32 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ + +function insertIntoMaxTree( + root: TreeNode | null, + val: number, +): TreeNode | null { + const dfs = (node: TreeNode | null): TreeNode | null => { + if (node === null) { + return new TreeNode(val); + } + if (node.val > val) { + node.right = dfs(node.right); + return node; + } + const temp = new TreeNode(val); + temp.left = node; + return temp; + }; + return dfs(root); +} diff --git a/tests/501-1000/999. available-captures-for-rook/manifest.yaml b/tests/501-1000/999. available-captures-for-rook/manifest.yaml new file mode 100644 index 00000000..b7577c34 --- /dev/null +++ b/tests/501-1000/999. available-captures-for-rook/manifest.yaml @@ -0,0 +1,2484 @@ +entry: + id: 999 + title: available-captures-for-rook + params: + board: + type: array + items: + type: array + items: + type: char + call: + cpp: Solution().numRookCaptures({board}) + rust: Solution::num_rook_captures({board}) + python3: Solution().numRookCaptures({board}) + python2: Solution().numRookCaptures({board}) + ruby: num_rook_captures({board}) + java: new Solution().numRookCaptures({board}) + csharp: new Solution().NumRookCaptures({board}) + kotlin: Solution().numRookCaptures({board}) + go: numRookCaptures({board}) + dart: Solution().numRookCaptures({board}) + swift: Solution().numRookCaptures({board}) + typescript: numRookCaptures({board}) +judge: + type: exact +limits: + time_ms: 1000 + memory_mb: 256 +oracle: + python3: + call: Checker().check({result}) + checker: "class Checker:\n def check(self, result):\n return True\n" +seed: 999 +tests: + - name: case_1 + in: + board: + elemType: char + value: + - - . + - . + - . + - . + - . + - . + - . + - . + - - B + - . + - . + - . + - p + - . + - . + - B + - - . + - . + - . + - . + - . + - B + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - B + - - . + - . + - . + - p + - . + - . + - . + - . + - - . + - p + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - p + - R + - . + - . + - . + - - . + - . + - p + - . + - . + - . + - . + - . + out: 2 + - name: case_2 + in: + board: + elemType: char + value: + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - p + - . + - . + - . + - . + - . + - . + - . + - - . + - p + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - R + - - . + - . + - . + - . + - . + - . + - . + - . + out: 0 + - name: case_3 + in: + board: + elemType: char + value: + - - . + - R + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + out: 0 + - name: case_4 + in: + board: + elemType: char + value: + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - p + - . + - R + - . + - . + - . + - . + - . + - - . + - . + - B + - . + - . + - . + - . + - . + - - . + - . + - . + - B + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - p + - p + - . + - . + - . + - . + out: 1 + - name: case_5 + in: + board: + elemType: char + value: + - - . + - . + - p + - . + - . + - p + - B + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - p + - R + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - p + - B + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - p + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + out: 2 + - name: case_6 + in: + board: + elemType: char + value: + - - R + - . + - . + - . + - . + - . + - . + - p + - - . + - . + - . + - . + - p + - . + - . + - . + - - . + - p + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + out: 1 + - name: case_7 + in: + board: + elemType: char + value: + - - . + - . + - . + - . + - . + - . + - . + - p + - - . + - B + - . + - . + - . + - p + - . + - . + - - . + - . + - . + - . + - . + - R + - . + - . + - - . + - . + - . + - . + - B + - . + - . + - . + - - . + - . + - . + - . + - . + - p + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - p + - . + - B + - B + - . + - . + - - . + - . + - . + - . + - B + - . + - . + - . + out: 2 + - name: case_8 + in: + board: + elemType: char + value: + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - R + - . + - - . + - . + - . + - . + - . + - . + - . + - . + out: 0 + - name: case_9 + in: + board: + elemType: char + value: + - - . + - . + - . + - . + - . + - . + - . + - R + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - p + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + out: 0 + - name: case_10 + in: + board: + elemType: char + value: + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - B + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - p + - . + - . + - . + - . + - . + - - B + - . + - . + - . + - . + - . + - . + - . + - - . + - B + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - p + - . + - . + - - . + - . + - . + - . + - . + - R + - . + - . + out: 1 + - name: case_11 + in: + board: + elemType: char + value: + - - . + - . + - . + - . + - . + - . + - p + - . + - - B + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - B + - . + - . + - - . + - . + - . + - . + - . + - B + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - R + - - . + - B + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + out: 0 + - name: case_12 + in: + board: + elemType: char + value: + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - p + - . + - . + - . + - p + - . + - . + - . + - - . + - . + - . + - p + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - B + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - B + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - B + - B + - R + - . + - . + out: 0 + - name: case_13 + in: + board: + elemType: char + value: + - - . + - . + - . + - B + - . + - . + - . + - B + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - p + - B + - . + - . + - . + - . + - . + - . + - - R + - . + - . + - . + - . + - . + - B + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - B + - . + - p + - . + - . + - p + - . + - . + out: 1 + - name: case_14 + in: + board: + elemType: char + value: + - - R + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - p + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - p + - B + - . + - . + - - . + - . + - . + - . + - B + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - B + - . + - . + - B + - . + - . + - B + - . + - - B + - . + - p + - . + - . + - . + - . + - . + out: 0 + - name: case_15 + in: + board: + elemType: char + value: + - - . + - . + - . + - . + - . + - . + - . + - . + - - B + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - B + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - R + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + out: 0 + - name: case_16 + in: + board: + elemType: char + value: + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - B + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - B + - . + - . + - B + - - . + - . + - . + - . + - . + - . + - . + - . + - - R + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + out: 0 + - name: case_17 + in: + board: + elemType: char + value: + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - R + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - p + - . + - . + - . + - B + - . + - - . + - . + - . + - p + - . + - . + - . + - . + - - p + - . + - . + - . + - p + - . + - . + - . + - - . + - . + - B + - . + - . + - B + - . + - . + - - . + - . + - . + - . + - . + - p + - . + - . + out: 0 + - name: case_18 + in: + board: + elemType: char + value: + - - p + - . + - . + - . + - p + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - B + - . + - p + - . + - . + - - . + - . + - B + - . + - . + - . + - . + - . + - - . + - R + - . + - . + - B + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - p + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - p + - . + - . + - . + out: 0 + - name: case_19 + in: + board: + elemType: char + value: + - - . + - . + - . + - . + - . + - . + - . + - . + - - p + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - B + - . + - . + - . + - . + - . + - - . + - . + - . + - B + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - B + - - . + - . + - . + - . + - . + - . + - . + - R + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - B + - . + - . + - . + - . + out: 0 + - name: case_20 + in: + board: + elemType: char + value: + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - B + - . + - . + - B + - . + - . + - . + - - . + - . + - R + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - B + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - B + - . + - p + out: 0 + - name: case_21 + in: + board: + elemType: char + value: + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - B + - . + - . + - . + - - . + - . + - . + - . + - R + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - p + - . + - . + - . + - . + - - . + - . + - . + - B + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + out: 0 + - name: case_22 + in: + board: + elemType: char + value: + - - . + - . + - . + - . + - . + - . + - B + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - B + - . + - - . + - . + - . + - . + - . + - . + - p + - . + - - . + - . + - . + - . + - . + - . + - B + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - R + - - . + - . + - . + - . + - B + - p + - . + - . + out: 0 + - name: case_23 + in: + board: + elemType: char + value: + - - . + - . + - . + - . + - . + - . + - p + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - B + - . + - - p + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - B + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - R + - . + - p + out: 1 + - name: case_24 + in: + board: + elemType: char + value: + - - . + - . + - . + - . + - . + - p + - . + - . + - - . + - . + - R + - . + - . + - . + - . + - B + - - . + - . + - . + - . + - . + - . + - p + - p + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - B + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - B + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + out: 0 + - name: case_25 + in: + board: + elemType: char + value: + - - B + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - B + - . + - . + - . + - . + - p + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - B + - . + - . + - . + - . + - . + - . + - . + - - R + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + out: 0 + - name: case_26 + in: + board: + elemType: char + value: + - - . + - . + - . + - . + - B + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - p + - . + - . + - . + - R + - - . + - . + - . + - p + - . + - p + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - B + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - B + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - p + - . + out: 1 + - name: case_27 + in: + board: + elemType: char + value: + - - . + - . + - . + - . + - B + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - p + - . + - R + - B + - . + - . + - - . + - p + - . + - . + - . + - B + - . + - . + - - B + - . + - . + - . + - . + - B + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - B + - B + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + out: 1 + - name: case_28 + in: + board: + elemType: char + value: + - - . + - . + - . + - B + - B + - . + - . + - . + - - B + - p + - p + - . + - . + - . + - . + - B + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - p + - . + - . + - . + - . + - - . + - . + - . + - R + - . + - . + - . + - . + - - . + - . + - . + - B + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - B + - . + - . + - . + - . + - . + - . + - . + out: 1 + - name: case_29 + in: + board: + elemType: char + value: + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - R + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + out: 0 + - name: case_30 + in: + board: + elemType: char + value: + - - . + - . + - . + - . + - . + - B + - . + - . + - - . + - . + - . + - . + - . + - . + - R + - . + - - . + - . + - . + - p + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - p + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + out: 0 + - name: case_31 + in: + board: + elemType: char + value: + - - B + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - R + - . + - p + - . + - . + - . + - - . + - . + - . + - . + - . + - p + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - B + - . + - . + - p + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + out: 1 + - name: case_32 + in: + board: + elemType: char + value: + - - p + - . + - . + - . + - . + - . + - B + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - B + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - p + - . + - - . + - . + - . + - p + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - R + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + out: 1 + - name: case_33 + in: + board: + elemType: char + value: + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - R + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - B + - . + - . + - . + - . + - - . + - B + - B + - . + - . + - . + - . + - . + out: 0 + - name: case_34 + in: + board: + elemType: char + value: + - - . + - . + - . + - . + - B + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - B + - . + - B + - . + - . + - - . + - p + - . + - . + - . + - R + - . + - . + - - . + - . + - . + - . + - . + - B + - . + - . + - - p + - . + - p + - . + - . + - p + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + out: 1 + - name: case_35 + in: + board: + elemType: char + value: + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - p + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - B + - - . + - R + - B + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + - - . + - . + - . + - . + - . + - . + - . + - . + out: 0 diff --git a/tests/501-1000/999. available-captures-for-rook/sol.cpp b/tests/501-1000/999. available-captures-for-rook/sol.cpp new file mode 100644 index 00000000..0fcabf10 --- /dev/null +++ b/tests/501-1000/999. available-captures-for-rook/sol.cpp @@ -0,0 +1,45 @@ +class Solution { +public: + int numRookCaptures(vector>& board) { + int pwa = 0; + for (int i = 0; i < 8; i++) { + for (int j = 0; j < 8; j++) { + if (board[i][j] == 'R') { + for (int k = i - 1; k >= 0; k--) { + if (board[k][j] == 'B') { + break; + } else if (board[k][j] == 'p') { + pwa++; + break; + } + } + for (int k = i + 1; k < 8; k++) { + if (board[k][j] == 'B') { + break; + } else if (board[k][j] == 'p') { + pwa++; + break; + } + } + for (int k = j + 1; k < 8; k++) { + if (board[i][k] == 'B') { + break; + } else if (board[i][k] == 'p') { + pwa++; + break; + } + } + for (int k = j - 1; k >= 0; k--) { + if (board[i][k] == 'B') { + break; + } else if (board[i][k] == 'p') { + pwa++; + break; + } + } + } + } + } + return pwa; + } +}; diff --git a/tests/501-1000/999. available-captures-for-rook/sol.cs b/tests/501-1000/999. available-captures-for-rook/sol.cs new file mode 100644 index 00000000..815e0f2e --- /dev/null +++ b/tests/501-1000/999. available-captures-for-rook/sol.cs @@ -0,0 +1,44 @@ +public class Solution { + public int NumRookCaptures(char[][] board) { + int pwa = 0; + for (int i = 0; i < 8; i++) { + for (int j = 0; j < 8; j++) { + if (board[i][j] == 'R') { + for (int k = i - 1; k >= 0; k--) { + if (board[k][j] == 'B') { + break; + } else if (board[k][j] == 'p') { + pwa++; + break; + } + } + for (int k = i + 1; k < 8; k++) { + if (board[k][j] == 'B') { + break; + } else if (board[k][j] == 'p') { + pwa++; + break; + } + } + for (int k = j + 1; k < 8; k++) { + if (board[i][k] == 'B') { + break; + } else if (board[i][k] == 'p') { + pwa++; + break; + } + } + for (int k = j - 1; k >= 0; k--) { + if (board[i][k] == 'B') { + break; + } else if (board[i][k] == 'p') { + pwa++; + break; + } + } + } + } + } + return pwa; + } +} diff --git a/tests/501-1000/999. available-captures-for-rook/sol.dart b/tests/501-1000/999. available-captures-for-rook/sol.dart new file mode 100644 index 00000000..88f2360f --- /dev/null +++ b/tests/501-1000/999. available-captures-for-rook/sol.dart @@ -0,0 +1,44 @@ +class Solution { + int numRookCaptures(List> board) { + int pwa = 0; + for (int i = 0; i < 8; i++) { + for (int j = 0; j < 8; j++) { + if (board[i][j] == "R") { + for (int k = i - 1; k >= 0; k--) { + if (board[k][j] == "B") { + break; + } else if (board[k][j] == "p") { + pwa++; + break; + } + } + for (int k = i + 1; k < 8; k++) { + if (board[k][j] == "B") { + break; + } else if (board[k][j] == "p") { + pwa++; + break; + } + } + for (int k = j + 1; k < 8; k++) { + if (board[i][k] == "B") { + break; + } else if (board[i][k] == "p") { + pwa++; + break; + } + } + for (int k = j - 1; k >= 0; k--) { + if (board[i][k] == "B") { + break; + } else if (board[i][k] == "p") { + pwa++; + break; + } + } + } + } + } + return pwa; + } +} diff --git a/tests/501-1000/999. available-captures-for-rook/sol.go b/tests/501-1000/999. available-captures-for-rook/sol.go new file mode 100644 index 00000000..be0ee386 --- /dev/null +++ b/tests/501-1000/999. available-captures-for-rook/sol.go @@ -0,0 +1,42 @@ +func numRookCaptures(board [][]byte) int { + pwa := 0 + for i := 0; i < 8; i++ { + for j := 0; j < 8; j++ { + if board[i][j] == 'R' { + for k := i - 1; k >= 0; k-- { + if board[k][j] == 'B' { + break + } else if board[k][j] == 'p' { + pwa++ + break + } + } + for k := i + 1; k < 8; k++ { + if board[k][j] == 'B' { + break + } else if board[k][j] == 'p' { + pwa++ + break + } + } + for k := j + 1; k < 8; k++ { + if board[i][k] == 'B' { + break + } else if board[i][k] == 'p' { + pwa++ + break + } + } + for k := j - 1; k >= 0; k-- { + if board[i][k] == 'B' { + break + } else if board[i][k] == 'p' { + pwa++ + break + } + } + } + } + } + return pwa +} diff --git a/tests/501-1000/999. available-captures-for-rook/sol.java b/tests/501-1000/999. available-captures-for-rook/sol.java new file mode 100644 index 00000000..ec5ae8e0 --- /dev/null +++ b/tests/501-1000/999. available-captures-for-rook/sol.java @@ -0,0 +1,44 @@ +class Solution { + public int numRookCaptures(char[][] board) { + int pwa = 0; + for (int i = 0; i < 8; i++) { + for (int j = 0; j < 8; j++) { + if (board[i][j] == 'R') { + for (int k = i - 1; k >= 0; k--) { + if (board[k][j] == 'B') { + break; + } else if (board[k][j] == 'p') { + pwa++; + break; + } + } + for (int k = i + 1; k < 8; k++) { + if (board[k][j] == 'B') { + break; + } else if (board[k][j] == 'p') { + pwa++; + break; + } + } + for (int k = j + 1; k < 8; k++) { + if (board[i][k] == 'B') { + break; + } else if (board[i][k] == 'p') { + pwa++; + break; + } + } + for (int k = j - 1; k >= 0; k--) { + if (board[i][k] == 'B') { + break; + } else if (board[i][k] == 'p') { + pwa++; + break; + } + } + } + } + } + return pwa; + } +} diff --git a/tests/501-1000/999. available-captures-for-rook/sol.kt b/tests/501-1000/999. available-captures-for-rook/sol.kt new file mode 100644 index 00000000..1970e82d --- /dev/null +++ b/tests/501-1000/999. available-captures-for-rook/sol.kt @@ -0,0 +1,44 @@ +class Solution { + fun numRookCaptures(board: Array): Int { + var pwa = 0 + for (i in 0 until 8) { + for (j in 0 until 8) { + if (board[i][j] == 'R') { + for (k in i - 1 downTo 0) { + if (board[k][j] == 'B') { + break + } else if (board[k][j] == 'p') { + pwa++ + break + } + } + for (k in i + 1 until 8) { + if (board[k][j] == 'B') { + break + } else if (board[k][j] == 'p') { + pwa++ + break + } + } + for (k in j + 1 until 8) { + if (board[i][k] == 'B') { + break + } else if (board[i][k] == 'p') { + pwa++ + break + } + } + for (k in j - 1 downTo 0) { + if (board[i][k] == 'B') { + break + } else if (board[i][k] == 'p') { + pwa++ + break + } + } + } + } + } + return pwa + } +} diff --git a/tests/501-1000/999. available-captures-for-rook/sol.py b/tests/501-1000/999. available-captures-for-rook/sol.py new file mode 100644 index 00000000..dd5fd4aa --- /dev/null +++ b/tests/501-1000/999. available-captures-for-rook/sol.py @@ -0,0 +1,34 @@ +from typing import List + + +class Solution: + def numRookCaptures(self, board: List[List[str]]) -> int: + pwa = 0 + for i in range(8): + for j in range(8): + if board[i][j] == "R": + for k in range(i - 1, -1, -1): + if board[k][j] == "B": + break + elif board[k][j] == "p": + pwa += 1 + break + for k in range(i + 1, 8): + if board[k][j] == "B": + break + elif board[k][j] == "p": + pwa += 1 + break + for k in range(j + 1, 8): + if board[i][k] == "B": + break + elif board[i][k] == "p": + pwa += 1 + break + for k in range(j - 1, -1, -1): + if board[i][k] == "B": + break + elif board[i][k] == "p": + pwa += 1 + break + return pwa diff --git a/tests/501-1000/999. available-captures-for-rook/sol.py2 b/tests/501-1000/999. available-captures-for-rook/sol.py2 new file mode 100644 index 00000000..8a1a2168 --- /dev/null +++ b/tests/501-1000/999. available-captures-for-rook/sol.py2 @@ -0,0 +1,35 @@ +class Solution(object): + def numRookCaptures(self, board): + """ + :type board: List[List[str]] + :rtype: int + """ + pwa = 0 + for i in range(8): + for j in range(8): + if board[i][j] == "R": + for k in range(i-1, -1, -1): + if board[k][j] == "B": + break + elif board[k][j] == "p": + pwa += 1 + break + for k in range(i+1, 8): + if board[k][j] == "B": + break + elif board[k][j] == "p": + pwa += 1 + break + for k in range(j+1, 8): + if board[i][k] == "B": + break + elif board[i][k] == "p": + pwa += 1 + break + for k in range(j-1, -1, -1): + if board[i][k] == "B": + break + elif board[i][k] == "p": + pwa += 1 + break + return pwa diff --git a/tests/501-1000/999. available-captures-for-rook/sol.rb b/tests/501-1000/999. available-captures-for-rook/sol.rb new file mode 100644 index 00000000..4b2cc550 --- /dev/null +++ b/tests/501-1000/999. available-captures-for-rook/sol.rb @@ -0,0 +1,44 @@ +# @param {Character[][]} board +# @return {Integer} +def num_rook_captures(board) + pwa = 0 + (0...8).each do |i| + (0...8).each do |j| + if board[i][j] == "R" + (i-1).downto(0) do |k| + if board[k][j] == "B" + break + elsif board[k][j] == "p" + pwa += 1 + break + end + end + (i+1...8).each do |k| + if board[k][j] == "B" + break + elsif board[k][j] == "p" + pwa += 1 + break + end + end + (j+1...8).each do |k| + if board[i][k] == "B" + break + elsif board[i][k] == "p" + pwa += 1 + break + end + end + (j-1).downto(0) do |k| + if board[i][k] == "B" + break + elsif board[i][k] == "p" + pwa += 1 + break + end + end + end + end + end + pwa +end diff --git a/tests/501-1000/999. available-captures-for-rook/sol.rs b/tests/501-1000/999. available-captures-for-rook/sol.rs new file mode 100644 index 00000000..415aa239 --- /dev/null +++ b/tests/501-1000/999. available-captures-for-rook/sol.rs @@ -0,0 +1,44 @@ +impl Solution { + pub fn num_rook_captures(board: Vec>) -> i32 { + let mut pwa = 0; + for i in 0..8 { + for j in 0..8 { + if board[i][j] == 'R' { + for k in (0..i).rev() { + if board[k][j] == 'B' { + break; + } else if board[k][j] == 'p' { + pwa += 1; + break; + } + } + for k in i+1..8 { + if board[k][j] == 'B' { + break; + } else if board[k][j] == 'p' { + pwa += 1; + break; + } + } + for k in j+1..8 { + if board[i][k] == 'B' { + break; + } else if board[i][k] == 'p' { + pwa += 1; + break; + } + } + for k in (0..j).rev() { + if board[i][k] == 'B' { + break; + } else if board[i][k] == 'p' { + pwa += 1; + break; + } + } + } + } + } + pwa + } +} diff --git a/tests/501-1000/999. available-captures-for-rook/sol.swift b/tests/501-1000/999. available-captures-for-rook/sol.swift new file mode 100644 index 00000000..c2f30132 --- /dev/null +++ b/tests/501-1000/999. available-captures-for-rook/sol.swift @@ -0,0 +1,44 @@ +class Solution { + func numRookCaptures(_ board: [[Character]]) -> Int { + var pwa = 0 + for i in 0..<8 { + for j in 0..<8 { + if board[i][j] == "R" { + for k in stride(from: i - 1, through: 0, by: -1) { + if board[k][j] == "B" { + break + } else if board[k][j] == "p" { + pwa += 1 + break + } + } + for k in i + 1..<8 { + if board[k][j] == "B" { + break + } else if board[k][j] == "p" { + pwa += 1 + break + } + } + for k in j + 1..<8 { + if board[i][k] == "B" { + break + } else if board[i][k] == "p" { + pwa += 1 + break + } + } + for k in stride(from: j - 1, through: 0, by: -1) { + if board[i][k] == "B" { + break + } else if board[i][k] == "p" { + pwa += 1 + break + } + } + } + } + } + return pwa + } +} diff --git a/tests/501-1000/999. available-captures-for-rook/sol.ts b/tests/501-1000/999. available-captures-for-rook/sol.ts new file mode 100644 index 00000000..f590be08 --- /dev/null +++ b/tests/501-1000/999. available-captures-for-rook/sol.ts @@ -0,0 +1,42 @@ +function numRookCaptures(board: string[][]): number { + let pwa = 0; + for (let i = 0; i < 8; i++) { + for (let j = 0; j < 8; j++) { + if (board[i][j] === "R") { + for (let k = i - 1; k >= 0; k--) { + if (board[k][j] === "B") { + break; + } else if (board[k][j] === "p") { + pwa++; + break; + } + } + for (let k = i + 1; k < 8; k++) { + if (board[k][j] === "B") { + break; + } else if (board[k][j] === "p") { + pwa++; + break; + } + } + for (let k = j + 1; k < 8; k++) { + if (board[i][k] === "B") { + break; + } else if (board[i][k] === "p") { + pwa++; + break; + } + } + for (let k = j - 1; k >= 0; k--) { + if (board[i][k] === "B") { + break; + } else if (board[i][k] === "p") { + pwa++; + break; + } + } + } + } + } + return pwa; +}